]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/security_functions.php
Mailer used in many places, we still need a good 'selling' title
[mailer.git] / inc / libs / security_functions.php
index ba081bd00fe80d1cd1251977a691b76e3bf38ec8..96e39998fe8a7ab061992afccee2df548db2ce40 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 09/20/2005 *
- * ===============                              Last change: 09/20/2005 *
+ * Mailer v0.2.1-FINAL                                Start: 09/20/2005 *
+ * ===================                          Last change: 09/20/2005 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : security_functions.php                           *
@@ -51,15 +51,20 @@ if (ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) {
  * @param      $strip  Strip tags
  * @return     $str    A (hopefully) secured string against XSS and other bad things
  */
-function secureString ($str, $strip=true) {
+function secureString ($str, $strip = true, $encode = false) {
        // Shall we strip HTML code?
        if ($strip === true) $str = strip_tags($str);
 
        // Trim string
        $str = trim($str);
 
-       // Encode in entities
-       $str = htmlentities($str, ENT_QUOTES);
+       // Encode in entities if requested
+       if ($encode === true) {
+               // Encode in entities (this breakes UTF-8!)
+               $str = htmlentities($str, ENT_QUOTES);
+       } // END - if
+
+       // Return result
        return $str;
 }
 
@@ -71,17 +76,17 @@ ini_set('magic_quotes_gpc', false); // This may not work on some systems
 if (!isset($_SERVER)) {
        global $_SERVER;
        $_SERVER = $GLOBALS['_SERVER'];
-}
+} // END - if
 
 if (!isset($_GET)) {
        global $_GET;
        $_GET = $GLOBALS['_GET'];
-}
+} // END - if
 
 if (!isset($_POST)) {
        global $_POST;
        $_POST = $GLOBALS['_POST'];
-}
+} // END - if
 
 // Include IP-Filter here
 //require("/usr/share/php/ipfilter.php");
@@ -89,7 +94,7 @@ if (!isset($_POST)) {
 // Generate arrays which holds the relevante chars to replace
 $GLOBALS['security_chars'] = array(
        // The chars we are looking for...
-       'from' => array('{', '}', '/', '.', "'", "$", '(', ')', '{--', '--}', '{?', '?}', '%', ';', '[', ']', ':', '--'),
+       'from' => array('{', '}', '/', '.', "'", '$', '(', ')', '{--', '--}', '{?', '?}', '%', ';', '[', ']', ':', '--'),
        // ... and we will replace to.
        'to'   => array(
                '{OPEN_ANCHOR2}',
@@ -183,7 +188,7 @@ unset($phpSelfDirectory);
 unset($phpSelfFile);
 
 // Security system loaded...
-define('__SECURITY', '1');
+define('__SECURITY', 1);
 
 // [EOF]
 ?>