<?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 *
* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
* @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;
}
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");
+//include("/usr/share/php/ipfilter.php");
// 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}',
$_SERVER['PHP_SELF'] = secureString($_SERVER['PHP_SELF']);
// Split it up into path and filename
-$SELF_DIR = dirname($_SERVER['PHP_SELF']);
-$SELF_FILE = basename($_SERVER['PHP_SELF']);
+$phpSelfDirectory = dirname($_SERVER['PHP_SELF']);
+$phpSelfFile = basename($_SERVER['PHP_SELF']);
-// Check for a .php inside the $SELF_DIR...
-while (ereg('.php', $SELF_DIR)) {
+// Check for a .php inside the $phpSelfDirectory...
+while (ereg('.php', $phpSelfDirectory)) {
// Correct the dirname
- $SELF_DIR = substr($SELF_DIR, 0, (strpos($SELF_DIR, '.php') + 4));
+ $phpSelfDirectory = substr($phpSelfDirectory, 0, (strpos($phpSelfDirectory, '.php') + 4));
// Rewrite filename...
- $SELF_FILE = basename($SELF_DIR);
+ $phpSelfFile = basename($phpSelfDirectory);
// ... and dirname
- $SELF_DIR = dirname($SELF_DIR);
+ $phpSelfDirectory = dirname($phpSelfDirectory);
} // END - while
// Put both together again and let's pray it is secured now...
-$_SERVER['PHP_SELF'] = $SELF_DIR . '/' . $SELF_FILE;
+$_SERVER['PHP_SELF'] = $phpSelfDirectory . '/' . $phpSelfFile;
// Remove uneccessary variables
-unset($SELF_DIR);
-unset($SELF_FILE);
+unset($phpSelfDirectory);
+unset($phpSelfFile);
// Security system loaded...
-define('__SECURITY', '1');
+define('__SECURITY', 1);
// [EOF]
?>