diff options
| -rw-r--r-- | central/trunk/activate.php | 103 | ||||
| -rw-r--r-- | central/trunk/changepassword.php | 119 | ||||
| -rw-r--r-- | central/trunk/index.php | 262 | ||||
| -rw-r--r-- | central/trunk/login.php | 87 | ||||
| -rw-r--r-- | central/trunk/logout.php | 11 | ||||
| -rw-r--r-- | central/trunk/register.php | 109 | ||||
| -rw-r--r-- | central/trunk/userpanel.php | 24 | ||||
| -rw-r--r-- | central/trunk/xmlrpc.php | 266 |
8 files changed, 258 insertions, 723 deletions
| diff --git a/central/trunk/activate.php b/central/trunk/activate.php deleted file mode 100644 index 9706a69..0000000 --- a/central/trunk/activate.php +++ /dev/null | |||
| @@ -1,103 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* InstaDisc Server - A Four Island Project */ | ||
| 4 | |||
| 5 | include('includes/instadisc.php'); | ||
| 6 | include('includes/template.php'); | ||
| 7 | |||
| 8 | if (!isset($_GET['submit'])) | ||
| 9 | { | ||
| 10 | showForm('','',array()); | ||
| 11 | } else { | ||
| 12 | $numOfErrors = 0; | ||
| 13 | $errors = array(); | ||
| 14 | |||
| 15 | $getpending = "SELECT * FROM pending WHERE username = \"" . mysql_real_escape_string($_POST['username']) . "\" AND code = \"" . mysql_real_escape_string($_POST['code']) . "\""; | ||
| 16 | $getpending2 = mysql_query($getpending); | ||
| 17 | $getpending3 = mysql_fetch_array($getpending2); | ||
| 18 | if ($getpending3['username'] != $_POST['username']) | ||
| 19 | { | ||
| 20 | addError($numOfErrors, $errors, '', 'Account could not be found'); | ||
| 21 | } | ||
| 22 | |||
| 23 | if ($numOfErrors > 0) | ||
| 24 | { | ||
| 25 | showForm($_POST['username'], $_POST['code'], $errors); | ||
| 26 | } else { | ||
| 27 | if ($_POST['submit'] == "Verify") | ||
| 28 | { | ||
| 29 | if (instaDisc_activateAccount($_POST['username'], $_POST['code'])) | ||
| 30 | { | ||
| 31 | $template = new FITemplate('activated'); | ||
| 32 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 33 | $template->display(); | ||
| 34 | } else { | ||
| 35 | addError($numOfErrors, $errors, '', 'The email could not be sent'); | ||
| 36 | showForm($_POST['username'], $_POST['code'], $errors); | ||
| 37 | } | ||
| 38 | } else { | ||
| 39 | instaDisc_deactivateAccount($_POST['username'], $_POST['code']); | ||
| 40 | } | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | function showForm($username, $code, $errors) | ||
| 45 | { | ||
| 46 | $template = new FITemplate('activate'); | ||
| 47 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 48 | |||
| 49 | if (isset($errors[1])) | ||
| 50 | { | ||
| 51 | $template->adds_block('ERROR', array('ex'=>'1')); | ||
| 52 | |||
| 53 | foreach ($errors as $name => $value) | ||
| 54 | { | ||
| 55 | $template->adds_block('ERRORS', array( 'NAME' => $name, | ||
| 56 | 'MSG' => $value['msg'])); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | |||
| 60 | $template->add('USERNAME_ERR', ifErrors($errors, 'username')); | ||
| 61 | $template->add('CODE_ERR', ifErrors($errors, 'code')); | ||
| 62 | |||
| 63 | doErrors($template, $errors, 'username'); | ||
| 64 | doErrors($template, $errors, 'code'); | ||
| 65 | |||
| 66 | $template->add('USERNAME', $username); | ||
| 67 | $template->add('CODE', $code); | ||
| 68 | |||
| 69 | $template->display(); | ||
| 70 | } | ||
| 71 | |||
| 72 | function ifErrors($errors, $id) | ||
| 73 | { | ||
| 74 | foreach ($errors as $name => $value) | ||
| 75 | { | ||
| 76 | if ($value['field'] == $id) | ||
| 77 | { | ||
| 78 | return ' error'; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | return ''; | ||
| 83 | } | ||
| 84 | |||
| 85 | function doErrors($template, $errors, $id) | ||
| 86 | { | ||
| 87 | foreach ($errors as $name => $value) | ||
| 88 | { | ||
| 89 | if ($value['field'] == $id) | ||
| 90 | { | ||
| 91 | $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name, | ||
| 92 | 'VALUE' => $value['msg'])); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
| 98 | { | ||
| 99 | $numOfErrors++; | ||
| 100 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
| 101 | } | ||
| 102 | |||
| 103 | ?> | ||
| diff --git a/central/trunk/changepassword.php b/central/trunk/changepassword.php deleted file mode 100644 index 1b92666..0000000 --- a/central/trunk/changepassword.php +++ /dev/null | |||
| @@ -1,119 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* InstaDisc Server - A Four Island Project */ | ||
| 4 | |||
| 5 | include('includes/instadisc.php'); | ||
| 6 | include('includes/template.php'); | ||
| 7 | |||
| 8 | if (isset($_SESSION['username'])) | ||
| 9 | { | ||
| 10 | if (!isset($_GET['submit'])) | ||
| 11 | { | ||
| 12 | showForm('','','',array()); | ||
| 13 | } else { | ||
| 14 | $numOfErrors = 0; | ||
| 15 | $errors = array(); | ||
| 16 | |||
| 17 | if ($_POST['old'] == '') | ||
| 18 | { | ||
| 19 | addError($numOfErrors, $errors, 'old', 'Old Password is a required field'); | ||
| 20 | } else { | ||
| 21 | if (!instaDisc_verifyUser($_SESSION['username'], $_POST['old'])) | ||
| 22 | { | ||
| 23 | addError($numOfErrors, $errors, 'old', 'Old password is not correct'); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | if ($_POST['new'] == '') | ||
| 28 | { | ||
| 29 | addError($numOfErrors, $errors, 'new', 'New Password is a required field'); | ||
| 30 | } | ||
| 31 | |||
| 32 | if ($_POST['confirm'] == '') | ||
| 33 | { | ||
| 34 | addError($numOfErrors, $errors, 'confirm', 'Confirm New Password is a required field'); | ||
| 35 | } | ||
| 36 | |||
| 37 | if ($_POST['new'] != $_POST['confirm']) | ||
| 38 | { | ||
| 39 | addError($numOfErrors, $errors, 'confirm', 'Passwords do not match'); | ||
| 40 | } | ||
| 41 | |||
| 42 | if ($numOfErrors > 0) | ||
| 43 | { | ||
| 44 | showForm($_POST['old'], $_POST['new'], $_POST['confirm'], $errors); | ||
| 45 | } else { | ||
| 46 | instaDisc_changePassword($_SESSION['username'], $_POST['new']); | ||
| 47 | |||
| 48 | $template = new FITemplate('changedpassword'); | ||
| 49 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 50 | $template->display(); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } else { | ||
| 54 | header('Location: index.php'); | ||
| 55 | } | ||
| 56 | |||
| 57 | function showForm($old, $new, $confirm, $errors) | ||
| 58 | { | ||
| 59 | $template = new FITemplate('changepassword'); | ||
| 60 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 61 | |||
| 62 | if (isset($errors[1])) | ||
| 63 | { | ||
| 64 | $template->adds_block('ERROR', array('ex'=>'1')); | ||
| 65 | |||
| 66 | foreach ($errors as $name => $value) | ||
| 67 | { | ||
| 68 | $template->adds_block('ERRORS', array( 'NAME' => $name, | ||
| 69 | 'MSG' => $value['msg'])); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | $template->add('OLD_ERR', ifErrors($errors, 'old')); | ||
| 74 | $template->add('NEW_ERR', ifErrors($errors, 'new')); | ||
| 75 | $template->add('CONFIRM_ERR', ifErrors($errors, 'confirm')); | ||
| 76 | |||
| 77 | doErrors($template, $errors, 'old'); | ||
| 78 | doErrors($template, $errors, 'new'); | ||
| 79 | doErrors($template, $errors, 'confirm'); | ||
| 80 | |||
| 81 | $template->add('OLD', $old); | ||
| 82 | $template->add('NEW', $new); | ||
| 83 | $template->add('CONFIRM', $confirm); | ||
| 84 | |||
| 85 | $template->display(); | ||
| 86 | } | ||
| 87 | |||
| 88 | function ifErrors($errors, $id) | ||
| 89 | { | ||
| 90 | foreach ($errors as $name => $value) | ||
| 91 | { | ||
| 92 | if ($value['field'] == $id) | ||
| 93 | { | ||
| 94 | return ' error'; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | return ''; | ||
| 99 | } | ||
| 100 | |||
| 101 | function doErrors($template, $errors, $id) | ||
| 102 | { | ||
| 103 | foreach ($errors as $name => $value) | ||
| 104 | { | ||
| 105 | if ($value['field'] == $id) | ||
| 106 | { | ||
| 107 | $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name, | ||
| 108 | 'VALUE' => $value['msg'])); | ||
| 109 | } | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
| 114 | { | ||
| 115 | $numOfErrors++; | ||
| 116 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
| 117 | } | ||
| 118 | |||
| 119 | ?> | ||
| diff --git a/central/trunk/index.php b/central/trunk/index.php index 703cab8..ea77e3f 100644 --- a/central/trunk/index.php +++ b/central/trunk/index.php | |||
| @@ -2,11 +2,265 @@ | |||
| 2 | 2 | ||
| 3 | /* InstaDisc Server - A Four Island Project */ | 3 | /* InstaDisc Server - A Four Island Project */ |
| 4 | 4 | ||
| 5 | include('includes/xmlrpc/xmlrpc.inc'); | ||
| 6 | include('includes/xmlrpc/xmlrpcs.inc'); | ||
| 5 | include('includes/instadisc.php'); | 7 | include('includes/instadisc.php'); |
| 6 | include('includes/template.php'); | ||
| 7 | 8 | ||
| 8 | $template = new FITemplate('index'); | 9 | function checkRegistration($username, $verification, $verificationID) |
| 9 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | 10 | { |
| 10 | $template->display(); | 11 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) |
| 12 | { | ||
| 13 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 14 | } | ||
| 15 | |||
| 16 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 17 | } | ||
| 18 | |||
| 19 | function deleteItem($username, $verification, $verificationID, $id) | ||
| 20 | { | ||
| 21 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 22 | { | ||
| 23 | $getitem = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID = " . $id; | ||
| 24 | $getitem2 = mysql_query($getitem); | ||
| 25 | $getitem3 = mysql_fetch_array($getitem2); | ||
| 26 | if ($getitem3['itemID'] == $id) | ||
| 27 | { | ||
| 28 | $delitem = "DELETE FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID = " . $id; | ||
| 29 | $delitem2 = mysql_query($delitem); | ||
| 30 | |||
| 31 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 36 | } | ||
| 37 | |||
| 38 | function resendItem($username, $verification, $verificationID, $id) | ||
| 39 | { | ||
| 40 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 41 | { | ||
| 42 | $getitem = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID = " . $id; | ||
| 43 | $getitem2 = mysql_query($getitem); | ||
| 44 | $getitem3 = mysql_fetch_array($getitem2); | ||
| 45 | if ($getitem3['itemID'] == $id) | ||
| 46 | { | ||
| 47 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 48 | $getuser2 = mysql_query($getuser); | ||
| 49 | $getuser3 = mysql_fetch_array($getuser2); | ||
| 50 | if ($getuser3['downloadItemMode'] == 'Push') | ||
| 51 | { | ||
| 52 | instaDisc_sendItem($username, $id); | ||
| 53 | |||
| 54 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 55 | } else if ($getuser3['downloadItemMode'] == 'Pull') | ||
| 56 | { | ||
| 57 | return new xmlrpcresp(new xmlrpcval(instaDisc_formItem($username, $id), 'string')); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 63 | } | ||
| 64 | |||
| 65 | function requestRetained($username, $verification, $verificationID) | ||
| 66 | { | ||
| 67 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 68 | { | ||
| 69 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 70 | $getuser2 = mysql_query($getuser); | ||
| 71 | $getuser3 = mysql_fetch_array($getuser2); | ||
| 72 | if ($getuser3['downloadItemMode'] == 'Push') | ||
| 73 | { | ||
| 74 | $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 75 | $getitems2 = mysql_query($getitems); | ||
| 76 | $i=0; | ||
| 77 | while ($getitems3[$i] = mysql_fetch_array($getitems2)) | ||
| 78 | { | ||
| 79 | if (!instaDisc_sendItem($username, $getitems3[$i]['itemID'])) | ||
| 80 | { | ||
| 81 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 82 | } | ||
| 83 | $i++; | ||
| 84 | } | ||
| 85 | |||
| 86 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 87 | } else if ($getuser3['downloadItemMode'] == 'Pull') | ||
| 88 | { | ||
| 89 | $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" LIMIT 0,2"; | ||
| 90 | $getitems2 = mysql_query($getitems); | ||
| 91 | $getitems3 = mysql_fetch_array($getitems2); | ||
| 92 | $getitems4 = mysql_fetch_array($getitems2); | ||
| 93 | if ($getitems3['username'] == $username) | ||
| 94 | { | ||
| 95 | $item = instaDisc_formItem($username, $getitems3['id']); | ||
| 96 | if ($getitems4['username'] == $username) | ||
| 97 | { | ||
| 98 | $item .= 'More: ' . $getitems4['id'] . "\n"; | ||
| 99 | } | ||
| 100 | |||
| 101 | return new xmlrpcresp(new xmlrpcval($item, 'string')); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 107 | } | ||
| 108 | |||
| 109 | function sendItem($username, $verification, $verificationID, $id) | ||
| 110 | { | ||
| 111 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 112 | { | ||
| 113 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 114 | $getuser2 = mysql_query($getuser); | ||
| 115 | $getuser3 = mysql_fetch_array($getuser2); | ||
| 116 | if ($getuser3['downloadItemMode'] == 'Pull') | ||
| 117 | { | ||
| 118 | $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID > " . ($id-1) . " LIMIT 0,2"; | ||
| 119 | $getitems2 = mysql_query($getitems); | ||
| 120 | $getitems3 = mysql_fetch_array($getitems2); | ||
| 121 | $getitems4 = mysql_fetch_array($getitems2); | ||
| 122 | if ($getitems3['username'] == $username) | ||
| 123 | { | ||
| 124 | $item = instaDisc_formItem($username, $getitems3['id']); | ||
| 125 | if ($getitems4['username'] == $username) | ||
| 126 | { | ||
| 127 | $item .= 'More: ' . $getitems4['id'] . "\n"; | ||
| 128 | } | ||
| 129 | |||
| 130 | return new xmlrpcresp(new xmlrpcval($item, 'string')); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | } | ||
| 134 | |||
| 135 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 136 | } | ||
| 137 | |||
| 138 | |||
| 139 | function sendFromUpdate($subscriptionURL, $title, $author, $url, $semantics, $encryptionID) | ||
| 140 | { | ||
| 141 | $getsed = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscriptionURL) . "\""; | ||
| 142 | $getsed2 = mysql_query($getsed); | ||
| 143 | $i=0; | ||
| 144 | while ($getsed3[$i] = mysql_fetch_array($getsed2)) | ||
| 145 | { | ||
| 146 | instaDisc_addItem($getsed3[$i]['username'], $subscriptionURL, $title, $author, $url, $semantics, $encryptionID); | ||
| 147 | $i++; | ||
| 148 | } | ||
| 149 | |||
| 150 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 151 | } | ||
| 152 | |||
| 153 | function deleteSubscription($username, $verification, $verificationID, $subscription) | ||
| 154 | { | ||
| 155 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 156 | { | ||
| 157 | $getsub = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscription) . "\" AND username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 158 | $getsub2 = mysql_query($getsub); | ||
| 159 | $getsub3 = mysql_fetch_array($getsub2); | ||
| 160 | if ($getsub3['url'] == $subscription) | ||
| 161 | { | ||
| 162 | $delsub = "DELETE FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscription) . "\" AND username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 163 | $delsub2 = mysql_query($delsub); | ||
| 164 | |||
| 165 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 169 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 170 | } | ||
| 171 | |||
| 172 | function addSubscription($username, $verification, $verificationID, $subscription, $category) | ||
| 173 | { | ||
| 174 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 175 | { | ||
| 176 | $getsub = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscription) . "\" AND username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 177 | $getsub2 = mysql_query($getsub) or die($getsub); | ||
| 178 | $getsub3 = mysql_fetch_array($getsub2); | ||
| 179 | if ($getsub3['url'] != $subscription) | ||
| 180 | { | ||
| 181 | $inssub = "INSERT INTO subscriptions (url, username, category) VALUES (\"" . mysql_real_escape_string($subscription) . "\", \"" . mysql_real_escape_string($username) . "\", \"" . mysql_real_escape_string($category) . "\")"; | ||
| 182 | $inssub2 = mysql_query($inssub); | ||
| 183 | |||
| 184 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 189 | } | ||
| 190 | |||
| 191 | function downloadItemModeTest() | ||
| 192 | { | ||
| 193 | $fp = @fsockopen($_SERVER['REMOTE_ADDR'], 61200, $errno, $errstr); | ||
| 194 | if ($fp) | ||
| 195 | { | ||
| 196 | fwrite($fp, "InstaDisc Download Item Mode Test\r\n\r\n\r\n"); | ||
| 197 | fclose($fp); | ||
| 198 | return new xmlrpcresp(new xmlrpcval('0', 'int')); | ||
| 199 | } else { | ||
| 200 | return new xmlrpcresp(new xmlrpcval('1', 'int')); | ||
| 201 | } | ||
| 202 | } | ||
| 203 | |||
| 204 | function setDownloadItemMode($username, $verification, $verificationID, $mode) | ||
| 205 | { | ||
| 206 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 207 | { | ||
| 208 | $setuser = "UPDATE users SET downloadItemMode = \"" . mysql_real_escape_string($mode) . "\" WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 209 | $setuser2 = mysql_query($setuser); | ||
| 210 | |||
| 211 | return new xmlrpcresp(new xmlrpcval('0', 'int')); | ||
| 212 | } | ||
| 213 | |||
| 214 | return new xmlrpcresp(new xmlrpcval('1', 'int')); | ||
| 215 | } | ||
| 216 | |||
| 217 | function initalizePort($username, $verification, $verificationID) | ||
| 218 | { | ||
| 219 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 220 | { | ||
| 221 | return new xmlrpcresp(new xmlrpcval(instaDisc_initalizePort($username), 'int')); | ||
| 222 | } | ||
| 223 | |||
| 224 | return new xmlrpcresp(new xmlrpcval('0', 'int')); | ||
| 225 | } | ||
| 226 | |||
| 227 | function deinitalizePort($username, $verification, $verificationID) | ||
| 228 | { | ||
| 229 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 230 | { | ||
| 231 | $setuser = "UPDATE users SET port = 0 WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 232 | $setuser2 = mysql_query($setuser); | ||
| 233 | |||
| 234 | return new xmlrpcresp(new xmlrpcval('0', 'int')); | ||
| 235 | } | ||
| 236 | |||
| 237 | return new xmlrpcresp(new xmlrpcval('1', 'int')); | ||
| 238 | } | ||
| 239 | |||
| 240 | function countSubscribers($url) | ||
| 241 | { | ||
| 242 | $cntsub = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($url) . "\""; | ||
| 243 | $cntsub2 = mysql_query($cntsub); | ||
| 244 | $cntsub3 = mysql_fetch_array($cntsub2); | ||
| 245 | |||
| 246 | return new xmlrpcresp(new xmlrpcval($cntsub3[0], 'int')); | ||
| 247 | } | ||
| 248 | |||
| 249 | $s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"), | ||
| 250 | "InstaDisc.deleteItem" => array("function" => "deleteItem"), | ||
| 251 | "InstaDisc.resendItem" => array("function" => "resendItem"), | ||
| 252 | "InstaDisc.requestRetained" => array("function" => "requestRetained"), | ||
| 253 | "InstaDisc.sendItem" => array("function" => "sendItem"), | ||
| 254 | "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"), | ||
| 255 | "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"), | ||
| 256 | "InstaDisc.addSubscription" => array("function" => "addSubscription"), | ||
| 257 | "InstaDisc.downloadItemModeTest" => array("function" => "downloadItemModeTest"), | ||
| 258 | "InstaDisc.setDownloadItemMode" => array("function" => "setDownloadItemMode"), | ||
| 259 | "InstaDisc.initalizePort" => array("function" => "initalizePort"), | ||
| 260 | "InstaDisc.deinitalizePort" => array("function" => "deinitalizePort"), | ||
| 261 | "InstaDisc.countSubscribers" => array("function" => "countSubscribers") | ||
| 262 | ),0); | ||
| 263 | $s->functions_parameters_type = 'phpvals'; | ||
| 264 | $s->service(); | ||
| 11 | 265 | ||
| 12 | ?> | 266 | ?> |
| diff --git a/central/trunk/login.php b/central/trunk/login.php deleted file mode 100644 index 19c5dc3..0000000 --- a/central/trunk/login.php +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* InstaDisc Server - A Four Island Project */ | ||
| 4 | |||
| 5 | include('includes/instadisc.php'); | ||
| 6 | include('includes/template.php'); | ||
| 7 | |||
| 8 | if (!isset($_GET['submit'])) | ||
| 9 | { | ||
| 10 | showForm('','',array()); | ||
| 11 | } else { | ||
| 12 | $numOfErrors = 0; | ||
| 13 | $errors = array(); | ||
| 14 | |||
| 15 | if (instaDisc_verifyUser($_POST['username'], $_POST['password'])) | ||
| 16 | { | ||
| 17 | $_SESSION['username'] = $_POST['username']; | ||
| 18 | |||
| 19 | $template = new FITemplate('loggedin'); | ||
| 20 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 21 | $template->display(); | ||
| 22 | } else { | ||
| 23 | addError($numOfErrors, $errors, '', 'Account could not be found'); | ||
| 24 | showForm($_POST['username'], $_POST['password'], $errors); | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | function showForm($username, $password, $errors) | ||
| 29 | { | ||
| 30 | $template = new FITemplate('login'); | ||
| 31 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 32 | |||
| 33 | if (isset($errors[1])) | ||
| 34 | { | ||
| 35 | $template->adds_block('ERROR', array('ex'=>'1')); | ||
| 36 | |||
| 37 | foreach ($errors as $name => $value) | ||
| 38 | { | ||
| 39 | $template->adds_block('ERRORS', array( 'NAME' => $name, | ||
| 40 | 'MSG' => $value['msg'])); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | $template->add('USERNAME_ERR', ifErrors($errors, 'username')); | ||
| 45 | $template->add('PASSWORD_ERR', ifErrors($errors, 'password')); | ||
| 46 | |||
| 47 | doErrors($template, $errors, 'username'); | ||
| 48 | doErrors($template, $errors, 'password'); | ||
| 49 | |||
| 50 | $template->add('USERNAME', $username); | ||
| 51 | $template->add('PASSWORD', $password); | ||
| 52 | |||
| 53 | $template->display(); | ||
| 54 | } | ||
| 55 | |||
| 56 | function ifErrors($errors, $id) | ||
| 57 | { | ||
| 58 | foreach ($errors as $name => $value) | ||
| 59 | { | ||
| 60 | if ($value['field'] == $id) | ||
| 61 | { | ||
| 62 | return ' error'; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | return ''; | ||
| 67 | } | ||
| 68 | |||
| 69 | function doErrors($template, $errors, $id) | ||
| 70 | { | ||
| 71 | foreach ($errors as $name => $value) | ||
| 72 | { | ||
| 73 | if ($value['field'] == $id) | ||
| 74 | { | ||
| 75 | $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name, | ||
| 76 | 'VALUE' => $value['msg'])); | ||
| 77 | } | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
| 82 | { | ||
| 83 | $numOfErrors++; | ||
| 84 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
| 85 | } | ||
| 86 | |||
| 87 | ?> | ||
| diff --git a/central/trunk/logout.php b/central/trunk/logout.php deleted file mode 100644 index e915329..0000000 --- a/central/trunk/logout.php +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* InstaDisc Server - A Four Island Project */ | ||
| 4 | |||
| 5 | include('includes/instadisc.php'); | ||
| 6 | |||
| 7 | unset($_SESSION['username']); | ||
| 8 | |||
| 9 | header('Location: index.php'); | ||
| 10 | |||
| 11 | ?> | ||
| diff --git a/central/trunk/register.php b/central/trunk/register.php deleted file mode 100644 index 8a02d0c..0000000 --- a/central/trunk/register.php +++ /dev/null | |||
| @@ -1,109 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* InstaDisc Server - A Four Island Project */ | ||
| 4 | |||
| 5 | include('includes/instadisc.php'); | ||
| 6 | include('includes/template.php'); | ||
| 7 | |||
| 8 | if (!isset($_GET['submit'])) | ||
| 9 | { | ||
| 10 | showForm('','','',array()); | ||
| 11 | } else { | ||
| 12 | $numOfErrors = 0; | ||
| 13 | $errors = array(); | ||
| 14 | |||
| 15 | if ($_POST['username'] == '') | ||
| 16 | { | ||
| 17 | addError($numOfErrors, $errors, 'username', 'Username is a required field'); | ||
| 18 | } | ||
| 19 | |||
| 20 | if ($_POST['password'] == '') | ||
| 21 | { | ||
| 22 | addError($numOfErrors, $errors, 'password', 'Password is a required field'); | ||
| 23 | } | ||
| 24 | |||
| 25 | if ($_POST['email'] == '') | ||
| 26 | { | ||
| 27 | addError($numOfErrors, $errors, 'email', 'Email is a required field'); | ||
| 28 | } | ||
| 29 | |||
| 30 | if ($numOfErrors > 0) | ||
| 31 | { | ||
| 32 | showForm($_POST['username'], $_POST['password'], $_POST['email'], $errors); | ||
| 33 | } else { | ||
| 34 | $send = instaDisc_sendActivationEmail($_POST['username'], $_POST['password'], $_POST['email']); | ||
| 35 | if ($send === TRUE) | ||
| 36 | { | ||
| 37 | $template = new FITemplate('registered'); | ||
| 38 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 39 | $template->display(); | ||
| 40 | } else { | ||
| 41 | addError($numOfErrors, $errors, '', $send); | ||
| 42 | showForm($_POST['username'], $_POST['password'], $_POST['email'], $errors); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | function showForm($username, $password, $email, $errors) | ||
| 48 | { | ||
| 49 | $template = new FITemplate('register'); | ||
| 50 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 51 | |||
| 52 | if (isset($errors[1])) | ||
| 53 | { | ||
| 54 | $template->adds_block('ERROR', array('ex'=>'1')); | ||
| 55 | |||
| 56 | foreach ($errors as $name => $value) | ||
| 57 | { | ||
| 58 | $template->adds_block('ERRORS', array( 'NAME' => $name, | ||
| 59 | 'MSG' => $value['msg'])); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | $template->add('USERNAME_ERR', ifErrors($errors, 'username')); | ||
| 64 | $template->add('PASSWORD_ERR', ifErrors($errors, 'password')); | ||
| 65 | $template->add('EMAIL_ERR', ifErrors($errors, 'email')); | ||
| 66 | |||
| 67 | doErrors($template, $errors, 'username'); | ||
| 68 | doErrors($template, $errors, 'password'); | ||
| 69 | doErrors($template, $errors, 'email'); | ||
| 70 | |||
| 71 | $template->add('USERNAME', $username); | ||
| 72 | $template->add('PASSWORD', $password); | ||
| 73 | $template->add('EMAIL', $email); | ||
| 74 | |||
| 75 | $template->display(); | ||
| 76 | } | ||
| 77 | |||
| 78 | function ifErrors($errors, $id) | ||
| 79 | { | ||
| 80 | foreach ($errors as $name => $value) | ||
| 81 | { | ||
| 82 | if ($value['field'] == $id) | ||
| 83 | { | ||
| 84 | return ' error'; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | return ''; | ||
| 89 | } | ||
| 90 | |||
| 91 | function doErrors($template, $errors, $id) | ||
| 92 | { | ||
| 93 | foreach ($errors as $name => $value) | ||
| 94 | { | ||
| 95 | if ($value['field'] == $id) | ||
| 96 | { | ||
| 97 | $template->adds_block(strtoupper($id) . '_ERRS', array( 'NAME' => $name, | ||
| 98 | 'VALUE' => $value['msg'])); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | function addError(&$numOfErrors, &$errors, $field, $msg) | ||
| 104 | { | ||
| 105 | $numOfErrors++; | ||
| 106 | $errors[$numOfErrors] = array('field' => $field, 'msg' => $msg); | ||
| 107 | } | ||
| 108 | |||
| 109 | ?> | ||
| diff --git a/central/trunk/userpanel.php b/central/trunk/userpanel.php deleted file mode 100644 index d0570e1..0000000 --- a/central/trunk/userpanel.php +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* InstaDisc Server - A Four Island Project */ | ||
| 4 | |||
| 5 | include('includes/instadisc.php'); | ||
| 6 | include('includes/template.php'); | ||
| 7 | |||
| 8 | if (isset($_SESSION['username'])) | ||
| 9 | { | ||
| 10 | $template = new FITemplate('userpanel'); | ||
| 11 | $template->add('SITENAME', instaDisc_getConfig('siteName')); | ||
| 12 | $template->add('USERNAME', $_SESSION['username']); | ||
| 13 | |||
| 14 | if (instaDisc_getConfig('owner') == $_SESSION['username']) | ||
| 15 | { | ||
| 16 | $template->adds_block('ADMIN',array('ex'=>1)); | ||
| 17 | } | ||
| 18 | |||
| 19 | $template->display(); | ||
| 20 | } else { | ||
| 21 | header('Location: index.php'); | ||
| 22 | } | ||
| 23 | |||
| 24 | ?> | ||
| diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php deleted file mode 100644 index ea77e3f..0000000 --- a/central/trunk/xmlrpc.php +++ /dev/null | |||
| @@ -1,266 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | /* InstaDisc Server - A Four Island Project */ | ||
| 4 | |||
| 5 | include('includes/xmlrpc/xmlrpc.inc'); | ||
| 6 | include('includes/xmlrpc/xmlrpcs.inc'); | ||
| 7 | include('includes/instadisc.php'); | ||
| 8 | |||
| 9 | function checkRegistration($username, $verification, $verificationID) | ||
| 10 | { | ||
| 11 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 12 | { | ||
| 13 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 14 | } | ||
| 15 | |||
| 16 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 17 | } | ||
| 18 | |||
| 19 | function deleteItem($username, $verification, $verificationID, $id) | ||
| 20 | { | ||
| 21 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 22 | { | ||
| 23 | $getitem = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID = " . $id; | ||
| 24 | $getitem2 = mysql_query($getitem); | ||
| 25 | $getitem3 = mysql_fetch_array($getitem2); | ||
| 26 | if ($getitem3['itemID'] == $id) | ||
| 27 | { | ||
| 28 | $delitem = "DELETE FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID = " . $id; | ||
| 29 | $delitem2 = mysql_query($delitem); | ||
| 30 | |||
| 31 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 36 | } | ||
| 37 | |||
| 38 | function resendItem($username, $verification, $verificationID, $id) | ||
| 39 | { | ||
| 40 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 41 | { | ||
| 42 | $getitem = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID = " . $id; | ||
| 43 | $getitem2 = mysql_query($getitem); | ||
| 44 | $getitem3 = mysql_fetch_array($getitem2); | ||
| 45 | if ($getitem3['itemID'] == $id) | ||
| 46 | { | ||
| 47 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 48 | $getuser2 = mysql_query($getuser); | ||
| 49 | $getuser3 = mysql_fetch_array($getuser2); | ||
| 50 | if ($getuser3['downloadItemMode'] == 'Push') | ||
| 51 | { | ||
| 52 | instaDisc_sendItem($username, $id); | ||
| 53 | |||
| 54 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 55 | } else if ($getuser3['downloadItemMode'] == 'Pull') | ||
| 56 | { | ||
| 57 | return new xmlrpcresp(new xmlrpcval(instaDisc_formItem($username, $id), 'string')); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 63 | } | ||
| 64 | |||
| 65 | function requestRetained($username, $verification, $verificationID) | ||
| 66 | { | ||
| 67 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 68 | { | ||
| 69 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 70 | $getuser2 = mysql_query($getuser); | ||
| 71 | $getuser3 = mysql_fetch_array($getuser2); | ||
| 72 | if ($getuser3['downloadItemMode'] == 'Push') | ||
| 73 | { | ||
| 74 | $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 75 | $getitems2 = mysql_query($getitems); | ||
| 76 | $i=0; | ||
| 77 | while ($getitems3[$i] = mysql_fetch_array($getitems2)) | ||
| 78 | { | ||
| 79 | if (!instaDisc_sendItem($username, $getitems3[$i]['itemID'])) | ||
| 80 | { | ||
| 81 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 82 | } | ||
| 83 | $i++; | ||
| 84 | } | ||
| 85 | |||
| 86 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 87 | } else if ($getuser3['downloadItemMode'] == 'Pull') | ||
| 88 | { | ||
| 89 | $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" LIMIT 0,2"; | ||
| 90 | $getitems2 = mysql_query($getitems); | ||
| 91 | $getitems3 = mysql_fetch_array($getitems2); | ||
| 92 | $getitems4 = mysql_fetch_array($getitems2); | ||
| 93 | if ($getitems3['username'] == $username) | ||
| 94 | { | ||
| 95 | $item = instaDisc_formItem($username, $getitems3['id']); | ||
| 96 | if ($getitems4['username'] == $username) | ||
| 97 | { | ||
| 98 | $item .= 'More: ' . $getitems4['id'] . "\n"; | ||
| 99 | } | ||
| 100 | |||
| 101 | return new xmlrpcresp(new xmlrpcval($item, 'string')); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 107 | } | ||
| 108 | |||
| 109 | function sendItem($username, $verification, $verificationID, $id) | ||
| 110 | { | ||
| 111 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 112 | { | ||
| 113 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 114 | $getuser2 = mysql_query($getuser); | ||
| 115 | $getuser3 = mysql_fetch_array($getuser2); | ||
| 116 | if ($getuser3['downloadItemMode'] == 'Pull') | ||
| 117 | { | ||
| 118 | $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID > " . ($id-1) . " LIMIT 0,2"; | ||
| 119 | $getitems2 = mysql_query($getitems); | ||
| 120 | $getitems3 = mysql_fetch_array($getitems2); | ||
| 121 | $getitems4 = mysql_fetch_array($getitems2); | ||
| 122 | if ($getitems3['username'] == $username) | ||
| 123 | { | ||
| 124 | $item = instaDisc_formItem($username, $getitems3['id']); | ||
| 125 | if ($getitems4['username'] == $username) | ||
| 126 | { | ||
| 127 | $item .= 'More: ' . $getitems4['id'] . "\n"; | ||
| 128 | } | ||
| 129 | |||
| 130 | return new xmlrpcresp(new xmlrpcval($item, 'string')); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | } | ||
| 134 | |||
| 135 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 136 | } | ||
| 137 | |||
| 138 | |||
| 139 | function sendFromUpdate($subscriptionURL, $title, $author, $url, $semantics, $encryptionID) | ||
| 140 | { | ||
| 141 | $getsed = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscriptionURL) . "\""; | ||
| 142 | $getsed2 = mysql_query($getsed); | ||
| 143 | $i=0; | ||
| 144 | while ($getsed3[$i] = mysql_fetch_array($getsed2)) | ||
| 145 | { | ||
| 146 | instaDisc_addItem($getsed3[$i]['username'], $subscriptionURL, $title, $author, $url, $semantics, $encryptionID); | ||
| 147 | $i++; | ||
| 148 | } | ||
| 149 | |||
| 150 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 151 | } | ||
| 152 | |||
| 153 | function deleteSubscription($username, $verification, $verificationID, $subscription) | ||
| 154 | { | ||
| 155 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 156 | { | ||
| 157 | $getsub = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscription) . "\" AND username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 158 | $getsub2 = mysql_query($getsub); | ||
| 159 | $getsub3 = mysql_fetch_array($getsub2); | ||
| 160 | if ($getsub3['url'] == $subscription) | ||
| 161 | { | ||
| 162 | $delsub = "DELETE FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscription) . "\" AND username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 163 | $delsub2 = mysql_query($delsub); | ||
| 164 | |||
| 165 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 166 | } | ||
| 167 | } | ||
| 168 | |||
| 169 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 170 | } | ||
| 171 | |||
| 172 | function addSubscription($username, $verification, $verificationID, $subscription, $category) | ||
| 173 | { | ||
| 174 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 175 | { | ||
| 176 | $getsub = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscription) . "\" AND username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 177 | $getsub2 = mysql_query($getsub) or die($getsub); | ||
| 178 | $getsub3 = mysql_fetch_array($getsub2); | ||
| 179 | if ($getsub3['url'] != $subscription) | ||
| 180 | { | ||
| 181 | $inssub = "INSERT INTO subscriptions (url, username, category) VALUES (\"" . mysql_real_escape_string($subscription) . "\", \"" . mysql_real_escape_string($username) . "\", \"" . mysql_real_escape_string($category) . "\")"; | ||
| 182 | $inssub2 = mysql_query($inssub); | ||
| 183 | |||
| 184 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
| 189 | } | ||
| 190 | |||
| 191 | function downloadItemModeTest() | ||
| 192 | { | ||
| 193 | $fp = @fsockopen($_SERVER['REMOTE_ADDR'], 61200, $errno, $errstr); | ||
| 194 | if ($fp) | ||
| 195 | { | ||
| 196 | fwrite($fp, "InstaDisc Download Item Mode Test\r\n\r\n\r\n"); | ||
| 197 | fclose($fp); | ||
| 198 | return new xmlrpcresp(new xmlrpcval('0', 'int')); | ||
| 199 | } else { | ||
| 200 | return new xmlrpcresp(new xmlrpcval('1', 'int')); | ||
| 201 | } | ||
| 202 | } | ||
| 203 | |||
| 204 | function setDownloadItemMode($username, $verification, $verificationID, $mode) | ||
| 205 | { | ||
| 206 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 207 | { | ||
| 208 | $setuser = "UPDATE users SET downloadItemMode = \"" . mysql_real_escape_string($mode) . "\" WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 209 | $setuser2 = mysql_query($setuser); | ||
| 210 | |||
| 211 | return new xmlrpcresp(new xmlrpcval('0', 'int')); | ||
| 212 | } | ||
| 213 | |||
| 214 | return new xmlrpcresp(new xmlrpcval('1', 'int')); | ||
| 215 | } | ||
| 216 | |||
| 217 | function initalizePort($username, $verification, $verificationID) | ||
| 218 | { | ||
| 219 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 220 | { | ||
| 221 | return new xmlrpcresp(new xmlrpcval(instaDisc_initalizePort($username), 'int')); | ||
| 222 | } | ||
| 223 | |||
| 224 | return new xmlrpcresp(new xmlrpcval('0', 'int')); | ||
| 225 | } | ||
| 226 | |||
| 227 | function deinitalizePort($username, $verification, $verificationID) | ||
| 228 | { | ||
| 229 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | ||
| 230 | { | ||
| 231 | $setuser = "UPDATE users SET port = 0 WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
| 232 | $setuser2 = mysql_query($setuser); | ||
| 233 | |||
| 234 | return new xmlrpcresp(new xmlrpcval('0', 'int')); | ||
| 235 | } | ||
| 236 | |||
| 237 | return new xmlrpcresp(new xmlrpcval('1', 'int')); | ||
| 238 | } | ||
| 239 | |||
| 240 | function countSubscribers($url) | ||
| 241 | { | ||
| 242 | $cntsub = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($url) . "\""; | ||
| 243 | $cntsub2 = mysql_query($cntsub); | ||
| 244 | $cntsub3 = mysql_fetch_array($cntsub2); | ||
| 245 | |||
| 246 | return new xmlrpcresp(new xmlrpcval($cntsub3[0], 'int')); | ||
| 247 | } | ||
| 248 | |||
| 249 | $s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"), | ||
| 250 | "InstaDisc.deleteItem" => array("function" => "deleteItem"), | ||
| 251 | "InstaDisc.resendItem" => array("function" => "resendItem"), | ||
| 252 | "InstaDisc.requestRetained" => array("function" => "requestRetained"), | ||
| 253 | "InstaDisc.sendItem" => array("function" => "sendItem"), | ||
| 254 | "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"), | ||
| 255 | "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"), | ||
| 256 | "InstaDisc.addSubscription" => array("function" => "addSubscription"), | ||
| 257 | "InstaDisc.downloadItemModeTest" => array("function" => "downloadItemModeTest"), | ||
| 258 | "InstaDisc.setDownloadItemMode" => array("function" => "setDownloadItemMode"), | ||
| 259 | "InstaDisc.initalizePort" => array("function" => "initalizePort"), | ||
| 260 | "InstaDisc.deinitalizePort" => array("function" => "deinitalizePort"), | ||
| 261 | "InstaDisc.countSubscribers" => array("function" => "countSubscribers") | ||
| 262 | ),0); | ||
| 263 | $s->functions_parameters_type = 'phpvals'; | ||
| 264 | $s->service(); | ||
| 265 | |||
| 266 | ?> | ||
