From f58e72c0d5181c5bf77393cf657d2c2bccee1073 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 2 Aug 2008 14:48:59 +0000 Subject: Central: Added instaDisc_getConfig() This functions retrives a single configuration value out of the database. --- central/trunk/instadisc.php | 25 +++++++++++++++++-------- 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, $cntverid = "SELECT COUNT(*) FROM oldVerID WHERE username = \"" . mysql_escape_string($username) . "\""; $cntverid2 = mysql_query($cntverid); $cntverid3 = mysql_fetch_array($cntverid2); - if ($cntverid3[0] >= intval(getConfig('verIDBufferSize'))) + if ($cntverid3[0] >= intval(instaDisc_getConfig('verIDBufferSize'))) { $delverid = "DELETE FROM oldVerID WHERE username = \"" . mysql_escape_string($username) . "\""; $delverid2 = mysql_query($delverid); @@ -74,7 +74,7 @@ function instaDisc_sendItem($username, $id) function instaDisc_sendUpdateNotice($softwareVersion) { - $username = getConfig('owner'); + $username = instaDisc_getConfig('owner'); $subscription = 'http://' . $_SERVER['HTTP_HOST']; $title = 'Update your software to ' . $software; $author = 'Hatkirby'; @@ -132,14 +132,14 @@ function instaDisc_phpMailer() { $mail = new PHPMailer(); $mail->IsSMTP(); - $mail->From = 'instadisc@' . getConfig('mailDomain'); + $mail->From = 'instadisc@' . instaDisc_getConfig('mailDomain'); $mail->FromName = 'InstaDisc'; - $mail->Host = getConfig('smtpHost'); - if (getConfig('smtpAuth') == 'true') + $mail->Host = instaDisc_getConfig('smtpHost'); + if (instaDisc_getConfig('smtpAuth') == 'true') { $mail->SMTPAuth = true; - $mail->Username = getConfig('smtpUser'); - $mail->Password = getConfig('smtpPass'); + $mail->Username = instaDisc_getConfig('smtpUser'); + $mail->Password = instaDisc_getConfig('smtpPass'); } $mail->Helo = $_SERVER['HTTP_HOST']; $mail->ClearAddresses(); @@ -178,7 +178,7 @@ function instaDisc_activateAccount($username, $penKey) $mail = instaDisc_phpMailer(); $mail->AddAddress($getuser3['email'], $username); $mail->Subject = 'Welcome to InstaDisc!'; - $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") . "!"; + $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") . "!"; return $mail->Send(); } else { @@ -229,4 +229,13 @@ function instaDisc_deleteAccount($username) return false; } +function instaDisc_getConfig($key) +{ + $getconfig = "SELECT * FROM config WHERE name = \"" . mysql_escape_string($key) . "\""; + $getconfig2 = mysql_query($getconfig); + $getconfig3 = mysql_fetch_array($getconfig2); + + return $getconfig3['value']; +} + ?> 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 new xmlrpcval($author, 'string'), new xmlrpcval($url, 'string'), new xmlrpcval($semantics, 'array'), - new xmlrpcval(getConfig('softwareVersion'), 'int'), - new xmlrpcval(getConfig('databaseVersion'), 'int'))); + new xmlrpcval(instaDisc_getConfig('softwareVersion'), 'int'), + new xmlrpcval(instaDisc_getConfig('databaseVersion'), 'int'))); $client->send($msg); $i++; } @@ -120,10 +120,10 @@ function sendFromCentral($cserver, $verification, $verificationID, $subscription { if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'key')) { - if ($softwareVersion > getConfig('softwareVersion')) + if ($softwareVersion > instaDisc_getConfig('softwareVersion')) { instaDisc_sendUpdateNotice($softwareVersion); - } else if ($softwareVersion < getConfig('softwareVersion')) + } else if ($softwareVersion < instaDisc_getConfig('softwareVersion')) { $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_escape_string($cserver2) . "\""; @@ -136,11 +136,11 @@ function sendFromCentral($cserver, $verification, $verificationID, $subscription $msg = new xmlrpcmsg("InstaDisc.sendUpdateNotice", array( new xmlrpcval($cserver2, 'string'), new xmlrpcval(md5($cserver2 . ':' . $getuk3['key'] . ':' . $verID), 'string'), new xmlrpcval($verID, 'int'), - new xmlrpcval(getConfig('softwareVersion'), 'int'))); + new xmlrpcval(instaDisc_getConfig('softwareVersion'), 'int'))); $client->send($msg); } - if ($databaseVersion > getConfig('databaseVersion')) + if ($databaseVersion > instaDisc_getConfig('databaseVersion')) { $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_escape_string($cserver2) . "\""; @@ -153,9 +153,9 @@ function sendFromCentral($cserver, $verification, $verificationID, $subscription $msg = new xmlrpcmsg("InstaDisc.askForDatabase", array( new xmlrpcval($cserver2, 'string'), new xmlrpcval(md5($cserver2 . ':' . $getuk3['key'] . ':' . $verID), 'string'), new xmlrpcval($verID, 'int'), - new xmlrpcval(getConfig('databaseVersion'), 'int'))); + new xmlrpcval(instaDisc_getConfig('databaseVersion'), 'int'))); $client->send($msg); - } else if ($databaseVersion < getConfig('databaseVersion')) + } else if ($databaseVersion < instaDisc_getConfig('databaseVersion')) { instaDisc_sendDatabase($cserver); } @@ -179,7 +179,7 @@ function sendUpdateNotice($cserver, $verification, $verificationID, $softwareVer { if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'key')) { - if ($softwareVersion > getConfig('softwareVersion')) + if ($softwareVersion > instaDisc_getConfig('softwareVersion')) { instaDisc_sendUpdateNotice($softwareVersion); @@ -194,7 +194,7 @@ function askForDatabase($cserver, $verification, $verificationID, $databaseVersi { if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'key')) { - if ($databaseVersion < getConfig('databaseVersion')) + if ($databaseVersion < instaDisc_getConfig('databaseVersion')) { instaDisc_sendDatabase($cserver); -- cgit 1.4.1