diff --git a/oss/joomla/trunk/components/com_jdownloads/jdownloads.class.php b/oss/joomla/trunk/components/com_jdownloads/jdownloads.class.php index d244028e..c21a2536 100644 --- a/oss/joomla/trunk/components/com_jdownloads/jdownloads.class.php +++ b/oss/joomla/trunk/components/com_jdownloads/jdownloads.class.php @@ -64,6 +64,10 @@ class jlist_files extends JTable{ var $metadesc = null; var $size = null; var $date_added = null; + var $file_date = null; + var $publish_from = null; + var $publish_to = null; + var $use_timeframe = null; var $url_download = null; var $extern_file = null; var $extern_site = null; @@ -77,7 +81,9 @@ class jlist_files extends JTable{ var $created_by = null; var $created_mail = null; var $modified_by = null; - var $modified_date = null; + var $modified_date = null; + var $submitted_by = null; + var $set_aup_points = null; var $downloads = null; var $ordering = null; var $published = null; diff --git a/oss/joomla/trunk/components/com_jdownloads/jdownloads.html.php b/oss/joomla/trunk/components/com_jdownloads/jdownloads.html.php index e2e86b86..86230734 100644 --- a/oss/joomla/trunk/components/com_jdownloads/jdownloads.html.php +++ b/oss/joomla/trunk/components/com_jdownloads/jdownloads.html.php @@ -2,7 +2,7 @@ /** * @version 1.5 * @package JDownloads -* @copyright (C) 2009 www.jdownloads.com +* @copyright (C) 2009 Arno Betz - www.jdownloads.com * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * * @@ -44,12 +44,18 @@ function treeSelectList( &$src_list, $src_id, $tgt_list, $tag_name, $tag_attribs } defined( '_JEXEC' ) or die( 'Restricted access-html' ); +$jlistConfig = buildjlistConfig(); ?> - + + addCustomHeadTag(''); $mainframe->addCustomHeadTag( "" ); $mainframe->addCustomHeadTag( "" ); $mainframe->addCustomHeadTag( "" ); @@ -63,11 +69,11 @@ class jlist_HTML{ / Nur Kategorien-Übersicht anzeigen ############################################################## */ function showCats($option, $cats, $total, $sum_pages, $limit, $limitstart, $site_aktuell, $sub_cats, $sub_files, $sum_all_cats, $totalfiles, $no_cats){ - global $jlistConfig, $jlistTemplates, $Itemid, $mainframe; + global $jlistConfig, $jlistTemplates, $Itemid, $mainframe, $page_title; $user = &JFactory::getUser(); $database = &JFactory::getDBO(); - $mainframe->setPageTitle( $jlistConfig['jd.header.title']); + $mainframe->setPageTitle($page_title); $html_cat = makeHeader($html_cat, true, true, false, 0, false, false, false, false, false, $sum_pages, $limit, $total, $limitstart, $site_aktuell); echo $html_cat; @@ -96,7 +102,7 @@ class jlist_HTML{ // symbol anzeigen - auch als url if ($cats[$i]->cat_pic != '' ) { $size = $jlistConfig['cat.pic.size']; - $catpic = $catlink.' '; + $catpic = $catlink.' '; } else { $catpic = ''; } @@ -121,7 +127,7 @@ class jlist_HTML{ $html_cat = str_replace('{cat_info_begin}', "", $html_cat); // google adsense if ($jlistConfig['google.adsense.active']){ - $html_cat = str_replace('{google_adsense}', $jlistConfig['google.adsense.code'], $html_cat); + $html_cat = str_replace('{google_adsense}', stripslashes($jlistConfig['google.adsense.code']), $html_cat); } else { $html_cat = str_replace('{google_adsense}', '', $html_cat); } @@ -152,7 +158,7 @@ class jlist_HTML{ echo JText::_('JLIST_BACKEND_OFFLINE_ADMIN_MESSAGE_TEXT'); echo $html_cat; } else { - $html_off = '

'.$jlistConfig['offline.text'].'

'; + $html_off = '

'.stripslashes($jlistConfig['offline.text']).'

'; $html_off .= $footer; echo $html_off; } @@ -164,11 +170,11 @@ class jlist_HTML{ / Nur Kategorien-Übersicht anzeigen ############################################################## */ function showCatswithColumns($option, $cats, $total, $sum_pages, $limit, $limitstart, $site_aktuell, $sub_cats, $sub_files, $sum_all_cats, $totalfiles, $columns, $no_cats){ - global $jlistConfig, $jlistTemplates, $Itemid, $mainframe; + global $jlistConfig, $jlistTemplates, $Itemid, $mainframe, $page_title; $user = &JFactory::getUser(); $database = &JFactory::getDBO(); - $mainframe->setPageTitle( $jlistConfig['jd.header.title']); + $mainframe->setPageTitle($page_title); $html_cat = makeHeader($html_cat, true, true, false, 0, false, false, false, false, false, $sum_pages, $limit, $total, $limitstart, $site_aktuell); echo $html_cat; @@ -206,7 +212,7 @@ class jlist_HTML{ // symbol anzeigen - auch als url if ($cats[$i]->cat_pic != '' ) { $size = $jlistConfig['cat.pic.size']; - $catpic = $catlink.' '; + $catpic = $catlink.' '; } else { $catpic = ''; } @@ -252,7 +258,7 @@ class jlist_HTML{ $html_cat = str_replace('{cat_info_begin}', "", $html_cat); // google adsense if ($jlistConfig['google.adsense.active']){ - $html_cat = str_replace('{google_adsense}', $jlistConfig['google.adsense.code'], $html_cat); + $html_cat = str_replace('{google_adsense}', stripslashes($jlistConfig['google.adsense.code']), $html_cat); } else { $html_cat = str_replace('{google_adsense}', '', $html_cat); } @@ -295,7 +301,7 @@ class jlist_HTML{ echo JText::_('JLIST_BACKEND_OFFLINE_ADMIN_MESSAGE_TEXT'); echo $html_cat; } else { - $html_off = '

'.$jlistConfig['offline.text'].'

'; + $html_off = '

'.stripslashes($jlistConfig['offline.text']).'

'; $html_off .= $footer; echo $html_off; } @@ -312,7 +318,7 @@ class jlist_HTML{ $database = &JFactory::getDBO(); $app = &JFactory::getApplication(); - $mainframe->setPageTitle( $jlistConfig['jd.header.title'].' - '.$cat[0]->cat_title ); + $mainframe->setPageTitle($page_title.' - '.$cat[0]->cat_title ); $mainframe->appendMetaTag( 'keywords' , strip_tags($cat[0]->metakey )); $mainframe->appendMetaTag( 'description' , strip_tags($cat[0]->metadesc)); $sum_subs = count($subcats); @@ -325,7 +331,7 @@ class jlist_HTML{ // get pic if ($cat[0]->cat_pic != '' ) { $size = $jlistConfig['cat.pic.size']; - $catpic = ' '; + $catpic = ' '; } else { $catpic = ''; } @@ -382,7 +388,7 @@ class jlist_HTML{ } // google adsense if ($jlistConfig['google.adsense.active']){ - $html_cat = str_replace('{google_adsense}', $jlistConfig['google.adsense.code'], $html_cat); + $html_cat = str_replace('{google_adsense}', stripslashes($jlistConfig['google.adsense.code']), $html_cat); } else { $html_cat = str_replace('{google_adsense}', '', $html_cat); } @@ -403,7 +409,7 @@ class jlist_HTML{ // Symbol anzeigen - auch als url if ($subcats[$i]->cat_pic != '' ) { $size = $jlistConfig['cat.pic.size']; - $catpic = $catlink.' '; + $catpic = $catlink.' '; } else { $catpic = ''; } @@ -439,7 +445,7 @@ class jlist_HTML{ // Symbol anzeigen - auch als url if ($subcats[$i]->cat_pic != '' ) { $size = $jlistConfig['cat.pic.size']; - $catpic = $catlink.' '; + $catpic = $catlink.' '; } else { $catpic = ''; } @@ -461,6 +467,7 @@ class jlist_HTML{ } $html_cat = str_replace('{sum_files_cat}', JText::_('JLIST_FRONTEND_COUNT_FILES').' '.$sum_subfiles[$i], $html_cat); } + $html_cat = str_replace('{cat_description}', $subcats[$i]->cat_description, $html_cat); $html_cat = str_replace('{cat_pic}', $catpic, $html_cat); $html_cat = str_replace('{cat_info_begin}', '', $html_cat); @@ -486,7 +493,7 @@ class jlist_HTML{ } // google adsense if ($jlistConfig['google.adsense.active']){ - $html_cat = str_replace('{google_adsense}', $jlistConfig['google.adsense.code'], $html_cat); + $html_cat = str_replace('{google_adsense}', stripslashes($jlistConfig['google.adsense.code']), $html_cat); } else { $html_cat = str_replace('{google_adsense}', '', $html_cat); } @@ -504,19 +511,19 @@ class jlist_HTML{ // anzeigen wenn im Layout aktiviert (0 = aktiv !!) if ($jlistTemplates[2][0]->symbol_off == 0 ) { $msize = $jlistConfig['info.icons.size']; - $pic_date = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_DATE').' '; - $pic_license = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_LICENCE').' '; - $pic_author = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_AUTHOR').' '; - $pic_website = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_WEBSITE').' '; - $pic_system = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_SYSTEM').' '; - $pic_language = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_LANGUAGE').' '; - $pic_downloads = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_DOWNLOAD').' '; - $pic_download = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_DOWNLOAD').' '; - $pic_price = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_PRICE').' '; - $pic_size = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_FILESIZE').' '; + $pic_date = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_DATE').' '; + $pic_license = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_LICENCE').' '; + $pic_author = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_AUTHOR').' '; + $pic_website = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_WEBSITE').' '; + $pic_system = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_SYSTEM').' '; + $pic_language = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_LANGUAGE').' '; + $pic_downloads = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_DOWNLOAD').' '; + $pic_download = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_DOWNLOAD').' '; + $pic_price = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_PRICE').' '; + $pic_size = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_FILESIZE').' '; } // a little pic for extern links - $extern_url_pic = ''; + $extern_url_pic = ''; // files der cat anzeigen for ($i=0; $iurl_download, $html_file); + // google adsense if ($jlistConfig['google.adsense.active']){ - $html_file = str_replace('{google_adsense}', $jlistConfig['google.adsense.code'], $html_file); + $html_file = str_replace('{google_adsense}', stripslashes($jlistConfig['google.adsense.code']), $html_file); } else { $html_file = str_replace('{google_adsense}', '', $html_file); } @@ -597,19 +606,19 @@ class jlist_HTML{ // Symbol anzeigen - auch als url if ($files[$i]->file_pic != '' ) { $fpicsize = $jlistConfig['file.pic.size']; - $filepic = ''.' '; + $filepic = ''.' '; } else { $filepic = ''; } $html_file = str_replace('{file_pic}',$filepic, $html_file); // link zu details am ende - $html_file = str_replace('{link_to_details}',$detail_link_text, $html_file); + $html_file = str_replace('{link_to_details}','
'.$detail_link_text, $html_file); $html_file = str_replace('{file_title}', $titel_link_text, $html_file); } else { // no links if ($files[$i]->file_pic != '' ) { $fpicsize = $jlistConfig['file.pic.size']; - $filepic = ''; + $filepic = ''; } else { $filepic = ''; } @@ -649,12 +658,21 @@ class jlist_HTML{ } } - $html_file = str_replace('{description}', $files[$i]->description, $html_file); + if ($jlistConfig['auto.file.short.description'] && $jlistConfig['auto.file.short.description.value'] > 0){ + if (strlen($files[$i]->description) > $jlistConfig['auto.file.short.description.value']){ + $shorted_text=preg_replace("/[^ ]*$/", '..', substr($files[$i]->description, 0, $jlistConfig['auto.file.short.description.value'])); + $html_file = str_replace('{description}', $shorted_text, $html_file); + } else { + $html_file = str_replace('{description}', $files[$i]->description, $html_file); + } + } else { + $html_file = str_replace('{description}', $files[$i]->description, $html_file); + } // pics for: new file / hot file / updated - $hotpic = ''; - $newpic = ''; - $updatepic = ''; + $hotpic = ''; + $newpic = ''; + $updatepic = ''; if ($jlistConfig['loads.is.file.hot'] > 0 && $files[$i]->downloads >= $jlistConfig['loads.is.file.hot'] ){ $html_file = str_replace('{pic_is_hot}', $hotpic, $html_file); @@ -702,7 +720,7 @@ class jlist_HTML{ $info = getID3v2Tags($mp3_path_abs); if ($info){ // add it - $mp3_info = $jlistConfig['mp3.info.layout']; + $mp3_info = stripslashes($jlistConfig['mp3.info.layout']); $mp3_info = str_replace('{name_title}', JText::_('JLIST_FE_VIEW_ID3_TITLE'), $mp3_info); $mp3_info = str_replace('{name}', $files[$i]->url_download, $mp3_info); $mp3_info = str_replace('{album_title}', JText::_('JLIST_FE_VIEW_ID3_ALBUM'), $mp3_info); @@ -731,7 +749,7 @@ class jlist_HTML{ $lic = array(); if ($files[$i]->license == '') $files[$i]->license = 0; $database->setQuery('SELECT * from #__jdownloads_license WHERE id = '.$files[$i]->license); - $database->loadObject( $lic ); + $lic = $database->loadObject(); $lic_data = ''; if (!$lic->license_url == '') { $lic_data = $pic_license.''.$lic->license_title.' '.$extern_url_pic; @@ -759,6 +777,7 @@ class jlist_HTML{ $html_file = str_replace('{cat_id}', $files[$i]->cat_id, $html_file); + // file size if (!$files[$i]->size == '') { $html_file = str_replace('{size}', $pic_size.$files[$i]->size, $html_file); $html_file = str_replace('{filesize_value}', $pic_size.$files[$i]->size, $html_file); @@ -767,13 +786,23 @@ class jlist_HTML{ $html_file = str_replace('{filesize_value}', '', $html_file); } + // price if (!$files[$i]->price == '') { $html_file = str_replace('{price_value}', $pic_price.$files[$i]->price, $html_file); } else { $html_file = str_replace('{price_value}', '', $html_file); } - if (!$files[$i]->date_added == '') { + // file_date + if ($files[$i]->file_date != '0000-00-00 00:00:00') { + $filedate_data = $pic_date.substr(JHTML::_('date',$files[$i]->file_date, $jlistConfig['global.datetime'], $offset = NULL),0,10); + } else { + $filedate_data = ''; + } + $html_file = str_replace('{file_date}',$filedate_data, $html_file); + + // date_added + if ($files[$i]->date_added != '0000-00-00 00:00:00') { $date_data = $pic_date.substr(JHTML::_('date',$files[$i]->date_added, $jlistConfig['global.datetime'], $offset = NULL),0,10); } else { $date_data = ''; @@ -783,6 +812,8 @@ class jlist_HTML{ $html_file = str_replace('{created_by_value}',$files[$i]->created_by, $html_file); $html_file = str_replace('{modified_by_value}',$files[$i]->modified_by, $html_file); + + // modified_date if ($files[$i]->modified_date != '0000-00-00 00:00:00') { $modified_data = $pic_date.substr(JHTML::_('date',$files[$i]->modified_date, $jlistConfig['global.datetime'], $offset = NULL),0,10); } else { @@ -792,7 +823,22 @@ class jlist_HTML{ // only view download-url when user has corect access level if ($user->get('aid') >= $access[1]) { - + $blank_window = ''; + $blank_window1 = ''; + $blank_window2 = ''; + // get file extension + $view_types = array(); + $view_types = explode(',', $jlistConfig['file.types.view']); + $only_file_name = basename($files[$i]->url_download); + $fileextension = strtolower(substr(strrchr($only_file_name,"."),1)); + if (in_array($fileextension, $view_types)){ + $blank_window = 'target="_blank"'; + } + // check is set link to a new window? + if ($files[$i]->extern_file && $files[$i]->extern_site ){ + $blank_window = 'target="_blank"'; + } + // direct download ohne zusammenfassung? if ($jlistConfig['direct.download'] == '0'){ $url_task = 'summary'; @@ -800,25 +846,38 @@ class jlist_HTML{ $url_task = 'finish'; } $download_link = JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&task='.$url_task.'&cid='.$files[$i]->file_id.'&catid='.$files[$i]->cat_id); - $download_link_text = ''; + if ($url_task == 'finish'){ + $download_link_text = ''; + } else { + $download_link_text = ''; + } if (!$pic_download){ - $pic_download = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_DOWNLOAD').''; + $pic_download = ''.JText::_('JLIST_FRONTEND_MINI_ICON_ALT_DOWNLOAD').''; + } + if ($jlistConfig['view.also.download.link.text']){ + $html_file = str_replace('{url_download}',$download_link_text.$pic_download.'
'.JText::_('JLIST_LINKTEXT_DOWNLOAD_URL').'
', $html_file); + } else { + $html_file = str_replace('{url_download}',$download_link_text.$pic_download.'', $html_file); } - $html_file = str_replace('{url_download}',$download_link_text.$pic_download.'
'.JText::_('JLIST_LINKTEXT_DOWNLOAD_URL').'', $html_file); - // mirrors if ($files[$i]->mirror_1) { + if ($files[$i]->extern_site_mirror_1 && $url_task == 'finish'){ + $blank_window1 = 'target="_blank"'; + } $mirror1_link_dum = JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&task='.$url_task.'&cid='.$files[$i]->file_id.'&catid='.$files[$i]->cat_id.'&m=1'); - $mirror1_link = JRoute::_(''); - $mir1_down_pic = ''.JText::_('JLIST_FRONTEND_MIRROR_URL_TITLE_1').''; + $mirror1_link = JRoute::_(''); + $mir1_down_pic = ''.JText::_('JLIST_FRONTEND_MIRROR_URL_TITLE_1').''; $html_file = str_replace('{mirror_1}', $mirror1_link.$mir1_down_pic.'', $html_file); } else { $html_file = str_replace('{mirror_1}', '', $html_file); } if ($files[$i]->mirror_2) { + if ($files[$i]->extern_site_mirror_2 && $url_task == 'finish'){ + $blank_window2 = 'target="_blank"'; + } $mirror2_link_dum = JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&task='.$url_task.'&cid='.$files[$i]->file_id.'&catid='.$files[$i]->cat_id.'&m=2'); - $mirror2_link = ''; - $mir2_down_pic = ''.JText::_('JLIST_FRONTEND_MIRROR_URL_TITLE_2').''; + $mirror2_link = ''; + $mir2_down_pic = ''.JText::_('JLIST_FRONTEND_MIRROR_URL_TITLE_2').''; $html_file = str_replace('{mirror_2}', $mirror2_link.$mir2_down_pic.'', $html_file); } else { $html_file = str_replace('{mirror_2}', '', $html_file); @@ -911,7 +970,7 @@ class jlist_HTML{ $html_file = str_replace('{hits_value}',$pic_downloads.$files[$i]->downloads, $html_file); $html_file = str_replace('{ordering}',$files[$i]->ordering, $html_file); $html_file = str_replace('{published}',$files[$i]->published, $html_file); - + $html_files .= $html_file; } @@ -971,7 +1030,7 @@ class jlist_HTML{ echo JText::_('JLIST_BACKEND_OFFLINE_ADMIN_MESSAGE_TEXT'); echo $html_cat; } else { - $html_off = '

'.$jlistConfig['offline.text'].'

'; + $html_off = '

'.stripslashes($jlistConfig['offline.text']).'

'; $html_off .= $footer; echo $html_off; } @@ -983,13 +1042,13 @@ class jlist_HTML{ / Einzelnen Download anzeigen mit Detail Infos / ################################################################################# */ function showDownload($option, $file, $cat, $access){ - global $jlistConfig, $jlistTemplates, $Itemid, $mainframe, $addScriptJWAjaxVote; + global $jlistConfig, $jlistTemplates, $Itemid, $mainframe, $addScriptJWAjaxVote, $page_title; $user = &JFactory::getUser(); $database = &JFactory::getDBO(); $mainframe = JFactory::getApplication(); $app = JFactory::getApplication(); - $mainframe->setPageTitle( $jlistConfig['jd.header.title'].' - '.$cat->cat_title.' - '.$file->file_title ); + $mainframe->setPageTitle($page_title.' - '.$cat->cat_title.' - '.$file->file_title ); $mainframe->appendMetaTag( 'keywords' , strip_tags($file->metakey )); $mainframe->appendMetaTag( 'description' , strip_tags($file->metadesc)); @@ -1012,11 +1071,12 @@ function showDownload($option, $file, $cat, $access){ $html_file = str_replace('{created_by_title}', JText::_('JLIST_FE_DETAILS_CREATED_BY_TITLE'), $html_file); $html_file = str_replace('{modified_by_title}', JText::_('JLIST_FE_DETAILS_MODIFIED_BY_TITLE'), $html_file); $html_file = str_replace('{modified_date_title}', JText::_('JLIST_FE_DETAILS_MODIFIED_DATE_TITLE'), $html_file); + $html_file = str_replace('{file_date_title}', JText::_('JLIST_FE_DETAILS_FILE_DATE_TITLE'), $html_file); $html_file = str_replace('{file_name}', $file->url_download, $html_file); // google adsense if ($jlistConfig['google.adsense.active']){ - $html_file = str_replace('{google_adsense}', $jlistConfig['google.adsense.code'], $html_file); + $html_file = str_replace('{google_adsense}', stripslashes($jlistConfig['google.adsense.code']), $html_file); } else { $html_file = str_replace('{google_adsense}', '', $html_file); } @@ -1037,7 +1097,7 @@ function showDownload($option, $file, $cat, $access){ $html_file = str_replace('{cat_title}', $cattitle, $html_file); // a little pic for extern links - $extern_url_pic = ''; + $extern_url_pic = ''; // für JHMTL Tooltip JHTML::_('behavior.tooltip'); @@ -1045,7 +1105,7 @@ function showDownload($option, $file, $cat, $access){ // get pic if ($file->file_pic != '' ) { $fpicsize = $jlistConfig['file.pic.size']; - $filepic = ' '; + $filepic = ' '; } else { $filepic = ''; } @@ -1087,11 +1147,10 @@ function showDownload($option, $file, $cat, $access){ } else { $html_file = str_replace('{description_long}',$file->description_long, $html_file); } - // pics for: new file / hot file /updated - $hotpic = ''; - $newpic = ''; - $updatepic = ''; + $hotpic = ''; + $newpic = ''; + $updatepic = ''; // berechnung für HOT if ($jlistConfig['loads.is.file.hot'] > 0 && $file->downloads >= $jlistConfig['loads.is.file.hot'] ){ @@ -1150,7 +1209,7 @@ function showDownload($option, $file, $cat, $access){ $info = getID3v2Tags($mp3_path_abs); if ($info){ // add it - $mp3_info = $jlistConfig['mp3.info.layout']; + $mp3_info = stripslashes($jlistConfig['mp3.info.layout']); $mp3_info = str_replace('{name_title}', JText::_('JLIST_FE_VIEW_ID3_TITLE'), $mp3_info); $mp3_info = str_replace('{name}', $file->url_download, $mp3_info); $mp3_info = str_replace('{album_title}', JText::_('JLIST_FE_VIEW_ID3_ALBUM'), $mp3_info); @@ -1209,8 +1268,17 @@ function showDownload($option, $file, $cat, $access){ // funktion zur berechnung entfernt - hier nur falls vorhanden platzhalter entfernen $html_file = str_replace('{download_time}','', $html_file); - - if (!$file->date_added != '0000-00-00 00:00:00') { + + // file_date + if ($file->file_date != '0000-00-00 00:00:00') { + $filedate_data = $pic_date.substr(JHTML::_('date',$file->file_date, $jlistConfig['global.datetime'], $offset = NULL),0,10); + } else { + $filedate_data = ''; + } + $html_file = str_replace('{file_date}',$filedate_data, $html_file); + + // date_added + if ($file->date_added != '0000-00-00 00:00:00') { $date_data = $pic_date.substr(JHTML::_('date',$file->date_added, $jlistConfig['global.datetime'], $offset = NULL),0,10); } else { $date_data = ''; @@ -1219,6 +1287,21 @@ function showDownload($option, $file, $cat, $access){ // only view download link when user has corect access level if ($user->get('aid') >= $access[1]) { + $blank_window = ''; + $blank_window1 = ''; + $blank_window2 = ''; + // get file extension + $view_types = array(); + $view_types = explode(',', $jlistConfig['file.types.view']); + $only_file_name = basename($file->url_download); + $fileextension = strtolower(substr(strrchr($only_file_name,"."),1)); + if (in_array($fileextension, $view_types)){ + $blank_window = 'target="_blank"'; + } + // check is set link to a new window? + if ($file->extern_file && $file->extern_site ){ + $blank_window = 'target="_blank"'; + } // direct download ohne zusammenfassung? if ($jlistConfig['direct.download'] == '0'){ $url_task = 'summary'; @@ -1226,20 +1309,30 @@ function showDownload($option, $file, $cat, $access){ $url_task = 'finish'; } $download_link = JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&task='.$url_task.'&cid='.$file->file_id.'&catid='.$file->cat_id); - $download_link_text = ''.JText::_('JLIST_LINKTEXT_DOWNLOAD_URL').''; + if ($url_task == 'finish'){ + $download_link_text = ''.JText::_('JLIST_LINKTEXT_DOWNLOAD_URL').''; + } else { + $download_link_text = ''.JText::_('JLIST_LINKTEXT_DOWNLOAD_URL').''; + } $html_file = str_replace('{url_download}',$pic_download.$download_link_text, $html_file); // mirrors if ($file->mirror_1) { + if ($file->extern_site_mirror_1 && $url_task == 'finish'){ + $blank_window1 = 'target="_blank"'; + } $mirror1_link_dum = JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&task='.$url_task.'&cid='.$file->file_id.'&catid='.$file->cat_id.'&m=1'); - $mirror1_link = ''.JText::_('JLIST_FRONTEND_MIRROR_URL_TITLE_1').''; + $mirror1_link = ''.JText::_('JLIST_FRONTEND_MIRROR_URL_TITLE_1').''; $html_file = str_replace('{mirror_1}', $mirror1_link, $html_file); } else { $html_file = str_replace('{mirror_1}', '', $html_file); } if ($file->mirror_2) { + if ($file->extern_site_mirror_2 && $url_task == 'finish'){ + $blank_window2 = 'target="_blank"'; + } $mirror2_link_dum = JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&task='.$url_task.'&cid='.$file->file_id.'&catid='.$file->cat_id.'&m=2'); - $mirror2_link = ''.JText::_('JLIST_FRONTEND_MIRROR_URL_TITLE_2').''; + $mirror2_link = ''.JText::_('JLIST_FRONTEND_MIRROR_URL_TITLE_2').''; $html_file = str_replace('{mirror_2}', $mirror2_link, $html_file); } else { $html_file = str_replace('{mirror_2}', '', $html_file); @@ -1324,7 +1417,15 @@ function showDownload($option, $file, $cat, $access){ $obj_title = $file->file_title; $html_file .= JComments::showComments($obj_id, 'com_jdownloads', $obj_title); } - } + } + + // Option for JomComment integration + if ($jlistConfig['view.jom.comment']){ + if (file_exists(JPATH_PLUGINS . DS . 'content' . DS . 'jom_comment_bot.php')){ + include_once( JPATH_PLUGINS . DS . 'content' . DS . 'jom_comment_bot.php' ); + $html_file .= jomcomment($file->file_id, "com_jdownloads"); + } + } // insert rating system if ($jlistConfig['view.ratings']){ @@ -1336,7 +1437,8 @@ function showDownload($option, $file, $cat, $access){ $footer = makeFooter(true, false, false, $sum_pages, $limit, $limitstart, $site_aktuell); $html_file .= $footer; - + // support for content plugins + $html_file = JHTML::_('content.prepare', $html_file); if ( !$jlistConfig['offline'] ) { echo $html_file; } else { @@ -1344,7 +1446,7 @@ function showDownload($option, $file, $cat, $access){ echo JText::_('JLIST_BACKEND_OFFLINE_ADMIN_MESSAGE_TEXT'); echo $html_file; } else { - $html_off = '

'.$jlistConfig['offline.text'].'

'; + $html_off = '

'.stripslashes($jlistConfig['offline.text']).'

'; $html_off .= $footer; echo $html_off; } @@ -1352,30 +1454,34 @@ function showDownload($option, $file, $cat, $access){ } /* ################################################################################# -/ Zusammenfassung anzeigen mit link zur Downloadseite +/ View Summary page with link to Download / ################################################################################# */ -function Summary($option, $marked_files_id, $mail_files, $filename, $download_link, $del_ok, $extern_site){ - global $jlistConfig, $jlistTemplates, $Itemid, $mainframe; +function Summary($option, $marked_files_id, $mail_files, $filename, $download_link, $del_ok, $extern_site, $sum_aup_points, $has_licenses){ + global $jlistConfig, $jlistTemplates, $Itemid, $mainframe, $page_title; $user = &JFactory::getUser(); $database = &JFactory::getDBO(); - $mainframe->setPageTitle( $jlistConfig['jd.header.title'].' - '.JText::_('JLIST_BACKEND_TEMP_TYP3') ); + $mainframe->setPageTitle($page_title.' - '.JText::_('JLIST_BACKEND_TEMP_TYP3') ); $html_sum = makeHeader($html_sum, true, false, false, 0, false, false, false, true, false, 0, $sum_pages, $list_per_page, $total, $list_start); echo $html_sum; // build output from template $html_sum = $jlistTemplates[3][0]->template_text; $html_sum = str_replace('{download_liste}', $mail_files, $html_sum); $html_sum = str_replace('{title_text}', JText::_('JLIST_FE_SUMMARY_PAGE_TITLE_TEXT'), $html_sum); - $html_sum = str_replace('{license_note}', JText::_('JLIST_FE_SUMMARY_PAGE_LICENSE_NOTE'), $html_sum); + if ($has_licenses){ + $html_sum = str_replace('{license_note}', JText::_('JLIST_FE_SUMMARY_PAGE_LICENSE_NOTE'), $html_sum); + } else { + $html_sum = str_replace('{license_note}', '', $html_sum); + } // summary pic $sum_size = $jlistConfig['cat.pic.size']; - $sumpic = ' '; + $sumpic = ' '; $html_sum = str_replace('{summary_pic}', $sumpic, $html_sum); // google adsense if ($jlistConfig['google.adsense.active']){ - $html_sum = str_replace('{google_adsense}', $jlistConfig['google.adsense.code'], $html_sum); + $html_sum = str_replace('{google_adsense}', stripslashes($jlistConfig['google.adsense.code']), $html_sum); } else { $html_sum = str_replace('{google_adsense}', '', $html_sum); } @@ -1384,16 +1490,34 @@ function Summary($option, $marked_files_id, $mail_files, $filename, $download_li function countdown2(){ if (counter >0){ counter-=1; - document.getElementById("countdown").innerHTML=sprintf(\''.$jlistConfig['countdown.text'].'\',counter); + document.getElementById("countdown").innerHTML=sprintf("'.stripslashes($jlistConfig['countdown.text']).'",counter); } else { document.getElementById("countdown").innerHTML=\''.'{link}'.'\' window.clearInterval(active); } } '; + } + // support for AUP + 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); + $profil = AlphaUserPointsHelper:: getUserInfo('', $user->id); + } + if ($profil){ + $points_info = sprintf( JText::_('JLIST_FE_VIEW_AUP_SUM_POINTS'), $sum_aup_points, $profil->points); + $html_sum = str_replace('{aup_points_info}', $points_info, $html_sum); + } else { + $points_info = sprintf( JText::_('JLIST_FE_VIEW_AUP_SUM_POINTS'), $sum_aup_points, 0); + $html_sum = str_replace('{aup_points_info}', $points_info, $html_sum); + } + } else { + $html_sum = str_replace('{aup_points_info}', '', $html_sum); } + if (count($marked_files_id) > 1) { - $link = '
'.JText::_('JLIST_LINKTEXT_ZIP').'
'; + $link = '
'.JText::_('JLIST_LINKTEXT_ZIP').'
'; if ($countdown){ $countdown = str_replace('{link}', $link, $countdown); $html_sum = str_replace('{download_link}', '
'.$countdown.'
', $html_sum); @@ -1410,7 +1534,7 @@ function Summary($option, $marked_files_id, $mail_files, $filename, $download_li $html_sum = str_replace('{external_download_info}', '', $html_sum); } - $link = '
'.JText::_('JLIST_LINKTEXT_ZIP').'
'; + $link = '
'.JText::_('JLIST_LINKTEXT_ZIP').'
'; if ($countdown){ $countdown = str_replace('{link}', $link, $countdown); $html_sum = str_replace('{download_link}', '
'.$countdown.'
', $html_sum); @@ -1426,7 +1550,7 @@ function Summary($option, $marked_files_id, $mail_files, $filename, $download_li // view frontend upload form function viewUpload($option, $task ){ - global $jlistConfig, $Itemid, $mainframe; + global $jlistConfig, $Itemid, $mainframe, $page_title; $user = &JFactory::getUser(); $database = &JFactory::getDBO(); @@ -1438,12 +1562,12 @@ function viewUpload($option, $task ){ 'clear_entities'=>'0' ); - $mainframe->setPageTitle( $jlistConfig['jd.header.title'].' - '.JText::_('JLIST_FRONTEND_UPLOAD_PAGE_TITLE') ); + $mainframe->setPageTitle($page_title.' - '.JText::_('JLIST_FRONTEND_UPLOAD_PAGE_TITLE') ); // variablen vorbelegen - $image1 = ''; + $upload_ok_pic = ''; $max_file_size = $jlistConfig['allowed.upload.file.size'] * 1024 ; $name_pic = 'form_no_value.png'; @@ -1476,12 +1600,13 @@ function viewUpload($option, $task ){ } else { $access= true; // nur einfügen wenn access = true - $html_form .= '

'.$jlistConfig['upload.form.text'].'
'; + $html_form .= '

'.stripslashes($jlistConfig['upload.form.text']).'
'; } // Inhalte holen, falls vorhanden if ($user->get('id') > 0) { $name = $user->get('username'); $mail = $user->get('email'); + $submitted_by = $user->id; $disabled = 'disabled="disabled"'; $name_pic = ''; $mail_pic = ''; @@ -1577,6 +1702,14 @@ function viewUpload($option, $task ){ $mark_catdir = $database->loadResult(); $description = trim($description); $description_long = trim($description_long); + + // build file alias + $file_alias = $filetitle; + $file_alias = JFilterOutput::stringURLSafe($file_alias); + if (trim(str_replace('-','',$file_alias)) == '') { + $datenow =& JFactory::getDate(); + $file_alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } // check file extensions if ($file_upload['tmp_name'] != '') { @@ -1658,11 +1791,15 @@ function viewUpload($option, $task ){ // get filedate $date_added = JHTML::_('date', 'now', '%Y-%m-%d %H:%M:%S' ); $url_download = basename($target_path); + $url_download = utf8_encode($url_download); // auto publish ? if ($jlistConfig['upload.auto.publish']){ $publish = 1; + setAUPPointsUploads($submitted_by, $filetitle); + $set_aup_points = 0; } else { + $set_aup_points = 1; $publish = 0; } @@ -1673,8 +1810,11 @@ function viewUpload($option, $task ){ } else { $filepic = $jlistConfig['file.pic.default.filename']; } + + - $database->setQuery("INSERT INTO #__jdownloads_files (`file_id`, `file_title`, `description`, `description_long`, `file_pic`, `thumbnail`, `price`, `release`, `language`, `system`, `license`, `url_license`, `size`, `date_added`, `url_download`, `url_home`, `author`, `url_author`, `created_by`, `created_mail`, `modified_by`, `modified_date`, `downloads`, `cat_id`, `ordering`, `published`, `checked_out`, `checked_out_time`) VALUES (NULL, '$filetitle', '$description', '$description_long', '$filepic', '$thumbnail', '$price', '$version', '$language_sel', '$system_sel', '$license_sel', '', '$size', '$date_added', '$url_download', '$author_url', '$author', '', '$name', '$mail', '', '0000-00-00 00:00:00', '0', '$catlist_sel', '0', '$publish', '0', '0000-00-00 00:00:00')"); + $database->setQuery("INSERT INTO #__jdownloads_files (`file_id`, `file_title`, `file_alias`,`description`, `description_long`, `file_pic`, `thumbnail`, `price`, `release`, `language`, `system`, `license`, `url_license`, `size`, `date_added`, `file_date`, `url_download`, `url_home`, `author`, `url_author`, `created_by`, `created_mail`, `modified_by`, `modified_date`, `submitted_by`, `set_aup_points`, `downloads`, `cat_id`, `ordering`, `published`, `checked_out`, `checked_out_time`) + VALUES (NULL, '$filetitle', '$file_alias', '$description', '$description_long', '$filepic', '$thumbnail', '$price', '$version', '$language_sel', '$system_sel', '$license_sel', '', '$size', '$date_added', '', '$url_download', '$author_url', '$author', '', '$name', '$mail', '', '0000-00-00 00:00:00', '$submitted_by', '$set_aup_points', '0', '$catlist_sel', '0', '$publish', '0', '0000-00-00 00:00:00')"); if (!$database->query()) { // fehler beim erstellen in DB echo $database->stderr(); @@ -1737,14 +1877,13 @@ function viewUpload($option, $task ){ // auto publish ? if ($jlistConfig['upload.auto.publish']){ $publish = 1; + setAUPPointsUploads($submitted_by, $filetitle); } else { $publish = 0; } - - - $database->setQuery("INSERT INTO #__jdownloads_files (`file_id`, `file_title`, `description`, `description_long`, `file_pic`, `thumbnail`, `price`, `release`, `language`, `system`, `license`, `url_license`, `size`, `date_added`, `url_download`, `extern_file`, `extern_site`, `url_home`, `author`, `url_author`, `created_by`, `created_mail`, `modified_by`, `modified_date`, `downloads`, `cat_id`, `ordering`, `published`, `checked_out`, `checked_out_time`) VALUES - (NULL, '$filetitle', '$description', '$description_long', '$filepic', '$thumbnail', '$price', '$version', '$language_sel', '$system_sel', '$license_sel', '', '$size', '$date_added', '', '$extern_file', '$linked_to_extern_site', '$author_url', '$author', '', '$name', '$mail', '', '0000-00-00 00:00:00', '0', '$catlist_sel', '0', '$publish', '0', '0000-00-00 00:00:00')"); + $database->setQuery("INSERT INTO #__jdownloads_files (`file_id`, `file_title`, `file_alias`, `description`, `description_long`, `file_pic`, `thumbnail`, `price`, `release`, `language`, `system`, `license`, `url_license`, `size`, `date_added`, `file_date`, `url_download`, `extern_file`, `extern_site`, `url_home`, `author`, `url_author`, `created_by`, `created_mail`, `modified_by`, `modified_date`, `submitted_by`, `downloads`, `cat_id`, `ordering`, `published`, `checked_out`, `checked_out_time`) VALUES + (NULL, '$filetitle', '$file_alias', '$description', '$description_long', '$filepic', '$thumbnail', '$price', '$version', '$language_sel', '$system_sel', '$license_sel', '', '$size', '$date_added', '', '', '$extern_file', '$linked_to_extern_site', '$author_url', '$author', '', '$name', '$mail', '', '0000-00-00 00:00:00', '$submitted_by', '0', '$catlist_sel', '0', '$publish', '0', '0000-00-00 00:00:00')"); if (!$database->query()) { echo $database->stderr(); exit; @@ -1775,7 +1914,7 @@ function viewUpload($option, $task ){ if ($access) { // form anzeigen - $form = '
+ $form = ' '; } @@ -1979,7 +2118,7 @@ function viewUpload($option, $task ){ @@ -1998,8 +2137,7 @@ function viewUpload($option, $task ){ if (isset($msg)) { $html_form = str_replace('{msg}', $msg, $html_form); } - - echo $html_form; + echo $html_form; echo $footer; // Focus auf erstes feld setzen @@ -2008,17 +2146,17 @@ function viewUpload($option, $task ){ if ($user->get('id') > 0) { ?> setPageTitle( $jlistConfig['jd.header.title'].' - '.JText::_('JLIST_FRONTEND_SEARCH_LINKTEXT') ); + $mainframe->setPageTitle( $page_title.' - '.JText::_('JLIST_FRONTEND_SEARCH_LINKTEXT') ); $html_form = makeHeader($html_form, true, false, false, 0, false, true, false, false, false, 0, 0, 0, 0, 0); echo $html_form; $html_form = ''; @@ -2037,11 +2175,15 @@ function showSearchForm($option){ $html_form = ''; $html_form .= '
'.JText::_('JLIST_FRONTEND_UPLOAD_TITEL_NAME').' @@ -1942,7 +2081,7 @@ function viewUpload($option, $task ){ '.JText::_('JLIST_FRONTEND_UPLOAD_EXTERN_FILE_TITEL').' '.$image1.$extern_file_pic.$image2.' -
'.JText::_('JLIST_FRONTEND_UPLOAD_ALLOWED_FILETYPE').': '.$jlistConfig['allowed.upload.file.types'].' +
'.JText::_('JLIST_FRONTEND_UPLOAD_ALLOWED_FILETYPE').': '.$jlistConfig['allowed.upload.file.types'].'
    -
+ + + @@ -2078,7 +2220,7 @@ function showSearchForm($option){ echo JText::_('JLIST_BACKEND_OFFLINE_ADMIN_MESSAGE_TEXT'); echo $html_cat; } else { - $html_off = '

'.$jlistConfig['offline.text'].'

'; + $html_off = '

'.stripslashes($jlistConfig['offline.text']).'

'; echo $html_off; } } @@ -2094,10 +2236,10 @@ function showSearchForm($option){ } function showSearchResult($option){ - global $Itemid, $jlistConfig, $mainframe; + global $Itemid, $jlistConfig, $mainframe, $page_title; $database = &JFactory::getDBO(); - $mainframe->setPageTitle( $jlistConfig['jd.header.title'].' - '.JText::_('JLIST_FRONTEND_SEARCH_RESULT_TITLE') ); + $mainframe->setPageTitle($page_title.' - '.JText::_('JLIST_FRONTEND_SEARCH_RESULT_TITLE') ); $html_form = makeHeader($html_form, true, false, false, 0, false, true, false, false, false, 0, 0, 0, 0, 0); $searchtext = $database->getEscaped(JArrayHelper::getValue($_POST, 'jdsearchtext', '')); @@ -2112,24 +2254,40 @@ function showSearchResult($option){ if (!$searchintitle && !$searchintext){ echo "\n"; } + + $search_array = explode(' ', $searchtext); + $files2 = array(); - if ($searchintitle && $searchintext){ - $database->setQuery("SELECT * FROM #__jdownloads_files WHERE file_title LIKE '%$searchtext%' OR description LIKE '%$searchtext%' OR description_long LIKE '%$searchtext%' AND published = 1 ORDER BY date_added LIMIT $searchnumber"); + foreach ($search_array as $word) { + if ($searchintitle && $searchintext){ + $database->setQuery("SELECT * FROM #__jdownloads_files WHERE file_title LIKE '%$word%' OR description LIKE '%$word%' OR description_long LIKE '%$word%' AND published = 1 ORDER BY date_added LIMIT $searchnumber"); + } + if ($searchintitle && !$searchintext){ + $database->setQuery("SELECT * FROM #__jdownloads_files WHERE file_title LIKE '%$word%' AND published = 1 ORDER BY date_added LIMIT $searchnumber"); + } + if (!$searchintitle && $searchintext){ + $database->setQuery("SELECT * FROM #__jdownloads_files WHERE description LIKE '%$word%' OR description_long LIKE '%$word%' AND published = 1 ORDER BY date_added LIMIT $searchnumber"); + } + $files = $database->loadObjectList(); + + foreach ($files as $file) { + if (!array_key_exists($file->file_id, $files2)) { + $files2[$file->file_id] = array('file'=>$file, 'ctr'=> 0); + } + $files2[$file->file_id]['ctr']++; + } + } - if ($searchintitle && !$searchintext){ - $database->setQuery("SELECT * FROM #__jdownloads_files WHERE file_title LIKE '%$searchtext%' AND published = 1 ORDER BY date_added LIMIT $searchnumber"); - } - if (!$searchintitle && $searchintext){ - $database->setQuery("SELECT * FROM #__jdownloads_files WHERE description LIKE '%$searchtext%' OR description_long LIKE '%$searchtext%' AND published = 1 ORDER BY date_added LIMIT $searchnumber"); - } - $files = $database->loadObjectList(); - if ($files) { + usort($files2, '_ctrSort'); + + if ($files2) { // files gefunden // cat der files holen und auf access beschränken $access = checkAccess_JD(); $output = array(); - foreach($files as $file) { + foreach($files2 as $file2) { + $file = $file2['file']; if ($file->published) { $database->setQuery("SELECT * FROM #__jdownloads_cats WHERE cat_id = '$file->cat_id'"); $cat = $database->loadObjectList(); @@ -2151,17 +2309,20 @@ function showSearchResult($option){ '; foreach ($output as $out){ - $regexp = "/($searchtext)(?![^<]+>)/i"; + // suchtext farblich hervorheben - if ($searchintitle && $searchintext){ - $out->description = preg_replace($regexp, ''.$searchtext.'', $out->description); - $out->file_title = preg_replace($regexp, ''.$searchtext.'', $out->file_title); - } - if ($searchintitle && !$searchintext){ - $out->file_title = preg_replace($regexp, ''.$searchtext.'', $out->file_title); - } - if (!$searchintitle && $searchintext){ - $out->description = preg_replace($regexp, ''.$searchtext.'', $out->description); + foreach ($search_array as $word) { + $regexp = "/($word)(?![^<]+>)/i"; + if ($searchintitle && $searchintext){ + $out->description = preg_replace($regexp, ''.$word.'', $out->description); + $out->file_title = preg_replace($regexp, ''.$word.'', $out->file_title); + } + if ($searchintitle && !$searchintext){ + $out->file_title = preg_replace($regexp, ''.$word.'', $out->file_title); + } + if (!$searchintitle && $searchintext){ + $out->description = preg_replace($regexp, ''.$word.'', $out->description); + } } $titel_link = JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&task=view.download&catid='.$out->cat_id.'&cid='.$out->file_id); $titel_link_text = ''.$out->file_title.''; diff --git a/oss/joomla/trunk/components/com_jdownloads/jdownloads.php b/oss/joomla/trunk/components/com_jdownloads/jdownloads.php index 301f3554..be4b1d3c 100644 --- a/oss/joomla/trunk/components/com_jdownloads/jdownloads.php +++ b/oss/joomla/trunk/components/com_jdownloads/jdownloads.php @@ -15,12 +15,17 @@ 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, $pop, $jlistConfig, $jlistTemplates; + + global $Itemid, $mainframe; + global $id, $limit, $limitstart, $site_aktuell, $catid, $cid, $task, $pop, $jlistConfig, $jlistTemplates, $page_title; + + $document =& JFactory::getDocument(); + $params = &$mainframe->getParams(); + define( 'ELPATH', dirname(__FILE__) ); $GLOBALS['_VERSION'] = new JVersion(); @@ -38,12 +43,36 @@ $jconfig = new JConfig(); if (!is_array( $id)) { $id = array(0); } - + $GLOBALS['jlistConfig'] = buildjlistConfig(); $GLOBALS['jlistTemplates'] = getTemplates(); + // 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 { + $document->setTitle( $menu_params->get( 'page_title')); + } + $page_title = $document->getTitle( 'title'); + + $pop = intval( JArrayHelper::getValue( $_REQUEST, 'pop', 0 ) ); $task = JArrayHelper::getValue( $_REQUEST, 'task' ); + $view = JArrayHelper::getValue( $_REQUEST, 'view' ); $cid = (int)JArrayHelper::getValue($_REQUEST, 'cid', array()); $catid = (int)JArrayHelper::getValue($_REQUEST, 'catid', 0); @@ -51,6 +80,19 @@ $jconfig = new JConfig(); $limitstart = intval( JArrayHelper::getValue( $_REQUEST, 'start', 0 ) ); $site_aktuell = intval( JArrayHelper::getValue( $_REQUEST, 'site', 1 ) ); + $menus = &JSite::getMenu(); + $menu = $menus->getActive(); + + // 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 ($view && !$task) $task = $view; + switch ($task) { case 'upload': @@ -87,7 +129,11 @@ switch ($task) { case 'report': reportDownload($option,$cid); - break; + break; + + case 'viewcategories': + showCats($option,$cid); + break; default: showCats($option,$cid); break; @@ -100,9 +146,11 @@ function Summary($option){ $app = &JFactory::getApplication(); $user = &JFactory::getUser(); $database = &JFactory::getDBO(); - + // AUP support + $sum_aup_points = 0; $extern_site = false; $marked_files_id = array(); + $has_licenses = false; // file-id der ausgewählten dateien holen - falls verwendet $marked_files_id = JArrayHelper::getValue( $_POST, 'cb_arr', array(0)); for($i=0,$n=count($marked_files_id);$i<$n;$i++){ @@ -131,12 +179,13 @@ function Summary($option){ $breadcrumbs->addItem($cat_title, JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&task=viewcategory&catid='.$catid)); } if ($fileid){ - $database->setQuery('SELECT file_title FROM #__jdownloads_files WHERE published = 1 AND file_id = '.$fileid); - if (!$file_title = $database->loadResult()){ + $database->setQuery('SELECT * FROM #__jdownloads_files WHERE published = 1 AND file_id = '.$fileid); + if (!$file = $database->loadObject()){ // jump to the mainsite $app->redirect(JURI::base(true)); } - $breadcrumbs->addItem($file_title, JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&task=view.download&catid='.$catid.'&cid='.$fileid)); + $breadcrumbs->addItem($file->file_title, JRoute::_('index.php?option='.$option.'&Itemid='.$Itemid.'&task=view.download&catid='.$catid.'&cid='.$fileid)); + } $breadcrumbs->addItem(JText::_('JLIST_FRONTEND_HEADER_SUMMARY_TITLE'), ''); @@ -173,9 +222,25 @@ function Summary($option){ $database->setQuery("SELECT * FROM #__jdownloads_license"); $lic_arr = $database->loadObjectList(); + // 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; $ilicense -1 > 0){ - $mail_files .= "
  • ".$mail_files_arr[$i]->file_title.' '.$mail_files_arr[$i]->release.'   '.JText::_('JLIST_FE_DETAILS_LICENSE_TITLE').': '.$lic_arr[$mail_files_arr[$i]->license-1]->license_title.'   '.JText::_('JLIST_FE_DETAILS_FILESIZE_TITLE').': '.$mail_files_arr[$i]->size.'
  • '; + + // 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){ + $has_licenses = true; + $mail_files .= "
  • ".$mail_files_arr[$i]->file_title.' '.$mail_files_arr[$i]->release.'   '.JText::_('JLIST_FE_DETAILS_LICENSE_TITLE').': '.$lic_arr[$mail_files_arr[$i]->license-1]->license_title.'   '.JText::_('JLIST_FE_DETAILS_FILESIZE_TITLE').': '.$mail_files_arr[$i]->size.'
  • '; } else { $mail_files .= "
  • ".$mail_files_arr[$i]->file_title.' '.$mail_files_arr[$i]->release.'   '.JText::_('JLIST_FE_DETAILS_FILESIZE_TITLE').': '.$mail_files_arr[$i]->size.'
  • '; } @@ -191,7 +256,16 @@ function Summary($option){ } 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)){ + $extern_site = true; + } + } // wenn kein direktlink - checkox variante if (!$direktlink){ @@ -207,7 +281,7 @@ function Summary($option){ for ($i=0; $isetQuery("SELECT url_download FROM #__jdownloads_files WHERE file_id = '".(int)$marked_files_id[$i]."'"); - $filename = $database->loadResult(); + $filename = utf8_decode($database->loadResult()); $database->setQuery("SELECT cat_id FROM #__jdownloads_files WHERE file_id = '".(int)$marked_files_id[$i]."'"); $cat_id = $database->loadResult(); $database->setQuery("SELECT cat_dir FROM #__jdownloads_cats WHERE cat_id = '$cat_id'"); @@ -232,8 +306,8 @@ function Summary($option){ $download_link = $filename; } } - - jlist_HTML::Summary($option, $marked_files_id, $mail_files, $filename, $download_link, $del_ok, $extern_site); + $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); } // finish and start the download @@ -245,6 +319,8 @@ function finish($option){ $database = &JFactory::getDBO(); $extern = false; $extern_site = false; + $can_download = false; + $price = ''; // anti lecching $url = JURI::base( false ); @@ -303,8 +379,21 @@ function finish($option){ // jump to the mainsite $app->redirect(JURI::base(true)); } + + // 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); + } + // 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 (JArrayHelper::getValue( $_REQUEST, 'list', '' )); + $files_arr = explode(',', $files); if ($files){ // sammeldownload $user_random_id = intval(JArrayHelper::getValue( $_REQUEST, 'user', 0 )); @@ -312,8 +401,8 @@ function finish($option){ $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_title FROM #__jdownloads_files WHERE published = 1 AND file_id IN ('.$files.')'); - if (!$ok = $database->loadObjectList()){ + $database->setQuery('SELECT file_id, file_title FROM #__jdownloads_files WHERE published = 1 AND file_id IN ('.$files.')'); + if (!$rows = $database->loadObjectList()){ $app->redirect(JURI::base(true)); } // Zähler versorgen @@ -323,6 +412,57 @@ function finish($option){ if ($jlistConfig['send.mailto.option'] == '1') { sendMail($files); } + // 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 = '
    '.stripslashes($jlistConfig['user.message.when.zero.points']).'
    '. + '
    '.JText::_('JLIST_BACKEND_SET_AUP_FE_MESSAGE_NO_DOWNLOAD_POINTS').' '.(int)$profil->points.'
    '.JText::_('JLIST_BACKEND_SET_AUP_FE_MESSAGE_NO_DOWNLOAD_NEEDED').' '.JText::_($sum_points).'
    '. + ''; + echo $aup_no_points; + } + // 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 .= ''; + echo '
    '.stripslashes($jlistConfig['limited.download.reached.message']).' '.$date.'
    '.$back; + } + } else { // einzelner download // check whether direct access @@ -330,56 +470,92 @@ function finish($option){ if (!$ok = $database->loadResult()){ $app->redirect(JURI::base(true)); } - // hits um 1 erhöhen - $database->setQuery("UPDATE #__jdownloads_files SET downloads=downloads+1 WHERE file_id = '".(int)$fileid."'"); - $database->query(); - - // 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; - } - // send mail - if ($jlistConfig['send.mailto.option'] == '1') { - sendMail($fileid); - } + // 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 .= ''; + echo '
    '.stripslashes($jlistConfig['limited.download.reached.message']).' '.$date.'
    '.$back; + } else { + // hits um 1 erhöhen + $database->setQuery("UPDATE #__jdownloads_files SET downloads=downloads+1 WHERE file_id = '".(int)$fileid."'"); + $database->query(); + + // get filename and build path + if (!$is_mirror){ + $database->setQuery("SELECT url_download FROM #__jdownloads_files WHERE file_id = '".(int)$fileid."'"); + $file_url = utf8_decode($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; + } + + // send mail + if ($jlistConfig['send.mailto.option'] == '1') { + sendMail($fileid); + } + // 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 = '
    '.stripslashes($jlistConfig['user.message.when.zero.points']).'
    '. + '
    '.JText::_('JLIST_BACKEND_SET_AUP_FE_MESSAGE_NO_DOWNLOAD_POINTS').' '.(int)$profil->points.'
    '.JText::_('JLIST_BACKEND_SET_AUP_FE_MESSAGE_NO_DOWNLOAD_NEEDED').' '.JText::_($price).'
    '. + ''; + echo $aup_no_points; + } + } } // run download - $x = download($filename, $filename_direct, $extern, $extern_site); - + if ($can_download && $may_download){ + $x = download($filename, $filename_direct, $extern, $extern_site); + } if ($x == 2) { - // datei nicht vorhanden + // files not exists echo '

    '.JText::_('JLIST_FRONTEND_FILE_NOT_FOUND_MESSAGE').'

    '; } } @@ -405,7 +581,7 @@ function download($file, $filename_direct, $extern, $extern_site){ // if url go to other website - open it in a new browser window if ($extern_site){ - echo "\n"; + echo "\n"; exit; } @@ -418,6 +594,11 @@ function download($file, $filename_direct, $extern, $extern_site){ $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 @@ -433,6 +614,10 @@ function download($file, $filename_direct, $extern, $extern_site){ header('Content-Disposition: inline; filename="'.$filename.'"'); } header("Content-Transfer-Encoding: binary\n"); + // set_time_limit doesn't work in safe mode + if (!ini_get('safe_mode')){ + @set_time_limit(0); + } @readfile($file); } exit; @@ -870,7 +1055,7 @@ function sendMail($files){ $html_format = true; $text = ""; - $text = $jlistConfig['send.mailto.template.download']; + $text = stripslashes($jlistConfig['send.mailto.template.download']); $text = str_replace('{file_list}', $mail_files, $text); $text = str_replace('{ip_address}', $ip, $text); $text = str_replace('{user_name}', $user_name, $text); @@ -900,7 +1085,7 @@ function sendMailUploads($name, $mail, $url_download, $filetitle, $description){ $html_format = true; $text = ""; - $text = $jlistConfig['send.mailto.template.upload']; + $text = stripslashes($jlistConfig['send.mailto.template.upload']); $text = str_replace('{name}', $name, $text); $text = str_replace('{ip}', $ip, $text); $text = str_replace('{mail}', $mail, $text); @@ -1036,11 +1221,14 @@ function fsize($file) { // build comp header function makeHeader($header, $compo_text, $is_showcats, $is_one_cat, $sum_subs, $is_detail, $is_search, $is_upload, $is_summary, $is_finish, $sum_pages, $limit, $total, $limitstart, $site_aktuell) { - global $jlistConfig, $Itemid; + global $jlistConfig, $Itemid, $page_title; $user = &JFactory::getUser(); $database = &JFactory::getDBO(); + $database->setQuery("SELECT id from #__menu WHERE link = 'index.php?option=com_jdownloads&view=viewcategories' and published = 1"); + $Itemid = $database->loadResult(); + // Anzeige 1 von 0 verhindern if ($sum_pages == 0){ $sum_pages = 1; @@ -1048,13 +1236,13 @@ function makeHeader($header, $compo_text, $is_showcats, $is_one_cat, $sum_subs, // compo header $header = ''; - $header = '
    '.$jlistConfig['jd.header.title'].'
    '; + $header = '
    '.$page_title.'
    '; // components description if ($compo_text && $jlistConfig['downloads.titletext'] != '') { - $header_text = $jlistConfig['downloads.titletext']; + $header_text = stripslashes($jlistConfig['downloads.titletext']); if ($jlistConfig['google.adsense.active'] && $jlistConfig['google.adsense.code'] != ''){ - $header_text = str_replace( '{google_adsense}', $jlistConfig['google.adsense.code'], $header_text); + $header_text = str_replace( '{google_adsense}', stripslashes($jlistConfig['google.adsense.code']), $header_text); } else { $header_text = str_replace( '{google_adsense}', '', $header_text); } @@ -1062,14 +1250,14 @@ function makeHeader($header, $compo_text, $is_showcats, $is_one_cat, $sum_subs, } // home link - $header .= '

    '.JText::_('JLIST_FRONTEND_SEARCH_DESCRIPTION').' +
    '.JText::_('JLIST_FRONTEND_SEARCH_TEXT_TITLE').' - +
    '; + $header .= '
    '.' '.JText::_('JLIST_FRONTEND_HOME_LINKTEXT').'
    '; // insert search link - $header .= ''; + $header .= ''; // insert frontend upload link if active if ($jlistConfig['frontend.upload.active']) { - $header .= ''; + $header .= ''; } // listbox aller cats erzeugen wenn aktiviert in config @@ -1102,8 +1290,11 @@ function makeHeader($header, $compo_text, $is_showcats, $is_one_cat, $sum_subs, 'class="inputbox" size="1" onchange="gocat(cat_list,'.$Itemid.')"', 'value', 'text', $selected ); $header .= '
    '.' '.JText::_('JLIST_FRONTEND_HOME_LINKTEXT').''.' '.JText::_('JLIST_FRONTEND_SEARCH_LINKTEXT').''.' '.JText::_('JLIST_FRONTEND_SEARCH_LINKTEXT').''.' '.JText::_('JLIST_FRONTEND_UPLOAD_LINKTEXT').''.' '.JText::_('JLIST_FRONTEND_UPLOAD_LINKTEXT').''.$cat_listbox.'
    '; + } else { + $header .=''; } + // Subheader !! // hide subheader @@ -1143,12 +1334,14 @@ function makeHeader($header, $compo_text, $is_showcats, $is_one_cat, $sum_subs, '.JText::_('JLIST_FRONTEND_SUBTITLE_OVER_CATLIST').'
    '.$nav1.' '.JText::_('JLIST_FRONTEND_HEADER_PAGENAVI_PAGE_TEXT').' '.$site_aktuell.' '.JText::_('JLIST_FRONTEND_HEADER_PAGENAVI_TO_TEXT').' '.$sum_pages.' '.$nav2.'
    '.JText::_('JLIST_FRONTEND_SUBHEADER_NUMBER_OF_CATS_TITLE').': '.$total.''; + $header .= ''; } else { $header .= ''; + $header .= '
    '.JText::_('JLIST_FRONTEND_SUBTITLE_OVER_CATLIST').'
    '.JText::_('JLIST_FRONTEND_SUBHEADER_NUMBER_OF_CATS_TITLE').': '.$total.'
    '; } } @@ -1197,11 +1390,13 @@ function makeHeader($header, $compo_text, $is_showcats, $is_one_cat, $sum_subs, '.JText::_('JLIST_FRONTEND_SUBTITLE_OVER_ONE_CAT').': '.$title.'
    '.$nav1.' '.JText::_('JLIST_FRONTEND_HEADER_PAGENAVI_PAGE_TEXT').' '.$site_aktuell.' '.JText::_('JLIST_FRONTEND_HEADER_PAGENAVI_TO_TEXT').' '.$sum_pages.' '.$nav2.'
    '.$einf.''; + $header .= ''; } else { $header .= ''; + $header .= '
    '.JText::_('JLIST_FRONTEND_SUBTITLE_OVER_ONE_CAT').': '.$title.'
    '.$einf.'
    '; } } } @@ -1302,9 +1497,9 @@ function makeFooter($make_back_button, $is_showcats, $is_one_cat, $sum_pages, $l } // footer text if ($jlistConfig['downloads.footer.text'] != '') { - $footer_text = $jlistConfig['downloads.footer.text']; + $footer_text = stripslashes($jlistConfig['downloads.footer.text']); if ($jlistConfig['google.adsense.active'] && $jlistConfig['google.adsense.code'] != ''){ - $footer_text = str_replace( '{google_adsense}', $jlistConfig['google.adsense.code'], $footer_text); + $footer_text = str_replace( '{google_adsense}', stripslashes($jlistConfig['google.adsense.code']), $footer_text); } else { $footer_text = str_replace( '{google_adsense}', '', $footer_text); } @@ -1337,12 +1532,12 @@ function reportDownload($option,$cid){ $first_adress = array_shift($empfaenger); $success = JUtility::sendMail('jDownloads', 'jDownloads', $first_adress, $betreff, $text, $html_format, '',$empfaenger); if ($success){ - $message = '

    '.JText::_('JLIST_REPORT_FILE_MESSAGE_OK').'

    '; + $message = '

    '.JText::_('JLIST_REPORT_FILE_MESSAGE_OK').'

    '; } else { - $message = '

    '.JText::_('JLIST_REPORT_FILE_MESSAGE_ERROR').'

    '; + $message = '

    '.JText::_('JLIST_REPORT_FILE_MESSAGE_ERROR').'

    '; } } else { - $message = '

    '.JText::_('JLIST_REPORT_FILE_MESSAGE_ERROR').'

    '; + $message = '

    '.JText::_('JLIST_REPORT_FILE_MESSAGE_ERROR').'

    '; } $message .= ''; echo $message; @@ -1503,8 +1698,9 @@ function create_new_thumb($picturepath) { } function checkFileName($name){ + global $jlistConfig; if ($name) { - $name = utf8_decode($name); + $name = utf8_decode($name); // change to uppercase if ($jlistConfig['fix.upload.filename.uppercase']){ $name = strtolower($name); @@ -1517,13 +1713,13 @@ function checkFileName($name){ // change special chars $name = strtr($name, array( "'" => "", 'ä' => 'ae', 'ü' => 'ue', 'ö' => 'oe', 'Ä' => 'ae', 'Ü' => 'ue', 'Ö' => 'oe', 'ß' => 'ss', 'Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u')); // remove invalid chars - $name = preg_replace('#[^a-z0-9_.-]#', '', $name); + $name = preg_replace('#[^A-Za-z0-9 _.-]#', '', $name); } // anti hack .php.rar - $name = str_ireplace('.php.', '.', $name); - $name = str_ireplace('.php4.', '.', $name); - $name = str_ireplace('.php5.', '.', $name); - $name = utf8_encode($name); + $name = JString::str_ireplace('.php.', '.', $name); + $name = JString::str_ireplace('.php4.', '.', $name); + $name = JString::str_ireplace('.php5.', '.', $name); + //$name = utf8_encode($name); } return $name; } @@ -1598,7 +1794,7 @@ function getID3v2Tags($file,$blnAllFrames=0){ } $frameContent=fread($fp,$frameSize); if(!$arrTag[$frameName]){ - $arrTag[$frameName]=trim($frameContent);// the frame content (always?) starts with 0, so it's better to remove it + $arrTag[$frameName]=trim(utf8_encode($frameContent));// the frame content (always?) starts with 0, so it's better to remove it } else{// if there is more than one frame with the same name $arrTag[$frameName]=$arrTag[$frameName]."~".trim($frameContent); @@ -1669,11 +1865,11 @@ function getRatings($id){
    • -
    • 1
    • -
    • 2
    • -
    • 3
    • -
    • 4
    • -
    • 5
    • +
    • +
    • +
    • +
    • +
    '; @@ -1684,11 +1880,11 @@ function getRatings($id){
    • -
    • 1
    • -
    • 2
    • -
    • 3
    • -
    • 4
    • -
    • 5
    • +
    • +
    • +
    • +
    • +
    '; @@ -1707,4 +1903,150 @@ function getRatings($id){ return $html; } +function setAUPPointsUploads($submitted_by, $file_title){ + // added (or reduce) points to the alphauserpoints when is activated in the jD config + // $submitted_by = user ID after upload a file + global $jlistConfig; + if ($jlistConfig['use.alphauserpoints'] && $submitted_by){ + $api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php'; + if (file_exists($api_AUP)){ + require_once ($api_AUP); + $aupid = AlphaUserPointsHelper::getAnyUserReferreID( $submitted_by ); + if ($aupid){ + $text = JText::_('JLIST_BACKEND_SET_AUP_UPLOAD_TEXT'); + $text = sprintf($text, $file_title); + AlphaUserPointsHelper::newpoints( 'plgaup_jdownloads_user_upload_published', $aupid, $file_title, $text); + } + } + } +} + +function setAUPPointsDownload($user_id, $file_title, $price){ + // added (or reduce) points to the alphauserpoints when is activated in the jD config + // $user_id = user ID from the file download + global $jlistConfig; + if ($jlistConfig['use.alphauserpoints'] && $user_id){ + $api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php'; + if (file_exists($api_AUP)){ + require_once ($api_AUP); + $aupid = AlphaUserPointsHelper::getAnyUserReferreID( $user_id ); + if ($aupid){ + $text = JText::_('JLIST_BACKEND_SET_AUP_DOWNLOAD_TEXT'); + $text = sprintf($text, $file_title); + // get AUP user data + $profil = AlphaUserPointsHelper:: getUserInfo ( '', $user_id ); + if ($jlistConfig['user.can.download.file.when.zero.points'] || $profil->points > 0 || $price == 0){ + if ($price){ + // price as points activated + if ($profil->points >= $price){ + if ($jlistConfig['use.alphauserpoints.with.price.field']){ + AlphaUserPointsHelper::newpoints( 'plgaup_jdownloads_user_download_use_price', $aupid, '', $text, '-'.$price, $text); + return true; + } else { + AlphaUserPointsHelper::newpoints( 'plgaup_jdownloads_user_download', $aupid, '', $text); + return true; + } + } else { + // not enough points . no download + return false; + } + } else { + // use points set in AUP plugin + //AlphaUserPointsHelper::newpoints( 'plgaup_jdownloads_user_download', $aupid, '', $text); + return true; + } + } else { + // not enough points . no download + return false; + } + } + } else { + return true; + } + } else { + if ($price){ + // not registered user + return false; + } else { + // guest but no price + return true; + } + } +} + +function setAUPPointsDownloads($user_id, $file_title, $price){ + // added (or reduce) points to the alphauserpoints when is activated in the jD config + // $user_id = user ID from the file download + global $jlistConfig; + if ($jlistConfig['use.alphauserpoints'] && $user_id){ + $api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php'; + if (file_exists($api_AUP)){ + require_once ($api_AUP); + $aupid = AlphaUserPointsHelper::getAnyUserReferreID( $user_id ); + if ($aupid){ + $text = JText::_('JLIST_BACKEND_SET_AUP_DOWNLOAD_TEXT'); + $text = sprintf($text, $file_title); + // get AUP user data + $profil = AlphaUserPointsHelper:: getUserInfo ( '', $user_id ); + if ($jlistConfig['user.can.download.file.when.zero.points'] || $profil->points > 0 || $price == 0){ + if ($price){ + // price as points activated + AlphaUserPointsHelper::newpoints( 'plgaup_jdownloads_user_download_use_price', $aupid, '', $text, '-'.$price, $text); + return true; + } else { + AlphaUserPointsHelper::newpoints( 'plgaup_jdownloads_user_download', $aupid, '', $text); + return true; + } + } else { + return false; + } + } + } else { + return true; + } + } else { + return true; + } +} + +function checkLog($fileid, $user){ + global $jlistConfig; + $database = &JFactory::getDBO(); + $app = JFactory::getApplication(); + $offset = $app->getCfg('offset'); + $datenow =& JFactory::getDate(); + $datenow->setOffset($offset); + + $date = $datenow->toFormat("%Y-%m-%d"); + $max_files_day = $jlistConfig['limited.download.number.per.day']; + if ($max_files_day == 0 || $user->get('aid') == 0 || $user->get('aid') == 2){ + // not limited or guest or special user group + return true; + } else { + // delete first old data sets + $database->setQuery("DELETE FROM #__jdownloads_log WHERE log_datetime != '$date'"); + $database->Query(); + // check limit + $logged_user_files = array(); + $database->setQuery("SELECT * FROM #__jdownloads_log WHERE log_datetime = '$date' AND log_user = '". (int) $user->get('id')."'"); + $logged_user_files = $database->loadObjectList(); + if (!$logged_user_files || count($logged_user_files) < $max_files_day){ + // add file in log + $database->setQuery("INSERT INTO #__jdownloads_log (log_file_id, log_ip, log_datetime, log_user, log_browser) VALUES ('".$fileid."', '".$_SERVER['REMOTE_ADDR']."', '".$date."', '".$user->get('id')."', '')"); + $database->query(); + return true; + } else { + // download not allowed + return false; + } + } +} + +// added for search function +function _ctrSort($a, $b) { + if (!is_array($a) || !is_array($b) || !array_key_exists("ctr", $a) || !array_key_exists("ctr", $b) || $a['ctr'] == $b['ctr']) + return 0; + return ($a['ctr'] < $b['ctr']) ? 1 : -1; + +} ?> \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/lightbox/lightbox.js b/oss/joomla/trunk/components/com_jdownloads/lightbox/lightbox.js index 95726e07..c18a67a5 100644 --- a/oss/joomla/trunk/components/com_jdownloads/lightbox/lightbox.js +++ b/oss/joomla/trunk/components/com_jdownloads/lightbox/lightbox.js @@ -38,8 +38,8 @@ // // If you would like to use a custom loading image or close button reference them in the next two lines. -var loadingImage = 'components/com_jdownloads/lightbox/loading.gif'; -var closeButton = 'components/com_jdownloads/lightbox/close.gif'; +var loadingImage = live_site+'components/com_jdownloads/lightbox/loading.gif'; +var closeButton = live_site+'components/com_jdownloads/lightbox/close.gif'; diff --git a/oss/joomla/trunk/components/com_jdownloads/views/upload/index.html b/oss/joomla/trunk/components/com_jdownloads/views/upload/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/upload/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/upload/metadata.xml b/oss/joomla/trunk/components/com_jdownloads/views/upload/metadata.xml new file mode 100644 index 00000000..e2a880ce --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/upload/metadata.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/upload/tmpl/default.xml b/oss/joomla/trunk/components/com_jdownloads/views/upload/tmpl/default.xml new file mode 100644 index 00000000..83cb4594 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/upload/tmpl/default.xml @@ -0,0 +1,14 @@ + + + + + + + + + JD_MENU_UPLOAD_LAYOUT + JD_MENU_UPLOAD_LAYOUT_DESC + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/upload/tmpl/index.html b/oss/joomla/trunk/components/com_jdownloads/views/upload/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/upload/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/view.download/index.html b/oss/joomla/trunk/components/com_jdownloads/views/view.download/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/view.download/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/view.download/metadata.xml b/oss/joomla/trunk/components/com_jdownloads/views/view.download/metadata.xml new file mode 100644 index 00000000..de4b1332 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/view.download/metadata.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/view.download/tmpl/default.xml b/oss/joomla/trunk/components/com_jdownloads/views/view.download/tmpl/default.xml new file mode 100644 index 00000000..840e7bc5 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/view.download/tmpl/default.xml @@ -0,0 +1,18 @@ + + + + + + + + + JD_MENU_VIEWDOWNLOAD_LAYOUT + JD_MENU_VIEWDOWNLOAD_LAYOUT_DESC + + + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/view.download/tmpl/index.html b/oss/joomla/trunk/components/com_jdownloads/views/view.download/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/view.download/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/index.html b/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/metadata.xml b/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/metadata.xml new file mode 100644 index 00000000..e1625879 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/metadata.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/tmpl/default.xml b/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/tmpl/default.xml new file mode 100644 index 00000000..2af5e0d2 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/tmpl/default.xml @@ -0,0 +1,14 @@ + + + + + + + + + JD_MENU_CATEGORIES_LIST_LAYOUT + JD_MENU_CATEGORIES_LIST_LAYOUT_DESC + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/tmpl/index.html b/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/viewcategories/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/index.html b/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/metadata.xml b/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/metadata.xml new file mode 100644 index 00000000..3b94282f --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/metadata.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/tmpl/default.xml b/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/tmpl/default.xml new file mode 100644 index 00000000..f5d2cb20 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/tmpl/default.xml @@ -0,0 +1,18 @@ + + + + + + + + + JD_MENU_CATEGORY_LIST_LAYOUT + JD_MENU_CATEGORY_LIST_LAYOUT_DESC + + + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/tmpl/index.html b/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/components/com_jdownloads/views/viewcategory/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file