Размер файла: 4.46Kb
<?php
/**
* Wap Portal Server
*
* Copyright (C) 2002 - 2004 Emir Sakic
*
* Wap Portal Server
* Developer: Emir Sakic - [email protected]
* Homepage: http://www.sakic.net
* Date: 15/03/2004
* Version #: 1.2
**/
?>
<?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&id=<?php echo $component_id; ?>&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 "<b>"._EMAIL_STR.":</b> $row->email<br />\n";
print "<b>"._DATE_STR.":</b> ";
$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&id=$component_id&gbfrom=$prev\">"._PREV_STR."</a> ";
}
$next = $gbfrom + $gbinc;
if ($next <= $total) {
echo "<a href=\"index.php?option=component&id=$component_id&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 */ ?>