The online racing simulator
#51 - vane
im having a bit of trouble loading it onto the website :S tried fopen with fread and fget and a whole load more but cant get it to read the first line from status.txt
This is a simple way to read line-by-line. There are a few things you'll have to work out yourself, as I'm not going to do it all for you.


$handle = fopen("bla.txt", "r");
while ( !feof($handle) )
{
$single_line = fgets($handle);
echo $single_line;
}

fclose($handle);

Quote from JamesF1 :This is a simple way to read line-by-line. There are a few things you'll have to work out yourself, as I'm not going to do it all for you.


$handle = fopen("bla.txt", "r");
while ( !feof($handle) )
{
$single_line = fgets($handle);
echo $single_line;
}

fclose($handle);


or


<?php 
foreach (file('bla.txt') as $line)
   echo 
$line;
?>

Quote from JamesF1 :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

So, you don't like the user name, password part. How about the query string? It is well formed, and placed in the right hands would mean a lot less code. hell, you could even pass plid / uid / cid thought as the key for each member. You could go even more in depth later on as to add what lap they are on ect, ect, ect.

Now the only issue is that 4,000 chars (or 2,000 if your using IE as your browser) is the safe limit for URL length. How ever, the specification of the HTTP protocol does not specify any maximum length, but the server software it self some times has limits. Such as Apache with the lowest of 4000 chars, Perl HTTP:aemon with around 8,000 chars, and IIS with 16,384 chars. Anything more they tend to spew out a "413 Entity Too Large" error.

How ever, if we really get to this point, we should really look into using POST to send our variables.
-
(gru) DELETED by gru
#54 - vane
thanks for all the help! hate to nag but would there be any way of reading and writing to a specific line in a .txt file eg writing something onto line 17 then reading from line 17?
Quote from vane :thanks for all the help! hate to nag but would there be any way of reading and writing to a specific line in a .txt file eg writing something onto line 17 then reading from line 17?


<?php 
function config_parser_read($file)
{    
# Function Returns array(0 => Array('Key' => 'KeyName', 'Val' => 'Value'), ect...); (PHP4)
    
foreach (file($file) as $line => $data)
        list(
$return[$line]['key'][], $return[$line]['val'][]) = split('='$data2);
}
function 
config_parser_write($file$path)
{    
# Function expects an array like that found in the config_parser_read function. (PHP5)
    
foreach ($file as $line $data)
        
$file $file[$line] = implode($data'=');
    
$file implode($filePHP_EOL);
    return 
file_put_contents($file$path);
}
// Change only one line in the config.
$line 12;
$key 'AdminPass';
$val 'Scawen';
$file config_parser_read('config.ini');
$file[$line] = array('Key' => $key'Val' => $val);
?>

This is all from memory, so there is really no guarantee this will work. Test it, before you use it.
#56 - vane
i don't quite understand what to do with this :s could you tell me the basics of it?
#58 - vane
your back! welcome back sean!
#59 - sun
Couldnt you just create a txt file and put in it 'online' then in the insim do like a read off the txt file then do it in the msg ? or in website my bro knows php and php can read txt files by just simply creating a txt file and putting the opening of a php sign then put online or what ever in it so php coding in a txt file then the site will read it.


VERY SIMPLE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Sun.

That makes no sense. What I can grasp from your saying, is you want to use a .txt file as a PHP Includes, which wouldn't really work at all.
Quote from dawesdust_12 :Sun.

That makes no sense. What I can grasp from your saying, is you want to use a .txt file as a PHP Includes, which wouldn't really work at all.

I think he meant read, from an online location.
Sun, the only real problem with your idea would be that not all servers allow the file_get_contents function, as well as any file function within PHP, to connect to a remote server. But the idea it's self is a sound one, if I understand it correctly.

From what I understand he meant:
  1. Make 'an insim' that places a txt file on the web. (This can be done via a command, or on each STA packet).
  2. Have a php program then read that file, and parse it.
    • I would like to point out that you should respect HTTP file headers in this case.
    • If you get a no content changed message, then there is no reason to redownload that file.
    • Also, you should really place the script on a CRON or something so you don't pound the file on each page view.

FGED GREDG RDFGDR GSFDG