]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - soapscripts/recentchanges
1.5.5 2015-12-11
[SourceForge/phpwiki.git] / soapscripts / recentchanges
1 #!/usr/bin/php
2 <?php
3 if (count($argv) == 1) {
4     $limit = 20;
5 } elseif (count($argv) == 2) {
6     $limit = $argv[0];
7 } else {
8     echo "usage: $argv[0] [limit]\n";
9     exit;
10 }
11
12 $wsdl = getenv('PHPWIKI_WSDL_URL');
13 if ($wsdl === false) {
14     $wsdl = "http://phpwiki.fr/PhpWiki.wsdl";
15 }
16
17 try {
18     $client = new SoapClient($wsdl);
19 } catch (SoapFault $fault) {
20     die($fault->faultstring);
21 }
22
23 $phpwiki = getenv("HOME")."/.phpwiki";
24 if (!file_exists($phpwiki)) {
25     $login = readline("Login: ");
26     $password = readline("Password: ");
27     $credentials = base64_encode($login.':'.$password);
28     if ($fp = fopen($phpwiki, 'w')) {
29         fprintf($fp, "%s:%s", $login, $password);
30         fclose($fp);
31         chmod($phpwiki, 0600);
32     }
33 } else {
34     $credentials = base64_encode(file_get_contents($phpwiki));
35 }
36
37 try {
38     $changes = $client->getRecentChanges($limit, $credentials);
39     foreach ($changes as $change) {
40         echo "Pagename: ".$change['pagename']."\n";
41         echo "Last modified: ".$change['lastModified']."\n";
42         echo "Author: ".$change['author']."\n";
43         echo "Summary: ".$change['summary']."\n";
44         echo "Version: ".$change['version']."\n";
45         echo "\n";
46     }
47
48 } catch (SoapFault $e) {
49     echo 'Error: ' .  $e->getMessage() . "\n";
50 }