/*
Script name : index.php
Scriptor : Denny Harianto
Date : January 5, 2007
Modified : January 5, 2007
Project : Rexplast
*/
session_start();
$idsession = session_id();
require("includes/functions.php");
function cetakcontent()
{ $query = "select content
from content
where id='1'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$t = $row['content'];
return $t;
}
function cetakproduct()
{
$q = "select count(*) as jrec from product
";
$r = mysql_query($q);
$row = mysql_fetch_array($r);
$jrec = $row['jrec'];
$trandom = mt_rand(0, $jrec-1);
$q = "select * from product
limit $trandom, 1
";
$r = mysql_query($q);
$row = mysql_fetch_array($r);
$tthumbnail = "
";
$tdesc = "{$row['name']}
{$row['shortdesc']}
";
$tdetail = "";
$t = '
| ' . $tthumbnail . ' |
|
| ' . $tdetail . ' |
';
return $t;
}
// main program
myconnect();
useronline();
$t = '';
$fp = fopen("template-index.html", "r");
while (!feof($fp))
{ $buffer = fgets($fp, 4096);
include('common.php');
if (strstr($buffer,"{Product}"))
{ $buffer = str_replace("{Product}", cetakproduct(), $buffer);
}
$t .= $buffer;
}
print $t;
mysql_close($db);
?>