[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/ -> filebrowser.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2012 Oliver Georgi <oliver@phpwcms.de> // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  /**
  24   * Sept. 2009
  25   * enhancement to enable phpwcms filebrowser support in FCK Editor
  26   * based on concept and work of Markus Köhl <www.pagewerkstatt.ch>
  27   *
  28   * April 2011
  29   * - enhancement to enable phpwcms filebrowser support in CKEditor
  30   *   based on concept and work of Markus Köhl <www.leanux.ch>
  31   * - Issue 265 based on TB's post
  32   */
  33  
  34  session_start();
  35  
  36  $phpwcms            = array();
  37  $phpwcms_root        = dirname(__FILE__);
  38  $js_files_all        = array();
  39  $js_files_select    = array();
  40  
  41  require($phpwcms_root.'/config/phpwcms/conf.inc.php');
  42  require ($phpwcms_root.'/include/inc_lib/default.inc.php');
  43  
  44  if( empty($_SESSION["wcs_user_lang"]) ) {
  45  
  46      session_destroy();
  47      headerRedirect( PHPWCMS_URL );
  48  
  49  } else {
  50  
  51      require (PHPWCMS_ROOT.'/include/inc_lang/backend/en/lang.ext.inc.php');
  52      $cust_lang = PHPWCMS_ROOT.'/include/inc_lang/backend/' . strtolower(substr($_SESSION["wcs_user_lang"], 0, 2)) . '/lang.ext.inc.php';
  53      if(is_file($cust_lang)) {
  54          include($cust_lang);
  55      }
  56  
  57  }
  58  
  59  // set target for article summary/list image
  60  if(isset($_GET['target'])) {
  61  
  62      switch($_GET['target']) {
  63          
  64          case 'list':    $_SESSION['filebrowser_image_target'] = '_list_';
  65                          break;    
  66      
  67          default:         $_SESSION['filebrowser_image_target'] = '_';
  68      }
  69  
  70  } elseif(empty($_SESSION['filebrowser_image_target'])) {
  71  
  72      $_SESSION['filebrowser_image_target'] = '_';
  73  
  74  }
  75  
  76  if(isset($_GET['entry_id'])) {
  77      $_SESSION['filebrowser_image_entry_id'] = preg_replace('/[^a-z0-9_]/', '', $_GET['entry_id']);
  78  }
  79  
  80  require_once  (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php');
  81  require_once  (PHPWCMS_ROOT.'/include/inc_lib/general.inc.php');
  82  
  83  checkLogin();
  84  
  85  require_once  (PHPWCMS_ROOT.'/include/inc_lib/backend.functions.inc.php');
  86  require_once  (PHPWCMS_ROOT.'/include/inc_lib/imagick.convert.inc.php');
  87  
  88  $phpwcms_filestorage = PHPWCMS_FILES;
  89  
  90  $js_aktion = (isset($_GET["opt"])) ? intval($_GET["opt"]) : 0;
  91  
  92  switch($js_aktion) {
  93  
  94      case 0:     
  95      case 1:     
  96      case 3: 
  97      case 7:
  98      case 8:
  99      case 5:
 100      case 11:
 101      case 17:    $titel        = $BL['IMAGE_TITLE'];    
 102                  $filetype    = $BL['IMAGE_FILES'];
 103                  break;
 104  
 105      case 4:
 106      case 9:
 107      case 10:
 108      case 16:
 109      case 15:
 110      case 18:    $titel        = $BL['FILE_TITLE'];
 111                  $filetype    = $BL['FILES'];
 112                  break;
 113      
 114      case 2:
 115      case 6:
 116      case 12:
 117      case 13:
 118      case 14:    $titel        = $BL['MEDIA_TITLE'];    
 119                  $filetype    = $BL['MEDIA_FILES'];
 120                  break;
 121      
 122  }
 123  
 124  if(isset($folder)) unset($folder);
 125  if(isset($_SESSION["folder"])) $folder = $_SESSION["folder"];
 126  if(isset($_GET["folder"])) {
 127      list($folder_id, $folder_value) = explode('|', $_GET["folder"]);
 128      $folder[$folder_id] = intval($folder_value);
 129      $_SESSION["folder"] = $folder; //Rückgabe des Aktuellen Array mit Aufolderwerten in die Session
 130  }
 131  $_SESSION["list_zaehler"] = 0; //Zähler für die Public-Listenfunktion setzen
 132  
 133  //Checken, welcher Ordner aktiv
 134  if(isset($_GET["files"])) {
 135  
 136      $_SESSION["imgdir"] = intval($_GET["files"]);
 137  
 138  } elseif(!isset($_SESSION["imgdir"])) {
 139  
 140      $_SESSION["imgdir"] = 0;
 141  
 142  } else {
 143  
 144      $_SESSION["imgdir"] = intval($_SESSION["imgdir"]);
 145  
 146  }
 147  
 148  //Does user have files and folders that can be used
 149  $sql = "SELECT COUNT(f_id) FROM ".DB_PREPEND."phpwcms_file WHERE f_aktiv=1 AND (f_public=1 OR f_uid=".$_SESSION["wcs_user_id"].") AND f_trash=0 LIMIT 1";
 150  if($result = mysql_query($sql, $db) or die ("error while counting private files")) {
 151      if($row = mysql_fetch_row($result)) $count_user_files = $row[0];
 152      mysql_free_result($result);
 153  }
 154  
 155  ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 156  <html xmlns="http://www.w3.org/1999/xhtml">
 157  <head>
 158  
 159      <title><?php echo $titel ?></title>
 160  
 161      <meta http-equiv="Content-Type" content="text/html; charset=<?php echo PHPWCMS_CHARSET ?>" />
 162      <meta http-equiv="Expires" content="0" />
 163      <meta http-equiv="Pragma" content="no-cache" />
 164      <meta http-equiv="cache-control" content="no-cache" />
 165      <script src="include/inc_js/phpwcms.js" type="text/javascript"></script>
 166      <script src="include/inc_js/filebrowser.js" type="text/javascript"></script>
 167      <link href="include/inc_css/phpwcms.css" rel="stylesheet" type="text/css" />
 168      <style type="text/css">body{margin:5px;}</style>
 169  
 170  </head>
 171  
 172  <body>
 173  <table summary="" border="0" cellspacing="0" cellpadding="0">
 174    <tr>
 175          <td bgcolor="#7C98A2"><img src="img/leer.gif" alt="" width="1" height="1" border="0" /></td>
 176          <td rowspan="4"><img src="img/leer.gif" alt="" width="5" height="1" border="0" /></td>
 177          <td bgcolor="#7C98A2"><img src="img/leer.gif" alt="" width="1" height="1" border="0" /></td>
 178    </tr>
 179    <tr>
 180      <td bgcolor="#7C98A2" class="msgreiter">&nbsp;<?php echo $BL['FOLDER_LIST'] ?>&nbsp;</td>
 181      <td bgcolor="#7C98A2" class="msgreiter">&nbsp;<?php echo $filetype ?>&nbsp;</td>
 182    </tr>
 183    <tr>
 184      <td bgcolor="#7C98A2"><img src="img/leer.gif" alt="" width="1" height="1" border="0" /></td>
 185      <td bgcolor="#7C98A2"><img src="img/leer.gif" alt="" width="1" height="1" border="0" /></td>
 186    </tr>
 187    <tr>
 188      <td valign="top"><?php
 189      
 190  if(!empty($count_user_files)) { //Listing in case of user files/folders
 191  
 192      echo '<table summary="" bgColor="#FCFDFD" border="0" cellspacing="0" cellpadding="0">'.LF;
 193      
 194      //Anzeige des Festplattensymbols
 195      $dirname = $BL['ROOT_DIR'];
 196      if(!isset($folder[0])) {
 197          $folder[0] = 0;
 198      }
 199      $folder_status = true_false($folder[0]);
 200      // Change based on Issue 265 by TB to allow file's uploader to select own items
 201      $count_sql = "SELECT COUNT(f_id) FROM ".DB_PREPEND."phpwcms_file WHERE f_pid=0 AND f_aktiv=1 AND f_trash=0 AND (f_public=1 OR f_uid=".$_SESSION["wcs_user_id"].") LIMIT 1";
 202  
 203      if($count_result = mysql_query($count_sql, $db)) {
 204          if($count_row = mysql_fetch_row($count_result)) {
 205              $count = '<img src="img/leer.gif" height="1" width="2" alt="" border="0" /><a href="filebrowser.php?opt='.$js_aktion.'&amp;folder=0'.
 206                       '%7C'.$folder_status.'">'.on_off($folder_status, $dirname, 0).'</a>';
 207              $count_wert = $count_row[0];
 208          }
 209          mysql_free_result($count_result);
 210      }
 211      
 212      // define current directory name
 213      $current_dirname = $dirname;
 214      
 215      $dirname    =  "<a href=\"filebrowser.php?opt=".$js_aktion."&amp;files=0\" title=\"".$BL['SHOW_FILES']."\">".$dirname."</a>";
 216      $bgcol        = (isset($row["f_id"]) && $row["f_id"] == $_SESSION["imgdir"]) ? ' bgcolor="#FED83F"' : '';
 217      
 218      echo '<tr'.$bgcol.'><td colspan="2"><img src="img/leer.gif" height="2" width="1" border="0" alt="" /></td></tr>'.LF; //Abstand vor
 219      echo '<tr'.$bgcol.'><td class="msglist" nowrap="nowrap">';
 220      echo $count.'<img src="img/leer.gif" height="1" width="4" border="0" alt="" /><img src="img/icons/harddisk_16x11.gif" border="0" alt="" />'; //Zellinhalt 1. Spalte
 221      echo '<img src="img/leer.gif" height="1" width="4" alt="" border="0" />'.$dirname.'</td><td><img src="img/leer.gif" height="1" width="5" border="0" alt="" /></td></tr>'.LF;
 222      //Aufbau trennende Tabellen-Zeile
 223      echo '<tr'.$bgcol.'><td colspan="2"><img src="img/leer.gif" height="1" width="1" border="0" alt="" /></td></tr>'.LF; //Abstand nach
 224      echo '<tr bgcolor="#CDDEE4"><td colspan="2"><img src="img/leer.gif" height="1" width="1" border="0" alt="" /></td></tr>'.LF;
 225          
 226      //Wenn überhaupt Ordner für User vorhanden, dann Listing
 227      if(!$folder_status && $count_wert) {
 228          folder_list(0, $db, 18, "filebrowser.php?opt=".$js_aktion."&amp;");
 229      }
 230  
 231      echo '</table>';
 232  } else {
 233      echo "no files available";
 234  }
 235      
 236      ?></td>
 237      <td valign="top"><?php
 238      
 239      //Tabelle
 240      
 241      echo '<table summary="" bgColor="#FFFFFF" width="100%" border="0" cellspacing="0" cellpadding="0">'.LF;
 242      $file_sql  = "SELECT * FROM ".DB_PREPEND."phpwcms_file WHERE f_pid=".$_SESSION["imgdir"]." AND ";
 243      switch($js_aktion) {
 244  
 245          case 6:        $file_sql .= "f_ext IN ('swf', 'mp3', 'flv', 'mp4', 'm4v', 'f4v', 'jpg', 'jpeg', 'png', 'gif') AND ";
 246                      break;
 247                      
 248                      // H.264
 249          case 12:    $file_sql .= "f_ext IN ('mp4', 'm4p', 'mov', 'm4p', 'm4a', 'm4v') AND ";
 250                      break;
 251                      
 252                      // WebM
 253          case 13:    $file_sql .= "f_ext IN ('webm') AND ";
 254                      break;
 255              
 256                      // Ogg
 257          case 14:    $file_sql .= "f_ext IN ('ogg', 'ogv', 'oga', 'ogx') AND ";
 258                      break;
 259          
 260                      // Typical Doc files
 261          case 18:    $file_sql .= "f_ext IN ('pdf', 'doc', 'docx', 'txt', 'xls', 'xlsx', 'ppt', 'pptx', 'odt', 'ods', 'odp', 'pages', 'key', 'numbers') AND ";
 262          case 15:    $entry_id  = empty($_SESSION['filebrowser_image_entry_id']) ? '' : $_SESSION['filebrowser_image_entry_id'];
 263                      break;
 264          
 265          case 11:
 266          case 17:
 267          case 8:        $entry_id  = empty($_SESSION['filebrowser_image_entry_id']) ? '' : $_SESSION['filebrowser_image_entry_id'];
 268          case 7:        $file_sql .= "f_ext IN ('jpeg', 'jpg', 'png', 'gif') AND ";
 269                      break;
 270  
 271          case 2:     $default_ext  = "f_ext IN ('aif', 'aiff', 'mov', 'movie', 'mp3', 'mpeg', 'mpeg4', ";
 272                      $default_ext .= "'mpeg2', 'wav', 'swf', 'ram', 'ra', 'wma', 'wmv', ";
 273                      $default_ext .= "'avi', 'au', 'midi', 'moov', 'rm', 'rpm', 'mid', 'midi')";
 274                  
 275                      if(!empty($phpwcms["multimedia_ext"])) {
 276                  
 277                          $allowed_ext = convertStringToArray(strtolower($phpwcms["multimedia_ext"]));
 278                          if(count($allowed_ext)) {                        
 279                              $default_ext = "f_ext IN ('".implode("', '", $allowed_ext) . "')";
 280                          }
 281                      
 282                      }
 283                  
 284                      $file_sql .= $default_ext." AND ";
 285                  
 286                      break;
 287  
 288      }
 289      $file_sql .= "f_aktiv=1 AND f_kid=1 AND f_trash=0 AND ";
 290      $file_sql .= "(f_public=1 OR f_uid=".$_SESSION["wcs_user_id"].") ";
 291      $file_sql .= "ORDER BY f_sort, f_name";
 292      
 293      if($file_result = mysql_query($file_sql, $db) or die ("error while listing files<br />".html_entities($file_sql))) {
 294          $file_durchlauf = 0;
 295          
 296          if(empty($_SESSION['image_browser_article'])) {
 297              $target_form = 'articlecontent';
 298          } else {
 299              $target_form = 'article';
 300          }
 301          
 302          while($file_row = mysql_fetch_array($file_result)) {
 303              $filename = html_specialchars($file_row["f_name"]);
 304              
 305              $thumb_image = true;
 306              if( !in_array($js_aktion, array(2, 4, 9, 10, 16, 18)) ) {
 307                  // check if file can have thumbnail - if so it can be choosen for usage
 308                  $thumb_image = get_cached_image(
 309                                   array(    "target_ext"    =>    $file_row["f_ext"],
 310                                          "image_name"    =>    $file_row["f_hash"] . '.' . $file_row["f_ext"],
 311                                          "thumb_name"    =>    md5($file_row["f_hash"].$phpwcms["img_list_width"].$phpwcms["img_list_height"].$phpwcms["sharpen_level"])
 312                                        )
 313                                  );
 314              }
 315  
 316              if($thumb_image != false || in_array($js_aktion, array(6, 10, 12, 13, 14, 16, 18))) {
 317              
 318                  $js_files_select[$file_durchlauf] = '      [' . $file_durchlauf .', ' . $file_row["f_id"] . ', "' . $filename . '"]';
 319                  $add_all = false;
 320              
 321                  switch($js_aktion) {
 322                      case 0:  $jst = empty($_SESSION['filebrowser_image_target']) ? '_' : $_SESSION['filebrowser_image_target']; 
 323                      
 324                               $js  = "window.opener.document.".$target_form.".cimage".$jst."name.value='".$filename."';";
 325                               $js .= "window.opener.document.".$target_form.".cimage".$jst."id.value='".$file_row["f_id"]."';";
 326                                break;
 327  
 328                      case 2:  $js  = "window.opener.document.articlecontent.cmedia_name.value='".$filename."';";
 329                               $js .= "window.opener.document.articlecontent.cmedia_id.value='".$file_row["f_id"]."';";
 330                                break;
 331                               
 332                      case 6:
 333                      case 12:
 334                      case 13:
 335                      case 14: $js = "window.opener.setIdName('".$file_row["f_id"]."', '".$filename."', ".$js_aktion.");";
 336                                break;
 337                      
 338                      case 18: 
 339                      case 15: $js = "window.opener.setIdName('".$entry_id."', '".$file_row["f_id"]."', '".$filename."');";
 340                                break;
 341                               
 342                      case 7:  $js = "window.opener.setImgIdName('".$file_row["f_id"]."', '".$filename."');";
 343                                break;
 344                               
 345                      case 8:  $js = "window.opener.setImgIdName('".$entry_id."', '".$file_row["f_id"]."', '".$filename."');";
 346                                break;
 347                  
 348                      case 4:  $js = "addFile(window.opener.document.articlecontent.cfile_list,'".$filename."','".$file_row["f_id"]."');";
 349                               $js_files_all[] = $js;
 350                               $add_all = true;
 351                               break;
 352                               
 353                      case 9:  $js = "window.opener.addFile('".$file_row["f_id"]."', '".$filename."');";
 354                               $js_files_all[] = $js;
 355                               $add_all = true;
 356                               break;
 357                               
 358                      case 5:  $js = "addFile(window.opener.img_field,'".$filename."','".$file_row["f_id"]."');";
 359                               $js_files_all[] = $js;
 360                               $add_all = true;
 361                               break;
 362                               
 363                      //mod
 364                      case 10: $js  = "window.opener.SetUrl('download.php?f=".$file_row["f_hash"] . "&target=0');";
 365                               break;
 366          
 367                      case 11: $js  = "window.opener.SetUrl('image_resized.php?format=" . $file_row["f_ext"]. "&q=85&imgfile=".$phpwcms_filestorage.$file_row["f_hash"] . '.' . $file_row["f_ext"]. "');";
 368                               break;
 369                               
 370                      //CKEditor
 371                      case 16: $js  = "window.opener.CKEDITOR.tools.callFunction(2, 'download.php?f=".$file_row["f_hash"] . "&target=0');";
 372                               break;
 373                      
 374                      case 17: $js  = "window.opener.CKEDITOR.tools.callFunction(2,'image_resized.php?format=" . $file_row["f_ext"]. "&q=85&imgfile=".$phpwcms_filestorage.$file_row["f_hash"] . '.' . $file_row["f_ext"]. "');";
 375                               break;
 376                          
 377                           
 378                      default: $js = "addFile(window.opener.document.articlecontent.cimage_list,'".$filename."','".$file_row["f_id"]."');";
 379                               $js_files_all[] = $js;
 380                               $add_all = true;
 381                  }
 382                  
 383                  // show "add all files"
 384                  if($file_durchlauf === 0 && $add_all) {
 385                  
 386                      echo '
 387                          <tr id="addAllFilesLink">
 388                              <td colspan="4" class="add_all_files"><a href="#" onclick="addAllFiles();return false;" title="' . $BL['ADD_ALL_FILES'] . '">' . 
 389                                  $BL['ADD_ALL_FILES'] .    '
 390                                  <img src="img/button/add_9x9a.gif" alt="" border="0" />
 391                                  </a></td>
 392                          </tr>
 393                          <tr>
 394                              <td colspan="4" bgcolor="#CDDEE4"><img src="img/leer.gif" alt="" border="0" /></td>
 395                          </tr>
 396                            ';
 397                  
 398                  }
 399              
 400                  echo '<tr><td colspan="4"><img src="img/leer.gif" width="1" height="2" border="0" alt="" /></td></tr>'.LF;
 401                  echo "<tr>\n<td><img src=\"img/icons/small_".extimg($file_row["f_ext"])."\" border=\"0\" alt=\"\" hspace=\"3\" vspace=\"1\" /></td>\n";
 402              
 403                  if($js_aktion != 4 && $js_aktion != 10 && $js_aktion != 16) {
 404                      echo "<td class=\"msglist\">".$filename."</td>\n<td><img src=\"img/leer.gif\" width=\"5\" height=\"1\" alt=\"\" border=\"0\" />";
 405                  } else {
 406                      echo "<td class=\"msglist\"><a href=\"#\" onclick=\"".$js."tmt_winControl('self','close()');\">".$filename."</a></td>\n<td>";
 407                  }
 408              
 409                  echo "<a href=\"#\" onclick=\"".$js."return false;\" title=\"".$BL['TAKE_IMAGE']."\">";
 410                  echo "<img src=\"img/button/add_9x9a.gif\" border=\"0\" alt=\"\" hspace=\"5\" vspace=\"2\" /></a></td>\n";
 411                  echo "<td><img src=\"img/leer.gif\" alt=\"\" border=\"0\" /></td>\n</tr>\n";
 412                  echo "<tr><td colspan=\"4\"><img src=\"img/leer.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" /></td></tr>\n";
 413                  if(!empty($thumb_image[0]) && in_array( $js_aktion, array(0, 1, 3, 5, 6, 7, 8, 10, 11, 17, 18) ) ) {
 414                      echo "<tr><td>&nbsp;</td>\n<td colspan=\"3\"><a href=\"#\" onclick=\"".$js;
 415                      echo "tmt_winControl('self','close()');\">";
 416                      echo '<img src="'.PHPWCMS_IMAGES . $thumb_image[0] .'" border="0" '.$thumb_image[3].' alt="" />';
 417                      echo "</a></td>\n</tr>\n";
 418                  }
 419                  echo "<tr><td colspan=\"4\"><img src=\"img/leer.gif\" width=\"1\" height=\"2\" alt=\"\" border=\"0\" /></td></tr>\n";
 420                  echo "<tr><td colspan=\"4\" bgcolor=\"#CDDEE4\"><img src=\"img/leer.gif\" width=\"1\" height=\"1\" alt=\"\" border=\"0\" /></td></tr>\n";
 421                  $file_durchlauf++;
 422              }
 423  
 424          }
 425          if(!$file_durchlauf) { //Abschluss der Filelisten-Tabelle
 426              echo "<tr><td colspan=\"4\"><img src=\"img/leer.gif\" width=\"3\" height=\"2\" alt=\"\" border=\"0\" /></td></tr>\n";
 427              echo "<tr><td colspan=\"4\" class=\"msglist\">&nbsp;".$BL['NO_FILE']."&nbsp;&nbsp;</td></tr>\n";
 428              echo "<tr><td colspan=\"4\"><img src=\"img/leer.gif\" width=\"3\" height=\"2\" alt=\"\" border=\"0\" /></td></tr>\n";
 429          }
 430      } //Ende Liste Dateien
 431      
 432      echo "</table>";
 433      
 434      if( count($js_files_select) ) {
 435          
 436          echo LF . '<script type="text/javascript">';
 437          echo LF . SCRIPT_CDATA_START . LF;
 438          
 439          echo 'var files_all = new Array(' . LF;
 440          echo implode(','.LF, $js_files_select);
 441          echo LF . '    );';
 442          echo LF . 'var files_total = ' . $file_durchlauf . ';';
 443          
 444          echo LF . LF;
 445          echo 'function addAllFiles() {';
 446          echo LF . '    ';
 447          echo implode(LF . '    ', $js_files_all);
 448          echo LF . '    //if(closewin == true) tmt_winControl("self","close()");';
 449          echo LF . '    getObjectById("addAllFilesLink").style.display = "none";';
 450          echo LF . '    if(confirm("' . str_replace('{VAL}', $current_dirname, $BL['ADD_ALL_CONFIRM']) . '")) tmt_winControl("self","close()");';
 451          echo LF . '}' . LF;
 452          
 453          echo LF . SCRIPT_CDATA_END;
 454          echo LF . '</script>' . LF;
 455          
 456          
 457      }
 458      
 459      ?></td>
 460    </tr>
 461  </table>
 462  </body>
 463  </html>
 464  <?php
 465  
 466  //function folder_list($pid, $dbcon, $vor, $zieldatei) {
 467  function folder_list($pid, $dbcon, $vor, $zieldatei) {
 468      global $current_dirname;
 469      $folder = $_SESSION["folder"];
 470      $pid = intval($pid);
 471      $userID = intval($_SESSION["wcs_user_id"]);
 472      $sql = "SELECT f_id, f_name, f_aktiv, f_public FROM ".DB_PREPEND."phpwcms_file WHERE ".
 473             "f_pid=".intval($pid)." AND f_aktiv=1 AND f_kid=0 AND f_trash=0 AND ".
 474             "(f_public=1 OR f_uid=".$userID.") ORDER BY f_sort, f_name";
 475      $result = mysql_query($sql, $dbcon);
 476      while($row = mysql_fetch_array($result)) {
 477      
 478          $dirname = html_specialchars($row["f_name"]);
 479          
 480          //Ermitteln des Aufolderwertes
 481          if(!isset($folder[$row["f_id"]])) $folder[$row["f_id"]] = 0;
 482          $folder_status = true_false($folder[$row["f_id"]]);
 483          
 484          //Ermitteln, ob überhaupt abhängige Dateien/Ordner existieren
 485          $count_sql = "SELECT COUNT(f_id) FROM ".DB_PREPEND."phpwcms_file WHERE ".
 486                       "f_pid=".$row["f_id"]." AND f_trash=0 AND f_aktiv=1 AND ".
 487                       "(f_public=1 OR f_uid=".$userID.") LIMIT 1";
 488          if($count_result = mysql_query($count_sql, $dbcon)) {
 489              if($count_row = mysql_fetch_row($count_result)) {
 490                  $count = '<img src="img/leer.gif" height="1" width="2" alt="" border="0" /><a href="'.$zieldatei."folder=".$row["f_id"].
 491                           '%7C'.$folder_status.'">'.on_off($folder_status, $dirname, 0).'</a>';
 492                  $count_wert = $count_row[0];
 493              }
 494              mysql_free_result($count_result);
 495          }
 496          
 497          $dirname = '<a href="'.$zieldatei."files=".$row["f_id"].'" title="'.$GLOBALS['BL']['SHOW_FILES1'].'">'. $dirname . '</a>';
 498  
 499          if($row["f_id"] == $_SESSION["imgdir"]) {
 500              $bgcol = ' bgcolor="#FED83F"';
 501              $current_dirname = $row["f_name"];
 502          } else {
 503              $bgcol = '';
 504          }
 505          
 506          //Aufbau der Zeile
 507          echo "<tr".$bgcol."><td colspan=\"2\"><img src=\"img/leer.gif\" height=\"2\" width=\"1\" alt=\"\" border=\"0\" /></td></tr>\n"; //Abstand vor
 508          echo "<tr".$bgcol."><td class=\"msglist\" nowrap=\"nowrap\">";
 509          echo $count."<img src=\"img/leer.gif\" height=\"1\" width=\"".($vor+6)."\" border=\"0\" alt=\"\" /><img src=\"img/icons/folder_zu.gif\" border=\"0\" alt=\"\" />"; //Zellinhalt 1. Spalte
 510          echo "<img src=\"img/leer.gif\" height=\"1\" width=\"5\" alt=\"\" border=\"0\" />".$dirname."</td><td><img src=\"img/leer.gif\" height=\"1\" width=\"5\" alt=\"\" border=\"0\" /></td></tr>\n";
 511          //Aufbau trennende Tabellen-Zeile
 512          echo "<tr".$bgcol."><td colspan=\"2\"><img src=\"img/leer.gif\" height=\"1\" width=\"1\" alt=\"\" border=\"0\" /></td></tr>\n"; //Abstand nach
 513          echo "<tr bgcolor=\"#CDDEE4\"><td colspan=\"2\"><img src=\"img/leer.gif\" height=\"1\" width=\"1\" alt=\"\" border=\"0\" /></td></tr>\n"; //Trennlinie<img src='img/lines/line-lightgrey-dotted-538.gif'>
 514          
 515          //Weiter, wenn Unterstruktur
 516          if(!$folder_status && $count_wert) {
 517              folder_list($row["f_id"], $dbcon, $vor+18, $zieldatei); //, $userID
 518          }
 519          
 520          //Zaehler mitführen
 521          $_SESSION["list_zaehler"]++;
 522      }
 523      mysql_free_result($result);
 524  }
 525  
 526  function on_off($wert, $string, $art = 1) {
 527      //Erzeugt das Status-Zeichen für Klapp-Auf/Zu
 528      //Wenn Art = 1 dann als Zeichen, ansonsten als Bild
 529      if($wert) {
 530          if($art == 1) {
 531              return "+";
 532          } else {
 533              return "<img src=\"img/symbols/klapp_zu.gif\" border=\"0\" alt=\"\" title=\"".$GLOBALS['BL']['OPEN_DIR'].": ".$string."\" />";
 534          }
 535      } else {
 536          if($art == 1) {
 537              return "-";
 538          } else {
 539              return "<img src=\"img/symbols/klapp_auf.gif\" border=\"0\" alt=\"\" title=\"".$GLOBALS['BL']['CLOSE_DIR'].": ".$string."\" />";
 540          }
 541      }
 542  }
 543  
 544  function true_false($wert) {
 545      //Wechselt den Wahr/Falsch wert zum Gegenteil: 1=>0 und 0=>1
 546      if(intval($wert)) { return 0; } else { return 1; }
 547  }
 548  
 549  ?>


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1