View file éÑαß¿∩ 2 »«αΓá½/wml/guestbook.php

File size: 4.44Kb
<?php
	/**
	 *	Wap Portal русская версия
	 *
	 *	Copyright (C) 2002 - 2005 Красников Виктор
	 *
	 *	Wap Portal
	 *	Developer: Красников Виктор - [email protected]
	 *  Homepage: http://tut.spb.su
	 *	Date: 05/05/2005
	 * 	Version #: 1.0
	**/
?>

<?php /* GUESTBOOK */ ?>
<?php

// Check Title
$query = "SELECT * FROM wps_menu WHERE type='component' AND itemid = '$id'";
$result = mysql_query($query);
$row = mysql_fetch_object ($result);
$guestbook_title = $row->title;

$component_id = $id;

if (isset($sendgnow) && $sendgnow==1) {
?>
<card id="Card5" title="<?php echo $guestbook_title; ?>" ontimer="index.php?option=component&amp;id=<?php echo $component_id; ?>&amp;sendgnow=0">
<timer value="20"/>
<p>
<?php
	// determine whether properly sent
	if (isset($sndgname) && $sndgname!="" && isset($sndgcomment) && $sndgcomment!="") {
		if (isset($sndgemail) && $sndgemail != "" && NotValidEmail($sndgemail)) {
			echo _INVALID_EMAIL;
		} else {
			$time = date("Y-m-d H:i:s", time());
			$ip = $_SERVER['REMOTE_ADDR'];

			// Flood protection
			$query = "SELECT date FROM wps_guestbook WHERE ip = '$ip' ORDER by date DESC";
			$result = mysql_query($query);
			$row = mysql_fetch_object($result);
			if (mysql_num_rows ($result) > 0 && $row->date > date("Y-m-d H:i:s", time() - 15 * 60)) {
				echo _FLOOD;
			} else {
				$query = "INSERT INTO wps_guestbook VALUES ( '', '$sndgname', '$sndgemail', '$time', '$sndgcomment', '$ip')";
				mysql_query($query) or die (mysql_error());
				echo _COMMENT_ADDED;
			}
		}
	} else {
		echo _COMPLETE;
	}
?>
</p>
<p align="center">
<anchor><?php echo _BACK; ?>
<prev/>
</anchor>
</p>
</card>
<?php

} else {

?>
<card id="Card5" title="<?php echo $guestbook_title; ?>">
<p>
<?php echo _GBOOK_INTRO; ?>
</p>
<?php
$query = "SELECT timediff FROM wps_timediff";
$result = mysql_query($query);
$row = mysql_fetch_object ($result);
$timeadjust = ($row->timediff * 60 * 60);

$query = "SELECT id FROM wps_guestbook";
$result = mysql_query($query);
$total = mysql_num_rows ($result);

if (empty($gbfrom)) $gbfrom = 0;
$gbinc = 5;
$query = "SELECT * FROM wps_guestbook ORDER BY date DESC, id DESC LIMIT $gbfrom, $gbinc";
$result = mysql_query($query);
for ($count = 1; $row = mysql_fetch_object ($result); $count++) {
	print "<p>\n";
	print "<b>"._NAME_STR.":</b> $row->name<br />\n";
	if ($row->email!="") print _EMAIL_STR.": $row->email<br />\n";
	print _DATE_STR.": ";
	$arrDateTime = explode(" ", $row->date);
	$arrDate = explode("-", $arrDateTime[0]);
	$arrTime = explode(":", $arrDateTime[1]);
	$date_sh = strftime ($dateformatshort, mktime ($arrTime[0],$arrTime[1],$arrTime[2],$arrDate[1],$arrDate[2],$arrDate[0]) + $timeadjust);
	print "$date_sh<br />\n";
	print "<b>"._COMMENTS.":</b><br />\n";
	print "$row->comment<br />\n";
	print "</p>\n";
}
?>
<p>
<?php
$prev = $gbfrom - $gbinc;
if ($prev >= 0) {
	echo "<a href=\"index.php?option=component&amp;id=$component_id&amp;gbfrom=$prev\">"._PREV_STR."</a>&nbsp;&nbsp;";
}
$next = $gbfrom + $gbinc;
if ($next <= $total) {
	echo "<a href=\"index.php?option=component&amp;id=$component_id&amp;gbfrom=$next\">"._NEXT_STR."</a>";
}
?>
</p>
<p align="center">
<?php echo "<a href=\"#signgbook\">"._SIGN_STR."</a>"; ?>
</p>
<p align="center">
<?php echo "<a href=\"index.php\">"._HOME."</a>"; ?>
</p>
</card>
<?php

}

?>
<card id="signgbook" title="<?echo $guestbook_title;?>">
<p>
<?php echo _SIGN_STR; ?>
</p>
<p>
<?php echo _YOUR_NAME; ?>:<br />
<input type="text" name="g_name" maxlength="30" emptyok="true"/><br />
<?php echo _YOUR_EMAIL; ?>:<br />
<input type="text" name="g_email" maxlength="50" emptyok="true"/><br />
<?php echo _COMMENTS; ?>:<br />
<input type="text" name="g_comment" maxlength="200" emptyok="true"/><br />
<anchor><?php echo _SEND_STR; ?>
<go href="index.php" method="post">
<postfield name="sndgname" value="$(g_name)"/>
<postfield name="sndgemail" value="$(g_email)"/>
<postfield name="sndgcomment" value="$(g_comment)"/>
<postfield name="option" value="component"/>
<postfield name="id" value="<?php echo $component_id; ?>"/>
<postfield name="sendgnow" value="1"/>
</go>
</anchor>
</p>
<p align="center">
<anchor><?php echo _BACK; ?>
<prev/>
</anchor>
</p>
</card>
<?php
function NotValidEmail($email) {
	if (eregi("^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3}))$", $email)) {
		return FALSE;
	} else {
		return TRUE;
	}
}
?>
<?php /* END GUESTBOOK */ ?>