Monday, June 30th, 2008
set_magic_quotes_runtime(FALSE);
if (get_magic_quotes_gpc()) {
/*
All these global variables are slash-encoded by default,
because magic_quotes_gpc is set by default!
(And magic_quotes_gpc affects more than just $_GET, $_POST, and $_COOKIE)
*/
$_SERVER = stripslashes_array($_SERVER);
$_GET = stripslashes_array($_GET);
$_POST = stripslashes_array($_POST);
$_COOKIE = stripslashes_array($_COOKIE);
$_FILES = stripslashes_array($_FILES);
$_ENV = stripslashes_array($_ENV);
$_REQUEST = stripslashes_array($_REQUEST);
$HTTP_SERVER_VARS = stripslashes_array($HTTP_SERVER_VARS);
$HTTP_GET_VARS = stripslashes_array($HTTP_GET_VARS);
$HTTP_POST_VARS = stripslashes_array($HTTP_POST_VARS);
$HTTP_COOKIE_VARS = stripslashes_array($HTTP_COOKIE_VARS);
$HTTP_POST_FILES = stripslashes_array($HTTP_POST_FILES);
$HTTP_ENV_VARS = stripslashes_array($HTTP_ENV_VARS);
if (isset($_SESSION)) { #These are unconfirmed (?)
$_SESSION = stripslashes_array($_SESSION, ”);
$HTTP_SESSION_VARS = stripslashes_array($HTTP_SESSION_VARS, ”);
}
/*
The $GLOBALS array is also slash-encoded, but when all the above are
changed, $GLOBALS is updated to reflect those changes. (Therefore
$GLOBALS should never be modified directly). $GLOBALS also contains
infinite recursion, so it’s dangerous…
*/
}
function stripslashes_array($data) {
if (is_array($data)){
foreach ($data as $key => $value){
$data[$key] = stripslashes_array($value);
}
return $data;
}else{
return stripslashes($data);
}
}
Tags: array, cookie, Default, Disable, effect, false, files, get, HTTP, magic, PHP, quotes, runtime, session, Slash (/), these, VARS
Posted in PHP | No Comments »
Monday, June 30th, 2008
<?php
$extension = “php_domxml”;
var_dump(safe_dl($extension));
/**
* Loads extension safely
*
* Checks whether the extension is already loaded, if so does not try to reload it.
* Depending ot current OS it will try to load “.dll” or “.so” file.
* Some checks are made for GD library.
*
* @param string extension the extension that will be loaded
* @author RAJI <raji.peaceful@gmail.com>
* @author RAJI
*/
function safe_dl($extension)
{
$res = 0;
$extension = strtolower(trim($extension));
// if these is an extension supplied remove it
if (($posit = strpos($extension, “.”)) !== false)
$extension = substr($extension, 0, $posit);
// special check for gd1 & gd2
if ($extension == ‘gd’ || $extension == ‘gd2′ )
{
$ar = @gd_info();
if (is_array($ar)
&& !empty($ar["GD Version"])
&& (
// gd1
( ($extension == ‘gd’ && strpos($ar["GD Version"], “1.”) !== false)
||
// gd2
$extension == ‘gd2′&& strpos($ar["GD Version"], “2.”) !== false)
)
)
return true;
else
return false;
}
// if already loading return true
if (!empty($extension)
&& extension_loaded($extension))
return true;
// if not extension not loaded try to load it
if ( !empty($extension) &&
!extension_loaded($extension) &&
( @ini_get(”enable_dl”) == 1 ||
strtolower(@ini_get(”enable_dl”) ) == “on”)
)
{
// depending on OS load appopriate extension
$res = @dl($extension . “.”
. (strpos(strtolower(PHP_OS), “win”) !== false
? ‘dll’
: ’so’));
}
return $res
? true
: false;
}
?>
Tags: extension, load, loaded, peaceful, PHP, RAJI, runtime, Safely
Posted in PHP | No Comments »
Monday, June 30th, 2008
ini_set(’include_path’, ‘/usr/share/code’ . PATH_SEPARATOR . ini_get(’include_path’));
Tags: Change, configuration, Include, modify, path, PHP, runtime, values
Posted in PHP | No Comments »