Location: PHPKode > projects > WebETB > doku/manage.php4
<?php
/******************************************************************************/
/*	MODUL:	doku/manage.php4           													*/
/*																										*/
/* DATUM:	27.03.2006, Version 0.1															*/
/* BESCHR.:	Hinzufuegen oder entfernen von Dokumenten sowie Erstellung        */
/*          einer virtuellen Ordnerstruktur                                   */
/*																										*/
/*	AUTOR:   Marcus Groh																			*/
/*	LIZENZ:  GPL v2 vom Juni 1991 															*/
/*																										*/
/*	AENDERUNGEN:	01.07.2005        -initiale Version								   */
/*                27.03.2006 v 0.1, -Versionskennzeichnung eingefuehrt        */
/*                                  -Code unter GPL v2 gestellt               */
/*                                  -Tabellenname dynamisiert                 */
/*																										*/
/******************************************************************************/
$allowed_groups=array("elw");
include ('../_include/header_1.php4');
// Initial Values
$disabled="";
$error_msg1="&nbsp;";
$submit_text="Eintragen";
$max_file_size=7000000;
$db_action=1;


if (isset($add_docu))
{
   
   // check file size MAX / MIN
   if ( ($frm_typ == "2" ) && ( $frm_fname_size >= $max_file_size ) ) 
   {
      $error_msg1="Datei ist gr&ouml;sser als $max_file_size kB.";
      $db_action=0;
   }
   elseif ( ($frm_typ == "2" ) && ( $frm_fname_size <= 0 ) )
   {
      $error_msg1="Datei hat 0 Byte L&auml;nge.";
      $db_action=0;   
   }
   
   // check if title is empty
   if ( strlen($frm_titel) == 0)
   {
      $error_msg1="Geben Sie einen Titel an.";
      $db_action=0;   
   }
         
   // prepare new filename
   if ($frm_typ == "2" )
   {
      $tran_file_name=str_replace(" ", "_", $frm_fname_name);
      $tran_file_name=str_replace("ö", "oe", $tran_file_name);
      $tran_file_name=str_replace("ä", "ae", $tran_file_name);
      $tran_file_name=str_replace("ü", "ue", $tran_file_name);
      $tran_file_name=str_replace("ß", "ss", $tran_file_name);
   }

   // Make entry in db
   if ($db_action)
   {
      switch ($frm_typ)
      {
         case 0:  // New Main-Folder
            $insert_new_mfold="insert into $T_dokumnt values ('%','0','$frm_titel','$frm_descr','$frm_keywrds','','0')";
            mysql_db_query($database["database"],$insert_new_mfold,$db);
            break;
         
         case 1:  // New Sub-Folder
            $insert_new_sfold="insert into $T_dokumnt values ('%','1','$frm_titel','$frm_descr','$frm_keywrds','','$frm_fpid')";
            mysql_db_query($database["database"],$insert_new_sfold,$db);
            break;      
      
          case 2:  // New File
            $insert_new_file="insert into $T_dokumnt values ('%','2','$frm_titel','$frm_descr','$frm_keywrds','$frm_fname','$frm_fpid')";
            mysql_db_query($database["database"],$insert_new_file,$db);
            
            // Get actual file id and finish new filename and target folder
            $new_file_id=mysql_insert_id();
            $new_filename=$new_file_id . "_" . $tran_file_name;            
            $file_url=$file_path . "/" . $new_filename;
            
            // Copy File and update db-entry
            copy ($frm_fname, $file_url);
            $update_new_file="Update $T_dokumnt set f_name='$new_filename' where file_id=$new_file_id";
            mysql_db_query($database["database"],$update_new_file,$db);
            break;                
      }
   
   
   }
      
   $add_docu="";
}

function list_subfolder ($db_fid,$pos)
{
      include "../config/conf_glbl.php4";
      
      // Look for subfolders
      $select_file_pid="select file_id, titel from $T_dokumnt where file_pid=$db_fid and typ like '1'";
      $result_file_pid=@mysql_db_query($database["database"],$select_file_pid,$db);
      
      // if none exists return, otherwise print out
      if ( mysql_num_rows($result_file_pid) != 0 )
      {
         $pos=$pos + 3;
         while ($row=mysql_fetch_array($result_file_pid))
         {
            $db_sub_fid=$row['file_id'];
            $db_sub_titel=$row['titel'];
            echo "      <option value=\"$db_sub_fid\" style=\"font-style:italic;\">";            
            for ($i=1; $i<=$pos; $i++)
                  { echo "&nbsp;"; }
            echo "+-> $db_sub_titel\n";
            list_subfolder ($db_sub_fid,$pos);            
         }
      }
      else
      {
         return ;         
      }
      
      return $pos;
}
   ?>
   <script language="JavaScript">
   <!--
       function update_form()
        {
         if (document.forms['manage_docs'].elements['frm_typ'].value != '2' )
         {
            document.forms['manage_docs'].elements['frm_fname'].disabled='TRUE';
            document.forms['manage_docs'].elements['frm_keywrds'].disabled='TRUE';
            if (document.forms['manage_docs'].elements['frm_typ'].value == '0' )
            {
               document.forms['manage_docs'].elements['frm_fpid'].disabled='TRUE';
               }
                           else
            {
               document.forms['manage_docs'].elements['frm_fpid'].disabled='';
               }            
            }
         else
         {
            document.forms['manage_docs'].elements['frm_fname'].disabled='';
            document.forms['manage_docs'].elements['frm_keywrds'].disabled='';
            document.forms['manage_docs'].elements['frm_fpid'].disabled='';
            }
         }       
   //-->
   </script>   
   <center>
   <p id="ERR"><? echo $error_msg1; ?></p>
   <form action="" name="manage_docs" method=POST enctype="multipart/form-data">
   <table border="0" cellpadding="0" cellspacing="0" width="720">
   <tr>
      <th colspan="6">Ordner und Dokumente anlegen</th>
   </tr>
   <tr>
      <td colspan="6" height="3"></td>
   </tr>
   <tr>
      <td width="100">&nbsp;Typ: </td>
      <td width="5">&nbsp;</td>
      <td width="200"><select name="frm_typ" onChange="update_form();" style="border: 1px solid silver; width: 190px">
          <option value="0">Hauptkategorie
          <option value="1">Unterkategorie
          <option selected value="2">Datei
      </td>
      <td width="150">Datei: </td>
      <td width="5">&nbsp;</td>
      <td width="260"><input type=file <? echo $disabled; ?> name="frm_fname" maxlength=<? echo $max_file_size; ?> size=23 style="border: 1px solid silver"></td>
   </tr>
   <tr>
      <td colspan="6" height="3"></td>
   </tr>   
   <tr>
      <td width="100">&nbsp;Titel: </td>
      <td width="5">&nbsp;</td>
      <td width="200"><input type=text name="frm_titel" style="border: 1px solid silver; width: 190px"></td>
      <td width="150">Kurze Beschreibung: </td>
      <td width="5">&nbsp;</td>
      <td width="260"><input type=text name="frm_descr" style="border: 1px solid silver; width: 257px"></td>
   </tr>
   <tr>
      <td colspan="6" height="3"></td>
   </tr> 
   <tr>
      <td width="100" valign="top">&nbsp;Ablage: </td>
      <td width="5">&nbsp;</td>
      <td width="200" valign="top"><select name="frm_fpid" style="border: 1px solid silver; width: 190px">
          <?
          // Get Main Folders
          $select_file_id="select file_id, titel from $T_dokumnt where typ like '0' order by titel";
          $result_file_id=@mysql_db_query($database["database"],$select_file_id,$db);
          if ( mysql_num_rows($result_file_id) == 0)
          {
            // We have no folders.
            echo "<option value=\"0\">&nbsp;\n";
          }
          else
          {
            // List folders and subfolders
               while ( $row=mysql_fetch_array($result_file_id))
               {
                  $db_fid=$row['file_id'];
                  $db_titel=$row['titel'];
                  $pos=0;
                  echo "   <option value=\"$db_fid\">$db_titel\n";
                  list_subfolder($db_fid,$pos);
               }          
          }
          ?>
      </td>      
      <td valign="top">Suchbegriffe: </td>
      <td width="5">&nbsp;</td>
      <td width="260" ><textarea NAME="frm_keywrds" <? echo $disabled; ?> style="width: 257; height: 50px; border: 1px solid silver;"></textarea>
   <tr>
      <td colspan="6" height="5" style="background-color: #E0E0E0;"></td>
   </tr> 
   </tr>
   </table>
   <input type="submit" Value="<? echo $submit_text; ?>" style="border: 1px solid silver;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   <input type="reset" Value="R&uuml;cksetzen"  style="border: 1px solid silver;">
   <input type="hidden" name="add_docu" value="true">
   </form>
   <br>  
   <table border="0" cellpadding="0" cellspacing="0" width="720">
   <tr>
      <th>Ordner und Dokumente l&ouml;schen</th>
      <th width="16" style="background-color: #E0E0E0;" ><img src="../_img/spacer.gif" width="16" border="0"></th>
   </tr>
   <tr>
      <td height="2"></td>
      <td width="16" style="background-color: #E0E0E0;" ><img src="../_img/spacer.gif" height="1" width="16" border="0"></td>
   </tr>
   <tr>
      <td colspan="2">
         <iframe src="list_doc.php4" HEIGHT="250" WIDTH="720" name="_DOKU" FRAMEBORDER="0" FRAMESPACING="0" BORDER="0" MARGINWIDTH="0" MARGINHEIGHT="0" TOPMARGIN="0" NORESIZE SCROLLING="yes"></iframe>      
      </td>      
   </tr>
   </table>
   </center>
   <?

include ('../_include/footer_1.php4');
?>
Return current item: WebETB