Skip to content

Commit

Permalink
Fix minor issues reported by Phan
Browse files Browse the repository at this point in the history
  • Loading branch information
cmb69 committed Mar 21, 2022
1 parent 42a5fb4 commit c36c7f1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmsimple/classes/Controller.php
Expand Up @@ -443,7 +443,7 @@ public function outputAdminScripts()
{
global $tx, $o;

$interval = 1000 * (ini_get('session.gc_maxlifetime') - 1);
$interval = 1000 * ((int) ini_get('session.gc_maxlifetime') - 1);
$o .= <<<EOT
<script>
if (document.cookie.indexOf('status=adm') == -1) {
Expand Down
3 changes: 2 additions & 1 deletion cmsimple/classes/LinkChecker.php
Expand Up @@ -312,7 +312,7 @@ protected function makeHeadRequest($scheme, $host, $path)
)
)
);
$headers = get_headers($url, 1, $context);
$headers = get_headers($url, true, $context);
$status = array();
for ($i = 0; $i <= $maxredir; $i++) {
if (!empty($headers[$i])) {
Expand All @@ -321,6 +321,7 @@ protected function makeHeadRequest($scheme, $host, $path)
break;
}
}
assert(isset($headers_tmp));
preg_match('#HTTP/[0-9\.]+\s+([0-9]+)#i', $headers_tmp, $status);
if (!empty($status[1])) {
return (int) $status[1];
Expand Down
2 changes: 1 addition & 1 deletion cmsimple/classes/PasswordForgotten.php
Expand Up @@ -134,7 +134,7 @@ private function submit()
* Resets the password to a randomly generated one and sends an appropriate
* info email.
*
* @return void.
* @return void
*/
private function reset()
{
Expand Down
2 changes: 1 addition & 1 deletion cmsimple/compat.php
Expand Up @@ -117,7 +117,7 @@ function chkdl($fl)
$m = false;
if (is_dir($pth['folder']['downloads'])) {
if ($fd = opendir($pth['folder']['downloads'])) {
while (($p = readdir($fd)) == true) {
while (($p = readdir($fd))) {
if (preg_match("/.+\..+$/", $p)) {
if ($fl == $sn . '?download=' . $p) {
$m = true;
Expand Down
14 changes: 7 additions & 7 deletions cmsimple/functions.php
Expand Up @@ -773,8 +773,8 @@ function XH_readContents($language = null)
$temp = $tx['toc']['empty'] . ' ' . $empty;
}
$h[] = $temp;
$ancestors[$l[$i] - 1] = XH_uenc($temp, $search, $replace);
$ancestors = array_slice($ancestors, 0, $l[$i]);
$ancestors[(int) $l[$i] - 1] = XH_uenc($temp, $search, $replace);
$ancestors = array_slice($ancestors, 0, (int) $l[$i]);
$url = implode($cf['uri']['seperator'], $ancestors);
$u[] = utf8_substr($url, 0, (int) $cf['uri']['length']);
$tooLong[] = utf8_strlen($url) > $cf['uri']['length'];
Expand Down Expand Up @@ -1060,7 +1060,7 @@ function tag($s)
*
* @param int $s The HTTP status response code (401, 403, 404).
*
* @return void.
* @return void
*/
function shead($s)
{
Expand Down Expand Up @@ -1115,7 +1115,7 @@ function XH_debugmode()
$dbglevel = '';
$filename = $pth['folder']['downloads'] . '_XHdebug.txt';
if (file_exists($filename)) {
ini_set('display_errors', 0);
ini_set('display_errors', "0");
$dbglevel = file_get_contents($filename);
if (strlen($dbglevel) == 1) {
set_error_handler('XH_debug');
Expand Down Expand Up @@ -1150,7 +1150,7 @@ function XH_debugmode()
error_reporting(E_ERROR | E_USER_ERROR | E_USER_WARNING | E_PARSE);
}
} else {
ini_set('display_errors', 0);
ini_set('display_errors', "0");
error_reporting(0);
}
return error_reporting() > 0;
Expand Down Expand Up @@ -1394,7 +1394,7 @@ function gc($s)
/**
* Returns wether the user is logged in.
*
* @return bool.
* @return bool
*/
function logincheck()
{
Expand Down Expand Up @@ -1961,7 +1961,7 @@ function XH_isInternalPath($path)
/**
* Returns whether a URL points to this CMSimple installation.
*
* @param string $urlParts Parts of an URL.
* @param array $urlParts Parts of an URL.
*
* @return bool
*
Expand Down
1 change: 1 addition & 0 deletions cmsimple/seofuncs.php
Expand Up @@ -32,6 +32,7 @@ function XH_URI_Cleaning()
global $su, $s, $xh_publisher, $pth;

$parts = parse_url(CMSIMPLE_URL);
assert(isset($parts['scheme'], $parts['host'], $parts['path']));
$scheme = $parts['scheme'];
$host = $parts['host'];
$port = '';
Expand Down
3 changes: 2 additions & 1 deletion cmsimple/tplfuncs.php
Expand Up @@ -412,7 +412,7 @@ function content()

if (!($edit && XH_ADM) && $s > -1) {
if (isset($_GET['search'])) {
$search = XH_hsc(trim(preg_replace('/\s+/u', ' ', (stsl($_GET['search'])))));
$search = XH_hsc(trim(preg_replace('/\s+/u', ' ', $_GET['search'])));
$words = explode(' ', $search);
$c[$s] = XH_highlightSearchWords($words, $c[$s]);
}
Expand Down Expand Up @@ -526,6 +526,7 @@ function languagemenu()
$i = array_search($sl, $r);
unset($r[$i]);

$langName = [];
$langNames = explode(';', $cf['language']['2nd_lang_names']);
foreach ($langNames as $value) {
$langName[substr($value, 0, 2)] = substr($value, 3);
Expand Down

0 comments on commit c36c7f1

Please sign in to comment.