Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?
2
 
3
// Write posted data to file
4
function writetofile($post1,$post2,$post3) {
5
include "config.php";
6
 
7
$msgfilename = "messages.txt";
8
$curdate = date('Y/m/d H:i:s');
9
$save = file($msgfilename);
10
$filename = fopen($msgfilename, "r+");
11
 
12
					if ($badlang == "1") {
13
 
14
						$badwordsfile = "badlanguage.txt";
15
						if (file_exists($badwordsfile)) {
16
 
17
							$handle = fopen("badlanguage.txt", "r");
18
 
19
							while (!feof($handle)) {
20
 
21
								$buffer = fgets($handle, 4096);
22
								$badword = explode(",", $buffer);
23
 
24
								$post1 = str_replace($badword, "****", $post1);
25
								$post3 = str_replace($badword, "****", $post3);
26
 
27
							} // End While
28
 
29
							fclose($handle);
30
 
31
								fwrite($filename, $post1."\t".$post2."\t".$post3."\t".$curdate."\t".$_SERVER['REMOTE_ADDR']."\r\n");
32
 
33
								foreach ($save as $reinsert) {
34
								fwrite($filename, $reinsert);
35
								}
36
 
37
								fclose($filename);					
38
 
39
								if ($savename == "1") {
40
								setcookie("phpSHOUT_Cookie", $_POST["name"], time()+3600);
41
								}
42
								header('Location: '.$_SERVER['HTTP_REFERER'].'');
43
 
44
						} // End If file exists
45
 
46
					} else if ($badlang == "0") {
47
 
48
								fwrite($filename, $post1."\t".$post2."\t".$post3."\t".$curdate."\t".$_SERVER['REMOTE_ADDR']."\r\n");
49
 
50
								foreach ($save as $reinsert) {
51
								fwrite($filename, $reinsert);
52
								}
53
 
54
								fclose($filename);					
55
 
56
								if ($savename == "1") {
57
									setcookie("phpSHOUT_Cookie", $_POST["name"], time()+3600);
58
								}
59
 
60
								header('Location: '.$_SERVER['HTTP_REFERER'].'');
61
 
62
					} else {
63
 
64
						echo "Invalid Bad Language Value. Check your config.php file.";
65
 
66
					} // End If bad Language
67
 
68
} // End function
69
 
70
// Fill fields if error appears
71
function fillnamevalues($posted,$defaultval) {
72
include "config.php";
73
if (isset($_POST["$posted"])) {
74
	echo $_POST["$posted"];
75
} else if (isset($_COOKIE["phpSHOUT_Cookie"]) && $savename=="1") {
76
	echo $_COOKIE["phpSHOUT_Cookie"];
77
} else {
78
	echo $defaultval;
79
}
80
}
81
 
82
function filltextvalues($posted,$defaultval) {
83
if (isset($_POST["$posted"])) {
84
	echo $_POST["$posted"];
85
} else {
86
	echo $defaultval;
87
}
88
}
89
 
90
// Convert smilies to images
91
function smiles($messagetext) {
92
 
93
	include "config.php";
94
 
95
	$sm_search = array(":d",
96
					   ":)",
97
					   ":(",
98
					   ":o",
99
					   ":shock:",
100
					   ":-?",
101
					   "8)",
102
					   ":lol:",
103
					   ":x",
104
					   ":p",
105
					   ":redface:",
106
					   ":cry:",
107
					   ":evil:",
108
					   ":twisted:",
109
					   ":roll:",
110
					   ";)",
111
					   ":!:",
112
					   ":?:",
113
					   ":idea:",
114
					   ":arrow:"
115
					   );
116
	$sm_replace = array("<img src=$imagepath/icon_cheesygrin.gif>",
117
						"<img src=$imagepath/icon_smile.gif>",
118
						"<img src=$imagepath/icon_sad.gif>",
119
						"<img src=$imagepath/icon_surprised.gif>",
120
						"<img src=$imagepath/icon_eek.gif>",
121
						"<img src=$imagepath/icon_confused.gif>",
122
						"<img src=$imagepath/icon_cool.gif>",
123
						"<img src=$imagepath/icon_lol.gif>",
124
						"<img src=$imagepath/icon_mad.gif>",
125
						"<img src=$imagepath/icon_razz.gif>",
126
						"<img src=$imagepath/icon_redface.gif>",
127
						"<img src=$imagepath/icon_cry.gif>",
128
						"<img src=$imagepath/icon_evil.gif>",
129
						"<img src=$imagepath/icon_twisted.gif>",
130
						"<img src=$imagepath/icon_rolleyes.gif>",
131
						"<img src=$imagepath/icon_wink.gif>",
132
						"<img src=$imagepath/icon_exclaim.gif>",
133
						"<img src=$imagepath/icon_question.gif>",
134
						"<img src=$imagepath/icon_idea.gif>",
135
						"<img src=$imagepath/icon_arrow.gif>"
136
						);
137
	$output = str_replace($sm_search, $sm_replace, $messagetext);
138
 
139
	return $output; 
140
 
141
	}
142
 
143
// Word wrapping for messages.	
144
function real_wordwrap($string,$width,$break)
145
{
146
   $string = preg_replace('/([^\s]{'.$width.'})/i',"$1$break",$string);
147
   echo $string;
148
   return $string;
149
}
150
?>