From 0077cb99704fe863cf731fc5cab792af2ede96c2 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 17 Apr 2011 20:13:07 -0400 Subject: Backporting retarded amount of changes outside of version control --- modules/download/index.php | 268 ++++++++++++++++++++++----------------------- 1 file changed, 134 insertions(+), 134 deletions(-) (limited to 'modules/download/index.php') diff --git a/modules/download/index.php b/modules/download/index.php index b819e8d..8cd1d99 100644 --- a/modules/download/index.php +++ b/modules/download/index.php @@ -1,134 +1,134 @@ -. - */ - -if(!defined("MODULE_FILE")) -{ - die("Access denied..."); -} - -function getCategoryList() -{ - global $db; - $query = sprintf("SELECT category_id, title FROM bayonet_downloads_categories"); - $result = $db->Query($query); - $categories = $db->Fetch($result); - - return $categories; -} - -function getCategoryName($category) -{ - global $db; - if(!filter_var($category, FILTER_VALIDATE_INT)) - return array(); - - $query = sprintf("SELECT category_id, title FROM bayonet_downloads_categories WHERE category_id = %d", (int)$category); - $result = $db->Query($query); - $data = $db->FetchRow($result); - - return $data['title']; - //return is_array($data) ? $data : array(); -} - -function getCategoryFiles($category) -{ - global $db; - $query = sprintf("SELECT ca.category_id, ca.title AS category, dl.name, dl.filename, dl.description FROM bayonet_downloads_categories AS ca LEFT OUTER JOIN bayonet_downloads AS dl ON dl.category_id = ca.category_id WHERE ca.category_id = %d", (int)$category); - - $result = $db->Query($query); - $downloads = $db->FetchArray($result); - decho('downloads data'); - decho($downloads); - decho('downloads data done'); - - return $downloads; -} - -global $db; -$downloads = NULL; -$download_relative_path = "modules/" . basename(dirname(__FILE__)) . "/files/"; -$download_absolute_path = dirname(__FILE__) . "/files/"; - -$category = $_GET['category']; -if(isset($category) && !filter_var($category, FILTER_VALIDATE_INT)) -{ - ReportHack("Purposely invalid category entry."); - return; -} - -$downloads = getCategoryFiles($category); -decho($downloads); - -OpenContent(); -echo "
Categories
\n"; -echo "
\n"; - -$categoryList = getCategoryList(); - - foreach($categoryList as $categoryListItem) - { - echo "

"; - echo LinkModule("download", "&category={$categoryListItem['category_id']}",$categoryListItem['title']); - echo "

\n"; - } - - -echo "
\n\n"; -CloseContent(); - -echo "
"; //spacer between div tags - -if(isset($category)) -{ - OpenContent(); - echo "
" . getCategoryName($category) . "
\n"; - echo "
\n"; - - OpenContent(); - echo "
Files
\n"; - echo "
\n"; - - if(empty($downloads)) - { - echo "No downloads available.\n"; - return; - } - - foreach($downloads as $file) - { - $download_full_path = $download_absolute_path . $file['filename']; - - if(!file_exists($download_full_path)) $broken = "(Broken link detected)"; - echo "

"; - echo LinkInternal($file['name'], $file['filename'], $download_relative_path) . " $broken
\n"; - echo "Filename: {$file['filename']}
\n"; - printf("Size: %.2fKB
\n", filesize($download_full_path) / 1024); - echo "MD5 Hash: " . md5_file($download_full_path) . "
\n"; - echo "Description: {$file['description']}
\n"; - echo "

"; - - } - //logQueueFlush(FORCE); - - echo "
\n
"; - echo "\n"; -} - CloseContent(); -CloseContent(); -?> +. + */ + +if(!defined("MODULE_FILE")) +{ + die("Access denied..."); +} + +function getCategoryList() +{ + global $db; + $query = sprintf("SELECT category_id, title FROM bayonet_downloads_categories"); + $result = $db->Query($query); + $categories = $db->Fetch($result); + + return $categories; +} + +function getCategoryName($category) +{ + global $db; + if(!filter_var($category, FILTER_VALIDATE_INT)) + return array(); + + $query = sprintf("SELECT category_id, title FROM bayonet_downloads_categories WHERE category_id = %d", (int)$category); + $result = $db->Query($query); + $data = $db->FetchRow($result); + + return $data['title']; + //return is_array($data) ? $data : array(); +} + +function getCategoryFiles($category) +{ + global $db; + $query = sprintf("SELECT ca.category_id, ca.title AS category, dl.name, dl.filename, dl.description FROM bayonet_downloads_categories AS ca LEFT OUTER JOIN bayonet_downloads AS dl ON dl.category_id = ca.category_id WHERE ca.category_id = %d", (int)$category); + + $result = $db->Query($query); + $downloads = $db->FetchArray($result); + decho('downloads data'); + decho($downloads); + decho('downloads data done'); + + return $downloads; +} + +global $db; +$downloads = NULL; +$download_relative_path = "modules/" . basename(dirname(__FILE__)) . "/files/"; +$download_absolute_path = dirname(__FILE__) . "/files/"; + +$category = $_GET['category']; +if(isset($category) && !filter_var($category, FILTER_VALIDATE_INT)) +{ + ReportHack("Purposely invalid category entry."); + return; +} + +$downloads = getCategoryFiles($category); +decho($downloads); + +OpenContent(); +echo "
Categories
\n"; +echo "
\n"; + +$categoryList = getCategoryList(); + + foreach($categoryList as $categoryListItem) + { + echo "

"; + echo LinkModule("download", "&category={$categoryListItem['category_id']}",$categoryListItem['title']); + echo "

\n"; + } + + +echo "
\n\n"; +CloseContent(); + +echo "
"; //spacer between div tags + +if(isset($category)) +{ + OpenContent(); + echo "
" . getCategoryName($category) . "
\n"; + echo "
\n"; + + OpenContent(); + echo "
Files
\n"; + echo "
\n"; + + if(empty($downloads)) + { + echo "No downloads available.\n"; + return; + } + + foreach($downloads as $file) + { + $download_full_path = $download_absolute_path . $file['filename']; + + if(!file_exists($download_full_path)) $broken = "(Broken link detected)"; + echo "

"; + echo LinkInternal($file['name'], $file['filename'], $download_relative_path) . " $broken
\n"; + echo "Filename: {$file['filename']}
\n"; + printf("Size: %.2fKB
\n", filesize($download_full_path) / 1024); + echo "MD5 Hash: " . md5_file($download_full_path) . "
\n"; + echo "Description: {$file['description']}
\n"; + echo "

"; + + } + //logQueueFlush(FORCE); + + echo "
\n
"; + echo "\n"; +} + CloseContent(); +CloseContent(); +?> -- cgit