The online racing simulator
You could use a password to make sure no ones abuses it. So when you pass the status, you can pass the password in as well and check that in the PHP page...

http://www.url.com/index.php?password=pass&status=Testing

Then the PHP page could be something like this. Bare in mind I've barely written any PHP for years, this is untested and going from memory... It should give you a rough idea of how to save the file.


<?php

$password = "pass";
$filename = "status.txt";

if($_GET['password'] != $password)
die("Invalid password");

if(!isset($_GET['status']))
die("Status not set");

$file = fopen($filename, "w");
if($file)
{
fwrite($file, $_GET['status']);
fclose($file);
}
else die("Could not write status to file");

?>

Anyway, you can find the PHP reference at http://www.php.net/docs.php.
#27 - vane
thanks for that darktimes, i never could have done it without you! ill try it after ive done my gcse photography work or my photography teacher will get bi*chy

EDIT: keeps bringing up "Could not write status to file" :s do i need to create the status.txt myself and where do i put it?
Flat file databases, yum!

YUM (Is not a pun, not this time anyway, but it is kinda funny as it happens to be an update tool for Fedora Core.)

[Side Note]
Speaking of Fedora, Fedora Core 9 comes out in 22 days!
[/Side Note]
#29 - vane
yeah that was... useful
Quote from vane :thanks for that darktimes, i never could have done it without you! ill try it after ive done my gcse photography work or my photography teacher will get bi*chy

EDIT: keeps bringing up "Could not write status to file" :s do i need to create the status.txt myself and where do i put it?

Yes, you need to create the status.txt file yourself, put it in the same directory as the PHP code and CHMOD it to 777.
#31 - vane
chmod? what do you mean by that?

EDIT: i searched google and found it means change mode, do i need to enter
$ chmod a+rw status.txt

?

when i do that it doesnt come up with the error but it doesnt save anything to the .txt file
Although I think you can set it with code, you should actually be able to set the chmod in your FTP program. You're basically setting the permissions of the status.txt file so that the PHP program can write to it (like unsetting readonly in Windows). Have a look around the documentation of your FTP app to find out how to change the chmod, and then set it 777 (although I'm pretty sure some web guru will tell me 777 isn't the best permission setting, but it should work for your purposes).

I personally use the Firefox addon FireFTP for this sort of stuff, and if you right click on the file and select properties you can set the chmod in there. I'd gather most FTP programs allow similar functionality.
#34 - vane
i dont really use an ftp program, i just get windows explorer and type [url]ftp://.[/url]..
Quote from DarkTimes :...set it 777 (although I'm pretty sure some web guru will tell me 777 isn't the best permission setting...

I would advise using 755, instead.
000 is the safest though.
#37 - gru
Quote from DarkTimes :You could use a password to make sure no ones abuses it

bad idea
someone could sniff this password, what would prevent him from "hacking" site by typing correct url?

i would use IP check instead, and maybe a HTTP_USER_AGENT?


<?php

...

if (isset($_GET['status']))
{
if($_SERVER['REMOTE_ADDR'] != $my_insim_ip)
die("Invalid IP");

if(strpos($_SERVER['HTTP_USER_AGENT'], $my_insim_name) === false)
die("Invalid client");

//save status
}

...

?>

If you just want to be able to see what is happening on your server through a web page, have a peek at this..if it is what you want, I will send you the code!
http://www.tenball.co.uk
Quote from JamesF1 :I would advise using 755, instead.

Thanks, I was gonna say 744, it's been a while ...

Quote from dawesdust_12 :000 is the safest though.

But that would be pointless for this program.

------------------------


<?php 
php

switch($_GET['q']) {
    case 
'SELECT':
        
header('HTTP/1.1 501 Not Implemented');
        
# header('HTTP/1.1 203 Non-Authoritative Information');
    
break;
    case 
'UPDATE':
        if (
            
$_GET['u'] != '2733B42119F16644345AAD33B34FC86A' # $_GET['u'] dose not equals MD5 hash of 'Dygear'.
            
||               # OR
            
$_GET['p'] != 'DC647EB65E6711E155375218212B3964' # $_GET['p'] dose not equals MD5 hash of 'Password'.
        
) {
            
header('HTTP/1.1 401 Unauthorized');
        }
        
header('HTTP/1.1 200 OK');
        
file_put_contents('status.txt'serialize($_GET['v'])); # Use file_get_contents() to read and unserialize() to turn it back into an array.
    
break;
    default:
        
header('HTTP/1.1 400 Bad Request');
    break;
}

?>

I'd really think it would be a better idea to use MySQL(i) tho over flat files. Bad JuJu with flat files, that's all.

The query string could look something like this ...
?q=UPDATE&u=Dygear&p=Password&v[Drivers][]=Dygear&v[Drivers][]=Filur&v[Track]=BL1
#41 - vane
im attempting to get this fireftp thing working but it keeps saying it cant connect :s can anyone help?
Quote from Dygear :The query string could look something like this ...
?q=UPDATE&u=Dygear&p=Password&v[Drivers][]=Dygear&v[Drivers][]=Filur&v[Track]=BL1

I wouldn't advise doing that, but rather taking the approach that gru suggested a few posts up, it's a much smarter way of handling it. Or even simply limiting the access to the file to one IP addres using .htaccess
#43 - vane
i put the chmod of the .txt file to 777 but it does not change anything, it still does not save "testing" to the folder
#44 - vane
heh, That reminds me. I need to start learning php. Probley will once I have the basic's of C++ out of the way. And well done vane. Little effort always pays off
#47 - vane
it just proves that searching google does help after all

im guessing ill have to use fopen with the GET thing?
#48 - vane
ok i am having a little difficulty with this, with some code someone (cant remember who posted it) posted earlier, i tried adding a string e.g TextBox1 but i can include strings or all the HTTP stuff underneath gets underlined, can anyone help me?

EDIT: cancel that bloody noob mistake

didnt add the "using system" thingies
Quote from JamesF1 :But also allows you no RWE access to anything

The most secure computer is one not connected to the internet and with no physical access.

But that's also the most useless computer from a networking standpoint

FGED GREDG RDFGDR GSFDG