From ad712f0b0707e3439f7642c577f5bccd7520634a Mon Sep 17 00:00:00 2001 From: Deltik Minecraft Server Date: Fri, 30 Aug 2013 17:13:34 -0500 Subject: [PATCH 1/2] Syncing with upstream after a while... --- class2.php | 23 +- comment.php | 6 +- e107.htaccess | 3 + e107_admin/admin.php | 258 +- e107_admin/admin_log.php | 24 +- e107_admin/auth.php | 40 +- e107_admin/boot.php | 4 +- e107_admin/cpage.php | 133 +- e107_admin/db.php | 12 +- e107_admin/download.php | 1925 -------- e107_admin/footer.php | 4 + e107_admin/header.php | 17 +- e107_admin/image.php | 28 +- e107_admin/includes/infopanel.php | 256 +- e107_admin/language.php | 113 +- e107_admin/links.php | 28 +- e107_admin/menus.php | 225 +- e107_admin/newspost.php | 8 +- e107_admin/phpinfo.php | 8 + e107_admin/plugin.php | 381 +- e107_admin/theme.php | 45 +- e107_admin/update_routines.php | 150 +- e107_admin/userclass2.php | 6 +- e107_core/bbcodes/bb_h.php | 2 +- e107_core/bbcodes/bb_img.php | 18 +- e107_core/bbcodes/bb_youtube.php | 6 +- e107_core/bbcodes/code.bb | 55 - e107_core/bbcodes/hide.bb | 2 +- e107_core/bbcodes/table.bb | 2 +- e107_core/bbcodes/td.bb | 3 +- e107_core/bbcodes/tr.bb | 4 +- .../shortcodes/batch/admin_shortcodes.php | 6 +- .../shortcodes/batch/bbcode_shortcodes.php | 35 +- .../shortcodes/batch/comment_shortcodes.php | 4 +- .../shortcodes/batch/page_shortcodes.php | 8 +- .../shortcodes/batch/user_shortcodes.php | 59 +- e107_core/sql/core_sql.php | 7 +- e107_core/templates/bbcode_template.php | 38 +- e107_core/templates/email_template.php | 1 + e107_core/templates/footer_default.php | 3 + e107_core/templates/fpw_template.php | 16 +- e107_core/templates/header_default.php | 56 +- e107_core/templates/login_template.php | 17 +- e107_core/templates/nextprev_template.php | 5 +- e107_core/templates/page_template.php | 81 +- e107_core/templates/user_template.php | 8 +- e107_core/url/page/url.php | 53 +- e107_core/xml/default_install.xml | 22 +- e107_handlers/admin_handler.php | 8 +- e107_handlers/admin_log_class.php | 231 +- e107_handlers/admin_ui.php | 22 +- e107_handlers/arraystorage_class.php | 13 +- e107_handlers/avatar_handler.php | 11 +- e107_handlers/bbcode_handler.php | 4 +- e107_handlers/comment_class.php | 6 +- e107_handlers/core_functions.php | 104 +- e107_handlers/date_handler.php | 14 +- e107_handlers/db_verify_class.php | 13 +- e107_handlers/e107_class.php | 147 +- e107_handlers/e_marketplace.php | 811 +++- e107_handlers/e_parse_class.php | 256 +- e107_handlers/emote.php | 16 +- e107_handlers/emote_filter.php | 15 +- e107_handlers/file_class.php | 291 +- e107_handlers/form_handler.php | 294 +- e107_handlers/hybridauth/Hybrid/Auth.php | 23 +- e107_handlers/hybridauth/Hybrid/Endpoint.php | 8 +- e107_handlers/hybridauth/Hybrid/Logger.php | 2 +- .../hybridauth/Hybrid/Provider_Adapter.php | 2 +- .../Hybrid/Provider_Model_OAuth1.php | 10 +- .../Hybrid/Provider_Model_OAuth2.php | 4 +- .../Hybrid/Provider_Model_OpenID.php | 9 +- .../hybridauth/Hybrid/Providers/Facebook.php | 20 +- .../Hybrid/Providers/Foursquare.php | 2 +- .../hybridauth/Hybrid/Providers/Google.php | 4 +- .../hybridauth/Hybrid/Providers/LinkedIn.php | 111 +- .../hybridauth/Hybrid/Providers/Live.php | 6 +- .../hybridauth/Hybrid/Providers/MySpace.php | 8 +- .../hybridauth/Hybrid/Providers/Twitter.php | 43 +- .../hybridauth/Hybrid/Providers/Yahoo.php | 4 +- e107_handlers/hybridauth/Hybrid/Storage.php | 15 +- .../Hybrid/resources/config.php.tpl | 2 +- .../thirdparty/Facebook/base_facebook.php | 290 +- .../Hybrid/thirdparty/Facebook/facebook.php | 75 +- .../Facebook/fb_ca_chain_bundle.crt | 4025 ++++++++++++++++- .../Hybrid/thirdparty/LinkedIn/LinkedIn.php | 4 +- .../Hybrid/thirdparty/OAuth/OAuth.php | 27 +- .../Hybrid/thirdparty/OAuth/OAuth2Client.php | 4 +- .../Hybrid/thirdparty/OpenID/LightOpenID.php | 356 +- e107_handlers/iphandler_class.php | 39 +- e107_handlers/mailout_admin_class.php | 4 +- e107_handlers/media_class.php | 2 +- e107_handlers/menu_class.php | 18 +- e107_handlers/menumanager_class.php | 33 +- e107_handlers/news_class.php | 4 +- e107_handlers/notify_class.php | 5 +- e107_handlers/np_class.php | 10 +- e107_handlers/online_class.php | 14 +- e107_handlers/plugin_class.php | 53 +- e107_handlers/pref_class.php | 8 +- e107_handlers/profanity_filter.php | 24 +- e107_handlers/rate_class.php | 2 +- e107_handlers/ren_help.php | 15 +- e107_handlers/secure_img_handler.php | 5 + e107_handlers/session_handler.php | 58 +- e107_handlers/shortcode_handler.php | 13 +- e107_handlers/sitelinks_class.php | 95 +- e107_handlers/theme_handler.php | 209 +- e107_handlers/user_extended_class.php | 8 +- e107_handlers/user_model.php | 10 +- e107_handlers/xml_class.php | 37 +- e107_images/bbcode/heading.png | Bin 52110 -> 0 bytes e107_languages/English/English.php | 102 +- e107_languages/English/admin/lan_download.php | 149 - e107_languages/English/admin/lan_prefs.php | 2 +- e107_languages/English/admin/lan_theme.php | 6 +- e107_languages/English/lan_download.php | 103 - e107_languages/English/lan_np.php | 5 +- e107_languages/English/lan_ren_help.php | 2 +- e107_languages/English/lan_search.php | 14 +- e107_languages/English/lan_signup.php | 1 + e107_plugins/alt_auth/alt_auth_adminmenu.php | 12 +- .../alt_auth/alt_auth_login_class.php | 4 +- e107_plugins/banner/admin_banner.php | 3 +- e107_plugins/chatbox_menu/admin_chatbox.php | 3 +- e107_plugins/chatbox_menu/chatbox_menu.php | 4 +- .../languages/English/English.php | 2 +- e107_plugins/download/download.php | 4 +- .../download/languages/English/download.php | 14 +- e107_plugins/download/request.php | 97 +- e107_plugins/faqs/controllers/list.php | 12 +- e107_plugins/faqs/e_sitelink.php | 4 +- e107_plugins/faqs/faqs.php | 10 +- e107_plugins/faqs/faqs_shortcodes.php | 6 +- e107_plugins/faqs/plugin.xml | 4 +- .../featurebox_category_template.php | 4 +- e107_plugins/forum/e_admin_events.php | 5 +- e107_plugins/forum/e_emailprint.php | 12 +- e107_plugins/forum/e_frontpage.php | 4 +- e107_plugins/forum/e_latest.php | 2 +- e107_plugins/forum/e_linkgen.php | 10 +- e107_plugins/forum/e_notify.php | 7 +- e107_plugins/forum/e_search.php | 2 +- e107_plugins/forum/e_status.php | 2 +- e107_plugins/forum/forum.php | 101 +- e107_plugins/forum/forum_admin.php | 2 +- e107_plugins/forum/forum_class.php | 6 +- e107_plugins/forum/forum_post.php | 47 +- e107_plugins/forum/forum_stats.php | 20 +- e107_plugins/forum/forum_update.php | 2 +- e107_plugins/forum/forum_uploads.php | 3 +- e107_plugins/forum/forum_viewforum.php | 90 +- e107_plugins/forum/forum_viewtopic.php | 92 +- e107_plugins/forum/index.php | 6 +- .../forum/languages/English/English_front.php | 299 +- .../languages/English/lan_forum_conf.php | 4 + .../languages/English/lan_forum_frontpage.php | 4 +- .../languages/English/lan_forum_post.php | 6 +- .../languages/English/lan_forum_viewforum.php | 6 +- .../languages/English/lan_forum_viewtopic.php | 5 +- .../shortcodes/batch/post_shortcodes.php | 45 +- .../shortcodes/batch/view_shortcodes.php | 49 +- .../forum/templates/forum_icons_template.php | 100 +- .../forum/templates/forum_post_template.php | 32 +- .../forum/templates/forum_posted_template.php | 70 +- .../templates/forum_preview_template.php | 14 +- .../forum/templates/forum_template.php | 11 +- .../templates/forum_viewforum_template.php | 24 +- .../templates/forum_viewtopic_template.php | 8 +- e107_plugins/gallery/controllers/index.php | 6 +- e107_plugins/gallery/gallery.php | 8 +- e107_plugins/list_new/list_class.php | 2 +- e107_plugins/log/admin_config.php | 27 +- e107_plugins/log/consolidate.php | 119 +- e107_plugins/log/e_meta.php | 16 +- e107_plugins/log/log.php | 68 +- e107_plugins/log/stats.php | 495 +- e107_plugins/page/e_shortcode.php | 104 +- e107_plugins/page/e_sitelink.php | 22 +- e107_plugins/page/page_navigation_menu.php | 10 +- e107_plugins/pm/pm_shortcodes.php | 2 +- e107_plugins/poll/poll_class.php | 99 +- e107_plugins/tagwords/tagwords_class.php | 11 +- e107_plugins/tagwords/url/url.php | 17 + e107_plugins/tinymce/e_meta.php | 6 + e107_plugins/tinymce/templates/admin.xml | 2 +- e107_plugins/tinymce/templates/mainadmin.xml | 2 +- e107_plugins/user_menu/usertheme_menu.php | 16 +- .../user_menu/usertheme_menu_config.php | 65 +- e107_themes/bootstrap/admin_dark.css | 14 +- e107_themes/bootstrap/admin_style.css | 6 + e107_themes/bootstrap/admin_template.php | 7 +- e107_themes/bootstrap/install/install.xml | 4 +- e107_themes/bootstrap/languages/English.php | 6 +- e107_themes/bootstrap/style.css | 7 +- e107_themes/bootstrap/theme.php | 103 +- e107_themes/bootstrap/theme.xml | 1 + .../css/datetimepicker.css | 58 +- .../js/bootstrap-datetimepicker.min.js | 2 +- .../css/bootstrap-responsive.min.css | 2 +- e107_web/js/bootstrap/css/bootstrap.min.css | 4 +- e107_web/js/bootstrap/js/bootstrap.min.js | 2 +- e107_web/js/chap_script.js | 3 +- e107_web/js/core/admin.jquery.js | 43 + e107_web/js/core/all.jquery.js | 27 +- e107_web/js/core/mediaManager.js | 11 +- e107_web/js/plupload/upload.php | 2 +- fpw.php | 86 +- index.php | 31 + install_.php | 1925 -------- login.php | 6 +- news.php | 3 +- page.php | 189 +- signup.php | 93 +- usersettings.php | 11 +- 215 files changed, 10287 insertions(+), 7297 deletions(-) delete mode 100644 e107_admin/download.php delete mode 100644 e107_core/bbcodes/code.bb delete mode 100644 e107_images/bbcode/heading.png delete mode 100644 e107_languages/English/admin/lan_download.php delete mode 100644 e107_languages/English/lan_download.php delete mode 100644 install_.php diff --git a/class2.php b/class2.php index 78d1150c3..683a7e8d3 100644 --- a/class2.php +++ b/class2.php @@ -578,17 +578,14 @@ if(isset($pref['lan_global_list'])) -$sql->db_Mark_Time('Start: CHAPT challenge'); +$sql->db_Mark_Time('Start: CHAP challenge'); e107::getSession() - ->challenge() // Create a unique challenge string for CHAP login + ->challenge() // Make sure there is a unique challenge string for CHAP login ->check(); // Token protection - - - // // N: misc setups: online user tracking, cache // @@ -613,7 +610,9 @@ if(isset($pref['notify']) && $pref['notify'] == true) // O: Start user session // $sql -> db_Mark_Time('Start: Init session'); -init_session(); +init_session(); // Set up a lot of the user-related constants + + //DEPRECATED but necessary. BC Fix. function getip() @@ -865,7 +864,7 @@ if (!class_exists('e107table', false)) $thm = new $this->themeClass(); } - if(is_object($thm)) + if(is_object(vartrue($thm))) { $thm->tablestyle($caption, $text, $mode, array('menuArea'=>$this->eMenuArea, 'menuCount'=>$this->eMenuCount, 'menuTotal'=>varset($this->eMenuTotal[$this->eMenuArea]), 'setStyle'=>$this->eSetStyle)); } @@ -929,6 +928,8 @@ if (isset($_POST['userlogin']) || isset($_POST['userlogin_x'])) // $usr = new userlogin($_POST['username'], $_POST['userpass'], $_POST['autologin'], varset($_POST['hashchallenge'],'')); } + + // $_SESSION['ubrowser'] check not needed anymore - see session handler // e_QUERY not defined in single entry mod if (($_SERVER['QUERY_STRING'] == 'logout')/* || (($pref['user_tracking'] == 'session') && isset($_SESSION['ubrowser']) && ($_SESSION['ubrowser'] != $ubrowser))*/) @@ -947,7 +948,7 @@ if (($_SERVER['QUERY_STRING'] == 'logout')/* || (($pref['user_tracking'] == 'ses // TODO - should be done inside online handler, more core areas need it (session handler for example) if (isset($pref['track_online']) && $pref['track_online']) { - $sql->db_Update('online', "online_user_id = 0, online_pagecount=online_pagecount+1 WHERE online_user_id = '{$udata}' LIMIT 1"); + $sql->db_Update('online', "online_user_id = 0, online_pagecount=online_pagecount+1 WHERE online_user_id = '{$udata}'"); } // earlier event trigger with user data still available @@ -961,6 +962,7 @@ if (($_SERVER['QUERY_STRING'] == 'logout')/* || (($pref['user_tracking'] == 'ses { session_destroy(); $_SESSION[e_COOKIE]=''; + // @TODO: Need to destroy the session cookie as well (not done by session_destroy() } cookie(e_COOKIE, '', (time() - 2592000)); @@ -1912,6 +1914,11 @@ if(!isset($_E107['no_online']) && varset($pref['track_online'])) */ function cookie($name, $value, $expire=0, $path = e_HTTP, $domain = '', $secure = 0) { + if(!e_SUBDOMAIN || (defined('MULTILANG_SUBDOMAIN') && MULTILANG_SUBDOMAIN === TRUE)) + { + $domain = (e_DOMAIN != FALSE) ? ".".e_DOMAIN : ""; + } + setcookie($name, $value, $expire, $path, $domain, $secure); } diff --git a/comment.php b/comment.php index e4906fe7b..473ea577f 100644 --- a/comment.php +++ b/comment.php @@ -62,16 +62,16 @@ if(e_AJAX_REQUEST) // TODO improve security } - if(varset($_GET['mode']) == 'delete' && vartrue($_POST['itemid'])) + if(varset($_GET['mode']) == 'delete' && vartrue($_POST['itemid']) && ADMIN) { $status = e107::getComment()->deleteComment($_POST['itemid']); - $ret['msg'] = COMLAN_332; + $ret['msg'] = ($status) ? 'Ok' : COMLAN_332; $ret['error'] = ($status) ? false : true; echo json_encode($ret); exit; } - if(varset($_GET['mode']) == 'approve' && vartrue($_POST['itemid'])) + if(varset($_GET['mode']) == 'approve' && vartrue($_POST['itemid']) && ADMIN) { $status = e107::getComment()->approveComment($_POST['itemid']); $ret['msg'] = ($status) ? COMLAN_333 : COMLAN_334; diff --git a/e107.htaccess b/e107.htaccess index 5af85c4e5..0174b7344 100644 --- a/e107.htaccess +++ b/e107.htaccess @@ -63,3 +63,6 @@ RewriteRule .* index.php [L] + +### Enable when developing locally. +### SetEnv E_DEV true diff --git a/e107_admin/admin.php b/e107_admin/admin.php index 270fc92ab..2fc31497a 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -17,17 +17,13 @@ require_once('../class2.php'); include_once(e107::coreTemplatePath('admin_icons')); // Needs to be loaded before infopanel AND in boot.php - - if(vartrue($_GET['iframe']) == 1) { define('e_IFRAME', true); - } $e_sub_cat = 'main'; - if (varset($pref['adminstyle'])=='cascade' || varset($pref['adminstyle'])=='beginner') // Deprecated Admin-include. { $pref['adminstyle'] = 'infopanel'; @@ -45,152 +41,200 @@ if(strpos($pref['adminstyle'], 'infopanel') === 0) } + + require_once(e_ADMIN.'boot.php'); require_once(e_ADMIN.'auth.php'); require_once(e_HANDLER.'upload_handler.php'); + +new admin_start; + + $mes = e107::getMessage(); if (!isset($pref['adminstyle'])) $pref['adminstyle'] = 'infopanel'; // Shouldn't be needed - but just in case -// --- check for htmlarea. -if (is_dir(e_ADMIN.'htmlarea') || is_dir(e_HANDLER.'htmlarea')) + + + +class admin_start { - /*$text = ADLAN_ERR_2."

-
".$HANDLERS_DIRECTORY."htmlarea/
".$ADMIN_DIRECTORY."htmlarea/
"; - $ns -> tablerender(ADLAN_ERR_1, $text);*/ - - $mes->addWarning($HANDLERS_DIRECTORY."htmlarea/
".$ADMIN_DIRECTORY."htmlarea/"); -} + + private $incompat = array( + 'banhelper' => 1.7, + 'slir_admin' => 1.0, + 'facebook_like' => 0.7, + 'unanswered' => 1.4, + 'lightwindow' => '1.0b', + 'aa_jquery' => 1.2, + 'who' => 1.0, + 'ratings' => 4.2, + 'e107slider' => 0.1 + ); -// ------------- Compatibility Check ----------------------------- + private $allowed_types = null; -$installedPlugs = e107::getPref('plug_installed'); - -$incompat = array( - 'banhelper' => 1.7, - 'slir_admin' => 1.0 -); - - -$inCompatText = ""; -$incompatFolders = array_keys($incompat); - -foreach($incompat as $folder => $version) -{ - if(vartrue($installedPlugs[$folder]) && $version == $installedPlugs[$folder]) + + + + function __construct() { - $inCompatText .= "
  • ".$folder." v".$installedPlugs[$folder]."
  • "; + $this->checkWritable(); + $this->checkHtmlarea(); + $this->checkIncompatiblePlugins(); + $this->checkFileTypes(); + $this->checkSuspiciousFiles(); + } -} - -if($inCompatText) -{ - $text = ""; - $mes->addWarning("The following plugins are not compatible with this version of e107 and should be uninstalled: ".$text); -} -/* Not used in 0.8 -// check for old modules. -if(getperms('0') && isset($pref['modules']) && $pref['modules'] && $sql->db_Field("plugin",5) == "plugin_addons") -{ - $mods=explode(",", $pref['modules']); - $thef = "e_module.php"; - foreach ($mods as $mod) + function checkWritable() { - if (is_readable(e_PLUGIN."{$mod}/module.php")) + $mes = e107::getMessage(); + + if(deftrue('e_MEDIA') && !is_writable(e_MEDIA)) { - $mod_found[] = e_PLUGIN."{$mod}/module.php"; - } + $mes->addWarning("The folder ".e_MEDIA." is not writable. Please correct before proceeding."); + } + + if(deftrue('e_SYSTEM') && !is_writable(e_SYSTEM)) + { + $mes->addWarning("The folder ".e_SYSTEM." is not writable. Please correct before proceeding."); + } + } - if($mod_found) + + + + function checkHtmlarea() { - $text = ADLAN_ERR_5." ".$thef.":


    -
    - ".ADLAN_ERR_6." - -
    "; - $ns -> tablerender(ADLAN_ERR_4,$text); - } -} -*/ - -// check for file-types; -$allowed_types = get_filetypes(); // Get allowed types according to filetypes.xml or filetypes.php -if (count($allowed_types) == 0) -{ - $allowed_types = array('zip' => 1, 'gz' => 1, 'jpg' => 1, 'png' => 1, 'gif' => 1); - $mes->addInfo("Setting default filetypes: ".implode(', ',array_keys($allowed_types))); - -} - -//echo "Allowed filetypes = ".implode(', ',array_keys($allowed_types)).'
    '; -// avatar check. -$public = array(e_UPLOAD, e_AVATAR_UPLOAD); -$exceptions = array(".","..","/","CVS","avatars","Thumbs.db",".ftpquota",".htaccess","php.ini",".cvsignore",'e107.htaccess'); - -//TODO use $file-class to grab list and perform this check. -foreach ($public as $dir) -{ - if (is_dir($dir)) - { - if ($dh = opendir($dir)) + $mes = e107::getMessage(); + if (is_dir(e_ADMIN.'htmlarea') || is_dir(e_HANDLER.'htmlarea')) { - while (($file = readdir($dh)) !== false) + $mes->addWarning($HANDLERS_DIRECTORY."htmlarea/
    ".$ADMIN_DIRECTORY."htmlarea/"); + } + } + + + + function checkIncompatiblePlugins() + { + $mes = e107::getMessage(); + + $installedPlugs = e107::getPref('plug_installed'); + + $inCompatText = ""; + $incompatFolders = array_keys($this->incompat); + + foreach($this->incompat as $folder => $version) + { + if(vartrue($installedPlugs[$folder]) && $version == $installedPlugs[$folder]) { - if (is_dir($dir."/".$file) == FALSE && !in_array($file,$exceptions)) + $inCompatText .= "
  • ".$folder." v".$installedPlugs[$folder]."
  • "; + } + } + + if($inCompatText) + { + $text = ""; + $mes->addWarning("The following plugins are not compatible with this version of e107 and should be uninstalled: ".$text."uninstall"); + } + + } + + + function checkFileTypes() + { + $mes = e107::getMessage(); + + $this->allowed_types = get_filetypes(); // Get allowed types according to filetypes.xml or filetypes.php + if (count($this->allowed_types) == 0) + { + $this->allowed_types = array('zip' => 1, 'gz' => 1, 'jpg' => 1, 'png' => 1, 'gif' => 1); + $mes->addInfo("Setting default filetypes: ".implode(', ',array_keys($this->allowed_types))); + + } + } + + + + function checkSuspiciousFiles() + { + $mes = e107::getMessage(); + $public = array(e_UPLOAD, e_AVATAR_UPLOAD); + $exceptions = array(".","..","/","CVS","avatars","Thumbs.db",".ftpquota",".htaccess","php.ini",".cvsignore",'e107.htaccess'); + + //TODO use $file-class to grab list and perform this check. + foreach ($public as $dir) + { + if (is_dir($dir)) + { + if ($dh = opendir($dir)) { - $fext = substr(strrchr($file, "."), 1); - if (!array_key_exists(strtolower($fext),$allowed_types) ) + while (($file = readdir($dh)) !== false) { - if ($file == 'index.html' || $file == "null.txt") + if (is_dir($dir."/".$file) == FALSE && !in_array($file,$exceptions)) { - if (filesize($dir.'/'.$file)) + $fext = substr(strrchr($file, "."), 1); + if (!array_key_exists(strtolower($fext),$this->allowed_types) ) { - $potential[] = str_replace('../', '', $dir).'/'.$file; + if ($file == 'index.html' || $file == "null.txt") + { + if (filesize($dir.'/'.$file)) + { + $potential[] = str_replace('../', '', $dir).'/'.$file; + } + } + else + { + $potential[] = str_replace('../', '', $dir).'/'.$file; + } } } - else - { - $potential[] = str_replace('../', '', $dir).'/'.$file; - } } + closedir($dh); } } - closedir($dh); } + + if (isset($potential)) + { + //$text = ADLAN_ERR_3."

    "; + $mes->addWarning(ADLAN_ERR_3); + $text = ' +
    + View all +
    + '; + // $text .= "Note: Not fully functional at the moment."; $ns = e107::getRender(); return $ns->tablerender("Latest Comments",$text,'core-infopanel_online',true); @@ -667,20 +663,51 @@ EOF; } - function getStats() + private function getStats($type) { - if(file_exists(e_PLUGIN."awstats/awstats.graph.php")) //FIXME Cam: Find a generic solution. + + + if(file_exists(e_PLUGIN."awstats/awstats.graph.php")) { require_once(e_PLUGIN."awstats/awstats.graph.php"); - return; + $stat = new awstats; + + if($data = $stat->getData()) + { + return $data; + } + + // return; } - - if(!e107::isInstalled("log")) + if($type == 'demo') { - return; - } + $data = array(); + $data['labels'] = array("January","February","March","April","May","June","July"); + + + $data['datasets'][] = array( + 'fillColor' => "rgba(220,220,220,0.5)", + 'strokeColor' => "rgba(220,220,220,1)", + 'pointColor ' => "rgba(220,220,220,1)", + 'pointStrokeColor' => "#fff", + 'data' => array(65,59,90,81,56,55,40) + + ); + + $data['datasets'][] = array( + 'fillColor' => "rgba(151,187,205,0.5)", + 'strokeColor' => "rgba(151,187,205,1)", + 'pointColor ' => "rgba(151,187,205,1)", + 'pointStrokeColor' => "#fff", + 'data' => array(28,48,40,19,96,27,100) + ); + + return $data; + } + + $sql = e107::getDB(); @@ -694,9 +721,9 @@ EOF; DESC LIMIT 0,9 "; - if($amount = $sql -> db_Select_gen($qry)) + if($amount = $sql->gen($qry)) { - $array = $sql -> db_getList(); + $array = $sql->db_getList(); $ttotal = 0; $utotal = 0; @@ -772,58 +799,81 @@ EOF; } + $visitors = array(); + $unique = array(); + + ksort($dayarray); foreach($dayarray as $k=>$v) { $unix = strtotime($k); - $day[] = intval(vartrue($v['daytotal'])); + $visitors[] = intval(vartrue($v['daytotal'])); + $unique[] = intval(vartrue($v['dayunique'])); $label[] = "'".date("D",$unix)."'"; } - e107::js('log','js/awesomechart.js'); - e107::js('inline'," - function drawMyChart() - { - if(!!document.createElement('canvas').getContext) //check that the canvas element is supported - { - var mychart = new AwesomeChart('canvas1'); - - mychart.chartType = 'pareto'; - - - mychart.data = [".implode(", ",$day)."]; - mychart.labels = [".implode(", ",$label)."]; - mychart.colors = ['#0088CC', '#FF6600','#0088CC', '#FF6600','#0088CC', '#FF6600','#0088CC', '#FF6600','#0088CC']; - mychart.animate = true; - mychart.animationFrames = 30; - // mychart.randomColors = true; - // mychart.dataValueFontHeight = 20; - mychart.yAxisLabelFontHeight = 15; - mychart.chartMarkerSize = 20; - mychart.chartHorizontalLineStrokeStyle = '#999'; - mychart.chartHorizontalLineWidth = 1; - mychart.draw(); - } - } - - window.onload = drawMyChart; - - "); + $data = array(); + + $data['labels'] = $label; + + //visitors + $data['datasets'][] = array( + 'fillColor' => "rgba(220,220,220,0.5)", + 'strokeColor' => "rgba(220,220,220,1)", + 'pointColor ' => "rgba(220,220,220,1)", + 'pointStrokeColor' => "#fff", + 'data' => $visitors + + ); + + + //Unique Visitors + $data['datasets'][] = array( + 'fillColor' => "rgba(151,187,205,0.5)", + 'strokeColor' => "rgba(151,187,205,1)", + 'pointColor ' => "rgba(151,187,205,1)", + 'pointStrokeColor' => "#fff", + 'data' => $unique + ); + + + + return $data; - // print_a($dayarray);; } - function renderStats() + + + private function renderStats($type) { + + $data = $this->getStats($type); + - return ' - Your web-browser does not support the HTML 5 canvas element. - '; + $cht = e107::getChart(); + $cht->setType('line'); + $cht->setData($data,'canvas'); + $text = $cht->render('canvas'); + + + if($type == 'demo') + { + $text .= "
    These stats are for demonstration purposes only. Install Site Stats Plugin
    "; + } + else + { + $text .= "
    + Visitors    + Unique Visitors +
    "; + } + return $text; + } diff --git a/e107_admin/language.php b/e107_admin/language.php index e71093d0a..dd98ad210 100644 --- a/e107_admin/language.php +++ b/e107_admin/language.php @@ -190,6 +190,7 @@ if (varset($action) == "tools") function findIncludedFiles($script,$reverse=false) { + $mes = e107::getMessage(); $data = file_get_contents($script); @@ -306,9 +307,6 @@ if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans'])) // $lanfile = $_POST['deprecatedLans']; $script = $_POST['deprecatedLans']; - - - if(strpos($script,e_ADMIN)!==false) // CORE { $mes->addDebug("Mode: Core Admin Calculated"); @@ -336,6 +334,11 @@ if(varset($_POST['searchDeprecated']) && varset($_POST['deprecatedLans'])) { $script = e_ADMIN."update_routines.php,".e_ADMIN."e107_update.php"; } + + if(vartrue($_POST['deprecatedLanFile'])) //override. + { + $lanfile = $_POST['deprecatedLanFile']; + } if($res = unused($lanfile, $script, vartrue($_POST['deprecatedLansReverse']))) { @@ -703,8 +706,8 @@ function show_tools() ".LAN_CHECK_1." - - "; $languages = explode(",", e_LANLIST); sort($languages); @@ -738,8 +741,8 @@ function show_tools() ".LANG_LAN_23." - - "; $languages = explode(",", e_LANLIST); sort($languages); @@ -759,17 +762,25 @@ function show_tools() "; + $fl = e107::getFile(); + $fl->mode = 'full'; + + if(!$_SESSION['languageTools_lanFileList']) + { + + $_SESSION['languageTools_lanFileList'] = $fl->get_files(e_BASE,'.*?(English|lan_).*?\.php$','standard',5); + } + $text .= " Search for Deprecated Lans - - + "; - $fl = e107::getFile(); - $fl->mode = 'full'; - $omit = array('languages','\.png','\.gif','templates','handlers'); + + $omit = array('languages','\.png','\.gif','handlers'); $lans = $fl->get_files(e_ADMIN,'.php','standard',0); $fl->setFileFilter(array("^e_")); $plugs = $fl->get_files(e_PLUGIN,'.*?/?.*?\.php',$omit,2); @@ -806,15 +817,52 @@ function show_tools() $depOptions = array( - 0 => "Lan File > Script", - 1 => "Script > Lan File" + 1 => "Script > Lan File", + 0 => "Script < Lan File" + ); $text .= " - ". - $frm->select('deprecatedLansReverse',$depOptions,$_POST['deprecatedLansReverse']). - $frm->admin_button('searchDeprecated',"Check",'other')." - ".(count($lans) + count($plugs))." files found + ". + $frm->select('deprecatedLansReverse',$depOptions,$_POST['deprecatedLansReverse'],'class=select')." "; + + $search = array(e_PLUGIN,e_ADMIN,e_LANGUAGEDIR,e_THEME); + $replace = array("Plugins ","Admin ","Core ","Themes "); + + + $prev = 'Core'; + $text .= ""; + + // $frm->select('deprecatedLanFile',$_SESSION['languageTools_lanFileList'], $_POST['deprecatedLanFile'],'class=select&useValues=1','Select Language File (optional)'). + $text .= $frm->admin_button('searchDeprecated',"Check",'other'); + // $text .= "".(count($lans) + count($plugs))." files found"; + $text .= " "; @@ -1035,9 +1083,7 @@ function unused($lanfile,$script,$reverse=false) $mes = e107::getMessage(); $frm = e107::getForm(); - - unset($_SESSION['language-tools-unused']); // $mes->addInfo("LAN=".$lanfile."
    Script = ".$script); @@ -1137,6 +1183,12 @@ function unused($lanfile,$script,$reverse=false) { $text .= "".$k.""; } + + if($reverse == true) + { + $text .= "Definition"; + } + $text .= " @@ -1175,9 +1227,11 @@ function unused($lanfile,$script,$reverse=false) $text .= $frm->close(); + if($reverse != true) + { + $mes->addInfo("Pink items are likely to be unused LANs.
    Comment out and test thoroughly.
    "); + } - $mes->addInfo("Pink items are likely to be unused LANs.
    Comment out and test thoroughly.
    "); - $ret['text'] = $mes->render().$text; $ret['caption'] = "Deprecated LAN Check (experimental!)"; @@ -1262,11 +1316,12 @@ function compareit($needle,$haystack,$value='',$disabled=FALSE, $reverse=false){ $lines = explode("\n",$script); $text .= ""; + $text2 .= ($reverse == true) ? "" : ""; $count = 1; foreach($lines as $ln) { - if(preg_match("/\b".$needle."\b/i",$ln)) + if(preg_match("/\b".$needle."\b/i",$ln, $mtch)) { if($disabled) { @@ -1277,7 +1332,11 @@ function compareit($needle,$haystack,$value='',$disabled=FALSE, $reverse=false){ $text .= ADMIN_TRUE_ICON; } $text .= " Line:".$count." "; // "' Found"; - + + if($reverse == true) + { + $text2 .= print_a($ln,true); + } $found = TRUE; } @@ -1315,7 +1374,7 @@ function compareit($needle,$haystack,$value='',$disabled=FALSE, $reverse=false){ } } $text .= ""; - + $text2 .= ($reverse == true) ? "" : ""; } // $color = $found ? "" : "background-color:pink"; @@ -1346,7 +1405,7 @@ function compareit($needle,$haystack,$value='',$disabled=FALSE, $reverse=false){ $needle = "".$needle.""; } - return "".$needle .$disabled. "".$text.""; + return "".$needle .$disabled. "".$text.$text2.""; } diff --git a/e107_admin/links.php b/e107_admin/links.php index a32a330f8..b1fe46371 100644 --- a/e107_admin/links.php +++ b/e107_admin/links.php @@ -81,7 +81,7 @@ class links_admin_ui extends e_admin_ui 'link_button' => array('title'=> LAN_ICON, 'type'=>'icon', 'width'=>'5%', 'thclass' => 'center', 'class'=>'center'), 'link_id' => array('title'=> LAN_ID, 'type'=>'text','readParms'=>'link=link_url&target=dialog','noedit'=>TRUE), 'link_name' => array('title'=> LCLAN_15, 'width'=>'auto','type'=>'text', 'inline'=>true, 'required' => true, 'validate' => true), - 'link_category' => array('title'=> LAN_TEMPLATE, 'type' => 'dropdown', 'inline'=>true, 'batch'=>true, 'filter'=>true, 'width' => 'auto'), + 'link_category' => array('title'=> LAN_TEMPLATE, 'type' => 'dropdown', 'inline'=>true, 'batch'=>true, 'filter'=>true, 'width' => 'auto'), 'link_parent' => array('title'=> 'Sublink of', 'type' => 'method', 'width' => 'auto', 'batch'=>true, 'filter'=>true, 'thclass' => 'left first'), 'link_url' => array('title'=> LAN_URL, 'width'=>'auto', 'type'=>'text', 'inline'=>true, 'required'=>true,'validate' => true), @@ -521,7 +521,8 @@ class links_model_admin_tree extends e_admin_tree_model $src[$id] = $model; if($modified) { - $model->set('link_name', $level_image.$this->bcClean($model->get('link_name'))); + $model->set('link_name', $this->bcClean($model->get('link_name'))) + ->set('link_indent', $level_image); } $this->_tree_order($id, $search, $src, $level + 1, $modified); } @@ -675,6 +676,27 @@ class links_admin_form_ui extends e_admin_form_ui $this->_parents($link_id, $cats, $path, false); return in_array($parent_id, $path); } + + /** + * New core feature - triggered before values are rendered + */ + function renderValueTrigger(&$field, &$value, &$params, $id) + { + if($field !== 'link_name') return; + $tree = $this->getController()->getTreeModel(); + // notify we need modified tree + $tree->modify = true; + + //retrieve array of data models + $data = $tree->getTree(); + // retrieve the propper model by id + $model = varset($data[$id]); + + if(!$model) return; + + // Add indent as 'pre' parameter + $params['pre'] = $model->get('link_indent'); + } /** * Override Create list view @@ -691,7 +713,7 @@ class links_admin_form_ui extends e_admin_form_ui $tree = $options = array(); $tree[$id] = clone $controller->getTreeModel(); $tree[$id]->modify = true; - + // if going through confirm screen - no JS confirm $controller->setFieldAttr('options', 'noConfirm', $controller->deleteConfirmScreen); diff --git a/e107_admin/menus.php b/e107_admin/menus.php index 1f3f0398f..657adb0ff 100644 --- a/e107_admin/menus.php +++ b/e107_admin/menus.php @@ -77,9 +77,12 @@ if(strpos(e_QUERY, 'configure') !== FALSE || vartrue($_GET['enc'])) var target = window.parent.$('#e-save-form').attr('action'); var data = window.parent.$('#e-save-form').serialize(); + + alert(data); $.post(target, data ,function(ret) { + alert('Posted: '+ret); var a = $.parseJSON(ret); if(a.error) @@ -94,7 +97,7 @@ if(strpos(e_QUERY, 'configure') !== FALSE || vartrue($_GET['enc'])) window.parent.$('#uiModal').modal('show'); - + return false; }) ; @@ -118,6 +121,7 @@ if(strpos(e_QUERY, 'configure') !== FALSE || vartrue($_GET['enc'])) }).done(function( data ) { + var a = $.parseJSON(data); if(a.error) @@ -470,6 +474,39 @@ class e_layout $this->processPost(); } + + if(vartrue($_GET['enc'])) + { + $string = base64_decode($_GET['enc']); + parse_str($string,$_GET); + } + + if(vartrue($_GET['vis'])) + { + $text = $this->renderVisibilityOptions(); + } + + // print_a($_GET); + + if(vartrue($_GET['parmsId'])) + { + $text = $this->renderInstanceParameters(); + } + + if(vartrue($_POST['mode'])) + { + print_r($_POST); + // $men->setMenuId($this->menuId); + $text = $this->menuSaveAjax($_POST['mode']); + } + + + + echo $text; + + + + exit; } @@ -816,13 +853,16 @@ class e_layout // $area = 'area_'.$area; // 'layout' and 'area' will later be substituted. - $text .= $frm->hidden('data[layout][area]['.$c.'][name]',$row['name'] ); - $text .= $frm->hidden('data[layout][area]['.$c.'][class]',$row['class'] ); - $text .= $frm->hidden('data[layout][area]['.$c.'][path]',$row['path'] ); - $text .= $frm->hidden('data[layout][area]['.$c.'][pages]',$row['pages'] ); - $text .= $frm->hidden('data[layout][area]['.$c.'][parms]',$row['parms'] ); + + + + $text .= $frm->hidden('data[layout][area]['.$c.'][name]',$row['name'],array('id'=>'name-'.$area.'-'.$c) ); + $text .= $frm->hidden('data[layout][area]['.$c.'][class]',$row['class'], array('id'=>'class-'.$area.'-'.$c) ); + $text .= $frm->hidden('data[layout][area]['.$c.'][path]',$row['path'], array('id'=>'path-'.$area.'-'.$c) ); + $text .= $frm->hidden('data[layout][area]['.$c.'][pages]',$row['pages'], array('id'=>'pages-'.$area.'-'.$c) ); + $text .= $frm->hidden('data[layout][area]['.$c.'][parms]',$row['parms'], array('id'=>'parms-'.$area.'-'.$c) ); - $visibilityLink = e_SELF."?enc=".base64_encode('lay='.$layout.'&vis='.$c.'&iframe=1'); + $visibilityLink = e_SELF."?enc=".base64_encode('lay='.$layout.'&vis='.$area.'-'.$c.'&iframe=1&class='.$row['class'].'&pages='.$row['pages']); $text .= "×"; // $('.hello').remove(); @@ -863,7 +903,35 @@ class e_layout } + + function menuSaveAjax($mode = null) + { + print_r($_POST); + return; + + if($mode == 'visibility') + { + + $ret = $this->menuSaveVisibility(); + echo json_encode($ret); + return; + } + + + if($mode == 'parms') + { + $ret = $this->menuSaveParameters(); + echo json_encode($ret); + return; + } + + + + print_r($_POST); + return; + + } /** * Scan Plugin folders for new _menu files. @@ -882,7 +950,7 @@ class e_layout if (file_exists($file['path'].'/plugin.xml') || file_exists($file['path'].'/plugin.php')) { - if (e107::isInstalled($parent_dir)) + // if (e107::isInstalled($file['path'])) //FIXME need a check that doesn't exlude page, news and others that don't require installation. { $valid_menu = TRUE; // Whether new or existing, include in list } @@ -907,9 +975,148 @@ class e_layout } + private function renderVisibilityOptions() + { + if(!vartrue($_GET['vis'])) return; + + // print_a($_GET); + + + $sql = e107::getDb(); + $ns = e107::getRender(); + $frm = e107::getForm(); + + require_once(e_HANDLER."userclass_class.php"); + + /* + if(!$sql->select("menus", "*", "menu_id=".intval($_GET['vis']))) + { + $this->menuAddMessage("Couldn't Load Menu",E_MESSAGE_ERROR); + return; + } + + $row = $sql->fetch(); + */ + + + $listtype = substr($_GET['pages'], 0, 1); + $menu_pages = substr($_GET['pages'], 2); + $menu_pages = str_replace("|", "\n", $menu_pages); + + $text = "
    +
    +
    + ". MENLAN_7." ".$row['menu_name']." + + + + + +
    + ".MENLAN_4." ". + r_userclass('menu_class', intval($_GET['class']), "off", "public,member,guest,admin,main,classes,nobody")." +
    + "; + + $checked = ($listtype == 1) ? " checked='checked' " : ""; + + $text .= $frm->radio('listtype', 1, $checked, array('label'=>MENLAN_26, 'class'=> 'e-save')); + $text .= "
    "; + // $text .= " ".MENLAN_26."
    "; + $checked = ($listtype == 2) ? " checked='checked' " : ""; + + $text .= $frm->radio('listtype', 2, $checked, array('label'=>MENLAN_27, 'class'=> 'e-save')); + + + // $text .= " ".MENLAN_27."
    "; + + $text .= "
    +
    + +
    + + +
    +
    ".MENLAN_28."
    +
    "; + + $text .= $frm->hidden('mode','visibility'); + $text .= $frm->hidden('menu_id',$_GET['vis']); // is NOT an integer + + /* + $text .= " +
    "; + $text .= $frm->admin_button('class_submit', MENLAN_6, 'update'); + + +
    "; + */ + $text .= " +
    +
    +
    "; + + + return $text; + //$caption = MENLAN_7." ".$row['menu_name']; + //$ns->tablerender($caption, $text); + //echo $text; + } + + /** + * This one will be greatly extended, allowing menus to offer UI and us + * settings per instance later ($parm variable available for menus - same as shortcode's $parm) + */ + private function renderInstanceParameters() + { + if(!vartrue($_GET['parmsId'])) return; + $id = intval($_GET['parmsId']); + $frm = e107::getForm(); + $sql = e107::getDb(); + + if(!$sql->select("menus", "*", "menu_id=".$id)) + { + $this->menuAddMessage("Couldn't Load Menu",E_MESSAGE_ERROR); + return; + }; + $row = $sql->fetch(); + + // TODO lan + $text = "
    +
    +
    + Menu parameters ".$row['menu_name']." + + + + +
    + Parameters (query string format): + ".$frm->text('menu_parms', $row['menu_parms'], 900, 'class=e-save span7')." +
    "; + /* + + $text .= " +
    "; + $text .= $frm->admin_button('parms_submit', LAN_SAVE, 'update'); + $text .= " +
    "; + + */ + $text .= $frm->hidden('mode','parms'); + $text .= $frm->hidden('menu_id',$id); + $text .= " +
    +
    +
    "; + + return $text; + + } + /** * Render the main area with TABS and iframes. */ @@ -1133,7 +1340,7 @@ if($_POST) //BC - configure and dot delimiter deprecated if (!isset($_GET['configure'])) { - $men->menuScanMenus(); +// $men->menuScanMenus(); // - Runs 2x - Is already called by menuModify() in menumanager_class.php $text = $men->menuRenderMessage(); $text .= $men->menuSelectLayout(); $text .= $men->menuVisibilityOptions(); diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index c3a0470e2..4485438e3 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -1306,7 +1306,7 @@ class admin_newspost $ix = new news; // jQuery UI temporary date-time fix - inputdatetime -> inputdate - $_POST['news_start'] = vartrue(e107::getDate()->convert($_POST['news_start'],'inputdate'), 0); + $_POST['news_start'] = vartrue(e107::getDate()->convert($_POST['news_start'],'inputdatetime'), 0); if($_POST['news_start']) { @@ -1319,7 +1319,7 @@ class admin_newspost if($_POST['news_end']) { - $_POST['news_end'] = e107::getDate()->convert($_POST['news_end'],'inputdate'); + $_POST['news_end'] = e107::getDate()->convert($_POST['news_end'],'inputdatetime'); } else { @@ -1328,7 +1328,7 @@ class admin_newspost if($_POST['news_datestamp']) { - $_POST['news_datestamp'] = e107::getDate()->convert($_POST['news_datestamp'],'inputdate'); + $_POST['news_datestamp'] = e107::getDate()->convert($_POST['news_datestamp'],'inputdatetime'); } else { @@ -2427,7 +2427,7 @@ class admin_newspost
    "; - $text .= $frm->datepicker("news_datestamp",vartrue($_POST['news_datestamp']),"type=date"); //XXX should be 'datetime' when working correctly. + $text .= $frm->datepicker("news_datestamp",vartrue($_POST['news_datestamp']),"type=datetime"); //XXX should be 'datetime' when working correctly. $text .= "
    "; /* diff --git a/e107_admin/phpinfo.php b/e107_admin/phpinfo.php index 504790755..c6a924ab0 100644 --- a/e107_admin/phpinfo.php +++ b/e107_admin/phpinfo.php @@ -56,6 +56,14 @@ $security_risks = array( $mes->addWarning("".$risk.": ".$diz); } } + + if($sessionSavePath = ini_get('session.save_path')) + { + if(!is_writable($sessionSavePath)) + { + $mes->addError("session.save_path is not writable! That can cause major issues with your site."); + } + } // $phpinfo = preg_replace("#^.*#is", "", $phpinfo); diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index 73fc3d410..67c40b70b 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -17,101 +17,6 @@ if (!getperms("Z")) exit; } -// Only tested Locally so far. -if(e_AJAX_REQUEST && isset($_GET['src'])) // Ajax -{ - $string = base64_decode($_GET['src']); - parse_str($string,$p); - $remotefile = $p['plugin_url']; - - $localfile = md5($remotefile.time()).".zip"; - $status = "Downloading..."; - - $fl = e107::getFile(); - $fl->setAuthKey($e107SiteUsername,$e107SiteUserpass); - $fl->download($remotefile,'plugin'); - - exit; - - /* - - - - - - if(!file_exists(e_TEMP.$localfile)) - { - echo 'There was a problem retrieving the file'; - exit; - } - else - { - $contents = file_get_contents(e_TEMP.$localfile); - if($contents == 'LOGIN') - { - echo "
    Please login to your e107.org account and try again
    "; - exit; - } - } - - echo "Disabed"; - exit; - -// chmod(e_PLUGIN,0777); - chmod(e_TEMP.$localfile,0755); - - require_once(e_HANDLER."pclzip.lib.php"); - $archive = new PclZip(e_TEMP.$localfile); - $unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_PLUGIN, PCLZIP_OPT_SET_CHMOD, 0755)); -// chmod(e_PLUGIN,0755); - $dir = basename($unarc[0]['filename']); -// chmod(e_UPLOAD.$localfile,0666); - - - */ - /* Cannot use this yet until 'folder' is included in feed. - if($dir != $p['plugin_folder']) - { - - echo "
    There is a problem with the data submitted by the author of the plugin."; - echo "dir=".$dir; - echo "
    pfolder=".$p['plugin_folder']; - exit; - } - */ - /* - if($unarc[0]['folder'] ==1 && is_dir($unarc[0]['filename'])) - { - $status = "Unzipping..."; - $dir = basename($unarc[0]['filename']); - $plugPath = preg_replace("/[^a-z0-9-\._]/", "-", strtolower($dir)); - - e107::getSingleton('e107plugin')->update_plugins_table('update'); - e107::getDb()->gen("SELECT plugin_id FROM #plugin WHERE plugin_path = '".$plugPath."' LIMIT 1"); - $row = e107::getDb()->db_Fetch(MYSQL_ASSOC); - $status = e107::getSingleton('e107plugin')->install_plugin($row['plugin_id']); - //unlink(e_UPLOAD.$localfile); - - } - else - { - // print_a($fileList); - $status = "Error:
    Download Manually"; - //echo $archive->errorInfo(true); - // $status = "There was a problem"; - //unlink(e_UPLOAD.$localfile); - } - - echo $status; -// @unlink(e_TEMP.$localfile); - -// echo "file=".$file; - exit; - - */ - -} - e107::coreLan('plugin', true); $e_sub_cat = 'plug_manage'; @@ -123,7 +28,38 @@ global $user_pref; require_once(e_HANDLER.'plugin_class.php'); require_once(e_HANDLER.'file_class.php'); +$plugin = new e107plugin; +$pman = new pluginManager; +define("e_PAGETITLE",ADLAN_98." - ".$pman->pagetitle); +if(e_AJAX_REQUEST && isset($_GET['action'])) // Ajax +{ + if($_GET['action'] == 'download') + { + $string = base64_decode($_GET['src']); + parse_str($string, $p); + + $mp = $pman->getMarketplace(); + $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); + // Server flush useless. It's ajax ready state 4, we can't flush (sadly) before that (at least not for all browsers) + echo "
    Connecting...\n"; flush(); // FIXME change the modal default label, default is Loading...
    +		// download and flush
    +		$mp->download($p['plugin_id'], $p['plugin_mode'], 'plugin');
    +		
    +		echo "
    "; flush(); + } + /*$string = base64_decode($_GET['src']); + parse_str($string,$p); + $remotefile = $p['plugin_url']; + + $localfile = md5($remotefile.time()).".zip"; + $status = "Downloading..."; + + $fl = e107::getFile(); + $fl->setAuthKey($e107SiteUsername,$e107SiteUserpass); + $fl->download($remotefile,'plugin');*/ + exit; +} if(isset($_POST['uninstall_cancel'])) { @@ -222,11 +158,6 @@ class pluginmanager_form extends e_form } - - -$plugin = new e107plugin; -$pman = new pluginManager; -define("e_PAGETITLE",ADLAN_98." - ".$pman->pagetitle); require_once("auth.php"); $pman->pluginObserver(); $mes = e107::getMessage(); @@ -255,6 +186,12 @@ class pluginManager{ var $fieldpref; var $titlearray = array(); var $pagetitle; + + /** + * Marketplace handler instance + * @var e_marketplace + */ + var $mp; protected $pid = 'plugin_id'; @@ -304,11 +241,6 @@ class pluginManager{ $keys = array_keys($this -> titlearray); $this->pagetitle = (in_array($this->action,$keys)) ? $this -> titlearray[$this->action] : $this -> titlearray['installed']; - - - - - /* if(isset($_POST['uninstall-selected'])) { foreach($_POST['checkboxes'] as $val) @@ -325,7 +257,19 @@ class pluginManager{ } - + /** + * Temporary, e107::getMarketplace() coming soon + * @return e_marketplace + */ + public function getMarketplace() + { + if(null === $this->mp) + { + require_once(e_HANDLER.'e_marketplace.php'); + $this->mp = new e_marketplace(); // autodetect the best method + } + return $this->mp; + } @@ -445,7 +389,7 @@ class pluginManager{ function pluginOnline() { - global $plugin; + global $plugin, $e107SiteUsername, $e107SiteUserpass; $tp = e107::getParser(); $frm = e107::getForm(); @@ -456,61 +400,74 @@ class pluginManager{ $mes = e107::getMessage(); // $mes->addWarning("Some older plugins may produce unpredictable results."); - - $from = intval(varset($_GET['frm'])); + // check for cURL + if(!function_exists(curl_init)) + { + $mes->addWarning("cURL is currently required to use this feature. Contact your webhosting provider to enable cURL"); // TODO LAN? + } + + //TODO use admin_ui including filter capabilities by sending search queries back to the xml script. + $from = isset($_GET['frm']) ? intval($_GET['frm']) : 0; $srch = preg_replace('/[^\w]/','', vartrue($_GET['srch'])); - + + $mp = $this->getMarketplace(); + // auth + $mp->generateAuthKey($e107SiteUsername, $e107SiteUserpass); + + // do the request, retrieve and parse data + $xdata = $mp->call('getList', array( + 'type' => 'plugin', + 'params' => array('limit' => 10, 'search' => $srch, 'from' => $from) + )); + $total = $xdata['params']['count']; + + // OLD BIT OF CODE -------------------------------> + /* // $file = SITEURLBASE.e_PLUGIN_ABS."release/release.php"; // temporary testing $file = "http://e107.org/feed?type=plugin&frm=".$from."&srch=".$srch."&limit=10"; $xml->setOptArrayTags('plugin'); // make sure 'plugin' tag always returns an array $xdata = $xml->loadXMLfile($file,'advanced'); - $total = $xdata['@attributes']['total']; + $total = $xdata['@attributes']['total'];*/ + // OLD BIT OF CODE END -------------------------------> - //TODO use admin_ui including filter capabilities by sending search queries back to the xml script. - - // XML data array. + $c = 1; - foreach($xdata['plugin'] as $r) + foreach($xdata['data'] as $row) { - $row = $r['@attributes']; + //$row = $r['@attributes']; $badge = $this->compatibilityLabel($row['compatibility']);; $featured = ($row['featured']== 1) ? " Featured" : ''; $price = ($row['price'] > 0) ? "".$row['price']." credits" : "Free"; $data[] = array( - 'plugin_id' => $c, + 'plugin_id' => $row['params']['id'], + 'plugin_mode' => $row['params']['mode'], 'plugin_icon' => vartrue($row['icon'],e_IMAGE."admin_images/plugins_32.png"), - 'plugin_name' => stripslashes($row['name']).$featured, + 'plugin_name' => stripslashes($row['name']), + 'plugin_featured' => $featured, 'plugin_folder' => $row['folder'], 'plugin_date' => vartrue($row['date']), - 'plugin_category' => vartrue($r['category'][0]), + 'plugin_category' => vartrue($row['category'], 'n/a'), 'plugin_author' => vartrue($row['author']), 'plugin_version' => $row['version'], - 'plugin_description' => nl2br(vartrue($r['description'][0])), + 'plugin_description' => nl2br(vartrue($row['description'])), 'plugin_compatible' => $badge, 'plugin_website' => vartrue($row['authorUrl']), - 'plugin_url' => $row['url'], + //'plugin_url' => $row['url'], 'plugin_notes' => '', 'plugin_price' => $price ); $c++; } - -// print_a($data); + $fieldList = $this->fields; unset($fieldList['checkboxes']); - - - - - - - + $text = "