about summary refs log tree commit diff stats
path: root/update/library/trunk/instadisc.php
diff options
context:
space:
mode:
Diffstat (limited to 'update/library/trunk/instadisc.php')
-rw-r--r--update/library/trunk/instadisc.php78
1 files changed, 35 insertions, 43 deletions
diff --git a/update/library/trunk/instadisc.php b/update/library/trunk/instadisc.php index 1d8e44a..f5be298 100644 --- a/update/library/trunk/instadisc.php +++ b/update/library/trunk/instadisc.php
@@ -14,9 +14,32 @@ $idusActivationKey = array();
14$idusEncryptionKey = array(); 14$idusEncryptionKey = array();
15$instaDisc_subCount = 0; 15$instaDisc_subCount = 0;
16 16
17function instaDisc_sendItem($id, $title, $author, $url, $semantics, $encryptionID = 0) 17function instaDisc_sendItem($id, $title, $author, $url, $semantics)
18{ 18{
19 global $idusUsername, $idusPassword, $idusCentralServer, $idusSubscriptionURI; 19 global $idusUsername, $idusPassword, $idusCentralServer, $idusSubscriptionURI, $idusEncryptionKey;
20
21 $encID = 0;
22 if (($idusEncryptionKey[$id] != '') && extension_loaded('mcrypt'))
23 {
24 $encID = rand(1,2147483647);
25
26 $cipher = "rijndael-128";
27 $mode = "cbc";
28 $key = substr(md5(substr(str_pad($idusEncryptionKey[$id],16,$encID),0,16)),0,16);
29
30 $td = mcrypt_module_open($cipher, "", $mode, "");
31
32 $title = encryptString($td, $key, $title);
33 $author = encryptString($td, $key, $author);
34 $url = encryptString($td, $key, $url);
35
36 foreach ($semantics as $name => $value)
37 {
38 $semantics[$name] = encryptString($td, $key, $value);
39 }
40
41 mcrypt_module_close($td);
42 }
20 43
21 $verID = rand(1,2147483647); 44 $verID = rand(1,2147483647);
22 45
@@ -29,7 +52,7 @@ function instaDisc_sendItem($id, $title, $author, $url, $semantics, $encryptionI
29 new xmlrpcval($author, 'string'), 52 new xmlrpcval($author, 'string'),
30 new xmlrpcval($url, 'string'), 53 new xmlrpcval($url, 'string'),
31 new xmlrpcval(serialize($semantics), 'string'), 54 new xmlrpcval(serialize($semantics), 'string'),
32 new xmlrpcval($encryptionID, 'int'))); 55 new xmlrpcval($encID, 'int')));
33 $resp = $client->send($msg); 56 $resp = $client->send($msg);
34 $val = $resp->value()->scalarVal(); 57 $val = $resp->value()->scalarVal();
35 58
@@ -44,46 +67,6 @@ function instaDisc_sendItem($id, $title, $author, $url, $semantics, $encryptionI
44 } 67 }
45} 68}
46 69
47function instaDisc_sendEncrypted($id, $title, $author, $url, $semantics)
48{
49 global $idusEncryptionKey;
50
51 $encID = 0;
52 while ($encID == 0)
53 {
54 $encID = rand(1,2147483647);
55 }
56
57 $cipher = "rijndael-128";
58 $mode = "cbc";
59 $key = substr(md5(substr(str_pad($idusEncryptionKey[$id],16,$encID),0,16)),0,16);
60
61 $td = mcrypt_module_open($cipher, "", $mode, "");
62
63 mcrypt_generic_init($td, $key, strrev($key));
64 $title = bin2hex(mcrypt_generic($td, $title));
65 mcrypt_generic_deinit($td);
66
67 mcrypt_generic_init($td, $key, strrev($key));
68 $author = bin2hex(mcrypt_generic($td, $author));
69 mcrypt_generic_deinit($td);
70
71 mcrypt_generic_init($td, $key, strrev($key));
72 $url = bin2hex(mcrypt_generic($td, $url));
73 mcrypt_generic_deinit($td);
74
75 foreach ($semantics as $name => $value)
76 {
77 mcrypt_generic_init($td, $key, strrev($key));
78 $semantics[$name] = bin2hex(mcrypt_generic($td, $value));
79 mcrypt_generic_deinit($td);
80 }
81
82 mcrypt_module_close($td);
83
84 return instaDisc_sendItem($id, $title, $author, $url, $semantics, $encID);
85}
86
87function instaDisc_addSubscription($username, $password, $central, $uri, $title, $category, $key = '', $enc = '') 70function instaDisc_addSubscription($username, $password, $central, $uri, $title, $category, $key = '', $enc = '')
88{ 71{
89 global $instaDisc_subCount, $idusUsername, $idusPassword, $idusCentralServer, $idusSubscriptionURI, $idusSubscriptionTitle, $idusSubscriptionCategory, $idusActivationKey, $idusEncryptionKey; 72 global $instaDisc_subCount, $idusUsername, $idusPassword, $idusCentralServer, $idusSubscriptionURI, $idusSubscriptionTitle, $idusSubscriptionCategory, $idusActivationKey, $idusEncryptionKey;
@@ -98,4 +81,13 @@ function instaDisc_addSubscription($username, $password, $central, $uri, $title,
98 $instaDisc_subCount++; 81 $instaDisc_subCount++;
99} 82}
100 83
84function encryptString($td, $key, $string)
85{
86 mcrypt_generic_init($td, $key, strrev($key));
87 $string = bin2hex(mcrypt_generic($td, $string));
88 mcrypt_generic_deinit($td);
89
90 return $string;
91}
92
101?> 93?>