From a5be7960294b174face2ef8678c87ce2ada7cd6b Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 20 Sep 2008 16:04:35 +0000 Subject: Update: Wrote Subversion plugin Fixes #62 --- update/plugin/subversion/trunk/instadisc.php | 131 +++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 update/plugin/subversion/trunk/instadisc.php (limited to 'update/plugin/subversion/trunk/instadisc.php') 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 @@ + $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 ''; + } +} + +?> -- cgit 1.4.1