Home | Reviews | GUIpedia | Forum | Fun500
Jason | Is my php right?hey, i was just making sure that this piece of code is right, i did it off the top of my head :D
<?php
$_GET["to"]=fopen($_GET["to"],"a");
$_GET["from"]=fopen($_GET["from"],"a");
echo fwrite($_GET["to"],$_GET["to"]);
echo fwrite($_GET["to"],$_GET["from"]);
echo fwrite($_GET["to"],$_GET["datesent"]);
echo fwrite($_GET["to"],$_GET["timesent"]);
echo fwrite($_GET["to"],$_GET["message"]);
echo fwrite($_GET["from"],$_GET["to"]);
echo fwrite($_GET["from"],$_GET["from"]);
echo fwrite($_GET["from"],$_GET["datesent"]);
echo fwrite($_GET["from"],$_GET["timesent"]);
echo fwrite($_GET["from"],$_GET["message"]);
fclose($_GET["to"]);
fclose($_GET["from"]);
?>
| 2010-06-10 | 1:13 PM |
Todd | Re:Is my php right?<?php
$_GET["to"]=fopen($_GET["to"],"a"); // not really advocated in PHP but it does work
$_GET["from"]=fopen($_GET["from"],"a");
echo fwrite($_GET["to"],$_GET["to"]); // fwrite will write the file pointer to itself and echo the number of bytes to write the pointer
echo fwrite($_GET["to"],$_GET["from"]);
echo fwrite($_GET["to"],$_GET["datesent"]);
echo fwrite($_GET["to"],$_GET["timesent"]);
echo fwrite($_GET["to"],$_GET["message"]);
echo fwrite($_GET["from"],$_GET["to"]);
echo fwrite($_GET["from"],$_GET["from"]);
echo fwrite($_GET["from"],$_GET["datesent"]);
echo fwrite($_GET["from"],$_GET["timesent"]);
echo fwrite($_GET["from"],$_GET["message"]);
fclose($_GET["to"]);
fclose($_GET["from"]);
?>
Also why do you echo every fwrite? fwrite's return value is usually not used unless to ensure that the number of bytes written matches the number of bytes in the content being written. I think you mean something like this:
<?php
$a = fopen($_GET["to"],"a");
$b = fopen($_GET["from"],"a");
fwrite($a,$_GET["to"]);
fwrite($a,$_GET["from"]);
fwrite($a,$_GET["datesent"]);
fwrite($a,$_GET["timesent"]);
fwrite($a,$_GET["message"]);
fwrite($b,$_GET["to"]);
fwrite($b,$_GET["from"]);
fwrite($b,$_GET["datesent"]);
fwrite($b,$_GET["timesent"]);
fwrite($b,$_GET["message"]);
fclose($a);
fclose($b);
?>
Just a couple notes but I wouldn't advise using " when ' is more efficient for string literal processing in PHP. Also I would put some safeguard on $_GET['to'] and $_GET['from'] since there are no restrictions on which directory and file it can access which could lead to site hacking. | 2010-06-10 | 1:41 PM |
Jason | Re:Is my php right?thanks for the fix up! :D i will show DigiCom IE (internet edition, not internet explorer )
i'll also show DigiCom NE (network editon, does that stand for something else? ) if anyone has a network set up, no readme, i want to know if its easy enough to set up | 2010-06-11 | 4:47 AM |
Other
2021 Brandon Cornell