]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - soapscripts/titlesearch
WebM Video for Internet Explorer
[SourceForge/phpwiki.git] / soapscripts / titlesearch
1 #!/usr/bin/php
2 <?php
3 if (count($argv) != 2) {
4     echo "usage: $argv[0] term-to-search\n";
5     exit;
6 }
7
8 $wsdl = getenv('PHPWIKI_WSDL_URL');
9 if ($wsdl === false) {
10     $wsdl = "http://phpwiki.fr/PhpWiki.wsdl";
11 }
12
13 try {
14     $client = new SoapClient($wsdl);
15 } catch (SoapFault $fault) {
16     die($fault->faultstring);
17 }
18
19 $phpwiki = getenv("HOME")."/.phpwiki";
20 if (!file_exists($phpwiki)) {
21     $login = readline("Login: ");
22     $password = readline("Password: ");
23     $credentials = base64_encode($login.':'.$password);
24     if ($fp = fopen($phpwiki, 'w')) {
25         fprintf($fp, "%s:%s", $login, $password);
26         fclose($fp);
27         chmod($phpwiki, 0600);
28     }
29 } else {
30     $credentials = base64_encode(file_get_contents($phpwiki));
31 }
32
33 try {
34     $pages = $client->doTitleSearch($argv[1], $credentials);
35     foreach ($pages as $page) {
36         echo $page['pagename']."\n";
37     }
38 } catch (SoapFault $e) {
39     echo 'Error: ' .  $e->getMessage() . "\n";
40 }