2009-01-11 02:59:10 +00:00
< ? php
/*
2009-11-17 10:46:35 +00:00
* e107 website system
*
2009-11-18 01:06:08 +00:00
* Copyright ( C ) 2008 - 2009 e107 Inc ( e107 . org )
2009-11-17 10:46:35 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
*
*
* $Source : / cvs_backup / e107_0 . 8 / e107_plugins / download / download . php , v $
2010-02-10 18:18:01 +00:00
* $Revision $
* $Date $
* $Author $
2009-11-17 10:46:35 +00:00
*/
2009-09-17 20:38:20 +00:00
if ( ! defined ( 'e107_INIT' ))
2009-12-03 00:48:28 +00:00
{
2009-09-17 20:38:20 +00:00
require_once ( " ../../class2.php " );
}
2009-09-18 19:07:09 +00:00
if ( ! e107 :: isInstalled ( 'download' ))
{
2009-12-03 00:48:28 +00:00
header ( " location: " . e_BASE . " index.php " );
2009-09-18 19:07:09 +00:00
}
2009-09-17 20:38:20 +00:00
2009-05-04 20:09:45 +00:00
include_lan ( e_PLUGIN . 'download/languages/' . e_LANGUAGE . '/download.php' );
2009-02-11 21:41:54 +00:00
require_once ( e_PLUGIN . 'download/handlers/download_class.php' );
require_once ( e_PLUGIN . 'download/handlers/category_class.php' );
2009-01-13 00:42:54 +00:00
require_once ( e_PLUGIN . 'download/download_shortcodes.php' );
require_once ( e_HANDLER . 'comment_class.php' );
2009-01-11 02:59:10 +00:00
2009-02-11 21:41:54 +00:00
$dl = new download ();
$cobj = new comment ();
2009-01-11 02:59:10 +00:00
$dl_text = '' ; // Output variable
if ( ! defined ( " USER_WIDTH " )) { define ( " USER_WIDTH " , " width:100% " ); }
/* 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 " ));
$template_load_core = '
$template_name = $load_template . " .php " ;
if ( is_readable ( THEME . " templates/ " . $template_name ))
{
require_once ( THEME . " templates/ " . $template_name );
}
elseif ( is_readable ( THEME . $template_name ))
{
require_once ( THEME . $template_name );
}
else
{
2009-01-13 08:05:08 +00:00
require_once ( e_PLUGIN . " download/templates/ " . $template_name );
2009-01-11 02:59:10 +00:00
}
' ;
2009-01-14 22:53:38 +00:00
$order_options = array ( 'download_id' , 'download_datestamp' , 'download_requested' , 'download_name' , 'download_author' , 'download_requested' );
2009-01-11 02:59:10 +00:00
$sort_options = array ( 'ASC' , 'DESC' );
if ( ! e_QUERY || $_GET [ 'elan' ])
{
2009-02-11 21:41:54 +00:00
$action = 'maincats' ; // List categories
$maincatval = '' ; // Show all main categories
2009-01-11 02:59:10 +00:00
}
else
{ // Get parameters from the query
2009-02-11 21:41:54 +00:00
$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 ));
}
2009-05-03 21:16:15 +00:00
2009-02-11 21:41:54 +00:00
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 . " )) " ) )
{
$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 , " <div style='text-align:center'> " . LAN_dl_3 . " </div> " );
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 )
{
2009-05-03 21:16:15 +00:00
case 1 : // No permissions
if ( strlen ( $pref [ 'download_denied' ]) > 0 ) {
$errmsg = $tp -> toHTML ( $pref [ 'download_denied' ], true );
} else {
$errmsg = LAN_dl_63 ;
}
2009-02-11 21:41:54 +00:00
break ;
2009-05-03 21:16:15 +00:00
case 2 : // Quota exceeded
$errmsg = LAN_dl_62 ;
2009-02-11 21:41:54 +00:00
break ;
default :
$errmsg = LAN_dl_61 . " " . $errnum ; // Generic error - shouldn't happen
}
$ns -> tablerender ( LAN_dl_61 , " <div style='text-align:center'> " . $errmsg . " </div> " );
require_once ( FOOTERF );
exit ;
}
2009-01-11 02:59:10 +00:00
}
if ( isset ( $order ) && ! in_array ( $order , $order_options )) unset ( $order );
if ( isset ( $sort ) && ! in_array ( $sort , $sort_options )) unset ( $sort );
2012-04-20 07:28:53 +00:00
if ( ! isset ( $order )) $order = vartrue ( $pref [ 'download_order' ], 'download_datestamp' );
if ( ! isset ( $sort )) $sort = vartrue ( $pref [ 'download_sort' ], 'DESC' );
if ( ! isset ( $view )) $view = vartrue ( $pref [ 'download_view' ], '10' );
2009-01-11 02:59:10 +00:00
//--------------------------------------------------
// GENERATE DISPLAY TEXT
//--------------------------------------------------
switch ( $action )
{ // Displaying main category or categories
2009-02-11 21:41:54 +00:00
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 );
if ( ! defined ( " DL_IMAGESTYLE " )){ define ( " DL_IMAGESTYLE " , " border:1px solid blue " );}
// 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 ( $dlcat -> down_count == 0 )
{
$ns -> tablerender ( LAN_dl_18 , " <div style='text-align:center'> " . LAN_dl_2 . " </div> " );
require_once ( FOOTERF );
exit ;
}
$download_cat_table_string = " " ;
foreach ( $dlcat -> cat_tree as $dlrow )
{ // Display main category headings, then sub-categories, optionally with sub-sub categories expanded
2013-05-24 18:40:29 +02:00
$download_cat_table_string .= $tp -> parseTemplate ( $DOWNLOAD_CAT_PARENT_TABLE , TRUE , vartrue ( $download_shortcodes ));
2009-02-11 21:41:54 +00:00
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 ));
2013-05-24 18:40:29 +02:00
$dl_title = $tp -> parseTemplate ( " { BREADCRUMB=dlbreadcrumb} " , TRUE , $download_shortcodes );
2009-02-11 21:41:54 +00:00
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
2009-01-11 02:59:10 +00:00
} // End switch ($action)
if ( isset ( $_POST [ 'commentsubmit' ]))
{
if ( ! $sql -> db_Select ( " download " , " download_comment " , " download_id = ' { $id } ' " ))
{
header ( " location: " . e_BASE . " index.php " );
exit ;
}
else
{
2009-02-11 21:41:54 +00:00
$dlrow = $sql -> db_Fetch ();
if ( $dlrow [ 'download_comment' ] && ( ANON === TRUE || USER === TRUE ))
2009-01-11 02:59:10 +00:00
{
$clean_authorname = $_POST [ 'author_name' ];
$clean_comment = $_POST [ 'comment' ];
$clean_subject = $_POST [ 'subject' ];
$cobj -> enter_comment ( $clean_authorname , $clean_comment , " download " , $id , $pid , $clean_subject );
// $e107cache->clear("comment.download.{$sub_action}"); $sub_action not used here
$e107cache -> clear ( " comment.download " );
}
}
}
//====================================================
// LIST
//====================================================
if ( $action == " list " )
{
2009-02-11 21:41:54 +00:00
$total_downloads = $sql -> db_Count ( " download " , " (*) " , " WHERE download_category = ' { $id } ' AND download_active > 0 AND download_visible REGEXP ' " . e_CLASS_REGEXP . " ' " );
2009-01-11 02:59:10 +00:00
2009-02-11 21:41:54 +00:00
require_once ( HEADERF );
2009-01-11 02:59:10 +00:00
/* SHOW SUBCATS ... */
2009-02-11 21:41:54 +00:00
if ( $sql -> db_Select ( " download_category " , " download_category_id " , " download_category_parent=' { $id } ' " ))
2009-01-11 02:59:10 +00:00
{
/* there are subcats - display them ... */
$qry = "
2009-02-11 21:41:54 +00:00
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
2009-01-11 02:59:10 +00:00
" ;
$sql -> db_Select_gen ( $qry );
2009-02-11 21:41:54 +00:00
$scArray = $sql -> db_getList ();
2009-01-11 02:59:10 +00:00
$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 " );}
2009-02-11 21:41:54 +00:00
$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 );
2009-12-03 00:48:28 +00:00
$dlbreadcrumb = $dl -> getBreadcrumb ( array ( LAN_dl_18 => e_SELF , $type ));
2009-07-14 23:19:22 +00:00
$dl_title = $tp -> parseTemplate ( " { BREADCRUMB=dlbreadcrumb} " , TRUE , $download_shortcodes );
2009-02-11 21:41:54 +00:00
$ns -> tablerender ( $dl_title , $dl_text );
2009-07-14 23:19:22 +00:00
$text = " " ; // If other files, show in a separate block
$dl_title = " " ; // Cancel title once displayed
2009-01-11 02:59:10 +00:00
} // End of subcategory display
2009-02-11 21:41:54 +00:00
// Now display individual downloads
2009-01-11 02:59:10 +00:00
if ( ! check_class ( $download_category_class ))
{
$ns -> tablerender ( LAN_dl_18 , " <div style='text-align:center'> " . LAN_dl_3 . " </div> " );
require_once ( FOOTERF );
exit ;
}
if ( $total_downloads < $view ) { $dl_from = 0 ; }
$load_template = 'download_template' ;
if ( ! isset ( $DOWNLOAD_LIST_TABLE )) eval ( $template_load_core );
2009-02-11 21:41:54 +00:00
if ( ! defined ( " DL_IMAGESTYLE " )){ define ( " DL_IMAGESTYLE " , " border:1px solid blue " );}
2009-01-11 02:59:10 +00:00
require_once ( e_HANDLER . " rate_class.php " );
2009-02-11 21:41:54 +00:00
$dltdownloads = 0 ;
2009-01-11 02:59:10 +00:00
// $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 } " );
if ( $filetotal )
{ // Only show list if some files in it
2009-02-11 21:41:54 +00:00
$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 );
2009-12-03 00:48:28 +00:00
if ( $sql -> db_Select ( " download_category " , " * " , " download_category_id=' { $download_category_parent } ' " ))
{
$parent = $sql -> db_Fetch ();
}
$dlbreadcrumb = $dl -> getBreadcrumb ( array ( LAN_dl_18 => e_SELF , $parent [ 'download_category_name' ] => e_SELF . " ?list. " . $parent [ 'download_category_id' ], $type ));
2009-02-11 21:41:54 +00:00
$dl_title .= $tp -> parseTemplate ( " { BREADCRUMB=dlbreadcrumb} " , TRUE , $download_shortcodes );
$ns -> tablerender ( $dl_title , $dl_text );
2009-01-11 02:59:10 +00:00
}
if ( ! isset ( $DOWNLOAD_LIST_NEXTPREV ))
{
2009-02-11 21:41:54 +00:00
$sc_style [ 'DOWNLOAD_LIST_NEXTPREV' ][ 'pre' ] = " <div class='nextprev'> " ;
2009-01-11 02:59:10 +00:00
$sc_style [ 'DOWNLOAD_LIST_NEXTPREV' ][ 'post' ] = " </div> " ;
$DOWNLOAD_LIST_NEXTPREV = "
< div style = 'text-align:center;margin-left:auto;margin-right:auto' > { DOWNLOAD_BACK_TO_CATEGORY_LIST } < br />< br />
{ DOWNLOAD_LIST_NEXTPREV }
</ div > " ;
}
$nextprev_parms = $total_downloads . " , " . $view . " , " . $dl_from . " , " . e_SELF . " ?[FROM].list. { $id } . { $view } . { $order } . { $sort } . " ;
2009-02-11 21:41:54 +00:00
echo $tp -> parseTemplate ( $DOWNLOAD_LIST_NEXTPREV , TRUE , $download_shortcodes );
2009-01-11 02:59:10 +00:00
require_once ( FOOTERF );
exit ;
2009-02-11 21:41:54 +00:00
} // end of action=="list"
2009-01-11 02:59:10 +00:00
//====================================================
// VIEW
//====================================================
if ( $action == " view " )
{
$gen = new convert ;
$highlight_search = FALSE ;
if ( isset ( $_POST [ 'highlight_search' ])) {
$highlight_search = TRUE ;
}
$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 d . download_active > 0
AND d . download_visible IN ( " .USERCLASS_LIST. " )
AND dc . download_category_class IN ( " .USERCLASS_LIST. " )
LIMIT 1 " ;
2009-02-11 21:41:54 +00:00
if ( ! $sql -> db_Select_gen ( $query )){
2009-01-11 02:59:10 +00:00
require_once ( HEADERF );
$ns -> tablerender ( LAN_dl_18 , " <div style='text-align:center'> " . LAN_dl_3 . " </div> " );
require_once ( FOOTERF );
exit ;
}
2009-02-11 21:41:54 +00:00
$dlrow = $sql -> db_Fetch ();
2009-01-11 02:59:10 +00:00
2009-02-11 21:41:54 +00:00
$comment_edit_query = 'comment.download.' . $id ;
2009-01-11 02:59:10 +00:00
$load_template = 'download_template' ;
if ( ! isset ( $DOWNLOAD_VIEW_TABLE )) eval ( $template_load_core );
if ( ! defined ( " DL_IMAGESTYLE " )){ define ( " DL_IMAGESTYLE " , " border:0px " );}
if ( ! isset ( $DL_VIEW_PAGETITLE ))
{
$DL_VIEW_PAGETITLE = PAGE_NAME . " / { DOWNLOAD_CATEGORY} / { DOWNLOAD_VIEW_NAME} " ;
}
$DL_TITLE = $tp -> parseTemplate ( $DL_VIEW_PAGETITLE , TRUE , $download_shortcodes );
define ( " e_PAGETITLE " , $DL_TITLE );
require_once ( HEADERF );
$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_NEXTPREV ))
{
$DL_VIEW_NEXTPREV = "
< div style = 'text-align:center' >
< table style = '".USER_WIDTH."' >
< tr >
< td style = 'width:40%;' > { DOWNLOAD_VIEW_PREV } </ td >
< td style = 'width:20%; text-align: center;' > { DOWNLOAD_BACK_TO_LIST } </ td >
< td style = 'width:40%; text-align: right;' > { DOWNLOAD_VIEW_NEXT } </ td >
</ tr >
</ table >
</ div >
" ;
2009-02-11 21:41:54 +00:00
}
2009-01-11 02:59:10 +00:00
// ------- Next/Prev -----------
2009-02-11 21:41:54 +00:00
$text .= $tp -> parseTemplate ( $DL_VIEW_NEXTPREV , TRUE , $download_shortcodes );
2009-01-11 02:59:10 +00:00
2009-02-11 21:41:54 +00:00
$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 );
2009-01-11 02:59:10 +00:00
unset ( $text );
2009-02-11 21:41:54 +00:00
if ( $dlrow [ 'download_comment' ]) {
$cobj -> compose_comment ( " download " , " comment " , $id , $width , $dlrow [ 'download_name' ], $showrate = FALSE );
2009-01-11 02:59:10 +00:00
}
require_once ( FOOTERF );
exit ;
}
//====================================================
// REPORT BROKEN LINKS
//====================================================
if ( $action == " report " && check_class ( $pref [ 'download_reportbroken' ]))
{
2009-02-11 21:41:54 +00:00
$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")) {
2009-01-11 02:59:10 +00:00
require_once ( HEADERF );
require_once ( FOOTERF );
exit ;
}
2009-02-11 21:41:54 +00:00
$dlrow = $sql -> db_Fetch ();
extract ( $dlrow );
2009-01-11 02:59:10 +00:00
if ( isset ( $_POST [ 'report_download' ])) {
2009-02-11 21:41:54 +00:00
$report_add = $tp -> toDB ( $_POST [ 'report_add' ]);
$download_name = $tp -> toDB ( $download_name );
2009-01-11 02:59:10 +00:00
$user = USER ? USERNAME : LAN_dl_52 ;
if ( $pref [ 'download_email' ]) { // this needs to be moved into the NOTIFY, with an event.
require_once ( e_HANDLER . " mail.php " );
$subject = LAN_dl_60 . " " . SITENAME ;
$report = LAN_dl_58 . " " . SITENAME . " : \n " . ( substr ( SITEURL , - 1 ) == " / " ? SITEURL : SITEURL . " / " ) . " download.php?view. " . $download_id . " \n
" .LAN_dl_59. " " . $user . " \n " . $report_add ;
sendemail ( SITEADMINEMAIL , $subject , $report );
}
$sql -> db_Insert ( 'generic' , " 0, 'Broken Download', " . time () . " ,' " . USERID . " ', ' { $download_name } ', { $id } , ' { $report_add } ' " );
define ( " e_PAGETITLE " , PAGE_NAME . " / " . LAN_dl_47 );
require_once ( HEADERF );
2011-07-18 18:28:14 +00:00
$text = LAN_dl_48 . " <br /><br /><a href=' " . e_PLUGIN . " download/download.php?view. " . $download_id . " '> " . LAN_dl_49 . " </a> " ;
2009-02-11 21:41:54 +00:00
$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 );
2009-01-11 02:59:10 +00:00
} else {
define ( " e_PAGETITLE " , PAGE_NAME . " / " . LAN_dl_51 . " " . $download_name );
require_once ( HEADERF );
$text = " <form action=' " . e_SELF . " ?report. { $download_id } ' method='post'>
2009-02-11 21:41:54 +00:00
< table style = '".USER_WIDTH."' >
< tr >
< td style = 'width:50%' >
" .LAN_dl_32. " : " . $download_name . " < br />
< a href = '".e_PLUGIN."download/download?view.{$download_id}' >
< span class = 'smalltext' > " .LAN_dl_53. " </ span >
</ a >
</ td >
< td style = 'text-align:center;width:50%' >
</ td >
</ tr >
< tr >
< td > " .LAN_dl_54. " < br /> " .LAN_dl_55. " </ td >
< td style = 'text-align:center;' >
< textarea cols = '40' rows = '10' class = 'tbox' name = 'report_add' ></ textarea >
</ td >
</ tr >
< tr >
< td colspan = '2' style = 'text-align:center;' >< br />
2013-04-26 13:48:23 -07:00
< input class = 'btn button' type = 'submit' name = 'report_download' value = \ " " . LAN_dl_45 . " \" />
2009-02-11 21:41:54 +00:00
</ td >
</ tr >
</ table >
</ form > " ;
$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 );
2009-01-11 02:59:10 +00:00
}
require_once ( FOOTERF );
exit ;
}
//====================================================
// MIRRORS
//====================================================
if ( $action == " mirror " )
{
require_once ( HEADERF );
$load_template = 'download_template' ;
if ( ! isset ( $DOWNLOAD_MIRROR_START )) eval ( $template_load_core );
2009-02-11 21:41:54 +00:00
$sql -> db_Select ( " download_mirror " );
$mirrorList = $sql -> db_getList ( " ALL " , 0 , 200 , " mirror_id " );
2009-01-11 02:59:10 +00:00
2009-02-11 21:41:54 +00:00
$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 " ;
2009-01-11 02:59:10 +00:00
2009-02-11 21:41:54 +00:00
if ( $sql -> db_Select_gen ( $query ))
{
$dlrow = $sql -> db_Fetch ();
$array = explode ( chr ( 1 ), $dlrow [ 'download_mirror' ]);
2009-01-14 22:53:38 +00:00
if ( 2 == varset ( $pref [ 'mirror_order' ]))
{
// Order by name, sort array manually
usort ( $array , " sort_download_mirror_order " );
}
//elseif (1 == varset($pref['mirror_order']))
//{
// // Order by ID - do nothing order is as stored in DB
//}
elseif ( 0 == varset ( $pref [ 'mirror_order' ], 0 ))
{
// Shuffle the mirror list into a random order
$c = count ( $array );
for ( $i = 1 ; $i < $c ; $i ++ )
{
$d = mt_rand ( 0 , $i );
$tmp = $array [ $i ];
$array [ $i ] = $array [ $d ];
$array [ $d ] = $tmp ;
}
2009-01-11 02:59:10 +00:00
}
2009-02-11 21:41:54 +00:00
$dl_text = $tp -> parseTemplate ( $DOWNLOAD_MIRROR_START , TRUE , $download_shortcodes );
$download_mirror = 1 ;
2009-01-11 02:59:10 +00:00
foreach ( $array as $mirrorstring )
{
2009-02-11 21:41:54 +00:00
if ( $mirrorstring )
{
$dlmirrorfile = explode ( " , " , $mirrorstring );
$dlmirror = $mirrorList [ $dlmirrorfile [ 0 ]];
$dl_text .= $tp -> parseTemplate ( $DOWNLOAD_MIRROR , TRUE , $download_shortcodes );
}
2009-01-11 02:59:10 +00:00
}
2009-02-11 21:41:54 +00:00
$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 );
2009-01-11 02:59:10 +00:00
require_once ( FOOTERF );
}
}
2009-01-14 22:53:38 +00:00
function sort_download_mirror_order ( $a , $b )
{
$a = explode ( " , " , $a );
$b = explode ( " , " , $b );
if ( $a [ 1 ] == $b [ 1 ]) {
return 0 ;
}
return ( $a [ 1 ] < $b [ 1 ]) ? - 1 : 1 ;
}
2009-02-11 21:41:54 +00:00
?>