about summary refs log tree commit diff stats
path: root/central/trunk/xmlrpc.php
blob: a057c12245e16981b97f3e5f02aef67f536c7591 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php

/* InstaDisc Server - A Four Island Project */

include('xmlrpc/xmlrpc.inc');
include('xmlrpc/xmlrpcs.inc');
include('db.php');
include('instadisc.php');

function checkRegistration($xmlrpcmsg)
{
	$username = $xmlrpcmsg->getParam(0)->scalarVal();
	$verification = $xmlrpcmsg->getParam(1)->scalarVal();
	$verificationID = $xmlrpcmsg->getParam(2)->scalarVal();

	$getuser = "SELECT * FROM users WHERE username = \"" . $username "\"";
	$getuser2 = mysql_query($getuser):
	$getuser3 = mysql_fetch_array($getuser2);
	if ($getuser3['username'] == $username)
	{
		$test = $username . ":" . $getuser3['password'] . ":" .$verificationID;
		if (md5($test) == $verification)
		{
			return new xmlrpcresp(new xmlrpcval(0, "int"));
		}
	}

	return new xmlrpcresp(new xmlrpcval(1, "int"));
}

function deleteItem($xmlrpcmsg)
{
	$username = $xmlrpcmsg->getParam(0)->scalarVal();
	$verification = $xmlrpcmsg->getParam(1)->scalarVal();
	$verificationID = $xmlrpcmsg->getParam(2)->scalarVal();
	$id = $xmlrpcmsg->getParam(3)->scalarVal();

	$getuser = "SELECT * FROM users WHERE username = \"" . $username "\"";
	$getuser2 = mysql_query($getuser):
	$getuser3 = mysql_fetch_array($getuser2);
	if ($getuser3['username'] == $username)
	{
		$test = $username . ":" . $getuser3['password'] . ":" .$verificationID;
		if (md5($test) == $verification)
		{
			$getitem = "SELECT * FROM inbox WHERE id = " . $id;
			$getitem2 = mysql_query($getitem);
			$getitem3 = mysql_fetch_array($getitem2);
			if ($getitem3['id'] == $id)
			{
				$delitem = "DELETE inbox WHERE id = " . $id;
				$delitem2 = mysql_query($delitem);

				return new xmlrpcresp(new xmlrpcval(0, "int"));
			}
		}
	}

	return new xmlrpcresp(new xmlrpcval(1, "int"));
}

function resendItem($xmlrpcmsg)
{
	$username = $xmlrpcmsg->getParam(0)->scalarVal();
	$verification = $xmlrpcmsg->getParam(1)->scalarVal();
	$verificationID = $xmlrpcmsg->getParam(2)->scalarVal();
	$id = $xmlrpcmsg->getParam(3)->scalarVal();

	$getuser = "SELECT * FROM users WHERE username = \"" . $username "\"";
	$getuser2 = mysql_query($getuser):
	$getuser3 = mysql_fetch_array($getuser2);
	if ($getuser3['username'] == $username)
	{
		$test = $username . ":" . $getuser3['password'] . ":" .$verificationID;
		if (md5($test) == $verification)
		{
			$getitem = "SELECT * FROM inbox WHERE id = " . $id;
			$getitem2 = mysql_query($getitem);
			$getitem3 = mysql_fetch_array($getitem2);
			if ($getitem3['id'] == $id)
			{
				instaDisc_sendItem($id);

				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"),
			"InstaDisc.requestRetained" => array("function" => "requestRetained")
		));

?>