PHP site - code correction or anything else?

Links for php scripts

Moderators: macek, egami, gesf

congthanh
New php-forum User
New php-forum User
Posts: 3
Joined: Sun Jul 17, 2005 7:54 pm
Location: Vietnam
Contact:

PHP site - code correction or anything else?

Postby congthanh » Sun Jul 17, 2005 8:13 pm

Dear all,
I'm quite new to PHP. I have downloaded a demo site from the Internet (as you may see the credit hereafter).
The launched site works well with the index page (which loads home.inc). But the other pages when buttons clicked,. the address name appears on the address bar but the content does not load (For example when I click about, it does not load the file "about.inc". Can anyone help me? This demo can be viewed at: http://www.tuyendunglaodong.com/php/ - Thank you very much.
Hoang Cong Thanh (thanh@hcongthanh.com)


<?

/* ################

~~ NOTICE ~~
use this code ASIS FREE
but you need to keep this
notice and other copyright
statements in place. Thank
you for your support.

-Ahmed info@aratech.net
simplex.aratech.net

###################
*/

/*
The IF statment will read the name of the file associated with the URL. it will then include the file matching
the click name.
*/

global $click2;

$parameters = explode("=", $_SERVER['REQUEST_URI']);
$click2= $parameters[1];
$click2 = str_replace('%20',' ', $click2);

$thisyear= date(Y); // this will automatically update the Copyright year notice
if (!$click2)
{
$text="data/home.inc";
include ("skin.html.inc");
}

else {
$text="data/$click2.inc";

if (!file_exists($text)) // check if file exist, if not include error file
{ $text="data/error.inc"; }

include ("skin.html.inc");
}

function readmyfile ($filename)
{
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = ''; // reset buffer
$message = fopen($filename, 'rb');
if ($message === false) { return false; }
while (!feof($message)) { $buffer = fread($message, $chunksize); }
fclose($message);
return $buffer;
}

function replaceUrl($mm)
{
while(strpos($mm, "[url")!==false)
{
$begUrl = strpos($mm, "[url");
$endUrl = strpos($mm, "[/url]");
$url = substr($mm, $begUrl, $endUrl-$begUrl+6);
$posBracket = strpos($url, "]");
if ($posBracket != null){
if ($posBracket == 4){
// [url]data[/url]
$link = substr($url, 5, $endUrl - $begUrl -5);
$htmlUrl = "<a href=\"$link.inc\">$link</a>";
}
}

$mm = str_replace($url, $htmlUrl, $mm);
}

echo $mm;

}

function explodeUrl($mm)
{
$items = explode("|", $mm);
$item_count= count($items);
$xcount=0;
while ($xcount<$item_count)
{
echo "<a href=\"?click=$items[$xcount]\" class=\"button\">&nbsp;$items[$xcount]&nbsp;</a>&nbsp;&nbsp;"; $xcount++;
}
}


?>

Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest