From f72accdea0c1742b31531c3d65c5e93bbeb94083 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 30 Jan 2018 19:28:03 +0000 Subject: [PATCH 01/17] Fix tag cloud plugin on PHP 5.2 --- qa-plugin/tag-cloud-widget/qa-tag-cloud.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/qa-plugin/tag-cloud-widget/qa-tag-cloud.php b/qa-plugin/tag-cloud-widget/qa-tag-cloud.php index a90b9fb6e..69c7b7c96 100644 --- a/qa-plugin/tag-cloud-widget/qa-tag-cloud.php +++ b/qa-plugin/tag-cloud-widget/qa-tag-cloud.php @@ -116,9 +116,7 @@ public function output_widget($region, $place, $themeobject, $template, $request $populartags = qa_db_single_select(qa_db_popular_tags_selectspec(0, (int) qa_opt('tag_cloud_count_tags'))); - $populartagslog = array_map(function($e) { - return log($e) + 1; - }, $populartags); + $populartagslog = array_map(array($this, 'log_callback'), $populartags); $maxcount = reset($populartagslog); @@ -151,4 +149,9 @@ public function output_widget($region, $place, $themeobject, $template, $request $themeobject->output(''); } + + private function log_callback($e) + { + return log($e) + 1; + } } From 958b40d10d06b7d06073bbd42e338358de8f4f55 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 30 Jan 2018 19:28:23 +0000 Subject: [PATCH 02/17] Fix upgrade query with Wordpress integration --- qa-include/db/install.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/qa-include/db/install.php b/qa-include/db/install.php index 0a401ed5e..da2c763a8 100644 --- a/qa-include/db/install.php +++ b/qa-include/db/install.php @@ -1587,13 +1587,15 @@ function qa_db_upgrade_tables() case 67: // ensure we don't have old userids lying around - qa_db_upgrade_query('ALTER TABLE ^messages MODIFY fromuserid ' . $definitions['messages']['fromuserid']); - qa_db_upgrade_query('ALTER TABLE ^messages MODIFY touserid ' . $definitions['messages']['touserid']); - qa_db_upgrade_query('UPDATE ^messages SET fromuserid=NULL WHERE fromuserid NOT IN (SELECT userid FROM ^users)'); - qa_db_upgrade_query('UPDATE ^messages SET touserid=NULL WHERE touserid NOT IN (SELECT userid FROM ^users)'); - // set up foreign key on messages table - qa_db_upgrade_query('ALTER TABLE ^messages ADD CONSTRAINT ^messages_ibfk_1 FOREIGN KEY (fromuserid) REFERENCES ^users(userid) ON DELETE SET NULL'); - qa_db_upgrade_query('ALTER TABLE ^messages ADD CONSTRAINT ^messages_ibfk_2 FOREIGN KEY (touserid) REFERENCES ^users(userid) ON DELETE SET NULL'); + if (!QA_FINAL_EXTERNAL_USERS) { + qa_db_upgrade_query('ALTER TABLE ^messages MODIFY fromuserid ' . $definitions['messages']['fromuserid']); + qa_db_upgrade_query('ALTER TABLE ^messages MODIFY touserid ' . $definitions['messages']['touserid']); + qa_db_upgrade_query('UPDATE ^messages SET fromuserid=NULL WHERE fromuserid NOT IN (SELECT userid FROM ^users)'); + qa_db_upgrade_query('UPDATE ^messages SET touserid=NULL WHERE touserid NOT IN (SELECT userid FROM ^users)'); + // set up foreign key on messages table + qa_db_upgrade_query('ALTER TABLE ^messages ADD CONSTRAINT ^messages_ibfk_1 FOREIGN KEY (fromuserid) REFERENCES ^users(userid) ON DELETE SET NULL'); + qa_db_upgrade_query('ALTER TABLE ^messages ADD CONSTRAINT ^messages_ibfk_2 FOREIGN KEY (touserid) REFERENCES ^users(userid) ON DELETE SET NULL'); + } qa_db_upgrade_query($locktablesquery); break; From 5520ae809471828569f08d3f8e1f166ece6ca997 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 30 Jan 2018 19:29:07 +0000 Subject: [PATCH 03/17] Fix qa_db_list_tables (external users) --- qa-include/qa-db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa-include/qa-db.php b/qa-include/qa-db.php index 3b54c2c09..e4d4b5a61 100644 --- a/qa-include/qa-db.php +++ b/qa-include/qa-db.php @@ -458,7 +458,7 @@ function qa_db_list_tables($onlyTablesWithPrefix = false) $query = 'SHOW TABLES'; if ($onlyTablesWithPrefix) { - $col = 'Tables_in_' . QA_MYSQL_DATABASE; + $col = 'Tables_in_' . QA_FINAL_MYSQL_DATABASE; $query .= ' WHERE `' . $col . '` LIKE "' . str_replace('_', '\\_', QA_MYSQL_TABLE_PREFIX) . '%"'; if (defined('QA_MYSQL_USERS_PREFIX')) { $query .= ' OR `' . $col . '` LIKE "' . str_replace('_', '\\_', QA_MYSQL_USERS_PREFIX) . '%"'; From 176f6052449f63c538e885617346917e4f9133dc Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 30 Jan 2018 22:29:39 +0000 Subject: [PATCH 04/17] 1.8.0 --- VERSION.txt | 2 +- qa-include/db/install.php | 2 +- qa-include/qa-base.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index acfeb3b4c..afa2b3515 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -1.8.0-beta2 \ No newline at end of file +1.8.0 \ No newline at end of file diff --git a/qa-include/db/install.php b/qa-include/db/install.php index da2c763a8..f7bd7d81b 100644 --- a/qa-include/db/install.php +++ b/qa-include/db/install.php @@ -1600,7 +1600,7 @@ function qa_db_upgrade_tables() qa_db_upgrade_query($locktablesquery); break; - // Up to here: Version 1.8 beta1 + // Up to here: Version 1.8 } qa_db_set_db_version($newversion); diff --git a/qa-include/qa-base.php b/qa-include/qa-base.php index 822e44b0e..7f80bc209 100644 --- a/qa-include/qa-base.php +++ b/qa-include/qa-base.php @@ -20,8 +20,8 @@ */ -define('QA_VERSION', '1.8.0-beta2'); // also used as suffix for .js and .css requests -define('QA_BUILD_DATE', '2017-12-23'); +define('QA_VERSION', '1.8.0'); // also used as suffix for .js and .css requests +define('QA_BUILD_DATE', '2018-01-30'); /** From 1a34ee2ad34ddd7a2a0e49f0891ab8707fa96f9d Mon Sep 17 00:00:00 2001 From: pupi1985 Date: Tue, 6 Feb 2018 21:25:05 -0300 Subject: [PATCH 05/17] Update cached tag count when deleting posts --- qa-include/plugins/qa-search-basic.php | 1 + 1 file changed, 1 insertion(+) diff --git a/qa-include/plugins/qa-search-basic.php b/qa-include/plugins/qa-search-basic.php index aac2a6140..c4db3134d 100644 --- a/qa-include/plugins/qa-search-basic.php +++ b/qa-include/plugins/qa-search-basic.php @@ -90,6 +90,7 @@ public function unindex_post($postid) $wholetagids = qa_db_posttags_get_post_wordids($postid); qa_db_posttags_delete_post($postid); qa_db_word_tagcount_update($wholetagids); + qa_db_tagcount_update(); } public function move_post($postid, $categoryid) From 4ae9c8fcc006ba541e076e535cfabe1d6fb3f303 Mon Sep 17 00:00:00 2001 From: pupi1985 Date: Tue, 6 Feb 2018 23:55:37 -0300 Subject: [PATCH 06/17] Move the cache calculation away from the basic search plugin --- qa-include/app/post-create.php | 1 + qa-include/app/post-update.php | 3 +++ qa-include/plugins/qa-search-basic.php | 2 -- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qa-include/app/post-create.php b/qa-include/app/post-create.php index 03ed15fb6..a69a23f01 100644 --- a/qa-include/app/post-create.php +++ b/qa-include/app/post-create.php @@ -124,6 +124,7 @@ function qa_update_counts_for_q($postid) qa_db_unaqcount_update(); qa_db_unselqcount_update(); qa_db_unupaqcount_update(); + qa_db_tagcount_update(); } diff --git a/qa-include/app/post-update.php b/qa-include/app/post-update.php index 63fa95036..5806c1f83 100644 --- a/qa-include/app/post-update.php +++ b/qa-include/app/post-update.php @@ -106,6 +106,9 @@ function qa_question_set_content($oldquestion, $title, $content, $format, $text, } elseif ($oldquestion['type'] == 'Q') { // not hidden or queued qa_post_index($oldquestion['postid'], 'Q', $oldquestion['postid'], $oldquestion['parentid'], $title, $content, $format, $text, $tagstring, $oldquestion['categoryid']); + if ($tagschanged) { + qa_db_tagcount_update(); + } } $eventparams = array( diff --git a/qa-include/plugins/qa-search-basic.php b/qa-include/plugins/qa-search-basic.php index c4db3134d..28c576834 100644 --- a/qa-include/plugins/qa-search-basic.php +++ b/qa-include/plugins/qa-search-basic.php @@ -68,7 +68,6 @@ public function index_post($postid, $type, $questionid, $parentid, $title, $cont qa_db_word_contentcount_update(array_keys($contentwordidcounts)); qa_db_word_tagwordcount_update($tagwordids); qa_db_word_tagcount_update($wholetagids); - qa_db_tagcount_update(); } public function unindex_post($postid) @@ -90,7 +89,6 @@ public function unindex_post($postid) $wholetagids = qa_db_posttags_get_post_wordids($postid); qa_db_posttags_delete_post($postid); qa_db_word_tagcount_update($wholetagids); - qa_db_tagcount_update(); } public function move_post($postid, $categoryid) From d4b74099eeb7421a0c6ef58f3d941944e8c8287d Mon Sep 17 00:00:00 2001 From: pupi1985 Date: Fri, 9 Feb 2018 21:36:25 -0300 Subject: [PATCH 07/17] Fix some scenarios where ^userpoints records are not present and generate issues --- qa-include/app/users.php | 11 +++++++++++ qa-include/db/selects.php | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/qa-include/app/users.php b/qa-include/app/users.php index 3df963f8a..8d7c064ce 100644 --- a/qa-include/app/users.php +++ b/qa-include/app/users.php @@ -456,6 +456,17 @@ function qa_get_logged_in_user_cache() require_once QA_INCLUDE_DIR . 'db/selects.php'; $qa_cached_logged_in_user = qa_db_get_pending_result('loggedinuser', qa_db_user_account_selectspec($userid, true)); + // If the site is configured to share the ^users table then there might not be a record in the + // ^userpoints table so this creates it + if ($qa_cached_logged_in_user['points'] === null) { + require_once QA_INCLUDE_DIR . 'db/points.php'; + require_once QA_INCLUDE_DIR . 'db/users.php'; + + qa_db_points_update_ifuser($userid, null); + qa_db_uapprovecount_update(); + $qa_cached_logged_in_user = qa_db_single_select(qa_db_user_account_selectspec($userid, true)); + } + if (!isset($qa_cached_logged_in_user)) { // the user can no longer be found (should only apply to deleted users) qa_clear_session_user(); diff --git a/qa-include/db/selects.php b/qa-include/db/selects.php index a356b866f..030fb2706 100644 --- a/qa-include/db/selects.php +++ b/qa-include/db/selects.php @@ -1523,9 +1523,17 @@ function qa_db_top_users_selectspec($start, $count = null) ); } + // If the site is configured to share the ^users table then there might not be a record in the ^userpoints table + if (defined('QA_MYSQL_USERS_PREFIX')) { + $basePoints = (int)qa_opt('points_base'); + $source = '^users JOIN (SELECT ^users.userid, COALESCE(points,' . $basePoints . ') AS points FROM ^users LEFT JOIN ^userpoints ON ^users.userid=^userpoints.userid ORDER BY points DESC LIMIT #,#) y ON ^users.userid=y.userid'; + } else { + $source = '^users JOIN (SELECT userid FROM ^userpoints ORDER BY points DESC LIMIT #,#) y ON ^users.userid=y.userid JOIN ^userpoints ON ^users.userid=^userpoints.userid';; + } + return array( 'columns' => array('^users.userid', 'handle', 'points', 'flags', '^users.email', 'avatarblobid' => 'BINARY avatarblobid', 'avatarwidth', 'avatarheight'), - 'source' => '^users JOIN (SELECT userid FROM ^userpoints ORDER BY points DESC LIMIT #,#) y ON ^users.userid=y.userid JOIN ^userpoints ON ^users.userid=^userpoints.userid', + 'source' => $source, 'arguments' => array($start, $count), 'arraykey' => 'userid', 'sortdesc' => 'points', From 0bd2a820fb3a375e71398f106e9a5227e8477277 Mon Sep 17 00:00:00 2001 From: pupi1985 Date: Mon, 12 Feb 2018 14:00:51 -0300 Subject: [PATCH 08/17] Update hidden HTML to avoid its detection as malware --- qa-include/qa-theme-base.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qa-include/qa-theme-base.php b/qa-include/qa-theme-base.php index 6df1a1625..a1acc9b41 100644 --- a/qa-include/qa-theme-base.php +++ b/qa-include/qa-theme-base.php @@ -396,8 +396,7 @@ public function body() public function body_hidden() { - $indent = $this->isRTL ? '9999px' : '-9999px'; - $this->output('
'); + $this->output('
'); $this->waiting_template(); $this->output('
'); } From a1da5148e61a8e421a37331128180855659d55f5 Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 4 Mar 2018 00:47:15 +0000 Subject: [PATCH 09/17] Update branches --- CONTRIBUTING.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 09dd4889d..2e5844727 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,20 +1,20 @@ # How to contribute -As of version 1.6.3, all development of [Question2Answer][Home] will take place through GitHub. Bug reports and pull requests are encouraged, provided they follow these guidelines. +As of version 1.6.3, all development of [Question2Answer](http://www.question2answer.org/) will take place through GitHub. Bug reports and pull requests are encouraged, provided they follow these guidelines. ## Bug reports (issues) -If you find a bug (error) with Question2Answer, please [submit an issue here][Issues]. Be as descriptive as possible: include exactly what you did to make the bug appear, what you expect to happen, and what happened instead. Also include your PHP version and MySQL version. Remember to check for similar issues already reported. +If you find a bug (error) with Question2Answer, please [submit an issue here](https://github.com/q2a/question2answer/issues). Be as descriptive as possible: include exactly what you did to make the bug appear, what you expect to happen, and what happened instead. Also include your PHP version and MySQL version. Remember to check for similar issues already reported. If you think you've found a security issue, you can responsibly disclose it to us using the [contact form here](http://www.question2answer.org/feedback.php). -Note that general troubleshooting issues such as installation or how to use a feature should continue to be asked on the [Question2Answer Q&A][QA]. +Note that general troubleshooting issues such as installation or how to use a feature should continue to be asked on the [Question2Answer Q&A](http://www.question2answer.org/qa/). ## Pull requests -If you have found the cause of the bug in the Q2A code, you can submit the patch back to the Q2A repository. Create a fork of the repo, make the changes in your fork, then submit a pull request. Bug fix pull requessts must be made to the `dev` branch. PRs for new features must be made to the next version branch, for example `1.8`. +If you have found the cause of the bug in the Q2A code, you can submit the patch back to the Q2A repository. Create a fork of the repo, make the changes in your fork, then submit a pull request. Bug fix pull requests must be targeted to the **`bugfix`** branch. PRs for new features or large code changes must be made to the **`dev`** branch. If you wish to implement a feature, you should start a discussion on the [Question2Answer Q&A][QA] first. We welcome all ideas but they may not be appropriate for the Q2A core. Consider whether your idea could be developed as a plugin. @@ -23,7 +23,7 @@ If you wish to implement a feature, you should start a discussion on the [Questi From 1.7 onwards a new coding style has been implemented that is more in line with other projects. All PHP code should use these guidelines: -- PHP code should start with `` should be omitted to avoid accidental output. +- PHP code should start with `` should be omitted to avoid accidental whitespace output. - PHP files should use UTF-8 encoding without BOM (this is usually default in most text editors). - Trailing whitespace (tabs or spaces at the end of lines) should not be present. Any advanced text editor should be able to do this automatically when saving. (For Sublime Text you can add the option `"trim_trailing_white_space_on_save": true` to your preferences. In Notepad++ you can press Alt+Shift+S.) - Use tabs for indenting. Each file should start at level 0 (i.e. no indentation). @@ -39,9 +39,3 @@ If in doubt, follow the style of the surrounding code. Code examples can be foun ## Documentation Please see the repository [q2a.github.io](https://github.com/q2a/q2a.github.io/) which automatically produces the documentation website [docs.question2answer.org](http://docs.question2answer.org/). - - -[Home]: http://www.question2answer.org/ -[QA]: http://www.question2answer.org/qa/ -[Issues]: https://github.com/q2a/question2answer/issues -[PSR0]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md From fdd38b238d5cba564807af76a3c07c2603d11016 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 5 Mar 2018 21:57:51 +0000 Subject: [PATCH 10/17] Fix missing email confirmation link in user account --- qa-include/pages/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa-include/pages/account.php b/qa-include/pages/account.php index b9497e2d3..e29aedb7a 100644 --- a/qa-include/pages/account.php +++ b/qa-include/pages/account.php @@ -63,7 +63,7 @@ } $permit_error = qa_user_permit_error(); $isblocked = $permit_error !== false; -$pending_confirmation = $doconfirms && $permit_error == 'confirm'; +$pending_confirmation = $doconfirms && !$isconfirmed; // Process profile if saved From a0a0d32e9e3780843e286185facaa46ac24f799d Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 5 Mar 2018 22:57:40 +0000 Subject: [PATCH 11/17] Reinstate PHPMailerAutoload Loading classes directly caused conflicts with other software --- qa-include/app/emails.php | 3 +- .../vendor/PHPMailer/PHPMailerAutoload.php | 38 ++++++++++++++++--- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/qa-include/app/emails.php b/qa-include/app/emails.php index 5761ef397..561935c90 100644 --- a/qa-include/app/emails.php +++ b/qa-include/app/emails.php @@ -132,8 +132,7 @@ function qa_send_email($params) // @error_log(print_r($params, true)); - require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/class.phpmailer.php'; - require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/class.smtp.php'; + require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/PHPMailerAutoload.php'; $mailer = new PHPMailer(); $mailer->CharSet = 'utf-8'; diff --git a/qa-include/vendor/PHPMailer/PHPMailerAutoload.php b/qa-include/vendor/PHPMailer/PHPMailerAutoload.php index fb2e01b2b..7df3742b2 100755 --- a/qa-include/vendor/PHPMailer/PHPMailerAutoload.php +++ b/qa-include/vendor/PHPMailer/PHPMailerAutoload.php @@ -1,11 +1,39 @@ + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2014 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. */ -if (defined('QA_DEBUG_PERFORMANCE') && QA_DEBUG_PERFORMANCE) { - trigger_error('Included file ' . basename(__FILE__) . ' is deprecated'); +/** + * PHPMailer SPL autoloader. + * @param string $classname The name of the class to load + */ +function PHPMailerAutoload($classname) +{ + //Can't use __DIR__ as it's only in PHP 5.3+ + $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php'; + if (is_readable($filename)) { + require $filename; + } +} + +if (version_compare(PHP_VERSION, '5.3.0', '>=')) { + spl_autoload_register('PHPMailerAutoload', true, true); +} else { + spl_autoload_register('PHPMailerAutoload'); } -require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/class.phpmailer.php'; -require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/class.smtp.php'; +// old __autoload fallback removed as it causes problems in PHP 7.2 From c2da0046c9bbfa787eaee98efd75608731188f26 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 6 Mar 2018 22:08:01 +0000 Subject: [PATCH 12/17] Prevent browser content encoding error in PHP 5.3 Fixes #604. --- qa-include/qa-install.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qa-include/qa-install.php b/qa-include/qa-install.php index fa349155f..3a2cee71a 100644 --- a/qa-include/qa-install.php +++ b/qa-include/qa-install.php @@ -59,6 +59,8 @@ function qa_install_db_fail_handler($type, $errno = null, $error = null, $query if (ob_get_level() > 0) { // clears any current theme output to prevent broken design ob_end_clean(); + // prevents browser content encoding error + header('Content-Encoding: none'); } $success = ''; From 6890815a4a445779696f7c5a8c040fa530ba2dfe Mon Sep 17 00:00:00 2001 From: pupi1985 Date: Mon, 9 Apr 2018 03:47:38 -0300 Subject: [PATCH 13/17] Fix another PHP 7.2 count warning --- qa-include/app/format.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qa-include/app/format.php b/qa-include/app/format.php index cf354619a..1659cf7e0 100644 --- a/qa-include/app/format.php +++ b/qa-include/app/format.php @@ -381,8 +381,8 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt if (@$options['categoryview'] && isset($post['categoryname']) && isset($post['categorybackpath'])) { $favoriteclass = ''; - if (count(@$favoritemap['category'])) { - if (@$favoritemap['category'][$post['categorybackpath']]) { + if (isset($favoritemap['category']) && !empty($favoritemap['category'])) { + if (isset($favoritemap['category'][$post['categorybackpath']])) { $favoriteclass = ' qa-cat-favorited'; } else { foreach ($favoritemap['category'] as $categorybackpath => $dummy) { From dfa3df7fab262c2818659bdbe045d1ebcd43eab2 Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Wed, 30 May 2018 12:31:52 +0200 Subject: [PATCH 14/17] #642 fix php 7.2 warning on main page --- qa-include/app/format.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa-include/app/format.php b/qa-include/app/format.php index cf354619a..4649a90f6 100644 --- a/qa-include/app/format.php +++ b/qa-include/app/format.php @@ -381,7 +381,7 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt if (@$options['categoryview'] && isset($post['categoryname']) && isset($post['categorybackpath'])) { $favoriteclass = ''; - if (count(@$favoritemap['category'])) { + if (!empty($favoritemap['category']) && count($favoritemap['category'])) { if (@$favoritemap['category'][$post['categorybackpath']]) { $favoriteclass = ' qa-cat-favorited'; } else { From 20ea1c347f1b9332be4f0e7433f91a7adbcfcdcd Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Wed, 30 May 2018 14:15:35 +0200 Subject: [PATCH 15/17] #644 Registration link is still showing up when registration is disabled --- qa-include/app/captcha.php | 2 +- qa-include/app/messages.php | 5 ++++- qa-include/app/page.php | 2 +- qa-include/app/votes.php | 7 +++++-- qa-include/lang/qa-lang-main.php | 2 ++ qa-include/lang/qa-lang-misc.php | 2 ++ qa-include/lang/qa-lang-profile.php | 1 + qa-include/lang/qa-lang-question.php | 5 +++++ qa-include/pages/ask.php | 6 +++++- qa-include/pages/message.php | 5 ++++- qa-include/pages/messages.php | 5 ++++- qa-include/pages/question-post.php | 15 ++++++++++++--- qa-include/pages/question-view.php | 10 ++++++++-- qa-include/pages/question.php | 5 ++++- 14 files changed, 58 insertions(+), 14 deletions(-) diff --git a/qa-include/app/captcha.php b/qa-include/app/captcha.php index 0827bca17..bf57079a8 100644 --- a/qa-include/app/captcha.php +++ b/qa-include/app/captcha.php @@ -47,7 +47,7 @@ function qa_captcha_reason_note($captchareason) switch ($captchareason) { case 'login': - $notehtml = qa_insert_login_links(qa_lang_html('misc/captcha_login_fix')); + $notehtml = qa_insert_login_links(qa_lang_html(qa_opt('suspend_register_users') ? 'misc/captcha_login_fix_no_register' : 'misc/captcha_login_fix')); break; case 'confirm': diff --git a/qa-include/app/messages.php b/qa-include/app/messages.php index 9d85bcea7..6ef7fa97e 100644 --- a/qa-include/app/messages.php +++ b/qa-include/app/messages.php @@ -50,7 +50,10 @@ function qa_wall_error_html($fromuserid, $touserid, $touserflags) break; case 'login': - return qa_insert_login_links(qa_lang_html('profile/post_wall_must_login'), qa_request()); + return qa_insert_login_links(qa_lang_html( + qa_opt('suspend_register_users') ? 'profile/post_wall_must_login_no_register' : 'profile/post_wall_must_login'), + qa_request() + ); break; case 'confirm': diff --git a/qa-include/app/page.php b/qa-include/app/page.php index 27a61d215..6ba7b6677 100644 --- a/qa-include/app/page.php +++ b/qa-include/app/page.php @@ -777,7 +777,7 @@ function qa_content_prepare($voting = false, $categoryids = array()) ); } - if (!empty($userlinks['register'])) { + if (!empty($userlinks['register']) && !qa_opt('suspend_register_users')) { $qa_content['navigation']['user']['register'] = array( 'url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register'), diff --git a/qa-include/app/votes.php b/qa-include/app/votes.php index 420a3ffad..51f874f74 100644 --- a/qa-include/app/votes.php +++ b/qa-include/app/votes.php @@ -85,7 +85,7 @@ function qa_vote_error_html($post, $vote, $userid, $topage) break; case 'login': - return qa_insert_login_links(qa_lang_html('main/vote_must_login'), $topage); + return qa_insert_login_links(qa_lang_html(qa_opt('suspend_register_users') ? 'main/vote_must_login_no_register' : 'main/vote_must_login'), $topage); break; case 'confirm': @@ -200,7 +200,10 @@ function qa_flag_error_html($post, $userid, $topage) ) { switch (qa_user_post_permit_error('permit_flag', $post, QA_LIMIT_FLAGS)) { case 'login': - return qa_insert_login_links(qa_lang_html('question/flag_must_login'), $topage); + return qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'question/flag_must_login_no_register' : 'question/flag_must_login'), + $topage + ); break; case 'confirm': diff --git a/qa-include/lang/qa-lang-main.php b/qa-include/lang/qa-lang-main.php index 94679b9b4..e29f806c4 100644 --- a/qa-include/lang/qa-lang-main.php +++ b/qa-include/lang/qa-lang-main.php @@ -184,6 +184,7 @@ 'view_q_must_be_approved' => 'Your account must be approved to view question pages. Please wait or ^1add more information^2.', 'view_q_must_confirm' => 'Please ^5confirm your email address^6 to view question pages.', 'view_q_must_login' => 'Please ^1log in^2 or ^3register^4 to view question pages.', + 'view_q_must_login_no_register' => 'Please ^1log in^2 to view question pages.', 'viewed_qs_in_x' => 'Most viewed questions in ^', 'viewed_qs_title' => 'Most viewed questions', 'vote_disabled_approve' => 'Your account must be approved before you can vote', @@ -203,6 +204,7 @@ 'vote_limit' => 'Too many votes received - please try again in an hour', 'vote_must_confirm' => 'Please ^5confirm your email address^6 to vote.', 'vote_must_login' => 'Please ^1log in^2 or ^3register^4 to vote.', + 'vote_must_login_no_register' => 'Please ^1log in^2 to vote.', 'vote_not_allowed' => 'Voting on this is not allowed', 'vote_up_popup' => 'Click to vote up', 'voted_down_popup' => 'You have voted this down - click to remove vote', diff --git a/qa-include/lang/qa-lang-misc.php b/qa-include/lang/qa-lang-misc.php index 5dc13c623..084be9d1e 100644 --- a/qa-include/lang/qa-lang-misc.php +++ b/qa-include/lang/qa-lang-misc.php @@ -27,6 +27,7 @@ 'captcha_error' => 'Please complete the anti-spam verification', 'captcha_label' => 'Anti-spam verification:', 'captcha_login_fix' => 'To avoid this verification in future, please ^1log in^2 or ^3register^4.', + 'captcha_login_fix_no_register' => 'To avoid this verification in future, please ^1log in^2.', 'feed_a_edited_prefix' => 'Answer edited: ', 'feed_a_prefix' => 'Answered: ', 'feed_a_reshown_prefix' => 'Answer reshown: ', @@ -60,6 +61,7 @@ 'message_for_x' => 'Your message for ^:', 'message_limit' => 'You cannot send more private messages this hour', 'message_must_login' => 'Please ^1log in^2 or ^3register^4 to send private messages.', + 'message_must_login_no_register' => 'Please ^1log in^2 to send private messages.', 'message_recent_history' => 'Recent correspondence with ^', 'message_sent' => 'Your private message below was sent', 'more_favorite_qs' => 'More favorite questions...', diff --git a/qa-include/lang/qa-lang-profile.php b/qa-include/lang/qa-lang-profile.php index 3c2a027b1..12561b208 100644 --- a/qa-include/lang/qa-lang-profile.php +++ b/qa-include/lang/qa-lang-profile.php @@ -69,6 +69,7 @@ 'post_wall_must_be_approved' => 'Your account must be approved to post on this wall. Please wait or ^1add more information^2.', 'post_wall_must_confirm' => 'Please ^5confirm your email address^6 to post on this wall.', 'post_wall_must_login' => 'Please ^1log in^2 or ^3register^4 to post on this wall.', + 'post_wall_must_login_no_register' => 'Please ^1log in^2 to post on this wall.', 'questions' => 'Questions:', 'questions_by_x' => 'Questions by ^', 'ranked_x' => ' (ranked #^)', diff --git a/qa-include/lang/qa-lang-question.php b/qa-include/lang/qa-lang-question.php index b869aae30..9222ec18d 100644 --- a/qa-include/lang/qa-lang-question.php +++ b/qa-include/lang/qa-lang-question.php @@ -39,6 +39,7 @@ 'answer_must_be_approved' => 'Your account must be approved before you answer a question. Please wait or ^1add more information^2.', 'answer_must_confirm' => 'Please ^5confirm your email address^6 to answer this question.', 'answer_must_login' => 'Please ^1log in^2 or ^3register^4 to answer this question.', + 'answer_must_login_no_register' => 'Please ^1log in^2 to answer this question.', 'answer_q_popup' => 'Answer this question', 'approve_a_popup' => 'Approve this answer', 'approve_button' => 'approve', @@ -51,6 +52,7 @@ 'ask_must_be_approved' => 'Your account must be approved before you ask a question. Please wait or ^1add more information^2.', 'ask_must_confirm' => 'Please ^5confirm your email address^6 to ask a question.', 'ask_must_login' => 'Please ^1log in^2 or ^3register^4 to ask a question.', + 'ask_must_login_no_register' => 'Please ^1log in^2 to ask a question.', 'ask_same_q' => 'Before proceeding, please check your question was not asked already:', 'ask_title' => 'Ask a question', 'c_notify_email' => 'Email me at this address if a comment is added after mine:', @@ -84,6 +86,7 @@ 'comment_must_be_approved' => 'Your account must be approved before you add a comment. Please wait or ^1add more information^2.', 'comment_must_confirm' => 'Please ^5confirm your email address^6 to add a comment.', 'comment_must_login' => 'Please ^1log in^2 or ^3register^4 to add a comment.', + 'comment_must_login_no_register' => 'Please ^1log in^2 to add a comment.', 'comment_on_a' => 'On answer: ', 'comment_on_q' => 'On question: ', 'comment_q_popup' => 'Add a comment on this question', @@ -99,6 +102,7 @@ 'edit_c_title' => 'Edit comment', 'edit_must_confirm' => 'Please ^5confirm your email address^6 to edit this.', 'edit_must_login' => 'Please ^1log in^2 or ^3register^4 to edit this.', + 'edit_must_login_no_register' => 'Please ^1log in^2 to edit this.', 'edit_q_popup' => 'Edit this question', 'edit_q_title' => 'Edit Question', 'example_tags' => 'Example tags: ', @@ -109,6 +113,7 @@ 'flag_limit' => 'Too many posts flagged - please try again in an hour', 'flag_must_confirm' => 'Please ^5confirm your email address^6 to flag posts.', 'flag_must_login' => 'Please ^1log in^2 or ^3register^4 to flag posts.', + 'flag_must_login_no_register' => 'Please ^1log in^2 to flag posts.', 'flag_not_allowed' => 'Flagging this is not allowed', 'flag_q_popup' => 'Flag this question as spam or inappropriate', 'follow_a_popup' => 'Ask a new question relating to this answer', diff --git a/qa-include/pages/ask.php b/qa-include/pages/ask.php index 4f11c2438..b6f0af5a8 100644 --- a/qa-include/pages/ask.php +++ b/qa-include/pages/ask.php @@ -66,7 +66,11 @@ switch ($permiterror) { case 'login': - $qa_content['error'] = qa_insert_login_links(qa_lang_html('question/ask_must_login'), qa_request(), isset($followpostid) ? array('follow' => $followpostid) : null); + $qa_content['error'] = qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'question/ask_must_login_no_register' : 'question/ask_must_login'), + qa_request(), + isset($followpostid) ? array('follow' => $followpostid) : null + ); break; case 'confirm': diff --git a/qa-include/pages/message.php b/qa-include/pages/message.php index ce734becd..bb41aecd1 100644 --- a/qa-include/pages/message.php +++ b/qa-include/pages/message.php @@ -45,7 +45,10 @@ qa_redirect('users'); if (!isset($loginuserid)) { - $qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request()); + $qa_content['error'] = qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'misc/message_must_login_no_register' : 'misc/message_must_login'), + qa_request() + ); return $qa_content; } diff --git a/qa-include/pages/messages.php b/qa-include/pages/messages.php index c08846018..3818dc1f8 100644 --- a/qa-include/pages/messages.php +++ b/qa-include/pages/messages.php @@ -48,7 +48,10 @@ if (!isset($loginUserId)) { $qa_content = qa_content_prepare(); - $qa_content['error'] = qa_insert_login_links(qa_lang_html('misc/message_must_login'), qa_request()); + $qa_content['error'] = qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'misc/message_must_login_no_register' : 'misc/message_must_login'), + qa_request() + ); return $qa_content; } diff --git a/qa-include/pages/question-post.php b/qa-include/pages/question-post.php index 71874e19f..2fa809615 100644 --- a/qa-include/pages/question-post.php +++ b/qa-include/pages/question-post.php @@ -49,7 +49,10 @@ if (qa_clicked('a_doadd') || $pagestate == 'answer') { switch (qa_user_post_permit_error('permit_post_a', $question, QA_LIMIT_ANSWERS)) { case 'login': - $pageerror = qa_insert_login_links(qa_lang_html('question/answer_must_login'), qa_request()); + $pageerror = qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'question/answer_must_login_no_register' : 'question/answer_must_login'), + qa_request() + ); break; case 'confirm': @@ -276,7 +279,10 @@ function qa_page_q_permit_edit($post, $permitoption, &$error, $permitoption2 = n switch ($permiterror) { case 'login': - $error = qa_insert_login_links(qa_lang_html('question/edit_must_login'), qa_request()); + $error = qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'question/edit_must_login_no_register' : 'question/edit_must_login'), + qa_request() + ); break; case 'confirm': @@ -844,7 +850,10 @@ function qa_page_q_do_comment($question, $parent, $commentsfollows, $pagestart, switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) { case 'login': - $error = qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request()); + $error = qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'question/comment_must_login_no_register' : 'question/comment_must_login'), + qa_request() + ); break; case 'confirm': diff --git a/qa-include/pages/question-view.php b/qa-include/pages/question-view.php index a198b322f..234738f2d 100644 --- a/qa-include/pages/question-view.php +++ b/qa-include/pages/question-view.php @@ -882,7 +882,10 @@ function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question, switch (qa_user_post_permit_error('permit_post_a', $question, QA_LIMIT_ANSWERS)) { case 'login': $form = array( - 'title' => qa_insert_login_links(qa_lang_html('question/answer_must_login'), qa_request()), + 'title' => qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'question/answer_must_login_no_register' : 'question/answer_must_login'), + qa_request() + ), ); break; @@ -1031,7 +1034,10 @@ function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captch switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) { case 'login': $form = array( - 'title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request()), + 'title' => qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'question/comment_must_login_no_register' : 'question/comment_must_login'), + qa_request() + ), ); break; diff --git a/qa-include/pages/question.php b/qa-include/pages/question.php index 9fef3f084..ebd5f55e9 100644 --- a/qa-include/pages/question.php +++ b/qa-include/pages/question.php @@ -132,7 +132,10 @@ switch ($permiterror) { case 'login': - $qa_content['error'] = qa_insert_login_links(qa_lang_html('main/view_q_must_login'), $topage); + $qa_content['error'] = qa_insert_login_links( + qa_lang_html(qa_opt('suspend_register_users') ? 'main/view_q_must_login_no_register' : 'main/view_q_must_login'), + $topage + ); break; case 'confirm': From fc9ebb32de3bf597f4225f7ad701a31d3e0daa3a Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Wed, 30 May 2018 17:22:46 +0200 Subject: [PATCH 16/17] tabs to spaces --- qa-include/app/messages.php | 21 ++++++++++----- qa-include/app/votes.php | 39 ++++++++++++++++++++-------- qa-include/lang/qa-lang-main.php | 4 +-- qa-include/lang/qa-lang-misc.php | 4 +-- qa-include/lang/qa-lang-profile.php | 2 +- qa-include/lang/qa-lang-question.php | 10 +++---- qa-include/pages/ask.php | 38 +++++++++++++-------------- qa-include/pages/message.php | 6 ++--- qa-include/pages/question-post.php | 18 ++++++------- qa-include/pages/question-view.php | 17 +++++++----- qa-include/pages/question.php | 16 ++++++------ 11 files changed, 101 insertions(+), 74 deletions(-) diff --git a/qa-include/app/messages.php b/qa-include/app/messages.php index 6ef7fa97e..c35394f22 100644 --- a/qa-include/app/messages.php +++ b/qa-include/app/messages.php @@ -37,7 +37,10 @@ function qa_wall_error_html($fromuserid, $touserid, $touserflags) { require_once QA_INCLUDE_DIR . 'app/limits.php'; - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } if (!QA_FINAL_EXTERNAL_USERS && qa_opt('allow_user_walls')) { if (($touserflags & QA_USER_FLAGS_NO_WALL_POSTS) && !(isset($fromuserid) && $fromuserid == $touserid)) @@ -51,9 +54,9 @@ function qa_wall_error_html($fromuserid, $touserid, $touserflags) case 'login': return qa_insert_login_links(qa_lang_html( - qa_opt('suspend_register_users') ? 'profile/post_wall_must_login_no_register' : 'profile/post_wall_must_login'), - qa_request() - ); + qa_opt('suspend_register_users') ? 'profile/post_wall_must_login_no_register' : 'profile/post_wall_must_login'), + qa_request() + ); break; case 'confirm': @@ -92,7 +95,10 @@ function qa_wall_error_html($fromuserid, $touserid, $touserflags) */ function qa_wall_add_post($userid, $handle, $cookieid, $touserid, $tohandle, $content, $format) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } require_once QA_INCLUDE_DIR . 'app/format.php'; require_once QA_INCLUDE_DIR . 'db/messages.php'; @@ -145,7 +151,10 @@ function qa_wall_delete_post($userid, $handle, $cookieid, $message) */ function qa_wall_posts_add_rules($usermessages, $start) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } $userid = qa_get_logged_in_userid(); // reuse "Hiding or showing any post" and "Deleting hidden posts" permissions diff --git a/qa-include/app/votes.php b/qa-include/app/votes.php index 51f874f74..c06952443 100644 --- a/qa-include/app/votes.php +++ b/qa-include/app/votes.php @@ -36,7 +36,10 @@ */ function qa_vote_error_html($post, $vote, $userid, $topage) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } // The 'login', 'confirm', 'limit', 'userblock' and 'ipblock' permission errors are reported to the user here. // Others ('approve', 'level') prevent the buttons being clickable in the first place, in qa_get_vote_view(...) @@ -51,8 +54,7 @@ function qa_vote_error_html($post, $vote, $userid, $topage) return qa_lang_html('main/vote_disabled_queued'); } - switch($post['basetype']) - { + switch ($post['basetype']) { case 'Q': $allowVoting = qa_opt('voting_on_qs'); break; @@ -115,7 +117,10 @@ function qa_vote_error_html($post, $vote, $userid, $topage) */ function qa_vote_set($post, $userid, $handle, $cookieid, $vote) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } require_once QA_INCLUDE_DIR . 'db/points.php'; require_once QA_INCLUDE_DIR . 'db/hotness.php'; @@ -185,7 +190,10 @@ function qa_vote_set($post, $userid, $handle, $cookieid, $vote) */ function qa_flag_error_html($post, $userid, $topage) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } // The 'login', 'confirm', 'limit', 'userblock' and 'ipblock' permission errors are reported to the user here. // Others ('approve', 'level') prevent the flag button being shown, in qa_page_q_post_rules(...) @@ -201,9 +209,9 @@ function qa_flag_error_html($post, $userid, $topage) switch (qa_user_post_permit_error('permit_flag', $post, QA_LIMIT_FLAGS)) { case 'login': return qa_insert_login_links( - qa_lang_html(qa_opt('suspend_register_users') ? 'question/flag_must_login_no_register' : 'question/flag_must_login'), - $topage - ); + qa_lang_html(qa_opt('suspend_register_users') ? 'question/flag_must_login_no_register' : 'question/flag_must_login'), + $topage + ); break; case 'confirm': @@ -240,7 +248,10 @@ function qa_flag_error_html($post, $userid, $topage) */ function qa_flag_set_tohide($oldpost, $userid, $handle, $cookieid, $question) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } require_once QA_INCLUDE_DIR . 'db/votes.php'; require_once QA_INCLUDE_DIR . 'app/limits.php'; @@ -289,7 +300,10 @@ function qa_flag_set_tohide($oldpost, $userid, $handle, $cookieid, $question) */ function qa_flag_clear($oldpost, $userid, $handle, $cookieid) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } require_once QA_INCLUDE_DIR . 'db/votes.php'; require_once QA_INCLUDE_DIR . 'app/limits.php'; @@ -331,7 +345,10 @@ function qa_flag_clear($oldpost, $userid, $handle, $cookieid) */ function qa_flags_clear_all($oldpost, $userid, $handle, $cookieid) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } require_once QA_INCLUDE_DIR . 'db/votes.php'; require_once QA_INCLUDE_DIR . 'app/limits.php'; diff --git a/qa-include/lang/qa-lang-main.php b/qa-include/lang/qa-lang-main.php index e29f806c4..9fec4ba9d 100644 --- a/qa-include/lang/qa-lang-main.php +++ b/qa-include/lang/qa-lang-main.php @@ -184,7 +184,7 @@ 'view_q_must_be_approved' => 'Your account must be approved to view question pages. Please wait or ^1add more information^2.', 'view_q_must_confirm' => 'Please ^5confirm your email address^6 to view question pages.', 'view_q_must_login' => 'Please ^1log in^2 or ^3register^4 to view question pages.', - 'view_q_must_login_no_register' => 'Please ^1log in^2 to view question pages.', + 'view_q_must_login_no_register' => 'Please ^1log in^2 to view question pages.', 'viewed_qs_in_x' => 'Most viewed questions in ^', 'viewed_qs_title' => 'Most viewed questions', 'vote_disabled_approve' => 'Your account must be approved before you can vote', @@ -204,7 +204,7 @@ 'vote_limit' => 'Too many votes received - please try again in an hour', 'vote_must_confirm' => 'Please ^5confirm your email address^6 to vote.', 'vote_must_login' => 'Please ^1log in^2 or ^3register^4 to vote.', - 'vote_must_login_no_register' => 'Please ^1log in^2 to vote.', + 'vote_must_login_no_register' => 'Please ^1log in^2 to vote.', 'vote_not_allowed' => 'Voting on this is not allowed', 'vote_up_popup' => 'Click to vote up', 'voted_down_popup' => 'You have voted this down - click to remove vote', diff --git a/qa-include/lang/qa-lang-misc.php b/qa-include/lang/qa-lang-misc.php index 084be9d1e..81504df9b 100644 --- a/qa-include/lang/qa-lang-misc.php +++ b/qa-include/lang/qa-lang-misc.php @@ -27,7 +27,7 @@ 'captcha_error' => 'Please complete the anti-spam verification', 'captcha_label' => 'Anti-spam verification:', 'captcha_login_fix' => 'To avoid this verification in future, please ^1log in^2 or ^3register^4.', - 'captcha_login_fix_no_register' => 'To avoid this verification in future, please ^1log in^2.', + 'captcha_login_fix_no_register' => 'To avoid this verification in future, please ^1log in^2.', 'feed_a_edited_prefix' => 'Answer edited: ', 'feed_a_prefix' => 'Answered: ', 'feed_a_reshown_prefix' => 'Answer reshown: ', @@ -61,7 +61,7 @@ 'message_for_x' => 'Your message for ^:', 'message_limit' => 'You cannot send more private messages this hour', 'message_must_login' => 'Please ^1log in^2 or ^3register^4 to send private messages.', - 'message_must_login_no_register' => 'Please ^1log in^2 to send private messages.', + 'message_must_login_no_register' => 'Please ^1log in^2 to send private messages.', 'message_recent_history' => 'Recent correspondence with ^', 'message_sent' => 'Your private message below was sent', 'more_favorite_qs' => 'More favorite questions...', diff --git a/qa-include/lang/qa-lang-profile.php b/qa-include/lang/qa-lang-profile.php index 12561b208..0a63affde 100644 --- a/qa-include/lang/qa-lang-profile.php +++ b/qa-include/lang/qa-lang-profile.php @@ -69,7 +69,7 @@ 'post_wall_must_be_approved' => 'Your account must be approved to post on this wall. Please wait or ^1add more information^2.', 'post_wall_must_confirm' => 'Please ^5confirm your email address^6 to post on this wall.', 'post_wall_must_login' => 'Please ^1log in^2 or ^3register^4 to post on this wall.', - 'post_wall_must_login_no_register' => 'Please ^1log in^2 to post on this wall.', + 'post_wall_must_login_no_register' => 'Please ^1log in^2 to post on this wall.', 'questions' => 'Questions:', 'questions_by_x' => 'Questions by ^', 'ranked_x' => ' (ranked #^)', diff --git a/qa-include/lang/qa-lang-question.php b/qa-include/lang/qa-lang-question.php index 9222ec18d..1823e5a2f 100644 --- a/qa-include/lang/qa-lang-question.php +++ b/qa-include/lang/qa-lang-question.php @@ -39,7 +39,7 @@ 'answer_must_be_approved' => 'Your account must be approved before you answer a question. Please wait or ^1add more information^2.', 'answer_must_confirm' => 'Please ^5confirm your email address^6 to answer this question.', 'answer_must_login' => 'Please ^1log in^2 or ^3register^4 to answer this question.', - 'answer_must_login_no_register' => 'Please ^1log in^2 to answer this question.', + 'answer_must_login_no_register' => 'Please ^1log in^2 to answer this question.', 'answer_q_popup' => 'Answer this question', 'approve_a_popup' => 'Approve this answer', 'approve_button' => 'approve', @@ -52,7 +52,7 @@ 'ask_must_be_approved' => 'Your account must be approved before you ask a question. Please wait or ^1add more information^2.', 'ask_must_confirm' => 'Please ^5confirm your email address^6 to ask a question.', 'ask_must_login' => 'Please ^1log in^2 or ^3register^4 to ask a question.', - 'ask_must_login_no_register' => 'Please ^1log in^2 to ask a question.', + 'ask_must_login_no_register' => 'Please ^1log in^2 to ask a question.', 'ask_same_q' => 'Before proceeding, please check your question was not asked already:', 'ask_title' => 'Ask a question', 'c_notify_email' => 'Email me at this address if a comment is added after mine:', @@ -86,7 +86,7 @@ 'comment_must_be_approved' => 'Your account must be approved before you add a comment. Please wait or ^1add more information^2.', 'comment_must_confirm' => 'Please ^5confirm your email address^6 to add a comment.', 'comment_must_login' => 'Please ^1log in^2 or ^3register^4 to add a comment.', - 'comment_must_login_no_register' => 'Please ^1log in^2 to add a comment.', + 'comment_must_login_no_register' => 'Please ^1log in^2 to add a comment.', 'comment_on_a' => 'On answer: ', 'comment_on_q' => 'On question: ', 'comment_q_popup' => 'Add a comment on this question', @@ -102,7 +102,7 @@ 'edit_c_title' => 'Edit comment', 'edit_must_confirm' => 'Please ^5confirm your email address^6 to edit this.', 'edit_must_login' => 'Please ^1log in^2 or ^3register^4 to edit this.', - 'edit_must_login_no_register' => 'Please ^1log in^2 to edit this.', + 'edit_must_login_no_register' => 'Please ^1log in^2 to edit this.', 'edit_q_popup' => 'Edit this question', 'edit_q_title' => 'Edit Question', 'example_tags' => 'Example tags: ', @@ -113,7 +113,7 @@ 'flag_limit' => 'Too many posts flagged - please try again in an hour', 'flag_must_confirm' => 'Please ^5confirm your email address^6 to flag posts.', 'flag_must_login' => 'Please ^1log in^2 or ^3register^4 to flag posts.', - 'flag_must_login_no_register' => 'Please ^1log in^2 to flag posts.', + 'flag_must_login_no_register' => 'Please ^1log in^2 to flag posts.', 'flag_not_allowed' => 'Flagging this is not allowed', 'flag_q_popup' => 'Flag this question as spam or inappropriate', 'follow_a_popup' => 'Ask a new question relating to this answer', diff --git a/qa-include/pages/ask.php b/qa-include/pages/ask.php index b6f0af5a8..a7ef85f49 100644 --- a/qa-include/pages/ask.php +++ b/qa-include/pages/ask.php @@ -25,10 +25,10 @@ } -require_once QA_INCLUDE_DIR.'app/format.php'; -require_once QA_INCLUDE_DIR.'app/limits.php'; -require_once QA_INCLUDE_DIR.'db/selects.php'; -require_once QA_INCLUDE_DIR.'util/sort.php'; +require_once QA_INCLUDE_DIR . 'app/format.php'; +require_once QA_INCLUDE_DIR . 'app/limits.php'; +require_once QA_INCLUDE_DIR . 'db/selects.php'; +require_once QA_INCLUDE_DIR . 'util/sort.php'; // Check whether this is a follow-on question and get some info we need from the database @@ -67,10 +67,10 @@ switch ($permiterror) { case 'login': $qa_content['error'] = qa_insert_login_links( - qa_lang_html(qa_opt('suspend_register_users') ? 'question/ask_must_login_no_register' : 'question/ask_must_login'), - qa_request(), - isset($followpostid) ? array('follow' => $followpostid) : null - ); + qa_lang_html(qa_opt('suspend_register_users') ? 'question/ask_must_login_no_register' : 'question/ask_must_login'), + qa_request(), + isset($followpostid) ? array('follow' => $followpostid) : null + ); break; case 'confirm': @@ -109,8 +109,8 @@ } if (qa_clicked('doask')) { - require_once QA_INCLUDE_DIR.'app/post-create.php'; - require_once QA_INCLUDE_DIR.'util/string.php'; + require_once QA_INCLUDE_DIR . 'app/post-create.php'; + require_once QA_INCLUDE_DIR . 'util/string.php'; $categoryids = array_keys(qa_category_path($categories, @$in['categoryid'])); $userlevel = qa_user_level_for_categories($categoryids); @@ -126,8 +126,7 @@ if (!qa_check_form_security_code('ask', qa_post_text('code'))) { $errors['page'] = qa_lang_html('misc/form_security_again'); - } - else { + } else { $filtermodules = qa_load_modules_with('filter', 'filter_question'); foreach ($filtermodules as $filtermodule) { $oldin = $in; @@ -138,13 +137,12 @@ if (qa_using_categories() && count($categories) && (!qa_opt('allow_no_category')) && !isset($in['categoryid'])) { // check this here because we need to know count($categories) $errors['categoryid'] = qa_lang_html('question/category_required'); - } - elseif (qa_user_permit_error('permit_post_q', null, $userlevel)) { + } elseif (qa_user_permit_error('permit_post_q', null, $userlevel)) { $errors['categoryid'] = qa_lang_html('question/category_ask_not_allowed'); } if ($captchareason) { - require_once QA_INCLUDE_DIR.'app/captcha.php'; + require_once QA_INCLUDE_DIR . 'app/captcha.php'; qa_captcha_validate_post($errors); } @@ -197,7 +195,7 @@ $custom = qa_opt('show_custom_ask') ? trim(qa_opt('custom_ask')) : ''; $qa_content['form'] = array( - 'tags' => 'name="ask" method="post" action="'.qa_self_html().'"', + 'tags' => 'name="ask" method="post" action="' . qa_self_html() . '"', 'style' => 'tall', @@ -224,8 +222,8 @@ 'buttons' => array( 'ask' => array( - 'tags' => 'onclick="qa_show_waiting_after(this, false); '. - (method_exists($editor, 'update_script') ? $editor->update_script('content') : '').'"', + 'tags' => 'onclick="qa_show_waiting_after(this, false); ' . + (method_exists($editor, 'update_script') ? $editor->update_script('content') : '') . '"', 'label' => qa_lang_html('question/ask_button'), ), ), @@ -245,7 +243,7 @@ $qa_content['form']['fields']['title']['tags'] .= ' onchange="qa_title_change(this.value);"'; if (strlen(@$in['title'])) { - $qa_content['script_onloads'][] = 'qa_title_change('.qa_js($in['title']).');'; + $qa_content['script_onloads'][] = 'qa_title_change(' . qa_js($in['title']) . ');'; } } @@ -305,7 +303,7 @@ isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), @$in['email'], @$errors['email']); if ($captchareason) { - require_once QA_INCLUDE_DIR.'app/captcha.php'; + require_once QA_INCLUDE_DIR . 'app/captcha.php'; qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors, qa_captcha_reason_note($captchareason)); } diff --git a/qa-include/pages/message.php b/qa-include/pages/message.php index bb41aecd1..e535a9c4a 100644 --- a/qa-include/pages/message.php +++ b/qa-include/pages/message.php @@ -46,9 +46,9 @@ if (!isset($loginuserid)) { $qa_content['error'] = qa_insert_login_links( - qa_lang_html(qa_opt('suspend_register_users') ? 'misc/message_must_login_no_register' : 'misc/message_must_login'), - qa_request() - ); + qa_lang_html(qa_opt('suspend_register_users') ? 'misc/message_must_login_no_register' : 'misc/message_must_login'), + qa_request() + ); return $qa_content; } diff --git a/qa-include/pages/question-post.php b/qa-include/pages/question-post.php index 2fa809615..2bda81e60 100644 --- a/qa-include/pages/question-post.php +++ b/qa-include/pages/question-post.php @@ -50,9 +50,9 @@ switch (qa_user_post_permit_error('permit_post_a', $question, QA_LIMIT_ANSWERS)) { case 'login': $pageerror = qa_insert_login_links( - qa_lang_html(qa_opt('suspend_register_users') ? 'question/answer_must_login_no_register' : 'question/answer_must_login'), - qa_request() - ); + qa_lang_html(qa_opt('suspend_register_users') ? 'question/answer_must_login_no_register' : 'question/answer_must_login'), + qa_request() + ); break; case 'confirm': @@ -280,9 +280,9 @@ function qa_page_q_permit_edit($post, $permitoption, &$error, $permitoption2 = n switch ($permiterror) { case 'login': $error = qa_insert_login_links( - qa_lang_html(qa_opt('suspend_register_users') ? 'question/edit_must_login_no_register' : 'question/edit_must_login'), - qa_request() - ); + qa_lang_html(qa_opt('suspend_register_users') ? 'question/edit_must_login_no_register' : 'question/edit_must_login'), + qa_request() + ); break; case 'confirm': @@ -851,9 +851,9 @@ function qa_page_q_do_comment($question, $parent, $commentsfollows, $pagestart, switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) { case 'login': $error = qa_insert_login_links( - qa_lang_html(qa_opt('suspend_register_users') ? 'question/comment_must_login_no_register' : 'question/comment_must_login'), - qa_request() - ); + qa_lang_html(qa_opt('suspend_register_users') ? 'question/comment_must_login_no_register' : 'question/comment_must_login'), + qa_request() + ); break; case 'confirm': diff --git a/qa-include/pages/question-view.php b/qa-include/pages/question-view.php index 234738f2d..29cc195ee 100644 --- a/qa-include/pages/question-view.php +++ b/qa-include/pages/question-view.php @@ -102,7 +102,10 @@ function qa_page_q_load_c_follows($question, $childposts, $achildposts, $duplica */ function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $childposts = null) { - if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } + if (qa_to_override(__FUNCTION__)) { + $args = func_get_args(); + return qa_call_override(__FUNCTION__, $args); + } $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); @@ -883,9 +886,9 @@ function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question, case 'login': $form = array( 'title' => qa_insert_login_links( - qa_lang_html(qa_opt('suspend_register_users') ? 'question/answer_must_login_no_register' : 'question/answer_must_login'), - qa_request() - ), + qa_lang_html(qa_opt('suspend_register_users') ? 'question/answer_must_login_no_register' : 'question/answer_must_login'), + qa_request() + ), ); break; @@ -1035,9 +1038,9 @@ function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captch case 'login': $form = array( 'title' => qa_insert_login_links( - qa_lang_html(qa_opt('suspend_register_users') ? 'question/comment_must_login_no_register' : 'question/comment_must_login'), - qa_request() - ), + qa_lang_html(qa_opt('suspend_register_users') ? 'question/comment_must_login_no_register' : 'question/comment_must_login'), + qa_request() + ), ); break; diff --git a/qa-include/pages/question.php b/qa-include/pages/question.php index ebd5f55e9..efd95adfa 100644 --- a/qa-include/pages/question.php +++ b/qa-include/pages/question.php @@ -133,9 +133,9 @@ switch ($permiterror) { case 'login': $qa_content['error'] = qa_insert_login_links( - qa_lang_html(qa_opt('suspend_register_users') ? 'main/view_q_must_login_no_register' : 'main/view_q_must_login'), - $topage - ); + qa_lang_html(qa_opt('suspend_register_users') ? 'main/view_q_must_login_no_register' : 'main/view_q_must_login'), + $topage + ); break; case 'confirm': @@ -463,11 +463,11 @@ if (qa_opt('do_count_q_views') && !$formrequested && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ( - // if it has more than zero views, then it must be different IP & user & cookieid from the creator - (@inet_ntop($question['createip']) != qa_remote_ip_address() || !isset($question['createip'])) && - ($question['userid'] != $userid || !isset($question['userid'])) && - ($question['cookieid'] != $cookieid || !isset($question['cookieid'])) - )) + // if it has more than zero views, then it must be different IP & user & cookieid from the creator + (@inet_ntop($question['createip']) != qa_remote_ip_address() || !isset($question['createip'])) && + ($question['userid'] != $userid || !isset($question['userid'])) && + ($question['cookieid'] != $cookieid || !isset($question['cookieid'])) + )) ) { $qa_content['inc_views_postid'] = $questionid; } From 8df1c875cb4e4bb747be00319df0ea796bbc14e1 Mon Sep 17 00:00:00 2001 From: Hendrik Iseke Date: Wed, 30 May 2018 17:25:09 +0200 Subject: [PATCH 17/17] tabs to spaces --- qa-include/pages/messages.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qa-include/pages/messages.php b/qa-include/pages/messages.php index 3818dc1f8..b2c00cc4b 100644 --- a/qa-include/pages/messages.php +++ b/qa-include/pages/messages.php @@ -49,9 +49,9 @@ if (!isset($loginUserId)) { $qa_content = qa_content_prepare(); $qa_content['error'] = qa_insert_login_links( - qa_lang_html(qa_opt('suspend_register_users') ? 'misc/message_must_login_no_register' : 'misc/message_must_login'), - qa_request() - ); + qa_lang_html(qa_opt('suspend_register_users') ? 'misc/message_must_login_no_register' : 'misc/message_must_login'), + qa_request() + ); return $qa_content; } @@ -80,9 +80,9 @@ $qa_content['custom'] = '
' . - ($showOutbox ? '' . qa_lang_html('misc/inbox') . '' : qa_lang_html('misc/inbox')) . - ' - ' . - ($showOutbox ? qa_lang_html('misc/outbox') : '' . qa_lang_html('misc/outbox') . '') . + ($showOutbox ? '' . qa_lang_html('misc/inbox') . '' : qa_lang_html('misc/inbox')) . + ' - ' . + ($showOutbox ? qa_lang_html('misc/outbox') : '' . qa_lang_html('misc/outbox') . '') . '
'; $qa_content['message_list'] = array(