# HG changeset patch # User Matti Hamalainen # Date 1557832322 -10800 # Node ID dd0071a3162a497ce4f018f1fdefd03c7a811abe # Parent c9c73d2c4702b1f1bbdc2c959cf23c938d205f4a Cleanups and PHP7 fixes. diff -r c9c73d2c4702 -r dd0071a3162a msitegen.inc.php --- a/msitegen.inc.php Wed May 23 22:34:15 2018 +0300 +++ b/msitegen.inc.php Tue May 14 14:12:02 2019 +0300 @@ -172,20 +172,19 @@ function dhentities($str) { - return str_replace(array("<",">"), array("<", ">"), - htmlentities($str, ENT_NOQUOTES, "UTF-8")); + return htmlspecialchars($str, ENT_COMPAT, "UTF-8"); } function chentities($str) { - return htmlentities($str, ENT_NOQUOTES, "UTF-8"); + return htmlspecialchars($str, ENT_NOQUOTES, "UTF-8"); } function ihentities($str) { - return htmlentities($str, ENT_QUOTES, "UTF-8"); + return htmlspecialchars($str, ENT_QUOTES, "UTF-8"); } @@ -547,6 +546,21 @@ } +function stDBGetSQLParam($dbh, $type, $value) +{ + switch ($type) + { + case "d": return intval($value); + case "s": return $dbh->quote($value); + case "b": return intval($value) ? 1 : 0; + case "D": return intval(stGetRequestItem($value)); + case "S": return $dbh->quote(stGetRequestItem($value)); + case "Q": return $dbh->quote(stGetRequestItem($value)); + case "B": return intval(stGetRequestItem($value)) ? 1 : 0; + } +} + + function stConnectSQLDB() { global $db; @@ -565,22 +579,6 @@ } -function stDBGetSQLParam($dbh, $type, $value) -{ - switch ($type) - { - case "d": return intval($value); - case "s": return $dbh->quote($value); - case "b": return intval($value) ? 1 : 0; - - case "D": return intval(stGetRequestItem($value)); - case "S": return $dbh->quote(stGetRequestItem($value)); - case "Q": return $dbh->quote(stGetRequestItem($value)); - case "B": return intval(stGetRequestItem($value)) ? 1 : 0; - } -} - - function stDBPrepareSQLUpdate($dbh, $table, $cond, $pairs) { $sql = array(); @@ -787,7 +785,7 @@ case "mysql": foreach ($col as $elem) { - if ($elem != "AUTOINCREMENT") + if ($elem == "AUTOINCREMENT") $tmp[] = "AUTO_INCREMENT"; else $tmp[] = $elem; @@ -827,14 +825,14 @@ function stStrChop($str, $len) { - return (mb_strlen($str) > $len) ? mb_substr($str, 0, $len - 3)."..." : $str; + return (strlen($str) > $len) ? substr($str, 0, $len - 3)."..." : $str; } function stStrChopPad($str, $len) { $tmp = stStrChop($str, $len); - for ($i = mb_strlen($tmp); $i < $len; $i++) + for ($i = strlen($tmp); $i < $len; $i++) $tmp .= " "; return $tmp; } @@ -1142,8 +1140,6 @@ $localeInited = TRUE; $pageCharset = "UTF-8"; - //mb_internal_encoding($pageCharset); - $tmp = "en_US.".strtolower(str_replace("-", "", $pageCharset)); setlocale(LC_ALL, $tmp); }