3 if (count($argv) != 3) {
4 echo "usage: $argv[0] pagename filename\n";
8 if (!file_exists($argv[2])) {
9 echo "error: file $argv[2] does not exist\n";
13 if (!is_readable($argv[2])) {
14 echo "error: file $argv[2] is not readable\n";
18 $wsdl = getenv('PHPWIKI_WSDL_URL');
19 if ($wsdl === false) {
20 $wsdl = "http://phpwiki.fr/PhpWiki.wsdl";
24 $client = new SoapClient($wsdl);
25 } catch (SoapFault $fault) {
26 die($fault->faultstring);
29 $phpwiki = getenv("HOME")."/.phpwiki";
30 if (!file_exists($phpwiki)) {
31 $login = readline("Login: ");
32 $password = readline("Password: ");
33 $credentials = base64_encode($login.':'.$password);
34 if ($fp = fopen($phpwiki, 'w')) {
35 fprintf($fp, "%s:%s", $login, $password);
37 chmod($phpwiki, 0600);
40 $credentials = base64_encode(file_get_contents($phpwiki));
44 echo $client->doSavePage($argv[1], file_get_contents($argv[2]), $credentials);
46 } catch (SoapFault $e) {
47 echo 'Error: ' . $e->getMessage() . "\n";