about summary refs log tree commit diff stats
path: root/central/trunk/install.php
diff options
context:
space:
mode:
Diffstat (limited to 'central/trunk/install.php')
-rw-r--r--central/trunk/install.php176
1 files changed, 24 insertions, 152 deletions
diff --git a/central/trunk/install.php b/central/trunk/install.php index b7a97ab..4fd0172 100644 --- a/central/trunk/install.php +++ b/central/trunk/install.php
@@ -2,10 +2,6 @@
2 2
3/* InstaDisc Server - A Four Island Project */ 3/* InstaDisc Server - A Four Island Project */
4 4
5include('includes/class.phpmailer.php');
6
7$softwareVersion = 1;
8
9if (!isset($_GET['submit'])) 5if (!isset($_GET['submit']))
10{ 6{
11 showHeader('1'); 7 showHeader('1');
@@ -90,132 +86,49 @@ if (!isset($_GET['submit']))
90 break; 86 break;
91 87
92 case 2: 88 case 2:
93 if ($_POST['smtpHost'] == '') 89 if ($_POST['adminUser'] == '')
94 { 90 {
95 addError($numOfErrors, $errors, 'smtpHost', 'SMTP Host is a required field'); 91 addError($numOfErrors, $errors, 'adminUser', 'Admin Username is a required field');
96 } 92 }
97 93
98 if ($_POST['smtpAuth'] == 'on') 94 if ($_POST['adminPass'] == '')
99 { 95 {
100 if ($_POST['smtpUser'] == '') 96 addError($numOfErrors, $errors, 'adminPass', 'Admin Password is a required field');
101 {
102 addError($numOfErrors, $errors, 'smtpUser', 'When "SMTP Authentication Required?" is checked, SMTP Username is a required field');
103 }
104
105 if ($_POST['smtpPass'] == '')
106 {
107 addError($numOfErrors, $errors, 'smtpPass', 'When "SMTP Authentication Required?" is checked, SMTP Password is a required field');
108 }
109 } 97 }
110 98
111 if ($numOfErrors > 0) 99 if ($numOfErrors > 0)
112 { 100 {
113 showHeader('2'); 101 showHeader('2');
114 showStepTwo($_POST['mailDomain'], $_POST['smtpHost'], ($_POST['smtpAuth'] == 'on' ? ' CHECKED' : ''), $_POST['smtpUser'], $_POST['smtpPass'], $_POST['siteName'], $_POST['xmlrpcURL'], $_POST['adminUser'], $_POST['adminPass'], $_POST['adminEmail'], $errors); 102 showStepTwo($_POST['adminUser'], $_POST['adminPass'], $errors);
115 } else { 103 } else {
116 $mail = new PHPMailer(); 104 include_once('includes/config.php');
117 $mail->IsSMTP();
118 $mail->From = 'instadisc@' . $_POST['mailDomain'];
119 $mail->FromName = 'InstaDisc';
120 $mail->Host = $_POST['smtpHost'];
121 if ($_POST['smtpAuth'] == 'on')
122 {
123 $mail->SMTPAuth = true;
124 $mail->Username = $_POST['smtpUser'];
125 $mail->Password = $_POST['smtpPass'];
126 }
127 $mail->Helo = $_SERVER['HTTP_HOST'];
128 $mail->ClearAddresses();
129 $mail->AddAddress("test@fourisland.com");
130 $mail->Subject = 'Test Email';
131 $mail->Body = 'Please discard this email.';
132 $mail->Send();
133 if ($mail->IsError())
134 {
135 addError($numOfErrors, $errors, '', $mail->ErrorInfo);
136 }
137 105
138 if ($_POST['mailDomain'] == '') 106 mysql_connect($dbhost, $dbuser, $dbpass);
139 { 107 mysql_select_db($dbname);
140 addError($numOfErrors, $errors, 'mailDomain', 'Mail Domain is a required field');
141 }
142 108
143 if ($_POST['siteName'] == '') 109 $sql[0] = "INSERT INTO config (name,value) VALUES (\"owner\",\"" . mysql_real_escape_string($_POST['adminUser']) . "\")";
144 { 110 $sql[1] = "INSERT INTO config (name,value) VALUES (\"verIDBufferSize\",\"10000\")";
145 addError($numOfErrors, $errors, 'siteName', 'Site Name is a required field'); 111 $sql[2] = "INSERT INTO users (username, password, ip) VALUES (\"" . mysql_real_escape_string($_POST['adminUser']) . "\",\"" . mysql_real_escape_string(md5($_POST['adminPass'])) . "\",\"" . mysql_real_escape_string($_SERVER['REMOTE_ADDR']) . "\")";
146 }
147 112
148 if ($_POST['xmlrpcURL'] == '') 113 foreach ($sql as $name => $value)
149 { 114 {
150 addError($numOfErrors, $errors, 'xmlrpcURL', 'XML-RPC URL is a required field'); 115 if (!trim($value) == '')
151 } else {
152 include_once('includes/xmlrpc/xmlrpc.inc');
153
154 $client = new xmlrpc_client($_POST['xmlrpcURL']);
155 $msg = new xmlrpcmsg('system.listMethods');
156 $r = $client->send($msg);
157 if (stripos($r->faultString(),'Connect error') !== FALSE)
158 { 116 {
159 addError($numOfErrors, $errors, 'xmlrpcURL', $r->faultString()); 117 $sql2 = @mysql_query($value);
118 if (!$sql2)
119 {
120 addError($numOfErrors, $errors, '', "MySQL error \"" . mysql_error() . "\" while filling database");
121 }
160 } 122 }
161 } 123 }
162 124
163 if ($_POST['adminUser'] == '')
164 {
165 addError($numOfErrors, $errors, 'adminUser', 'Admin Username is a required field');
166 }
167
168 if ($_POST['adminPass'] == '')
169 {
170 addError($numOfErrors, $errors, 'adminPass', 'Admin Password is a required field');
171 }
172
173 if ($_POST['adminEmail'] == '')
174 {
175 addError($numOfErrors, $errors, 'adminEmail', 'Admin Email is a required field');
176 }
177
178 if ($numOfErrors > 0) 125 if ($numOfErrors > 0)
179 { 126 {
180 showHeader('2'); 127 showHeader('2');
181 showStepTwo($_POST['mailDomain'], $_POST['smtpHost'], ($_POST['smtpAuth'] == 'on' ? ' CHECKED' : ''), $_POST['smtpUser'], $_POST['smtpPass'], $_POST['siteName'], $_POST['xmlrpcURL'], $_POST['adminUser'], $_POST['adminPass'], $_POST['adminEmail'], $errors); 128 showStepTwo($_POST['adminUser'], $_POST['adminPass'], $errors);
182 } else { 129 } else {
183 include_once('includes/config.php'); 130 showHeader('3');
184 131 showStepThree();
185 mysql_connect($dbhost, $dbuser, $dbpass);
186 mysql_select_db($dbname);
187
188 $sql[0] = "INSERT INTO config (name,value) VALUES (\"mailDomain\",\"" . mysql_real_escape_string($_POST['mailDomain']) . "\")";
189 $sql[1] = "INSERT INTO config (name,value) VALUES (\"smtpHost\",\"" . mysql_real_escape_string($_POST['smtpHost']) . "\")";
190 $sql[2] = "INSERT INTO config (name,value) VALUES (\"smtpAuth\",\"" . mysql_real_escape_string(($_POST['smtpAuth'] == 'on' ? 'true' : 'false')) . "\")";
191 $sql[3] = "INSERT INTO config (name,value) VALUES (\"smtpUser\",\"" . mysql_real_escape_string($_POST['smtpUser']) . "\")";
192 $sql[4] = "INSERT INTO config (name,value) VALUES (\"smtpPass\",\"" . mysql_real_escape_string($_POST['smtpPass']) . "\")";
193 $sql[5] = "INSERT INTO config (name,value) VALUES (\"siteName\",\"" . mysql_real_escape_string($_POST['siteName']) . "\")";
194 $sql[6] = "INSERT INTO config (name,value) VALUES (\"xmlrpcURL\",\"" . mysql_real_escape_string($_POST['xmlrpcURL']) . "\")";
195 $sql[7] = "INSERT INTO config (name,value) VALUES (\"owner\",\"" . mysql_real_escape_string($_POST['adminUser']) . "\")";
196 $sql[8] = "INSERT INTO config (name,value) VALUES (\"verIDBufferSize\",\"10000\")";
197 $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_ADDR']) . "\")";
198
199 foreach ($sql as $name => $value)
200 {
201 if (!trim($value) == '')
202 {
203 $sql2 = @mysql_query($value);
204 if (!$sql2)
205 {
206 addError($numOfErrors, $errors, '', "MySQL error \"" . mysql_error() . "\" while filling database");
207 }
208 }
209 }
210
211 if ($numOfErrors > 0)
212 {
213 showHeader('2');
214 showStepTwo($_POST['mailDomain'], $_POST['smtpHost'], ($_POST['smtpAuth'] == 'on' ? ' CHECKED' : ''), $_POST['smtpUser'], $_POST['smtpPass'], $_POST['siteName'], $_POST['xmlrpcURL'], $_POST['adminUser'], $_POST['adminPass'], $_POST['adminEmail'], $errors);
215 } else {
216 showHeader('3');
217 showStepThree();
218 }
219 } 132 }
220 } 133 }
221 134
@@ -270,7 +183,7 @@ function showStepOne($host, $username, $password, $dbname, $errors)
270</DIV></FORM><?php 183</DIV></FORM><?php
271} 184}
272 185
273function showStepTwo($mailDomain, $smtpHost, $smtpAuth, $smtpUser, $smtpPass, $siteName, $xmlrpcURL, $adminUser, $adminPass, $adminEmail, $errors) 186function showStepTwo($adminUser, $adminPass, $errors)
274{ 187{
275?>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: 188?>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:
276<FORM CLASS="uniform" ACTION="./install.php?submit=2" METHOD="POST"> 189<FORM CLASS="uniform" ACTION="./install.php?submit=2" METHOD="POST">
@@ -286,43 +199,7 @@ function showStepTwo($mailDomain, $smtpHost, $smtpAuth, $smtpUser, $smtpPass, $s
286?></OL></DIV><?php 199?></OL></DIV><?php
287 } 200 }
288?> 201?>
289<FIELDSET CLASS="inlineLabels"><LEGEND>Email</LEGEND> 202<FIELDSET CLASS="inlineLabels"><LEGEND>Administrator's Account</LEGEND>
290<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'mailDomain'); ?>">
291<?php doErrors($errors, 'mailDomain'); ?> <LABEL FOR="mailDomain"><EM>*</EM> Mail Domain: </LABEL>
292 <INPUT TYPE="text" ID="mailDomain" NAME="mailDomain" CLASS="textInput" VALUE="<?php echo($mailDomain); ?>">
293 <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>
294</DIV>
295<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'smtpHost'); ?>">
296<?php doErrors($errors, 'smtpHost'); ?> <LABEL FOR="smtpHost"><EM>*</EM> SMTP Host: </LABEL>
297 <INPUT TYPE="text" ID="smtpHost" NAME="smtpHost" CLASS="textInput" VALUE="<?php echo($smtpHost); ?>">
298 <P CLASS="formHint">This is required because InstaDisc has to be able to send emails to people.</P>
299</DIV>
300<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'smtpAuth'); ?>">
301<?php doErrors($errors, 'smtpAuth'); ?> <LABEL FOR="smtpAuth">SMTP Authentication Required? </LABEL>
302 <INPUT TYPE="checkbox" ID="smtpAuth" NAME="smtpAuth" CLASS="textInput"<?php echo($smtpAuth); ?>">
303 <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>
304</DIV>
305<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'smtpUser'); ?>">
306<?php doErrors($errors, 'smtpUser'); ?> <LABEL FOR="smtpUser">SMTP Username: </LABEL>
307 <INPUT TYPE="text" ID="smtpUser" NAME="smtpUser" CLASS="textInput" VALUE="<?php echo($smtpUser); ?>">
308</DIV>
309<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'smtpPass'); ?>">
310<?php doErrors($errors, 'smtpPass'); ?> <LABEL FOR="smtpPass">SMTP Password: </LABEL>
311 <INPUT TYPE="password" ID="smtpPass" NAME="smtpPass" CLASS="textInput" VALUE="<?php echo($smtpPass); ?>">
312 <P CLASS="formHint">The two above fields only need be filled out if the "SMTP Authentication Required?" box is checked.</P>
313</DIV>
314</FIELDSET><FIELDSET CLASS="inlineLabels"><LEGEND>Website</LEGEND>
315<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'siteName'); ?>">
316<?php doErrors($errors, 'siteName'); ?> <LABEL FOR="siteName"><EM>*</EM> Site Name: </LABEL>
317 <INPUT TYPE="text" ID="siteName" NAME="siteName" CLASS="textInput" VALUE="<?php echo($siteName); ?>">
318 <P CLASS="formHint">Your website's name is required for a little personalization of emails.</P>
319</DIV>
320<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'xmlrpcURL'); ?>">
321<?php doErrors($errors, 'xmlrpcURL'); ?> <LABEL FOR="xmlrpcURL"><EM>*</EM> XML-RPC URL: </LABEL>
322 <INPUT TYPE="text" ID="xmlrpcURL" NAME="xmlrpcURL" CLASS="textInput" VALUE="<?php echo($xmlrpcURL); ?>">
323 <P CLASS="formHint">What is the URL of the xmlrpc.php file provided for you in the InstaDisc package?</P>
324</DIV>
325</FIELDSET><FIELDSET CLASS="inlineLabels"><LEGEND>Administrator's Account</LEGEND>
326<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'adminUser'); ?>"> 203<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'adminUser'); ?>">
327<?php doErrors($errors, 'adminUser'); ?> <LABEL FOR="adminUser"><EM>*</EM> Admin Username: </LABEL> 204<?php doErrors($errors, 'adminUser'); ?> <LABEL FOR="adminUser"><EM>*</EM> Admin Username: </LABEL>
328 <INPUT TYPE="text" ID="adminUser" NAME="adminUser" CLASS="textInput" VALUE="<?php echo($adminUser); ?>"> 205 <INPUT TYPE="text" ID="adminUser" NAME="adminUser" CLASS="textInput" VALUE="<?php echo($adminUser); ?>">
@@ -331,11 +208,6 @@ function showStepTwo($mailDomain, $smtpHost, $smtpAuth, $smtpUser, $smtpPass, $s
331<?php doErrors($errors, 'adminPass'); ?> <LABEL FOR="adminPass"><EM>*</EM> Admin Password: </LABEL> 208<?php doErrors($errors, 'adminPass'); ?> <LABEL FOR="adminPass"><EM>*</EM> Admin Password: </LABEL>
332 <INPUT TYPE="password" ID="adminPass" NAME="adminPass" CLASS="textInput" VALUE="<?php echo($adminPass); ?>"> 209 <INPUT TYPE="password" ID="adminPass" NAME="adminPass" CLASS="textInput" VALUE="<?php echo($adminPass); ?>">
333</DIV> 210</DIV>
334<DIV CLASS="ctrlHolder<?php ifErrors($errors, 'adminEmail'); ?>">
335<?php doErrors($errors, 'adminEmail'); ?> <LABEL FOR="adminEmail"><EM>*</EM> Admin Email: </LABEL>
336 <INPUT TYPE="text" ID="adminEmail" NAME="adminEmail" CLASS="textInput" VALUE="<?php echo($adminEmail); ?>">
337 <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>
338</DIV>
339</FIELDSET> 211</FIELDSET>
340<DIV CLASS="buttonHolder"> 212<DIV CLASS="buttonHolder">
341 <INPUT TYPE="submit" VALUE="Next"> 213 <INPUT TYPE="submit" VALUE="Next">
@@ -344,7 +216,7 @@ function showStepTwo($mailDomain, $smtpHost, $smtpAuth, $smtpUser, $smtpPass, $s
344 216
345function showStepThree() 217function showStepThree()
346{ 218{
347?>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. See <A HREF="http://fourisland.com/projects/instadisc/wiki/BecomingACentralServer">Becoming A Central Server</A>. Also, it would be smart to subscribe to your InstaDisc Update Notice Subscription, which will notify you if your Central Server's software gets out of date. It's the subscription.php file in this directory. Please subscribe to it, thanks!<P>However, remember that to be any use to anyone, you need your Central Server database, and to be added to others'. To do this, please find the appropriate help section on http://fourisland.com/projects/instadisc/BecomingACentralServer<?php 219?>Congradulations! You've successfully set up your InstaDisc Central Server's database!<?php
348} 220}
349 221
350function ifErrors($errors, $id) 222function ifErrors($errors, $id)