[ Index ]
 

Code source de e107 0.7.8

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/e107_admin/ -> filemanager.php (source)

   1  <?php
   2  /*
   3  + ----------------------------------------------------------------------------+
   4  |     e107 website system
   5  |
   6  |     ©Steve Dunstan 2001-2002
   7  |     http://e107.org
   8  |     jalist@e107.org
   9  |
  10  |     Released under the terms and conditions of the
  11  |     GNU General Public License (http://gnu.org).
  12  |
  13  |     $Source: /cvsroot/e107/e107_0.7/e107_admin/filemanager.php,v $
  14  |     $Revision: 1.21 $
  15  |     $Date: 2006/11/15 15:55:40 $
  16  |     $Author: lisa_ $
  17  +----------------------------------------------------------------------------+
  18  */
  19  require_once ("../class2.php");
  20  if (!getperms("6")) {
  21      header("location:".e_BASE."index.php");
  22      exit;
  23  }
  24  $e_sub_cat = 'filemanage';
  25  require_once ("auth.php");
  26  
  27  
  28  $pubfolder = (str_replace("../","",e_QUERY) == str_replace("../","",e_FILE."public/")) ? TRUE : FALSE;
  29  
  30  
  31  $imagedir = e_IMAGE."filemanager/";
  32  
  33      $dir_options[0] = FMLAN_47;
  34      $dir_options[1] = FMLAN_35;
  35      $dir_options[2] = FMLAN_40;
  36  
  37  
  38      $adchoice[0] = e_FILE."public/";
  39      $adchoice[1] = e_FILE;
  40      $adchoice[2] = e_IMAGE."newspost_images/";
  41  
  42  
  43  $path = str_replace("../", "", e_QUERY);
  44  if (!$path) {
  45      $path = str_replace("../", "", $adchoice[0]);
  46  }
  47  
  48  if($path == "/")
  49  {
  50      $path = $adchoice[0];
  51      echo "<b>Debug</b> ".$path." <br />";
  52  }
  53  
  54  
  55  // ===============================================
  56  
  57  
  58  foreach($_POST['deleteconfirm'] as $key=>$delfile){
  59      // check for delete.
  60      if (isset($_POST['selectedfile'][$key]) && isset($_POST['deletefiles'])) {
  61          if (!$_POST['ac'] == md5(ADMINPWCHANGE)) {
  62              exit;
  63          }
  64          $destination_file = e_BASE.$delfile;
  65          if (@unlink($destination_file)) {
  66              $message .= FMLAN_26." '".$destination_file."' ".FMLAN_27.".<br />";
  67          } else {
  68              $message .= FMLAN_28." '".$destination_file."'.<br />";
  69          }
  70      }
  71  
  72      // check for move to downloads or downloadimages.
  73      if (isset($_POST['selectedfile'][$key]) && (isset($_POST['movetodls'])) ){
  74      $newfile = str_replace($path,"",$delfile);
  75  
  76      // Move file to whatever folder.
  77          if (isset($_POST['movetodls'])){
  78  
  79              $newpath = $_POST['movepath'];
  80  
  81              if (rename(e_BASE.$delfile,$newpath.$newfile)){
  82                  $message .= FMLAN_38." ".$newpath.$newfile."<br />";
  83              } else {
  84                  $message .= FMLAN_39." ".$newpath.$newfile."<br />";
  85                  $message .= (!is_writable($newpath)) ? $newpath.LAN_NOTWRITABLE : "";
  86              }
  87          }
  88      }
  89  }
  90  
  91  
  92  
  93  if (isset($_POST['upload'])) {
  94      if (!$_POST['ac'] == md5(ADMINPWCHANGE)) {
  95          exit;
  96      }
  97      $pref['upload_storagetype'] = "1";
  98      require_once(e_HANDLER."upload_handler.php");
  99      $files = $_FILES['file_userfile'];
 100      foreach($files['name'] as $key => $name) {
 101          if ($files['size'][$key]) {
 102              $uploaded = file_upload(e_BASE.$_POST['upload_dir'][$key]);
 103          }
 104      }
 105  }
 106  
 107  if (isset($message)) {
 108      $ns->tablerender("", "<div style=\"text-align:center\"><b>".$message."</b></div>");
 109  }
 110  
 111  if (strpos(e_QUERY, ".") && !is_dir(realpath(e_BASE.$path))){
 112      echo "<iframe style=\"width:100%\" src=\"".e_BASE.e_QUERY."\" height=\"300\" scrolling=\"yes\"></iframe><br /><br />";
 113      if (!strpos(e_QUERY, "/")) {
 114          $path = "";
 115      } else {
 116          $path = substr($path, 0, strrpos(substr($path, 0, -1), "/"))."/";
 117      }
 118  }
 119  
 120  $files = array();
 121  $dirs = array();
 122  $path = explode("?", $path);
 123  $path = $path[0];
 124  $path = explode(".. ", $path);
 125  $path = $path[0];
 126  
 127  if ($handle = opendir(e_BASE.$path)) {
 128      while (false !== ($file = readdir($handle))) {
 129          if ($file != "." && $file != "..") {
 130  
 131              if (getenv('windir') && is_file(e_BASE.$path."\\".$file)) {
 132                  if (is_file(e_BASE.$path."\\".$file)) {
 133                      $files[] = $file;
 134                  } else {
 135                      $dirs[] = $file;
 136                  }
 137              } else {
 138                  if (is_file(e_BASE.$path."/".$file)) {
 139                      $files[] = $file;
 140                  } else {
 141                      $dirs[] = $file;
 142                  }
 143              }
 144          }
 145      }
 146  }
 147  closedir($handle);
 148  
 149  if (count($files) != 0) {
 150      sort($files);
 151  }
 152  if (count($dirs) != 0) {
 153      sort($dirs);
 154  }
 155  
 156  if (count($files) == 1) {
 157      $cstr = FMLAN_12;
 158  } else {
 159      $cstr = FMLAN_13;
 160  }
 161  
 162  if (count($dirs) == 1) {
 163      $dstr = FMLAN_14;
 164  } else {
 165      $dstr = FMLAN_15;
 166  }
 167  
 168  $pathd = $path;
 169  
 170  $text = "<div style='text-align:center'>\n
 171      <form method='post' action='".e_SELF."?".e_QUERY."'>\n
 172      <table style='".ADMIN_WIDTH."' class='fborder'>\n
 173      <tr>\n\n
 174  
 175      <td style='width:70%' class='forumheader3'>\n
 176      ".FMLAN_32."
 177      </td>\n
 178      <td class='forumheader3' style='text-align:center; width:30%'>\n
 179      <select name='admin_choice' class='tbox' onchange=\"location.href=this.options[selectedIndex].value\">\n";
 180  
 181  
 182      foreach($dir_options as $key=>$opt){
 183          $select = (str_replace("../","",$adchoice[$key]) == e_QUERY) ? "selected='selected'" : "";
 184          $text .= "<option value='".e_SELF."?".str_replace("../","",$adchoice[$key])."' $select>".$opt."</option>\n";
 185      }
 186  
 187  $text .= "</select>\n
 188      </td>\n
 189      </tr>\n\n
 190  
 191      <tr style='vertical-align:top'>\n
 192      <td colspan='2'  style='text-align:center' class='forumheader'>\n
 193      <input class='button' type='submit' name='updateoptions' value='".FMLAN_33."' />\n
 194      </td>\n
 195      </tr>\n\n
 196  
 197      </table>\n
 198      </form>\n
 199      </div>";
 200  $ns->tablerender(FMLAN_34, $text);
 201  
 202  
 203  $text = "<form enctype=\"multipart/form-data\" action=\"".e_SELF.(e_QUERY ? "?".e_QUERY : "")."\" method=\"post\">
 204      <div style=\"text-align:center\">
 205      <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1000000\" />
 206      <table class='fborder' style=\"".ADMIN_WIDTH."\">";
 207  
 208  $text .= "<tr>
 209      <td style=\"width:5%\" class=\"fcaption\">&nbsp;</td>
 210      <td style=\"width:30%\" class=\"fcaption\"><b>".FMLAN_17."</b></td>
 211      <td class=\"fcaption\"><b>".FMLAN_18."</b></td>
 212      <td style=\"width:30%\" class=\"fcaption\"><b>".FMLAN_19."</b></td>
 213      <td class=\"fcaption\"><b>".LAN_OPTIONS."</b></td>
 214      </tr>";
 215  
 216  if ($path != e_FILE) {
 217      if (substr_count($path, "/") == 1) {
 218          $pathup = e_SELF;
 219      } else {
 220          $pathup = e_SELF."?".substr($path, 0, strrpos(substr($path, 0, -1), "/"))."/";
 221      }
 222      $text .= "<tr><td colspan=\"5\" class=\"forumheader3\"><a href=\"".$pathup."\"><img src=\"".$imagedir."updir.png\" alt=\"".FMLAN_30."\" style=\"border:0\" /></a> 
 223          <a href=\"filemanager.php\"><img src=\"".$imagedir."home.png\" alt=\"".FMLAN_16."\" style=\"border:0\" /></a>
 224          </td>
 225          </tr>";
 226  }
 227  
 228  $c = 0;
 229  while ($dirs[$c]) {
 230      $dirsize = dirsize($path.$dirs[$c]);
 231      $text .= "<tr>
 232          <td class=\"forumheader3\" style=\"vertical-align:middle; text-align:center; width:5%\">
 233          <a href=\"".e_SELF."?".$path.$dirs[$c]."/\"><img src=\"".$imagedir."folder.png\" alt=\"".$dirs[$c]." ".FMLAN_31."\" style=\"border:0\" /></a>
 234          </td>
 235          <td style=\"width:30%\" class=\"forumheader3\">
 236          <a href=\"".e_SELF."?".$path.$dirs[$c]."/\">".$dirs[$c]."</a>
 237          </td>
 238          <td class=\"forumheader3\">".$dirsize."
 239          </td>
 240          <td class=\"forumheader3\">&nbsp;</td>
 241          <td class=\"forumheader3\">";
 242      if (FILE_UPLOADS && is_writable(e_BASE.$path.$dirs[$c])) {
 243          $text .= "<input class=\"button\" type=\"button\" name=\"erquest\" value=\"".FMLAN_21."\" onclick=\"expandit(this)\" />
 244              <div style=\"display:none;\">
 245              <input class=\"tbox\" type=\"file\" name=\"file_userfile[]\" size=\"50\" />
 246              <input class=\"button\" type=\"submit\" name=\"upload\" value=\"".FMLAN_22."\" />
 247              <input type=\"hidden\" name=\"upload_dir[]\" value=\"".$path.$dirs[$c]."\" />
 248              </div>";
 249      } else {
 250          $text .= "&nbsp;";
 251      }
 252      $text .= "</td>
 253          </tr>
 254  
 255  
 256          ";
 257      $c++;
 258  }
 259  
 260  $c = 0;
 261  while ($files[$c]) {
 262      $img = substr(strrchr($files[$c], "."), 1, 3);
 263      if (!$img || !preg_match("/css|exe|gif|htm|jpg|js|php|png|txt|xml|zip/i", $img)) {
 264          $img = "def";
 265      }
 266      $size = parsesize(filesize(e_BASE.$path."/".$files[$c]));
 267      $text .= "<tr>
 268          <td class=\"forumheader3\" style=\"vertical-align:middle; text-align:center; width:5%\">
 269          <img src=\"".$imagedir.$img.".png\" alt=\"".$files[$c]."\" style=\"border:0\" />
 270          </td>
 271          <td style=\"width:30%\" class=\"forumheader3\">
 272          <a href=\"".e_SELF."?".$path.$files[$c]."\">".$files[$c]."</a>
 273          </td>";
 274      $gen = new convert;
 275      $filedate = $gen -> convert_date(filemtime(e_BASE.$path."/".$files[$c]), "forum");
 276      $text .= "<td style=\"width:10%\" class=\"forumheader3\">".$size."</td>
 277          <td style=\"width:30%\" class=\"forumheader3\">".$filedate."</td>
 278          <td class=\"forumheader3\">";
 279  
 280      $text .= "<input  type=\"checkbox\" name=\"selectedfile[$c]\" value=\"1\" />";
 281      $text .="<input type=\"hidden\" name=\"deleteconfirm[$c]\" value=\"".$path.$files[$c]."\" />";
 282  
 283      $text .="</td>
 284          </tr>";
 285      $c++;
 286  }
 287  
 288      $text .= "<tr><td colspan='5' class='forumheader' style='text-align:right'>";
 289  
 290      if ($pubfolder || e_QUERY == ""){
 291          require_once(e_HANDLER."file_class.php");
 292          $fl = new e_file;
 293          $dl_dirlist = $fl->get_dirs(e_DOWNLOAD);
 294          $movechoice = array();
 295          $movechoice[] = e_DOWNLOAD;
 296          foreach($dl_dirlist as $dirs){
 297              $movechoice[] = e_DOWNLOAD.$dirs."/";
 298          }
 299          sort($movechoice);
 300          $movechoice[] = e_FILE."downloadimages/";
 301          if(e_QUERY != str_replace("../","",e_FILE."public/")){
 302              $movechoice[] = e_FILE."public/";
 303          }
 304          if(e_QUERY != str_replace("../","",e_FILE."downloadthumbs/")){
 305              $movechoice[] = e_FILE."downloadthumbs/";
 306          }
 307          if(e_QUERY != str_replace("../","",e_FILE."misc/")){
 308              $movechoice[] = e_FILE."misc/";
 309          }
 310          if(e_QUERY != str_replace("../","",e_IMAGE)){
 311              $movechoice[] = e_IMAGE;
 312          }
 313          if(e_QUERY != str_replace("../","",e_IMAGE."newspost_images/")){
 314              $movechoice[] = e_IMAGE."newspost_images/";
 315          }
 316  
 317  
 318  
 319  
 320          $text .= FMLAN_48."&nbsp;<select class='tbox' name='movepath'>\n";
 321          foreach($movechoice as $paths){
 322              $text .= "<option value='$paths'>".str_replace("../","",$paths)."</option>\n";
 323          }
 324          $text .= "</select>&nbsp;";
 325          $text .="<input class=\"button\" type=\"submit\" name=\"movetodls\" value=\"".FMLAN_50."\" onclick=\"return jsconfirm('".$tp->toJS(FMLAN_49)."') \" />
 326          ";
 327      }
 328  
 329      $text .= "<input class=\"button\" type=\"submit\" name=\"deletefiles\" value=\"".FMLAN_43."\" onclick=\"return jsconfirm('".$tp->toJS(FMLAN_46)."') \" />
 330          </td></tr></table>
 331          <input type='hidden' name='ac' value='".md5(ADMINPWCHANGE)."' />
 332          </div>
 333          </form>";
 334  
 335  $ns->tablerender(FMLAN_29.": <b>root/".$pathd."</b>&nbsp;&nbsp;[ ".count($dirs)." ".$dstr.", ".count($files)." ".$cstr." ]", $text);
 336  
 337  function dirsize($dir) {
 338      $_SERVER["DOCUMENT_ROOT"].e_HTTP.$dir;
 339      $dh = @opendir($_SERVER["DOCUMENT_ROOT"].e_HTTP.$dir);
 340      $size = 0;
 341      while ($file = @readdir($dh)) {
 342          if ($file != "." and $file != "..") {
 343              $path = $dir."/".$file;
 344              if (is_file($_SERVER["DOCUMENT_ROOT"].e_HTTP.$path)) {
 345                  $size += filesize($_SERVER["DOCUMENT_ROOT"].e_HTTP.$path);
 346              } else {
 347                  $size += dirsize($path."/");
 348              }
 349          }
 350      }
 351      @closedir($dh);
 352      return parsesize($size);
 353  }
 354  
 355  function parsesize($size) {
 356      $kb = 1024;
 357      $mb = 1024 * $kb;
 358      $gb = 1024 * $mb;
 359      $tb = 1024 * $gb;
 360      if ($size < $kb) {
 361          return $size." b";
 362      }
 363      else if($size < $mb) {
 364          return round($size/$kb, 2)." kb";
 365      }
 366      else if($size < $gb) {
 367          return round($size/$mb, 2)." mb";
 368      }
 369      else if($size < $tb) {
 370          return round($size/$gb, 2)." gb";
 371      } else {
 372          return round($size/$tb, 2)." tb";
 373      }
 374  }
 375  
 376  require_once ("footer.php");
 377  ?>


Généré le : Sun Apr 1 01:23:32 2007 par Balluche grâce à PHPXref 0.7