diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-02 14:48:59 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-02 14:48:59 +0000 |
commit | f58e72c0d5181c5bf77393cf657d2c2bccee1073 (patch) | |
tree | 941ee1ae07d56ed77a16346dc8dcb35d7d9437e0 | |
parent | 7174283738786d0e4bfc9669bdc2a7134f410895 (diff) | |
download | instadisc-f58e72c0d5181c5bf77393cf657d2c2bccee1073.tar.gz instadisc-f58e72c0d5181c5bf77393cf657d2c2bccee1073.tar.bz2 instadisc-f58e72c0d5181c5bf77393cf657d2c2bccee1073.zip |
Central: Added instaDisc_getConfig()
This functions retrives a single configuration value out of the database.
-rw-r--r-- | central/trunk/instadisc.php | 25 | ||||
-rw-r--r-- | central/trunk/xmlrpc.php | 20 |
2 files changed, 27 insertions, 18 deletions
diff --git a/central/trunk/instadisc.php b/central/trunk/instadisc.php index e2796aa..c9bf051 100644 --- a/central/trunk/instadisc.php +++ b/central/trunk/instadisc.php | |||
@@ -24,7 +24,7 @@ function instaDisc_checkVerification($username, $verification, $verificationID, | |||
24 | $cntverid = "SELECT COUNT(*) FROM oldVerID WHERE username = \"" . mysql_escape_string($username) . "\""; | 24 | $cntverid = "SELECT COUNT(*) FROM oldVerID WHERE username = \"" . mysql_escape_string($username) . "\""; |
25 | $cntverid2 = mysql_query($cntverid); | 25 | $cntverid2 = mysql_query($cntverid); |
26 | $cntverid3 = mysql_fetch_array($cntverid2); | 26 | $cntverid3 = mysql_fetch_array($cntverid2); |
27 | if ($cntverid3[0] >= intval(getConfig('verIDBufferSize'))) | 27 | if ($cntverid3[0] >= intval(instaDisc_getConfig('verIDBufferSize'))) |
28 | { | 28 | { |
29 | $delverid = "DELETE FROM oldVerID WHERE username = \"" . mysql_escape_string($username) . "\""; | 29 | $delverid = "DELETE FROM oldVerID WHERE username = \"" . mysql_escape_string($username) . "\""; |
30 | $delverid2 = mysql_query($delverid); | 30 | $delverid2 = mysql_query($delverid); |
@@ -74,7 +74,7 @@ function instaDisc_sendItem($username, $id) | |||
74 | 74 | ||
75 | function instaDisc_sendUpdateNotice($softwareVersion) | 75 | function instaDisc_sendUpdateNotice($softwareVersion) |
76 | { | 76 | { |
77 | $username = getConfig('owner'); | 77 | $username = instaDisc_getConfig('owner'); |
78 | $subscription = 'http://' . $_SERVER['HTTP_HOST']; | 78 | $subscription = 'http://' . $_SERVER['HTTP_HOST']; |
79 | $title = 'Update your software to ' . $software; | 79 | $title = 'Update your software to ' . $software; |
80 | $author = 'Hatkirby'; | 80 | $author = 'Hatkirby'; |
@@ -132,14 +132,14 @@ function instaDisc_phpMailer() | |||
132 | { | 132 | { |
133 | $mail = new PHPMailer(); | 133 | $mail = new PHPMailer(); |
134 | $mail->IsSMTP(); | 134 | $mail->IsSMTP(); |
135 | $mail->From = 'instadisc@' . getConfig('mailDomain'); | 135 | $mail->From = 'instadisc@' . instaDisc_getConfig('mailDomain'); |
136 | $mail->FromName = 'InstaDisc'; | 136 | $mail->FromName = 'InstaDisc'; |
137 | $mail->Host = getConfig('smtpHost'); | 137 | $mail->Host = instaDisc_getConfig('smtpHost'); |
138 | if (getConfig('smtpAuth') == 'true') | 138 | if (instaDisc_getConfig('smtpAuth') == 'true') |
139 | { | 139 | { |
140 | $mail->SMTPAuth = true; | 140 | $mail->SMTPAuth = true; |
141 | $mail->Username = getConfig('smtpUser'); | 141 | $mail->Username = instaDisc_getConfig('smtpUser'); |
142 | $mail->Password = getConfig('smtpPass'); | 142 | $mail->Password = instaDisc_getConfig('smtpPass'); |
143 | } | 143 | } |
144 | $mail->Helo = $_SERVER['HTTP_HOST']; | 144 | $mail->Helo = $_SERVER['HTTP_HOST']; |
145 | $mail->ClearAddresses(); | 145 | $mail->ClearAddresses(); |
@@ -178,7 +178,7 @@ function instaDisc_activateAccount($username, $penKey) | |||
178 | $mail = instaDisc_phpMailer(); | 178 | $mail = instaDisc_phpMailer(); |
179 | $mail->AddAddress($getuser3['email'], $username); | 179 | $mail->AddAddress($getuser3['email'], $username); |
180 | $mail->Subject = 'Welcome to InstaDisc!'; | 180 | $mail->Subject = 'Welcome to InstaDisc!'; |
181 | $mail->Body = "Welcome to InstaDisc! Thank you for registering at " . 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: " . getConfig("xmlrpcURL") . "\r\n\r\nOnce again, thank you for choosing " . getConfig("siteName") . "!"; | 181 | $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") . "!"; |
182 | 182 | ||
183 | return $mail->Send(); | 183 | return $mail->Send(); |
184 | } else { | 184 | } else { |
@@ -229,4 +229,13 @@ function instaDisc_deleteAccount($username) | |||
229 | return false; | 229 | return false; |
230 | } | 230 | } |
231 | 231 | ||
232 | function instaDisc_getConfig($key) | ||
233 | { | ||
234 | $getconfig = "SELECT * FROM config WHERE name = \"" . mysql_escape_string($key) . "\""; | ||
235 | $getconfig2 = mysql_query($getconfig); | ||
236 | $getconfig3 = mysql_fetch_array($getconfig2); | ||
237 | |||
238 | return $getconfig3['value']; | ||
239 | } | ||
240 | |||
232 | ?> | 241 | ?> |
diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php index 2c6b2e6..bbf2f2d 100644 --- a/central/trunk/xmlrpc.php +++ b/central/trunk/xmlrpc.php | |||
@@ -103,8 +103,8 @@ function sendFromUpdate($username, $verification, $verificationID, $subscription | |||
103 | new xmlrpcval($author, 'string'), | 103 | new xmlrpcval($author, 'string'), |
104 | new xmlrpcval($url, 'string'), | 104 | new xmlrpcval($url, 'string'), |
105 | new xmlrpcval($semantics, 'array'), | 105 | new xmlrpcval($semantics, 'array'), |
106 | new xmlrpcval(getConfig('softwareVersion'), 'int'), | 106 | new xmlrpcval(instaDisc_getConfig('softwareVersion'), 'int'), |
107 | new xmlrpcval(getConfig('databaseVersion'), 'int'))); | 107 | new xmlrpcval(instaDisc_getConfig('databaseVersion'), 'int'))); |
108 | $client->send($msg); | 108 | $client->send($msg); |
109 | $i++; | 109 | $i++; |
110 | } | 110 | } |
@@ -120,10 +120,10 @@ function sendFromCentral($cserver, $verification, $verificationID, $subscription | |||
120 | { | 120 | { |
121 | if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'key')) | 121 | if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'key')) |
122 | { | 122 | { |
123 | if ($softwareVersion > getConfig('softwareVersion')) | 123 | if ($softwareVersion > instaDisc_getConfig('softwareVersion')) |
124 | { | 124 | { |
125 | instaDisc_sendUpdateNotice($softwareVersion); | 125 | instaDisc_sendUpdateNotice($softwareVersion); |
126 | } else if ($softwareVersion < getConfig('softwareVersion')) | 126 | } else if ($softwareVersion < instaDisc_getConfig('softwareVersion')) |
127 | { | 127 | { |
128 | $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; | 128 | $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; |
129 | $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_escape_string($cserver2) . "\""; | 129 | $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_escape_string($cserver2) . "\""; |
@@ -136,11 +136,11 @@ function sendFromCentral($cserver, $verification, $verificationID, $subscription | |||
136 | $msg = new xmlrpcmsg("InstaDisc.sendUpdateNotice", array( new xmlrpcval($cserver2, 'string'), | 136 | $msg = new xmlrpcmsg("InstaDisc.sendUpdateNotice", array( new xmlrpcval($cserver2, 'string'), |
137 | new xmlrpcval(md5($cserver2 . ':' . $getuk3['key'] . ':' . $verID), 'string'), | 137 | new xmlrpcval(md5($cserver2 . ':' . $getuk3['key'] . ':' . $verID), 'string'), |
138 | new xmlrpcval($verID, 'int'), | 138 | new xmlrpcval($verID, 'int'), |
139 | new xmlrpcval(getConfig('softwareVersion'), 'int'))); | 139 | new xmlrpcval(instaDisc_getConfig('softwareVersion'), 'int'))); |
140 | $client->send($msg); | 140 | $client->send($msg); |
141 | } | 141 | } |
142 | 142 | ||
143 | if ($databaseVersion > getConfig('databaseVersion')) | 143 | if ($databaseVersion > instaDisc_getConfig('databaseVersion')) |
144 | { | 144 | { |
145 | $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; | 145 | $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; |
146 | $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_escape_string($cserver2) . "\""; | 146 | $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_escape_string($cserver2) . "\""; |
@@ -153,9 +153,9 @@ function sendFromCentral($cserver, $verification, $verificationID, $subscription | |||
153 | $msg = new xmlrpcmsg("InstaDisc.askForDatabase", array( new xmlrpcval($cserver2, 'string'), | 153 | $msg = new xmlrpcmsg("InstaDisc.askForDatabase", array( new xmlrpcval($cserver2, 'string'), |
154 | new xmlrpcval(md5($cserver2 . ':' . $getuk3['key'] . ':' . $verID), 'string'), | 154 | new xmlrpcval(md5($cserver2 . ':' . $getuk3['key'] . ':' . $verID), 'string'), |
155 | new xmlrpcval($verID, 'int'), | 155 | new xmlrpcval($verID, 'int'), |
156 | new xmlrpcval(getConfig('databaseVersion'), 'int'))); | 156 | new xmlrpcval(instaDisc_getConfig('databaseVersion'), 'int'))); |
157 | $client->send($msg); | 157 | $client->send($msg); |
158 | } else if ($databaseVersion < getConfig('databaseVersion')) | 158 | } else if ($databaseVersion < instaDisc_getConfig('databaseVersion')) |
159 | { | 159 | { |
160 | instaDisc_sendDatabase($cserver); | 160 | instaDisc_sendDatabase($cserver); |
161 | } | 161 | } |
@@ -179,7 +179,7 @@ function sendUpdateNotice($cserver, $verification, $verificationID, $softwareVer | |||
179 | { | 179 | { |
180 | if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'key')) | 180 | if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'key')) |
181 | { | 181 | { |
182 | if ($softwareVersion > getConfig('softwareVersion')) | 182 | if ($softwareVersion > instaDisc_getConfig('softwareVersion')) |
183 | { | 183 | { |
184 | instaDisc_sendUpdateNotice($softwareVersion); | 184 | instaDisc_sendUpdateNotice($softwareVersion); |
185 | 185 | ||
@@ -194,7 +194,7 @@ function askForDatabase($cserver, $verification, $verificationID, $databaseVersi | |||
194 | { | 194 | { |
195 | if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'key')) | 195 | if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'key')) |
196 | { | 196 | { |
197 | if ($databaseVersion < getConfig('databaseVersion')) | 197 | if ($databaseVersion < instaDisc_getConfig('databaseVersion')) |
198 | { | 198 | { |
199 | instaDisc_sendDatabase($cserver); | 199 | instaDisc_sendDatabase($cserver); |
200 | 200 | ||