From ff65e9ee2f7145265dc9c3daacfc2d5fd0756d3f Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 28 Sep 2008 15:39:55 +0000 Subject: Central: Completed step 9 Refs #69 --- central/trunk/includes/instadisc.php | 26 ++++++++++++++++++++++++++ central/trunk/xmlrpc.php | 27 ++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) (limited to 'central/trunk') diff --git a/central/trunk/includes/instadisc.php b/central/trunk/includes/instadisc.php index 003ad1b..1c4c968 100644 --- a/central/trunk/includes/instadisc.php +++ b/central/trunk/includes/instadisc.php @@ -237,4 +237,30 @@ function instaDisc_changePassword($username, $password) $setpass2 = mysql_query($setpass); } +function instaDisc_initalizePort($username) +{ + $getports = "SELECT * FROM users WHERE ip = \"" . mysql_real_escape_string($username) . "\" AND port <> 0 ORDER BY port ASC"; + $getports2 = mysql_query($getports); + $i=0; + while ($getports3[$i] = mysql_fetch_array($getports2)) + { + $i++; + } + + if ($i==0) + { + $port = 1204; + } else if ($i>=4331) + { + return 0; + } else { + $port = (61204 + ($i-1)); + } + + $setuser = "UPDATE users SET port = " . $port . " WHERE username = \"" . mysql_real_escape_string($username) . "\""; + $setuser2 = mysql_query($setuser); + + return $port; +} + ?> diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php index 466cae3..2e3aa62 100644 --- a/central/trunk/xmlrpc.php +++ b/central/trunk/xmlrpc.php @@ -153,6 +153,29 @@ function setDownloadItemMode($username, $verification, $verificationID, $mode) return new xmlrpcresp(new xmlrpcval('1', 'int')); } +function initalizePort($username, $verification, $verificationID) +{ + if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) + { + return new xmlrpcresp(new xmlrpcval(instaDisc_initalizePort($username), 'int')); + } + + return new xmlrpcresp(new xmlrpcval('0', 'int')); +} + +function deinitalizePort($username, $verification, $verificationID) +{ + if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) + { + $setuser = "UPDATE users SET port = 0 WHERE username = \"" . mysql_real_escape_string($username) . "\""; + $setuser2 = mysql_query($setuser); + + return new xmlrpcresp(new xmlrpcval('0', 'int')); + } + + return new xmlrpcresp(new xmlrpcval('1', 'int')); +} + $s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"), "InstaDisc.deleteItem" => array("function" => "deleteItem"), "InstaDisc.resendItem" => array("function" => "resendItem"), @@ -161,7 +184,9 @@ $s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"), "InstaDisc.addSubscription" => array("function" => "addSubscription"), "InstaDisc.downloadItemModeTest" => array("function" => "downloadItemModeTest"), - "InstaDisc.setDownloadItemMode" => array("function" => "setDownloadItemMode") + "InstaDisc.setDownloadItemMode" => array("function" => "setDownloadItemMode"), + "InstaDisc.initalizePort" => array("function" => "initalizePort"), + "InstaDisc.deinitalizePort" => array("function" => "deinitalizePort") ),0); $s->functions_parameters_type = 'phpvals'; $s->service(); -- cgit 1.4.1