diff options
-rw-r--r-- | central/trunk/instadisc.php | 7 | ||||
-rw-r--r-- | central/trunk/install.php | 160 |
2 files changed, 98 insertions, 69 deletions
diff --git a/central/trunk/instadisc.php b/central/trunk/instadisc.php index 34bf74e..a1d491a 100644 --- a/central/trunk/instadisc.php +++ b/central/trunk/instadisc.php | |||
@@ -180,9 +180,9 @@ function instaDisc_sendActivationEmail($username, $password, $email) | |||
180 | $mail->AddAddress($email, $username); | 180 | $mail->AddAddress($email, $username); |
181 | $mail->Subject = 'InstaDisc Account Verification'; | 181 | $mail->Subject = 'InstaDisc Account Verification'; |
182 | $mail->Body = "Hello, someone has recently registered an account at " . $_SERVER['HTTP_HOST'] . " with your email address. If that was you, and your chosen username IS " . $username . ", then copy the account verification code below to our Account Verification page, enter your username and press Activate!\r\n\r\n" . $penKey . "\r\n\r\nIf that was not you, copy the above code to our Account Verification page, enter the above username, and click Delete."; | 182 | $mail->Body = "Hello, someone has recently registered an account at " . $_SERVER['HTTP_HOST'] . " with your email address. If that was you, and your chosen username IS " . $username . ", then copy the account verification code below to our Account Verification page, enter your username and press Activate!\r\n\r\n" . $penKey . "\r\n\r\nIf that was not you, copy the above code to our Account Verification page, enter the above username, and click Delete."; |
183 | |||
184 | $mail->Send(); | 183 | $mail->Send(); |
185 | return ($mail->IsError() ? $mail->ErrorInfo : true); //$mail->Send(); | 184 | |
185 | return ($mail->IsError() ? $mail->ErrorInfo : true); | ||
186 | } | 186 | } |
187 | 187 | ||
188 | function instaDisc_activateAccount($username, $penKey) | 188 | function instaDisc_activateAccount($username, $penKey) |
@@ -202,8 +202,9 @@ function instaDisc_activateAccount($username, $penKey) | |||
202 | $mail->AddAddress($getuser3['email'], $username); | 202 | $mail->AddAddress($getuser3['email'], $username); |
203 | $mail->Subject = 'Welcome to InstaDisc!'; | 203 | $mail->Subject = 'Welcome to InstaDisc!'; |
204 | $mail->Body = "Welcome to InstaDisc! Thank you for registering at " . instaDisc_getConfig('siteName') . " Central Server, we hope you enjoy our service! Now, when you download an InstaDisc Client, it will ask you for the following information which you will need to enter into it for it to work:\r\n\r\nUsername: " . $username . "\r\nPassword: (you should know this, it's not displayed here for security reasons)\r\nCentral Server URL: " . instaDisc_getConfig("xmlrpcURL") . "\r\n\r\nOnce again, thank you for choosing " . instaDisc_getConfig("siteName") . "!"; | 204 | $mail->Body = "Welcome to InstaDisc! Thank you for registering at " . instaDisc_getConfig('siteName') . " Central Server, we hope you enjoy our service! Now, when you download an InstaDisc Client, it will ask you for the following information which you will need to enter into it for it to work:\r\n\r\nUsername: " . $username . "\r\nPassword: (you should know this, it's not displayed here for security reasons)\r\nCentral Server URL: " . instaDisc_getConfig("xmlrpcURL") . "\r\n\r\nOnce again, thank you for choosing " . instaDisc_getConfig("siteName") . "!"; |
205 | $mail->Send(); | ||
205 | 206 | ||
206 | return $mail->Send(); | 207 | return ($mail->IsError() ? $mail->ErrorInfo : true); |
207 | } else { | 208 | } else { |
208 | return false; | 209 | return false; |
209 | } | 210 | } |
diff --git a/central/trunk/install.php b/central/trunk/install.php index 846140a..5022faf 100644 --- a/central/trunk/install.php +++ b/central/trunk/install.php | |||
@@ -88,11 +88,6 @@ if (!isset($_GET['submit'])) | |||
88 | break; | 88 | break; |
89 | 89 | ||
90 | case 2: | 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'] == '') | 91 | if ($_POST['smtpHost'] == '') |
97 | { | 92 | { |
98 | addError($numOfErrors, $errors, 'smtpHost', 'SMTP Host is a required field'); | 93 | addError($numOfErrors, $errors, 'smtpHost', 'SMTP Host is a required field'); |
@@ -111,84 +106,117 @@ if (!isset($_GET['submit'])) | |||
111 | } | 106 | } |
112 | } | 107 | } |
113 | 108 | ||
114 | if ($_POST['siteName'] == '') | 109 | if ($numOfErrors > 0) |
115 | { | ||
116 | addError($numOfErrors, $errors, 'siteName', 'Site Name is a required field'); | ||
117 | } | ||
118 | |||
119 | if ($_POST['xmlrpcURL'] == '') | ||
120 | { | 110 | { |
121 | addError($numOfErrors, $errors, 'xmlrpcURL', 'XML-RPC URL is a required field'); | 111 | showHeader('2'); |
112 | showStepTwo($_POST['mailDomain'], $_POST['smtpHost'], ($_POST['smtpAuth'] == 'on' ? ' CHECKED' : ''), $_POST['smtpUser'], $_POST['smtpPass'], $_POST['siteName'], $_POST['xmlrpcURL'], $_POST['adminUser'], $_POST['adminPass'], $_POST['adminEmail'], $errors); | ||
122 | } else { | 113 | } else { |
123 | include_once('xmlrpc/xmlrpc.inc'); | 114 | $mail = new PHPMailer(); |
124 | 115 | $mail->IsSMTP(); | |
125 | $client = new xmlrpc_client($_POST['xmlrpcURL']); | 116 | $mail->From = 'instadisc@' . $_POST['mailDomain']; |
126 | $msg = new xmlrpcmsg('system.listMethods'); | 117 | $mail->FromName = 'InstaDisc'; |
127 | $r = $client->send($msg); | 118 | $mail->Host = $_POST['smtpHost']; |
128 | if (stripos($r->faultString(),'Connect error') !== FALSE) | 119 | if ($_POST['smtpAuth'] == 'on') |
120 | { | ||
121 | $mail->SMTPAuth = true; | ||
122 | $mail->Username = $_POST['smtpUser']; | ||
123 | $mail->Password = $_POST['smtpPass']; | ||
124 | } | ||
125 | $mail->Helo = $_SERVER['HTTP_HOST']; | ||
126 | $mail->ClearAddresses(); | ||
127 | $mail->AddAddress("test@fourisland.com"); | ||
128 | $mail->Subject = 'Test Email'; | ||
129 | $mail->Body = 'Please discard this email.'; | ||
130 | $mail->Send(); | ||
131 | if ($mail->IsError()) | ||
129 | { | 132 | { |
130 | addError($numOfErrors, $errors, 'xmlrpcURL', $r->faultString()); | 133 | addError($numOfErrors, $errors, '', $mail->ErrorInfo); |
131 | } | 134 | } |
132 | } | ||
133 | 135 | ||
134 | if ($_POST['adminUser'] == '') | 136 | if ($_POST['mailDomain'] == '') |
135 | { | 137 | { |
136 | addError($numOfErrors, $errors, 'adminUser', 'Admin Username is a required field'); | 138 | addError($numOfErrors, $errors, 'mailDomain', 'Mail Domain is a required field'); |
137 | } | 139 | } |
138 | |||
139 | if ($_POST['adminPass'] == '') | ||
140 | { | ||
141 | addError($numOfErrors, $errors, 'adminPass', 'Admin Password is a required field'); | ||
142 | } | ||
143 | 140 | ||
144 | if ($_POST['adminEmail'] == '') | 141 | if ($_POST['siteName'] == '') |
145 | { | 142 | { |
146 | addError($numOfErrors, $errors, 'adminEmail', 'Admin Email is a required field'); | 143 | addError($numOfErrors, $errors, 'siteName', 'Site Name is a required field'); |
147 | } | 144 | } |
148 | 145 | ||
149 | if ($numOfErrors > 0) | 146 | if ($_POST['xmlrpcURL'] == '') |
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'] == 'on' ? 'true' : 'false')) . "\")"; | ||
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_ADDR']) . "\")"; | ||
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 | { | 147 | { |
175 | if (!trim($value) == '') | 148 | addError($numOfErrors, $errors, 'xmlrpcURL', 'XML-RPC URL is a required field'); |
149 | } else { | ||
150 | include_once('xmlrpc/xmlrpc.inc'); | ||
151 | |||
152 | $client = new xmlrpc_client($_POST['xmlrpcURL']); | ||
153 | $msg = new xmlrpcmsg('system.listMethods'); | ||
154 | $r = $client->send($msg); | ||
155 | if (stripos($r->faultString(),'Connect error') !== FALSE) | ||
176 | { | 156 | { |
177 | $sql2 = @mysql_query($value); | 157 | addError($numOfErrors, $errors, 'xmlrpcURL', $r->faultString()); |
178 | if (!$sql2) | ||
179 | { | ||
180 | addError($numOfErrors, $errors, '', "MySQL error \"" . mysql_error() . "\" while filling database"); | ||
181 | } | ||
182 | } | 158 | } |
183 | } | 159 | } |
184 | 160 | ||
161 | if ($_POST['adminUser'] == '') | ||
162 | { | ||
163 | addError($numOfErrors, $errors, 'adminUser', 'Admin Username is a required field'); | ||
164 | } | ||
165 | |||
166 | if ($_POST['adminPass'] == '') | ||
167 | { | ||
168 | addError($numOfErrors, $errors, 'adminPass', 'Admin Password is a required field'); | ||
169 | } | ||
170 | |||
171 | if ($_POST['adminEmail'] == '') | ||
172 | { | ||
173 | addError($numOfErrors, $errors, 'adminEmail', 'Admin Email is a required field'); | ||
174 | } | ||
175 | |||
185 | if ($numOfErrors > 0) | 176 | if ($numOfErrors > 0) |
186 | { | 177 | { |
187 | showHeader('2'); | 178 | 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); | 179 | 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 { | 180 | } else { |
190 | showHeader('3'); | 181 | include_once('config.php'); |
191 | showStepThree(); | 182 | |
183 | mysql_connect($dbhost, $dbuser, $dbpass); | ||
184 | mysql_select_db($dbname); | ||
185 | |||
186 | $sql[0] = "INSERT INTO config (name,value) VALUES (\"mailDomain\",\"" . mysql_real_escape_string($_POST['mailDomain']) . "\")"; | ||
187 | $sql[1] = "INSERT INTO config (name,value) VALUES (\"smtpHost\",\"" . mysql_real_escape_string($_POST['smtpHost']) . "\")"; | ||
188 | $sql[2] = "INSERT INTO config (name,value) VALUES (\"smtpAuth\",\"" . mysql_real_escape_string(($_POST['smtpAuth'] == 'on' ? 'true' : 'false')) . "\")"; | ||
189 | $sql[3] = "INSERT INTO config (name,value) VALUES (\"smtpUser\",\"" . mysql_real_escape_string($_POST['smtpUser']) . "\")"; | ||
190 | $sql[4] = "INSERT INTO config (name,value) VALUES (\"smtpPass\",\"" . mysql_real_escape_string($_POST['smtpPass']) . "\")"; | ||
191 | $sql[5] = "INSERT INTO config (name,value) VALUES (\"siteName\",\"" . mysql_real_escape_string($_POST['siteName']) . "\")"; | ||
192 | $sql[6] = "INSERT INTO config (name,value) VALUES (\"xmlrpcURL\",\"" . mysql_real_escape_string($_POST['xmlrpcURL']) . "\")"; | ||
193 | $sql[7] = "INSERT INTO config (name,value) VALUES (\"owner\",\"" . mysql_real_escape_string($_POST['adminUser']) . "\")"; | ||
194 | $sql[8] = "INSERT INTO config (name,value) VALUES (\"verIDBufferSize\",\"100\")"; | ||
195 | $sql[9] = "INSERT INTO config (name,value) VALUES (\"softwareVersion\",\"" . $softwareVersion . "\")"; | ||
196 | $sql[10] = "INSERT INTO config (name,value) VALUES (\"databaseVersion\",\"1\")"; | ||
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 | $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') . "\")"; | ||
199 | |||
200 | foreach ($sql as $name => $value) | ||
201 | { | ||
202 | if (!trim($value) == '') | ||
203 | { | ||
204 | $sql2 = @mysql_query($value); | ||
205 | if (!$sql2) | ||
206 | { | ||
207 | addError($numOfErrors, $errors, '', "MySQL error \"" . mysql_error() . "\" while filling database"); | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
212 | if ($numOfErrors > 0) | ||
213 | { | ||
214 | showHeader('2'); | ||
215 | showStepTwo($_POST['mailDomain'], $_POST['smtpHost'], ($_POST['smtpAuth'] == 'on' ? ' CHECKED' : ''), $_POST['smtpUser'], $_POST['smtpPass'], $_POST['siteName'], $_POST['xmlrpcURL'], $_POST['adminUser'], $_POST['adminPass'], $_POST['adminEmail'], $errors); | ||
216 | } else { | ||
217 | showHeader('3'); | ||
218 | showStepThree(); | ||
219 | } | ||
192 | } | 220 | } |
193 | } | 221 | } |
194 | 222 | ||