Completed
Push — php51 ( 490862...f49e4f )
by Gaetano
07:16
created
demo/server/server.php 3 patches
Indentation   +811 added lines, -811 removed lines patch added patch discarded remove patch
@@ -13,240 +13,240 @@  discard block
 block discarded – undo
13 13
 // give user a chance to see the source for this server instead of running the services
14 14
 if ($_SERVER['REQUEST_METHOD'] != 'POST' && isset($_GET['showSource']))
15 15
 {
16
-	highlight_file(__FILE__);
17
-	die();
16
+    highlight_file(__FILE__);
17
+    die();
18 18
 }
19 19
 
20
-	include("xmlrpc.inc");
21
-	include("xmlrpcs.inc");
22
-	include("xmlrpc_wrappers.inc");
23
-
24
-	/**
25
-	* Used to test usage of object methods in dispatch maps and in wrapper code
26
-	*/
27
-	class xmlrpc_server_methods_container
28
-	{
29
-		/**
30
-		* Method used to test logging of php warnings generated by user functions.
31
-		*/
32
-		function phpwarninggenerator($m)
33
-		{
34
-			$a = $b; // this triggers a warning in E_ALL mode, since $b is undefined
35
-			return new xmlrpcresp(new xmlrpcval(1, 'boolean'));
36
-		}
37
-
38
-	    /**
39
-	     * Method used to testcatching of exceptions in the server.
40
-	     */
41
-	    function exceptiongenerator($m)
42
-	    {
43
-	        throw new Exception("it's just a test", 1);
44
-	    }
45
-
46
-		/**
47
-		* a PHP version of the state-number server. Send me an integer and i'll sell you a state
48
-		* @param integer $s
49
-		* @return string
50
-		*/
51
-		static function findstate($s)
52
-		{
53
-			return inner_findstate($s);
54
-		}
55
-	}
56
-
57
-
58
-	// a PHP version
59
-	// of the state-number server
60
-	// send me an integer and i'll sell you a state
61
-
62
-	$stateNames = array(
63
-		"Alabama", "Alaska", "Arizona", "Arkansas", "California",
64
-		"Colorado", "Columbia", "Connecticut", "Delaware", "Florida",
65
-		"Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas",
66
-		"Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan",
67
-		"Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada",
68
-		"New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina",
69
-		"North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island",
70
-		"South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont",
71
-		"Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"
72
-	);
73
-
74
-	$findstate_sig=array(array($xmlrpcString, $xmlrpcInt));
75
-	$findstate_doc='When passed an integer between 1 and 51 returns the
20
+    include("xmlrpc.inc");
21
+    include("xmlrpcs.inc");
22
+    include("xmlrpc_wrappers.inc");
23
+
24
+    /**
25
+     * Used to test usage of object methods in dispatch maps and in wrapper code
26
+     */
27
+    class xmlrpc_server_methods_container
28
+    {
29
+        /**
30
+         * Method used to test logging of php warnings generated by user functions.
31
+         */
32
+        function phpwarninggenerator($m)
33
+        {
34
+            $a = $b; // this triggers a warning in E_ALL mode, since $b is undefined
35
+            return new xmlrpcresp(new xmlrpcval(1, 'boolean'));
36
+        }
37
+
38
+        /**
39
+         * Method used to testcatching of exceptions in the server.
40
+         */
41
+        function exceptiongenerator($m)
42
+        {
43
+            throw new Exception("it's just a test", 1);
44
+        }
45
+
46
+        /**
47
+         * a PHP version of the state-number server. Send me an integer and i'll sell you a state
48
+         * @param integer $s
49
+         * @return string
50
+         */
51
+        static function findstate($s)
52
+        {
53
+            return inner_findstate($s);
54
+        }
55
+    }
56
+
57
+
58
+    // a PHP version
59
+    // of the state-number server
60
+    // send me an integer and i'll sell you a state
61
+
62
+    $stateNames = array(
63
+        "Alabama", "Alaska", "Arizona", "Arkansas", "California",
64
+        "Colorado", "Columbia", "Connecticut", "Delaware", "Florida",
65
+        "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas",
66
+        "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan",
67
+        "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada",
68
+        "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina",
69
+        "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island",
70
+        "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont",
71
+        "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"
72
+    );
73
+
74
+    $findstate_sig=array(array($xmlrpcString, $xmlrpcInt));
75
+    $findstate_doc='When passed an integer between 1 and 51 returns the
76 76
 name of a US state, where the integer is the index of that state name
77 77
 in an alphabetic order.';
78 78
 
79 79
 
80
-	function findstate($m)
81
-	{
82
-		global $xmlrpcerruser, $stateNames;
83
-		$err="";
84
-		// get the first param
85
-		$sno=$m->getParam(0);
86
-
87
-		// param must be there and of the correct type: server object does the
88
-		// validation for us
89
-
90
-		// extract the value of the state number
91
-		$snv=$sno->scalarval();
92
-		// look it up in our array (zero-based)
93
-		if (isset($stateNames[$snv-1]))
94
-		{
95
-			$sname=$stateNames[$snv-1];
96
-		}
97
-		else
98
-		{
99
-			// not, there so complain
100
-			$err="I don't have a state for the index '" . $snv . "'";
101
-		}
102
-
103
-		// if we generated an error, create an error return response
104
-		if ($err)
105
-		{
106
-			return new xmlrpcresp(0, $xmlrpcerruser, $err);
107
-		}
108
-		else
109
-		{
110
-			// otherwise, we create the right response
111
-			// with the state name
112
-			return new xmlrpcresp(new xmlrpcval($sname));
113
-		}
114
-	}
115
-
116
-	/**
117
-	* Inner code of the state-number server.
118
-	* Used to test auto-registration of PHP funcions as xmlrpc methods.
119
-	* @param integer $stateno the state number
120
-	* @return string the name of the state (or error descrption)
121
-	*/
122
-	function inner_findstate($stateno)
123
-	{
124
-		global $stateNames;
125
-		if (isset($stateNames[$stateno-1]))
126
-		{
127
-			return $stateNames[$stateno-1];
128
-		}
129
-		else
130
-		{
131
-			// not, there so complain
132
-			return "I don't have a state for the index '" . $stateno . "'";
133
-		}
134
-	}
135
-	$findstate2_sig = wrap_php_function('inner_findstate');
136
-
137
-	$findstate3_sig = wrap_php_function(array('xmlrpc_server_methods_container', 'findstate'));
138
-
139
-	$findstate5_sig = wrap_php_function('xmlrpc_server_methods_container::findstate');
140
-
141
-	$obj = new xmlrpc_server_methods_container();
142
-	$findstate4_sig = wrap_php_function(array($obj, 'findstate'));
143
-
144
-	$addtwo_sig=array(array($xmlrpcInt, $xmlrpcInt, $xmlrpcInt));
145
-	$addtwo_doc='Add two integers together and return the result';
146
-	function addtwo($m)
147
-	{
148
-		$s=$m->getParam(0);
149
-		$t=$m->getParam(1);
150
-		return new xmlrpcresp(new xmlrpcval($s->scalarval()+$t->scalarval(),"int"));
151
-	}
152
-
153
-	$addtwodouble_sig=array(array($xmlrpcDouble, $xmlrpcDouble, $xmlrpcDouble));
154
-	$addtwodouble_doc='Add two doubles together and return the result';
155
-	function addtwodouble($m)
156
-	{
157
-		$s=$m->getParam(0);
158
-		$t=$m->getParam(1);
159
-		return new xmlrpcresp(new xmlrpcval($s->scalarval()+$t->scalarval(),"double"));
160
-	}
161
-
162
-	$stringecho_sig=array(array($xmlrpcString, $xmlrpcString));
163
-	$stringecho_doc='Accepts a string parameter, returns the string.';
164
-	function stringecho($m)
165
-	{
166
-		// just sends back a string
167
-		$s=$m->getParam(0);
168
-		$v = $s->scalarval();
169
-		return new xmlrpcresp(new xmlrpcval($s->scalarval()));
170
-	}
171
-
172
-	$echoback_sig=array(array($xmlrpcString, $xmlrpcString));
173
-	$echoback_doc='Accepts a string parameter, returns the entire incoming payload';
174
-	function echoback($m)
175
-	{
176
-		// just sends back a string with what i got
177
-		// sent to me, just escaped, that's all
178
-		//
179
-		// $m is an incoming message
180
-		$s="I got the following message:\n" . $m->serialize();
181
-		return new xmlrpcresp(new xmlrpcval($s));
182
-	}
183
-
184
-	$echosixtyfour_sig=array(array($xmlrpcString, $xmlrpcBase64));
185
-	$echosixtyfour_doc='Accepts a base64 parameter and returns it decoded as a string';
186
-	function echosixtyfour($m)
187
-	{
188
-		// accepts an encoded value, but sends it back
189
-		// as a normal string. this is to test base64 encoding
190
-		// is working as expected
191
-		$incoming=$m->getParam(0);
192
-		return new xmlrpcresp(new xmlrpcval($incoming->scalarval(), "string"));
193
-	}
194
-
195
-	$bitflipper_sig=array(array($xmlrpcArray, $xmlrpcArray));
196
-	$bitflipper_doc='Accepts an array of booleans, and returns them inverted';
197
-	function bitflipper($m)
198
-	{
199
-		global $xmlrpcArray;
200
-
201
-		$v=$m->getParam(0);
202
-		$sz=$v->arraysize();
203
-		$rv=new xmlrpcval(array(), $xmlrpcArray);
204
-
205
-		for($j=0; $j<$sz; $j++)
206
-		{
207
-			$b=$v->arraymem($j);
208
-			if ($b->scalarval())
209
-			{
210
-				$rv->addScalar(false, "boolean");
211
-			}
212
-			else
213
-			{
214
-				$rv->addScalar(true, "boolean");
215
-			}
216
-		}
217
-
218
-		return new xmlrpcresp($rv);
219
-	}
220
-
221
-	// Sorting demo
222
-	//
223
-	// send me an array of structs thus:
224
-	//
225
-	// Dave 35
226
-	// Edd  45
227
-	// Fred 23
228
-	// Barney 37
229
-	//
230
-	// and I'll return it to you in sorted order
231
-
232
-	function agesorter_compare($a, $b)
233
-	{
234
-		global $agesorter_arr;
235
-
236
-		// don't even ask me _why_ these come padded with
237
-		// hyphens, I couldn't tell you :p
238
-		$a=str_replace("-", "", $a);
239
-		$b=str_replace("-", "", $b);
240
-
241
-		if ($agesorter_arr[$a]==$agesorter[$b])
242
-		{
243
-			return 0;
244
-		}
245
-		return ($agesorter_arr[$a] > $agesorter_arr[$b]) ? -1 : 1;
246
-	}
247
-
248
-	$agesorter_sig=array(array($xmlrpcArray, $xmlrpcArray));
249
-	$agesorter_doc='Send this method an array of [string, int] structs, eg:
80
+    function findstate($m)
81
+    {
82
+        global $xmlrpcerruser, $stateNames;
83
+        $err="";
84
+        // get the first param
85
+        $sno=$m->getParam(0);
86
+
87
+        // param must be there and of the correct type: server object does the
88
+        // validation for us
89
+
90
+        // extract the value of the state number
91
+        $snv=$sno->scalarval();
92
+        // look it up in our array (zero-based)
93
+        if (isset($stateNames[$snv-1]))
94
+        {
95
+            $sname=$stateNames[$snv-1];
96
+        }
97
+        else
98
+        {
99
+            // not, there so complain
100
+            $err="I don't have a state for the index '" . $snv . "'";
101
+        }
102
+
103
+        // if we generated an error, create an error return response
104
+        if ($err)
105
+        {
106
+            return new xmlrpcresp(0, $xmlrpcerruser, $err);
107
+        }
108
+        else
109
+        {
110
+            // otherwise, we create the right response
111
+            // with the state name
112
+            return new xmlrpcresp(new xmlrpcval($sname));
113
+        }
114
+    }
115
+
116
+    /**
117
+     * Inner code of the state-number server.
118
+     * Used to test auto-registration of PHP funcions as xmlrpc methods.
119
+     * @param integer $stateno the state number
120
+     * @return string the name of the state (or error descrption)
121
+     */
122
+    function inner_findstate($stateno)
123
+    {
124
+        global $stateNames;
125
+        if (isset($stateNames[$stateno-1]))
126
+        {
127
+            return $stateNames[$stateno-1];
128
+        }
129
+        else
130
+        {
131
+            // not, there so complain
132
+            return "I don't have a state for the index '" . $stateno . "'";
133
+        }
134
+    }
135
+    $findstate2_sig = wrap_php_function('inner_findstate');
136
+
137
+    $findstate3_sig = wrap_php_function(array('xmlrpc_server_methods_container', 'findstate'));
138
+
139
+    $findstate5_sig = wrap_php_function('xmlrpc_server_methods_container::findstate');
140
+
141
+    $obj = new xmlrpc_server_methods_container();
142
+    $findstate4_sig = wrap_php_function(array($obj, 'findstate'));
143
+
144
+    $addtwo_sig=array(array($xmlrpcInt, $xmlrpcInt, $xmlrpcInt));
145
+    $addtwo_doc='Add two integers together and return the result';
146
+    function addtwo($m)
147
+    {
148
+        $s=$m->getParam(0);
149
+        $t=$m->getParam(1);
150
+        return new xmlrpcresp(new xmlrpcval($s->scalarval()+$t->scalarval(),"int"));
151
+    }
152
+
153
+    $addtwodouble_sig=array(array($xmlrpcDouble, $xmlrpcDouble, $xmlrpcDouble));
154
+    $addtwodouble_doc='Add two doubles together and return the result';
155
+    function addtwodouble($m)
156
+    {
157
+        $s=$m->getParam(0);
158
+        $t=$m->getParam(1);
159
+        return new xmlrpcresp(new xmlrpcval($s->scalarval()+$t->scalarval(),"double"));
160
+    }
161
+
162
+    $stringecho_sig=array(array($xmlrpcString, $xmlrpcString));
163
+    $stringecho_doc='Accepts a string parameter, returns the string.';
164
+    function stringecho($m)
165
+    {
166
+        // just sends back a string
167
+        $s=$m->getParam(0);
168
+        $v = $s->scalarval();
169
+        return new xmlrpcresp(new xmlrpcval($s->scalarval()));
170
+    }
171
+
172
+    $echoback_sig=array(array($xmlrpcString, $xmlrpcString));
173
+    $echoback_doc='Accepts a string parameter, returns the entire incoming payload';
174
+    function echoback($m)
175
+    {
176
+        // just sends back a string with what i got
177
+        // sent to me, just escaped, that's all
178
+        //
179
+        // $m is an incoming message
180
+        $s="I got the following message:\n" . $m->serialize();
181
+        return new xmlrpcresp(new xmlrpcval($s));
182
+    }
183
+
184
+    $echosixtyfour_sig=array(array($xmlrpcString, $xmlrpcBase64));
185
+    $echosixtyfour_doc='Accepts a base64 parameter and returns it decoded as a string';
186
+    function echosixtyfour($m)
187
+    {
188
+        // accepts an encoded value, but sends it back
189
+        // as a normal string. this is to test base64 encoding
190
+        // is working as expected
191
+        $incoming=$m->getParam(0);
192
+        return new xmlrpcresp(new xmlrpcval($incoming->scalarval(), "string"));
193
+    }
194
+
195
+    $bitflipper_sig=array(array($xmlrpcArray, $xmlrpcArray));
196
+    $bitflipper_doc='Accepts an array of booleans, and returns them inverted';
197
+    function bitflipper($m)
198
+    {
199
+        global $xmlrpcArray;
200
+
201
+        $v=$m->getParam(0);
202
+        $sz=$v->arraysize();
203
+        $rv=new xmlrpcval(array(), $xmlrpcArray);
204
+
205
+        for($j=0; $j<$sz; $j++)
206
+        {
207
+            $b=$v->arraymem($j);
208
+            if ($b->scalarval())
209
+            {
210
+                $rv->addScalar(false, "boolean");
211
+            }
212
+            else
213
+            {
214
+                $rv->addScalar(true, "boolean");
215
+            }
216
+        }
217
+
218
+        return new xmlrpcresp($rv);
219
+    }
220
+
221
+    // Sorting demo
222
+    //
223
+    // send me an array of structs thus:
224
+    //
225
+    // Dave 35
226
+    // Edd  45
227
+    // Fred 23
228
+    // Barney 37
229
+    //
230
+    // and I'll return it to you in sorted order
231
+
232
+    function agesorter_compare($a, $b)
233
+    {
234
+        global $agesorter_arr;
235
+
236
+        // don't even ask me _why_ these come padded with
237
+        // hyphens, I couldn't tell you :p
238
+        $a=str_replace("-", "", $a);
239
+        $b=str_replace("-", "", $b);
240
+
241
+        if ($agesorter_arr[$a]==$agesorter[$b])
242
+        {
243
+            return 0;
244
+        }
245
+        return ($agesorter_arr[$a] > $agesorter_arr[$b]) ? -1 : 1;
246
+    }
247
+
248
+    $agesorter_sig=array(array($xmlrpcArray, $xmlrpcArray));
249
+    $agesorter_doc='Send this method an array of [string, int] structs, eg:
250 250
 <pre>
251 251
  Dave   35
252 252
  Edd	45
@@ -255,80 +255,80 @@  discard block
 block discarded – undo
255 255
 </pre>
256 256
 And the array will be returned with the entries sorted by their numbers.
257 257
 ';
258
-	function agesorter($m)
259
-	{
260
-		global $agesorter_arr, $xmlrpcerruser, $s;
261
-
262
-		xmlrpc_debugmsg("Entering 'agesorter'");
263
-		// get the parameter
264
-		$sno=$m->getParam(0);
265
-		// error string for [if|when] things go wrong
266
-		$err="";
267
-		// create the output value
268
-		$v=new xmlrpcval();
269
-		$agar=array();
270
-
271
-		if (isset($sno) && $sno->kindOf()=="array")
272
-		{
273
-			$max=$sno->arraysize();
274
-			// TODO: create debug method to print can work once more
275
-			// print "<!-- found $max array elements -->\n";
276
-			for($i=0; $i<$max; $i++)
277
-			{
278
-				$rec=$sno->arraymem($i);
279
-				if ($rec->kindOf()!="struct")
280
-				{
281
-					$err="Found non-struct in array at element $i";
282
-					break;
283
-				}
284
-				// extract name and age from struct
285
-				$n=$rec->structmem("name");
286
-				$a=$rec->structmem("age");
287
-				// $n and $a are xmlrpcvals,
288
-				// so get the scalarval from them
289
-				$agar[$n->scalarval()]=$a->scalarval();
290
-			}
291
-
292
-			$agesorter_arr=$agar;
293
-			// hack, must make global as uksort() won't
294
-			// allow us to pass any other auxilliary information
295
-			uksort($agesorter_arr, agesorter_compare);
296
-			$outAr=array();
297
-			while (list( $key, $val ) = each( $agesorter_arr ) )
298
-			{
299
-				// recreate each struct element
300
-				$outAr[]=new xmlrpcval(array("name" =>
301
-				new xmlrpcval($key),
302
-				"age" =>
303
-				new xmlrpcval($val, "int")), "struct");
304
-			}
305
-			// add this array to the output value
306
-			$v->addArray($outAr);
307
-		}
308
-		else
309
-		{
310
-			$err="Must be one parameter, an array of structs";
311
-		}
312
-
313
-		if ($err)
314
-		{
315
-			return new xmlrpcresp(0, $xmlrpcerruser, $err);
316
-		}
317
-		else
318
-		{
319
-			return new xmlrpcresp($v);
320
-		}
321
-	}
322
-
323
-	// signature and instructions, place these in the dispatch
324
-	// map
325
-	$mail_send_sig=array(array(
326
-		$xmlrpcBoolean, $xmlrpcString, $xmlrpcString,
327
-		$xmlrpcString, $xmlrpcString, $xmlrpcString,
328
-		$xmlrpcString, $xmlrpcString
329
-	));
330
-
331
-	$mail_send_doc='mail.send(recipient, subject, text, sender, cc, bcc, mimetype)<br/>
258
+    function agesorter($m)
259
+    {
260
+        global $agesorter_arr, $xmlrpcerruser, $s;
261
+
262
+        xmlrpc_debugmsg("Entering 'agesorter'");
263
+        // get the parameter
264
+        $sno=$m->getParam(0);
265
+        // error string for [if|when] things go wrong
266
+        $err="";
267
+        // create the output value
268
+        $v=new xmlrpcval();
269
+        $agar=array();
270
+
271
+        if (isset($sno) && $sno->kindOf()=="array")
272
+        {
273
+            $max=$sno->arraysize();
274
+            // TODO: create debug method to print can work once more
275
+            // print "<!-- found $max array elements -->\n";
276
+            for($i=0; $i<$max; $i++)
277
+            {
278
+                $rec=$sno->arraymem($i);
279
+                if ($rec->kindOf()!="struct")
280
+                {
281
+                    $err="Found non-struct in array at element $i";
282
+                    break;
283
+                }
284
+                // extract name and age from struct
285
+                $n=$rec->structmem("name");
286
+                $a=$rec->structmem("age");
287
+                // $n and $a are xmlrpcvals,
288
+                // so get the scalarval from them
289
+                $agar[$n->scalarval()]=$a->scalarval();
290
+            }
291
+
292
+            $agesorter_arr=$agar;
293
+            // hack, must make global as uksort() won't
294
+            // allow us to pass any other auxilliary information
295
+            uksort($agesorter_arr, agesorter_compare);
296
+            $outAr=array();
297
+            while (list( $key, $val ) = each( $agesorter_arr ) )
298
+            {
299
+                // recreate each struct element
300
+                $outAr[]=new xmlrpcval(array("name" =>
301
+                new xmlrpcval($key),
302
+                "age" =>
303
+                new xmlrpcval($val, "int")), "struct");
304
+            }
305
+            // add this array to the output value
306
+            $v->addArray($outAr);
307
+        }
308
+        else
309
+        {
310
+            $err="Must be one parameter, an array of structs";
311
+        }
312
+
313
+        if ($err)
314
+        {
315
+            return new xmlrpcresp(0, $xmlrpcerruser, $err);
316
+        }
317
+        else
318
+        {
319
+            return new xmlrpcresp($v);
320
+        }
321
+    }
322
+
323
+    // signature and instructions, place these in the dispatch
324
+    // map
325
+    $mail_send_sig=array(array(
326
+        $xmlrpcBoolean, $xmlrpcString, $xmlrpcString,
327
+        $xmlrpcString, $xmlrpcString, $xmlrpcString,
328
+        $xmlrpcString, $xmlrpcString
329
+    ));
330
+
331
+    $mail_send_doc='mail.send(recipient, subject, text, sender, cc, bcc, mimetype)<br/>
332 332
 recipient, cc, and bcc are strings, comma-separated lists of email addresses, as described above.<br/>
333 333
 subject is a string, the subject of the message.<br/>
334 334
 sender is a string, it\'s the email address of the person sending the message. This string can not be
@@ -336,517 +336,517 @@  discard block
 block discarded – undo
336 336
 text is a string, it contains the body of the message.<br/>
337 337
 mimetype, a string, is a standard MIME type, for example, text/plain.
338 338
 ';
339
-	// WARNING; this functionality depends on the sendmail -t option
340
-	// it may not work with Windows machines properly; particularly
341
-	// the Bcc option. Sneak on your friends at your own risk!
342
-	function mail_send($m)
343
-	{
344
-		global $xmlrpcerruser, $xmlrpcBoolean;
345
-		$err="";
346
-
347
-		$mTo=$m->getParam(0);
348
-		$mSub=$m->getParam(1);
349
-		$mBody=$m->getParam(2);
350
-		$mFrom=$m->getParam(3);
351
-		$mCc=$m->getParam(4);
352
-		$mBcc=$m->getParam(5);
353
-		$mMime=$m->getParam(6);
354
-
355
-		if ($mTo->scalarval()=="")
356
-		{
357
-			$err="Error, no 'To' field specified";
358
-		}
359
-
360
-		if ($mFrom->scalarval()=="")
361
-		{
362
-			$err="Error, no 'From' field specified";
363
-		}
364
-
365
-		$msghdr="From: " . $mFrom->scalarval() . "\n";
366
-		$msghdr.="To: ". $mTo->scalarval() . "\n";
367
-
368
-		if ($mCc->scalarval()!="")
369
-		{
370
-			$msghdr.="Cc: " . $mCc->scalarval(). "\n";
371
-		}
372
-		if ($mBcc->scalarval()!="")
373
-		{
374
-			$msghdr.="Bcc: " . $mBcc->scalarval(). "\n";
375
-		}
376
-		if ($mMime->scalarval()!="")
377
-		{
378
-			$msghdr.="Content-type: " . $mMime->scalarval() . "\n";
379
-		}
380
-		$msghdr.="X-Mailer: XML-RPC for PHP mailer 1.0";
381
-
382
-		if ($err=="")
383
-		{
384
-			if (!mail("",
385
-				$mSub->scalarval(),
386
-				$mBody->scalarval(),
387
-				$msghdr))
388
-			{
389
-				$err="Error, could not send the mail.";
390
-			}
391
-		}
392
-
393
-		if ($err)
394
-		{
395
-			return new xmlrpcresp(0, $xmlrpcerruser, $err);
396
-		}
397
-		else
398
-		{
399
-			return new xmlrpcresp(new xmlrpcval("true", $xmlrpcBoolean));
400
-		}
401
-	}
402
-
403
-	$getallheaders_sig=array(array($xmlrpcStruct));
404
-	$getallheaders_doc='Returns a struct containing all the HTTP headers received with the request. Provides limited functionality with IIS';
405
-	function getallheaders_xmlrpc($m)
406
-	{
407
-		global $xmlrpcerruser;
408
-		if (function_exists('getallheaders'))
409
-		{
410
-			return new xmlrpcresp(php_xmlrpc_encode(getallheaders()));
411
-		}
412
-		else
413
-		{
414
-			$headers = array();
415
-			// IIS: poor man's version of getallheaders
416
-			foreach ($_SERVER as $key => $val)
417
-				if (strpos($key, 'HTTP_') === 0)
418
-				{
419
-					$key = ucfirst(str_replace('_', '-', strtolower(substr($key, 5))));
420
-					$headers[$key] = $val;
421
-				}
422
-			return new xmlrpcresp(php_xmlrpc_encode($headers));
423
-		}
424
-	}
425
-
426
-	$setcookies_sig=array(array($xmlrpcInt, $xmlrpcStruct));
427
-	$setcookies_doc='Sends to client a response containing a single \'1\' digit, and sets to it http cookies as received in the request (array of structs describing a cookie)';
428
-	function setcookies($m)
429
-	{
430
-		$m = $m->getParam(0);
431
-		while(list($name,$value) = $m->structeach())
432
-		{
433
-			$cookiedesc = php_xmlrpc_decode($value);
434
-			setcookie($name, @$cookiedesc['value'], @$cookiedesc['expires'], @$cookiedesc['path'], @$cookiedesc['domain'], @$cookiedesc['secure']);
435
-		}
436
-		return new xmlrpcresp(new xmlrpcval(1, 'int'));
437
-	}
438
-
439
-	$getcookies_sig=array(array($xmlrpcStruct));
440
-	$getcookies_doc='Sends to client a response containing all http cookies as received in the request (as struct)';
441
-	function getcookies($m)
442
-	{
443
-		return new xmlrpcresp(php_xmlrpc_encode($_COOKIE));
444
-	}
445
-
446
-	$v1_arrayOfStructs_sig=array(array($xmlrpcInt, $xmlrpcArray));
447
-	$v1_arrayOfStructs_doc='This handler takes a single parameter, an array of structs, each of which contains at least three elements named moe, larry and curly, all <i4>s. Your handler must add all the struct elements named curly and return the result.';
448
-	function v1_arrayOfStructs($m)
449
-	{
450
-		$sno=$m->getParam(0);
451
-		$numcurly=0;
452
-		for($i=0; $i<$sno->arraysize(); $i++)
453
-		{
454
-			$str=$sno->arraymem($i);
455
-			$str->structreset();
456
-			while(list($key,$val)=$str->structeach())
457
-			{
458
-				if ($key=="curly")
459
-				{
460
-					$numcurly+=$val->scalarval();
461
-				}
462
-			}
463
-		}
464
-		return new xmlrpcresp(new xmlrpcval($numcurly, "int"));
465
-	}
466
-
467
-	$v1_easyStruct_sig=array(array($xmlrpcInt, $xmlrpcStruct));
468
-	$v1_easyStruct_doc='This handler takes a single parameter, a struct, containing at least three elements named moe, larry and curly, all &lt;i4&gt;s. Your handler must add the three numbers and return the result.';
469
-	function v1_easyStruct($m)
470
-	{
471
-		$sno=$m->getParam(0);
472
-		$moe=$sno->structmem("moe");
473
-		$larry=$sno->structmem("larry");
474
-		$curly=$sno->structmem("curly");
475
-		$num=$moe->scalarval() + $larry->scalarval() + $curly->scalarval();
476
-		return new xmlrpcresp(new xmlrpcval($num, "int"));
477
-	}
478
-
479
-	$v1_echoStruct_sig=array(array($xmlrpcStruct, $xmlrpcStruct));
480
-	$v1_echoStruct_doc='This handler takes a single parameter, a struct. Your handler must return the struct.';
481
-	function v1_echoStruct($m)
482
-	{
483
-		$sno=$m->getParam(0);
484
-		return new xmlrpcresp($sno);
485
-	}
486
-
487
-	$v1_manyTypes_sig=array(array(
488
-		$xmlrpcArray, $xmlrpcInt, $xmlrpcBoolean,
489
-		$xmlrpcString, $xmlrpcDouble, $xmlrpcDateTime,
490
-		$xmlrpcBase64
491
-	));
492
-	$v1_manyTypes_doc='This handler takes six parameters, and returns an array containing all the parameters.';
493
-	function v1_manyTypes($m)
494
-	{
495
-		return new xmlrpcresp(new xmlrpcval(array(
496
-			$m->getParam(0),
497
-			$m->getParam(1),
498
-			$m->getParam(2),
499
-			$m->getParam(3),
500
-			$m->getParam(4),
501
-			$m->getParam(5)),
502
-			"array"
503
-		));
504
-	}
505
-
506
-	$v1_moderateSizeArrayCheck_sig=array(array($xmlrpcString, $xmlrpcArray));
507
-	$v1_moderateSizeArrayCheck_doc='This handler takes a single parameter, which is an array containing between 100 and 200 elements. Each of the items is a string, your handler must return a string containing the concatenated text of the first and last elements.';
508
-	function v1_moderateSizeArrayCheck($m)
509
-	{
510
-		$ar=$m->getParam(0);
511
-		$sz=$ar->arraysize();
512
-		$first=$ar->arraymem(0);
513
-		$last=$ar->arraymem($sz-1);
514
-		return new xmlrpcresp(new xmlrpcval($first->scalarval() .
515
-		$last->scalarval(), "string"));
516
-	}
517
-
518
-	$v1_simpleStructReturn_sig=array(array($xmlrpcStruct, $xmlrpcInt));
519
-	$v1_simpleStructReturn_doc='This handler takes one parameter, and returns a struct containing three elements, times10, times100 and times1000, the result of multiplying the number by 10, 100 and 1000.';
520
-	function v1_simpleStructReturn($m)
521
-	{
522
-		$sno=$m->getParam(0);
523
-		$v=$sno->scalarval();
524
-		return new xmlrpcresp(new xmlrpcval(array(
525
-			"times10"   => new xmlrpcval($v*10, "int"),
526
-			"times100"  => new xmlrpcval($v*100, "int"),
527
-			"times1000" => new xmlrpcval($v*1000, "int")),
528
-			"struct"
529
-		));
530
-	}
531
-
532
-	$v1_nestedStruct_sig=array(array($xmlrpcInt, $xmlrpcStruct));
533
-	$v1_nestedStruct_doc='This handler takes a single parameter, a struct, that models a daily calendar. At the top level, there is one struct for each year. Each year is broken down into months, and months into days. Most of the days are empty in the struct you receive, but the entry for April 1, 2000 contains a least three elements named moe, larry and curly, all &lt;i4&gt;s. Your handler must add the three numbers and return the result.';
534
-	function v1_nestedStruct($m)
535
-	{
536
-		$sno=$m->getParam(0);
537
-
538
-		$twoK=$sno->structmem("2000");
539
-		$april=$twoK->structmem("04");
540
-		$fools=$april->structmem("01");
541
-		$curly=$fools->structmem("curly");
542
-		$larry=$fools->structmem("larry");
543
-		$moe=$fools->structmem("moe");
544
-		return new xmlrpcresp(new xmlrpcval($curly->scalarval() + $larry->scalarval() + $moe->scalarval(), "int"));
545
-	}
546
-
547
-	$v1_countTheEntities_sig=array(array($xmlrpcStruct, $xmlrpcString));
548
-	$v1_countTheEntities_doc='This handler takes a single parameter, a string, that contains any number of predefined entities, namely &lt;, &gt;, &amp; \' and ".<BR>Your handler must return a struct that contains five fields, all numbers: ctLeftAngleBrackets, ctRightAngleBrackets, ctAmpersands, ctApostrophes, ctQuotes.';
549
-	function v1_countTheEntities($m)
550
-	{
551
-		$sno=$m->getParam(0);
552
-		$str=$sno->scalarval();
553
-		$gt=0; $lt=0; $ap=0; $qu=0; $amp=0;
554
-		for($i=0; $i<strlen($str); $i++)
555
-		{
556
-			$c=substr($str, $i, 1);
557
-			switch($c)
558
-			{
559
-				case ">":
560
-					$gt++;
561
-					break;
562
-				case "<":
563
-					$lt++;
564
-					break;
565
-				case "\"":
566
-					$qu++;
567
-					break;
568
-				case "'":
569
-					$ap++;
570
-					break;
571
-				case "&":
572
-					$amp++;
573
-					break;
574
-				default:
575
-					break;
576
-			}
577
-		}
578
-		return new xmlrpcresp(new xmlrpcval(array(
579
-			"ctLeftAngleBrackets"  => new xmlrpcval($lt, "int"),
580
-			"ctRightAngleBrackets" => new xmlrpcval($gt, "int"),
581
-			"ctAmpersands"		 => new xmlrpcval($amp, "int"),
582
-			"ctApostrophes"		=> new xmlrpcval($ap, "int"),
583
-			"ctQuotes"			 => new xmlrpcval($qu, "int")),
584
-			"struct"
585
-		));
586
-	}
587
-
588
-	// trivial interop tests
589
-	// http://www.xmlrpc.com/stories/storyReader$1636
590
-
591
-	$i_echoString_sig=array(array($xmlrpcString, $xmlrpcString));
592
-	$i_echoString_doc="Echoes string.";
593
-
594
-	$i_echoStringArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
595
-	$i_echoStringArray_doc="Echoes string array.";
596
-
597
-	$i_echoInteger_sig=array(array($xmlrpcInt, $xmlrpcInt));
598
-	$i_echoInteger_doc="Echoes integer.";
599
-
600
-	$i_echoIntegerArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
601
-	$i_echoIntegerArray_doc="Echoes integer array.";
602
-
603
-	$i_echoFloat_sig=array(array($xmlrpcDouble, $xmlrpcDouble));
604
-	$i_echoFloat_doc="Echoes float.";
605
-
606
-	$i_echoFloatArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
607
-	$i_echoFloatArray_doc="Echoes float array.";
608
-
609
-	$i_echoStruct_sig=array(array($xmlrpcStruct, $xmlrpcStruct));
610
-	$i_echoStruct_doc="Echoes struct.";
611
-
612
-	$i_echoStructArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
613
-	$i_echoStructArray_doc="Echoes struct array.";
614
-
615
-	$i_echoValue_doc="Echoes any value back.";
616
-	$i_echoValue_sig=array(array($xmlrpcValue, $xmlrpcValue));
617
-
618
-	$i_echoBase64_sig=array(array($xmlrpcBase64, $xmlrpcBase64));
619
-	$i_echoBase64_doc="Echoes base64.";
620
-
621
-	$i_echoDate_sig=array(array($xmlrpcDateTime, $xmlrpcDateTime));
622
-	$i_echoDate_doc="Echoes dateTime.";
623
-
624
-	function i_echoParam($m)
625
-	{
626
-		$s=$m->getParam(0);
627
-		return new xmlrpcresp($s);
628
-	}
629
-
630
-	function i_echoString($m) { return i_echoParam($m); }
631
-	function i_echoInteger($m) { return i_echoParam($m); }
632
-	function i_echoFloat($m) { return i_echoParam($m); }
633
-	function i_echoStruct($m) { return i_echoParam($m); }
634
-	function i_echoStringArray($m) { return i_echoParam($m); }
635
-	function i_echoIntegerArray($m) { return i_echoParam($m); }
636
-	function i_echoFloatArray($m) { return i_echoParam($m); }
637
-	function i_echoStructArray($m) { return i_echoParam($m); }
638
-	function i_echoValue($m) { return i_echoParam($m); }
639
-	function i_echoBase64($m) { return i_echoParam($m); }
640
-	function i_echoDate($m) { return i_echoParam($m); }
641
-
642
-	$i_whichToolkit_sig=array(array($xmlrpcStruct));
643
-	$i_whichToolkit_doc="Returns a struct containing the following strings: toolkitDocsUrl, toolkitName, toolkitVersion, toolkitOperatingSystem.";
644
-
645
-	function i_whichToolkit($m)
646
-	{
647
-		global $xmlrpcName, $xmlrpcVersion,$SERVER_SOFTWARE;
648
-		$ret=array(
649
-			"toolkitDocsUrl" => "http://phpxmlrpc.sourceforge.net/",
650
-			"toolkitName" => $xmlrpcName,
651
-			"toolkitVersion" => $xmlrpcVersion,
652
-			"toolkitOperatingSystem" => isset ($SERVER_SOFTWARE) ? $SERVER_SOFTWARE : $_SERVER['SERVER_SOFTWARE']
653
-		);
654
-		return new xmlrpcresp ( php_xmlrpc_encode($ret));
655
-	}
656
-
657
-	$o=new xmlrpc_server_methods_container;
658
-	$a=array(
659
-		"examples.getStateName" => array(
660
-			"function" => "findstate",
661
-			"signature" => $findstate_sig,
662
-			"docstring" => $findstate_doc
663
-		),
664
-		"examples.sortByAge" => array(
665
-			"function" => "agesorter",
666
-			"signature" => $agesorter_sig,
667
-			"docstring" => $agesorter_doc
668
-		),
669
-		"examples.addtwo" => array(
670
-			"function" => "addtwo",
671
-			"signature" => $addtwo_sig,
672
-			"docstring" => $addtwo_doc
673
-		),
674
-		"examples.addtwodouble" => array(
675
-			"function" => "addtwodouble",
676
-			"signature" => $addtwodouble_sig,
677
-			"docstring" => $addtwodouble_doc
678
-		),
679
-		"examples.stringecho" => array(
680
-			"function" => "stringecho",
681
-			"signature" => $stringecho_sig,
682
-			"docstring" => $stringecho_doc
683
-		),
684
-		"examples.echo" => array(
685
-			"function" => "echoback",
686
-			"signature" => $echoback_sig,
687
-			"docstring" => $echoback_doc
688
-		),
689
-		"examples.decode64" => array(
690
-			"function" => "echosixtyfour",
691
-			"signature" => $echosixtyfour_sig,
692
-			"docstring" => $echosixtyfour_doc
693
-		),
694
-		"examples.invertBooleans" => array(
695
-			"function" => "bitflipper",
696
-			"signature" => $bitflipper_sig,
697
-			"docstring" => $bitflipper_doc
698
-		),
699
-		"examples.generatePHPWarning" => array(
700
-			"function" => array($o, "phpwarninggenerator")
701
-			//'function' => 'xmlrpc_server_methods_container::phpwarninggenerator'
702
-		),
703
-		"examples.raiseException" => array(
704
-			"function" => array($o, "exceptiongenerator")
705
-		),
706
-		"examples.getallheaders" => array(
707
-			"function" => 'getallheaders_xmlrpc',
708
-			"signature" => $getallheaders_sig,
709
-			"docstring" => $getallheaders_doc
710
-		),
711
-		"examples.setcookies" => array(
712
-			"function" => 'setcookies',
713
-			"signature" => $setcookies_sig,
714
-			"docstring" => $setcookies_doc
715
-		),
716
-		"examples.getcookies" => array(
717
-			"function" => 'getcookies',
718
-			"signature" => $getcookies_sig,
719
-			"docstring" => $getcookies_doc
720
-		),
721
-		"mail.send" => array(
722
-			"function" => "mail_send",
723
-			"signature" => $mail_send_sig,
724
-			"docstring" => $mail_send_doc
725
-		),
726
-		"validator1.arrayOfStructsTest" => array(
727
-			"function" => "v1_arrayOfStructs",
728
-			"signature" => $v1_arrayOfStructs_sig,
729
-			"docstring" => $v1_arrayOfStructs_doc
730
-		),
731
-		"validator1.easyStructTest" => array(
732
-			"function" => "v1_easyStruct",
733
-			"signature" => $v1_easyStruct_sig,
734
-			"docstring" => $v1_easyStruct_doc
735
-		),
736
-		"validator1.echoStructTest" => array(
737
-			"function" => "v1_echoStruct",
738
-			"signature" => $v1_echoStruct_sig,
739
-			"docstring" => $v1_echoStruct_doc
740
-		),
741
-		"validator1.manyTypesTest" => array(
742
-			"function" => "v1_manyTypes",
743
-			"signature" => $v1_manyTypes_sig,
744
-			"docstring" => $v1_manyTypes_doc
745
-		),
746
-		"validator1.moderateSizeArrayCheck" => array(
747
-			"function" => "v1_moderateSizeArrayCheck",
748
-			"signature" => $v1_moderateSizeArrayCheck_sig,
749
-			"docstring" => $v1_moderateSizeArrayCheck_doc
750
-		),
751
-		"validator1.simpleStructReturnTest" => array(
752
-			"function" => "v1_simpleStructReturn",
753
-			"signature" => $v1_simpleStructReturn_sig,
754
-			"docstring" => $v1_simpleStructReturn_doc
755
-		),
756
-		"validator1.nestedStructTest" => array(
757
-			"function" => "v1_nestedStruct",
758
-			"signature" => $v1_nestedStruct_sig,
759
-			"docstring" => $v1_nestedStruct_doc
760
-		),
761
-		"validator1.countTheEntities" => array(
762
-			"function" => "v1_countTheEntities",
763
-			"signature" => $v1_countTheEntities_sig,
764
-			"docstring" => $v1_countTheEntities_doc
765
-		),
766
-		"interopEchoTests.echoString" => array(
767
-			"function" => "i_echoString",
768
-			"signature" => $i_echoString_sig,
769
-			"docstring" => $i_echoString_doc
770
-		),
771
-		"interopEchoTests.echoStringArray" => array(
772
-			"function" => "i_echoStringArray",
773
-			"signature" => $i_echoStringArray_sig,
774
-			"docstring" => $i_echoStringArray_doc
775
-		),
776
-		"interopEchoTests.echoInteger" => array(
777
-			"function" => "i_echoInteger",
778
-			"signature" => $i_echoInteger_sig,
779
-			"docstring" => $i_echoInteger_doc
780
-		),
781
-		"interopEchoTests.echoIntegerArray" => array(
782
-			"function" => "i_echoIntegerArray",
783
-			"signature" => $i_echoIntegerArray_sig,
784
-			"docstring" => $i_echoIntegerArray_doc
785
-		),
786
-		"interopEchoTests.echoFloat" => array(
787
-			"function" => "i_echoFloat",
788
-			"signature" => $i_echoFloat_sig,
789
-			"docstring" => $i_echoFloat_doc
790
-		),
791
-		"interopEchoTests.echoFloatArray" => array(
792
-			"function" => "i_echoFloatArray",
793
-			"signature" => $i_echoFloatArray_sig,
794
-			"docstring" => $i_echoFloatArray_doc
795
-		),
796
-		"interopEchoTests.echoStruct" => array(
797
-			"function" => "i_echoStruct",
798
-			"signature" => $i_echoStruct_sig,
799
-			"docstring" => $i_echoStruct_doc
800
-		),
801
-		"interopEchoTests.echoStructArray" => array(
802
-			"function" => "i_echoStructArray",
803
-			"signature" => $i_echoStructArray_sig,
804
-			"docstring" => $i_echoStructArray_doc
805
-		),
806
-		"interopEchoTests.echoValue" => array(
807
-			"function" => "i_echoValue",
808
-			"signature" => $i_echoValue_sig,
809
-			"docstring" => $i_echoValue_doc
810
-		),
811
-		"interopEchoTests.echoBase64" => array(
812
-			"function" => "i_echoBase64",
813
-			"signature" => $i_echoBase64_sig,
814
-			"docstring" => $i_echoBase64_doc
815
-		),
816
-		"interopEchoTests.echoDate" => array(
817
-			"function" => "i_echoDate",
818
-			"signature" => $i_echoDate_sig,
819
-			"docstring" => $i_echoDate_doc
820
-		),
821
-		"interopEchoTests.whichToolkit" => array(
822
-			"function" => "i_whichToolkit",
823
-			"signature" => $i_whichToolkit_sig,
824
-			"docstring" => $i_whichToolkit_doc
825
-		)
826
-	);
827
-
828
-	if ($findstate2_sig)
829
-		$a['examples.php.getStateName'] = $findstate2_sig;
830
-
831
-	if ($findstate3_sig)
832
-		$a['examples.php2.getStateName'] = $findstate3_sig;
833
-
834
-	if ($findstate4_sig)
835
-		$a['examples.php3.getStateName'] = $findstate4_sig;
339
+    // WARNING; this functionality depends on the sendmail -t option
340
+    // it may not work with Windows machines properly; particularly
341
+    // the Bcc option. Sneak on your friends at your own risk!
342
+    function mail_send($m)
343
+    {
344
+        global $xmlrpcerruser, $xmlrpcBoolean;
345
+        $err="";
346
+
347
+        $mTo=$m->getParam(0);
348
+        $mSub=$m->getParam(1);
349
+        $mBody=$m->getParam(2);
350
+        $mFrom=$m->getParam(3);
351
+        $mCc=$m->getParam(4);
352
+        $mBcc=$m->getParam(5);
353
+        $mMime=$m->getParam(6);
354
+
355
+        if ($mTo->scalarval()=="")
356
+        {
357
+            $err="Error, no 'To' field specified";
358
+        }
359
+
360
+        if ($mFrom->scalarval()=="")
361
+        {
362
+            $err="Error, no 'From' field specified";
363
+        }
364
+
365
+        $msghdr="From: " . $mFrom->scalarval() . "\n";
366
+        $msghdr.="To: ". $mTo->scalarval() . "\n";
367
+
368
+        if ($mCc->scalarval()!="")
369
+        {
370
+            $msghdr.="Cc: " . $mCc->scalarval(). "\n";
371
+        }
372
+        if ($mBcc->scalarval()!="")
373
+        {
374
+            $msghdr.="Bcc: " . $mBcc->scalarval(). "\n";
375
+        }
376
+        if ($mMime->scalarval()!="")
377
+        {
378
+            $msghdr.="Content-type: " . $mMime->scalarval() . "\n";
379
+        }
380
+        $msghdr.="X-Mailer: XML-RPC for PHP mailer 1.0";
381
+
382
+        if ($err=="")
383
+        {
384
+            if (!mail("",
385
+                $mSub->scalarval(),
386
+                $mBody->scalarval(),
387
+                $msghdr))
388
+            {
389
+                $err="Error, could not send the mail.";
390
+            }
391
+        }
392
+
393
+        if ($err)
394
+        {
395
+            return new xmlrpcresp(0, $xmlrpcerruser, $err);
396
+        }
397
+        else
398
+        {
399
+            return new xmlrpcresp(new xmlrpcval("true", $xmlrpcBoolean));
400
+        }
401
+    }
402
+
403
+    $getallheaders_sig=array(array($xmlrpcStruct));
404
+    $getallheaders_doc='Returns a struct containing all the HTTP headers received with the request. Provides limited functionality with IIS';
405
+    function getallheaders_xmlrpc($m)
406
+    {
407
+        global $xmlrpcerruser;
408
+        if (function_exists('getallheaders'))
409
+        {
410
+            return new xmlrpcresp(php_xmlrpc_encode(getallheaders()));
411
+        }
412
+        else
413
+        {
414
+            $headers = array();
415
+            // IIS: poor man's version of getallheaders
416
+            foreach ($_SERVER as $key => $val)
417
+                if (strpos($key, 'HTTP_') === 0)
418
+                {
419
+                    $key = ucfirst(str_replace('_', '-', strtolower(substr($key, 5))));
420
+                    $headers[$key] = $val;
421
+                }
422
+            return new xmlrpcresp(php_xmlrpc_encode($headers));
423
+        }
424
+    }
425
+
426
+    $setcookies_sig=array(array($xmlrpcInt, $xmlrpcStruct));
427
+    $setcookies_doc='Sends to client a response containing a single \'1\' digit, and sets to it http cookies as received in the request (array of structs describing a cookie)';
428
+    function setcookies($m)
429
+    {
430
+        $m = $m->getParam(0);
431
+        while(list($name,$value) = $m->structeach())
432
+        {
433
+            $cookiedesc = php_xmlrpc_decode($value);
434
+            setcookie($name, @$cookiedesc['value'], @$cookiedesc['expires'], @$cookiedesc['path'], @$cookiedesc['domain'], @$cookiedesc['secure']);
435
+        }
436
+        return new xmlrpcresp(new xmlrpcval(1, 'int'));
437
+    }
438
+
439
+    $getcookies_sig=array(array($xmlrpcStruct));
440
+    $getcookies_doc='Sends to client a response containing all http cookies as received in the request (as struct)';
441
+    function getcookies($m)
442
+    {
443
+        return new xmlrpcresp(php_xmlrpc_encode($_COOKIE));
444
+    }
445
+
446
+    $v1_arrayOfStructs_sig=array(array($xmlrpcInt, $xmlrpcArray));
447
+    $v1_arrayOfStructs_doc='This handler takes a single parameter, an array of structs, each of which contains at least three elements named moe, larry and curly, all <i4>s. Your handler must add all the struct elements named curly and return the result.';
448
+    function v1_arrayOfStructs($m)
449
+    {
450
+        $sno=$m->getParam(0);
451
+        $numcurly=0;
452
+        for($i=0; $i<$sno->arraysize(); $i++)
453
+        {
454
+            $str=$sno->arraymem($i);
455
+            $str->structreset();
456
+            while(list($key,$val)=$str->structeach())
457
+            {
458
+                if ($key=="curly")
459
+                {
460
+                    $numcurly+=$val->scalarval();
461
+                }
462
+            }
463
+        }
464
+        return new xmlrpcresp(new xmlrpcval($numcurly, "int"));
465
+    }
466
+
467
+    $v1_easyStruct_sig=array(array($xmlrpcInt, $xmlrpcStruct));
468
+    $v1_easyStruct_doc='This handler takes a single parameter, a struct, containing at least three elements named moe, larry and curly, all &lt;i4&gt;s. Your handler must add the three numbers and return the result.';
469
+    function v1_easyStruct($m)
470
+    {
471
+        $sno=$m->getParam(0);
472
+        $moe=$sno->structmem("moe");
473
+        $larry=$sno->structmem("larry");
474
+        $curly=$sno->structmem("curly");
475
+        $num=$moe->scalarval() + $larry->scalarval() + $curly->scalarval();
476
+        return new xmlrpcresp(new xmlrpcval($num, "int"));
477
+    }
478
+
479
+    $v1_echoStruct_sig=array(array($xmlrpcStruct, $xmlrpcStruct));
480
+    $v1_echoStruct_doc='This handler takes a single parameter, a struct. Your handler must return the struct.';
481
+    function v1_echoStruct($m)
482
+    {
483
+        $sno=$m->getParam(0);
484
+        return new xmlrpcresp($sno);
485
+    }
486
+
487
+    $v1_manyTypes_sig=array(array(
488
+        $xmlrpcArray, $xmlrpcInt, $xmlrpcBoolean,
489
+        $xmlrpcString, $xmlrpcDouble, $xmlrpcDateTime,
490
+        $xmlrpcBase64
491
+    ));
492
+    $v1_manyTypes_doc='This handler takes six parameters, and returns an array containing all the parameters.';
493
+    function v1_manyTypes($m)
494
+    {
495
+        return new xmlrpcresp(new xmlrpcval(array(
496
+            $m->getParam(0),
497
+            $m->getParam(1),
498
+            $m->getParam(2),
499
+            $m->getParam(3),
500
+            $m->getParam(4),
501
+            $m->getParam(5)),
502
+            "array"
503
+        ));
504
+    }
505
+
506
+    $v1_moderateSizeArrayCheck_sig=array(array($xmlrpcString, $xmlrpcArray));
507
+    $v1_moderateSizeArrayCheck_doc='This handler takes a single parameter, which is an array containing between 100 and 200 elements. Each of the items is a string, your handler must return a string containing the concatenated text of the first and last elements.';
508
+    function v1_moderateSizeArrayCheck($m)
509
+    {
510
+        $ar=$m->getParam(0);
511
+        $sz=$ar->arraysize();
512
+        $first=$ar->arraymem(0);
513
+        $last=$ar->arraymem($sz-1);
514
+        return new xmlrpcresp(new xmlrpcval($first->scalarval() .
515
+        $last->scalarval(), "string"));
516
+    }
517
+
518
+    $v1_simpleStructReturn_sig=array(array($xmlrpcStruct, $xmlrpcInt));
519
+    $v1_simpleStructReturn_doc='This handler takes one parameter, and returns a struct containing three elements, times10, times100 and times1000, the result of multiplying the number by 10, 100 and 1000.';
520
+    function v1_simpleStructReturn($m)
521
+    {
522
+        $sno=$m->getParam(0);
523
+        $v=$sno->scalarval();
524
+        return new xmlrpcresp(new xmlrpcval(array(
525
+            "times10"   => new xmlrpcval($v*10, "int"),
526
+            "times100"  => new xmlrpcval($v*100, "int"),
527
+            "times1000" => new xmlrpcval($v*1000, "int")),
528
+            "struct"
529
+        ));
530
+    }
531
+
532
+    $v1_nestedStruct_sig=array(array($xmlrpcInt, $xmlrpcStruct));
533
+    $v1_nestedStruct_doc='This handler takes a single parameter, a struct, that models a daily calendar. At the top level, there is one struct for each year. Each year is broken down into months, and months into days. Most of the days are empty in the struct you receive, but the entry for April 1, 2000 contains a least three elements named moe, larry and curly, all &lt;i4&gt;s. Your handler must add the three numbers and return the result.';
534
+    function v1_nestedStruct($m)
535
+    {
536
+        $sno=$m->getParam(0);
537
+
538
+        $twoK=$sno->structmem("2000");
539
+        $april=$twoK->structmem("04");
540
+        $fools=$april->structmem("01");
541
+        $curly=$fools->structmem("curly");
542
+        $larry=$fools->structmem("larry");
543
+        $moe=$fools->structmem("moe");
544
+        return new xmlrpcresp(new xmlrpcval($curly->scalarval() + $larry->scalarval() + $moe->scalarval(), "int"));
545
+    }
546
+
547
+    $v1_countTheEntities_sig=array(array($xmlrpcStruct, $xmlrpcString));
548
+    $v1_countTheEntities_doc='This handler takes a single parameter, a string, that contains any number of predefined entities, namely &lt;, &gt;, &amp; \' and ".<BR>Your handler must return a struct that contains five fields, all numbers: ctLeftAngleBrackets, ctRightAngleBrackets, ctAmpersands, ctApostrophes, ctQuotes.';
549
+    function v1_countTheEntities($m)
550
+    {
551
+        $sno=$m->getParam(0);
552
+        $str=$sno->scalarval();
553
+        $gt=0; $lt=0; $ap=0; $qu=0; $amp=0;
554
+        for($i=0; $i<strlen($str); $i++)
555
+        {
556
+            $c=substr($str, $i, 1);
557
+            switch($c)
558
+            {
559
+                case ">":
560
+                    $gt++;
561
+                    break;
562
+                case "<":
563
+                    $lt++;
564
+                    break;
565
+                case "\"":
566
+                    $qu++;
567
+                    break;
568
+                case "'":
569
+                    $ap++;
570
+                    break;
571
+                case "&":
572
+                    $amp++;
573
+                    break;
574
+                default:
575
+                    break;
576
+            }
577
+        }
578
+        return new xmlrpcresp(new xmlrpcval(array(
579
+            "ctLeftAngleBrackets"  => new xmlrpcval($lt, "int"),
580
+            "ctRightAngleBrackets" => new xmlrpcval($gt, "int"),
581
+            "ctAmpersands"		 => new xmlrpcval($amp, "int"),
582
+            "ctApostrophes"		=> new xmlrpcval($ap, "int"),
583
+            "ctQuotes"			 => new xmlrpcval($qu, "int")),
584
+            "struct"
585
+        ));
586
+    }
587
+
588
+    // trivial interop tests
589
+    // http://www.xmlrpc.com/stories/storyReader$1636
590
+
591
+    $i_echoString_sig=array(array($xmlrpcString, $xmlrpcString));
592
+    $i_echoString_doc="Echoes string.";
593
+
594
+    $i_echoStringArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
595
+    $i_echoStringArray_doc="Echoes string array.";
596
+
597
+    $i_echoInteger_sig=array(array($xmlrpcInt, $xmlrpcInt));
598
+    $i_echoInteger_doc="Echoes integer.";
599
+
600
+    $i_echoIntegerArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
601
+    $i_echoIntegerArray_doc="Echoes integer array.";
602
+
603
+    $i_echoFloat_sig=array(array($xmlrpcDouble, $xmlrpcDouble));
604
+    $i_echoFloat_doc="Echoes float.";
605
+
606
+    $i_echoFloatArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
607
+    $i_echoFloatArray_doc="Echoes float array.";
608
+
609
+    $i_echoStruct_sig=array(array($xmlrpcStruct, $xmlrpcStruct));
610
+    $i_echoStruct_doc="Echoes struct.";
611
+
612
+    $i_echoStructArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
613
+    $i_echoStructArray_doc="Echoes struct array.";
614
+
615
+    $i_echoValue_doc="Echoes any value back.";
616
+    $i_echoValue_sig=array(array($xmlrpcValue, $xmlrpcValue));
617
+
618
+    $i_echoBase64_sig=array(array($xmlrpcBase64, $xmlrpcBase64));
619
+    $i_echoBase64_doc="Echoes base64.";
620
+
621
+    $i_echoDate_sig=array(array($xmlrpcDateTime, $xmlrpcDateTime));
622
+    $i_echoDate_doc="Echoes dateTime.";
623
+
624
+    function i_echoParam($m)
625
+    {
626
+        $s=$m->getParam(0);
627
+        return new xmlrpcresp($s);
628
+    }
629
+
630
+    function i_echoString($m) { return i_echoParam($m); }
631
+    function i_echoInteger($m) { return i_echoParam($m); }
632
+    function i_echoFloat($m) { return i_echoParam($m); }
633
+    function i_echoStruct($m) { return i_echoParam($m); }
634
+    function i_echoStringArray($m) { return i_echoParam($m); }
635
+    function i_echoIntegerArray($m) { return i_echoParam($m); }
636
+    function i_echoFloatArray($m) { return i_echoParam($m); }
637
+    function i_echoStructArray($m) { return i_echoParam($m); }
638
+    function i_echoValue($m) { return i_echoParam($m); }
639
+    function i_echoBase64($m) { return i_echoParam($m); }
640
+    function i_echoDate($m) { return i_echoParam($m); }
641
+
642
+    $i_whichToolkit_sig=array(array($xmlrpcStruct));
643
+    $i_whichToolkit_doc="Returns a struct containing the following strings: toolkitDocsUrl, toolkitName, toolkitVersion, toolkitOperatingSystem.";
644
+
645
+    function i_whichToolkit($m)
646
+    {
647
+        global $xmlrpcName, $xmlrpcVersion,$SERVER_SOFTWARE;
648
+        $ret=array(
649
+            "toolkitDocsUrl" => "http://phpxmlrpc.sourceforge.net/",
650
+            "toolkitName" => $xmlrpcName,
651
+            "toolkitVersion" => $xmlrpcVersion,
652
+            "toolkitOperatingSystem" => isset ($SERVER_SOFTWARE) ? $SERVER_SOFTWARE : $_SERVER['SERVER_SOFTWARE']
653
+        );
654
+        return new xmlrpcresp ( php_xmlrpc_encode($ret));
655
+    }
656
+
657
+    $o=new xmlrpc_server_methods_container;
658
+    $a=array(
659
+        "examples.getStateName" => array(
660
+            "function" => "findstate",
661
+            "signature" => $findstate_sig,
662
+            "docstring" => $findstate_doc
663
+        ),
664
+        "examples.sortByAge" => array(
665
+            "function" => "agesorter",
666
+            "signature" => $agesorter_sig,
667
+            "docstring" => $agesorter_doc
668
+        ),
669
+        "examples.addtwo" => array(
670
+            "function" => "addtwo",
671
+            "signature" => $addtwo_sig,
672
+            "docstring" => $addtwo_doc
673
+        ),
674
+        "examples.addtwodouble" => array(
675
+            "function" => "addtwodouble",
676
+            "signature" => $addtwodouble_sig,
677
+            "docstring" => $addtwodouble_doc
678
+        ),
679
+        "examples.stringecho" => array(
680
+            "function" => "stringecho",
681
+            "signature" => $stringecho_sig,
682
+            "docstring" => $stringecho_doc
683
+        ),
684
+        "examples.echo" => array(
685
+            "function" => "echoback",
686
+            "signature" => $echoback_sig,
687
+            "docstring" => $echoback_doc
688
+        ),
689
+        "examples.decode64" => array(
690
+            "function" => "echosixtyfour",
691
+            "signature" => $echosixtyfour_sig,
692
+            "docstring" => $echosixtyfour_doc
693
+        ),
694
+        "examples.invertBooleans" => array(
695
+            "function" => "bitflipper",
696
+            "signature" => $bitflipper_sig,
697
+            "docstring" => $bitflipper_doc
698
+        ),
699
+        "examples.generatePHPWarning" => array(
700
+            "function" => array($o, "phpwarninggenerator")
701
+            //'function' => 'xmlrpc_server_methods_container::phpwarninggenerator'
702
+        ),
703
+        "examples.raiseException" => array(
704
+            "function" => array($o, "exceptiongenerator")
705
+        ),
706
+        "examples.getallheaders" => array(
707
+            "function" => 'getallheaders_xmlrpc',
708
+            "signature" => $getallheaders_sig,
709
+            "docstring" => $getallheaders_doc
710
+        ),
711
+        "examples.setcookies" => array(
712
+            "function" => 'setcookies',
713
+            "signature" => $setcookies_sig,
714
+            "docstring" => $setcookies_doc
715
+        ),
716
+        "examples.getcookies" => array(
717
+            "function" => 'getcookies',
718
+            "signature" => $getcookies_sig,
719
+            "docstring" => $getcookies_doc
720
+        ),
721
+        "mail.send" => array(
722
+            "function" => "mail_send",
723
+            "signature" => $mail_send_sig,
724
+            "docstring" => $mail_send_doc
725
+        ),
726
+        "validator1.arrayOfStructsTest" => array(
727
+            "function" => "v1_arrayOfStructs",
728
+            "signature" => $v1_arrayOfStructs_sig,
729
+            "docstring" => $v1_arrayOfStructs_doc
730
+        ),
731
+        "validator1.easyStructTest" => array(
732
+            "function" => "v1_easyStruct",
733
+            "signature" => $v1_easyStruct_sig,
734
+            "docstring" => $v1_easyStruct_doc
735
+        ),
736
+        "validator1.echoStructTest" => array(
737
+            "function" => "v1_echoStruct",
738
+            "signature" => $v1_echoStruct_sig,
739
+            "docstring" => $v1_echoStruct_doc
740
+        ),
741
+        "validator1.manyTypesTest" => array(
742
+            "function" => "v1_manyTypes",
743
+            "signature" => $v1_manyTypes_sig,
744
+            "docstring" => $v1_manyTypes_doc
745
+        ),
746
+        "validator1.moderateSizeArrayCheck" => array(
747
+            "function" => "v1_moderateSizeArrayCheck",
748
+            "signature" => $v1_moderateSizeArrayCheck_sig,
749
+            "docstring" => $v1_moderateSizeArrayCheck_doc
750
+        ),
751
+        "validator1.simpleStructReturnTest" => array(
752
+            "function" => "v1_simpleStructReturn",
753
+            "signature" => $v1_simpleStructReturn_sig,
754
+            "docstring" => $v1_simpleStructReturn_doc
755
+        ),
756
+        "validator1.nestedStructTest" => array(
757
+            "function" => "v1_nestedStruct",
758
+            "signature" => $v1_nestedStruct_sig,
759
+            "docstring" => $v1_nestedStruct_doc
760
+        ),
761
+        "validator1.countTheEntities" => array(
762
+            "function" => "v1_countTheEntities",
763
+            "signature" => $v1_countTheEntities_sig,
764
+            "docstring" => $v1_countTheEntities_doc
765
+        ),
766
+        "interopEchoTests.echoString" => array(
767
+            "function" => "i_echoString",
768
+            "signature" => $i_echoString_sig,
769
+            "docstring" => $i_echoString_doc
770
+        ),
771
+        "interopEchoTests.echoStringArray" => array(
772
+            "function" => "i_echoStringArray",
773
+            "signature" => $i_echoStringArray_sig,
774
+            "docstring" => $i_echoStringArray_doc
775
+        ),
776
+        "interopEchoTests.echoInteger" => array(
777
+            "function" => "i_echoInteger",
778
+            "signature" => $i_echoInteger_sig,
779
+            "docstring" => $i_echoInteger_doc
780
+        ),
781
+        "interopEchoTests.echoIntegerArray" => array(
782
+            "function" => "i_echoIntegerArray",
783
+            "signature" => $i_echoIntegerArray_sig,
784
+            "docstring" => $i_echoIntegerArray_doc
785
+        ),
786
+        "interopEchoTests.echoFloat" => array(
787
+            "function" => "i_echoFloat",
788
+            "signature" => $i_echoFloat_sig,
789
+            "docstring" => $i_echoFloat_doc
790
+        ),
791
+        "interopEchoTests.echoFloatArray" => array(
792
+            "function" => "i_echoFloatArray",
793
+            "signature" => $i_echoFloatArray_sig,
794
+            "docstring" => $i_echoFloatArray_doc
795
+        ),
796
+        "interopEchoTests.echoStruct" => array(
797
+            "function" => "i_echoStruct",
798
+            "signature" => $i_echoStruct_sig,
799
+            "docstring" => $i_echoStruct_doc
800
+        ),
801
+        "interopEchoTests.echoStructArray" => array(
802
+            "function" => "i_echoStructArray",
803
+            "signature" => $i_echoStructArray_sig,
804
+            "docstring" => $i_echoStructArray_doc
805
+        ),
806
+        "interopEchoTests.echoValue" => array(
807
+            "function" => "i_echoValue",
808
+            "signature" => $i_echoValue_sig,
809
+            "docstring" => $i_echoValue_doc
810
+        ),
811
+        "interopEchoTests.echoBase64" => array(
812
+            "function" => "i_echoBase64",
813
+            "signature" => $i_echoBase64_sig,
814
+            "docstring" => $i_echoBase64_doc
815
+        ),
816
+        "interopEchoTests.echoDate" => array(
817
+            "function" => "i_echoDate",
818
+            "signature" => $i_echoDate_sig,
819
+            "docstring" => $i_echoDate_doc
820
+        ),
821
+        "interopEchoTests.whichToolkit" => array(
822
+            "function" => "i_whichToolkit",
823
+            "signature" => $i_whichToolkit_sig,
824
+            "docstring" => $i_whichToolkit_doc
825
+        )
826
+    );
827
+
828
+    if ($findstate2_sig)
829
+        $a['examples.php.getStateName'] = $findstate2_sig;
830
+
831
+    if ($findstate3_sig)
832
+        $a['examples.php2.getStateName'] = $findstate3_sig;
833
+
834
+    if ($findstate4_sig)
835
+        $a['examples.php3.getStateName'] = $findstate4_sig;
836 836
 
837 837
     if ($findstate5_sig)
838 838
         $a['examples.php4.getStateName'] = $findstate5_sig;
839 839
 
840
-	$s=new xmlrpc_server($a, false);
841
-	$s->setdebug(3);
842
-	$s->compress_response = true;
843
-
844
-	// out-of-band information: let the client manipulate the server operations.
845
-	// we do this to help the testsuite script: do not reproduce in production!
846
-	if (isset($_GET['RESPONSE_ENCODING']))
847
-		$s->response_charset_encoding = $_GET['RESPONSE_ENCODING'];
848
-	if (isset($_GET['EXCEPTION_HANDLING']))
849
-		$s->exception_handling = $_GET['EXCEPTION_HANDLING'];
850
-	$s->service();
851
-	// that should do all we need!
840
+    $s=new xmlrpc_server($a, false);
841
+    $s->setdebug(3);
842
+    $s->compress_response = true;
843
+
844
+    // out-of-band information: let the client manipulate the server operations.
845
+    // we do this to help the testsuite script: do not reproduce in production!
846
+    if (isset($_GET['RESPONSE_ENCODING']))
847
+        $s->response_charset_encoding = $_GET['RESPONSE_ENCODING'];
848
+    if (isset($_GET['EXCEPTION_HANDLING']))
849
+        $s->exception_handling = $_GET['EXCEPTION_HANDLING'];
850
+    $s->service();
851
+    // that should do all we need!
852 852
 ?>
853 853
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 		"Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"
72 72
 	);
73 73
 
74
-	$findstate_sig=array(array($xmlrpcString, $xmlrpcInt));
75
-	$findstate_doc='When passed an integer between 1 and 51 returns the
74
+	$findstate_sig = array(array($xmlrpcString, $xmlrpcInt));
75
+	$findstate_doc = 'When passed an integer between 1 and 51 returns the
76 76
 name of a US state, where the integer is the index of that state name
77 77
 in an alphabetic order.';
78 78
 
@@ -80,24 +80,24 @@  discard block
 block discarded – undo
80 80
 	function findstate($m)
81 81
 	{
82 82
 		global $xmlrpcerruser, $stateNames;
83
-		$err="";
83
+		$err = "";
84 84
 		// get the first param
85
-		$sno=$m->getParam(0);
85
+		$sno = $m->getParam(0);
86 86
 
87 87
 		// param must be there and of the correct type: server object does the
88 88
 		// validation for us
89 89
 
90 90
 		// extract the value of the state number
91
-		$snv=$sno->scalarval();
91
+		$snv = $sno->scalarval();
92 92
 		// look it up in our array (zero-based)
93 93
 		if (isset($stateNames[$snv-1]))
94 94
 		{
95
-			$sname=$stateNames[$snv-1];
95
+			$sname = $stateNames[$snv-1];
96 96
 		}
97 97
 		else
98 98
 		{
99 99
 			// not, there so complain
100
-			$err="I don't have a state for the index '" . $snv . "'";
100
+			$err = "I don't have a state for the index '".$snv."'";
101 101
 		}
102 102
 
103 103
 		// if we generated an error, create an error return response
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		else
130 130
 		{
131 131
 			// not, there so complain
132
-			return "I don't have a state for the index '" . $stateno . "'";
132
+			return "I don't have a state for the index '".$stateno."'";
133 133
 		}
134 134
 	}
135 135
 	$findstate2_sig = wrap_php_function('inner_findstate');
@@ -141,70 +141,70 @@  discard block
 block discarded – undo
141 141
 	$obj = new xmlrpc_server_methods_container();
142 142
 	$findstate4_sig = wrap_php_function(array($obj, 'findstate'));
143 143
 
144
-	$addtwo_sig=array(array($xmlrpcInt, $xmlrpcInt, $xmlrpcInt));
145
-	$addtwo_doc='Add two integers together and return the result';
144
+	$addtwo_sig = array(array($xmlrpcInt, $xmlrpcInt, $xmlrpcInt));
145
+	$addtwo_doc = 'Add two integers together and return the result';
146 146
 	function addtwo($m)
147 147
 	{
148
-		$s=$m->getParam(0);
149
-		$t=$m->getParam(1);
150
-		return new xmlrpcresp(new xmlrpcval($s->scalarval()+$t->scalarval(),"int"));
148
+		$s = $m->getParam(0);
149
+		$t = $m->getParam(1);
150
+		return new xmlrpcresp(new xmlrpcval($s->scalarval()+$t->scalarval(), "int"));
151 151
 	}
152 152
 
153
-	$addtwodouble_sig=array(array($xmlrpcDouble, $xmlrpcDouble, $xmlrpcDouble));
154
-	$addtwodouble_doc='Add two doubles together and return the result';
153
+	$addtwodouble_sig = array(array($xmlrpcDouble, $xmlrpcDouble, $xmlrpcDouble));
154
+	$addtwodouble_doc = 'Add two doubles together and return the result';
155 155
 	function addtwodouble($m)
156 156
 	{
157
-		$s=$m->getParam(0);
158
-		$t=$m->getParam(1);
159
-		return new xmlrpcresp(new xmlrpcval($s->scalarval()+$t->scalarval(),"double"));
157
+		$s = $m->getParam(0);
158
+		$t = $m->getParam(1);
159
+		return new xmlrpcresp(new xmlrpcval($s->scalarval()+$t->scalarval(), "double"));
160 160
 	}
161 161
 
162
-	$stringecho_sig=array(array($xmlrpcString, $xmlrpcString));
163
-	$stringecho_doc='Accepts a string parameter, returns the string.';
162
+	$stringecho_sig = array(array($xmlrpcString, $xmlrpcString));
163
+	$stringecho_doc = 'Accepts a string parameter, returns the string.';
164 164
 	function stringecho($m)
165 165
 	{
166 166
 		// just sends back a string
167
-		$s=$m->getParam(0);
167
+		$s = $m->getParam(0);
168 168
 		$v = $s->scalarval();
169 169
 		return new xmlrpcresp(new xmlrpcval($s->scalarval()));
170 170
 	}
171 171
 
172
-	$echoback_sig=array(array($xmlrpcString, $xmlrpcString));
173
-	$echoback_doc='Accepts a string parameter, returns the entire incoming payload';
172
+	$echoback_sig = array(array($xmlrpcString, $xmlrpcString));
173
+	$echoback_doc = 'Accepts a string parameter, returns the entire incoming payload';
174 174
 	function echoback($m)
175 175
 	{
176 176
 		// just sends back a string with what i got
177 177
 		// sent to me, just escaped, that's all
178 178
 		//
179 179
 		// $m is an incoming message
180
-		$s="I got the following message:\n" . $m->serialize();
180
+		$s = "I got the following message:\n".$m->serialize();
181 181
 		return new xmlrpcresp(new xmlrpcval($s));
182 182
 	}
183 183
 
184
-	$echosixtyfour_sig=array(array($xmlrpcString, $xmlrpcBase64));
185
-	$echosixtyfour_doc='Accepts a base64 parameter and returns it decoded as a string';
184
+	$echosixtyfour_sig = array(array($xmlrpcString, $xmlrpcBase64));
185
+	$echosixtyfour_doc = 'Accepts a base64 parameter and returns it decoded as a string';
186 186
 	function echosixtyfour($m)
187 187
 	{
188 188
 		// accepts an encoded value, but sends it back
189 189
 		// as a normal string. this is to test base64 encoding
190 190
 		// is working as expected
191
-		$incoming=$m->getParam(0);
191
+		$incoming = $m->getParam(0);
192 192
 		return new xmlrpcresp(new xmlrpcval($incoming->scalarval(), "string"));
193 193
 	}
194 194
 
195
-	$bitflipper_sig=array(array($xmlrpcArray, $xmlrpcArray));
196
-	$bitflipper_doc='Accepts an array of booleans, and returns them inverted';
195
+	$bitflipper_sig = array(array($xmlrpcArray, $xmlrpcArray));
196
+	$bitflipper_doc = 'Accepts an array of booleans, and returns them inverted';
197 197
 	function bitflipper($m)
198 198
 	{
199 199
 		global $xmlrpcArray;
200 200
 
201
-		$v=$m->getParam(0);
202
-		$sz=$v->arraysize();
203
-		$rv=new xmlrpcval(array(), $xmlrpcArray);
201
+		$v = $m->getParam(0);
202
+		$sz = $v->arraysize();
203
+		$rv = new xmlrpcval(array(), $xmlrpcArray);
204 204
 
205
-		for($j=0; $j<$sz; $j++)
205
+		for ($j = 0; $j<$sz; $j++)
206 206
 		{
207
-			$b=$v->arraymem($j);
207
+			$b = $v->arraymem($j);
208 208
 			if ($b->scalarval())
209 209
 			{
210 210
 				$rv->addScalar(false, "boolean");
@@ -235,18 +235,18 @@  discard block
 block discarded – undo
235 235
 
236 236
 		// don't even ask me _why_ these come padded with
237 237
 		// hyphens, I couldn't tell you :p
238
-		$a=str_replace("-", "", $a);
239
-		$b=str_replace("-", "", $b);
238
+		$a = str_replace("-", "", $a);
239
+		$b = str_replace("-", "", $b);
240 240
 
241
-		if ($agesorter_arr[$a]==$agesorter[$b])
241
+		if ($agesorter_arr[$a] == $agesorter[$b])
242 242
 		{
243 243
 			return 0;
244 244
 		}
245
-		return ($agesorter_arr[$a] > $agesorter_arr[$b]) ? -1 : 1;
245
+		return ($agesorter_arr[$a]>$agesorter_arr[$b]) ? -1 : 1;
246 246
 	}
247 247
 
248
-	$agesorter_sig=array(array($xmlrpcArray, $xmlrpcArray));
249
-	$agesorter_doc='Send this method an array of [string, int] structs, eg:
248
+	$agesorter_sig = array(array($xmlrpcArray, $xmlrpcArray));
249
+	$agesorter_doc = 'Send this method an array of [string, int] structs, eg:
250 250
 <pre>
251 251
  Dave   35
252 252
  Edd	45
@@ -261,43 +261,43 @@  discard block
 block discarded – undo
261 261
 
262 262
 		xmlrpc_debugmsg("Entering 'agesorter'");
263 263
 		// get the parameter
264
-		$sno=$m->getParam(0);
264
+		$sno = $m->getParam(0);
265 265
 		// error string for [if|when] things go wrong
266
-		$err="";
266
+		$err = "";
267 267
 		// create the output value
268
-		$v=new xmlrpcval();
269
-		$agar=array();
268
+		$v = new xmlrpcval();
269
+		$agar = array();
270 270
 
271
-		if (isset($sno) && $sno->kindOf()=="array")
271
+		if (isset($sno) && $sno->kindOf() == "array")
272 272
 		{
273
-			$max=$sno->arraysize();
273
+			$max = $sno->arraysize();
274 274
 			// TODO: create debug method to print can work once more
275 275
 			// print "<!-- found $max array elements -->\n";
276
-			for($i=0; $i<$max; $i++)
276
+			for ($i = 0; $i<$max; $i++)
277 277
 			{
278
-				$rec=$sno->arraymem($i);
279
-				if ($rec->kindOf()!="struct")
278
+				$rec = $sno->arraymem($i);
279
+				if ($rec->kindOf() != "struct")
280 280
 				{
281
-					$err="Found non-struct in array at element $i";
281
+					$err = "Found non-struct in array at element $i";
282 282
 					break;
283 283
 				}
284 284
 				// extract name and age from struct
285
-				$n=$rec->structmem("name");
286
-				$a=$rec->structmem("age");
285
+				$n = $rec->structmem("name");
286
+				$a = $rec->structmem("age");
287 287
 				// $n and $a are xmlrpcvals,
288 288
 				// so get the scalarval from them
289
-				$agar[$n->scalarval()]=$a->scalarval();
289
+				$agar[$n->scalarval()] = $a->scalarval();
290 290
 			}
291 291
 
292
-			$agesorter_arr=$agar;
292
+			$agesorter_arr = $agar;
293 293
 			// hack, must make global as uksort() won't
294 294
 			// allow us to pass any other auxilliary information
295 295
 			uksort($agesorter_arr, agesorter_compare);
296
-			$outAr=array();
297
-			while (list( $key, $val ) = each( $agesorter_arr ) )
296
+			$outAr = array();
297
+			while (list($key, $val) = each($agesorter_arr))
298 298
 			{
299 299
 				// recreate each struct element
300
-				$outAr[]=new xmlrpcval(array("name" =>
300
+				$outAr[] = new xmlrpcval(array("name" =>
301 301
 				new xmlrpcval($key),
302 302
 				"age" =>
303 303
 				new xmlrpcval($val, "int")), "struct");
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 		}
308 308
 		else
309 309
 		{
310
-			$err="Must be one parameter, an array of structs";
310
+			$err = "Must be one parameter, an array of structs";
311 311
 		}
312 312
 
313 313
 		if ($err)
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
 
323 323
 	// signature and instructions, place these in the dispatch
324 324
 	// map
325
-	$mail_send_sig=array(array(
325
+	$mail_send_sig = array(array(
326 326
 		$xmlrpcBoolean, $xmlrpcString, $xmlrpcString,
327 327
 		$xmlrpcString, $xmlrpcString, $xmlrpcString,
328 328
 		$xmlrpcString, $xmlrpcString
329 329
 	));
330 330
 
331
-	$mail_send_doc='mail.send(recipient, subject, text, sender, cc, bcc, mimetype)<br/>
331
+	$mail_send_doc = 'mail.send(recipient, subject, text, sender, cc, bcc, mimetype)<br/>
332 332
 recipient, cc, and bcc are strings, comma-separated lists of email addresses, as described above.<br/>
333 333
 subject is a string, the subject of the message.<br/>
334 334
 sender is a string, it\'s the email address of the person sending the message. This string can not be
@@ -342,51 +342,51 @@  discard block
 block discarded – undo
342 342
 	function mail_send($m)
343 343
 	{
344 344
 		global $xmlrpcerruser, $xmlrpcBoolean;
345
-		$err="";
345
+		$err = "";
346 346
 
347
-		$mTo=$m->getParam(0);
348
-		$mSub=$m->getParam(1);
349
-		$mBody=$m->getParam(2);
350
-		$mFrom=$m->getParam(3);
351
-		$mCc=$m->getParam(4);
352
-		$mBcc=$m->getParam(5);
353
-		$mMime=$m->getParam(6);
347
+		$mTo = $m->getParam(0);
348
+		$mSub = $m->getParam(1);
349
+		$mBody = $m->getParam(2);
350
+		$mFrom = $m->getParam(3);
351
+		$mCc = $m->getParam(4);
352
+		$mBcc = $m->getParam(5);
353
+		$mMime = $m->getParam(6);
354 354
 
355
-		if ($mTo->scalarval()=="")
355
+		if ($mTo->scalarval() == "")
356 356
 		{
357
-			$err="Error, no 'To' field specified";
357
+			$err = "Error, no 'To' field specified";
358 358
 		}
359 359
 
360
-		if ($mFrom->scalarval()=="")
360
+		if ($mFrom->scalarval() == "")
361 361
 		{
362
-			$err="Error, no 'From' field specified";
362
+			$err = "Error, no 'From' field specified";
363 363
 		}
364 364
 
365
-		$msghdr="From: " . $mFrom->scalarval() . "\n";
366
-		$msghdr.="To: ". $mTo->scalarval() . "\n";
365
+		$msghdr = "From: ".$mFrom->scalarval()."\n";
366
+		$msghdr .= "To: ".$mTo->scalarval()."\n";
367 367
 
368
-		if ($mCc->scalarval()!="")
368
+		if ($mCc->scalarval() != "")
369 369
 		{
370
-			$msghdr.="Cc: " . $mCc->scalarval(). "\n";
370
+			$msghdr .= "Cc: ".$mCc->scalarval()."\n";
371 371
 		}
372
-		if ($mBcc->scalarval()!="")
372
+		if ($mBcc->scalarval() != "")
373 373
 		{
374
-			$msghdr.="Bcc: " . $mBcc->scalarval(). "\n";
374
+			$msghdr .= "Bcc: ".$mBcc->scalarval()."\n";
375 375
 		}
376
-		if ($mMime->scalarval()!="")
376
+		if ($mMime->scalarval() != "")
377 377
 		{
378
-			$msghdr.="Content-type: " . $mMime->scalarval() . "\n";
378
+			$msghdr .= "Content-type: ".$mMime->scalarval()."\n";
379 379
 		}
380
-		$msghdr.="X-Mailer: XML-RPC for PHP mailer 1.0";
380
+		$msghdr .= "X-Mailer: XML-RPC for PHP mailer 1.0";
381 381
 
382
-		if ($err=="")
382
+		if ($err == "")
383 383
 		{
384 384
 			if (!mail("",
385 385
 				$mSub->scalarval(),
386 386
 				$mBody->scalarval(),
387 387
 				$msghdr))
388 388
 			{
389
-				$err="Error, could not send the mail.";
389
+				$err = "Error, could not send the mail.";
390 390
 			}
391 391
 		}
392 392
 
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
 		}
401 401
 	}
402 402
 
403
-	$getallheaders_sig=array(array($xmlrpcStruct));
404
-	$getallheaders_doc='Returns a struct containing all the HTTP headers received with the request. Provides limited functionality with IIS';
403
+	$getallheaders_sig = array(array($xmlrpcStruct));
404
+	$getallheaders_doc = 'Returns a struct containing all the HTTP headers received with the request. Provides limited functionality with IIS';
405 405
 	function getallheaders_xmlrpc($m)
406 406
 	{
407 407
 		global $xmlrpcerruser;
@@ -423,12 +423,12 @@  discard block
 block discarded – undo
423 423
 		}
424 424
 	}
425 425
 
426
-	$setcookies_sig=array(array($xmlrpcInt, $xmlrpcStruct));
427
-	$setcookies_doc='Sends to client a response containing a single \'1\' digit, and sets to it http cookies as received in the request (array of structs describing a cookie)';
426
+	$setcookies_sig = array(array($xmlrpcInt, $xmlrpcStruct));
427
+	$setcookies_doc = 'Sends to client a response containing a single \'1\' digit, and sets to it http cookies as received in the request (array of structs describing a cookie)';
428 428
 	function setcookies($m)
429 429
 	{
430 430
 		$m = $m->getParam(0);
431
-		while(list($name,$value) = $m->structeach())
431
+		while (list($name, $value) = $m->structeach())
432 432
 		{
433 433
 			$cookiedesc = php_xmlrpc_decode($value);
434 434
 			setcookie($name, @$cookiedesc['value'], @$cookiedesc['expires'], @$cookiedesc['path'], @$cookiedesc['domain'], @$cookiedesc['secure']);
@@ -436,60 +436,60 @@  discard block
 block discarded – undo
436 436
 		return new xmlrpcresp(new xmlrpcval(1, 'int'));
437 437
 	}
438 438
 
439
-	$getcookies_sig=array(array($xmlrpcStruct));
440
-	$getcookies_doc='Sends to client a response containing all http cookies as received in the request (as struct)';
439
+	$getcookies_sig = array(array($xmlrpcStruct));
440
+	$getcookies_doc = 'Sends to client a response containing all http cookies as received in the request (as struct)';
441 441
 	function getcookies($m)
442 442
 	{
443 443
 		return new xmlrpcresp(php_xmlrpc_encode($_COOKIE));
444 444
 	}
445 445
 
446
-	$v1_arrayOfStructs_sig=array(array($xmlrpcInt, $xmlrpcArray));
447
-	$v1_arrayOfStructs_doc='This handler takes a single parameter, an array of structs, each of which contains at least three elements named moe, larry and curly, all <i4>s. Your handler must add all the struct elements named curly and return the result.';
446
+	$v1_arrayOfStructs_sig = array(array($xmlrpcInt, $xmlrpcArray));
447
+	$v1_arrayOfStructs_doc = 'This handler takes a single parameter, an array of structs, each of which contains at least three elements named moe, larry and curly, all <i4>s. Your handler must add all the struct elements named curly and return the result.';
448 448
 	function v1_arrayOfStructs($m)
449 449
 	{
450
-		$sno=$m->getParam(0);
451
-		$numcurly=0;
452
-		for($i=0; $i<$sno->arraysize(); $i++)
450
+		$sno = $m->getParam(0);
451
+		$numcurly = 0;
452
+		for ($i = 0; $i<$sno->arraysize(); $i++)
453 453
 		{
454
-			$str=$sno->arraymem($i);
454
+			$str = $sno->arraymem($i);
455 455
 			$str->structreset();
456
-			while(list($key,$val)=$str->structeach())
456
+			while (list($key, $val) = $str->structeach())
457 457
 			{
458
-				if ($key=="curly")
458
+				if ($key == "curly")
459 459
 				{
460
-					$numcurly+=$val->scalarval();
460
+					$numcurly += $val->scalarval();
461 461
 				}
462 462
 			}
463 463
 		}
464 464
 		return new xmlrpcresp(new xmlrpcval($numcurly, "int"));
465 465
 	}
466 466
 
467
-	$v1_easyStruct_sig=array(array($xmlrpcInt, $xmlrpcStruct));
468
-	$v1_easyStruct_doc='This handler takes a single parameter, a struct, containing at least three elements named moe, larry and curly, all &lt;i4&gt;s. Your handler must add the three numbers and return the result.';
467
+	$v1_easyStruct_sig = array(array($xmlrpcInt, $xmlrpcStruct));
468
+	$v1_easyStruct_doc = 'This handler takes a single parameter, a struct, containing at least three elements named moe, larry and curly, all &lt;i4&gt;s. Your handler must add the three numbers and return the result.';
469 469
 	function v1_easyStruct($m)
470 470
 	{
471
-		$sno=$m->getParam(0);
472
-		$moe=$sno->structmem("moe");
473
-		$larry=$sno->structmem("larry");
474
-		$curly=$sno->structmem("curly");
475
-		$num=$moe->scalarval() + $larry->scalarval() + $curly->scalarval();
471
+		$sno = $m->getParam(0);
472
+		$moe = $sno->structmem("moe");
473
+		$larry = $sno->structmem("larry");
474
+		$curly = $sno->structmem("curly");
475
+		$num = $moe->scalarval()+$larry->scalarval()+$curly->scalarval();
476 476
 		return new xmlrpcresp(new xmlrpcval($num, "int"));
477 477
 	}
478 478
 
479
-	$v1_echoStruct_sig=array(array($xmlrpcStruct, $xmlrpcStruct));
480
-	$v1_echoStruct_doc='This handler takes a single parameter, a struct. Your handler must return the struct.';
479
+	$v1_echoStruct_sig = array(array($xmlrpcStruct, $xmlrpcStruct));
480
+	$v1_echoStruct_doc = 'This handler takes a single parameter, a struct. Your handler must return the struct.';
481 481
 	function v1_echoStruct($m)
482 482
 	{
483
-		$sno=$m->getParam(0);
483
+		$sno = $m->getParam(0);
484 484
 		return new xmlrpcresp($sno);
485 485
 	}
486 486
 
487
-	$v1_manyTypes_sig=array(array(
487
+	$v1_manyTypes_sig = array(array(
488 488
 		$xmlrpcArray, $xmlrpcInt, $xmlrpcBoolean,
489 489
 		$xmlrpcString, $xmlrpcDouble, $xmlrpcDateTime,
490 490
 		$xmlrpcBase64
491 491
 	));
492
-	$v1_manyTypes_doc='This handler takes six parameters, and returns an array containing all the parameters.';
492
+	$v1_manyTypes_doc = 'This handler takes six parameters, and returns an array containing all the parameters.';
493 493
 	function v1_manyTypes($m)
494 494
 	{
495 495
 		return new xmlrpcresp(new xmlrpcval(array(
@@ -503,58 +503,58 @@  discard block
 block discarded – undo
503 503
 		));
504 504
 	}
505 505
 
506
-	$v1_moderateSizeArrayCheck_sig=array(array($xmlrpcString, $xmlrpcArray));
507
-	$v1_moderateSizeArrayCheck_doc='This handler takes a single parameter, which is an array containing between 100 and 200 elements. Each of the items is a string, your handler must return a string containing the concatenated text of the first and last elements.';
506
+	$v1_moderateSizeArrayCheck_sig = array(array($xmlrpcString, $xmlrpcArray));
507
+	$v1_moderateSizeArrayCheck_doc = 'This handler takes a single parameter, which is an array containing between 100 and 200 elements. Each of the items is a string, your handler must return a string containing the concatenated text of the first and last elements.';
508 508
 	function v1_moderateSizeArrayCheck($m)
509 509
 	{
510
-		$ar=$m->getParam(0);
511
-		$sz=$ar->arraysize();
512
-		$first=$ar->arraymem(0);
513
-		$last=$ar->arraymem($sz-1);
514
-		return new xmlrpcresp(new xmlrpcval($first->scalarval() .
510
+		$ar = $m->getParam(0);
511
+		$sz = $ar->arraysize();
512
+		$first = $ar->arraymem(0);
513
+		$last = $ar->arraymem($sz-1);
514
+		return new xmlrpcresp(new xmlrpcval($first->scalarval().
515 515
 		$last->scalarval(), "string"));
516 516
 	}
517 517
 
518
-	$v1_simpleStructReturn_sig=array(array($xmlrpcStruct, $xmlrpcInt));
519
-	$v1_simpleStructReturn_doc='This handler takes one parameter, and returns a struct containing three elements, times10, times100 and times1000, the result of multiplying the number by 10, 100 and 1000.';
518
+	$v1_simpleStructReturn_sig = array(array($xmlrpcStruct, $xmlrpcInt));
519
+	$v1_simpleStructReturn_doc = 'This handler takes one parameter, and returns a struct containing three elements, times10, times100 and times1000, the result of multiplying the number by 10, 100 and 1000.';
520 520
 	function v1_simpleStructReturn($m)
521 521
 	{
522
-		$sno=$m->getParam(0);
523
-		$v=$sno->scalarval();
522
+		$sno = $m->getParam(0);
523
+		$v = $sno->scalarval();
524 524
 		return new xmlrpcresp(new xmlrpcval(array(
525
-			"times10"   => new xmlrpcval($v*10, "int"),
526
-			"times100"  => new xmlrpcval($v*100, "int"),
527
-			"times1000" => new xmlrpcval($v*1000, "int")),
525
+			"times10"   => new xmlrpcval($v * 10, "int"),
526
+			"times100"  => new xmlrpcval($v * 100, "int"),
527
+			"times1000" => new xmlrpcval($v * 1000, "int")),
528 528
 			"struct"
529 529
 		));
530 530
 	}
531 531
 
532
-	$v1_nestedStruct_sig=array(array($xmlrpcInt, $xmlrpcStruct));
533
-	$v1_nestedStruct_doc='This handler takes a single parameter, a struct, that models a daily calendar. At the top level, there is one struct for each year. Each year is broken down into months, and months into days. Most of the days are empty in the struct you receive, but the entry for April 1, 2000 contains a least three elements named moe, larry and curly, all &lt;i4&gt;s. Your handler must add the three numbers and return the result.';
532
+	$v1_nestedStruct_sig = array(array($xmlrpcInt, $xmlrpcStruct));
533
+	$v1_nestedStruct_doc = 'This handler takes a single parameter, a struct, that models a daily calendar. At the top level, there is one struct for each year. Each year is broken down into months, and months into days. Most of the days are empty in the struct you receive, but the entry for April 1, 2000 contains a least three elements named moe, larry and curly, all &lt;i4&gt;s. Your handler must add the three numbers and return the result.';
534 534
 	function v1_nestedStruct($m)
535 535
 	{
536
-		$sno=$m->getParam(0);
537
-
538
-		$twoK=$sno->structmem("2000");
539
-		$april=$twoK->structmem("04");
540
-		$fools=$april->structmem("01");
541
-		$curly=$fools->structmem("curly");
542
-		$larry=$fools->structmem("larry");
543
-		$moe=$fools->structmem("moe");
544
-		return new xmlrpcresp(new xmlrpcval($curly->scalarval() + $larry->scalarval() + $moe->scalarval(), "int"));
536
+		$sno = $m->getParam(0);
537
+
538
+		$twoK = $sno->structmem("2000");
539
+		$april = $twoK->structmem("04");
540
+		$fools = $april->structmem("01");
541
+		$curly = $fools->structmem("curly");
542
+		$larry = $fools->structmem("larry");
543
+		$moe = $fools->structmem("moe");
544
+		return new xmlrpcresp(new xmlrpcval($curly->scalarval()+$larry->scalarval()+$moe->scalarval(), "int"));
545 545
 	}
546 546
 
547
-	$v1_countTheEntities_sig=array(array($xmlrpcStruct, $xmlrpcString));
548
-	$v1_countTheEntities_doc='This handler takes a single parameter, a string, that contains any number of predefined entities, namely &lt;, &gt;, &amp; \' and ".<BR>Your handler must return a struct that contains five fields, all numbers: ctLeftAngleBrackets, ctRightAngleBrackets, ctAmpersands, ctApostrophes, ctQuotes.';
547
+	$v1_countTheEntities_sig = array(array($xmlrpcStruct, $xmlrpcString));
548
+	$v1_countTheEntities_doc = 'This handler takes a single parameter, a string, that contains any number of predefined entities, namely &lt;, &gt;, &amp; \' and ".<BR>Your handler must return a struct that contains five fields, all numbers: ctLeftAngleBrackets, ctRightAngleBrackets, ctAmpersands, ctApostrophes, ctQuotes.';
549 549
 	function v1_countTheEntities($m)
550 550
 	{
551
-		$sno=$m->getParam(0);
552
-		$str=$sno->scalarval();
553
-		$gt=0; $lt=0; $ap=0; $qu=0; $amp=0;
554
-		for($i=0; $i<strlen($str); $i++)
551
+		$sno = $m->getParam(0);
552
+		$str = $sno->scalarval();
553
+		$gt = 0; $lt = 0; $ap = 0; $qu = 0; $amp = 0;
554
+		for ($i = 0; $i<strlen($str); $i++)
555 555
 		{
556
-			$c=substr($str, $i, 1);
557
-			switch($c)
556
+			$c = substr($str, $i, 1);
557
+			switch ($c)
558 558
 			{
559 559
 				case ">":
560 560
 					$gt++;
@@ -588,42 +588,42 @@  discard block
 block discarded – undo
588 588
 	// trivial interop tests
589 589
 	// http://www.xmlrpc.com/stories/storyReader$1636
590 590
 
591
-	$i_echoString_sig=array(array($xmlrpcString, $xmlrpcString));
592
-	$i_echoString_doc="Echoes string.";
591
+	$i_echoString_sig = array(array($xmlrpcString, $xmlrpcString));
592
+	$i_echoString_doc = "Echoes string.";
593 593
 
594
-	$i_echoStringArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
595
-	$i_echoStringArray_doc="Echoes string array.";
594
+	$i_echoStringArray_sig = array(array($xmlrpcArray, $xmlrpcArray));
595
+	$i_echoStringArray_doc = "Echoes string array.";
596 596
 
597
-	$i_echoInteger_sig=array(array($xmlrpcInt, $xmlrpcInt));
598
-	$i_echoInteger_doc="Echoes integer.";
597
+	$i_echoInteger_sig = array(array($xmlrpcInt, $xmlrpcInt));
598
+	$i_echoInteger_doc = "Echoes integer.";
599 599
 
600
-	$i_echoIntegerArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
601
-	$i_echoIntegerArray_doc="Echoes integer array.";
600
+	$i_echoIntegerArray_sig = array(array($xmlrpcArray, $xmlrpcArray));
601
+	$i_echoIntegerArray_doc = "Echoes integer array.";
602 602
 
603
-	$i_echoFloat_sig=array(array($xmlrpcDouble, $xmlrpcDouble));
604
-	$i_echoFloat_doc="Echoes float.";
603
+	$i_echoFloat_sig = array(array($xmlrpcDouble, $xmlrpcDouble));
604
+	$i_echoFloat_doc = "Echoes float.";
605 605
 
606
-	$i_echoFloatArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
607
-	$i_echoFloatArray_doc="Echoes float array.";
606
+	$i_echoFloatArray_sig = array(array($xmlrpcArray, $xmlrpcArray));
607
+	$i_echoFloatArray_doc = "Echoes float array.";
608 608
 
609
-	$i_echoStruct_sig=array(array($xmlrpcStruct, $xmlrpcStruct));
610
-	$i_echoStruct_doc="Echoes struct.";
609
+	$i_echoStruct_sig = array(array($xmlrpcStruct, $xmlrpcStruct));
610
+	$i_echoStruct_doc = "Echoes struct.";
611 611
 
612
-	$i_echoStructArray_sig=array(array($xmlrpcArray, $xmlrpcArray));
613
-	$i_echoStructArray_doc="Echoes struct array.";
612
+	$i_echoStructArray_sig = array(array($xmlrpcArray, $xmlrpcArray));
613
+	$i_echoStructArray_doc = "Echoes struct array.";
614 614
 
615
-	$i_echoValue_doc="Echoes any value back.";
616
-	$i_echoValue_sig=array(array($xmlrpcValue, $xmlrpcValue));
615
+	$i_echoValue_doc = "Echoes any value back.";
616
+	$i_echoValue_sig = array(array($xmlrpcValue, $xmlrpcValue));
617 617
 
618
-	$i_echoBase64_sig=array(array($xmlrpcBase64, $xmlrpcBase64));
619
-	$i_echoBase64_doc="Echoes base64.";
618
+	$i_echoBase64_sig = array(array($xmlrpcBase64, $xmlrpcBase64));
619
+	$i_echoBase64_doc = "Echoes base64.";
620 620
 
621
-	$i_echoDate_sig=array(array($xmlrpcDateTime, $xmlrpcDateTime));
622
-	$i_echoDate_doc="Echoes dateTime.";
621
+	$i_echoDate_sig = array(array($xmlrpcDateTime, $xmlrpcDateTime));
622
+	$i_echoDate_doc = "Echoes dateTime.";
623 623
 
624 624
 	function i_echoParam($m)
625 625
 	{
626
-		$s=$m->getParam(0);
626
+		$s = $m->getParam(0);
627 627
 		return new xmlrpcresp($s);
628 628
 	}
629 629
 
@@ -639,23 +639,23 @@  discard block
 block discarded – undo
639 639
 	function i_echoBase64($m) { return i_echoParam($m); }
640 640
 	function i_echoDate($m) { return i_echoParam($m); }
641 641
 
642
-	$i_whichToolkit_sig=array(array($xmlrpcStruct));
643
-	$i_whichToolkit_doc="Returns a struct containing the following strings: toolkitDocsUrl, toolkitName, toolkitVersion, toolkitOperatingSystem.";
642
+	$i_whichToolkit_sig = array(array($xmlrpcStruct));
643
+	$i_whichToolkit_doc = "Returns a struct containing the following strings: toolkitDocsUrl, toolkitName, toolkitVersion, toolkitOperatingSystem.";
644 644
 
645 645
 	function i_whichToolkit($m)
646 646
 	{
647
-		global $xmlrpcName, $xmlrpcVersion,$SERVER_SOFTWARE;
648
-		$ret=array(
647
+		global $xmlrpcName, $xmlrpcVersion, $SERVER_SOFTWARE;
648
+		$ret = array(
649 649
 			"toolkitDocsUrl" => "http://phpxmlrpc.sourceforge.net/",
650 650
 			"toolkitName" => $xmlrpcName,
651 651
 			"toolkitVersion" => $xmlrpcVersion,
652 652
 			"toolkitOperatingSystem" => isset ($SERVER_SOFTWARE) ? $SERVER_SOFTWARE : $_SERVER['SERVER_SOFTWARE']
653 653
 		);
654
-		return new xmlrpcresp ( php_xmlrpc_encode($ret));
654
+		return new xmlrpcresp(php_xmlrpc_encode($ret));
655 655
 	}
656 656
 
657
-	$o=new xmlrpc_server_methods_container;
658
-	$a=array(
657
+	$o = new xmlrpc_server_methods_container;
658
+	$a = array(
659 659
 		"examples.getStateName" => array(
660 660
 			"function" => "findstate",
661 661
 			"signature" => $findstate_sig,
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
     if ($findstate5_sig)
838 838
         $a['examples.php4.getStateName'] = $findstate5_sig;
839 839
 
840
-	$s=new xmlrpc_server($a, false);
840
+	$s = new xmlrpc_server($a, false);
841 841
 	$s->setdebug(3);
842 842
 	$s->compress_response = true;
843 843
 
Please login to merge, or discard this patch.
Braces   +29 added lines, -30 removed lines patch added patch discarded remove patch
@@ -93,8 +93,7 @@  discard block
 block discarded – undo
93 93
 		if (isset($stateNames[$snv-1]))
94 94
 		{
95 95
 			$sname=$stateNames[$snv-1];
96
-		}
97
-		else
96
+		} else
98 97
 		{
99 98
 			// not, there so complain
100 99
 			$err="I don't have a state for the index '" . $snv . "'";
@@ -104,8 +103,7 @@  discard block
 block discarded – undo
104 103
 		if ($err)
105 104
 		{
106 105
 			return new xmlrpcresp(0, $xmlrpcerruser, $err);
107
-		}
108
-		else
106
+		} else
109 107
 		{
110 108
 			// otherwise, we create the right response
111 109
 			// with the state name
@@ -125,8 +123,7 @@  discard block
 block discarded – undo
125 123
 		if (isset($stateNames[$stateno-1]))
126 124
 		{
127 125
 			return $stateNames[$stateno-1];
128
-		}
129
-		else
126
+		} else
130 127
 		{
131 128
 			// not, there so complain
132 129
 			return "I don't have a state for the index '" . $stateno . "'";
@@ -208,8 +205,7 @@  discard block
 block discarded – undo
208 205
 			if ($b->scalarval())
209 206
 			{
210 207
 				$rv->addScalar(false, "boolean");
211
-			}
212
-			else
208
+			} else
213 209
 			{
214 210
 				$rv->addScalar(true, "boolean");
215 211
 			}
@@ -304,8 +300,7 @@  discard block
 block discarded – undo
304 300
 			}
305 301
 			// add this array to the output value
306 302
 			$v->addArray($outAr);
307
-		}
308
-		else
303
+		} else
309 304
 		{
310 305
 			$err="Must be one parameter, an array of structs";
311 306
 		}
@@ -313,8 +308,7 @@  discard block
 block discarded – undo
313 308
 		if ($err)
314 309
 		{
315 310
 			return new xmlrpcresp(0, $xmlrpcerruser, $err);
316
-		}
317
-		else
311
+		} else
318 312
 		{
319 313
 			return new xmlrpcresp($v);
320 314
 		}
@@ -393,8 +387,7 @@  discard block
 block discarded – undo
393 387
 		if ($err)
394 388
 		{
395 389
 			return new xmlrpcresp(0, $xmlrpcerruser, $err);
396
-		}
397
-		else
390
+		} else
398 391
 		{
399 392
 			return new xmlrpcresp(new xmlrpcval("true", $xmlrpcBoolean));
400 393
 		}
@@ -408,15 +401,15 @@  discard block
 block discarded – undo
408 401
 		if (function_exists('getallheaders'))
409 402
 		{
410 403
 			return new xmlrpcresp(php_xmlrpc_encode(getallheaders()));
411
-		}
412
-		else
404
+		} else
413 405
 		{
414 406
 			$headers = array();
415 407
 			// IIS: poor man's version of getallheaders
416
-			foreach ($_SERVER as $key => $val)
417
-				if (strpos($key, 'HTTP_') === 0)
408
+			foreach ($_SERVER as $key => $val) {
409
+							if (strpos($key, 'HTTP_') === 0)
418 410
 				{
419 411
 					$key = ucfirst(str_replace('_', '-', strtolower(substr($key, 5))));
412
+			}
420 413
 					$headers[$key] = $val;
421 414
 				}
422 415
 			return new xmlrpcresp(php_xmlrpc_encode($headers));
@@ -825,17 +818,21 @@  discard block
 block discarded – undo
825 818
 		)
826 819
 	);
827 820
 
828
-	if ($findstate2_sig)
829
-		$a['examples.php.getStateName'] = $findstate2_sig;
821
+	if ($findstate2_sig) {
822
+			$a['examples.php.getStateName'] = $findstate2_sig;
823
+	}
830 824
 
831
-	if ($findstate3_sig)
832
-		$a['examples.php2.getStateName'] = $findstate3_sig;
825
+	if ($findstate3_sig) {
826
+			$a['examples.php2.getStateName'] = $findstate3_sig;
827
+	}
833 828
 
834
-	if ($findstate4_sig)
835
-		$a['examples.php3.getStateName'] = $findstate4_sig;
829
+	if ($findstate4_sig) {
830
+			$a['examples.php3.getStateName'] = $findstate4_sig;
831
+	}
836 832
 
837
-    if ($findstate5_sig)
838
-        $a['examples.php4.getStateName'] = $findstate5_sig;
833
+    if ($findstate5_sig) {
834
+            $a['examples.php4.getStateName'] = $findstate5_sig;
835
+    }
839 836
 
840 837
 	$s=new xmlrpc_server($a, false);
841 838
 	$s->setdebug(3);
@@ -843,10 +840,12 @@  discard block
 block discarded – undo
843 840
 
844 841
 	// out-of-band information: let the client manipulate the server operations.
845 842
 	// we do this to help the testsuite script: do not reproduce in production!
846
-	if (isset($_GET['RESPONSE_ENCODING']))
847
-		$s->response_charset_encoding = $_GET['RESPONSE_ENCODING'];
848
-	if (isset($_GET['EXCEPTION_HANDLING']))
849
-		$s->exception_handling = $_GET['EXCEPTION_HANDLING'];
843
+	if (isset($_GET['RESPONSE_ENCODING'])) {
844
+			$s->response_charset_encoding = $_GET['RESPONSE_ENCODING'];
845
+	}
846
+	if (isset($_GET['EXCEPTION_HANDLING'])) {
847
+			$s->exception_handling = $_GET['EXCEPTION_HANDLING'];
848
+	}
850 849
 	$s->service();
851 850
 	// that should do all we need!
852 851
 ?>
853 852
\ No newline at end of file
Please login to merge, or discard this patch.
demo/vardemo.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -2,59 +2,59 @@  discard block
 block discarded – undo
2 2
 <head><title>xmlrpc</title></head>
3 3
 <body>
4 4
 <?php
5
-	include("xmlrpc.inc");
6
-
7
-	$f = new xmlrpcmsg('examples.getStateName');
8
-
9
-	print "<h3>Testing value serialization</h3>\n";
10
-
11
-	$v = new xmlrpcval(23, "int");
12
-	print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
13
-	$v = new xmlrpcval("What are you saying? >> << &&");
14
-	print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
15
-
16
-	$v = new xmlrpcval(array(
17
-		new xmlrpcval("ABCDEFHIJ"),
18
-		new xmlrpcval(1234, 'int'),
19
-		new xmlrpcval(1, 'boolean')),
20
-		"array"
21
-	);
22
-
23
-	print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
24
-
25
-	$v = new xmlrpcval(
26
-		array(
27
-			"thearray" => new xmlrpcval(
28
-				array(
29
-					new xmlrpcval("ABCDEFHIJ"),
30
-					new xmlrpcval(1234, 'int'),
31
-					new xmlrpcval(1, 'boolean'),
32
-					new xmlrpcval(0, 'boolean'),
33
-					new xmlrpcval(true, 'boolean'),
34
-					new xmlrpcval(false, 'boolean')
35
-				),
36
-				"array"
37
-			),
38
-			"theint" => new xmlrpcval(23, 'int'),
39
-			"thestring" => new xmlrpcval("foobarwhizz"),
40
-			"thestruct" => new xmlrpcval(
41
-				array(
42
-					"one" => new xmlrpcval(1, 'int'),
43
-					"two" => new xmlrpcval(2, 'int')
44
-				),
45
-				"struct"
46
-			)
47
-		),
48
-		"struct"
49
-	);
50
-
51
-	print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
52
-
53
-	$w = new xmlrpcval(array($v, new xmlrpcval("That was the struct!")), "array");
54
-
55
-	print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
56
-
57
-	$w = new xmlrpcval("Mary had a little lamb,
5
+    include("xmlrpc.inc");
6
+
7
+    $f = new xmlrpcmsg('examples.getStateName');
8
+
9
+    print "<h3>Testing value serialization</h3>\n";
10
+
11
+    $v = new xmlrpcval(23, "int");
12
+    print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
13
+    $v = new xmlrpcval("What are you saying? >> << &&");
14
+    print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
15
+
16
+    $v = new xmlrpcval(array(
17
+        new xmlrpcval("ABCDEFHIJ"),
18
+        new xmlrpcval(1234, 'int'),
19
+        new xmlrpcval(1, 'boolean')),
20
+        "array"
21
+    );
22
+
23
+    print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
24
+
25
+    $v = new xmlrpcval(
26
+        array(
27
+            "thearray" => new xmlrpcval(
28
+                array(
29
+                    new xmlrpcval("ABCDEFHIJ"),
30
+                    new xmlrpcval(1234, 'int'),
31
+                    new xmlrpcval(1, 'boolean'),
32
+                    new xmlrpcval(0, 'boolean'),
33
+                    new xmlrpcval(true, 'boolean'),
34
+                    new xmlrpcval(false, 'boolean')
35
+                ),
36
+                "array"
37
+            ),
38
+            "theint" => new xmlrpcval(23, 'int'),
39
+            "thestring" => new xmlrpcval("foobarwhizz"),
40
+            "thestruct" => new xmlrpcval(
41
+                array(
42
+                    "one" => new xmlrpcval(1, 'int'),
43
+                    "two" => new xmlrpcval(2, 'int')
44
+                ),
45
+                "struct"
46
+            )
47
+        ),
48
+        "struct"
49
+    );
50
+
51
+    print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
52
+
53
+    $w = new xmlrpcval(array($v, new xmlrpcval("That was the struct!")), "array");
54
+
55
+    print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
56
+
57
+    $w = new xmlrpcval("Mary had a little lamb,
58 58
 Whose fleece was white as snow,
59 59
 And everywhere that Mary went
60 60
 the lamb was sure to go.
@@ -63,29 +63,29 @@  discard block
 block discarded – undo
63 63
 She tied it to a pylon
64 64
 Ten thousand volts went down its back
65 65
 And turned it into nylon", "base64"
66
-	);
67
-	print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
68
-	print "<PRE>Value of base64 string is: '" . $w->scalarval() . "'</PRE>";
66
+    );
67
+    print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
68
+    print "<PRE>Value of base64 string is: '" . $w->scalarval() . "'</PRE>";
69 69
 
70
-	$f->method('');
71
-	$f->addParam(new xmlrpcval("41", "int"));
70
+    $f->method('');
71
+    $f->addParam(new xmlrpcval("41", "int"));
72 72
 
73
-	print "<h3>Testing request serialization</h3>\n";
74
-	$op = $f->serialize();
75
-	print "<PRE>" . htmlentities($op) . "</PRE>";
73
+    print "<h3>Testing request serialization</h3>\n";
74
+    $op = $f->serialize();
75
+    print "<PRE>" . htmlentities($op) . "</PRE>";
76 76
 
77
-	print "<h3>Testing ISO date format</h3><pre>\n";
77
+    print "<h3>Testing ISO date format</h3><pre>\n";
78 78
 
79
-	$t = time();
80
-	$date = iso8601_encode($t);
81
-	print "Now is $t --> $date\n";
82
-	print "Or in UTC, that is " . iso8601_encode($t, 1) . "\n";
83
-	$tb = iso8601_decode($date);
84
-	print "That is to say $date --> $tb\n";
85
-	print "Which comes out at " . iso8601_encode($tb) . "\n";
86
-	print "Which was the time in UTC at " . iso8601_decode($date, 1) . "\n";
79
+    $t = time();
80
+    $date = iso8601_encode($t);
81
+    print "Now is $t --> $date\n";
82
+    print "Or in UTC, that is " . iso8601_encode($t, 1) . "\n";
83
+    $tb = iso8601_decode($date);
84
+    print "That is to say $date --> $tb\n";
85
+    print "Which comes out at " . iso8601_encode($tb) . "\n";
86
+    print "Which was the time in UTC at " . iso8601_decode($date, 1) . "\n";
87 87
 
88
-	print "</pre>\n";
88
+    print "</pre>\n";
89 89
 ?>
90 90
 </body>
91 91
 </html>
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
 	print "<h3>Testing value serialization</h3>\n";
10 10
 
11 11
 	$v = new xmlrpcval(23, "int");
12
-	print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
12
+	print "<PRE>".htmlentities($v->serialize())."</PRE>";
13 13
 	$v = new xmlrpcval("What are you saying? >> << &&");
14
-	print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
14
+	print "<PRE>".htmlentities($v->serialize())."</PRE>";
15 15
 
16 16
 	$v = new xmlrpcval(array(
17 17
 		new xmlrpcval("ABCDEFHIJ"),
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 		"array"
21 21
 	);
22 22
 
23
-	print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
23
+	print "<PRE>".htmlentities($v->serialize())."</PRE>";
24 24
 
25 25
 	$v = new xmlrpcval(
26 26
 		array(
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 		"struct"
49 49
 	);
50 50
 
51
-	print "<PRE>" . htmlentities($v->serialize()) . "</PRE>";
51
+	print "<PRE>".htmlentities($v->serialize())."</PRE>";
52 52
 
53 53
 	$w = new xmlrpcval(array($v, new xmlrpcval("That was the struct!")), "array");
54 54
 
55
-	print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
55
+	print "<PRE>".htmlentities($w->serialize())."</PRE>";
56 56
 
57 57
 	$w = new xmlrpcval("Mary had a little lamb,
58 58
 Whose fleece was white as snow,
@@ -64,26 +64,26 @@  discard block
 block discarded – undo
64 64
 Ten thousand volts went down its back
65 65
 And turned it into nylon", "base64"
66 66
 	);
67
-	print "<PRE>" . htmlentities($w->serialize()) . "</PRE>";
68
-	print "<PRE>Value of base64 string is: '" . $w->scalarval() . "'</PRE>";
67
+	print "<PRE>".htmlentities($w->serialize())."</PRE>";
68
+	print "<PRE>Value of base64 string is: '".$w->scalarval()."'</PRE>";
69 69
 
70 70
 	$f->method('');
71 71
 	$f->addParam(new xmlrpcval("41", "int"));
72 72
 
73 73
 	print "<h3>Testing request serialization</h3>\n";
74 74
 	$op = $f->serialize();
75
-	print "<PRE>" . htmlentities($op) . "</PRE>";
75
+	print "<PRE>".htmlentities($op)."</PRE>";
76 76
 
77 77
 	print "<h3>Testing ISO date format</h3><pre>\n";
78 78
 
79 79
 	$t = time();
80 80
 	$date = iso8601_encode($t);
81 81
 	print "Now is $t --> $date\n";
82
-	print "Or in UTC, that is " . iso8601_encode($t, 1) . "\n";
82
+	print "Or in UTC, that is ".iso8601_encode($t, 1)."\n";
83 83
 	$tb = iso8601_decode($date);
84 84
 	print "That is to say $date --> $tb\n";
85
-	print "Which comes out at " . iso8601_encode($tb) . "\n";
86
-	print "Which was the time in UTC at " . iso8601_decode($date, 1) . "\n";
85
+	print "Which comes out at ".iso8601_encode($tb)."\n";
86
+	print "Which was the time in UTC at ".iso8601_decode($date, 1)."\n";
87 87
 
88 88
 	print "</pre>\n";
89 89
 ?>
Please login to merge, or discard this patch.
demo/client/comment.php 3 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -6,41 +6,41 @@  discard block
 block discarded – undo
6 6
 // define some utility functions
7 7
 function bomb() { print "</body></html>"; exit(); }
8 8
 function dispatch($client, $method, $args) {
9
-	$msg=new xmlrpcmsg($method, $args);
10
-	$resp=$client->send($msg);
11
-	if (!$resp) { print "<p>IO error: ".$client->errstr."</p>"; bomb(); }
12
-	if ($resp->faultCode()) {
13
-		print "<p>There was an error: " . $resp->faultCode() . " " .
14
-			$resp->faultString() . "</p>";
15
-		bomb();
16
-	}
17
-	return php_xmlrpc_decode($resp->value());
9
+    $msg=new xmlrpcmsg($method, $args);
10
+    $resp=$client->send($msg);
11
+    if (!$resp) { print "<p>IO error: ".$client->errstr."</p>"; bomb(); }
12
+    if ($resp->faultCode()) {
13
+        print "<p>There was an error: " . $resp->faultCode() . " " .
14
+            $resp->faultString() . "</p>";
15
+        bomb();
16
+    }
17
+    return php_xmlrpc_decode($resp->value());
18 18
 }
19 19
 
20 20
 // create client for discussion server
21 21
 $dclient=new xmlrpc_client("${mydir}/discuss.php",
22
-													 "xmlrpc.usefulinc.com", 80);
22
+                                                        "xmlrpc.usefulinc.com", 80);
23 23
 
24 24
 // check if we're posting a comment, and send it if so
25 25
 @$storyid=$_POST["storyid"];
26 26
 if ($storyid) {
27 27
 
28 28
 
29
-	//	print "Returning to " . $HTTP_POST_VARS["returnto"];
29
+    //	print "Returning to " . $HTTP_POST_VARS["returnto"];
30 30
 
31
-	$res=dispatch($dclient, "discuss.addComment",
32
-								array(new xmlrpcval($storyid),
33
-											new xmlrpcval(stripslashes
34
-																		(@$_POST["name"])),
35
-											new xmlrpcval(stripslashes
36
-																		(@$_POST["commenttext"]))));
31
+    $res=dispatch($dclient, "discuss.addComment",
32
+                                array(new xmlrpcval($storyid),
33
+                                            new xmlrpcval(stripslashes
34
+                                                                        (@$_POST["name"])),
35
+                                            new xmlrpcval(stripslashes
36
+                                                                        (@$_POST["commenttext"]))));
37 37
 
38
-	// send the browser back to the originating page
39
-	Header("Location: ${mydir}/comment.php?catid=" .
40
-				 $_POST["catid"] . "&chanid=" .
41
-				 $_POST["chanid"] . "&oc=" .
42
-				 $_POST["catid"]);
43
-	exit(0);
38
+    // send the browser back to the originating page
39
+    Header("Location: ${mydir}/comment.php?catid=" .
40
+                    $_POST["catid"] . "&chanid=" .
41
+                    $_POST["chanid"] . "&oc=" .
42
+                    $_POST["catid"]);
43
+    exit(0);
44 44
 }
45 45
 
46 46
 // now we've got here, we're exploring the story store
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
 <?php
53 53
 @$catid=$_GET["catid"];
54 54
 if (@$_GET["oc"]==$catid)
55
-	@$chanid=$_GET["chanid"];
55
+    @$chanid=$_GET["chanid"];
56 56
 else
57
-	$chanid=0;
57
+    $chanid=0;
58 58
 
59 59
 $client=new xmlrpc_client("/meerkat/xml-rpc/server.php",
60
-													"www.oreillynet.com", 80);
60
+                                                    "www.oreillynet.com", 80);
61 61
 
62 62
 if (@$_GET["comment"] &&
63
-		(!@$_GET["cdone"])) {
64
-	// we're making a comment on a story,
65
-	// so display a comment form
63
+        (!@$_GET["cdone"])) {
64
+    // we're making a comment on a story,
65
+    // so display a comment form
66 66
 ?>
67 67
 <h3>Make a comment on the story</h3>
68 68
 <form method="post">
@@ -80,54 +80,54 @@  discard block
 block discarded – undo
80 80
 </form>
81 81
 <?php
82 82
 } else {
83
-	$categories=dispatch($client, "meerkat.getCategories", array());
84
-	if ($catid)
85
-		$sources = dispatch($client, "meerkat.getChannelsByCategory",
86
-												array(new xmlrpcval($catid, "int")));
87
-	if ($chanid) {
88
-		$stories = dispatch($client, "meerkat.getItems",
89
-					array(new xmlrpcval(
90
-						array(
91
-							"channel" => new xmlrpcval($chanid, "int"),
92
-							"ids" => new xmlrpcval(1, "int"),
93
-							"descriptions" => new xmlrpcval(200, "int"),
94
-							"num_items" => new xmlrpcval(5, "int"),
95
-							"dates" => new xmlrpcval(0, "int")
96
-						), "struct")));
97
-	}
83
+    $categories=dispatch($client, "meerkat.getCategories", array());
84
+    if ($catid)
85
+        $sources = dispatch($client, "meerkat.getChannelsByCategory",
86
+                                                array(new xmlrpcval($catid, "int")));
87
+    if ($chanid) {
88
+        $stories = dispatch($client, "meerkat.getItems",
89
+                    array(new xmlrpcval(
90
+                        array(
91
+                            "channel" => new xmlrpcval($chanid, "int"),
92
+                            "ids" => new xmlrpcval(1, "int"),
93
+                            "descriptions" => new xmlrpcval(200, "int"),
94
+                            "num_items" => new xmlrpcval(5, "int"),
95
+                            "dates" => new xmlrpcval(0, "int")
96
+                        ), "struct")));
97
+    }
98 98
 ?>
99 99
 <form>
100 100
 <p>Subject area:<br />
101 101
 <select name="catid">
102 102
 <?php
103
-	if (!$catid)
104
-		print "<option value=\"0\">Choose a category</option>\n";
105
-	while(list($k,$v) = each($categories)) {
106
-		print "<option value=\"" . $v['id'] ."\"";
107
-		if ($v['id']==$catid) print " selected=\"selected\"";
108
-			print ">". $v['title'] . "</option>\n";
109
-	}
103
+    if (!$catid)
104
+        print "<option value=\"0\">Choose a category</option>\n";
105
+    while(list($k,$v) = each($categories)) {
106
+        print "<option value=\"" . $v['id'] ."\"";
107
+        if ($v['id']==$catid) print " selected=\"selected\"";
108
+            print ">". $v['title'] . "</option>\n";
109
+    }
110 110
 ?>
111 111
 </select></p>
112 112
 <?php
113
-	if ($catid) {
113
+    if ($catid) {
114 114
 ?>
115 115
 <p>News source:<br />
116 116
 <select name="chanid">
117 117
 <?php
118
-		if (!$chanid)
119
-			print "<option value=\"0\">Choose a source</option>\n";
120
-		while(list($k,$v) = each($sources)) {
121
-			print "<option value=\"" . $v['id'] ."\"";
122
-			if ($v['id']==$chanid) print "\" selected=\"selected\"";
123
-			print ">". $v['title'] . "</option>\n";
124
-		}
118
+        if (!$chanid)
119
+            print "<option value=\"0\">Choose a source</option>\n";
120
+        while(list($k,$v) = each($sources)) {
121
+            print "<option value=\"" . $v['id'] ."\"";
122
+            if ($v['id']==$chanid) print "\" selected=\"selected\"";
123
+            print ">". $v['title'] . "</option>\n";
124
+        }
125 125
 ?>
126 126
 </select>
127 127
 </p>
128 128
 
129 129
 <?php
130
-		} // end if ($catid)
130
+        } // end if ($catid)
131 131
 ?>
132 132
 
133 133
 <p><input type="submit" value="Update" /></p>
@@ -135,43 +135,43 @@  discard block
 block discarded – undo
135 135
 </form>
136 136
 
137 137
 <?php
138
-	 if ($chanid) {
138
+        if ($chanid) {
139 139
 ?>
140 140
 
141 141
 <h2>Stories available</h2>
142 142
 <table>
143 143
 <?php
144
-	 while(list($k,$v) = each($stories)) {
145
-		 print "<tr>";
146
-		 print "<td><b>" . $v['title'] . "</b><br />";
147
-		 print $v['description'] . "<br />";
148
-		 print "<em><a target=\"_blank\" href=\"" .
149
-			 $v['link'] . "\">Read full story</a> ";
150
-		 print "<a href=\"comment.php?catid=${catid}&chanid=${chanid}&" .
151
-			 "oc=${oc}&comment=" . $v['id'] . "\">Comment on this story</a>";
152
-		 print "</em>";
153
-		 print "</td>";
154
-		 print "</tr>\n";
155
-		 // now look for existing comments
156
-		 $res=dispatch($dclient, "discuss.getComments",
157
-							array(new xmlrpcval($v['id'])));
158
-		 if (sizeof($res)>0) {
159
-			 print "<tr><td bgcolor=\"#dddddd\"><p><b><i>" .
160
-				 "Comments on this story:</i></b></p>";
161
-			 for($i=0; $i<sizeof($res); $i++) {
162
-				 $s=$res[$i];
163
-				 print "<p><b>From:</b> " . htmlentities($s['name']) . "<br />";
164
-				 print "<b>Comment:</b> " . htmlentities($s['comment']) . "</p>";
165
-			 }
166
-			 print "</td></tr>\n";
167
-		 }
168
-		 print "<tr><td><hr /></td></tr>\n";
169
-	 }
144
+        while(list($k,$v) = each($stories)) {
145
+            print "<tr>";
146
+            print "<td><b>" . $v['title'] . "</b><br />";
147
+            print $v['description'] . "<br />";
148
+            print "<em><a target=\"_blank\" href=\"" .
149
+                $v['link'] . "\">Read full story</a> ";
150
+            print "<a href=\"comment.php?catid=${catid}&chanid=${chanid}&" .
151
+                "oc=${oc}&comment=" . $v['id'] . "\">Comment on this story</a>";
152
+            print "</em>";
153
+            print "</td>";
154
+            print "</tr>\n";
155
+            // now look for existing comments
156
+            $res=dispatch($dclient, "discuss.getComments",
157
+                            array(new xmlrpcval($v['id'])));
158
+            if (sizeof($res)>0) {
159
+                print "<tr><td bgcolor=\"#dddddd\"><p><b><i>" .
160
+                    "Comments on this story:</i></b></p>";
161
+                for($i=0; $i<sizeof($res); $i++) {
162
+                    $s=$res[$i];
163
+                    print "<p><b>From:</b> " . htmlentities($s['name']) . "<br />";
164
+                    print "<b>Comment:</b> " . htmlentities($s['comment']) . "</p>";
165
+                }
166
+                print "</td></tr>\n";
167
+            }
168
+            print "<tr><td><hr /></td></tr>\n";
169
+        }
170 170
 ?>
171 171
 </table>
172 172
 
173 173
 <?php
174
-		} // end if ($chanid)
174
+        } // end if ($chanid)
175 175
 } // end if comment
176 176
 ?>
177 177
 <hr />
Please login to merge, or discard this patch.
Spacing   +41 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,44 +1,42 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 include("xmlrpc.inc");
3 3
 
4
-$mydir="/demo";
4
+$mydir = "/demo";
5 5
 
6 6
 // define some utility functions
7 7
 function bomb() { print "</body></html>"; exit(); }
8 8
 function dispatch($client, $method, $args) {
9
-	$msg=new xmlrpcmsg($method, $args);
10
-	$resp=$client->send($msg);
9
+	$msg = new xmlrpcmsg($method, $args);
10
+	$resp = $client->send($msg);
11 11
 	if (!$resp) { print "<p>IO error: ".$client->errstr."</p>"; bomb(); }
12 12
 	if ($resp->faultCode()) {
13
-		print "<p>There was an error: " . $resp->faultCode() . " " .
14
-			$resp->faultString() . "</p>";
13
+		print "<p>There was an error: ".$resp->faultCode()." ".
14
+			$resp->faultString()."</p>";
15 15
 		bomb();
16 16
 	}
17 17
 	return php_xmlrpc_decode($resp->value());
18 18
 }
19 19
 
20 20
 // create client for discussion server
21
-$dclient=new xmlrpc_client("${mydir}/discuss.php",
21
+$dclient = new xmlrpc_client("${mydir}/discuss.php",
22 22
 													 "xmlrpc.usefulinc.com", 80);
23 23
 
24 24
 // check if we're posting a comment, and send it if so
25
-@$storyid=$_POST["storyid"];
25
+@$storyid = $_POST["storyid"];
26 26
 if ($storyid) {
27 27
 
28 28
 
29 29
 	//	print "Returning to " . $HTTP_POST_VARS["returnto"];
30 30
 
31
-	$res=dispatch($dclient, "discuss.addComment",
31
+	$res = dispatch($dclient, "discuss.addComment",
32 32
 								array(new xmlrpcval($storyid),
33
-											new xmlrpcval(stripslashes
34
-																		(@$_POST["name"])),
35
-											new xmlrpcval(stripslashes
36
-																		(@$_POST["commenttext"]))));
33
+											new xmlrpcval(stripslashes(@$_POST["name"])),
34
+											new xmlrpcval(stripslashes(@$_POST["commenttext"]))));
37 35
 
38 36
 	// send the browser back to the originating page
39
-	Header("Location: ${mydir}/comment.php?catid=" .
40
-				 $_POST["catid"] . "&chanid=" .
41
-				 $_POST["chanid"] . "&oc=" .
37
+	Header("Location: ${mydir}/comment.php?catid=".
38
+				 $_POST["catid"]."&chanid=".
39
+				 $_POST["chanid"]."&oc=".
42 40
 				 $_POST["catid"]);
43 41
 	exit(0);
44 42
 }
@@ -50,13 +48,13 @@  discard block
 block discarded – undo
50 48
 <body bgcolor="#ffffff">
51 49
 <h2>Meerkat integration</h2>
52 50
 <?php
53
-@$catid=$_GET["catid"];
54
-if (@$_GET["oc"]==$catid)
55
-	@$chanid=$_GET["chanid"];
51
+@$catid = $_GET["catid"];
52
+if (@$_GET["oc"] == $catid)
53
+	@$chanid = $_GET["chanid"];
56 54
 else
57
-	$chanid=0;
55
+	$chanid = 0;
58 56
 
59
-$client=new xmlrpc_client("/meerkat/xml-rpc/server.php",
57
+$client = new xmlrpc_client("/meerkat/xml-rpc/server.php",
60 58
 													"www.oreillynet.com", 80);
61 59
 
62 60
 if (@$_GET["comment"] &&
@@ -71,7 +69,7 @@  discard block
 block discarded – undo
71 69
    name="commenttext"></textarea></p>
72 70
 <input type="submit" value="Send comment" />
73 71
 <input type="hidden" name="storyid"
74
-   value="<?php echo @$_GET["comment"];?>" />
72
+   value="<?php echo @$_GET["comment"]; ?>" />
75 73
 <input type="hidden" name="chanid"
76 74
    value="<?php echo $chanid; ?>" />
77 75
 <input type="hidden" name="catid"
@@ -80,7 +78,7 @@  discard block
 block discarded – undo
80 78
 </form>
81 79
 <?php
82 80
 } else {
83
-	$categories=dispatch($client, "meerkat.getCategories", array());
81
+	$categories = dispatch($client, "meerkat.getCategories", array());
84 82
 	if ($catid)
85 83
 		$sources = dispatch($client, "meerkat.getChannelsByCategory",
86 84
 												array(new xmlrpcval($catid, "int")));
@@ -102,10 +100,10 @@  discard block
 block discarded – undo
102 100
 <?php
103 101
 	if (!$catid)
104 102
 		print "<option value=\"0\">Choose a category</option>\n";
105
-	while(list($k,$v) = each($categories)) {
106
-		print "<option value=\"" . $v['id'] ."\"";
107
-		if ($v['id']==$catid) print " selected=\"selected\"";
108
-			print ">". $v['title'] . "</option>\n";
103
+	while (list($k, $v) = each($categories)) {
104
+		print "<option value=\"".$v['id']."\"";
105
+		if ($v['id'] == $catid) print " selected=\"selected\"";
106
+			print ">".$v['title']."</option>\n";
109 107
 	}
110 108
 ?>
111 109
 </select></p>
@@ -117,10 +115,10 @@  discard block
 block discarded – undo
117 115
 <?php
118 116
 		if (!$chanid)
119 117
 			print "<option value=\"0\">Choose a source</option>\n";
120
-		while(list($k,$v) = each($sources)) {
121
-			print "<option value=\"" . $v['id'] ."\"";
122
-			if ($v['id']==$chanid) print "\" selected=\"selected\"";
123
-			print ">". $v['title'] . "</option>\n";
118
+		while (list($k, $v) = each($sources)) {
119
+			print "<option value=\"".$v['id']."\"";
120
+			if ($v['id'] == $chanid) print "\" selected=\"selected\"";
121
+			print ">".$v['title']."</option>\n";
124 122
 		}
125 123
 ?>
126 124
 </select>
@@ -141,27 +139,27 @@  discard block
 block discarded – undo
141 139
 <h2>Stories available</h2>
142 140
 <table>
143 141
 <?php
144
-	 while(list($k,$v) = each($stories)) {
142
+	 while (list($k, $v) = each($stories)) {
145 143
 		 print "<tr>";
146
-		 print "<td><b>" . $v['title'] . "</b><br />";
147
-		 print $v['description'] . "<br />";
148
-		 print "<em><a target=\"_blank\" href=\"" .
149
-			 $v['link'] . "\">Read full story</a> ";
150
-		 print "<a href=\"comment.php?catid=${catid}&chanid=${chanid}&" .
151
-			 "oc=${oc}&comment=" . $v['id'] . "\">Comment on this story</a>";
144
+		 print "<td><b>".$v['title']."</b><br />";
145
+		 print $v['description']."<br />";
146
+		 print "<em><a target=\"_blank\" href=\"".
147
+			 $v['link']."\">Read full story</a> ";
148
+		 print "<a href=\"comment.php?catid=${catid}&chanid=${chanid}&".
149
+			 "oc=${oc}&comment=".$v['id']."\">Comment on this story</a>";
152 150
 		 print "</em>";
153 151
 		 print "</td>";
154 152
 		 print "</tr>\n";
155 153
 		 // now look for existing comments
156
-		 $res=dispatch($dclient, "discuss.getComments",
154
+		 $res = dispatch($dclient, "discuss.getComments",
157 155
 							array(new xmlrpcval($v['id'])));
158 156
 		 if (sizeof($res)>0) {
159
-			 print "<tr><td bgcolor=\"#dddddd\"><p><b><i>" .
157
+			 print "<tr><td bgcolor=\"#dddddd\"><p><b><i>".
160 158
 				 "Comments on this story:</i></b></p>";
161
-			 for($i=0; $i<sizeof($res); $i++) {
162
-				 $s=$res[$i];
163
-				 print "<p><b>From:</b> " . htmlentities($s['name']) . "<br />";
164
-				 print "<b>Comment:</b> " . htmlentities($s['comment']) . "</p>";
159
+			 for ($i = 0; $i<sizeof($res); $i++) {
160
+				 $s = $res[$i];
161
+				 print "<p><b>From:</b> ".htmlentities($s['name'])."<br />";
162
+				 print "<b>Comment:</b> ".htmlentities($s['comment'])."</p>";
165 163
 			 }
166 164
 			 print "</td></tr>\n";
167 165
 		 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -10 removed lines patch added patch discarded remove patch
@@ -51,10 +51,11 @@  discard block
 block discarded – undo
51 51
 <h2>Meerkat integration</h2>
52 52
 <?php
53 53
 @$catid=$_GET["catid"];
54
-if (@$_GET["oc"]==$catid)
54
+if (@$_GET["oc"]==$catid) {
55 55
 	@$chanid=$_GET["chanid"];
56
-else
56
+} else {
57 57
 	$chanid=0;
58
+}
58 59
 
59 60
 $client=new xmlrpc_client("/meerkat/xml-rpc/server.php",
60 61
 													"www.oreillynet.com", 80);
@@ -81,9 +82,10 @@  discard block
 block discarded – undo
81 82
 <?php
82 83
 } else {
83 84
 	$categories=dispatch($client, "meerkat.getCategories", array());
84
-	if ($catid)
85
-		$sources = dispatch($client, "meerkat.getChannelsByCategory",
85
+	if ($catid) {
86
+			$sources = dispatch($client, "meerkat.getChannelsByCategory",
86 87
 												array(new xmlrpcval($catid, "int")));
88
+	}
87 89
 	if ($chanid) {
88 90
 		$stories = dispatch($client, "meerkat.getItems",
89 91
 					array(new xmlrpcval(
@@ -100,11 +102,14 @@  discard block
 block discarded – undo
100 102
 <p>Subject area:<br />
101 103
 <select name="catid">
102 104
 <?php
103
-	if (!$catid)
104
-		print "<option value=\"0\">Choose a category</option>\n";
105
+	if (!$catid) {
106
+			print "<option value=\"0\">Choose a category</option>\n";
107
+	}
105 108
 	while(list($k,$v) = each($categories)) {
106 109
 		print "<option value=\"" . $v['id'] ."\"";
107
-		if ($v['id']==$catid) print " selected=\"selected\"";
110
+		if ($v['id']==$catid) {
111
+		    print " selected=\"selected\"";
112
+		}
108 113
 			print ">". $v['title'] . "</option>\n";
109 114
 	}
110 115
 ?>
@@ -115,11 +120,14 @@  discard block
 block discarded – undo
115 120
 <p>News source:<br />
116 121
 <select name="chanid">
117 122
 <?php
118
-		if (!$chanid)
119
-			print "<option value=\"0\">Choose a source</option>\n";
123
+		if (!$chanid) {
124
+					print "<option value=\"0\">Choose a source</option>\n";
125
+		}
120 126
 		while(list($k,$v) = each($sources)) {
121 127
 			print "<option value=\"" . $v['id'] ."\"";
122
-			if ($v['id']==$chanid) print "\" selected=\"selected\"";
128
+			if ($v['id']==$chanid) {
129
+			    print "\" selected=\"selected\"";
130
+			}
123 131
 			print ">". $v['title'] . "</option>\n";
124 132
 		}
125 133
 ?>
Please login to merge, or discard this patch.
demo/client/wrap.php 3 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -8,49 +8,49 @@
 block discarded – undo
8 8
 2) wrapping of remote methods into php functions
9 9
 </h3>
10 10
 <?php
11
-	include("xmlrpc.inc");
12
-	include("xmlrpc_wrappers.inc");
11
+    include("xmlrpc.inc");
12
+    include("xmlrpc_wrappers.inc");
13 13
 
14
-	$c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
15
-	$c->return_type = 'phpvals'; // let client give us back php values instead of xmlrpcvals
16
-	$r =& $c->send(new xmlrpcmsg('system.listMethods'));
17
-	if($r->faultCode())
18
-	{
19
-		echo "<p>Server methods list could not be retrieved: error '".htmlspecialchars($r->faultString())."'</p>\n";
20
-	}
21
-	else
22
-	{
23
-		$testcase = '';
24
-		echo "<p>Server methods list retrieved, now wrapping it up...</p>\n<ul>\n";
25
-		foreach($r->value() as $methodname) // $r->value is an array of strings
26
-		{
27
-			// do not wrap remote server system methods
28
-			if (strpos($methodname, 'system.') !== 0)
29
-			{
30
-				$funcname = wrap_xmlrpc_method($c, $methodname);
31
-				if($funcname)
32
-				{
33
-					echo "<li>Remote server method ".htmlspecialchars($methodname)." wrapped into php function ".$funcname."</li>\n";
34
-				}
35
-				else
36
-				{
37
-					echo "<li>Remote server method ".htmlspecialchars($methodname)." could not be wrapped!</li>\n";
38
-				}
39
-				if($methodname == 'examples.getStateName')
40
-				{
41
-					$testcase = $funcname;
42
-				}
43
-			}
44
-		}
45
-		echo "</ul>\n";
46
-		if($testcase)
47
-		{
48
-			echo "Now testing function $testcase: remote method to convert U.S. state number into state name";
49
-			$statenum = 25;
50
-			$statename = $testcase($statenum, 2);
51
-			echo "State number $statenum is ".htmlspecialchars($statename);
52
-		}
53
-	}
14
+    $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
15
+    $c->return_type = 'phpvals'; // let client give us back php values instead of xmlrpcvals
16
+    $r =& $c->send(new xmlrpcmsg('system.listMethods'));
17
+    if($r->faultCode())
18
+    {
19
+        echo "<p>Server methods list could not be retrieved: error '".htmlspecialchars($r->faultString())."'</p>\n";
20
+    }
21
+    else
22
+    {
23
+        $testcase = '';
24
+        echo "<p>Server methods list retrieved, now wrapping it up...</p>\n<ul>\n";
25
+        foreach($r->value() as $methodname) // $r->value is an array of strings
26
+        {
27
+            // do not wrap remote server system methods
28
+            if (strpos($methodname, 'system.') !== 0)
29
+            {
30
+                $funcname = wrap_xmlrpc_method($c, $methodname);
31
+                if($funcname)
32
+                {
33
+                    echo "<li>Remote server method ".htmlspecialchars($methodname)." wrapped into php function ".$funcname."</li>\n";
34
+                }
35
+                else
36
+                {
37
+                    echo "<li>Remote server method ".htmlspecialchars($methodname)." could not be wrapped!</li>\n";
38
+                }
39
+                if($methodname == 'examples.getStateName')
40
+                {
41
+                    $testcase = $funcname;
42
+                }
43
+            }
44
+        }
45
+        echo "</ul>\n";
46
+        if($testcase)
47
+        {
48
+            echo "Now testing function $testcase: remote method to convert U.S. state number into state name";
49
+            $statenum = 25;
50
+            $statename = $testcase($statenum, 2);
51
+            echo "State number $statenum is ".htmlspecialchars($statename);
52
+        }
53
+    }
54 54
 ?>
55 55
 </body>
56 56
 </html>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
 
14 14
 	$c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
15 15
 	$c->return_type = 'phpvals'; // let client give us back php values instead of xmlrpcvals
16
-	$r =& $c->send(new xmlrpcmsg('system.listMethods'));
17
-	if($r->faultCode())
16
+	$r = & $c->send(new xmlrpcmsg('system.listMethods'));
17
+	if ($r->faultCode())
18 18
 	{
19 19
 		echo "<p>Server methods list could not be retrieved: error '".htmlspecialchars($r->faultString())."'</p>\n";
20 20
 	}
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 	{
23 23
 		$testcase = '';
24 24
 		echo "<p>Server methods list retrieved, now wrapping it up...</p>\n<ul>\n";
25
-		foreach($r->value() as $methodname) // $r->value is an array of strings
25
+		foreach ($r->value() as $methodname) // $r->value is an array of strings
26 26
 		{
27 27
 			// do not wrap remote server system methods
28 28
 			if (strpos($methodname, 'system.') !== 0)
29 29
 			{
30 30
 				$funcname = wrap_xmlrpc_method($c, $methodname);
31
-				if($funcname)
31
+				if ($funcname)
32 32
 				{
33 33
 					echo "<li>Remote server method ".htmlspecialchars($methodname)." wrapped into php function ".$funcname."</li>\n";
34 34
 				}
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 				{
37 37
 					echo "<li>Remote server method ".htmlspecialchars($methodname)." could not be wrapped!</li>\n";
38 38
 				}
39
-				if($methodname == 'examples.getStateName')
39
+				if ($methodname == 'examples.getStateName')
40 40
 				{
41 41
 					$testcase = $funcname;
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		echo "</ul>\n";
46
-		if($testcase)
46
+		if ($testcase)
47 47
 		{
48 48
 			echo "Now testing function $testcase: remote method to convert U.S. state number into state name";
49 49
 			$statenum = 25;
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,22 +17,22 @@
 block discarded – undo
17 17
 	if($r->faultCode())
18 18
 	{
19 19
 		echo "<p>Server methods list could not be retrieved: error '".htmlspecialchars($r->faultString())."'</p>\n";
20
-	}
21
-	else
20
+	} else
22 21
 	{
23 22
 		$testcase = '';
24 23
 		echo "<p>Server methods list retrieved, now wrapping it up...</p>\n<ul>\n";
25
-		foreach($r->value() as $methodname) // $r->value is an array of strings
24
+		foreach($r->value() as $methodname) {
25
+		    // $r->value is an array of strings
26 26
 		{
27 27
 			// do not wrap remote server system methods
28 28
 			if (strpos($methodname, 'system.') !== 0)
29 29
 			{
30 30
 				$funcname = wrap_xmlrpc_method($c, $methodname);
31
+		}
31 32
 				if($funcname)
32 33
 				{
33 34
 					echo "<li>Remote server method ".htmlspecialchars($methodname)." wrapped into php function ".$funcname."</li>\n";
34
-				}
35
-				else
35
+				} else
36 36
 				{
37 37
 					echo "<li>Remote server method ".htmlspecialchars($methodname)." could not be wrapped!</li>\n";
38 38
 				}
Please login to merge, or discard this patch.
demo/client/agesort.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,1 +1,1 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
demo/client/client.php 3 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -5,45 +5,45 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,34 +8,34 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 ?>
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,15 +30,13 @@
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
demo/client/mail.php 3 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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">
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@
 block discarded – undo
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") {
Please login to merge, or discard this patch.
demo/client/zopetest.php 3 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -4,26 +4,26 @@
 block discarded – undo
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>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
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>
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@
 block discarded – undo
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())
Please login to merge, or discard this patch.
demo/client/introspect.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,1 +1,1 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,1 +1,1 @@
 block discarded – undo
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
Please login to merge, or discard this patch.