|
From: <luc...@us...> - 2014-04-05 02:59:32
|
Revision: 12422
http://sourceforge.net/p/xoops/svn/12422
Author: luciorota
Date: 2014-04-05 02:59:29 +0000 (Sat, 05 Apr 2014)
Log Message:
-----------
use XoopsLocal::formatTimestamp
added: calculate file size also for local files
removed duplicated language definition
check/improve wfdownloads_download function for very large files
Modified Paths:
--------------
XoopsModules/wfdownloads/trunk/wfdownloads/admin/downloads.php
XoopsModules/wfdownloads/trunk/wfdownloads/admin/mirrors.php
XoopsModules/wfdownloads/trunk/wfdownloads/admin/ratings.php
XoopsModules/wfdownloads/trunk/wfdownloads/admin/reportsmodifications.php
XoopsModules/wfdownloads/trunk/wfdownloads/admin/reviews.php
XoopsModules/wfdownloads/trunk/wfdownloads/class/category.php
XoopsModules/wfdownloads/trunk/wfdownloads/docs/changelog.txt
XoopsModules/wfdownloads/trunk/wfdownloads/include/common.php
XoopsModules/wfdownloads/trunk/wfdownloads/include/functions.php
XoopsModules/wfdownloads/trunk/wfdownloads/language/english/admin.php
XoopsModules/wfdownloads/trunk/wfdownloads/visit.php
XoopsModules/wfdownloads/trunk/wfdownloads/xoops_version.php
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/admin/downloads.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/admin/downloads.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/admin/downloads.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -164,7 +164,7 @@
$userRatings = $wfdownloads->getHandler('rating')->getUserAverage($criteria);
foreach (array_keys($regvotes) as $i) {
- $formatted_date = formatTimestamp($regvotes[$i]->getVar('ratingtimestamp'), _DATESTRING);
+ $formatted_date = XoopsLocal::formatTimestamp($regvotes[$i]->getVar('ratingtimestamp'), 'l');
$userAvgRating = isset($userRatings[$regvotes[$i]->getVar('ratinguser')]) ? $userRatings[$regvotes[$i]->getVar(
'ratinguser'
)]["avg"] : 0;
@@ -209,7 +209,7 @@
$anonymousVotes = $wfdownloads->getHandler('rating')->getObjects($anonymousCriteria);
foreach (array_keys($anonymousVotes) as $i) {
- $formatted_date = formatTimestamp($anonymousVotes[$i]->getVar('ratingtimestamp'), _DATESTRING);
+ $formatted_date = XoopsLocal::formatTimestamp($anonymousVotes[$i]->getVar('ratingtimestamp'), 'l');
$userAvgRating = isset($userRatings['avg']) ? $userRatings["avg"] : 0;
$userVotes = isset($userRatings['count']) ? $userRatings["count"] : 0;
@@ -254,12 +254,16 @@
$url = ($_POST['url'] != "http://") ? $_POST['url'] : '';
$filename = '';
$filetype = '';
+ // Get size from form
+ $size = (empty($_POST['size']) || !is_numeric($_POST['size'])) ? 0 : (int)$_POST["size"];
} else {
$url = ($_POST["url"] != "http://") ? $_POST['url'] : '';
$filename = $_POST['filename'];
$filetype = $_POST['filetype'];
+ $filePath = $wfdownloads->getConfig('uploaddir') . '/' . $filename;
+ // Get size from filesystem
+ $size = @filesize($filePath);
}
- $size = (empty($_POST['size']) || !is_numeric($_POST['size'])) ? 0 : (int)$_POST["size"];
$title = trim($_POST['title']);
$download->setVar('filename', $filename);
$download->setVar('filetype', $filetype);
@@ -353,7 +357,7 @@
if ($lid > 0 && !empty($dhistoryhistory)) {
$dhistory = $dhistory . "\n\n";
$time = time();
- $dhistory .= _AM_WFDOWNLOADS_FILE_HISTORYVERS . $version . _AM_WFDOWNLOADS_FILE_HISTORDATE . formatTimestamp($time, _DATESTRING) . "\n\n";
+ $dhistory .= _AM_WFDOWNLOADS_FILE_HISTORYVERS . $version . _AM_WFDOWNLOADS_FILE_HISTORDATE . XoopsLocal::formatTimestamp($time, 'l') . "\n\n";
$dhistory .= $dhistoryhistory;
}
$download->setVar('dhistory', $dhistory);
@@ -661,7 +665,7 @@
$publishedDownload_array['title_html'] = $myts->htmlSpecialChars(trim($publishedDownload_array['title']));
$publishedDownload_array['category_title'] = $categories[$publishedDownload_array['cid']]['title'];
$publishedDownload_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($publishedDownload_array['submitter']);
- $publishedDownload_array['published_timestamp'] = formatTimestamp($publishedDownload_array['published'], _DATESTRING);
+ $publishedDownload_array['published_timestamp'] = XoopsLocal::formatTimestamp($publishedDownload_array['published'], 'l');
$GLOBALS['xoopsTpl']->append('published_downloads', $publishedDownload_array);
}
}
@@ -708,7 +712,7 @@
$platform = $myts->htmlSpecialChars($newDownload_array['platform']);
$logourl = $myts->htmlSpecialChars($newDownload_array['screenshot']);
$newDownload_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($newDownload_array['submitter']);
- $newDownload_array['date_timestamp'] = formatTimestamp($newDownload_array['date'], _DATESTRING);
+ $newDownload_array['date_timestamp'] = XoopsLocal::formatTimestamp($newDownload_array['date'], 'l');
$GLOBALS['xoopsTpl']->append('new_downloads', $newDownload_array);
}
}
@@ -731,7 +735,7 @@
$autopublishedDownload_array['title_html'] = $myts->htmlSpecialChars(trim($autopublishedDownload_array['title']));
$autopublishedDownload_array['category_title'] = $categories[$autopublishedDownload_array['cid']]['title'];
$autopublishedDownload_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($autopublishedDownload_array['submitter']);
- $autopublishedDownload_array['published_timestamp'] = formatTimestamp($autopublishedDownload_array['published'], _DATESTRING);
+ $autopublishedDownload_array['published_timestamp'] = XoopsLocal::formatTimestamp($autopublishedDownload_array['published'], 'l');
$GLOBALS['xoopsTpl']->append('autopublished_downloads', $autopublishedDownload_array);
}
}
@@ -757,7 +761,7 @@
$expired_download_array['title_html'] = $myts->htmlSpecialChars(trim($expired_download_array['title']));
$expired_download_array['category_title'] = $categories[$expired_download_array['cid']]['title'];
$expired_download_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($expired_download_array['submitter']);
- $expired_download_array['published_timestamp'] = formatTimestamp($expired_download_array['published'], _DATESTRING);
+ $expired_download_array['published_timestamp'] = XoopsLocal::formatTimestamp($expired_download_array['published'], 'l');
$GLOBALS['xoopsTpl']->append('expired_downloads', $expired_download_array);
}
}
@@ -780,7 +784,7 @@
$offlineDownload_array['title_html'] = $myts->htmlSpecialChars(trim($offlineDownload_array['title']));
$offlineDownload_array['category_title'] = $categories[$offlineDownload_array['cid']]['title'];
$offlineDownload_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($offlineDownload_array['submitter']);
- $offlineDownload_array['published_timestamp'] = formatTimestamp($offlineDownload_array['published'], _DATESTRING);
+ $offlineDownload_array['published_timestamp'] = XoopsLocal::formatTimestamp($offlineDownload_array['published'], 'l');
$GLOBALS['xoopsTpl']->append('offline_downloads', $offlineDownload_array);
}
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/admin/mirrors.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/admin/mirrors.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/admin/mirrors.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -151,7 +151,7 @@
'lid'
)]['title'] : "";
$mirror_waiting_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($mirror_waiting->getVar('uid'));
- $mirror_waiting_array['formatted_date'] = formatTimestamp($mirror_waiting->getVar('date'), _DATESTRING);
+ $mirror_waiting_array['formatted_date'] = XoopsLocal::formatTimestamp($mirror_waiting->getVar('date'), 'l');
$GLOBALS['xoopsTpl']->append('mirrors_waiting', $mirror_waiting_array);
}
//Include page navigation
@@ -176,7 +176,7 @@
$mirror_published_array['download_title'] = isset($downloads[$mirror_published->getVar('lid')])
? $downloads[$mirror_published->getVar('lid')]['title'] : "";
$mirror_published_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($mirror_published->getVar('uid'));
- $mirror_published_array['formatted_date'] = formatTimestamp($mirror_published->getVar('date'), _DATESTRING);
+ $mirror_published_array['formatted_date'] = XoopsLocal::formatTimestamp($mirror_published->getVar('date'), 'l');
$GLOBALS['xoopsTpl']->append('mirrors_published', $mirror_published_array);
}
//Include page navigation
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/admin/ratings.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/admin/ratings.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/admin/ratings.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -66,7 +66,7 @@
);
foreach ($ratings as $rating) {
$rating_array = $rating->toArray();
- $rating_array['formatted_date'] = formatTimestamp($rating->getVar('ratingtimestamp'), _DATESTRING);
+ $rating_array['formatted_date'] = XoopsLocal::formatTimestamp($rating->getVar('ratingtimestamp'), 'l');
$rating_array['submitter_uname'] = XoopsUser::getUnameFromId($rating->getVar('ratinguser'));
$rating_array['submitter_uid'] = $rating->getVar('ratinguser');
$rating_array['download_title'] = $downloads[$rating->getVar('lid')]->getVar('title');
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/admin/reportsmodifications.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/admin/reportsmodifications.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/admin/reportsmodifications.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -128,9 +128,9 @@
case "published" :
case "expired" :
case "updated" :
- $downloadContent = ($downloadContent != false) ? formatTimestamp($downloadContent, _DATESTRING) : _NO;
+ $downloadContent = ($downloadContent != false) ? XoopsLocal::formatTimestamp($downloadContent, 'l') : _NO;
//
- $modificationContent = ($modificationContent != false) ? formatTimestamp($modificationContent, _DATESTRING) : _NO;
+ $modificationContent = ($modificationContent != false) ? XoopsLocal::formatTimestamp($modificationContent, 'l') : _NO;
break;
case "platform":
case "license":
@@ -371,7 +371,7 @@
$report_array['reporter_email'] = isset($users[$report->getVar('sender')]) ? $users[$report->getVar('sender')]->getVar('email') : '';
$report_array['reporter_uname'] = isset($users[$report->getVar('sender')]) ? $users[$report->getVar('sender')]->getVar('uname')
: $xoopsConfig['anonymous'];
- $report_array['formatted_date'] = formatTimestamp($report->getVar('date'), _DATESTRING);
+ $report_array['formatted_date'] = XoopsLocal::formatTimestamp($report->getVar('date'), 'l');
$GLOBALS['xoopsTpl']->append('reports', $report_array);
}
//Include page navigation
@@ -396,7 +396,7 @@
$modification_array = $modification->toArray();
$modification_array['title'] = ($modification->getVar('title'));
$modification_array['submitter_uname'] = XoopsUserUtility::getUnameFromId($modification->getVar('submitter'));
- $modification_array['formatted_date'] = formatTimestamp($modification->getVar('requestdate'), _DATESTRING);
+ $modification_array['formatted_date'] = XoopsLocal::formatTimestamp($modification->getVar('requestdate'), 'l');
$download = $wfdownloads->getHandler('download')->get($modification->getVar('lid'));
$modification_array['download'] = $download->toArray();
$GLOBALS['xoopsTpl']->append('modifications', $modification_array);
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/admin/reviews.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/admin/reviews.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/admin/reviews.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -157,7 +157,7 @@
$review_waiting_array['reviewer_uname'] = XoopsUserUtility::getUnameFromId($review_waiting->getVar('uid'));
$reviewer = $member_handler->getUser($review_waiting->getVar('uid'));
$review_waiting_array['reviewer_email'] = is_object($reviewer) ? $reviewer->email() : '';
- $review_waiting_array['formatted_date'] = formatTimestamp($review_waiting->getVar('date'), _DATESTRING);
+ $review_waiting_array['formatted_date'] = XoopsLocal::formatTimestamp($review_waiting->getVar('date'), 'l');
$GLOBALS['xoopsTpl']->append('reviews_waiting', $review_waiting_array);
}
//Include page navigation
@@ -188,7 +188,7 @@
$review_published_array['reviewer_uname'] = XoopsUserUtility::getUnameFromId($review_published->getVar('uid'));
$reviewer = $member_handler->getUser($review_published->getVar('uid'));
$review_published_array['reviewer_email'] = is_object($reviewer) ? $reviewer->email() : '';
- $review_published_array['formatted_date'] = formatTimestamp($review_published->getVar('date'), _DATESTRING);
+ $review_published_array['formatted_date'] = XoopsLocal::formatTimestamp($review_published->getVar('date'), 'l');
$GLOBALS['xoopsTpl']->append('reviews_published', $review_published_array);
}
//Include page navigation
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/class/category.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/class/category.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/class/category.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -174,7 +174,7 @@
}
// form: button tray
$button_tray = new XoopsFormElementTray('', '');
- $button_tray->addElement(new XoopsFormHidden('op', 'save'));
+ $button_tray->addElement(new XoopsFormHidden('op', 'category.save'));
if ($this->isNew()) {
$button_create = new XoopsFormButton('', '', _SUBMIT, 'submit');
$button_create->setExtra('onclick="this.form.elements.op.value=\'category.save\'"');
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/docs/changelog.txt
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/docs/changelog.txt 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/docs/changelog.txt 2014-04-05 02:59:29 UTC (rev 12422)
@@ -1,4 +1,6 @@
-<b><u>=> Version 3.23 Beta (2014-03-12)</u></b>
+<b><u>=> Version 3.23 Beta (2014-04-04)</u></b>
+- added: calculate file size also for local files (luciorota)
+- added: use XoopsLocal::formatTimestamp (luciorota)
- update jQuery Thickbox plugin to 3.1 (luciorota)
- fixed: jQuery bug in templates (luciorota)
- standardization of English language files (cesag)
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/include/common.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/include/common.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/include/common.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -46,6 +46,7 @@
xoops_load('XoopsUserUtility');
+xoops_load('XoopsLocal');
// MyTextSanitizer object
$myts = MyTextSanitizer::getInstance();
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/include/functions.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/include/functions.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/include/functions.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -1244,16 +1244,17 @@
function wfdownloads_download($filePath, $isBinary = true, $retBytes = true)
{
- $chunkSize = 1 * (1024 * 1024); // how many bytes per chunk
- $buffer = '';
- $cnt = 0;
+ // how many bytes per chunk
+ //$chunkSize = 1 * (1024 * 1024);
+ $chunkSize = 8 * (1024 * 1024); //8MB (highest possible fread length)
+ $buffer = '';
+ $bytesCounter = 0;
if ($isBinary == true) {
$handler = fopen($filePath, 'rb');
} else {
$handler = fopen($filePath, 'r');
}
-
if ($handler === false) {
return false;
}
@@ -1263,17 +1264,97 @@
ob_flush();
flush();
if ($retBytes) {
- $cnt += strlen($buffer);
+ $bytesCounter += strlen($buffer);
}
}
$status = fclose($handler);
if ($retBytes && $status) {
- return $cnt; // return num. bytes delivered like readfile() does.
+ return $bytesCounter; // return num. bytes delivered like readfile() does.
}
return $status;
}
+// IN PROGRESS
+// IN PROGRESS
+// IN PROGRESS
+/**
+* @author Jack Mason
+* @website volunteer @ http://www.osipage.com, web access application and bookmarking tool.
+* @copyright Free script, use anywhere as you like, no attribution required
+* @created 2014
+* The script is capable of downloading really large files in PHP. Files greater than 2GB may fail in 32-bit windows or similar system.
+* All incorrect headers have been removed and no nonsense code remains in this script. Should work well.
+* The best and most recommended way to download files with PHP is using xsendfile, learn
+* more here: https://tn123.org/mod_xsendfile/
+*/
+function wfdownloads_largeDownload($filePath, $fileMimetype) {
+ /* You may need these ini settings too */
+ set_time_limit(0);
+ ini_set('memory_limit', '512M');
+ if(!empty($filePath)) {
+ $fileInfo = pathinfo($filePath);
+ $fileName = $fileInfo['basename'];
+ $fileExtrension = $fileInfo['extension'];
+ $default_contentType = "application/octet-stream";
+ // to find and use specific content type, check out this IANA page : http://www.iana.org/assignments/media-types/media-types.xhtml
+ if ($fileMimetype =! '') {
+ $contentType = $fileMimetype;
+ } else {
+ $contentType = $default_contentType;
+ }
+ if(file_exists($filePath)) {
+ $size = filesize($filePath);
+ $offset = 0;
+ $length = $size;
+ //HEADERS FOR PARTIAL DOWNLOAD FACILITY BEGINS
+ if(isset($_SERVER['HTTP_RANGE'])) {
+ preg_match('/bytes=(\d+)-(\d+)?/', $_SERVER['HTTP_RANGE'], $matches);
+ $offset = intval($matches[1]);
+ $length = intval($matches[2]) - $offset;
+ $fhandle = fopen($filePath, 'r');
+ fseek($fhandle, $offset); // seek to the requested offset, this is 0 if it's not a partial content request
+ $data = fread($fhandle, $length);
+ fclose($fhandle);
+ header('HTTP/1.1 206 Partial Content');
+ header('Content-Range: bytes ' . $offset . '-' . ($offset + $length) . '/' . $size);
+ }//HEADERS FOR PARTIAL DOWNLOAD FACILITY BEGINS
+ //USUAL HEADERS FOR DOWNLOAD
+ header("Content-Disposition: attachment;filename=".$fileName);
+ header('Content-Type: '.$contentType);
+ header("Accept-Ranges: bytes");
+ header("Pragma: public");
+ header("Expires: -1");
+ header("Cache-Control: no-cache");
+ header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0");
+ header("Content-Length: ".filesize($filePath));
+ $chunksize = 8 * (1024 * 1024); //8MB (highest possible fread length)
+ if ($size > $chunksize) {
+ $handle = fopen($_FILES["file"]["tmp_name"], 'rb');
+ $buffer = '';
+ while (!feof($handle) && (connection_status() === CONNECTION_NORMAL)) {
+ $buffer = fread($handle, $chunksize);
+ print $buffer;
+ ob_flush();
+ flush();
+ }
+ if(connection_status() !== CONNECTION_NORMAL) {
+ echo "Connection aborted";
+ }
+ fclose($handle);
+ } else {
+ ob_clean();
+ flush();
+ readfile($filePath);
+ }
+ } else {
+ echo 'File does not exist!';
+ }
+ } else {
+ echo 'There is no file to download!';
+ }
+}
+
function wfdownloads_getForum($selectedForumId)
{
global $xoopsDB;
@@ -1418,7 +1499,9 @@
return $truncate;
}
-
+// IN PROGRESS
+// IN PROGRESS
+// IN PROGRESS
/*
php4swish-e 1.1, a web search interface for the swish-e search engine.
swish-e is a popular open-source search engine that runs on many platforms.
@@ -1485,6 +1568,9 @@
print("</SCRIPT>");
}
+// IN PROGRESS
+// IN PROGRESS
+// IN PROGRESS
function wfdownloads_swishe_search($search_query)
{
$wfdownloads = WfdownloadsWfdownloads::getInstance();
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/language/english/admin.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/language/english/admin.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/language/english/admin.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -642,5 +642,4 @@
define('_AM_WFDOWNLOADS_TEXTOPTIONS_DESC', "Description and Summary text options");
define('_AM_WFDOWNLOADS_FCATEGORY_DESCRIPTION_DESC', "");
-define('_AM_WFDOWNLOADS_FCATEGORY_SUMMARY_DESC', "");
-define('_AM_WFDOWNLOADS_TEXTOPTIONS_DESC', "Description and Summary text options");
\ No newline at end of file
+define('_AM_WFDOWNLOADS_FCATEGORY_SUMMARY_DESC', "");
\ No newline at end of file
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/visit.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/visit.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/visit.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -39,7 +39,7 @@
$cid = WfdownloadsRequest::getInt('cid', $download->getVar('cid'));
$agreed = WfdownloadsRequest::getBool('agreed', false, 'POST');
-//Download not published, expired or taken offline - redirect
+// Download not published, expired or taken offline - redirect
if (
$download->getVar('published') == 0 ||
$download->getVar('published') > time() ||
@@ -55,14 +55,8 @@
redirect_header('index.php', 3, _NOPERM);
}
-function reportBroken($lid)
-{
- echo "<h4>" . _MD_WFDOWNLOADS_BROKENFILE . "</h4>\n";
- echo "<div>" . _MD_WFDOWNLOADS_PLEASEREPORT . "\n";
- echo "<a href='" . WFDOWNLOADS_URL . "/brokenfile.php?lid={$lid}'>" . _MD_WFDOWNLOADS_CLICKHERE . "</a>\n";
- echo "</div>\n";
-}
+
if ($agreed == false) {
if ($wfdownloads->getConfig('check_host')) {
$isAGoodHost = false;
@@ -129,8 +123,10 @@
$ip_log->setVar('uid', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0);
$wfdownloads->getHandler('ip_log')->insert($ip_log, true);
- $fullFilename = trim($download->getVar('filename'));
- if ((!$download->getVar('url') == '' && !$download->getVar('url') == 'http://') || $fullFilename == '') {
+ // Download file
+ $fileFilename = trim($download->getVar('filename')); // IN PROGRESS: why 'trim'?
+ if ((!$download->getVar('url') == '' && !$download->getVar('url') == 'http://') || $fileFilename == '') {
+ // download is a remote file: download from remote url
include XOOPS_ROOT_PATH . '/header.php';
$xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js');
@@ -142,8 +138,9 @@
echo "<div align='center'>" . wfdownloads_headerImage() . "</div>";
$url = $myts->htmlSpecialChars(preg_replace('/javascript:/si', 'javascript:', $download->getVar('url')), ENT_QUOTES);
- echo "<h4><img src='" . WFDOWNLOADS_URL . "/images/icon/downloads.gif' align='middle' alt='' title='" . _MD_WFDOWNLOADS_DOWNINPROGRESS
- . "' /> " . _MD_WFDOWNLOADS_DOWNINPROGRESS . "</h4>\n";
+ echo "<h4>\n";
+ echo "<img src='" . WFDOWNLOADS_URL . "/images/icon/downloads.gif' align='middle' alt='' title='" . _MD_WFDOWNLOADS_DOWNINPROGRESS . "' /> " . _MD_WFDOWNLOADS_DOWNINPROGRESS . "\n";
+ echo "</h4>\n";
echo "<div>" . _MD_WFDOWNLOADS_DOWNSTARTINSEC . "</div><br />\n";
echo "<div>" . _MD_WFDOWNLOADS_DOWNNOTSTART . "\n";
echo "<a href='{$url}' target='_blank'>" . _MD_WFDOWNLOADS_CLICKHERE . "</a>.\n";
@@ -155,38 +152,51 @@
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Refresh: 3; url={$url}");
- } elseif (!empty($fullFilename)) {
- $mimeType = $download->getVar('filetype');
- $file = strrev($fullFilename);
- $tempFilename = strtolower(strrev(substr($file, 0, strpos($file, '--'))));
- $filename = ($tempFilename == '') ? $fullFilename : $tempFilename;
- $filePath = $wfdownloads->getConfig('uploaddir') . '/' . stripslashes(trim($fullFilename));
+ } elseif (!empty($fileFilename)) {
+ // download is a local file: download from filesystem
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
- // MSIE Bug fix.
- $headerFilename = (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) ? preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1)
- : $filename;
+ // get file informations from filesystem
+ $fileFilename = trim($download->getVar('filename')); // IN PROGRESS: why 'trim'?
+ $fileMimetype = ($download->getVar('filetype') != '') ? $download->getVar('filetype') : "application/octet-stream";
+ $filePath = $wfdownloads->getConfig('uploaddir') . '/' . stripslashes(trim($fileFilename));
+ $fileFilesize = filesize($filePath);
+ $fileInfo = pathinfo($filePath);
+ $fileName = $fileInfo['basename'];
+ $fileExtension = $fileInfo['extension'];
+
+ $headerFilename = strtolower(strrev(substr(strrev($fileFilename), 0, strpos(strrev($fileFilename), '--'))));
+ $headerFilename = ($headerFilename == '') ? $fileFilename : $headerFilename;
+ // MSIE Bug fix
+ if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
+ $headerFilename = preg_replace('/\./', '%2e', $headerFilename, substr_count($headerFilename, '.') - 1);
+ }
+ //
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
- header("Content-Length: " . (string)(filesize($filePath)));
+ header("Content-Length: " . (string)($fileFilesize));
header("Content-Transfer-Encoding: binary");
- if (isset($mimeType)) {
- header("Content-Type: {$mimeType}");
- }
+ header("Content-Type: {$fileMimetype}");
header("Content-Disposition: attachment; filename={$headerFilename}");
- if (isset($mimeType) && strstr($mimeType, 'text/')) {
+ if (strstr($fileMimetype, 'text/')) {
+ // downladed file is not binary
wfdownloads_download($filePath, false, true);
} else {
+ // downladed file is binary
wfdownloads_download($filePath, true, true);
}
exit();
} else {
+ // download is a broken file: report broken
include XOOPS_ROOT_PATH . '/header.php';
echo "<br />";
echo "<div align='center'>" . wfdownloads_headerImage() . "</div>";
- reportBroken($lid);
+ echo "<h4>" . _MD_WFDOWNLOADS_BROKENFILE . "</h4>\n";
+ echo "<div>" . _MD_WFDOWNLOADS_PLEASEREPORT . "\n";
+ echo "<a href='" . WFDOWNLOADS_URL . "/brokenfile.php?lid={$lid}'>" . _MD_WFDOWNLOADS_CLICKHERE . "</a>\n";
+ echo "</div>\n";
}
include 'footer.php';
}
Modified: XoopsModules/wfdownloads/trunk/wfdownloads/xoops_version.php
===================================================================
--- XoopsModules/wfdownloads/trunk/wfdownloads/xoops_version.php 2014-04-05 02:54:22 UTC (rev 12421)
+++ XoopsModules/wfdownloads/trunk/wfdownloads/xoops_version.php 2014-04-05 02:59:29 UTC (rev 12422)
@@ -42,9 +42,9 @@
$modversion['onUpdate'] = 'include/module.php';
$modversion['onUninstall'] = 'include/module.php';
-$modversion['date'] = '2014-03-12';
-$modversion['release_date'] = '2014/03/12';
-$modversion['releasedate'] = '2014-03-12';
+$modversion['date'] = '2014-04-04';
+$modversion['release_date'] = '2014/04/04';
+$modversion['releasedate'] = '2014-04-04';
$modversion['status'] = 'BETA 2';
$modversion['teammembers'] = "Bender, David, FrankBlack, Xpider, M0nty, Mithrandir, Marcan, felix[fx2024], Sudhaker, Jegelstaff";
|