Author |
Message |
|
Thanks for spotting that one! Works a treat now.
|
|
|
Hi. I've added Carbonize's Image verification script to Advanced Guestbook 2.3.1 - when I go to addentry.php I get the following error:
Parse error: parse error, unexpected $ in /home/********/public_html/guestbook/addentry.php on line 40
The code for this file is:
<?php
include("verify.php");
$include_path = dirname(__FILE__);
include_once $include_path."/admin/config.inc.php";
include_once $include_path."/lib/$DB_CLASS";
include_once $include_path."/lib/image.class.php";
include_once $include_path."/lib/template.class.php";
include_once $include_path."/lib/vars.class.php";
include_once $include_path."/lib/add.class.php";
$gb_post = new addentry($include_path);
if (isset($HTTP_POST_VARS["gb_action"])) {
if (isset($HTTP_POST_VARS["gb_action"])) {
if (strtoupper($_POST["keycode"])!=$Vword)
{
echo ("The <strong>Image Verication</strong> code you supplied is incorrect.<br />\nPlease enter the 8 characters that appear in the image.");
echo $gb_post->process();
die();
}
$gb_post->Vrand = $Vrand;
$gb_post->name = (isset($HTTP_POST_VARS["gb_name"])) ? $HTTP_POST_VARS["gb_name"] : '';
$gb_post->email = (isset($HTTP_POST_VARS["gb_email"])) ? $HTTP_POST_VARS["gb_email"] : '';
$gb_post->url = (isset($HTTP_POST_VARS["gb_url"])) ? $HTTP_POST_VARS["gb_url"] : '';
$gb_post->comment = (isset($HTTP_POST_VARS["gb_comment"])) ? $HTTP_POST_VARS["gb_comment"] : '';
$gb_post->location = (isset($HTTP_POST_VARS["gb_location"])) ? $HTTP_POST_VARS["gb_location"] : '';
$gb_post->icq = (isset($HTTP_POST_VARS["gb_icq"])) ? $HTTP_POST_VARS["gb_icq"] : '';
$gb_post->aim = (isset($HTTP_POST_VARS["gb_aim"])) ? $HTTP_POST_VARS["gb_aim"] : '';
$gb_post->gender = (isset($HTTP_POST_VARS["gb_gender"])) ? $HTTP_POST_VARS["gb_gender"] : '';
$gb_post->userfile = (isset($HTTP_POST_FILES["userfile"]["tmp_name"]) && $HTTP_POST_FILES["userfile"]["tmp_name"] != "") ? $HTTP_POST_FILES : '';
$gb_post->user_img = (isset($HTTP_POST_VARS["gb_user_img"])) ? $HTTP_POST_VARS["gb_user_img"] : '';
$gb_post->preview = (isset($HTTP_POST_VARS["gb_preview"])) ? 1 : 0;
$gb_post->private = (isset($HTTP_POST_VARS["gb_private"])) ? 1 : 0;
echo $gb_post->process($HTTP_POST_VARS["gb_action"]);
} else {
echo $gb_post->process();
}
?>
|
|
|
Sorry, I meant that the page for adding comments will stand on its own!! The comments themselves will be under the post.
I'm glad you like the design! It was really fiddly and has taken a long time to perfect.
Don't worry about the real pros. You've been more than helpful to me
|
|
|
Thanks for all your help with this. I take your point that I might need to post comments so I'm going to leave it the way it is (after all, it works and looks how I want it) and make comments password-protected to be added by admins only, and perhaps a message to say that comments are only allowed from admins. The comments page will stand on its own and not look like the rest of the site but I'm sure it doesn't matter too much. But if I could get it to pop-up, close and reload in the main window it would be good!!!!
|
|
|
Perhaps I am trying too hard, but what annoys me is that I can integrate the index.php and addentry.php files with no problem but not the comment.php. In other words, I am 2 thirds of the way there, just need the other third.
Another idea. Is there any way of turning the comment feature off? This could be good for me as well as on another site I designed people used it for spamming. Any ideas?
|
|
|
Er...no! Didn't realise that was what it was for.
|
|
|
Nice. Actually what I want to do is remove the drop-down menu. I don't need it and would rather leave it out. Which files do I have to edit and what do I have to do?
|
|
|
Ok. I didn't really want to post the link yet as it's a site under development but if you can help it would be worthwhile and you can see what I mean.
The link is:
http://www.webciter.org/guestbook/ - try adding a comment to my test post and you'll see the errors.
|
|
|
Because I do not want to have the Guestbook as a standalone page! I already have a site with around 20 pages that I want to integrate the Guestbook into. Like the proxy2.de web site - the PHPBB forum is part of the exitsing page layout not in its own.
Am I making sense?
|
|
|
I'm having so much hassle with the comment.php page. In the event that I can't work out how to fix it I've come up with another idea: the page works OK if I use it as a standalone page but not when I include the code into an existing page on my site.
So, how could I modify it so that the comment.php page loads up as a new window, resized to fit the form it contains, which then closes open submitting the comment and then redirects to the existing index.php page (ie. not in the new window)?? I know it can be done with Javascript but I'm not sure what needs to be altered with the Guestbook to make it work.
|
|
|
BTW, this is code for comment.class.php:
line 175 that it says the error occurs on is in red, way down at the bottom of the page:
<?php
/**
* ----------------------------------------------
* Advanced Guestbook 2.3.1 (PHP/MySQL)
* Copyright (c)2001 Chi Kien Uong
* URL: http://www.proxy2.de
* ----------------------------------------------
*/
class gb_comment {
var $comment;
var $ip;
var $id;
var $db;
var $user;
var $pass_comment;
var $template;
var $path;
function gb_comment($path='') {
global $HTTP_SERVER_VARS;
if (isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']) && !empty($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) {
$this->ip = $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'];
} else {
$this->ip = getenv("REMOTE_ADDR");
}
$this->db = new guestbook_vars($path);
$this->db->getVars();
$this->path = $path;
$this->template =& $this->db->template;
}
function is_valid_id() {
$this->db->query("select id from ".$this->db->table['data']." WHERE (id = '$this->id')");
$this->db->fetch_array($this->db->result);
return ($this->db->record) ? true : false;
}
function comment_form() {
global $GB_UPLOAD, $GB_PG;
$this->db->query( "select x.*, y.p_filename, y.width, y.height from ".$this->db->table['data']." x left join ".$this->db->table['pics']." y on (x.id=y.msg_id and y.book_id=2) WHERE (id = '$this->id')");
$row = $this->db->fetch_array($this->db->result);
$LANG =& $this->db->LANG;
$VARS =& $this->db->VARS;
$DATE = $this->db->DateFormat($row['date']);
$MESSAGE = nl2br($row['comment']);
$id = $this->id;
$bgcolor = $this->db->VARS['tb_color_1'];
$COMMENT ='';
if ($row['p_filename'] && ereg("^img-",$row['p_filename'])) {
$img = new gb_image();
$img->set_border_size($this->db->VARS["img_width"], $this->db->VARS["img_height"]);
$new_img_size = $img->get_img_size_format($row['width'], $row['height']);
if (file_exists("$this->path/$GB_UPLOAD/t_$row[p_filename]")) {
$row['p_filename'] = "t_$row[p_filename]";
}
eval("\$USER_PIC = \"".$this->template->get_template($this->db->GB_TPL['image'])."\";");
} else {
$USER_PIC = '';
}
if ($this->db->VARS["smilies"] == 1) {
$MESSAGE = $this->db->emotion($MESSAGE);
}
if (!$row['location']) {
$row['location'] = "-";
}
if ($row['url']) {
eval("\$URL = \"".$this->template->get_template($this->db->GB_TPL['url'])."\";");
} else {
$URL = '';
}
if ($row['icq'] && $this->db->VARS["allow_icq"]==1) {
eval("\$ICQ = \"".$this->template->get_template($this->db->GB_TPL['icq'])."\";");
} else {
$ICQ = '';
}
if ($row['aim'] && $this->db->VARS["allow_aim"]==1) {
eval("\$AIM = \"".$this->template->get_template($this->db->GB_TPL['aim'])."\";");
} else {
$AIM = '';
}
if ($row['email']) {
eval("\$EMAIL = \"".$this->template->get_template($this->db->GB_TPL['email'])."\";");
} else {
$EMAIL = '';
}
if ($this->db->VARS["allow_gender"]==1) {
$GENDER = ($row['gender']=="f") ? " <img src=\"$GB_PG[base_url]/img/female.gif\" width=\"12\" height=\"12\">" : " <img src=\"$GB_PG[base_url]/img/male.gif\" width=\"12\" height=\"12\">";
} else {
$GENDER = '';
}
if ($this->db->VARS["show_ip"] == 1) {
$hostname = ( eregi("^[-a-z_]+", $row['host']) ) ? "Host" : "IP";
$HOST = "$hostname: $row[host]\n";
} else {
$HOST='';
}
if ($this->db->VARS["need_pass"]==1) {
eval("\$COMMENT_PASS = \"".$this->template->get_template($this->db->GB_TPL['com_pass'])."\";");
} else {
$COMMENT_PASS = '';
}
$GB_COMMENT = "#";
eval("\$GB_ENTRY = \"".$this->template->get_template($this->db->GB_TPL['entry'])."\";");
eval("\$comment_html = \"".$this->template->get_template($this->db->GB_TPL['header'])."\";");
eval("\$comment_html .= \"".$this->template->get_template($this->db->GB_TPL['com_form'])."\";");
eval("\$comment_html .= \"".$this->template->get_template($this->db->GB_TPL['footer'])."\";");
return $comment_html;
}
function check_comment() {
$this->comment = $this->db->FormatString($this->comment);
if (empty($this->comment)) {
return $this->db->gb_error($this->db->LANG["ErrorPost11"]);
}
$this->user = $this->db->FormatString($this->user);
if (empty($this->user)) {
return $this->db->gb_error($this->db->LANG["ErrorPost1"]);
}
if (!$this->db->CheckWordLength($this->user)) {
return $this->db->gb_error($this->db->LANG["ErrorPost4"]);
}
if (!$this->db->CheckWordLength($this->comment)) {
return $this->db->gb_error($this->db->LANG["ErrorPost10"]);
}
if ($this->db->VARS["allow_html"]==0) {
$this->comment = htmlspecialchars($this->comment);
}
if ($this->db->VARS["agcode"]==1) {
$this->comment = $this->db->AGCode($this->comment);
}
if (!get_magic_quotes_gpc()) {
$this->user = addslashes($this->user);
$this->comment = addslashes($this->comment);
}
$this->user = htmlspecialchars($this->user);
if ($this->db->VARS["need_pass"]==1) {
if (get_magic_quotes_gpc()) {
$this->pass_comment = stripslashes($this->pass_comment);
}
if ($this->db->VARS["comment_pass"] != "$this->pass_comment") {
return $this->db->gb_error($this->db->LANG["PassMess3"]);
}
}
if ($this->db->VARS["censor"]==1) {
$this->user = $this->db->CensorBadWords($this->user);
$this->comment = $this->db->CensorBadWords($this->comment);
}
if ($this->db->VARS["flood_check"]==1) {
if ($this->db->FloodCheck($this->ip)) {
return $this->db->gb_error($this->db->LANG["ErrorPost8"]);
}
}
if ($this->db->VARS["banned_ip"]==1) {
if ($this->db->isBannedIp($this->ip)) {
return $this->db->gb_error($this->db->LANG["ErrorPost9"]);
}
}
return 1;
}
function insert_comment() {
$the_time = time();
$host = @gethostbyaddr($this->ip);
$this->db->query("INSERT INTO ".$this->db->table['com']." (id,name,comments,host,timestamp) VALUES ('$this->id','$this->user','$this->comment','$host','$the_time')");
}
function comment_action($action='') {
global $GB_PG;
if ($this->id && $this->is_valid_id() && $action==1) {
$status = $this->check_comment();
if ($status == 1) {
$this->insert_comment();
header("Location: $GB_PG[index]");
} else {
echo $status;
}
} elseif ($this->id && $this->is_valid_id()) {
echo $this->comment_form();
} else {
header("Location: $GB_PG[index]");
}
}
}
?>
|
|
|
It means that I on screen I see the error messages as I have posted them yet it DOES post the comment into the guestbook. ie. it works, but leaves the 'guest' thinking 'did anything post' and looks messy!!
Thanks amber222 for all your help so far.
|
|
|
Yes, I checked comment.class.php - no extra lines there. I'll try the search on this Forum again.
|
|
|
The problem has happened again. In adding the code for comment.php into an existing web page I get:
Warning: Cannot modify header information - headers already sent by (output started at /home/*****/public_html/guestbook/comment.php:7) in /home/*****/public_html/guestbook/lib/comment.class.php on line 182
(***** added by me).
It works OK if I do the same for index.php and addentry.php but not this file. I have looked in comment.class.php and cannot see any whitespace at the start or end of the file. Any ideas why this is??
|
|
|
Thanx! Worked a treat!!!
|
|
|