Page Navigation
Many people have asked me how i got index2.php?page=link
Basically what happens, is where ever the following code is put on your main php page, is where the the page link.php will go.
|
<?php
if (! file_exists("$page.php")) { include("updates.php"); } else { include("$page.php"); } ?> |
So. This code should go where you would like the content of link.php to go, in your main php file.
After you have correctly done everything, if you get a '404' updates.php will show up by default, although you can change this.you do not have to have a file named page.php.
In the page which will be included, all of everything from the main php file will also be included there. EG - font tags.
Then just rename your links to (yourfile).php?page=whatever
Online Users
Quite a long script for such a small result.
Create a new file leave it blank, but save it as usersonline.txt
Now make a new file, and add the following script:
|
<?
$remote = $_SERVER["REMOTE_ADDR"]; $file = "usersonline.txt"; $timeoutseconds = 60; //how long the user stays on, before classed offline which can be changed $timestamp = time(); $timeout = ($timestamp-$timeoutseconds); $fp = fopen("$file", "a+"); $write = $remote."||".$timestamp."n"; fwrite($fp, $write); fclose($fp); $online_array = array(); $file_array = file($file); foreach($file_array as $newdata){ list($ip, $time) = explode("||", $newdata); if($time >= $timeout){ array_push($online_array, $ip); } } $online_array = array_unique($online_array); $online = count($online_array); if($online == "1"){ echo "Users Online: $online"; }else{ echo "Users Online: $online"; } ?> |
Save this as usersonline.php
Now, once you have uploaded both files, and chmoded usersonline.txt to 777. You should include the following script where you would like the number of users online to show up:
|
<?
include("usersonline.php"); ?> |
Chmod
Many people think chmod is really difficult and cant seem to realise how to do it. maybe this will help. If you see every collumn (goes up and down) as the first number. the seccond collumn as the 2nd number, and the 3rd collumn as the third number.
The top row of numbers is a 4. The middle is a 2. the bottom is a 1. so there i would have 644: 4+2 for the first letter. 4 for the next. and 4 for the last. so... based on the information ive just told you. what would the following CHMOD be?
The answer is 776
If you are stuck on why.. think about it. the first column. 4+2+1 = 7 the 2nd. 4+2+1 = 7 and the third 4+2 = 6

