From f055b49d91b301f7c5422e9559e5e1a9cc4e6810 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 21 Jan 2021 09:38:38 -0800 Subject: [PATCH] PHP8 Plugin code cleanup --- e107_core/templates/header_default.php | 2 +- e107_handlers/comment_class.php | 7 +- e107_handlers/plugin_class.php | 2 +- e107_plugins/_blank/_blank.php | 8 +- e107_plugins/_blank/admin_config.php | 2 +- e107_plugins/_blank/e_url.php | 2 +- e107_plugins/alt_auth/alt_auth_conf.php | 2 +- e107_plugins/alt_auth/e107db_conf.php | 2 +- e107_plugins/alt_auth/importdb_conf.php | 2 +- e107_plugins/alt_auth/ldap_conf.php | 2 +- e107_plugins/alt_auth/otherdb_conf.php | 2 +- e107_plugins/alt_auth/radius_conf.php | 2 +- e107_plugins/banner/admin_banner.php | 4 +- e107_plugins/banner/banner.php | 2 +- e107_plugins/blogcalendar_menu/archive.php | 6 +- e107_plugins/blogcalendar_menu/config.php | 8 +- e107_plugins/chatbox_menu/admin_chatbox.php | 2 +- e107_plugins/chatbox_menu/chat.php | 21 +- e107_plugins/chatbox_menu/chatbox_menu.php | 6 +- e107_plugins/clock_menu/config.php | 14 +- e107_plugins/comment_menu/comment_menu.php | 4 +- e107_plugins/comment_menu/config.php | 2 +- e107_plugins/contact/e_url.php | 2 +- e107_plugins/download/admin_download.php | 4 +- e107_plugins/download/download.php | 157 ++-- e107_plugins/download/download_shortcodes.php | 12 +- e107_plugins/download/e_url.php | 2 +- .../download/handlers/category_class.php | 2 +- .../download/handlers/download_class.php | 6 +- e107_plugins/download/request.php | 824 +++++++++--------- e107_plugins/faqs/admin_config.php | 2 +- e107_plugins/faqs/e_url.php | 2 +- e107_plugins/faqs/faqs.php | 2 +- e107_plugins/featurebox/admin_config.php | 4 +- e107_plugins/forum/e_url.php | 2 +- e107_plugins/forum/forum.php | 161 ++-- e107_plugins/forum/forum_admin.php | 2 +- e107_plugins/forum/forum_class.php | 8 +- e107_plugins/forum/forum_conf.php | 2 +- e107_plugins/forum/forum_post.php | 2 +- e107_plugins/forum/forum_stats.php | 2 +- e107_plugins/forum/forum_test.php | 2 +- e107_plugins/forum/forum_uploads.php | 2 +- e107_plugins/forum/forum_viewforum.php | 2 +- e107_plugins/forum/forum_viewtopic.php | 2 +- e107_plugins/gallery/admin_gallery.php | 2 +- e107_plugins/gallery/e_url.php | 2 +- e107_plugins/gallery/gallery.php | 2 +- e107_plugins/gsitemap/admin_config.php | 2 +- e107_plugins/gsitemap/e_url.php | 2 +- e107_plugins/hero/admin_config.php | 2 +- e107_plugins/import/admin_import.php | 2 +- e107_plugins/linkwords/admin_config.php | 2 +- e107_plugins/list_new/admin_list_config.php | 2 +- e107_plugins/list_new/list.php | 2 +- e107_plugins/log/admin_config.php | 2 +- e107_plugins/log/e_url.php | 2 +- e107_plugins/log/log.php | 2 +- e107_plugins/log/stats.php | 2 +- e107_plugins/log/stats_csv.php | 2 +- e107_plugins/login_menu/config.php | 2 +- e107_plugins/news/e_url.php | 2 +- e107_plugins/news/news.php | 2 +- e107_plugins/newsfeed/admin_config.php | 2 +- e107_plugins/newsfeed/e_url.php | 2 +- e107_plugins/newsfeed/newsfeed.php | 2 +- e107_plugins/newsletter/admin_config.php | 2 +- e107_plugins/newsletter/nl_archive.php | 2 +- e107_plugins/online/config.php | 2 +- e107_plugins/pm/admin_config.php | 2 +- e107_plugins/pm/e_url.php | 2 +- e107_plugins/pm/pm.php | 2 +- e107_plugins/pm/pm_conf.php | 2 +- e107_plugins/poll/admin_config.php | 2 +- e107_plugins/poll/oldpolls.php | 2 +- e107_plugins/poll/poll.php | 2 +- e107_plugins/rss_menu/admin_prefs.php | 2 +- e107_plugins/rss_menu/rss.php | 2 +- e107_plugins/social/admin_config.php | 2 +- e107_plugins/tinymce4/admin_config.php | 2 +- e107_plugins/tinymce4/wysiwyg.php | 2 +- e107_plugins/user/usertheme_menu_config.php | 2 +- e107_tests/tests/unit/pluginsTest.php | 44 + 83 files changed, 753 insertions(+), 675 deletions(-) diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index 5dc0fb897..cdeb7e35d 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -206,7 +206,7 @@ if(THEME_LEGACY === true || !deftrue('BOOTSTRAP')) // re-initalize in case globals are destroyed from $e_headers includes $e_js = e107::getJs(); $e_pref = e107::getConfig(); - +$pref = e107::getPref(); // --- Load plugin Meta files - now possible to add to all zones! -------- $e_meta_content = ''; diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index 6254f6a69..5549c0c4b 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -1496,7 +1496,12 @@ class comment return null; } - global $pref,$sql,$sql2,$tp; + $sql = e107::getDb(); + $tp = e107::getParser(); + $sql2 = e107::getDb('sql2'); + $pref = e107::getPref(); + + $from1 = ($from ? $from : '0'); $amount1 = ($amount ? $amount : '10'); $valid = ($cdvalid ? $cdvalid : '0'); diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 8a2766fff..a49ac4c43 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -85,7 +85,7 @@ class e_plugin "chatbox_menu", "clock_menu","comment_menu", "contact", "download", "featurebox", "forum","gallery", "gsitemap", "hero", "import", "linkwords", "list_new", "log", "login_menu", - "metaweblog", "newforumposts_main", "news", "newsfeed", + "newforumposts_main", "news", "newsfeed", "newsletter","online", "page", "pm","poll", "rss_menu","search_menu","siteinfo", "social", "tagcloud", "tinymce4", "user" diff --git a/e107_plugins/_blank/_blank.php b/e107_plugins/_blank/_blank.php index 09d1ff4fb..edd3f1505 100644 --- a/e107_plugins/_blank/_blank.php +++ b/e107_plugins/_blank/_blank.php @@ -11,7 +11,7 @@ */ if (!defined('e107_INIT')) { - require_once("../../class2.php"); + require_once(__DIR__.'/../../class2.php'); } @@ -47,7 +47,7 @@ class _blank_front // $template = e107::getTemplate('_blank','_blank','default'); // $text = $tp->parseTemplate($template['start'],true, $sc); - if($rows = $sql->retrieve('blank','*',false,'',true)) // combined select and fetch function - returns an array. + if($rows = $sql->retrieve('blank','*',false,true)) // combined select and fetch function - returns an array. { // print_a($rows); foreach($rows as $key=>$value) // loop throug @@ -56,7 +56,7 @@ class _blank_front // $sc->setVars($value); // if shortcodes are enabled. // $text .= $tp->parseTemplate($template['item'],true, $sc); - $text .= $tp->toHTML($value['blank_type'])."
"; + $text .= $tp->toHTML(varset($value['blank_type']))."
"; } // $text .= $tp->parseTemplate($template['end'],true, $sc); @@ -128,7 +128,7 @@ $_blankFront = new _blank_front; require_once(HEADERF); // render the header (everything before the main content area) $_blankFront->run(); require_once(FOOTERF); // render the footer (everything after the main content area) -exit; + // For a more elaborate plugin - please see e107_plugins/gallery diff --git a/e107_plugins/_blank/admin_config.php b/e107_plugins/_blank/admin_config.php index 21be73807..eac6fc4cd 100644 --- a/e107_plugins/_blank/admin_config.php +++ b/e107_plugins/_blank/admin_config.php @@ -10,7 +10,7 @@ * */ -require_once("../../class2.php"); +require_once(__DIR__."/../../class2.php"); if (!getperms("P")) { e107::redirect('admin'); diff --git a/e107_plugins/_blank/e_url.php b/e107_plugins/_blank/e_url.php index 193d48eb2..e6f19fbe1 100644 --- a/e107_plugins/_blank/e_url.php +++ b/e107_plugins/_blank/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/alt_auth/alt_auth_conf.php b/e107_plugins/alt_auth/alt_auth_conf.php index abed250bc..9545da722 100755 --- a/e107_plugins/alt_auth/alt_auth_conf.php +++ b/e107_plugins/alt_auth/alt_auth_conf.php @@ -28,7 +28,7 @@ 2. Change admin log references */ $eplug_admin = true; -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if(!getperms('P') || !e107::isInstalled('alt_auth')) { e107::redirect('admin'); diff --git a/e107_plugins/alt_auth/e107db_conf.php b/e107_plugins/alt_auth/e107db_conf.php index b7c6a3474..85d5cbb76 100644 --- a/e107_plugins/alt_auth/e107db_conf.php +++ b/e107_plugins/alt_auth/e107db_conf.php @@ -20,7 +20,7 @@ * @version $Id$; */ $eplug_admin = true; -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); require_once(e_ADMIN.'auth.php'); require_once(e_HANDLER.'form_handler.php'); e107::includeLan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_e107db_conf.php'); diff --git a/e107_plugins/alt_auth/importdb_conf.php b/e107_plugins/alt_auth/importdb_conf.php index 8050f6de5..f9f88728a 100644 --- a/e107_plugins/alt_auth/importdb_conf.php +++ b/e107_plugins/alt_auth/importdb_conf.php @@ -22,7 +22,7 @@ */ $eplug_admin = true; -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); require_once(e_ADMIN.'auth.php'); require_once(e_HANDLER.'form_handler.php'); e107::includeLan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_importdb_conf.php'); diff --git a/e107_plugins/alt_auth/ldap_conf.php b/e107_plugins/alt_auth/ldap_conf.php index 3910e9b30..3c05a7f33 100755 --- a/e107_plugins/alt_auth/ldap_conf.php +++ b/e107_plugins/alt_auth/ldap_conf.php @@ -21,7 +21,7 @@ */ $eplug_admin = true; -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); require_once(e_ADMIN.'auth.php'); require_once(e_HANDLER.'form_handler.php'); e107::includeLan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_ldap_conf.php'); diff --git a/e107_plugins/alt_auth/otherdb_conf.php b/e107_plugins/alt_auth/otherdb_conf.php index 3a31c7881..d48cece52 100644 --- a/e107_plugins/alt_auth/otherdb_conf.php +++ b/e107_plugins/alt_auth/otherdb_conf.php @@ -21,7 +21,7 @@ * @version $Id$; */ $eplug_admin = true; -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); require_once(e_ADMIN.'auth.php'); require_once(e_HANDLER.'form_handler.php'); e107::includeLan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_otherdb_conf.php'); diff --git a/e107_plugins/alt_auth/radius_conf.php b/e107_plugins/alt_auth/radius_conf.php index 67a41ea48..06940c649 100644 --- a/e107_plugins/alt_auth/radius_conf.php +++ b/e107_plugins/alt_auth/radius_conf.php @@ -17,7 +17,7 @@ +----------------------------------------------------------------------------+ */ $eplug_admin = true; -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); require_once(e_ADMIN."auth.php"); require_once(e_HANDLER."form_handler.php"); e107::includeLan(e_PLUGIN.'alt_auth/languages/'.e_LANGUAGE.'/admin_radius_conf.php'); diff --git a/e107_plugins/banner/admin_banner.php b/e107_plugins/banner/admin_banner.php index 63c732992..b30593836 100644 --- a/e107_plugins/banner/admin_banner.php +++ b/e107_plugins/banner/admin_banner.php @@ -10,7 +10,7 @@ * */ -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('D') && !getperms('P')) { e107::redirect('admin'); @@ -644,7 +644,7 @@ require_once(e_ADMIN."auth.php"); e107::getAdminUI()->runPage(); require_once(e_ADMIN."footer.php"); -exit; + //TODO - Put client/password in a separate table? \ No newline at end of file diff --git a/e107_plugins/banner/banner.php b/e107_plugins/banner/banner.php index a18dfedfb..1a57a832d 100644 --- a/e107_plugins/banner/banner.php +++ b/e107_plugins/banner/banner.php @@ -11,7 +11,7 @@ if (!defined('e107_INIT')) { - require_once("../../class2.php"); + require_once(__DIR__.'/../../class2.php'); } if (!e107::isInstalled('banner')) diff --git a/e107_plugins/blogcalendar_menu/archive.php b/e107_plugins/blogcalendar_menu/archive.php index 7818ed8da..42cf34bc5 100644 --- a/e107_plugins/blogcalendar_menu/archive.php +++ b/e107_plugins/blogcalendar_menu/archive.php @@ -17,7 +17,7 @@ | Based on code by: Thomas Bouve (crahan@gmx.net) */ -require_once("../../class2.php"); +require_once(__DIR__."/../../class2.php"); require_once(e_HANDLER."userclass_class.php"); e107::includeLan(e_PLUGIN."blogcalendar_menu/languages/".e_LANGUAGE.".php"); @@ -74,6 +74,8 @@ $end_year = $cur_year; $year_selector = "
"; $year_selector .= "".BLOGCAL_ARCHIV1.": "; // if the nr of months per row is undefined, default to 3 - $months_per_row = $pref['blogcal_mpr']?$pref['blogcal_mpr']: - "3"; + $months_per_row = isset($pref['blogcal_mpr']) ? $pref['blogcal_mpr']: 3; for($i = 1; $i <= 12; $i++) { $text .= "
'; } - $e107cache->set('nq_chatbox', $text); + e107::getCache()->set('nq_chatbox', $text); } diff --git a/e107_plugins/clock_menu/config.php b/e107_plugins/clock_menu/config.php index 2e7f0d9a8..f0e9a709b 100644 --- a/e107_plugins/clock_menu/config.php +++ b/e107_plugins/clock_menu/config.php @@ -12,7 +12,7 @@ $eplug_admin = TRUE; -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('1')) { e107::redirect('admin'); @@ -62,7 +62,7 @@ $text = " ".CLOCK_AD_L2.": - + @@ -72,27 +72,27 @@ $text = " ".CLOCK_AD_L7.": - ".CLOCK_AD_L8." + ".CLOCK_AD_L8." ".CLOCK_AD_L9.": - ".CLOCK_AD_L13." + ".CLOCK_AD_L13." ".CLOCK_AD_L10.": - ".CLOCK_AD_L13." + ".CLOCK_AD_L13." ".CLOCK_AD_L11.": - ".CLOCK_AD_L13." + ".CLOCK_AD_L13." ".CLOCK_AD_L12.": - ".CLOCK_AD_L13." + ".CLOCK_AD_L13." diff --git a/e107_plugins/comment_menu/comment_menu.php b/e107_plugins/comment_menu/comment_menu.php index e6ccf59f4..3ecf58594 100644 --- a/e107_plugins/comment_menu/comment_menu.php +++ b/e107_plugins/comment_menu/comment_menu.php @@ -38,7 +38,7 @@ if (!defined('e107_INIT')) // $cobj = e107::getObject('comment'); - +e107::lan('comment_menu', null); $cobj = e107::getComment(); $menu_pref = e107::getConfig('menu')->getPref(); @@ -83,6 +83,8 @@ require_once (e_PLUGIN."comment_menu/comment_menu_shortcodes.php"); $sc = e107::getScBatch('comment_menu', true); $sc->wrapper('comment_menu'); +$tp = e107::getParser(); + $text .= $tp->parseTemplate($TEMPLATE['start'], true, $sc); foreach ($data as $row) diff --git a/e107_plugins/comment_menu/config.php b/e107_plugins/comment_menu/config.php index d4436966d..b9d0fcea4 100644 --- a/e107_plugins/comment_menu/config.php +++ b/e107_plugins/comment_menu/config.php @@ -11,7 +11,7 @@ */ $eplug_admin = TRUE; -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); require_once(e_HANDLER."userclass_class.php"); e107::includeLan(e_PLUGIN."comment_menu/languages/".e_LANGUAGE.".php"); diff --git a/e107_plugins/contact/e_url.php b/e107_plugins/contact/e_url.php index 067099053..78b92d187 100644 --- a/e107_plugins/contact/e_url.php +++ b/e107_plugins/contact/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/download/admin_download.php b/e107_plugins/download/admin_download.php index 80eb4ce19..a9a7d6676 100644 --- a/e107_plugins/download/admin_download.php +++ b/e107_plugins/download/admin_download.php @@ -17,7 +17,7 @@ $eplug_admin = true; define('DOWNLOAD_DEBUG',FALSE); -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if (!getperms("P") || !e107::isInstalled('download')) { e107::redirect('admin'); @@ -246,6 +246,6 @@ require_once(e_ADMIN."auth.php"); //download/includes/admin.php is auto-loaded. e107::getAdminUI()->runPage(); require_once(e_ADMIN."footer.php"); -exit; + diff --git a/e107_plugins/download/download.php b/e107_plugins/download/download.php index ce1214d3b..18dfe8734 100644 --- a/e107_plugins/download/download.php +++ b/e107_plugins/download/download.php @@ -8,108 +8,113 @@ * */ -if (!defined('e107_INIT')) +if(!defined('e107_INIT')) { - require_once("../../class2.php"); + require_once(__DIR__ . '/../../class2.php'); } -if (!e107::isInstalled('download')) +if(!e107::isInstalled('download')) { e107::redirect(); } - e107::lan('download',false, true); // Loads e_PLUGIN.'download/languages/'.e_LANGUAGE.'/English_front.php' +e107::lan('download', false, true); // Loads e_PLUGIN.'download/languages/'.e_LANGUAGE.'/English_front.php' - $bcList = array( - 'LAN_dl_7' => 'LAN_DESCRIPTION', - 'LAN_dl_10' => 'LAN_SIZE', - 'LAN_dl_11' => 'LAN_IMAGE', - 'LAN_dl_17' => 'LAN_FILES', - 'LAN_dl_18' => 'LAN_PLUGIN_DOWNLOAD_NAME', - 'LAN_dl_19' => 'LAN_CATEGORY', - "LAN_dl_20" => "LAN_FILES", - "LAN_dl_21" => "LAN_SIZE", - "LAN_dl_22" => "LAN_DATE", - "LAN_dl_23" => "LAN_FILE", - "LAN_dl_24" => "LAN_AUTHOR", - "LAN_dl_25" => "LAN_ASCENDING", - "LAN_dl_26" => "LAN_DESCENDING", - "LAN_dl_27" => "LAN_GO", - "LAN_dl_28" => "LAN_NAME", - 'LAN_dl_32' => "LAN_DOWNLOAD", - 'LAN_dl_35' => "LAN_BACK", - ); +$bcList = array( + 'LAN_dl_7' => 'LAN_DESCRIPTION', + 'LAN_dl_10' => 'LAN_SIZE', + 'LAN_dl_11' => 'LAN_IMAGE', + 'LAN_dl_17' => 'LAN_FILES', + 'LAN_dl_18' => 'LAN_PLUGIN_DOWNLOAD_NAME', + 'LAN_dl_19' => 'LAN_CATEGORY', + "LAN_dl_20" => "LAN_FILES", + "LAN_dl_21" => "LAN_SIZE", + "LAN_dl_22" => "LAN_DATE", + "LAN_dl_23" => "LAN_FILE", + "LAN_dl_24" => "LAN_AUTHOR", + "LAN_dl_25" => "LAN_ASCENDING", + "LAN_dl_26" => "LAN_DESCENDING", + "LAN_dl_27" => "LAN_GO", + "LAN_dl_28" => "LAN_NAME", + 'LAN_dl_32' => "LAN_DOWNLOAD", + 'LAN_dl_35' => "LAN_BACK", +); - e107::getLanguage()->bcDefs($bcList); +e107::getLanguage()->bcDefs($bcList); - - require_once(e_PLUGIN.'download/handlers/download_class.php'); - require_once(e_PLUGIN.'download/handlers/category_class.php'); +require_once(e_PLUGIN . 'download/handlers/download_class.php'); +require_once(e_PLUGIN . 'download/handlers/category_class.php'); - $dl = new download(); +$dl = new download(); - if(!defined("USER_WIDTH") && !deftrue('BOOTSTRAP')) { define("USER_WIDTH","width:100%"); } +if(!defined("USER_WIDTH") && !deftrue('BOOTSTRAP')) +{ + define("USER_WIDTH", "width:100%"); +} - /* define images */ - if(deftrue('BOOTSTRAP') && BOOTSTRAP === 3) +/* define images */ +if(deftrue('BOOTSTRAP') && BOOTSTRAP === 3) +{ + define("IMAGE_DOWNLOAD", (file_exists(THEME . "images/download.png") ? THEME . "images/download.png" : 'icon-download.glyph')); + define("IMAGE_NEW", (file_exists(THEME . "images/new.png") ? THEME . "images/new.png" : 'icon-star.glyph')); +} +elseif(deftrue('BOOTSTRAP') && BOOTSTRAP === 4) +{ + define("IMAGE_DOWNLOAD", (file_exists(THEME . "images/download.png") ? THEME . "images/download.png" : 'fa-download.glyph')); + define("IMAGE_NEW", (file_exists(THEME . "images/new.png") ? THEME . "images/new.png" : 'fa-star.glyph')); +} +else +{ + define("IMAGE_DOWNLOAD", (file_exists(THEME . "images/download.png") ? THEME . "images/download.png" : e_IMAGE . "generic/download.png")); + define("IMAGE_NEW", (file_exists(THEME . "images/new.png") ? THEME . "images/new.png" : e_IMAGE . "generic/new.png")); +} + + +$dl->init(); + +// Legacy Comment Save. +if(isset($_POST['commentsubmit'])) +{ + if(!$sql->select("download", "download_comment", "download_id = '{$id}' ")) { - define("IMAGE_DOWNLOAD", (file_exists(THEME."images/download.png") ? THEME."images/download.png" : 'icon-download.glyph')); - define("IMAGE_NEW", (file_exists(THEME."images/new.png") ? THEME."images/new.png" : 'icon-star.glyph')); + e107::redirect(); + exit; } - elseif(deftrue('BOOTSTRAP') && BOOTSTRAP === 4) + else { - define("IMAGE_DOWNLOAD", (file_exists(THEME."images/download.png") ? THEME."images/download.png" : 'fa-download.glyph')); - define("IMAGE_NEW", (file_exists(THEME."images/new.png") ? THEME."images/new.png" : 'fa-star.glyph')); - } - else - { - define("IMAGE_DOWNLOAD", (file_exists(THEME."images/download.png") ? THEME."images/download.png" : e_IMAGE."generic/download.png")); - define("IMAGE_NEW", (file_exists(THEME."images/new.png") ? THEME."images/new.png" : e_IMAGE."generic/new.png")); - } - - - $dl->init(); - - // Legacy Comment Save. - if (isset($_POST['commentsubmit'])) - { - if (!$sql->select("download", "download_comment", "download_id = '{$id}' ")) + $dlrow = $sql->fetch(); + if($dlrow['download_comment'] && (ANON === true || USER === true)) { - e107::redirect(); - exit; - } - else - { - $dlrow = $sql->fetch(); - if ($dlrow['download_comment'] && (ANON === TRUE || USER === TRUE)) - { - $clean_authorname = $_POST['author_name']; - $clean_comment = $_POST['comment']; - $clean_subject = $_POST['subject']; - - e107::getComment()->enter_comment($clean_authorname, $clean_comment, "download", $id, $pid, $clean_subject); - // $e107cache->clear("comment.download.{$sub_action}"); $sub_action not used here - e107::getCache()->clear("comment.download"); - } + $clean_authorname = $_POST['author_name']; + $clean_comment = $_POST['comment']; + $clean_subject = $_POST['subject']; + + e107::getComment()->enter_comment($clean_authorname, $clean_comment, "download", $id, $pid, $clean_subject); + // $e107cache->clear("comment.download.{$sub_action}"); $sub_action not used here + e107::getCache()->clear("comment.download"); } } +} - $dl->load(); +$dl->load(); - if(!defined("e_PAGETITLE")) {define("e_PAGETITLE", LAN_PLUGIN_DOWNLOAD_NAME);} +if(!defined("e_PAGETITLE")) +{ + define("e_PAGETITLE", LAN_PLUGIN_DOWNLOAD_NAME); +} - require_once (HEADERF); +require_once(HEADERF); // echo "
".e_PAGETITLE."
"; - - echo $dl->render(); - - require_once (FOOTERF); - - -exit ; + +echo $dl->render(); + +require_once(FOOTERF); + + + diff --git a/e107_plugins/download/download_shortcodes.php b/e107_plugins/download/download_shortcodes.php index 4b69a33ec..092d5f0b7 100644 --- a/e107_plugins/download/download_shortcodes.php +++ b/e107_plugins/download/download_shortcodes.php @@ -23,7 +23,7 @@ e107::plugLan('download', 'front', true); */ class download_shortcodes extends e_shortcode { - public $qry; + public $qry = array(); public $dlsubrow; public $dlsubsubrow; public $mirror; @@ -45,7 +45,9 @@ class download_shortcodes extends e_shortcode { $breadcrumb = array(); - switch ($this->qry['action']) + $action = varset($this->qry['action']); + + switch ($action) { case 'mirror': $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download', 'index')); @@ -71,7 +73,11 @@ class download_shortcodes extends e_shortcode $breadcrumb[] = array('text' => $this->parent['download_category_name'], 'url' => ($this->parent['download_category_id']) ? e107::url('download', 'category', $this->parent) : null); } - $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => ($this->var['download_category_id']) ? e107::url('download', 'category', $this->var) : null); + if(isset($this->var['download_category_name'])) + { + $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => ($this->var['download_category_id']) ? e107::url('download', 'category', $this->var) : null); + } + $breadcrumb[] = array('text' => varset($this->var['download_name']), 'url' => null); break; } diff --git a/e107_plugins/download/e_url.php b/e107_plugins/download/e_url.php index 89a4317f5..2a734de6c 100644 --- a/e107_plugins/download/e_url.php +++ b/e107_plugins/download/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/download/handlers/category_class.php b/e107_plugins/download/handlers/category_class.php index cfb5b853a..638add31a 100644 --- a/e107_plugins/download/handlers/category_class.php +++ b/e107_plugins/download/handlers/category_class.php @@ -50,7 +50,7 @@ class downloadCategory */ function down_cat_tree($nest_level = 1, $load_cat_class = USERCLASS_LIST, $main_cat_load = '', $accum = FALSE) { - global $sql2; + $sql2 = e107::getDb('sql2'); $catlist = array(); $this->cat_count = 0; diff --git a/e107_plugins/download/handlers/download_class.php b/e107_plugins/download/handlers/download_class.php index 2d24ee61e..6418ce3c7 100644 --- a/e107_plugins/download/handlers/download_class.php +++ b/e107_plugins/download/handlers/download_class.php @@ -99,7 +99,7 @@ class download $tmp = explode('.', e_QUERY); - $order = str_replace("download_","",$pref['download_order']); + $order = str_replace("download_","", varset($pref['download_order'], 'id')); // Set Defaults $this->qry['action'] = 'maincats'; @@ -134,7 +134,7 @@ class download $this->qry['order'] = preg_replace("#\W#", "", $tp->toDB($tmp[4])); $this->qry['sort'] = preg_replace("#\W#", "", $tp->toDB($tmp[5])); } - elseif($tmp[1]) + elseif(!empty($tmp[1])) { $this->qry['action'] = preg_replace("#\W#", "", $tp->toDB($tmp[0])); $this->qry['id'] = intval($tmp[1]); @@ -310,7 +310,7 @@ class download if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:1px solid blue");} // Read in tree of categories which this user is allowed to see - $dlcat = new downloadCategory(varset($pref['download_subsub'],1),USERCLASS_LIST,$maincatval,varset($pref['download_incinfo'],FALSE)); + $dlcat = new downloadCategory(varset($pref['download_subsub'],1),USERCLASS_LIST, null ,varset($pref['download_incinfo'],FALSE)); if ($dlcat->down_count == 0) { diff --git a/e107_plugins/download/request.php b/e107_plugins/download/request.php index 149031de2..e38411c50 100644 --- a/e107_plugins/download/request.php +++ b/e107_plugins/download/request.php @@ -1,449 +1,457 @@ select('download', 'download_id', "download_url='".$tp->toDB(e_QUERY)."'")) + + static function request() { - $row = $sql->fetch(); - $type = 'file'; - $id = $row['download_id']; - } - elseif((strpos(e_QUERY, "http://") === 0) || (strpos(e_QUERY, "ftp://") === 0) || (strpos(e_QUERY, "https://") === 0)) - { - header("location: ".e_QUERY); - exit(); - } - elseif(file_exists(e_DOWNLOAD.e_QUERY)) // 1 - should we allow this? - { - e107::getFile()->send(e_DOWNLOAD.e_QUERY); - exit(); - } -} + + $log = e107::getLog(); + $id = false; + + $sql = e107::getDb(); + $tp = e107::getParser(); + $pref = e107::pref('core'); + + if(!is_numeric(e_QUERY) && empty($_GET['id'])) + { + if($sql->select('download', 'download_id', "download_url='" . $tp->toDB(e_QUERY) . "'")) + { + $row = $sql->fetch(); + $type = 'file'; + $id = $row['download_id']; + } + elseif((strpos(e_QUERY, "http://") === 0) || (strpos(e_QUERY, "ftp://") === 0) || (strpos(e_QUERY, "https://") === 0)) + { + header("location: " . e_QUERY); + exit(); + } + elseif(file_exists(e_DOWNLOAD . e_QUERY)) // 1 - should we allow this? + { + e107::getFile()->send(e_DOWNLOAD . e_QUERY); + exit(); + } + } + if(strpos(e_QUERY, "mirror") !== false) + { // Download from mirror + list($action, $download_id, $mirror_id) = explode(".", e_QUERY); + $download_id = intval($download_id); + $mirror_id = intval($mirror_id); + $qry = "SELECT d.*, dc.download_category_class FROM #download as d LEFT JOIN #download_category AS dc ON dc.download_category_id = d.download_category WHERE d.download_id = {$download_id}"; + if($sql->gen($qry)) + { + $row = $sql->fetch(); + extract($row); + if(check_class($row['download_category_class']) && check_class($row['download_class'])) + { + if($pref['download_limits'] && $row['download_active'] == 1) + { + check_download_limits(); + } + $mirrorList = explode(chr(1), $row['download_mirror']); + $mstr = ""; + foreach($mirrorList as $mirror) + { + if($mirror) + { + $tmp = explode(",", $mirror); + $mid = intval($tmp[0]); + $address = $tmp[1]; + $requests = $tmp[2]; + if($tmp[0] == $mirror_id) + { + $gaddress = trim($address); + $requests++; + } + $mstr .= $mid . "," . $address . "," . $requests . chr(1); + } + } + $sql->update("download", "download_requested = download_requested + 1, download_mirror = '{$mstr}' WHERE download_id = '" . intval($download_id) . "'"); + $sql->update("download_mirror", "mirror_count = mirror_count + 1 WHERE mirror_id = '" . intval($mirror_id) . "'"); + header("Location: " . decorate_download_location($gaddress)); + exit(); + } + + $goUrl = e107::url('download', 'index', null, array('query' => array('action' => 'error', 'id' => 1))); // ."?action=error&id=1"; + e107::redirect($goUrl); + //header("Location: ".e_BASE."download.php?error.{$download_id}.1"); + exit; + } + } + + $tmp = explode(".", e_QUERY); + if(empty($tmp[1]) || strpos(e_QUERY, "pub_") !== false) + { + $id = intval($tmp[0]); + $type = "file"; + } + else + { + $table = preg_replace("#\W#", "", $tp->toDB($tmp[0], true)); + $id = intval($tmp[1]); + $type = "image"; + } + + if(vartrue($_GET['id'])) // SEF URL + { + $id = intval($_GET['id']); + $type = 'file'; + } -if(strpos(e_QUERY, "mirror") !== false) -{ // Download from mirror - list($action, $download_id, $mirror_id) = explode(".", e_QUERY); - $download_id = intval($download_id); - $mirror_id = intval($mirror_id); - $qry = "SELECT d.*, dc.download_category_class FROM #download as d LEFT JOIN #download_category AS dc ON dc.download_category_id = d.download_category WHERE d.download_id = {$download_id}"; - if ($sql->gen($qry)) - { + if(preg_match("#.*\.[a-z,A-Z]{3,4}#", e_QUERY)) + { + if(strpos(e_QUERY, "pub_") !== false) + { + $bid = str_replace("pub_", "", e_QUERY); + if(file_exists(e_UPLOAD . $bid)) + { + e107::getFile()->send(e_UPLOAD . $bid); + exit(); + } + $log->addError("Line" . __LINE__ . ": Couldn't find " . e_UPLOAD . $bid . ""); + } + if(file_exists(e_DOWNLOAD . e_QUERY)) + { + e107::getFile()->send(e_DOWNLOAD . e_QUERY); + exit(); + } + $log->addError("Line" . __LINE__ . ": Couldn't find " . e_DOWNLOAD . e_QUERY); + $log->toFile('download_requests', 'Download Requests', true); // Create a log file and add the log messages + require_once(HEADERF); + e107::getRender()->tablerender(LAN_ERROR, "
" . LAN_FILE_NOT_FOUND . "\n

\n" . LAN_BACK . "
"); + require_once(FOOTERF); + exit(); + } + + if($type == "file") + { + $qry = "SELECT d.*, dc.download_category_class FROM #download as d LEFT JOIN #download_category AS dc ON dc.download_category_id = d.download_category WHERE d.download_id = {$id}"; + if($sql->gen($qry)) + { + $row = $sql->fetch(); + + $row['download_url'] = $tp->replaceConstants($row['download_url']); // must be relative file-path. + + if(check_class($row['download_category_class']) && check_class($row['download_class'])) + { + if($row['download_active'] == 0) // Inactive download - don't allow + { + require_once(HEADERF); + $search = array("[", "]"); + $replace = array("", ""); + + e107::getRender()->tablerender(LAN_ERROR, "
" . str_replace($search, $replace, LAN_dl_78) . '
'); + require_once(FOOTERF); + exit(); + } + + if($pref['download_limits'] && $row['download_active'] == 1) + { + check_download_limits(); + } + extract($row); + if($row['download_mirror']) + { + $array = explode(chr(1), $row['download_mirror']); + $c = (count($array) - 1); + for($i = 1; $i < $c; $i++) + { + $d = mt_rand(0, $i); + $tmp = $array[$i]; + $array[$i] = $array[$d]; + $array[$d] = $tmp; + } + $tmp = explode(",", $array[0]); + $mirror_id = $tmp[0]; + $mstr = ""; + foreach($array as $mirror) + { + if($mirror) + { + $tmp = explode(",", $mirror); + $mid = $tmp[0]; + $address = $tmp[1]; + $requests = $tmp[2]; + if($tmp[0] == $mirror_id) + { + $gaddress = trim($address); + $requests++; + } + $mstr .= $mid . "," . $address . "," . $requests . chr(1); + } + } + $sql->update("download", "download_requested = download_requested + 1, download_mirror = '{$mstr}' WHERE download_id = '" . intval($download_id) . "'"); + $sql->update("download_mirror", "mirror_count = mirror_count + 1 WHERE mirror_id = '" . intval($mirror_id) . "'"); + + header("Location: " . decorate_download_location($gaddress)); + exit(); + } + + // increment download count + $sql->update("download", "download_requested = download_requested + 1 WHERE download_id = '{$id}'"); + $user_id = USER ? USERID : 0; + $ip = e107::getIPHandler()->getIP(false); + $request_data = "'0', '{$user_id}', '{$ip}', '{$id}', '" . time() . "'"; + //add request info to db + $sql->insert("download_requests", $request_data, false); + // if (preg_match("/Binary\s(.*?)\/.*/", $download_url, $result)) + // { + // $bid = $result[1]; + /// $result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id = '{$bid}'"); + // $binary_data = @mysql_result($result, 0, "binary_data"); + // $binary_filetype = @mysql_result($result, 0, "binary_filetype"); + // $binary_name = @mysql_result($result, 0, "binary_name"); + // header("Content-type: {$binary_filetype}"); + // header("Content-length: {$download_filesize}"); + // header("Content-Disposition: attachment; filename={$binary_name}"); + // header("Content-Description: PHP Generated Data"); + // echo $binary_data; + // exit(); + // } + if(strpos($row['download_url'], "http://") !== false || strpos($row['download_url'], "ftp://") !== false || strpos($row['download_url'], "https://") !== false) + { + $download_url = e107::getParser()->parseTemplate($row['download_url'], true); // support for shortcode-driven dynamic URLS. + e107::redirect(decorate_download_location($download_url)); + // header("Location: {$download_url}"); + exit(); + } + else + { + if(file_exists(e_DOWNLOAD . $row['download_url'])) + { + e107::getFile()->send(e_DOWNLOAD . $row['download_url']); + exit(); + } + elseif(file_exists($row['download_url'])) + { + e107::getFile()->send($row['download_url']); + exit(); + } + elseif(file_exists(e_UPLOAD . $row['download_url'])) + { + e107::getFile()->send(e_UPLOAD . $row['download_url']); + exit(); + } + $log->addError("Couldn't find " . e_DOWNLOAD . $row['download_url'] . " or " . $row['download_url'] . " or " . e_UPLOAD . $row['download_url']); + $log->toFile('download_requests', 'Download Requests', true); // Create a log file and add the log messages + } + } + else + { // Download Access Denied. + if((!strpos($pref['download_denied'], ".php") && + !strpos($pref['download_denied'], ".htm") && + !strpos($pref['download_denied'], ".html") && + !strpos($pref['download_denied'], ".shtml") || + (strpos($pref['download_denied'], "signup.php") && USER == true) + )) + { + // $goUrl = e107::getUrl()->create('download/index')."?action=error&id=1"; + $goUrl = e107::url('download', 'index', null, array('query' => array('action' => 'error', 'id' => 1))); + e107::redirect($goUrl); + return; + } + else + { + e107::redirect(trim($pref['download_denied'])); + return; + } + } + } + //else if(strstr(e_QUERY, "pub_")) + // { + /* check to see if public upload and not in download table ... */ + /*$bid = str_replace("pub_", "", e_QUERY); + if($result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id = '$bid' ")) + { + $binary_data = @mysql_result($result, 0, "binary_data"); + $binary_filetype = @mysql_result($result, 0, "binary_filetype"); + $binary_name = @mysql_result($result, 0, "binary_name"); + header("Content-type: {$binary_filetype}"); + header("Content-length: {$download_filesize}"); + header("Content-Disposition: attachment; filename={$binary_name}"); + header("Content-Description: PHP Generated Data"); + echo $binary_data; + exit(); + }*/ + // } + + + $log->addError("Line" . __LINE__ . ": Couldn't find " . e_DOWNLOAD . e_QUERY); + $log->toFile('download_requests', 'Download Requests', true); // Create a log file and add the log messages + require_once(HEADERF); + e107::getRender()->tablerender(LAN_ERROR, "
" . LAN_FILE_NOT_FOUND . "

" . LAN_BACK . "
"); + require_once(FOOTERF); + return; + } + + $sql->select($table, "*", "{$table}_id = '{$id}'"); $row = $sql->fetch(); extract($row); - if (check_class($row['download_category_class']) && check_class($row['download_class'])) - { - if($pref['download_limits'] && $row['download_active'] == 1) - { - check_download_limits(); - } - $mirrorList = explode(chr(1), $row['download_mirror']); - $mstr = ""; - foreach($mirrorList as $mirror) - { - if($mirror) - { - $tmp = explode(",", $mirror); - $mid = intval($tmp[0]); - $address = $tmp[1]; - $requests = $tmp[2]; - if($tmp[0] == $mirror_id) - { - $gaddress = trim($address); - $requests ++; - } - $mstr .= $mid.",".$address.",".$requests.chr(1); - } - } - $sql->update("download", "download_requested = download_requested + 1, download_mirror = '{$mstr}' WHERE download_id = '".intval($download_id)."'"); - $sql->update("download_mirror", "mirror_count = mirror_count + 1 WHERE mirror_id = '".intval($mirror_id)."'"); - header("Location: ".decorate_download_location($gaddress)); - exit(); - } - - $goUrl = e107::url('download', 'index', null, array('query'=>array('action'=>'error','id'=>1))); // ."?action=error&id=1"; - e107::redirect($goUrl); - //header("Location: ".e_BASE."download.php?error.{$download_id}.1"); - exit; - } -} - -$tmp = explode(".", e_QUERY); -if (!$tmp[1] || strpos(e_QUERY, "pub_") !== false) -{ - $id = intval($tmp[0]); - $type = "file"; -} -else -{ - $table = preg_replace("#\W#", "", $tp->toDB($tmp[0], true)); - $id = intval($tmp[1]); - $type = "image"; -} - -if(vartrue($_GET['id'])) // SEF URL -{ - $id = intval($_GET['id']); - $type = 'file'; -} - - - -if (preg_match("#.*\.[a-z,A-Z]{3,4}#", e_QUERY)) -{ - if(strpos(e_QUERY, "pub_") !== false) - { - $bid = str_replace("pub_", "", e_QUERY); - if (file_exists(e_UPLOAD.$bid)) - { - e107::getFile()->send(e_UPLOAD.$bid); - exit(); - } - $log->addError("Line".__LINE__.": Couldn't find ".e_UPLOAD.$bid.""); - } - if (file_exists(e_DOWNLOAD.e_QUERY)) - { - e107::getFile()->send(e_DOWNLOAD.e_QUERY); - exit(); - } - $log->addError("Line".__LINE__.": Couldn't find ".e_DOWNLOAD.e_QUERY); - $log->toFile('download_requests','Download Requests', true); // Create a log file and add the log messages - require_once(HEADERF); - e107::getRender()->tablerender(LAN_ERROR, "
".LAN_FILE_NOT_FOUND."\n

\n".LAN_BACK."
"); - require_once(FOOTERF); - exit(); -} - -if ($type == "file") -{ - $qry = "SELECT d.*, dc.download_category_class FROM #download as d LEFT JOIN #download_category AS dc ON dc.download_category_id = d.download_category WHERE d.download_id = {$id}"; - if ($sql->gen($qry)) - { - $row = $sql->fetch(); - - $row['download_url'] = $tp->replaceConstants($row['download_url']); // must be relative file-path. - - if (check_class($row['download_category_class']) && check_class($row['download_class'])) - { - if ($row['download_active'] == 0) // Inactive download - don't allow - { - require_once(HEADERF); - $search = array("[","]"); - $replace = array("", ""); - - e107::getRender()->tablerender(LAN_ERROR, "
".str_replace($search, $replace, LAN_dl_78).'
'); - require_once(FOOTERF); - exit(); - } - - if($pref['download_limits'] && $row['download_active'] == 1) - { - check_download_limits(); - } - extract($row); - if($row['download_mirror']) - { - $array = explode(chr(1), $row['download_mirror']); - $c = (count($array)-1); - for ($i=1; $i < $c; $i++) - { - $d = mt_rand(0, $i); - $tmp = $array[$i]; - $array[$i] = $array[$d]; - $array[$d] = $tmp; - } - $tmp = explode(",", $array[0]); - $mirror_id = $tmp[0]; - $mstr = ""; - foreach($array as $mirror) - { - if($mirror) - { - $tmp = explode(",", $mirror); - $mid = $tmp[0]; - $address = $tmp[1]; - $requests = $tmp[2]; - if($tmp[0] == $mirror_id) - { - $gaddress = trim($address); - $requests ++; - } - $mstr .= $mid.",".$address.",".$requests.chr(1); - } - } - $sql->update("download", "download_requested = download_requested + 1, download_mirror = '{$mstr}' WHERE download_id = '".intval($download_id)."'"); - $sql->update("download_mirror", "mirror_count = mirror_count + 1 WHERE mirror_id = '".intval($mirror_id)."'"); - - header("Location: ".decorate_download_location($gaddress)); - exit(); - } - - // increment download count - $sql->update("download", "download_requested = download_requested + 1 WHERE download_id = '{$id}'"); - $user_id = USER ? USERID : 0; - $ip = e107::getIPHandler()->getIP(FALSE); - $request_data = "'0', '{$user_id}', '{$ip}', '{$id}', '".time()."'"; - //add request info to db - $sql->insert("download_requests", $request_data, FALSE); - // if (preg_match("/Binary\s(.*?)\/.*/", $download_url, $result)) - // { - // $bid = $result[1]; - /// $result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id = '{$bid}'"); - // $binary_data = @mysql_result($result, 0, "binary_data"); - // $binary_filetype = @mysql_result($result, 0, "binary_filetype"); - // $binary_name = @mysql_result($result, 0, "binary_name"); - // header("Content-type: {$binary_filetype}"); - // header("Content-length: {$download_filesize}"); - // header("Content-Disposition: attachment; filename={$binary_name}"); - // header("Content-Description: PHP Generated Data"); - // echo $binary_data; - // exit(); - // } - if (strpos($row['download_url'], "http://") !== false || strpos($row['download_url'], "ftp://") !== false || strpos($row['download_url'], "https://") !== false) - { - $download_url = e107::getParser()->parseTemplate($row['download_url'],true); // support for shortcode-driven dynamic URLS. - e107::redirect(decorate_download_location($download_url)); - // header("Location: {$download_url}"); - exit(); - } - else - { - if (file_exists(e_DOWNLOAD.$row['download_url'])) - { - e107::getFile()->send(e_DOWNLOAD.$row['download_url']); - exit(); - } - elseif(file_exists($row['download_url'])) - { - e107::getFile()->send($row['download_url']); - exit(); - } - elseif(file_exists(e_UPLOAD.$row['download_url'])) - { - e107::getFile()->send(e_UPLOAD.$row['download_url']); - exit(); - } - $log->addError("Couldn't find ".e_DOWNLOAD.$row['download_url']." or ".$row['download_url']." or ".e_UPLOAD.$row['download_url']); - $log->toFile('download_requests','Download Requests', true); // Create a log file and add the log messages - } - } - else - { // Download Access Denied. - if((!strpos($pref['download_denied'],".php") && - !strpos($pref['download_denied'],".htm") && - !strpos($pref['download_denied'],".html") && - !strpos($pref['download_denied'],".shtml") || - (strpos($pref['download_denied'],"signup.php") && USER == TRUE) - )) - { - // $goUrl = e107::getUrl()->create('download/index')."?action=error&id=1"; - $goUrl = e107::url('download', 'index', null, array('query'=>array('action'=>'error','id'=>1))); - e107::redirect($goUrl); - exit(); - } - else - { - e107::redirect(trim($pref['download_denied'])); - exit(); - } - } - } - //else if(strstr(e_QUERY, "pub_")) -// { - /* check to see if public upload and not in download table ... */ - /*$bid = str_replace("pub_", "", e_QUERY); - if($result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id = '$bid' ")) - { + $image = ($table == "upload" ? $row['upload_ss'] : $row['download_image']); + //if (preg_match("/Binary\s(.*?)\/.*/", $image, $result)) + //{ + /* $bid = $result[1]; + $result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id = '{$bid}'"); $binary_data = @mysql_result($result, 0, "binary_data"); $binary_filetype = @mysql_result($result, 0, "binary_filetype"); $binary_name = @mysql_result($result, 0, "binary_name"); header("Content-type: {$binary_filetype}"); - header("Content-length: {$download_filesize}"); - header("Content-Disposition: attachment; filename={$binary_name}"); - header("Content-Description: PHP Generated Data"); + header("Content-Disposition: inline; filename={$binary_name}"); echo $binary_data; - exit(); - }*/ -// } - - - $log->addError("Line".__LINE__.": Couldn't find ".e_DOWNLOAD.e_QUERY); - $log->toFile('download_requests','Download Requests', true); // Create a log file and add the log messages - require_once(HEADERF); - e107::getRender()->tablerender(LAN_ERROR, "
".LAN_FILE_NOT_FOUND."

".LAN_BACK."
"); - require_once(FOOTERF); - exit(); -} + exit();*/ -$sql->select($table, "*", "{$table}_id = '{$id}'"); -$row = $sql->fetch(); -extract($row); -$image = ($table == "upload" ? $row['upload_ss'] : $row['download_image']); -//if (preg_match("/Binary\s(.*?)\/.*/", $image, $result)) -//{ -/* $bid = $result[1]; - $result = @mysql_query("SELECT * FROM ".MPREFIX."rbinary WHERE binary_id = '{$bid}'"); - $binary_data = @mysql_result($result, 0, "binary_data"); - $binary_filetype = @mysql_result($result, 0, "binary_filetype"); - $binary_name = @mysql_result($result, 0, "binary_name"); - header("Content-type: {$binary_filetype}"); - header("Content-Disposition: inline; filename={$binary_name}"); - echo $binary_data; - exit();*/ - -//} + //} -// $image = ($table == "upload" ? $upload_ss : $download_image); + // $image = ($table == "upload" ? $upload_ss : $download_image); -if (strpos($image, "http") !== FALSE) -{ - e107::redirect($image); - exit(); -} -else -{ - if ($table == "download") - { - require_once(HEADERF); - $imagecaption = ''; // TODO ?name or text Screenshot - - if (file_exists(e_FILE."download/{$image}")) + if(strpos($image, "http") !== false) { - $disp = "
"; + e107::redirect($image); + return; } - else if(file_exists(e_FILE."downloadimages/{$image}")) + else { - $disp = "
"; - } - else - { - $image = $tp->replaceConstants($image,'abs'); - $disp = "
"; - } - - $disp .= "
".LAN_BACK."
"; - - e107::getRender()->tablerender($imagecaption, $disp); - - require_once(FOOTERF); - } else - { - if (is_file(e_UPLOAD.$image)) - { - echo ""; - } - elseif(is_file(e_FILE."downloadimages/{$image}")) - { - echo ""; - } - else - { - require_once(HEADERF); - e107::getRender()->tablerender(LAN_ERROR, "
".LAN_FILE_NOT_FOUND."

".LAN_BACK."
"); - require_once(FOOTERF); - exit; - } - exit(); - } -} - - - -function check_download_limits() -{ - global $pref, $sql, $HEADER; - // Check download count limits - $qry = "SELECT gen_intdata, gen_chardata, (gen_intdata/gen_chardata) as count_perday FROM #generic WHERE gen_type = 'download_limit' AND gen_datestamp IN (".USERCLASS_LIST.") AND (gen_chardata >= 0 AND gen_intdata >= 0) ORDER BY count_perday DESC"; - if($sql->gen($qry)) - { - $limits = $sql->fetch(); - $cutoff = time() - (86400 * $limits['gen_chardata']); - if(USER) - { - $where = "dr.download_request_datestamp > {$cutoff} AND dr.download_request_userid = ".USERID; - } - else - { - $ip = e107::getIPHandler()->getIP(FALSE); - $where = "dr.download_request_datestamp > {$cutoff} AND dr.download_request_ip = '{$ip}'"; - } - $qry = "SELECT COUNT(d.download_id) as count FROM #download_requests as dr LEFT JOIN #download as d ON dr.download_request_download_id = d.download_id AND d.download_active = 1 WHERE {$where} GROUP by dr.download_request_userid"; - if($sql->gen($qry)) - { - $row = $sql->fetch(); - if($row['count'] >= $limits['gen_intdata']) + if($table == "download") { - // Exceeded download count limit - // $goUrl = e107::getUrl()->create('download/index')."?action=error&id=2"; - $goUrl = e107::url('download', 'index', null, array('query'=>array('action'=>'error','id'=>2))); - e107::redirect($goUrl); - // e107::redirect(e_BASE."download.php?error.{$cutoff}.2"); - /* require_once(HEADERF); - $ns->tablerender(LAN_ERROR, LAN_dl_62); - require(FOOTERF); */ - exit(); + require_once(HEADERF); + $imagecaption = ''; // TODO ?name or text Screenshot + + if(file_exists(e_FILE . "download/{$image}")) + { + $disp = "
"; + } + elseif(file_exists(e_FILE . "downloadimages/{$image}")) + { + $disp = "
"; + } + else + { + $image = $tp->replaceConstants($image, 'abs'); + $disp = "
"; + } + + $disp .= "
" . LAN_BACK . "
"; + + e107::getRender()->tablerender($imagecaption, $disp); + + require_once(FOOTERF); + } + else + { + if(is_file(e_UPLOAD . $image)) + { + echo ""; + } + elseif(is_file(e_FILE . "downloadimages/{$image}")) + { + echo ""; + } + else + { + require_once(HEADERF); + e107::getRender()->tablerender(LAN_ERROR, "
" . LAN_FILE_NOT_FOUND . "

" . LAN_BACK . "
"); + require_once(FOOTERF); + } + + return; } } } - // Check download bandwidth limits - $qry = "SELECT gen_user_id, gen_ip, (gen_user_id/gen_ip) as bw_perday FROM #generic WHERE gen_type='download_limit' AND gen_datestamp IN (".USERCLASS_LIST.") AND (gen_user_id >= 0 AND gen_ip >= 0) ORDER BY bw_perday DESC"; - if($sql->gen($qry)) + + + function check_download_limits() { - $limit = $sql->fetch(); - $cutoff = time() - (86400*$limit['gen_ip']); - if(USER) + global $pref, $sql, $HEADER; + // Check download count limits + $qry = "SELECT gen_intdata, gen_chardata, (gen_intdata/gen_chardata) as count_perday FROM #generic WHERE gen_type = 'download_limit' AND gen_datestamp IN (".USERCLASS_LIST.") AND (gen_chardata >= 0 AND gen_intdata >= 0) ORDER BY count_perday DESC"; + if($sql->gen($qry)) { - $where = "dr.download_request_datestamp > {$cutoff} AND dr.download_request_userid = ".USERID; - } - else - { - $ip = e107::getIPHandler()->getIP(FALSE); - $where = "dr.download_request_datestamp > {$cutoff} AND dr.download_request_ip = '{$ip}'"; + $limits = $sql->fetch(); + $cutoff = time() - (86400 * $limits['gen_chardata']); + if(USER) + { + $where = "dr.download_request_datestamp > {$cutoff} AND dr.download_request_userid = ".USERID; + } + else + { + $ip = e107::getIPHandler()->getIP(FALSE); + $where = "dr.download_request_datestamp > {$cutoff} AND dr.download_request_ip = '{$ip}'"; + } + $qry = "SELECT COUNT(d.download_id) as count FROM #download_requests as dr LEFT JOIN #download as d ON dr.download_request_download_id = d.download_id AND d.download_active = 1 WHERE {$where} GROUP by dr.download_request_userid"; + if($sql->gen($qry)) + { + $row = $sql->fetch(); + if($row['count'] >= $limits['gen_intdata']) + { + // Exceeded download count limit + // $goUrl = e107::getUrl()->create('download/index')."?action=error&id=2"; + $goUrl = e107::url('download', 'index', null, array('query'=>array('action'=>'error','id'=>2))); + e107::redirect($goUrl); + // e107::redirect(e_BASE."download.php?error.{$cutoff}.2"); + /* require_once(HEADERF); + $ns->tablerender(LAN_ERROR, LAN_dl_62); + require(FOOTERF); */ + exit(); + } + } } - $qry = "SELECT SUM(d.download_filesize) as total_bw FROM #download_requests as dr LEFT JOIN #download as d ON dr.download_request_download_id = d.download_id AND d.download_active = 1 WHERE {$where} GROUP by dr.download_request_userid"; - if($sql->gen($qry)) + // Check download bandwidth limits + $qry = "SELECT gen_user_id, gen_ip, (gen_user_id/gen_ip) as bw_perday FROM #generic WHERE gen_type='download_limit' AND gen_datestamp IN (".USERCLASS_LIST.") AND (gen_user_id >= 0 AND gen_ip >= 0) ORDER BY bw_perday DESC"; + if($sql->gen($qry)) { - $row = $sql->fetch(); - - if($row['total_bw'] / 1024 > $limit['gen_user_id']) - { //Exceed bandwith limit - // $goUrl = e107::getUrl()->create('download/index')."?action=error&id=2"; - $goUrl = e107::url('download', 'index', null, array('query'=>array('action'=>'error','id'=>2))); - e107::redirect($goUrl); - // e107::redirect(e_BASE."download.php?error.{$cutoff}.2"); - /* require(HEADERF); - $ns->tablerender(LAN_ERROR, LAN_dl_62); - require(FOOTERF); */ - exit(); + $limit = $sql->fetch(); + $cutoff = time() - (86400*$limit['gen_ip']); + if(USER) + { + $where = "dr.download_request_datestamp > {$cutoff} AND dr.download_request_userid = ".USERID; + } + else + { + $ip = e107::getIPHandler()->getIP(FALSE); + $where = "dr.download_request_datestamp > {$cutoff} AND dr.download_request_ip = '{$ip}'"; + } + $qry = "SELECT SUM(d.download_filesize) as total_bw FROM #download_requests as dr LEFT JOIN #download as d ON dr.download_request_download_id = d.download_id AND d.download_active = 1 WHERE {$where} GROUP by dr.download_request_userid"; + if($sql->gen($qry)) + { + $row = $sql->fetch(); + + if($row['total_bw'] / 1024 > $limit['gen_user_id']) + { //Exceed bandwith limit + // $goUrl = e107::getUrl()->create('download/index')."?action=error&id=2"; + $goUrl = e107::url('download', 'index', null, array('query'=>array('action'=>'error','id'=>2))); + e107::redirect($goUrl); + // e107::redirect(e_BASE."download.php?error.{$cutoff}.2"); + /* require(HEADERF); + $ns->tablerender(LAN_ERROR, LAN_dl_62); + require(FOOTERF); */ + exit(); + } } } } + + function decorate_download_location($url) + { + $pref = e107::getPref(); + if ($pref['download_security_mode'] !== 'nginx-secure_link_md5') + return $url; + require_once(__DIR__."/handlers/NginxSecureLinkMd5Decorator.php"); + $decorator = new NginxSecureLinkMd5Decorator($url, $pref); + return $decorator->decorate(); + } + } -function decorate_download_location($url) -{ - $pref = e107::getPref(); - if ($pref['download_security_mode'] !== 'nginx-secure_link_md5') - return $url; - require_once(__DIR__."/handlers/NginxSecureLinkMd5Decorator.php"); - $decorator = new NginxSecureLinkMd5Decorator($url, $pref); - return $decorator->decorate(); -} \ No newline at end of file + +download_request::request(); \ No newline at end of file diff --git a/e107_plugins/faqs/admin_config.php b/e107_plugins/faqs/admin_config.php index df3255dbd..d34fde50e 100644 --- a/e107_plugins/faqs/admin_config.php +++ b/e107_plugins/faqs/admin_config.php @@ -8,7 +8,7 @@ * */ -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); e107::lan('faqs', 'admin',true); //TODO LANS diff --git a/e107_plugins/faqs/e_url.php b/e107_plugins/faqs/e_url.php index f76446735..1a4217eba 100644 --- a/e107_plugins/faqs/e_url.php +++ b/e107_plugins/faqs/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/faqs/faqs.php b/e107_plugins/faqs/faqs.php index 385390765..5543e884a 100644 --- a/e107_plugins/faqs/faqs.php +++ b/e107_plugins/faqs/faqs.php @@ -12,7 +12,7 @@ if (!defined('e107_INIT')) { - require_once("../../class2.php"); + require_once(__DIR__.'/../../class2.php'); } if(file_exists(e_PLUGIN."faqs/controllers/list.php")) // bc for old controller. diff --git a/e107_plugins/featurebox/admin_config.php b/e107_plugins/featurebox/admin_config.php index f431a42eb..813b34a07 100644 --- a/e107_plugins/featurebox/admin_config.php +++ b/e107_plugins/featurebox/admin_config.php @@ -9,7 +9,7 @@ * Featurebox administration * */ -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if (!getperms("P") || !e107::isInstalled('featurebox')) { e107::redirect('admin'); @@ -290,5 +290,5 @@ require_once(e_ADMIN."auth.php"); e107::getAdminUI()->runPage(); require_once(e_ADMIN."footer.php"); -exit; + diff --git a/e107_plugins/forum/e_url.php b/e107_plugins/forum/e_url.php index 8d0633b6a..5413f0629 100644 --- a/e107_plugins/forum/e_url.php +++ b/e107_plugins/forum/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/forum/forum.php b/e107_plugins/forum/forum.php index 0c340229a..445772e03 100644 --- a/e107_plugins/forum/forum.php +++ b/e107_plugins/forum/forum.php @@ -11,7 +11,7 @@ */ if(!defined('e107_INIT')) { - require_once('../../class2.php'); + require_once(__DIR__.'/../../class2.php'); } $e107 = e107::getInstance(); $tp = e107::getParser(); @@ -214,82 +214,6 @@ foreach ($forumList['parents'] as $parent) } -function parse_forum($f, $restricted_string = '') -{ - - global $FORUM_MAIN_FORUM, $forumList, $sc; - - $tp = e107::getParser(); - - if(!empty($forumList['subs']) && is_array($forumList['subs'][$f['forum_id']])) - { - $lastPost = explode('.', $f['forum_lastpost_info']); - $lastpost_datestamp = reset($lastPost); - $ret = parse_subs($forumList, $f['forum_id'], $lastpost_datestamp); - - $f['forum_threads'] += $ret['threads']; - $f['forum_replies'] += $ret['replies']; - if(isset($ret['lastpost_info'])) - { - $f['forum_lastpost_info'] = $ret['lastpost_info']; - $f['forum_lastpost_user'] = $ret['lastpost_user']; - $f['forum_lastpost_user_anon'] = $ret['lastpost_user_anon']; - $f['user_name'] = $ret['user_name']; - } - - $f['text'] = $ret['text']; - } - - $sc->setVars($f); - - $sc->wrapper('forum/main/forum'); - - return $tp->parseTemplate($FORUM_MAIN_FORUM, true, $sc); -} - - - -function parse_subs($forumList, $id, $lastpost_datestamp) -{ - - $tp = e107::getParser(); - $ret = array(); - - $subList = $forumList['subs'][$id]; - - $ret['text'] = ''; - $ret['threads'] = 0; - $ret['replies'] = 0; - - foreach($subList as $sub) - { - // print_a($sub); - - $ret['text'] .= ($ret['text'] ? ', ' : ''); - - $urlData = $sub; - $urlData['parent_sef'] = $forumList['all'][$sub['forum_sub']]['forum_sef']; // = array('parent_sef'=> - $suburl = e107::url('forum','forum', $urlData); - - $ret['text'] .= "".$tp->toHTML($sub['forum_name']).''; - $ret['threads'] += $sub['forum_threads']; - $ret['replies'] += $sub['forum_replies']; - $tmp = explode('.', $sub['forum_lastpost_info']); - - if($tmp[0] > $lastpost_datestamp) - { - $ret['lastpost_info'] = $sub['forum_lastpost_info']; - $ret['lastpost_user'] = $sub['forum_lastpost_user']; - $ret['lastpost_user_anon'] = $sub['forum_lastpost_user_anon']; - $ret['user_name'] = $sub['user_name']; - $lastpost_datestamp = $tmp[0]; - } - } - - - return $ret; -} - //if (e_QUERY == 'track') //{ @@ -468,7 +392,7 @@ function forum_track() $row['thread_sef'] = eHelper::title2sef($row['thread_name'],'dashl'); $data['NEWIMAGE'] = $IMAGE_nonew_small; - + if ($row['thread_datestamp'] > USERLV && !in_array($row['thread_id'], $viewed)) { $data['NEWIMAGE'] = $IMAGE_new_small; @@ -476,7 +400,7 @@ function forum_track() $data['LASTPOSTUSER'] = !empty($row['user_name']) ? " $row['user_name'], 'id' => $row['thread_lastuser']))."'>".$row['user_name']."" : LAN_ANONYMOUS; $data['LASTPOSTDATE'] = $tp->toDate($row['thread_lastpost'],'relative'); - + $buttonId = "forum-track-button-".intval($row['thread_id']); $forumUrl = e107::url('forum','forum',$row); @@ -538,3 +462,82 @@ function forum_track() } + +function parse_forum($f, $restricted_string = '') +{ + + global $FORUM_MAIN_FORUM, $forumList, $sc; + + $tp = e107::getParser(); + + if(!empty($forumList['subs']) && is_array($forumList['subs'][$f['forum_id']])) + { + $lastPost = explode('.', $f['forum_lastpost_info']); + $lastpost_datestamp = reset($lastPost); + $ret = parse_subs($forumList, $f['forum_id'], $lastpost_datestamp); + + $f['forum_threads'] += $ret['threads']; + $f['forum_replies'] += $ret['replies']; + if(isset($ret['lastpost_info'])) + { + $f['forum_lastpost_info'] = $ret['lastpost_info']; + $f['forum_lastpost_user'] = $ret['lastpost_user']; + $f['forum_lastpost_user_anon'] = $ret['lastpost_user_anon']; + $f['user_name'] = $ret['user_name']; + } + + $f['text'] = $ret['text']; + } + + $sc->setVars($f); + + $sc->wrapper('forum/main/forum'); + + return $tp->parseTemplate($FORUM_MAIN_FORUM, true, $sc); +} + + + +function parse_subs($forumList, $id, $lastpost_datestamp) +{ + + $tp = e107::getParser(); + $ret = array(); + + $subList = $forumList['subs'][$id]; + + $ret['text'] = ''; + $ret['threads'] = 0; + $ret['replies'] = 0; + + foreach($subList as $sub) + { + // print_a($sub); + + $ret['text'] .= ($ret['text'] ? ', ' : ''); + + $urlData = $sub; + $urlData['parent_sef'] = $forumList['all'][$sub['forum_sub']]['forum_sef']; // = array('parent_sef'=> + $suburl = e107::url('forum','forum', $urlData); + + $ret['text'] .= "".$tp->toHTML($sub['forum_name']).''; + $ret['threads'] += $sub['forum_threads']; + $ret['replies'] += $sub['forum_replies']; + $tmp = explode('.', $sub['forum_lastpost_info']); + + if($tmp[0] > $lastpost_datestamp) + { + $ret['lastpost_info'] = $sub['forum_lastpost_info']; + $ret['lastpost_user'] = $sub['forum_lastpost_user']; + $ret['lastpost_user_anon'] = $sub['forum_lastpost_user_anon']; + $ret['user_name'] = $sub['user_name']; + $lastpost_datestamp = $tmp[0]; + } + } + + + return $ret; +} + + + diff --git a/e107_plugins/forum/forum_admin.php b/e107_plugins/forum/forum_admin.php index 5be3c8327..bd2f01255 100644 --- a/e107_plugins/forum/forum_admin.php +++ b/e107_plugins/forum/forum_admin.php @@ -9,7 +9,7 @@ */ $eplug_admin = true; -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('P')) { e107::redirect('admin'); diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index ee95bd6bb..693e479b1 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -1756,15 +1756,17 @@ class e107forum $sql = e107::getDb(); $viewed = ''; - if($e107->currentUser['user_plugin_forum_viewed']) + $forumViewed = e107::getUserExt()->get(USERID, 'user_plugin_forum_viewed' ); + + if($forumViewed) { - $viewed = " AND thread_id NOT IN (".$e107->currentUser['user_plugin_forum_viewed'].")"; + $viewed = " AND thread_id NOT IN (".$forumViewed.")"; } $_newqry = ' SELECT DISTINCT f.forum_sub, ft.thread_forum_id FROM `#forum_thread` AS ft LEFT JOIN `#forum` AS f ON f.forum_id = ft.thread_forum_id - WHERE ft.thread_lastpost > '.USERLV.' '.$viewed; + WHERE ft.thread_lastpost > '.defset('USERLV', strtotime('1 month ago') ).' '.$viewed; $ret = array(); diff --git a/e107_plugins/forum/forum_conf.php b/e107_plugins/forum/forum_conf.php index f1bb569b8..64814a853 100644 --- a/e107_plugins/forum/forum_conf.php +++ b/e107_plugins/forum/forum_conf.php @@ -8,7 +8,7 @@ * */ -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); $e107 = e107::getInstance(); if (!$e107->isInstalled('forum')) { diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 7b2ed2321..78213e9e6 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -13,7 +13,7 @@ if(!defined('e107_INIT')) { - require_once('../../class2.php'); + require_once(__DIR__.'/../../class2.php'); } // Now defined in shortcodes that handle the editors diff --git a/e107_plugins/forum/forum_stats.php b/e107_plugins/forum/forum_stats.php index e93e06c7c..a0afcc5f0 100644 --- a/e107_plugins/forum/forum_stats.php +++ b/e107_plugins/forum/forum_stats.php @@ -10,7 +10,7 @@ if(!defined('e107_INIT')) { - require_once('../../class2.php'); + require_once(__DIR__.'/../../class2.php'); } if (!e107::isInstalled('forum')) diff --git a/e107_plugins/forum/forum_test.php b/e107_plugins/forum/forum_test.php index 8a36e7ca1..041516672 100644 --- a/e107_plugins/forum/forum_test.php +++ b/e107_plugins/forum/forum_test.php @@ -1,5 +1,5 @@ isInstalled('forum')) { diff --git a/e107_plugins/forum/forum_viewforum.php b/e107_plugins/forum/forum_viewforum.php index 02394eae9..ada8fd2e6 100644 --- a/e107_plugins/forum/forum_viewforum.php +++ b/e107_plugins/forum/forum_viewforum.php @@ -12,7 +12,7 @@ if(!defined('e107_INIT')) { - require_once('../../class2.php'); + require_once(__DIR__.'/../../class2.php'); } $e107 = e107::getInstance(); if(!e107::isInstalled('forum')) diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index fddfc7edd..42c115495 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -12,7 +12,7 @@ if(!defined('e107_INIT')) { - require_once('../../class2.php'); + require_once(__DIR__.'/../../class2.php'); } e107::lan('forum', "front", true); diff --git a/e107_plugins/gallery/admin_gallery.php b/e107_plugins/gallery/admin_gallery.php index a82b002a0..70a57a9f9 100644 --- a/e107_plugins/gallery/admin_gallery.php +++ b/e107_plugins/gallery/admin_gallery.php @@ -12,7 +12,7 @@ $eplug_admin = true; -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if(!getperms("P") || !e107::isInstalled('gallery')) { diff --git a/e107_plugins/gallery/e_url.php b/e107_plugins/gallery/e_url.php index 977731dac..d788909a3 100644 --- a/e107_plugins/gallery/e_url.php +++ b/e107_plugins/gallery/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/gallery/gallery.php b/e107_plugins/gallery/gallery.php index 7032c6661..a664af139 100644 --- a/e107_plugins/gallery/gallery.php +++ b/e107_plugins/gallery/gallery.php @@ -11,7 +11,7 @@ * Render gallery pages. */ -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if(!e107::isInstalled('gallery')) { diff --git a/e107_plugins/gsitemap/admin_config.php b/e107_plugins/gsitemap/admin_config.php index 51da9b2c7..3fce19a23 100644 --- a/e107_plugins/gsitemap/admin_config.php +++ b/e107_plugins/gsitemap/admin_config.php @@ -9,7 +9,7 @@ * Plugin Administration - gsitemap * */ -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if(!getperms("P") || !e107::isInstalled('gsitemap')) { e107::redirect('admin'); diff --git a/e107_plugins/gsitemap/e_url.php b/e107_plugins/gsitemap/e_url.php index 35b3f5dd5..bcd23ec67 100644 --- a/e107_plugins/gsitemap/e_url.php +++ b/e107_plugins/gsitemap/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/hero/admin_config.php b/e107_plugins/hero/admin_config.php index 330a424f5..5e49995ac 100644 --- a/e107_plugins/hero/admin_config.php +++ b/e107_plugins/hero/admin_config.php @@ -2,7 +2,7 @@ // Generated e107 Plugin Admin Area -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('P')) { e107::redirect('admin'); diff --git a/e107_plugins/import/admin_import.php b/e107_plugins/import/admin_import.php index fa3445660..c955f222f 100644 --- a/e107_plugins/import/admin_import.php +++ b/e107_plugins/import/admin_import.php @@ -33,7 +33,7 @@ Options supported: define('IMPORT_DEBUG',TRUE); // define('IMPORT_DEBUG',TRUE); -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); // define("USE_PERSISTANT_DB",TRUE); diff --git a/e107_plugins/linkwords/admin_config.php b/e107_plugins/linkwords/admin_config.php index ac2bc6513..63e3b2617 100644 --- a/e107_plugins/linkwords/admin_config.php +++ b/e107_plugins/linkwords/admin_config.php @@ -10,7 +10,7 @@ * */ -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('P') || !e107::isInstalled('linkwords')) { diff --git a/e107_plugins/list_new/admin_list_config.php b/e107_plugins/list_new/admin_list_config.php index 6038ca84e..fbc19a2d4 100644 --- a/e107_plugins/list_new/admin_list_config.php +++ b/e107_plugins/list_new/admin_list_config.php @@ -23,7 +23,7 @@ */ //include and require several classes -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if(!getperms("1") || !e107::isInstalled('list_new')) { e107::redirect('admin'); diff --git a/e107_plugins/list_new/list.php b/e107_plugins/list_new/list.php index 8897a7e84..49f0044ae 100644 --- a/e107_plugins/list_new/list.php +++ b/e107_plugins/list_new/list.php @@ -22,7 +22,7 @@ * @subpackage list_new */ -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if (!e107::isInstalled('list_new')) { diff --git a/e107_plugins/log/admin_config.php b/e107_plugins/log/admin_config.php index cd0647312..b7804270b 100644 --- a/e107_plugins/log/admin_config.php +++ b/e107_plugins/log/admin_config.php @@ -10,7 +10,7 @@ * */ -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('P') || !e107::isInstalled('log')) { diff --git a/e107_plugins/log/e_url.php b/e107_plugins/log/e_url.php index 823c4d41e..0bedd6607 100644 --- a/e107_plugins/log/e_url.php +++ b/e107_plugins/log/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/log/log.php b/e107_plugins/log/log.php index f46db701e..0df20f66a 100644 --- a/e107_plugins/log/log.php +++ b/e107_plugins/log/log.php @@ -25,7 +25,7 @@ //error_reporting(0); // error_reporting(E_ALL); define('e_MINIMAL',true); -require_once("../../class2.php"); // More secure to include it. +require_once(__DIR__.'/../../class2.php'); // More secure to include it. header('Cache-Control: no-cache, must-revalidate'); // See if this discourages browser caching header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past diff --git a/e107_plugins/log/stats.php b/e107_plugins/log/stats.php index 6f0c6a9c8..ab4a530c8 100644 --- a/e107_plugins/log/stats.php +++ b/e107_plugins/log/stats.php @@ -11,7 +11,7 @@ if (!defined('e107_INIT')) { - require_once("../../class2.php"); + require_once(__DIR__.'/../../class2.php'); } if (!e107::isInstalled('log')) diff --git a/e107_plugins/log/stats_csv.php b/e107_plugins/log/stats_csv.php index e4180e595..bb8d1d83c 100644 --- a/e107_plugins/log/stats_csv.php +++ b/e107_plugins/log/stats_csv.php @@ -17,7 +17,7 @@ //define('CSV_DEBUG', TRUE); -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('P')) { e107::redirect(); diff --git a/e107_plugins/login_menu/config.php b/e107_plugins/login_menu/config.php index fc85915e7..d845b54b0 100644 --- a/e107_plugins/login_menu/config.php +++ b/e107_plugins/login_menu/config.php @@ -25,7 +25,7 @@ $eplug_admin = TRUE; -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('4')) { e107::redirect('admin'); diff --git a/e107_plugins/news/e_url.php b/e107_plugins/news/e_url.php index 361f4f424..f867fc098 100644 --- a/e107_plugins/news/e_url.php +++ b/e107_plugins/news/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php index 5985f9f35..f5419faa8 100644 --- a/e107_plugins/news/news.php +++ b/e107_plugins/news/news.php @@ -15,7 +15,7 @@ if (!defined('e107_INIT')) { - require_once("../../class2.php"); + require_once(__DIR__.'/../../class2.php'); } diff --git a/e107_plugins/newsfeed/admin_config.php b/e107_plugins/newsfeed/admin_config.php index 7a6aa9ba6..a0685e9d9 100644 --- a/e107_plugins/newsfeed/admin_config.php +++ b/e107_plugins/newsfeed/admin_config.php @@ -10,7 +10,7 @@ // Generated e107 Plugin Admin Area -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('P') || !e107::isInstalled('newsfeed')) { e107::redirect('admin'); diff --git a/e107_plugins/newsfeed/e_url.php b/e107_plugins/newsfeed/e_url.php index c36f86e88..8564ca3a5 100644 --- a/e107_plugins/newsfeed/e_url.php +++ b/e107_plugins/newsfeed/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/newsfeed/newsfeed.php b/e107_plugins/newsfeed/newsfeed.php index 00e54bddd..fcd58f9b5 100644 --- a/e107_plugins/newsfeed/newsfeed.php +++ b/e107_plugins/newsfeed/newsfeed.php @@ -16,7 +16,7 @@ */ if(!defined('e107_INIT')) { - require_once('../../class2.php'); + require_once(__DIR__.'/../../class2.php'); } if (!e107::isInstalled('newsfeed')) diff --git a/e107_plugins/newsletter/admin_config.php b/e107_plugins/newsletter/admin_config.php index 293eb50c0..897319a4c 100644 --- a/e107_plugins/newsletter/admin_config.php +++ b/e107_plugins/newsletter/admin_config.php @@ -11,7 +11,7 @@ */ -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('P')) { e107::redirect('admin'); diff --git a/e107_plugins/newsletter/nl_archive.php b/e107_plugins/newsletter/nl_archive.php index ff139c38a..54984314a 100644 --- a/e107_plugins/newsletter/nl_archive.php +++ b/e107_plugins/newsletter/nl_archive.php @@ -10,7 +10,7 @@ * */ -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!e107::isInstalled('newsletter') || !ADMIN) { e107::redirect(); diff --git a/e107_plugins/online/config.php b/e107_plugins/online/config.php index 6253f0fb3..d89324a1d 100644 --- a/e107_plugins/online/config.php +++ b/e107_plugins/online/config.php @@ -11,7 +11,7 @@ */ $eplug_admin = TRUE; -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); e107::includeLan(e_PLUGIN.'online/languages/'.e_LANGUAGE.'.php'); if (!getperms('1')) diff --git a/e107_plugins/pm/admin_config.php b/e107_plugins/pm/admin_config.php index 0ae3aeccc..81796d239 100644 --- a/e107_plugins/pm/admin_config.php +++ b/e107_plugins/pm/admin_config.php @@ -2,7 +2,7 @@ // Generated e107 Plugin Admin Area -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('P')) { e107::redirect('admin'); diff --git a/e107_plugins/pm/e_url.php b/e107_plugins/pm/e_url.php index d936f9dfd..a241b1b07 100644 --- a/e107_plugins/pm/e_url.php +++ b/e107_plugins/pm/e_url.php @@ -10,7 +10,7 @@ * * if (!defined('e107_INIT')) * { - * require_once("../../class2.php"); + * require_once(__DIR__.'/../../class2.php'); * } * */ diff --git a/e107_plugins/pm/pm.php b/e107_plugins/pm/pm.php index f197ee360..5af0b217e 100755 --- a/e107_plugins/pm/pm.php +++ b/e107_plugins/pm/pm.php @@ -22,7 +22,7 @@ $retrieve_prefs[] = 'pm_prefs'; if(!defined('e107_INIT')) { - require_once("../../class2.php"); + require_once(__DIR__.'/../../class2.php'); } diff --git a/e107_plugins/pm/pm_conf.php b/e107_plugins/pm/pm_conf.php index 9fbead085..4c67f64d9 100755 --- a/e107_plugins/pm/pm_conf.php +++ b/e107_plugins/pm/pm_conf.php @@ -33,7 +33,7 @@ TODO: $retrieve_prefs[] = 'pm_prefs'; $eplug_admin = TRUE; -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!e107::isInstalled('pm') || !getperms('P')) { diff --git a/e107_plugins/poll/admin_config.php b/e107_plugins/poll/admin_config.php index f2b8f1180..da3d5cc5b 100644 --- a/e107_plugins/poll/admin_config.php +++ b/e107_plugins/poll/admin_config.php @@ -8,7 +8,7 @@ * */ -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if (!is_object($tp)) $tp = new e_parse; if (!getperms("P") || !e107::isInstalled('poll')) { diff --git a/e107_plugins/poll/oldpolls.php b/e107_plugins/poll/oldpolls.php index 1456f3520..8b9754688 100644 --- a/e107_plugins/poll/oldpolls.php +++ b/e107_plugins/poll/oldpolls.php @@ -8,7 +8,7 @@ * */ -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if (!e107::isInstalled('poll')) { e107::redirect(); diff --git a/e107_plugins/poll/poll.php b/e107_plugins/poll/poll.php index f2ff1ba3f..443320cff 100644 --- a/e107_plugins/poll/poll.php +++ b/e107_plugins/poll/poll.php @@ -12,7 +12,7 @@ * $Id$ */ -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!e107::isInstalled('poll')) { e107::redirect(); diff --git a/e107_plugins/rss_menu/admin_prefs.php b/e107_plugins/rss_menu/admin_prefs.php index 77216f0ea..cca6c5ff3 100644 --- a/e107_plugins/rss_menu/admin_prefs.php +++ b/e107_plugins/rss_menu/admin_prefs.php @@ -18,7 +18,7 @@ Notes: - using $caption = "whatever", is unneccessary. */ -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if(!getperms("P") || !e107::isInstalled('rss_menu')) { diff --git a/e107_plugins/rss_menu/rss.php b/e107_plugins/rss_menu/rss.php index decdc9f4e..39e73cf7b 100644 --- a/e107_plugins/rss_menu/rss.php +++ b/e107_plugins/rss_menu/rss.php @@ -26,7 +26,7 @@ if (!defined('e107_INIT')) $_E107['minimal'] = true; } - require_once('../../class2.php'); + require_once(__DIR__.'/../../class2.php'); } $e107 = e107::getInstance(); diff --git a/e107_plugins/social/admin_config.php b/e107_plugins/social/admin_config.php index 9ad5e9819..ad873c5cd 100644 --- a/e107_plugins/social/admin_config.php +++ b/e107_plugins/social/admin_config.php @@ -2,7 +2,7 @@ // Generated e107 Plugin Admin Area -require_once('../../class2.php'); +require_once(__DIR__.'/../../class2.php'); if (!getperms('P')) { e107::redirect('admin'); diff --git a/e107_plugins/tinymce4/admin_config.php b/e107_plugins/tinymce4/admin_config.php index 85b570357..86561c525 100644 --- a/e107_plugins/tinymce4/admin_config.php +++ b/e107_plugins/tinymce4/admin_config.php @@ -8,7 +8,7 @@ * * */ -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); if( !e107::isInstalled('tinymce4')) { e107::redirect('admin'); diff --git a/e107_plugins/tinymce4/wysiwyg.php b/e107_plugins/tinymce4/wysiwyg.php index 5b06b3088..21e891d0e 100644 --- a/e107_plugins/tinymce4/wysiwyg.php +++ b/e107_plugins/tinymce4/wysiwyg.php @@ -11,7 +11,7 @@ $_E107['no_online'] = true; $_E107['no_forceuserupdate'] = true; $_E107['no_menus'] = true; $_E107['no_maintenance'] = true; -require_once("../../class2.php"); //TODO Prevent Theme loading. +require_once(__DIR__.'/../../class2.php'); //TODO Prevent Theme loading. /* echo ' diff --git a/e107_plugins/user/usertheme_menu_config.php b/e107_plugins/user/usertheme_menu_config.php index 7c256513f..27b9275ef 100644 --- a/e107_plugins/user/usertheme_menu_config.php +++ b/e107_plugins/user/usertheme_menu_config.php @@ -9,7 +9,7 @@ */ $eplug_admin = TRUE; -require_once("../../class2.php"); +require_once(__DIR__.'/../../class2.php'); e107::includeLan(e_PLUGIN."user_menu/languages/".e_LANGUAGE.".php"); require_once(e_HANDLER.'userclass_class.php'); diff --git a/e107_tests/tests/unit/pluginsTest.php b/e107_tests/tests/unit/pluginsTest.php index 18e7274bc..e1920f283 100644 --- a/e107_tests/tests/unit/pluginsTest.php +++ b/e107_tests/tests/unit/pluginsTest.php @@ -133,6 +133,50 @@ } + public function testPluginScripts() + { + + $core = e107::getPlug()->getCorePluginList(); + + + foreach($core as $plug) + { + $parm = null; // + e107::plugLan($plug, 'global'); // load global language (usually done in class2.php) + e107::getConfig()->setPref('plug_installed/'.$plug, 1); // simulate installed. + + $path = e_PLUGIN.$plug; + $files = scandir($path); + unset($files[0], $files[1]); // . and .. + + foreach($files as $f) + { + $filePath = $path.'/'.$f; + + if(is_dir($filePath) || (strpos($f, '_sql.php') !== false) || strpos($f, '.php') === false) + { + continue; + } + + echo " --- ".$filePath." --- \n"; + ob_start(); + require_once( $filePath); + ob_end_clean(); + // echo $plug.'/'.$f."\n"; + + } + + } + + + } + + + + + + + /** * @see https://github.com/e107inc/e107/issues/3547