diff --git a/e107_plugins/download/download.php b/e107_plugins/download/download.php index 36be286a0..c52c749ef 100644 --- a/e107_plugins/download/download.php +++ b/e107_plugins/download/download.php @@ -11,32 +11,26 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/download/download.php,v $ -| $Revision: 1.4 $ -| $Date: 2009-01-14 22:53:38 $ +| $Revision: 1.5 $ +| $Date: 2009-02-11 21:41:54 $ | $Author: bugrain $ | +----------------------------------------------------------------------------+ */ - require_once("../../class2.php"); if (!plugInstalled('download')) { exit(); } include_lan(e_PLUGIN.'download/languages/'.e_LANGUAGE.'/lan_download.php'); +require_once(e_PLUGIN.'download/handlers/download_class.php'); +require_once(e_PLUGIN.'download/handlers/category_class.php'); require_once(e_PLUGIN.'download/download_shortcodes.php'); require_once(e_HANDLER.'comment_class.php'); -$cobj = new comment; -global $tp; - +$dl = new download(); +$cobj = new comment(); $dl_text = ''; // Output variable if(!defined("USER_WIDTH")) { define("USER_WIDTH","width:100%"); } -// Following two now set in prefs -// To prevent display of sub-categories on the main display, change the value in the following line from '1' to '0' -//$pref['download_subsub'] = '1'; -// To include file counts and sizes from subcategories and subsubcategories in superior categories, change the following to '1' -//$pref['download_incinfo'] = '1'; - /* define images */ define("IMAGE_DOWNLOAD", (file_exists(THEME."images/download.png") ? THEME."images/download.png" : e_IMAGE."generic/download.png")); define("IMAGE_NEW", (file_exists(THEME."images/new.png") ? THEME."images/new.png" : e_IMAGE."generic/new.png")); @@ -60,173 +54,151 @@ $template_load_core = ' $order_options = array('download_id','download_datestamp','download_requested','download_name','download_author','download_requested'); $sort_options = array('ASC', 'DESC'); - if (!e_QUERY || $_GET['elan']) { - $action = 'maincats'; // List categories - $maincatval = ''; // Show all main categories + $action = 'maincats'; // List categories + $maincatval = ''; // Show all main categories } else { // Get parameters from the query - $maincatval = ''; // Show all main categories - $tmp = explode(".", e_QUERY); - if (is_numeric($tmp[0])) // $tmp[0] at least must be valid - { - $dl_from = intval($tmp[0]); - $action = varset(preg_replace("#\W#", "", $tp -> toDB($tmp[1])),'list'); - $id = intval($tmp[2]); - $view = intval($tmp[3]); - $order = preg_replace("#\W#", "", $tp -> toDB($tmp[4])); - $sort = preg_replace("#\W#", "", $tp -> toDB($tmp[5])); - } - else - { - $action = preg_replace("#\W#", "", $tp -> toDB($tmp[0])); - $id = intval($tmp[1]); - $errnum = intval(varset($tmp[2],0)); - } - switch ($action) - { - case 'list' : // Category-based listing - if (isset($_POST['view'])) - { - $view = intval($_POST['view']); - $sort = varset($_POST['sort'],'DESC'); - $order = varset($_POST['order'],'download_datestamp'); - } - if (!isset($dl_from)) $dl_from = 0; + $maincatval = ''; // Show all main categories + $tmp = explode(".", e_QUERY); + if (is_numeric($tmp[0])) // $tmp[0] at least must be valid + { + $dl_from = intval($tmp[0]); + $action = varset(preg_replace("#\W#", "", $tp->toDB($tmp[1])),'list'); + $id = intval($tmp[2]); + $view = intval($tmp[3]); + $order = preg_replace("#\W#", "", $tp->toDB($tmp[4])); + $sort = preg_replace("#\W#", "", $tp->toDB($tmp[5])); + } + else + { + $action = preg_replace("#\W#", "", $tp->toDB($tmp[0])); + $id = intval($tmp[1]); + $errnum = intval(varset($tmp[2],0)); + } + switch ($action) + { + case 'list' : // Category-based listing + if (isset($_POST['view'])) + { + $view = intval($_POST['view']); + $sort = varset($_POST['sort'],'DESC'); + $order = varset($_POST['order'],'download_datestamp'); + } + if (!isset($dl_from)) $dl_from = 0; - // Get category type, page title - if ($sql->db_Select("download_category", "download_category_name,download_category_description,download_category_parent,download_category_class", "(download_category_id='{$id}') AND (download_category_class IN (".USERCLASS_LIST."))") ) - { - $row = $sql->db_Fetch(); - extract($row); - $type = "".$download_category_name.""; - $type .= ($download_category_description) ? " [".$download_category_description."]" : ""; - define("e_PAGETITLE", PAGE_NAME." / ".$download_category_name); - } - else - { // No access to this category - define("e_PAGETITLE", PAGE_NAME); - require_once(HEADERF); - $ns->tablerender(LAN_dl_18, "
".LAN_dl_3."
"); - require_once(FOOTERF); - exit; - } - if ($download_category_parent == 0) - { // It's a main category - change the listing type required - $action = 'maincats'; - $maincatval = $id; - } - break; - case 'view' : // Details of individual download - break; - case 'report' : - break; - case 'mirror' : - break; - case 'error' : // Errors passed from request.php - define("e_PAGETITLE", PAGE_NAME); - require_once(HEADERF); - switch ($errnum) - { - case 1 : - $errmsg = LAN_dl_63; // No permissions - break; - case 2 : - $errmsg = LAN_dl_62; // Quota exceeded - break; - default: - $errmsg = LAN_dl_61." ".$errnum; // Generic error - shouldn't happen - } - $ns->tablerender(LAN_dl_61, "
".$errmsg."
"); - require_once(FOOTERF); - exit; - } + // Get category type, page title + if ($sql->db_Select("download_category", "download_category_name,download_category_description,download_category_parent,download_category_class", "(download_category_id='{$id}') AND (download_category_class IN (".USERCLASS_LIST."))") ) + { + $dlrow = $sql->db_Fetch(); + extract($dlrow); + $type = $download_category_name; + define("e_PAGETITLE", PAGE_NAME." / ".$download_category_name); + } + else + { // No access to this category + define("e_PAGETITLE", PAGE_NAME); + require_once(HEADERF); + $ns->tablerender(LAN_dl_18, "
".LAN_dl_3."
"); + require_once(FOOTERF); + exit; + } + if ($download_category_parent == 0) + { // It's a main category - change the listing type required + $action = 'maincats'; + $maincatval = $id; + } + break; + case 'view' : // Details of individual download + break; + case 'report' : + break; + case 'mirror' : + break; + case 'error' : // Errors passed from request.php + define("e_PAGETITLE", PAGE_NAME); + require_once(HEADERF); + switch ($errnum) + { + case 1 : + $errmsg = LAN_dl_63; // No permissions + break; + case 2 : + $errmsg = LAN_dl_62; // Quota exceeded + break; + default: + $errmsg = LAN_dl_61." ".$errnum; // Generic error - shouldn't happen + } + $ns->tablerender(LAN_dl_61, "
".$errmsg."
"); + require_once(FOOTERF); + exit; + } } if (isset($order) && !in_array($order,$order_options)) unset($order); if (isset($sort) && !in_array($sort,$sort_options)) unset($sort); - if (!isset($order)) $order = varset($pref['download_order'],'download_datestamp'); if (!isset($sort)) $sort = varset($pref['download_sort'], 'DESC'); if (!isset($view)) $view = varset($pref['download_view'], '10'); - //-------------------------------------------------- // GENERATE DISPLAY TEXT //-------------------------------------------------- switch ($action) { // Displaying main category or categories - case 'maincats' : - require_once(HEADERF); - if ($cacheData = $e107cache->retrieve("download_cat".$maincatval,720)) // expires every 12 hours. - { - echo $cacheData; - require_once(FOOTERF); - exit; - } + case 'maincats' : + require_once(HEADERF); + if ($cacheData = $e107cache->retrieve("download_cat".$maincatval,720)) // expires every 12 hours. //TODO make this an option + { + echo $cacheData; + require_once(FOOTERF); + exit; + } - // Load the theme - $load_template = 'download_template'; - if (!isset($DOWNLOAD_CAT_PARENT_TABLE)) eval($template_load_core); + // Load the theme + $load_template = 'download_template'; + if (!isset($DOWNLOAD_CAT_PARENT_TABLE)) eval($template_load_core); - if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:1px solid blue");} + if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:1px solid blue");} - // Read in tree of categories which this user is allowed to see - $dl = new down_cat_handler(varset($pref['download_subsub'],1),USERCLASS_LIST,$maincatval,varset($pref['download_incinfo'],FALSE)); + // Read in tree of categories which this user is allowed to see + $dlcat = new downloadCategory(varset($pref['download_subsub'],1),USERCLASS_LIST,$maincatval,varset($pref['download_incinfo'],FALSE)); - if ($dl->down_count == 0) - { - $ns->tablerender(LAN_dl_18, "
".LAN_dl_2."
"); - require_once(FOOTERF); - exit; - } - else - { - $download_cat_table_string = ""; // Notice removal - foreach($dl->cat_tree as $row) - { // Display main category headings, then sub-categories, optionally with sub-sub categories expanded - $download_cat_table_string .= parse_download_cat_parent_table($row); - foreach($row['subcats'] as $crow) - { - $download_cat_table_string .= parse_download_cat_child_table($crow); - } - } - } + if ($dlcat->down_count == 0) + { + $ns->tablerender(LAN_dl_18, "
".LAN_dl_2."
"); + require_once(FOOTERF); + exit; + } - $download_cat_table_start = preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_CAT_TABLE_START); + $download_cat_table_string = ""; + foreach($dlcat->cat_tree as $dlrow) + { // Display main category headings, then sub-categories, optionally with sub-sub categories expanded + $download_cat_table_string .= $tp->parseTemplate($DOWNLOAD_CAT_PARENT_TABLE, TRUE, $download_shortcodes); + foreach($dlrow['subcats'] as $dlsubrow) + { + $download_cat_table_string .= $tp->parseTemplate($DOWNLOAD_CAT_CHILD_TABLE, TRUE, $download_shortcodes); + foreach($dlsubrow['subsubcats'] as $dlsubsubrow) + { + $download_cat_table_string .= $tp->parseTemplate($DOWNLOAD_CAT_SUBSUB_TABLE, TRUE, $download_shortcodes); + } + } + } + $dl_text = $tp->parseTemplate($DOWNLOAD_CAT_TABLE_START, TRUE, $download_shortcodes); + $dl_text .= $download_cat_table_string; + $dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_END, TRUE, $download_shortcodes); + $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18)); + $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); - $DOWNLOAD_CAT_NEWDOWNLOAD_TEXT = " ".LAN_dl_36; - $DOWNLOAD_CAT_SEARCH = " -
-

- - - -

-
"; - - $download_cat_table_end = preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_CAT_TABLE_END); - $dl_text = $download_cat_table_start.$download_cat_table_string.$download_cat_table_end; - - ob_start(); - - if(isset($DOWNLOAD_CAT_TABLE_RENDERPLAIN) && $DOWNLOAD_CAT_TABLE_RENDERPLAIN) - { - echo $dl_text; - } - else - { - $ns->tablerender(LAN_dl_18, $dl_text); - } - - $cache_data = ob_get_flush(); - $e107cache->set("download_cat".$maincatval, $cache_data); - - require_once(FOOTERF); - exit; - // Add other 'cases' here + ob_start(); + $ns->tablerender($dl_title, $dl_text); + $cache_data = ob_get_flush(); + $e107cache->set("download_cat".$maincatval, $cache_data); + require_once(FOOTERF); + exit; + // Add other 'cases' here } // End switch ($action) @@ -239,8 +211,8 @@ if (isset($_POST['commentsubmit'])) } else { - $row = $sql->db_Fetch(); - if ($row['download_comment'] && (ANON === TRUE || USER === TRUE)) + $dlrow = $sql->db_Fetch(); + if ($dlrow['download_comment'] && (ANON === TRUE || USER === TRUE)) { $clean_authorname = $_POST['author_name']; $clean_comment = $_POST['comment']; @@ -258,59 +230,47 @@ if (isset($_POST['commentsubmit'])) //==================================================== if ($action == "list") { - $total_downloads = $sql->db_Count("download", "(*)", "WHERE download_category = '{$id}' AND download_active > 0 AND download_visible REGEXP '".e_CLASS_REGEXP."'"); + $total_downloads = $sql->db_Count("download", "(*)", "WHERE download_category = '{$id}' AND download_active > 0 AND download_visible REGEXP '".e_CLASS_REGEXP."'"); - require_once(HEADERF); + require_once(HEADERF); /* SHOW SUBCATS ... */ - if($sql -> db_Select("download_category", "download_category_id", "download_category_parent='{$id}' ")) + if($sql->db_Select("download_category", "download_category_id", "download_category_parent='{$id}' ")) { /* there are subcats - display them ... */ $qry = " - SELECT dc.*, dc2.download_category_name AS parent_name, dc2.download_category_icon as parent_icon, SUM(d.download_filesize) AS d_size, - COUNT(d.download_id) AS d_count, - MAX(d.download_datestamp) as d_last, - SUM(d.download_requested) as d_requests - FROM #download_category AS dc - LEFT JOIN #download AS d ON dc.download_category_id = d.download_category AND d.download_active > 0 AND d.download_visible IN (".USERCLASS_LIST.") - LEFT JOIN #download_category as dc2 ON dc2.download_category_id='{$id}' - WHERE dc.download_category_class IN (".USERCLASS_LIST.") AND dc.download_category_parent='{$id}' - GROUP by dc.download_category_id ORDER by dc.download_category_order + SELECT dc.*, dc2.download_category_name AS parent_name, dc2.download_category_icon as parent_icon, SUM(d.download_filesize) AS d_size, + COUNT(d.download_id) AS d_count, + MAX(d.download_datestamp) as d_last, + SUM(d.download_requested) as d_requests + FROM #download_category AS dc + LEFT JOIN #download AS d ON dc.download_category_id = d.download_category AND d.download_active > 0 AND d.download_visible IN (".USERCLASS_LIST.") + LEFT JOIN #download_category as dc2 ON dc2.download_category_id='{$id}' + WHERE dc.download_category_class IN (".USERCLASS_LIST.") AND dc.download_category_parent='{$id}' + GROUP by dc.download_category_id ORDER by dc.download_category_order "; $sql->db_Select_gen($qry); - $scArray = $sql -> db_getList(); + $scArray = $sql->db_getList(); $load_template = 'download_template'; if (!isset($DOWNLOAD_CAT_PARENT_TABLE)) eval($template_load_core); if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:1px solid blue");} - foreach($scArray as $row) - { - $download_cat_table_string .= parse_download_cat_child_table($row, FALSE); - } - if(strstr($row['parent_icon'], chr(1))) { - list($download_category_icon, $download_category_icon_empty) = explode(chr(1), $row['parent_icon']); - } - $DOWNLOAD_CAT_MAIN_ICON = ($download_category_icon ? "" : " "); - $DOWNLOAD_CAT_MAIN_NAME = $tp->toHTML($row['parent_name'], FALSE, 'USER_TITLE'); - $download_cat_table_start = preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_CAT_TABLE_START); - $DOWNLOAD_CAT_NEWDOWNLOAD_TEXT = " ".LAN_dl_36; - $download_cat_table_end = preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_CAT_TABLE_END); - $text = $download_cat_table_start.$download_cat_table_string.$download_cat_table_end; - if($DOWNLOAD_CAT_TABLE_RENDERPLAIN) - { - echo $text; - } - else - { - $ns->tablerender($type, $text); - } + $download_cat_table_string = ""; + $dl_text = $tp->parseTemplate($DOWNLOAD_CAT_TABLE_PRE, TRUE, $download_shortcodes); + $dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_START, TRUE, $download_shortcodes); + foreach($scArray as $dlsubsubrow) + { + $dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_SUBSUB_TABLE, TRUE, $download_shortcodes); + } + $dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_END, TRUE, $download_shortcodes); + $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $type)); + $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); + $ns->tablerender($dl_title, $dl_text); $text = ""; // If other files, show in a separate block $type = ""; // Cancel title once displayed } // End of subcategory display -// Now display individual downloads - // Next line looks unnecessary -// $core_total = $sql->db_Count("download WHERE download_category='{$id}' AND download_active > 0 AND download_visible IN (".USERCLASS_LIST.")"); + // Now display individual downloads if (!check_class($download_category_class)) { $ns->tablerender(LAN_dl_18, "
".LAN_dl_3."
"); @@ -320,59 +280,39 @@ if ($action == "list") if ($total_downloads < $view) { $dl_from = 0; } - if(strstr($download_category_icon, chr(1))) - { - list($download_category_icon, $download_category_icon_empty) = explode(chr(1), $download_category_icon); - } - $DOWNLOAD_CATEGORY_ICON = ($download_category_icon ? "" : " "); - - $DOWNLOAD_CATEGORY = $tp->toHTML($download_category_name,FALSE,'USER_TITLE'); - $DOWNLOAD_CATEGORY_DESCRIPTION = $tp -> toHTML($download_category_description, TRUE,'DESCRIPTION'); - $load_template = 'download_template'; if (!isset($DOWNLOAD_LIST_TABLE)) eval($template_load_core); - if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:1px solid blue");} + if (!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:1px solid blue");} - $gen = new convert; require_once(e_HANDLER."rate_class.php"); - $rater = new rater; - $tdownloads = 0; + $dltdownloads = 0; // $dl_from - first entry to show (note - can get reset due to reuse of query, even if values overridden this time) // $view - number of entries per page // $total_downloads - total number of entries matching search criteria $filetotal = $sql->db_Select("download", "*", "download_category='{$id}' AND download_active > 0 AND download_visible IN (".USERCLASS_LIST.") ORDER BY {$order} {$sort} LIMIT {$dl_from}, {$view}"); - $ft = ($filetotal < $view ? $filetotal : $view); - while ($row = $sql->db_Fetch()) - { - extract($row); - $download_list_table_string .= parse_download_list_table($row); - $tdownloads += $download_requested; - } - - $DOWNLOAD_LIST_TOTAL_AMOUNT = $tdownloads." ".LAN_dl_16; - $DOWNLOAD_LIST_TOTAL_FILES = $ft." ".LAN_dl_17; - - $download_list_table_start = preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_LIST_TABLE_START); - $download_list_table_end = preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_LIST_TABLE_END); - $text .= $download_list_table_start.$download_list_table_string.$download_list_table_end; - - if ($filetotal) { // Only show list if some files in it - if($DOWNLOAD_LIST_TABLE_RENDERPLAIN) - { - echo $text; - } - else - { - $ns->tablerender($type, $text); - } + $dl_text = $tp->parseTemplate($DOWNLOAD_LIST_TABLE_START, TRUE, $download_shortcodes); + $dlft = ($filetotal < $view ? $filetotal : $view); + while ($dlrow = $sql->db_Fetch()) + { + $agreetext = $tp->toHTML($pref['agree_text'],TRUE,'DESCRIPTION'); + $current_row = ($current_row) ? 0 : 1; // Alternating CSS for each row.(backwards compatible) + $template = ($current_row == 1) ? $DOWNLOAD_LIST_TABLE : str_replace("forumheader3","forumheader3 forumheader3_alt",$DOWNLOAD_LIST_TABLE); + $dl_text .= $tp->parseTemplate($template,TRUE,$download_shortcodes);; + $dltdownloads += $dlrow['download_requested']; + } + + $dl_text .= $tp->parseTemplate($DOWNLOAD_LIST_TABLE_END, TRUE, $download_shortcodes); + $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $type)); + $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); + $ns->tablerender($dl_title, $dl_text); } if(!isset($DOWNLOAD_LIST_NEXTPREV)) { - $sc_style['DOWNLOAD_LIST_NEXTPREV']['pre'] = "
"; + $sc_style['DOWNLOAD_LIST_NEXTPREV']['pre'] = "
"; $sc_style['DOWNLOAD_LIST_NEXTPREV']['post'] = "
"; $DOWNLOAD_LIST_NEXTPREV = " @@ -382,12 +322,11 @@ if ($action == "list") } $nextprev_parms = $total_downloads.",".$view.",".$dl_from.",".e_SELF."?[FROM].list.{$id}.{$view}.{$order}.{$sort}."; - echo $tp->parseTemplate($DOWNLOAD_LIST_NEXTPREV, TRUE, $download_shortcodes); + echo $tp->parseTemplate($DOWNLOAD_LIST_NEXTPREV, TRUE, $download_shortcodes); require_once(FOOTERF); exit; -} // end of action=="list" - +} // end of action=="list" //==================================================== // VIEW @@ -409,16 +348,16 @@ if ($action == "view") AND dc.download_category_class IN (".USERCLASS_LIST.") LIMIT 1"; - if(!$sql -> db_Select_gen($query)){ + if(!$sql->db_Select_gen($query)){ require_once(HEADERF); $ns->tablerender(LAN_dl_18, "
".LAN_dl_3."
"); require_once(FOOTERF); exit; } - $dl = $sql -> db_Fetch(); + $dlrow = $sql->db_Fetch(); -$comment_edit_query = 'comment.download.'.$id; + $comment_edit_query = 'comment.download.'.$id; $load_template = 'download_template'; if (!isset($DOWNLOAD_VIEW_TABLE)) eval($template_load_core); @@ -436,11 +375,6 @@ $comment_edit_query = 'comment.download.'.$id; $DL_TEMPLATE = $DOWNLOAD_VIEW_TABLE_START.$DOWNLOAD_VIEW_TABLE.$DOWNLOAD_VIEW_TABLE_END; $text = $tp->parseTemplate($DL_TEMPLATE, TRUE, $download_shortcodes); - if(!isset($DL_VIEW_CAPTION)) - { - $DL_VIEW_CAPTION = "{DOWNLOAD_VIEW_CAPTION}"; - } - if(!isset($DL_VIEW_NEXTPREV)) { $DL_VIEW_NEXTPREV = " @@ -454,22 +388,18 @@ $comment_edit_query = 'comment.download.'.$id;
"; - } + } // ------- Next/Prev ----------- - $text .= $tp->parseTemplate($DL_VIEW_NEXTPREV,TRUE,$download_shortcodes); - $caption = $tp->parseTemplate($DL_VIEW_CAPTION,TRUE,$download_shortcodes); + $text .= $tp->parseTemplate($DL_VIEW_NEXTPREV,TRUE,$download_shortcodes); - if($DOWNLOAD_VIEW_TABLE_RENDERPLAIN) { - echo $text; - } else { - - $ns->tablerender($caption, $text); - } + $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $dlrow['download_category_name']=>e_SELF."?list.".$dlrow['download_category_id'], $dlrow['download_name'])); + $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); + $ns->tablerender($dl_title, $text); unset($text); - if ($dl['download_comment']) { - $cobj->compose_comment("download", "comment", $id, $width,$dl['download_name'], $showrate=FALSE); + if ($dlrow['download_comment']) { + $cobj->compose_comment("download", "comment", $id, $width,$dlrow['download_name'], $showrate=FALSE); } require_once(FOOTERF); @@ -482,18 +412,27 @@ $comment_edit_query = 'comment.download.'.$id; //==================================================== if ($action == "report" && check_class($pref['download_reportbroken'])) { - if (!$sql->db_Select("download", "*", "download_id = {$id} AND download_active > 0")) { + $query = " + SELECT d.*, dc.* FROM #download AS d + LEFT JOIN #download_category AS dc ON d.download_category = dc.download_category_id + WHERE d.download_id = {$id} + AND download_active > 0 + LIMIT 1"; + + if(!$sql->db_Select_gen($query)) + { + //if (!$sql->db_Select("download", "*", "download_id = {$id} AND download_active > 0")) { require_once(HEADERF); require_once(FOOTERF); exit; } - $row = $sql -> db_Fetch(); - extract($row); + $dlrow = $sql->db_Fetch(); + extract($dlrow); if (isset($_POST['report_download'])) { - $report_add = $tp -> toDB($_POST['report_add']); - $download_name = $tp -> toDB($download_name); + $report_add = $tp->toDB($_POST['report_add']); + $download_name = $tp->toDB($download_name); $user = USER ? USERNAME : LAN_dl_52; if ($pref['download_email']) { // this needs to be moved into the NOTIFY, with an event. @@ -510,44 +449,46 @@ if ($action == "report" && check_class($pref['download_reportbroken'])) require_once(HEADERF); $text = LAN_dl_48."

".LAN_dl_49."tablerender(LAN_dl_50, $text); - + $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $dlrow['download_category_name']=>e_SELF."?list.".$dlrow['download_category_id'], $dlrow['download_name']=>e_SELF."?view.".$dlrow['download_id'], LAN_dl_50)); + $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); + $ns->tablerender($dl_title, $text); } else { define("e_PAGETITLE", PAGE_NAME." / ".LAN_dl_51." ".$download_name); require_once(HEADERF); $text = "
- - - - - - - - - - - - -
- ".LAN_dl_32.": ".$download_name."
- - ".LAN_dl_53." - -
-
".LAN_dl_54."
".LAN_dl_55." -
- -

- -
"; - $ns->tablerender(LAN_dl_50, $text); + + + + + + + + + + + + +
+ ".LAN_dl_32.": ".$download_name."
+ + ".LAN_dl_53." + +
+
".LAN_dl_54."
".LAN_dl_55."
+ +

+ +
+
"; + $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $dlrow['download_category_name']=>e_SELF."?list.".$dlrow['download_category_id'], $dlrow['download_name']=>e_SELF."?view.".$dlrow['download_id'], LAN_dl_50)); + $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); + $ns->tablerender($dl_title, $text); } require_once(FOOTERF); exit; } - //==================================================== // MIRRORS //==================================================== @@ -558,15 +499,19 @@ if($action == "mirror") $load_template = 'download_template'; if (!isset($DOWNLOAD_MIRROR_START)) eval($template_load_core); - $sql -> db_Select("download_mirror"); - $mirrorList = $sql -> db_getList("ALL", 0, 200, "mirror_id"); + $sql->db_Select("download_mirror"); + $mirrorList = $sql->db_getList("ALL", 0, 200, "mirror_id"); - if($sql -> db_Select("download", "*", "download_id = {$id}")) + $query = " + SELECT d.*, dc.* FROM #download AS d + LEFT JOIN #download_category AS dc ON d.download_category = dc.download_category_id + WHERE d.download_id = {$id} + LIMIT 1"; + + if($sql->db_Select_gen($query)) { - $row = $sql->db_Fetch(); - - extract($row); - $array = explode(chr(1), $download_mirror); + $dlrow = $sql->db_Fetch(); + $array = explode(chr(1), $dlrow['download_mirror']); if (2 == varset($pref['mirror_order'])) { // Order by name, sort array manually @@ -589,32 +534,21 @@ if($action == "mirror") } } - $download_mirror = ""; + $dl_text = $tp->parseTemplate($DOWNLOAD_MIRROR_START, TRUE, $download_shortcodes); + $download_mirror = 1; foreach($array as $mirrorstring) { - if($mirrorstring) - { - $download_mirror .= parse_download_mirror_table($row, $mirrorstring, $mirrorList); - } + if($mirrorstring) + { + $dlmirrorfile = explode(",", $mirrorstring); + $dlmirror = $mirrorList[$dlmirrorfile[0]]; + $dl_text .= $tp->parseTemplate($DOWNLOAD_MIRROR, TRUE, $download_shortcodes); + } } - - $DOWNLOAD_MIRROR_HOST_LAN = LAN_dl_68; - $DOWNLOAD_MIRROR_GET_LAN = LAN_dl_32; - $DOWNLOAD_MIRROR_LOCATION_LAN = LAN_dl_70; - $DOWNLOAD_MIRROR_DESCRIPTION_LAN = LAN_dl_71; - $DOWNLOAD_MIRROR_REQUEST = LAN_dl_72."'".$download_name."'"; - - $download_mirror_start = preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_MIRROR_START); - $download_mirror_end = preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_MIRROR_END); - - $text = $download_mirror_start.$download_mirror.$download_mirror_end; - - if($DOWNLOAD_MIRROR_RENDERPLAIN) { - echo $text; - } else { - $ns->tablerender(LAN_dl_67, $text); - } - + $dl_text .= $tp->parseTemplate($DOWNLOAD_MIRROR_END, TRUE, $download_shortcodes); + $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $dlrow['download_category_name']=>e_SELF."?list.".$dlrow['download_category_id'], $dlrow['download_name']=>e_SELF."?view.".$dlrow['download_id'], LAN_dl_67)); + $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); + $ns->tablerender($dl_title, $dl_text); require_once(FOOTERF); } } @@ -628,276 +562,4 @@ function sort_download_mirror_order($a, $b) } return ($a[1] < $b[1]) ? -1 : 1; } - -function parse_download_mirror_table($row, $mirrorstring, $mirrorList) -{ - - global $DOWNLOAD_MIRROR, $e107; - list($mirrorHost_id, $mirrorHost_url, $mirrorRequests, $mirrorFilesize) = explode(",", $mirrorstring); - - extract($mirrorList[$mirrorHost_id]); - - $DOWNLOAD_MIRROR_NAME = "
{$mirror_name}"; - $DOWNLOAD_MIRROR_IMAGE = ($mirror_image ? "" : ""); - $DOWNLOAD_MIRROR_LOCATION = ($mirror_location ? $mirror_location : ""); - $DOWNLOAD_MIRROR_DESCRIPTION = ($mirror_description ? $mirror_description : ""); - - $DOWNLOAD_MIRROR_FILESIZE = $e107->parseMemorySize($mirrorFilesize); - $DOWNLOAD_MIRROR_LINK = ""; - - $DOWNLOAD_MIRROR_REQUESTS = (ADMIN ? LAN_dl_73.$mirrorRequests : ""); - $DOWNLOAD_TOTAL_MIRROR_REQUESTS = (ADMIN ? LAN_dl_74.$mirror_count : ""); - - return(preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_MIRROR)); -} - - - - -function parse_download_cat_parent_table($row) -{ - global $tp,$e107,$current_row,$DOWNLOAD_CAT_PARENT_TABLE; - extract($row); - $current_row = ($current_row) ? 0 : 1; // Alternating CSS for each row.(backwards compatible) - - $template = ($current_row == 1) ? $DOWNLOAD_CAT_PARENT_TABLE : str_replace("forumheader3","forumheader3 forumheader3_alt",$DOWNLOAD_CAT_PARENT_TABLE); - - $DOWNLOAD_CAT_MAIN_ICON = ''; - $DOWNLOAD_CAT_MAIN_NAME = ''; - $DOWNLOAD_CAT_MAIN_DESCRIPTION = ''; - - if (check_class($download_category_class)) - { - if(strstr($download_category_icon, chr(1))) - { - list($download_category_icon, $download_category_icon_empty) = explode(chr(1), $download_category_icon); - } - $DOWNLOAD_CAT_MAIN_ICON = ($download_category_icon ? "" : " "); - $DOWNLOAD_CAT_MAIN_NAME = $tp->toHTML($download_category_name,FALSE,'USER_TITLE'); - $DOWNLOAD_CAT_MAIN_DESCRIPTION = $tp->toHTML($row['download_category_description'],TRUE,'DESCRIPTION'); - } - return(preg_replace("/\{(.*?)\}/e", '$\1', $template)); -} - - - function get_cat_icons($source, $count) - { - if (!$source) return " "; - list($ret[TRUE],$ret[FALSE]) = explode(chr(1), $source.chr(1)); - if (!$ret[FALSE]) $ret[FALSE] = $ret[TRUE]; - return ""; - } - - function check_new_download($last_val) - { - if(USER && ($last_val > USERLV)) - { - return ""; - } - else - { - return ""; - } - } - - -function parse_download_cat_child_table($row) -{ - global $tp,$e107,$current_row, $DOWNLOAD_CAT_CHILD_TABLE, $DOWNLOAD_CAT_SUBSUB_TABLE; - - $current_row = ($current_row) ? 0 : 1; // Alternating CSS for each row.(backwards compatible) - $template = ($current_row == 1) ? $DOWNLOAD_CAT_CHILD_TABLE : str_replace("forumheader3","forumheader3 forumheader3_alt",$DOWNLOAD_CAT_CHILD_TABLE); - - $DOWNLOAD_CAT_SUB_ICON = get_cat_icons($row['download_category_icon'],$row['d_count']); - $DOWNLOAD_CAT_SUB_NEW_ICON = check_new_download($row['d_last_subs']); - $dcatname=$tp->toHTML($row['download_category_name'],FALSE,'USER_TITLE'); - $DOWNLOAD_CAT_SUB_NAME = ($row['d_count'] ? "".$dcatname."" : $dcatname); - $DOWNLOAD_CAT_SUB_NAME_LINKED = "".$dcatname.""; - $DOWNLOAD_CAT_SUB_DESCRIPTION = $tp->toHTML($row['download_category_description'],TRUE,'DESCRIPTION'); - $DOWNLOAD_CAT_SUB_COUNT = $row['d_count']; - $DOWNLOAD_CAT_SUB_SIZE = $e107->parseMemorySize($row['d_size']); - $DOWNLOAD_CAT_SUB_DOWNLOADED = intval( $row['d_requests']); - $DOWNLOAD_CAT_SUBSUB = ""; - // check for subsub cats ... - foreach($row['subsubcats'] as $subrow) - { - $DOWNLOAD_CAT_SUBSUB_ICON = get_cat_icons($subrow['download_category_icon'],$subrow['d_count']); - $DOWNLOAD_CAT_SUBSUB_DESCRIPTION = $tp->toHTML($subrow['download_category_description'],TRUE,'DESCRIPTION'); - $DOWNLOAD_CAT_SUBSUB_COUNT = intval($subrow['d_count']); - $DOWNLOAD_CAT_SUBSUB_SIZE = $e107->parseMemorySize($subrow['d_size']); - $DOWNLOAD_CAT_SUBSUB_DOWNLOADED = intval($subrow['d_requests']); - - $DOWNLOAD_CAT_SUBSUB_NEW_ICON = check_new_download($subrow['d_last']); - $DOWNLOAD_CAT_SUBSUB_NAME = ($subrow['d_count'] ? "".$tp->toHTML($subrow['download_category_name'], FALSE, 'USER_TITLE')."" : $tp->toHTML($subrow['download_category_name'],FALSE,'USER_TITLE')); - $DOWNLOAD_CAT_SUBSUB .= preg_replace("/\{(.*?)\}/e", '$\1', $DOWNLOAD_CAT_SUBSUB_TABLE); - } - - return(preg_replace("/\{(.*?)\}/e", '$\1', $template)); -} - - -function parse_download_list_table($row) -{ -// ***** $agreetext may not need to be global - global $download_shortcodes,$tp,$current_row,$DOWNLOAD_LIST_TABLE, $rater, $pref, $gen, $agreetext; - - $agreetext = $tp->toHTML($pref['agree_text'],TRUE,'DESCRIPTION'); - $current_row = ($current_row) ? 0 : 1; // Alternating CSS for each row.(backwards compatible) - $template = ($current_row == 1) ? $DOWNLOAD_LIST_TABLE : str_replace("forumheader3","forumheader3 forumheader3_alt",$DOWNLOAD_LIST_TABLE); - - return $tp->parseTemplate($template,TRUE,$download_shortcodes); - -} - - -//============================================= -// DOWNLOAD CATEGORY CLASS -//============================================= - -class down_cat_handler -{ - var $cat_tree; // Initialised with all categories in a tree structure - var $cat_count; // Count visible subcats and subsubcats - var $down_count; // Counts total downloads - - function down_cat_handler($nest_level = 1, $load_class = USERCLASS_LIST, $main_cat_load = '', $accum = FALSE) - { // Constructor - make a copy of the tree for re-use - // $nest_level = 0 merges subsubcats with subcats. >0 creates full tree. - // If load-class non-null, assumed to be a 'class set' such as USERCLASS_LIST - // If $accum is TRUE, include file counts and sizes in superior categories - define("SUB_PREFIX","-->"); // Added in front of sub categories - define("SUBSUB_PREFIX","---->"); // Added in front of sub-sub categories - $this->cat_tree = $this->down_cat_tree($nest_level,$load_class, $main_cat_load, $accum); - } - - -// Function returns a 'tree' of download categories, subcategories, and sub-sub-categories. -// Returns empty array if nothing defined -// Within the 'main category' level of the nesting, array 'subcats' has the next level's info -// Within the 'sub-category' level of the nesting, array 'subsubcats' has the next level's info -// If $main_cat_load is numeric, and the value of a 'main' category, only that main category is displayed. -// (Unpredictable if $main_cat_load is some other category) - function down_cat_tree($nest_level = 1, $load_cat_class = USERCLASS_LIST, $main_cat_load = '', $accum = FALSE) - { - global $sql2; - - $catlist = array(); - $this->cat_count = 0; - $this->down_count = 0; - $temp2 = ""; - $temp1 = ""; - if ($load_cat_class != "") - { - $temp1 = " WHERE dc.download_category_class IN ({$load_cat_class}) "; - $temp2 = "AND d.download_visible IN ({$load_cat_class}) "; - } - - $qry = " - SELECT dc.*, - dc1.download_category_parent AS d_parent1, dc1.download_category_order, - SUM(d.download_filesize) AS d_size, - COUNT(d.download_id) AS d_count, - MAX(d.download_datestamp) as d_last, - SUM(d.download_requested) as d_requests - FROM #download_category as dc - LEFT JOIN #download_category as dc1 ON dc1.download_category_id=dc.download_category_parent - LEFT JOIN #download_category as dc2 ON dc2.download_category_id=dc1.download_category_parent - LEFT JOIN #download AS d on d.download_category = dc.download_category_id AND d.download_active > 0 {$temp2} - {$temp1} - GROUP by dc.download_category_id - ORDER by dc2.download_category_order, dc1.download_category_order, dc.download_category_order"; // This puts main categories first, then sub-cats, then sub-sub cats - - if (!$sql2->db_Select_gen($qry)) return $catlist; - - while ($row = $sql2->db_Fetch()) - { - $tmp = $row['download_category_parent']; - if ($tmp == '0') - { // Its a main category - if (!is_numeric($main_cat_load) || ($main_cat_load == $row['download_category_id'])) - { - $row['subcats'] = array(); - $catlist[$row['download_category_id']] = $row; - } - } - else - { - if (isset($catlist[$tmp])) - { // Sub-Category - $this->cat_count++; - $this->down_count += $row['d_count']; - $catlist[$tmp]['subcats'][$row['download_category_id']] = $row; - $catlist[$tmp]['subcats'][$row['download_category_id']]['subsubcats'] = array(); - $catlist[$tmp]['subcats'][$row['download_category_id']]['d_last_subs'] = - $catlist[$tmp]['subcats'][$row['download_category_id']]['d_last']; - } - else - { // Its a sub-sub category - if (isset($catlist[$row['d_parent1']]['subcats'][$tmp])) - { - $this->cat_count++; - $this->down_count += $row['d_count']; - if ($accum || ($nest_level == 0)) - { // Add the counts into the subcategory values - $catlist[$row['d_parent1']]['subcats'][$tmp]['d_size'] += $row['d_size']; - $catlist[$row['d_parent1']]['subcats'][$tmp]['d_count'] += $row['d_count']; - $catlist[$row['d_parent1']]['subcats'][$tmp]['d_requests'] += $row['d_requests']; - } - if ($nest_level == 0) - { // Reflect subcat dates in category - if ($catlist[$row['d_parent1']]['subcats'][$tmp]['d_last'] < $row['d_last']) - $catlist[$row['d_parent1']]['subcats'][$tmp]['d_last'] = $row['d_last']; - } - else - { - $catlist[$row['d_parent1']]['subcats'][$tmp]['subsubcats'][$row['download_category_id']] = $row; - } - // Separately accumulate 'last update' for subcat plus associated subsubcats - if ($catlist[$row['d_parent1']]['subcats'][$tmp]['d_last_subs'] < $row['d_last']) - $catlist[$row['d_parent1']]['subcats'][$tmp]['d_last_subs'] = $row['d_last']; - } - } - } - } - return $catlist; - } - - -// Rest of the class isn't actually used normally, but print_tree() might help with debug - - function print_cat($cat, $prefix,$postfix) - { - $text = "".$cat['download_category_id']."".$cat['download_category_parent'].""; - $text .= $prefix.htmlspecialchars($cat['download_category_name']).$postfix."".$cat['d_size'].""; - $text .= "".$cat['d_count']."".$cat['d_requests']."".strftime('%H:%M %d-%m-%Y',$cat['d_last']).""; - $text .= ""; - return $text; - } - - function print_tree() - { - echo ""; - foreach ($this->cat_tree as $thiscat) - { // Main categories - $scprefix = SUB_PREFIX; - echo $this->print_cat($thiscat,'',''); - foreach ($thiscat['subcats'] as $sc) - { // Sub-categories - $sscprefix = SUBSUB_PREFIX; - echo $this->print_cat($sc,$scprefix,''); - foreach ($sc['subsubcats'] as $ssc) - { // Sub-sub categories - echo $this->print_cat($ssc,$sscprefix,''); - } - } - } - echo "
IDParentNameBytesFilesRequestsLast Download
"; - return; - } - -} - - - - -?> +?> \ No newline at end of file diff --git a/e107_plugins/download/download_admin.php b/e107_plugins/download/download_admin.php index 5139838d4..e28985b16 100644 --- a/e107_plugins/download/download_admin.php +++ b/e107_plugins/download/download_admin.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/download/download_admin.php,v $ -| $Revision: 1.6 $ -| $Date: 2009-01-17 19:17:56 $ +| $Revision: 1.7 $ +| $Date: 2009-02-11 21:41:54 $ | $Author: bugrain $ +----------------------------------------------------------------------------+ */ @@ -29,6 +29,7 @@ if (!getperms("P") || !plugInstalled('download')) include_lan(e_PLUGIN.'download/languages/'.e_LANGUAGE.'/lan_download.php'); include_lan(e_PLUGIN.'download/languages/'.e_LANGUAGE.'/lan_download_admin.php'); +require_once(e_PLUGIN.'download/handlers/download_class.php'); require_once(e_HANDLER."calendar/calendar_class.php"); require_once(e_HANDLER."ren_help.php"); $cal = new DHTML_Calendar(true); @@ -53,7 +54,8 @@ $pst->page = array("download.php?create","download.php?cat"); // display preset $pst->id = array("admin_downloads","admin_dl_cat"); // ------------------------------- -$download = new download; +$download = new download(); +$adminDownload = new adminDownload(); require_once(e_ADMIN."auth.php"); $pst->save_preset(); // unique name(s) for the presets - comma separated. @@ -65,14 +67,15 @@ $pst->save_preset("admin_downloads"); // unique name for the preset */ $rs = new form; -$sub_action = ''; +$subAction = ''; if (e_QUERY) { $tmp = explode(".", e_QUERY); $action = $tmp[0]; - $sub_action = varset($tmp[1],''); + $subAction = varset($tmp[1],''); $id = intval(varset($tmp[2],'')); $from = varset($tmp[3], 0); + $maintPage = varset($tmp[4], ''); unset($tmp); } @@ -88,46 +91,6 @@ if(isset($_POST['delete'])) $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_FILE."public/")) -{ - foreach($public_array as $key=>$val) - { - $file_array[] = str_replace(e_FILE."public/","",$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"); @@ -135,15 +98,15 @@ if(isset($_POST)) if (isset($_POST['add_category'])) { - $download->create_category($sub_action, $id); + $adminDownload->create_category($subAction, $id); } if (isset($_POST['submit_download'])) { - $download->submit_download($sub_action, $id); + $adminDownload->submit_download($subAction, $id); $action = "main"; - unset($sub_action, $id); + unset($subAction, $id); } @@ -263,7 +226,7 @@ if(isset($_POST['updatelimits'])) if(isset($_POST['submit_mirror'])) { - $download->submit_mirror($sub_action, $id); + $adminDownload->submit_mirror($subAction, $id); } @@ -276,14 +239,14 @@ if($action == "mirror") if ($action == "dlm") { $action = "create"; - $id = $sub_action; - $sub_action = "dlm"; + $id = $subAction; + $subAction = "dlm"; } if ($action == "create") { - $download->create_download($sub_action, $id); + $adminDownload->create_download($subAction, $id); } @@ -299,7 +262,7 @@ if ($delete == 'category') if ($action == 'cat') { - $download->show_categories($sub_action, $id); + $adminDownload->show_categories($subAction, $id); } @@ -312,7 +275,7 @@ if ($delete == 'main') admin_purge_related('download', $del_id); $e_event->trigger('dldelete', $del_id); } - unset($sub_action, $id); + unset($subAction, $id); } @@ -322,10 +285,16 @@ if (isset($message)) } +if ($from === "maint" && isset($_POST['submit_download'])) +{ // Return to one of the maintanence pages after submitting the create/edit form + $action = $from; + $subAction = $maintPage; +} if (!e_QUERY || $action == "main") { - $download->show_existing_items($action, $sub_action, $id, $from, $amount); + $adminDownload->show_filter_form($action, $subAction, $id, $from, $amount); + $adminDownload->show_existing_items($action, $subAction, $id, $from, $amount); } @@ -344,8 +313,8 @@ if ($action == "opt") - ".DOWLAN_69." - "; + ".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' " : ""; @@ -353,31 +322,31 @@ if ($action == "opt") - ".DOWLAN_158." - + ".DOWLAN_158." + - ".DOWLAN_159." - + ".DOWLAN_159." + - + ".DOWLAN_55." - + - + ".DOWLAN_56." - + - + ".LAN_ORDER." - + - ".DOWLAN_160." - + ".DOWLAN_160." + - ".DOWLAN_151." - ". r_userclass("download_reportbroken", $pref['download_reportbroken'])." + ".DOWLAN_151." + ". r_userclass("download_reportbroken", $pref['download_reportbroken'])." - ".DOWLAN_150." - ". ($pref['download_email'] ? "" : "")." + ".DOWLAN_150." + ". ($pref['download_email'] ? "" : "")." - ".DOWLAN_100." - ". ($agree_flag ? "" : "")." + ".DOWLAN_100." + ". ($agree_flag ? "" : "")." - + ".DOWLAN_101." - + - + ".DOWLAN_146." - + - + @@ -463,6 +432,320 @@ if ($action == "opt") $ns->tablerender(DOWLAN_54, $text); } +if ($action == 'maint') +{ + global $pref, $ns; + switch ($subAction) + { + case 'duplicates': + { + $title = DOWLAN_166; + //$query = 'SELECT count(download_url), download_id, download_url FROM #download where download_url <> "" group by download_url'; + //$query = 'SELECT count(d1.download_url) AS c,d1.download_id As d1id,d2.download_id AS d2id FROM #download AS d1 + // JOIN #download AS d2 ON d1.download_url=d2.download_url + // WHERE (d1.download_url <> "" and d1.download_url = d2.download_url) + // AND d1.download_iddb_Select_gen($query,true); + //echo mysql_error(); + //var_dump($res); + //while($row = $sql->db_Fetch()) { + // var_dump($row); + //} + $text = ""; + $query = "SELECT d.*, dc.* FROM `#download` AS d + LEFT JOIN `#download_category` AS dc ON dc.download_category_id=d.download_category + WHERE download_url<>'' + ORDER BY download_url ASC, download_id ASC"; + $count = $sql->db_Select_gen($query); + $foundSome = false; + if ($count) { + $currentURL = ""; + while($row = $sql->db_Fetch()) { + if (!$foundSome) { + $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $foundSome = true; + } + $text .= ''; + if ($currentURL != $row['download_url']) { + $text .= ''; + $currentURL = $row['download_url']; + } else { + $text .= ''; + } + $text .= ''; + $text .= "'; + $text .= ''; + $text .= ''; + $text .= ''; + } + } + if ($foundSome) { + $text .= '
'.DOWLAN_13.''.DOWLAN_67.''.DOWLAN_27.''.DOWLAN_11.''.LAN_OPTIONS.'
'.$row['download_url'].'*'.$row['download_id'].'".$row['download_name'].''.$row['download_category_name'].' + '.ADMIN_EDIT_ICON.' + toJS(DOWLAN_33.' [ID: '.$row["download_id"].' ]').'") \' /> +
'; + } + else + { + $text = DOWLAN_172; + } + break; + } + case 'orphans': + { + $title = DOWLAN_167; + $text = ""; + require_once(e_HANDLER."file_class.php"); + $efile = new e_file(); + $files = $efile->get_files(e_DOWNLOAD); + $foundSome = false; + foreach($files as $file) { + if (0 == $sql->db_Count('download', '(*)', " WHERE download_url='".$file['fname']."'")) { + if (!$foundSome) { + $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); + $text .= ''; + $text .= ''; + $text .= ''; +//TODO $text .= ''; + $text .= ''; + $foundSome = true; + } + $text .= ''; + $text .= ''; +//TODO $text .= ''; +//TODO $text .= ''; + } + } + if ($foundSome) { + $text .= '
'.DOWLAN_13.''.LAN_OPTIONS.'
'.$file['fname'].' +//TODO '.E_16_CREATE.' +//TODO toJS(DOWLAN_173.' [ '.$file["fname"].' ]').'") \' /> +//TODO
'; + } + else + { + $text = DOWLAN_174; + } + break; + } + case 'missing': + { + $title = DOWLAN_168; + $text = ""; + $query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc.download_category_id=d.download_category"; + $count = $sql->db_Select_gen($query); + $foundSome = false; + if ($count) { + while($row = $sql->db_Fetch()) { + if (!is_readable(e_DOWNLOAD.$row['download_url'])) { + if (!$foundSome) { + $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $foundSome = true; + } + $text .= ''; + $text .= ''; + $text .= "'; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + } + } + } + if ($foundSome) { + $text .= '
'.DOWLAN_67.''.DOWLAN_27.''.DOWLAN_11.''.DOWLAN_13.''.LAN_OPTIONS.'
'.$row['download_id'].'".$row['download_name'].''.$row['download_category_name'].''.$row['download_url'].' + '.ADMIN_EDIT_ICON.' + toJS(DOWLAN_33.' [ID: '.$row["download_id"].' ]').'") \' /> +
'; + } + else + { + $text = DOWLAN_172; + } + break; + } + case 'inactive': + { + $title = DOWLAN_169; + $text = ""; + $query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc.download_category_id=d.download_category WHERE download_active=0"; + $count = $sql->db_Select_gen($query); + $foundSome = false; + if ($count) { + while($row = $sql->db_Fetch()) { + if (!$foundSome) { + $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $foundSome = true; + } + $text .= ''; + $text .= ''; + $text .= "'; + $text .= ''; + if (strlen($row['download_url']) > 0) { + $text .= ''; + } else { + $mirrorArray = download::makeMirrorArray($row['download_mirror'], TRUE); + $text .= ''; + } + $text .= ''; + $text .= ''; + } + } + if ($foundSome) { + $text .= '
'.DOWLAN_67.''.DOWLAN_27.''.DOWLAN_11.''.DOWLAN_13.''.LAN_OPTIONS.'
'.$row['download_id'].'".$row['download_name'].''.$row['download_category_name'].''.$row['download_url'].''; + foreach($mirrorArray as $mirror) { + $text .= $mirror['url'].'
'; + } + $text .= '
+ '.ADMIN_EDIT_ICON.' + toJS(DOWLAN_33.' [ID: '.$row["download_id"].' ]').'") \' /> +
'; + } + else + { + $text = DOWLAN_172; + } + break; + } + case 'nocategory': + { + $title = DOWLAN_178; + $text = ""; + $query = "SELECT * FROM `#download` WHERE download_category=0"; + $count = $sql->db_Select_gen($query); + $foundSome = false; + if ($count) { + while($row = $sql->db_Fetch()) { + if (!$foundSome) { + $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $foundSome = true; + } + $text .= ''; + $text .= ''; + $text .= "'; + if (strlen($row['download_url']) > 0) { + $text .= ''; + } else { + $mirrorArray = download::makeMirrorArray($row['download_mirror'], TRUE); + $text .= ''; + } + $text .= ''; + $text .= ''; + } + } + if ($foundSome) { + $text .= '
'.DOWLAN_67.''.DOWLAN_27.''.DOWLAN_13.''.LAN_OPTIONS.'
'.$row['download_id'].'".$row['download_name'].''.$row['download_url'].''; + foreach($mirrorArray as $mirror) { + $text .= $mirror['url'].'
'; + } + $text .= '
+ '.ADMIN_EDIT_ICON.' + toJS(DOWLAN_33.' [ID: '.$row["download_id"].' ]').'") \' /> +
'; + } + else + { + $text = DOWLAN_172; + } + break; + } + case 'filesize': + { + $title = DOWLAN_170; + $text = ""; + $query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc.download_category_id=d.download_category WHERE d.download_url<>''"; + $count = $sql->db_Select_gen($query); + $foundSome = false; + if ($count) { + while($row = $sql->db_Fetch()) { + if (is_readable(e_DOWNLOAD.$row['download_url'])) { + $filesize = filesize(e_DOWNLOAD.$row['download_url']); + if ($filesize <> $row['download_filesize']) { + if (!$foundSome) { + $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $foundSome = true; + } + $text .= ''; + $text .= ''; + $text .= "'; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + } + } + } + } + if ($foundSome) { + $text .= '
'.DOWLAN_67.''.DOWLAN_27.''.DOWLAN_11.''.DOWLAN_13.''.DOWLAN_180.''.LAN_OPTIONS.'
'.$row['download_id'].'".$row['download_name'].''.$row['download_category_name'].''.$row['download_url'].''.$row['download_filesize'].' / '; + $text .= $filesize; + $text .= ' + '.ADMIN_EDIT_ICON.' + toJS(DOWLAN_33.' [ID: '.$row["download_id"].' ]').'") \' /> +
'; + } + else + { + $text = DOWLAN_172; + } + break; + } + case 'log': + { + $text = "log - view manage download history log"; + header('location: '.e_ADMIN.'admin_log.php?downlog'); + exit(); + break; + } + default: + { + $text = DOWLAN_179; + } + } + $ns->tablerender(DOWLAN_165.' - '.$title, $text); +} if($action == 'limits') @@ -482,7 +765,7 @@ if($action == 'limits')
- - - - + + - @@ -533,12 +816,12 @@ if($action == 'limits') - - + - @@ -563,9 +846,15 @@ exit; -class download +class adminDownload { - function show_existing_items($action, $sub_action, $id, $from, $amount) + function show_filter_form($action, $subAction, $id, $from, $amount) + { + global $download, $ns; + $text .= $download->getCategorySelectList($download_category); + $ns->tablerender(DOWLAN_FILTER, $text); + } + function show_existing_items($action, $subAction, $id, $from, $amount) { global $sql, $rs, $ns, $tp, $mySQLdefaultdb, $pref; $text = "
"; @@ -600,13 +889,13 @@ class download } else { - $query .= " ORDER BY ".($sub_action ? $sub_action : $sortorder)." ".($id ? $id : $sortdirection)." LIMIT $from, $amount"; + $query .= " ORDER BY ".($subAction ? $subAction : $sortorder)." ".($id ? $id : $sortdirection)." LIMIT $from, $amount"; } - if ($dl_count = $sql->db_Select_gen($query)) + if ($dl_count = $sql->db_Select_gen($query)) { - $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform")." -
+ "; if($pref['download_limits'] == 1) { @@ -509,13 +792,13 @@ if($action == 'limits') { $txt .= "
".$row['limit_id']."".r_userclass_name($row['limit_classnum'])." + ".$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")." + ".r_userclass("newlimit_class", 0, "off", "guest, member, admin, classes, language")." ".DOWLAN_109." ".DOWLAN_110." + ".DOWLAN_111." ".DOWLAN_109." ".DOWLAN_110."
+ $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform")." +
"; @@ -630,16 +919,16 @@ class download while ($row = $sql->db_Fetch()) { - $text .= ""; + $text .= ""; // Display Chosen options foreach($search_display as $disp) { - $text .= " @@ -706,7 +995,7 @@ class download $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]"; + $parms = "{$downloads},{$amount},{$from},".e_SELF."?".(e_QUERY ? "$action.$subAction.$id." : "main.{$sortorder}.{$sortdirection}.")."[FROM]"; $text .= "
".$tp->parseTemplate("{NEXTPREV={$parms}}"); } @@ -715,8 +1004,7 @@ class download $text .= "
\n

\n\n\n

"; $text .= "
".LAN_DISPLAYOPT."
"; - $text .= "
ID
".$row['download_id']."
".$row['download_id'].""; + $text .= ""; switch ($disp) { case "download_name" : - $text .= "".$row['download_name'].""; + $text .= "".$row['download_name'].""; break; case "download_category" : $text .= $row['download_category_name']." "; @@ -688,7 +977,7 @@ class download $text .= " - + ".ADMIN_EDIT_ICON." toJS(DOWLAN_33." [ID: ".$row['download_id']." ]")."') \" />
"; + $text .= "
"; $fields = mysql_list_fields($mySQLdefaultdb, MPREFIX."download"); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { @@ -724,55 +1012,68 @@ class download } $m = 0; $replacechar = array("download_","_"); - foreach($fname as $fcol) - { + foreach($fname as $fcol) + { $checked = (in_array($fcol,$search_display)) ? "checked='checked'" : ""; $text .= "\n"; $m++; - if($m == 5) - { + if($m == 5) + { $text .= ""; $m = 0; - } - } + } + } - $text .= "
"; $text .= "".str_replace($replacechar," ",$fcol) . "
+ $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['maint']['text'] = DOWLAN_165; + $var['maint']['link'] = e_SELF."?maint"; $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); } + function show_maint_options($action,$subAction) { + if ($action != "maint") { + return; + } + $var['duplicates']['text'] = DOWLAN_166; + $var['duplicates']['link'] = e_SELF."?maint.duplicates"; + $var['orphans']['text'] = DOWLAN_167; + $var['orphans']['link'] = e_SELF."?maint.orphans"; + $var['missing']['text'] = DOWLAN_168; + $var['missing']['link'] = e_SELF."?maint.missing"; + $var['inactive']['text'] = DOWLAN_169; + $var['inactive']['link'] = e_SELF."?maint.inactive"; + $var['nocategory']['text'] = DOWLAN_178; + $var['nocategory']['link'] = e_SELF."?maint.nocategory"; + $var['filesize']['text'] = DOWLAN_170; + $var['filesize']['link'] = e_SELF."?maint.filesize"; + $var['log']['text'] = DOWLAN_171; + $var['log']['link'] = e_SELF."?maint.log"; + show_admin_menu(DOWLAN_177, $subAction, $var); + } // --------------------------------------------------------------------------- @@ -815,12 +1116,40 @@ class download - function create_download($sub_action, $id) + function create_download($subAction, $id) { - global $cal,$tp, $sql, $fl, $rs, $ns, $file_array, $image_array, $thumb_array,$pst; - require_once(e_FILE."shortcode/batch/download_shortcodes.php"); + global $download, $cal, $tp, $sql, $fl, $rs, $ns, $file_array, $image_array, $thumb_array, $pst; + require_once(e_PLUGIN.'download/download_shortcodes.php'); require_once(e_HANDLER."form_handler.php"); + if($file_array = $fl->get_files(e_DOWNLOAD, "","standard",5)) + { + sort($file_array); + } + if($public_array = $fl->get_files(e_FILE."public/")) + { + foreach($public_array as $key=>$val) + { + $file_array[] = str_replace(e_FILE."public/","",$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.'downloadthumbs/', '\.gif$|\.jpg$|\.png$|\.GIF$|\.JPG$|\.PNG$','standard',2)) + { + sort($thumb_array); + } + $eform = new e_form(); $mirrorArray = array(); @@ -836,7 +1165,7 @@ class download return; } $download_active = 1; - if ($sub_action == "edit" && !$_POST['submit']) + if ($subAction == "edit" && !$_POST['submit']) { if ($sql->db_Select("download", "*", "download_id=".$id)) { @@ -847,8 +1176,9 @@ class download } } - if ($sub_action == "dlm" && !$_POST['submit']) + if ($subAction == "dlm" && !$_POST['submit']) { + require_once(e_PLUGIN.'download/download_shortcodes.php'); if ($sql->db_Select("upload", "*", "upload_id=".$id)) { $row = $sql->db_Fetch(); @@ -868,31 +1198,22 @@ class download $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_13." +
".DOWLAN_131."   +
- ".DOWLAN_149." -
- URL:  - - -    ".DOWLAN_66." - -
- -
".DOWLAN_128.":"; - + $text .= " + +
+ +
+ + + + + + + + + +
".DOWLAN_149." + +
".DOWLAN_66." + +
+
+
+ + + + - - - - - - "; + $text .=" + + + + + + + "; } // End of mirror-related stuff - $download_author = $download_author == "" ? USERNAME : $download_author; - $download_author_email = $download_author_email == "" ? USEREMAIL : $download_author_email; - $text .= " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".DOWLAN_128.""; // See if any mirrors to display if(!$sql -> db_Select("download_mirror")) @@ -954,20 +1283,16 @@ class download } else { - $text .= DOWLAN_132."
-
"; - + $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 .=" - + "; foreach ($mirrorList as $mirror) { @@ -976,8 +1301,8 @@ class download } $text .= " - - "; + + "; if (DOWNLOAD_DEBUG) { if ($id) @@ -986,150 +1311,136 @@ class download } else { - $text .= " - "; + $text .= ""; } } - $text .= "
"; + $text .= "
"; } - - $text .="

- -
".DOWLAN_155." - - ".DOWLAN_156."
- ".DOWLAN_157." -
".DOWLAN_155." + ".DOWLAN_156."
+ ".DOWLAN_157." +
".DOWLAN_15.": - -
".DOWLAN_16.": - -
".DOWLAN_17.": - -
".DOWLAN_18.": - "; - $text .= $eform->bbarea('download_description',$download_description); - $text .= "
".DOWLAN_19.": - "; - - if($sub_action == "dlm" && $download_image) - { - $text .= " - \n"; - } - - $text .= " -
".DOWLAN_20.": - -
".LAN_DATESTAMP.": +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + - "; - - - $text .= " - - - - - - - - - - - "; - - if ($sub_action == "dlm") { + $text .= " + + + + + + + + + "; + if ($subAction == "dlm") { $text .= " - - - - - - - - - - - - "; + + + + + + + + "; } $text .= " - - + - -
".DOWLAN_11.""; + $text .= $download->getCategorySelectList($download_category); + $text .= "
".DOWLAN_12." + toForm($download_name)."\" maxlength='200' /> +
".DOWLAN_15." + +
".DOWLAN_16." + +
".DOWLAN_17." + +
".DOWLAN_18." "; - if(!$download_datestamp){ + $text .= $eform->bbarea('download_description',$download_description); + $text .= "
".DOWLAN_19." + "; + if($subAction == "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['size'] = "22"; $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.":"; - - + $text .= "   ".DOWLAN_148." +
".DOWLAN_21." + +
".DOWLAN_102.""; if ($download_comment == "0") { $text .= LAN_YES.": ".LAN_NO.": "; @@ -1137,78 +1448,64 @@ class download $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_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.":
- - -
".DOWLAN_153." + +
".DOWLAN_103." + + +
"; - - - if ($id && $sub_action == "edit") { +
"; + if ($id && $subAction == "edit") { $text .= " "; } else { $text .= ""; } - $text .= "
+ $text .= " +
+
+
"; $ns->tablerender(ADLAN_24, $text); } @@ -1225,14 +1522,14 @@ class download // Actually save a new or edited download to the DB - function submit_download($sub_action, $id) + function submit_download($subAction, $id) { global $tp, $sql, $DOWNLOADS_DIRECTORY, $e_event; $dlInfo = array(); $dlMirrors = array(); - if($sub_action == 'edit') + if($subAction == 'edit') { if($_POST['download_url_external'] == '') { @@ -1396,7 +1693,7 @@ class download if ($id) { // Its an edit - admin_update($sql->db_UpdateArray('download',array_merge($dlInfo,$dlMirrors),'WHERE download_id='.intval($id)), 'update', DOWLAN_2." (".$_POST['download_name'].")"); + admin_update($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 @@ -1405,7 +1702,7 @@ class download } else { - if (admin_update($download_id = $sql->db_Insert('download',array_merge($dlInfo,$dlMirrors)), 'insert', DOWLAN_1." (".$_POST['download_name'].")")) + if (admin_update($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); @@ -1445,16 +1742,13 @@ class download // ----------------------------------------------------------------------------- - function show_categories($sub_action, $id) + function show_categories($subAction, $id) { - global $sql, $rs, $ns, $tp, $pst; + global $download, $sql, $sql2, $rs, $ns, $tp, $pst; require_once(e_HANDLER."form_handler.php"); $eform = new e_form(); - if (!is_object($sql2)) { - $sql2 = new db; - } $text = $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); $text .= "
"; @@ -1471,15 +1765,20 @@ class download { $cat_array[$cat['download_category_parent']][] = $cat; } - $text .= " - +
+ + + + + + + - - - - - + + + + "; @@ -1492,75 +1791,100 @@ class download } $text .= " - - - + - + + + "; - //Show main categories - + //Show sub categories if(is_array($cat_array[$parent['download_category_id']])) { - foreach($cat_array[$parent['download_category_id']] as $main) + foreach($cat_array[$parent['download_category_id']] as $subcat) { - if(strstr($main['download_category_icon'], chr(1))) + if(strstr($subcat['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']])) + //Show sub-sub categories + if(is_array($cat_array[$subcat['download_category_id']])) { - foreach($cat_array[$main['download_category_id']] as $sub) + foreach($cat_array[$subcat['download_category_id']] as $subsubcat) { - if(strstr($sub['download_category_icon'], chr(1))) + if(strstr($subsubcat['download_category_icon'], chr(1))) { - list($sub['download_category_icon'], $sub['download_category_icon_empty']) = explode(chr(1), $sub['download_category_icon']); + list($subsubcat['download_category_icon'], $subsubcat['download_category_icon_empty']) = explode(chr(1), $subsubcat['download_category_icon']); } $text .= " - - - - + + + - "; @@ -1593,7 +1917,7 @@ class download } closedir($handle); - if ($sub_action == "edit" && !$_POST['add_category']) { + if ($subAction == "edit" && !$_POST['add_category']) { if ($sql->db_Select("download_category", "*", "download_category_id=$id")) { $row = $sql->db_Fetch(); extract($row); @@ -1616,50 +1940,34 @@ class download $text = "
 ".DOWLAN_11."".DOWLAN_52."".LAN_ORDER."".LAN_OPTIONS."".DOWLAN_11."".DOWLAN_52."".LAN_ORDER."".LAN_OPTIONS."
".($parent['download_category_icon'] ? "" : " ")."{$parent['download_category_name']} - + ".($parent['download_category_icon'] ? "" : " ")." + "; + $text .= $tp->toHTML($parent['download_category_name']); + $text .= "
+ "; + $text .= $tp->toHTML($parent['download_category_description']); + $text .= "
- ".ADMIN_EDIT_ICON." + + + + + ".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']} ]")."') \"/>"; + list($subcat['download_category_icon'], $subcat['download_category_icon_empty']) = explode(chr(1), $subcat['download_category_icon']); } $text .= " -
".($subcat['download_category_icon'] ? "" : " ")." + "; + $text .= $tp->toHTML($subcat['download_category_name']); + $text .= " +
+ "; + $text .= $tp->toHTML($subcat['download_category_description']); + $text .= " +
{$subcat['filecount']} + + + ".ADMIN_EDIT_ICON.""; + if(!is_array($cat_array[$subcat['download_category_id']]) && !$subcat['filecount']) + { + $text .= "toJS(DOWLAN_34." [ID: {$subcat['download_category_id']} ]")."') \"/>"; + } + $text .= " +
".($sub['download_category_icon'] ? "" : " ")."    ".DOWLAN_53.": {$sub['download_category_name']}
    {$sub['download_category_description']}
{$sub['filecount']} - + ".($subsubcat['download_category_icon'] ? "" : " ")." +     "; + $text .= $tp->toHTML($subsubcat['download_category_name']); + $text .= " +
+     "; + $text .= $tp->toHTML($subsubcat['download_category_description']); + $text .= " +
{$subsubcat['filecount']} + - ".ADMIN_EDIT_ICON." + + ".ADMIN_EDIT_ICON." "; - if(!$sub['filecount']) - { - $text .= "toJS(DOWLAN_34." [ID: {$sub['download_category_id']} ]")."') \"/>"; - } + if(!$subsubcat['filecount']) + { + $text .= "toJS(DOWLAN_34." [ID: {$subsubcat['download_category_id']} ]")."') \"/>"; + } $text .= "
+ + + + + - - + - - + - - + - - + - - + - - - - - + "; - $text .= " - + +
".DOWLAN_37.": "; + ".DOWLAN_37.": "; - if (!$download_cats = $sql->db_Select("download_category")) { - $text .= " - \n"; - } else { - $text .= " - "; - } + $text .= $download->getCategorySelectList($main_category_parent, DOWLAN_40, false, false); $text .= "
".DOWLAN_12.": + ".DOWLAN_12.":
".DOWLAN_18.": "; + ".DOWLAN_18.": "; $text .= $eform->bbarea('download_category_description',$download_category_description); $text .= "
".DOWLAN_41.": + ".DOWLAN_41.": - -
".DOWLAN_147.": + ".DOWLAN_147.": - -
".DOWLAN_43.":
(".DOWLAN_44.")
".r_userclass("download_category_class", $download_category_class, 'off', 'public, nobody, member, admin, classes, language')." - + ".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'])) { + if ($id && $subAction == "edit" && !isset($_POST['add_category'])) { $text .= " "; } else { $text .= ""; } $text .= "
"; $ns->tablerender(DOWLAN_39, $text); } - function create_category($sub_action, $id) + function create_category($subAction, $id) { global $sql, $tp, $admin_log; $download_category_name = $tp->toDB($_POST['download_category_name']); @@ -1739,18 +2040,15 @@ class download admin_update($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") + if ($subAction == "sn") { $sql->db_Delete("tmp", "tmp_time='{$id}' "); } } - - function show_existing_mirrors() { - - global $sql, $ns, $tp, $sub_action, $id, $delete, $del_id, $admin_log; + global $sql, $ns, $tp, $subAction, $id, $delete, $del_id, $admin_log; require_once(e_HANDLER."form_handler.php"); $eform = new e_form(); @@ -1787,10 +2085,10 @@ class download $text .= " - $mirror_id - ".$tp -> toHTML($mirror_name)." - ".($mirror_image ? "" : DOWLAN_28)." - + $mirror_id + ".$tp -> toHTML($mirror_name)." + ".($mirror_image ? "" : DOWLAN_28)." + ".ADMIN_EDIT_ICON." @@ -1807,7 +2105,7 @@ class download $fl = new e_file; $imagelist = $fl->get_files(e_FILE.'downloadimages/'); - if($sub_action == "edit" && !defined("SUBMITTED")) + if($subAction == "edit" && !defined("SUBMITTED")) { $sql -> db_Select("download_mirror", "*", "mirror_id='".intval($id)."' "); $mirror = $sql -> db_Fetch(); @@ -1825,30 +2123,29 @@ class download - - + - - + - - + - - + - - + @@ -1887,8 +2184,6 @@ class download $ns -> tablerender($caption, $text); } - - function submit_mirror() { global $tp, $sql, $admin_log; @@ -1959,13 +2254,11 @@ class download function download_admin_adminmenu($parms) { - global $download; - global $action; - $download->show_options($action); + global $adminDownload,$action,$subAction; + $adminDownload->show_options($action); + if ('maint' == $action) + { + $adminDownload->show_maint_options($action,$subAction); + } } - - - - - -?> +?> \ No newline at end of file diff --git a/e107_plugins/download/download_shortcodes.php b/e107_plugins/download/download_shortcodes.php index df8697e3d..060bd29c9 100644 --- a/e107_plugins/download/download_shortcodes.php +++ b/e107_plugins/download/download_shortcodes.php @@ -11,520 +11,580 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/download/download_shortcodes.php,v $ -| $Revision: 1.2 $ -| $Date: 2009-01-14 23:45:33 $ +| $Revision: 1.3 $ +| $Date: 2009-02-11 21:41:54 $ | $Author: bugrain $ +----------------------------------------------------------------------------+ */ if (!defined('e107_INIT')) { exit; } -include_once(e_HANDLER.'shortcode_handler.php'); -$download_shortcodes = $tp -> e_sc -> parse_scbatch(__FILE__); -/* -SC_BEGIN DOWNLOAD_LIST_NAME -global $row,$tp,$pref; -if($parm == "nolink"){ - return $tp->toHTML($row['download_name'],TRUE,'LINKTEXT'); -} -if($parm == "request"){ +register_shortcode('download_shortcodes', true); +initShortcodeClass('download_shortcodes'); - $agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION')); - if($row['download_mirror_type']){ - $text = ($pref['agree_flag'] ? "" : ""); - }else{ - $text = ($pref['agree_flag'] ? "" : ""); - } - $text .= $tp->toHTML($row['download_name'], FALSE, 'USER_TITLE').""; - return $text; -} - -return "".$tp->toHTML($row['download_name'],TRUE,'LINKTEXT').""; -SC_END - - -SC_BEGIN DOWNLOAD_LIST_AUTHOR -global $row; -return $row['download_author']; -SC_END - - -SC_BEGIN DOWNLOAD_LIST_REQUESTED -global $row; -return $row['download_requested']; -SC_END - - -SC_BEGIN DOWNLOAD_LIST_ICON -global $row; -$img = ""; -if($parm == "link"){ - return "".$img.""; -}else{ - return $img; -} -return; -SC_END - - -SC_BEGIN DOWNLOAD_LIST_NEWICON -global $row; -return (USER && $row['download_datestamp'] > USERLV ? "" : ""); -SC_END - -SC_BEGIN DOWNLOAD_LIST_RECENTICON -global $row, $pref; -// convert "recent_download_days" to seconds -return ($row['download_datestamp'] > time()-($pref['recent_download_days']*86400) ? '' : ''); -SC_END - -SC_BEGIN DOWNLOAD_LIST_FILESIZE -global $row, $e107; -return $e107->parseMemorySize($row['download_filesize']); -SC_END - - -SC_BEGIN DOWNLOAD_LIST_DATESTAMP -global $row; -$gen = new convert; -return $gen->convert_date($row['download_datestamp'], "short"); -SC_END - - -SC_BEGIN DOWNLOAD_LIST_THUMB -global $row; -$img = ($row['download_thumb']) ? "" : ""; -if($parm == "link" && $row['download_thumb']){ - return "".$img.""; -}else{ - return $img; -} -SC_END - - -SC_BEGIN DOWNLOAD_LIST_ID -global $row; -return $row['download_id']; -SC_END - - -SC_BEGIN DOWNLOAD_LIST_RATING -global $row; -$rater = new rater; -$ratearray = $rater->getrating("download", $row['download_id']); - if (!$ratearray[0]) { - return LAN_dl_13; - } else { - return ($ratearray[2] ? "{$ratearray[1]}.{$ratearray[2]}/{$ratearray[0]}" : "{$ratearray[1]}/{$ratearray[0]}"); - } -SC_END - - -SC_BEGIN DOWNLOAD_LIST_LINK -global $tp,$row,$pref; -$agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION')); - if($row['download_mirror_type']){ - return ($pref['agree_flag'] ? "" : ""); - }else{ - return ($pref['agree_flag'] ? "" : ""); - } -SC_END - -SC_BEGIN DOWNLOAD_LIST_NEXTPREV - global $nextprev_parms,$tp; - return $tp->parseTemplate("{NEXTPREV={$nextprev_parms}}"); -SC_END - - -// ---------------------- Download View ---------------------------------------- - -SC_BEGIN DOWNLOAD_VIEW_ID -global $dl; -return $dl['download_id']; -SC_END - - -SC_BEGIN DOWNLOAD_ADMIN_EDIT -global $dl; -return (ADMIN && getperms('6')) ? "" : ""; -SC_END - -SC_BEGIN DOWNLOAD_CATEGORY -global $dl; -return $dl['download_category_name']; -SC_END - -SC_BEGIN DOWNLOAD_CATEGORY_ICON -global $dl; -list($present,$missing) = explode(chr(1),$dl['download_category_icon']); -if($present) +/** + * download_shortcodes + */ +class download_shortcodes { - return ""; -} + var $e107; + var $postInfo; -SC_END - -SC_BEGIN DOWNLOAD_CATEGORY_DESCRIPTION -global $tp,$dl; -$text = $tp -> toHTML($dl['download_category_description'], TRUE,'DESCRIPTION'); -if($parm){ - return substr($text,0,$parm); -}else{ - return $text; -} -SC_END - -SC_BEGIN DOWNLOAD_VIEW_NAME -global $dl; -$link['view'] = "".$dl['download_name'].""; -$link['request'] = "".$dl['download_name'].""; - -if($parm){ - return $link[$parm]; -} -return $dl['download_name']; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_NAME_LINKED -global $pref,$dl,$tp; -if ($pref['agree_flag'] == 1) { - return "toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name'].""; -} else { - return "".$dl['download_name'].""; -} -SC_END - -SC_BEGIN DOWNLOAD_VIEW_AUTHOR -global $dl; -return ($dl['download_author'] ? $dl['download_author'] : ""); -SC_END - - -SC_BEGIN DOWNLOAD_VIEW_AUTHOREMAIL -global $tp,$dl; -return ($dl['download_author_email']) ? $tp -> toHTML($dl['download_author_email'], TRUE, 'LINKTEXT') : ""; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_AUTHORWEBSITE -global $tp,$dl; -return ($dl['download_author_website']) ? $tp -> toHTML($dl['download_author_website'], TRUE,'LINKTEXT') : ""; -SC_END - - - -SC_BEGIN DOWNLOAD_VIEW_DESCRIPTION -global $tp, $dl; -$maxlen = ($parm ? intval($parm) : 0); -$text = ($dl['download_description'] ? $tp->toHTML($dl['download_description'], TRUE, 'DESCRIPTION') : ""); -if($maxlen){ - return substr($text, 0, $maxlen); -}else{ - return $text; -} -return $text; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_DATE -global $gen,$dl; -return ($dl['download_datestamp']) ? $gen->convert_date($dl['download_datestamp'], $parm) : ""; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_DATE_SHORT -// deprecated: DOWNLOAD_VIEW_DATE should be used instead. -global $gen,$dl; -return ($dl['download_datestamp']) ? $gen->convert_date($dl['download_datestamp'], "short") : ""; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_DATE_LONG -// deprecated: DOWNLOAD_VIEW_DATE should be used instead. -global $gen,$dl; -return ($dl['download_datestamp']) ? $gen->convert_date($dl['download_datestamp'], "long") : ""; -SC_END - - - -SC_BEGIN DOWNLOAD_VIEW_IMAGE -global $dl; -if ($dl['download_thumb']) { - return ($dl['download_image'] ? "" : ""); -} -else if($dl['download_image']) { - return "".LAN_dl_40.""; -} -else -{ - return LAN_dl_75; -} -SC_END - -SC_BEGIN DOWNLOAD_VIEW_IMAGEFULL -global $dl; -return ($dl['download_image']) ? "" : ""; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_LINK -global $pref,$dl,$tp; -if ($pref['agree_flag'] == 1) { - $dnld_link = "toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\">"; -} else { - $dnld_link = ""; -} - -if($dl['download_mirror']) -{ - if($dl['download_mirror_type']) + /** + * download_shortcodes constructor + */ + function download_shortcodes() { - return "".LAN_dl_66.""; + $this->e107 = e107::getInstance(); + $this->postInfo = array(); } - else + // Category ************************************************************************************ + function get_download_cat_main_name() { + global $tp, $dlrow; + return $tp->toHTML($dlrow['download_category_name'], FALSE, 'USER_TITLE'); + } + function get_download_cat_main_description() { + global $tp, $dlrow; + return $tp->toHTML($dlrow['download_category_description'], TRUE, 'DESCRIPTION'); + } + function get_download_cat_main_icon() { + global $dlrow; + // Pass count as 1 to force non-empty icon + return $this->_get_cat_icons($dlrow['download_category_icon'], 1, $dlrow['download_category_name']); + } + // Sub-Category ******************************************************************************** + function get_download_cat_sub_name() { + global $tp, $dlsubrow; + if ($dlsubrow['d_count']) + { + return "".$tp->toHTML($dlsubrow['download_category_name'], FALSE, 'USER_TITLE').""; + } + else + { + return $tp->toHTML($dlsubrow['download_category_name'], FALSE, 'USER_TITLE'); + } + } + function get_download_cat_sub_description() { + global $tp, $dlsubrow; + return $tp->toHTML($dlsubrow['download_category_description'], TRUE, 'DESCRIPTION'); + } + function get_download_cat_sub_icon() { + global $dlsubrow; + return $this->_get_cat_icons($dlsubrow['download_category_icon'], $dlsubrow['d_count'], $dlsubrow['download_category_name']); + } + function get_download_cat_sub_new_icon() { + global $dlsubrow; + return $this->_check_new_download($dlsubrow['d_last_subs']); + } + function get_download_cat_sub_count() { + global $dlsubrow; + return $dlsubrow['d_count']; + } + function get_download_cat_sub_size() { + global $e107, $dlsubrow; + return $this->e107->parseMemorySize($dlsubrow['d_size']); + } + function get_download_cat_sub_downloaded() { + global $dlsubrow; + return intval($dlsubrow['d_requests']); + } + // Sub-Sub-Category **************************************************************************** + function get_download_cat_subsub_name() { + global $tp, $dlsubsubrow; + if ($dlsubsubrow['d_count']) + { + return "".$tp->toHTML($dlsubsubrow['download_category_name'], FALSE, 'USER_TITLE').""; + } + else + { + return $tp->toHTML($dlsubsubrow['download_category_name'], FALSE, 'USER_TITLE'); + } + } + function get_download_cat_subsub_description() { + global $tp, $dlsubsubrow; + return $tp->toHTML($dlsubsubrow['download_category_description'], TRUE, 'DESCRIPTION'); + } + function get_download_cat_subsub_icon() { + global $dlsubsubrow; + return $this->_get_cat_icons($dlsubsubrow['download_category_icon'], $dlsubsubrow['d_count'], $dlsubsubrow['download_category_name']); + } + function get_download_cat_subsub_count() { + global $dlsubsubrow; + return $dlsubsubrow['d_count']; + } + function get_download_cat_subsub_size() { + global $e107, $dlsubsubrow; + return $this->e107->parseMemorySize($dlsubsubrow['d_size']); + } + function get_download_cat_subsub_downloaded() { + global $dlsubsubrow; + return intval($dlsubsubrow['d_requests']); + } + // List **************************************************************************************** + function get_download_list_name() + { + global $dlrow,$tp,$pref,$parm; + if ($parm == "nolink"){ + return $tp->toHTML($dlrow['download_name'],TRUE,'LINKTEXT'); + } + if ($parm == "request"){ + $agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION')); + if ($dlrow['download_mirror_type']){ + $text = ($pref['agree_flag'] ? "" : ""); + }else{ + $text = ($pref['agree_flag'] ? "" : ""); + } + $text .= $tp->toHTML($dlrow['download_name'], FALSE, 'USER_TITLE').""; + return $text; + } + return "".$tp->toHTML($dlrow['download_name'],TRUE,'LINKTEXT').""; + } + function get_download_list_author() + { + global $dlrow; + return $dlrow['download_author']; + } + function get_download_list_requested() + { + global $dlrow; + return $dlrow['download_requested']; + } + function get_download_list_newicon() + { + global $dlrow; + return (USER && $dlrow['download_datestamp'] > USERLV ? "*" : ""); + } + function get_download_list_recenticon() + { + global $dlrow, $pref; + // convert "recent_download_days" to seconds + return ($dlrow['download_datestamp'] > time()-($pref['recent_download_days']*86400) ? '' : ''); + } + function get_download_list_filesize() + { + global $dlrow, $e107; + return $e107->parseMemorySize($dlrow['download_filesize']); + } + function get_download_list_datestamp() + { + global $dlrow; + $gen = new convert; + return $gen->convert_date($dlrow['download_datestamp'], "short"); + } + function get_download_list_thumb() + { + global $dlrow,$parm; + $img = ($dlrow['download_thumb']) ? "*" : ""; + if ($parm == "link" && $dlrow['download_thumb']){ + return "".$img.""; + } + else + { + return $img; + } + } + function get_download_list_id() + { + global $dlrow; + return $dlrow['download_id']; + } + function get_download_list_rating() + { + global $dlrow; + $rater = new rater(); + $ratearray = $rater->getrating("download", $dlrow['download_id']); + if (!$ratearray[0]) { + return LAN_dl_13; + } + else + { + return ($ratearray[2] ? "{$ratearray[1]}.{$ratearray[2]}/{$ratearray[0]}" : "{$ratearray[1]}/{$ratearray[0]}"); + } + } + function get_download_list_link() + { + global $tp, $dlrow, $pref, $parm; + $agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION')); + + $img = "".LAN_dl_32.""; + if ($dlrow['download_mirror_type']) + { + return "{$img}"; + } + else + { + return ($pref['agree_flag'] ? "{$img}" : "{$img}"); + } + } + function get_download_list_icon() + { + global $dlrow,$parm; + if ($parm == "link"){ + return "".$img.""; + } + else + { + return $img; + } + return; + } + function get_download_list_nextprev() + { + global $nextprev_parms,$tp; + return $tp->parseTemplate("{NEXTPREV={$nextprev_parms}}"); + } + function get_download_list_total_amount() { + global $dltdownloads; + return $dltdownloads." ".LAN_dl_16; + } + function get_download_list_total_files() { + global $dlft; + return $dlft." ".LAN_dl_17; + } + // View **************************************************************************************** + function get_download_view_id() + { + global $dlrow; + return $dlrow['download_id']; + } + function get_download_admin_edit() + { + global $dlrow; + return (ADMIN && getperms('6')) ? "*" : ""; + } + function get_download_category() + { + global $dlrow; + return $dlrow['download_category_name']; + } + function get_download_category_description() + { + global $tp,$dl,$parm; + $text = $tp -> toHTML($dl['download_category_description'], TRUE,'DESCRIPTION'); + if ($parm){ + return substr($text,0,$parm); + }else{ + return $text; + } + } + function get_download_view_name() + { + global $dlrow,$parm; + $link['view'] = "".$dlrow['download_name'].""; + $link['request'] = "".$dlrow['download_name'].""; + if ($parm){ + return $link[$parm]; + } + return $dlrow['download_name']; + } + function get_download_view_name_linked() + { + global $pref,$dl,$tp; + if ($pref['agree_flag'] == 1) { + return "toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name'].""; + } else { + return "".$dl['download_name'].""; + } + } + function get_download_view_author() + { + global $dlrow; + return ($dlrow['download_author'] ? $dlrow['download_author'] : ""); + } + function get_download_view_authoremail() + { + global $tp,$dlrow; + return ($dlrow['download_author_email']) ? $tp -> toHTML($dlrow['download_author_email'], TRUE, 'LINKTEXT') : ""; + } + function get_download_view_authorwebsite() + { + global $tp,$dlrow; + return ($dlrow['download_author_website']) ? $tp -> toHTML($dlrow['download_author_website'], TRUE,'LINKTEXT') : ""; + } + function get_download_view_description() + { + global $tp,$dlrow,$parm; + $maxlen = ($parm ? intval($parm) : 0); + $text = ($dlrow['download_description'] ? $tp->toHTML($dlrow['download_description'], TRUE, 'DESCRIPTION') : ""); + if ($maxlen){ + return substr($text, 0, $maxlen); + }else{ + return $text; + } + return $text; + } + function get_download_view_date() + { + global $gen,$dlrow,$parm; + return ($dlrow['download_datestamp']) ? $gen->convert_date($dlrow['download_datestamp'], $parm) : ""; + } + function get_download_view_date_short() + { + // deprecated: DOWNLOAD_VIEW_DATE should be used instead. + global $gen,$dlrow; + return ($dlrow['download_datestamp']) ? $gen->convert_date($dlrow['download_datestamp'], "short") : ""; + } + function get_download_view_date_long() + { + // deprecated: DOWNLOAD_VIEW_DATE should be used instead. + global $gen,$dlrow; + return ($dlrow['download_datestamp']) ? $gen->convert_date($dlrow['download_datestamp'], "long") : ""; + } + function get_download_view_image() + { + global $dlrow; + if ($dlrow['download_thumb']) { + return ($dlrow['download_image'] ? "*" : "*"); + } + else if ($dlrow['download_image']) { + return "".LAN_dl_40.""; + } + else + { + return LAN_dl_75; + } + } + function get_download_view_imagefull() + { + global $dlrow; + return ($dlrow['download_image']) ? "*" : ""; + } + function get_download_view_link() + { + global $pref,$dlrow,$tp; + $click = ""; + if ($pref['agree_flag'] == 1) { + $click = " onclick='return confirm(\"".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."\")'"; + } + $dnld_link = ""; + if ($dlrow['download_mirror']) + { + if ($dlrow['download_mirror_type']) + { + return "".LAN_dl_66.""; + } + else + { + return $dnld_link."*"; + } + } + else + { + return $dnld_link." *"; + } + } + function get_download_view_filesize() + { + global $dlrow, $e107; + return ($dlrow['download_filesize']) ? $e107->parseMemorySize($dlrow['download_filesize']) : ""; + } + function get_download_view_rating() + { + require_once(e_HANDLER."rate_class.php"); + $rater = new rater; + global $dlrow, $imode; + $text = " +
".DOWLAN_12." + ".DOWLAN_12."
".DOWLAN_139." + ".DOWLAN_139."
".DOWLAN_136." + ".DOWLAN_136."
".DOWLAN_141." + ".DOWLAN_141."
".DOWLAN_18.""; + ".DOWLAN_18.""; $text .= $eform->bbarea('mirror_description',$mirror_description); $text .= "
+ +
"; + if ($ratearray = $rater->getrating("download", $dlrow['download_id'])) { + for($c = 1; $c <= $ratearray[1]; $c++) { + $text .= "*"; + } + if ($ratearray[2]) { + $text .= "*"; + } + if ($ratearray[2] == "") { + $ratearray[2] = 0; + } + $text .= " ".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]." "; + $text .= ($ratearray[0] == 1 ? LAN_dl_43 : LAN_dl_44); + } else { + $text .= LAN_dl_13; + } + $text .= ""; + if (!$rater->checkrated("download", $dlrow['download_id']) && USER) { + $text .= $rater->rateselect("     ".LAN_dl_14, "download", $dlrow['download_id']).""; + } + else if (!USER) { + $text .= " "; + } else { + $text .= LAN_dl_15; + } + $text .= "
"; + return $text; + } + function get_download_report_link() + { + global $dlrow,$pref; + return (check_class($pref['download_reportbroken'])) ? "".LAN_dl_45."" : ""; + } + function get_download_view_caption() + { + global $dlrow; + $text = $dlrow['download_category_name']; + $text .= ($dlrow['download_category_description']) ? " [ ".$dlrow['download_category_description']." ]" : ""; + return $text; + } + // Mirror ************************************************************************************** + function get_download_mirror_request() { + global $dlrow; + return $dlrow['download_name']; + } + function get_download_mirror_request_icon() { + global $dlrow; + return ($dlrow['download_thumb'] ? "*" : ""); + } + function get_download_mirror_name() { + global $dlmirror; + return "".$dlmirror['mirror_name'].""; + } + function get_download_mirror_image() { + global $dlrow, $dlmirror; + return ($dlmirror['mirror_image'] ? "*" : ""); + } + function get_download_mirror_location() { + global $dlmirror; + return ($dlmirror['mirror_location'] ? $dlmirror['mirror_location'] : ""); + } + function get_download_mirror_description() { + global $dlmirror,$tp; + return ($dlmirror['mirror_description'] ? $tp->toHTML($dlmirror['mirror_description'], TRUE) : ""); + } + function get_download_mirror_filesize() { + global $e107, $dlmirrorfile; + return $e107->parseMemorySize($dlmirrorfile[3]); + } + function get_download_mirror_link() { + global $dlrow, $dlmirrorfile, $tp, $pref; + $click = " onclick='return confirm(\"".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."\")'"; + return " + *"; + } + function get_download_mirror_requests() { + global $dlmirrorfile; + return (ADMIN ? LAN_dl_73.$dlmirrorfile[2] : ""); + } + function get_download_total_mirror_requests() { + global $dlmirror; + return (ADMIN ? LAN_dl_74.$dlmirror['mirror_count'] : ""); + } + // --------- Download View Lans ----------------------------- + function get_download_view_author_lan() + { + global $dlrow; + return ($dlrow['download_author']) ? LAN_dl_24 : ""; + } + function get_download_view_authoremail_lan() + { + global $dlrow; + return ($dlrow['download_author_email']) ? LAN_dl_30 : ""; + } + function get_download_view_authorwebsite_lan() + { + global $dlrow; + return ($dlrow['download_author_website']) ? LAN_dl_31 : ""; + } + function get_download_view_date_lan() + { + global $dlrow; + return ($dlrow['download_datestamp']) ? LAN_dl_22 : ""; + } + function get_download_view_image_lan() + { + return LAN_dl_11; + } + function get_download_view_requested() + { + global $dlrow; + return $dlrow['download_requested']; + } + function get_download_view_rating_lan() + { + return LAN_dl_12; + } + function get_download_view_filesize_lan() + { + return LAN_dl_10; + } + function get_download_view_description_lan() + { + return LAN_dl_7; + } + function get_download_view_requested_lan() + { + return LAN_dl_77; + } + function get_download_view_link_lan() + { + return LAN_dl_32; + } + // ----------- Download View : Previous and Next --------------- + function get_download_view_prev() + { + global $dlrow,$sql; + $dlrow_id = intval($dlrow['download_id']); + if ($sql->db_Select("download", "*", "download_category='".intval($dlrow['download_category_id'])."' AND download_id < {$dlrow_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp DESC LIMIT 1")) { + $dlrowrow = $sql->db_Fetch(); + return "<< ".LAN_dl_33." [".$dlrowrow['download_name']."]\n"; + } else { + return " "; + } + } + function get_download_view_next() + { + global $dlrow,$sql; + $dlrow_id = intval($dlrow['download_id']); + if ($sql->db_Select("download", "*", "download_category='".intval($dlrow['download_category_id'])."' AND download_id > {$dlrow_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp ASC LIMIT 1")) { + $dlrowrow = $sql->db_Fetch(); + extract($dlrowrow); + return "[".$dlrowrow['download_name']."] ".LAN_dl_34." >>\n"; + } else { + return " "; + } + } + function get_download_back_to_list() + { + global $dlrow; + return "".LAN_dl_35.""; + } + function get_download_back_to_category_list() + { + return "".LAN_dl_9.""; + } + // Misc stuff --------------------------------------------------------------------------------- + function get_download_cat_newdownload_text() + { + return "* ".LAN_dl_36; + } + function get_download_cat_search() + { + return "
+

+ + + +

+
"; + } + /** + * @private + */ + function _get_cat_icons($source, $count, $alt) { - return $dnld_link." "; + if (!$source) return " "; + list($ret[TRUE],$ret[FALSE]) = explode(chr(1), $source.chr(1)); + if (!$ret[FALSE]) $ret[FALSE] = $ret[TRUE]; + return "*"; + } + function _check_new_download($last_val) + { + if (USER && ($last_val > USERLV)) + { + return "*"; + } + else + { + return ""; + } } } -else -{ - return $dnld_link." "; -} -SC_END - -SC_BEGIN DOWNLOAD_VIEW_FILESIZE -global $dl, $e107; -return ($dl['download_filesize']) ? $e107->parseMemorySize($dl['download_filesize']) : ""; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_RATING - require_once(e_HANDLER."rate_class.php"); - $rater = new rater; - global $dl, $imode; - $text = " - - -
"; - - if ($ratearray = $rater->getrating("download", $dl['download_id'])) { - for($c = 1; $c <= $ratearray[1]; $c++) { - $text .= ""; - } - if ($ratearray[2]) { - $text .= ""; - } - if ($ratearray[2] == "") { - $ratearray[2] = 0; - } - $text .= " ".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]." "; - $text .= ($ratearray[0] == 1 ? LAN_dl_43 : LAN_dl_44); - } else { - $text .= LAN_dl_13; - } - $text .= ""; - - if (!$rater->checkrated("download", $dl['download_id']) && USER) { - $text .= $rater->rateselect("     ".LAN_dl_14, "download", $dl['download_id']).""; - } - else if(!USER) { - $text .= " "; - } else { - $text .= LAN_dl_15; - } - $text .= "
"; -return $text; -SC_END - -SC_BEGIN DOWNLOAD_REPORT_LINK -global $dl,$pref; -return (check_class($pref['download_reportbroken'])) ? "".LAN_dl_45."" : ""; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_CAPTION -global $dl; - $text = $dl['download_category_name']; - $text .= ($dl['download_category_description']) ? " [ ".$dl['download_category_description']." ]" : ""; -return $text; -SC_END - - -// --------- Download View Lans ----------------------------- - -SC_BEGIN DOWNLOAD_VIEW_AUTHOR_LAN -global $dl; -return ($dl['download_author']) ? LAN_dl_24 : ""; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_AUTHOREMAIL_LAN -global $dl; -return ($dl['download_author_email']) ? LAN_dl_30 : ""; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_AUTHORWEBSITE_LAN -global $dl; -return ($dl['download_author_website']) ? LAN_dl_31 : ""; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_DATE_LAN -global $dl; -return ($dl['download_datestamp']) ? LAN_dl_22 : ""; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_IMAGE_LAN -return LAN_dl_11; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_REQUESTED -global $dl; -return $dl['download_requested']; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_RATING_LAN -return LAN_dl_12; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_FILESIZE_LAN -return LAN_dl_10; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_DESCRIPTION_LAN -return LAN_dl_7; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_REQUESTED_LAN -return LAN_dl_77; -SC_END - -SC_BEGIN DOWNLOAD_VIEW_LINK_LAN -return LAN_dl_32; -SC_END - - - -// ----------- Download View : Previous and Next --------------- - -SC_BEGIN DOWNLOAD_VIEW_PREV -global $dl,$sql; - - $dl_id = intval($dl['download_id']); - - if ($sql->db_Select("download", "*", "download_category='".intval($dl['download_category_id'])."' AND download_id < {$dl_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp DESC LIMIT 1")) { - $row = $sql->db_Fetch(); - return "<< ".LAN_dl_33." [".$row['download_name']."]\n"; - } else { - return " "; - } -SC_END - -SC_BEGIN DOWNLOAD_VIEW_NEXT -global $dl,$sql; -$dl_id = intval($dl['download_id']); - if ($sql->db_Select("download", "*", "download_category='".intval($dl['download_category_id'])."' AND download_id > {$dl_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp ASC LIMIT 1")) { - $row = $sql->db_Fetch(); - extract($row); - return "[".$row['download_name']."] ".LAN_dl_34." >>\n"; - } else { - return " "; - } -SC_END - - -SC_BEGIN DOWNLOAD_BACK_TO_LIST -global $dl; -return "".LAN_dl_35.""; -SC_END - -SC_BEGIN DOWNLOAD_BACK_TO_CATEGORY_LIST - return "".LAN_dl_9.""; -SC_END - - -// --------------- Download - Admin ----------------------------------- - -SC_BEGIN DOWNLOAD_CATEGORY_SELECT - global $sql; - $cdc = $parm; - - $boxinfo = "\n"; - $qry = " - SELECT dc.download_category_name, dc.download_category_order, dc.download_category_id, dc.download_category_parent, - dc1.download_category_parent AS d_parent1 - FROM #download_category AS dc - LEFT JOIN #download_category as dc1 ON dc1.download_category_id=dc.download_category_parent AND dc1.download_category_class IN (".USERCLASS_LIST.") - LEFT JOIN #download_category as dc2 ON dc2.download_category_id=dc1.download_category_parent "; - if (ADMIN === FALSE) $qry .= " WHERE dc.download_category_class IN (".USERCLASS_LIST.") "; - $qry .= " ORDER by dc2.download_category_order, dc1.download_category_order, dc.download_category_order"; // This puts main categories first, then sub-cats, then sub-sub cats - - if (!$sql->db_Select_gen($qry)) - { - return "Error reading categories
"; - exit; - } - - $boxinfo .= "\n"; - return $boxinfo; - -SC_END - - - - - - -*/ -?> +?> \ No newline at end of file diff --git a/e107_plugins/download/handlers/category_class.php b/e107_plugins/download/handlers/category_class.php new file mode 100644 index 000000000..af6305575 --- /dev/null +++ b/e107_plugins/download/handlers/category_class.php @@ -0,0 +1,165 @@ +0 creates full tree. + // If load-class non-null, assumed to be a 'class set' such as USERCLASS_LIST + // If $accum is TRUE, include file counts and sizes in superior categories + define("SUB_PREFIX","-->"); // Added in front of sub categories + define("SUBSUB_PREFIX","---->"); // Added in front of sub-sub categories + $this->cat_tree = $this->down_cat_tree($nest_level,$load_class, $main_cat_load, $accum); + } + + +// Function returns a 'tree' of download categories, subcategories, and sub-sub-categories. +// Returns empty array if nothing defined +// Within the 'main category' level of the nesting, array 'subcats' has the next level's info +// Within the 'sub-category' level of the nesting, array 'subsubcats' has the next level's info +// If $main_cat_load is numeric, and the value of a 'main' category, only that main category is displayed. +// (Unpredictable if $main_cat_load is some other category) + function down_cat_tree($nest_level = 1, $load_cat_class = USERCLASS_LIST, $main_cat_load = '', $accum = FALSE) + { + global $sql2; + + $catlist = array(); + $this->cat_count = 0; + $this->down_count = 0; + $temp2 = ""; + $temp1 = ""; + if ($load_cat_class != "") + { + $temp1 = " WHERE dc.download_category_class IN ({$load_cat_class}) "; + $temp2 = "AND d.download_visible IN ({$load_cat_class}) "; + } + + $qry = " + SELECT dc.*, + dc1.download_category_parent AS d_parent1, dc1.download_category_order, + SUM(d.download_filesize) AS d_size, + COUNT(d.download_id) AS d_count, + MAX(d.download_datestamp) as d_last, + SUM(d.download_requested) as d_requests + FROM #download_category as dc + LEFT JOIN #download_category as dc1 ON dc1.download_category_id=dc.download_category_parent + LEFT JOIN #download_category as dc2 ON dc2.download_category_id=dc1.download_category_parent + LEFT JOIN #download AS d on d.download_category = dc.download_category_id AND d.download_active > 0 {$temp2} + {$temp1} + GROUP by dc.download_category_id + ORDER by dc2.download_category_order, dc1.download_category_order, dc.download_category_order"; // This puts main categories first, then sub-cats, then sub-sub cats + + if (!$sql2->db_Select_gen($qry)) return $catlist; + + while ($row = $sql2->db_Fetch()) + { + $tmp = $row['download_category_parent']; + if ($tmp == '0') + { // Its a main category + if (!is_numeric($main_cat_load) || ($main_cat_load == $row['download_category_id'])) + { + $row['subcats'] = array(); + $catlist[$row['download_category_id']] = $row; + } + } + else + { + if (isset($catlist[$tmp])) + { // Sub-Category + $this->cat_count++; + $this->down_count += $row['d_count']; + $catlist[$tmp]['subcats'][$row['download_category_id']] = $row; + $catlist[$tmp]['subcats'][$row['download_category_id']]['subsubcats'] = array(); + $catlist[$tmp]['subcats'][$row['download_category_id']]['d_last_subs'] = + $catlist[$tmp]['subcats'][$row['download_category_id']]['d_last']; + } + else + { // Its a sub-sub category + if (isset($catlist[$row['d_parent1']]['subcats'][$tmp])) + { + $this->cat_count++; + $this->down_count += $row['d_count']; + if ($accum || ($nest_level == 0)) + { // Add the counts into the subcategory values + $catlist[$row['d_parent1']]['subcats'][$tmp]['d_size'] += $row['d_size']; + $catlist[$row['d_parent1']]['subcats'][$tmp]['d_count'] += $row['d_count']; + $catlist[$row['d_parent1']]['subcats'][$tmp]['d_requests'] += $row['d_requests']; + } + if ($nest_level == 0) + { // Reflect subcat dates in category + if ($catlist[$row['d_parent1']]['subcats'][$tmp]['d_last'] < $row['d_last']) + $catlist[$row['d_parent1']]['subcats'][$tmp]['d_last'] = $row['d_last']; + } + else + { + $catlist[$row['d_parent1']]['subcats'][$tmp]['subsubcats'][$row['download_category_id']] = $row; + } + // Separately accumulate 'last update' for subcat plus associated subsubcats + if ($catlist[$row['d_parent1']]['subcats'][$tmp]['d_last_subs'] < $row['d_last']) + $catlist[$row['d_parent1']]['subcats'][$tmp]['d_last_subs'] = $row['d_last']; + } + } + } + } + return $catlist; + } + + +// Rest of the class isn't actually used normally, but print_tree() might help with debug + + function print_cat($cat, $prefix,$postfix) + { + $text = "".$cat['download_category_id']."".$cat['download_category_parent'].""; + $text .= $prefix.htmlspecialchars($cat['download_category_name']).$postfix."".$cat['d_size'].""; + $text .= "".$cat['d_count']."".$cat['d_requests']."".strftime('%H:%M %d-%m-%Y',$cat['d_last']).""; + $text .= ""; + return $text; + } + + function print_tree() + { + echo ""; + foreach ($this->cat_tree as $thiscat) + { // Main categories + $scprefix = SUB_PREFIX; + echo $this->print_cat($thiscat,'',''); + foreach ($thiscat['subcats'] as $sc) + { // Sub-categories + $sscprefix = SUBSUB_PREFIX; + echo $this->print_cat($sc,$scprefix,''); + foreach ($sc['subsubcats'] as $ssc) + { // Sub-sub categories + echo $this->print_cat($ssc,$sscprefix,''); + } + } + } + echo "
IDParentNameBytesFilesRequestsLast Download
"; + return; + } + +} +?> \ No newline at end of file diff --git a/e107_plugins/download/handlers/download_class.php b/e107_plugins/download/handlers/download_class.php new file mode 100644 index 000000000..7fc4cb984 --- /dev/null +++ b/e107_plugins/download/handlers/download_class.php @@ -0,0 +1,146 @@ +$crumb) { + $dlbreadcrumb[$ix]['sep'] = " :: "; + $ix++; + if (is_int($key)) + { + $dlbreadcrumb[$ix]['value'] = $crumb; + } + else + { + $dlbreadcrumb[$ix]['value'] = "".$key.""; + } + } + $dlbreadcrumb['fieldlist'] = implode(",", array_keys($dlbreadcrumb)); + return $dlbreadcrumb; + } + function getCategorySelectList($currentID=0, $blankText="", $incSubSub=true, $groupOnMain=true) + { + global $sql,$parm; + $boxinfo = "\n"; + $qry = " + SELECT dc.download_category_name, dc.download_category_order, dc.download_category_id, dc.download_category_parent, + dc1.download_category_parent AS d_parent1 + FROM #download_category AS dc + LEFT JOIN #download_category as dc1 ON dc1.download_category_id=dc.download_category_parent AND dc1.download_category_class IN (".USERCLASS_LIST.") + LEFT JOIN #download_category as dc2 ON dc2.download_category_id=dc1.download_category_parent "; + if (ADMIN === FALSE) $qry .= " WHERE dc.download_category_class IN (".USERCLASS_LIST.") "; + $qry .= " ORDER by dc2.download_category_order, dc1.download_category_order, dc.download_category_order"; // This puts main categories first, then sub-cats, then sub-sub cats + if (!$sql->db_Select_gen($qry)) + { + return "Error reading categories
"; + exit; + } + $boxinfo .= "\n"; + return $boxinfo; + } +} +?> \ No newline at end of file diff --git a/e107_plugins/download/help.php b/e107_plugins/download/help.php index 3ccd18ee7..74e4b5d31 100644 --- a/e107_plugins/download/help.php +++ b/e107_plugins/download/help.php @@ -11,16 +11,84 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/download/help.php,v $ -| $Revision: 1.1 $ -| $Date: 2009-01-11 02:59:10 $ +| $Revision: 1.2 $ +| $Date: 2009-02-11 21:41:54 $ | $Author: bugrain $ +----------------------------------------------------------------------------+ */ if (!defined('e107_INIT')) { exit; } -$text = "Please upload your files into the ".e_FILE."downloads folder, your images into the ".e_FILE."downloadimages folder and thumbnail images into the ".e_FILE."downloadthumbs folder. -

-To submit a download, first create a parent, then create a category under that parent, you will then be able to make the download available."; -$ns -> tablerender("Download Help", $text); +if (e_QUERY) +{ + $tmp = explode(".", e_QUERY); + $action = $tmp[0]; + $subAction = $tmp[1]; +} + +switch($action) { + case 'create' :{ + $text = DOWLAN_HELP_2; + break; + } + case 'cat' :{ + $text = DOWLAN_HELP_3; + break; + } + case 'opt' :{ + $text = DOWLAN_HELP_4; + break; + } + case 'maint' :{ + switch($subAction) { + case 'duplicates': { + $text = DOWLAN_HELP_5_1; + break; + } + case 'orphans': { + $text = DOWLAN_HELP_5_2; + break; + } + case 'missing': { + $text = DOWLAN_HELP_5_3; + break; + } + case 'inactive': { + $text = DOWLAN_HELP_5_4; + break; + } + case 'nocategory': { + $text = DOWLAN_HELP_5_5; + break; + } + case 'filesize': { + $text = DOWLAN_HELP_5_6; + break; + } + case 'log': { + $text = DOWLAN_HELP_5_7; + break; + } + default: { + $text = DOWLAN_HELP_5; + break; + } + } + break; + } + case 'limits' :{ + $text = DOWLAN_HELP_6; + break; + } + case 'mirror' :{ + $text = DOWLAN_HELP_7; + break; + } + default : { + $text = "Please upload your files into the ".e_DOWNLOAD." folder, your images into the ".e_FILE."downloadimages folder and thumbnail images into the ".e_FILE."downloadthumbs folder. +

+ To submit a download, first create a parent, then create a category under that parent, you will then be able to make the download available."; + } +} +$ns -> tablerender(DOWLAN_HELP_1, $text); ?> \ No newline at end of file diff --git a/e107_plugins/download/languages/English/lan_download.php b/e107_plugins/download/languages/English/lan_download.php index 892b66006..10e82f37b 100644 --- a/e107_plugins/download/languages/English/lan_download.php +++ b/e107_plugins/download/languages/English/lan_download.php @@ -4,8 +4,8 @@ | e107 website system - Language File. | | $Source: /cvs_backup/e107_0.8/e107_plugins/download/languages/English/lan_download.php,v $ -| $Revision: 1.1 $ -| $Date: 2009-01-11 02:59:10 $ +| $Revision: 1.2 $ +| $Date: 2009-02-11 21:41:54 $ | $Author: bugrain $ +----------------------------------------------------------------------------+ */ @@ -64,7 +64,7 @@ define("LAN_dl_46", "click here to download"); define("LAN_dl_47", "Post has been reported"); define("LAN_dl_48", "Download has been reported to administrator.
Thank you."); define("LAN_dl_49", "Click here to return to download"); -define("LAN_dl_50", "Report broken download to an administrator"); +define("LAN_dl_50", "Broken download reported"); define("LAN_dl_51", "Reporting download: "); define("LAN_dl_52", "Guest"); define("LAN_dl_53", "Click to view download"); @@ -84,7 +84,7 @@ define("LAN_dl_65", "File Not Found"); define("LAN_dl_66", "Select download mirror"); -define("LAN_dl_67", "Please select mirror to use ..."); +define("LAN_dl_67", "Select mirror ..."); define("LAN_dl_68", "Mirror Host"); // define("LAN_dl_69", "Download"); // duplicate define("LAN_dl_70", "Location"); @@ -98,6 +98,6 @@ define("LAN_dl_75", "no image available "); define("LAN_dl_76", "Go to page"); define("LAN_dl_77", "Downloads"); // Intentional duplicate - some languages need it to be different. This is for number of downloads -define('LAN_dl_78', 'That download has been disabled or discontinued. Please check in the --LINK--downloads area for a more recent version.'); +define('LAN_dl_78', 'That download has been disabled or discontinued. Please check in the --LINK--downloads area for a more recent version.'); ?> diff --git a/e107_plugins/download/languages/English/lan_download_admin.php b/e107_plugins/download/languages/English/lan_download_admin.php index 22da940cc..fff7da3cc 100644 --- a/e107_plugins/download/languages/English/lan_download_admin.php +++ b/e107_plugins/download/languages/English/lan_download_admin.php @@ -4,8 +4,8 @@ | e107 website system - Language File. | | $Source: /cvs_backup/e107_0.8/e107_plugins/download/languages/English/lan_download_admin.php,v $ -| $Revision: 1.4 $ -| $Date: 2009-01-14 23:45:33 $ +| $Revision: 1.5 $ +| $Date: 2009-02-11 21:41:54 $ | $Author: bugrain $ +----------------------------------------------------------------------------+ */ @@ -51,7 +51,7 @@ define("DOWLAN_40", "None - main parent"); define("DOWLAN_41", "Icon"); define("DOWLAN_42", "View Images"); define("DOWLAN_43", "Visible to"); -define("DOWLAN_44", "Ticking will make the category visible to only users in that class"); +define("DOWLAN_44", "Selection will make the category visible to only users in that class"); define("DOWLAN_45", "Create Category"); define("DOWLAN_46", "Update Category"); define("DOWLAN_47", "Category created"); @@ -72,7 +72,7 @@ define("DOWLAN_62", "Ascending"); define("DOWLAN_63", "Descending"); define("DOWLAN_64", "Update Options"); define("DOWLAN_65", "Options Updated"); -define("DOWLAN_66", "Enter filesize"); +define("DOWLAN_66", "Filesize"); define("DOWLAN_67", "ID"); define("DOWLAN_68", "File Missing!"); define("DOWLAN_69", "Downloads handled by PHP"); @@ -104,7 +104,7 @@ define("DOWLAN_123", "Active - File is subject to download limits"); define("DOWLAN_124", "Active - File is NOT subject to download limits"); define("DOWLAN_125", "Download limits active"); define("DOWLAN_126", "Activation status updated"); -define("DOWLAN_127", "Only enter filesize if the download is an external file"); +define("DOWLAN_127", "Only enter filesize if the download is an external file"); // TODO not used? define("DOWLAN_128", "Mirrors"); define("DOWLAN_129", "leave blank if not using mirrors"); define("DOWLAN_130", "Add another mirror"); @@ -130,7 +130,7 @@ define("DOWLAN_146", "Custom Download-denial message or URL"); define("DOWLAN_147", "Icon for empty category"); define("DOWLAN_148", "Check to update date stamp to current time"); -define("DOWLAN_149", "Or click here to use an external file"); +define("DOWLAN_149", "URL"); define("DOWLAN_150", "Email admin when broken download reported"); define("DOWLAN_151", "Broken-download reporting available to"); @@ -153,4 +153,38 @@ define("DOWLAN_163", "Name"); define("DOWLAN_164", "Recent downloads age (in days)"); +define("DOWLAN_165", "Maintenance"); +define("DOWLAN_166", "Duplicates"); +define("DOWLAN_167", "Orphans"); +define("DOWLAN_168", "Missing"); +define("DOWLAN_169", "Inactive"); +define("DOWLAN_170", "File size"); +define("DOWLAN_171", "Log"); +define("DOWLAN_172", "No entries"); +define("DOWLAN_173", "Are you sure you want to delete this file?"); +define("DOWLAN_174", "No orphaned files found"); +define("DOWLAN_175", "Local"); +define("DOWLAN_176", "External"); +define("DOWLAN_177", "Maintenance options"); +define("DOWLAN_178", "No category"); +define("DOWLAN_179", "Select an option from the Maintenance Options menu"); +define("DOWLAN_180", "File size (database/disk)"); + +define("DOWLAN_HELP_1", "Download Help"); +define("DOWLAN_HELP_2", "

Create/edit a download.

Enter only one of: File, URL or Mirror.

Ensure you select a category, otherwise your download will not be visible on the downloads page.

"); +define("DOWLAN_HELP_3", "Help for cat"); +define("DOWLAN_HELP_4", "Help for opt"); +define("DOWLAN_HELP_5", "Use the maintenance pages to find duplicate downloads, find orphaned files, find missing (broken) entries, manage inactive downloads, refresh file sizes and view the downlaod log."); +define("DOWLAN_HELP_5_1", "This page shows duplicate entries in the database - records where the same file is referenced more than once."); +define("DOWLAN_HELP_5_2", "This page shows orphan files - files in the downloads directory that do not have a record in the database referenceing them."); +define("DOWLAN_HELP_5_3", "This page shows missing entries in the database - records that reference a non-existing file."); +define("DOWLAN_HELP_5_4", "This page shows all records that are marked as inactive."); +define("DOWLAN_HELP_5_5", "This page shows records in the database that are not associated with a download category."); +define("DOWLAN_HELP_5_6", "This page shows records in the database that have an incorrect file size when comapred to the file in the downloads folder."); +define("DOWLAN_HELP_5_7", "This page shows the downloads log entries."); +define("DOWLAN_HELP_6", "Help for limits"); +define("DOWLAN_HELP_7", "Help for mirror"); +define("DOWLAN_HELP_8", "Help for "); +define("DOWLAN_HELP_9", "Help for "); + ?> \ No newline at end of file diff --git a/e107_plugins/download/plugin.xml b/e107_plugins/download/plugin.xml index 023821ad1..141fea818 100755 --- a/e107_plugins/download/plugin.xml +++ b/e107_plugins/download/plugin.xml @@ -1,5 +1,5 @@ - + This plugin is a fully featured Download system @@ -17,7 +17,7 @@ Configure Download Your download plugin is now installed - + diff --git a/e107_plugins/download/templates/download_template.php b/e107_plugins/download/templates/download_template.php index f689fc4ca..db04774fb 100644 --- a/e107_plugins/download/templates/download_template.php +++ b/e107_plugins/download/templates/download_template.php @@ -11,131 +11,150 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/download/templates/download_template.php,v $ -| $Revision: 1.1 $ -| $Date: 2009-01-14 23:43:36 $ +| $Revision: 1.2 $ +| $Date: 2009-02-11 21:41:54 $ | $Author: bugrain $ +----------------------------------------------------------------------------+ */ if (!defined('e107_INIT')) { exit; } if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%"); } - /* set style of download image and thumbnail */ define("DL_IMAGESTYLE","border:0px"); // ##### CAT TABLE -------------------------------------------------------------------------------- +if(!isset($DOWNLOAD_CAT_TABLE_PRE)) +{ + $DOWNLOAD_CAT_TABLE_PRE = " +

{DOWNLOAD_CAT_MAIN_DESCRIPTION}
"; +} if(!isset($DOWNLOAD_CAT_TABLE_START)) { - $DOWNLOAD_CAT_TABLE_START = " -
- \n - - - - - - - "; + $DOWNLOAD_CAT_TABLE_START = " +
+
 ".LAN_dl_19."".LAN_dl_20."".LAN_dl_21."".LAN_dl_77."
\n + + + + + + + + + + + + + + + + + + + + + + + + "; } if(!isset($DOWNLOAD_CAT_PARENT_TABLE)) { - $DOWNLOAD_CAT_PARENT_TABLE = " - - - "; + $DOWNLOAD_CAT_PARENT_TABLE = " + + + + "; } if(!isset($DOWNLOAD_CAT_CHILD_TABLE)) { - $DOWNLOAD_CAT_CHILD_TABLE = " - - - - - - - - {DOWNLOAD_CAT_SUBSUB} - "; - + $DOWNLOAD_CAT_CHILD_TABLE = " + + + + + + + + {DOWNLOAD_CAT_SUBSUB}"; } - if(!isset($DOWNLOAD_CAT_SUBSUB_TABLE)) { $DOWNLOAD_CAT_SUBSUB_TABLE = " - - - - - - - - "; + + + + + + + "; } - if(!isset($DOWNLOAD_CAT_TABLE_END)) { - $DOWNLOAD_CAT_TABLE_END = " - - -
".LAN_dl_19."".LAN_dl_20."".LAN_dl_21."".LAN_dl_77."
{DOWNLOAD_CAT_NEWDOWNLOAD_TEXT}
{DOWNLOAD_CAT_SEARCH}
- {DOWNLOAD_CAT_MAIN_ICON} {DOWNLOAD_CAT_MAIN_NAME} -
+ {DOWNLOAD_CAT_MAIN_ICON} + + {DOWNLOAD_CAT_MAIN_NAME}
+ {DOWNLOAD_CAT_MAIN_DESCRIPTION} +
- {DOWNLOAD_CAT_SUB_ICON} - - {DOWNLOAD_CAT_SUB_NEW_ICON} {DOWNLOAD_CAT_SUB_NAME}
- - {DOWNLOAD_CAT_SUB_DESCRIPTION} - -
- {DOWNLOAD_CAT_SUB_COUNT} - - {DOWNLOAD_CAT_SUB_SIZE} - - {DOWNLOAD_CAT_SUB_DOWNLOADED} -
+ {DOWNLOAD_CAT_SUB_ICON} + + {DOWNLOAD_CAT_SUB_NEW_ICON} {DOWNLOAD_CAT_SUB_NAME}
+ {DOWNLOAD_CAT_SUB_DESCRIPTION} +
+ {DOWNLOAD_CAT_SUB_COUNT} + + {DOWNLOAD_CAT_SUB_SIZE} + + {DOWNLOAD_CAT_SUB_DOWNLOADED} +
-   - - - - - - - -
". - LAN_dl_42." - - {DOWNLOAD_CAT_SUBSUB_ICON} - - {DOWNLOAD_CAT_SUBSUB_NEW_ICON} {DOWNLOAD_CAT_SUBSUB_NAME}
- - {DOWNLOAD_CAT_SUBSUB_DESCRIPTION} - -
-
- {DOWNLOAD_CAT_SUBSUB_COUNT} - - {DOWNLOAD_CAT_SUBSUB_SIZE} - - {DOWNLOAD_CAT_SUBSUB_DOWNLOADED} -
+   + + + + + + +
+ {DOWNLOAD_CAT_SUBSUB_ICON} + + {DOWNLOAD_CAT_SUBSUB_NEW_ICON} {DOWNLOAD_CAT_SUBSUB_NAME}
+ + {DOWNLOAD_CAT_SUBSUB_DESCRIPTION} + +
+
+ {DOWNLOAD_CAT_SUBSUB_COUNT} + + {DOWNLOAD_CAT_SUBSUB_SIZE} + + {DOWNLOAD_CAT_SUBSUB_DOWNLOADED} +
{DOWNLOAD_CAT_NEWDOWNLOAD_TEXT}
{DOWNLOAD_CAT_SEARCH}
-
\n"; + $DOWNLOAD_CAT_TABLE_END = " + + + \n"; } -// ##### ------------------------------------------------------------------------------------------ - - - // ##### LIST TABLE ------------------------------------------------------------------------------- if(!isset($DOWNLOAD_LIST_TABLE_START)) { - $DOWNLOAD_LIST_TABLE_START = " -
-
- \n - - + + +
- ".LAN_dl_37." - \n + + + + + + + + + + + - - - - - - - - - - "; - + +   + + + + + + + + + + + + "; } - if(!isset($DOWNLOAD_LIST_TABLE)) { - $DOWNLOAD_LIST_TABLE = " - - - - - - - - - "; + $DOWNLOAD_LIST_TABLE = " + + + + + + + + + "; } if(!isset($DOWNLOAD_LIST_TABLE_END)) { - $DOWNLOAD_LIST_TABLE_END = " - -
+ ".LAN_dl_37." + -   - ".LAN_dl_39." - +   + ".LAN_dl_39." + -   - -
".LAN_dl_28."".LAN_dl_22."".LAN_dl_24."".LAN_dl_21."".LAN_dl_29."".LAN_dl_12."".LAN_dl_8."
".LAN_dl_28."".LAN_dl_22."".LAN_dl_24."".LAN_dl_21."".LAN_dl_29."".LAN_dl_12."".LAN_dl_8."
- {DOWNLOAD_LIST_NEWICON} {DOWNLOAD_LIST_NAME} - - {DOWNLOAD_LIST_DATESTAMP} - - {DOWNLOAD_LIST_AUTHOR} - - {DOWNLOAD_LIST_FILESIZE} - - {DOWNLOAD_LIST_REQUESTED} - - {DOWNLOAD_LIST_RATING} - - {DOWNLOAD_LIST_LINK} {DOWNLOAD_LIST_ICON} -
+ {DOWNLOAD_LIST_NEWICON} {DOWNLOAD_LIST_NAME} + + {DOWNLOAD_LIST_DATESTAMP} + + {DOWNLOAD_LIST_AUTHOR} + + {DOWNLOAD_LIST_FILESIZE} + + {DOWNLOAD_LIST_REQUESTED} + + {DOWNLOAD_LIST_RATING} + + {DOWNLOAD_LIST_LINK} +
{DOWNLOAD_LIST_TOTAL_AMOUNT} {DOWNLOAD_LIST_TOTAL_FILES}
- + $DOWNLOAD_LIST_TABLE_END = " +
{DOWNLOAD_LIST_TOTAL_AMOUNT} {DOWNLOAD_LIST_TOTAL_FILES}
+
\n"; } -// ##### ------------------------------------------------------------------------------------------ - - // ##### VIEW TABLE ------------------------------------------------------------------------------- - $DL_VIEW_PAGETITLE = PAGE_NAME." / {DOWNLOAD_CATEGORY} / {DOWNLOAD_VIEW_NAME}"; -$DL_VIEW_CAPTION = "{DOWNLOAD_VIEW_CAPTION}"; - $DL_VIEW_NEXTPREV = " -
- - - - - - -
{DOWNLOAD_VIEW_PREV}{DOWNLOAD_BACK_TO_LIST}{DOWNLOAD_VIEW_NEXT}
-
\n"; +$DL_VIEW_NEXTPREV = " +
+ + + + + + +
{DOWNLOAD_VIEW_PREV}{DOWNLOAD_BACK_TO_LIST}{DOWNLOAD_VIEW_NEXT}
+
\n"; // Only renders the following rows when data is present. $sc_style['DOWNLOAD_VIEW_AUTHOR_LAN']['pre'] = ""; @@ -249,104 +263,111 @@ $sc_style['DOWNLOAD_VIEW_AUTHORWEBSITE']['post'] = ""; if(!isset($DOWNLOAD_VIEW_TABLE)) { - $DOWNLOAD_VIEW_TABLE = " -
- \n - - - - - {DOWNLOAD_VIEW_AUTHOR_LAN} - {DOWNLOAD_VIEW_AUTHOR} - - {DOWNLOAD_VIEW_AUTHOREMAIL_LAN} - {DOWNLOAD_VIEW_AUTHOREMAIL} - - {DOWNLOAD_VIEW_AUTHORWEBSITE_LAN} - {DOWNLOAD_VIEW_AUTHORWEBSITE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- {DOWNLOAD_VIEW_NAME} -
{DOWNLOAD_VIEW_DESCRIPTION_LAN}{DOWNLOAD_VIEW_DESCRIPTION}
{DOWNLOAD_VIEW_IMAGE_LAN}{DOWNLOAD_VIEW_IMAGE}
{DOWNLOAD_VIEW_FILESIZE_LAN}{DOWNLOAD_VIEW_FILESIZE}
{DOWNLOAD_VIEW_DATE_LAN}{DOWNLOAD_VIEW_DATE=long}
{DOWNLOAD_VIEW_REQUESTED_LAN}{DOWNLOAD_VIEW_REQUESTED}
{DOWNLOAD_VIEW_LINK_LAN}{DOWNLOAD_VIEW_LINK}
{DOWNLOAD_VIEW_RATING_LAN}{DOWNLOAD_VIEW_RATING}
{DOWNLOAD_REPORT_LINK}
-
{DOWNLOAD_ADMIN_EDIT}
+ $DOWNLOAD_VIEW_TABLE = " +
+ + + + + + + + + {DOWNLOAD_VIEW_AUTHOR_LAN} + {DOWNLOAD_VIEW_AUTHOR} + {DOWNLOAD_VIEW_AUTHOREMAIL_LAN} + {DOWNLOAD_VIEW_AUTHOREMAIL} + {DOWNLOAD_VIEW_AUTHORWEBSITE_LAN} + {DOWNLOAD_VIEW_AUTHORWEBSITE} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {DOWNLOAD_VIEW_NAME} +
{DOWNLOAD_VIEW_DESCRIPTION_LAN}{DOWNLOAD_VIEW_DESCRIPTION}
{DOWNLOAD_VIEW_IMAGE_LAN}{DOWNLOAD_VIEW_IMAGE}
{DOWNLOAD_VIEW_FILESIZE_LAN}{DOWNLOAD_VIEW_FILESIZE}
{DOWNLOAD_VIEW_DATE_LAN}{DOWNLOAD_VIEW_DATE=long}
{DOWNLOAD_VIEW_REQUESTED_LAN}{DOWNLOAD_VIEW_REQUESTED}
{DOWNLOAD_VIEW_LINK_LAN}{DOWNLOAD_VIEW_LINK}
{DOWNLOAD_VIEW_RATING_LAN}{DOWNLOAD_VIEW_RATING}
{DOWNLOAD_REPORT_LINK}
+
{DOWNLOAD_ADMIN_EDIT}
\n"; } -// ##### ------------------------------------------------------------------------------------------ - // ##### MIRROR LIST ------------------------------------------------------------------------------- - if(!isset($DOWNLOAD_MIRROR_START)) { $DOWNLOAD_MIRROR_START = "
- - - - - - - - - - +
{DOWNLOAD_MIRROR_REQUEST}
{DOWNLOAD_MIRROR_HOST_LAN}{DOWNLOAD_MIRROR_DESCRIPTION_LAN}{DOWNLOAD_MIRROR_LOCATION_LAN}{DOWNLOAD_MIRROR_GET_LAN}
+ + + + + + + + + + + + + + + + + + "; } if(!isset($DOWNLOAD_MIRROR)) { $DOWNLOAD_MIRROR = " - - - - - - + + + + + + + + "; } if(!isset($DOWNLOAD_MIRROR_END)) { $DOWNLOAD_MIRROR_END = " -
{DOWNLOAD_MIRROR_REQUEST_ICON}".LAN_dl_72."{DOWNLOAD_MIRROR_REQUEST}
".LAN_dl_68."".LAN_dl_71."".LAN_dl_70."".LAN_dl_21."".LAN_dl_32."
{DOWNLOAD_MIRROR_IMAGE}

{DOWNLOAD_MIRROR_REQUESTS}
{DOWNLOAD_TOTAL_MIRROR_REQUESTS}
{DOWNLOAD_MIRROR_DESCRIPTION}
{DOWNLOAD_MIRROR_LOCATION}
{DOWNLOAD_MIRROR_LINK} {DOWNLOAD_MIRROR_FILESIZE}
{DOWNLOAD_MIRROR_IMAGE} + {DOWNLOAD_MIRROR_NAME} +
+ {DOWNLOAD_MIRROR_REQUESTS} +
{DOWNLOAD_TOTAL_MIRROR_REQUESTS} +
+
{DOWNLOAD_MIRROR_DESCRIPTION}{DOWNLOAD_MIRROR_LOCATION}{DOWNLOAD_MIRROR_FILESIZE}{DOWNLOAD_MIRROR_LINK}
+
"; }