[ Index ]
 

Code source de e107 0.7.8

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

title

Body

[fermer]

/e107_admin/ -> upload.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/upload.php,v $
  14  |     $Revision: 1.19 $
  15  |     $Date: 2006/11/30 16:07:08 $
  16  |     $Author: lisa_ $
  17  +----------------------------------------------------------------------------+
  18  */
  19  require_once ("../class2.php");
  20  if (!getperms("V")) {
  21      header("location:".e_BASE."index.php");
  22      exit;
  23  }
  24  $e_sub_cat = 'upload';
  25  if (e_QUERY) {
  26      $tmp = explode(".", e_QUERY);
  27      $action = $tmp[0];
  28      $id = $tmp[1];
  29  }
  30  
  31  if ($action == "dis" && isset($_POST['updelete']['upload_'.$id]) ) {
  32      $res = $sql -> db_Select("upload", "*", "upload_id='".intval($id)."'");
  33      $row = $sql -> db_Fetch();
  34      if (preg_match("#Binary (.*?)/#", $row['upload_file'], $match)) {
  35          $sql -> db_Delete("rbinary", "binary_id='".$tp -> toDB($match[1])."'");
  36      } else if ($row['upload_file'] && file_exists(e_FILE."public/".$row['upload_file'])) {
  37          unlink(e_FILE."public/".$row['upload_file']);
  38      }
  39      if (preg_match("#Binary (.*?)/#", $row['upload_ss'], $match)) {
  40          $sql -> db_Delete("rbinary", "binary_id='".$tp -> toDB($match[1])."'");
  41      } else if ($row['upload_ss'] && file_exists(e_FILE."public/".$row['upload_ss'])) {
  42          unlink(e_FILE."public/".$row['upload_ss']);
  43      }
  44      $message = ($sql->db_Delete("upload", "upload_id='".intval($id)."'")) ? UPLLAN_1 : LAN_DELETED_FAILED;
  45  }
  46  
  47  if ($action == "dlm") {
  48      header("location: ".e_ADMIN."download.php?dlm.".$id);
  49      exit;
  50  }
  51  
  52  if ($action == "news") {
  53      header("location: ".e_ADMIN."newspost.php?create.upload.".$id);
  54      exit;
  55  }
  56  
  57  
  58  if ($action == "dl") {
  59  
  60      $id = str_replace("%20", " ", $id);
  61  
  62      if (preg_match("/Binary\s(.*?)\/.*/", $id, $result)) {
  63          $bid = $result[1];
  64          $result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id='$bid' ");
  65          $binary_data = @mysql_result($result, 0, "binary_data");
  66          $binary_filetype = @mysql_result($result, 0, "binary_filetype");
  67          $binary_name = @mysql_result($result, 0, "binary_name");
  68          header("Content-type: ".$binary_filetype);
  69          header("Content-length: ".$download_filesize);
  70          header("Content-Disposition: attachment; filename=".$binary_name);
  71          header("Content-Description: PHP Generated Data");
  72          echo $binary_data;
  73          exit;
  74      } else {
  75          header("location:".e_FILE."public/".str_replace("dl.", "", e_QUERY));
  76          exit;
  77      }
  78  }
  79  
  80  require_once ("auth.php");
  81  require_once(e_HANDLER."userclass_class.php");
  82  $gen = new convert;
  83  require_once(e_HANDLER."form_handler.php");
  84  $rs = new form;
  85  
  86  if (isset($_POST['optionsubmit'])) {
  87  
  88      $pref['upload_storagetype'] = $_POST['upload_storagetype'];
  89      $pref['upload_maxfilesize'] = $_POST['upload_maxfilesize'];
  90      $pref['upload_class'] = $_POST['upload_class'];
  91      $pref['upload_enabled'] = (FILE_UPLOADS ? $_POST['upload_enabled'] : 0);
  92      if ($pref['upload_enabled'] && !$sql->db_Select("links", "*", "link_url='upload.php' ")) {
  93          $sql->db_Insert("links", "0, '".UPLLAN_44."', 'upload.php', '', '', 1,0,0,0,0");
  94      }
  95  
  96      if (!$pref['upload_enabled'] && $sql->db_Select("links", "*", "link_url='upload.php' ")) {
  97          $sql->db_Delete("links", "link_url='upload.php' ");
  98      }
  99  
 100      save_prefs();
 101      $message = UPLLAN_2;
 102  }
 103  
 104  if (isset($message)) {
 105      require_once(e_HANDLER."message_handler.php");
 106      message_handler("ADMIN_MESSAGE", $message);
 107  }
 108  
 109  if (!FILE_UPLOADS) {
 110      message_handler("ADMIN_MESSAGE", UPLLAN_41);
 111  }
 112  
 113  
 114  // view -------------------------------------------------------------------------------------------------------------------------------------------------------------------
 115  
 116  if ($action == "view") {
 117      $sql->db_Select("upload", "*", "upload_id='$id'");
 118      $row = $sql->db_Fetch();
 119       extract($row);
 120  
 121      $post_author_id = substr($upload_poster, 0, strpos($upload_poster, "."));
 122      $post_author_name = substr($upload_poster, (strpos($upload_poster, ".")+1));
 123      $poster = (!$post_author_id ? "<b>".$post_author_name."</b>" : "<a href='".e_BASE."user.php?id.".$post_author_id."'><b>".$post_author_name."</b></a>");
 124      $upload_datestamp = $gen->convert_date($upload_datestamp, "long");
 125  
 126      $text = "<div style='text-align:center'>
 127          <table style='".ADMIN_WIDTH."' class='fborder'>
 128  
 129          <tr>
 130          <td style='width:30%' class='forumheader3'>".UPLLAN_3."</td>
 131          <td style='width:70%' class='forumheader3'>$upload_id</td>
 132          </tr>
 133  
 134          <tr>
 135          <td style='width:30%' class='forumheader3'>".LAN_DATE."</td>
 136          <td style='width:70%' class='forumheader3'>$upload_datestamp</td>
 137          </tr>
 138  
 139          <tr>
 140          <td style='width:30%' class='forumheader3'>".UPLLAN_5."</td>
 141          <td style='width:70%' class='forumheader3'>$poster</td>
 142          </tr>
 143  
 144          <tr>
 145          <td style='width:30%' class='forumheader3'>".UPLLAN_6."</td>
 146          <td style='width:70%' class='forumheader3'><a href='mailto:$upload_email'>$upload_email</td>
 147          </tr>
 148  
 149          <tr>
 150          <td style='width:30%' class='forumheader3'>".UPLLAN_7."</td>
 151          <td style='width:70%' class='forumheader3'>".($upload_website ? "<a href='$upload_website'>$upload_website</a>" : " - ")."</td>
 152          </tr>
 153  
 154          <tr>
 155          <td style='width:30%' class='forumheader3'>".UPLLAN_8."</td>
 156          <td style='width:70%' class='forumheader3'>".($upload_name ? $upload_name: " - ")."</td>
 157          </tr>
 158  
 159          <tr>
 160          <td style='width:30%' class='forumheader3'>".UPLLAN_9."</td>
 161          <td style='width:70%' class='forumheader3'>".($upload_version ? $upload_version : " - ")."</td>
 162          </tr>
 163  
 164          <tr>
 165          <td style='width:30%' class='forumheader3'>".UPLLAN_10."</td>
 166          <td style='width:70%' class='forumheader3'>".(is_numeric($upload_file) ? "Binary file ID ".$upload_file : "<a href='".e_SELF."?dl.$upload_file'>$upload_file</a>")."</td>
 167          </tr>
 168  
 169          <tr>
 170          <td style='width:30%' class='forumheader3'>".UPLLAN_11."</td>
 171          <td style='width:70%' class='forumheader3'>".parsesize($upload_filesize)."</td>
 172          </tr>
 173  
 174          <tr>
 175          <td style='width:30%' class='forumheader3'>".UPLLAN_12."</td>
 176          <td style='width:70%' class='forumheader3'>".($upload_ss ? "<a href='".e_BASE."request.php?upload.".$upload_id."'>".$upload_ss."</a>" : " - ")."</td>
 177          </tr>
 178  
 179          <tr>
 180          <td style='width:30%' class='forumheader3'>".UPLLAN_13."</td>
 181          <td style='width:70%' class='forumheader3'>$upload_description</td>
 182          </tr>
 183  
 184          <tr>
 185          <td style='width:30%' class='forumheader3'>".UPLLAN_14."</td>
 186          <td style='width:70%' class='forumheader3'>".($upload_demo ? $upload_demo : " - ")."</td>
 187          </tr>
 188  
 189          <tr>
 190          <td style='width:30%' class='forumheader3'>".LAN_OPTIONS."</td>
 191          <td style='width:70%' class='forumheader3'><a href='".e_SELF."?dlm.$upload_id'>".UPLAN_COPYTODLM."</a> | <a href='".e_SELF."?news.$upload_id'>".UPLLAN_16."</a> | <a href='".e_SELF."?dis.$upload_id'>".UPLLAN_17."</a></td>
 192          </tr>
 193  
 194          </table>
 195          </div>";
 196  
 197      $ns->tablerender(UPLLAN_18, $text);
 198  
 199  }
 200  
 201  
 202  // list -------------------------------------------------------------------------------------------------------------------------------------------------------------------
 203  $imgd = e_BASE.$IMAGES_DIRECTORY;
 204  $text = "<div style='text-align:center'>
 205  <table style='".ADMIN_WIDTH."' class='fborder'>
 206  <tr>
 207  <td style='width:5%' class='fcaption'>".UPLLAN_22."</td>
 208  <td style='width:10%' class='fcaption'>".LAN_DATE."</td>
 209  <td style='width:20%' class='fcaption'>".UPLLAN_5."</td>
 210  <td style='width:20%' class='fcaption'>".UPLLAN_23."</td>
 211  <td style='width:30%' class='fcaption'>".UPLLAN_24."</td>
 212  <td style='width:18px' class='fcaption'>".UPLLAN_42."</td>
 213  </tr>";
 214  
 215  $text .= "<tr><td class='forumheader3' style='text-align:center' colspan='6'>";
 216  
 217  if (!$active_uploads = $sql->db_Select("upload", "*", "upload_active=0 ORDER BY upload_id ASC")) {
 218      $text .= UPLLAN_19.".\n</td>\n</tr>";
 219  } else {
 220  
 221      $activeUploads = $sql -> db_getList();
 222  
 223      $text .= UPLLAN_20." ".($active_uploads == 1 ? UPLAN_IS : UPLAN_ARE).$active_uploads." ".($active_uploads == 1 ? UPLLAN_21 : UPLLAN_27)." ...";
 224  
 225      $text .= "</td></tr>";
 226  
 227      foreach($activeUploads as $row)
 228      {
 229          extract($row);
 230          $post_author_id = substr($upload_poster, 0, strpos($upload_poster, "."));
 231          $post_author_name = substr($upload_poster, (strpos($upload_poster, ".")+1));
 232          $poster = (!$post_author_id ? "<b>".$post_author_name."</b>" : "<a href='".e_BASE."user.php?id.".$post_author_id."'><b>".$post_author_name."</b></a>");
 233          $upload_datestamp = $gen->convert_date($upload_datestamp, "short");
 234          $text .= "<tr>
 235          <td style='width:5%' class='forumheader3'>".$upload_id ."</td>
 236          <td style='width:20%' class='forumheader3'>".$upload_datestamp."</td>
 237          <td style='width:15%' class='forumheader3'>".$poster."</td>
 238          <td style='width:20%' class='forumheader3'><a href='".e_SELF."?view.".$upload_id."'>".$upload_name ."</a></td>
 239          <td style='width:20%' class='forumheader3'>".$upload_file ."</td>
 240          <td style='width:50px;white-space:nowrap' class='forumheader3'>
 241          <form action='".e_SELF."?dis.$upload_id' id='uploadform_{$upload_id}' method='post'>
 242          <div><a href='".e_SELF."?dlm.$upload_id'><img src='".e_IMAGE."admin_images/downloads_16.png' alt='".UPLAN_COPYTODLS."' title='".UPLAN_COPYTODLS."' style='border:0' /></a>
 243          <a href='".e_SELF."?news.$upload_id'><img src='".e_IMAGE."admin_images/news_16.png' alt='".UPLLAN_16."' title='".UPLLAN_16."' style='border:0' /></a>
 244          <input type='image' title='".LAN_DELETE."' name='updelete[upload_{$upload_id}]' src='".ADMIN_DELETE_ICON_PATH."' onclick=\"return jsconfirm('".$tp->toJS(UPLLAN_45." [ $upload_name ]")."') \"/>
 245          </div></form></td>
 246          </tr>";
 247      }
 248  }
 249  $text .= "</table>\n</div>";
 250  
 251  $ns->tablerender(UPLLAN_43, $text);
 252  
 253  
 254  // options -------------------------------------------------------------------------------------------------------------------------------------------------------------------
 255  
 256  if (is_readable(e_ADMIN.'filetypes.php')) {
 257      $allowed_filetypes = trim(file_get_contents(e_ADMIN.'filetypes.php'));
 258  }
 259  
 260  $text = "<div style='text-align:center'>
 261      <form method='post' action='".e_SELF."'>
 262      <table style='".ADMIN_WIDTH."' class='fborder'>
 263      <tr>
 264      <td style='width:50%' class='forumheader3'>".UPLLAN_25."<br />
 265      <span class='smalltext'>".UPLLAN_26."</span></td>
 266      <td style='width:50%' class='forumheader3'>". ($pref['upload_enabled'] == 1 ? $rs->form_radio("upload_enabled", 1, 1)." ".LAN_YES.$rs->form_radio("upload_enabled", 0)." ".LAN_NO : $rs->form_radio("upload_enabled", 1)." ".LAN_YES.$rs->form_radio("upload_enabled", 0, 1)." ".LAN_NO)."
 267      </td>
 268      </tr>
 269  
 270      <tr>
 271      <td style='width:50%' class='forumheader3'>".UPLLAN_29."<br />
 272      <span class='smalltext'>".UPLLAN_30."</span></td>
 273      <td style='width:50%' class='forumheader3'>". ($pref['upload_storagetype'] == 1 ? $rs->form_radio("upload_storagetype", 1, 1)." ".UPLLAN_31."<br />".$rs->form_radio("upload_storagetype", 2)." ".UPLLAN_32 : $rs->form_radio("upload_storagetype", 1)." ".UPLLAN_31."<br />".$rs->form_radio("upload_storagetype", 2, 1)." ".UPLLAN_32)."
 274      </td>
 275      </tr>
 276  
 277      <tr>
 278      <td style='width:70%' class='forumheader3'>".UPLLAN_33."<br />
 279      <span class='smalltext'>".UPLLAN_34." ".ini_get('upload_max_filesize')." )</span></td>
 280      <td style='width:30%' class='forumheader3'>". $rs->form_text("upload_maxfilesize", 10, $pref['upload_maxfilesize'], 10)."
 281      </td>
 282      </tr>
 283  
 284      <tr>
 285      <td style='width:70%' class='forumheader3'>".UPLLAN_35."<br />
 286      <span class='smalltext'>".UPLLAN_48."</span></td>
 287      <td style='width:30%' class='forumheader3'>".$allowed_filetypes."
 288      </td>
 289      </tr>
 290  
 291      <tr>
 292      <td style='width:70%' class='forumheader3'>".UPLLAN_37."<br />
 293      <span class='smalltext'>".UPLLAN_38."</span></td>
 294      <td style='width:30%' class='forumheader3'>".r_userclass("upload_class", $pref['upload_class'],"off","nobody,public,guest,member,admin,classes")."
 295  
 296      </td>
 297      </tr>
 298  
 299      <tr>
 300      <td colspan='2' class='forumheader' style='text-align:center'>". $rs->form_button("submit", "optionsubmit", UPLLAN_39)."
 301      </td>
 302      </tr>
 303      </table>". $rs->form_close()."
 304      </div>";
 305  
 306  $ns->tablerender(LAN_OPTIONS, $text);
 307  
 308  
 309  
 310  function parsesize($size) {
 311      $kb = 1024;
 312      $mb = 1024 * $kb;
 313      $gb = 1024 * $mb;
 314      $tb = 1024 * $gb;
 315      if ($size < $kb) {
 316          return $size." b";
 317      }
 318      else if($size < $mb) {
 319          return round($size/$kb, 2)." kb";
 320      }
 321      else if($size < $gb) {
 322          return round($size/$mb, 2)." mb";
 323      }
 324      else if($size < $tb) {
 325          return round($size/$gb, 2)." gb";
 326      } else {
 327          return round($size/$tb, 2)." tb";
 328      }
 329  }
 330  
 331  
 332  require_once ("footer.php");
 333  ?>


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