function jd_file_fill_downloadok($p_Template, $files, $p_Symbol_Off, $p_DownloadType, $download_allowed) { global $jlistConfigM, $jDFPsfolders, $jDFPrank, $jDFPlive_site, $jDFPplugin_live_site, $jDFPabsolute_path, $cat_link_itemidsPlg, $jDLayoutTitleExists, $root_itemid, $date_format; $db = JFactory::getDBO(); $user = JFactory::getUser(); $jd_user_settings = JDHelper::getUserRules(); $jdlink_author_text = ''; $createdbyname = ''; $modifiedbyname = ''; $l_Template = str_replace("{{{", "[[[", $p_Template); $jdpic_license = ''; $jdpic_date = ''; $jdpic_author = ''; $jdpic_website = ''; $jdpic_system = ''; $jdpic_language = ''; $jdpic_download = ''; $jdpic_hits = ''; $jdpic_size = ''; $jdpic_price = ''; $cat_itemid = 0; if ($p_Symbol_Off == 0) { $msize = $jlistConfigM['info.icons.size']; $jdpic_license = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'license.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_LICENCE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_LICENCE') . '" /> '; $jdpic_date = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'date.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DATE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DATE') . '" /> '; $jdpic_author = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'contact.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_AUTHOR') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_AUTHOR') . '" /> '; $jdpic_website = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'weblink.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_WEBSITE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_WEBSITE') . '" /> '; $jdpic_system = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'system.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_SYSTEM') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_SYSTEM') . '" /> '; $jdpic_language = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'language.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_LANGUAGE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_LANGUAGE') . '" /> '; $jdpic_download = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'download.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DOWNLOAD') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DOWNLOAD') . '" /> '; $jdpic_hits = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'download.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DOWNLOAD') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_DOWNLOAD_HITS') . '" /> '; $jdpic_size = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'stuff.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_FILESIZE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_FILESIZE') . '" /> '; $jdpic_price = '<img src="' . JURI::base() . $jDFPsfolders['mini'] . 'currency.png" style="vertical-align:middle;" width="' . $msize . '" height="' . $msize . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_PRICE') . '" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_PRICE') . '" /> '; } // Build a little pic for extern links $jdextern_url_pic = '<img src="' . $jDFPplugin_live_site . 'content/jdownloads/jdownloads/images/link_extern.gif" style="vertical-align:middle;" alt="" title="" />'; $jd_file_pic = '<img src="' . JURI::base() . $jDFPsfolders['file'] . $files->file_pic . '" style="vertical-align:middle;" border="0" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" alt="" title="" />'; // Pics for: new file / hot file /updated $hotpic = '<img src="' . JURI::base() . 'images/jdownloads/hotimages/' . $jlistConfigM['picname.is.file.hot'] . '" alt="" />'; $newpic = '<img src="' . JURI::base() . 'images/jdownloads/newimages/' . $jlistConfigM['picname.is.file.new'] . '" alt="" />'; $updatepic = '<img src="' . JURI::base() . 'images/jdownloads/updimages/' . $jlistConfigM['picname.is.file.updated'] . '" alt="" />'; // Alternate CSS buttons when selected in configuration $status_color_hot = $jlistConfigM['css.button.color.hot']; $status_color_new = $jlistConfigM['css.button.color.new']; $status_color_updated = $jlistConfigM['css.button.color.updated']; $download_color = $jlistConfigM['css.button.color.download']; $download_size = $jlistConfigM['css.button.size.download']; $download_size_mirror = $jlistConfigM['css.button.size.download.mirror']; $download_color_mirror1 = $jlistConfigM['css.button.color.mirror1']; $download_color_mirror2 = $jlistConfigM['css.button.color.mirror2']; $download_size_listings = $jlistConfigM['css.button.size.download.small']; $jd_cat_id = $files->cat_id; $jd_filename = $files->url_download; $jd_file_language = $files->file_language; $jd_system = $files->system; if ($files->category_cat_dir_parent) { $category_dir = $files->category_cat_dir_parent . '/' . $files->category_cat_dir; } else { $category_dir = $files->category_cat_dir; } // Has this Download really a file? if (!$files->url_download && !$files->other_file_id && !$files->extern_file) { // only a document without file $no_file_info = JText::_('COM_JDOWNLOADS_FRONTEND_ONLY_DOCUMENT_USER_INFO'); $download_has_a_file = false; } else { $download_has_a_file = true; $no_file_info = ''; } // Compute the download slugs $files->slug = $files->file_alias ? $files->file_id . ':' . $files->file_alias : $files->file_id; // create all file titles $l_Template = JDHelper::buildFieldTitles($l_Template, $files); // When we have a simple document, view only the info not any buttons. if (!$download_has_a_file) { if (strpos($l_Template, '{url_download}')) { $l_Template = str_replace('{url_download}', $no_file_info, $l_Template); } else { $l_Template = str_replace('{checkbox_list}', $no_file_info, $l_Template); } // Place the images $l_Template = JDHelper::placeThumbs($l_Template, $files->images); if ($jlistConfigM['view.detailsite']) { $title_link = JRoute::_(JDownloadsHelperRoute::getDownloadRoute($files->slug, $files->cat_id, $files->language)); $title_link_text = '<a href="' . $title_link . '">' . $db->escape($files->file_title) . '</a>'; $detail_link_text = '<a href="' . $title_link . '">' . JText::_('COM_JDOWNLOADS_FE_DETAILS_LINK_TEXT_TO_DETAILS') . '</a>'; // Build the file symbol (with link) if ($files->file_pic != '') { $filepic = '<a href="' . $title_link . '">' . '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" /></a> '; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); // link to details view at the end $l_Template = str_replace('{link_to_details}', $detail_link_text, $l_Template); $l_Template = str_replace('{file_title}', $title_link_text, $l_Template); } else { // no links if ($files->file_pic != '') { $filepic = '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" />'; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); // remove link to details view at the end $l_Template = str_replace('{link_to_details}', '', $l_Template); $l_Template = str_replace('{file_title}', $files->file_title, $l_Template); } $l_Template = str_replace('{checkbox_list}', '', $l_Template); $l_Template = str_replace('{mirror_1}', '', $l_Template); $l_Template = str_replace('{mirror_2}', '', $l_Template); $l_Template = str_replace('{hits_value}', '', $l_Template); $l_Template = str_replace('{filesize_value}', '', $l_Template); } // insert rating system if ($jlistConfigM['view.ratings']) { $rating_system = JDHelper::getRatings($files->file_id, $files->rating_count, $files->rating_sum); $l_Template = str_replace('{rating}', $rating_system, $l_Template); } else { $l_Template = str_replace('{rating}', '', $l_Template); } // Build the license info data and build link if ($files->license == '') { $files->license = 0; } $lic_data = ''; if ($files->license_url != '') { $lic_data = $jdpic_license . '<a href="' . $files->license_url . '" target="_blank" rel="nofollow" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_MINI_ICON_ALT_LICENCE') . '">' . $files->license_title . '</a> ' . $jdextern_url_pic; } else { if ($files->license_title != '') { if ($files->license_text != '') { $lic_data = $jdpic_license . $files->license_title; $lic_data .= JHtml::_('tooltip', $files->license_text, $files->license_title); } else { $lic_data = $files->license_title; } } else { $lic_data = ''; } } $l_Template = str_replace('{license_text}', $lic_data, $l_Template); $l_Template = str_replace('{license}', $lic_data, $l_Template); // old placeholder // Build the 'files language' data $file_lang_values = explode(',', JDHelper::getOnlyLanguageSubstring($jlistConfigM['language.list'])); if ($jd_file_language == 0) { $jd_showlanguage = ''; } else { $jd_showlanguage = $jdpic_language . $file_lang_values[$jd_file_language]; } $l_Template = str_replace("{language}", $jd_showlanguage, $l_Template); // old placeholder $l_Template = str_replace("{language_text}", $jd_showlanguage, $l_Template); // Build the 'System' data $file_sys_values = explode(',', $jlistConfigM['system.list']); if ($jd_system == 0) { $jd_showsystem = ''; } else { $jd_showsystem = $jdpic_system . $file_sys_values[$jd_system]; } $l_Template = str_replace("{system}", $jd_showsystem, $l_Template); // old placeholder $l_Template = str_replace("{system_text}", $jd_showsystem, $l_Template); // Build hits values $numbers_downloads = JDHelper::strToNumber((int) $files->downloads); $jd_showhits = $jdpic_hits . $numbers_downloads; $l_Template = str_replace("{hits_value}", $jd_showhits, $l_Template); // Build website url if (!$files->url_home == '') { if (strpos($files->url_home, 'http://') !== false) { $l_Template = str_replace('{url_home}', $jdpic_website . '<a href="' . $files->url_home . '" target="_blank" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '</a> ' . $jdextern_url_pic, $l_Template); $l_Template = str_replace('{author_url_text} ', $jdpic_website . '<a href="' . $files->url_home . '" target="_blank" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '</a> ' . $jdextern_url_pic, $l_Template); } else { $l_Template = str_replace('{url_home}', $jdpic_website . '<a href="http://' . $files->url_home . '" target="_blank" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '</a> ' . $jdextern_url_pic, $l_Template); $l_Template = str_replace('{author_url_text}', $jdpic_website . '<a href="http://' . $files->url_home . '" target="_blank" title="' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_HOMEPAGE') . '</a> ' . $jdextern_url_pic, $l_Template); } } else { $l_Template = str_replace('{url_home}', '', $l_Template); $l_Template = str_replace('{author_url_text}', '', $l_Template); } // Encode is link a mail if (strpos($files->url_author, '@') && $jlistConfigM['mail.cloaking']) { if (!$files->author) { $mail_encode = JHtml::_('email.cloak', $files->url_author); } else { $mail_encode = JHtml::_('email.cloak', $files->url_author, true, $files->author, false); } } // Build author link if ($files->author != '') { if ($files->url_author != '') { if ($mail_encode) { $link_author = $jdpic_author . $mail_encode; } else { if (strpos($files->url_author, 'http://') !== false) { $link_author = $jdpic_author . '<a href="' . $files->url_author . '" target="_blank">' . $files->author . '</a> ' . $extern_url_pic; } else { $link_author = $jdpic_author . '<a href="http://' . $files->url_author . '" target="_blank">' . $files->author . '</a> ' . $extern_url_pic; } } $l_Template = str_replace('{author}', $link_author, $l_Template); $l_Template = str_replace('{author_text}', $link_author, $l_Template); $l_Template = str_replace('{url_author}', '', $l_Template); } else { $link_author = $jdpic_author . $files->author; $l_Template = str_replace('{author}', $link_author, $l_Template); $l_Template = str_replace('{author_text}', $link_author, $l_Template); $l_Template = str_replace('{url_author}', '', $l_Template); } } else { $l_Template = str_replace('{url_author}', $jdpic_author . $files->url_author, $l_Template); $l_Template = str_replace('{author}', '', $l_Template); $l_Template = str_replace('{author_text}', '', $l_Template); } // Place the images $l_Template = JDHelper::placeThumbs($l_Template, $files->images, 'list'); // Compute for HOT symbol if ($jlistConfigM['loads.is.file.hot'] > 0 && $files->downloads >= $jlistConfigM['loads.is.file.hot']) { // Is the old button pic used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $l_Template = str_replace('{pic_is_hot}', $hotpic, $l_Template); } else { // CSS Button is selected $l_Template = str_replace('{pic_is_hot}', '<span class="jdbutton ' . $status_color_hot . ' jstatus">' . JText::_('COM_JDOWNLOADS_HOT') . '</span>', $l_Template); } } else { $l_Template = str_replace('{pic_is_hot}', '', $l_Template); } // Compute for NEW symbol $days_diff = JDHelper::computeDateDifference(date('Y-m-d H:i:s'), $files->date_added); if ($jlistConfigM['days.is.file.new'] > 0 && $days_diff <= $jlistConfigM['days.is.file.new']) { // Is the old button used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $l_Template = str_replace('{pic_is_new}', $newpic, $l_Template); } else { // CSS Button is selected $l_Template = str_replace('{pic_is_new}', '<span class="jdbutton ' . $status_color_new . ' jstatus">' . JText::_('COM_JDOWNLOADS_NEW') . '</span>', $l_Template); } } else { $l_Template = str_replace('{pic_is_new}', '', $l_Template); } // Compute for UPDATED symbol // View it only when in the download is activated the 'updated' option if ($files->update_active) { $days_diff = JDHelper::computeDateDifference(date('Y-m-d H:i:s'), $files->modified); if ($jlistConfigM['days.is.file.updated'] > 0 && $days_diff >= 0 && $days_diff <= $jlistConfigM['days.is.file.updated']) { if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $l_Template = str_replace('{pic_is_updated}', $updatepic, $l_Template); } else { // CSS Button is selected $l_Template = str_replace('{pic_is_updated}', '<span class="jdbutton ' . $status_color_updated . ' jstatus">' . JText::_('COM_JDOWNLOADS_UPDATED') . '</span>', $l_Template); } } else { $l_Template = str_replace('{pic_is_updated}', '', $l_Template); } } else { $l_Template = str_replace('{pic_is_updated}', '', $l_Template); } // file size if (!$files->size == '') { $l_Template = str_replace('{size}', $jdpic_size . $files->size, $l_Template); $l_Template = str_replace('{filesize_value}', $jdpic_size . $files->size, $l_Template); } else { $l_Template = str_replace('{size}', '', $l_Template); $l_Template = str_replace('{filesize_value}', '', $l_Template); } // price if ($files->price != '') { $l_Template = str_replace('{price_value}', $jdpic_price . $files->price, $l_Template); } else { $l_Template = str_replace('{price_value}', '', $l_Template); } // file_date if ($files->file_date != '0000-00-00 00:00:00') { if ($files->params->get('show_date') == 0) { $filedate_data = $jdpic_date . JHtml::_('date', $files->file_date, $date_format['long']); $filedate_data_title = JText::_('COM_JDOWNLOADS_EDIT_FILE_FILE_DATE_TITLE'); } else { $filedate_data = $jdpic_date . JHtml::_('date', $files->file_date, $date_format['short']); $filedate_data_title = ''; } } else { $filedate_data = ''; $filedate_data_title = ''; } $l_Template = str_replace('{file_date}', $filedate_data, $l_Template); // date_added if ($files->date_added != '0000-00-00 00:00:00') { if ($files->params->get('show_date') == 0) { // use 'normal' date-time format field $date_data = $jdpic_date . JHtml::_('date', $files->date_added, $date_format['long']); } else { // use 'short' date-time format field $date_data = $jdpic_date . JHtml::_('date', $files->date_added, $date_format['short']); } } else { $date_data = ''; } $l_Template = str_replace('{date_added}', $date_data, $l_Template); $l_Template = str_replace('{created_date_value}', $date_data, $l_Template); if ($files->creator) { $l_Template = str_replace('{created_by_value}', $files->creator, $l_Template); } else { $l_Template = str_replace('{created_by_value}', '', $l_Template); } if ($files->modifier) { $l_Template = str_replace('{modified_by_value}', $files->modifier, $l_Template); } else { $l_Template = str_replace('{modified_by_value}', '', $l_Template); } // modified_date if ($files->modified != '0000-00-00 00:00:00') { if ($files->params->get('show_date') == 0) { $modified_data = $jdpic_date . JHtml::_('date', $files->modified, $date_format['long']); } else { $modified_data = $jdpic_date . JHtml::_('date', $files->modified, $date_format['short']); } } else { $modified_data = ''; } $l_Template = str_replace('{modified_date_value}', $modified_data, $l_Template); if ($files->release == '') { $l_Template = str_replace('{release}', '', $l_Template); } else { $l_Template = str_replace('{release}', $files->release, $l_Template); // with versions text from language file // $l_Template = str_replace('{release}', JText::_('COM_JDOWNLOADS_FRONTEND_VERSION_TITLE').$files->release, $l_Template); } // Create an additional hint for the description footer when this download has a file but user has not the download permissions if ($download_has_a_file) { if ($user->guest) { // when CSS3 buttons are activate, we use it also for the message if ($jlistConfigM['use.css.buttons.instead.icons']) { $first_reg_msg = '<div class="' . $jlistConfigM['css.button.color.download'] . ' ' . $jlistConfigM['css.button.size.download'] . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED') . '</div>'; } else { $first_reg_msg = '<div class="jdpf_not_logged_in">' . JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED') . '</div>'; } } else { // when CSS3 buttons are activate, we use it also for the message if ($jlistConfigM['use.css.buttons.instead.icons']) { $first_reg_msg = '<div class="' . $jlistConfigM['css.button.color.download'] . ' ' . $jlistConfigM['css.button.size.download'] . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED2') . '</div>'; } else { $first_reg_msg = '<div class="jdpf_not_logged_in">' . JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED2') . '</div>'; } } } else { $first_reg_msg = ''; } // Check and build the description text if ($jlistConfigM['plugin.auto.file.short.description'] && $jlistConfigM['plugin.auto.file.short.description.value'] > 0) { if (strlen($files->description) > $jlistConfigM['plugin.auto.file.short.description.value']) { // Cut description text $shorted_text = preg_replace("/[^ ]*\$/", '..', substr($files->description, 0, $jlistConfigM['plugin.auto.file.short.description.value'])); if (!$download_allowed) { //$l_Template = str_replace('{description}', $shorted_text.$first_reg_msg, $l_Template); $l_Template = str_replace('{description}', $shorted_text, $l_Template); } else { $l_Template = str_replace('{description}', $shorted_text, $l_Template); } } else { if (!$download_allowed) { // $l_Template = str_replace('{description}', $files->description.$first_reg_msg, $l_Template); $l_Template = str_replace('{description}', $files->description, $l_Template); } else { $l_Template = str_replace('{description}', $files->description, $l_Template); } } } else { if (!$download_allowed) { //$l_Template = str_replace("{description}",$files->description.$first_reg_msg, $l_Template); $l_Template = str_replace("{description}", $files->description, $l_Template); } else { $l_Template = str_replace("{description}", $files->description, $l_Template); } } // create filename if ($files->url_download) { $l_Template = str_replace('{file_name}', JDHelper::getShorterFilename($files->url_download), $l_Template); } elseif (isset($files->filename_from_other_download) && $files->filename_from_other_download != '') { $l_Template = str_replace('{file_name}', JDHelper::getShorterFilename($files->filename_from_other_download), $l_Template); } else { $l_Template = str_replace('{file_name}', '', $l_Template); } // google adsense if ($jlistConfigM['google.adsense.active']) { $l_Template = str_replace('{google_adsense}', stripslashes($jlistConfigM['google.adsense.code']), $l_Template); } else { $l_Template = str_replace('{google_adsense}', '', $l_Template); } // report download link if ($jd_user_settings->view_report_form) { $report_link = '<a href="' . JRoute::_("index.php?option=com_jdownloads&view=report&id=" . $files->slug . "&catid=" . $files->cat_id . "&Itemid=" . $root_itemid) . '" rel="nofollow">' . JText::_('COM_JDOWNLOADS_FRONTEND_REPORT_FILE_LINK_TEXT') . '</a>'; $l_Template = str_replace('{report_link}', $report_link, $l_Template); } else { $l_Template = str_replace('{report_link}', '', $l_Template); } // media player if ($files->preview_filename) { // we use the preview file when exist $is_preview = true; $files->itemtype = JDHelper::getFileExtension($files->preview_filename); $is_playable = JDHelper::isPlayable($files->preview_filename); $extern_media = false; } else { $is_preview = false; if ($files->extern_file) { $extern_media = true; $files->itemtype = JDHelper::getFileExtension($files->extern_file); $is_playable = JDHelper::isPlayable($files->extern_file); } else { $files->itemtype = JDHelper::getFileExtension($files->url_download); $is_playable = JDHelper::isPlayable($files->url_download); $extern_media = false; } } if (!$jlistConfigM['flowplayer.use'] && $files->itemtype == 'mp3') { // we use only the 'OLD' mp3 player if ($extern_media) { $mp3_path = $files->extern_file; } else { if ($is_preview) { // we need the path to the "previews" folder $mp3_path = JUri::base() . basename($jlistConfigM['files.uploaddir']) . '/' . $jlistConfigM['preview.files.folder.name'] . '/' . $files->preview_filename; } else { // we use the normal download file for the player $mp3_path = JUri::base() . basename($jlistConfigM['files.uploaddir']) . '/' . $category_dir . '/' . $files->url_download; } } $mp3_config = trim($jlistConfigM['mp3.player.config']); $mp3_config = str_replace('', '', $mp3_config); $mp3_config = str_replace(';', '&', $mp3_config); $mp3_player = '<object type="application/x-shockwave-flash" data="components/com_jdownloads/assets/mp3_player_maxi.swf" width="200" height="20"> <param name="movie" value="components/com_jdownloads/assets/mp3_player_maxi.swf" /> <param name="wmode" value="transparent"/> <param name="FlashVars" value="mp3=' . $mp3_path . '&' . $mp3_config . '" /> </object>'; $l_Template = str_replace('{mp3_player}', $mp3_player, $l_Template); } if ($jlistConfigM['flowplayer.use'] && $is_playable) { // we will use the new flowplayer option if ($extern_media) { $media_path = $files->extern_file; } else { if ($is_preview) { // we need the relative path to the "previews" folder $media_path = basename($jlistConfigM['files.uploaddir']) . '/' . $jlistConfigM['preview.files.folder.name'] . '/' . $files->preview_filename; } else { // we use the normal download file for the player $media_path = basename($jlistConfigM['files.uploaddir']) . '/' . $category_dir . '/' . $files->url_download; } } $ipadcode = ''; if ($files->itemtype == 'mp3') { $fullscreen = 'false'; $autohide = 'false'; $playerheight = (int) $jlistConfigM['flowplayer.playerheight.audio']; // we must use also the ipad plugin identifier when required // see http://flowplayer.blacktrash.org/test/ipad-audio.html and http://flash.flowplayer.org/plugins/javascript/ipad.html if ($ipad_user) { $ipadcode = '.ipad();'; } } else { $fullscreen = 'true'; $autohide = 'true'; $playerheight = (int) $jlistConfigM['flowplayer.playerheight']; } $player = '<a href="' . $media_path . '" style="display:block;width:' . $jlistConfigM['flowplayer.playerwidth'] . 'px; height:' . $playerheight . 'px;" class="player" id="player' . $files->file_id . '"></a>'; $player .= '<script language="JavaScript"> // install flowplayer into container flowplayer("player' . $files->file_id . '", "' . JURI::base() . 'components/com_jdownloads/assets/flowplayer/flowplayer-3.2.16.swf", { plugins: { controls: { // insert at first the config settings ' . $jlistConfigM['flowplayer.control.settings'] . ' // and now the basics fullscreen: ' . $fullscreen . ', height: ' . (int) $jlistConfigM['flowplayer.playerheight.audio'] . ', autoHide: ' . $autohide . ', } }, clip: { autoPlay: false, // optional: when playback starts close the first audio playback onBeforeBegin: function() { $f("player' . $files->file_id . '").close(); } } })' . $ipadcode . '; </script>'; // the 'ipad code' above is only required for ipad/iphone users // We will replace at first the old placeholder when exist if (strpos($l_Template, '{mp3_player}')) { $l_Template = str_replace('{mp3_player}', $player, $l_Template); } else { $l_Template = str_replace('{preview_player}', $player, $l_Template); } } if ($jlistConfigM['mp3.view.id3.info'] && $files->itemtype == 'mp3' && !$extern_media) { // read mp3 infos if ($is_preview) { // get the path to the preview file $mp3_path_abs = $jlistConfigM['files.uploaddir'] . '/' . $jlistConfigM['preview.files.folder.name'] . '/' . $files->preview_filename; } else { // get the path to the downloads file $mp3_path_abs = $jlistConfigM['files.uploaddir'] . '/' . $category_dir . '/' . $files->url_download; } $info = JDHelper::getID3v2Tags($mp3_path_abs); if ($info) { // add it $mp3_info = stripslashes($jlistConfigM['mp3.info.layout']); $mp3_info = str_replace('{name_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_TITLE'), $mp3_info); if ($is_preview) { $mp3_info = str_replace('{name}', $files->preview_filename, $mp3_info); } else { $mp3_info = str_replace('{name}', $files->url_download, $mp3_info); } $mp3_info = str_replace('{album_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_ALBUM'), $mp3_info); if (isset($info['TALB'])) { $mp3_info = str_replace('{album}', $info['TALB'], $mp3_info); } else { $mp3_info = str_replace('{album}', '', $mp3_info); } $mp3_info = str_replace('{artist_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_ARTIST'), $mp3_info); if (isset($info['TPE1'])) { $mp3_info = str_replace('{artist}', $info['TPE1'], $mp3_info); } else { $mp3_info = str_replace('{artist}', '', $mp3_info); } $mp3_info = str_replace('{genre_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_GENRE'), $mp3_info); if (isset($info['TCON'])) { $mp3_info = str_replace('{genre}', $info['TCON'], $mp3_info); } else { $mp3_info = str_replace('{genre}', '', $mp3_info); } $mp3_info = str_replace('{year_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_YEAR'), $mp3_info); if (isset($info['TYER'])) { $mp3_info = str_replace('{year}', $info['TYER'], $mp3_info); } else { $mp3_info = str_replace('{year}', '', $mp3_info); } $mp3_info = str_replace('{length_title}', JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_LENGTH'), $mp3_info); if (isset($info['TLEN'])) { $mp3_info = str_replace('{length}', $info['TLEN'] . ' ' . JText::_('COM_JDOWNLOADS_FE_VIEW_ID3_MINS'), $mp3_info); } else { $mp3_info = str_replace('{length}', '', $mp3_info); } $l_Template = str_replace('{mp3_id3_tag}', $mp3_info, $l_Template); } } // replace the {preview_url} if ($files->preview_filename) { // we need the relative path to the "previews" folder $media_path = basename($jlistConfigM['files.uploaddir']) . '/' . $jlistConfigM['preview.files.folder.name'] . '/' . $files->preview_filename; $l_Template = str_replace('{preview_url}', $media_path, $l_Template); } else { $l_Template = str_replace('{preview_url}', '', $l_Template); } $user_can_see_download_url = false; // only view download link when user has correct access level if ($files->params->get('access-download') == true) { $user_can_see_download_url = true; $blank_window = ''; $blank_window1 = ''; $blank_window2 = ''; // get file extension $view_types = array(); $view_types = explode(',', $jlistConfigM['file.types.view']); $only_file_name = basename($files->url_download); $filesextension = JDHelper::getFileExtension($only_file_name); if (in_array($filesextension, $view_types)) { $blank_window = 'target="_blank"'; } // check is set link to a new window? if ($files->extern_file && $files->extern_site) { $blank_window = 'target="_blank"'; } // is 'direct download' activated? if ($jlistConfigM['direct.download'] == '0') { // when not, we must link to the summary page $url_task = 'summary'; $blank_window = ''; $download_link = JRoute::_(JDownloadsHelperRoute::getOtherRoute($files->slug, $files->cat_id, $files->language, $url_task)); } else { if ($files->license_agree || $files->password || $jd_user_settings->view_captcha) { // user must agree the license - fill out a password field - or fill out the captcha human check - so we must view the summary page! $url_task = 'summary'; $download_link = JRoute::_(JDownloadsHelperRoute::getOtherRoute($files->slug, $files->cat_id, $files->language, $url_task)); } else { // start the download promptly $url_task = 'download.send'; $download_link = JRoute::_('index.php?option=com_jdownloads&task=download.send&id=' . $files->file_id . '&catid=' . $files->cat_id . '&m=0'); } } if ($url_task == 'download.send') { // is the old button used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $download_link_text = '<a ' . $blank_window . ' href="' . $download_link . '" class="jd_download_url"><img src="' . JURI::base() . 'images/jdownloads/downloadimages/' . $jlistConfigM['download.pic.details'] . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" /></a>'; } else { // we use the new css button $download_link_text = '<a ' . $blank_window . ' href="' . $download_link . '" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jdbutton ' . $download_color . ' ' . $download_size_listings . '">' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '</a>'; } } else { // is the old button used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $download_link_text = '<a href="' . $download_link . '" class="jd_download_url"><img src="' . JURI::base() . 'images/jdownloads/downloadimages/' . $jlistConfigM['download.pic.details'] . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" title="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" /></a>'; } else { // we use the new css button $download_link_text = '<a ' . $blank_window . ' href="' . $download_link . '" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jdbutton ' . $download_color . ' ' . $download_size_listings . '">' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '</a>'; } } if (strpos($l_Template, '{url_download}')) { $l_Template = str_replace('{url_download}', $download_link_text, $l_Template); } else { $l_Template = str_replace('{checkbox_list}', $download_link_text, $l_Template); } // mirrors if ($files->mirror_1) { if ($files->extern_site_mirror_1 && $url_task == 'download.send') { $blank_window1 = 'target="_blank"'; } $mirror1_link_dum = JRoute::_('index.php?option=com_jdownloads&task=download.send&id=' . $files->file_id . '&catid=' . $files->cat_id . '&m=1'); //$mirror1_link_dum = JRoute::_(JDownloadsHelperRoute::getOtherRoute($files->slug, $files->cat_id, $files->language, $url_task, 1)); // is the old button used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $mirror1_link = '<a ' . $blank_window1 . ' href="' . $mirror1_link_dum . '" class="jd_download_url"><img src="' . JURI::base() . 'images/jdownloads/downloadimages/' . $jlistConfigM['download.pic.mirror_1'] . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MIRROR_URL_TITLE_1') . '" /></a>'; } else { // we use the new css button $mirror1_link = '<a ' . $blank_window1 . ' href="' . $mirror1_link_dum . '" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jdbutton ' . $download_color_mirror1 . ' ' . $download_size_mirror . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_MIRROR_URL_TITLE_1') . '</a>'; } $l_Template = str_replace('{mirror_1}', $mirror1_link, $l_Template); } else { $l_Template = str_replace('{mirror_1}', '', $l_Template); } if ($files->mirror_2) { if ($files->extern_site_mirror_2 && $url_task == 'download.send') { $blank_window2 = 'target="_blank"'; } $mirror2_link_dum = JRoute::_('index.php?option=com_jdownloads&task=download.send&id=' . $files->file_id . '&catid=' . $files->cat_id . '&m=2'); //$mirror2_link_dum = JRoute::_(JDownloadsHelperRoute::getOtherRoute($files->slug, $files->cat_id, $files->language, $url_task, 2)); // is the old button used? if ($jlistConfigM['use.css.buttons.instead.icons'] == '0') { $mirror2_link = '<a ' . $blank_window2 . ' href="' . $mirror2_link_dum . '" class="jd_download_url"><img src="' . JURI::base() . 'images/jdownloads/downloadimages/' . $jlistConfigM['download.pic.mirror_2'] . '" border="0" alt="' . JText::_('COM_JDOWNLOADS_FRONTEND_MIRROR_URL_TITLE_2') . '" /></a>'; } else { // we use the new css button $mirror2_link = '<a ' . $blank_window2 . ' href="' . $mirror2_link_dum . '" alt="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jdbutton ' . $download_color_mirror2 . ' ' . $download_size_mirror . '">' . JText::_('COM_JDOWNLOADS_FRONTEND_MIRROR_URL_TITLE_2') . '</a>'; } $l_Template = str_replace('{mirror_2}', $mirror2_link, $l_Template); } else { $l_Template = str_replace('{mirror_2}', '', $l_Template); } } else { // visitor has not access to download this item - so we will inform him if (strpos($l_Template, '{url_download}')) { $l_Template = str_replace('{url_download}', $first_reg_msg, $l_Template); } else { $l_Template = str_replace('{checkbox_list}', $first_reg_msg, $l_Template); } $l_Template = str_replace('{mirror_1}', '', $l_Template); $l_Template = str_replace('{mirror_2}', '', $l_Template); } if ($jlistConfigM['view.detailsite']) { $title_link = JRoute::_(JDownloadsHelperRoute::getDownloadRoute($files->slug, $files->cat_id, $files->language)); $title_link_text = '<a href="' . $title_link . '">' . $db->escape($files->file_title) . '</a>'; $detail_link_text = '<a href="' . $title_link . '">' . JText::_('COM_JDOWNLOADS_FE_DETAILS_LINK_TEXT_TO_DETAILS') . '</a>'; // Build the file symbol (with link) if ($files->file_pic != '') { $filepic = '<a href="' . $title_link . '">' . '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" /></a> '; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); // link to details view at the end $l_Template = str_replace('{link_to_details}', $detail_link_text, $l_Template); $l_Template = str_replace('{file_title}', $title_link_text, $l_Template); } elseif ($jlistConfigM['use.download.title.as.download.link']) { if ($user_can_see_download_url) { // build title link as download link if ($url_task == 'download.send') { $download_link_text = '<a ' . $blank_window . ' href="' . $download_link . '" title="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '" class="jd_download_url">' . $files->file_title . '</a>'; } else { $download_link_text = '<a href="' . $download_link . '" title="' . JText::_('COM_JDOWNLOADS_LINKTEXT_DOWNLOAD_URL') . '">' . $files->file_title . '</a>'; } // View file icon also with link if ($files->file_pic != '') { $filepic = '<a href="' . $download_link . '"><img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" /></a>'; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); $l_Template = str_replace('{link_to_details}', '', $l_Template); $l_Template = str_replace('{file_title}', $download_link_text, $l_Template); } else { // user may not use download link $l_Template = str_replace('{file_title}', $files->file_title, $l_Template); if ($files->file_pic != '') { $filepic = '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" />'; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); } } else { // no links if ($files->file_pic != '') { $filepic = '<img src="' . JURI::base() . 'images/jdownloads/fileimages/' . $files->file_pic . '" align="top" width="' . $jlistConfigM['file.pic.size'] . '" height="' . $jlistConfigM['file.pic.size.height'] . '" border="0" alt="" />'; } else { $filepic = ''; } $l_Template = str_replace('{file_pic}', $filepic, $l_Template); // remove link to details view at the end $l_Template = str_replace('{link_to_details}', '', $l_Template); $l_Template = str_replace('{file_title}', $files->file_title, $l_Template); } $l_Template = str_replace('{file_title_only}', $files->file_title, $l_Template); $l_Template = str_replace('{checkbox_list}', '', $l_Template); $l_Template = str_replace('{file_id}', $files->file_id, $l_Template); $l_Template = str_replace('{ordering}', $files->ordering, $l_Template); $l_Template = str_replace('{published}', $files->published, $l_Template); $l_Template = str_replace('{cat_id}', $files->cat_id, $l_Template); $l_Template = str_replace('{rank}', $jDFPrank, $l_Template); $l_Template = str_replace('{mp3_player}', '', $l_Template); $l_Template = str_replace('{mp3_id3_tag}', '', $l_Template); $l_Template = str_replace('{preview_player}', '', $l_Template); $l_Template = str_replace('{report_link}', '', $l_Template); $l_Template = str_replace('{sum_jcomments}', '', $l_Template); $l_Template = str_replace('{rating}', '', $l_Template); // custom fields $custom_fields_arr = existsCustomFieldsTitlesPlg(); $row_custom_values = array('dummy', $files->custom_field_1, $files->custom_field_2, $files->custom_field_3, $files->custom_field_4, $files->custom_field_5, $files->custom_field_6, $files->custom_field_7, $files->custom_field_8, $files->custom_field_9, $files->custom_field_10, $files->custom_field_11, $files->custom_field_12, $files->custom_field_13, $files->custom_field_14); for ($x = 1; $x < 15; $x++) { // replace placeholder with title and value if (in_array($x, $custom_fields_arr[0]) && $row_custom_values[$x] && $row_custom_values[$x] != '0000-00-00') { $l_Template = str_replace("{custom_title_{$x}}", $custom_fields_arr[1][$x - 1], $l_Template); if ($x > 5) { $l_Template = str_replace("{custom_value_{$x}}", stripslashes($row_custom_values[$x]), $l_Template); } else { $l_Template = str_replace("{custom_value_{$x}}", $custom_fields_arr[2][$x - 1][$row_custom_values[$x]], $l_Template); } } else { // remove placeholder if ($jlistConfigM['remove.field.title.when.empty']) { $l_Template = str_replace("{custom_title_{$x}}", '', $l_Template); } else { $l_Template = str_replace("{custom_title_{$x}}", $custom_fields_arr[1][$x - 1], $l_Template); } $l_Template = str_replace("{custom_value_{$x}}", '', $l_Template); } } // insert files title area if (!$jDLayoutTitleExists) { $l_Template = str_replace('{files_title_begin}', '', $l_Template); $l_Template = str_replace('{files_title_end}', '', $l_Template); $l_Template = str_replace('{files_title_text}', JText::_('COM_JDOWNLOADS_FE_FILELIST_TITLE_OVER_FILES_LIST'), $l_Template); $jDLayoutTitleExists = true; } else { if (strpos($l_Template, "{files_title_end}") > 0) { $pos_end = strpos($l_Template, '{files_title_end}'); $pos_beg = strpos($l_Template, '{files_title_begin}'); $l_Template = substr_replace($l_Template, '', $pos_beg, $pos_end - $pos_beg + 17); } } // support for other content plugins // $l_Template = JHTML::_('content.prepare', $l_Template); // remove empty html tags if ($jlistConfigM['remove.empty.tags']) { $l_Template = JDHelper::removeEmptyTags($l_Template); } return str_replace("[[[", "{", $l_Template); }
$body = str_replace('{language_text}', $this->item_lang_values[$this->item->file_language], $body); } // media player if ($this->item->preview_filename) { // we use the preview file when exist $is_preview = true; $this->itemtype = JDHelper::getFileExtension($this->item->preview_filename); $is_playable = JDHelper::isPlayable($this->item->preview_filename); } else { $is_preview = false; if ($this->item->extern_file) { $extern_media = true; $this->itemtype = JDHelper::getFileExtension($this->item->extern_file); $is_playable = JDHelper::isPlayable($this->item->extern_file); } else { $this->itemtype = JDHelper::getFileExtension($this->item->url_download); $is_playable = JDHelper::isPlayable($this->item->url_download); $extern_media = false; } } if (!$jlistConfig['flowplayer.use'] && $this->itemtype == 'mp3') { // we use only the 'OLD' mp3 player if ($extern_media) { $mp3_path = $this->item->extern_file; } else { if ($is_preview) { // we need the path to the "previews" folder $mp3_path = JUri::base() . $jdownloads_root_dir_name . '/' . $jlistConfig['preview.files.folder.name'] . '/' . $this->item->preview_filename; } else { // we use the normal download file for the player $mp3_path = JUri::base() . $jdownloads_root_dir_name . '/' . $category_dir . '/' . $this->item->url_download;
} } else { $modified_data = ''; } $html_file = str_replace('{modified_date_value}', $modified_data, $html_file); // only view download-url when user has correct access level if ($files[$i]->params->get('access-download') == true) { $user_can_see_download_url++; $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 = JDHelper::getFileExtension($only_file_name); 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 without summary page? if ($jlistConfig['direct.download'] == '0') { $url_task = 'summary'; $download_link = JRoute::_(JDownloadsHelperRoute::getOtherRoute($files[$i]->slug, $files[$i]->cat_id, $files[$i]->language, $url_task)); } else { if ($files[$i]->license_agree || $files[$i]->password || $jd_user_settings->view_captcha) { // user must agree the license - fill out a password field - or fill out the captcha human check - so we must view the summary page! $url_task = 'summary';
/** * Method to submit the downloads file to the browser. * * * @return null */ public function send() { global $jlistConfig; jimport('joomla.environment.uri'); $jinput = JFactory::getApplication()->input; $app = JFactory::getApplication(); $params = $app->getParams(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $db = JFactory::getDBO(); $config = array('ignore_request' => true); $model = $this->getModel('send', 'jdownloadsModel', $config); $user_rules = JDHelper::getUserRules(); clearstatcache(); $active = $app->getMenu()->getActive(); if ($active) { $current_link = $active->link; } else { $current_link = JRoute::_(JUri::current() . '?option=com_jdownloads'); } // abort when downloads are offline if ($jlistConfig['offline']) { $msg = JDHelper::getOnlyLanguageSubstring($jlistConfig['offline.text']); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } $allow = false; $extern = false; $extern_site = false; $can_download = false; $aup_exist = false; $profile = ''; // Which file types shall be viewed in browser $view_types = array(); $view_types = explode(',', $jlistConfig['file.types.view']); // get request data $cat_id = $db->escape($jinput->get('catid', 0, 'int')); $file_id = $db->escape($jinput->get('id', 0, 'int')); $mirror = $db->escape($jinput->get('m', 0, 'int')); $files_list = $db->escape($jinput->get('list', '', 'string')); $zip_file = $db->escape($jinput->get('user', 0, 'cmd')); // get session data $stored_random_id = (int) JDHelper::getSessionDecoded('jd_random_id'); $stored_file_id = (int) JDHelper::getSessionDecoded('jd_fileid'); $stored_cat_id = (int) JDHelper::getSessionDecoded('jd_catid'); $stored_files_list = JDHelper::getSessionDecoded('jd_list'); // compare and check it if ($cat_id > 0 && $cat_id != $stored_cat_id || $file_id > 0 && $file_id != $stored_file_id || $zip_file > 0 && $zip_file != $stored_random_id || $files_list != '' && $files_list != $stored_files_list) { // perhaps use it a direct download option $this->items = $model->getItems($file_id); if ($this->items) { $this->state = $model->getState(); $sum_selected_files = $this->state->get('sum_selected_files'); $sum_selected_volume = $this->state->get('sum_selected_volume'); $sum_files_prices = $this->state->get('sum_files_prices'); $must_confirm_license = $this->state->get('must_confirm_license'); $directlink = $this->state->get('directlink_used'); $marked_files_id = $this->state->get('download.marked_files.id'); // check the permission access for direct download option $within_the_user_limits = JDHelper::checkDirectDownloadLimits($cat_id, $file_id, $files_list, $user_rules, $sum_selected_files, $sum_selected_volume); if ($within_the_user_limits !== true) { // user has his limits reached or not enough points $msg = JText::_($within_the_user_limits); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } } else { // invalid data found / url manipulations? $msg = JText::_('COM_JDOWNLOADS_INVALID_DOWNLOAD_DATA_MSG'); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } } // check leeching if ($is_leeching = JDHelper::useAntiLeeching()) { // download stopped - view hint $msg = JText::_('COM_JDOWNLOADS_ANTILEECH_MSG') . ' ' . JText::_('COM_JDOWNLOADS_ANTILEECH_MSG2'); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } if ($zip_file) { // user has selected more as a single file $zip_file = $jlistConfig['zipfile.prefix'] . $zip_file . '.zip'; $filename = $jlistConfig['files.uploaddir'] . '/' . $jlistConfig['tempzipfiles.folder.name'] . '/' . $zip_file; if (!file_exists($filename)) { // download stopped - zip file not found $msg = JText::_('COM_JDOWNLOADS_FILE_NOT_FOUND') . ': ' . basename($zip_file); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } } // download action check (not for uncategorized) if ($cat_id > 1) { // If the category has been passed in the data or URL check it. $allow = $user->authorise('download', 'com_jdownloads.category.' . $cat_id); if ($file_id && $allow) { // If the category has been passed in the data or URL check it. $allow = $user->authorise('download', 'com_jdownloads.download.' . $file_id); } } else { if ($file_id) { // If the category has been passed in the data or URL check it. $allow = $user->authorise('download', 'com_jdownloads.download.' . $file_id); } } if (!$allow) { // download stopped - user has not the right to download it $msg = JText::_('COM_JDOWNLOADS_DOWNLOAD_NOT_ALLOWED_MSG'); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } $transfer_speed = (int) $user_rules->transfer_speed_limit_kb; if ($jlistConfig['use.alphauserpoints']) { // get AUP user info $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php'; if (file_exists($api_AUP) && !$user->guest) { require_once $api_AUP; $aup_exist = true; // get user profile data from AUP $profile = AlphaUserPointsHelper::getUserInfo('', $user->id); // get standard points value from AUP $db->setQuery("SELECT points FROM #__alpha_userpoints_rules WHERE published = 1 AND plugin_function = 'plgaup_jdownloads_user_download'"); $aup_fix_points = floatval($db->loadResult()); //$aup_fix_points = JDHelper::strToNumber($aup_fix_points); } } // build a array with IDs $files_arr = explode(',', $files_list); // get the files data for multi or single download $query = $db->getQuery(true); $query->select('a.*'); $query->from('#__jdownloads_files AS a'); // Join on category table. $query->select('c.title AS category_title, c.id AS category_id, c.cat_dir AS category_cat_dir, c.cat_dir_parent AS category_cat_dir_parent'); $query->join('LEFT', '#__jdownloads_categories AS c on c.id = a.cat_id'); // Join on license table. $query->select('l.title AS license_title'); $query->join('LEFT', '#__jdownloads_licenses AS l on l.id = a.license'); $query->where('(a.published = ' . $db->Quote('1') . ')'); if ($files_list) { $query->where('a.file_id IN (' . $files_list . ')'); } else { $query->where('a.file_id = ' . $db->Quote($file_id)); } // Filter by access level so when we get not a result this user has not the access to view it $query->where('a.access IN (' . $groups . ')'); $query->where('c.access IN (' . $groups . ')'); $db->setQuery($query); $files = $db->loadObjectList(); if (!$files) { // invalid data or user has not really the access $msg = JText::_('COM_JDOWNLOADS_DATA_NOT_FOUND'); $app->redirect(JRoute::_($current_link), $msg, 'error'); } // When we have a regged user, we must check whether he downloads the file in parts. // If so, we may only once write the download data in log and compute the AUP etc. $download_in_parts = JDHelper::getLastDownloadActivity($user->id, $files_list, $file_id, $user_rules->download_limit_after_this_time); if (count($files) > 1) { // mass download if (!$download_in_parts) { // add AUP points if ($jlistConfig['use.alphauserpoints'] && $aup_exist) { if ($jlistConfig['use.alphauserpoints.with.price.field']) { $db->setQuery("SELECT SUM(price) FROM #__jdownloads_files WHERE file_id IN ({$files_list})"); $sum_points = (int) $db->loadResult(); if ($profile->points >= $sum_points) { foreach ($files as $aup_data) { $db->setQuery("SELECT price FROM #__jdownloads_files WHERE file_id = '{$aup_data->file_id}'"); if ($price = floatval($db->loadResult())) { $can_download = JDHelper::setAUPPointsDownloads($user->id, $aup_data->file_title, $aup_data->file_id, $price, $profile); } } } } else { // use fix points $sum_points = $aup_fix_points * count($files_arr); if ($profile->points >= $sum_points) { foreach ($files as $aup_data) { $can_download = JDHelper::setAUPPointsDownloads($user->id, $aup_data->file_title, $aup_data->file_id, 0, $profile); } } else { $can_download = false; } } } else { // no AUP active $can_download = true; } if ($jlistConfig['user.can.download.file.when.zero.points'] && !$user->guest) { $can_download = true; } } else { $can_download = true; } } else { // single download // we must be ensure that the user cannot skiped special options or settings // check at first the password option if ($files[0]->password_md5 != '') { // captcha is activated for this user $session_result = (int) JDHelper::getSessionDecoded('jd_password_run'); if ($session_result < 2) { // Abort !!! $msg = JText::_('COM_JDOWNLOADS_ANTILEECH_MSG'); $app->redirect(JRoute::_($current_link), $msg, 'error'); } else { JDHelper::writeSessionEncoded('0', 'jd_password_run'); } } else { // when is not use a password, we must check captcha if ($user_rules->view_captcha) { // captcha is activated for this user $session_result = (int) JDHelper::getSessionDecoded('jd_captcha_run'); if ($session_result < 2) { // Abort !!! $msg = JText::_('COM_JDOWNLOADS_ANTILEECH_MSG'); $app->redirect(JRoute::_($current_link), $msg, 'error'); } else { JDHelper::writeSessionEncoded('0', 'jd_captcha_run'); } } } if (!$mirror) { if ($files[0]->url_download) { // build the complete category path if ($files[0]->cat_id > 1) { // Download has a category if ($files[0]->category_cat_dir_parent != '') { $cat_dir = $files[0]->category_cat_dir_parent . '/' . $files[0]->category_cat_dir; } else { $cat_dir = $files[0]->category_cat_dir; } $filename = $jlistConfig['files.uploaddir'] . '/' . $cat_dir . '/' . $files[0]->url_download; $filename_direct = $jlistConfig['files.uploaddir'] . '/' . $cat_dir . '/' . $files[0]->url_download; } else { // Download is 'uncategorized' $filename = $jlistConfig['files.uploaddir'] . '/' . $jlistConfig['uncategorised.files.folder.name'] . '/' . $files[0]->url_download; } } elseif ($files[0]->other_file_id) { // A file from another Download was assigned $query = $db->getQuery(true); $query->select('a.*'); $query->from('#__jdownloads_files AS a'); // Join on category table. $query->select('c.id AS category_id, c.cat_dir AS category_cat_dir, c.cat_dir_parent AS category_cat_dir_parent'); $query->join('LEFT', '#__jdownloads_categories AS c on c.id = a.cat_id'); $query->where('a.published = ' . $db->Quote('1')); $query->where('a.file_id = ' . $db->Quote($files[0]->other_file_id)); $query->where('a.access IN (' . $groups . ')'); $db->setQuery($query); $other_file_data = $db->loadObject(); if ($other_file_data->cat_id > 1) { // the assigned Download has a category if ($other_file_data->category_cat_dir_parent != '') { $cat_dir = $other_file_data->category_cat_dir_parent . '/' . $other_file_data->category_cat_dir; } else { $cat_dir = $other_file_data->category_cat_dir; } $filename = $jlistConfig['files.uploaddir'] . '/' . $cat_dir . '/' . $other_file_data->url_download; $filename_direct = $jlistConfig['files.uploaddir'] . '/' . $cat_dir . '/' . $other_file_data->url_download; } else { // Download is 'uncategorized' $filename = $jlistConfig['files.uploaddir'] . '/' . $jlistConfig['uncategorised.files.folder.name'] . '/' . $other_file_data->url_download; } } else { $filename = $files[0]->extern_file; if ($files[0]->extern_site) { $extern_site = true; } $extern = true; } } else { // is mirror if ($mirror == 1) { $filename = $files[0]->mirror_1; if ($files[0]->extern_site_mirror_1) { $extern_site = true; } } else { $filename = $files[0]->mirror_2; if ($files[0]->extern_site_mirror_2) { $extern_site = true; } } $extern = true; } $price = ''; // Is AUP rule or price option used - we need the price for it if ($aup_exist) { if ($jlistConfig['use.alphauserpoints.with.price.field']) { $price = floatval($files[0]->price); } else { $price = $aup_fix_points; } } if (!$download_in_parts) { $can_download = JDHelper::setAUPPointsDownload($user->id, $files[0]->file_title, $files[0]->file_id, $price, $profile); if ($jlistConfig['user.can.download.file.when.zero.points'] && $user->id) { $can_download = true; } } else { $can_download = true; } } // plugin support // load external plugins $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('jdownloads'); $results = $dispatcher->trigger('onBeforeDownloadIsSendJD', array(&$files, &$can_download, $user_rules, $download_in_parts)); if (!$can_download) { $msg = JText::_('COM_JDOWNLOADS_BACKEND_SET_AUP_FE_MESSAGE_NO_DOWNLOAD'); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } else { // run download if (!$download_in_parts) { // send at first e-mail if ($jlistConfig['send.mailto.option'] == '1' && $files) { JDHelper::sendMailDownload($files); } // give uploader AUP points when is set on if ($jlistConfig['use.alphauserpoints']) { if ($jlistConfig['use.alphauserpoints.with.price.field']) { JDHelper::setAUPPointsDownloaderToUploaderPrice($files); } else { JDHelper::setAUPPointsDownloaderToUploader($files); } } // write data in log if ($jlistConfig['activate.download.log']) { JDHelper::updateLog($type = 1, $files, ''); } // update downloads hits if (count($files) > 1) { $db->setQuery('UPDATE #__jdownloads_files SET downloads=downloads+1 WHERE file_id IN (' . $files_list . ')'); $db->execute(); } else { $db->setQuery("UPDATE #__jdownloads_files SET downloads=downloads+1 WHERE file_id = '" . $files[0]->file_id . "'"); $db->execute(); } } // get filesize if (!$extern) { if (!file_exists($filename)) { $msg = JText::_('COM_JDOWNLOADS_FILE_NOT_FOUND') . ': ' . basename($filename); $app->redirect(JRoute::_($current_link), $msg, 'notice'); } else { $size = filesize($filename); } } else { $size = JDHelper::getUrlFilesize($filename); } // if url go to other website - open it in a new browser window if ($extern_site) { echo "<script>document.location.href='{$filename}';</script>\n"; exit; } // if set the option for direct link to the file if (!$jlistConfig['use.php.script.for.download']) { $root = str_replace('\\', '/', $_SERVER["DOCUMENT_ROOT"]); $root = rtrim($root, "/"); $host = $_SERVER["HTTP_HOST"] . '/'; $filename_direct = str_replace($root, $host, $filename_direct); $filename_direct = str_replace('//', '/', $filename_direct); if (strpos('http://', $filename_direct) === false && strpos('https://', $filename_direct) === false && strpos('ftp://', $filename_direct) === false) { $filename_direct = 'http://' . $filename_direct; } $app->redirect($filename_direct); } else { $only_filename = basename($filename); $extension = JDHelper::getFileExtension($only_filename); if ($extern) { $mime_type = JDHelper::getMimeTypeRemote($filename); } else { $mime_type = JDHelper::getMimeTyp($extension); } // Check for protocol and set the appropriate headers $use_ssl = false; $uri = JUri::getInstance(JUri::current()); $protocol = $uri->getScheme(); if ($protocol == 'https') { $use_ssl = true; } $open_in_browser = false; if (in_array($extension, $view_types)) { // view file in browser $open_in_browser = true; } clearstatcache(); if ($extern) { 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: " . $mime_type); header("Content-Length: " . (string) $size); if (!$open_in_browser) { header('Content-Disposition: attachment; filename="' . $only_filename . '"'); } else { // view file in browser header('Content-Disposition: inline; filename="' . $only_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=" . $current_link); } // set_time_limit doesn't work in safe mode if (!ini_get('safe_mode')) { @set_time_limit(0); } @readfile($filename); flush(); exit; } else { $download_class_file = JPATH_SITE . DS . 'components' . DS . 'com_jdownloads' . DS . 'helpers' . DS . 'downloader.php'; if (file_exists($download_class_file)) { require_once $download_class_file; $object = new downloader(); $object->set_byfile($filename); // Type: Download from a file $object->set_filename($only_filename); // Set the file basename $object->set_filesize($size); // Set the file basename $object->set_mime($mime_type); // Set the mime type $object->set_speed($transfer_speed); // Set download speed $object->set_refresh($current_link, (int) $jlistConfig['redirect.after.download']); // // redirect to category when it is set the time in configuration $object->use_resume = true; // Set the value for using Resume Mode $object->use_ssl = $use_ssl; // Set support for SSL $object->open_in_browser = $open_in_browser; // Set whether the file shall be opened in browser window $object->use_autoexit = true; // Set the value for auto exit ('false' worked not really with extern file?) $object->download(); // Run the download flush(); exit; } else { $msg = JText::_('COM_JDOWNLOADS_FILE_NOT_FOUND') . ': ' . $filename; $app->redirect(JRoute::_($current_link), $msg, 'notice'); } } } } }