Skip to content

Commit

Permalink
Merge pull request #114 from mambax7/master
Browse files Browse the repository at this point in the history
updates/cosmetics
  • Loading branch information
mambax7 authored Feb 12, 2021
2 parents 5b35f2e + 3e92fcb commit 7f7149f
Show file tree
Hide file tree
Showing 23 changed files with 251 additions and 245 deletions.
2 changes: 1 addition & 1 deletion blocks/newbb_block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
2 changes: 1 addition & 1 deletion class/Common/Breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Breadcrumb

public function __construct()
{
$this->dirname = \basename(dirname(__DIR__, 2));
$this->dirname = \basename(\dirname(__DIR__, 2));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions class/Common/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
46 changes: 23 additions & 23 deletions class/Common/FilesManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '<script>history.go(-1);</script>');
Expand All @@ -50,7 +50,7 @@ public static function createFolder($folder)
*/
public static function copyFile($file, $folder)
{
return copy($file, $folder);
return \copy($file, $folder);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -98,21 +98,21 @@ 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()) {
// recursively handle subdirectories
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
Expand All @@ -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;
}

Expand All @@ -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()) {
Expand All @@ -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
}

/**
Expand All @@ -179,28 +179,28 @@ 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;
}

// Open the source directory to read in files
$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());
// rmdir($fObj->getPath()); // now delete the directory
}
}
$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
}

/**
Expand All @@ -222,20 +222,20 @@ 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;
}

// Open the source directory to read in files
$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());
}
Expand Down
4 changes: 2 additions & 2 deletions class/Common/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -67,7 +67,7 @@ private function changePrefix()
. '</span>'
);

trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!');
\trigger_error('Could not migrate table: ' . $oldName . '! The table ' . $newName . ' already exist!');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion class/Common/ServerStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
4 changes: 2 additions & 2 deletions class/Common/SysUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions class/Common/VersionChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions class/ForumHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public function getAllTopics($forum, $criteria = null)
$forum_link = '<a href="' . XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $myrow['forum_id'] . '">' . $viewAllForums[$myrow['forum_id']]['forum_name'] . '</a>';
}

$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 = '<span style="color:'.$typen[$myrow["type_id"]]["type_color"].'">['.$typen[$myrow["type_id"]]["type_name"].']</span> '.$topic_title.'';
Expand All @@ -377,15 +377,15 @@ 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('[', '&#91;', htmlspecialchars($topic_excerpt, ENT_QUOTES | ENT_HTML5));
$topic_excerpt = \str_replace('[', '&#91;', \htmlspecialchars($topic_excerpt, \ENT_QUOTES | \ENT_HTML5));
}
// START irmtfan move here

//BigKev73 > Adding this code to support jumping directly to the last read post if that value exists for a user, block also would need to change to support same functionality
$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']){
Expand Down Expand Up @@ -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']),
Expand Down Expand Up @@ -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];
Expand Down
12 changes: 6 additions & 6 deletions class/IconHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -198,7 +198,7 @@ public function assignImages($images)
}

/**
* @return int|void
* @return int
*/
public function render()
{
Expand Down
Loading

0 comments on commit 7f7149f

Please sign in to comment.