PDA

View Full Version : Probably easy, But I'm a newbie! QUICK QUESTION



Copernicus
January 26th, 2005, 01:30 PM
I have been dabbling in PHP and messin around with things, I really like it, tho it is a little tricky to understand.

However, I have a piece of script I just can't wrap my head around.
I know how to do a simple redirect in php, however, how can I make it redirect to the specified page at the bottom of this code? It's probably pretty easy, but I have no clue, it has been stumping me for days already (literally)


<?php/** generate_url.php** Script for generating URLs that can be accessed one single time.**//* Generate a unique token: */$token = md5(uniqid(rand(),1));/* This file is used for storing tokens. One token per line. */$file = "/tmp/urls.txt";if( !($fd = fopen($file,"a")) ) die("Could not open $file!");if( !(flock($fd,LOCK_EX)) ) die("Could not aquire exclusive lock on $file!");if( !(fwrite($fd,$token."\n")) ) die("Could not write to $file!");if( !(flock($fd,LOCK_UN)) ) die("Could not release lock on $file!");if( !(fclose($fd)) ) die("Could not close file pointer for $file!");/* Parse out the current working directory for this script. */$cwd = substr(
%4$s SERVER['PHP_SELF'],0,strrpos(
%4$s SERVER['PHP_SELF'],"/"));/* Report the one-time URL to the user: */print "Use this URL to download the secret file:<br><br>\n";print "<a href='http://".
%4$s SERVER['HTTP_HOST']. "$cwd/get_file.php?q=$token'>\n";print "http://".
%4$s SERVER['HTTP_HOST']."/get_file.php?q=$token</a>\n";?> Any input would be greatly appreciated, If you have the time to briefly explain why this is, that would be awesome.CG