From 69cc367a082da97de58bdada22c2017f126c23a5 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 1 Jun 2013 16:24:41 -0700 Subject: [PATCH] Removed old download script --- e107_admin/download.php | 1925 --------------------------------------- 1 file changed, 1925 deletions(-) delete mode 100644 e107_admin/download.php diff --git a/e107_admin/download.php b/e107_admin/download.php deleted file mode 100644 index 43d00fb6f..000000000 --- a/e107_admin/download.php +++ /dev/null @@ -1,1925 +0,0 @@ -load_files(); -} -*/ - -$e_sub_cat = 'download'; - -require_once(e_HANDLER."form_handler.php"); -require_once(e_HANDLER."userclass_class.php"); -require_once(e_HANDLER."file_class.php"); - -$fl = new e_file; - - -$rs = new form; -$frm = new e_form; -$download = new download; - -require_once("auth.php"); - - - - - -$sub_action = ''; -if (e_QUERY) -{ - $tmp = explode(".", e_QUERY); - $action = $tmp[0]; - $sub_action = varset($tmp[1],''); - $id = intval(varset($tmp[2],'')); - $from = varset($tmp[3], 0); - unset($tmp); -} - - -if(isset($_POST['delete'])) -{ - $tmp = array_keys($_POST['delete']); - list($delete, $del_id) = explode("_", $tmp[0]); - $del_id = intval($del_id); - unset($_POST['searchquery']); -} - -$from = ($from ? $from : 0); -$amount = 50; - - -if($file_array = $fl->get_files(e_DOWNLOAD, "","standard",5)) -{ - sort($file_array); -} - - -if($public_array = $fl->get_files(e_UPLOAD)) -{ - foreach($public_array as $key=>$val) - { - $file_array[] = str_replace(e_UPLOAD,"",$val); - } -} - - - -if ($sql->db_Select("rbinary")) -{ - while ($row = $sql->db_Fetch()) - { - extract($row); - $file_array[] = "Binary ".$binary_id."/".$binary_name; - } -} - - - -if($image_array = $fl->get_files(e_FILE.'downloadimages/', '\.gif$|\.jpg$|\.png$|\.GIF$|\.JPG$|\.PNG$','standard',2)) -{ - sort($image_array); -} - -if($thumb_array = $fl->get_files(e_FILE.'downloadimages/', '\.gif$|\.jpg$|\.png$|\.GIF$|\.JPG$|\.PNG$','standard',2)) -{ - sort($thumb_array); -} - - - -if(isset($_POST)) -{ - $e107cache->clear("download_cat"); -} - -if (isset($_POST['add_category'])) -{ - $download->create_category($sub_action, $id); -} - - -if (isset($_POST['submit_download'])) -{ - $download->submit_download($sub_action, $id); - $action = "main"; - unset($sub_action, $id); -} - - -if(isset($_POST['update_catorder'])) -{ - foreach($_POST['catorder'] as $key=>$order) - { - if (is_numeric($_POST['catorder'][$key])) - { - $sql -> db_Update("download_category", "download_category_order='".intval($order)."' WHERE download_category_id='".intval($key)."'"); - } - } - $admin_log->log_event('DOWNL_08',implode(',',array_keys($_POST['catorder'])),E_LOG_INFORMATIVE,''); - $ns->tablerender("", "
".LAN_UPDATED."
"); -} - - -if (isset($_POST['updateoptions'])) -{ - unset($temp); - $temp['download_php'] = $_POST['download_php']; - $temp['download_view'] = $_POST['download_view']; - $temp['download_sort'] = $_POST['download_sort']; - $temp['download_order'] = $_POST['download_order']; - $temp['agree_flag'] = $_POST['agree_flag']; - $temp['download_email'] = $_POST['download_email']; - $temp['agree_text'] = $tp->toDB($_POST['agree_text']); - $temp['download_denied'] = $tp->toDB($_POST['download_denied']); - $temp['download_reportbroken'] = $_POST['download_reportbroken']; - if ($_POST['download_subsub']) $temp['download_subsub'] = '1'; else $temp['download_subsub'] = '0'; - if ($_POST['download_incinfo']) $temp['download_incinfo'] = '1'; else $temp['download_incinfo'] = '0'; - if ($admin_log->logArrayDiffs($temp, $pref, 'DOWNL_01')) - { - save_prefs(); - $message = DOWLAN_65; - } - else - { - $message = DOWLAN_8; - } -} - -$targetFields = array('gen_datestamp', 'gen_user_id', 'gen_ip', 'gen_intdata', 'gen_chardata'); // Fields for download limits - -if(isset($_POST['addlimit'])) -{ - if($sql->db_Select('generic','gen_id',"gen_type = 'download_limit' AND gen_datestamp = {$_POST['newlimit_class']}")) - { - $message = DOWLAN_116; - } - else - { - $vals = array(); - $vals['gen_type'] = 'download_limit'; - foreach(array('newlimit_class','new_bw_num','new_bw_days','new_count_num','new_count_days') as $k => $lName) - { - $vals[$targetFields[$k]] = intval($_POST[$lName]); - } - $valString = implode(',',$vals); - if($sql->db_Insert('generic',$vals)) - { - $message = DOWLAN_117; - $admin_log->log_event('DOWNL_09',$valString,E_LOG_INFORMATIVE,''); - } - else - { - $message = DOWLAN_118; - } - unset($vals); - } -} - - -if(isset($_POST['updatelimits'])) -{ - - if($pref['download_limits'] != $_POST['download_limits']) - { - $pref['download_limits'] = ($_POST['download_limits'] == 'on') ? 1 : 0; - save_prefs(); - $message .= DOWLAN_126."
"; - } - foreach(array_keys($_POST['count_num']) as $idLim) - { - $idLim = intval($idLim); - if(!$_POST['count_num'][$idLim] && !$_POST['count_days'][$idLim] && !$_POST['bw_num'][$idLim] && !$_POST['bw_days'][$idLim]) - { - //All entries empty - Remove record - if($sql->db_Delete('generic',"gen_id = {$idLim}")) - { - $message .= $idLim." - ".DOWLAN_119."
"; - $admin_log->log_event('DOWNL_11','ID: '.$idLim,E_LOG_INFORMATIVE,''); - } - else - { - $message .= $idLim." - ".DOWLAN_120."
"; - } - } - else - { - $vals = array(); - foreach(array('bw_num','bw_days','count_num','count_days') as $k => $lName) - { - $vals[$targetFields[$k+1]] = intval($_POST[$lName][$idLim]); - } - $valString = implode(',',$vals); - $sql->db_UpdateArray('generic',$vals," WHERE gen_id = {$idLim}"); - $admin_log->log_event('DOWNL_10',$idLim.', '.$valString,E_LOG_INFORMATIVE,''); - $message .= $idLim." - ".DOWLAN_121."
"; - unset($vals); - } - } -} - - -if(isset($_POST['submit_mirror'])) -{ - $download->submit_mirror($sub_action, $id); -} - - -if($action == "mirror") -{ - $download -> show_existing_mirrors(); -} - - -if ($action == "dlm") -{ - $action = "create"; - $id = $sub_action; - $sub_action = "dlm"; -} - - -if ($action == "create") -{ - $download->create_download($sub_action, $id); -} - - -if ($delete == 'category') -{ - if (e107::getMessage()->addAuto($sql->db_Delete('download_category', 'download_category_id='.$del_id), 'delete', DOWLAN_49." #".$del_id." ".DOWLAN_36)) - { - $sql->db_Delete('download_category', 'download_category_parent='.$del_id); - $admin_log->log_event('DOWNL_04',$del_id,E_LOG_INFORMATIVE,''); - } -} - - -if ($action == 'cat') -{ - $download->show_categories($sub_action, $id); -} - - -if ($delete == 'main') -{ - $result = e107::getMessage()->addAuto($sql->db_Delete('download', 'download_id='.$del_id), 'delete', DOWLAN_27." #".$del_id." ".DOWLAN_36); - if($result) - { - $admin_log->log_event('DOWNL_07',$del_id,E_LOG_INFORMATIVE,''); - admin_purge_related('download', $del_id); - $e_event->trigger('dldelete', $del_id); - } - unset($sub_action, $id); -} - - -if (isset($message)) -{ - $ns->tablerender("", "
".$message."
"); -} - - - -if (!e_QUERY || $action == "main") -{ - $download->show_existing_items($action, $sub_action, $id, $from, $amount); -} - - - - -if ($action == "opt") -{ - global $pref, $ns; - $agree_flag = $pref['agree_flag']; - $agree_text = $pref['agree_text']; - $text = "
-
\n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".DOWLAN_69.""; - $c = $pref['download_php'] ? " checked = 'checked' " : ""; - $ssc = ((!isset($pref['download_subsub'])) || ($pref['download_subsub'] == '1')) ? " checked = 'checked' " : ""; - $sacc = (varset($pref['download_incinfo'],0) == '1') ? " checked = 'checked' " : ""; - $text .= " ".DOWLAN_70."
".DOWLAN_158." -
".DOWLAN_159." -
- ".DOWLAN_55." - - -
- ".DOWLAN_56." - - - -
- ".LAN_ORDER." - - -
".DOWLAN_151."". r_userclass("download_reportbroken", $pref['download_reportbroken'])."
".DOWLAN_150."". ($pref['download_email'] ? "" : "")."
".DOWLAN_100."". ($agree_flag ? "" : "")."
- ".DOWLAN_101." - - -
- ".DOWLAN_146." - - -
- -
-
-
"; - $ns->tablerender(DOWLAN_54, $text); -} - - - -if($action == 'limits') -{ - if($sql->db_Select('userclass_classes','userclass_id, userclass_name')) - { - $classList = $sql->db_getList(); - } - 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'")) - { - while($row = $sql->db_Fetch()) - { - $limitList[$row['limit_classnum']] = $row; - } - } - $txt = " -
- - - - - - - - - - - "; - - foreach($limitList as $row) - { - $txt .= " - - - - - - - "; - } - - $txt .= " - - - - - - - - - - - - - - - "; - - $txt .= "
- "; - if($pref['download_limits'] == 1) - { - $chk = "checked = 'checked'"; - } - else - { - $chk = ""; - } - - $txt .= " - ".DOWLAN_125." -
".DOWLAN_67."".DOWLAN_113."".DOWLAN_107."".DOWLAN_108."
".$row['limit_id']."".r_userclass_name($row['limit_classnum'])." - ".DOWLAN_109." - ".DOWLAN_110." - - ".DOWLAN_111." ".DOWLAN_109." - ".DOWLAN_110." -
- -


".r_userclass("newlimit_class", 0, "off", "guest, member, admin, classes, language")." - ".DOWLAN_109." - ".DOWLAN_110." - - ".DOWLAN_111." ".DOWLAN_109." - ".DOWLAN_110." -
- -
"; - - $ns->tablerender(DOWLAN_112, $txt); - require_once(e_ADMIN.'footer.php'); - exit; -} - -require_once("footer.php"); -exit; - - - - -class download -{ - function show_existing_items($action, $sub_action, $id, $from, $amount) - { - global $sql, $rs, $ns, $tp, $mySQLdefaultdb, $pref; - $text = "
"; - $sortorder = ($pref['download_order']) ? $pref['download_order'] : "download_datestamp"; - $sortdirection = ($pref['download_sort']) ? strtolower($pref['download_sort']) : "desc"; - if ($sortdirection != 'desc') $sortdirection = 'asc'; - if(isset($_POST['searchdisp'])) - { - $pref['admin_download_disp'] = implode("|",$_POST['searchdisp']); - save_prefs(); - } - - if(!$pref['admin_download_disp']) - { - $search_display = array("download_name","download_class"); - } - else - { - $search_display = explode("|",$pref['admin_download_disp']); - } - - $query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc. download_category_id = d.download_category"; - - if (isset($_POST['searchquery']) && $_POST['searchquery'] != "") - { - $query .= " WHERE download_url REGEXP('".$_POST['searchquery']."') OR download_author REGEXP('".$_POST['searchquery']."') OR download_description REGEXP('".$_POST['searchquery']."') "; - foreach($search_display as $disp) - { - $query .= " OR $disp REGEXP('".$_POST['searchquery']."') "; - } - $query .= " ORDER BY {$sortorder} {$sortdirection}"; - } - else - { - $query .= " ORDER BY ".($sub_action ? $sub_action : $sortorder)." ".($id ? $id : $sortdirection)." LIMIT $from, $amount"; - } - - if ($dl_count = $sql->db_Select_gen($query)) - { - $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform")." - - - - "; - - // Search Display Column header.---------- - foreach($search_display as $disp) - { - if($disp == "download_name") - { // Toggle direction - $text .= ""; - } - else - { - $repl = array("download_","_"); - $text .= ""; - } - } - - - $text .=""; - - while ($row = $sql->db_Fetch()) - { - $text .= ""; - - // Display Chosen options - foreach($search_display as $disp) - { - $text .= ""; - } - - - $text .= " - - "; - } - $text .= "
ID".DOWLAN_27."".ucwords(str_replace($repl," ",$disp))."".LAN_OPTIONS."
".$row['download_id'].""; - switch ($disp) - { - case "download_name" : - $text .= "".$row['download_name'].""; - break; - case "download_category" : - $text .= $row['download_category_name']." "; - break; - case "download_datestamp" : - $text .= ($row[$disp]) ? strftime($pref['shortdate'],$row[$disp])." " : " "; - break; - case "download_class" : - case "download_visible" : - $text .= r_userclass_name($row[$disp])." "; - break; - case "download_filesize" : - $text .= ($row[$disp]) ? round(($row[$disp] / 1000))." Kb " : " "; - break; - case "download_thumb" : - $text .= ($row[$disp]) ? "" : ""; - break; - case "download_image" : - $text .= "".$row[$disp]." "; - break; - case "download_description" : - $text .= $tp->toHTML($row[$disp],TRUE)." "; - break; - case "download_active" : - if($row[$disp]== 1) - { - $text .= "\n"; - } - elseif($row[$disp]== 2) - { - $text .= "\n"; - } - else - { - $text .= "\n"; - } - break; - case "download_comment" : - $text .= ($row[$disp]) ? ADMIN_TRUE_ICON : " "; - break; - default : - $text .= $row[$disp]." "; - } - $text .= " - ".ADMIN_EDIT_ICON." - toJS(DOWLAN_33." [ID: ".$row['download_id']." ]")."') \" /> -
"; - } - else - { // 'No downloads yet' - $text .= "
".DOWLAN_6."
"; - } - $text .= "
"; - - // Next-Previous. - $downloads = $sql->db_Count("download"); - if ($downloads > $amount && !$_POST['searchquery']) - { - $parms = "{$downloads},{$amount},{$from},".e_SELF."?".(e_QUERY ? "$action.$sub_action.$id." : "main.{$sortorder}.{$sortdirection}.")."[FROM]"; - $text .= "
".$tp->parseTemplate("{NEXTPREV={$parms}}"); - } - - - // Search & display options etc. - $text .= "
\n

\n\n\n

"; - - $text .= "
".LAN_DISPLAYOPT."
"; - $text .= " -
\n -
"; - - - $ns->tablerender(DOWLAN_7, $text); - } - - function show_options($action) { - - if ($action == "") { - $action = "main"; - } - $var['main']['text'] = DOWLAN_29; - $var['main']['link'] = e_SELF; - - $var['create']['text'] = DOWLAN_30; - $var['create']['link'] = e_SELF."?create"; - - $var['cat']['text'] = DOWLAN_31; - $var['cat']['link'] = e_SELF."?cat"; - $var['cat']['perm'] = "Q"; - - $var['opt']['text'] = LAN_OPTIONS; - $var['opt']['link'] = e_SELF."?opt"; - - $var['limits']['text'] = DOWLAN_112; - $var['limits']['link'] = e_SELF."?limits"; - - $var['mirror']['text'] = DOWLAN_128; - $var['mirror']['link'] = e_SELF."?mirror"; - - show_admin_menu(DOWLAN_32, $action, $var); - - } - - -// --------------------------------------------------------------------------- - - - // Given the string which is stored in the DB, turns it into an array of mirror entries - // If $byID is true, the array index is the mirror ID. Otherwise its a simple array - function makeMirrorArray($source, $byID = FALSE) - { - $ret = array(); - if($source) - { - $mirrorTArray = explode(chr(1), $source); - - $count = 0; - foreach($mirrorTArray as $mirror) - { - if ($mirror) - { - list($mid, $murl, $mreq) = explode(",", $mirror); - $ret[$byID ? $mid : $count] = array('id' => $mid, 'url' => $murl, 'requests' => $mreq); - $count++; - } - } - } - return $ret; - } - - - // Turn the array into a string which can be stored in the DB - function compressMirrorArray($source) - { - if (!is_array($source) || !count($source)) return ''; - $inter = array(); - foreach ($source as $s) - { - $inter[] = $s['id'].','.$s['url'].','.$s['requests']; - } - return implode(chr(1),$inter); - } - - - - function create_download($sub_action, $id) - { - global $cal,$tp, $sql, $fl, $rs, $ns, $file_array, $image_array, $thumb_array; - require_once(e_CORE."shortcodes/batch/download_shortcodes.php"); - - $mirrorArray = array(); - - $download_status[0] = DOWLAN_122; - $download_status[1] = DOWLAN_123; - $download_status[2] = DOWLAN_124; - - - if (!$sql->db_Select("download_category")) - { - $ns->tablerender(ADLAN_24, "
".DOWLAN_5."
"); - return; - } - $download_active = 1; - if ($sub_action == "edit" && !$_POST['submit']) - { - if ($sql->db_Select("download", "*", "download_id=".$id)) - { - $row = $sql->db_Fetch(); - extract($row); - - $mirrorArray = $this->makeMirrorArray($row['download_mirror']); - } - } - - if ($sub_action == "dlm" && !$_POST['submit']) - { - if ($sql->db_Select("upload", "*", "upload_id=".$id)) - { - $row = $sql->db_Fetch(); - - $download_category = $row['upload_category']; - $download_name = $row['upload_name'].($row['upload_version'] ? " v" . $row['upload_version'] : ""); - $download_url = $row['upload_file']; - $download_author_email = $row['upload_email']; - $download_author_website = $row['upload_website']; - $download_description = $row['upload_description']; - $download_image = $row['upload_ss']; - $download_filesize = $row['upload_filesize']; - $image_array[] = array("path" => "", "fname" => $row['upload_ss']); - $download_author = substr($row['upload_poster'], (strpos($row['upload_poster'], ".")+1)); - } - } - - - $text = " -
-
- - - - - - - - - - - - - - - - - - - "; - } - else - { - $text .= DOWLAN_132."
-
"; - - $mirrorList = $sql -> db_getList(); // Get the list of possible mirrors - - $m_count = (count($mirrorArray) ? count($mirrorArray) : 1); // Count of mirrors actually in use (or count of 1 if none defined yet) - - for($count = 1; $count <= $m_count; $count++) - { - - $opt = ($count==1) ? "id='mirror'" : ""; - $text .=" - - "; - if (DOWNLOAD_DEBUG) - { - if ($id) - { - $text .= '('.$mirrorArray[($count-1)]['requests'].')'; - } - else - { - $text .= " - "; - } - } - $text .= "
"; - } - - $text .="

- - - - - - - - "; - } // End of mirror-related stuff - - $text .= " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "; - - - $text .= " - - - - - - - - - - - "; - - if ($sub_action == "dlm") { - $text .= " - - - - - - - - - - - - "; - } - - $text .= " - - - -
".DOWLAN_11.""; - - $text .= $tp->parseTemplate("{DOWNLOAD_CATEGORY_SELECT={$download_category}}",true,$download_shortcodes); - - $text .= "
".DOWLAN_12.": - toForm($download_name)."\" maxlength='200' /> -
".DOWLAN_13.":
".DOWLAN_131."   - -
- ".DOWLAN_149." -
- URL:  - - -    ".DOWLAN_66." - -
- -
".DOWLAN_128.":"; - - - // See if any mirrors to display - if(!$sql -> db_Select("download_mirror")) - { // No mirrors defined here - $text .= DOWLAN_144."
".DOWLAN_155." - - ".DOWLAN_156."
- ".DOWLAN_157." -
".DOWLAN_15.": - -
".DOWLAN_16.": - -
".DOWLAN_17.": - -
".DOWLAN_18.": - -
".DOWLAN_19.": - "; - - if($sub_action == "dlm" && $download_image) - { - $text .= " - \n"; - } - - $text .= " -
".DOWLAN_20.": - -
".LAN_DATESTAMP.": - "; - if(!$download_datestamp){ - $download_datestamp = time(); - } - $cal_options['showsTime'] = false; - $cal_options['showOthers'] = false; - $cal_options['weekNumbers'] = false; - $cal_options['ifFormat'] = "%d/%m/%Y %H:%M:%S"; - $cal_options['timeFormat'] = "24"; - $cal_attrib['class'] = "tbox"; - $cal_attrib['size'] = "12"; - $cal_attrib['name'] = "download_datestamp"; - $cal_attrib['value'] = date("d/m/Y H:i:s", $download_datestamp); - $text .= $cal->make_input_field($cal_options, $cal_attrib); - - $update_checked = ($_POST['update_datestamp']) ? "checked='checked'" : ""; - $text .= "  ".DOWLAN_148." - -
".DOWLAN_21.": - "; - - $text .= "
".DOWLAN_102.":"; - - - if ($download_comment == "0") { - $text .= LAN_YES.": - ".LAN_NO.": "; - } else { - $text .= LAN_YES.": - ".LAN_NO.": "; - } - - $text .= "
".DOWLAN_145.":".r_userclass('download_visible', $download_visible, 'off', 'public, nobody, member, admin, classes, language')."
".DOWLAN_106.":".r_userclass('download_class', $download_class, 'off', 'public, nobody, member, admin, classes, language')."
".DOWLAN_153.":
- -
".DOWLAN_103.":
- - -
"; - - - if ($id && $sub_action == "edit") { - $text .= " "; - } else { - $text .= ""; - } - - $text .= "
-
-
"; - $ns->tablerender(ADLAN_24, $text); - } - - -// ----------------------------------------------------------------------------- - - function show_message($message) { - global $ns; - $ns->tablerender("", "
".$message."
"); - } - -// ----------------------------------------------------------------------------- - - - // Actually save a new or edited download to the DB - function submit_download($sub_action, $id) - { - global $tp, $sql, $DOWNLOADS_DIRECTORY, $e_event; - - $dlInfo = array(); - $dlMirrors = array(); - - if($sub_action == 'edit') - { - if($_POST['download_url_external'] == '') - { - $_POST['download_filesize_external'] = FALSE; - } - } - - if ($_POST['download_url_external'] && $_POST['download_url'] == '') - { - $dlInfo['download_url'] = $tp->toDB($_POST['download_url_external']); - $filesize = intval($_POST['download_filesize_external']); - } - else - { - $dlInfo['download_url'] = $tp->toDB($_POST['download_url']); - if($_POST['download_filesize_external']) - { - $filesize = intval($_POST['download_filesize_external']); - } - else - { - if (strpos($DOWNLOADS_DIRECTORY, "/") === 0 || strpos($DOWNLOADS_DIRECTORY, ":") >= 1) - { - $filesize = filesize($DOWNLOADS_DIRECTORY.$dlInfo['download_url']); - } - else - { - $filesize = filesize(e_BASE.$DOWNLOADS_DIRECTORY.$dlInfo['download_url']); - } - } - } - - if (!$filesize) - { - if($sql->db_Select("upload", "upload_filesize", "upload_file='{$dlInfo['download_url']}'")) - { - $row = $sql->db_Fetch(); - $filesize = $row['upload_filesize']; - } - } - $dlInfo['download_filesize'] = $filesize; - - - // ---- Move Images and Files ------------ - if($_POST['move_image']) - { - if($_POST['download_thumb']) - { - $oldname = e_UPLOAD.$_POST['download_thumb']; - $newname = e_FILE."downloadthumbs/".$_POST['download_thumb']; - if(!$this -> move_file($oldname,$newname)) - { - return; - } - } - if($_POST['download_image']) - { - $oldname = e_UPLOAD.$_POST['download_image']; - $newname = e_FILE."downloadimages/".$_POST['download_image']; - if(!$this -> move_file($oldname,$newname)) - { - return; - } - } - } - - if($_POST['move_file'] && $_POST['download_url']) - { - $oldname = e_UPLOAD.$_POST['download_url']; - $newname = $_POST['move_file'].$_POST['download_url']; - if(!$this -> move_file($oldname,$newname)) - { - return; - } - $dlInfo['download_url'] = str_replace(e_DOWNLOAD,"",$newname); - } - - - // ------------------------------------------ - - - $dlInfo['download_description'] = $tp->toDB($_POST['download_description']); - $dlInfo['download_name'] = $tp->toDB($_POST['download_name']); - $dlInfo['download_author'] = $tp->toDB($_POST['download_author']); - $dlInfo['download_author_email'] = $tp->toDB($_POST['download_author_email']); - $dlInfo['download_author_website'] = $tp->toDB($_POST['download_author_website']); - $dlInfo['download_category'] = intval($_POST['download_category']); - $dlInfo['download_active'] = intval($_POST['download_active']); - $dlInfo['download_thumb'] = $tp->toDB($_POST['download_thumb']); - $dlInfo['download_image'] = $tp->toDB($_POST['download_image']); - $dlInfo['download_comment'] = $tp->toDB($_POST['download_comment']); - $dlInfo['download_class'] = intval($_POST['download_class']); - $dlInfo['download_visible'] =intval($_POST['download_visible']); - - if (preg_match("#(.*?)/(.*?)/(.*?) (.*?):(.*?):(.*?)$#", $_POST['download_datestamp'], $matches)) - { - $dlInfo['download_datestamp'] = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); - } - else - { - $dlInfo['download_datestamp'] = time(); - } - - if($_POST['update_datestamp']) - { - $dlInfo['download_datestamp'] = time(); - } - - $mirrorStr = ""; - $mirrorFlag = FALSE; - - // See if any mirrors defined - // Need to check all the possible mirror names - might have deleted the first one if we're in edit mode - foreach ($_POST['download_mirror_name'] as $mn) - { - if ($mn) - { - $mirrorFlag = TRUE; - break; - } - } - if($mirrorFlag) - { - $mirrors = count($_POST['download_mirror_name']); - $mirrorArray = array(); - $newMirrorArray = array(); - if ($id && $sql->db_Select('download','download_mirror', 'download_id = '.$id)) // Get existing download stats - { - if ($row = $sql->db_Fetch()) - { - $mirrorArray = $this->makeMirrorArray($row['download_mirror'], TRUE); - } - } - for($a=0; $a<$mirrors; $a++) - { - $mid = trim($_POST['download_mirror_name'][$a]); - $murl = trim($_POST['download_mirror'][$a]); - if ($mid && $murl) - { - $newMirrorArray[$mid] = array('id' => $mid, 'url' => $murl, 'requests' => 0); - if (DOWNLOAD_DEBUG && !$id) - { - $newMirrorArray[$mid]['requests'] = intval($_POST['download_mirror_requests'][$a]); - } - } - } - // Now copy across any existing usage figures - foreach ($newMirrorArray as $k => $m) - { - if (isset($mirrorArray[$k])) - { - $newMirrorArray[$k]['requests'] = $mirrorArray[$k]['requests']; - } - } - $mirrorStr = $this->compressMirrorArray($newMirrorArray); - } - - $dlMirrors['download_mirror']=$mirrorStr; - $dlMirrors['download_mirror_type']=intval($_POST['download_mirror_type']); - - if ($id) - { // Its an edit - e107::getMessage()->addAuto($sql->db_UpdateArray('download',array_merge($dlInfo,$dlMirrors),'WHERE download_id='.intval($id)), 'update', DOWLAN_2." (".$_POST['download_name'].")"); - $dlInfo['download_id'] = $id; - $this->downloadLog('DOWNL_06',$dlInfo,$dlMirrors); - $dlInfo['download_datestamp'] = $time; // This is what 0.7 did, regardless of settings - unset($dlInfo['download_class']); // Also replicating 0.7 - $e_event->trigger('dlupdate', $dlInfo); - } - else - { - if (e107::getMessage()->addAuto($download_id = $sql->db_Insert('download',array_merge($dlInfo,$dlMirrors)), 'insert', DOWLAN_1." (".$_POST['download_name'].")")) - { - $dlInfo['download_id'] = $download_id; - $this->downloadLog('DOWNL_05',$dlInfo,$dlMirrors); - $dlInfo['download_datestamp'] = $time; // This is what 0.7 did, regardless of settings - unset($dlInfo['download_class']); // Also replicating 0.7 - $e_event->trigger("dlpost", $dlInfo); - - if ($_POST['remove_upload']) - { - $sql->db_Update("upload", "upload_active='1' WHERE upload_id='".$_POST['remove_id']."'"); - $mes = "
".$_POST['download_name']." ".DOWLAN_104; - $mes .= "

".DOWLAN_105.""; - $this->show_message($mes); - } - } - } - } - - - function downloadLog($aText, &$dlInfo, &$mirrorInfo=NULL) - { - global $admin_log; - $logString = DOWLAN_9; - foreach ($dlInfo as $k => $v) - { - $logString .= '[!br!]'.$k.'=>'.$v; - } - if ($mirrorInfo != NULL) - { - foreach ($mirrorInfo as $k => $v) - { - $logString .= '[!br!]'.$k.'=>'.$v; - } - } - $admin_log->log_event($aText,$logString,E_LOG_INFORMATIVE,''); - } - -// ----------------------------------------------------------------------------- - - function show_categories($sub_action, $id) - { - global $sql, $rs, $ns, $tp; - - if (!is_object($sql2)) { - $sql2 = new db; - } - $text = $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); - $text .= "
"; - - $qry = " - SELECT dc.*, COUNT(d.download_id) AS filecount FROM #download_category AS dc - LEFT JOIN #download AS d ON d.download_category = dc.download_category_id - GROUP BY dc.download_category_id - ORDER BY dc.download_category_order - "; - if($sql->db_Select_gen($qry)) - { - $categories = $sql->db_getList(); - foreach($categories as $cat) - { - $cat_array[$cat['download_category_parent']][] = $cat; - } - - $text .= " - - - - - - - - "; - - - //Start displaying parent categories - foreach($cat_array[0] as $parent) - { - if(strstr($parent['download_category_icon'], chr(1))) - { - list($parent['download_category_icon'], $parent['download_category_icon_empty']) = explode(chr(1), $parent['download_category_icon']); - } - - $text .= " - - - - - - "; - - //Show main categories - - if(is_array($cat_array[$parent['download_category_id']])) - { - foreach($cat_array[$parent['download_category_id']] as $main) - { - - if(strstr($main['download_category_icon'], chr(1))) - { - list($main['download_category_icon'], $main['download_category_icon_empty']) = explode(chr(1), $main['download_category_icon']); - } - $text .= " - - - - - - "; - - //Show sub categories - if(is_array($cat_array[$main['download_category_id']])) - { - foreach($cat_array[$main['download_category_id']] as $sub) - { - - if(strstr($sub['download_category_icon'], chr(1))) - { - list($sub['download_category_icon'], $sub['download_category_icon_empty']) = explode(chr(1), $sub['download_category_icon']); - } - $text .= " - - - - - - "; - } - } - } - } - - } - - $text .= "
 ".DOWLAN_11."".DOWLAN_52."".LAN_ORDER."".LAN_OPTIONS."
".($parent['download_category_icon'] ? "" : " ")."{$parent['download_category_name']} - - - ".ADMIN_EDIT_ICON." - "; - if(!is_array($cat_array[$parent['download_category_id']])) - { - $text .= "toJS(DOWLAN_34." [ID: {$parent['download_category_id']} ]")."') \"/>"; - } - $text .= " -
".($main['download_category_icon'] ? "" : " ")."{$main['download_category_name']}
{$main['download_category_description']}
{$main['filecount']} - - - ".ADMIN_EDIT_ICON.""; - if(!is_array($cat_array[$main['download_category_id']]) && !$main['filecount']) - { - $text .= "toJS(DOWLAN_34." [ID: {$main['download_category_id']} ]")."') \"/>"; - } - $text .= " -
".($sub['download_category_icon'] ? "" : " ")."    ".DOWLAN_53.": {$sub['download_category_name']}
    {$sub['download_category_description']}
{$sub['filecount']} - - - ".ADMIN_EDIT_ICON." - "; - if(!$sub['filecount']) - { - $text .= "toJS(DOWLAN_34." [ID: {$sub['download_category_id']} ]")."') \"/>"; - } - $text .= " -
"; - $text .= "
- -
"; - } - else - { - $text .= "
".DOWLAN_38."
"; - } - $text .= ""; - $ns->tablerender(DOWLAN_37, $text); - - unset($download_category_id, $download_category_name, $download_category_description, $download_category_parent, $download_category_icon, $download_category_class); - - $handle = opendir(e_IMAGE."icons"); - while ($file = readdir($handle)) { - if ($file != "." && $file != ".." && $file != "/" && $file != "CVS") { - $iconlist[] = $file; - } - } - closedir($handle); - - if ($sub_action == "edit" && !$_POST['add_category']) { - if ($sql->db_Select("download_category", "*", "download_category_id=$id")) { - $row = $sql->db_Fetch(); - extract($row); - $main_category_parent = $download_category_parent; - if(strstr($download_category_icon, chr(1))) - { - list($download_category_icon, $download_category_icon_empty) = explode(chr(1), $download_category_icon); - } - else - { - $download_category_icon_empty = ""; - } - } - } - - - extract($preset); - - $frm_action = (isset($_POST['add_category'])) ? e_SELF."?cat" : e_SELF."?".e_QUERY; - $text = "
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - "; - - - $text .= " - - - -
".DOWLAN_37.": "; - - if (!$download_cats = $sql->db_Select("download_category")) { - $text .= " - \n"; - } else { - $text .= " - "; - } - $text .= "
".DOWLAN_12.": - -
".DOWLAN_18.": - -
".DOWLAN_41.": - - -
- -
".DOWLAN_147.": - - -
- -
".DOWLAN_43.":
(".DOWLAN_44.")
".r_userclass("download_category_class", $download_category_class, 'off', 'public, nobody, member, admin, classes, language')." - -
"; - if ($id && $sub_action == "edit" && !isset($_POST['add_category'])) { - $text .= " "; - } else { - $text .= ""; - } - $text .= "
-
-
"; - $ns->tablerender(DOWLAN_39, $text); - } - - function create_category($sub_action, $id) - { - global $sql, $tp, $admin_log, $frm; - $download_category_name = $tp->toDB($_POST['download_category_name']); - $download_category_description = $tp->toDB($_POST['download_category_description']); - $download_category_icon = $tp->toDB($_POST['download_category_icon']); - $download_category_class = $tp->toDB($_POST['download_category_class']); - $download_categoory_parent = intval($_POST['download_category_parent']); - - if(isset($_POST['download_category_icon_empty']) && $_POST['download_category_icon_empty'] != "") - { - $download_category_icon .= trim(chr(1).$tp->toDB($_POST['download_category_icon_empty'])); - } - - if ($id) - { - e107::getMessage()->addAuto($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= '{$download_categoory_parent}', download_category_class='{$download_category_class}' WHERE download_category_id='{$id}'"), 'update', DOWLAN_48); - $admin_log->log_event('DOWNL_03',$download_category_name.'[!br!]'.$download_category_description,E_LOG_INFORMATIVE,''); - } - else - { - e107::getMessage()->addAuto($sql->db_Insert("download_category", "0, '{$download_category_name}', '{$download_category_description}', '{$download_category_icon}', '{$download_categoory_parent}', '{$download_category_class}', 0 "), 'insert', DOWLAN_47); - $admin_log->log_event('DOWNL_02',$download_category_name.'[!br!]'.$download_category_description,E_LOG_INFORMATIVE,''); - } - if ($sub_action == "sn") - { - $sql->db_Delete("tmp", "tmp_time='{$id}' "); - } - } - - - - function show_existing_mirrors() - { - - global $sql, $ns, $tp, $sub_action, $id, $delete, $del_id, $admin_log; - - if($delete == "mirror") - { - e107::getMessage()->addAuto($sql -> db_Delete("download_mirror", "mirror_id=".$del_id), delete, DOWLAN_135); - $admin_log->log_event('DOWNL_14','ID: '.$del_id,E_LOG_INFORMATIVE,''); - } - - - if(!$sql -> db_Select("download_mirror")) - { - $text = "
".DOWLAN_144."
"; // No mirrors defined yet - } - else - { - - $text = "
-
- - - - - - - - "; - - $mirrorList = $sql -> db_getList(); - - foreach($mirrorList as $mirror) - { - extract($mirror); - $text .= " - - - - - - - - "; - } - $text .= "
ID".DOWLAN_12."".DOWLAN_136."".LAN_OPTIONS."
$mirror_id".$tp -> toHTML($mirror_name)."".($mirror_image ? "" : DOWLAN_28)." - ".ADMIN_EDIT_ICON." - -
"; - - } - - $ns -> tablerender(DOWLAN_138, $text); - - require_once(e_HANDLER."file_class.php"); - $fl = new e_file; - $imagelist = $fl->get_files(e_FILE.'downloadimages/'); - - if($sub_action == "edit" && !defined("SUBMITTED")) - { - $sql -> db_Select("download_mirror", "*", "mirror_id='".intval($id)."' "); - $mirror = $sql -> db_Fetch(); - extract($mirror); - $edit = TRUE; - } - else - { - unset($mirror_name, $mirror_url, $mirror_image, $mirror_location, $mirror_description); - $edit = FALSE; - } - - $text = "
-
\n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".DOWLAN_12." - -
".DOWLAN_139." - -
".DOWLAN_136." - - - -
- -
".DOWLAN_141." - -
".DOWLAN_18." - -
- ".($edit ? "" : "")." -
-
-
"; - - $caption = ($edit ? DOWLAN_142 : DOWLAN_143); - - $ns -> tablerender($caption, $text); - } - - - - function submit_mirror() - { - global $tp, $sql, $admin_log; - define("SUBMITTED", TRUE); - if(isset($_POST['mirror_name']) && isset($_POST['mirror_url'])) - { - $name = $tp -> toDB($_POST['mirror_name']); - $url = $tp -> toDB($_POST['mirror_url']); - $location = $tp -> toDB($_POST['mirror_location']); - $description = $tp -> toDB($_POST['mirror_description']); - - $logString = $name.'[!br!]'.$url.'[!br!]'.$location.'[!br!]'.$description; - - if (isset($_POST['id'])) - { - e107::getMessage()->addAuto($sql -> db_Update("download_mirror", "mirror_name='{$name}', mirror_url='{$url}', mirror_image='".$tp->toDB($_POST['mirror_image'])."', mirror_location='{$location}', mirror_description='{$description}' WHERE mirror_id=".intval($_POST['id'])), 'update', DOWLAN_133); - $admin_log->log_event('DOWNL_13','ID: '.intval($_POST['id']).'[!br!]'.$logString,E_LOG_INFORMATIVE,''); - } - else - { - e107::getMessage()->addAuto($sql -> db_Insert("download_mirror", "0, '{$name}', '{$url}', '".$tp->toDB($_POST['mirror_image'])."', '{$location}', '{$description}', 0"), 'insert', DOWLAN_134); - $admin_log->log_event('DOWNL_12',$logString,E_LOG_INFORMATIVE,''); - } - } - } - - // --------------------------------------------------------------------------- - - function move_file($oldname,$newname) - { - global $ns; - if(file_exists($newname)) - { - return TRUE; - } - - if(!file_exists($oldname) || is_dir($oldname)) - { - $ns -> tablerender(LAN_ERROR,DOWLAN_68 . " : ".$oldname); - return FALSE; - } - - $directory = dirname($newname); - if(is_writable($directory)) - { - if(!rename($oldname,$newname)) - { - $ns -> tablerender(LAN_ERROR,DOWLAN_152." ".$oldname ." -> ".$newname); - return FALSE; - } - else - { - return TRUE; - } - } - else - { - $ns -> tablerender(LAN_ERROR,$directory ." ".LAN_NOTWRITABLE); - return FALSE; - } - } - -// ------------------------------------------------------------------------- - - -} // end class. - - -function download_adminmenu($parms) -{ - global $download; - global $action; - $download->show_options($action); -} - - - - - -?>