Просмотр файла guestbook/result.php

Размер файла: 5.25Kb
<?php 
/*
 * $RCSfile: result.php,v1 $
 *
 * Wap-GuestBook - a wap based guestbook
 * Copyright (C) 2004-2005 Chinmay N. Muranjan
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

header("Content-type: text/vnd.wap.wml"); 
echo "<?xml version=\"1.0\"?>"; 
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"" 
   . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; 
?> 

<?php
include('inc/config.inc.php');
include('inc/func.inc.php');

//$limit = 6;
$X = 0;

if (isset($_GET['order']))
{
	$order = $_GET['order'];
}
else
{
	$order = $order;
}

$db = mysql_connect($host,$user,$pass);
mysql_select_db($database,$db);

$numresults = mysql_query("SELECT * FROM $table"); 
    $numrows = mysql_num_rows($numresults);

if ($numrows > 0)
{
     
	if (empty($offset)) 
	{ 
		$offset=0; 
	} 

	$query = "SELECT * FROM $table order by id $order limit $offset,$limit"; 

	$result = mysql_query ($query) or die ("query 2 failed");
?>

<wml>
<head><meta http-equiv="Cache-control" content="no-cache"/></head>
<card id="card1" title="RESULT">
<p>

<?
	if($order == "ASC")
	{
?>
		Oldest First&nbsp;|&nbsp;<a href="<? echo $show_inc."?order=DESC"; ?>">Newest First</a><br/>
<?
	}
	else
	{
?>
		<a href="<? echo $show_inc."?order=ASC"; ?>">Oldest First</a>&nbsp;|&nbsp;Newest First<br/>
<?
	}
	
	while ($line = mysql_fetch_object($result)) 
	{
		print "$line->id"; 
		print ".";
		print "<br/>";   
		print "$line->datetime&nbsp;";
		print "<br/>";
		print "<b>";
		print "$line->name&nbsp;";
		print "</b>Wrotes:";    
		print "<br/>";
		$str = $line->comments;
		$str = validateHtml($str);
		print "\"$str\"";
		if (preg_match ("*X*","$str"))
		{
			$X = $X + 1;
		}

		print "<br/>";

		if ($line->show_email == "1")
		{   
			print "[<b>Email:</b>&nbsp;$line->email]";
			print "<br/>";
		}
		else
		{   
			print "[<b>Email:</b>&nbsp;<i>hidden</i>]";
			print "<br/>";
		}

		if ($line->show_url =="0")
			print "";
		elseif ($line->show_url == "1")
			print "[<b>URL:</b>&nbsp;<i>hidden</i>]<br/>";
		else
			print "[<b>URL:</b>&nbsp;$line->url]<br/>";

		if ($line->rate=="3" OR $line->rate=="4" OR $line->rate=="5")
			print "[<b>Rate:&nbsp;$line->rate</b>/5]";
		else
			print "[<b>Rate:&nbsp;</b>$line->rate/5]";

		print "<br/>";     
		print "------<br/>";
	}

	if ($X > 0):
		print "<small>('*X*' -> 'comment modified')</small><br/>";
	endif;

	if ($offset >= 3) 
	{ 
		$prevoffset = $offset - $limit; 
		print "<a href=\"$show_inc?offset=$prevoffset&amp;order=$order\">[ PREV ]</a><br/>"; 
	}
 
	$pages=intval($numrows/$limit); 

	if ($pages < ($numrows/$limit))
	{ 
		$pages=($pages + 1); 
	}

	$j = ($offset/6) + 1;
	print "[ $j ]<br/>";
?>
Choose Page...
	<select name="Choose" title="Choose Page..." value="<? print "[ $j ]"; ?>">
<?
	for ($i = 1; $i <= $pages; $i++) 
	{ 
		$newoffset = $limit*($i-1); 

		if ($newoffset == $offset) 
		{ 
			print "<option value=\"$i\">[ $i ]</option>"; 
		} 
		else 
		{
?>
		<option value="<? print "$i"; ?>">
			<onevent type="onpick">
				<go href="<? print $show_inc."?offset=".$newoffset."&amp;order=".$order; ?>"/>
			</onevent>
		<? print "[ $i ]"; ?>
		</option>
<?
		} 
	} 
?>
	</select>
<?
	//show next if not last 

	if (! ( ($offset/$limit) == ($pages - 1) ) && ($pages != 1) ) 
	{ 
		$newoffset = $offset+$limit; 
		print "<a href=\"$show_inc?offset=$newoffset&amp;order=$order\">[ NEXT ]</a><br/>"; 
	}

}
else
{
?>
<wml>
<head><meta http-equiv="Cache-control" content="no-cache"/></head>
<card id="card1" title="RESULT">
<p>
Currently there are no entries in the guestbook.<br/>Be the first one to <? print "<a href=\"$sign\">Sign In</a>" ?>!!<br/>
<?
}
print "<br/>";
print "Back To: <br/>";
print "<a href=\"$sign\">Sign Guestbook</a><br/>";
print "<a href=\"$home\">HOME</a><br/>";

mysql_close();
?>

</p>

<!-- END MAIN CONTENT AREA -->
<p><br/><small>
Comments are the property of their posters.<br/>
        [ <a href="info.php?type=6">License</a>
        &nbsp;|&nbsp;
        <a href="info.php?type=3">Change Log</a>
        &nbsp;|&nbsp;
        <a href="info.php?type=5">To Do List</a>
        &nbsp;|&nbsp;
        <a href="info.php?type=4">Bugs</a> ]
      <br/>
      Powered by <a href="info.php?type=1">Wap_GuestBook v2.0</a>&nbsp;and&nbsp;<a href="info.php?type=2">PHP</a>. Copyright © 2004-2005 <a href="info.php?type=1">Chinmay N. Muranjan</a>, All Rights Reserved.<br/></small>
      <!-- YOU MAY NOT REMOVE THIS COPYRIGHT NOTICE WITHOUT PERMISSION FROM THE Wap_GuestBook AUTHOR --></p>

</card>
</wml>