-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Performance 4 (plugins) #12228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance 4 (plugins) #12228
Changes from 26 commits
d020e05
f8d247c
bcd8841
e1288c3
fdd996c
dfc5b98
aac1916
90ffc54
a9d98bd
33ba088
5c7afbf
9a1a4b6
a8f2a36
a158cae
b3da6e9
58b8fbb
8f28982
776666b
7b70c06
af3e78b
f5fc398
ac4921a
6f79ff1
943f500
ac0ebb4
b9adbc5
42a5a54
9e8063e
492fb9e
475b880
7edf386
5e7202b
9581e65
d0d9261
bea9c0b
bf361ca
b7636dc
755c648
8afee4f
5f011db
76fe7a9
33d7bd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,12 +40,12 @@ public function onInit($id = 'dynamic_recaptcha_1') | |
| { | ||
| $pubkey = $this->params->get('public_key', ''); | ||
|
|
||
| if ($pubkey == null || $pubkey == '') | ||
| if ($pubkey === null || $pubkey === '') | ||
|
||
| { | ||
| throw new Exception(JText::_('PLG_RECAPTCHA_ERROR_NO_PUBLIC_KEY')); | ||
| } | ||
|
|
||
| if ($this->params->get('version', '1.0') == '1.0') | ||
| if ($this->params->get('version', '1.0') === '1.0') | ||
| { | ||
| JHtml::_('jquery.framework'); | ||
|
|
||
|
|
@@ -82,7 +82,7 @@ public function onInit($id = 'dynamic_recaptcha_1') | |
| */ | ||
| public function onDisplay($name = null, $id = 'dynamic_recaptcha_1', $class = '') | ||
| { | ||
| if ($this->params->get('version', '1.0') == '1.0') | ||
| if ($this->params->get('version', '1.0') === '1.0') | ||
| { | ||
| return '<div id="' . $id . '" ' . $class . '></div>'; | ||
| } | ||
|
|
@@ -117,13 +117,13 @@ public function onCheckAnswer($code = null) | |
| case '1.0': | ||
| $challenge = $input->get('recaptcha_challenge_field', '', 'string'); | ||
| $response = $input->get('recaptcha_response_field', '', 'string'); | ||
| $spam = ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0); | ||
| $spam = ($challenge === null || $challenge === '' || $response === null || $response === ''); | ||
|
||
| break; | ||
| case '2.0': | ||
| // Challenge Not needed in 2.0 but needed for getResponse call | ||
| $challenge = null; | ||
| $response = $input->get('g-recaptcha-response', '', 'string'); | ||
| $spam = ($response == null || strlen($response) == 0); | ||
| $spam = ($response === null || $response === ''); | ||
|
||
| break; | ||
| } | ||
|
|
||
|
|
@@ -226,7 +226,7 @@ private function getResponse($privatekey, $remoteip, $response, $challenge = nul | |
| */ | ||
| private function _recaptcha_qsencode($data) | ||
| { | ||
| $req = ""; | ||
| $req = ''; | ||
|
|
||
| foreach ($data as $key => $value) | ||
| { | ||
|
|
@@ -258,14 +258,14 @@ private function _recaptcha_http_post($host, $path, $data, $port = 80) | |
| $http_request = "POST $path HTTP/1.0\r\n"; | ||
| $http_request .= "Host: $host\r\n"; | ||
| $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; | ||
| $http_request .= "Content-Length: " . strlen($req) . "\r\n"; | ||
| $http_request .= 'Content-Length: ' . strlen($req) . "\r\n"; | ||
|
||
| $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; | ||
| $http_request .= "\r\n"; | ||
| $http_request .= $req; | ||
|
|
||
| $response = ''; | ||
|
|
||
| if (($fs = @fsockopen($host, $port, $errno, $errstr, 10)) == false ) | ||
| if (($fs = @fsockopen($host, $port, $errno, $errstr, 10)) === false ) | ||
|
||
| { | ||
| die('Could not open socket'); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,10 +41,10 @@ class JReCaptchaResponse | |
|
|
||
| class JReCaptcha | ||
| { | ||
| private static $_signupUrl = "https://www.google.com/recaptcha/admin"; | ||
| private static $_siteVerifyUrl = "https://www.google.com/recaptcha/api/siteverify"; | ||
| private static $_signupUrl = 'https://www.google.com/recaptcha/admin'; | ||
| private static $_siteVerifyUrl = 'https://www.google.com/recaptcha/api/siteverify'; | ||
| private $_secret; | ||
| private static $_version = "php_1.0"; | ||
| private static $_version = 'php_1.0'; | ||
|
|
||
| /** | ||
| * Constructor. | ||
|
|
@@ -53,10 +53,10 @@ class JReCaptcha | |
| */ | ||
| public function __construct($secret) | ||
| { | ||
| if ($secret == null || $secret == "") | ||
| if ($secret === null || $secret === '') | ||
| { | ||
| die("To use reCAPTCHA you must get an API key from <a href='" | ||
| . self::$_signupUrl . "'>" . self::$_signupUrl . "</a>"); | ||
| . self::$_signupUrl . "'>" . self::$_signupUrl . '</a>'); | ||
|
||
| } | ||
| $this->_secret = $secret; | ||
| } | ||
|
|
@@ -70,7 +70,7 @@ public function __construct($secret) | |
| */ | ||
| private function _encodeQS($data) | ||
| { | ||
| $req = ""; | ||
| $req = ''; | ||
| foreach ($data as $key => $value) | ||
| { | ||
| $req .= $key . '=' . urlencode(stripslashes($value)) . '&'; | ||
|
|
@@ -94,9 +94,8 @@ private function _submitHTTPGet($path, $data) | |
| { | ||
| $req = $this->_encodeQS($data); | ||
| $http = JHttpFactory::getHttp(); | ||
| $response = $http->get($path . '?' . $req)->body; | ||
|
|
||
| return $response; | ||
| return $http->get($path . '?' . $req)->body; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -111,7 +110,7 @@ private function _submitHTTPGet($path, $data) | |
| public function verifyResponse($remoteIp, $response) | ||
| { | ||
| // Discard empty solution submissions | ||
| if ($response == null || strlen($response) == 0) | ||
| if ($response === null || $response === '') | ||
| { | ||
| $recaptchaResponse = new JReCaptchaResponse(); | ||
| $recaptchaResponse->success = false; | ||
|
|
@@ -132,7 +131,7 @@ public function verifyResponse($remoteIp, $response) | |
| $answers = json_decode($getResponse, true); | ||
| $recaptchaResponse = new JReCaptchaResponse(); | ||
|
|
||
| if (trim($answers['success']) == true) | ||
| if (trim($answers['success']) === true) | ||
|
||
| { | ||
| $recaptchaResponse->success = true; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,7 +98,7 @@ protected function getContactId($created_by) | |
| $query->where('contact.published = 1'); | ||
| $query->where('contact.user_id = ' . (int) $created_by); | ||
|
|
||
| if (JLanguageMultilang::isEnabled() == 1) | ||
| if (JLanguageMultilang::isEnabled() === 1) | ||
|
||
| { | ||
| $query->where('(contact.language in ' | ||
| . '(' . $this->db->quote(JFactory::getLanguage()->getTag()) . ',' . $this->db->quote('*') . ') ' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ class PlgContentEmailcloak extends JPlugin | |
| public function onContentPrepare($context, &$row, &$params, $page = 0) | ||
| { | ||
| // Don't run this plugin when the content is being indexed | ||
| if ($context == 'com_finder.indexer') | ||
| if ($context === 'com_finder.indexer') | ||
| { | ||
| return true; | ||
| } | ||
|
|
@@ -68,13 +68,13 @@ protected function _getPattern ($link, $text) | |
| */ | ||
| protected function _addAttributesToEmail($jsEmail, $before, $after) | ||
| { | ||
| if ($before !== "") | ||
| if ($before !== '') | ||
| { | ||
| $before = str_replace("'", "\'", $before); | ||
| $jsEmail = str_replace(".innerHTML += '<a '", ".innerHTML += '<a {$before}'", $jsEmail); | ||
| } | ||
|
|
||
| if ($after !== "") | ||
| if ($after !== '') | ||
| { | ||
| $after = str_replace("'", "\'", $after); | ||
| $jsEmail = str_replace("'\'>'", "'\'{$after}>'", $jsEmail); | ||
|
|
@@ -123,7 +123,7 @@ protected function _cloak(&$text, &$params) | |
| $searchText = '((?:[\x20-\x7f]|[\xA1-\xFF]|[\xC2-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF4][\x80-\xBF]{3})[^<>]+)'; | ||
|
|
||
| // Any Image link | ||
| $searchImage = "(<img[^>]+>)"; | ||
| $searchImage = '(<img[^>]+>)'; | ||
|
|
||
| // Any Text with <span or <strong | ||
| $searchTextSpan = '(<span[^>]+>|<span>|<strong>|<strong><span[^>]+>|<strong><span>)' . $searchText . '(</span>|</strong>|</span></strong>)'; | ||
|
|
@@ -283,12 +283,12 @@ protected function _cloak(&$text, &$params) | |
| * Search for derivatives of link code <a href="mailto:[email protected]"> | ||
| * <img anything>[email protected]</a> | ||
| */ | ||
| $pattern = $this->_getPattern($searchEmail, ($searchImage . $searchEmail)); | ||
| $pattern = $this->_getPattern($searchEmail, $searchImage . $searchEmail); | ||
|
|
||
| while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) | ||
| { | ||
| $mail = $regs[2][0]; | ||
| $mailText = $regs[4][0] . ($regs[5][0]); | ||
| $mailText = $regs[4][0] . $regs[5][0]; | ||
|
|
||
| $replacement = JHtml::_('email.cloak', $mail, $mode, $mailText); | ||
|
|
||
|
|
@@ -303,7 +303,7 @@ protected function _cloak(&$text, &$params) | |
| * Search for derivatives of link code <a href="mailto:[email protected]"> | ||
| * <img anything>any text</a> | ||
| */ | ||
| $pattern = $this->_getPattern($searchEmail, ($searchImage . $searchText)); | ||
| $pattern = $this->_getPattern($searchEmail, $searchImage . $searchText); | ||
|
|
||
| while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) | ||
| { | ||
|
|
@@ -435,7 +435,7 @@ protected function _cloak(&$text, &$params) | |
| * Search for derivatives of link code | ||
| * <a href="mailto:[email protected]?subject=Text"><img anything>[email protected]</a> | ||
| */ | ||
| $pattern = $this->_getPattern($searchEmailLink, ($searchImage . $searchEmail)); | ||
| $pattern = $this->_getPattern($searchEmailLink, $searchImage . $searchEmail); | ||
|
|
||
| while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) | ||
| { | ||
|
|
@@ -459,7 +459,7 @@ protected function _cloak(&$text, &$params) | |
| * Search for derivatives of link code | ||
| * <a href="mailto:[email protected]?subject=Text"><img anything>any text</a> | ||
| */ | ||
| $pattern = $this->_getPattern($searchEmailLink, ($searchImage . $searchText)); | ||
| $pattern = $this->_getPattern($searchEmailLink, $searchImage . $searchText); | ||
|
|
||
| while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE)) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->paramsis an intance of Registry. Methodgetif key not exists may returnsnull.I would only change to
if ($this->params->get('username')).Otherwise you have to be 100% sure that this won't break anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be better. Thanks, will change.