diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-04 12:12:25 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-04 12:12:25 +0000 |
commit | 0df0e5f1e927ea1d04bd5ef3c12be3bc2c72837c (patch) | |
tree | 81f557ea530b0748fe5b48fdde961e4d459b0151 /central/trunk/install.php | |
parent | 96969d7023cf8703bf9c460e1d54d4e32a076987 (diff) | |
download | instadisc-0df0e5f1e927ea1d04bd5ef3c12be3bc2c72837c.tar.gz instadisc-0df0e5f1e927ea1d04bd5ef3c12be3bc2c72837c.tar.bz2 instadisc-0df0e5f1e927ea1d04bd5ef3c12be3bc2c72837c.zip |
Central: Wrote installation script
Closes #4
Diffstat (limited to 'central/trunk/install.php')
-rw-r--r-- | central/trunk/install.php | 346 |
1 files changed, 338 insertions, 8 deletions
diff --git a/central/trunk/install.php b/central/trunk/install.php index d04e99b..7b5514f 100644 --- a/central/trunk/install.php +++ b/central/trunk/install.php | |||
@@ -2,20 +2,350 @@ | |||
2 | 2 | ||
3 | /* InstaDisc Server - A Four Island Project */ | 3 | /* InstaDisc Server - A Four Island Project */ |
4 | 4 | ||
5 | if (!isset($_GET['step'])) | 5 | $softwareVersion = 1; |
6 | |||
7 | if (!isset($_GET['submit'])) | ||
8 | { | ||
9 | showHeader('1'); | ||
10 | showStepOne('localhost', 'root', '', 'instadisc', array()); | ||
11 | } else { | ||
12 | $numOfErrors = 0; | ||
13 | $errors = array(); | ||
14 | |||
15 | switch ($_GET['submit']) | ||
16 | { | ||
17 | case 1: | ||
18 | if ($_POST['host'] == '') | ||
19 | { | ||
20 | addError($numOfErrors, $errors, 'host', 'Hostname is a required field'); | ||
21 | } | ||
22 | |||
23 | if ($_POST['username'] == '') | ||
24 | { | ||
25 | addError($numOfErrors, $errors, 'username', 'Username is a required field'); | ||
26 | } | ||
27 | |||
28 | if ($_POST['password'] == '') | ||
29 | { | ||
30 | addError($numOfErrors, $errors, 'password', 'Password is a required field'); | ||
31 | } | ||
32 | |||
33 | if ($_POST['dbname'] == '') | ||
34 | { | ||
35 | addError($numOfErrors, $errors, 'dbname', 'Name is a required field'); | ||
36 | } | ||
37 | |||
38 | if ($numOfErrors > 0) | ||
39 | { | ||
40 | showHeader('1'); | ||
41 | showStepOne($_POST['host'], $_POST['username'], $_POST['password'], $_POST['dbname'], $errors); | ||
42 | } else { | ||
43 | if (!@mysql_connect($_POST['host'], $_POST['username'], $_POST['password'])) | ||
44 | { | ||
45 | addError($numOfErrors, $errors, '', 'Cannot connect to database server'); | ||
46 | showHeader('1'); | ||
47 | showStepOne($_POST['host'], $_POST['username'], $_POST['password'], $_POST['dbname'], $errors); | ||
48 | } else { | ||
49 | if (!@mysql_select_db($_POST['dbname'])) | ||
50 | { | ||
51 | addError($numOfErrors, $errors, 'dbname', 'Database does not exist'); | ||
52 | showHeader('1'); | ||
53 | showStepOne($_POST['host'], $_POST['username'], $_POST['password'], $_POST['dbname'], $errors); | ||
54 | } else { | ||
55 | $sql = file_get_contents('instadisc.sql'); | ||
56 | $makedb = split(';', $sql); | ||
57 | foreach ($makedb as $name => $value) | ||
58 | { | ||
59 | if (!trim($value) == '') | ||
60 | { | ||
61 | $makedb2 = @mysql_query($value); | ||
62 | if (!$makedb2) | ||
63 | { | ||
64 | addError($numOfErrors, $errors, '', "MySQL error \"" . mysql_error() . "\" while creating database"); | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | |||
69 | @file_put_contents('config.php', "<?php\n\n/* InstaDisc Server - A Four Island Project */\n\n\$dbhost = \"" . $_POST['host'] . "\";\n\$dbuser = \"" . $_POST['username'] . "\";\n\$dbpass = \"" . $_POST['password'] . "\";\n\$dbname = \"" . $_POST['dbname'] . "\";\n\n?>"); | ||
70 | |||
71 | if (!file_exists('config.php')) | ||
72 | { | ||
73 | addError($numOfErrors, $errors, '', 'Could not write config.php file, please check directory permissions'); | ||
74 | } | ||
75 | |||
76 | if ($numOfErrors > 0) | ||
77 | { | ||
78 | showHeader('1'); | ||
79 | showStepOne($_POST['host'], $_POST['username'], $_POST['password'], $_POST['dbname'], $errors); | ||
80 | } else { | ||
81 | showHeader('2'); | ||
82 | showStepTwo('','',' CHECKED','','','','','','','', array()); | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | |||
88 | break; | ||
89 | |||
90 | case 2: | ||
91 | if ($_POST['mailDomain'] == '') | ||
92 | { | ||
93 | addError($numOfErrors, $errors, 'mailDomain', 'Mail Domain is a required field'); | ||
94 | } | ||
95 | |||
96 | if ($_POST['smtpHost'] == '') | ||
97 | { | ||
98 | addError($numOfErrors, $errors, 'smtpHost', 'SMTP Host is a required field'); | ||
99 | } | ||
100 | |||
101 | if ($_POST['smtpAuth'] == 'on') | ||
102 | { | ||
103 | if ($_POST['smtpUser'] == '') | ||
104 | { | ||
105 | addError($numOfErrors, $errors, 'smtpUser', 'When "SMTP Authentication Required?" is checked, SMTP Username is a required field'); | ||
106 | } | ||
107 | |||
108 | if ($_POST['smtpPass'] == '') | ||
109 | { | ||
110 | addError($numOfErrors, $errors, 'smtpPass', 'When "SMTP Authentication Required?" is checked, SMTP Password is a required field'); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | if ($_POST['siteName'] == '') | ||
115 | { | ||
116 | addError($numOfErrors, $errors, 'siteName', 'Site Name is a required field'); | ||
117 | } | ||
118 | |||
119 | if ($_POST['xmlrpcURL'] == '') | ||
120 | { | ||
121 | addError($numOfErrors, $errors, 'xmlrpcURL', 'XML-RPC URL is a required field'); | ||
122 | } else { | ||
123 | include_once('xmlrpc/xmlrpc.inc'); | ||
124 | |||
125 | $client = new xmlrpc_client($_POST['xmlrpcURL']); | ||
126 | $msg = new xmlrpcmsg('system.listMethods'); | ||
127 | $r = $client->send($msg); | ||
128 | if (stripos($r->faultString(),'Connect error') !== FALSE) | ||
129 | { | ||
130 | addError($numOfErrors, $errors, 'xmlrpcURL', $r->faultString()); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | if ($_POST['adminUser'] == '') | ||
135 | { | ||
136 | addError($numOfErrors, $errors, 'adminUser', 'Admin Username is a required field'); | ||
137 | } | ||
138 | |||
139 | if ($_POST['adminPass'] == '') | ||
140 | { | ||
141 | addError($numOfErrors, $errors, 'adminPass', 'Admin Password is a required field'); | ||
142 | } | ||
143 | |||
144 | if ($_POST['adminEmail'] == '') | ||
145 | { | ||
146 | addError($numOfErrors, $errors, 'adminEmail', 'Admin Email is a required field'); | ||
147 | } | ||
148 | |||
149 | if ($numOfErrors > 0) | ||
150 | { | ||
151 | showHeader('2'); | ||
152 | showStepTwo($_POST['mailDomain'], $_POST['smtpHost'], ($_POST['smtpAuth'] == 'on' ? ' CHECKED' : ''), $_POST['smtpUser'], $_POST['smtpPass'], $_POST['siteName'], $_POST['xmlrpcURL'], $_POST['adminUser'], $_POST['adminPass'], $_POST['adminEmail'], $errors); | ||
153 | } else { | ||
154 | include_once('config.php'); | ||
155 | |||
156 | mysql_connect($dbhost, $dbuser, $dbpass); | ||
157 | mysql_select_db($dbname); | ||
158 | |||
159 | $sql[0] = "INSERT INTO config (name,value) VALUES (\"mailDomain\",\"" . mysql_real_escape_string($_POST['mailDomain']) . "\")"; | ||
160 | $sql[1] = "INSERT INTO config (name,value) VALUES (\"smtpHost\",\"" . mysql_real_escape_string($_POST['smtpHost']) . "\")"; | ||
161 | $sql[2] = "INSERT INTO config (name,value) VALUES (\"smtpAuth\",\"" . mysql_real_escape_string($_POST['smtpAuth']) . "\")"; | ||
162 | $sql[3] = "INSERT INTO config (name,value) VALUES (\"smtpUser\",\"" . mysql_real_escape_string($_POST['smtpUser']) . "\")"; | ||
163 | $sql[4] = "INSERT INTO config (name,value) VALUES (\"smtpPass\",\"" . mysql_real_escape_string($_POST['smtpPass']) . "\")"; | ||
164 | $sql[5] = "INSERT INTO config (name,value) VALUES (\"siteName\",\"" . mysql_real_escape_string($_POST['siteName']) . "\")"; | ||
165 | $sql[6] = "INSERT INTO config (name,value) VALUES (\"xmlrpcURL\",\"" . mysql_real_escape_string($_POST['xmlrpcURL']) . "\")"; | ||
166 | $sql[7] = "INSERT INTO config (name,value) VALUES (\"owner\",\"" . mysql_real_escape_string($_POST['adminUser']) . "\")"; | ||
167 | $sql[8] = "INSERT INTO config (name,value) VALUES (\"verIDBufferSize\",\"100\")"; | ||
168 | $sql[9] = "INSERT INTO config (name,value) VALUES (\"softwareVersion\",\"" . $softwareVersion . "\")"; | ||
169 | $sql[10] = "INSERT INTO config (name,value) VALUES (\"databaseVersion\",\"1\")"; | ||
170 | $sql[11] = "INSERT INTO users (username, password, email, ip) VALUES (\"" . mysql_real_escape_string($_POST['adminUser']) . "\",\"" . mysql_real_escape_string(md5($_POST['adminPass'])) . "\",\"" . mysql_real_escape_string($_POST['adminEmail']) . "\",\"" . mysql_real_escape_string($_SERVER['REMOTE_IP']) . "\")"; | ||
171 | $sql[12] = "INSERT INTO centralServers (url, code, xmlrpc) VALUES (\"" . mysql_real_escape_string('central.fourisland.com') . "\",\"" . mysql_real_escape_string(md5('central.fourisland.com')) . "\",\"" . mysql_real_escape_string('http://central.fourisland.com/xmlrpc.php') . "\")"; | ||
172 | |||
173 | foreach ($sql as $name => $value) | ||
174 | { | ||
175 | if (!trim($value) == '') | ||
176 | { | ||
177 | $sql2 = @mysql_query($value); | ||
178 | if (!$sql2) | ||
179 | { | ||
180 | addError($numOfErrors, $errors, '', "MySQL error \"" . mysql_error() . "\" while filling database"); | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | |||
185 | if ($numOfErrors > 0) | ||
186 | { | ||
187 | showHeader('2'); | ||
188 | showStepTwo($_POST['mailDomain'], $_POST['smtpHost'], ($_POST['smtpAuth'] == 'on' ? ' CHECKED' : ''), $_POST['smtpUser'], $_POST['smtpPass'], $_POST['siteName'], $_POST['xmlrpcURL'], $_POST['adminUser'], $_POST['adminPass'], $_POST['adminEmail'], $errors); | ||
189 | } else { | ||
190 | showHeader('3'); | ||
191 | showStepThree(); | ||
192 | } | ||
193 | } | ||
194 | |||
195 | break; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | ?><P><CENTER><SMALL><SMALL>InstaDisc (C) Starla Insigna 2008. InstaDisc Setup uses the UniForm form theme</SMALL></SMALL></CENTER></BODY></HTML><?php | ||
200 | |||
201 | function showHeader($number) | ||
6 | { | 202 | { |
7 | ?>Welcome to the InstaDisc Central Server installation! Please input your database details here:<P><FORM ACTION="./install.php?step=2" METHOD="POST">Database host: <INPUT TYPE="text" NAME="host" VALUE="localhost"><BR>Username: <INPUT TYPE="text" NAME="username" VALUE="root"><BR>Password: <INPUT TYPE="text" NAME="password"><BR>Database name: <INPUT TYPE="text" NAME="name"> (Note: You must create this database BEFORE running installation)<BR><INPUT TYPE="submit"></FORM><?php | 203 | ?><HTML><HEAD><TITLE>InstaDisc Server Setup Step <?php echo($number); ?></TITLE><LINK REL="stylesheet" TYPE="text/css" HREF="uniform.css"></HEAD><BODY><CENTER><H1>InstaDisc Installation</H1></CENTER><P><?php |
8 | } else if ($_GET['step']==2) | 204 | } |
205 | |||
206 | function showStepOne($host, $username, $password, $dbname, $errors) | ||
9 | { | 207 | { |
10 | if (!mysql_connect($_POST['host'], $_POST['username'], $_POST['password'])) | 208 | ?>Welcome to the InstaDisc Central Server installation! Please input your database details below.<P> |
209 | <FORM CLASS="uniform" ACTION="./install.php?submit=1" METHOD="POST"> | ||
210 | <?php | ||
211 | if (isset($errors[1])) | ||
11 | { | 212 | { |
12 | ?>Cannot connect to your database server! Please verify you typed you host, username and password correctly. <A HREF="./install.php">Back</A><?php exit(); | 213 | ?><DIV ID="errorMsg">Uh oh! Validation errors!<P> |
214 | <OL><?php | ||
215 | foreach ($errors as $name => $value) | ||
216 | { | ||
217 | ?><LI><A HREF="#error<?php echo($name); ?>"><?php echo($value['msg']); ?></A></LI><?php | ||
218 | } | ||
219 | ?></OL></DIV><?php | ||
13 | } | 220 | } |
14 | if (!mysql_select_db($_POST['name'])) | 221 | ?> |
222 | <FIELDSET CLASS="inlineLabels"><LEGEND>Database Details</LEGEND> | ||
223 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'host'); ?>"> | ||
224 | <?php doErrors($errors, 'host'); ?> <LABEL FOR="host"><EM>*</EM> Host: </LABEL> | ||
225 | <INPUT TYPE="text" ID="host" NAME="host" CLASS="textInput" VALUE="<?php echo($host); ?>"> | ||
226 | </DIV> | ||
227 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'username'); ?>"> | ||
228 | <?php doErrors($errors, 'username'); ?> <LABEL FOR="username"><EM>*</EM> Username: </LABEL> | ||
229 | <INPUT TYPE="text" ID="username" NAME="username" CLASS="textInput" VALUE="<?php echo($username); ?>"> | ||
230 | </DIV> | ||
231 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'password'); ?>"> | ||
232 | <?php doErrors($errors, 'password'); ?> <LABEL FOR="password"><EM>*</EM> Password: </LABEL> | ||
233 | <INPUT TYPE="password" ID="password" NAME="password" CLASS="textInput" VALUE="<?php echo($password); ?>"> | ||
234 | </DIV> | ||
235 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'dbname'); ?>"> | ||
236 | <?php doErrors($errors, 'dbname'); ?> <LABEL FOR="dbname"><EM>*</EM> Name: </LABEL> | ||
237 | <INPUT TYPE="text" ID="dbname" NAME="dbname" CLASS="textInput" VALUE="<?php echo($dbname); ?>"> | ||
238 | <P CLASS="formHint">You need to create this database before running this script.</P> | ||
239 | </DIV> | ||
240 | </FIELDSET> | ||
241 | <DIV CLASS="buttonHolder"> | ||
242 | <INPUT TYPE="submit" VALUE="Next"> | ||
243 | </DIV></FORM><?php | ||
244 | } | ||
245 | |||
246 | function showStepTwo($mailDomain, $smtpHost, $smtpAuth, $smtpUser, $smtpPass, $siteName, $xmlrpcURL, $adminUser, $adminPass, $adminEmail, $errors) | ||
247 | { | ||
248 | ?>Your database has been set up. All we need to do now is fill it up a little. Please answer the below questions to set up your configuration: | ||
249 | <FORM CLASS="uniform" ACTION="./install.php?submit=2" METHOD="POST"> | ||
250 | <?php | ||
251 | if (isset($errors[1])) | ||
15 | { | 252 | { |
16 | ?>Cannot connect to your database! Please verify that the database you specified already exists and that you spelled it correctly. <A HREF="./install.php">Back</A><?php exit(); | 253 | ?><DIV ID="errorMsg">Uh oh! Validation errors!<P> |
254 | <OL><?php | ||
255 | foreach ($errors as $name => $value) | ||
256 | { | ||
257 | ?><LI><A HREF="#error<?php echo($name); ?>"><?php echo($value['msg']); ?></A></LI><?php | ||
258 | } | ||
259 | ?></OL></DIV><?php | ||
17 | } | 260 | } |
261 | ?> | ||
262 | <FIELDSET CLASS="inlineLabels"><LEGEND>Email</LEGEND> | ||
263 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'mailDomain'); ?>"> | ||
264 | <?php doErrors($errors, 'mailDomain'); ?> <LABEL FOR="mailDomain"><EM>*</EM> Mail Domain: </LABEL> | ||
265 | <INPUT TYPE="text" ID="mailDomain" NAME="mailDomain" CLASS="textInput" VALUE="<?php echo($mailDomain); ?>"> | ||
266 | <P CLASS="formHint">Type in the part that comes after the @ in your email addresses. This is used when InstaDisc needs to send an email to someone.</P> | ||
267 | </DIV> | ||
268 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'smtpHost'); ?>"> | ||
269 | <?php doErrors($errors, 'smtpHost'); ?> <LABEL FOR="smtpHost"><EM>*</EM> SMTP Host: </LABEL> | ||
270 | <INPUT TYPE="text" ID="smtpHost" NAME="smtpHost" CLASS="textInput" VALUE="<?php echo($smtpHost); ?>"> | ||
271 | <P CLASS="formHint">This is required because InstaDisc has to be able to send emails to people.</P> | ||
272 | </DIV> | ||
273 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'smtpAuth'); ?>"> | ||
274 | <?php doErrors($errors, 'smtpAuth'); ?> <LABEL FOR="smtpAuth">SMTP Authentication Required? </LABEL> | ||
275 | <INPUT TYPE="checkbox" ID="smtpAuth" NAME="smtpAuth" CLASS="textInput"<?php echo($smtpAuth); ?>"> | ||
276 | <P CLASS="formHint">If your SMTP server requires authentication (most do), you need to check this box and enter the authentication details in the fields below.</P> | ||
277 | </DIV> | ||
278 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'smtpUser'); ?>"> | ||
279 | <?php doErrors($errors, 'smtpUser'); ?> <LABEL FOR="smtpUser">SMTP Username: </LABEL> | ||
280 | <INPUT TYPE="text" ID="smtpUser" NAME="smtpUser" CLASS="textInput" VALUE="<?php echo($smtpUser); ?>"> | ||
281 | </DIV> | ||
282 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'smtpPass'); ?>"> | ||
283 | <?php doErrors($errors, 'smtpPass'); ?> <LABEL FOR="smtpPass">SMTP Password: </LABEL> | ||
284 | <INPUT TYPE="password" ID="smtpPass" NAME="smtpPass" CLASS="textInput" VALUE="<?php echo($smtpPass); ?>"> | ||
285 | <P CLASS="formHint">The two above fields only need be filled out if the "SMTP Authentication Required?" box is checked.</P> | ||
286 | </DIV> | ||
287 | </FIELDSET><FIELDSET CLASS="inlineLabels"><LEGEND>Website</LEGEND> | ||
288 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'siteName'); ?>"> | ||
289 | <?php doErrors($errors, 'siteName'); ?> <LABEL FOR="siteName"><EM>*</EM> Site Name: </LABEL> | ||
290 | <INPUT TYPE="text" ID="siteName" NAME="siteName" CLASS="textInput" VALUE="<?php echo($siteName); ?>"> | ||
291 | <P CLASS="formHint">Your website's name is required for a little personalization of emails.</P> | ||
292 | </DIV> | ||
293 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'xmlrpcURL'); ?>"> | ||
294 | <?php doErrors($errors, 'xmlrpcURL'); ?> <LABEL FOR="xmlrpcURL"><EM>*</EM> XML-RPC URL: </LABEL> | ||
295 | <INPUT TYPE="text" ID="xmlrpcURL" NAME="xmlrpcURL" CLASS="textInput" VALUE="<?php echo($xmlrpcURL); ?>"> | ||
296 | <P CLASS="formHint">What is the URL of the xmlrpc.php file provided for you in the InstaDisc package?</P> | ||
297 | </DIV> | ||
298 | </FIELDSET><FIELDSET CLASS="inlineLabels"><LEGEND>Administrator's Account</LEGEND> | ||
299 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'adminUser'); ?>"> | ||
300 | <?php doErrors($errors, 'adminUser'); ?> <LABEL FOR="adminUser"><EM>*</EM> Admin Username: </LABEL> | ||
301 | <INPUT TYPE="text" ID="adminUser" NAME="adminUser" CLASS="textInput" VALUE="<?php echo($adminUser); ?>"> | ||
302 | </DIV> | ||
303 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'adminPass'); ?>"> | ||
304 | <?php doErrors($errors, 'adminPass'); ?> <LABEL FOR="adminPass"><EM>*</EM> Admin Password: </LABEL> | ||
305 | <INPUT TYPE="password" ID="adminPass" NAME="adminPass" CLASS="textInput" VALUE="<?php echo($adminPass); ?>"> | ||
306 | </DIV> | ||
307 | <DIV CLASS="ctrlHolder<?php ifErrors($errors, 'adminEmail'); ?>"> | ||
308 | <?php doErrors($errors, 'adminEmail'); ?> <LABEL FOR="adminEmail"><EM>*</EM> Admin Email: </LABEL> | ||
309 | <INPUT TYPE="text" ID="adminEmail" NAME="adminEmail" CLASS="textInput" VALUE="<?php echo($adminEmail); ?>"> | ||
310 | <P CLASS="formHint">You, the administrator, must have an account on your InstaDisc server to be able to edit configuration values (mostly the ones you just entered) at will.</P> | ||
311 | </DIV> | ||
312 | </FIELDSET> | ||
313 | <DIV CLASS="buttonHolder"> | ||
314 | <INPUT TYPE="submit" VALUE="Next"> | ||
315 | </DIV></FORM><?php | ||
316 | } | ||
18 | 317 | ||
318 | function showStepThree() | ||
319 | { | ||
19 | ?>Congradulations! You've successfully set up your InstaDisc Central Server's database! Now, the next step for you is to implement the functions in instadisc.php into your web application. Read README.txt for more information.<?php | 320 | ?>Congradulations! You've successfully set up your InstaDisc Central Server's database! Now, the next step for you is to implement the functions in instadisc.php into your web application. Read README.txt for more information.<?php |
20 | } | 321 | } |
21 | ?> | 322 | |
323 | function ifErrors($errors, $id) | ||
324 | { | ||
325 | foreach ($errors as $name => $value) | ||
326 | { | ||
327 | if ($value['field'] == $id) | ||
328 | { | ||
329 | echo(' error'); | ||
330 | return; | ||
331 | } | ||
332 | } | ||
333 | } | ||
334 | |||
335 | |||
336 | function doErrors($errors, $id) | ||
337 | { | ||
338 | foreach ($errors as $name => $value) | ||
339 | { | ||
340 | if ($value['field'] == $id) | ||
341 | { | ||
342 | ?> <P ID="error<?php echo($name); ?>" CLASS="errorField"><EM>*</EM> <?php echo($value['msg']); ?></P><?php echo("\n"); | ||
343 | } | ||
344 | } | ||
345 | } | ||
346 | |||
347 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
348 | { | ||
349 | $numOfErrors++; | ||
350 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
351 | } | ||