From ea05203b6b015792d10cdecaaa789c08e6a176f7 Mon Sep 17 00:00:00 2001 From: John Rayes Date: Fri, 24 Mar 2023 21:49:07 -0700 Subject: [PATCH] Formatting Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- .gitignore | 4 + Populate.php | 162 +++++++++++++++++----------------- ban_script.php | 48 +++++----- install_script/install.php | 10 +-- install_script/install_db.php | 12 ++- patch_to_mod.php | 20 ++--- repair_settings.php | 26 +++--- smfinfo.php | 43 +++++---- 8 files changed, 168 insertions(+), 157 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9fc313e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ + +.idea/ + +vendor/ diff --git a/Populate.php b/Populate.php index 76bdf97..91b3b55 100644 --- a/Populate.php +++ b/Populate.php @@ -37,12 +37,12 @@ class Populate { private $blockSize = 500; private $refreshRate = 0; - private $loremIpsum = null; - private $ounters = array(); + private $loremIpsum; + private $counters = array(); private $timeStart = 0; - public function __construct ($options = array()) + public function __construct($options = array()) { global $smcFunc; @@ -58,7 +58,7 @@ public function __construct ($options = array()) $this->counters['topics']['current'] = 0; $this->counters['messages']['max'] = 3000000; $this->counters['messages']['current'] = 0; - $this->timeStart = microtime(TRUE); + $this->timeStart = microtime(true); // Override defaults foreach ($options as $_key => $_value) @@ -66,7 +66,7 @@ public function __construct ($options = array()) $this->loremIpsum = new LoremIpsumGenerator(); - // Determine our 'currents' + $end = false; foreach ($this->counters as $key => $val) { $request = $smcFunc['db_query']('', 'SELECT COUNT(*) FROM {db_prefix}' . $key); @@ -74,8 +74,7 @@ public function __construct ($options = array()) $smcFunc['db_free_result']($request); if ($key != 'topics' && $this->counters[$key]['current'] < $this->counters[$key]['max']) { - $func = 'make'.ucfirst($key); - $end = false; + $func = 'make' . ucfirst($key); break; } else @@ -87,7 +86,7 @@ public function __construct ($options = array()) $this->complete($end); } - private function makeCategories () + private function makeCategories() { global $sourcedir; require_once($sourcedir . '/Subs-Categories.php'); @@ -105,7 +104,7 @@ private function makeCategories () $this->pause(); } - private function makeBoards () + private function makeBoards() { global $sourcedir; require_once($sourcedir . '/Subs-Boards.php'); @@ -121,7 +120,7 @@ private function makeBoards () if (mt_rand() < (mt_getrandmax() / 2)) { $boardOptions = array_merge($boardOptions, array( - 'target_board' => mt_rand(1, $this->counters['boards']['current']-1), + 'target_board' => mt_rand(1, $this->counters['boards']['current'] - 1), 'move_to' => 'child', )); } @@ -132,7 +131,7 @@ private function makeBoards () $this->pause(); } - private function makeMembergroups () + private function makeMembergroups() { global $smcFunc; @@ -159,7 +158,7 @@ private function makeMembergroups () $this->pause(); } - private function makeMembers () + private function makeMembers() { global $sourcedir, $modSettings; require_once($sourcedir . '/Subs-Members.php'); @@ -172,7 +171,7 @@ private function makeMembers () $regOptions = array( 'interface' => 'admin', 'username' => 'Member ' . ++$this->counters['members']['current'], - 'email' => 'member_' . $this->counters['members']['current'] . '@' . $_SERVER['SERVER_NAME'] . (strpos($_SERVER['SERVER_NAME'], '.') === FALSE ? '.com' : ''), + 'email' => 'member_' . $this->counters['members']['current'] . '@' . $_SERVER['SERVER_NAME'] . (strpos($_SERVER['SERVER_NAME'], '.') === false ? '.com' : ''), 'password' => '', 'require' => 'nothing', 'send_welcome_email' => false, @@ -187,7 +186,7 @@ private function makeMembers () $this->pause(); } - private function makeMessages () + private function makeMessages() { global $sourcedir; require_once($sourcedir . '/Subs-Post.php'); @@ -195,9 +194,9 @@ private function makeMessages () while ($this->counters['messages']['current'] < $this->counters['messages']['max'] && $this->blockSize--) { $msgOptions = array( - 'subject' => trim($this->loremIpsum->getContent(mt_rand(1,6), 'txt')), + 'subject' => trim($this->loremIpsum->getContent(mt_rand(1, 6), 'txt')), 'body' => trim($this->loremIpsum->getContent(mt_rand(5, 60), 'txt')), - 'approved' => TRUE + 'approved' => true ); $makenew = ($this->counters['topics']['current'] < $this->counters['topics']['max']) && (mt_rand() < (int)(mt_getrandmax() * ($this->counters['topics']['max'] / $this->counters['messages']['max']))); @@ -205,7 +204,7 @@ private function makeMessages () $topicOptions = array( 'id' => $makenew ? 0 : mt_rand(1, $this->counters['topics']['current']), 'board' => mt_rand(1, $this->counters['boards']['max']), - 'mark_as_read' => TRUE, + 'mark_as_read' => true, ); if ($makenew) @@ -216,7 +215,7 @@ private function makeMessages () 'id' => $member, 'name' => 'Member ' . $member, 'email' => 'member_' . $member . '@' . $_SERVER['SERVER_NAME'] . '.com', - 'update_post_count' => TRUE, + 'update_post_count' => true, ); createPost($msgOptions, $topicOptions, $posterOptions); @@ -224,7 +223,7 @@ private function makeMessages () $this->pause(); } - private function pause ($end = false) + private function pause($end = false) { if (!$end) { @@ -244,14 +243,14 @@ private function pause ($end = false) echo ' ' . $val['current'] . ' of ' . $val['max'] . ' ' . $key . ' created
'; echo ' - Time taken for last request: ' . round(microtime(TRUE) - $this->timeStart, 3) . ' seconds'; + Time taken for last request: ' . round(microtime(true) - $this->timeStart, 3) . ' seconds'; if ($end) echo '

Completed'; } - private function fixupTopicsBoards () + private function fixupTopicsBoards() { global $smcFunc, $sourcedir, $db_type; @@ -277,7 +276,7 @@ private function fixupTopicsBoards () } } - private function complete ($end) + private function complete($end) { if ($end) { @@ -287,41 +286,35 @@ private function complete ($end) } } -class LoremIpsumGenerator { - /** - * Copyright (c) 2009, Mathew Tinsley (tinsley@tinsology.net) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the organization nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY MATHEW TINSLEY ''AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - private $words, $wordsPerParagraph, $wordsPerSentence; - - function __construct ($wordsPer = 100) - { - $this->wordsPerParagraph = $wordsPer; - $this->wordsPerSentence = 24.460; - $this->words = array( +/** + * Copyright (c) 2009, Mathew Tinsley (tinsley@tinsology.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the organization nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY MATHEW TINSLEY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +class LoremIpsumGenerator +{ + private $words = array( 'lorem', 'ipsum', 'dolor', @@ -499,10 +492,20 @@ function __construct ($wordsPer = 100) 'elementum', 'tempor', 'risus', - 'cras' ); - } + 'cras' + ); + + private $wordsPerParagraph = 100; - function getContent ($count, $format = 'html', $loremipsum = true) + private $wordsPerSentence = 24.460; + + /** + * @param $count + * @param string $format + * @param bool $loremipsum + * @return array|string + */ + function getContent($count, $format = 'html', $loremipsum = true) { $format = strtolower($format); @@ -520,7 +523,7 @@ function getContent ($count, $format = 'html', $loremipsum = true) } } - private function getWords (&$arr, $count, $loremipsum) + private function getWords(&$arr, $count, $loremipsum) { $i = 0; if ($loremipsum) @@ -543,7 +546,7 @@ private function getWords (&$arr, $count, $loremipsum) } } - private function getPlain ($count, $loremipsum, $returnStr = true) + private function getPlain($count, $loremipsum, $returnStr = true) { $words = array(); $this->getWords($words, $count, $loremipsum); @@ -583,7 +586,7 @@ private function getPlain ($count, $loremipsum, $returnStr = true) return $sentences; } - private function getText ($count, $loremipsum) + private function getText($count, $loremipsum) { $sentences = $this->getPlain($count, $loremipsum, false); $paragraphs = $this->getParagraphArr($sentences); @@ -598,7 +601,7 @@ private function getText ($count, $loremipsum) return implode("\n\n\t", $paragraphStr); } - private function getParagraphArr ($sentences) + private function getParagraphArr($sentences) { $wordsPer = $this->wordsPerParagraph; $sentenceAvg = $this->wordsPerSentence; @@ -627,7 +630,7 @@ private function getParagraphArr ($sentences) return $paragraphs; } - private function getHTML ($count, $loremipsum) + private function getHTML($count, $loremipsum) { $sentences = $this->getPlain($count, $loremipsum, false); $paragraphs = $this->getParagraphArr($sentences); @@ -643,7 +646,7 @@ private function getHTML ($count, $loremipsum) return implode("\n", $paragraphStr); } - private function paragraphToString ($paragraph, $htmlCleanCode = false) + private function paragraphToString($paragraph, $htmlCleanCode = false) { $paragraphStr = ''; foreach ($paragraph as $sentence) @@ -661,7 +664,7 @@ private function paragraphToString ($paragraph, $htmlCleanCode = false) * Inserts commas and periods in the given * word array. */ - private function punctuate (& $sentence) + private function punctuate(& $sentence) { $count = count($sentence); $sentence[$count - 1] = $sentence[$count - 1] . '.'; @@ -687,7 +690,7 @@ private function punctuate (& $sentence) * sentence of the given length. Average and * standard deviation are determined superficially */ - private function numberOfCommas ($len) + private function numberOfCommas($len) { $avg = (float) log($len, 6); $stdDev = (float) $avg / 6.000; @@ -704,7 +707,7 @@ private function numberOfCommas ($len) * Average: 24.46 * Standard Deviation: 5.08 */ - private function gaussianSentence () + private function gaussianSentence() { $avg = (float) 24.460; $stdDev = (float) 5.080; @@ -718,32 +721,33 @@ private function gaussianSentence () * Source: * http://us.php.net/manual/en/function.rand.php#53784 */ - private function gauss () - { // N(0,1) + private function gauss() + { +// N(0,1) // returns random number with normal distribution: // mean=0 // std dev=1 // auxilary vars - $x=$this->random_0_1(); - $y=$this->random_0_1(); + $x = $this->random_0_1(); + $y = $this->random_0_1(); // two independent variables with normal distribution N(0,1) - $u=sqrt(-2*log($x))*cos(2*pi()*$y); - $v=sqrt(-2*log($x))*sin(2*pi()*$y); + $u = sqrt(-2 * log($x)) * cos(2 * pi() * $y); + $v = sqrt(-2 * log($x)) * sin(2 * pi() * $y); // i will return only one, couse only one needed return $u; } - private function gauss_ms ($m=0.0,$s=1.0) + private function gauss_ms($m = 0.0, $s = 1.0) { - return $this->gauss()*$s+$m; + return $this->gauss() * $s + $m; } - private function random_0_1 () + private function random_0_1() { - return (float)rand()/(float)getrandmax(); + return (float) rand() / (float) getrandmax(); } } \ No newline at end of file diff --git a/ban_script.php b/ban_script.php index ce0a5d7..88374c8 100644 --- a/ban_script.php +++ b/ban_script.php @@ -30,7 +30,7 @@ * and tranlsate it. ;D * */ -function bans_english () +function bans_english() { global $txt; @@ -68,7 +68,7 @@ function bans_english () // and then let's throw out the template! :P obExit(null, null, true); -function bans_menu_button (&$buttons) +function bans_menu_button(&$buttons) { global $boardurl, $txt, $context; bans_loadLanguage(); @@ -85,7 +85,7 @@ function bans_menu_button (&$buttons) ); } -function bans_loadLanguage () +function bans_loadLanguage() { global $user_info; @@ -95,7 +95,7 @@ function bans_loadLanguage () return $flang(); } -function bans_main () +function bans_main() { global $txt, $sourcedir, $boardurl, $context, $forum_version, $user_info, $smcFunc; @@ -228,7 +228,7 @@ function bans_main () } } -function bans_getBanNames () +function bans_getBanNames() { global $smcFunc; @@ -246,7 +246,7 @@ function bans_getBanNames () return $banNames; } -function list_getToBeBans ($start, $items_per_page, $sort) +function list_getToBeBans($start, $items_per_page, $sort) { global $smcFunc, $context, $user_info; @@ -265,7 +265,7 @@ function list_getToBeBans ($start, $items_per_page, $sort) list ($lastRead) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); - if(empty($lastRead)) + if (empty($lastRead)) $lastRead = 0; } else @@ -296,7 +296,7 @@ function list_getToBeBans ($start, $items_per_page, $sort) return $suggested; } -function list_getNumToBeBans () +function list_getNumToBeBans() { global $smcFunc, $context, $user_info; @@ -315,7 +315,7 @@ function list_getNumToBeBans () list ($lastRead) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); - if(empty($lastRead)) + if (empty($lastRead)) $lastRead = 0; } else @@ -340,7 +340,7 @@ function list_getNumToBeBans () return $numPacks; } -function template_ban_script () +function template_ban_script() { global $context, $txt, $boardurl; @@ -373,7 +373,7 @@ function template_ban_script () echo '
-
+