diff --git a/blocks/newbb_block.php b/blocks/newbb_block.php index 796203f9..9b0e731b 100644 --- a/blocks/newbb_block.php +++ b/blocks/newbb_block.php @@ -188,7 +188,7 @@ function b_newbb_show($options) // START irmtfan remove hardcoded html in URLs - add $seo_topic_url //$seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id']; //BigKev73 > Change to support jumping directly to that post, vs just the page that the topic is on - $seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id'] . '&post_id=' . $topic['post_id']."#forumpost" . $topic['post_id']; + $seo_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id'] . '&post_id=' . $topic['post_id'] . '#forumpost' . $topic['post_id']; $seo_topic_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewtopic.php?topic_id=' . $topic['id']; $seo_forum_url = XOOPS_URL . '/' . SEO_MODULE_NAME . '/viewforum.php?forum=' . $topic['forum_id']; if (!empty($newbbConfig['do_rewrite'])) { diff --git a/class/Common/Breadcrumb.php b/class/Common/Breadcrumb.php index aa26b8e6..48881fd1 100644 --- a/class/Common/Breadcrumb.php +++ b/class/Common/Breadcrumb.php @@ -39,7 +39,7 @@ class Breadcrumb public function __construct() { - $this->dirname = \basename(dirname(__DIR__, 2)); + $this->dirname = \basename(\dirname(__DIR__, 2)); } /** diff --git a/class/Common/Configurator.php b/class/Common/Configurator.php index 2d523068..434ca792 100644 --- a/class/Common/Configurator.php +++ b/class/Common/Configurator.php @@ -42,10 +42,10 @@ class Configurator */ public function __construct() { - $moduleDirName = \basename(dirname(__DIR__, 2)); + $moduleDirName = \basename(\dirname(__DIR__, 2)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); - $config = require dirname(__DIR__, 2) . '/config/config.php'; + $config = require \dirname(__DIR__, 2) . '/config/config.php'; $this->name = $config->name; $this->paths = $config->paths; diff --git a/class/Common/FilesManagement.php b/class/Common/FilesManagement.php index 9f61b2c2..2cf6c2bc 100644 --- a/class/Common/FilesManagement.php +++ b/class/Common/FilesManagement.php @@ -31,9 +31,9 @@ trait FilesManagement public static function createFolder($folder) { try { - if (!is_dir($folder)) { - if (!is_dir($folder) && !mkdir($folder) && !is_dir($folder)) { - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); + if (!\is_dir($folder)) { + if (!\is_dir($folder) && !\mkdir($folder) && !\is_dir($folder)) { + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); } file_put_contents($folder . '/index.html', ''); @@ -50,7 +50,7 @@ public static function createFolder($folder) */ public static function copyFile($file, $folder) { - return copy($file, $folder); + return \copy($file, $folder); } /** @@ -59,21 +59,21 @@ public static function copyFile($file, $folder) */ public static function recurseCopy($src, $dst) { - $dir = opendir($src); + $dir = \opendir($src); // @mkdir($dst); - if (!@mkdir($dst) && !is_dir($dst)) { + if (!@\mkdir($dst) && !\is_dir($dst)) { throw new \RuntimeException('The directory ' . $dst . ' could not be created.'); } - while (false !== ($file = readdir($dir))) { + while (false !== ($file = \readdir($dir))) { if (('.' !== $file) && ('..' !== $file)) { - if (is_dir($src . '/' . $file)) { + if (\is_dir($src . '/' . $file)) { self::recurseCopy($src . '/' . $file, $dst . '/' . $file); } else { - copy($src . '/' . $file, $dst . '/' . $file); + \copy($src . '/' . $file, $dst . '/' . $file); } } } - closedir($dir); + \closedir($dir); } /** @@ -98,7 +98,7 @@ public static function deleteDirectory($src) $dirInfo = new \SplFileInfo($src); // validate is a directory if ($dirInfo->isDir()) { - $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); + $fileList = \array_diff(\scandir($src, \SCANDIR_SORT_NONE), ['..', '.']); foreach ($fileList as $k => $v) { $fileInfo = new \SplFileInfo("{$src}/{$v}"); if ($fileInfo->isDir()) { @@ -106,13 +106,13 @@ public static function deleteDirectory($src) if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { break; } - } elseif (!($success = unlink($fileInfo->getRealPath()))) { + } elseif (!($success = \unlink($fileInfo->getRealPath()))) { break; } } // now delete this (sub)directory if all the files are gone if ($success) { - $success = rmdir($dirInfo->getRealPath()); + $success = \rmdir($dirInfo->getRealPath()); } } else { // input is not a valid directory @@ -139,7 +139,7 @@ public static function rrmdir($src) } // If source is not a directory stop processing - if (!is_dir($src)) { + if (!\is_dir($src)) { return false; } @@ -151,7 +151,7 @@ public static function rrmdir($src) if ($fObj->isFile()) { $filename = $fObj->getPathname(); $fObj = null; // clear this iterator object to close the file - if (!unlink($filename)) { + if (!\unlink($filename)) { return false; // couldn't delete the file } } elseif (!$fObj->isDot() && $fObj->isDir()) { @@ -160,7 +160,7 @@ public static function rrmdir($src) } } $iterator = null; // clear iterator Obj to close file/directory - return rmdir($src); // remove the directory & return results + return \rmdir($src); // remove the directory & return results } /** @@ -179,12 +179,12 @@ public static function rmove($src, $dest) } // If source is not a directory stop processing - if (!is_dir($src)) { + if (!\is_dir($src)) { return false; } // If the destination directory does not exist and could not be created stop processing - if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { return false; } @@ -192,7 +192,7 @@ public static function rmove($src, $dest) $iterator = new \DirectoryIterator($src); foreach ($iterator as $fObj) { if ($fObj->isFile()) { - rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); + \rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } elseif (!$fObj->isDot() && $fObj->isDir()) { // Try recursively on directory self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); @@ -200,7 +200,7 @@ public static function rmove($src, $dest) } } $iterator = null; // clear iterator Obj to close file/directory - return rmdir($src); // remove the directory & return results + return \rmdir($src); // remove the directory & return results } /** @@ -222,12 +222,12 @@ public static function rcopy($src, $dest) } // If source is not a directory stop processing - if (!is_dir($src)) { + if (!\is_dir($src)) { return false; } // If the destination directory does not exist and could not be created stop processing - if (!is_dir($dest) && !mkdir($dest) && !is_dir($dest)) { + if (!\is_dir($dest) && !\mkdir($dest) && !\is_dir($dest)) { return false; } @@ -235,7 +235,7 @@ public static function rcopy($src, $dest) $iterator = new \DirectoryIterator($src); foreach ($iterator as $fObj) { if ($fObj->isFile()) { - copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); + \copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } elseif (!$fObj->isDot() && $fObj->isDir()) { self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); } diff --git a/class/Common/Migrate.php b/class/Common/Migrate.php index cfd1f734..08ba8824 100644 --- a/class/Common/Migrate.php +++ b/class/Common/Migrate.php @@ -39,7 +39,7 @@ public function __construct(Newbb\Common\Configurator $configurator) { $this->renameTables = $configurator->renameTables; - $moduleDirName = basename(dirname(__DIR__, 2)); + $moduleDirName = \basename(\dirname(__DIR__, 2)); parent::__construct($moduleDirName); } @@ -67,7 +67,7 @@ private function changePrefix() . '' ); - trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!'); + \trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!'); } } } diff --git a/class/Common/ServerStats.php b/class/Common/ServerStats.php index daffde1c..bbfdb185 100644 --- a/class/Common/ServerStats.php +++ b/class/Common/ServerStats.php @@ -27,7 +27,7 @@ trait ServerStats public static function getServerStats() { //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); - $moduleDirName = \basename(dirname(__DIR__, 2)); + $moduleDirName = \basename(\dirname(__DIR__, 2)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); \xoops_loadLanguage('common', $moduleDirName); $html = ''; diff --git a/class/Common/SysUtility.php b/class/Common/SysUtility.php index db6ac651..f696cee6 100644 --- a/class/Common/SysUtility.php +++ b/class/Common/SysUtility.php @@ -214,11 +214,11 @@ public static function cloneRecord($tableName, $id_field, $id) $new_id = false; $table = $GLOBALS['xoopsDB']->prefix($tableName); // copy content of the record you wish to clone - $tempTable = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query("SELECT * FROM $table WHERE $id_field='$id' "), MYSQLI_ASSOC) or exit('Could not select record'); + $tempTable = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query("SELECT * FROM $table WHERE $id_field='$id' "), \MYSQLI_ASSOC) or exit('Could not select record'); // set the auto-incremented id's value to blank. unset($tempTable[$id_field]); // insert cloned copy of the original record - $result = $GLOBALS['xoopsDB']->queryF("INSERT INTO $table (" . implode(', ', array_keys($tempTable)) . ") VALUES ('" . implode("', '", array_values($tempTable)) . "')") or exit ($GLOBALS['xoopsDB']->error()); + $result = $GLOBALS['xoopsDB']->queryF("INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", \array_values($tempTable)) . "')") or exit ($GLOBALS['xoopsDB']->error()); if ($result) { // Return the new id diff --git a/class/Common/VersionChecks.php b/class/Common/VersionChecks.php index 299f2e5f..0f251b1d 100644 --- a/class/Common/VersionChecks.php +++ b/class/Common/VersionChecks.php @@ -29,7 +29,7 @@ trait VersionChecks */ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) { - $moduleDirName = \basename(dirname(__DIR__, 2)); + $moduleDirName = \basename(\dirname(__DIR__, 2)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); @@ -61,7 +61,7 @@ public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = */ public static function checkVerPhp(\XoopsModule $module = null) { - $moduleDirName = \basename(dirname(__DIR__, 2)); + $moduleDirName = \basename(\dirname(__DIR__, 2)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); if (null === $module) { $module = \XoopsModule::getByDirname($moduleDirName); @@ -98,7 +98,7 @@ public static function checkVerPhp(\XoopsModule $module = null) public static function checkVerModule($helper, $source = 'github', $default = 'master') { - $moduleDirName = \basename(dirname(__DIR__, 2)); + $moduleDirName = \basename(\dirname(__DIR__, 2)); $moduleDirNameUpper = mb_strtoupper($moduleDirName); $update = ''; $repository = 'XoopsModules25x/' . $moduleDirName; diff --git a/class/ForumHandler.php b/class/ForumHandler.php index 54487892..0d1088e6 100644 --- a/class/ForumHandler.php +++ b/class/ForumHandler.php @@ -362,7 +362,7 @@ public function getAllTopics($forum, $criteria = null) $forum_link = '' . $viewAllForums[$myrow['forum_id']]['forum_name'] . ''; } - $topic_title = htmlspecialchars($myrow['topic_title'], ENT_QUOTES | ENT_HTML5); + $topic_title = \htmlspecialchars($myrow['topic_title'], \ENT_QUOTES | \ENT_HTML5); // irmtfan remove here and move to for loop //if ($myrow['type_id'] > 0) { //$topic_title = '['.$typen[$myrow["type_id"]]["type_name"].'] '.$topic_title.''; @@ -377,7 +377,7 @@ public function getAllTopics($forum, $criteria = null) $topic_excerpt = ''; } else { $topic_excerpt = \xoops_substr(\newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $excerpt); - $topic_excerpt = \str_replace('[', '[', htmlspecialchars($topic_excerpt, ENT_QUOTES | ENT_HTML5)); + $topic_excerpt = \str_replace('[', '[', \htmlspecialchars($topic_excerpt, \ENT_QUOTES | \ENT_HTML5)); } // START irmtfan move here @@ -385,7 +385,7 @@ public function getAllTopics($forum, $criteria = null) $topicLink ='viewtopic.php?topic_id=' . $myrow['topic_id']; if ($xoopsUser){ - $lastRead = newbbGetRead('topic', $myrow['topic_id']); + $lastRead = \newbbGetRead('topic', $myrow['topic_id']); if (isset($lastRead)){ if (!empty($lastRead)){ if ($lastRead<$myrow['topic_last_post_id']){ @@ -421,12 +421,12 @@ public function getAllTopics($forum, $criteria = null) //mb 'topic_poster_uid' => $myrow['topic_poster'], - 'topic_poster_name' => htmlspecialchars($myrow['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5), + 'topic_poster_name' => \htmlspecialchars($myrow['poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous'], \ENT_QUOTES | \ENT_HTML5), 'topic_views' => $myrow['topic_views'], 'topic_time' => \newbbFormatTimestamp($myrow['topic_time']), 'topic_last_posttime' => \newbbFormatTimestamp($myrow['last_post_time']), 'topic_last_poster_uid' => $myrow['uid'], - 'topic_last_poster_name' => htmlspecialchars($myrow['last_poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5), + 'topic_last_poster_name' => \htmlspecialchars($myrow['last_poster_name'] ?: $GLOBALS['xoopsConfig']['anonymous'], \ENT_QUOTES | \ENT_HTML5), 'topic_forum_link' => $forum_link, 'topic_excerpt' => $topic_excerpt, 'stick' => empty($myrow['topic_sticky']), @@ -897,7 +897,7 @@ public function &display($forums, $length_title_index = 30, $count_subforum = 1) $users_linked = \newbbGetUnameFromIds(\array_unique($users), !empty($GLOBALS['xoopsModuleConfig']['show_realname']), true); $forums_array = []; - $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5); + $name_anonymous = \htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], \ENT_QUOTES | \ENT_HTML5); foreach (\array_keys($forums) as $id) { $forum = &$forums[$id]; diff --git a/class/IconHandler.php b/class/IconHandler.php index 8d7c187b..f7493da4 100644 --- a/class/IconHandler.php +++ b/class/IconHandler.php @@ -97,12 +97,12 @@ public function getPath($type, $dirname = 'newbb', $default = '', $endDir = 'ima $rel_dir = "modules/{$dirname}/{$endDir}"; // START irmtfan add default for all pathes if (empty($default)) { - $path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}" : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}")); + $path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir(\XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? \XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}" : $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}")); } else { - $path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir($theme_path . "/{$rel_dir}/{$default}/") ? $theme_path . "/{$rel_dir}/{$default}" : (\is_dir(XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? XOOPS_THEME_PATH - . "/default/{$rel_dir}/{$type}" : (\is_dir( - XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}/" - ) ? XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}" : (\is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}") : $GLOBALS['xoops']->path( + $path = \is_dir($theme_path . "/{$rel_dir}/{$type}/") ? $theme_path . "/{$rel_dir}/{$type}" : (\is_dir($theme_path . "/{$rel_dir}/{$default}/") ? $theme_path . "/{$rel_dir}/{$default}" : (\is_dir(\XOOPS_THEME_PATH . "/default/{$rel_dir}/{$type}/") ? \XOOPS_THEME_PATH + . "/default/{$rel_dir}/{$type}" : (\is_dir( + \XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}/" + ) ? \XOOPS_THEME_PATH . "/default/{$rel_dir}/{$default}" : (\is_dir($GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}/")) ? $GLOBALS['xoops']->path("modules/{$dirname}/templates/{$endDir}/{$type}") : $GLOBALS['xoops']->path( "modules/{$dirname}/templates/{$endDir}/{$default}" )) // XOOPS_ROOT_PATH ) // XOOPS_THEME_PATH {$default} @@ -198,7 +198,7 @@ public function assignImages($images) } /** - * @return int|void + * @return int */ public function render() { diff --git a/class/ObjectTree.php b/class/ObjectTree.php index ce27baa5..eb32c1af 100644 --- a/class/ObjectTree.php +++ b/class/ObjectTree.php @@ -48,13 +48,13 @@ public function __construct($objectArr, $rootId = null) /** * Make options for a select box from * - * @param int $key ID of the object to display as the root of select options - * @param string $ret (reference to a string when called from outside) Result from previous recursions - * @param string $prefix_orig String to indent items at deeper levels - * @param string $prefix_curr String to indent the current item + * @param int $key ID of the object to display as the root of select options + * @param array $ret (reference to a string when called from outside) Result from previous recursions + * @param string $prefix_orig String to indent items at deeper levels + * @param string $prefix_curr String to indent the current item * @param null|array $tags * @internal param string $fieldName Name of the member variable from the - * node objects that should be used as the title for the options. + * node objects that should be used as the title for the options. * @internal param string $selected Value to display as selected * @access private */ @@ -270,7 +270,7 @@ public function &makeArrayTree($key = 0, $tags = null, $depth = 0) */ public function &myGetParentForums($key, array $ret = [], $uplevel = 0) { - if (isset($this->tree[$key]['parent']) && isset($this->tree[$this->tree[$key]['parent']]['obj'])) { + if (isset($this->tree[$key]['parent'], $this->tree[$this->tree[$key]['parent']]['obj'])) { $ret[$uplevel] = $this->tree[$this->tree[$key]['parent']]['obj']; if ($this->tree[$key]['parent'] !== $key) { //$parents = $this->getParentForums($this->tree[$key]['parent'], $ret, $uplevel+1); @@ -293,7 +293,7 @@ public function &getParentForums($key, $reverse = true) { $ret = []; $pids = []; - if (isset($this->tree[$key]['parent']) && isset($this->tree[$this->tree[$key]['parent']]['obj'])) { + if (isset($this->tree[$key]['parent'], $this->tree[$this->tree[$key]['parent']]['obj'])) { $pids[] = $this->tree[$this->tree[$key]['parent']]['obj']->getVar($this->myId); $parents = $this->myGetParentForums($this->tree[$key]['parent'], $ret); foreach (\array_keys($parents) as $newkey) { diff --git a/class/OnlineHandler.php b/class/OnlineHandler.php index 140a6c22..662d3a91 100644 --- a/class/OnlineHandler.php +++ b/class/OnlineHandler.php @@ -20,7 +20,7 @@ use XoopsModules\Newbb; /** @var \XoopsOnlineHandler $xoopsOnlineHandler */ -require_once dirname(__DIR__) . '/include/functions.config.php'; +require_once \dirname(__DIR__) . '/include/functions.config.php'; /** * Class OnlineHandler @@ -51,14 +51,14 @@ public function __construct(XoopsDatabase $db = null) */ public function init($forum = null, $forumtopic = null) { - if (is_object($forum)) { + if (\is_object($forum)) { $this->forum_id = $forum->getVar('forum_id'); $this->forumObject = $forum; } else { $this->forum_id = (int)$forum; $this->forumObject = $forum; } - if (is_object($forumtopic)) { + if (\is_object($forumtopic)) { $this->topic_id = $forumtopic->getVar('topic_id'); if (empty($this->forum_id)) { $this->forum_id = $forumtopic->getVar('forum_id'); @@ -75,10 +75,10 @@ public function update() global $xoopsModule; // set gc probabillity to 10% for now.. - if (mt_rand(1, 100) < 60) { + if (\random_int(1, 100) < 60) { $this->gc(150); } - if (is_object($GLOBALS['xoopsUser'])) { + if (\is_object($GLOBALS['xoopsUser'])) { $uid = $GLOBALS['xoopsUser']->getVar('uid'); $uname = $GLOBALS['xoopsUser']->getVar('uname'); $name = $GLOBALS['xoopsUser']->getVar('name'); @@ -89,14 +89,14 @@ public function update() } /** @var \XoopsOnlineHandler $xoopsOnlineHandler */ - $xoopsOnlineHandler = xoops_getHandler('online'); - $xoopsupdate = $xoopsOnlineHandler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), \Xmf\IPAddress::fromRequest()->asReadable()); + $xoopsOnlineHandler = \xoops_getHandler('online'); + $xoopsupdate = $xoopsOnlineHandler->write($uid, $uname, \time(), $xoopsModule->getVar('mid'), \Xmf\IPAddress::fromRequest()->asReadable()); if (!$xoopsupdate) { //xoops_error("newbb online upate error"); } $uname = (empty($GLOBALS['xoopsModuleConfig']['show_realname']) || empty($name)) ? $uname : $name; - $this->write($uid, $uname, time(), $this->forum_id, IPAddress::fromRequest()->asReadable(), $this->topic_id); + $this->write($uid, $uname, \time(), $this->forum_id, IPAddress::fromRequest()->asReadable(), $this->topic_id); } /** @@ -104,8 +104,8 @@ public function update() */ public function render(Smarty $xoopsTpl) { - require_once dirname(__DIR__) . '/include/functions.render.php'; - require_once dirname(__DIR__) . '/include/functions.user.php'; + require_once \dirname(__DIR__) . '/include/functions.render.php'; + require_once \dirname(__DIR__) . '/include/functions.user.php'; $criteria = null; if ($this->topic_id) { $criteria = new Criteria('online_topic', $this->topic_id); @@ -113,7 +113,7 @@ public function render(Smarty $xoopsTpl) $criteria = new Criteria('online_forum', $this->forum_id); } $users = $this->getAll($criteria); - $num_total = count($users); + $num_total = \count($users); $num_user = 0; $users_id = []; @@ -131,18 +131,18 @@ public function render(Smarty $xoopsTpl) } $num_anonymous = $num_total - $num_user; $online = []; - $online['image'] = newbbDisplayImage('whosonline'); + $online['image'] = \newbbDisplayImage('whosonline'); $online['num_total'] = $num_total; $online['num_user'] = $num_user; $online['num_anonymous'] = $num_anonymous; - $administrator_list = newbbIsModuleAdministrators($users_id); + $administrator_list = \newbbIsModuleAdministrators($users_id); $moderator_list = []; - $member_list = array_diff(array_keys($administrator_list), $users_id); + $member_list = \array_diff(\array_keys($administrator_list), $users_id); if ($member_list) { - if (is_object($this->forumObject)) { + if (\is_object($this->forumObject)) { $moderator_list = $this->forumObject->getVar('forum_moderator'); } else { - $moderator_list = newbbIsForumModerators($member_list); + $moderator_list = \newbbIsForumModerators($member_list); } } foreach ($users_online as $uid => $user) { @@ -164,8 +164,8 @@ public function render(Smarty $xoopsTpl) */ public function showOnline() { - require_once dirname(__DIR__) . '/include/functions.render.php'; - require_once dirname(__DIR__) . '/include/functions.user.php'; + require_once \dirname(__DIR__) . '/include/functions.render.php'; + require_once \dirname(__DIR__) . '/include/functions.user.php'; $criteria = null; if ($this->topic_id) { $criteria = new Criteria('online_topic', $this->topic_id); @@ -173,7 +173,7 @@ public function showOnline() $criteria = new Criteria('online_forum', $this->forum_id); } $users = $this->getAll($criteria); - $num_total = count($users); + $num_total = \count($users); $num_user = 0; $users_id = []; @@ -191,26 +191,26 @@ public function showOnline() } $num_anonymous = $num_total - $num_user; $online = []; - $online['image'] = newbbDisplayImage('whosonline'); - $online['statistik'] = newbbDisplayImage('statistik'); + $online['image'] = \newbbDisplayImage('whosonline'); + $online['statistik'] = \newbbDisplayImage('statistik'); $online['num_total'] = $num_total; $online['num_user'] = $num_user; $online['num_anonymous'] = $num_anonymous; - $administrator_list = newbbIsModuleAdministrators($users_id); + $administrator_list = \newbbIsModuleAdministrators($users_id); $moderator_list = []; - $member_list = array_diff($users_id, array_keys($administrator_list)); + $member_list = \array_diff($users_id, \array_keys($administrator_list)); if ($member_list) { - if (is_object($this->forumObject)) { + if (\is_object($this->forumObject)) { $moderator_list = $this->forumObject->getVar('forum_moderator'); } else { - $moderator_list = newbbIsForumModerators($member_list); + $moderator_list = \newbbIsForumModerators($member_list); } } foreach ($users_online as $uid => $user) { - if (in_array($uid, $administrator_list)) { + if (\in_array($uid, $administrator_list)) { $user['level'] = 2; - } elseif (in_array($uid, $moderator_list)) { + } elseif (\in_array($uid, $moderator_list)) { $user['level'] = 1; } else { $user['level'] = 0; @@ -250,14 +250,14 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id) $sql .= " AND online_ip='" . $ip . "'"; } } else { - $sql = sprintf('INSERT INTO `%s` (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)', $this->db->prefix('newbb_online'), $uid, $this->db->quote($uname), $time, $this->db->quote($ip), $forum_id, $topic_id); + $sql = \sprintf('INSERT INTO `%s` (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)', $this->db->prefix('newbb_online'), $uid, $this->db->quote($uname), $time, $this->db->quote($ip), $forum_id, $topic_id); } if (!$this->db->queryF($sql)) { //xoops_error($this->db->error()); return false; } - $xoopsOnlineHandler = xoops_getHandler('online'); + $xoopsOnlineHandler = \xoops_getHandler('online'); $xoopsOnlineTable = $xoopsOnlineHandler->table; $sql = 'DELETE FROM ' @@ -292,10 +292,10 @@ public function write($uid, $uname, $time, $forum_id, $ip, $topic_id) public function gc($expire) { global $xoopsModule; - $sql = 'DELETE FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_updated < ' . (time() - (int)$expire); + $sql = 'DELETE FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_updated < ' . (\time() - (int)$expire); $this->db->queryF($sql); - $xoopsOnlineHandler = xoops_getHandler('online'); + $xoopsOnlineHandler = \xoops_getHandler('online'); $xoopsOnlineHandler->gc($expire); } @@ -310,7 +310,7 @@ public function getAll($criteria = null) $ret = []; $limit = $start = 0; $sql = 'SELECT * FROM ' . $this->db->prefix('newbb_online'); - if (is_object($criteria) && $criteria instanceof CriteriaElement) { + if (\is_object($criteria) && $criteria instanceof CriteriaElement) { $sql .= ' ' . $criteria->renderWhere(); $limit = $criteria->getLimit(); $start = $criteria->getStart(); @@ -324,7 +324,7 @@ public function getAll($criteria = null) } unset($myrow); } - $this->user_ids = array_unique($this->user_ids); + $this->user_ids = \array_unique($this->user_ids); } return $ret; } @@ -342,7 +342,7 @@ public function checkStatus($uids) } else { $sql = 'SELECT online_uid FROM ' . $this->db->prefix('newbb_online'); if (!empty($uids)) { - $sql .= ' WHERE online_uid IN (' . implode(', ', array_map('\intval', $uids)) . ')'; + $sql .= ' WHERE online_uid IN (' . \implode(', ', \array_map('\intval', $uids)) . ')'; } $result = $this->db->query($sql); @@ -354,7 +354,7 @@ public function checkStatus($uids) } } foreach ($uids as $uid) { - if (in_array($uid, $online_users)) { + if (\in_array($uid, $online_users)) { $ret[$uid] = 1; } } @@ -371,7 +371,7 @@ public function checkStatus($uids) public function getCount($criteria = null) { $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online'); - if (is_object($criteria) && $criteria instanceof CriteriaElement) { + if (\is_object($criteria) && $criteria instanceof CriteriaElement) { $sql .= ' ' . $criteria->renderWhere(); } if (!$result = $this->db->query($sql)) { diff --git a/class/Post.php b/class/Post.php index 595ff34c..0707ee5d 100644 --- a/class/Post.php +++ b/class/Post.php @@ -487,7 +487,7 @@ public function showPost($isAdmin) /** @var TopicHandler $topicHandler */ $topicHandler = Helper::getInstance()->getHandler('Topic'); if (null === $name_anonymous) { - $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5); + $name_anonymous = \htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], \ENT_QUOTES | \ENT_HTML5); } require_once \dirname(__DIR__) . '/include/functions.time.php'; diff --git a/class/ReadHandler.php b/class/ReadHandler.php index 36b2aed3..e26b0018 100644 --- a/class/ReadHandler.php +++ b/class/ReadHandler.php @@ -256,7 +256,7 @@ public function isReadItems($items, $uid = null) { $ret = null; if (empty($this->mode)) { - return $ret; + return null; } if (1 == $this->mode) { diff --git a/class/TopicHandler.php b/class/TopicHandler.php index 9e5f8418..e5f7383d 100644 --- a/class/TopicHandler.php +++ b/class/TopicHandler.php @@ -44,7 +44,7 @@ public function get($id = null, $fields = null) //get($id, $var = null) $tags = [$var]; } if (!$topicObject = parent::get($id, $tags)) { - return $ret; + return null; } $ret = $topicObject; if (!empty($var) && \is_string($var)) { @@ -243,7 +243,13 @@ public function getTopPostId($topic_id) } //Added by BigKev to get the next unread post ID based on the $lastreadpost_id - public function getNextPostId($topic_id, $lastreadpost_id) + + /** + * @param $topic_id + * @param $lastreadpost_id + * @return false|mixed + */ + public function getNextPostId($topic_id, $lastreadpost_id) { $sql = 'SELECT MIN(post_id) AS post_id FROM ' . $this->db->prefix('newbb_posts') . ' WHERE topic_id = ' . $topic_id . ' AND post_id > ' . $lastreadpost_id . ' ORDER BY post_id LIMIT 1'; $result = $this->db->query($sql); @@ -361,7 +367,7 @@ public function showTreeItem($topic, &$postArray) $postArray['poster'] = '' . $viewtopic_users[$postArray['uid']]['name'] . ''; } } else { - $postArray['poster'] = empty($postArray['poster_name']) ? htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5) : $postArray['poster_name']; + $postArray['poster'] = empty($postArray['poster_name']) ? \htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], \ENT_QUOTES | \ENT_HTML5) : $postArray['poster_name']; } return $postArray; diff --git a/class/TopicRenderer.php b/class/TopicRenderer.php index 65fc9de7..4de82dea 100644 --- a/class/TopicRenderer.php +++ b/class/TopicRenderer.php @@ -96,11 +96,11 @@ public function setVar($var, $val) { switch ($var) { case 'forum': - if (is_numeric($val)) { + if (\is_numeric($val)) { $val = (int)$val; // START irmtfan - if the forum is array - } elseif (is_array($val)) { - $val = implode('|', $val); + } elseif (\is_array($val)) { + $val = \implode('|', $val); //} elseif (!empty($val)) { // $val = implode("|", array_map("intval", explode(", ", $val))); } @@ -118,8 +118,8 @@ public function setVar($var, $val) break; case 'status': // START irmtfan to accept multiple status - $val = is_array($val) ? $val : [$val]; - $val = implode(',', $val); + $val = \is_array($val) ? $val : [$val]; + $val = \implode(',', $val); //$val = (in_array($val, array_keys($this->getStatus( $this->userlevel ))) ) ? $val : "all"; //irmtfan no need to check if status is empty or not //if ($val === "all" && !$this->is_multiple) $val = ""; irmtfan commented because it is done in sort // END irmtfan to accept multiple status @@ -139,7 +139,7 @@ public function setVars(array $vars = []) $this->init(); foreach ($vars as $var => $val) { - if (!in_array($var, $this->args)) { + if (!\in_array($var, $this->args)) { continue; } } @@ -224,7 +224,7 @@ public function myParseStatus($status = null) // Use database } elseif (2 == $this->config['read_mode']) { // START irmtfan use read_uid to find the unread posts when the user is logged in - $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + $read_uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; if (!empty($read_uid)) { $this->query['join'][] = 'LEFT JOIN ' . $this->handler->db->prefix('newbb_reads_topic') . ' AS r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' '; $this->query['where'][] = 'r.post_id = t.topic_last_post_id'; @@ -234,24 +234,24 @@ public function myParseStatus($status = null) // User cookie } elseif (1 == $this->config['read_mode']) { // START irmtfan fix read_mode = 1 bugs - for all users (member and anon) - $startdate = !empty($this->vars['since']) ? (time() - newbbGetSinceTime($this->vars['since'])) : 0; - $lastvisit = max($GLOBALS['last_visit'], $startdate); + $startdate = !empty($this->vars['since']) ? (\time() - \newbbGetSinceTime($this->vars['since'])) : 0; + $lastvisit = \max($GLOBALS['last_visit'], $startdate); if ($lastvisit) { $readmode1query = ''; if ($lastvisit > $startdate) { $readmode1query = 'p.post_time < ' . $lastvisit; } $topics = []; - $topic_lastread = newbbGetCookie('LT', true); - if (count($topic_lastread) > 0) { + $topic_lastread = \newbbGetCookie('LT', true); + if (\count($topic_lastread) > 0) { foreach ($topic_lastread as $id => $time) { if ($time > $lastvisit) { $topics[] = $id; } } } - if (count($topics) > 0) { - $topicquery = ' t.topic_id IN (' . implode(',', $topics) . ')'; + if (\count($topics) > 0) { + $topicquery = ' t.topic_id IN (' . \implode(',', $topics) . ')'; // because it should be OR $readmode1query = !empty($readmode1query) ? '(' . $readmode1query . ' OR ' . $topicquery . ')' : $topicquery; } @@ -266,7 +266,7 @@ public function myParseStatus($status = null) // Use database } elseif (2 == $this->config['read_mode']) { // START irmtfan use read_uid to find the unread posts when the user is logged in - $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; + $read_uid = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; if (!empty($read_uid)) { $this->query['join'][] = 'LEFT JOIN ' . $this->handler->db->prefix('newbb_reads_topic') . ' AS r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' '; $this->query['where'][] = '(r.read_id IS NULL OR r.post_id < t.topic_last_post_id)'; @@ -276,23 +276,23 @@ public function myParseStatus($status = null) // User cookie } elseif (1 == $this->config['read_mode']) { // START irmtfan fix read_mode = 1 bugs - for all users (member and anon) - $startdate = !empty($this->vars['since']) ? (time() - newbbGetSinceTime($this->vars['since'])) : 0; - $lastvisit = max($GLOBALS['last_visit'], $startdate); + $startdate = !empty($this->vars['since']) ? (\time() - \newbbGetSinceTime($this->vars['since'])) : 0; + $lastvisit = \max($GLOBALS['last_visit'], $startdate); if ($lastvisit) { if ($lastvisit > $startdate) { $this->query['where'][] = 'p.post_time > ' . $lastvisit; } $topics = []; - $topic_lastread = newbbGetCookie('LT', true); - if (count($topic_lastread) > 0) { + $topic_lastread = \newbbGetCookie('LT', true); + if (\count($topic_lastread) > 0) { foreach ($topic_lastread as $id => $time) { if ($time > $lastvisit) { $topics[] = $id; } } } - if (count($topics) > 0) { - $this->query['where'][] = ' t.topic_id NOT IN (' . implode(',', $topics) . ')'; + if (\count($topics) > 0) { + $this->query['where'][] = ' t.topic_id NOT IN (' . \implode(',', $topics) . ')'; } } // END irmtfan fix read_mode = 1 bugs - for all users (member and anon) @@ -332,7 +332,7 @@ public function parseVar($var, $val) /** @var Newbb\ForumHandler $forumHandler */ $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); // START irmtfan - get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums // Get accessible forums - $accessForums = $forumHandler->getIdsByValues(array_map('\intval', @explode('|', $val))); + $accessForums = $forumHandler->getIdsByValues(\array_map('\intval', @\explode('|', $val))); // Filter specified forums if any //if (!empty($val) && $_forums = @explode('|', $val)) { //$accessForums = array_intersect($accessForums, array_map('intval', $_forums)); @@ -346,31 +346,31 @@ public function parseVar($var, $val) //} elseif (count($accessForums) === 1) { //$this->query["where"][] = "t.forum_id = " . $accessForums[0]; } else { - $this->query['where'][] = 't.forum_id IN ( ' . implode(', ', $accessForums) . ' )'; + $this->query['where'][] = 't.forum_id IN ( ' . \implode(', ', $accessForums) . ' )'; } break; case 'uid': // irmtfan add multi topic poster if (-1 !== $val) { - $val = implode(',', array_map('\intval', explode(',', $val))); + $val = \implode(',', \array_map('\intval', \explode(',', $val))); $this->query['where'][] = 't.topic_poster IN ( ' . $val . ' )'; } break; case 'lastposter': // irmtfan add multi lastposter if (-1 !== $val) { - $val = implode(',', array_map('\intval', explode(',', $val))); + $val = \implode(',', \array_map('\intval', \explode(',', $val))); $this->query['where'][] = 'p.uid IN ( ' . $val . ' )'; } break; case 'since': if (!empty($val)) { // START irmtfan if unread && read_mode = 1 and last_visit > startdate do not add where query | to accept multiple status - $startdate = time() - newbbGetSinceTime($val); - if (in_array('unread', explode(',', $this->vars['status'])) && 1 == $this->config['read_mode'] + $startdate = \time() - \newbbGetSinceTime($val); + if (\in_array('unread', \explode(',', $this->vars['status'])) && 1 == $this->config['read_mode'] && $GLOBALS['last_visit'] > $startdate) { break; } // irmtfan digest_time | to accept multiple status - if (in_array('digest', explode(',', $this->vars['status']))) { + if (\in_array('digest', \explode(',', $this->vars['status']))) { $this->query['where'][] = 't.digest_time > ' . $startdate; } // irmtfan - should be >= instead of = @@ -385,9 +385,9 @@ public function parseVar($var, $val) break; case 'status': // START irmtfan to accept multiple status - $val = explode(',', $val); + $val = \explode(',', $val); // irmtfan - add 'all' to always parse t.approved = 1 - if (0 === count(array_intersect($val, ['all', 'active', 'pending', 'deleted']))) { + if (0 === \count(\array_intersect($val, ['all', 'active', 'pending', 'deleted']))) { $val[] = 'all'; } foreach ($val as $key => $status) { @@ -451,69 +451,69 @@ public function getSort($header = null, $var = null) { $headers = [ 'topic' => [ - 'title' => _MD_NEWBB_TOPICS, + 'title' => \_MD_NEWBB_TOPICS, 'sort' => 't.topic_title', ], 'forum' => [ - 'title' => _MD_NEWBB_FORUM, + 'title' => \_MD_NEWBB_FORUM, 'sort' => 't.forum_id', ], 'poster' => [ - 'title' => _MD_NEWBB_TOPICPOSTER, /*irmtfan _MD_NEWBB_POSTER to _MD_NEWBB_TOPICPOSTER*/ + 'title' => \_MD_NEWBB_TOPICPOSTER, /*irmtfan _MD_NEWBB_POSTER to _MD_NEWBB_TOPICPOSTER*/ 'sort' => 't.topic_poster', ], 'replies' => [ - 'title' => _MD_NEWBB_REPLIES, + 'title' => \_MD_NEWBB_REPLIES, 'sort' => 't.topic_replies', ], 'views' => [ - 'title' => _MD_NEWBB_VIEWS, + 'title' => \_MD_NEWBB_VIEWS, 'sort' => 't.topic_views', ], 'lastpost' => [ // irmtfan show topic_page_jump_icon smarty - 'title' => _MD_NEWBB_LASTPOST, + 'title' => \_MD_NEWBB_LASTPOST, /*irmtfan _MD_NEWBB_DATE to _MD_NEWBB_LASTPOSTTIME again change to _MD_LASTPOST*/ 'sort' => 't.topic_last_post_id', ], // START irmtfan add more sorts 'lastposttime' => [ // irmtfan same as lastpost - 'title' => _MD_NEWBB_LASTPOSTTIME, + 'title' => \_MD_NEWBB_LASTPOSTTIME, 'sort' => 't.topic_last_post_id', ], 'lastposter' => [ // irmtfan - 'title' => _MD_NEWBB_POSTER, + 'title' => \_MD_NEWBB_POSTER, 'sort' => 'p.uid', // poster uid ], 'lastpostmsgicon' => [ // irmtfan - 'title' => _MD_NEWBB_MESSAGEICON, + 'title' => \_MD_NEWBB_MESSAGEICON, 'sort' => 'p.icon', // post message icon ], 'ratings' => [ - 'title' => _MD_NEWBB_RATINGS, + 'title' => \_MD_NEWBB_RATINGS, 'sort' => 't.rating', // irmtfan t.topic_rating to t.rating ], 'votes' => [ - 'title' => _MD_NEWBB_VOTES, + 'title' => \_MD_NEWBB_VOTES, 'sort' => 't.votes', ], 'publish' => [ - 'title' => _MD_NEWBB_TOPICTIME, + 'title' => \_MD_NEWBB_TOPICTIME, 'sort' => 't.topic_id', ], 'digest' => [ - 'title' => _MD_NEWBB_DIGEST, + 'title' => \_MD_NEWBB_DIGEST, 'sort' => 't.digest_time', ], 'sticky' => [ - 'title' => _MD_NEWBB_STICKY, + 'title' => \_MD_NEWBB_STICKY, 'sort' => 't.topic_sticky', ], 'lock' => [ - 'title' => _MD_NEWBB_LOCK, + 'title' => \_MD_NEWBB_LOCK, 'sort' => 't.topic_status', ], 'poll' => [ - 'title' => _MD_NEWBB_POLL_POLL, + 'title' => \_MD_NEWBB_POLL_POLL, 'sort' => 't.poll_id', ], ]; @@ -526,7 +526,7 @@ public function getSort($header = null, $var = null) } if (2 == $this->userlevel) { $headers['approve'] = [ - 'title' => _MD_NEWBB_APPROVE, + 'title' => \_MD_NEWBB_APPROVE, 'sort' => 't.approved', ]; } @@ -541,7 +541,7 @@ public function getSort($header = null, $var = null) return @$headers[$header]; } $ret = null; - foreach (array_keys($headers) as $key) { + foreach (\array_keys($headers) as $key) { $ret[$key] = @$headers[$key][$var]; } @@ -558,12 +558,12 @@ public function getHeader($header = null) { $headersSort = $this->getSort('', 'title'); // additional headers - important: those cannot be in sort anyway - $headers = array_merge( + $headers = \array_merge( $headersSort, [ - 'attachment' => _MD_NEWBB_TOPICSHASATT, // show attachment smarty - 'read' => _MD_NEWBB_MARK_UNREAD . '|' . _MD_NEWBB_MARK_READ, // read/unread show topic_folder smarty - 'pagenav' => _MD_NEWBB_PAGENAV_DISPLAY, // show topic_page_jump smarty - sort by topic_replies? + 'attachment' => \_MD_NEWBB_TOPICSHASATT, // show attachment smarty + 'read' => \_MD_NEWBB_MARK_UNREAD . '|' . \_MD_NEWBB_MARK_READ, // read/unread show topic_folder smarty + 'pagenav' => \_MD_NEWBB_PAGENAV_DISPLAY, // show topic_page_jump smarty - sort by topic_replies? ] ); @@ -582,32 +582,32 @@ public function getStatus($type = null, $status = null) $links = [ //"" => "", /* irmtfan remove empty array */ 'all' => _ALL, - 'digest' => _MD_NEWBB_DIGEST, - 'undigest' => _MD_NEWBB_UNDIGEST, // irmtfan add - 'sticky' => _MD_NEWBB_STICKY, // irmtfan add - 'unsticky' => _MD_NEWBB_UNSTICKY, // irmtfan add - 'lock' => _MD_NEWBB_LOCK, // irmtfan add - 'unlock' => _MD_NEWBB_UNLOCK, // irmtfan add - 'poll' => _MD_NEWBB_TOPICHASPOLL, // irmtfan add - 'unpoll' => _MD_NEWBB_TOPICHASNOTPOLL, // irmtfan add - 'voted' => _MD_NEWBB_VOTED, // irmtfan add - 'unvoted' => _MD_NEWBB_UNVOTED, // irmtfan add - 'viewed' => _MD_NEWBB_VIEWED, // irmtfan add - 'unviewed' => _MD_NEWBB_UNVIEWED, // irmtfan add - 'replied' => _MD_NEWBB_REPLIED, // irmtfan add - 'unreplied' => _MD_NEWBB_UNREPLIED, - 'read' => _MD_NEWBB_READ, // irmtfan add - 'unread' => _MD_NEWBB_UNREAD, + 'digest' => \_MD_NEWBB_DIGEST, + 'undigest' => \_MD_NEWBB_UNDIGEST, // irmtfan add + 'sticky' => \_MD_NEWBB_STICKY, // irmtfan add + 'unsticky' => \_MD_NEWBB_UNSTICKY, // irmtfan add + 'lock' => \_MD_NEWBB_LOCK, // irmtfan add + 'unlock' => \_MD_NEWBB_UNLOCK, // irmtfan add + 'poll' => \_MD_NEWBB_TOPICHASPOLL, // irmtfan add + 'unpoll' => \_MD_NEWBB_TOPICHASNOTPOLL, // irmtfan add + 'voted' => \_MD_NEWBB_VOTED, // irmtfan add + 'unvoted' => \_MD_NEWBB_UNVOTED, // irmtfan add + 'viewed' => \_MD_NEWBB_VIEWED, // irmtfan add + 'unviewed' => \_MD_NEWBB_UNVIEWED, // irmtfan add + 'replied' => \_MD_NEWBB_REPLIED, // irmtfan add + 'unreplied' => \_MD_NEWBB_UNREPLIED, + 'read' => \_MD_NEWBB_READ, // irmtfan add + 'unread' => \_MD_NEWBB_UNREAD, ]; $links_admin = [ - 'active' => _MD_NEWBB_TYPE_ADMIN, - 'pending' => _MD_NEWBB_TYPE_PENDING, - 'deleted' => _MD_NEWBB_TYPE_DELETED, + 'active' => \_MD_NEWBB_TYPE_ADMIN, + 'pending' => \_MD_NEWBB_TYPE_PENDING, + 'deleted' => \_MD_NEWBB_TYPE_DELETED, ]; // all status, for admin if ($type > 1) { - $links = array_merge($links, $links_admin); // irmtfan to accept multiple status + $links = \array_merge($links, $links_admin); // irmtfan to accept multiple status } return $this->getFromKeys($links, $status); // irmtfan to accept multiple status @@ -621,17 +621,17 @@ public function buildSelection(\Smarty $xoopsTpl) { $selection = ['action' => $this->page]; $selection['vars'] = $this->vars; - require_once dirname(__DIR__) . '/include/functions.forum.php'; - $forum_selected = empty($this->vars['forum']) ? null : explode('|', @$this->vars['forum']); + require_once \dirname(__DIR__) . '/include/functions.forum.php'; + $forum_selected = empty($this->vars['forum']) ? null : \explode('|', @$this->vars['forum']); $selection['forum'] = ''; $sort_selected = $this->vars['sort']; $sorts = $this->getSort('', 'title'); $selection['sort'] = "'; $since = $this->vars['since'] ?? $this->config['since_default']; - $selection['since'] = newbbSinceSelectBox($since); + $selection['since'] = \newbbSinceSelectBox($since); $xoopsTpl->assign_by_ref('selection', $selection); } @@ -678,7 +678,7 @@ public function buildHeaders(\Smarty $xoopsTpl) } $headers = $this->getSort('', 'title'); - if (!is_array($headers)) { + if (!\is_array($headers)) { throw new \RuntimeException('$headers must be an array.'); } foreach ($headers as $header => $title) { @@ -687,7 +687,7 @@ public function buildHeaders(\Smarty $xoopsTpl) $_args[] = 'order=' . ((@$this->vars['order'] + 1) % 2); } $headers_data[$header]['title'] = $title; - $headers_data[$header]['link'] = $this->page . '?' . implode('&', array_merge($args, $_args)); + $headers_data[$header]['link'] = $this->page . '?' . \implode('&', \array_merge($args, $_args)); } $xoopsTpl->assign_by_ref('headers', $headers_data); } @@ -711,7 +711,7 @@ public function buildFilters(\Smarty $xoopsTpl) foreach ($links as $link => $title) { $_args = ["status={$link}"]; $status[$link]['title'] = $title; - $status[$link]['link'] = $this->page . '?' . implode('&', array_merge($args, $_args)); + $status[$link]['link'] = $this->page . '?' . \implode('&', \array_merge($args, $_args)); } $xoopsTpl->assign_by_ref('filters', $status); } @@ -727,7 +727,7 @@ public function getTypes($type_id = null) /** @var Newbb\TypeHandler $typeHandler */ $typeHandler = Helper::getInstance()->getHandler('Type'); - $types = $typeHandler->getByForum(explode('|', @$this->vars['forum'])); + $types = $typeHandler->getByForum(\explode('|', @$this->vars['forum'])); } if (empty($type_id)) { @@ -759,7 +759,7 @@ public function buildTypes(\Smarty $xoopsTpl) foreach ($types as $id => $type) { $_args = ["type={$id}"]; $status[$id]['title'] = $type['type_name']; - $status[$id]['link'] = $this->page . '?' . implode('&', array_merge($args, $_args)); + $status[$id]['link'] = $this->page . '?' . \implode('&', \array_merge($args, $_args)); } $xoopsTpl->assign_by_ref('types', $status); } @@ -780,9 +780,9 @@ public function buildCurrent(\Smarty $xoopsTpl) } $status = []; - $status['title'] = implode(',', $this->getStatus($this->userlevel, $this->vars['status'])); // irmtfan to accept multiple status + $status['title'] = \implode(',', $this->getStatus($this->userlevel, $this->vars['status'])); // irmtfan to accept multiple status //$status['link'] = $this->page.(empty($this->vars['status']) ? '' : '?status='.$this->vars['status']); - $status['link'] = $this->page . (empty($args) ? '' : '?' . implode('&', $args)); + $status['link'] = $this->page . (empty($args) ? '' : '?' . \implode('&', $args)); $xoopsTpl->assign_by_ref('current', $status); } @@ -802,9 +802,9 @@ public function buildPagenav(\Smarty $xoopsTpl) $args[] = "{$var}={$val}"; } require_once $GLOBALS['xoops']->path('class/pagenav.php'); - $nav = new \XoopsPageNav($count_topic, $this->config['topics_per_page'], @$this->vars['start'], 'start', implode('&', $args)); + $nav = new \XoopsPageNav($count_topic, $this->config['topics_per_page'], @$this->vars['start'], 'start', \implode('&', $args)); if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) { - $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url; + $nav->url = \formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . ' /' . $nav->url; } if ('select' === $this->config['pagenav_display']) { $navi = $nav->renderSelect(); @@ -840,8 +840,8 @@ public function getCount() $joins[] = 'LEFT JOIN ' . $this->handler->db->prefix('newbb_posts') . ' AS p ON p.post_id = t.topic_last_post_id'; $wheres[] = '1 = 1'; - $sql = ' SELECT ' . implode(', ', $selects) . ' FROM ' . implode(', ', $froms) . ' ' . implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index: join when post_excerpt = 0 - ' WHERE ' . implode(' AND ', $wheres) . ' AND ' . @implode(' AND ', @$this->query['where']); + $sql = ' SELECT ' . \implode(', ', $selects) . ' FROM ' . \implode(', ', $froms) . ' ' . \implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . \implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index: join when post_excerpt = 0 + ' WHERE ' . \implode(' AND ', $wheres) . ' AND ' . @\implode(' AND ', @$this->query['where']); if (!$result = $this->handler->db->query($sql)) { return 0; @@ -863,7 +863,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) //$this->parseVars(); if ($this->noperm) { - if (is_object($xoopsTpl)) { + if (\is_object($xoopsTpl)) { $xoopsTpl->assign_by_ref('topics', $ret); return; @@ -892,11 +892,11 @@ public function renderTopics(\Smarty $xoopsTpl = null) } //if (empty($this->query["sort"])) $this->query["sort"][] = 't.topic_last_post_id DESC'; // irmtfan commented no need - $sql = ' SELECT ' . implode(', ', $selects) . ' FROM ' . implode(', ', $froms) . ' ' . implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index join when post_excerpt = 0 - ' WHERE ' . implode(' AND ', $wheres) . ' AND ' . @implode(' AND ', @$this->query['where']) . ' ORDER BY ' . implode(', ', $this->query['sort']); + $sql = ' SELECT ' . \implode(', ', $selects) . ' FROM ' . \implode(', ', $froms) . ' ' . \implode(' ', $joins) . (!empty($this->query['join']) ? ' ' . \implode(' ', $this->query['join']) : '') . // irmtfan bug fix: Undefined index join when post_excerpt = 0 + ' WHERE ' . \implode(' AND ', $wheres) . ' AND ' . @\implode(' AND ', @$this->query['where']) . ' ORDER BY ' . \implode(', ', $this->query['sort']); if (!$result = $this->handler->db->query($sql, $this->config['topics_per_page'], @$this->vars['start'])) { - if (is_object($xoopsTpl)) { + if (\is_object($xoopsTpl)) { $xoopsTpl->assign_by_ref('topics', $ret); return; @@ -905,11 +905,11 @@ public function renderTopics(\Smarty $xoopsTpl = null) return $ret; } - require_once dirname(__DIR__) . '/include/functions.render.php'; - require_once dirname(__DIR__) . '/include/functions.session.php'; - require_once dirname(__DIR__) . '/include/functions.time.php'; - require_once dirname(__DIR__) . '/include/functions.read.php'; - require_once dirname(__DIR__) . '/include/functions.topic.php'; + require_once \dirname(__DIR__) . '/include/functions.render.php'; + require_once \dirname(__DIR__) . '/include/functions.session.php'; + require_once \dirname(__DIR__) . '/include/functions.time.php'; + require_once \dirname(__DIR__) . '/include/functions.read.php'; + require_once \dirname(__DIR__) . '/include/functions.topic.php'; $sticky = 0; $topics = []; @@ -917,7 +917,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) $reads = []; $types = []; $forums = []; - $anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5); + $anonymous = \htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], \ENT_QUOTES | \ENT_HTML5); while (false !== ($myrow = $this->handler->db->fetchArray($result))) { if ($myrow['topic_sticky']) { @@ -928,7 +928,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) // START irmtfan remove topic_icon hardcode smarty // topic_icon: just regular topic_icon if (!empty($myrow['icon'])) { - $topic_icon = ''; + $topic_icon = ''; } else { $topic_icon = ''; } @@ -936,19 +936,19 @@ public function renderTopics(\Smarty $xoopsTpl = null) // ------------------------------------------------------ // rating_img - $rating = number_format($myrow['rating'] / 2, 0); + $rating = \number_format($myrow['rating'] / 2, 0); // irmtfan - add alt key for rating if ($rating < 1) { - $rating_img = newbbDisplayImage('blank'); + $rating_img = \newbbDisplayImage('blank'); } else { - $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating)); + $rating_img = \newbbDisplayImage('rate' . $rating, \constant('_MD_NEWBB_RATE' . $rating)); } // ------------------------------------------------------ // topic_page_jump $topic_page_jump = ''; $topic_page_jump_icon = ''; - $totalpages = ceil(($myrow['topic_replies'] + 1) / $this->config['posts_per_page']); + $totalpages = \ceil(($myrow['topic_replies'] + 1) / $this->config['posts_per_page']); if ($totalpages > 1) { $topic_page_jump .= '  '; $append = false; @@ -966,7 +966,7 @@ public function renderTopics(\Smarty $xoopsTpl = null) } } // BigKev73 - Added to make jump ICON, jump and scroll to the correct "last post" - $topic_page_jump_icon = "" . newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ''; + $topic_page_jump_icon = "" . \newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ''; // irmtfan - move here for both topics with and without pages - change topic_id to post_id //$topic_page_jump_icon = "" . newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . ''; @@ -974,11 +974,11 @@ public function renderTopics(\Smarty $xoopsTpl = null) // ------------------------------------------------------ // => topic array - $topic_title = htmlspecialchars($myrow['topic_title'], ENT_QUOTES | ENT_HTML5); + $topic_title = \htmlspecialchars($myrow['topic_title'], \ENT_QUOTES | \ENT_HTML5); // irmtfan use topic_title_excerpt for block topic title length $topic_title_excerpt = $topic_title; if (!empty($this->config['topic_title_excerpt'])) { - $topic_title_excerpt = xoops_substr($topic_title, 0, $this->config['topic_title_excerpt']); + $topic_title_excerpt = \xoops_substr($topic_title, 0, $this->config['topic_title_excerpt']); } // irmtfan hardcode class commented //if ($myrow['topic_digest']) { @@ -987,11 +987,11 @@ public function renderTopics(\Smarty $xoopsTpl = null) if (empty($this->config['post_excerpt'])) { $topic_excerpt = ''; - } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !newbbIsAdmin($myrow['forum_id'])) { + } elseif (($myrow['post_karma'] > 0 || $myrow['require_reply'] > 0) && !\newbbIsAdmin($myrow['forum_id'])) { $topic_excerpt = ''; } else { - $topic_excerpt = xoops_substr(newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $this->config['post_excerpt']); - $topic_excerpt = str_replace('[', '[', htmlspecialchars($topic_excerpt, ENT_QUOTES | ENT_HTML5)); + $topic_excerpt = \xoops_substr(\newbbHtml2text($myts->displayTarea($myrow['post_text'])), 0, $this->config['post_excerpt']); + $topic_excerpt = \str_replace('[', '[', \htmlspecialchars($topic_excerpt, \ENT_QUOTES | \ENT_HTML5)); } $topics[$myrow['topic_id']] = [ @@ -1010,23 +1010,23 @@ public function renderTopics(\Smarty $xoopsTpl = null) 'topic_page_jump_icon' => $topic_page_jump_icon, 'topic_replies' => $myrow['topic_replies'], 'topic_poster_uid' => $myrow['topic_poster'], - 'topic_poster_name' => !empty($myrow['poster_name']) ? htmlspecialchars($myrow['poster_name'], ENT_QUOTES | ENT_HTML5) : $anonymous, + 'topic_poster_name' => !empty($myrow['poster_name']) ? \htmlspecialchars($myrow['poster_name'], \ENT_QUOTES | \ENT_HTML5) : $anonymous, 'topic_views' => $myrow['topic_views'], - 'topic_time' => newbbFormatTimestamp($myrow['topic_time']), + 'topic_time' => \newbbFormatTimestamp($myrow['topic_time']), 'topic_last_post_id' => $myrow['topic_last_post_id'], //irmtfan added - 'topic_last_posttime' => newbbFormatTimestamp($myrow['last_post_time']), + 'topic_last_posttime' => \newbbFormatTimestamp($myrow['last_post_time']), 'topic_last_poster_uid' => $myrow['uid'], - 'topic_last_poster_name' => !empty($myrow['last_poster_name']) ? htmlspecialchars($myrow['last_poster_name'], ENT_QUOTES | ENT_HTML5) : $anonymous, + 'topic_last_poster_name' => !empty($myrow['last_poster_name']) ? \htmlspecialchars($myrow['last_poster_name'], \ENT_QUOTES | \ENT_HTML5) : $anonymous, 'topic_forum' => $myrow['forum_id'], 'topic_excerpt' => $topic_excerpt, - 'sticky' => $myrow['topic_sticky'] ? newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY) : '', + 'sticky' => $myrow['topic_sticky'] ? \newbbDisplayImage('topic_sticky', \_MD_NEWBB_TOPICSTICKY) : '', // irmtfan bug fixed - 'lock' => $myrow['topic_status'] ? newbbDisplayImage('topic_locked', _MD_NEWBB_TOPICLOCK) : '', + 'lock' => $myrow['topic_status'] ? \newbbDisplayImage('topic_locked', \_MD_NEWBB_TOPICLOCK) : '', //irmtfan added - 'digest' => $myrow['topic_digest'] ? newbbDisplayImage('topic_digest', _MD_NEWBB_TOPICDIGEST) : '', + 'digest' => $myrow['topic_digest'] ? \newbbDisplayImage('topic_digest', \_MD_NEWBB_TOPICDIGEST) : '', //irmtfan added - 'poll' => $myrow['topic_haspoll'] ? newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL) : '', + 'poll' => $myrow['topic_haspoll'] ? \newbbDisplayImage('poll', \_MD_NEWBB_TOPICHASPOLL) : '', //irmtfan added 'approve' => $myrow['approved'], //irmtfan added @@ -1046,8 +1046,8 @@ public function renderTopics(\Smarty $xoopsTpl = null) // forums $forums[$myrow['forum_id']] = 1; } - $posters_name = newbbGetUnameFromIds(array_keys($posters), $this->config['show_realname'], true); - $topic_isRead = newbbIsRead('topic', $reads); + $posters_name = \newbbGetUnameFromIds(\array_keys($posters), $this->config['show_realname'], true); + $topic_isRead = \newbbIsRead('topic', $reads); /* $type_list = []; if (count($types) > 0) { @@ -1059,19 +1059,19 @@ public function renderTopics(\Smarty $xoopsTpl = null) /** @var Newbb\ForumHandler $forumHandler */ $forumHandler = Helper::getInstance()->getHandler('Forum'); - if (count($forums) > 0) { - $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', array_keys($forums)) . ')', 'IN'), ['forum_name', 'hot_threshold'], false); + if (\count($forums) > 0) { + $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . \implode(', ', \array_keys($forums)) . ')', 'IN'), ['forum_name', 'hot_threshold'], false); } else { $forum_list = $forumHandler->getAll(); } - foreach (array_keys($topics) as $id) { + foreach (\array_keys($topics) as $id) { $topics[$id]['topic_read'] = empty($topic_isRead[$id]) ? 0 : 1; // add topic-read/topic-new smarty variable $topics[$id]['topic_forum_link'] = '' . $forum_list[$topics[$id]['topic_forum']]['forum_name'] . ''; //irmtfan use topic_title_excerpt -- add else if (!empty($topics[$id]['type_id']) && isset($type_list[$topics[$id]['type_id']])) { - $topics[$id]['topic_title'] = getTopicTitle($topics[$id]['topic_title_excerpt'], $type_list[$topics[$id]['type_id']]['type_name'], $type_list[$topics[$id]['type_id']]['type_color']); + $topics[$id]['topic_title'] = \getTopicTitle($topics[$id]['topic_title_excerpt'], $type_list[$topics[$id]['type_id']]['type_name'], $type_list[$topics[$id]['type_id']]['type_color']); } else { $topics[$id]['topic_title'] = $topics[$id]['topic_title_excerpt']; } @@ -1091,30 +1091,30 @@ public function renderTopics(\Smarty $xoopsTpl = null) // $topic_folder_text = _MD_NEWBB_TOPICDIGEST; if ($topics[$id]['topic_replies'] >= $forum_list[$topics[$id]['topic_forum']]['hot_threshold']) { $topic_folder = empty($topic_isRead[$id]) ? 'topic_hot_new' : 'topic_hot'; - $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_MORETHAN : \_MD_NEWBB_MORETHAN2; + $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_MORETHAN : \_MD_NEWBB_MORETHAN2; } else { $topic_folder = empty($topic_isRead[$id]) ? 'topic_new' : 'topic'; - $topic_folder_text = empty($topic_isRead[$id]) ? _MD_NEWBB_NEWPOSTS : _MD_NEWBB_NONEWPOSTS; + $topic_folder_text = empty($topic_isRead[$id]) ? \_MD_NEWBB_NEWPOSTS : \_MD_NEWBB_NONEWPOSTS; } //} // END irmtfan remove hardcodes from topic_folder smarty - $topics[$id]['topic_folder'] = newbbDisplayImage($topic_folder, $topic_folder_text); + $topics[$id]['topic_folder'] = \newbbDisplayImage($topic_folder, $topic_folder_text); // END irmtfan - add topic_folder_text for alt unset($topics[$id]['topic_poster_name'], $topics[$id]['topic_last_poster_name']); // irmtfan remove $topics[$id]["stats"] because it is not exist now } - if (count($topics) > 0) { - $sql = ' SELECT DISTINCT topic_id FROM ' . $this->handler->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . implode(',', array_keys($topics)) . ')'; + if (\count($topics) > 0) { + $sql = ' SELECT DISTINCT topic_id FROM ' . $this->handler->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . \implode(',', \array_keys($topics)) . ')'; $result = $this->handler->db->query($sql); if ($result) { while (list($topic_id) = $this->handler->db->fetchRow($result)) { - $topics[$topic_id]['attachment'] = ' ' . newbbDisplayImage('attachment', _MD_NEWBB_TOPICSHASATT); + $topics[$topic_id]['attachment'] = ' ' . \newbbDisplayImage('attachment', \_MD_NEWBB_TOPICSHASATT); } } } - if (is_object($xoopsTpl)) { + if (\is_object($xoopsTpl)) { $xoopsTpl->assign_by_ref('sticky', $sticky); $xoopsTpl->assign_by_ref('topics', $topics); @@ -1136,8 +1136,8 @@ public function getFromKeys($array, $keys = null) if (empty($keys)) { return $array; } // all keys - $keyarr = is_string($keys) ? explode(',', $keys) : $keys; - $keyarr = array_intersect(array_keys($array), $keyarr); // keys should be in array + $keyarr = \is_string($keys) ? \explode(',', $keys) : $keys; + $keyarr = \array_intersect(\array_keys($array), $keyarr); // keys should be in array $ret = []; foreach ($keyarr as $key) { $ret[$key] = $array[$key]; diff --git a/class/Tree.php b/class/Tree.php index a59aef1a..0d8b2773 100644 --- a/class/Tree.php +++ b/class/Tree.php @@ -96,7 +96,7 @@ public function setPostArray($postArray) */ public function getPostTree(&$postTree_array, $pid = 0, $prefix = '  ') { - if (!is_array($postTree_array)) { + if (!\is_array($postTree_array)) { $postTree_array = []; } diff --git a/class/User.php b/class/User.php index 9511672d..a9d8ee42 100644 --- a/class/User.php +++ b/class/User.php @@ -222,7 +222,7 @@ public function getInfo($user) if (!\is_object($user) || !$user->isActive()) { if (null === $name_anonymous) { - $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5); + $name_anonymous = \htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], \ENT_QUOTES | \ENT_HTML5); } return ['name' => $name_anonymous, 'link' => $name_anonymous]; diff --git a/class/UserstatsHandler.php b/class/UserstatsHandler.php index 6fc86917..ccd99426 100644 --- a/class/UserstatsHandler.php +++ b/class/UserstatsHandler.php @@ -50,7 +50,7 @@ public function get($id = null, $fields = null) //get($id) { $object = null; if (!$id = (int)$id) { - return $object; + return null; } $object = $this->create(false); $object->setVar($this->keyName, $id); diff --git a/class/Utility.php b/class/Utility.php index 601645a4..f5a49a08 100644 --- a/class/Utility.php +++ b/class/Utility.php @@ -75,8 +75,8 @@ public function addField($field, $table) public static function prepareFolder($folder) { try { - if (!@mkdir($folder) && !is_dir($folder)) { - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); + if (!@\mkdir($folder) && !\is_dir($folder)) { + throw new \RuntimeException(\sprintf('Unable to create the %s directory', $folder)); } file_put_contents($folder . '/index.html', ''); } catch (\Exception $e) { @@ -87,7 +87,7 @@ public static function prepareFolder($folder) public static function cleanCache() { $cacheHelper = new Cache('newbb'); - if (method_exists($cacheHelper, 'clear')) { + if (\method_exists($cacheHelper, 'clear')) { $cacheHelper->clear(); return; @@ -99,7 +99,7 @@ public static function cleanCache() 3, // xoops_cache ]; $maintenance->CleanCache($cacheList); - xoops_setActiveModules(); + \xoops_setActiveModules(); } /** diff --git a/class/plugins/plugin.tag.php b/class/plugins/plugin.tag.php index dc79ed3b..7612fd7b 100644 --- a/class/plugins/plugin.tag.php +++ b/class/plugins/plugin.tag.php @@ -34,15 +34,15 @@ */ function newbb_tag_iteminfo(&$items) { - if (0 === count($items) || !is_array($items)) { + if (0 === \count($items) || !\is_array($items)) { return false; } $items_id = []; - foreach (array_keys($items) as $cat_id) { + foreach (\array_keys($items) as $cat_id) { // Some handling here to build the link upon catid // catid is not used in newbb, so just skip it - foreach (array_keys($items[$cat_id]) as $item_id) { + foreach (\array_keys($items[$cat_id]) as $item_id) { // In newbb, the item_id is "topic_id" $items_id[] = (int)$item_id; } @@ -50,10 +50,10 @@ function newbb_tag_iteminfo(&$items) /** @var TopicHandler $itemHandler */ $itemHandler = Helper::getInstance()->getHandler('Topic'); /** @var \XoopsObject $itemsObject */ - $itemsObject = $itemHandler->getObjects(new Criteria('topic_id', '(' . implode(', ', $items_id) . ')', 'IN'), true); + $itemsObject = $itemHandler->getObjects(new Criteria('topic_id', '(' . \implode(', ', $items_id) . ')', 'IN'), true); - foreach (array_keys($items) as $cat_id) { - foreach (array_keys($items[$cat_id]) as $item_id) { + foreach (\array_keys($items) as $cat_id) { + foreach (\array_keys($items[$cat_id]) as $item_id) { /** @var \XoopsObject $itemObject */ if (!$itemObject = $itemsObject[$item_id]) { continue; @@ -63,7 +63,7 @@ function newbb_tag_iteminfo(&$items) 'uid' => $itemObject->getVar('topic_poster'), 'link' => "viewtopic.php?topic_id={$item_id}", 'time' => $itemObject->getVar('topic_time'), - 'tags' => tag_parse_tag($itemObject->getVar('topic_tags', 'n')), + 'tags' => \tag_parse_tag($itemObject->getVar('topic_tags', 'n')), 'content' => '', ]; } diff --git a/seo_url.php b/seo_url.php index 3423abbe..71d1c2c1 100644 --- a/seo_url.php +++ b/seo_url.php @@ -236,7 +236,7 @@ function forum_seo_forum($_cat_id) /** * @param $_cat_id - * @return mixed|string + * @return array|string|string[]|null */ function forum_seo_topic($_cat_id) { @@ -257,7 +257,7 @@ function forum_seo_topic($_cat_id) /** * @param $_cat_id - * @return mixed|string + * @return array|string|string[]|null */ function forum_seo_post($_cat_id) { diff --git a/topicmanager.php b/topicmanager.php index f8f195f5..c016aa72 100644 --- a/topicmanager.php +++ b/topicmanager.php @@ -254,7 +254,7 @@ $topicObject->loadFilters('update'); //$sql = sprintf('UPDATE "%s" SET forum_id = "%u" WHERE topic_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_posts'), $newforum, $topic_id); - $sql = sprintf("UPDATE %s SET forum_id = %u WHERE topic_id = %u", $GLOBALS['xoopsDB']->prefix('newbb_posts'), $newforum, $topic_id); + $sql = sprintf('UPDATE %s SET forum_id = %u WHERE topic_id = %u', $GLOBALS['xoopsDB']->prefix('newbb_posts'), $newforum, $topic_id); if (!$r = $GLOBALS['xoopsDB']->query($sql)) { return false; } @@ -308,7 +308,7 @@ $user_stat = $userstatsHandler->get($topicObject->getVar('topic_poster')); if ($user_stat) { $z = $user_stat->getVar('user_digests') + 1; - $user_stat->setVar('user_digests', (int)$z); + $user_stat->setVar('user_digests', $z); $userstatsHandler->insert($user_stat); } }