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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
<?php
/* InstaDisc Update - A Four Island Project */
include('xmlrpc/xmlrpc.inc');
$subTitle = $_SERVER['argv'][1];
$author = $_SERVER['argv'][2];
$title = $_SERVER['argv'][3];
$rev = $_SERVER['argv'][4];
$argToWrite = parseArg(5,6);
if ($argToWrite != '')
{
$$argToWrite = $_SERVER['argv'][6];
}
$argToWrite = parseArg(7,8);
if ($argToWrite != '')
{
$$argToWrite = $_SERVER['argv'][8];
}
if (!isset($urlScheme))
{
$urlScheme = '';
}
if (!isset($subPassword))
{
$subPassword = '';
}
instaDisc_sendItem($title, $author, str_replace('REV', $rev, $urlScheme), array(), $subTitle, $subPassword);
function instaDisc_sendItem($title, $author, $url, $semantics, $subTitle, $subPassword = '')
{
$subscriptionURL = 'http://' . $_SERVER['SERVER_NAME'] . '/vcs-rev/' . generateSlug($subTitle) . '/';
$encID = 0;
if (($subPassword != '') && extension_loaded('mcrypt'))
{
$encID = rand(1,2147483647);
$cipher = "rijndael-128";
$mode = "cbc";
$key = substr(md5(substr(str_pad($subPassword,16,$encID),0,16)),0,16);
$td = mcrypt_module_open($cipher, "", $mode, "");
$title = encryptString($td, $key, $title);
$author = encryptString($td, $key, $author);
$url = encryptString($td, $key, $url);
foreach ($semantics as $name => $value)
{
$semantics[$name] = encryptString($td, $key, $value);
}
mcrypt_module_close($td);
}
$verID = rand(1,2147483647);
$client = new xmlrpc_client('http://central.fourisland.com/xmlrpc.php');
$msg = new xmlrpcmsg("InstaDisc.sendFromUpdate", array( new xmlrpcval($subscriptionURL, 'string'),
new xmlrpcval($title, 'string'),
new xmlrpcval($author, 'string'),
new xmlrpcval($url, 'string'),
new xmlrpcval(serialize($semantics), 'string'),
new xmlrpcval($encID, 'int')));
$client->setDebug(4);
$resp = $client->send($msg);
$val = $resp->value()->scalarVal();
if ($val == 2)
{
return instaDisc_sendItem($title, $author, $url, $semantics, $subTitle, $subPassword);
} else if ($val == 0)
{
return TRUE;
} else {
return FALSE;
}
}
function generateSlug($title)
{
$title = preg_replace('/[^A-Za-z0-9]/','-',$title);
$title = preg_replace('/-{2,}/','-',$title);
if (substr($title,0,1) == '-')
{
$title = substr($title,1);
}
if (substr($title,strlen($title)-1,1) == '-')
{
$title = substr($title,0,strlen($title)-1);
}
$title = strtolower($title);
return($title);
}
function encryptString($td, $key, $string)
{
mcrypt_generic_init($td, $key, strrev($key));
$string = bin2hex(mcrypt_generic($td, $string));
mcrypt_generic_deinit($td);
return $string;
}
function parseArg($switch, $value)
{
if ((!isset($_SERVER['argv'][$switch])) || (!isset($_SERVER['argv'][$value])))
{
return '';
}
if ($_SERVER['argv'][$switch] == '-u')
{
return 'urlScheme';
} else if ($_SERVER['argv'][$switch] == '-p')
{
return 'subPassword';
} else {
return '';
}
}
?>
|