[ Index ]
 

Code source de e107 0.7.8

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

title

Body

[fermer]

/e107_admin/ -> download.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/download.php,v $
  14  |     $Revision: 1.95 $
  15  |     $Date: 2006/12/03 15:09:29 $
  16  |     $Author: lisa_ $
  17  +----------------------------------------------------------------------------+
  18  */
  19  require_once ("../class2.php");
  20  if (!getperms("R")) {
  21      header("location:".e_BASE."index.php");
  22      exit;
  23  }
  24  
  25  require_once(e_HANDLER."calendar/calendar_class.php");
  26  $cal = new DHTML_Calendar(true);
  27  function headerjs()
  28  {
  29      global $cal;
  30      return $cal->load_files();
  31  }
  32  
  33  $e_sub_cat = 'download';
  34  
  35  require_once(e_HANDLER."form_handler.php");
  36  require_once(e_HANDLER."userclass_class.php");
  37  require_once(e_HANDLER."file_class.php");
  38  
  39  $fl = new e_file;
  40  
  41  // -------- Presets. ------------
  42  require_once(e_HANDLER."preset_class.php");
  43  $pst = new e_preset;
  44  $pst->form = array("myform","dlform"); // form id of the form that will have it's values saved.
  45  $pst->page = array("download.php?create","download.php?cat"); // display preset options on which page(s).
  46  $pst->id = array("admin_downloads","admin_dl_cat");
  47  // -------------------------------
  48  
  49  $download = new download;
  50  require_once ("auth.php");
  51  $pst->save_preset();  // unique name(s) for the presets - comma separated.
  52  
  53   /*
  54  One form example (no arrays needed)
  55  $pst->form = "myform"; // form id of the form that will have it's values saved.
  56  $pst->page = "download.php?create"; // display preset options on which page.
  57  $pst->save_preset("admin_downloads");  // unique name for the preset
  58  */
  59  
  60  $rs = new form;
  61  if (e_QUERY) {
  62      $tmp = explode(".", e_QUERY);
  63      $action = $tmp[0];
  64      $sub_action = $tmp[1];
  65      $id = $tmp[2];
  66      $from = ($tmp[3] ? $tmp[3] : 0);
  67      unset($tmp);
  68  }
  69  
  70  if(isset($_POST['delete']))
  71  {
  72      $tmp = array_keys($_POST['delete']);
  73      list($delete, $del_id) = explode("_", $tmp[0]);
  74      unset($_POST['searchquery']);
  75  }
  76  
  77  $from = ($from ? $from : 0);
  78  $amount = 50;
  79  
  80  
  81  if($file_array = $fl->get_files(e_DOWNLOAD, "","standard",2)){
  82          sort($file_array);
  83  }
  84  
  85  if($public_array = $fl->get_files(e_FILE."public/")){
  86      foreach($public_array as $key=>$val){
  87          $file_array[] = str_replace(e_FILE."public/","",$val);
  88      }
  89  }
  90  
  91  
  92  
  93  if ($sql->db_Select("rbinary")){
  94      while ($row = $sql->db_Fetch())    {
  95          extract($row);
  96          $file_array[] = "Binary ".$binary_id."/".$binary_name;
  97      }
  98  }
  99  
 100  
 101  
 102  if($image_array = $fl->get_files(e_FILE."downloadimages/", ".gif|.jpg|.png|.GIF|.JPG|.PNG","standard",2)){
 103      sort($image_array);
 104  }
 105  
 106  if($thumb_array = $fl->get_files(e_FILE."downloadthumbs/", ".gif|.jpg|.png|.GIF|.JPG|.PNG","standard",2)){
 107      sort($thumb_array);
 108  }
 109  
 110  if(isset($_POST)){
 111      $e107cache->clear("download_cat");
 112  }
 113  
 114  if (isset($_POST['add_category'])) {
 115      $download->create_category($sub_action, $id);
 116  }
 117  
 118  if (isset($_POST['submit_download'])) {
 119      $download->submit_download($sub_action, $id);
 120      $action = "main";
 121      unset($sub_action, $id);
 122  }
 123  
 124  
 125  if(isset($_POST['update_catorder'])){
 126       foreach($_POST['catorder'] as $key=>$order){
 127          if($_POST['catorder'][$key]){
 128              $sql -> db_Update("download_category", "download_category_order='".intval($order)."' WHERE download_category_id='".intval($key)."'");
 129            }
 130      }
 131         $ns->tablerender("", "<div style='text-align:center'><b>".LAN_UPDATED."</b></div>");
 132  }
 133  
 134  if (isset($_POST['updateoptions']))
 135  {
 136      $pref['download_php'] = $_POST['download_php'];
 137      $pref['download_view'] = $_POST['download_view'];
 138      $pref['download_sort'] = $_POST['download_sort'];
 139      $pref['download_order'] = $_POST['download_order'];
 140      $pref['agree_flag'] = $_POST['agree_flag'];
 141      $pref['download_email'] = $_POST['download_email'];
 142      $pref['agree_text'] = $tp->toDB($_POST['agree_text']);
 143      $pref['download_denied'] = $tp->toDB($_POST['download_denied']);
 144      $pref['download_reportbroken'] = $_POST['download_reportbroken'];
 145      save_prefs();
 146      $message = DOWLAN_65;
 147  }
 148  
 149  if(isset($_POST['addlimit']))
 150  {
 151      if($sql->db_Select('generic','gen_id',"gen_type = 'download_limit' AND gen_datestamp = {$_POST['newlimit_class']}"))
 152      {
 153          $message = DOWLAN_116;
 154      }
 155      else
 156      {
 157          if($sql->db_Insert('generic',"0, 'download_limit', '".intval($_POST['newlimit_class'])."', '".intval($_POST['new_bw_num'])."', '".intval($_POST['new_bw_days'])."', '".intval($_POST['new_count_num'])."', '".intval($_POST['new_count_days'])."'"))
 158          {
 159              $message = DOWLAN_117;
 160          }
 161          else
 162          {
 163              $message = DOWLAN_118;
 164          }
 165      }
 166  }
 167  
 168  if(isset($_POST['updatelimits']))
 169  {
 170  
 171      if($pref['download_limits'] != $_POST['download_limits'])
 172      {
 173          $pref['download_limits'] = ($_POST['download_limits'] == 'on') ? 1 : 0;
 174          save_prefs();
 175          $message .= DOWLAN_126."<br />";
 176      }
 177      foreach(array_keys($_POST['count_num']) as $id)
 178      {
 179          if(!$_POST['count_num'][$id] && !$_POST['count_days'][$id] && !$_POST['bw_num'][$id] && !$_POST['bw_days'][$id])
 180          {
 181              //All entries empty - Remove record
 182              if($sql->db_Delete('generic',"gen_id = {$id}"))
 183              {
 184                  $message .= $id." - ".DOWLAN_119."<br />";
 185              }
 186              else
 187              {
 188                  $message .= $id." - ".DOWLAN_120."<br />";
 189              }
 190          }
 191          else
 192          {
 193              $sql->db_Update('generic',"gen_user_id = '".intval($_POST['bw_num'][$id])."', gen_ip = '".intval($_POST['bw_days'][$id])."', gen_intdata = '".intval($_POST['count_num'][$id])."', gen_chardata = '".intval($_POST['count_days'][$id])."' WHERE gen_id = {$id}");
 194              $message .= $id." - ".DOWLAN_121."<br />";
 195          }
 196      }
 197  }
 198  
 199  if(isset($_POST['submit_mirror']))
 200  {
 201      $download->submit_mirror($sub_action, $id);
 202  }
 203  
 204  if($action == "mirror")
 205  {
 206      $download -> show_existing_mirrors();
 207  }
 208  
 209  
 210  if ($action == "dlm")
 211  {
 212      $action = "create";
 213      $id = $sub_action;
 214      $sub_action = "dlm";
 215  }
 216  
 217  if ($action == "create") {
 218      $download->create_download($sub_action, $id);
 219  }
 220  
 221  if ($delete == 'category') {
 222      if (admin_update($sql->db_Delete("download_category", "download_category_id='$del_id' "), 'delete', DOWLAN_49." #".$del_id." ".DOWLAN_36)) {
 223          $sql->db_Delete("download_category", "download_category_parent='{$del_id}' ");
 224      }
 225  }
 226  
 227  if ($action == "cat") {
 228      $download->show_categories($sub_action, $id);
 229  }
 230  
 231  if ($delete == 'main') {
 232  
 233      $result = admin_update($sql->db_Delete("download", "download_id='$del_id' "), 'delete', DOWLAN_27." #".$del_id." ".DOWLAN_36);
 234      if($result)
 235      {
 236          admin_purge_related("download", $del_id);
 237          $e_event->trigger("dldelete", $del_id);
 238      }
 239      unset($sub_action, $id);
 240  }
 241  
 242  
 243  if (isset($message)) {
 244      $ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
 245  }
 246  
 247  if (!e_QUERY || $action == "main") {
 248      $download->show_existing_items($action, $sub_action, $id, $from, $amount);
 249  }
 250  
 251  
 252  if ($action == "opt") {
 253      global $pref, $ns;
 254      $agree_flag = $pref['agree_flag'];
 255      $agree_text = $pref['agree_text'];
 256      $text = "<div style='text-align:center'>
 257          <form method='post' action='".e_SELF."?".e_QUERY."'>\n
 258          <table style='".ADMIN_WIDTH."' class='fborder'>
 259          <tr>
 260          <td style='width:70%' class='forumheader3'>".DOWLAN_69."</td>
 261          <td class='forumheader3' style='width:30%;text-align:left'>";
 262      $c = $pref['download_php'] ? " checked = 'checked' " : "";
 263      $text .= "<input type='checkbox' name='download_php' value='1' {$c} /> <span class='smalltext'>".DOWLAN_70."</span></td>
 264          </tr>
 265          <tr>
 266          <td style='width:70%' class='forumheader3'>
 267          ".DOWLAN_55."
 268          </td>
 269          <td class='forumheader3' style='width:30%;text-align:left'>
 270          <select name='download_view' class='tbox'>". ($pref['download_view'] == 5 ? "<option selected='selected'>5</option>" : "<option>5</option>"). ($pref['download_view'] == 10 ? "<option selected='selected'>10</option>" : "<option>10</option>"). ($pref['download_view'] == 15 ? "<option selected='selected'>15</option>" : "<option>15</option>"). ($pref['download_view'] == 20 ? "<option selected='selected'>20</option>" : "<option>20</option>"). ($pref['download_view'] == 50 ? "<option selected='selected'>50</option>" : "<option>50</option>")."
 271          </select>
 272          </td>
 273          </tr>
 274  
 275          <tr><td style='width:70%' class='forumheader3'>
 276          ".DOWLAN_56."
 277          </td>
 278          <td class='forumheader3' style='width:30%;text-align:left'>
 279  
 280          <select name='download_order' class='tbox'>";
 281          $order_options = array("download_id"=>"Id No.","download_datestamp"=>LAN_DATE,"download_requested"=>ADLAN_24,"download_name"=>DOWLAN_59,"download_author"=>DOWLAN_15);
 282          foreach($order_options as $value=>$label){
 283              $select = ($pref['download_order'] == $value) ? "selected='selected'" : "";
 284              $text .= "<option value='$value' $select >$label</option>\n";
 285          }
 286  
 287          $text .= "</select>
 288          </td>
 289          </tr>
 290          <tr><td style='width:70%' class='forumheader3'>
 291          ".LAN_ORDER."
 292          </td>
 293          <td class='forumheader3' style='width:30%;text-align:left'>
 294          <select name='download_sort' class='tbox'>". ($pref['download_sort'] == "ASC" ? "<option value='ASC' selected='selected'>".DOWLAN_62."</option>" : "<option value='ASC'>".DOWLAN_62."</option>"). ($pref['download_sort'] == "DESC" ? "<option value='DESC' selected='selected'>".DOWLAN_63."</option>" : "<option value='DESC'>".DOWLAN_63."</option>")."
 295          </select>
 296          </td>
 297          </tr>
 298  
 299          <tr>
 300          <td style='width:70%' class='forumheader3'>".DOWLAN_151."</td>
 301          <td class='forumheader3' style='width:30%;text-align:left'>". r_userclass("download_reportbroken", $_POST['download_reportbroken'])."</td>
 302          </tr>
 303  
 304          <tr>
 305          <td style='width:70%' class='forumheader3'>".DOWLAN_150."</td>
 306          <td class='forumheader3' style='width:30%;text-align:left'>". ($pref['download_email'] ? "<input type='checkbox' name='download_email' value='1' checked='checked' />" : "<input type='checkbox' name='download_email' value='1' />")."</td>
 307          </tr>
 308  
 309          <tr>
 310          <td style='width:70%' class='forumheader3'>".DOWLAN_100."</td>
 311          <td class='forumheader3' style='width:30%;text-align:left'>". ($agree_flag ? "<input type='checkbox' name='agree_flag' value='1' checked='checked' />" : "<input type='checkbox' name='agree_flag' value='1' />")."</td>
 312          </tr>
 313  
 314  
 315  
 316          <tr><td style='width:70%' class='forumheader3'>
 317          ".DOWLAN_101."
 318          </td>
 319          <td class='forumheader3' style='width:30%;text-align:left'>
 320          <textarea class='tbox' name='agree_text' cols='59' rows='3'>$agree_text</textarea>
 321          </td>
 322          </tr>
 323  
 324          <tr><td style='width:70%' class='forumheader3'>
 325          ".DOWLAN_146."
 326          </td>
 327          <td class='forumheader3' style='width:30%;text-align:left'>
 328          <textarea class='tbox' name='download_denied' cols='59' rows='3'>".$pref['download_denied']."</textarea>
 329          </td>
 330          </tr>
 331  
 332          <tr style='vertical-align:top'>
 333          <td colspan='2'  style='text-align:center' class='forumheader'>
 334          <input class='button' type='submit' name='updateoptions' value='".DOWLAN_64."' />
 335          </td>
 336          </tr>
 337  
 338          </table>
 339          </form>
 340          </div>";
 341      $ns->tablerender(DOWLAN_54, $text);
 342  }
 343  
 344  if($action == 'limits')
 345  {
 346      if($sql->db_Select('userclass_classes','userclass_id, userclass_name'))
 347      {
 348          $classList = $sql->db_getList();
 349      }
 350      if($sql->db_Select("generic", "gen_id as limit_id, gen_datestamp as limit_classnum, gen_user_id as limit_bw_num, gen_ip as limit_bw_days, gen_intdata as limit_count_num, gen_chardata as limit_count_days", "gen_type = 'download_limit'"))
 351      {
 352          while($row = $sql->db_Fetch())
 353          {
 354              $limitList[$row['limit_classnum']] = $row;
 355          }
 356      }
 357      $txt = "
 358          <form method='post' action='".e_SELF."?".e_QUERY."'>
 359          <table class='fborder' style='width:100%'>
 360          <tr>
 361              <td colspan='4' class='forumheader3' style='text-align:left'>
 362          ";
 363          if($pref['download_limits'] == 1)
 364          {
 365              $chk = "checked = 'checked'";
 366          }
 367          else
 368          {
 369              $chk = "";
 370          }
 371  
 372          $txt .= "
 373              <input type='checkbox' name='download_limits' {$chk} /> ".DOWLAN_125."
 374              </td>
 375          </tr>
 376          <tr>
 377              <td class='fcaption'>".DOWLAN_67."</td>
 378              <td class='fcaption'>".DOWLAN_113."</td>
 379              <td class='fcaption'>".DOWLAN_107."</td>
 380              <td class='fcaption'>".DOWLAN_108."</td>
 381          </tr>
 382      ";
 383  
 384      foreach($limitList as $row)
 385      {
 386          $txt .= "
 387          <tr>
 388          <td class='forumheader3'>".$row['limit_id']."</td>
 389          <td class='forumheader3'>".r_userclass_name($row['limit_classnum'])."</td>
 390          <td class='forumheader3'>
 391              <input type='text' class='tbox' size='5' name='count_num[{$row['limit_id']}]' value='".($row['limit_count_num'] ? $row['limit_count_num'] : "")."' /> ".DOWLAN_109."
 392              <input type='text' class='tbox' size='5' name='count_days[{$row['limit_id']}]' value='".($row['limit_count_days'] ? $row['limit_count_days'] : "")."' /> ".DOWLAN_110."
 393          </td>
 394          <td class='forumheader3'>
 395              <input type='text' class='tbox' size='5' name='bw_num[{$row['limit_id']}]' value='".($row['limit_bw_num'] ? $row['limit_bw_num'] : "")."' /> ".DOWLAN_111." ".DOWLAN_109."
 396              <input type='text' class='tbox' size='5' name='bw_days[{$row['limit_id']}]' value='".($row['limit_bw_days'] ? $row['limit_bw_days'] : "")."' /> ".DOWLAN_110."
 397          </td>
 398          </tr>
 399          ";
 400      }
 401  
 402      $txt .= "
 403      <tr>
 404      <td class='forumheader' colspan='4' style='text-align:center'>
 405      <input type='submit' class='button' name='updatelimits' value='".DOWLAN_115."' />
 406      </td>
 407      </tr>
 408      <tr>
 409      <td colspan='4'><br /><br /></td>
 410      </tr>
 411      <tr>
 412      <td colspan='2' class='forumheader3'>".r_userclass("newlimit_class", 0, "off", "guest, member, admin, classes, language")."</td>
 413      <td class='forumheader3'>
 414          <input type='text' class='tbox' size='5' name='new_count_num' value='' /> ".DOWLAN_109."
 415          <input type='text' class='tbox' size='5' name='new_count_days' value='' /> ".DOWLAN_110."
 416      </td>
 417      <td class='forumheader3'>
 418          <input type='text' class='tbox' size='5' name='new_bw_num' value='' /> ".DOWLAN_111." ".DOWLAN_109."
 419          <input type='text' class='tbox' size='5' name='new_bw_days' value='' /> ".DOWLAN_110."
 420      </td>
 421      </tr>
 422      <tr>
 423      <td class='forumheader' colspan='4' style='text-align:center'>
 424      <input type='submit' class='button' name='addlimit' value='".DOWLAN_114."' />
 425      </td>
 426      </tr>
 427      ";
 428  
 429      $txt .= "</table></form>";
 430  
 431      $ns->tablerender(DOWLAN_112, $txt);
 432      require_once(e_ADMIN.'footer.php');
 433      exit;
 434  }
 435  
 436  //$download->show_options($action);
 437  
 438  require_once ("footer.php");
 439  exit;
 440  
 441  class download {
 442  
 443  	function show_existing_items($action, $sub_action, $id, $from, $amount) {
 444          global $sql, $rs, $ns, $tp, $mySQLdefaultdb,$pref;
 445          $text = "<div style='text-align:center'><div style='padding : 1px; ".ADMIN_WIDTH."; margin-left: auto; margin-right: auto;'>";
 446          $sortorder = ($pref['download_order']) ? $pref['download_order'] : "download_datestamp";
 447          if(isset($_POST['searchdisp'])){
 448              $pref['admin_download_disp'] = implode("|",$_POST['searchdisp']);
 449              save_prefs();
 450          }
 451  
 452          if(!$pref['admin_download_disp']){
 453              $search_display = array("download_name","download_class");
 454          }else{
 455              $search_display = explode("|",$pref['admin_download_disp']);
 456          }
 457  
 458           $query = "SELECT d.*, dc.* FROM #download AS d    LEFT JOIN #download_category AS dc ON dc. download_category_id  = d.download_category";
 459  
 460          if (isset($_POST['searchquery']) && $_POST['searchquery'] != "") {
 461              $query .= " WHERE  download_url REGEXP('".$_POST['searchquery']."') OR download_author REGEXP('".$_POST['searchquery']."') OR download_description  REGEXP('".$_POST['searchquery']."') ";
 462              foreach($search_display as $disp){
 463                    $query .= " OR $disp REGEXP('".$_POST['searchquery']."') ";
 464              }
 465              $query .= " ORDER BY ".$sortorder." DESC";
 466          } else {
 467              $query .= " ORDER BY ".($sub_action ? $sub_action : $sortorder)." ".($id ? $id : "DESC")."  LIMIT $from, $amount";
 468          }
 469  
 470            if ($sql->db_Select_gen($query)) {
 471              $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform")."
 472                  <table class='fborder' style='width:99%'>
 473                  <tr>
 474                  <td style='width:5%' class='fcaption'>ID</td>
 475                  ";
 476  
 477  // Search Display Column header.----------
 478              foreach($search_display as $disp){
 479                  if($disp == "download_name"){
 480                      $text .= "<td class='fcaption'><a href='".e_SELF."?main.download_name.".($id == "desc" ? "asc" : "desc").".$from'>".DOWLAN_27."</a></td>";
 481                  }else{
 482                      $repl = array("download_","_");
 483                      $text .= "<td class='fcaption'><a href='".e_SELF."?main.$disp.".($id == "desc" ? "asc" : "desc").".$from'>".ucwords(str_replace($repl," ",$disp))."</a></td>";
 484                  }
 485              }
 486  
 487  // ------------------------------
 488              $text .="
 489                  <td style='width:10%' class='fcaption'>".LAN_OPTIONS."</td>
 490                  </tr>";
 491              while ($row = $sql->db_Fetch()) {
 492                  extract($row);
 493                  $text .= "<tr>
 494                      <td style='width:5%;vertical-align:top' class='forumheader3'>$download_id</td>";
 495  
 496  // Display Chosen options -------------------------------------
 497          $bolean_list = array("download_active","download_comment");
 498  
 499          foreach($search_display as $disp){
 500              $text .= "<td class='forumheader3' style='vertical-align:top'>";
 501  
 502              if($disp == "download_name"){
 503                  $text .= "<a href='".e_BASE."download.php?view.$download_id'>$download_name</a>";
 504              }elseif($disp == "download_category"){
 505                  $text .= $row['download_category_name']."&nbsp;";
 506              }elseif($disp == "download_datestamp"){
 507                  $text .= ($row[$disp]) ? strftime($pref['shortdate'],$row[$disp])."&nbsp;" : "&nbsp";
 508              }elseif($disp == "download_class" || $disp == "download_visible"){
 509                  $text .= r_userclass_name($row[$disp])."&nbsp;";
 510              }elseif($disp == "download_filesize"){
 511                  $text .= ($row[$disp]) ? round(($row[$disp] / 1000))." Kb&nbsp;" : "&nbsp";
 512              }elseif($disp == "download_thumb"){
 513                  $text .= ($row[$disp]) ? "<img src='".e_FILE."downloadthumbs/".$row[$disp]."' alt='' />" : "";
 514              }elseif($disp == "download_image"){
 515                  $text .= "<a rel='external' href='".e_FILE."downloadimages/".$row[$disp]."' >".$row[$disp]."</a>&nbsp;";
 516              }elseif($disp == "download_description"){
 517                  $text .= $tp->toHTML($row[$disp],TRUE)."&nbsp;";
 518              }elseif($disp == "download_active"){
 519                  if($row[$disp]== 1){ $text .= "<img src='".ADMIN_TRUE_ICON_PATH."' title='".DOWLAN_123."' alt='' style='cursor:help' />\n";     }
 520                  elseif($row[$disp]== 2){ $text .= "<img src='".ADMIN_TRUE_ICON_PATH."' title='".DOWLAN_124."' alt='' style='cursor:help' /><img src='".ADMIN_TRUE_ICON_PATH."' title='".DOWLAN_124."' alt='' style='cursor:help' />\n";     }
 521                  else{ $text .= "<img src='".ADMIN_FALSE_ICON_PATH."' title='".DOWLAN_122."' alt='' style='cursor:help' />\n";  }
 522              }elseif($disp == "download_comment"){
 523                  $text .= ($row[$disp]) ? ADMIN_TRUE_ICON : "&nbsp;";
 524              }else{
 525                  $text .= $row[$disp]."&nbsp;";
 526              }
 527  
 528              $text .= "</td>";
 529          }
 530  // -------------------------------------------------------------
 531  
 532              $text .= "
 533                      <td style='width:20%;vertical-align:top; text-align:center' class='forumheader3'>
 534                      <a href='".e_SELF."?create.edit.{$download_id}'>".ADMIN_EDIT_ICON."</a>
 535                      <input type='image' title='".LAN_DELETE."' name='delete[main_{$download_id}]' src='".ADMIN_DELETE_ICON_PATH."' onclick=\"return jsconfirm('".$tp->toJS(DOWLAN_33." [ID: $download_id ]")."') \" />
 536                      </td>
 537                      </tr>";
 538              }
 539              $text .= "</table></form>";
 540          } else {
 541              $text .= "<div style='text-align:center'>".DOWLAN_6."</div>";
 542          }
 543          $text .= "</div>";
 544  
 545  // Next-Previous. ==========================
 546  
 547          $downloads = $sql->db_Count("download");
 548          if ($downloads > $amount && !$_POST['searchquery']) {
 549              $parms = "{$downloads},{$amount},{$from},".e_SELF."?".(e_QUERY ? "$action.$sub_action.$id." : "main.download_id.desc.")."[FROM]";
 550              $text .= "<br />".$tp->parseTemplate("{NEXTPREV={$parms}}");
 551          }
 552  
 553  
 554  // Search  & display options etc. =========================.
 555  
 556          $text .= "<br /><form method='post' action='".e_SELF."'>\n<p>\n<input class='tbox' type='text' name='searchquery' size='20' value='' maxlength='50' />\n<input class='button' type='submit' name='searchsubmit' value='".DOWLAN_51."' />\n</p>";
 557  
 558          $text .= "<div style='cursor:pointer' onclick=\"expandit('sdisp')\">".LAN_DISPLAYOPT."</div>";
 559          $text .= "<div id='sdisp' style='padding-top:4px;display:none;text-align:center;margin-left:auto;margin-right:auto'>
 560          <table class='forumheader3' style='width:95%'><tr>";
 561          $fields = mysql_list_fields($mySQLdefaultdb, MPREFIX."download");
 562          $columns = mysql_num_fields($fields);
 563          for ($i = 0; $i < $columns; $i++) {
 564              $fname[] = mysql_field_name($fields, $i);
 565          }
 566          $m = 0;
 567          $replacechar = array("download_","_");
 568          foreach($fname as $fcol){
 569          $checked = (in_array($fcol,$search_display)) ? "checked='checked'" : "";
 570              $text .= "<td style='text-align:left; padding:0px'>";
 571              $text .= "<input type='checkbox' name='searchdisp[]' value='".$fcol."' $checked />".str_replace($replacechar," ",$fcol) . "</td>\n";
 572              $m++;
 573              if($m == 5){
 574                  $text .= "</tr><tr>";
 575                  $m = 0;
 576               }
 577          }
 578  
 579          $text .= "</table></div>
 580          </form>\n
 581          </div>";
 582  // ======================
 583  
 584          $ns->tablerender(DOWLAN_7, $text);
 585      }
 586  
 587  	function show_options($action) {
 588  
 589          if ($action == "") {
 590              $action = "main";
 591          }
 592          $var['main']['text'] = DOWLAN_29;
 593          $var['main']['link'] = e_SELF;
 594  
 595          $var['create']['text'] = DOWLAN_30;
 596          $var['create']['link'] = e_SELF."?create";
 597  
 598          $var['cat']['text'] = DOWLAN_31;
 599          $var['cat']['link'] = e_SELF."?cat";
 600          $var['cat']['perm'] = "Q";
 601  
 602          $var['opt']['text'] = LAN_OPTIONS;
 603          $var['opt']['link'] = e_SELF."?opt";
 604  
 605          $var['limits']['text'] = DOWLAN_112;
 606          $var['limits']['link'] = e_SELF."?limits";
 607  
 608          $var['mirror']['text'] = DOWLAN_128;
 609          $var['mirror']['link'] = e_SELF."?mirror";
 610  
 611          show_admin_menu(DOWLAN_32, $action, $var);
 612  
 613      }
 614  
 615  
 616  // ---------------------------------------------------------------------------
 617  
 618  
 619  	function create_download($sub_action, $id) {
 620  
 621  
 622          global $cal,$tp, $sql, $fl, $rs, $ns, $file_array, $image_array, $thumb_array,$pst;
 623          require_once(e_FILE."shortcode/batch/download_shortcodes.php");
 624  
 625          $download_status[0] = DOWLAN_122;
 626          $download_status[1] = DOWLAN_123;
 627          $download_status[2] = DOWLAN_124;
 628          $preset = $pst->read_preset("admin_downloads");  // read preset values into array
 629          extract($preset);
 630  
 631          if (!$sql->db_Select("download_category")) {
 632              $ns->tablerender(ADLAN_24, "<div style='text-align:center'>".DOWLAN_5."</div>");
 633              return;
 634          }
 635          $download_active = 1;
 636          if ($sub_action == "edit" && !$_POST['submit']) {
 637              if ($sql->db_Select("download", "*", "download_id='$id' ")) {
 638                  $row = $sql->db_Fetch();
 639                  extract($row);
 640  
 641                  if($download_mirror)
 642                  {
 643  
 644                      $mirrorTArray = explode(chr(1), $download_mirror);
 645                      $mirrorArray = array();
 646  
 647                      $count=0;
 648                      foreach($mirrorTArray as $mirror)
 649                      {
 650                          if($mirror)
 651                          {
 652                              list($mid, $murl) = explode(",", $mirror);
 653                              $mirrorArray[$count]['id'] = $mid;
 654                              $mirrorArray[$count]['url'] = $murl;
 655                              $count++;
 656                          }
 657                      }
 658                  }
 659              }
 660          }
 661  
 662          if ($sub_action == "dlm" && !$_POST['submit']) {
 663              if ($sql->db_Select("upload", "*", "upload_id='$id' ")) {
 664                  $row = $sql->db_Fetch();
 665  
 666                  $download_category = $row['upload_category'];
 667                  $download_name = $row['upload_name'].($row['upload_version'] ? " v" . $row['upload_version'] : "");
 668                  $download_url = $row['upload_file'];
 669                  $download_author_email = $row['upload_email'];
 670                  $download_author_website = $row['upload_website'];
 671                  $download_description = $row['upload_description'];
 672                  $download_image = $row['upload_ss'];
 673                  $download_filesize = $row['upload_filesize'];
 674                  $image_array[] = array("path" => "", "fname" => $row['upload_ss']);
 675                  $download_author = substr($row['upload_poster'], (strpos($row['upload_poster'], ".")+1));
 676              }
 677          }
 678  
 679  
 680          $text = "
 681              <div style='text-align:center'>
 682              <form method='post' action='".e_SELF."?".e_QUERY."' id='myform'>
 683              <table style='".ADMIN_WIDTH."' class='fborder'>
 684              <tr>
 685              <td style='width:20%' class='forumheader3'>".DOWLAN_11."</td>
 686              <td style='width:80%' class='forumheader3'>";
 687  
 688          $text .= $tp->parseTemplate("{DOWNLOAD_CATEGORY_SELECT={$download_category}}",true,$download_shortcodes);
 689  
 690          $text .= "</td>
 691              </tr>
 692  
 693              <tr>
 694              <td style='width:20%; vertical-align:top' class='forumheader3'><span style='text-decoration:underline'>".DOWLAN_12."</span>:</td>
 695              <td style='width:80%' class='forumheader3'>
 696              <input class='tbox' type='text' name='download_name' size='60' value=\"".$tp->toForm($download_name)."\" maxlength='200' />
 697              </td>
 698              </tr>
 699  
 700              <tr>
 701              <td style='width:20%; vertical-align:top' class='forumheader3'><span style='text-decoration:underline;cursor:help' title='".DOWLAN_127."' >".DOWLAN_13."</span>:</td>
 702              <td style='width:80%' class='forumheader3'><div style='padding-bottom:5px'>".DOWLAN_131."&nbsp;&nbsp;
 703  
 704             <select name='download_url' class='tbox'>
 705              <option value=''>&nbsp;</option>
 706              ";
 707  
 708          $counter = 0;
 709          while (isset($file_array[$counter])) {
 710              $fpath = str_replace(e_DOWNLOAD,"",$file_array[$counter]['path']).$file_array[$counter]['fname'];
 711              if (stristr($fpath, $download_url) !== FALSE) {
 712                  $selected = " selected='selected'";
 713                  $found = 1;
 714              } else {
 715                  $selected = "";
 716              }
 717  
 718              $text .= "<option value='".$fpath."' $selected>".$fpath."</option>\n";
 719              $counter++;
 720          }
 721  
 722          if (preg_match("/http:|ftp:/", $download_url)) {
 723              $download_url_external = $download_url;
 724          }
 725  
 726          $etext = " - (".DOWLAN_68.")";
 727          if (file_exists(e_FILE."public/".$download_url)) {
 728              $etext = "";
 729          }
 730  
 731          if (!$found && $download_url) {
 732              $text .= "<option value='".$download_url."' selected='selected'>".$download_url.$etext."</option>\n";
 733          }
 734  
 735          $text .= "</select></div>
 736              <span style='padding-top:6px;cursor:pointer;text-decoration:underline' onclick='expandit(this)' title='".DOWLAN_14."'>".DOWLAN_149."</span>
 737              <div id='use_ext' style='padding-top:6px;display:none'>
 738             URL:&nbsp;
 739  
 740              <input class='tbox' type='text' name='download_url_external' size='40' value='$download_url_external' maxlength='150' />
 741              &nbsp;&nbsp;&nbsp;".DOWLAN_66."
 742              <input class='tbox' type='text' name='download_filesize_external' size='8' value='$download_filesize' maxlength='10' />
 743             </div>
 744  
 745              </td>
 746              </tr>
 747  
 748              <tr>
 749              <td style='width:20%' class='forumheader3'><span title='".DOWLAN_129."' style='cursor:help'>".DOWLAN_128."</span>:</td>
 750              <td style='width:80%' class='forumheader3'>";
 751  
 752          if(!$sql -> db_Select("download_mirror"))
 753          {
 754              $text .= DOWLAN_144."</tr>";
 755          }
 756          else
 757          {
 758  
 759              $text .= DOWLAN_132."<br />
 760              <div id='mirrorsection'>";
 761  
 762              $mirrorList = $sql -> db_getList();
 763  
 764              $m_count = (count($mirrorArray) ? count($mirrorArray) : 1);
 765  
 766              for($count = 1; $count <= $m_count; $count++){
 767  
 768                  $opt = ($count==1) ? "id='mirror'" : "";
 769                  $text .="<span $opt>
 770                  <select name='download_mirror_name[]' class='tbox'>
 771                      <option value=''>&nbsp;</option>";
 772  
 773                  foreach($mirrorList as $mirror)    {
 774                      extract($mirror);
 775                      $text .= "<option value='$mirror_id'".($mirror_id == $mirrorArray[($count-1)]['id'] ? " selected='selected'" : "").">$mirror_name</option>\n";
 776                  }
 777  
 778                  $text .= "</select>
 779                  <input  class='tbox' type='text' name='download_mirror[]' style='width: 75%;' value=\"".$mirrorArray[($count-1)]['url']."\" maxlength='200' />";
 780                  $text .= "</span><br />";
 781              }
 782  
 783              $text .="</div><input class='button' type='button' name='addoption' value='".DOWLAN_130."' onclick=\"duplicateHTML('mirror','mirrorsection')\" /><br />
 784  
 785              </td>
 786              </tr>
 787  
 788              <tr>
 789              <td style='width:20%' class='forumheader3' ><span style='cursor:help' title='".DOWLAN_154."'>".DOWLAN_155."</span></td>
 790              <td style='width:80%' class='forumheader3'>
 791  
 792              <input type='radio' name='download_mirror_type' value='1'".($download_mirror_type ? " checked='checked'" : "")." /> ".DOWLAN_156."<br />
 793              <input type='radio' name='download_mirror_type' value='0'".(!$download_mirror_type ? " checked='checked'" : "")." /> ".DOWLAN_157."
 794              </td>
 795              </tr>";
 796          }
 797  
 798              $text .= "<tr>
 799              <td style='width:20%' class='forumheader3'>".DOWLAN_15.":</td>
 800              <td style='width:80%' class='forumheader3'>
 801              <input class='tbox' type='text' name='download_author' size='60' value='$download_author' maxlength='100' />
 802              </td>
 803              </tr>
 804  
 805              <tr>
 806              <td style='width:20%' class='forumheader3'>".DOWLAN_16.":</td>
 807              <td style='width:80%' class='forumheader3'>
 808              <input class='tbox' type='text' name='download_author_email' size='60' value='$download_author_email' maxlength='100' />
 809              </td>
 810              </tr>
 811  
 812              <tr>
 813              <td style='width:20%' class='forumheader3'>".DOWLAN_17.":</td>
 814              <td style='width:80%' class='forumheader3'>
 815              <input class='tbox' type='text' name='download_author_website' size='60' value='$download_author_website' maxlength='100' />
 816              </td>
 817              </tr>
 818  
 819              <tr>
 820              <td style='width:20%' class='forumheader3'><span style='text-decoration:underline'>".DOWLAN_18."</span>: </td>
 821              <td style='width:80%' class='forumheader3'>
 822              <textarea class='tbox' name='download_description' cols='50' rows='5' style='width:90%'>$download_description</textarea>
 823              </td>
 824              </tr>
 825  
 826              <tr>
 827              <td style='width:20%' class='forumheader3'>".DOWLAN_19.":</td>
 828              <td style='width:80%' class='forumheader3'>
 829              <select name='download_image' class='tbox'>
 830              <option value=''>&nbsp;</option>";
 831  
 832              foreach($image_array as $img)
 833              {
 834                  $fpath = str_replace(e_FILE."downloadimages/","",$img['path'].$img['fname']);
 835                  $sel = ($download_image == $fpath) ? " selected='selected'" : "";
 836                  $text .= "<option value='".$fpath."' $sel>".$fpath."</option>\n";
 837              }
 838  
 839          $text .= "
 840              </select>";
 841  
 842              if($sub_action == "dlm" && $download_image)
 843              {
 844                  $text .= "
 845                  <input type='hidden' name='move_image' value='1' />\n";
 846              }
 847  
 848          $text .= "
 849              </td>
 850              </tr>
 851  
 852              <tr>
 853              <td style='width:20%' class='forumheader3'>".DOWLAN_20.":</td>
 854              <td style='width:80%' class='forumheader3'>
 855              <select name='download_thumb' class='tbox'>
 856              <option value=''>&nbsp;</option>
 857              ";
 858  
 859              foreach($thumb_array as $thm){
 860                  $tpath = str_replace(e_FILE."downloadthumbs/","",$thm['path'].$thm['fname']);
 861                  $sel = ($download_thumb == $tpath) ? " selected='selected'" : "";
 862                  $text .= "<option value='".$tpath."' $sel>".$tpath."</option>\n";
 863              }
 864  
 865          $text .= "</select>
 866              </td>
 867              </tr>
 868  
 869  
 870          <tr>
 871          <td style='width:20%' class='forumheader3'>".LAN_DATESTAMP.":</td>
 872          <td style='width:80%' class='forumheader3'>
 873          ";
 874          if(!$download_datestamp){
 875              $download_datestamp = time();
 876             }
 877          $cal_options['firstDay'] = 0;
 878          $cal_options['showsTime'] = false;
 879          $cal_options['showOthers'] = false;
 880          $cal_options['weekNumbers'] = false;
 881          $cal_options['ifFormat'] = "%d/%m/%Y %H:%M:%S";
 882          $cal_options['timeFormat'] = "24";
 883          $cal_attrib['class'] = "tbox";
 884          $cal_attrib['size'] = "12";
 885          $cal_attrib['name'] = "download_datestamp";
 886          $cal_attrib['value'] = date("d/m/Y H:i:s", $download_datestamp);
 887          $text .= $cal->make_input_field($cal_options, $cal_attrib);
 888  
 889          $update_checked = ($_POST['update_datestamp']) ? "checked='checked'" : "";
 890          $text .= "&nbsp;&nbsp;<span><input type='checkbox' value='1' name='update_datestamp' $update_checked />".DOWLAN_148."
 891          </span>
 892          </td>
 893          </tr>
 894  
 895  
 896  
 897              <tr>
 898              <td style='width:20%' class='forumheader3'>".DOWLAN_21.":</td>
 899              <td style='width:80%' class='forumheader3'>
 900              <select name='download_active' class='tbox'>
 901              ";
 902  
 903              foreach($download_status as $key => $val){
 904                  $sel = ($download_active == $key) ? " selected = 'selected' " : "";
 905                  $text .= "<option value='{$key}' {$sel}>{$val}</option>\n";
 906              }
 907              $text .= "</select>";
 908  
 909          $text .= "</td>
 910              </tr>
 911  
 912  
 913              <tr>
 914              <td style='width:20%' class='forumheader3'>".DOWLAN_102.":</td>
 915              <td style='width:80%' class='forumheader3'>";
 916  
 917  
 918          if ($download_comment == "0") {
 919              $text .= LAN_YES.": <input type='radio' name='download_comment' value='1' />
 920                  ".LAN_NO.": <input type='radio' name='download_comment' value='0' checked='checked' />";
 921          } else {
 922              $text .= LAN_YES.": <input type='radio' name='download_comment' value='1' checked='checked' />
 923                  ".LAN_NO.": <input type='radio' name='download_comment' value='0' />";
 924          }
 925  
 926          $text .= "</td>
 927              </tr>";
 928  
 929  
 930          $text .= "
 931              <tr>
 932              <td style='width:20%' class='forumheader3'>".DOWLAN_145.":</td>
 933              <td style='width:80%' class='forumheader3'>".r_userclass('download_visible', $download_visible, 'off', 'public, nobody, member, admin, classes, language')."</td>
 934              </tr>
 935  
 936  
 937              <tr>
 938              <td style='width:20%' class='forumheader3'>".DOWLAN_106.":</td>
 939              <td style='width:80%' class='forumheader3'>".r_userclass('download_class', $download_class, 'off', 'public, nobody, member, admin, classes, language')."</td>
 940              </tr>
 941              ";
 942  
 943          if ($sub_action == "dlm") {
 944              $text .= "
 945  
 946              <tr>
 947                  <td style='width:30%' class='forumheader3'>".DOWLAN_153.":<br /></td>
 948                  <td style='width:70%' class='forumheader3'>
 949                  <select name='move_file' class='tbox'>
 950                  <option value=''>".LAN_NO."</option>
 951                  ";
 952  
 953                  $dl_dirlist = $fl->get_dirs(e_DOWNLOAD);
 954                     if($dl_dirlist){
 955                      sort($dl_dirlist);
 956                      $text .= "<option value='".e_DOWNLOAD."'>/</option>\n";
 957                      foreach($dl_dirlist as $dirs)
 958                      {
 959                          $text .= "\t\t\t\t<option value='". e_DOWNLOAD.$dirs."/'>".$dirs."/</option>\n";
 960                      }
 961                  }
 962                  else
 963                  {
 964                      $text .= "\t\t\t\t<option value='".e_DOWNLOAD."'>".LAN_YES."</option>\n";
 965                  }
 966  
 967              $text .= "</select>
 968                  </td>
 969              </tr>
 970  
 971  
 972              <tr>
 973                  <td style='width:30%' class='forumheader3'>".DOWLAN_103.":<br /></td>
 974                  <td style='width:70%' class='forumheader3'>
 975                  <input type='checkbox' name='remove_upload' value='1' />
 976                  <input type='hidden' name='remove_id' value='$id' />
 977                  </td>
 978              </tr>
 979              ";
 980          }
 981  
 982          $text .= "
 983              <tr style='vertical-align:top'>
 984              <td colspan='2' style='text-align:center' class='forumheader'>";
 985  
 986  
 987          if ($id && $sub_action == "edit") {
 988              $text .= "<input class='button' type='submit' name='submit_download' value='".DOWLAN_24."' /> ";
 989          } else {
 990              $text .= "<input class='button' type='submit' name='submit_download' value='".DOWLAN_25."' />";
 991          }
 992  
 993          $text .= "</td>
 994              </tr>
 995              </table>
 996              </form>
 997              </div>";
 998          $ns->tablerender(ADLAN_24, $text);
 999      }
1000  
1001  
1002  // -----------------------------------------------------------------------------
1003  
1004  
1005  	function show_message($message) {
1006          global $ns;
1007          $ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
1008      }
1009  
1010  
1011  // -----------------------------------------------------------------------------
1012  
1013  
1014  
1015  	function submit_download($sub_action, $id) {
1016          global $tp, $sql, $DOWNLOADS_DIRECTORY, $e_event;
1017  
1018          if($sub_action == 'edit')
1019          {
1020              if($_POST['download_url_external'] == '')
1021              {
1022                  $_POST['download_filesize_external'] = FALSE;
1023              }
1024          }
1025  
1026          if ($_POST['download_url_external'] && $_POST['download_url'] == '')
1027          {
1028              $durl = $_POST['download_url_external'];
1029              $filesize = $_POST['download_filesize_external'];
1030          }
1031          else
1032          {
1033              $durl = $_POST['download_url'];
1034              if($_POST['download_filesize_external'])
1035              {
1036                  $filesize = $_POST['download_filesize_external'];
1037              }
1038              else
1039              {
1040                  if (strpos($DOWNLOADS_DIRECTORY, "/") === 0 || strpos($DOWNLOADS_DIRECTORY, ":") >= 1)
1041                  {
1042                      $filesize = filesize($DOWNLOADS_DIRECTORY.$durl);
1043                  }
1044                  else
1045                  {
1046                      $filesize = filesize(e_BASE.$DOWNLOADS_DIRECTORY.$durl);
1047                  }
1048              }
1049          }
1050  
1051          if (!$filesize)
1052          {
1053              if($sql->db_Select("upload", "upload_filesize", "upload_file='$durl'"))
1054              {
1055                  $row = $sql->db_Fetch();
1056                  $filesize = $row['upload_filesize'];
1057              }
1058          }
1059  
1060          //  ----   Move Images and Files ------------
1061  
1062          if($_POST['move_image'])
1063          {
1064              if($_POST['download_thumb'])
1065              {
1066                  $oldname = e_FILE."public/".$_POST['download_thumb'];
1067                  $newname = e_FILE."downloadthumbs/".$_POST['download_thumb'];
1068                  if(!$this -> move_file($oldname,$newname))
1069                  {
1070                      return;
1071                  }
1072              }
1073              if($_POST['download_image'])
1074              {
1075                  $oldname = e_FILE."public/".$_POST['download_image'];
1076                  $newname = e_FILE."downloadimages/".$_POST['download_image'];
1077                  if(!$this -> move_file($oldname,$newname))
1078                  {
1079                      return;
1080                  }
1081              }
1082          }
1083  
1084          if($_POST['move_file'] && $_POST['download_url'])
1085          {
1086              $oldname = e_FILE."public/".$_POST['download_url'];
1087              $newname = $_POST['move_file'].$_POST['download_url'];
1088              if(!$this -> move_file($oldname,$newname))
1089              {
1090                  return;
1091              }
1092              $durl = str_replace(e_DOWNLOAD,"",$newname);
1093          }
1094  
1095  
1096         // ------------------------------------------
1097  
1098  
1099          $_POST['download_description'] = $tp->toDB($_POST['download_description']);
1100          $_POST['download_name'] = $tp->toDB($_POST['download_name']);
1101          $_POST['download_author'] = $tp->toDB($_POST['download_author']);
1102  
1103          if (preg_match("#(.*?)/(.*?)/(.*?) (.*?):(.*?):(.*?)$#", $_POST['download_datestamp'], $matches)){
1104              $_POST['download_datestamp'] = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]);
1105          }else{
1106             $_POST['download_datestamp'] = time();
1107          }
1108  
1109          if($_POST['update_datestamp']){    $_POST['download_datestamp'] = time();    }
1110  
1111          $mirrorStr = "";
1112          $mirrorReq = "";
1113  
1114          if($_POST['download_mirror_name'][0])
1115          {
1116              $mirrors = count($_POST['download_mirror_name']);
1117              for($a=0; $a<$mirrors; $a++)
1118              {
1119                  $mirror_id = $_POST['download_mirror_name'][$a];
1120                  $mirror_url = $_POST['download_mirror'][$a];
1121                  $mirrorStr .= $mirror_id.",".$mirror_url.",0".chr(1);
1122              }
1123          }
1124  
1125          if ($id)
1126          {
1127              admin_update($sql->db_Update("download", "download_name='".$_POST['download_name']."', download_url='".$durl."', download_author='".$_POST['download_author']."', download_author_email='".$_POST['download_author_email']."', download_author_website='".$_POST['download_author_website']."', download_description='".$_POST['download_description']."', download_filesize='".$filesize."', download_category='".intval($_POST['download_category'])."', download_active='".intval($_POST['download_active'])."', download_datestamp='".intval($_POST['download_datestamp'])."', download_thumb='".$_POST['download_thumb']."', download_image='".$_POST['download_image']."', download_comment='".intval($_POST['download_comment'])."', download_class = '{$_POST['download_class']}', download_mirror='$mirrorStr', download_mirror_type='".intval($_POST['download_mirror_type'])."' , download_visible='".$_POST['download_visible']."' WHERE download_id=".intval($id)), 'update', DOWLAN_2." (<a href='".e_BASE."download.php?view.".$id."'>".$_POST['download_name']."</a>)");
1128              $dlinfo = array("download_id" => $download_id, "download_name" => $_POST['download_name'], "download_url" => $durl, "download_author" => $_POST['download_author'], "download_author_email" => $_POST['download_author_email'], "download_author_website" => $_POST['download_author_website'], "download_description" => $_POST['download_description'], "download_filesize" => $filesize, "download_category" => $_POST['download_category'], "download_active" => $_POST['download_active'], "download_datestamp" => $time, "download_thumb" => $_POST['download_thumb'], "download_image" => $_POST['download_image'], "download_comment" => $_POST['download_comment'] );
1129              $e_event->trigger("dlupdate", $dlinfo);
1130          } else {
1131              if (admin_update($download_id = $sql->db_Insert("download", "0, '".$_POST['download_name']."', '".$durl."', '".$_POST['download_author']."', '".$_POST['download_author_email']."', '".$_POST['download_author_website']."', '".$_POST['download_description']."', '".$filesize."', '0', '".intval($_POST['download_category'])."', '".intval($_POST['download_active'])."', '".intval($_POST['download_datestamp'])."', '".$_POST['download_thumb']."', '".$_POST['download_image']."', '".intval($_POST['download_comment'])."', '{$_POST['download_class']}', '$mirrorStr', '".intval($_POST['download_mirror_type'])."', '".$_POST['download_visible']."' "), 'insert', DOWLAN_1." (<a href='".e_BASE."download.php?view.".$download_id."'>".$_POST['download_name']."</a>)")) {
1132                  $dlinfo = array("download_id" => $download_id, "download_name" => $_POST['download_name'], "download_url" => $durl, "download_author" => $_POST['download_author'], "download_author_email" => $_POST['download_author_email'], "download_author_website" => $_POST['download_author_website'], "download_description" => $_POST['download_description'], "download_filesize" => $filesize, "download_category" => $_POST['download_category'], "download_active" => $_POST['download_active'], "download_datestamp" => $time, "download_thumb" => $_POST['download_thumb'], "download_image" => $_POST['download_image'], "download_comment" => $_POST['download_comment'] );
1133                  $e_event->trigger("dlpost", $dlinfo);
1134  
1135                  if ($_POST['remove_upload']) {
1136                      $sql->db_Update("upload", "upload_active='1' WHERE upload_id='".$_POST['remove_id']."'");
1137                      $mes = "<br />".$_POST['download_name']." ".DOWLAN_104;
1138                      $mes .= "<br /><br /><a href='".e_ADMIN."upload.php'>".DOWLAN_105."</a>";
1139                      $this->show_message($mes);
1140                  }
1141              }
1142          }
1143      }
1144  
1145  
1146  // -----------------------------------------------------------------------------
1147  
1148  	function show_categories($sub_action, $id)
1149      {
1150          global $sql, $rs, $ns, $tp, $pst;
1151  
1152          if (!is_object($sql2)) {
1153              $sql2 = new db;
1154          }
1155          $text = $rs->form_open("post", e_SELF."?".e_QUERY, "myform");
1156          $text .= "<div style='padding : 1px; ".ADMIN_WIDTH."; height : 200px; overflow : auto; margin-left: auto; margin-right: auto;'>";
1157  
1158          $qry = "
1159          SELECT dc.*, COUNT(d.download_id) AS filecount FROM #download_category AS dc
1160          LEFT JOIN #download AS d ON d.download_category = dc.download_category_id
1161          GROUP BY dc.download_category_id
1162          ORDER BY dc.download_category_order
1163          ";
1164          if($sql->db_Select_gen($qry))
1165          {
1166              $categories = $sql->db_getList();
1167              foreach($categories as $cat)
1168              {
1169                  $cat_array[$cat['download_category_parent']][] = $cat;
1170              }
1171  
1172              $text .= "
1173              <table class='fborder' style='width:99%'>
1174                  <tr>
1175                  <td style='width:5%; text-align:center' class='fcaption'>&nbsp;</td>
1176                  <td style='width:70%; text-align:center' class='fcaption'>".DOWLAN_11."</td>
1177                  <td style='width:5%; text-align:center' class='fcaption'>".DOWLAN_52."</td>
1178                  <td style='width:5%; text-align:center' class='fcaption'>".LAN_ORDER."</td>
1179                  <td style='width:20%; text-align:center' class='fcaption'>".LAN_OPTIONS."</td>
1180                  </tr>";
1181  
1182  
1183              //Start displaying parent categories
1184              foreach($cat_array[0] as $parent)
1185              {
1186                  if(strstr($parent['download_category_icon'], chr(1)))
1187                  {
1188                      list($parent['download_category_icon'], $parent['download_category_icon_empty']) = explode(chr(1), $parent['download_category_icon']);
1189                  }
1190  
1191                  $text .= "<tr>
1192                      <td style='width:5%; text-align:center' class='forumheader'>".($parent['download_category_icon'] ? "<img src='".e_IMAGE."icons/{$parent['download_category_icon']}' style='vertical-align:middle; border:0' alt='' />" : "&nbsp;")."</td>
1193                      <td colspan='2' style='width:70%' class='forumheader'><b>{$parent['download_category_name']}</b></td>
1194                      <td class='forumheader3'>
1195                       <input class='tbox' type='text' name='catorder[{$parent['download_category_id']}]' value='{$parent['download_category_order']}' size='3' />
1196                      </td>
1197                      <td style='text-align:left;padding-left:12px' class='forumheader'>
1198                      <a href='".e_SELF."?cat.edit.{$parent['download_category_id']}'>".ADMIN_EDIT_ICON."</a>
1199                      ";
1200                      if(!is_array($cat_array[$parent['download_category_id']]))
1201                      {
1202                          $text .= "<input type='image' title='".LAN_DELETE."' name='delete[category_{$parent['download_category_id']}]' src='".ADMIN_DELETE_ICON_PATH."' onclick=\"return jsconfirm('".$tp->toJS(DOWLAN_34." [ID: {$parent['download_category_id']} ]")."') \"/>";
1203                      }
1204                  $text .= "
1205                      </td>
1206                      </tr>
1207                      ";
1208  
1209                  //Show main categories
1210  
1211                  if(is_array($cat_array[$parent['download_category_id']]))
1212                  {
1213                      foreach($cat_array[$parent['download_category_id']] as $main)
1214                      {
1215  
1216                          if(strstr($main['download_category_icon'], chr(1)))
1217                          {
1218                              list($main['download_category_icon'], $main['download_category_icon_empty']) = explode(chr(1), $main['download_category_icon']);
1219                          }
1220                          $text .= "<tr>
1221                          <td style='width:5%; text-align:center' class='forumheader3'>".($main['download_category_icon'] ? "<img src='".e_IMAGE."icons/{$main['download_category_icon']}' style='vertical-align:middle; border:0' alt='' />" : "&nbsp;")."</td>
1222                          <td style='width:70%' class='forumheader3'>{$main['download_category_name']}<br /><span class='smalltext'>{$main['download_category_description']}</span></td>
1223                          <td style='width:5%; text-align:center' class='forumheader3'>{$main['filecount']}</td>
1224                          <td class='forumheader3'>
1225                              <input class='tbox' type='text' name='catorder[{$main['download_category_id']}]' value='{$main['download_category_order']}' size='3' />
1226                          </td>
1227                          <td style='width:20%; text-align:left;padding-left:12px' class='forumheader3'>
1228                          <a href='".e_SELF."?cat.edit.{$main['download_category_id']}'>".ADMIN_EDIT_ICON."</a>";
1229                          if(!is_array($cat_array[$main['download_category_id']]) && !$main['filecount'])
1230                          {
1231                              $text .= "<input type='image' title='".LAN_DELETE."' name='delete[category_{$main['download_category_id']}]' src='".ADMIN_DELETE_ICON_PATH."' onclick=\"return jsconfirm('".$tp->toJS(DOWLAN_34." [ID: {$main['download_category_id']} ]")."') \"/>";
1232                          }
1233                          $text .= "
1234                          </td>
1235                          </tr>";
1236  
1237                          //Show sub categories
1238                          if(is_array($cat_array[$main['download_category_id']]))
1239                          {
1240                              foreach($cat_array[$main['download_category_id']] as $sub)
1241                              {
1242  
1243                                  if(strstr($sub['download_category_icon'], chr(1)))
1244                                  {
1245                                      list($sub['download_category_icon'], $sub['download_category_icon_empty']) = explode(chr(1), $sub['download_category_icon']);
1246                                  }
1247                                  $text .= "<tr>
1248                                      <td style='width:5%; text-align:center' class='forumheader3'>".($sub['download_category_icon'] ? "<img src='".e_IMAGE."icons/{$sub['download_category_icon']}' style='vertical-align:middle; border:0' alt='' />" : "&nbsp;")."</td>
1249                                      <td style='width:70%' class='forumheader3'>&nbsp;&nbsp;&nbsp;&nbsp;".DOWLAN_53.": {$sub['download_category_name']}<br />&nbsp;&nbsp;&nbsp;&nbsp;<span class='smalltext'>{$sub['download_category_description']}</span></td>
1250                                      <td style='width:5%; text-align:center' class='forumheader3'>{$sub['filecount']}</td>
1251                                      <td class='forumheader3'>
1252                                          <input class='tbox' type='text' name='catorder[{$sub['download_category_id']}]' value='{$sub['download_category_order']}' size='3' />
1253                                      </td>
1254                                      <td style='width:20%; text-align:left;padding-left:12px' class='forumheader3'>
1255                                      <a href='".e_SELF."?cat.edit.{$sub['download_category_id']}'>".ADMIN_EDIT_ICON."</a>
1256                                      ";
1257                                      if(!$sub['filecount'])
1258                                      {
1259                                          $text .= "<input type='image' title='".LAN_DELETE."' name='delete[category_{$sub['download_category_id']}]' src='".ADMIN_DELETE_ICON_PATH."' onclick=\"return jsconfirm('".$tp->toJS(DOWLAN_34." [ID: {$sub['download_category_id']} ]")."') \"/>";
1260                                      }
1261                                  $text .= "
1262                                      </td>
1263                                      </tr>";
1264                              }
1265                          }
1266                      }
1267                  }
1268  
1269              }
1270  
1271              $text .= "</table></div>";
1272              $text .= "<div style='text-align:center'>
1273                  <input class='button' type='submit' name='update_catorder' value='".LAN_UPDATE."' />
1274                  </div>";
1275          }
1276          else
1277          {
1278              $text .= "<div style='text-align:center'>".DOWLAN_38."</div>";
1279          }
1280          $text .= "</form>";
1281          $ns->tablerender(DOWLAN_37, $text);
1282  
1283          unset($download_category_id, $download_category_name, $download_category_description, $download_category_parent, $download_category_icon, $download_category_class);
1284  
1285          $handle = opendir(e_IMAGE."icons");
1286          while ($file = readdir($handle)) {
1287              if ($file != "." && $file != ".." && $file != "/" && $file != "CVS") {
1288                  $iconlist[] = $file;
1289              }
1290          }
1291          closedir($handle);
1292  
1293          if ($sub_action == "edit" && !$_POST['add_category']) {
1294              if ($sql->db_Select("download_category", "*", "download_category_id=$id")) {
1295                  $row = $sql->db_Fetch();
1296                   extract($row);
1297                  $main_category_parent = $download_category_parent;
1298                  if(strstr($download_category_icon, chr(1)))
1299                  {
1300                      list($download_category_icon, $download_category_icon_empty) = explode(chr(1), $download_category_icon);
1301                  }
1302                  else
1303                  {
1304                      $download_category_icon_empty = "";
1305                  }
1306              }
1307          }
1308  
1309          $preset = $pst->read_preset("admin_dl_cat");  // read preset values into array
1310          extract($preset);
1311  
1312          $frm_action = (isset($_POST['add_category'])) ? e_SELF."?cat" : e_SELF."?".e_QUERY;
1313          $text = "<div style='text-align:center'>
1314              <form method='post' action='{$frm_action}' id='dlform'>
1315              <table style='".ADMIN_WIDTH."' class='fborder'>
1316              <tr>
1317              <td style='width:30%' class='forumheader3'>".DOWLAN_37.": </td>
1318              <td style='width:70%' class='forumheader3'>";
1319  
1320          if (!$download_cats = $sql->db_Select("download_category")) {
1321              $text .= "
1322                  <select name='download_category_parent' class='tbox'>
1323                  <option>".DOWLAN_40."</option>
1324                  </select>\n";
1325          } else {
1326              $text .= "
1327                  <select name='download_category_parent' class='tbox'>
1328                  <option>".DOWLAN_40."</option>";
1329  
1330              while (list($cat_id, $cat_name, $null, $null, $cat_parent) = $sql->db_Fetch()) {
1331                  $sql2->db_Select("download_category", "download_category_parent", "download_category_id='$cat_parent'", TRUE);
1332                  $row = $sql2->db_Fetch();
1333                   extract($row);
1334                  if (!$download_category_parent || !$cat_parent) {
1335                      $text .= ($main_category_parent == $cat_id ? "<option value='$cat_id' selected='selected'>".$cat_name."</option>" : "<option value='$cat_id'>".$cat_name."</option>");
1336                  }
1337              }
1338              $text .= "</select>";
1339          }
1340          $text .= "</td></tr><tr>
1341              <td style='width:30%' class='forumheader3'>".DOWLAN_12.": </td>
1342              <td style='width:70%' class='forumheader3'>
1343              <input class='tbox' type='text' name='download_category_name' size='40' value='$download_category_name' maxlength='100' />
1344              </td>
1345              </tr>
1346  
1347              <tr>
1348              <td style='width:30%' class='forumheader3'>".DOWLAN_18.": </td>
1349              <td style='width:70%' class='forumheader3'>
1350              <textarea class='tbox' name='download_category_description' cols='59' rows='3'>$download_category_description</textarea>
1351              </td>
1352              </tr>
1353  
1354              <tr>
1355              <td style='width:30%' class='forumheader3'>".DOWLAN_41.": </td>
1356              <td style='width:70%' class='forumheader3'>
1357              <input class='tbox' type='text' id='download_category_icon' name='download_category_icon' size='60' value='$download_category_icon' maxlength='100' />
1358  
1359              <br />
1360              <input class='button' type ='button' style='cursor:hand' size='30' value='".DOWLAN_42."' onclick='expandit(this)' />
1361              <div id='cat_icn' style='display:none;{head}' >";
1362  
1363          while (list($key, $icon) = each($iconlist)) {
1364              $text .= "<a href=\"javascript:insertext('$icon','download_category_icon','cat_icn')\"><img src='".e_IMAGE."icons/".$icon."' style='border:0' alt='' /></a> ";
1365          }
1366  
1367          reset($iconlist);
1368  
1369          $text .= "
1370              </div></td>
1371              </tr>
1372  
1373              <tr>
1374              <td style='width:30%' class='forumheader3'>".DOWLAN_147.": </td>
1375              <td style='width:70%' class='forumheader3'>
1376              <input class='tbox' type='text' id='download_category_icon_empty' name='download_category_icon_empty' size='60' value='$download_category_icon_empty' maxlength='100' />
1377  
1378              <br />
1379              <input class='button' type ='button' style='cursor:hand' size='30' value='".DOWLAN_42."' onclick='expandit(this)' />
1380              <div id='cat_icn_empty' style='display:none;{head}' >";
1381  
1382          while (list($key, $icon) = each($iconlist)) {
1383              $text .= "<a href=\"javascript:insertext('$icon','download_category_icon_empty','cat_icn_empty')\"><img src='".e_IMAGE."icons/".$icon."' style='border:0' alt='' /></a> ";
1384          }
1385  
1386          $text .= "
1387              </div></td>
1388              </tr>
1389  
1390  
1391  
1392              <tr>
1393              <td style='width:30%' class='forumheader3'>".DOWLAN_43.":<br /><span class='smalltext'>(".DOWLAN_44.")</span></td>
1394              <td style='width:70%' class='forumheader3'>".r_userclass("download_category_class", $download_category_class, 'off', 'public, nobody, member, admin, classes, language')."
1395  
1396              </td></tr>";
1397  
1398  
1399          $text .= "
1400              <tr style='vertical-align:top'>
1401              <td colspan='2' style='text-align:center' class='forumheader'>";
1402          if ($id && $sub_action == "edit" && !isset($_POST['add_category'])) {
1403              $text .= "<input class='button' type='submit' name='add_category' value='".DOWLAN_46."' /> ";
1404          } else {
1405              $text .= "<input class='button' type='submit' name='add_category' value='".DOWLAN_45."' />";
1406          }
1407          $text .= "</td>
1408              </tr>
1409              </table>
1410              </form>
1411              </div>";
1412          $ns->tablerender(DOWLAN_39, $text);
1413      }
1414  
1415  	function create_category($sub_action, $id) {
1416          global $sql, $tp;
1417          $download_category_name = $tp->toDB($_POST['download_category_name']);
1418          $download_category_description = $tp->toDB($_POST['download_category_description']);
1419            $download_category_icon = $tp->toDB($_POST['download_category_icon']);
1420  
1421          if(isset($_POST['download_category_icon_empty']) && $_POST['download_category_icon_empty'] != ""){
1422              $download_category_icon .= trim(chr(1).$tp->toDB($_POST['download_category_icon_empty']));
1423          }
1424  
1425          if ($id) {
1426              admin_update($sql->db_Update("download_category", "download_category_name='$download_category_name', download_category_description='$download_category_description', download_category_icon ='$download_category_icon', download_category_parent= '".intval($_POST['download_category_parent'])."', download_category_class='".$_POST['download_category_class']."' WHERE download_category_id='$id'"), 'update', DOWLAN_48);
1427          } else {
1428              admin_update($sql->db_Insert("download_category", "0, '$download_category_name', '$download_category_description', '$download_category_icon', '".intval($_POST['download_category_parent'])."', '".$_POST['download_category_class']."', 0 "), 'insert', DOWLAN_47);
1429          }
1430          if ($sub_action == "sn") {
1431              $sql->db_Delete("tmp", "tmp_time='$id' ");
1432          }
1433      }
1434  
1435  
1436  
1437  	function show_existing_mirrors()
1438      {
1439  
1440          global $sql, $ns, $tp, $sub_action, $id, $delete, $del_id;
1441  
1442          if($delete == "mirror")
1443          {
1444              admin_update($sql -> db_Delete("download_mirror", "mirror_id=".$del_id), delete, DOWLAN_135);
1445          }
1446  
1447  
1448          if(!$sql -> db_Select("download_mirror"))
1449          {
1450              $text = "<div style='text-align:center;'>".DOWLAN_144."</div>"; // No mirrors defined yet
1451          }
1452          else
1453          {
1454  
1455              $text = "<div style='text-align:center'>
1456              <form method='post' action='".e_SELF."?".e_QUERY."'>
1457              <table style='".ADMIN_WIDTH."' class='fborder'>
1458              <tr>
1459              <td style='width: 10%; text-align: center;' class='forumheader'>ID</td>
1460              <td style='width: 30%;' class='forumheader'>".DOWLAN_12."</td>
1461              <td style='width: 30%;' class='forumheader'>".DOWLAN_136."</td>
1462              <td style='width: 30%; text-align: center;' class='forumheader'>".LAN_OPTIONS."</td>
1463              </tr>
1464              ";
1465  
1466              $mirrorList = $sql -> db_getList();
1467  
1468              foreach($mirrorList as $mirror)
1469              {
1470                  extract($mirror);
1471                  $text .= "
1472  
1473                  <tr>
1474                  <td style='width: 10%; text-align: center;' class='forumheader3'>$mirror_id</td>
1475                  <td style='width: 30%;' class='forumheader3'>".$tp -> toHTML($mirror_name)."</td>
1476                  <td style='width: 30%;' class='forumheader3'>".($mirror_image ? "<img src='".e_FILE."downloadimages/".$mirror_image."' alt='' />" : DOWLAN_28)."</td>
1477                  <td style='width: 30%; text-align: center;' class='forumheader3'>
1478                  <a href='".e_SELF."?mirror.edit.{$mirror_id}'>".ADMIN_EDIT_ICON."</a>
1479                  <input type='image' title='".LAN_DELETE."' name='delete[mirror_{$mirror_id}]' src='".ADMIN_DELETE_ICON_PATH."' onclick=\"return jsconfirm('".DOWLAN_137." [ID: $mirror_id ]')\"/>
1480                  </td>
1481                  </tr>
1482                  ";
1483              }
1484              $text .= "</table></form></div>";
1485  
1486          }
1487  
1488          $ns -> tablerender(DOWLAN_138, $text);
1489  
1490          require_once(e_HANDLER."file_class.php");
1491          $fl = new e_file;
1492          $rejecthumb = array('$.','$..','/','CVS','thumbs.db','*._$',"thumb_", 'index', 'null*');
1493          $imagelist = $fl->get_files(e_FILE."downloadimages/","",$rejecthumb);
1494  
1495          if($sub_action == "edit" && !defined("SUBMITTED"))
1496          {
1497              $sql -> db_Select("download_mirror", "*", "mirror_id='".intval($id)."' ");
1498              $mirror = $sql -> db_Fetch();
1499              extract($mirror);
1500              $edit = TRUE;
1501          }
1502          else
1503          {
1504              unset($mirror_name, $mirror_url, $mirror_image, $mirror_location, $mirror_description);
1505              $edit = FALSE;
1506          }
1507  
1508          $text = "<div style='text-align:center'>
1509          <form method='post' action='".e_SELF."?".e_QUERY."' id='dataform'>\n
1510          <table style='".ADMIN_WIDTH."' class='fborder'>
1511  
1512          <tr>
1513          <td style='width: 30%;' class='forumheader3'>".DOWLAN_12."</td>
1514          <td style='width: 70%;' class='forumheader3'>
1515          <input class='tbox' type='text' name='mirror_name' size='60' value='$mirror_name' maxlength='200' />
1516          </td>
1517          </tr>
1518  
1519          <tr>
1520          <td style='width: 30%;' class='forumheader3'>".DOWLAN_139."</td>
1521          <td style='width: 70%;' class='forumheader3'>
1522          <input class='tbox' type='text' name='mirror_url' size='70' value='$mirror_url' maxlength='200' />
1523          </td>
1524          </tr>
1525  
1526          <tr>
1527          <td style='width: 30%;' class='forumheader3'>".DOWLAN_136."</td>
1528          <td style='width: 70%;' class='forumheader3'>
1529          <input class='tbox' type='text' id='mirror_image' name='mirror_image' size='60' value='$mirror_image' maxlength='200' />
1530  
1531  
1532          <br /><input class='button' type ='button' style='cursor:hand' size='30' value='".DOWLAN_42."' onclick='expandit(this)' />
1533          <div id='imagefile' style='display:none;{head}'>";
1534  
1535          $text .= DOWLAN_140."<br /><br />";
1536  
1537          foreach($imagelist as $file){
1538              $text .= "<a href=\"javascript:insertext('".$file['fname']."','mirror_image','imagefile')\"><img src='".e_FILE."downloadimages/".$file['fname']."' alt='' /></a> ";
1539          }
1540  
1541          $text .= "</div>
1542          </td>
1543          </tr>
1544  
1545          <tr>
1546          <td style='width: 30%;' class='forumheader3'>".DOWLAN_141."</td>
1547          <td style='width: 70%;' class='forumheader3'>
1548          <input class='tbox' type='text' name='mirror_location' size='60' value='$mirror_location' maxlength='200' />
1549          </td>
1550          </tr>
1551  
1552          <tr>
1553          <td style='width: 30%;' class='forumheader3'>".DOWLAN_18."</td>
1554          <td style='width: 70%;' class='forumheader3'>
1555          <textarea class='tbox' name=' mirror_description' cols='70' rows='6'>$mirror_description</textarea>
1556          </td>
1557          </tr>
1558  
1559          <tr>
1560          <td colspan='2' class='forumheader' style='text-align:center;'>
1561          ".($edit ? "<input class='button' type='submit' name='submit_mirror' value='".DOWLAN_142."' /><input type='hidden' name='id' value='$mirror_id' />" : "<input class='button' type='submit' name='submit_mirror' value='".DOWLAN_143."' />")."
1562          </td>
1563          </tr>
1564  
1565          </table>
1566          </form>
1567          </div>";
1568  
1569          $caption = ($edit ? DOWLAN_142 : DOWLAN_143);
1570  
1571          $ns -> tablerender($caption, $text);
1572      }
1573  
1574  	function submit_mirror()
1575      {
1576          global $tp, $sql;
1577          define("SUBMITTED", TRUE);
1578          if(isset($_POST['mirror_name']) && isset($_POST['mirror_url']))
1579          {
1580              $name = $tp -> toDB($_POST['mirror_name']);
1581              $url = $tp -> toDB($_POST['mirror_url']);
1582              $location = $tp -> toDB($_POST['mirror_location']);
1583  
1584              $description = $tp -> toDB($_POST['mirror_description']);
1585  
1586              if (isset($_POST['id'])){
1587                  admin_update($sql -> db_Update("download_mirror", "mirror_name='$name', mirror_url='$url', mirror_image='".$_POST['mirror_image']."', mirror_location='$location', mirror_description='$description' WHERE mirror_id=".$_POST['id']), 'update', DOWLAN_133);
1588              } else {
1589                  admin_update($sql -> db_Insert("download_mirror", "0, '$name', '$url', '".$_POST['mirror_image']."', '$location', '$description', 0"), 'insert', DOWLAN_134);
1590              }
1591          }
1592      }
1593  
1594   // ---------------------------------------------------------------------------
1595  
1596      function move_file($oldname,$newname)
1597      {
1598          global $ns;
1599          if(file_exists($newname))
1600          {
1601              return TRUE;
1602          }
1603  
1604          if(!file_exists($oldname) || is_dir($oldname))
1605          {
1606              $ns -> tablerender(LAN_ERROR,DOWLAN_68 . " : ".$oldname);
1607              return FALSE;
1608          }
1609  
1610          $directory = dirname($newname);
1611          if(is_writable($directory))
1612          {
1613              if(!rename($oldname,$newname))
1614              {
1615                  $ns -> tablerender(LAN_ERROR,DOWLAN_152." ".$oldname ." -> ".$newname);
1616                  return FALSE;
1617              }
1618              else
1619              {
1620                  return TRUE;
1621              }
1622          }
1623          else
1624          {
1625              $ns -> tablerender(LAN_ERROR,$directory ." ".LAN_NOTWRITABLE);
1626              return FALSE;
1627          }
1628      }
1629  
1630  // -------------------------------------------------------------------------
1631  
1632  
1633  } // end class.
1634  
1635  
1636  function download_adminmenu($parms) {
1637      global $download;
1638      global $action;
1639      $download->show_options($action);
1640  }
1641  
1642  
1643  
1644  
1645  
1646  ?>


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