diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-13 15:18:01 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-13 15:18:01 +0000 |
commit | e22d0258ab3be779f78c17c6567c4205226e7399 (patch) | |
tree | f8daf1fcbbfcbb7aa1ea3c08fb2a9bd167aa56d2 /update/plugin/mediawiki/trunk | |
parent | 63dab0db05f95c82714741eee8731c59c928eab8 (diff) | |
download | instadisc-e22d0258ab3be779f78c17c6567c4205226e7399.tar.gz instadisc-e22d0258ab3be779f78c17c6567c4205226e7399.tar.bz2 instadisc-e22d0258ab3be779f78c17c6567c4205226e7399.zip |
Update: Added encryption functions
Refs #19
Diffstat (limited to 'update/plugin/mediawiki/trunk')
-rw-r--r-- | update/plugin/mediawiki/trunk/extensions/instadisc/instadisc.php | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/update/plugin/mediawiki/trunk/extensions/instadisc/instadisc.php b/update/plugin/mediawiki/trunk/extensions/instadisc/instadisc.php index 93cdd82..7601c71 100644 --- a/update/plugin/mediawiki/trunk/extensions/instadisc/instadisc.php +++ b/update/plugin/mediawiki/trunk/extensions/instadisc/instadisc.php | |||
@@ -15,9 +15,9 @@ $wgHooks['ArticleSaveComplete'][] = 'instaDisc_sendItem'; | |||
15 | 15 | ||
16 | function instaDisc_sendItem(&$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor, &$flags, &$revision) | 16 | function instaDisc_sendItem(&$article, &$user, &$text, &$summary, &$minoredit, &$watchthis, &$sectionanchor, &$flags, &$revision) |
17 | { | 17 | { |
18 | global $instaDisc_password, $instaDisc_subscriptionPersonal, $instaDisc_seriesURL, $instaDisc_seriesUsername, $instaDisc_seriesPassword, $instaDisc_subscriptionID, $instaDisc_subscriptionURL, $instaDisc_subscriptionTitle, $instaDisc_subscriptionCategory; | 18 | global $instaDisc_password, $instaDisc_subscriptionPersonal, $instaDisc_seriesURL, $instaDisc_seriesUsername, $instaDisc_seriesPassword, $instaDisc_subscriptionID, $instaDisc_subscriptionURL, $instaDisc_subscriptionTitle; |
19 | 19 | ||
20 | if (!isset($instaDisc_password) || !isset($instaDisc_subscriptionPersonal) || !isset($instaDisc_seriesURL) || !isset($instaDisc_seriesUsername) || !isset($instaDisc_seriesPassword) || !isset($instaDisc_subscriptionID) || !isset($instaDisc_subscriptionURL) || !isset($instaDisc_subscriptionTitle) || !isset($instaDisc_subscriptionCategory)) | 20 | if (!isset($instaDisc_password) || !isset($instaDisc_subscriptionPersonal) || !isset($instaDisc_seriesURL) || !isset($instaDisc_seriesUsername) || !isset($instaDisc_seriesPassword) || !isset($instaDisc_subscriptionID) || !isset($instaDisc_subscriptionURL) || !isset($instaDisc_subscriptionTitle)) |
21 | { | 21 | { |
22 | return false; | 22 | return false; |
23 | } | 23 | } |
@@ -27,7 +27,7 @@ function instaDisc_sendItem(&$article, &$user, &$text, &$summary, &$minoredit, & | |||
27 | $url = $article->getTitle()->getFullURL(); | 27 | $url = $article->getTitle()->getFullURL(); |
28 | 28 | ||
29 | $encID = 0; | 29 | $encID = 0; |
30 | if ($instaDisc_password != '') | 30 | if (($instaDisc_password != '') && (extension_loaded('mcrypt')) |
31 | { | 31 | { |
32 | $encID = encryptData($title, $author, $url, $instaDisc_password); | 32 | $encID = encryptData($title, $author, $url, $instaDisc_password); |
33 | } | 33 | } |
@@ -44,7 +44,7 @@ function instaDisc_sendItem(&$article, &$user, &$text, &$summary, &$minoredit, & | |||
44 | new xmlrpcval($instaDisc_subscriptionID, 'string'), | 44 | new xmlrpcval($instaDisc_subscriptionID, 'string'), |
45 | new xmlrpcval($instaDisc_subscriptionURL, 'string'), | 45 | new xmlrpcval($instaDisc_subscriptionURL, 'string'), |
46 | new xmlrpcval($instaDisc_subscriptionTitle, 'string'), | 46 | new xmlrpcval($instaDisc_subscriptionTitle, 'string'), |
47 | new xmlrpcval($instaDisc_subscriptionCategory, 'string'), | 47 | new xmlrpcval('page-change', 'string'), |
48 | new xmlrpcval($instaDisc_subscriptionPersonal, 'string'), | 48 | new xmlrpcval($instaDisc_subscriptionPersonal, 'string'), |
49 | new xmlrpcval($title, 'string'), | 49 | new xmlrpcval($title, 'string'), |
50 | new xmlrpcval($author, 'string'), | 50 | new xmlrpcval($author, 'string'), |
@@ -64,3 +64,32 @@ function instaDisc_sendItem(&$article, &$user, &$text, &$summary, &$minoredit, & | |||
64 | return false; | 64 | return false; |
65 | } | 65 | } |
66 | } | 66 | } |
67 | |||
68 | function encryptData(&$title, &$author, &$url, $password) | ||
69 | { | ||
70 | $encID = rand(1,2147483647); | ||
71 | |||
72 | $cipher = "rijndael-128"; | ||
73 | $mode = "cbc"; | ||
74 | $key = substr(md5(substr(str_pad($password,16,$encID),0,16)),0,16); | ||
75 | |||
76 | $td = mcrypt_module_open($cipher, "", $mode, ""); | ||
77 | |||
78 | $title = encryptString($td, $key, $title); | ||
79 | $author = encryptString($td, $key, $author); | ||
80 | $url = encryptString($td, $key, $url); | ||
81 | |||
82 | mcrypt_module_close($td); | ||
83 | |||
84 | return $encID; | ||
85 | } | ||
86 | |||
87 | function encryptString($td, $key, $string) | ||
88 | { | ||
89 | mcrypt_generic_init($td, $key, strrev($key)); | ||
90 | $string = bin2hex(mcrypt_generic($td, $string)); | ||
91 | mcrypt_generic_deinit($td); | ||
92 | |||
93 | return $string; | ||
94 | } | ||
95 | |||