كود PHP:
<?
/*
Script: Topic.php
Descrip: Simple Topic Getter.
Other: This script is written by MOBARMEG [@] Hotmail [.] Com
*/
// ####### Connect 2 db #######
Mysql_pconnect('localhost', 'user', 'pass');
Mysql_select_db('name');
// ####### Templates #######
$tmp = '<a href="'.$_SERVER['PHP_SELF'].'?cid={CID}&tid={TID}">{TITLE}</a><br />';
$tmp2 = '<b>{TITLE}</b> <br /> <i>{TEXT}</i>';
$err = 'لم يتم العثور على الموضوع!';
// ####### Start Script #######
$cid = Addslashes(Strip_tags($_GET['cid']));
$tid = Addslashes(Strip_tags($_GET['tid']));
if(empty($cid) || empty($tid) || !is_numeric($cid) || !is_numeric($tid))
{
$query = Mysql_query("SELECT * FROM topics")
Or Die(Mysql_error());
while($row = Mysql_fetch_object($query))
{
$cid = $row->cid;
$tid = $row->tid;
$title = Stripslashes($row->title);
$out = str_replace('{CID}', $cid, $tmp);
$out = str_replace('{TID}', $tid, $out);
$out = str_replace('{TITLE}', $title, $out);
echo $out;
}
}
else
{
$query = Mysql_query("SELECT * FROM topics WHERE cid='$cid' AND tid='$tid'");
if(Mysql_num_rows($query) <= 0)
Die($err);
$row = Mysql_fetch_object($query);
$title = Stripslashes($row->title);
$text = Stripslashes($row->text);
$out = $tmp2;
$out = str_replace('{TITLE}', $title, $out);
$out = str_replace('{TEXT}', $text, $out);
echo $out;
}
?>