@@ -1,1 +1,1 @@ |
||
1 | -<html> <head><title>xmlrpc</title></head> <body> <h1>Agesort demo</h1> <h2>Send an array of 'name' => 'age' pairs to the server that will send it back sorted.</h2> <h3>The source code demonstrates basic lib usage, including handling of xmlrpc arrays and structs</h3> <p></p> <?php include("xmlrpc.inc"); $inAr=array("Dave" => 24, "Edd" => 45, "Joe" => 37, "Fred" => 27); reset($inAr); print "This is the input data:<br/><pre>"; while (list($key, $val)=each($inAr)) { print $key . ", " . $val . "\n"; } print "</pre>"; // create parameters from the input array: an xmlrpc array of xmlrpc structs $p=array(); foreach($inAr as $key => $val) { $p[]=new xmlrpcval(array("name" => new xmlrpcval($key), "age" => new xmlrpcval($val, "int")), "struct"); } $v=new xmlrpcval($p, "array"); print "Encoded into xmlrpc format it looks like this: <pre>\n" . htmlentities($v->serialize()). "</pre>\n"; // create client and message objects $f=new xmlrpcmsg('examples.sortByAge', array($v)); $c=new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); // set maximum debug level, to have the complete communication printed to screen $c->setDebug(2); // send request print "Now sending request (detailed debug info follows)"; $r=&$c->send($f); // check response for errors, and take appropriate action if (!$r->faultCode()) { print "The server gave me these results:<pre>"; $v=$r->value(); $max=$v->arraysize(); for($i=0; $i<$max; $i++) { $rec=$v->arraymem($i); $n=$rec->structmem("name"); $a=$rec->structmem("age"); print htmlspecialchars($n->scalarval()) . ", " . htmlspecialchars($a->scalarval()) . "\n"; } print "<hr/>For nerds: I got this value back<br/><pre>" . htmlentities($r->serialize()). "</pre><hr/>\n"; } else { print "An error occurred:<pre>"; print "Code: " . htmlspecialchars($r->faultCode()) . "\nReason: '" . htmlspecialchars($r->faultString()).'\'</pre><hr/>'; } ?> </body> </html> |
|
2 | 1 | \ No newline at end of file |
2 | +<html> <head><title>xmlrpc</title></head> <body> <h1>Agesort demo</h1> <h2>Send an array of 'name' => 'age' pairs to the server that will send it back sorted.</h2> <h3>The source code demonstrates basic lib usage, including handling of xmlrpc arrays and structs</h3> <p></p> <?php include("xmlrpc.inc"); $inAr = array("Dave" => 24, "Edd" => 45, "Joe" => 37, "Fred" => 27); reset($inAr); print "This is the input data:<br/><pre>"; while (list($key, $val) = each($inAr)) { print $key.", ".$val."\n"; } print "</pre>"; // create parameters from the input array: an xmlrpc array of xmlrpc structs $p = array(); foreach ($inAr as $key => $val) { $p[] = new xmlrpcval(array("name" => new xmlrpcval($key), "age" => new xmlrpcval($val, "int")), "struct"); } $v = new xmlrpcval($p, "array"); print "Encoded into xmlrpc format it looks like this: <pre>\n".htmlentities($v->serialize())."</pre>\n"; // create client and message objects $f = new xmlrpcmsg('examples.sortByAge', array($v)); $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); // set maximum debug level, to have the complete communication printed to screen $c->setDebug(2); // send request print "Now sending request (detailed debug info follows)"; $r = &$c->send($f); // check response for errors, and take appropriate action if (!$r->faultCode()) { print "The server gave me these results:<pre>"; $v = $r->value(); $max = $v->arraysize(); for ($i = 0; $i<$max; $i++) { $rec = $v->arraymem($i); $n = $rec->structmem("name"); $a = $rec->structmem("age"); print htmlspecialchars($n->scalarval()).", ".htmlspecialchars($a->scalarval())."\n"; } print "<hr/>For nerds: I got this value back<br/><pre>".htmlentities($r->serialize())."</pre><hr/>\n"; } else { print "An error occurred:<pre>"; print "Code: ".htmlspecialchars($r->faultCode())."\nReason: '".htmlspecialchars($r->faultString()).'\'</pre><hr/>'; } ?> </body> </html> |
|
3 | 3 | \ No newline at end of file |
@@ -5,45 +5,45 @@ |
||
5 | 5 | <h2>Send a U.S. state number to the server and get back the state name</h2> |
6 | 6 | <h3>The code demonstrates usage of the php_xmlrpc_encode function</h3> |
7 | 7 | <?php |
8 | - include("xmlrpc.inc"); |
|
8 | + include("xmlrpc.inc"); |
|
9 | 9 | |
10 | - // Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off |
|
11 | - if(!isset($HTTP_POST_VARS) && isset($_POST)) |
|
12 | - { |
|
13 | - $HTTP_POST_VARS = $_POST; |
|
14 | - } |
|
10 | + // Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off |
|
11 | + if(!isset($HTTP_POST_VARS) && isset($_POST)) |
|
12 | + { |
|
13 | + $HTTP_POST_VARS = $_POST; |
|
14 | + } |
|
15 | 15 | |
16 | - if(isset($HTTP_POST_VARS["stateno"]) && $HTTP_POST_VARS["stateno"]!="") |
|
17 | - { |
|
18 | - $stateno=(integer)$HTTP_POST_VARS["stateno"]; |
|
19 | - $f=new xmlrpcmsg('examples.getStateName', |
|
20 | - array(php_xmlrpc_encode($stateno)) |
|
21 | - ); |
|
22 | - print "<pre>Sending the following request:\n\n" . htmlentities($f->serialize()) . "\n\nDebug info of server data follows...\n\n"; |
|
23 | - $c=new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); |
|
24 | - $c->setDebug(1); |
|
25 | - $r=&$c->send($f); |
|
26 | - if(!$r->faultCode()) |
|
27 | - { |
|
28 | - $v=$r->value(); |
|
29 | - print "</pre><br/>State number " . $stateno . " is " |
|
30 | - . htmlspecialchars($v->scalarval()) . "<br/>"; |
|
31 | - // print "<HR>I got this value back<BR><PRE>" . |
|
32 | - // htmlentities($r->serialize()). "</PRE><HR>\n"; |
|
33 | - } |
|
34 | - else |
|
35 | - { |
|
36 | - print "An error occurred: "; |
|
37 | - print "Code: " . htmlspecialchars($r->faultCode()) |
|
38 | - . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>"; |
|
39 | - } |
|
40 | - } |
|
41 | - else |
|
42 | - { |
|
43 | - $stateno = ""; |
|
44 | - } |
|
16 | + if(isset($HTTP_POST_VARS["stateno"]) && $HTTP_POST_VARS["stateno"]!="") |
|
17 | + { |
|
18 | + $stateno=(integer)$HTTP_POST_VARS["stateno"]; |
|
19 | + $f=new xmlrpcmsg('examples.getStateName', |
|
20 | + array(php_xmlrpc_encode($stateno)) |
|
21 | + ); |
|
22 | + print "<pre>Sending the following request:\n\n" . htmlentities($f->serialize()) . "\n\nDebug info of server data follows...\n\n"; |
|
23 | + $c=new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); |
|
24 | + $c->setDebug(1); |
|
25 | + $r=&$c->send($f); |
|
26 | + if(!$r->faultCode()) |
|
27 | + { |
|
28 | + $v=$r->value(); |
|
29 | + print "</pre><br/>State number " . $stateno . " is " |
|
30 | + . htmlspecialchars($v->scalarval()) . "<br/>"; |
|
31 | + // print "<HR>I got this value back<BR><PRE>" . |
|
32 | + // htmlentities($r->serialize()). "</PRE><HR>\n"; |
|
33 | + } |
|
34 | + else |
|
35 | + { |
|
36 | + print "An error occurred: "; |
|
37 | + print "Code: " . htmlspecialchars($r->faultCode()) |
|
38 | + . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>"; |
|
39 | + } |
|
40 | + } |
|
41 | + else |
|
42 | + { |
|
43 | + $stateno = ""; |
|
44 | + } |
|
45 | 45 | |
46 | - print "<form action=\"client.php\" method=\"POST\"> |
|
46 | + print "<form action=\"client.php\" method=\"POST\"> |
|
47 | 47 | <input name=\"stateno\" value=\"" . $stateno . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form> |
48 | 48 | <p>Enter a state number to query its name</p>"; |
49 | 49 |
@@ -8,34 +8,34 @@ discard block |
||
8 | 8 | include("xmlrpc.inc"); |
9 | 9 | |
10 | 10 | // Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off |
11 | - if(!isset($HTTP_POST_VARS) && isset($_POST)) |
|
11 | + if (!isset($HTTP_POST_VARS) && isset($_POST)) |
|
12 | 12 | { |
13 | 13 | $HTTP_POST_VARS = $_POST; |
14 | 14 | } |
15 | 15 | |
16 | - if(isset($HTTP_POST_VARS["stateno"]) && $HTTP_POST_VARS["stateno"]!="") |
|
16 | + if (isset($HTTP_POST_VARS["stateno"]) && $HTTP_POST_VARS["stateno"] != "") |
|
17 | 17 | { |
18 | - $stateno=(integer)$HTTP_POST_VARS["stateno"]; |
|
19 | - $f=new xmlrpcmsg('examples.getStateName', |
|
18 | + $stateno = (integer) $HTTP_POST_VARS["stateno"]; |
|
19 | + $f = new xmlrpcmsg('examples.getStateName', |
|
20 | 20 | array(php_xmlrpc_encode($stateno)) |
21 | 21 | ); |
22 | - print "<pre>Sending the following request:\n\n" . htmlentities($f->serialize()) . "\n\nDebug info of server data follows...\n\n"; |
|
23 | - $c=new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); |
|
22 | + print "<pre>Sending the following request:\n\n".htmlentities($f->serialize())."\n\nDebug info of server data follows...\n\n"; |
|
23 | + $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); |
|
24 | 24 | $c->setDebug(1); |
25 | - $r=&$c->send($f); |
|
26 | - if(!$r->faultCode()) |
|
25 | + $r = &$c->send($f); |
|
26 | + if (!$r->faultCode()) |
|
27 | 27 | { |
28 | - $v=$r->value(); |
|
29 | - print "</pre><br/>State number " . $stateno . " is " |
|
30 | - . htmlspecialchars($v->scalarval()) . "<br/>"; |
|
28 | + $v = $r->value(); |
|
29 | + print "</pre><br/>State number ".$stateno." is " |
|
30 | + . htmlspecialchars($v->scalarval())."<br/>"; |
|
31 | 31 | // print "<HR>I got this value back<BR><PRE>" . |
32 | 32 | // htmlentities($r->serialize()). "</PRE><HR>\n"; |
33 | 33 | } |
34 | 34 | else |
35 | 35 | { |
36 | 36 | print "An error occurred: "; |
37 | - print "Code: " . htmlspecialchars($r->faultCode()) |
|
38 | - . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>"; |
|
37 | + print "Code: ".htmlspecialchars($r->faultCode()) |
|
38 | + . " Reason: '".htmlspecialchars($r->faultString())."'</pre><br/>"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | else |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | print "<form action=\"client.php\" method=\"POST\"> |
47 | -<input name=\"stateno\" value=\"" . $stateno . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form> |
|
47 | +<input name=\"stateno\" value=\"" . $stateno."\"><input type=\"submit\" value=\"go\" name=\"submit\"></form> |
|
48 | 48 | <p>Enter a state number to query its name</p>"; |
49 | 49 | |
50 | 50 | ?> |
@@ -30,15 +30,13 @@ |
||
30 | 30 | . htmlspecialchars($v->scalarval()) . "<br/>"; |
31 | 31 | // print "<HR>I got this value back<BR><PRE>" . |
32 | 32 | // htmlentities($r->serialize()). "</PRE><HR>\n"; |
33 | - } |
|
34 | - else |
|
33 | + } else |
|
35 | 34 | { |
36 | 35 | print "An error occurred: "; |
37 | 36 | print "Code: " . htmlspecialchars($r->faultCode()) |
38 | 37 | . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>"; |
39 | 38 | } |
40 | - } |
|
41 | - else |
|
39 | + } else |
|
42 | 40 | { |
43 | 41 | $stateno = ""; |
44 | 42 | } |
@@ -6,53 +6,53 @@ |
||
6 | 6 | * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt |
7 | 7 | */ |
8 | 8 | |
9 | - /** |
|
10 | - * Takes a client object, a remote method name, and a variable numbers of |
|
11 | - * php values, and calls the method with the supplied parameters. The |
|
12 | - * parameters are native php values and the result is an xmlrpcresp object. |
|
13 | - * |
|
14 | - * Notes: |
|
15 | - * The function encodes the received parameters using php_xmlrpc_encode: |
|
16 | - * the limitations of automatic encoding apply to this function too); |
|
17 | - * |
|
18 | - * the type of the value returned by the function can be changed setting |
|
19 | - * beforehand the 'return_type' member of the client object to 'phpvals' - |
|
20 | - * see the manual for more details about this capability). |
|
21 | - * |
|
22 | - * |
|
23 | - * @author Toth Istvan |
|
24 | - * |
|
25 | - * @param xmlrpc_client client object, properly set up to connect to server |
|
26 | - * @param string remote function name |
|
27 | - * @param mixed $parameter1 |
|
28 | - * @param mixed $parameter2 |
|
29 | - * @param mixed $parameter3 ... |
|
30 | - * @return xmlrpcresp or false on error |
|
31 | - */ |
|
32 | - function xmlrpccall_simple() |
|
33 | - { |
|
34 | - if(func_num_args() < 2) |
|
35 | - { |
|
36 | - // Incorrect |
|
37 | - return false; |
|
38 | - } |
|
39 | - else |
|
40 | - { |
|
41 | - $varargs = func_get_args(); |
|
42 | - $client = array_shift($varargs); |
|
43 | - $remote_function_name = array_shift($varargs); |
|
44 | - if (!is_a($client, 'xmlrpc_client') || !is_string($remote_function_name)) |
|
45 | - { |
|
46 | - return false; |
|
47 | - } |
|
9 | + /** |
|
10 | + * Takes a client object, a remote method name, and a variable numbers of |
|
11 | + * php values, and calls the method with the supplied parameters. The |
|
12 | + * parameters are native php values and the result is an xmlrpcresp object. |
|
13 | + * |
|
14 | + * Notes: |
|
15 | + * The function encodes the received parameters using php_xmlrpc_encode: |
|
16 | + * the limitations of automatic encoding apply to this function too); |
|
17 | + * |
|
18 | + * the type of the value returned by the function can be changed setting |
|
19 | + * beforehand the 'return_type' member of the client object to 'phpvals' - |
|
20 | + * see the manual for more details about this capability). |
|
21 | + * |
|
22 | + * |
|
23 | + * @author Toth Istvan |
|
24 | + * |
|
25 | + * @param xmlrpc_client client object, properly set up to connect to server |
|
26 | + * @param string remote function name |
|
27 | + * @param mixed $parameter1 |
|
28 | + * @param mixed $parameter2 |
|
29 | + * @param mixed $parameter3 ... |
|
30 | + * @return xmlrpcresp or false on error |
|
31 | + */ |
|
32 | + function xmlrpccall_simple() |
|
33 | + { |
|
34 | + if(func_num_args() < 2) |
|
35 | + { |
|
36 | + // Incorrect |
|
37 | + return false; |
|
38 | + } |
|
39 | + else |
|
40 | + { |
|
41 | + $varargs = func_get_args(); |
|
42 | + $client = array_shift($varargs); |
|
43 | + $remote_function_name = array_shift($varargs); |
|
44 | + if (!is_a($client, 'xmlrpc_client') || !is_string($remote_function_name)) |
|
45 | + { |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | - $xmlrpcval_array = array(); |
|
50 | - foreach($varargs as $parameter) |
|
51 | - { |
|
52 | - $xmlrpcval_array[] = php_xmlrpc_encode($parameter); |
|
53 | - } |
|
49 | + $xmlrpcval_array = array(); |
|
50 | + foreach($varargs as $parameter) |
|
51 | + { |
|
52 | + $xmlrpcval_array[] = php_xmlrpc_encode($parameter); |
|
53 | + } |
|
54 | 54 | |
55 | - return $client->send(new xmlrpcmsg($remote_function_name, $xmlrpcval_array)); |
|
56 | - } |
|
57 | - } |
|
55 | + return $client->send(new xmlrpcmsg($remote_function_name, $xmlrpcval_array)); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | ?> |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function xmlrpccall_simple() |
33 | 33 | { |
34 | - if(func_num_args() < 2) |
|
34 | + if (func_num_args()<2) |
|
35 | 35 | { |
36 | 36 | // Incorrect |
37 | 37 | return false; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | $xmlrpcval_array = array(); |
50 | - foreach($varargs as $parameter) |
|
50 | + foreach ($varargs as $parameter) |
|
51 | 51 | { |
52 | 52 | $xmlrpcval_array[] = php_xmlrpc_encode($parameter); |
53 | 53 | } |
@@ -35,8 +35,7 @@ |
||
35 | 35 | { |
36 | 36 | // Incorrect |
37 | 37 | return false; |
38 | - } |
|
39 | - else |
|
38 | + } else |
|
40 | 39 | { |
41 | 40 | $varargs = func_get_args(); |
42 | 41 | $client = array_shift($varargs); |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Allow users to see the source of this file even if PHP is not configured for it |
3 | 3 | if ((isset($HTTP_GET_VARS['showSource']) && $HTTP_GET_VARS['showSource']) || |
4 | - (isset($_GET['showSource']) && $_GET['showSource'])) |
|
5 | - { highlight_file(__FILE__); die(); } |
|
4 | + (isset($_GET['showSource']) && $_GET['showSource'])) |
|
5 | + { highlight_file(__FILE__); die(); } |
|
6 | 6 | ?> |
7 | 7 | <html> |
8 | 8 | <head><title>xmlrpc</title></head> |
@@ -18,36 +18,36 @@ discard block |
||
18 | 18 | |
19 | 19 | // Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off |
20 | 20 | if (!isset($HTTP_POST_VARS) && isset($_POST)) |
21 | - $HTTP_POST_VARS = $_POST; |
|
21 | + $HTTP_POST_VARS = $_POST; |
|
22 | 22 | |
23 | 23 | if (isset($HTTP_POST_VARS["server"]) && $HTTP_POST_VARS["server"]) { |
24 | - if ($HTTP_POST_VARS["server"]=="Userland") { |
|
25 | - $XP="/RPC2"; $XS="206.204.24.2"; |
|
26 | - } else { |
|
27 | - $XP="/xmlrpc/server.php"; $XS="pingu.heddley.com"; |
|
28 | - } |
|
29 | - $f=new xmlrpcmsg('mail.send'); |
|
30 | - $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailto"])); |
|
31 | - $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailsub"])); |
|
32 | - $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailmsg"])); |
|
33 | - $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailfrom"])); |
|
34 | - $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailcc"])); |
|
35 | - $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailbcc"])); |
|
36 | - $f->addParam(new xmlrpcval("text/plain")); |
|
24 | + if ($HTTP_POST_VARS["server"]=="Userland") { |
|
25 | + $XP="/RPC2"; $XS="206.204.24.2"; |
|
26 | + } else { |
|
27 | + $XP="/xmlrpc/server.php"; $XS="pingu.heddley.com"; |
|
28 | + } |
|
29 | + $f=new xmlrpcmsg('mail.send'); |
|
30 | + $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailto"])); |
|
31 | + $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailsub"])); |
|
32 | + $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailmsg"])); |
|
33 | + $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailfrom"])); |
|
34 | + $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailcc"])); |
|
35 | + $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailbcc"])); |
|
36 | + $f->addParam(new xmlrpcval("text/plain")); |
|
37 | 37 | |
38 | - $c=new xmlrpc_client($XP, $XS, 80); |
|
39 | - $c->setDebug(2); |
|
40 | - $r=&$c->send($f); |
|
41 | - if (!$r->faultCode()) { |
|
42 | - print "Mail sent OK<br/>\n"; |
|
43 | - } else { |
|
44 | - print "<fonr color=\"red\">"; |
|
45 | - print "Mail send failed<br/>\n"; |
|
46 | - print "Fault: "; |
|
47 | - print "Code: " . htmlspecialchars($r->faultCode()) . |
|
48 | - " Reason: '" . htmlspecialchars($r->faultString()) . "'<br/>"; |
|
49 | - print "</font><br/>"; |
|
50 | - } |
|
38 | + $c=new xmlrpc_client($XP, $XS, 80); |
|
39 | + $c->setDebug(2); |
|
40 | + $r=&$c->send($f); |
|
41 | + if (!$r->faultCode()) { |
|
42 | + print "Mail sent OK<br/>\n"; |
|
43 | + } else { |
|
44 | + print "<fonr color=\"red\">"; |
|
45 | + print "Mail send failed<br/>\n"; |
|
46 | + print "Fault: "; |
|
47 | + print "Code: " . htmlspecialchars($r->faultCode()) . |
|
48 | + " Reason: '" . htmlspecialchars($r->faultString()) . "'<br/>"; |
|
49 | + print "</font><br/>"; |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | ?> |
53 | 53 | <form method="POST"> |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | $HTTP_POST_VARS = $_POST; |
22 | 22 | |
23 | 23 | if (isset($HTTP_POST_VARS["server"]) && $HTTP_POST_VARS["server"]) { |
24 | - if ($HTTP_POST_VARS["server"]=="Userland") { |
|
25 | - $XP="/RPC2"; $XS="206.204.24.2"; |
|
24 | + if ($HTTP_POST_VARS["server"] == "Userland") { |
|
25 | + $XP = "/RPC2"; $XS = "206.204.24.2"; |
|
26 | 26 | } else { |
27 | - $XP="/xmlrpc/server.php"; $XS="pingu.heddley.com"; |
|
27 | + $XP = "/xmlrpc/server.php"; $XS = "pingu.heddley.com"; |
|
28 | 28 | } |
29 | - $f=new xmlrpcmsg('mail.send'); |
|
29 | + $f = new xmlrpcmsg('mail.send'); |
|
30 | 30 | $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailto"])); |
31 | 31 | $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailsub"])); |
32 | 32 | $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailmsg"])); |
@@ -35,17 +35,17 @@ discard block |
||
35 | 35 | $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailbcc"])); |
36 | 36 | $f->addParam(new xmlrpcval("text/plain")); |
37 | 37 | |
38 | - $c=new xmlrpc_client($XP, $XS, 80); |
|
38 | + $c = new xmlrpc_client($XP, $XS, 80); |
|
39 | 39 | $c->setDebug(2); |
40 | - $r=&$c->send($f); |
|
40 | + $r = &$c->send($f); |
|
41 | 41 | if (!$r->faultCode()) { |
42 | 42 | print "Mail sent OK<br/>\n"; |
43 | 43 | } else { |
44 | 44 | print "<fonr color=\"red\">"; |
45 | 45 | print "Mail send failed<br/>\n"; |
46 | 46 | print "Fault: "; |
47 | - print "Code: " . htmlspecialchars($r->faultCode()) . |
|
48 | - " Reason: '" . htmlspecialchars($r->faultString()) . "'<br/>"; |
|
47 | + print "Code: ".htmlspecialchars($r->faultCode()). |
|
48 | + " Reason: '".htmlspecialchars($r->faultString())."'<br/>"; |
|
49 | 49 | print "</font><br/>"; |
50 | 50 | } |
51 | 51 | } |
@@ -17,8 +17,9 @@ |
||
17 | 17 | include("xmlrpc.inc"); |
18 | 18 | |
19 | 19 | // Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off |
20 | -if (!isset($HTTP_POST_VARS) && isset($_POST)) |
|
20 | +if (!isset($HTTP_POST_VARS) && isset($_POST)) { |
|
21 | 21 | $HTTP_POST_VARS = $_POST; |
22 | +} |
|
22 | 23 | |
23 | 24 | if (isset($HTTP_POST_VARS["server"]) && $HTTP_POST_VARS["server"]) { |
24 | 25 | if ($HTTP_POST_VARS["server"]=="Userland") { |
@@ -4,26 +4,26 @@ |
||
4 | 4 | <h1>Zope test demo</h1> |
5 | 5 | <h3>The code demonstrates usage of basic authentication to connect to the server</h3> |
6 | 6 | <?php |
7 | - include("xmlrpc.inc"); |
|
7 | + include("xmlrpc.inc"); |
|
8 | 8 | |
9 | - $f = new xmlrpcmsg('document_src', array()); |
|
10 | - $c = new xmlrpc_client("/index_html", "pingu.heddley.com", 9080); |
|
11 | - $c->setCredentials("username", "password"); |
|
12 | - $c->setDebug(2); |
|
13 | - $r = $c->send($f); |
|
14 | - if(!$r->faultCode()) |
|
15 | - { |
|
16 | - $v = $r->value(); |
|
17 | - print "I received:" . htmlspecialchars($v->scalarval()) . "<br/>"; |
|
18 | - print "<hr/>I got this value back<br/>pre>" . |
|
19 | - htmlentities($r->serialize()). "</pre>\n"; |
|
20 | - } |
|
21 | - else |
|
22 | - { |
|
23 | - print "An error occurred: "; |
|
24 | - print "Code: " . htmlspecialchars($r->faultCode()) |
|
25 | - . " Reason: '" . ($r->faultString()) . "'<br/>"; |
|
26 | - } |
|
9 | + $f = new xmlrpcmsg('document_src', array()); |
|
10 | + $c = new xmlrpc_client("/index_html", "pingu.heddley.com", 9080); |
|
11 | + $c->setCredentials("username", "password"); |
|
12 | + $c->setDebug(2); |
|
13 | + $r = $c->send($f); |
|
14 | + if(!$r->faultCode()) |
|
15 | + { |
|
16 | + $v = $r->value(); |
|
17 | + print "I received:" . htmlspecialchars($v->scalarval()) . "<br/>"; |
|
18 | + print "<hr/>I got this value back<br/>pre>" . |
|
19 | + htmlentities($r->serialize()). "</pre>\n"; |
|
20 | + } |
|
21 | + else |
|
22 | + { |
|
23 | + print "An error occurred: "; |
|
24 | + print "Code: " . htmlspecialchars($r->faultCode()) |
|
25 | + . " Reason: '" . ($r->faultString()) . "'<br/>"; |
|
26 | + } |
|
27 | 27 | ?> |
28 | 28 | </body> |
29 | 29 | </html> |
@@ -11,18 +11,18 @@ |
||
11 | 11 | $c->setCredentials("username", "password"); |
12 | 12 | $c->setDebug(2); |
13 | 13 | $r = $c->send($f); |
14 | - if(!$r->faultCode()) |
|
14 | + if (!$r->faultCode()) |
|
15 | 15 | { |
16 | 16 | $v = $r->value(); |
17 | - print "I received:" . htmlspecialchars($v->scalarval()) . "<br/>"; |
|
18 | - print "<hr/>I got this value back<br/>pre>" . |
|
19 | - htmlentities($r->serialize()). "</pre>\n"; |
|
17 | + print "I received:".htmlspecialchars($v->scalarval())."<br/>"; |
|
18 | + print "<hr/>I got this value back<br/>pre>". |
|
19 | + htmlentities($r->serialize())."</pre>\n"; |
|
20 | 20 | } |
21 | 21 | else |
22 | 22 | { |
23 | 23 | print "An error occurred: "; |
24 | - print "Code: " . htmlspecialchars($r->faultCode()) |
|
25 | - . " Reason: '" . ($r->faultString()) . "'<br/>"; |
|
24 | + print "Code: ".htmlspecialchars($r->faultCode()) |
|
25 | + . " Reason: '".($r->faultString())."'<br/>"; |
|
26 | 26 | } |
27 | 27 | ?> |
28 | 28 | </body> |
@@ -17,8 +17,7 @@ |
||
17 | 17 | print "I received:" . htmlspecialchars($v->scalarval()) . "<br/>"; |
18 | 18 | print "<hr/>I got this value back<br/>pre>" . |
19 | 19 | htmlentities($r->serialize()). "</pre>\n"; |
20 | - } |
|
21 | - else |
|
20 | + } else |
|
22 | 21 | { |
23 | 22 | print "An error occurred: "; |
24 | 23 | print "Code: " . htmlspecialchars($r->faultCode()) |
@@ -1,1 +1,1 @@ |
||
1 | -<html> <head><title>xmlrpc</title></head> <body> <h1>Introspect demo</h1> <h2>Query server for available methods and their description</h2> <h3>The code demonstrates usage of multicall and introspection methods</h3> <?php include("xmlrpc.inc"); function display_error($r) { print "An error occurred: "; print "Code: " . $r->faultCode() . " Reason: '" .$r->faultString()."'<br/>"; } // 'new style' client constuctor $c = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php"); print "<h3>methods available at http://" . $c->server . $c->path . "</h3>\n"; $m = new xmlrpcmsg('system.listMethods'); $r =& $c->send($m); if($r->faultCode()) { display_error($r); } else { $v=$r->value(); for($i=0; $i<$v->arraysize(); $i++) { $mname=$v->arraymem($i); print "<h4>" . $mname->scalarval() . "</h4>\n"; // build messages first, add params later $m1 = new xmlrpcmsg('system.methodHelp'); $m2 = new xmlrpcmsg('system.methodSignature'); $val = new xmlrpcval($mname->scalarval(), "string"); $m1->addParam($val); $m2->addParam($val); // send multiple messages in one pass. // If server does not support multicall, client will fall back to 2 separate calls $ms = array($m1, $m2); $rs =& $c->send($ms); if($rs[0]->faultCode()) { display_error($rs[0]); } else { $val=$rs[0]->value(); $txt=$val->scalarval(); if($txt != "") { print "<h4>Documentation</h4><p>${txt}</p>\n"; } else { print "<p>No documentation available.</p>\n"; } } if($rs[1]->faultCode()) { display_error($rs[1]); } else { print "<h4>Signature</h4><p>\n"; $val = $rs[1]->value(); if($val->kindOf()=="array") { for($j=0; $j<$val->arraysize(); $j++) { $x = $val->arraymem($j); $ret = $x->arraymem(0); print "<code>" . $ret->scalarval() . " " . $mname->scalarval() . "("; if($x->arraysize()>1) { for($k=1; $k<$x->arraysize(); $k++) { $y = $x->arraymem($k); print $y->scalarval(); if($k < $x->arraysize()-1) { print ", "; } } } print ")</code><br/>\n"; } } else { print "Signature unknown\n"; } print "</p>\n"; } } } ?> </body> </html> |
|
2 | 1 | \ No newline at end of file |
2 | +<html> <head><title>xmlrpc</title></head> <body> <h1>Introspect demo</h1> <h2>Query server for available methods and their description</h2> <h3>The code demonstrates usage of multicall and introspection methods</h3> <?php include("xmlrpc.inc"); function display_error($r) { print "An error occurred: "; print "Code: ".$r->faultCode()." Reason: '".$r->faultString()."'<br/>"; } // 'new style' client constuctor $c = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php"); print "<h3>methods available at http://".$c->server.$c->path."</h3>\n"; $m = new xmlrpcmsg('system.listMethods'); $r = & $c->send($m); if ($r->faultCode()) { display_error($r); } else { $v = $r->value(); for ($i = 0; $i<$v->arraysize(); $i++) { $mname = $v->arraymem($i); print "<h4>".$mname->scalarval()."</h4>\n"; // build messages first, add params later $m1 = new xmlrpcmsg('system.methodHelp'); $m2 = new xmlrpcmsg('system.methodSignature'); $val = new xmlrpcval($mname->scalarval(), "string"); $m1->addParam($val); $m2->addParam($val); // send multiple messages in one pass. // If server does not support multicall, client will fall back to 2 separate calls $ms = array($m1, $m2); $rs = & $c->send($ms); if ($rs[0]->faultCode()) { display_error($rs[0]); } else { $val = $rs[0]->value(); $txt = $val->scalarval(); if ($txt != "") { print "<h4>Documentation</h4><p>${txt}</p>\n"; } else { print "<p>No documentation available.</p>\n"; } } if ($rs[1]->faultCode()) { display_error($rs[1]); } else { print "<h4>Signature</h4><p>\n"; $val = $rs[1]->value(); if ($val->kindOf() == "array") { for ($j = 0; $j<$val->arraysize(); $j++) { $x = $val->arraymem($j); $ret = $x->arraymem(0); print "<code>".$ret->scalarval()." ".$mname->scalarval()."("; if ($x->arraysize()>1) { for ($k = 1; $k<$x->arraysize(); $k++) { $y = $x->arraymem($k); print $y->scalarval(); if ($k<$x->arraysize()-1) { print ", "; } } } print ")</code><br/>\n"; } } else { print "Signature unknown\n"; } print "</p>\n"; } } } ?> </body> </html> |
|
3 | 3 | \ No newline at end of file |
@@ -1,1 +1,1 @@ |
||
1 | -<html> <head><title>xmlrpc</title></head> <body> <h1>Introspect demo</h1> <h2>Query server for available methods and their description</h2> <h3>The code demonstrates usage of multicall and introspection methods</h3> <?php include("xmlrpc.inc"); function display_error($r) { print "An error occurred: "; print "Code: " . $r->faultCode() . " Reason: '" .$r->faultString()."'<br/>"; } // 'new style' client constuctor $c = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php"); print "<h3>methods available at http://" . $c->server . $c->path . "</h3>\n"; $m = new xmlrpcmsg('system.listMethods'); $r =& $c->send($m); if($r->faultCode()) { display_error($r); } else { $v=$r->value(); for($i=0; $i<$v->arraysize(); $i++) { $mname=$v->arraymem($i); print "<h4>" . $mname->scalarval() . "</h4>\n"; // build messages first, add params later $m1 = new xmlrpcmsg('system.methodHelp'); $m2 = new xmlrpcmsg('system.methodSignature'); $val = new xmlrpcval($mname->scalarval(), "string"); $m1->addParam($val); $m2->addParam($val); // send multiple messages in one pass. // If server does not support multicall, client will fall back to 2 separate calls $ms = array($m1, $m2); $rs =& $c->send($ms); if($rs[0]->faultCode()) { display_error($rs[0]); } else { $val=$rs[0]->value(); $txt=$val->scalarval(); if($txt != "") { print "<h4>Documentation</h4><p>${txt}</p>\n"; } else { print "<p>No documentation available.</p>\n"; } } if($rs[1]->faultCode()) { display_error($rs[1]); } else { print "<h4>Signature</h4><p>\n"; $val = $rs[1]->value(); if($val->kindOf()=="array") { for($j=0; $j<$val->arraysize(); $j++) { $x = $val->arraymem($j); $ret = $x->arraymem(0); print "<code>" . $ret->scalarval() . " " . $mname->scalarval() . "("; if($x->arraysize()>1) { for($k=1; $k<$x->arraysize(); $k++) { $y = $x->arraymem($k); print $y->scalarval(); if($k < $x->arraysize()-1) { print ", "; } } } print ")</code><br/>\n"; } } else { print "Signature unknown\n"; } print "</p>\n"; } } } ?> </body> </html> |
|
2 | 1 | \ No newline at end of file |
2 | +<html> <head><title>xmlrpc</title></head> <body> <h1>Introspect demo</h1> <h2>Query server for available methods and their description</h2> <h3>The code demonstrates usage of multicall and introspection methods</h3> <?php include("xmlrpc.inc"); function display_error($r) { print "An error occurred: "; print "Code: " . $r->faultCode() . " Reason: '" .$r->faultString()."'<br/>"; } // 'new style' client constuctor $c = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php"); print "<h3>methods available at http://" . $c->server . $c->path . "</h3>\n"; $m = new xmlrpcmsg('system.listMethods'); $r =& $c->send($m); if($r->faultCode()) { display_error($r); } else { $v=$r->value(); for($i=0; $i<$v->arraysize(); $i++) { $mname=$v->arraymem($i); print "<h4>" . $mname->scalarval() . "</h4>\n"; // build messages first, add params later $m1 = new xmlrpcmsg('system.methodHelp'); $m2 = new xmlrpcmsg('system.methodSignature'); $val = new xmlrpcval($mname->scalarval(), "string"); $m1->addParam($val); $m2->addParam($val); // send multiple messages in one pass. // If server does not support multicall, client will fall back to 2 separate calls $ms = array($m1, $m2); $rs =& $c->send($ms); if($rs[0]->faultCode()) { display_error($rs[0]); } else { $val=$rs[0]->value(); $txt=$val->scalarval(); if($txt != "") { print "<h4>Documentation</h4><p>${txt}</p>\n"; } else { print "<p>No documentation available.</p>\n"; } } if($rs[1]->faultCode()) { display_error($rs[1]); } else { print "<h4>Signature</h4><p>\n"; $val = $rs[1]->value(); if($val->kindOf()=="array") { for($j=0; $j<$val->arraysize(); $j++) { $x = $val->arraymem($j); $ret = $x->arraymem(0); print "<code>" . $ret->scalarval() . " " . $mname->scalarval() . "("; if($x->arraysize()>1) { for($k=1; $k<$x->arraysize(); $k++) { $y = $x->arraymem($k); print $y->scalarval(); if($k < $x->arraysize()-1) { print ", "; } } } print ")</code><br/>\n"; } } else { print "Signature unknown\n"; } print "</p>\n"; } } } ?> </body> </html> |
|
3 | 3 | \ No newline at end of file |
@@ -1,1 +1,1 @@ |
||
1 | -<html> <head><title>xmlrpc</title></head> <body> <h1>Which toolkit demo</h1> <h2>Query server for toolkit information</h2> <h3>The code demonstrates usage of the php_xmlrpc_decode function</h3> <?php include("xmlrpc.inc"); $f = new xmlrpcmsg('interopEchoTests.whichToolkit', array()); $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); $r = $c->send($f); if(!$r->faultCode()) { $v = php_xmlrpc_decode($r->value()); print "<pre>"; print "name: " . htmlspecialchars($v["toolkitName"]) . "\n"; print "version: " . htmlspecialchars($v["toolkitVersion"]) . "\n"; print "docs: " . htmlspecialchars($v["toolkitDocsUrl"]) . "\n"; print "os: " . htmlspecialchars($v["toolkitOperatingSystem"]) . "\n"; print "</pre>"; } else { print "An error occurred: "; print "Code: " . htmlspecialchars($r->faultCode()) . " Reason: '" . htmlspecialchars($r->faultString()) . "'\n"; } ?> </body> </html> |
|
2 | 1 | \ No newline at end of file |
2 | +<html> <head><title>xmlrpc</title></head> <body> <h1>Which toolkit demo</h1> <h2>Query server for toolkit information</h2> <h3>The code demonstrates usage of the php_xmlrpc_decode function</h3> <?php include("xmlrpc.inc"); $f = new xmlrpcmsg('interopEchoTests.whichToolkit', array()); $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); $r = $c->send($f); if (!$r->faultCode()) { $v = php_xmlrpc_decode($r->value()); print "<pre>"; print "name: ".htmlspecialchars($v["toolkitName"])."\n"; print "version: ".htmlspecialchars($v["toolkitVersion"])."\n"; print "docs: ".htmlspecialchars($v["toolkitDocsUrl"])."\n"; print "os: ".htmlspecialchars($v["toolkitOperatingSystem"])."\n"; print "</pre>"; } else { print "An error occurred: "; print "Code: ".htmlspecialchars($r->faultCode())." Reason: '".htmlspecialchars($r->faultString())."'\n"; } ?> </body> </html> |
|
3 | 3 | \ No newline at end of file |
@@ -1,1 +1,1 @@ |
||
1 | -<html> <head><title>xmlrpc</title></head> <body> <h1>Which toolkit demo</h1> <h2>Query server for toolkit information</h2> <h3>The code demonstrates usage of the php_xmlrpc_decode function</h3> <?php include("xmlrpc.inc"); $f = new xmlrpcmsg('interopEchoTests.whichToolkit', array()); $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); $r = $c->send($f); if(!$r->faultCode()) { $v = php_xmlrpc_decode($r->value()); print "<pre>"; print "name: " . htmlspecialchars($v["toolkitName"]) . "\n"; print "version: " . htmlspecialchars($v["toolkitVersion"]) . "\n"; print "docs: " . htmlspecialchars($v["toolkitDocsUrl"]) . "\n"; print "os: " . htmlspecialchars($v["toolkitOperatingSystem"]) . "\n"; print "</pre>"; } else { print "An error occurred: "; print "Code: " . htmlspecialchars($r->faultCode()) . " Reason: '" . htmlspecialchars($r->faultString()) . "'\n"; } ?> </body> </html> |
|
2 | 1 | \ No newline at end of file |
2 | +<html> <head><title>xmlrpc</title></head> <body> <h1>Which toolkit demo</h1> <h2>Query server for toolkit information</h2> <h3>The code demonstrates usage of the php_xmlrpc_decode function</h3> <?php include("xmlrpc.inc"); $f = new xmlrpcmsg('interopEchoTests.whichToolkit', array()); $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); $r = $c->send($f); if(!$r->faultCode()) { $v = php_xmlrpc_decode($r->value()); print "<pre>"; print "name: " . htmlspecialchars($v["toolkitName"]) . "\n"; print "version: " . htmlspecialchars($v["toolkitVersion"]) . "\n"; print "docs: " . htmlspecialchars($v["toolkitDocsUrl"]) . "\n"; print "os: " . htmlspecialchars($v["toolkitOperatingSystem"]) . "\n"; print "</pre>"; } else { print "An error occurred: "; print "Code: " . htmlspecialchars($r->faultCode()) . " Reason: '" . htmlspecialchars($r->faultString()) . "'\n"; } ?> </body> </html> |
|
3 | 3 | \ No newline at end of file |
@@ -8,29 +8,29 @@ discard block |
||
8 | 8 | |
9 | 9 | function highlight($file) |
10 | 10 | { |
11 | - $starttag = '<pre class="programlisting">'; |
|
12 | - $endtag = '</pre>'; |
|
11 | + $starttag = '<pre class="programlisting">'; |
|
12 | + $endtag = '</pre>'; |
|
13 | 13 | |
14 | - $content = file_get_contents($file); |
|
15 | - $last = 0; |
|
16 | - $out = ''; |
|
17 | - while(($start = strpos($content, $starttag, $last)) !== false) |
|
18 | - { |
|
14 | + $content = file_get_contents($file); |
|
15 | + $last = 0; |
|
16 | + $out = ''; |
|
17 | + while(($start = strpos($content, $starttag, $last)) !== false) |
|
18 | + { |
|
19 | 19 | $end = strpos($content, $endtag, $start); |
20 | - $code = substr($content, $start+strlen($starttag), $end-$start-strlen($starttag)); |
|
21 | - if ($code[strlen($code)-1] == "\n") { |
|
22 | - $code = substr($code, 0, -1); |
|
23 | - } |
|
20 | + $code = substr($content, $start+strlen($starttag), $end-$start-strlen($starttag)); |
|
21 | + if ($code[strlen($code)-1] == "\n") { |
|
22 | + $code = substr($code, 0, -1); |
|
23 | + } |
|
24 | 24 | //var_dump($code); |
25 | - $code = str_replace(array('>', '<'), array('>', '<'), $code); |
|
25 | + $code = str_replace(array('>', '<'), array('>', '<'), $code); |
|
26 | 26 | $code = highlight_string('<?php '.$code, true); |
27 | 27 | $code = str_replace('<span style="color: #0000BB"><?php <br />', '<span style="color: #0000BB">', $code); |
28 | 28 | //echo($code); |
29 | 29 | $out = $out . substr($content, $last, $start+strlen($starttag)-$last) . $code . $endtag; |
30 | 30 | $last = $end+strlen($endtag); |
31 | - } |
|
32 | - $out .= substr($content, $last, strlen($content)); |
|
33 | - return $out; |
|
31 | + } |
|
32 | + $out .= substr($content, $last, strlen($content)); |
|
33 | + return $out; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $dir = $argv[1]; |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | $files = scandir($dir); |
39 | 39 | foreach($files as $file) |
40 | 40 | { |
41 | - if (substr($file, -5, 5) == '.html') |
|
42 | - { |
|
43 | - $out = highlight($dir.'/'.$file); |
|
44 | - file_put_contents($dir.'/'.$file, $out); |
|
45 | - } |
|
41 | + if (substr($file, -5, 5) == '.html') |
|
42 | + { |
|
43 | + $out = highlight($dir.'/'.$file); |
|
44 | + file_put_contents($dir.'/'.$file, $out); |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | ?> |
49 | 49 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $content = file_get_contents($file); |
15 | 15 | $last = 0; |
16 | 16 | $out = ''; |
17 | - while(($start = strpos($content, $starttag, $last)) !== false) |
|
17 | + while (($start = strpos($content, $starttag, $last)) !== false) |
|
18 | 18 | { |
19 | 19 | $end = strpos($content, $endtag, $start); |
20 | 20 | $code = substr($content, $start+strlen($starttag), $end-$start-strlen($starttag)); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $code = highlight_string('<?php '.$code, true); |
27 | 27 | $code = str_replace('<span style="color: #0000BB"><?php <br />', '<span style="color: #0000BB">', $code); |
28 | 28 | //echo($code); |
29 | - $out = $out . substr($content, $last, $start+strlen($starttag)-$last) . $code . $endtag; |
|
29 | + $out = $out.substr($content, $last, $start+strlen($starttag)-$last).$code.$endtag; |
|
30 | 30 | $last = $end+strlen($endtag); |
31 | 31 | } |
32 | 32 | $out .= substr($content, $last, strlen($content)); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $dir = $argv[1]; |
37 | 37 | |
38 | 38 | $files = scandir($dir); |
39 | -foreach($files as $file) |
|
39 | +foreach ($files as $file) |
|
40 | 40 | { |
41 | 41 | if (substr($file, -5, 5) == '.html') |
42 | 42 | { |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @copyright (c) 2007-2014 G. Giunta |
6 | 6 | */ |
7 | 7 | |
8 | -if ($_SERVER['argc'] < 4) |
|
8 | +if ($_SERVER['argc']<4) |
|
9 | 9 | die("Usage: php convert.php docbook.xml \path\\to\stylesheet.xsl output-dir|output_file\n"); |
10 | 10 | else |
11 | 11 | echo "Starting xsl conversion process...\n"; |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | |
27 | 27 | // Configure the transformer |
28 | 28 | $proc = new XSLTProcessor; |
29 | -if (version_compare(PHP_VERSION,'5.4',"<")) |
|
29 | +if (version_compare(PHP_VERSION, '5.4', "<")) |
|
30 | 30 | { |
31 | - if(defined('XSL_SECPREF_WRITE_FILE')) |
|
31 | + if (defined('XSL_SECPREF_WRITE_FILE')) |
|
32 | 32 | ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
33 | 33 | } |
34 | 34 | else |
35 | 35 | { |
36 | - if(is_callable(array($proc, 'setSecurityPreferences'))) |
|
36 | + if (is_callable(array($proc, 'setSecurityPreferences'))) |
|
37 | 37 | { |
38 | 38 | $proc->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
39 | 39 | } |
@@ -5,18 +5,21 @@ discard block |
||
5 | 5 | * @copyright (c) 2007-2014 G. Giunta |
6 | 6 | */ |
7 | 7 | |
8 | -if ($_SERVER['argc'] < 4) |
|
8 | +if ($_SERVER['argc'] < 4) { |
|
9 | 9 | die("Usage: php convert.php docbook.xml \path\\to\stylesheet.xsl output-dir|output_file\n"); |
10 | -else |
|
10 | +} else { |
|
11 | 11 | echo "Starting xsl conversion process...\n"; |
12 | +} |
|
12 | 13 | |
13 | 14 | $doc = $_SERVER['argv'][1]; |
14 | 15 | $xss = $_SERVER['argv'][2]; |
15 | 16 | |
16 | -if (!file_exists($doc)) |
|
17 | +if (!file_exists($doc)) { |
|
17 | 18 | die("KO: file $doc cannot be found\n"); |
18 | -if (!file_exists($xss)) |
|
19 | +} |
|
20 | +if (!file_exists($xss)) { |
|
19 | 21 | die("KO: file $xss cannot be found\n"); |
22 | +} |
|
20 | 23 | |
21 | 24 | // Load the XML source |
22 | 25 | $xml = new DOMDocument; |
@@ -28,16 +31,15 @@ discard block |
||
28 | 31 | $proc = new XSLTProcessor; |
29 | 32 | if (version_compare(PHP_VERSION,'5.4',"<")) |
30 | 33 | { |
31 | - if(defined('XSL_SECPREF_WRITE_FILE')) |
|
32 | - ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
|
33 | -} |
|
34 | -else |
|
34 | + if(defined('XSL_SECPREF_WRITE_FILE')) { |
|
35 | + ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
|
36 | + } |
|
37 | + } else |
|
35 | 38 | { |
36 | 39 | if(is_callable(array($proc, 'setSecurityPreferences'))) |
37 | 40 | { |
38 | 41 | $proc->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
39 | - } |
|
40 | - else |
|
42 | + } else |
|
41 | 43 | { |
42 | 44 | $proc->setSecurityPrefs(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); |
43 | 45 | } |
@@ -48,18 +50,19 @@ discard block |
||
48 | 50 | //{ |
49 | 51 | if (is_dir($_SERVER['argv'][3])) |
50 | 52 | { |
51 | - if (!$proc->setParameter('', 'base.dir', realpath($_SERVER['argv'][3]))) |
|
52 | - echo "setting param base.dir KO\n"; |
|
53 | - } |
|
54 | - else |
|
53 | + if (!$proc->setParameter('', 'base.dir', realpath($_SERVER['argv'][3]))) { |
|
54 | + echo "setting param base.dir KO\n"; |
|
55 | + } |
|
56 | + } else |
|
55 | 57 | { |
56 | 58 | //echo "{$_SERVER['argv'][3]} is not a dir\n"; |
57 | 59 | } |
58 | 60 | //} |
59 | 61 | |
60 | 62 | $out = $proc->transformToXML($xml); |
61 | -if (!is_dir($_SERVER['argv'][3])) |
|
63 | +if (!is_dir($_SERVER['argv'][3])) { |
|
62 | 64 | file_put_contents($_SERVER['argv'][3], $out); |
65 | +} |
|
63 | 66 | |
64 | 67 | echo "OK\n"; |
65 | 68 | ?> |
66 | 69 | \ No newline at end of file |