/    Sign up×
Community /Pin to ProfileBookmark

addslahses and arrays.

I edit to tell this:

does addslashes work with an array? so instead of using addslashes with every single post element I just write this:

$_POST = addslahses($_POST);

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@mikkoMar 17.2005 — Unless magic_quotes_gpc is off in your php.ini, addslashes is run automatically on all $_GET and $_POST data...

Running adslashes again will probably result in twice escaped data.


http://uk2.php.net/manual/en/function.addslashes.php
Copy linkTweet thisAlerts:
@ShrineDesignsMar 17.2005 — this is a modded version of phpbb's automatic implimentation of gpc magic quotes[code=php]<?php
//
// addslashes to vars if magic_quotes_gpc is off
// this is a security precaution to prevent someone
// trying to break out of a SQL statement.
//
if(!get_magic_quotes_gpc())
{
if(is_array($_GET))
{
while(list($k, $v) = each($_GET))
{
if(is_array($_GET[$k]))
{
while(list($k2, $v2) = each($_GET[$k]))
{
$_GET[$k][$k2] = addslashes($v2);
}
@reset($_GET[$k]);
}
else
{
$_GET[$k] = addslashes($v);
}
}
@reset($_GET);
}
if(is_array($_POST))
{
while(list($k, $v) = each($_POST))
{
if(is_array($_POST[$k]))
{
while(list($k2, $v2) = each($_POST[$k]))
{
$_POST[$k][$k2] = addslashes($v2);
}
@reset($_POST[$k]);
}
else
{
$_POST[$k] = addslashes($v);
}
}
@reset($_POST);
}
if(is_array($_COOKIE))
{
while(list($k, $v) = each($_COOKIE))
{
if(is_array($_COOKIE[$k]))
{
while(list($k2, $v2) = each($_COOKIE[$k]))
{
$_COOKIE[$k][$k2] = addslashes($v2);
}
@reset($_COOKIE[$k]);
}
else
{
$_COOKIE[$k] = addslashes($v);
}
}
@reset($_COOKIE);
}
}
?>[/code]
×

Success!

Help @amahmood spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...