Skip to content

Commit

Permalink
Merge pull request #12 from mambax7/master
Browse files Browse the repository at this point in the history
1.04_FINAL
  • Loading branch information
mambax7 authored Aug 8, 2021
2 parents 6b92cb1 + 6f84de9 commit aae4e34
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion admin/admin_footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Xmf\Module\Admin;

$pathIcon32 = Admin::iconUrl('', 32);
$pathIcon32 = Xmf\Module\Admin::iconUrl('', 32);
//$pathIcon32 = Xmf\Module\Admin::iconUrl('', 32);

echo "<div class='adminfooter'>\n" . " <div style='text-align: center;'>\n" . " <a href='https://xoops.org' rel='external'><img src='{$pathIcon32}/xoopsmicrobutton.gif' alt='XOOPS' title='XOOPS'></a>\n" . " </div>\n" . ' ' . _AM_MODULEADMIN_ADMIN_FOOTER . "\n" . '</div>';

Expand Down
1 change: 0 additions & 1 deletion admin/admin_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
require_once \dirname(__DIR__) . '/include/common.php';

$moduleDirName = \basename(\dirname(__DIR__));
/** @var Moduleinstaller\Helper $helper */
$helper = Moduleinstaller\Helper::getInstance();
$adminObject = Admin::getInstance();

Expand Down
1 change: 0 additions & 1 deletion admin/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
$moduleDirName = \basename(\dirname(__DIR__));
$moduleDirNameUpper = mb_strtoupper($moduleDirName);

/** @var \XoopsModules\Moduleinstaller\Helper $helper */
$helper = Helper::getInstance();
$helper->loadLanguage('common');
$helper->loadLanguage('feedback');
Expand Down
2 changes: 1 addition & 1 deletion class/Common/ServerStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function getServerStats()
$gdlib = \function_exists('gd_info') ? '<span style="color: green;">' . \constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . \constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>';
$html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
if (\function_exists('gd_info')) {
if (true === ($gdlib = gd_info())) {
if (true == ($gdlib = gd_info())) {
$html .= '<li>' . \constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>';
}
}
Expand Down
8 changes: 4 additions & 4 deletions class/Common/SysUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ public static function truncateHtml($text, $length = 100, $ending = '...', $exac
$truncate .= $line_matchings[1];
}
// calculate the length of the plain text part of the line; handle entities as one character
$content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
$content_length = mb_strlen(\preg_replace('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', ' ', $line_matchings[2]));
if ($total_length + $content_length > $length) {
// the number of characters which are left
$left = $length - $total_length;
$entities_length = 0;
// search for html entities
if (\preg_match_all('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
if (\preg_match_all('/&[0-9a-z]{2,8};|&#\d{1,7};|[0-9a-f]{1,6};/i', $line_matchings[2], $entities, \PREG_OFFSET_CAPTURE)) {
// calculate the real length of all entities in the legal range
foreach ($entities[0] as $entity) {
if ($left >= $entity[1] + 1 - $entities_length) {
Expand Down Expand Up @@ -210,7 +210,7 @@ public static function fieldExists($fieldname, $table)
* @param int $id_field
* @param int $id
*
* @return mixed
* @return void
*/
public static function cloneRecord($tableName, $id_field, $id)
{
Expand All @@ -225,7 +225,7 @@ public static function cloneRecord($tableName, $id_field, $id)
// set the auto-incremented id's value to blank.
unset($tempTable[$id_field]);
// insert cloned copy of the original record
$sql = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", \array_values($tempTable)) . "')";
$sql = "INSERT INTO $table (" . \implode(', ', \array_keys($tempTable)) . ") VALUES ('" . \implode("', '", $tempTable) . "')";
$result = $GLOBALS['xoopsDB']->queryF($sql);
if (!$result) {
exit($GLOBALS['xoopsDB']->error());
Expand Down
4 changes: 2 additions & 2 deletions class/Common/VersionChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ trait VersionChecks
/**
* Verifies XOOPS version meets minimum requirements for this module
* @static
* @param \XoopsModule $module
* @param \XoopsModule|null $module
*
* @param null|string $requiredVer
* @param null|string $requiredVer
* @return bool true if meets requirements, false if not
*/
public static function checkVerXoops(XoopsModule $module = null, $requiredVer = null)
Expand Down
4 changes: 2 additions & 2 deletions class/InstallWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function loadLangFile($file)
*/
public function initLanguage($language)
{
$language = \preg_replace("/[^a-z0-9_\-]/i", '', $language);
$language = \preg_replace('/[^a-z0-9_\-]/i', '', $language);
if (!\file_exists("./language/{$language}/install.php")) {
$language = 'english';
}
Expand All @@ -176,7 +176,7 @@ public function initLanguage($language)
/**
* @param $page
*
* @return bool|mixed
* @return false|int|string
*/
public function setPage($page)
{
Expand Down
2 changes: 1 addition & 1 deletion class/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

use XoopsModules\Moduleinstaller;
use XoopsModules\Moduleinstaller\Common;
use XoopsModules\Moduleinstaller\Constants;
//use XoopsModules\Moduleinstaller\Constants;

/**
* Class Utility
Expand Down
13 changes: 12 additions & 1 deletion docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
<h5>1.04 RC-2 [2020-12-01]</h5> Dev: Xoops 2.5.11, PHP 7.4.13, PHP 8.0
<h5>1.04 Final [2021-12-01]</h5> Dev: Xoops 2.5.11, PHP 7.4.22, PHP 8.0.8
<hr>
- 1.04 Final Release

<h5>1.04 RC-2 [NOT RELEASED]</h5> Dev: Xoops 2.5.11, PHP 7.4.13, PHP 8.0
<hr>
- fixed InstallWizard name (SebT34/mamba)
- simplify loading of language files (mamba)
- language updates (mamba)
- image update for PHP8 (mamba)
- add round((float) (mamba)
- remove function cloneRecord (mamba)
- min PHP 7.3 (mamba)
- Unqualified function/constant reference (mamba)

<h5>1.04 RC-1 [2020-12-01]</h5> Dev: Xoops 2.5.11, PHP 7.4.13, PHP 8.0
<hr>
Expand Down
12 changes: 6 additions & 6 deletions extras/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@
foreach ($module as $mid) {
$mid = (int)$mid;
$modifs_mods[$i]['mid'] = $mid;
$modifs_mods[$i]['oldname'] = htmlspecialchars(($oldname[$mid]));
$modifs_mods[$i]['newname'] = htmlspecialchars(trim(($newname[$mid])));
$modifs_mods[$i]['newstatus'] = isset($newstatus[$mid]) ? htmlspecialchars($newstatus[$mid]) : 0;
$modifs_mods[$i]['oldname'] = htmlspecialchars(($oldname[$mid]), ENT_QUOTES | ENT_HTML5);
$modifs_mods[$i]['newname'] = htmlspecialchars(trim(($newname[$mid])), ENT_QUOTES | ENT_HTML5);
$modifs_mods[$i]['newstatus'] = isset($newstatus[$mid]) ? htmlspecialchars($newstatus[$mid], ENT_QUOTES | ENT_HTML5) : 0;
++$i;
}
$xoopsTpl->assign('modifs_mods', $modifs_mods);
Expand Down Expand Up @@ -320,7 +320,7 @@
xoops_cp_footer();
break;
case 'install':
$module = htmlspecialchars($module);
$module = htmlspecialchars($module, ENT_QUOTES | ENT_HTML5);
// Get module handler
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
Expand Down Expand Up @@ -375,7 +375,7 @@
xoops_cp_footer();
break;
case 'uninstall':
$module = htmlspecialchars($module);
$module = htmlspecialchars($module, ENT_QUOTES | ENT_HTML5);
// Get module handler
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
Expand Down Expand Up @@ -429,7 +429,7 @@
xoops_cp_footer();
break;
case 'update':
$module = htmlspecialchars($module);
$module = htmlspecialchars($module, ENT_QUOTES | ENT_HTML5);
// Get module handler
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
Expand Down
10 changes: 5 additions & 5 deletions extras/modulesadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function xoops_module_install($dirname)
}
}

if (false === $error) {
if (!$error) {
$sqlfile = $module->getInfo('sqlfile');
if (is_array($sqlfile) && !empty($sqlfile[XOOPS_DB_TYPE])) {
$sql_file_path = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/' . $sqlfile[XOOPS_DB_TYPE];
Expand Down Expand Up @@ -155,7 +155,7 @@ function xoops_module_install($dirname)
}
}
// if there was an error, delete the tables created so far, so the next installation will not fail
if (true === $error) {
if ($error) {
foreach ($created_tables as $ct) {
$db->query('DROP TABLE ' . $db->prefix($ct));
}
Expand Down Expand Up @@ -814,7 +814,7 @@ function xoops_module_update($dirname)

$myts = \MyTextSanitizer::getInstance();

$dirname = htmlspecialchars(trim($dirname));
$dirname = htmlspecialchars(trim($dirname), ENT_QUOTES | ENT_HTML5);
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
$module = $moduleHandler->getByDirname($dirname);
Expand Down Expand Up @@ -856,7 +856,7 @@ function xoops_module_update($dirname)
}
$msgs[] = '<strong>' . _VERSION . ':</strong> ' . $module->getInfo('version') . '&nbsp;' . $module->getInfo('module_status');
if (false !== $module->getInfo('author') && '' != trim($module->getInfo('author'))) {
$msgs[] = '<strong>' . _AUTHOR . ':</strong> ' . htmlspecialchars(trim($module->getInfo('author')));
$msgs[] = '<strong>' . _AUTHOR . ':</strong> ' . htmlspecialchars(trim($module->getInfo('author')), ENT_QUOTES | ENT_HTML5);
}
$msgs[] = '</div><div class="logger">';
$msgs[] = _AM_SYSTEM_MODULES_MODULE_DATA_UPDATE;
Expand Down Expand Up @@ -885,7 +885,7 @@ function xoops_module_update($dirname)
// START irmtfan solve templates duplicate issue
// if (!in_array($tpl['file'], $delng)) { // irmtfan bug fix: remove codes for delete templates
$type = ($tpl['type'] ?? 'module');
if (preg_match("/\.css$/i", $tpl['file'])) {
if (preg_match('/\.css$/i', $tpl['file'])) {
$type = 'css';
}
$criteria = new \CriteriaCompo();
Expand Down
3 changes: 1 addition & 2 deletions include/oninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function xoops_module_pre_install_moduleinstaller(\XoopsModule $module)
$xoopsSuccess = $utility::checkVerXoops($module);
$phpSuccess = $utility::checkVerPhp($module);

if (false !== $xoopsSuccess && false !== $phpSuccess) {
if ($xoopsSuccess && $phpSuccess) {
$moduleTables = &$module->getInfo('tables');
foreach ($moduleTables as $table) {
$GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';');
Expand All @@ -55,7 +55,6 @@ function xoops_module_install_moduleinstaller(\XoopsModule $module)

$moduleDirName = \basename(\dirname(__DIR__));

/** @var Moduleinstaller\Helper $helper */
$helper = Moduleinstaller\Helper::getInstance();
$utility = new Utility();
$configurator = new Moduleinstaller\Common\Configurator();
Expand Down
1 change: 0 additions & 1 deletion include/onuninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ function xoops_module_uninstall_moduleinstaller(\XoopsModule $module)

$moduleDirName = \basename(\dirname(__DIR__));
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
/** @var Moduleinstaller\Helper $helper */
$helper = Moduleinstaller\Helper::getInstance();

$utility = new Utility();
Expand Down
4 changes: 2 additions & 2 deletions xoops_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
$moduleDirName = basename(__DIR__);

$modversion['version'] = '1.04';
$modversion['module_status'] = 'RC-2';
$modversion['release_date'] = '2021/06/20';
$modversion['module_status'] = 'Final';
$modversion['release_date'] = '2021/08/08';
$modversion['name'] = _MI_INSTALLER_NAME;
$modversion['description'] = _MI_INSTALLER_DESC;
$modversion['author'] = 'Michael Beck';
Expand Down

0 comments on commit aae4e34

Please sign in to comment.