From e973a2cdae5e3ddbdf8bdc2e263342445259e0e9 Mon Sep 17 00:00:00 2001 From: Moc Date: Fri, 10 Jan 2014 17:17:38 +0100 Subject: [PATCH 1/3] Fixed PHP notice in user profile (forumpost count) and syntax cleanup --- e107_core/shortcodes/batch/user_shortcodes.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e107_core/shortcodes/batch/user_shortcodes.php b/e107_core/shortcodes/batch/user_shortcodes.php index e5412cdd7..fa5e43d33 100644 --- a/e107_core/shortcodes/batch/user_shortcodes.php +++ b/e107_core/shortcodes/batch/user_shortcodes.php @@ -96,7 +96,7 @@ class user_shortcodes extends e_shortcode } e107::setRegistry('total_chatposts', $chatposts); } - return ($chatposts!=0) ? round(($this->var['user_chats']/$chatposts) * 100, 2): 0; + return ($chatposts != 0) ? round(($this->var['user_chats']/$chatposts) * 100, 2) : 0; } @@ -109,7 +109,7 @@ class user_shortcodes extends e_shortcode $commentposts = $sql->count("comments"); e107::setRegistry('total_commentposts', $commentposts); } - return ($commentposts!=0) ? round(($this->var['user_comments']/$commentposts) * 100, 2): 0; + return ($commentposts != 0) ? round(($this->var['user_comments']/$commentposts) * 100, 2) : 0; } @@ -119,11 +119,11 @@ class user_shortcodes extends e_shortcode $sql = e107::getDb(); if(!$forumposts = e107::getRegistry('total_forumposts')) { - $forumposts = (e107::isInstalled("forum")) ? $sql->count("forum_thread"): 0; + $forumposts = (e107::isInstalled("forum")) ? $sql->count("forum_thread") : 0; e107::setRegistry('total_forumposts', $forumposts); $user_forumposts = $sql->count("forum_thread","(*)","where thread_user=".$this->var['user_id']); } - return ($forumposts!==0) ? round(($user_forumposts/$forumposts) * 100, 2): 0; + return ($forumposts != 0) ? round(($user_forumposts/$forumposts) * 100, 2) : 0; } From fff2a74aa5889938fc2d0aec20b7d8353b156f6d Mon Sep 17 00:00:00 2001 From: nlstart Date: Tue, 4 Mar 2014 00:25:57 +0100 Subject: [PATCH 2/3] Improved merge pull request #496 from Moc --- e107_core/shortcodes/batch/user_shortcodes.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/e107_core/shortcodes/batch/user_shortcodes.php b/e107_core/shortcodes/batch/user_shortcodes.php index 8c203e554..23aad23db 100644 --- a/e107_core/shortcodes/batch/user_shortcodes.php +++ b/e107_core/shortcodes/batch/user_shortcodes.php @@ -92,11 +92,11 @@ class user_shortcodes extends e_shortcode $chatposts = 0; // In case plugin not installed if (e107::isInstalled("chatbox_menu")) { - $chatposts = $sql->count("chatbox"); + $chatposts = intval($sql->count("chatbox")); } e107::setRegistry('total_chatposts', $chatposts); } - return ($chatposts != 0) ? round(($this->var['user_chats']/$chatposts) * 100, 2) : 0; + return ($chatposts > 0) ? round(($this->var['user_chats']/$chatposts) * 100, 2) : 0; } @@ -106,10 +106,10 @@ class user_shortcodes extends e_shortcode $sql = e107::getDb(); if(!$commentposts = e107::getRegistry('total_commentposts')) { - $commentposts = $sql->count("comments"); + $commentposts = intval($sql->count("comments")); e107::setRegistry('total_commentposts', $commentposts); } - return ($commentposts != 0) ? round(($this->var['user_comments']/$commentposts) * 100, 2) : 0; + return ($commentposts > 0) ? round(($this->var['user_comments']/$commentposts) * 100, 2) : 0; } @@ -119,11 +119,11 @@ class user_shortcodes extends e_shortcode $sql = e107::getDb(); if(!$forumposts = e107::getRegistry('total_forumposts')) { - $forumposts = (e107::isInstalled("forum")) ? $sql->count("forum_thread") : 0; + $forumposts = (e107::isInstalled("forum")) ? intval($sql->count("forum_thread")) : 0; e107::setRegistry('total_forumposts', $forumposts); $user_forumposts = $sql->count("forum_thread","(*)","where thread_user=".$this->var['user_id']); } - return ($forumposts != 0) ? round(($user_forumposts/$forumposts) * 100, 2) : 0; + return ($forumposts > 0) ? round(($user_forumposts/$forumposts) * 100, 2) : 0; } From a888c96ce880ddf18de43b0e5097d8982180d408 Mon Sep 17 00:00:00 2001 From: Nathan Pipes Date: Sat, 8 Mar 2014 22:09:17 +0800 Subject: [PATCH 3/3] Fixes isrequired The isrequired flag did not support IP6 localhost, nor did it allow 192.168 addresses, normally used for local private networks. Now it does --- install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.php b/install.php index af959e385..df9b08e08 100644 --- a/install.php +++ b/install.php @@ -386,7 +386,7 @@ class e_install // $page_info = nl2br(LANINS_023); $page_info = "
Please fill in the form below with your MySQL details. If you do not know this information, please contact your hosting provider. You may hover over each field for additional information.
"; $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); - $isrequired = (($_SERVER['SERVER_ADDR'] == "127.0.0.1") || ($_SERVER['SERVER_ADDR'] == "localhost")) ? "" : "required='required'"; // + regex for 198.168.x.x + $isrequired = (($_SERVER['SERVER_ADDR'] == "127.0.0.1") || ($_SERVER['SERVER_ADDR'] == "localhost") || ($_SERVER['SERVER_ADDR'] == "::1") || preg_match('^192\.168\.\d{1,3}\.\d{1,3}$',$_SERVER['SERVER_ADDR'])) ? "" : "required='required'"; // Deals with IP V6, and 192.168.x.x address ranges, could be improved to validate x.x to a valid IP but for this use, I dont think its required to be that picky. $output = "