Subversion Repositories personal-webbase

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. if (!defined('WBLEGAL')) die('Kann nicht ohne Personal WebBase ausgef&uuml;hrt werden.');
  4.  
  5. if (($aktion == 'new') || ($aktion == 'edit'))
  6. {
  7.         echo str_replace('<body', '<body onload="self.focus();document.getElementById(\'name\').focus();"', $header);
  8.  
  9.         if ($aktion == 'new') echo '<h1>Neue HTML-Seite</h1>';
  10.         if ($aktion == 'edit') echo '<h1>HTML-Seite bearbeiten</h1>';
  11.  
  12.         if ($aktion == 'edit')
  13.         {
  14.                 $res = db_query("SELECT * FROM `".$WBConfig->getMySQLPrefix()."html` WHERE `id` = '".db_escape($id)."' AND `user_cnid` = '".$benutzer['id']."'");
  15.                 if (db_num($res) == 0)
  16.                         die($header.'Auf diesen Datensatz kann nicht zugegriffen werden. Entweder ist er nicht mehr verf&uuml;gbar, oder die Zugriffsberechtigungen sind falsch.'.$footer);
  17.                 $row = db_fetch($res);
  18.  
  19.                 $auszuwaehlen = (isset($row['folder_cnid'])) ? $row['folder_cnid'] : '';
  20.                 $name = (isset($row['name'])) ? $row['name'] : '';
  21.                 $html_code = (isset($row['html_code'])) ? $row['html_code'] : '';
  22.         }
  23.         else
  24.         {
  25.                 $auszuwaehlen = (isset($folder)) ? $folder : 0;
  26.                 $name = '';
  27.                 $html_code = '';
  28.         }
  29.  
  30.         if (isset($vorlage) && ($vorlage != ''))
  31.         {
  32.                 // Achtung! Ein Hacker könnte durch ../ die MySQL-Zugangsdaten statt einer Vorlage auslesen!
  33.                 if (strpos($vorlage, '..'))
  34.                         die($header.'<b>Fehler</b><br><br>Es ist eine Schutzverletzung aufgetreten!'.$footer);
  35.  
  36.                 $html_code = '';
  37.  
  38.                 $handle = @fopen('modules/'.$modul.'/templates/'.$vorlage, 'r');
  39.                 if ($handle)
  40.                 {
  41.                         while (!@feof($handle))
  42.                         {
  43.                                 $html_code .= @fgets($handle, 4096);
  44.                         }
  45.                 }
  46.                 @fclose($handle);
  47.         }
  48.  
  49. echo '<script language="JavaScript" type="text/javascript">
  50. <!--
  51.  
  52. function subm_form(act)
  53. {
  54.         if (act == 0)
  55.         {
  56.                 document.forms["mainform"].target = \'\';
  57.                 document.forms["mainform"].elements["seite"].value = \'operate\';
  58.         }
  59.         if (act == 1)
  60.         {
  61.                 document.forms["mainform"].target = \'_blank\';
  62.                 document.forms["mainform"].elements["seite"].value = \'checksite\';
  63.         }
  64.         document.forms.mainform.submit();
  65. }
  66.  
  67. // -->
  68. </script>
  69.  
  70. <form method="POST" name="mainform" action="'.$_SERVER['PHP_SELF'].'">
  71. <input type="hidden" name="seite" value="operate">
  72. <input type="hidden" name="aktion" value="'.$aktion.'">
  73. <input type="hidden" name="modul" value="'.$modul.'">';
  74.  
  75. if ($aktion == 'edit')
  76.         echo '<input type="hidden" name="id" value="'.$id.'">';
  77.  
  78. echo '<table cellspacing="0" cellpadding="0" border="0">
  79. <tr>
  80.         <td colspan="2"><b>Allgemeine Informationen</b><br><br></td>
  81. </tr>
  82. <tr>
  83.         <td valign="top">Name:<img src="designs/spacer.gif" height="1" width="35" alt=""></td>
  84.         <td valign="top"><input type="text" class="normal" onmouseover="this.className=\'highlight\';" onmouseout="this.className=\'normal\';" name="name" id="name" value="'.$name.'" size="50"></td>
  85. </tr>
  86. <tr>
  87.         <td valign="top">In Ordner:<img src="designs/spacer.gif" height="1" width="35" alt=""></td>
  88.         <td valign="top">';
  89.  
  90.         gfx_zeichneordnerbox($modul, 0, 0, $auszuwaehlen);
  91.  
  92.         echo '</td>
  93. </tr>
  94. <tr>
  95.         <td colspan="2"><br><b>HTML-Daten</b><br><br></td>
  96. </tr>
  97. <tr>
  98.         <td valign="top">HTML-Code:<img src="designs/spacer.gif" height="1" width="35" alt=""></td>
  99.         <td valign="top" width="100%">
  100.         <table width="100%"><tr><td rowspan="8" style="vertical-align:top;width:100%">Verwenden Sie eine vordefinierte HTML-Seite wenn Sie z.B. ein automatisches Login-Formular erstellen, jedoch kein Personal WebBase-Modul schreiben m&ouml;chten.<br><br>
  101.         <textarea style="width:100%; overflow:auto;" wrap="virtual" name="html_code" rows="15" cols="50">'.$html_code.'</textarea><br><br>
  102.         Eine Vorlage kann Ihnen die Arbeit erleichtern. W&auml;hlen Sie eine Vorlage, wenn Sie dies w&uuml;nschen.
  103.         <ul>';
  104.  
  105. function liste_vorlagen()
  106. {
  107.         global $modul;
  108.         $ary = array();
  109.         $i = 0;
  110.         $v = 'modules/'.$modul.'/templates/';
  111.         $verz=opendir($v);
  112.  
  113.         while ($file = readdir($verz))
  114.         {
  115.                 if (($file != '.') && ($file != '..')   && ($file != 'index.html') && ($file != '.htaccess') && (is_file($v.$file)))
  116.                 {
  117.                         $i++;
  118.                         $ary[$i] = $file;
  119.                 }
  120.         }
  121.  
  122.         closedir($verz);
  123.         sort($ary);
  124.  
  125.         return $ary;
  126. }
  127.  
  128. $vorlagen = liste_vorlagen();
  129.  
  130. foreach ($vorlagen AS $m1 => $m2)
  131. {
  132.         if (!isset($id)) $id = 0;
  133.         echo '<li><a href="'.$_SERVER['PHP_SELF'].'?seite='.$seite.'&amp;modul='.$modul.'&amp;aktion='.$aktion.'&amp;id='.$id.'&amp;vorlage='.$m2.'">'.$m2.'</a></li>';
  134. }
  135.  
  136. unset($m1);
  137. unset($m2);
  138.  
  139. if (!isset($danach)) $danach = 'A';
  140.  
  141.         echo '</ul>Bitte beachten Sie, dass beim &Ouml;ffnen einer Vorlage die aktuellen &Auml;nderungen &uuml;berschrieben werden.<br><br>
  142.         <a href="javascript:subm_form(1);">Seite testen</a></td></tr></table>
  143.         </td>
  144. </tr>
  145.  
  146. <tr>
  147.         <td colspan="2"><br><b>Nach Speicherung</b><br><br></td>
  148. </tr>
  149. <tr>
  150.         <td valign="top">Aktion: </td>
  151.         <td><select name="danach">
  152.                 <option value="A"'; if ($danach == 'A') echo ' selected'; echo '>Zur&uuml;ck zum Hauptmen&uuml;</option>
  153.                 <option value="B"'; if ($danach == 'B') echo ' selected'; echo '>Neuer Eintrag in Kategorie</option>
  154.                 <option value="C"'; if ($danach == 'C') echo ' selected'; echo '>Neuer Eintrag im Ordner</option>
  155.         </select></td>
  156. </tr>
  157. </table><br>
  158. <a href="javascript:subm_form(0);">';
  159.  
  160. if ($aktion == 'new') echo 'Eintragung hinzuf&uuml;gen';
  161. if ($aktion == 'edit') echo 'Eintragung aktualisieren';
  162.  
  163. echo '</a>&nbsp;|&nbsp;<a href="'.$_SERVER['PHP_SELF'].'?seite=main&amp;modul='.$modul.'">Zur&uuml;ck</a>
  164.  
  165. </form>';
  166.  
  167.         echo $footer;
  168.  
  169. }
  170.  
  171. ?>