NightGuard, да пробовалпо всякому, все равно не выходит, просто белый экран после этого, не понимаю в чем дело!
Посмотрите кому не трудно 1909 строчка
[code]<?php
/**
* @version 1.5
* @package JDownloads
* @copyright (C) 2009
www.jdownloads.com* @license
http://www.gnu.org/copyleft/gpl.html GNU/GPL
*
*
*
*/
defined( '_JEXEC' ) or die( 'Restricted access-php' );
Error_Reporting(E_ERROR);
clearstatcache();
session_start();
jimport( 'joomla.application.component.view');
$database = &JFactory::getDBO();
$jconfig = new JConfig();
global $Itemid, $mainframe;
global $id, $limit, $limitstart, $site_aktuell, $catid, $cid, $task, $view, $pop, $jlistConfig, $jlistTemplates, $page_title;
global $cat_link_itemids, $upload_link_itemid, $search_link_itemid, $root_itemid;
$mainframe = JFactory::getApplication();
$Itemid = JRequest::getInt('Itemid');
jimport( 'joomla.html.parameter' );
$document =& JFactory::getDocument();
$params = &$mainframe->getParams();
$GLOBALS['_VERSION'] = new JVersion();
$version = $GLOBALS['_VERSION']->getShortVersion();
$params2 = JComponentHelper::getParams('com_languages');
$frontend_lang = $params2->get('site', 'en-GB');
$language = JLanguage::getInstance($frontend_lang);
require_once( JPATH_COMPONENT_SITE.DS.'jdownloads.html.php' );
require_once( JPATH_COMPONENT_SITE.DS.'jdownloads.class.php' );
//require_once(ELPATH.'/../../includes/pageNavigation.php');
$id = (int)JArrayHelper::getValue( $_REQUEST, 'cid', array(0));
if (!is_array( $id)) {
$id = array(0);
}
$cid = $id;
$GLOBALS['jlistConfig'] = buildjlistConfig();
$GLOBALS['jlistTemplates'] = getTemplates();
// search for root menu item to use
$sql = 'SELECT id FROM #__menu WHERE link = ' . $database->Quote("index.php?option=com_jdownloads&view=viewcategories"). ' AND published = 1' ;
$database->setQuery($sql);
$root_itemid = $database->loadResult();
if (!$root_itemid) $root_itemid = $Itemid;
// Page Title
$menus = &JSite::getMenu();
$menu = $menus->getActive();
// because the application sets a default page title, we need to get it
// right from the menu item itself
if (is_object( $menu )) {
$menu_params = new JParameter( $menu->params );
$x = $menu_params->get( 'page_title');
if (!$menu_params->get( 'page_title')) {
$params->set('page_title', $jlistConfig['jd.header.title']);
}
} else {
$params->set('page_title', $jlistConfig['jd.header.title']);
}
if ($params->get('page_title')){
$document->setTitle( $params->get( 'page_title' ) );
} else {
if ($menu_params && $menu_params->get( 'page_title')){
if ($menu_params->get( 'page_title')){
$document->setTitle( $menu_params->get( 'page_title'));
}
}
}
$page_title = $document->getTitle( 'title');
// get all published single category menu links
$database->setQuery("SELECT id, link from #__menu WHERE link LIKE 'index.php?option=com_jdownloads&view=viewcategory&catid%' AND published = 1");
$cat_link_itemids = $database->loadAssocList();
if ($cat_link_itemids){
for ($i=0; $i < count($cat_link_itemids); $i++){
$cat_link_itemids[$i][catid] = substr( strrchr ( $cat_link_itemids[$i][link], '=' ), 1);
}
}
// get upload link itemid when exists
$database->setQuery("SELECT id from #__menu WHERE link = 'index.php?option=com_jdownloads&view=upload' AND published = 1");
$upload_link_itemid = $database->loadResult();
// get search link itemid when exists
$database->setQuery("SELECT id from #__menu WHERE link = 'index.php?option=com_jdownloads&view=search' AND published = 1");
$search_link_itemid = $database->loadResult();
$pop = intval( JArrayHelper::getValue( $_REQUEST, 'pop', 0 ) );
$task = JRequest::getCmd( 'task' );
$view = JRequest::getCmd( 'view' );
$cid = (int)JArrayHelper::getValue($_REQUEST, 'cid', array());
$catid = (int)JArrayHelper::getValue($_REQUEST, 'catid', 0);
$limit = intval($jlistConfig['files.per.side']);
$limitstart = intval( JRequest::getInt( 'limitstart', 0 ) );
$site_aktuell = intval( JRequest::getInt( 'site', 1 ) );
// AUP integration
if ($jlistConfig['use.alphauserpoints']){
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if (file_exists($api_AUP)){
require_once ($api_AUP);
}
}
if ($task && !$view) $view = $task;
switch ($view) {
case 'upload':
viewUpload($option,$view);
break;
case 'summary':
Summary($option);
break;
case 'finish':
finish($option);
break;
case 'viewcategory':
showOneCategory($option,$cid);
break;
case 'viewdownload':
case 'view.download':
showDownload($option,$cid);
break;
case 'download':
download($option,$cid);
break;
case 'search':
showSearchForm($option,$cid);
break;
case 'searchresult':
showSearchResult($option,$cid);
break;
case 'report':
reportDownload($option,$cid);
break;
case 'viewcategories':
showCats($option,$cid);
break;
case 'editor.insert.file':
editorInsertFile('com_jdownloads');
break;
case 'edit':
require_once(JPATH_COMPONENT.'/jdownloads.edit.php');
editFile($option, $cid);
break;
case 'save':
require_once(JPATH_COMPONENT.'/jdownloads.edit.php');
saveFile($option, $cid);
break;
default: showCats($option,$cid);
break;
}
// show summary
function Summary($option){
global $jlistConfig, $Itemid, $mainframe;
//$session = JFactory::getSession();
//$session->set('jd_sec_check', 1);
$app = &JFactory::getApplication();
$user = &JFactory::getUser();
$user_access = checkAccess_JD();
$users_access = (int)substr($user_access, 0, 1);
$database = &JFactory::getDBO();
// AUP support
$sum_aup_points = 0;
$extern_site = false;
$open_in_blank_page = false;
$marked_files_id = array();
$has_licenses = false;
$must_confirm = false;
$license_text = '';
// get file-id from the marked files - when used
$marked_files_id = JArrayHelper::getValue( $_POST, 'cb_arr', array(0));
for($i=0,$n=count($marked_files_id);$i<$n;$i++){
$marked_files_id[$i] = intval($marked_files_id[$i]);
}
// get file id
$fileid = intval(JArrayHelper::getValue( $_REQUEST, 'cid', 0 ));
// get cat id
$catid = intval(JArrayHelper::getValue( $_REQUEST, 'catid', 0 ));
// get groups access
$user_is_in_groups = getUserGroupsX();
$user_is_in_groups_arr = explode(',', $user_is_in_groups);
// check access for manual url manipulation - fix
$database->setQuery('SELECT * FROM #__jdownloads_cats WHERE published = 1 AND cat_id = '.$catid);
$cat = $database->loadObject();
$access[0] = (int)substr($cat->cat_access, 0, 1);
$access[1] = (int)substr($cat->cat_access, 1, 1);
if ($users_access < $access[1] || !$cat){
if (!in_array($cat->cat_group_access, $user_is_in_groups_arr)){
// jump to login
if (!$user->id) {
$app->redirect(JRoute::_('index.php?option=com_users&view=login'));
} else {
echo "<script> alert('".JText::_('COM_JDOWNLOADS_FRONTEND_ANTILEECH_MESSAGE')."'); window.history.go(-1); </script>\n";
exit();
}
}
}
$breadcrumbs =& $mainframe->getPathWay();
if ($catid){
$breadcrumbs = createPathway($catid, $breadcrumbs, $option);
$breadcrumbs->addItem($cat->cat_title, JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&view=viewcategory&catid='.$catid));
}
if ($fileid){
$database->setQuery("SELECT * FROM #__jdownloads_files WHERE published = 1 AND file_id = '$fileid' AND cat_id = '$catid'");
if (!$file = $database->loadObject()){
// jump to login
if (!$user->id) {
$app->redirect(JRoute::_('index.php?option=com_users&view=login'));
} else {
echo "<script> alert('".JText::_('COM_JDOWNLOADS_FRONTEND_ANTILEECH_MESSAGE')."'); window.history.go(-1); </script>\n";
exit();
}
}
$breadcrumbs->addItem($file->file_title, JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&view=viewdownload&catid='.$catid.'&cid='.$fileid));
}
$breadcrumbs->addItem(JText::_('COM_JDOWNLOADS_FRONTEND_HEADER_SUMMARY_TITLE'), '');
// is mirror file ?
$is_mirror = intval(JArrayHelper::getValue( $_REQUEST, 'm', 0 ));
// when exists - no checkbox was used
if ($fileid){
$direktlink = true;
$id_text = $fileid;
$filename = JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&view=finish&cid='.$fileid.'&catid='.$catid.'&m='.$is_mirror);
if ($file->license && $file->license_agree) $must_confirm = true;
$download_link = $filename;
$file_title = ' - '.$file->file_title;
}
// move in text for view the files list
$anz = 0;
if (!$id_text){
$anz = count($marked_files_id);
if ( $anz > 1 ){
$id_text = implode(',', $marked_files_id);
} else {
$id_text = $marked_files_id[0];
}
}
// get filetitle and release for mail and summary
$mail_files_arr = array();
$mail_files = "<div><ul>";
$database->setQuery("SELECT * FROM #__jdownloads_files WHERE published = 1 AND file_id IN ($id_text) ");
if (!$mail_files_arr = $database->loadObjectList()){
// jump to login
if (!$user->id) {
$app->redirect(JRoute::_('index.php?option=com_users&view=login'));
} else {
echo "<script> alert('".JText::_('COM_JDOWNLOADS_FRONTEND_ANTILEECH_MESSAGE')."'); window.history.go(-1); </script>\n";
exit();
}
}
if ($jlistConfig['use.alphauserpoints']){
// get standard points value from AUP
$database->setQuery("SELECT points FROM #__alpha_userpoints_rules WHERE published = 1 AND plugin_function = 'plgaup_jdownloads_user_download'");
$aup_default_points = (int)$database->loadResult();
}
for ($i=0; $i<count($mail_files_arr); $i++) {
// build sum of aup points
if ($jlistConfig['use.alphauserpoints']){
if ($jlistConfig['use.alphauserpoints.with.price.field']){
$sum_aup_points = $sum_aup_points + (int)$mail_files_arr[$i]->price;
} else {
$sum_aup_points += $aup_default_points;
}
}
// get license name
if ($mail_files_arr[$i]->license > 0){
if ($mail_files_arr[$i]->license && $mail_files_arr[$i]->license_agree) $must_confirm = true;
$lic = $mail_files_arr[$i]->license;
$has_licenses = true;
$database->setQuery("SELECT * FROM #__jdownloads_license WHERE id = '$lic'");
$license = $database->loadObject();
if ($must_confirm) $license_text = stripslashes($license->license_text);
if ($license->license_url){
// add license link
// a little pic for extern links
$extern_url_pic = '<img src="'.JURI::base().'components/com_jdownloads/assets/images/link_extern.gif" alt="" />';
$mail_files .= "<div><li><b>".$mail_files_arr[$i]->file_title.' '.$mail_files_arr[$i]->release.' </b>'.JText::_('COM_JDOWNLOADS_FE_DETAILS_LICENSE_TITLE').': <b><a href="'.$license->license_url.'" target="_blank">'.$license->license_title.'</a> '.$extern_url_pic.' </b>'.JText::_('COM_JDOWNLOADS_FE_DETAILS_FILESIZE_TITLE').': <b>'.$mail_files_arr[$i]->size.'</b></li></div>';
} else {
$mail_files .= "<div><li><b>".$mail_files_arr[$i]->file_title.' '.$mail_files_arr[$i]->release.' </b>'.JText::_('COM_JDOWNLOADS_FE_DETAILS_LICENSE_TITLE').': <b>'.$license->license_title.' </b>'.JText::_('COM_JDOWNLOADS_FE_DETAILS_FILESIZE_TITLE').': <b>'.$mail_files_arr[$i]->size.'</b></li></div>';
}
} else {
$mail_files .= "<div><li><b>".$mail_files_arr[$i]->file_title.' '.$mail_files_arr[$i]->release.' </b>'.JText::_('COM_JDOWNLOADS_FE_DETAILS_FILESIZE_TITLE').': <b>'.$mail_files_arr[$i]->size.'</b></li></div>';
}
}
$mail_files .= "</ul></div>";
// set flag when link must opened in a new browser window
if (!$is_mirror && $i == 1 && $mail_files_arr[0]->extern_site){
$extern_site = true;
}
if ($is_mirror == 1 && $i == 1 && $mail_files_arr[0]->extern_site_mirror_1){
$extern_site = true;
}
if ($is_mirror == 2 && $i == 1 && $mail_files_arr[0]->extern_site_mirror_2){
$extern_site = true;
}
// get file extension when only one file selected - set flag when link must opened in a new browser window
if (count($marked_files_id) == 1 && $mail_files_arr[0]->url_download) {
$view_types = array();
$view_types = explode(',', $jlistConfig['file.types.view']);
$fileextension = strtolower(substr(strrchr($mail_files_arr[0]->url_download,"."),1));
if (in_array($fileextension, $view_types)){
$open_in_blank_page = true;
}
}
// when mass download with checkboxes
if (!$direktlink){
// more as one file is selected - zip it in a temp file
$download_verz = JURI::base().$jlistConfig['files.uploaddir'].'/';
$zip_verz = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/';
if (count($marked_files_id) > 1) {
// build random value for zip filename
if (empty($user_random_id)){
$user_random_id = buildRandomID();
}
$zip=new ss_zip();
for ($i=0; $i<count($marked_files_id); $i++) {
// get file url
$database->setQuery("SELECT url_download, cat_id, file_title FROM #__jdownloads_files WHERE file_id = '".(int)$marked_files_id[$i]."'");
$file_data = $database->loadObject();
$filename = $file_data->url_download;
$file_title = $file_title.' - '.$file_data->file_title;
$cat_id = $file_data->cat_id;
$database->setQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = '$cat_id'");
$cat_dir = $database->loadResult();
$cat_dir = $cat_dir.'/';
$zip->add_file($zip_verz.$cat_dir.$filename, $filename);
}
$zip->archive(); // return the ZIP
$zip->save($zip_verz."tempzipfiles/".$jlistConfig['zipfile.prefix'].$user_random_id.".zip");
$zip_size = fsize($zip_verz."tempzipfiles/".$jlistConfig['zipfile.prefix'].$user_random_id.".zip");
$zip_file_info = JText::_('COM_JDOWNLOADS_FRONTEND_SUMMARY_ZIP_FILESIZE').': <b>'.$zip_size.'</b>';
// delete older zip files
$del_ok = deleteOldFile($zip_verz."tempzipfiles/");
$filename = $download_verz."tempzipfiles/".$jlistConfig['zipfile.prefix'].$user_random_id.".zip";
$download_link = JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&view=finish&catid='.$cat_id.'&list='.$id_text.'&user='.$user_random_id);
} else {
// only one file selected
$database->setQuery("SELECT cat_id, file_title FROM #__jdownloads_files WHERE file_id = '".(int)$marked_files_id[0]."'");
$cat_id = $database->loadObject();
$filename = JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&view=finish&cid='.(int)$marked_files_id[0].'&catid='.$cat_id->cat_id);
$download_link = $filename;
$file_title = ' - '.$cat_id->file_title;
}
}
$sum_aup_points = ABS($sum_aup_points);
jlist_HTML::Summary($option, $marked_files_id, $mail_files, $filename, $download_link, $del_ok, $extern_site, $sum_aup_points, $has_licenses, $open_in_blank_page, $must_confirm, $license_text, $zip_file_info, $file_title);
}
// finish and start the download
function finish($option){
global $mainframe, $jlistConfig, $mail_files, $Itemid;
$app = &JFactory::getApplication();
$user = &JFactory::getUser();
$coreUserGroups = $user->getAuthorisedGroups();
$user_access = checkAccess_JD();
$users_access = (int)substr($user_access, 0, 1);
$database = &JFactory::getDBO();
$extern = false;
$extern_site = false;
$can_download = false;
$price = '';
// anti lecching
$url = JURI::base( false );
list($remove,$stuff2)=split('//',$url,2);
list($domain,$stuff2)=split('/',$stuff2,2);
$domain = str_replace('www.', '', $domain);
$refr=getenv("HTTP_REFERER");
list($remove,$stuff)=split('//',$refr,2);
list($home,$stuff)=split('/',$stuff,2);
$home = str_replace('www.', '', $home);
// check leeching
$blocking = false;
if ($home != $domain) {
$allowed_urls = explode(',' , $jlistConfig['allowed.leeching.sites']);
if ($jlistConfig['check.leeching']) {
if ($jlistConfig['block.referer.is.empty']) {
if (!$refr) {
$blocking = true;
}
} else {
if (!$refr){
$blocking = false;
}
}
if (in_array($home,$allowed_urls)) {
$blocking = false;
} else {
$blocking = true;
}
}
}
// check blacklist
if ($jlistConfig['use.blocking.list'] && $jlistConfig['blocking.list'] != '') {
$user_ip = getRealIp();
if (stristr($jlistConfig['blocking.list'], $user_ip)){
$blocking = true;
}
}
if ($blocking) {
// leeching message
echo '<div align ="center"><br /><b><font color="red">'.JText::_('COM_JDOWNLOADS_FRONTEND_ANTILEECH_MESSAGE').'</font></b><br /></div>';
echo '<div align ="center"><br />'.JText::_('COM_JDOWNLOADS_FRONTEND_ANTILEECH_MESSAGE2').'<br /></div>';
} else {
// get file id
$fileid = intval(JArrayHelper::getValue( $_REQUEST, 'cid', 0 ));
// get cat id
$catid = intval(JArrayHelper::getValue( $_REQUEST, 'catid', 0 ));
$is_mirror = intval(JArrayHelper::getValue( $_REQUEST, 'm', 0 ));
// get groups access
$user_is_in_groups = getUserGroupsX();
$user_is_in_groups_arr = explode(',', $user_is_in_groups);
// check access for manually url manipulation - fix
$database->setQuery('SELECT * FROM #__jdownloads_cats WHERE published = 1 AND cat_id = '.$catid);
$cat = $database->loadObject();
$access[0] = (int)substr($cat->cat_access, 0, 1);
$access[1] = (int)substr($cat->cat_access, 1, 1);
if ($users_access < $access[1] || !$cat){
if (!in_array($cat->cat_group_access, $user_is_in_groups_arr)){
// jump to login
if (!$user->id) {
$app->redirect(JRoute::_('index.php?option=com_users&view=login'));
} else {
echo "<script> alert('".JText::_('COM_JDOWNLOADS_FRONTEND_ANTILEECH_MESSAGE')."'); window.history.go(-1); </script>\n";
exit();
}
}
}
// set page for the redirect after download button click
if (!$Itemid){
$database->setQuery("SELECT id from #__menu WHERE link = 'index.php?option=com_jdownloads&view=viewcategories' and published = 1");
$Itemid = $database->loadResult();
}
$redirect_to = JRoute::_( "index.php?option=com_jdownloads&Itemid=".$Itemid."&view=viewcategory&catid=".$catid);
// get AUP user points
$api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
if (file_exists($api_AUP)){
require_once ($api_AUP);
$profil = AlphaUserPointsHelper:: getUserInfo('', $user->id);
}
if ($jlistConfig['use.alphauserpoints']){
// get standard points value from AUP
$database->setQuery("SELECT points FROM #__alpha_userpoints_rules WHERE published = 1 AND plugin_function = 'plgaup_jdownloads_user_download'");
$aup_fix_points = (int)$database->loadResult();
$aup_fix_points = abs($aup_fix_points);
}
// files liste holen wenn mhr als ein download markiert
$files = $database->getEscaped (JRequest::getString('list', '' ));
$files_arr = explode(',', $files);
if ($files){
// sammeldownload
$user_random_id = intval(JRequest::getString('user', 0 ));
$download_verz = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/';
$filename = $download_verz.'tempzipfiles/'.$jlistConfig['zipfile.prefix'].$user_random_id.'.zip';
$filename_direct = JURI::base().$jlistConfig['files.uploaddir'].'/tempzipfiles/'.$jlistConfig['zipfile.prefix'].$user_random_id.'.zip';
// check whether direct access
$database->setQuery('SELECT file_id, file_title FROM #__jdownloads_files WHERE published = 1 AND file_id IN ('.$files.')');
if (!$rows = $database->loadObjectList()){
// jump to login
if (!$user->id) {
$app->redirect(JRoute::_('index.php?option=com_users&view=login'));
} else {
echo "<script> alert('".JText::_('COM_JDOWNLOADS_FRONTEND_ANTILEECH_MESSAGE')."'); window.history.go(-1); </script>\n";
exit();
}
}
// add AUP points
if ($jlistConfig['use.alphauserpoints']){
if ($jlistConfig['use.alphauserpoints.with.price.field']){
$database->setQuery("SELECT SUM(price) FROM #__jdownloads_files WHERE file_id IN ($files)");
$sum_points = (int)$database->loadResult();
if ($profil->points >= $sum_points){
foreach($rows as $aup_data){
$database->setQuery("SELECT price FROM #__jdownloads_files WHERE file_id = '$aup_data->file_id'");
if ($price = (int)$database->loadResult()){
$can_download = setAUPPointsDownloads($user->id, $aup_data->file_title, $price);
}
}
}
} else {
// use fix points
$sum_points = $aup_fix_points * count($files_arr);
if ($profil->points >= $sum_points){
foreach($rows as $aup_data){
$can_download = setAUPPointsDownloads($user->id, $aup_data->file_title, 0);
}
} else {
$can_download = false;
}
}
} else {
// no AUP active
$can_download = true;
}
if ($jlistConfig['user.can.download.file.when.zero.points'] && $user->id){
$can_download = true;
}
if (!$can_download){
$aup_no_points = '<div style="text-align:center" class="jd_div_aup_message">'.stripslashes($jlistConfig['user.message.when.zero.points']).'</div>'.
'<div style="text-align:center" class="jd_div_aup_message">'.JText::_('COM_JDOWNLOADS_BACKEND_SET_AUP_FE_MESSAGE_NO_DOWNLOAD_POINTS').' '.(int)$profil->points.'<br />'.JText::_('COM_JDOWNLOADS_BACKEND_SET_AUP_FE_MESSAGE_NO_DOWNLOAD_NEEDED').' '.JText::_($sum_points).'</div>'.
'<div style="text-align:left" class="back_button"><a href="javascript:history.go(-1)">'.JText::_('COM_JDOWNLOADS_FRONTEND_BACK_BUTTON').'</a></div>';
echo $aup_no_points;
}
// download limits
// check the log - can user download the file?
$may_download = false;
foreach ($files_arr as $file){
$may_download = checkLog($file, $user);
}
if (!$may_download){
// download not possible
$datenow =& JFactory::getDate();
$date = $datenow->toFormat("%Y-%m-%d %H:%m");
$back .= '<div style="text-align:left" class="back_button"><a href="javascript:history.go(-1)">'.JText::_('COM_JDOWNLOADS_FRONTEND_BACK_BUTTON').'</a></div>';
echo '<div style="text-align:center" class="jd_limit_reached_message">'.stripslashes($jlistConfig['limited.download.reached.message']).' '.$date.'</div>'.$back;
}
} else {
// einzelner download
// check whether direct access
$database->setQuery("SELECT file_title FROM #__jdownloads_files WHERE published = 1 AND file_id = '$fileid' AND cat_id = '$catid'");
if (!$ok = $database->loadResult()){
// jump to login
if (!$user->id) {
$app->redirect(JRoute::_('index.php?option=com_users&view=login'));
} else {
echo "<script> alert('".JText::_('COM_JDOWNLOADS_FRONTEND_ANTILEECH_MESSAGE')."'); window.history.go(-1); </script>\n";
exit();
}
}
// download limits
// check the log - can user download the file?
$may_download = false;
$may_download = checkLog($fileid, $user);
if (!$may_download){
// download not possible
$datenow =& JFactory::getDate();
$date = $datenow->toFormat("%Y-%m-%d %H:%m");
$back .= '<div style="text-align:left" class="back_button"><a href="javascript:history.go(-1)">'.JText::_('COM_JDOWNLOADS_FRONTEND_BACK_BUTTON').'</a></div>';
echo '<div style="text-align:center" class="jd_limit_reached_message">'.stripslashes($jlistConfig['limited.download.reached.message']).' '.$date.'</div>'.$back;
} else {
// get filename and build path
if (!$is_mirror){
$database->setQuery("SELECT url_download FROM #__jdownloads_files WHERE file_id = '".(int)$fileid."'");
$file_url = $database->loadResult();
if ($file_url){
$database->setQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = '".(int)$catid."'");
$cat_dir = $database->loadResult();
$filename = JPATH_SITE.'/'.$jlistConfig['files.uploaddir'].'/'.$cat_dir.'/'.$file_url;
$filename_direct = JURI::base().$jlistConfig['files.uploaddir'].'/'.$cat_dir.'/'.$file_url;
} else {
$database->setQuery("SELECT * FROM #__jdownloads_files WHERE file_id = '".(int)$fileid."'");
$result = $database->loadObjectlist();
$filename = $result[0]->extern_file;
if ($result[0]->extern_site){
$extern_site = true;
}
$extern = true;
}
} else {
// is mirror
$database->setQuery("SELECT * FROM #__jdownloads_files WHERE file_id = '".(int)$fileid."'");
$result = $database->loadObjectlist();
if ($is_mirror == 1){
$filename = $result[0]->mirror_1;
if ($result[0]->extern_site_mirror_1){
$extern_site = true;
}
} else {
$filename = $result[0]->mirror_2;
if ($result[0]->extern_site_mirror_2){
$extern_site = true;
}
}
$extern = true;
}
// AUP integration
if ($jlistConfig['use.alphauserpoints.with.price.field'] && $jlistConfig['use.alphauserpoints']){
$database->setQuery("SELECT price FROM #__jdownloads_files WHERE file_id = '".(int)$fileid."'");
$price = (int)$database->loadResult();
} else {
if ($jlistConfig['use.alphauserpoints']){
$price = $aup_fix_points;
}
}
$can_download = setAUPPointsDownload($user->id, $ok, $price);
if ($jlistConfig['user.can.download.file.when.zero.points'] && $user->id){
$can_download = true;
}
if (!$can_download){
// get AUP user data
$profil = AlphaUserPointsHelper:: getUserInfo ( '', $user->id );
$aup_no_points = '<div style="text-align:center" class="jd_div_aup_message">'.stripslashes($jlistConfig['user.message.when.zero.points']).'</div>'.
'<div style="text-align:center" class="jd_div_aup_message">'.JText::_('COM_JDOWNLOADS_BACKEND_SET_AUP_FE_MESSAGE_NO_DOWNLOAD_POINTS').' '.(int)$profil->points.'<br />'.JText::_('COM_JDOWNLOADS_BACKEND_SET_AUP_FE_MESSAGE_NO_DOWNLOAD_NEEDED').' '.JText::_($price).'</div>'.
'<div style="text-align:left" class="back_button"><a href="javascript:history.go(-1)">'.JText::_('COM_JDOWNLOADS_FRONTEND_BACK_BUTTON').'</a></div>';
echo $aup_no_points;
}
}
}
// run download
if ($can_download && $may_download){
// send mail
if ($jlistConfig['send.mailto.option'] == '1') {
if ($fileid){
sendMail($fileid);
} else {
sendMail($files);
}
}
// give uploader AUP points when is set on
if ($jlistConfig['use.alphauserpoints']){
setAUPPointsDownloaderToUploader($fileid, $files);
}
// update downloads hits
if ($files){
$database->setQuery('UPDATE #__jdownloads_files SET downloads=downloads+1 WHERE file_id IN ('.$files.')');
$database->query();
} else {
if ($fileid){
$database->setQuery("UPDATE #__jdownloads_files SET downloads=downloads+1 WHERE file_id = '".(int)$fileid."'");
$database->query();
}
}
// start download
$x = download($filename, $filename_direct, $extern, $extern_site, $redirect_to);
}
if ($x == 2) {
// files not exists
echo '<div align ="center"><br /><b><font color="#990000">'.JText::_('COM_JDOWNLOADS_FRONTEND_FILE_NOT_FOUND_MESSAGE').'</font></b><br /><br /></div>';
}
}
}
// download starten
function download($file, $filename_direct, $extern, $extern_site, $redirect_to){
global $jlistConfig, $mainframe;
$app = &JFactory::getApplication();
$view_types = array();
$view_types = explode(',', $jlistConfig['file.types.view']);
clearstatcache();
// existiert file - wenn nicht error
if (!$extern){
if (!file_exists($file)) {
return 2;
} else {
$len = filesize($file);
}
} else {
$len = urlfilesize($file);
}
// if url go to other website - open it in a new browser window
if ($extern_site){
echo "<script>document.location.href='$file';</script>\n";
exit;
}
// if set the option for direct link to the file
if (!$jlistConfig['use.php.script.for.download']){
if (empty($filename_direct)) {
$app->redirect($file);
} else {
$app->redirect($filename_direct);
}
} else {
$filename = basename($file);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
$ctype = datei_mime($file_extension);
ob_end_clean();
// needed for MS IE - otherwise content disposition is not used?
if (ini_get('zlib.output_compression')){
ini_set('zlib.output_compression', 'Off');
}
header("Cache-Control: public, must-revalidate");
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
// header("Pragma: no-cache"); // Problems with MS IE
header("Expires: 0");
header("Content-Description: File Transfer");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: " . $ctype);
header("Content-Length: ".(string)$len);
if (!in_array($file_extension, $view_types)){
header('Content-Disposition: attachment; filename="'.$filename.'"');
} else {
// view file in browser
header('Content-Disposition: inline; filename="'.$filename.'"');
}
header("Content-Transfer-Encoding: binary\n");
// redirect to category when it is set the time
if (intval($jlistConfig['redirect.after.download']) > 0){
header( "refresh:".$jlistConfig['redirect.after.download']."; url=".$redirect_to );
}
// set_time_limit doesn't work in safe mode
if (!ini_get('safe_mode')){
@set_time_limit(0);
}
@readfile($file);
}
exit;
}
function datei_mime($filetype) {
switch ($filetype) {
case "ez": $mime="application/andrew-inset"; break;
case "hqx": $mime="application/mac-binhex40"; break;
case "cpt": $mime="application/mac-compactpro"; break;
case "doc": $mime="application/msword"; break;
case "bin": $mime="application/octet-stream"; break;
case "dms": $mime="application/octet-stream"; break;
case "lha": $mime="application/octet-stream"; break;
case "lzh": $mime="application/octet-stream"; break;
case "exe": $mime="application/octet-stream"; break;
case "class": $mime="application/octet-stream"; break;
case "dll": $mime="application/octet-stream"; break;
case "oda": $mime="application/oda"; break;
case "pdf": $mime="application/pdf"; break;
case "ai": $mime="application/postscript"; break;
case "eps": $mime="application/postscript"; break;
case "ps": $mime="application/postscript"; break;
case "xls": $mime="application/vnd.ms-excel"; break;
case "ppt": $mime="application/vnd.ms-powerpoint"; break;
case "wbxml": $mime="application/vnd.wap.wbxml"; break;
case "wmlc": $mime="application/vnd.wap.wmlc"; break;
case "wmlsc": $mime="application/vnd.wap.wmlscriptc"; break;
case "vcd": $mime="application/x-cdlink"; break;
case "pgn": $mime="application/x-chess-pgn"; break;
case "csh": $mime="application/x-csh"; break;
case "dvi": $mime="application/x-dvi"; break;
case "spl": $mime="application/x-futuresplash"; break;
case "gtar": $mime="application/x-gtar"; break;
case "hdf": $mime="application/x-hdf"; break;
case "js": $mime="application/x-javascript"; break;
case "nc": $mime="application/x-netcdf"; break;
case "cdf": $mime="application/x-netcdf"; break;
case "swf": $mime="application/x-shockwave-flash"; break;
case "tar": $mime="application/x-tar"; break;
case "tcl": $mime="application/x-tcl"; break;
case "tex": $mime="application/x-tex"; break;
case "texinfo": $mime="application/x-texinfo"; break;
case "texi": $mime="application/x-texinfo"; break;
case "t": $mime="application/x-troff"; break;
case "tr": $mime="application/x-troff"; break;
case "roff": $mime="application/x-troff"; break;
case "man": $mime="application/x-troff-man"; break;
case "me": $mime="application/x-troff-me"; break;
case "ms": $mime="application/x-troff-ms"; break;
case "ustar": $mime="application/x-ustar"; break;
case "src": $mime="application/x-wais-source"; break;
case "zip": $mime="application/x-zip"; break;
case "au": $mime="audio/basic"; break;
case "snd": $mime="audio/basic"; break;
case "mid": $mime="audio/midi"; break;
case "midi": $mime="audio/midi"; break;
case "kar": $mime="audio/midi"; break;
case "mpga": $mime="audio/mpeg"; break;
case "mp2": $mime="audio/mpeg"; break;
case "mp3": $mime="audio/mpeg"; break;
case "aif": $mime="audio/x-aiff"; break;
case "aiff": $mime="audio/x-aiff"; break;
case "aifc": $mime