magic quotes

T

Tim

Guest
My server will not let me add a .htaccess file or edit the php.ini file to get around the magic quotes set to on problem.

Am I up the proverbial creek or is there any other way I can get round this problem? I read that I could add the script below to php files so that it wouldn't matter if magic quotes were on or off. Would this work and if so, which php files should I add it to?

Thanks

<?php
highlight_string ( "<?php

function myAddSlashes( $string ) {

if (get_magic_quotes_gpc()==1) {

return ( $string );

} else {

return ( addslashes ( $string ) );

}

}

?>" );
?>

 
D

Debbie S

Guest
You could try header.php.

Debbie
(Latest version of DaDaBIK when this message was posted: 3.2 Beta)
 
L

Liam G. McFaul

Guest
Have you had any success with this solution?

greetings from Holland,

Liam
 
A

alpha2zee

Guest
This works -

DaDaBik requires magic_quotes_gpc to be ON for it to work. However, more and more servers have it set to OFF (default in latest PHP versions), and many users do not have access to php.ini files or cannot use .htaccess files to turn it on (with the statement 'php_flag magic_quotes_gpc On').

The following fixes DaDaBik so it works with magic_quotes_gpc either set to on or off.

Idea
----

Change all instances of addslashes and stripslashes to new, magic_quotes_gpc setting-dependent functions add_slashes and strip_slashes.

How
----

Use the 'find - replace (across all files of a folder)' functionality of a good code editor such as BBEdit to find 'addslashes' and replace them with 'add_slashes,' and then find 'stripslashes' and replace them with 'strip_slashes.' This can be done laboriously too by going through every .php file inside the DaDaBik folder.

Then, edit include/config.php. At end, add:

// magic quotes issues
function add_slashes($value) {
if (is_array($value)) {
foreach ($value as $index => $val) {
$value[$index] = add_slashes($val);
}
return $value;
} else {
return addslashes($value);
}
}
function strip_slashes($value) {
if (is_array($value)) {
foreach ($value as $index => $val) {
$value[$index] = strip_slashes($val);
}
return $value;
} else {
return stripslashes($value);
}
}
if (!get_magic_quotes_gpc()) {
// Recursively apply addslashes() to all data
$_GET = add_slashes($_GET);
$_POST = add_slashes($_POST);
$_COOKIE = add_slashes($_COOKIE);
$_REQUEST = add_slashes($_REQUEST);
}

Finally, edit include/common_start.php. Remove these lines:

if (get_magic_quotes_gpc()==0){
echo "<p><b>[00] Error:</b> you have to set magic_quotes_gpc to On in php.ini.";
exit;
} // end if
 

chichi

New member
I tried alpha2zee´s solution
it is working fine. Thanks for the workaround. I used dreamweaver to search and replace.
Nice work and help here!!!
chichi
 

andrerio

New member
Shouldn't be a need to this in future releases of Dadabik! Eugenio should prepare it to be PHP5 Default php.ini already!
 

andrerio

New member
Just FYI... I was able to get my Dadabik working with my hosting provider by changing from PHP5 to PHP4 in the cPanel host configuration.
 
Top