Hi all,
I am a complete amatuer at coding (I know a little c# bit very little about php) so hope you can help.
A while back I made a silverlight game and wanted to it to have a high score table. The game runs in the browser on the users computer so the only way I could think of to do this was by the game sending the users score to a php file on the server. The php then writes the score into an xml file also on the server. When the game wants to know the score it reads the xml file.
Only problem being my server account somehow got hacked and my website account was suspended (it had some kind of virus/malware and was sending out shed loads of junk emails.) My provider says it was likely due to my php file having vulnerabilities. If it happens again my account will be closed for good.
I naively made no allowance for making this script secure.
this was my code…
<?php $stringData = $_POST['table']; $name = $_POST['name']; $kill = $_POST['kill']; if ($stringData != "") { $ourFileName = "v6.xml"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fwrite($ourFileHandle, $stringData); fclose($ourFileHandle); mail( "[email protected]", "The game has been played by ".$name.". A total of ".$kill." baddies were zapped" ,$stringData, "[email protected]" ); } ?>So this is my question…
How do I make my php secure? (the easiest way possible…!!)
And also does the read/write permissions of the files on the server have any bearing on this?
Hope you can help!
Many thanks,
Ian