about summary refs log tree commit diff stats
path: root/central/trunk
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2008-08-01 18:15:38 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-08-01 18:15:38 +0000
commitbe96f198642944da86e8c43b0eab5e7cd0dacdea (patch)
tree88349d0329ed72eb1f224848d81f6fe4079f544d /central/trunk
parentdfa87010beb0f598f45234e55185afc924cd4b12 (diff)
downloadinstadisc-be96f198642944da86e8c43b0eab5e7cd0dacdea.tar.gz
instadisc-be96f198642944da86e8c43b0eab5e7cd0dacdea.tar.bz2
instadisc-be96f198642944da86e8c43b0eab5e7cd0dacdea.zip
Central: Added library skeleton
Added the library method signatures for XML-RPC used functions to the library,
and also implemented a instaDisc_sendUpdateNotice() and instaDisc_addItem().
Refs #3.
Diffstat (limited to 'central/trunk')
-rw-r--r--central/trunk/instadisc.php38
-rw-r--r--central/trunk/xmlrpc.php34
2 files changed, 65 insertions, 7 deletions
diff --git a/central/trunk/instadisc.php b/central/trunk/instadisc.php index f8f33e5..f4fcd1e 100644 --- a/central/trunk/instadisc.php +++ b/central/trunk/instadisc.php
@@ -19,4 +19,42 @@ function instaDisc_checkVerification($username, $verification, $verificationID,
19 return false; 19 return false;
20} 20}
21 21
22function instaDisc_sendItem($username, $id)
23{
24}
25
26function instaDisc_sendUpdateNotice($softwareVersion)
27{
28 $username = getConfig('owner');
29 $subscription = 'http://' . $_SERVER['HTTP_HOST'];
30 $title = 'Update your software to ' . $software;
31 $author = 'Hatkirby';
32 $url = 'http://fourisland.com/projects/instadisc/wiki/CentralSoftwareUpdate';
33 $semantics = array();
34
35 instaDisc_addItem($username, $subscription, $title, $author, $url, $semantics);
36}
37
38function instaDisc_sendDatabase($cserver)
39{
40}
41
42function instaDisc_addItem($username, $subscription, $title, $author, $url, $semantics)
43{
44 $getuser = "SELECT * FROM users WHERE username = \"" . $username . "\"";
45 $getuser2 = mysql_query($getuser);
46 $getuser3 = mysql_fetch_array($getuser2);
47 if ($getuser3['username'] == $username)
48 {
49 $itemID = $getuser3['nextItemID'];
50 $setuser = "UPDATE users SET nextItemID = nextItemID+1 WHERE username = \"" . $username . "\"";
51 $setuser2 = mysql_query($setuser);
52
53 $insitem = "INSERT INTO inbox (username, itemID, subscription, title, author, url, semantics) VALUES (\"" . $username . "\", " . $itemID . ", \"" . $subscription . "\", \"" . $title . "\", \"" . $author . "\", \"" . $url . "\", \"" . serialize($semantics) . "\")";
54 $insitem2 = mysql_query($insitem);
55
56 instaDisc_sendItem($username, $itemID);
57 }
58}
59
22?> 60?>
diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php index ecd0bfc..18c344b 100644 --- a/central/trunk/xmlrpc.php +++ b/central/trunk/xmlrpc.php
@@ -21,12 +21,12 @@ function deleteItem($username, $verification, $verificationID, $id)
21{ 21{
22 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) 22 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
23 { 23 {
24 $getitem = "SELECT * FROM inbox WHERE id = " . $id; 24 $getitem = "SELECT * FROM inbox WHERE username = \"" . $username . "\" AND itemID = " . $id;
25 $getitem2 = mysql_query($getitem); 25 $getitem2 = mysql_query($getitem);
26 $getitem3 = mysql_fetch_array($getitem2); 26 $getitem3 = mysql_fetch_array($getitem2);
27 if ($getitem3['id'] == $id) 27 if ($getitem3['id'] == $id)
28 { 28 {
29 $delitem = "DELETE inbox WHERE id = " . $id; 29 $delitem = "DELETE inbox WHERE username = \"" . $username . "\" AND itemID = " . $id;
30 $delitem2 = mysql_query($delitem); 30 $delitem2 = mysql_query($delitem);
31 31
32 return new xmlrpcresp(new xmlrpcval(0, "int")); 32 return new xmlrpcresp(new xmlrpcval(0, "int"));
@@ -40,12 +40,12 @@ function resendItem($username, $verification, $verificationID, $id)
40{ 40{
41 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) 41 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
42 { 42 {
43 $getitem = "SELECT * FROM inbox WHERE id = " . $id; 43 $getitem = "SELECT * FROM inbox WHERE username = \"" . $username . "\" AND itemID = " . $id;
44 $getitem2 = mysql_query($getitem); 44 $getitem2 = mysql_query($getitem);
45 $getitem3 = mysql_fetch_array($getitem2); 45 $getitem3 = mysql_fetch_array($getitem2);
46 if ($getitem3['id'] == $id) 46 if ($getitem3['id'] == $id)
47 { 47 {
48 instaDisc_sendItem($id); 48 instaDisc_sendItem($username, $id);
49 49
50 return new xmlrpcresp(new xmlrpcval(0, "int")); 50 return new xmlrpcresp(new xmlrpcval(0, "int"));
51 } 51 }
@@ -103,7 +103,7 @@ function sendFromCentral($cserver, $verification, $verificationID, $subscription
103 { 103 {
104 if ($softwareVersion > getConfig('softwareVersion')) 104 if ($softwareVersion > getConfig('softwareVersion'))
105 { 105 {
106 instaDisc_sendUpdateNotice(); 106 instaDisc_sendUpdateNotice($softwareVersion);
107 } else if ($softwareVersion < getConfig('softwareVersion')) 107 } else if ($softwareVersion < getConfig('softwareVersion'))
108 { 108 {
109 $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; 109 $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
@@ -162,7 +162,7 @@ function sendUpdateNotice($cserver, $verification, $verificationID, $softwareVer
162 { 162 {
163 if ($softwareVersion > getConfig('softwareVersion')) 163 if ($softwareVersion > getConfig('softwareVersion'))
164 { 164 {
165 instaDisc_sendUpdateNotice(); 165 instaDisc_sendUpdateNotice($softwareVersion);
166 166
167 return new xmlrpcresp(new xmlrpcval(0, "int")); 167 return new xmlrpcresp(new xmlrpcval(0, "int"));
168 } 168 }
@@ -186,6 +186,25 @@ function askForDatabase($cserver, $verification, $verificationID, $databaseVersi
186 return new xmlrpcresp(new xmlrpcval(1, "int")); 186 return new xmlrpcresp(new xmlrpcval(1, "int"));
187} 187}
188 188
189function deleteSubscription($username, $verification, $verificationID, $subscription)
190{
191 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
192 {
193 $getsub = "SELECT * FROM subscriptions WHERE url = \"" . $subscription . "\" AND username = \"" . $username . "\" AND owner = \"false\"";
194 $getsub2 = mysql_query($getsub);
195 $getsub3 = mysql_fetch_array($getsub2);
196 if ($getsub3['url'] == $subscription)
197 {
198 $delsub = "DELETE subscriptions WHERE url = \"" . $subscription . "\" AND username = \"" . $username . "\" AND owner = \"false\"";
199 $delsub2 = mysql_query($delsub);
200
201 return new xmlrpcresp(new xmlrpcval(0, "int"));
202 }
203 }
204
205 return new xmlrpcresp(new xmlrpcval(1, "int"));
206}
207
189$s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"), 208$s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"),
190 "InstaDisc.deleteItem" => array("function" => "deleteItem"), 209 "InstaDisc.deleteItem" => array("function" => "deleteItem"),
191 "InstaDisc.resendItem" => array("function" => "resendItem"), 210 "InstaDisc.resendItem" => array("function" => "resendItem"),
@@ -193,7 +212,8 @@ $s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function"
193 "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"), 212 "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"),
194 "InstaDisc.sendFromCentral" => array("function" => "sendFromCentral"), 213 "InstaDisc.sendFromCentral" => array("function" => "sendFromCentral"),
195 "InstaDisc.sendUpdateNotice" => array("function" => "sendUpdateNotice"), 214 "InstaDisc.sendUpdateNotice" => array("function" => "sendUpdateNotice"),
196 "InstaDisc.askForDatabase" => array("function" => "askForDatabase") 215 "InstaDisc.askForDatabase" => array("function" => "askForDatabase"),
216 "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription")
197 ),0); 217 ),0);
198$s->functions_parameters_type = 'phpvals'; 218$s->functions_parameters_type = 'phpvals';
199$s->service(); 219$s->service();