Menu

[r1]: / examples / rename.php  Maximize  Restore  History

Download this file

43 lines (35 with data), 875 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
require_once ("../phpolait/phpolait.php");
/**
* Simple test class for the JSON RPC server
*/
class RestrictedServer {
function myecho($msg) {
return $msg;
}
function hidden() {
return "Inaccessible method";
}
function version() {
return "PHP-O-Lait Version 0.5";
}
}
$server = new JSONRpcServer( new RestrictedServer(),
array ("version"=>true, "Echo"=>"myecho")
);
?>
<html>
<head>
<?php $server->javascript('proxy'); ?>
</head>
<html>
<body>
<a href="javascript:alert(proxy.Echo('Echo from server'));">
Echo('Echo from server')</a><br />
<a href="javascript:alert(proxy.version());">
version()</a><br />
<a href="javascript:alert(proxy.hidden());">
hidden()</a>
(Won't produce an error since the JavaScript method does not exist.)<br />
</body>
</html>