1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
| include("./config.php");
include("./lang.php");
// array_to_string and string_to_array functions
// originally by daenders AT yahoo DOT com on php.net
function array_to_string($array) {
$retval = '';
foreach ($array as $index => $value) {
$retval .= urlencode(base64_encode($index)) . '|' . urlencode(base64_encode($value)) . '||';
}
return urlencode(substr($retval, 0, -2));
}
function string_to_array($string) {
$retval = array();
$string = urldecode($string);
$tmp_array = explode('||', $string);
foreach ($tmp_array as $tmp_val) {
list($index, $value) = explode('|', $tmp_val);
$retval[base64_decode(urldecode($index))] = base64_decode(urldecode($value));
}
return $retval;
}
function check_words($string,$banwordz) {
for($i=0;$i<sizeof($banwordz);$i++){
$string=eregi_replace($banwordz[$i], "****", $string);
}
return $string;
}
function check_ip($bannedipz) {
$isokay = true;
foreach($bannedipz as $banip) {
if ($_SERVER['REMOTE_ADDR'] == $banip) {
$isokay = false;
}
}
return $isokay;
}
function getTagName($text,$cnt)
{
while(($cnt < strlen($text))&&(eregi("[^a-z0-9]",substr($text,$cnt,1))))$cnt++;
$tagNameStart=$cnt;
while(($cnt < strlen($text))&&(!eregi("[^a-z0-9]",substr($text,$cnt,1))))$cnt++;
return substr($text,$tagNameStart,$cnt-$tagNameStart);
}
function getTagEnd($text,$cnt)
{
return strpos($text,">",$cnt);
}
function closeUnclosedTags($text)
{
$openedTags=array();
$cnt=0;
while(($cnt < strlen($text))&&(true))
{
if(substr($text,$cnt,2)=="</")
{
$tagEnd=getTagEnd($text,$cnt);
$tagName=getTagName($text,$cnt);
$lastOpenedTag=array_pop($openedTags);
if($lastOpenedTag==NULL)
{
//error: no tag was opened - delete the close tag
$text=substr($text,0,$cnt).substr($text,$tagEnd+1);
}elseif($lastOpenedTag!=$tagName){
//error: closing unopened tag (possible cross-nesting) - return the original opened tag and delete the close tag
array_push($openedTags,$lastOpenedTag);
$text=substr($text,0,$cnt).substr($text,$tagEnd+1);
}else{ $cnt=$tagEnd+1; }
}elseif(substr($text,$cnt,1)=="<"){
$tagEnd=getTagEnd($text,$cnt);
$tagName=getTagName($text,$cnt);
if(substr($text,$tagEnd-1,1)!="/")array_push($openedTags,$tagName);
$cnt=$tagEnd+1;
}else{
$cnt++;
}
}
while(count($openedTags)>0)$text.="</".array_pop($openedTags).">";
return $text;
}
function parse_smileys($string) {
$smileylist = array();
$i = 0;
if ($handle = opendir('./smileys/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$smileylist[$i] = str_replace(".gif", "", $file);
$i++;
}
}
closedir($handle);
}
foreach ($smileylist as $smileycheck){
$string = str_replace(":".$smileycheck.":", "[img]\"smileys/".$smileycheck.".gif\"[/img]", $string);
}
return $string;
}
//############################################################
// retrieve cookies to remember name/url
if(isset($_COOKIE['remembername'])){$cookiename=$_COOKIE['remembername'];}
else{$cookiename=$lang["name"];}
if(isset($_COOKIE['rememberurl'])){$cookieurl=$_COOKIE['rememberurl'];}
else{$cookieurl="http://";}
//############################################################
if(isset($_GET['act'])){$act = $_GET['act'];}else{$act = "null";}
switch($act) {
case "tag":
//############################################################
if (!check_ip($bannedips)) {
die($lang["error"].$lang["banned"]."<a href=\"index.php\">".$lang["back"]."</a>");
}
$tagname = $_POST['tagname'];
$tagmsg = $_POST['tagmsg'];
$tagurl = $_POST['tagurl'];
if (!isset($_POST['tagname']) || !$_POST['tagmsg'] || $tagname == "Name" || $tagmsg == "Message" ) {
die($lang["error"].$lang["fillin"]."<a href=\"index.php\">".$lang["back"]."</a>");
}
$tagname = strip_tags(check_words($tagname,$banwords));
if (strlen($tagname) > $maxname) {
die($lang["error"].str_replace("%1",$maxname,$lang["longname"])."<a href=\"index.php\">".$lang["back"]."</a>");
}
$tagmsg = strip_tags(check_words($tagmsg,$banwords),$allowedhtml);
$tagmsg = str_replace("style=", "alt=", $tagmsg);
$tagmsg = closeUnclosedTags($tagmsg);
if (strlen($tagmsg) > $maxsize) {
die($lang["error"].str_replace("%1",$maxsize,$lang["longmsg"])."<a href=\"index.php\">".$lang["back"]."</a>");
}
$tagurl = strip_tags(check_words($tagurl,$banwords));
if (!empty($tagurl) && (substr($tagurl, 0, 7) != "http://")){
die($lang["error"].$lang["badurl"]."<a href=\"index.php\">".$lang["back"]."</a>");
}
if (!empty($_COOKIE['floodprotect'])) {
$cookietime = time() - $_COOKIE['floodprotect'];
if ($cookietime <= $floodtimer) {
die($lang["error"].$lang["flood"]."<a href=\"index.php\">".$lang["back"]."</a>");
}
}
setcookie("floodprotect", time(), time()+100);
setcookie("remembername", $tagname, time()+10000000);
setcookie("rememberurl", $tagurl, time()+10000000);
$postit = array();
$postit[] = 0;
$postit[] = $tagname;
$postit[] = $tagurl;
$postit[] = $_SERVER['REMOTE_ADDR'];
$postit[] = $tagmsg;
$postit[] = time();
$tagdb = fopen("./db.txt", "a+");
if (!fwrite($tagdb, array_to_string($postit)."\n")) {
die("CHMOD db.txt to 666");
}
fclose($tagdb);
echo "<script>window.location='index.php';</script>";
break;
case "info":
//########################################################
include("./header.php");
echo "<center><strong><div class=\"taga\">".$lang["smileys"]."</div></strong>
<table width=\"100%\" class=\"tagb\" cellspacing=\"5\" cellpadding=\"0\" border=\"0\">";
$smileylist = array();
$i = 0;
if ($handle = opendir('./smileys/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$smileylist[$i] = str_replace(".gif", "", $file);
$i++;
}
}
closedir($handle);
}
foreach ($smileylist as $smileyshow){
echo "<tr><td align=\"right\">:".$smileyshow.":</td><td align=\"left\">[img]\"smileys/".$smileyshow.".gif\"[/img]</td></tr>";
}
echo "</table><br /><strong><div class=\"taga\">".$lang["html"]."</div></strong><div class=\"tagb\">";
echo str_replace(",","<br />",str_replace(">",">",str_replace("<","<",$allowedhtml)));
//below is a link back to me. if you remove it, you're lame.
echo "</div><br /><div class=\"formarea\">Powered by <strong>tagBox v1.31.6</strong><br /><a href=\"http://www.j-fx.ws/tagbox/\" target=\"_blank\">http://www.j-fx.ws/tagbox/</a></div></center>";
break;
case "history":
//########################################################
include("./header.php");
$lines = file("./db.txt");
$numlines = count($lines);
if($reverse_posts){ $lines = array_reverse($lines); }
$numlines = count($lines);
echo "<center><strong>".$lang["history"]."</strong><br />".str_replace("%1",$numlines,$lang["numtags"])."</center><br />\n";
$i = 0;
$ab = 0;
while( $i < $numlines ) {
$thistag = string_to_array($lines[$i]);
$thistag[4] = parse_smileys($thistag[4]);
if(!$thistag[2] || ($thistag[2]=="http://")) {
$thistag[2] = "<a href=\"#\">";
} else {
$thistag[2] = "<a href=\"".$thistag[2]."\" target=\"_blank\">";
}
if($timestamps_enabled&&$thistag[5]){$timestamp = date($timestamp_format,$thistag[5])." » ";}else{$timestamp="";}
if(!$ab){
echo "<div class=\"taga\">".$timestamp."<strong>".$thistag[2].stripslashes($thistag[1])."</a> »</strong> ".stripslashes($thistag[4])."</div>\n";
$ab = 1;
}else{
echo "<div class=\"tagb\">".$timestamp."<strong>".$thistag[2].stripslashes($thistag[1])."</a> »</strong> ".stripslashes($thistag[4])."</div>\n";
$ab = 0;
}
$i++;
}
break;
default:
//########################################################
include("./header.php");
$lines = file("./db.txt");
$numlines = count($lines);
if ($numtags >= $numlines)
$i = 0;
else
$i = $numlines - $numtags;
if($reverse_posts){
$lines = array_reverse($lines);
$i = 0;
}
$ab = 0;
while( $i < $numlines ) {
if($reverse_posts && ($i > $numtags - 1)){ $i = $numlines + 1; } else {
$thistag = string_to_array($lines[$i]);
$thistag[4] = parse_smileys($thistag[4]);
if(!$thistag[2] || ($thistag[2]=="http://")) {
$thistag[2] = "<a href=\"#\">";
} else {
$thistag[2] = "<a href=\"".$thistag[2]."\" target=\"_blank\">";
}
if($timestamps_enabled&&$thistag[5]){$timestamp = date($timestamp_format,$thistag[5])." » ";}else{$timestamp="";}
if(!$ab){
echo "<div class=\"taga\">".$timestamp."<strong>".$thistag[2].stripslashes($thistag[1])."</a> »</strong> ".stripslashes($thistag[4])."</div>\n";
$ab = 1;
}else{
echo "<div class=\"tagb\">".$timestamp."<strong>".$thistag[2].stripslashes($thistag[1])."</a> »</strong> ".stripslashes($thistag[4])."</div>\n";
$ab = 0;
}
}
$i++;
}
if($users_online_enabled) {
include("./online.php");
}
if($clickable_smileys) {
echo "<br /><div class=\"formarea\">";
$smileylist = array();
$i = 0;
if ($handle = opendir('./smileys/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$smileylist[$i] = str_replace(".gif", "", $file);
$i++;
}
}
closedir($handle);
}
foreach ($smileylist as $smileyshow){
echo "[img]\"smileys/".$smileyshow.".gif\"[/img] ";
}
echo "</div>";
}
include("./footer.php");
break;
}
?> |