<?php
/************************************
* Cadence
* Remotely Hosted Guestbook Script.
* (c) 2006, Dennis Pedrie
* www.CadenceBook.com
* idx.php
***********************************
* Cadence Guestbook is licensed under
* a Creative Commons License.
* More information is available by visiting
* http://creativecommons.org/licenses/by/3.0/
* or the LICENSE file in the Cadence Root Folder
***********************************/
##### 15 PER PAGE!!! ###
if(!defined('IN_CADENCE')) {
trigger_error("You may not access this file directly",E_USER_ERROR);
}
//Header
$tpl->display($gbook->style .'/header.tpl',$book);
// Build bbCode Tags
include "class/bbcode.php";
$bbcode = new bbcode;
$bbcode_query = $db->get_results("SELECT * FROM ". TABLE_PREFIX ."bbcode WHERE bbc_enabled = 1");
foreach($bbcode_query as $bbc) {
$new_tag = array(
'Name' => $bbc->bbc_key,
'HasParam' => ($bbc->bbc_has_param == 1) ? true : false,
'ParamRegex' => ($bbc->bbc_param_regex == 'false') ? "[^\\]]+" : $bbc->bbc_param_regex,
'HtmlBegin' => $bbc->bbc_html_start,
'HtmlEnd' => $bbc->bbc_html_end,
'ParamRegexReplace' => ($bbc->bbc_param_regex_replace != '') ? unserialize($bbc->bbc_param_regex_replace) : array(),
'HasEnd' => ($bbc->bbc_has_end == 1) ? true : false);
echo $bbcode->add_tag($new_tag);
}
//Query for Posts
$query = $db->get_results($q->getposts($book));
//Content
if($db->num_rows > 0) {
foreach($query as $query) {
$vars = array(
'id' => $query->post_id,
'ip' => $query->post_ip,
'author' => $query->post_author,
'is_user' => $query->post_is_gbook_user,
'date' => date("M d, Y g:i A", $query->post_date),
'content' => nl2br($bbcode->parse_bbcode($query->post_content)),
'browser' => $query->post_browser,
'hash' => $query->post_hash,
'email' => $query->post_email,
'editlink' => "index.php?book=$book&act=admin&do=posts&code=edit&id=$query->post_id",
'deletelink' => "javascript:delete_post('index.php?book=$book&act=admin&acpact=posts&delete=". $query->post_id ."&auth=". $query->post_hash ."')",
'iplink' => 'index.php?book='. $book .'&act=admin&acpact=users&do=iplookup&ip='.$query->post_ip);
$tpl->assign("post",$vars);
//Display the template.
$tpl->display($gbook->style .'/post.tpl');
}
}
else {
echo "<strong>No Posts Available</strong><br />";
}
if(!$gbook->logged && $CONFIG['use_captcha']) {
// Create CAPTCHA
include "class/captcha/hn_captcha.class.X1.php";
$captcha =& new hn_captcha_x1($CAPTCHA);
if($captcha->garbage_collector_error) {
// Error! (Counter-file or deleting lost images)
echo "An error has occured";
exit;
}
switch($captcha->validate_submit()) {
// was submitted and has valid keys
case 1:
//Show Comment Form
$tpl->display($gbook->style .'/commentform.tpl');
break;
// was submitted with no matching keys, but has not reached the maximum try's
case 2:
echo $captcha->display_form();
break;
// was submitted, has bad keys and also reached the maximum try's
case 3:
//if(!headers_sent() && isset($captcha->badguys_url)) header('location: '.$captcha->badguys_url);
echo "<p><br>Reached the maximum try's of ".$captcha->maxtry." without success!";
echo "<br><br><a href=\"".$_SERVER['PHP_SELF']."?download=yes&id=1234\">New DEMO</a></p>";
break;
// was not submitted, first entry
default:
echo $captcha->display_form();
break;
}
}
else {
//Show Comment Form
$tpl->display($gbook->style .'/commentform.tpl');
}
//Footer
$tpl->display($gbook->style .'/footer.tpl');
?>