6 |
kaklik |
1 |
<?php
|
|
|
2 |
##############################################################################
|
|
|
3 |
# Copyright (C) 2004 Ramil ALcibar #
|
|
|
4 |
# http://www.triphp.com #
|
|
|
5 |
# ralcibar@fastmail.fm #
|
|
|
6 |
# #
|
|
|
7 |
# This program is free software; you can redistribute it and/or modify #
|
|
|
8 |
# it under the terms of the GNU General Public License as published by #
|
|
|
9 |
# the Free Software Foundation; either version 2 of the License, or #
|
|
|
10 |
# (at your option) any later version. #
|
|
|
11 |
# #
|
|
|
12 |
# This program is distributed in the hope that it will be useful, #
|
|
|
13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
|
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
|
15 |
# GNU General Public License for more details. #
|
|
|
16 |
# #
|
|
|
17 |
# You should have received a copy of the GNU General Public License #
|
|
|
18 |
# along with this program; if not, write to the Free Software #
|
|
|
19 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
|
|
|
20 |
##############################################################################
|
|
|
21 |
?>
|
|
|
22 |
<?php include 'config.php'; ?>
|
|
|
23 |
<?php
|
|
|
24 |
// replace smileys and bad word filtering
|
|
|
25 |
function creplace($msg)
|
|
|
26 |
{
|
|
|
27 |
// smileys
|
|
|
28 |
$msg = str_replace(":)", "<img src='smileys/smile.gif' alt=':)' align='absbottom'>", $msg);
|
|
|
29 |
$msg = str_replace(":(", "<img src='smileys/sad.gif' alt=':(' align='absbottom'>", $msg);
|
|
|
30 |
$msg = str_replace(":p", "<img src='smileys/tongue.gif' alt=':p' align='absbottom'>", $msg);
|
|
|
31 |
$msg = str_replace(":D", "<img src='smileys/biggrin.gif' alt=':)' align='absbottom'>", $msg);
|
|
|
32 |
$msg = str_replace(":0", "<img src='smileys/eek.gif' alt=':p' align='absbottom'>", $msg);
|
|
|
33 |
$msg = str_replace(":S", "<img src='smileys/confused.gif' alt=':)' align='absbottom'>", $msg);
|
|
|
34 |
$msg = str_replace(";)", "<img src='smileys/wink.gif' alt=':(' align='absbottom'>", $msg);
|
|
|
35 |
$msg = str_replace("=blush", "<img src='smileys/blush.gif' alt=':p' align='absbottom'>", $msg);
|
|
|
36 |
$msg = str_replace("=boggle", "<img src='smileys/boggle.gif' alt=':)' align='absbottom'>", $msg);
|
|
|
37 |
$msg = str_replace("=cool", "<img src='smileys/cool.gif' alt=':(' align='absbottom'>", $msg);
|
|
|
38 |
$msg = str_replace("=roll", "<img src='smileys/rolleyes.gif' alt=':p' align='absbottom'>", $msg);
|
|
|
39 |
$msg = str_replace("=stress", "<img src='smileys/stress.gif' alt=':(' align='absbottom'>", $msg);
|
|
|
40 |
$msg = str_replace("=tired", "<img src='smileys/tired.gif' alt=':p' align='absbottom'>", $msg);
|
|
|
41 |
$msg = str_replace("=ur", "<img src='smileys/urgh.gif' alt=':)' align='absbottom'>", $msg);
|
|
|
42 |
$msg = str_replace("=>", "<img src='smileys/inlove.gif' alt=':(' align='absbottom'>", $msg);
|
|
|
43 |
$msg = str_replace("=lol", "<img src='smileys/icon_lol.gif' alt=':p' align='absbottom'>", $msg);
|
|
|
44 |
|
|
|
45 |
// bad word filter
|
|
|
46 |
// add as many bad words as you can
|
|
|
47 |
$msg = str_replace("bad", "*", $msg);
|
|
|
48 |
$msg = str_replace("shit", "*", $msg);
|
|
|
49 |
$msg = str_replace("bitch", "*", $msg);
|
|
|
50 |
$msg = str_replace("atay", "*", $msg);
|
|
|
51 |
$msg = str_replace("fuck", "*", $msg);
|
|
|
52 |
$msg = str_replace("sex", "*", $msg);
|
|
|
53 |
$msg = str_replace("ugly", "*", $msg);
|
|
|
54 |
$msg = str_replace("hate", "*", $msg);
|
|
|
55 |
$msg = str_replace("hatred", "*", $msg);
|
|
|
56 |
return $msg;
|
|
|
57 |
}
|
|
|
58 |
?>
|
|
|
59 |
<?php
|
|
|
60 |
// check if the form is submitted
|
|
|
61 |
if(isset($_POST['submit']))
|
|
|
62 |
{
|
|
|
63 |
$name = $_POST['name'];
|
|
|
64 |
$email = $_POST['email'];
|
|
|
65 |
$message = $_POST['message'];
|
|
|
66 |
$date = date("Y-m-d");
|
|
|
67 |
$ip = $_SERVER['REMOTE_ADDR'];
|
|
|
68 |
$name = htmlspecialchars($name);
|
|
|
69 |
$email = htmlspecialchars($email);
|
|
|
70 |
$message = htmlspecialchars($message);
|
|
|
71 |
// insert into database
|
|
|
72 |
$strsql = "INSERT INTO myphptag (Name, Email, Message, DatePost, IP)
|
|
|
73 |
VALUES ('$name','$email','$message','$date','$ip')";
|
|
|
74 |
mysql_query($strsql, $ServerConnect) or die(mysql_error());
|
|
|
75 |
header('Location:'.$_SERVER['REQUEST_URI']);
|
|
|
76 |
exit;
|
|
|
77 |
}
|
|
|
78 |
?>
|
|
|
79 |
<html>
|
|
|
80 |
<head>
|
|
|
81 |
<title>MyPHPTag</title>
|
|
|
82 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
|
83 |
<script language="JavaScript" type="text/JavaScript">
|
|
|
84 |
function checkForm()
|
|
|
85 |
{
|
|
|
86 |
var gname, gmessage;
|
|
|
87 |
with(window.document.shout)
|
|
|
88 |
{
|
|
|
89 |
gname = name;
|
|
|
90 |
gmessage = message;
|
|
|
91 |
}
|
|
|
92 |
if(gname.value == '')
|
|
|
93 |
{
|
|
|
94 |
alert('Name cannot be null!');
|
|
|
95 |
gname.focus;
|
|
|
96 |
return false;
|
|
|
97 |
}
|
|
|
98 |
if(gmessage.value == '')
|
|
|
99 |
{
|
|
|
100 |
alert('Message cannot be null!');
|
|
|
101 |
gmessage.focus;
|
|
|
102 |
return false;
|
|
|
103 |
}
|
|
|
104 |
else if(gmessage.value.length > 255)
|
|
|
105 |
{
|
|
|
106 |
alert("Please don't abuse our shoutbox!\nEnter only up to 255 characters.");
|
|
|
107 |
gmessage.focus;
|
|
|
108 |
return false;
|
|
|
109 |
}
|
|
|
110 |
else
|
|
|
111 |
{
|
|
|
112 |
return true;
|
|
|
113 |
}
|
|
|
114 |
}
|
|
|
115 |
function addsmiley(code)
|
|
|
116 |
{
|
|
|
117 |
var pretext = document.shout.message.value;
|
|
|
118 |
this.code = code;
|
|
|
119 |
document.shout.message.value = pretext + code;
|
|
|
120 |
}
|
|
|
121 |
</script>
|
|
|
122 |
<link href="style.css" rel="stylesheet" type="text/css">
|
|
|
123 |
</head>
|
|
|
124 |
<body>
|
|
|
125 |
<?php
|
|
|
126 |
if(!isset( $_GET ['page' ]))
|
|
|
127 |
{
|
|
|
128 |
$page =1;
|
|
|
129 |
}
|
|
|
130 |
else
|
|
|
131 |
{
|
|
|
132 |
$page =$_GET ['page' ];
|
|
|
133 |
}
|
|
|
134 |
// Define the number of results per page
|
|
|
135 |
$max_results = 5;
|
|
|
136 |
// Figure out the limit for the query based on the current page number.
|
|
|
137 |
$from = (( $page *$max_results ) - $max_results );
|
|
|
138 |
// Perform MySQL query on only the current page number's results
|
|
|
139 |
$query = "SELECT * FROM myphptag ORDER BY TagId DESC LIMIT $from, $max_results";
|
|
|
140 |
$result = mysql_query($query) or die('Error:'.mysql_error());
|
|
|
141 |
$num_rows = mysql_num_rows($result);
|
|
|
142 |
?>
|
|
|
143 |
<form name="shout" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" onSubmit="return checkForm();">
|
|
|
144 |
<table width="175" cellspacing="0" cellpadding="2" align="center" style="border:1px solid #333333;">
|
|
|
145 |
<?php
|
|
|
146 |
if($num_rows == 0)
|
|
|
147 |
{
|
|
|
148 |
?>
|
|
|
149 |
<tr>
|
|
|
150 |
<td align="center"><div class="headingfont">No entry!</div></td>
|
|
|
151 |
</tr>
|
|
|
152 |
<?php
|
|
|
153 |
}
|
|
|
154 |
else if ($num_rows>0)
|
|
|
155 |
{
|
|
|
156 |
$x=0;
|
|
|
157 |
while($x<$num_rows)
|
|
|
158 |
{
|
|
|
159 |
if (($x%2)==0) { $bgcolor="#FFFFFF"; } else { $bgcolor="#F0F0F0"; }
|
|
|
160 |
$key = mysql_result($result,$x,"TagId");
|
|
|
161 |
$name = mysql_result($result,$x,"Name");
|
|
|
162 |
$email = mysql_result($result,$x,"Email");
|
|
|
163 |
$message = mysql_result($result,$x,"Message");
|
|
|
164 |
$nmessage = nl2br($message);
|
|
|
165 |
$fmessage = creplace($nmessage);
|
|
|
166 |
$finalmessage = wordwrap($fmessage, 15, "\n", 1);
|
|
|
167 |
$dateposted = mysql_result($result,$x,"DatePost");
|
|
|
168 |
$ip = mysql_result($result,$x,"IP");
|
|
|
169 |
?>
|
|
|
170 |
<tr bgcolor="<?php echo $bgcolor; ?>">
|
|
|
171 |
<td align="left" valign="top" class="content">
|
|
|
172 |
<?php
|
|
|
173 |
if ($email == "")
|
|
|
174 |
{
|
|
|
175 |
echo "<div class='headingfont'>" .$name . ":</div>";
|
|
|
176 |
}
|
|
|
177 |
else
|
|
|
178 |
{
|
|
|
179 |
echo "<a href='mailto:" . $email . "'>$name</a>:<br>";
|
|
|
180 |
}
|
|
|
181 |
echo $finalmessage;
|
|
|
182 |
?>
|
|
|
183 |
</td>
|
|
|
184 |
</tr>
|
|
|
185 |
<?php
|
|
|
186 |
$x++;
|
|
|
187 |
}
|
|
|
188 |
}
|
|
|
189 |
?>
|
|
|
190 |
<?php
|
|
|
191 |
// Figure out the total number of results in DB:
|
|
|
192 |
$total_results =mysql_result (mysql_query ("SELECT COUNT(*) as Num FROM myphptag" ), 0);
|
|
|
193 |
// Figure out the total number of pages. Always round up using ceil()
|
|
|
194 |
$total_pages =ceil ($total_results /$max_results );
|
|
|
195 |
?>
|
|
|
196 |
<tr>
|
|
|
197 |
<td class="entryheaders" colspan="2" align="center">
|
|
|
198 |
<?php
|
|
|
199 |
// Build Previous Link
|
|
|
200 |
if( $page >1)
|
|
|
201 |
{
|
|
|
202 |
$prev = ( $page -1);
|
|
|
203 |
echo "<a href=\"" .$_SERVER ['PHP_SELF' ]. "?page=$prev \" ><img src='images/previous.gif' border='0' alt='previous' align='middle'></a> " ;
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
for( $i =1;$i <= $total_pages ;$i ++)
|
|
|
207 |
{
|
|
|
208 |
if(( $page ) == $i )
|
|
|
209 |
{
|
|
|
210 |
echo "$i ";
|
|
|
211 |
}
|
|
|
212 |
else
|
|
|
213 |
{
|
|
|
214 |
echo "<a href=\"" .$_SERVER ['PHP_SELF' ]. "?page=$i \" >$i</a> " ;
|
|
|
215 |
}
|
|
|
216 |
}
|
|
|
217 |
// Build Next Link
|
|
|
218 |
if( $page <$total_pages )
|
|
|
219 |
{
|
|
|
220 |
$next = ( $page +1);
|
|
|
221 |
echo "<a href=\"" .$_SERVER ['PHP_SELF' ]. "?page=$next \" ><img src='images/next.gif' border='0' alt='previous' align='middle'></a>" ;
|
|
|
222 |
}
|
|
|
223 |
?>
|
|
|
224 |
</td>
|
|
|
225 |
</tr>
|
|
|
226 |
<?php
|
|
|
227 |
mysql_close($ServerConnect);
|
|
|
228 |
?>
|
|
|
229 |
<tr>
|
|
|
230 |
<td>
|
|
|
231 |
Name:<br>
|
|
|
232 |
<input type="text" name="name" maxlength="50" size="25"><br>
|
|
|
233 |
Email:<br>
|
|
|
234 |
<input type="text" name="email" maxlength="50" size="25"><br>
|
|
|
235 |
Message:<br>
|
|
|
236 |
<textarea name="message" cols="24" rows="4"></textarea><br>
|
|
|
237 |
<img src="smileys/smile.gif" alt=":)" border="0" onClick="addsmiley(':)')" style="cursor: pointer;">
|
|
|
238 |
<img src="smileys/sad.gif" alt=":(" border="0" onClick="addsmiley(':(')" style="cursor: pointer;">
|
|
|
239 |
<img src="smileys/tongue.gif" alt=":p" border="0" onClick="addsmiley(':p')" style="cursor: pointer;">
|
|
|
240 |
<img src="smileys/biggrin.gif" alt=":D" border="0" onClick="addsmiley(':D')" style="cursor: pointer;">
|
|
|
241 |
<img src="smileys/eek.gif" alt=":0" border="0" onClick="addsmiley(':0')" style="cursor: pointer;">
|
|
|
242 |
<img src="smileys/confused.gif" alt=":S" border="0" onClick="addsmiley(':S')" style="cursor: pointer;">
|
|
|
243 |
<img src="smileys/wink.gif" alt=";)" border="0" onClick="addsmiley(';)')" style="cursor: pointer;">
|
|
|
244 |
<img src="smileys/blush.gif" alt="=blush" border="0" onClick="addsmiley('=blush')" style="cursor: pointer;">
|
|
|
245 |
<img src="smileys/boggle.gif" alt="=boggle" border="0" onClick="addsmiley('=boggle')" style="cursor: pointer;">
|
|
|
246 |
<img src="smileys/cool.gif" alt="=cool" border="0" onClick="addsmiley('=cool')" style="cursor: pointer;">
|
|
|
247 |
<img src="smileys/stress.gif" alt="=stress" border="0" onClick="addsmiley('=stress')" style="cursor: pointer;">
|
|
|
248 |
<img src="smileys/tired.gif" alt="=tired" border="0" onClick="addsmiley('=tired')" style="cursor: pointer;">
|
|
|
249 |
<img src="smileys/icon_lol.gif" alt="=lol" border="0" onClick="addsmiley('=lol')" style="cursor: pointer;">
|
|
|
250 |
<img src="smileys/inlove.gif" alt="=tired" border="0" onClick="addsmiley('=>')" style="cursor: pointer;">
|
|
|
251 |
<img src="smileys/rolleyes.gif" alt="=lol" border="0" onClick="addsmiley('=roll')" style="cursor: pointer;">
|
|
|
252 |
<img src="smileys/urgh.gif" alt="=tired" border="0" onClick="addsmiley('=ur')" style="cursor: pointer;"><br><br>
|
|
|
253 |
<input type="submit" name="submit" value="SHOUT">
|
|
|
254 |
</td>
|
|
|
255 |
</tr>
|
|
|
256 |
</table>
|
|
|
257 |
</form>
|
|
|
258 |
</body>
|
|
|
259 |
</html>
|