How its exactly function that all system?
Not exactly sure what you are asking here...
The script is really simple. I'll walk you through it:
1. Opens the list of links into an array, where each element is a single link.
$linksfile ="urlrotator.txt";
$urls = file("$linksfile");
2. Removes the end line characters to prevent possible errors.
$urls=str_replace('\n','',$urls);
3. Uses the array_shift function to remove the first link from the array. This is the one that you are redirected to in the last line.
$goto=array_shift($urls);
4. Puts this link onto the end of the array using array_push. Note that the first link is now at the bottom of the list, and the next sequential link is at the top of the list.
array_push($urls,$goto);
5. Makes the array into a string separated by new lines '\n'.
$strurls=implode('\n',$urls);
6. Replaces the old list of links with this modified one.
$handle=fopen($linksfile,"w");
fwrite($handle,$strurls);
fclose($handle);
7. Performs the redirection.
header("Location: $goto");
Since the link that was redirected to is moved to the bottom of the array, there is no "end"--the function continues to cycle through the list of links each time it is called.
?>