]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - soapscripts/createpagefromfile
Add AS in SQL
[SourceForge/phpwiki.git] / soapscripts / createpagefromfile
1 #!/usr/bin/php
2 <?php
3 if (count($argv) != 3) {
4     echo "usage: $argv[0] pagename filename\n";
5     exit;
6 }
7
8 if (!file_exists($argv[2])) {
9     echo "error: file $argv[2] does not exist\n";
10     exit;
11 }
12
13 if (!is_readable($argv[2])) {
14     echo "error: file $argv[2] is not readable\n";
15     exit;
16 }
17
18 $wsdl = getenv('PHPWIKI_WSDL_URL');
19 if ($wsdl === false) {
20     $wsdl = "http://phpwiki.fr/PhpWiki.wsdl";
21 }
22
23 try {
24     $client = new SoapClient($wsdl);
25 } catch (SoapFault $fault) {
26     die($fault->faultstring);
27 }
28
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);
36         fclose($fp);
37         chmod($phpwiki, 0600);
38     }
39 } else {
40     $credentials = base64_encode(file_get_contents($phpwiki));
41 }
42
43 try {
44     echo $client->doSavePage($argv[1], file_get_contents($argv[2]), $credentials);
45     echo "\n";
46 } catch (SoapFault $e) {
47     echo 'Error: ' .  $e->getMessage() . "\n";
48 }