Page 1 of 2
Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Tue Oct 13, 2009 8:40 pm
by eabigelow
Hi--
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Tue Oct 13, 2009 9:46 pm
by requinix
Here is the code from the add.phtml file:
$filename ="msg.dat";
$file= fopen($filename,'a');
fputs($file, "$message1 - $pseudo1 - $pseudo2 - $pseudo3\n");
fclose($file);
?>
Is that all of the code?
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Tue Oct 13, 2009 9:49 pm
by eabigelow
Hi, many thanks for replying!
Yes, this is all the code for the add.phtml file.
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Tue Oct 13, 2009 9:53 pm
by eabigelow
Whoops! Except for the <?php at the beginning!
Sorry!
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Tue Oct 13, 2009 10:12 pm
by requinix
register_globals and magic_quotes... wonderful...
Code: Select all
<?php
function unmagicquotes($string) {
return function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()
? stripslashes($string)
: $string;
}
if (isset($_POST["message1"], $_POST["pseudo1"], $_POST["pseudo2"], $_POST["pseudo3"])) {
$message1 = unmagicquotes($_POST["message1"]);
$pseudo1 = unmagicquotes($_POST["pseudo1"]);
$psuedo2 = unmagicquotes($_POST["pseudo2"]);
$pseudo3 = unmagicquotes($_POST["pseudo3"]);
$filename ="msg.dat";
$file= fopen($filename,'a');
fputs($file, "$message1 - $pseudo1 - $pseudo2 - $pseudo3\n");
fclose($file);
}
?>
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Tue Oct 13, 2009 10:19 pm
by eabigelow
Wow! I will try this right away. Many, many thanks (I am keeping my fingers crossed)!
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Tue Oct 13, 2009 10:28 pm
by eabigelow
Well, no go on this one so far. I cut and pasted your code into the add.phtml page and uploaded that, but nothing is showing.
I checked to make sure, and here is what I have in my www folder:
php_flag magic_quotes_gpc on
So it appears magic quotes is on. Also, my sever is running PHP 5.XX
Should I have the .htaccess file in the same folder as the add.phtml file?
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Tue Oct 13, 2009 10:33 pm
by eabigelow
Actually, now the inputted text is not showing on the msg.dat page at all... CHMODing file now...
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Tue Oct 13, 2009 10:40 pm
by eabigelow
No text is saving into the msg.dat file at all... CHMOD of add.phtml file at 777. Also tested with original file, and that works (at least for sending the text into the msg.dat file)...
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Wed Oct 14, 2009 2:02 am
by requinix
What's add.phtml now? There's a parse error in it.
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Wed Oct 14, 2009 3:17 pm
by eabigelow
Hi--
Sorry for the delay in responding.
Here is the current code in the add.phtml file:
<?php
function unmagicquotes($string) {
return function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()
? stripslashes($string)
: $string;
}
if (isset($_POST["message1"], $_POST["pseudo1"], $_POST["pseudo2"], $_POST["pseudo3"])) {
$message1 = unmagicquotes($_POST["message1"]);
$pseudo1 = unmagicquotes($_POST["pseudo1"]);
$psuedo2 = unmagicquotes($_POST["pseudo2"]);
$pseudo3 = unmagicquotes($_POST["pseudo3"]);
$filename ="msg.dat";
$file= fopen($filename,'a');
fputs($file, "$message1 - $pseudo1 - $pseudo2 - $pseudo3\n");
fclose($file);
}
?>
Does this help?
Many thanks!
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Wed Oct 14, 2009 3:57 pm
by requinix
I still don't see it.
Change the <?php to be just ?php. This will mean the page won't work and will display as HTML instead, but it'll give a clearer picture as to what exactly is in the file.
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Wed Oct 14, 2009 8:55 pm
by eabigelow
Hi--
hold on... working on this...
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Wed Oct 14, 2009 9:17 pm
by eabigelow
Ok--
Some good news!
With your script (as follows) the slashes are stripped from the first two text items, but not the last two (pseudo2, pseudo3). Added: Just tried again--this time, it worked for the first two, and the last, but not the third (pseudo2).
Here's the current add.phtml code:
Code: Select all
<?php
function unmagicquotes($string) {
return function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()
? stripslashes($string)
: $string;
}
if (isset($_POST["message1"], $_POST["pseudo1"], $_POST["pseudo2"], $_POST["pseudo3"])) {
$message1 = unmagicquotes($_POST["message1"]);
$pseudo1 = unmagicquotes($_POST["pseudo1"]);
$psuedo2 = unmagicquotes($_POST["pseudo2"]);
$pseudo3 = unmagicquotes($_POST["pseudo3"]);
$filename ="msg.dat";
$file= fopen($filename,'a');
fputs($file, "$message1 - $pseudo1 - $pseudo2 - $pseudo3\n");
fclose($file);
}
?>
I thank you for this good first step! Is there any reason why we may be missing some of the text items?
Re: Magic Quotes and Strip Slashes: What am I doing wrong?
Posted: Thu Oct 15, 2009 3:47 am
by jackpf
Why not just turn of magic quotes? :/