Location: PHPKode > projects > chillyCMS > chillyCMS/modules/guestbook/guestbook/editgbentry.php
<?php
define('DOIT',true);
//TODO: session issue
require_once('../../core/session.backend.include.php');
require_once(PATH.'/admin/insertfiles.include.php');
require_once(PATH."/modules/guestbook/languages/$language.php");

global $page;
//get original values from db
$id=intval($_GET["id"]);
$page->query("select * from mod_guestbook where `id`=$id");
$thisentry = $page->db->getdata();
$name=$thisentry["name"];
$message=$thisentry["message"];
$email=$thisentry["email"];
$active=$thisentry["active"];
$replyname=$thisentry["reply_user"];
$replydate=$thisentry["reply_date"];
$reply=$thisentry["reply"];

//update reply and reply date
if ($_POST["reply"] != $thisentry["reply"] or $_POST["reply"]=="") {
	$replydate=date("Y-m-d H:i:s");
	$reply=strip_tags($_POST["reply"]);
	$replyuid=$mysession->user->uid;
	$replyname=$mysession->user->user;
	if ($reply=="" or $reply==null ) { $reply=null; $replydate=null; $replyname=null; }
	$sql = "update mod_guestbook set reply_user=$replyuid, reply='$reply', reply_date='$replydate' where id=$id";
	$page->query($sql);
	//echo db_query("update mod_guestbook set reply_user=$replyuid, reply='$reply', reply_date='$replydate' where id=$id");
}
//update the rest of the message if necessary
if (!empty($_POST)) {
	if (isset($_POST["name"])) { $name=no_semicola(strip_tags($_POST["name"])); }
	if (isset($_POST["message"])) { $message=strip_tags($_POST["message"]); }
	if ($message=="") { $message=null; }
	if (isset($_POST["email"])) { $email=email_chars($_POST["email"]); }
	if (isset($_POST["active"])) {
		if ($_POST["active"]=="1") { $active=1; } else { $active=0; }
	} else {
		$active=0;
	}
	$sql = "update mod_guestbook set name='$name',message='$message',email='$email',active=$active where id=$id";
	$page->query($sql);
	//db_query("update mod_guestbook set name='$name',message='$message',email='$email',active=$active where id=$id");
	$msg=$l_gen["lbl_savedch"];
}
if ($active==1) { $active=" checked='checked'"; }

$page->set_type("popup");
$page->print_head();
$page->add("<h1 class='center' style=\"margin-top: 0; padding-top: 20px;\">$mod_gb[lbl_editentry]</h1>".
//message
"<p class='center'>$msg</p>".
//form
"<form method='post' action=''>".
"<table cellspacing=0; style='margin: 20px;width:90%;'>".
"<tr><td class='right' style='width:20%'>$mod_gb[lbl_name]</td><td class='left' style='width:80%'>".
	"<input type='text' name='name' value='$name' style='width:100%;'></td></tr>".
"<tr><td class='right'>$mod_gb[lbl_date]</td><td class='left'>$thisentry[msg_date]</td></tr>".
"<tr><td class='right'>$mod_gb[lbl_msg]</td><td class='left'><textarea name='message' style='width:100%;'>$message</textarea></td></tr>".
"<tr><td class='right'>$l_gen[lbl_email]</td><td class='left'><input type='text' name='email' value='$email' style='width:100%;'></td></tr>".
"<tr><td class='right'>$l_edit[lbl_active]</td><td class='left'><input type='checkbox' name='active' value='1'$active></td></tr>".
"<tr><td class='right'>$mod_gb[lbl_commdate]</td><td class='left'>$replydate</td></tr>".
"<tr><td class='right'>$mod_gb[lbl_commuser]</td><td class='left'>$replyname</td></tr>".
"<tr><td class='right'>$mod_gb[lbl_comment]</td><td class='left'><textarea name='reply' style='width:100%;'>$reply</textarea></td></tr>".
"<tr><td></td><td class='left'><input type='submit' class='button floatleft' style=\"width: auto;\" value='$l_gen[lbl_save]'/>".
"<input type='reset' class='button floatleft' style=\"width: auto;\" value='$l_gen[lbl_reset]'/></td></tr>".
"</table>".
"<input type='hidden' name='sent' value='sent'>".
"</form>");

$page->print_body($msg);
?>
Return current item: chillyCMS