changeset 1102:dd0071a3162a

Cleanups and PHP7 fixes.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 14 May 2019 14:12:02 +0300
parents c9c73d2c4702
children 1fe7df7c77fb
files msitegen.inc.php
diffstat 1 files changed, 21 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- 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("&lt;","&gt;"), 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);
 }