File: guestbook.php

package info (click to toggle)
achims-guestbook 2.52-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 956 kB
  • ctags: 714
  • sloc: php: 4,821; sh: 56; makefile: 38
file content (203 lines) | stat: -rw-r--r-- 7,759 bytes parent folder | download | duplicates (2)
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
<?php
/*
 guestbook.php - main guestbook modul

 Copyright (C) 2001 Achim Winkler <achim@lkcc.org>

 This 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, or (at your option)
 any later version.

 This software 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 package; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.
*/

	global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS;
	
	function ShowEntries($page, $entrypos) {
		global $phrase;
		
		if (!file_exists("output.php")) die ("Can't open output.php!");
		include("output.php");
		$output = new COutput($page, $entrypos, $phrase);
		$output->Output_All();
		unset($output);
		$action = "show";
	}


	function NewEntry() {
		global $newname, $newmail, $newurl, $newicq, $newaim, $newyim, $newmsn, $newloc, $newtext;
		
		if (!file_exists("tools.php")) die ("Can't open tools.php!");
		include("tools.php");
		if (!file_exists("input.php")) die ("Can't open input.php!");
		include("input.php");
		$input = new CInput();
		$input->Formular_Show(0, $newname, $newmail, $newurl, $newicq, $newaim, $newyim, $newmsn, $newloc, $newtext);
		unset($input);
	}


	function WriteEntry($emotion = "no", $preview = 0, $write = 0, $random = -1) {
		global $newname, $newmail, $newurl, $newicq, $newaim, $newyim, $newmsn, $newloc, $newtext, $lang;
		
		if (!file_exists("tools.php")) die ("Can't open tools.php!");
		include("tools.php");
		if (!file_exists("input.php")) die ("Can't open input.php!");
		include("input.php");
		$input = new CInput($emotion);
		if ($preview != 0 && $write != 0) {
			$input->Write_Data($newname, $newmail, $newicq, $newaim, $newyim, $newmsn, $newloc, $newurl, $newtext, $random);
			if (isset($lang)) header ("Location: guestbook.php?act=show&lang=$lang");
			else header ("Location: guestbook.php?act=show");
		}
		elseif ($preview != 0) {
			if (!file_exists("preview.php")) die ("Can't open preview.php!");
			include("preview.php");

			$preview = new CPreview($emotion);

			$preview->Show_Preview($newname, $newmail, $newicq, $newaim, $newyim, $newmsn, $newloc, $newurl, $newtext);
		}
		else {
			$input->Write_Data($newname, $newmail, $newicq, $newaim, $newyim, $newmsn, $newloc, $newurl, $newtext, $random);
		}
		unset($input);
	}

	
	function SearchEntry($next = "no") {
		global $what, $phrase, $page;
		
		if (!file_exists("search.php")) die ("Can't open search.php!");
		include("search.php");
		$search = new CSearch();
		
		if (!isset($what)) {
			$search->SearchScreen($phrase, $page, $next);
		} else {
			$search->Search($phrase, $page, $next);
		}	
	}
	
	ob_start();
	
	error_reporting(0);
	
	if (!ignore_user_abort()) ignore_user_abort(true);

	#administration in progress?
	if (!file_exists("config.php")) die ("Can't open config.php!");
	include("config.php");
	
	if (!function_exists("Unlock")) {
		function Unlock() {
			global $datapath;
			
			if (file_exists($datapath."/data.lck")) unlink($datapath."/data.lck");
			if (file_exists($datapath."/index.lck")) unlink($datapath."/index.lck");
			if (file_exists("temp/ip.lck")) unlink("temp/ip.lck");
		}
	}
	
	register_shutdown_function("Unlock");
	
	while (file_exists($datapath."/lock.lck")) {
		if ((filemtime($datapath."/lock.lck") + 1800) < time())	unlink($datapath."/lock.lck");
		usleep(500000);
		$i++;
		if ($i > 9) {
			echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
			echo "<HTML><HEAD><TITLE>Guestbook</TITLE><LINK HREF=\"guestbook.css\" REL=\"stylesheet\" TYPE=\"text/css\"></HEAD>";
			echo "<BODY>";
			echo "<TABLE BORDER=\"0\" VALIGN=\"middle\" WIDTH=\"100%\" HEIGHT=\"100%\">";
			echo "<TR><TD ALIGN=\"center\">";
			echo "<FONT SIZE=\"5\" COLOR=\"E01010\">Administration activities in progress.<BR>Please try it later again!</FONT>";
			echo "</TD></TR></TABLE></BODY></HTML>";
		}
	}

	if (isset($HTTP_GET_VARS['act'])) $act = $HTTP_GET_VARS['act'];
	if (isset($HTTP_POST_VARS['act'])) $act = $HTTP_POST_VARS['act'];
	if (isset($HTTP_POST_VARS['write'])) $write = $HTTP_POST_VARS['write'];
	if (isset($HTTP_POST_VARS['what'])) $what = $HTTP_POST_VARS['what'];
	if (isset($HTTP_GET_VARS['page'])) $page = $HTTP_GET_VARS['page'];
	if (isset($HTTP_POST_VARS['page'])) $page = $HTTP_POST_VARS['page'];
	if (isset($HTTP_GET_VARS['phrase'])) $phrase = $HTTP_GET_VARS['phrase'];
	if (isset($HTTP_POST_VARS['phrase'])) $phrase = $HTTP_POST_VARS['phrase'];
	if (isset($HTTP_POST_VARS['next'])) $next = $HTTP_POST_VARS['next'];
	if (isset($HTTP_GET_VARS['entrypos'])) $entrypos = $HTTP_GET_VARS['entrypos'];
	if (isset($HTTP_GET_VARS['lang'])) $lang = $HTTP_GET_VARS['lang'];
	if (isset($HTTP_POST_VARS['pre'])) $pre = $HTTP_POST_VARS['pre'];
	if (isset($HTTP_POST_VARS['presave'])) $presave = $HTTP_POST_VARS['presave'];
	if (isset($HTTP_POST_VARS['preview'])) $preview = $HTTP_POST_VARS['preview'];
	if (isset($HTTP_POST_VARS['random'])) $random = $HTTP_POST_VARS['random'];
	if (isset($HTTP_POST_VARS['emotion'])) $emotion = $HTTP_POST_VARS['emotion'];
	if (isset($HTTP_POST_VARS['newname'])) $newname = $HTTP_POST_VARS['newname'];
	if (isset($HTTP_POST_VARS['newmail'])) $newmail = $HTTP_POST_VARS['newmail'];
	if (isset($HTTP_POST_VARS['newurl'])) $newurl = $HTTP_POST_VARS['newurl'];
	if (isset($HTTP_POST_VARS['newicq'])) $newicq = $HTTP_POST_VARS['newicq'];
	if (isset($HTTP_POST_VARS['newaim'])) $newaim = $HTTP_POST_VARS['newaim'];
	if (isset($HTTP_POST_VARS['newyim'])) $newyim = $HTTP_POST_VARS['newyim'];
	if (isset($HTTP_POST_VARS['newmsn'])) $newmsn = $HTTP_POST_VARS['newmsn'];
	if (isset($HTTP_POST_VARS['newloc'])) $newloc = $HTTP_POST_VARS['newloc'];
	if (isset($HTTP_POST_VARS['newtext'])) $newtext = $HTTP_POST_VARS['newtext'];
	if (isset($HTTP_COOKIE_VARS['GuestbookAdmin'])) $GuestbookAdmin = $HTTP_COOKIE_VARS['GuestbookAdmin'];
	
	if (!isset($act) || $act == "" || $act == "show") {
		#show guestbook
		if (!isset($page)) $page = 1;
		if ($page < 1) $page = 1;
		if (!isset($entrypos)) $entrypos = -1;
		if (!isset($phrase)) $phrase = "";
		ShowEntries($page, $entrypos);
	}
	elseif ($act == "new") {
		#new guestbook entry
		if (!isset($newname)) $newname = "";
		if (!isset($newmail)) $newmail = "";
		if (!isset($newurl) || $newurl == "") $newurl = "http://";
		if (!isset($newicq)) $newicq = "";
		if (!isset($newaim)) $newaim = "";
		if (!isset($newyim)) $newyim = "";
		if (!isset($newmsn)) $newmsn = "";
		if (!isset($newloc)) $newloc = "";
		if (!isset($newtext)) $newtext = "";
		NewEntry();
	}
	elseif ($act == "write") {
		if ($pre == "yes" && isset($presave)) {
			#save the preview data
			WriteEntry($emotion, 1, 1, $random);
		}
		elseif ($pre == "yes") {
			#save data with preview
			WriteEntry($emotion, 1);
		} else {
			#save data without preview
			WriteEntry($emotion);
			if (isset($lang)) header ("Location: guestbook.php?act=show&lang=$lang");
			else header ("Location: guestbook.php?act=show");
		}
	}
	elseif ($act == "search") {
		if (!isset($next)) $next = "no";
		if (isset($entrypos)) $next = "yes";
		if ($next == "no") $page = 1;
		if (!isset($phrase) || $phrase == "") $phrase = "";
		
		SearchEntry($next);
	}

	ob_end_flush();

?>