Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
 
3
#function is used to protect users from hackers.
4
#it filters out a lot of the bad things they can do.
5
function dbinsans($text) {
6
$text = strip_tags ($text, "");
7
$text = str_replace(chr(10),"",$text);
8
$text = str_replace(chr(13), "<br>", $text);
9
$text = str_replace("\"","&quot;",$text);
10
$text = str_replace("'","&#39;",$text);
11
$text = addslashes($text);
12
return($text);
13
}
14
 
15
function stri_replace($find,$replace,$string)
16
{
17
#function thanks to bradhuizenga @ softhome.net
18
#he posted it on php.net
19
#My server, and many of yours, won't have the PHP str_ireplace function...
20
#This one he made stri_replace, will allow us to do replaces without care to case
21
       if(!is_array($find)) $find = array($find);
22
       if(!is_array($replace))
23
       {
24
               if(!is_array($find)) $replace = array($replace);
25
 
26
               else
27
               {
28
                       // this will duplicate the string into an array the size of $find
29
                       $c = count($find);
30
                       $rString = $replace;
31
                       unset($replace);
32
                       for ($i = 0; $i < $c; $i++)
33
                       {
34
                               $replace[$i] = $rString;
35
                       }
36
               }
37
       }
38
       foreach($find as $fKey => $fItem)
39
       {
40
               $between = explode(strtolower($fItem),strtolower($string));
41
               $pos = 0;
42
               foreach($between as $bKey => $bItem)
43
               {
44
                       $between[$bKey] = substr($string,$pos,strlen($bItem));
45
                       $pos += strlen($bItem) + strlen($fItem);
46
               }
47
               $string = implode($replace[$fKey],$between);
48
       }
49
       return($string);
50
}
51
 
52
/* 
53
Found at http://www.zend.com/codex.php?id=220&single=1
54
 
55
This function wraps text to the given number of characters.  It will only 
56
wrap on word boundaries, and removes any resulting leading whitespace. 
57
It also converts all whitespcae characters (tab, cr, space) to a space. 
58
It accepts two arguments: 
59
        $text - the text to be wrapped 
60
        $wrap - the number of characters at which to wrap 
61
 
62
It returns the wrapped text unless $text is null, then it returns void; 
63
or $wrap is not an integer, then it returns $text untouched. 
64
 
65
*/ 
66
function wrap_text($text, $wrap) { 
67
        if (!isset($text)) return;
68
	#I hate to edit that line from their code, I didn't have the function they
69
	#Were using, this is equal to what they had though...
70
        if (!is_integer($wrap)) return $text; 
71
 
72
        $text_array = explode("\n", $text); 
73
 
74
        $i = $j = 0; 
75
        while ($i < sizeof($text_array)) { 
76
                $text_array[$i] = preg_replace("/\s/", " ", $text_array[$i]); 
77
                $length = strlen($text_array[$i]); 
78
                if ($length <= $wrap) { 
79
                        $new_text_array[$j] = $text_array[$i]; 
80
                        $i++; 
81
                } 
82
                else { 
83
                        $tmp = substr($text_array[$i], 0, $wrap); 
84
                        $spacePos = strrpos($tmp, " "); 
85
                        if ($spacePos > 0) { 
86
                                $new_text_array[$j] = substr($text_array[$i], 0, $spacePos+1); 
87
                                $new_text_array[$j] = ltrim($new_text_array[$j]); 
88
                                $text_array[$i] = substr($text_array[$i], $spacePos+1); 
89
                        } 
90
                        else { 
91
                                $new_text_array[$j] = $tmp; 
92
                                $text_array[$i] = substr($text_array[$i], $wrap); 
93
                        } 
94
                } 
95
                $j++; 
96
        } 
97
        return (implode("\n", $new_text_array)); 
98
} 
99
 
100
 
101
function Swear_Replace(){
102
#a little function I crafted :-)
103
	$swearstring = 4; 
104
	#how big do we want the swear to show up?
105
	#like arse to #$%^ that's 4. arse to $%^&* is 5
106
	$seeder=0;
107
	if($seeder != 1){
108
		srand((double)microtime()*1000000);
109
		#seeds the random value
110
		$seeder = 1;
111
		#only do it once, so giving it a value
112
	}
113
	$result="";
114
	$chars = "!@#$%^*";
115
	for($i=0; $i<$swearstring; $i++){
116
		#uses the char array and the length
117
		$result .= substr($chars,rand(0,strlen($chars)-1),1);
118
		#randomly picks one character between the first, last in char array
119
	}
120
	return $result; 
121
	#returns string of #$%^ like characters
122
}
123
 
124
 
125
function webcode($text) {
126
#My baby! :-) This does all the switching, BB, Swears, Smilies, all here
127
global $Outside;
128
if ($Outside == 1)
129
include 'shoutoptions.php';
130
else
131
include 'ShoutBoxFiles/shoutoptions.php';
132
 
133
if ($swear==1)
134
	#if swear is activiated in phpoptions.php
135
	{
136
	if ($Outside== 1)
137
	$file = file("swears.txt");
138
	else
139
	$file = file("ShoutBoxFiles/swears.txt");
140
	#opens the swears.txt, every line is turned into an object in an array
141
	#we called the array $file
142
 
143
	foreach($file as $swear)
144
	#for each object in file we give loop through setting that object to $swear
145
		{
146
		$swear = trim($swear);
147
		#get rid of the spaces
148
 
149
		$random = Swear_Replace();
150
		#calls the Swear_Replace() I made and fills it with junk !@#$%^&*
151
 
152
		$text = stri_replace($swear,$random,$text);
153
		#replaces the swear with the junk
154
	}
155
}
156
 
157
$text = stri_replace("[Alphibia]","http://www.Alphibia.com",$text);
158
#a little plug here, don't worry it is only added if people type [Alphibia]
159
#like that will happen... for legal reasons, don't remove this >:o
160
 
161
$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
162
                     "<a href=\"\\0\">\\0</a>", $text);
163
#This is the regular expression that changes a link beginning with http:// into a link
164
 
165
$text = stri_replace("[Version]","Version 1.0",$text);
166
#current version, in case people care, will be useful if I release more and you need help
167
 
168
$text = stri_replace(" weborum "," <a href=\"http://forum.weborum.com\">Weborum</a> ", $text);
169
#Plug, will turn Weborum with a space before and after into a link.
170
 
171
$text = stri_replace("weborum ","<a href=\"http://forum.weborum.com\">Weborum</a> ", $text);
172
#Plug, will turn weborum followed by a space into a link
173
 
174
$text = stri_replace(" weborum"," <a href=\"http://forum.weborum.com\">Weborum</a>", $text);
175
#Plug, will turn a space followed by weborum into a link
176
 
177
#feel free to add your own plugs, but don't remove the above for legal reasons.
178
 
179
 
180
if ($smilies==1)
181
#if smilies is turned on
182
{
183
	if ($Outside== 1)
184
	$file = file("smilies.txt");
185
	else
186
	$file = file("ShoutBoxFiles/smilies.txt");
187
#opens the file with smilies and turns it into an array like swears
188
 
189
foreach($file as $smile)
190
#read the swears one for more info, works the same
191
	{
192
	list($old,$new) = explode("\|/", $smile);
193
	#this turns anything before the \|/ into a var and anything after into another
194
 
195
	$old = trim($old);
196
	#gets rid of the spaces before and after
197
 
198
	$new = trim($new);
199
	#gets rid of the spaces before and after
200
	if ($Outside== 1)
201
	$text = stri_replace($old,'<img src="../'.$directory.'/'.$new.'" alt="" />',$text);
202
	else
203
	$text = stri_replace($old,'<img src="'.$directory.'/'.$new.'" alt="" />',$text);
204
	#replaces it with the smilie :-)	
205
	}
206
}
207
 
208
 
209
if ($colors==1)
210
#if colors is turned on
211
{
212
	if ($Outside== 1)
213
	$file = file("colors.txt");
214
	else
215
	$file = file("ShoutBoxFiles/colors.txt");
216
#opens the colors and turns it into an array...
217
foreach($file as $color)
218
#same as the swears one...
219
	{
220
	list($old,$new) = explode("|", $color);
221
	#same as smilies except doing it at the | instead of \|/
222
 
223
	$old = trim($old);
224
	#gets rid of the spaces before and after
225
 
226
	$new = trim($new);
227
	#gets rid of the spaces before and after
228
 
229
	$text = stri_replace('[color='.$old.']','<span style="color:'.$new.';">',$text);
230
	#replaces [color=this] with <span style="color:that;">	
231
	}
232
 
233
$text = stri_replace("[/color]","</span>",$text);
234
#replaces all occurences of [/color] with </span>
235
}
236
 
237
$text = stri_replace("[b]","<b>",$text);
238
$text = stri_replace("[/b]","</b>",$text);
239
$text = stri_replace("[u]","<u>",$text);
240
$text = stri_replace("[/u]","</u>",$text);
241
$text = stri_replace("[i]","<i>",$text);
242
$text = stri_replace("[/i]","</i>",$text);
243
#BB code... simple replaces
244
 
245
return($text);
246
#returns the outputted text
247
}
248
 
249
function lefts( $varb, $num ){
250
#another function... this one cuts off anything after a certain amount of characters...
251
#useful with hacker kids who want to create their own post to your page and fudge it up
252
#this stops them :-)
253
	$dnum = intval($num);
254
	if (strlen($varb)>$dnum){
255
	$nvarb = substr($varb, 0, $dnum+3);
256
	}
257
	else if (strlen($varb)<$dnum){
258
	$nvarb=$varb;
259
	}
260
	return $nvarb;
261
}
262
 
263
function mailcheck($emailadr){
264
#regular expression... used in the entries file returns 1 if it finds it
265
return eregi("^[a-zA-Z0-9_\.-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4}$", $emailadr); 
266
}
267
 
268
function URLcheck($URL){
269
#regular expression... used in the entries file returns 1 if it finds it
270
return eregi("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", $URL); 
271
}
272
 
273
 
274
#The following functions are in javascript... used for cookie manipulation
275
#two are also used for the countdown box, and one is used to open popups.
276
#the noscript is required for legal reasons
277
?>
278
<noscript>
279
For a free easily customizable shout box/tag board script, head to <a href="www.alphibia.com">www.alphibia.com</a>.
280
</noscript>
281
<script language="JavaScript" type="text/javascript">
282
 
283
function setCookie(name, value, expires, path, domain, secure) {
284
  var curCookie = name + "=" + escape(value) +
285
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
286
      ((path) ? "; path=" + path : "") +
287
      ((domain) ? "; domain=" + domain : "") +
288
      ((secure) ? "; secure" : "");
289
  document.cookie = curCookie;
290
}
291
 
292
function getCookie(name) {
293
  var dc = document.cookie;
294
  var prefix = name + "=";
295
  var begin = dc.indexOf("; " + prefix);
296
  if (begin == -1) {
297
    begin = dc.indexOf(prefix);
298
    if (begin != 0) return null;
299
  } else
300
    begin += 2;
301
  var end = document.cookie.indexOf(";", begin);
302
  if (end == -1)
303
    end = dc.length;
304
  return unescape(dc.substring(begin + prefix.length, end));
305
}
306
 
307
function TrackCount(fieldObj,countFieldName,maxChars)
308
{
309
  var countField = eval("fieldObj.form."+countFieldName);
310
  var diff = maxChars - fieldObj.value.length;
311
 
312
  // Need to check &amp; enforce limit here also in case user pastes data
313
  if (diff < 0)
314
  {
315
    fieldObj.value = fieldObj.value.substring(0,maxChars);
316
    diff = maxChars - fieldObj.value.length;
317
  }
318
  countField.value = diff;
319
}
320
 
321
function shoutbox(url){
322
winpops=window.open(url,"","width=400,height=338,scrollbars,resizable,")
323
}
324
 
325
function LimitText(fieldObj,maxChars)
326
{
327
  var result = true;
328
  if (fieldObj.value.length >= maxChars)
329
    result = false;
330
 
331
  if (window.event)
332
    window.event.returnValue = result;
333
  return result;
334
}
335
</script>