]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - soapscripts/replacestring
Update jquery to 1.11.3
[SourceForge/phpwiki.git] / soapscripts / replacestring
1 #!/usr/bin/php
2 <?php
3 if (count($argv) != 4) {
4     echo "usage: $argv[0] pagename search replace\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     $old_content = $client->getPageContent($argv[1], $credentials);
35     $new_content = str_replace($argv[2], $argv[3], $old_content);
36     if ($new_content != $old_content) {
37        echo $client->doSavePage($argv[1], $new_content, $credentials);
38        echo "\n";
39     }
40 } catch (SoapFault $e) {
41     echo 'Error: ' .  $e->getMessage() . "\n";
42 }