about summary refs log tree commit diff stats
path: root/update/plugin/subversion/trunk/instadisc.php
diff options
context:
space:
mode:
Diffstat (limited to 'update/plugin/subversion/trunk/instadisc.php')
-rw-r--r--update/plugin/subversion/trunk/instadisc.php131
1 files changed, 131 insertions, 0 deletions
diff --git a/update/plugin/subversion/trunk/instadisc.php b/update/plugin/subversion/trunk/instadisc.php new file mode 100644 index 0000000..2a75099 --- /dev/null +++ b/update/plugin/subversion/trunk/instadisc.php
@@ -0,0 +1,131 @@
1<?php
2
3/* InstaDisc Update - A Four Island Project */
4
5include('xmlrpc/xmlrpc.inc');
6
7$subTitle = $_SERVER['argv'][1];
8$author = $_SERVER['argv'][2];
9$title = $_SERVER['argv'][3];
10$rev = $_SERVER['argv'][4];
11
12$argToWrite = parseArg(5,6);
13if ($argToWrite != '')
14{
15 $$argToWrite = $_SERVER['argv'][6];
16}
17
18$argToWrite = parseArg(7,8);
19if ($argToWrite != '')
20{
21 $$argToWrite = $_SERVER['argv'][8];
22}
23
24if (!isset($urlScheme))
25{
26 $urlScheme = '';
27}
28
29if (!isset($subPassword))
30{
31 $subPassword = '';
32}
33
34instaDisc_sendItem($title, $author, str_replace('REV', $rev, $urlScheme), array(), $subTitle, $subPassword);
35
36function instaDisc_sendItem($title, $author, $url, $semantics, $subTitle, $subPassword = '')
37{
38 $subscriptionURL = 'http://' . $_SERVER['SERVER_NAME'] . '/vcs-rev/' . generateSlug($subTitle) . '/';
39
40 $encID = 0;
41 if (($subPassword != '') && extension_loaded('mcrypt'))
42 {
43 $encID = rand(1,2147483647);
44
45 $cipher = "rijndael-128";
46 $mode = "cbc";
47 $key = substr(md5(substr(str_pad($subPassword,16,$encID),0,16)),0,16);
48
49 $td = mcrypt_module_open($cipher, "", $mode, "");
50
51 $title = encryptString($td, $key, $title);
52 $author = encryptString($td, $key, $author);
53 $url = encryptString($td, $key, $url);
54
55 foreach ($semantics as $name => $value)
56 {
57 $semantics[$name] = encryptString($td, $key, $value);
58 }
59
60 mcrypt_module_close($td);
61 }
62
63 $verID = rand(1,2147483647);
64
65 $client = new xmlrpc_client('http://central.fourisland.com/xmlrpc.php');
66 $msg = new xmlrpcmsg("InstaDisc.sendFromUpdate", array( new xmlrpcval($subscriptionURL, 'string'),
67 new xmlrpcval($title, 'string'),
68 new xmlrpcval($author, 'string'),
69 new xmlrpcval($url, 'string'),
70 new xmlrpcval(serialize($semantics), 'string'),
71 new xmlrpcval($encID, 'int')));
72 $client->setDebug(4);
73 $resp = $client->send($msg);
74 $val = $resp->value()->scalarVal();
75
76 if ($val == 2)
77 {
78 return instaDisc_sendItem($title, $author, $url, $semantics, $subTitle, $subPassword);
79 } else if ($val == 0)
80 {
81 return TRUE;
82 } else {
83 return FALSE;
84 }
85}
86
87function generateSlug($title)
88{
89 $title = preg_replace('/[^A-Za-z0-9]/','-',$title);
90 $title = preg_replace('/-{2,}/','-',$title);
91 if (substr($title,0,1) == '-')
92 {
93 $title = substr($title,1);
94 }
95 if (substr($title,strlen($title)-1,1) == '-')
96 {
97 $title = substr($title,0,strlen($title)-1);
98 }
99 $title = strtolower($title);
100
101 return($title);
102}
103
104function encryptString($td, $key, $string)
105{
106 mcrypt_generic_init($td, $key, strrev($key));
107 $string = bin2hex(mcrypt_generic($td, $string));
108 mcrypt_generic_deinit($td);
109
110 return $string;
111}
112
113function parseArg($switch, $value)
114{
115 if ((!isset($_SERVER['argv'][$switch])) || (!isset($_SERVER['argv'][$value])))
116 {
117 return '';
118 }
119
120 if ($_SERVER['argv'][$switch] == '-u')
121 {
122 return 'urlScheme';
123 } else if ($_SERVER['argv'][$switch] == '-p')
124 {
125 return 'subPassword';
126 } else {
127 return '';
128 }
129}
130
131?>