<?php
/*
myPHP Guestbook
Copyright (C) 2003 - 2006 Claudio Pose
myPHP Guestbook is a open source project of Networkarea.ch
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
include("config.inc.php");
include("functions.inc.php");
connect();
$sql_properties = mysql_query("SELECT
bbcode,
deactivate_html,
default_style,
default_template,
entries_per_site,
guestbook_status,
guestbook_title,
links_in_sitefunction,
max_word_length,
release_entries,
show_ip,
smilies,
statistic,
statistic_ban
FROM
".$table."_properties");
$properties = mysql_fetch_assoc($sql_properties);
$default_style = $properties['default_style'];
$sql_template = mysql_query("SELECT
bgcolor,
bgimage,
border,
cellpadding,
cellspacing,
html,
image_email,
image_homepage,
tablealign,
tablewidth,
tdcolor,
td2color
FROM
".$table."_template
WHERE
id='".$properties['default_template']."'");
$template = mysql_fetch_assoc($sql_template);
if ($properties['statistic']) {
include("stats.inc.php");
}
$sql_count_entries = "SELECT
id
FROM
".$table."_entries";
if (isset($properties['release_entries']) AND $properties['release_entries'] == 1) {
$sql_count_entries .= " WHERE status='1'";
}
$query_count_entries = mysql_query($sql_count_entries);
$count_entries = mysql_num_rows($query_count_entries);
include("lang.inc.php");
if (isset($_GET['page'])) {
if (!is_numeric($_GET['page']) OR empty($_GET['page'])) {
$page = 1;
} else {
$page = $_GET['page'];
}
} else {
$page = 1;
}
$page = mysql_escape_string($page);
$pages_total = ceil($count_entries/$properties['entries_per_site']) ;
$page_start = floor($page - $properties['links_in_sitefunction']/2) ;
$page_start = $page_start <= 0 ? 1 : $page_start ;
$page_end = ($page_start + $properties['links_in_sitefunction']-1) ;
$page_end = $page_end >= $pages_total ? $pages_total : $page_end ;
$page_max = $page*$properties['entries_per_site'];
$max_minus_per_page = $page_max-$properties['entries_per_site'];
$page_entry_start = $count_entries-$max_minus_per_page+1;
echo "<?xml version=\"1.0\" encoding=\"".$encoding."\" ?>
<!DOCTYPE html
PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"".$lang_short."\" lang=\"".$lang_short."\"><head>
<style type=\"text/css\">
<!-- ";
getStyle();
echo " //-->
</style>
<title>".$properties['guestbook_title']."</title>
</head>";
if ($template['bgimage'] == "") {
echo "<body bgcolor=\"".$template['bgcolor']."\" onload=\"parent.resize_me('guestbook')\">";
}
if ($template['bgimage'] != "") {
echo "<body bgcolor=\"".$template['bgcolor']."\" background=\"".$template['bgimage']."\" onload=\"parent.resize_me('guestbook')\">";
}
if ($properties['guestbook_status']) {
echo "<div align=\"".$template['tablealign']."\">".$ms[16]."<br /><b><a href=\"".$url."insert.php";
if (isset($get_lang)) {
echo "?lang=".$_GET['lang']."";
}
echo "\" title=\"".$ms[17]."\">".$ms[17]."</a></b><br /><br />";
if ($page > 1) {
$page_minus = $page-1;
echo " <a href=\"".$url."/index.php?page=".$page_minus."";
if ($get_lang) {
echo "&lang=".$_GET['lang']."";
}
echo "\"><img src=\"".$url."/images/links.gif\" alt=\"".$ms[6]."\" border=\"0\" /></a>";
}
if ($page_start > 1) {
echo " <a href=\"".$url."/index.php?page=1";
if ($get_lang) {
echo "&lang=".$_GET['lang']."";
}
echo "\">1</a> ...";
}
for ($i = $page_start; $i <= $page_end ;$i++) {
if ($i == $page) {
echo "<b>".$i."</b>";
} else {
echo " <a href=\"".$url."/index.php?page=".$i."";
if ($get_lang) {
echo "&lang=".$_GET['lang']."";
}
echo "\">".$i."</a> ";
}
}
if ($page_end < $pages_total) {
echo " ... <a href=\"".$url."/index.php?page=".$pages_total."";
if ($get_lang) {
echo "&lang=".$_GET['lang']."";
}
echo "\">".$pages_total."</a>";
}
if ($page < $pages_total) {
$page_plus = $page+1;
echo " <a href=\"".$url."/index.php?page=".$page_plus."";
if ($get_lang) {
echo "&lang=".$_GET['lang']."";
}
echo "\"><img src=\"".$url."/images/rechts.gif\" alt=\"".$ms[18]."\" border=\"0\" /></a>";
}
echo "</div>
<br />";
if ($properties['release_entries']) {
$sql_entries = mysql_query("SELECT
comment,
date,
email,
homepage,
icq,
id,
ip,
name,
text,
time
FROM
".$table."_entries
WHERE
status='1'
ORDER BY
id DESC
LIMIT
".(($page-1)*$properties['entries_per_site'] ).",".$properties['entries_per_site']."");
} else {
$sql_entries = mysql_query("SELECT
comment,
date,
email,
homepage,
icq,
id,
ip,
name,
text,
time
FROM
".$table."_entries
ORDER BY
id DESC
LIMIT
".(($page-1)*$properties['entries_per_site'] ).",".$properties['entries_per_site']."");
}
while ($entries = mysql_fetch_assoc($sql_entries)) {
$page_entry_start = $page_entry_start-1;
if ($properties['deactivate_html']) {
$entries['text'] = htmlentities($entries['text']);
}
$email = $entries['email'];
$entries['comment'] = nl2br($entries['comment']);
$entries['email'] = strip_tags($entries['email']);
$entries['email'] = noSpam($entries['email']);
$entries['email'] = stripslashes($entries['email']);
$entries['homepage'] = stripslashes($entries['homepage']);
$entries['homepage'] = strip_tags($entries['homepage']);
$entries['homepage'] = htmlentities($entries['homepage']);
$entries['id'] = $page_entry_start;
$entries['name'] = htmlentities($entries['name']);
$entries['name'] = stripslashes($entries['name']);
$entries['text'] = badwords($entries['text']);
$entries['text'] = shortWords($entries['text'], $properties['max_word_length']);
$entries['text'] = nl2br($entries['text']);
$entries['text'] = stripslashes($entries['text']);
if ($properties['bbcode']) {
$entries['text'] = bbcode($entries['text']);
$entries['comment'] = bbcode($entries['comment']);
}
if ($properties['smilies']) {
$entries['text'] = smilies($entries['text']);
$entries['comment'] = smilies($entries['comment']);
}
$template_data = $template['html'];
$template_data = str_replace("<\$border\$>", $template['border'], $template_data);
$template_data = str_replace("<\$cellpadding\$>", $template['cellpadding'], $template_data);
$template_data = str_replace("<\$cellspacing\$>", $template['cellspacing'], $template_data);
$template_data = str_replace("<\$date\$>", $entries['date'], $template_data);
$template_data = str_replace("<\$id\$>", $entries['id'], $template_data);
$template_data = str_replace("<\$name\$>", $entries['name'], $template_data);
$template_data = str_replace("<\$tablealign\$>", $template['tablealign'], $template_data);
$template_data = str_replace("<\$tablewidth\$>", $template['tablewidth'], $template_data);
$template_data = str_replace("<\$tdcolor\$>", $template['tdcolor'], $template_data);
$template_data = str_replace("<\$td2color\$>", $template['td2color'], $template_data);
$template_data = str_replace("<\$text\$>", $entries['text'], $template_data);
$template_data = str_replace("<\$time\$>", $entries['time'], $template_data);
if ($entries['comment']) {
$template_data = str_replace("<\$comment\$>", "<br /><br /><table cellpadding=\"2\" cellspacing=\"1\" align=\"center\" width=\"95%\" class=\"guestbook_table\"><tr><td bgcolor=\"".$template['tdcolor']."\" align=\"left\"><b>".$ms[116].":</b><br />".$entries['comment']."</td></tr></table>", $template_data);
} else {
$template_data = str_replace("<\$comment\$>", "", $template_data);
}
if ($properties['show_ip']) {
$template_data = str_replace("<\$ip\$>", "IP: ".$entries['ip']."<br />", $template_data);
} else {
$template_data = str_replace("<\$ip\$>", "", $template_data);
}
if ($entries['email'] == "") {
$template_data = str_replace("<\$email\$>", "", $template_data);
$template_data = str_replace("<\$email_icon\$>", "", $template_data);
} else {
$template_data = str_replace("<\$email\$>", "<a href=\"mailto:".$entries['email']."\" title=\"".$entries['email']."\">".$entries['email']."</a>", $template_data);
$template_data = str_replace("<\$email_icon\$>", "<a href=\"mailto:".$entries['email']."\"><img src=\"".$url."/images/icons/email/".$template['image_email']."\" border=\"0\" alt=\"".$entries['email']."\" /></a>", $template_data);
}
if ($entries['homepage'] == "" OR $entries['homepage'] == "http://") {
$template_data = str_replace("<\$homepage\$>", "", $template_data);
$template_data = str_replace("<\$homepage_icon\$>", "", $template_data);
} else {
$template_data = str_replace("<\$homepage\$>", "<a href=\"".$entries['homepage']."\" title=\"".$entries['homepage']."\">".$entries['homepage']."</a>", $template_data);
$template_data = str_replace("<\$homepage_icon\$>", "<a href=\"".$entries['homepage']."\" target=\"_blank\"><img src=\"".$url."/images/icons/homepage/".$template['image_homepage']."\" border=\"0\" alt=\"".$entries['homepage']."\" /></a>", $template_data);
}
if ($entries['icq'] == 0) {
$template_data = str_replace("<\$icq\$>", "", $template_data);
$template_data = str_replace("<\$icq_icon\$>", "", $template_data);
} else {
$template_data = str_replace("<\$icq\$>", "<a href=\"http://web.icq.com/whitepages/about_me?Uin=".$entries['icq']."\">".$entries['icq']."</a>", $template_data);
$template_data = str_replace("<\$icq_icon\$>", "<a href=\"http://web.icq.com/whitepages/about_me?Uin=".$entries['icq']."\" target=\"_blank\"><img src=\"http://wwp.icq.com/scripts/online.dll?icq=".$entries['icq']."&img=5\" border=\"0\" alt=\"".$entries['icq']."\" /></a>", $template_data);
}
echo "<div align=\"".$template['tablealign']."\">
".$template_data."
</div>";
}
echo "<p align=\"".$template['tablealign']."\">";
if ($page > 1) {
$page_minus = $page-1;
echo " <a href=\"".$url."/index.php?page=".$page_minus."";
if ($get_lang) {
echo "&lang=".$_GET['lang']."";
}
echo "\"><img src=\"".$url."/images/links.gif\" alt=\"".$ms[6]."\" border=\"0\" /></a>";
}
if ($page_start > 1) {
echo " <a href=\"".$url."/index.php?page=1";
if ($get_lang) {
echo "&lang=".$_GET['lang']."";
}
echo "\">1</a> ...";
}
for ($i = $page_start; $i <= $page_end ;$i++) {
if ($i == $page) {
echo "<b>".$i."</b>";
} else {
echo " <a href=\"".$url."/index.php?page=".$i."";
if ($get_lang) {
echo "&lang=".$_GET['lang']."";
}
echo "\">".$i."</a> ";
}
}
if ($page_end < $pages_total) {
echo " ... <a href=\"".$url."/index.php?page=".$pages_total."";
if ($get_lang) {
echo "&lang=".$_GET['lang']."";
}
echo "\">".$pages_total."</a>";
}
if ($page < $pages_total) {
$page_plus = $page+1;
echo " <a href=\"".$url."/index.php?page=".$page_plus."";
if ($get_lang) {
echo "&lang=".$_GET['lang']."";
}
echo "\"><img src=\"".$url."/images/rechts.gif\" alt=\"".$ms[18]."\" border=\"0\" /></a>";
}
echo '</p>';
} else {
echo "<b>".$ms[34]."</b>";
}
echo "</body>
</html>";
?>