Browse Source

Add files via upload

Capitan Cloud 1 year ago
parent
commit
b8ce6aaf70

+ 92 - 0
Private/config/config.inc.sample

@@ -0,0 +1,92 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * config.inc
+ * 
+ * Configuration settings.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode
+  */
+
+define('DEBUG', true);
+
+define('APP_NAME', "SqueePF");
+define('APP_HOST', "squeepf.5mode-foss.eu");
+define('APP_PATH', "/pathto/SqueePF");
+define('APP_PRIVATE_PATH', "/pathto/SqueePF/Private");
+define('APP_PUBLIC_PATH', "/pathto/SqueePF/Public");
+define('APP_SECRETS_FOLDER',"scr");
+define('APP_ROUTES_PATH', "/pathto/SqueePF/Private/routes");
+define('APP_ERROR_PATH', "/pathto/SqueePF/Private/error");
+define('APP_LICENSE', <<<LICENSETEXT
+Copyright 2021, 2024 5 Mode
+
+This file is part of SqueePF.
+
+SqueePF is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+SqueePF is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.  
+ 
+You should have received a copy of the GNU General Public License
+along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+LICENSETEXT
+);
+
+
+$CONFIG = [
+  'DEBUG' => true,
+
+  'APP' => [
+      'NAME' => "SqueePF",
+      'HOST' => "squeepf.5mode-foss.eu",
+      'PATH' => "/pathto/SqueePF/Public",
+      'PRIVATE_PATH' => "/pathto/SqueePF/Private",
+      'PUBLIC_PATH' => "/pathto/SqueePF/Public",
+      'SECRETS_FOLDER' => "scr",
+      'ROUTES_PATH' => "/pathto/SqueePF/Private/routes",
+      'ERROR_PATH' => "/pathto/SqueePF/Private/error",
+      'LICENSE' => <<<LICENSETEXT
+Copyright 2021, 2024 5 Mode
+
+This file is part of SqueePF.
+
+SqueePF is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+SqueePF is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.  
+ 
+You should have received a copy of the GNU General Public License
+along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+LICENSETEXT
+             
+            ]
+];

+ 67 - 0
Private/config/const.php.inc

@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * const.php.inc
+ * 
+ * Additional PHP constants.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode
+  */
+
+if (!defined("PHP_BR")) {
+  define('PHP_BR', "<br>");
+}
+if (!defined("PHP_CN")) {
+  define('PHP_CN', "zh-CN");
+}
+if (!defined("PHP_EN")) {
+  define('PHP_EN', "en-US");
+}
+if (!defined("PHP_ES")) {
+  define('PHP_ES', "es-ES");
+}
+if (!defined("PHP_FR")) {
+  define('PHP_FR', "fr-FR");
+}
+if (!defined("PHP_HYPHEN")) {
+  define('PHP_HYPHEN', "-");
+}
+if (!defined("PHP_IT")) {
+  define('PHP_IT', "it-IT");
+}
+if (!defined("PHP_PIPE")) {
+  define('PHP_PIPE', "|");
+}
+if (!defined("PHP_SLASH")) {
+  define('PHP_SLASH', "/");
+}
+if (!defined("PHP_SPACE")) {
+  define('PHP_SPACE', " ");
+}
+if (!defined("PHP_STR")) {
+  define('PHP_STR', "");
+}
+if (!defined("PHP_TILDE")) {
+  define('PHP_TILDE', "~");
+}
+if (!defined("PHP_UNDERSCORE")) {
+  define('PHP_UNDERSCORE', "_");
+}

+ 194 - 0
Private/core/init.inc

@@ -0,0 +1,194 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * init.inc
+ * 
+ * Initialization file.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode   
+ */
+
+// use fivemode\fivemode\class.myclass.inc;
+
+error_reporting(E_ALL & ~ (E_WARNING | E_NOTICE | E_STRICT | E_DEPRECATED));  
+ini_set('display_startup_errors',1);  
+ini_set('display_errors',1);  
+ini_set('log_errors',1); 
+
+
+// CONFIGURATION
+define("CONFIG_PATH", __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "config");
+
+require CONFIG_PATH . DIRECTORY_SEPARATOR . "config.inc";
+require CONFIG_PATH . DIRECTORY_SEPARATOR . "const.php.inc";
+
+mb_internal_encoding("UTF-8");
+
+
+// AUTOLOADER
+
+define("CLASSES_PATH", __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "classes");
+define("INTERFACES_PATH", __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "interfaces");
+
+/**
+ * Autoloader.
+ * 
+ * @param string $construct the name of the construct to load
+ */
+function autoloader($construct) {
+  
+  // For third-party libraries, eg. Pear
+  if (!defined("PHP_INCLUDE_PATH")) {
+    define("PHP_INCLUDE_PATH", ini_get("include_path"));
+  }
+  
+  $constructParts = explode('\\', $construct);
+  
+  // estrapolate the path from the construct name
+  $count = count($constructParts);
+  if ($count>1) {
+    $i = 0;
+    $constructPath = $constructParts[0];
+    for ($i=1; $i<($count-1); $i++) {
+      $constructPath .= DIRECTORY_SEPARATOR . $constructParts[$i];
+    }
+    $construct = $constructParts[$i];
+  }
+  
+  if (!stripos($construct, "interface")) {
+    // if it is a class
+  
+    switch ($construct) {
+      case "special_case":
+        $incPath = PHP_INCLUDE_PATH . DIRECTORY_SEPARATOR . "path/to/special_case.php";
+        break;
+      case "QRcode":
+        $incPath = CLASSES_PATH . DIRECTORY_SEPARATOR . "phpqrcode/qrlib.php";
+        //echo "incPath = $incPath" . PHP_BR;
+        break;
+      default:
+      
+        if (isset($constructPath)) {
+          $incPath = CLASSES_PATH . DIRECTORY_SEPARATOR . $constructPath . DIRECTORY_SEPARATOR . "class." . strtolower($construct) . ".inc";
+        } else {
+          $incPath = CLASSES_PATH . DIRECTORY_SEPARATOR . "class." . strtolower($construct) . ".inc";
+        }
+        
+        break;
+    }
+    
+  } else {
+    // if it is an interface
+    if (isset($constructPath)) {
+      $incPath = INTERFACES_PATH . DIRECTORY_SEPARATOR  . $constructPath . DIRECTORY_SEPARATOR . strtolower($construct) . ".inc";
+    } else {
+      $incPath = INTERFACES_PATH . DIRECTORY_SEPARATOR . strtolower($construct) . ".inc";
+    }  
+  }
+  
+  if (is_readable($incPath)) {
+    //echo "$incPath is readable" . PHP_BR;
+    require $incPath;
+  }
+  
+}
+spl_autoload_register("autoloader", true, true);
+
+
+// FUNCTIONS
+
+define("FUNCTIONS_PATH", __DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."functions");
+
+require FUNCTIONS_PATH . DIRECTORY_SEPARATOR . "func.string.inc";
+require FUNCTIONS_PATH . DIRECTORY_SEPARATOR . "func.app.inc";
+require FUNCTIONS_PATH . DIRECTORY_SEPARATOR . "func.various.inc";
+require FUNCTIONS_PATH . DIRECTORY_SEPARATOR . "func.file.inc";
+require FUNCTIONS_PATH . DIRECTORY_SEPARATOR . "func.filter.inc";
+require FUNCTIONS_PATH . DIRECTORY_SEPARATOR . "func.array.inc";
+
+
+// ERROR HANDLING AND LOGGING
+
+if (DEBUG) {
+  error_reporting(E_ALL | E_STRICT);  
+  ini_set('display_startup_errors',1);  
+  ini_set('display_errors',1);
+  ini_set('log_errors',1); 
+} else {
+  error_reporting(E_ALL & ~ (E_WARNING | E_NOTICE | E_STRICT | E_DEPRECATED));  
+  ini_set('display_startup_errors',0);  
+  ini_set('display_errors',0);  
+  ini_set('log_errors',1); 
+}
+
+// HEADERS
+
+//Page::setNoCacheHeaders();
+
+
+
+// SHUTDOWN 
+
+/**
+ * Shutdown callback.
+ * 
+ * @return void
+ */
+function shutdownCallback() {
+  
+  //Err::setLogOnlyHandlers();
+
+  //if (Cache::issetInstance()) {  
+    //For non-persistent connections only
+    //$cache = &Cache::getInstance();
+    //$cache->close();
+
+    //Cache::unsetInstance();
+  //}
+  
+}
+register_shutdown_function("shutdownCallback");
+
+
+// ERROR PARAMETERS
+
+//errNo
+//define("ERR_NO", substr(filter_input1(INPUT_GET, "errNo", FILTER_SANITIZE_MD5TOKEN), 0, 100));
+//if (ERR_NO!==PHP_STR && !filter_var1(ERR_NO, FILTER_VALIDATE_ERRNO)) {
+//  Err::trigger_error1(ERR::ERR_ERR, "Invalid error number: " . ERR_NO, __FILE__, __LINE__);
+//}
+
+//errKey
+//define("ERR_KEY", array_search(ERR_NO, Err::$A_ERR_NO));
+
+//errMsg
+//define("ERR_MSG", substr(filter_input1(INPUT_GET, "errMsg", FILTER_SANITIZE_ERRMSG), 0, 200));
+
+//errScript
+//define("ERR_SCRIPT", substr(filter_input(INPUT_GET, "errScript", FILTER_SANITIZE_STRING), 0, 255));
+
+//errLine
+//define("ERR_LINE",  substr(filter_input(INPUT_GET, "errLine", FILTER_SANITIZE_NUMBER_INT), 0, 5));
+
+//errStack
+//define("ERR_STACK", substr(filter_input1(INPUT_GET, "errStack", FILTER_SANITIZE_STRING_WITHBR), 0, 2000));
+
+?>

+ 243 - 0
Private/core/sc.inc

@@ -0,0 +1,243 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * sc.inc
+ * 
+ * Sanity check code.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2024, 5 Mode   
+ */
+ 
+ 
+ function SC_CHECK_ROUTE_STRU($route) {
+
+  $ret = false; 
+
+  echo_ifdebug(true, "CHECKING_ROUTE_STRU: Start<br>");
+
+  // Check for +DESC
+  if (!is_readable(APP_PRIVATE_PATH . "/routes/" . $route . "/+DESC")) {
+    return $ret;
+  }
+
+  echo_ifdebug(true, "CHECKING_ROUTE_STRU: +DESC: ok<br>");
+
+  // Check for +CONTENT
+  if (!is_readable(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/+CONTENT")) {
+    return $ret;
+  }
+
+  echo_ifdebug(true, "CHECKING_ROUTE_STRU: +CONTENT: exists<br>");
+
+  // Check file dependencies list
+  //  Private/routes/test/test.php
+  //  Private/functions/func.various.inc
+  //  Public/static/css/style.css
+  //  Public/static/res/logot.png
+
+  $af = file(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/+CONTENT");
+  foreach($af as &$line) {
+    if (!is_readable(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/" . trim(basename($line)) . "+scr")) {
+      return $ret;
+    }
+    echo_ifdebug(true, "CHECKING_ROUTE_STRU: " . trim(basename($line)) . "+scr: exists<br>");
+    if (left($line,7)==="Private") {
+      if (!is_readable(APP_PRIVATE_PATH. trim(substr($line, 7)))) {
+        return $ret;
+      }
+    } else {
+      if (!is_readable(APP_PUBLIC_PATH . trim(substr($line, 6)))) {
+        return $ret;
+      }
+    }
+  }
+
+  //echo_ifdebug(true, "CHECKING_ROUTE_STRU: +CONTENT: ok<br>");
+  
+  // Check for +REQUIRING
+  if (!is_readable(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/+REQUIRING")) {
+    return $ret;
+  }
+
+  // Check route dependencies list
+  $af = file(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/+REQUIRING");
+  foreach($af as &$line) {
+    if (!is_readable(APP_PRIVATE_PATH . "/routes/" . $line)) {
+      return $ret;
+    }
+  }
+
+  echo_ifdebug(true, "CHECKING_ROUTE_STRU: +REQUIRING: ok<br>");
+
+  return true;
+}
+
+
+function SC_CHECK_ROUTE_DEP($route) {
+
+  $ret = false; 
+
+  echo_ifdebug(true, "CHECKING_ROUTE_DEP: Start<br>");
+
+  // Check for +CONTENT
+  if (!is_readable(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/+CONTENT")) {
+    return $ret;
+  }
+
+  // echo_ifdebug(true, "CHECKING_ROUTE_DEP: +CONTENT: exists<br>");
+
+  //
+  // Check file dependencies list
+  //
+  //
+  //  index-scrs/:
+  //    func.various.inc+scr:
+  //	partial path
+  //	size
+  //	sha
+  //    style.css+scr
+  //	partial path
+  //	size
+  //	sha
+  //
+  //   Private/routes/test/test.php
+  //   Private/functions/func.various.inc
+  //   Public/static/css/style.css
+  //   Public/static/res/logot.png
+  //
+  
+  $af = file(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/+CONTENT");
+  foreach($af as &$line) {
+    if (is_readable(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/" . trim(basename($line)) . "+scr")) {
+      $asf = file(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/" . trim(basename($line)) . "+scr");
+      $size = trim($asf[1]);
+      $sha = trim($asf[2]);
+
+      if (left($line,7)==="Private") {
+        $filePath = APP_PRIVATE_PATH . trim(substr($line, 7));
+      } else {
+        $filePath = APP_PUBLIC_PATH . trim(substr($line, 6));
+      }
+
+      if (filesize($filePath) != $size) {
+        return $ret;
+      } 
+ 
+      if (hash("sha256", file_get_contents($filePath), false) !== $sha) {
+        return $ret;
+      } 
+
+      echo_ifdebug(true, "CHECKING_ROUTE_DEP: " . trim(basename($line)) . ": recognized<br>");
+
+    } else {
+      return $ret;
+    }
+  }
+
+  return true;
+}
+
+
+function SC_CHECK_ROUTE_RES($route) {
+
+  $ret = false; 
+  $res = [];
+  
+  echo_ifdebug(true, "CHECKING_ROUTE_RES: Start<br>");
+
+  // Check for +CONTENT
+  if (!is_readable(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/+CONTENT")) {
+    return $ret;
+  }
+
+  //echo_ifdebug(true, "CHECKING_ROUTE_RES: +CONTENT: exists<br>");
+
+  $af = file(APP_PRIVATE_PATH . "/routes/" . $route . "/" . APP_SECRETS_FOLDER . "/+CONTENT");
+  if (left($af[0],7)==="Private") {
+      $routeFilePath = APP_PRIVATE_PATH . trim(substr($af[0], 7));
+  } else {
+      $routeFilePath = APP_PUBLIC_PATH . trim(substr($af[0], 6));
+  }
+
+  $acf = file_get_contents($routeFilePath);
+  
+  // ANALYZING HEADER..
+  preg_match_all("/<head>.*<\/head>/s", $acf, $c, PREG_PATTERN_ORDER);
+  
+  //print_r($c[0][0]); // html header
+  preg_match_all('/\/js\/.+\.js/s', $c[0][0], $res, PREG_PATTERN_ORDER); 
+  if (!empty($res[0])) { 
+    foreach($res[0] as $item) {
+      if (!in_array("Public".$item.PHP_EOL,$af)) {
+        return $ret;
+      }
+     echo_ifdebug(true, "CHECKING_ROUTE_RES: $item in  " . basename($routeFilePath) . ": recognized<br>");      
+    }
+  }  
+  preg_match_all('/\/css\/.+\.css/s', $c[0][0], $res, PREG_PATTERN_ORDER); 
+  //print_r($res); 
+  if (!empty($res)) {
+    foreach($res[0] as $item) {
+      //echo("Public".$item);
+      if (!in_array("Public".$item.PHP_EOL,$af)) {
+        return $ret;
+     }
+     echo_ifdebug(true, "CHECKING_ROUTE_RES: $item in " . basename($routeFilePath) . ": recognized<br>");
+    }
+  }
+  //print_r($res[0]);
+
+  // ANALYZING BODY..
+  preg_match_all("/<body>.*<\/body>/s", $acf, $c, PREG_PATTERN_ORDER);
+  
+  //print_r($c[0][0]); // html body
+  preg_match_all('/\/res\/.+\.png/s', $c[0][0], $res, PREG_PATTERN_ORDER); 
+  if (!empty($res[0])) { 
+    foreach($res[0] as $item) {
+      //echo("Public".$item);
+      if (!in_array("Public".$item.PHP_EOL,$af)) {
+        return $ret;
+      }
+     echo_ifdebug(true, "CHECKING_ROUTE_RES: $item in  " . basename($routeFilePath) . ": recognized<br>");      
+    }
+  }  
+
+  return true;
+
+}
+
+function SC_CHECK_ROUTE_ALL($route) {
+
+  $ret = 200;
+
+  if (!is_readable(APP_PRIVATE_PATH . "/routes/" . $route)) {
+    $ret = 404;
+    return $ret;
+  }
+
+  if (!SC_CHECK_ROUTE_STRU($route) || !SC_CHECK_ROUTE_DEP($route) || !SC_CHECK_ROUTE_RES($route)) {
+    $ret = 502;
+    return $ret;
+  }
+
+  return $ret;
+
+}

+ 55 - 0
Private/error/err-401.php

@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * err-401.php
+ * 
+ * Unauthorized 401 error page.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode
+ */
+
+?>
+
+<?php //require APP_SCRIPT_PATH . "/header.php";?>
+
+
+    <div class="content-area">
+
+      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
+
+        <div class="box-centrd box-centrd-align-cent" style="width: 100%;">
+
+          <div align="center" style="width: 100%;">
+            <!--<img src="res/logo3.png" border="0">-->
+            <br><br>
+            <div style="width:100%; padding: 7%,0;"><h3>Unauthorized. 为授权. No autorizado. Non autorisé. Non autorizzato.</h3></div>
+          </div>
+
+        </div>  
+          
+        <br>
+        
+      </div>
+
+    </div>  
+
+
+<?php //require APP_SCRIPT_PATH . "/footer.php";?>

+ 63 - 0
Private/error/err-404.php

@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * err-404.php
+ * 
+ * Page Not Found. 404 error page.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode
+ */
+
+?>
+
+<?php //require APP_SCRIPT_PATH . "/header.php";?>
+
+
+    <div class="content-area">
+
+      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
+
+        <div class="box-centrd box-centrd-align-cent" style="width: 100%;">
+
+          <br><br>
+
+          <div class="spacer"><br><br><br><br></div>          
+          
+          <div align="center" style="width: 100%;">
+            <!--<img src="res/logo3.png" border="0">-->
+            <br><br>
+            <div style="width:100%; padding-left: 7%; padding-right: 7%;"><h3>Page not found. 找不到网页. Página no encontrada. Page non trouvée. Pagina non trovata.</h3></div>
+          </div>
+          
+          <div class="spacer-fixed" style="clear:both;"><br><br><br><br><br></div>
+
+          <div class="spacer" style="clear:both;"><br><br><br><br><br><br><br><br><br><br></div>
+
+        </div>  
+          
+        <br>
+
+      </div>
+
+    </div>  
+ 
+
+<?php //require APP_SCRIPT_PATH . "/footer.php";?>

+ 55 - 0
Private/error/err-502.php

@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * err-502.php
+ * 
+ * Unauthorized 502 error page.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode
+ */
+
+?>
+
+<?php //require APP_SCRIPT_PATH . "/header.php";?>
+
+
+    <div class="content-area">
+
+      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
+
+        <div class="box-centrd box-centrd-align-cent" style="width: 100%;">
+
+          <div align="center" style="width: 100%;">
+            <!--<img src="res/logo3.png" border="0">-->
+            <br><br>
+            <div style="width:100%; padding: 7%,0;"><h3>Unauthorized. 为授权. No autorizado. Non autorisé. Non autorizzato.</h3></div>
+          </div>
+
+        </div>  
+          
+        <br>
+        
+      </div>
+
+    </div>  
+
+
+<?php //require APP_SCRIPT_PATH . "/footer.php";?>

+ 80 - 0
Private/functions/func.app.inc

@@ -0,0 +1,80 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * func.app.inc
+ * 
+ * App related functions.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode    
+ */
+
+use fivemode\fivemode\Config;
+
+
+/**
+ * Retrieve the list of the app hosts 
+ * 
+ * @return array the hosts array
+ */
+function getHostsArray(): array {
+  $reta = [];
+  $reta[] = APP_HOST;
+  $i = 2;
+  while (true && $i<=10) {
+    if (defined("APP_HOST" . $i)) {
+      $reta[] = Config::get("APP/HOST" . $i);
+    } else {
+      break;
+    }  
+    $i++;
+  }
+  return $reta;
+}
+
+
+/**
+ * 
+ * @return string
+ */
+function getQRCodeUri(string $styleTag): string {
+  
+  $retval = PHP_STR;
+  
+  $serverName = strtolower($_SERVER['HTTP_HOST']);
+  
+  if (mb_stripos1($serverName, "5mode.com") || mb_stripos1($serverName, "localhost")) {
+    $retval = "qrcode_5mode" . $styleTag . ".png";
+  }
+  
+  return $retval; 
+}
+
+
+function isSubdomainHost(string &$subdomain) {
+  $hostname = str_replace("www.", PHP_STR, strtolower($_SERVER['HTTP_HOST']));    
+  $ipos = mb_stripos($hostname, ".");
+  $subdomain = left($hostname, $ipos);
+  $noSubdomain = false;
+  if (($subdomain==="5mode.com")) {
+    $noSubdomain = true;
+  }
+  return !$noSubdomain;
+}

+ 167 - 0
Private/functions/func.array.inc

@@ -0,0 +1,167 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * func.array.inc
+ * 
+ * Array related functions.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026, 5 Mode     
+ */
+
+/**
+ * Fix multiple file uploaded array ($_FILE)
+ * 
+ * @param array $f the $_FILE array
+ * @return array the array fixed
+ */
+function fixMultipleFileUpload(&$f): array
+{
+    $files = array();
+    $count = count($f['name']);
+    $keys = array_keys($f);
+   
+    for($i=0;$i<$count;$i++)
+    {
+        foreach($keys as $key)
+        {
+            $files[$i][$key] = $f[$key][$i];
+        }
+    }
+    return $files;
+}
+
+/**
+ * Count the non zero elements of the given array
+ * 
+ * @param array $array
+ */
+function count_nonzeros(& $array): int 
+{
+  return count(array_filter($array));
+}  
+  
+/**
+ * Count the dimensions of the given array
+ * 
+ * @param array $array
+ * @return int the dimensions of the array
+ */
+function array_dim(array $array): int
+{
+  if (is_array(reset($array))) {
+    $retval = array_dim(reset($array)) + 1;
+  } else {
+    $retval = 1;
+  }
+
+  return $retval;
+}
+
+/**
+ * Filter false array entries replacing them with nulls
+ * 
+ * @param array $array array to filter
+ * @return array the resulting array
+ */
+function array_filter_tonull(array $array): array 
+{
+  foreach($array as & $val) {
+    if (!$val) {
+      $val = null;
+    }
+  }
+  return $array;
+}
+
+/**
+ * Return the values from a single column in the input array 
+ * filtered for value between $min and $max..
+ * 
+ * @param array $array the array being filtered
+ * @param string $column the column to filter on
+ * @param mixed $min the min val of column
+ * @param mixed $max the max val of column
+ * @return array the filtered array
+ */
+function array_numcolumn(& $array, string $column, int $min = 0, int $max = 99999999999): array 
+{
+  $GLOBALS['min'] = $min;
+  $GLOBALS['max'] = $max;
+  $array = array_filter(array_column($array, $column), function($val) {
+    if ($val>=$GLOBALS['min'] && $val<=$GLOBALS['max']) {
+      return true;
+    } else {
+      return false;
+    }
+  });
+  return $array;
+}
+
+/**
+ * Count the keys of a given array
+ * 
+ * @param array $array
+ * @return int the number of keys
+ */
+function array_keys_count(& $array): int
+{
+  return count(array_keys($array));
+}
+
+/**
+ * Append a value to the right of array until the given length
+ * 
+ * @param array $array array to pad
+ * @param mixed $val the value to the append to the array
+ * @param int $len the final length of the padded array
+ * @return void
+ */
+function array_rpad(& $array, $val, int $newlen): void 
+{
+  $i=count($array);
+  if ($i>=$newlen) {
+    return;
+  }
+  while($i<$newlen) {
+    $array[] = $val; 
+    $i++;
+  }
+}
+
+/**
+ * Searches the array for a given value and returns the corresponding key if successful
+ * otherwise null, result safe (not 0)
+ * 
+ * @param mixed $needle the value to search 
+ * @param array $array the array being searched
+ * @return mixed the key associated to the value, or null
+ */
+function array_search2($needle, & $array) 
+{
+  $retval = null;
+  foreach ($array as $key => $value) {
+    if ($value === $needle) {
+      $retval = $key;
+      break;
+    }
+  }
+  return $retval;
+}

+ 106 - 0
Private/functions/func.file.inc

@@ -0,0 +1,106 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * func.file.inc
+ * 
+ * String related functions.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode
+ */
+
+/**
+ * Copy a source file
+ * 
+ * @param string $sourceFilePath the file to copy
+ * @param string $destFilePath the destination file
+ * @return void
+ */
+function cp(string $sourceFilePath, string $destFilePath): void 
+{
+  $dataLength = 300000;
+  $hsfile = fopen($sourceFilePath, "r");
+  $hdfile = fopen($destFilePath, "w");
+  while ($data = fread($hsfile, $dataLength)) {
+    fwrite($hdfile, $data);
+  }
+  fclose($hsfile);
+  fclose($hdfile);
+}
+
+/**
+ * Store FileSystem data version of an XML snip field 
+ * 
+ * @param string $details the SimpleXML base details collection
+ * @param string $filename the basedir
+ * @param string $field the field to save
+ * @return void
+ */
+function storeFSData($details, $filename, $field) {
+
+  $datapath = APP_DATA_PATH . PHP_SLASH . $filename . PHP_SLASH . "data" . PHP_SLASH . $field;
+  chdir($datapath);
+  $pattern = "*";
+  $apath = glob($pattern);
+  foreach($apath as $path) {
+    unlink($path);
+  }  
+  switch($field) {
+    case "title":
+      file_put_contents($details->detail[0]->title, PHP_STR);
+      break;
+    case "desc":
+      file_put_contents($details->detail[0]->desc, PHP_STR);
+      break;
+    case "code":
+      file_put_contents("code.txt", $details->detail[0]->code);
+      break;
+    case "tags":
+      $tags = trim($details->detail[0]->tags);
+      $a = explode(" ", $tags);
+      foreach($a as $f) {
+        file_put_contents($f, PHP_STR);
+      }  
+      break;
+    case "cats":
+      $cats = trim($details->detail[0]->cats);
+      $a = explode(" ", $cats);
+      foreach($a as $f) {
+        file_put_contents($f, PHP_STR);
+      }  
+      break;
+    case "label":
+      file_put_contents($details->detail[1]->label, PHP_STR);
+      break;
+    case "link":
+      file_put_contents($details->detail[1]->link, PHP_STR);
+      break;
+    case "email":
+      file_put_contents($details->detail[1]->email, PHP_STR);
+      break;
+    case "guid":
+      file_put_contents($details->detail[2]->guid, PHP_STR);
+      break;
+    case "password":
+      file_put_contents($details->detail[3]->password, PHP_STR);
+      break;
+  }
+  
+}

+ 300 - 0
Private/functions/func.filter.inc

@@ -0,0 +1,300 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * func-filter.inc
+ * 
+ * Custom filtering functions.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode
+ */
+
+use fivemode\fivemode\Err;
+use fivemode\fivemode\ErrUtil;
+
+
+// Validate / sanitize a given string
+define("FILTER_SANITIZE_BOOLEAN", 1);
+define("FILTER_SANITIZE_ERRMSG", 2);
+define("FILTER_SANITIZE_FILENAME", 3);
+define("FILTER_SANITIZE_FILENAME_WITH_SPACE", 4);
+define("FILTER_SANITIZE_FILEPATH", 5);
+define("FILTER_SANITIZE_IMAGENAME", 6);
+define("FILTER_SANITIZE_LANGUAGE", 7);
+define("FILTER_SANITIZE_KEY", 8);
+define("FILTER_SANITIZE_MD5TOKEN", 9);
+define("FILTER_SANITIZE_Q", 10);
+define("FILTER_SANITIZE_QM", 11);
+define("FILTER_SANITIZE_SCRIPTNAME", 12);
+define("FILTER_SANITIZE_SHA2TOKEN", 13);
+define("FILTER_SANITIZE_STRING_WITHBR", 14);
+define("FILTER_SANITIZE_TAG", 15);
+define("FILTER_SANITIZE_TAGS", 16);
+define("FILTER_SANITIZE_URL1", 17);
+define("FILTER_SANITIZE_USERNAME", 18);
+define("FILTER_SANITIZE_FILEPATH_LESS", 19);
+define("FILTER_CLEAN_LANDINGPAGE", 100);
+define("FILTER_VALIDATE_ERRNO", 200);
+define("FILTER_VALIDATE_IMAGENAME", 201);
+define("FILTER_VALIDATE_LANGUAGE", 202);
+define("FILTER_VALIDATE_SHA2TOKEN", 203);
+define("FILTER_VALIDATE_MD5TOKEN", 204);
+define("FILTER_VALIDATE_REFID", 205);
+define("FILTER_VALIDATE_USERNAME", 206);
+define("FILTER_VALIDATE_TIMEWINDOW", 207);
+
+
+/**
+ * Sanitize a given variable
+ * 
+ * @param string $string the string to check
+ * @param integer $filter the type of filter to apply
+ * @param mixed $param (optional) for various purpose
+ * @return mixed the string filtered, a boolean if the string is validate
+ */
+function filter_var1(string $string, int $filter, $param = null) {
+  if ($string=="") {
+    return $string;
+  }  
+  switch ($filter) {
+    case FILTER_SANITIZE_BOOLEAN:
+      return preg_replace("/[^0-1]/iu", "", $string);
+    case FILTER_SANITIZE_ERRMSG:
+      return str_replace(chr(10)," ", str_replace(chr(13)," ",filter_var($string, FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_STRIP_BACKTICK)));
+    case FILTER_SANITIZE_FILENAME:
+      return preg_replace("/[^\w\-.]/iu", "", $string);
+    case FILTER_SANITIZE_FILENAME_WITH_SPACE:
+      return preg_replace("/[^\w\-. ]/iu", "", $string);
+    case FILTER_SANITIZE_FILEPATH:
+      return preg_replace("/[^A-Za-z0-9-_.\/]/", "", $string);
+    case FILTER_SANITIZE_IMAGENAME:
+      return str_replace("_", "", preg_replace("/[^\w\- ]/iu", "", $string));
+    case FILTER_SANITIZE_KEY:
+      return preg_replace("/[^A-Za-z0-9-_]/", "", $string);
+    case FILTER_SANITIZE_LANGUAGE:
+      return preg_replace("/[^A-Za-z\-]/", "", $string);      
+    case FILTER_SANITIZE_MD5TOKEN:
+      return preg_replace("/[^A-Za-z0-9]/", "", $string);
+    case FILTER_SANITIZE_Q:
+      return trim(preg_replace("/[^\w\-: ]/iu", "", $string));
+    case FILTER_SANITIZE_QM:
+      return trim(preg_replace("/[^\w\.\-: ]/iu", "", $string));      
+    case FILTER_SANITIZE_SCRIPTNAME:
+      return preg_replace("/[^A-Za-z0-9-_]/", "", $string);
+    case FILTER_SANITIZE_SHA2TOKEN:
+      return preg_replace("/[^A-Za-z0-9]/", "", $string);
+    case FILTER_SANITIZE_STRING_WITHBR:
+      return str_replace("&NewLine;", "<br>", filter_var(str_replace("<br>", "&NewLine;", isset1($string,"")), FILTER_SANITIZE_STRING));
+    case FILTER_SANITIZE_TAG:
+      return preg_replace("/[^\w\-]/iu", "", $string);
+    case FILTER_SANITIZE_TAGS:
+      return preg_replace("/[^\w\- ]/iu", "", $string);
+    case FILTER_SANITIZE_URL1:
+      return preg_replace("/[^\w\-]/iu", "", $string);
+    case FILTER_SANITIZE_USERNAME:
+      return preg_replace("/[^\w\-]/", "", $string);
+    case FILTER_SANITIZE_FILEPATH_LESS:
+      $s = $string;
+      $s = str_replace("../", PHP_STR, $s);
+      $s = str_replace("..", PHP_STR, $s);
+      $s = str_replace("/", PHP_STR, $s);
+      $s = str_replace("*", PHP_STR, $s);
+      $s = str_replace("?", PHP_STR, $s);
+      $s = str_replace("%", PHP_STR, $s);
+      return trim_word($s, ['../', '..', '/', '*', '?', '%', '.']);
+    case FILTER_CLEAN_LANDINGPAGE:
+      $posLandingPage = strpos($string, "lndp");
+      $i = strpos($string, "&");
+      if ($posLandingPage===false) {
+        return $string;
+      }  
+      if ($i===false) {
+        return "";
+      } else {
+        return substr($string, $i+1); 
+      }
+      break;
+    case FILTER_VALIDATE_ERRNO:
+      if (preg_match("/^[0-9]+?$/", $string)) {
+        return true;
+      } else {
+        if (preg_match("/^([a-zA-Z0-9]{32})?$/", $string) && ErrUtil::isValidError($string)) {
+          return true;
+        } else {
+          return false;
+        }
+      }
+    case FILTER_VALIDATE_IMAGENAME:
+      return (mb_strlen($string)>=3 && mb_strlen($string)<=50 && preg_match("/^[\w\- ]+?$/iu", $string) && !stripos($string,"_"));
+    case FILTER_VALIDATE_LANGUAGE:
+      return preg_match("/^([a-z]{2}\-[A-Z]{2})?$/", $string);
+    case FILTER_VALIDATE_REFID:
+      if (!filter_var($string, FILTER_VALIDATE_INT)) {
+        return false;
+      } 
+      if (hash("sha256", $string . APP_SALT, false) != $param) {
+        return false;
+      }
+      return true;
+    case FILTER_VALIDATE_SHA2TOKEN:
+      return preg_match("/^([a-zA-Z0-9]{64})?$/", $string);
+    case FILTER_VALIDATE_MD5TOKEN:
+      return preg_match("/^([a-zA-Z0-9]{32})?$/", $string);      
+    case FILTER_VALIDATE_USERNAME:
+      return (strlen($string)>=3 && strlen($string)<=20 && preg_match("/^[\w\-]+?$/", $string));
+    case FILTER_VALIDATE_TIMEWINDOW:
+      return (strlen($string)===2 && preg_match("/^[0-9][d|w]$/", $string));
+    default:
+      Err::trigger_error1(ERR::ERR_GENERAL, "filter_var1: $filter filter: not implemented", __FILE__, __LINE__);
+      break;
+  }
+}  
+
+//INPUT_POST
+//INPUT_GET
+//INPUT_COOKIE
+//INPUT_ENV
+//INPUT_SERVER
+//INPUT_SESSION
+//INPUT_REQUEST
+
+/**
+ * Sanitize a given input string
+ * 
+ * @param integer $inputType the type of input INPUT_POST, INPUT_GET, etc.
+ * @param string $key the key of the input
+ * @param integer $filter the type of filter to apply
+ * @param mixed $param (optional) for various purpose
+ * @return mixed the string filtered, a boolean if the string is validate
+ */
+function filter_input1(int $inputType, string $key, int $filter, $param = null) {
+  
+  $input = array();  
+  switch ($inputType) {
+    case INPUT_POST:
+      $input =& $_POST;
+      break;
+    case INPUT_GET:
+      $input =& $_GET;
+      break;
+    default:
+      Err::trigger_error1(ERR::ERR_GENERAL, "filter_input1: $inputType inputType: not implemented", __FILE__, __LINE__);
+      break;
+  }
+  
+  if (!isset($input[$key])) {
+    return null;
+  }
+  
+  switch ($filter) {
+    case FILTER_SANITIZE_BOOLEAN:
+      return preg_replace("/[^0-1]/iu", "", $input[$key]);
+    case FILTER_SANITIZE_ERRMSG:
+      return str_replace(chr(10)," ", str_replace(chr(13)," ",filter_var($input[$key], FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_HIGH | FILTER_FLAG_STRIP_BACKTICK)));
+    case FILTER_SANITIZE_Q:
+      return trim(preg_replace("/[^\w\-: ]/iu", "", $input[$key]));
+    case FILTER_SANITIZE_QM:
+      return trim(preg_replace("/[^\w\.\-: ]/iu", "", $input[$key]));  
+    case FILTER_SANITIZE_MD5TOKEN:
+      return preg_replace("/[^A-Za-z0-9]/", "", $input[$key]);
+    case FILTER_SANITIZE_FILENAME:
+      return preg_replace("/[^\w\-.]/iu", "", $input[$key]);
+    case FILTER_SANITIZE_FILENAME_WITH_SPACE:
+      return preg_replace("/[^\w\-. ]/iu", "", $input[$key]);
+    case FILTER_SANITIZE_FILEPATH:
+      return preg_replace("/[^A-Za-z0-9-_.\/]/", "", $input[$key]);
+    case FILTER_SANITIZE_IMAGENAME:
+      return str_replace("_", "", preg_replace("/[^\w\- ]/iu", "", $input[$key]));      
+    case FILTER_SANITIZE_KEY:
+      return preg_replace("/[^A-Za-z0-9-_]/", "", $input[$key]);
+    case FILTER_SANITIZE_LANGUAGE:
+      return preg_replace("/[^A-Za-z\-]/", "", $input[$key]);      
+    case FILTER_SANITIZE_SCRIPTNAME:
+      return preg_replace("/[^A-Za-z0-9-_]/", "", $input[$key]);
+    case FILTER_SANITIZE_SHA2TOKEN:
+      return preg_replace("/[^A-Za-z0-9]/", "", $input[$key]);
+    case FILTER_SANITIZE_STRING_WITHBR:
+      return str_replace("&NewLine;", "<br>", filter_var(str_replace("<br>", "&NewLine;", isset1($input[$key],"")), FILTER_SANITIZE_STRING));
+    case FILTER_SANITIZE_TAG:
+      return preg_replace("/[^\w\-]/iu", "", $input[$key]);
+    case FILTER_SANITIZE_TAGS:
+      return preg_replace("/[^\w\- ]/iu", "", $input[$key]);
+    case FILTER_SANITIZE_URL1:
+      return preg_replace("/[^\w\-]/iu", "", $input[$key]);
+    case FILTER_SANITIZE_USERNAME:
+      return preg_replace("/[^\w\-]/", "", $input[$key]);
+    case FILTER_SANITIZE_FILEPATH_LESS:
+      $s = $input[$key];
+      $s = str_replace("../", PHP_STR, $s);
+      $s = str_replace("..", PHP_STR, $s);
+      $s = str_replace("/", PHP_STR, $s);
+      $s = str_replace("*", PHP_STR, $s);
+      $s = str_replace("?", PHP_STR, $s);
+      $s = str_replace("%", PHP_STR, $s);
+      return trim_word($s, ['../', '..', '/', '*', '?', '%', '.']);
+    case FILTER_CLEAN_LANDINGPAGE:
+      $posLandingPage = strpos($input[$key], "lndp");
+      $i = strpos($input[$key], "&");
+      if ($posLandingPage===false) {
+        return $input[$key];
+      }  
+      if ($i===false) {
+        return "";
+      } else {
+        return substr($input[$key], $i+1); 
+      }
+      break;
+    case FILTER_VALIDATE_ERRNO:
+      if (preg_match("/^[0-9]+?$/", $input[$key])) {
+        return true;
+      } else {
+        if (preg_match("/^([a-zA-Z0-9]{32})?$/", $input[$key]) && ErrUtil::isValidError($string)) {
+          return true;
+        } else {
+          return false;
+        }
+      }
+    case FILTER_VALIDATE_IMAGENAME:
+      return (mb_strlen($input[$key])>=3 && mb_strlen($input[$key])<=50 && preg_match("/^[\w\- ]+?$/iu", $input[$key]) && !stripos($input[$key], "_"));
+    case FILTER_VALIDATE_LANGUAGE:
+      return preg_match("/^([a-z]{2}\-[A-Z]{2})?$/", $input[$key]);
+    case FILTER_VALIDATE_REFID:
+      if (!filter_var($input[$key], FILTER_VALIDATE_INT)) {
+        return false;
+      } 
+      if (hash("sha256", $input[$key] . APP_SALT, false) != $param) {
+        return false;
+      }
+      return true;
+    case FILTER_VALIDATE_SHA2TOKEN:
+      return preg_match("/^([a-zA-Z0-9]{64})?$/", $input[$key]);
+    case FILTER_VALIDATE_MD5TOKEN:
+      return preg_match("/^([a-zA-Z0-9]{32})?$/", $input[$key]);  
+    case FILTER_VALIDATE_USERNAME:
+      return (strlen($input[$key])>=3 && strlen($input[$key])<=20 && preg_match("/^[\w\-]+?$/", $input[$key]));
+    case FILTER_VALIDATE_TIMEWINDOW:
+      return (strlen($input[$key])===2 && preg_match("/^[0-9][d|w]$/", $input[$key]));
+    default:
+      Err::trigger_error1(ERR::ERR_GENERAL, "filter_var1: $filter filter: not implemented", __FILE__, __LINE__);
+      break;
+  }
+}
+
+?>

+ 586 - 0
Private/functions/func.string.inc

@@ -0,0 +1,586 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * func.string.inc
+ * 
+ * String related functions.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode
+ */
+
+
+/**
+ * Check if the given word is a contraction 
+ * 
+ * @param string $w the word being checked
+ * @return bool if the word is a contraction, true/false
+ */
+function is_contraction(?string $w): bool 
+{
+  $retval = false;
+  if (!isset($w)) {
+    return $retval;
+  }
+  if ($w === mb_strtoupper($w)) {
+    $retval = true;
+  }
+  return $retval;
+}
+
+/**
+ * Check if the passed word is a given name 
+ * 
+ * @param string $w the word being checked
+ * @return bool if the word is a given name, true/false
+ */
+function is_givenName(?string $w): bool 
+{
+  $retval = false;
+  if (!isset($w)) {
+    return $retval;
+  }
+  if (is_ucfirst($w) && !is_contraction($w)) {
+    $retval = true;
+  }
+  return $retval;
+}
+
+
+/**
+ * Check if the given string start with a capital letter
+ * 
+ * @param string $s the string being checked
+ * @return bool if the string starts with a capital letter , true/false
+ */
+function is_ucfirst(?string $s): bool 
+{
+  $retval = false;
+  if (!isset($s)) {
+    return $retval;
+  }
+  if (ucfirst(mb_substr($s,0,1)) === mb_substr($s,0,1)) {
+    $retval = true;
+  }
+  return $retval;
+}
+
+/**
+ * Check if the letter is a vowel
+ * 
+ * @param char $letter the letter to check
+ * @return bool if the letter is vowel, true/false
+ */
+function is_vowel(string $letter): bool 
+{
+  $vowels = ['a','e','i','o','u'];
+  return in_array($letter, $vowels);
+}
+
+/**
+ * Check if the given url is a valid Facebook page
+ * 
+ * Eg:
+ * http://facebook.com/mrdanielebeta                                   
+ * http://facebook.com/pg/makeiteasyforabird
+ * 
+ * @param string $url the url to check
+ * @return bool if the url is Facebook url, true/false
+ */
+function isFacebookUrl(string $url): bool 
+{
+  $retval=false;
+  $maxLength = 60;
+  if (strlen($url)>60) {
+    return $retval;    
+  }
+  $url= strtolower($url);
+  $pattern1 = "/^http(s)?\:\/\/(www\.)?facebook\.com\/[\w\.]+$/";
+  $pattern2 = "/^http(s)?\:\/\/(www\.)?facebook\.com\/pg\/[\w\.]+$/";
+  if (preg_match($pattern1, $url) || preg_match($pattern2, $url)) {
+    $retval=true;
+  } else {
+    $retval=false;
+  }  
+  return $retval;
+}  
+
+/**
+ * Check if the given url is a valid domain url
+ * 
+ * Eg:
+ * http://danielebonini.com
+  * 
+ * @param string $url the url to check
+ * @return bool if the url is a valid domain url, true/false
+ */
+function isUrl(string $url): bool
+{
+  $retval=false;
+  $maxLength = 45;
+  if (strlen($url)>45) {
+    return $retval;    
+  }
+  $url= strtolower($url);
+  $pattern1 = "/^http(s)?\:\/\/(www\.)?\w+\.\w+$/";
+  $pattern2 = "/^http(s)?\:\/\/(www\.)?\w+\.\w+.\w+$/";
+  if (preg_match($pattern1, $url) || preg_match($pattern2, $url)) {
+    $retval=true;
+  } else {
+    $retval=false;
+  }  
+  return $retval;
+}  
+
+/**
+ * Check if the given url is a valid Youtube page
+ * 
+ * Eg:
+ * http://youtube.com/watch?v=eeerwr24334 
+ * 
+ * @param string $url the url to check
+ * @return bool if the url is Youtube url, true/false
+ */
+function isYoutubeUrl(string $url): bool 
+{
+  $retval=false;
+  $maxLength = 50;
+  if (strlen($url)>50) {
+    return $retval;    
+  }
+  $url= strtolower($url);
+  $pattern1 = "/^http(s)?\:\/\/(www\.)?youtube\.com\/watch\?v\=[\w]+$/";
+  if (preg_match($pattern1, $url)) {
+    $retval=true;
+  } else {
+    $retval=false;
+  }  
+  return $retval;
+}  
+
+/**
+ * Test if a word is of a latin language
+ * 
+ * @param string  $word the string to test
+ * @return bool  if $word is of a latin language, true/false
+ */
+function isLatinLang(string $word): bool 
+{
+  
+  //$char = mb_substr($word, 0, 1);
+  //return !preg_match("/[\x{31C0}-\x{31EF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4E00}-\x{9FFF}\x{F900}-\x{FAFF}\x{FE30}-\x{FE4F}]{1}/u", $char);
+  
+  $isNonLatinLang = preg_match("/^[\w-]+[\x{31C0}-\x{31EF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4E00}-\x{9FFF}\x{F900}-\x{FAFF}\x{FE30}-\x{FE4F}]+$/u", $word) ||
+                    preg_match("/^[\x{31C0}-\x{31EF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4E00}-\x{9FFF}\x{F900}-\x{FAFF}\x{FE30}-\x{FE4F}]+$/u", $word) ||
+                    preg_match("/^[\x{31C0}-\x{31EF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4E00}-\x{9FFF}\x{F900}-\x{FAFF}\x{FE30}-\x{FE4F}]+[\w-]+$/u", $word) ||
+                    preg_match("/^[\w-]+[\x{31C0}-\x{31EF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4E00}-\x{9FFF}\x{F900}-\x{FAFF}\x{FE30}-\x{FE4F}]+[\w-]+$/u", $word);
+  
+  return !$isNonLatinLang;
+}
+
+function json_decode_from_db(string $json, bool $assoc = false) 
+{
+  $temp = $json;
+  $temp = str_replace('\"', '"', $temp);
+  $temp = str_replace("\'", "'", $temp);
+  $temp = str_replace("\\\\", "\\", $temp);
+  
+  return json_decode($temp, $assoc);
+}
+
+/**
+ * Left cut the given string for the specified length 
+ * 
+ * @param string $string the string being cut on the left
+ * @param int $length the length of the substring to return
+ * @return string the resulting substring    
+ */
+function left(?string $string, int $length): string 
+{
+  if (!isset($string) || $string === PHP_STR) {
+    return PHP_STR;
+  }
+  return mb_substr($string, 0, $length);
+}
+
+/**
+ * Right cut the given string for the specified length 
+ * 
+ * @param string $string the string being cut on the right
+ * @param int $length the length of the substring to return
+ * @return string the resulting substring    
+ */
+function right(?string $string, int $length): string 
+{
+  if (!isset($string) || $string === PHP_STR) {
+    return PHP_STR;
+  }  
+  return mb_substr($string, mb_strlen($string) - $length);
+}
+
+/**
+ * Get the left word of the given sentence 
+ * 
+ * @param string $phrase  the sentence being processed
+ * @return string the first word    
+ */
+function leftWord(?string $phrase): string 
+{
+  if (isset1($phrase, PHP_STR)===PHP_STR) {
+    return PHP_STR;
+  }  
+
+  $aWords = explode(PHP_SPACE, $phrase);
+  return $aWords[0]; 
+}
+
+/**
+ * Get the right word of the given sentence 
+ * 
+ * @param string $phrase  the sentence being processed
+ * @return string the last word    
+ */
+function rightWord(?string $phrase): string 
+{
+  if (isset1($phrase, PHP_STR)===PHP_STR) {
+    return PHP_STR;
+  }  
+
+  $aWords = explode(PHP_SPACE, $phrase);
+  return $aWords[count($aWords)-1];
+}
+
+
+/**
+ * Return the number of words of the given phrase
+ * 
+ * @param string $phrase
+ * @return int the number of words of the phrase
+ */
+function mb_str_word_count(string $phrase): int 
+{
+  $aWords = explode(PHP_SPACE, $phrase);
+  return count($aWords);
+}
+
+/**
+ * Finds the position of first occurrence of a string within another, 
+ * result safe (excluding 0), case insensitive
+ * 
+ * @param string $string the string being searched
+ * @param string $needle the string searched
+ * @param int $offset the position in string to start the search 
+ * @return mixed the position of the needle or False
+ */
+function mb_stripos1(string $string, string $needle, int $offset = 0) 
+{
+  return mb_stripos(PHP_TILDE . $string, $needle, $offset);
+}  
+
+/**
+ * Normalize the case of the given text 
+ * 
+ * @param string $text text to case normalize
+ * @return string the normalized text
+ */
+function str_case_normalize(?string $text): string 
+{
+  $retval = $text;
+  
+  if (!isset($text) || $text === PHP_STR) {
+    return $retval;
+  }
+  
+  $aWords = explode(PHP_SPACE, $text);
+  
+  foreach($aWords as & $word) {
+    if (strtoupper(substr($word,0,1)) === substr($word,0,1)) {
+      $word = ucfirst(strtolower($word));
+    } else {  
+      $word = strtolower($word);
+    }  
+  }
+    
+  $retval = implode(" ", $aWords);
+  
+  return $retval;
+}  
+
+/**
+ * Clean a phase removing repeated spaces and trimming it  
+ * 
+ * @param string $string the string being cleaned
+ * @return string the cleaned string
+ */
+function str_cleanphrase(string $string): string 
+{
+  //return trim(str_replace("  ", PHP_SPACE, str_replace("  ", PHP_SPACE, $string)));
+  
+  //hypen
+  $retval = str_replace(" -", PHP_HYPHEN, $string);
+  $retval = str_replace("- ", PHP_HYPHEN, $retval);
+  $retval = ltrim($retval, PHP_HYPHEN);
+  $retval = rtrim($retval, PHP_HYPHEN);
+  //space
+  $retval = trim(str_replace("  ", PHP_SPACE, str_replace("  ", PHP_SPACE, $retval)));
+  
+  return $retval;
+}  
+
+/**
+ * Clean a phase removing repeated spaces and trimming it  
+ * 
+ * @param string $string the string being cleaned
+ * @return string the cleaned string
+ */
+function str_cleanphrase_M(string $string): string 
+{
+  //return trim(str_replace("  ", PHP_SPACE, str_replace("  ", PHP_SPACE, $string)));
+  
+  //hypen
+  $retval = str_replace(" -", PHP_HYPHEN, $string);
+  $retval = str_replace("- ", PHP_HYPHEN, $retval);
+  $retval = ltrim($retval, PHP_HYPHEN);
+  $retval = rtrim($retval, PHP_HYPHEN);
+  //axterix
+  //$retval = trim(str_replace("**", "*", str_replace("**", "*", $retval)));
+  $retval = str_replace("*", PHP_SPACE, $retval);
+  //space
+  $retval = trim(str_replace("  ", PHP_SPACE, str_replace("  ", PHP_SPACE, $retval)));
+  
+  return $retval;
+}  
+
+/**
+ * Clean a phase removing the plurals  
+ * 
+ * @param string $string the string being cleaned
+ * @return string the cleaned string
+ */
+function str_cleanplurals(string $string): string 
+{
+  $aWords = explode(PHP_SPACE, $string);
+  
+  foreach($aWords as &$word) {
+    if (right($word,3)==="ies") {
+      $word = left($word, strlen($word)-3) . "y";
+    }  
+    if (right($word,3)==="hes" || right($word,3)==="xes") {
+      $word = left($word, strlen($word)-2);
+    }  
+    if (right($word,2)==="es") {
+      $word = left($word, strlen($word)-2) . "e";
+    }  
+    if (right($word,2)!=="ss" && right($word,1)==="s") {
+      $word = left($word, strlen($word)-1);
+    }  
+  }
+  
+  return implode(PHP_SPACE, $aWords);
+}  
+
+/**
+ * Break the given phrase by a word separator
+ * 
+ * @param string $phrase the phrase being broken
+ * @param string $word_separetor the word at which beginning break the phrase
+ * @param string $retFirstPart the resulting broken first part of the phrase 
+ * @param string $retReminder the remaining part of the phrase
+ * @return void
+ */
+function str_phrasebrk(string $phrase, string $word_separetor, & $retFirstPart, & $retRemainder = null): void 
+{
+  $phrase = PHP_SPACE . $phrase . PHP_SPACE;
+  $i = mb_stripos1($phrase, PHP_SPACE . $word_separetor . PHP_SPACE);
+  if ($i) {
+    $retFirstPart = trim(mb_substr($phrase, 0, $i));
+    if (isset($retRemainder)) {
+      $retRemainder = trim(mb_substr($phrase, $i));
+    }
+  } else {  
+    $retFirstPart = trim($phrase);
+    if (isset($retRemainder)) {
+      $retRemainder = PHP_STR;
+    }     
+  }
+}
+
+/**
+ * Return the given needle only if not already present in string
+ * 
+ * @param string $string
+ * @param string $needle
+ * @return string
+ */
+function str_place(string $string, string $needle): string  
+{
+   if (mb_stripos(PHP_TILDE . $string, $needle)) {
+     return PHP_STR;
+   } else {
+     return $needle;
+   }
+}
+
+/**
+ * Replace a pattern in the given string
+ * 
+ * @param string $needle the pattern searched for
+ * @param string $replace the replacement
+ * @param string $string the string being searched
+ * @param int $replacements the number of replacements to perform
+ * @return string the replaced string
+ */
+function str_replace1(string $needle, string $replace, ?string $string, int $replacements = 1): string 
+{
+  if (!isset($string) || $replacements === 0) {
+    return $string;
+  }
+  
+  if ($replacements < 0 ) {
+    $string = implode(PHP_SPACE, array_reverse(explode(PHP_SPACE, $string)));
+    $replace = implode(PHP_SPACE, array_reverse(explode(PHP_SPACE, $replace)));
+    $string = preg_replace("/$needle/i", $replace, $string, abs($replacements));
+    $string = implode(PHP_SPACE, array_reverse(explode(PHP_SPACE, $string)));
+  } else {
+    $string = preg_replace("/$needle/i", $replace, $string, abs($replacements));
+  }
+  
+  return $string;
+}
+
+/**
+ * Reverse the words in the given phrase
+ * 
+ * @param string $string the string being reversed
+ * @return string the resulting reversed string
+ */
+function str_phrase_reverse(string $string): string 
+{
+  settype($aWords, "array");
+  $aWords = explode(PHP_SPACE, $string);
+  $aWords = array_reverse($aWords);
+  return implode(PHP_SPACE, $aWords);
+}
+
+/**
+ * Finds the position of the first occurance of a word 
+ * in the given string, result safe (excluding 0), case insensitive
+ * 
+ * @param string $phrase the phrase being searched
+ * @param string $word the searched word
+ * @param int $offset the position in string to start the search 
+ * @return mixed the position of the searched word, otherwise false 
+ */
+function str_wordipos(string $phrase, string $word, int $offset = 0) 
+{
+  if ($offset<0) {
+    $offset=0;
+  }
+  $word = strtolower($word);
+  $phrase = strtolower($phrase);
+  $aWords = explode(" ", $phrase);
+  $max = count($aWords) - 1;
+  $i = $offset; 
+  while ($i <= $max) {
+    $word2 = $aWords[$i];
+    if ($word === $word2) {
+      return $i + 1;
+    }
+    $i++;
+  }
+  return false;
+}
+
+/**
+ * Remove duplicate words from a phrase
+ * 
+ * @param string $phrase the string being processed
+ * @param bool $removeRightMost if remove the right-most duplicates, true/false
+ * @return string the resulting string
+ */
+function str_word_unique(string $phrase, bool $removeRightMost = true) 
+{
+  settype($aWords, "array");
+  $aWords = explode(PHP_SPACE, $phrase);
+  if ($removeRightMost) {
+    // Remove right-most duplicates from the given string..
+    $aWords = array_unique($aWords);
+  } else {
+    // Remove left-most duplicates from the given string..
+    $aWords = array_reverse($aWords);
+    $aWords = array_unique($aWords);
+    $aWords = array_reverse($aWords);
+  }  
+  return implode(PHP_SPACE, $aWords);
+}  
+
+/**
+ * Short words by the given char limit
+ * 
+ * @param string $phrase the phrase being parsed 
+ * @param int $wordLength the word limit to set
+ * @return string  the resulting phrase
+ */
+function str_word_length(string $phrase, int $wordLength): string 
+{
+  $aWords = explode(PHP_SPACE, $phrase);
+  foreach($aWords as & $word) {
+    $word = mb_substr($word, 0, $wordLength);
+  }
+  return implode(PHP_SPACE, $aWords);
+}
+
+/**
+ * Right trim a word from the given string
+ * 
+ * @param string $phrase the string being trimmed
+ * @param array $aWords the words to remove
+ * @return string the resulting right trimmed phrase 
+ */
+function rtrim_word(string $phrase, array $aWords): string 
+{
+  $retval = PHP_SPACE . $phrase . PHP_SPACE;
+  
+  foreach ($aWords as $word) {
+    if (right($retval, mb_strlen($word) + 2) === (PHP_SPACE . $word . PHP_SPACE)) {
+      $retval = left($retval, mb_strlen($retval) - (mb_strlen($word) + 1));
+    }  
+  }  
+  
+  return str_cleanphrase($retval);
+}
+
+/**
+ * Trim a word from the given string
+ * 
+ * @param string $phrase the string being trimmed
+ * @param array $aWords the words to remove
+ * @return string the resulting trimmed phrase 
+ */
+function trim_word(string $phrase, array $aWords) {
+
+  $retval = PHP_SPACE . $phrase . PHP_SPACE;
+  
+  foreach ($aWords as $word) {
+    $retval = str_ireplace(PHP_SPACE . $word . PHP_SPACE, PHP_SPACE, $retval);
+  }  
+  
+  return str_cleanphrase($retval);
+}

+ 129 - 0
Private/functions/func.various.inc

@@ -0,0 +1,129 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * func.various.inc
+ * 
+ * Functions of various kind.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode
+ */
+
+/**
+ * Replacement for echo with debug checking
+ * 
+ * @param boolean $debug_var a debug value, if true the echo will be executed 
+ * @param list $args a variable argument list
+ * @return void
+ */
+function echo_ifdebug(bool $debug_var, ...$args): void 
+{
+  if (!DEBUG || !$debug_var) {
+    return;
+  }
+  foreach($args as $arg) {
+    echo $arg;
+  }
+}
+
+function getResource(string $string, string $destLocale = "EN"): string
+{
+  
+  global $LOCALE;
+  
+  if ($destLocale === "EN") {
+    return $string; 
+  }    
+
+  if ($LOCALE[$destLocale]["Monday"]==PHP_STR) {
+    return $string; 
+  }    
+
+  return str_ireplace(array_keys($LOCALE[$destLocale]),array_values($LOCALE[$destLocale]), $string);
+}
+
+
+/**
+ * Get an integer result for a division
+ * 
+ * @param mixed $a first operand
+ * @param mixed $b second operand
+ * @return int the integer result
+ */
+function intdiv_1($a, $b): int 
+{
+  return ($a - $a % $b) / $b;
+}
+
+/**
+ * Check if the number is odd
+ * 
+ * @param mixed $a first operand
+ * @return bool if the number is odd, true/false
+ */
+function is_odd($a): bool 
+{
+  return ($a % 2) > 0;
+}
+
+/**
+ * Check if the number is pair
+ * 
+ * @param mixed $a first operand
+ * @return bool if the number is pair, true/false
+ */
+function is_pair($a): bool
+{
+  return ($a % 2) === 0;
+}
+
+
+/**
+ * Check if a variable is set with a default return
+ * 
+ * @param mixed $var the variable to check
+ * @param mixed $default the default value
+ * @return mixed the return value
+ */
+function isset1(&$var, $default=false) 
+{
+  if (isset($var)) {
+    return $var;
+  } else {
+    return $default;
+  }
+}
+
+/**
+ * Replacement for var_dump with debug checking
+ * 
+ * @param boolean $debug_var a debug value, if true the var_dump will be executed 
+ * @param list $args a variable argument list
+ * @return void
+ */
+function var_dump_ifdebug(bool $debug_var, ...$args): void 
+{
+  if (!DEBUG || !$debug_var) {
+    return;
+  }
+  foreach($args as $arg) {
+    var_dump($arg);
+  }
+}

+ 3 - 0
Private/index-scrs/func.various.inc+scr

@@ -0,0 +1,3 @@
+Private/functions/func.various.inc
+2804
+0dd28a9552d4759ec5d4d17b6456669018b75a78a5da294215536bf705f658b6

+ 3 - 0
Private/index-scrs/logot.png+scr

@@ -0,0 +1,3 @@
+Public/res/logot.png
+129228
+3bd3ee15a4d1c447a4da7e87cb0178936c15e3fd45e494a63083d8b3f7eed42b

+ 3 - 0
Private/index-scrs/style.css+scr

@@ -0,0 +1,3 @@
+Public/css/style.css
+81
+c13695da182c2e5ad0268b03cd7ecce0a57dbb6a1c43b429f1fab09b71ff41fe

+ 3 - 0
Private/index-scrs/test.php+scr

@@ -0,0 +1,3 @@
+Private/routes/test/test.php
+1008
+35637b4cf8da4c454fdd0559dc8ac5b166d7c1e5740a009952ad212724441830

+ 0 - 0
Private/log/empty


+ 5 - 0
Private/routes/test/+DESC

@@ -0,0 +1,5 @@
+<br>
+Simple and modern route: <br>
+- list item1<br>
+- list item2<br>
+- list item3<br>

+ 4 - 0
Private/routes/test/scr/+CONTENT

@@ -0,0 +1,4 @@
+Private/routes/test/test.php
+Private/functions/func.various.inc
+Public/css/style.css
+Public/res/logot.png

+ 0 - 0
Private/routes/test/scr/+REQUIRING


+ 38 - 0
Private/routes/test/test.php

@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * testlogo.php
+ * 
+ * Testing route 
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode
+ */
+ 
+?>
+
+<html>
+<head>
+   <link href="/css/style.css" type="text/css" rel="stylesheet"></link>
+</head>
+<body>
+<img src="/res/logot.png" alt="5mode logo">
+</body>
+</html>

+ 25 - 0
Private/templates/Licenses/license-SqueePF.txt

@@ -0,0 +1,25 @@
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * fileName.php
+ * 
+ * Description of the file.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026, 5 Mode
+ */

+ 0 - 0
Private/upload/empty


+ 5 - 0
Public/css/style.css

@@ -0,0 +1,5 @@
+body {
+   background-color: #020202;
+   font-size: 11px;
+   color: lightgreen;
+}

+ 75 - 0
Public/index.php

@@ -0,0 +1,75 @@
+<?php
+
+/**
+ * Copyright 2021, 2026 5 Mode
+ *
+ * This file is part of SqueePF.
+ *
+ * SqueePF is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SqueePF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.  
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with SqueePF. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * index.php
+ * 
+ * The index file.
+ *
+ * @author Daniele Bonini <my25mb@has.im>
+ * @copyrights (c) 2016, 2026 5 Mode     
+ */
+
+require "../Private/core/init.inc";
+require "../Private/core/sc.inc";
+
+// FUNCTION AND VARIABLE DECLARATIONS
+
+
+// PARAMETERS VALIDATION
+
+$url = filter_input(INPUT_GET, "url")??"";
+$url = strip_tags($url);
+$url = strtolower(trim(substr($url, 0, 300), "/"));
+
+//echo($url);
+//exit;
+
+switch ($url) {
+  case "":
+  case "test":
+  
+    $rret =  SC_CHECK_ROUTE_ALL("test");  
+    if ( $rret === 200) {
+       $scriptPath = APP_ROUTES_PATH . "/test";
+       define("ROUTE_NAME", "test");
+       define("ROUTE_FILENAME", "test.php");   
+    } else {
+       $scriptPath = APP_ERROR_PATH;
+       define("ROUTE_NAME", "err-$rret");
+       define("ROUTE_FILENAME", "err-$rret.php");  
+    }
+                
+    break; 
+  case "test/+desc":
+    $scriptPath = APP_ROUTES_PATH . "/test";
+    define("ROUTE_NAME", "+DESC");
+    define("ROUTE_FILENAME", "+DESC");   
+    break;     
+  default:
+    $scriptPath = APP_ERROR_PATH;
+    define("ROUTE_NAME", "err-404");
+    define("ROUTE_FILENAME", "err-404.php");  
+}
+
+if (ROUTE_NAME==="err-404") {
+  header("HTTP/1.1 404 Not Found");
+}  
+
+require $scriptPath . "/" . ROUTE_FILENAME;

File diff suppressed because it is too large
+ 1 - 0
Public/js/jquery-3.6.0.min.js


BIN
Public/res/logot.png


Some files were not shown because too many files changed in this diff