getFile(array(
'error' => 'error.tpl')
);
$template->add_vars(array(
'L_ERROR' => $lang['error'],
'DISPLAY' => $display)
);
$template->parse("error");
include($phphg_real_path . 'includes/page_footer.php');
exit();
} else {
$ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$sql = "SELECT ip FROM ".$prefix."_banned WHERE ip='$ip'";
$result = $db->query($sql);
$num2 = $db->num($result);
if($num2 > 0) {
include($phphg_real_path . 'includes/page_header.php');
$display = "Sorry but you were banned. Please contact the admin.";
$template->getFile(array(
'error' => 'error.tpl')
);
$template->add_vars(array(
'L_ERROR' => $lang['error'],
'L_DISPLAY' => $display)
);
$template->parse("error");
include($phphg_real_path . 'includes/page_footer.php');
exit();
} else {
$sql = "SELECT * FROM ".$prefix."_smilies";
$result = $db->query($sql);
while($row = $db->fetch($result)) {
if(!isset($smilie_code)) {
$smilie_code = array($row['code']);
} else {
array_push($smilie_code, $row['code']);
}
if(!isset($smilie_url)) {
$smilie_url = array($row['url']);
} else {
array_push($smilie_url, $row['url']);
}
if(!isset($smilie_name)) {
$smilie_name = array($row['name']);
} else {
array_push($smilie_name, $row['name']);
}
}
$code = count($smilie_code);
$url = count($smilie_url);
$sql = "SELECT * FROM ".$prefix."_filter";
$result = $db->query($sql);
while($row = $db->fetch($result)) {
if(!isset($filter_word)) {
$filter_word = array($row['word']);
} else {
array_push($filter_word, $row['word']);
}
if(!isset($filter_replace)) {
$filter_replace = array($row['replace']);
} else {
array_push($filter_replace, $row['replace']);
}
}
$word = count($filter_word);
$replace = count($filter_replace);
if(!isset($HTTP_GET_VARS['page'])) {
$page = 1;
} else {
$page = $HTTP_GET_VARS['page'];
}
$limit = $limit;
$from = ($page * $limit) - $limit;
$sql = "SELECT * FROM ".$prefix."_message ORDER BY 'date' DESC LIMIT $from,$limit";
$result = $db->query($sql);
$num = $db->num($result);
if($num < 1) {
include($phphg_real_path . 'includes/page_header.php');
$display = "There are no guestbook entires";
$template->getFile(array(
'error' => 'error.tpl')
);
$template->add_vars(array(
'L_ERROR' => $lang['error'],
'DISPLAY' => $display)
);
$template->parse("error");
include($phphg_real_path . 'includes/page_footer.php');
exit();
} else {
$entry = "";
while($row = $db->fetch($result)) {
$message = $row['message'];
$name = $row['username'];
$location = $row['location'];
$date = $row['date'];
$email = $row['email'];
$web_site = $row['website'];
$browser = $row['browser'];
$message2 = addslashes($message);
$name2 = addslashes($name);
$date = strtotime($date);
$post_date = date('D F d Y h:i:s', $date);
if($web_site == "") {
$website = "";
} else {
$website = "
";
}
for($i = 0; $i < $code; $i++) {
$image = "
";
$output = str_replace($smilie_code[$i], $image, $message2);
$message2 = $output;
}
for($j = 0; $j < $word; $j++) {
$output = str_replace($filter_word[$j], $filter_replace[$j], $message2);
$message2 = $output;
}
$template->add_block_vars("message", array(
'L_POST' => $lang['posted'],
'L_LOCATION' => $lang['location'],
'L_DATE' => $lang['date'],
'NAME' => $name2,
'LOCATION' => $location,
'BROWSER' => $browser,
'EMAIL' => $email,
'WEBSITE' => $website,
'DATE' => $post_date,
'MESSAGE' => $message2)
);
$entry .= "$lang[posted] " .$name2 . "
$lang[location] " .$location. "
$website | \r\n
$lang[date] " .$post_date . "
" . $message2 . " | \r\n
\r\n";
}
$sql2 = "SELECT count(*) FROM ".$prefix."_message";
$result2 = $db->query($sql2);
$total_results = $db->result($result2);
$total_pages = ceil($total_results / $limit);
if($page > 1) {
$pageprev = $page - 1;
$prev = "<< Prev ";
}
for($i = 1; $i <= $total_pages; $i++) {
if($page == $i) {
$pagenum .= "$i ";
} else {
$pagenum .= "$i ";
}
}
if($page < $total_pages) {
$pagenext = $page + 1;
$next = "Next >> ";
}
include($phphg_real_path . 'includes/page_header.php');
$template->getFile(array(
'index' => 'index.tpl')
);
$template->add_vars(array(
'L_NAME' => $lang['name'],
'L_COMMENTS' => $lang['comments'],
'PREV' => $prev,
'PAGENUM' => $pagenum,
'NEXT' => $next)
);
$template->parse("index");
include($phphg_real_path . 'includes/page_footer.php');
}
}
}
?>