6 // define some utility functions
9 print "</body></html>";
13 function dispatch($client, $method, $args)
15 $msg = new xmlrpcmsg($method, $args);
16 $resp = $client->send($msg);
18 print "<p>IO error: " . $client->errstr . "</p>";
21 if ($resp->faultCode()) {
22 print "<p>There was an error: " . $resp->faultCode() . " " .
23 $resp->faultString() . "</p>";
27 return php_xmlrpc_decode($resp->value());
30 // create client for discussion server
31 $dclient = new xmlrpc_client("${mydir}/discuss.php",
32 "xmlrpc.usefulinc.com", 80);
34 // check if we're posting a comment, and send it if so
35 @$storyid = $_POST["storyid"];
38 // print "Returning to " . $HTTP_POST_VARS["returnto"];
40 $res = dispatch($dclient, "discuss.addComment",
41 array(new xmlrpcval($storyid),
42 new xmlrpcval(stripslashes(@$_POST["name"])),
43 new xmlrpcval(stripslashes(@$_POST["commenttext"])),));
45 // send the browser back to the originating page
46 Header("Location: ${mydir}/comment.php?catid=" .
47 $_POST["catid"] . "&chanid=" .
48 $_POST["chanid"] . "&oc=" .
53 // now we've got here, we're exploring the story store
57 <head><title>meerkat browser</title></head>
58 <body bgcolor="#ffffff">
59 <h2>Meerkat integration</h2>
61 @$catid = $_GET["catid"];
62 if (@$_GET["oc"] == $catid) {
63 @$chanid = $_GET["chanid"];
68 $client = new xmlrpc_client("/meerkat/xml-rpc/server.php",
69 "www.oreillynet.com", 80);
71 if (@$_GET["comment"] &&
74 // we're making a comment on a story,
75 // so display a comment form
77 <h3>Make a comment on the story</h3>
79 <p>Your name:<br/><input type="text" size="30" name="name"/></p>
81 <p>Your comment:<br/><textarea rows="5" cols="60"
82 name="commenttext"></textarea></p>
83 <input type="submit" value="Send comment"/>
84 <input type="hidden" name="storyid"
85 value="<?php echo @$_GET["comment"];
87 <input type="hidden" name="chanid"
88 value="<?php echo $chanid;
90 <input type="hidden" name="catid"
91 value="<?php echo $catid;
98 $categories = dispatch($client, "meerkat.getCategories", array());
100 $sources = dispatch($client, "meerkat.getChannelsByCategory",
101 array(new xmlrpcval($catid, "int")));
104 $stories = dispatch($client, "meerkat.getItems",
107 "channel" => new xmlrpcval($chanid, "int"),
108 "ids" => new xmlrpcval(1, "int"),
109 "descriptions" => new xmlrpcval(200, "int"),
110 "num_items" => new xmlrpcval(5, "int"),
111 "dates" => new xmlrpcval(0, "int"),
116 <p>Subject area:<br/>
117 <select name="catid">
120 print "<option value=\"0\">Choose a category</option>\n";
122 while (list($k, $v) = each($categories)) {
123 print "<option value=\"" . $v['id'] . "\"";
124 if ($v['id'] == $catid) {
125 print " selected=\"selected\"";
127 print ">" . $v['title'] . "</option>\n";
135 <select name="chanid">
138 print "<option value=\"0\">Choose a source</option>\n";
140 while (list($k, $v) = each($sources)) {
141 print "<option value=\"" . $v['id'] . "\"";
142 if ($v['id'] == $chanid) {
143 print "\" selected=\"selected\"";
145 print ">" . $v['title'] . "</option>\n";
156 <p><input type="submit" value="Update"/></p>
157 <input type="hidden" name="oc" value="<?php echo $catid;
165 <h2>Stories available</h2>
168 while (list($k, $v) = each($stories)) {
170 print "<td><b>" . $v['title'] . "</b><br />";
171 print $v['description'] . "<br />";
172 print "<em><a target=\"_blank\" href=\"" .
173 $v['link'] . "\">Read full story</a> ";
174 print "<a href=\"comment.php?catid=${catid}&chanid=${chanid}&" .
175 "oc=${oc}&comment=" . $v['id'] . "\">Comment on this story</a>";
179 // now look for existing comments
180 $res = dispatch($dclient, "discuss.getComments",
181 array(new xmlrpcval($v['id'])));
182 if (sizeof($res) > 0) {
183 print "<tr><td bgcolor=\"#dddddd\"><p><b><i>" .
184 "Comments on this story:</i></b></p>";
185 for ($i = 0; $i < sizeof($res); $i++) {
187 print "<p><b>From:</b> " . htmlentities($s['name']) . "<br />";
188 print "<b>Comment:</b> " . htmlentities($s['comment']) . "</p>";
190 print "</td></tr>\n";
192 print "<tr><td><hr /></td></tr>\n";
199 } // end if ($chanid)
204 <a href="http://meerkat.oreillynet.com"><img align="right"
205 src="http://meerkat.oreillynet.com/icons/meerkat-powered.jpg"
206 height="31" width="88" alt="Meerkat powered, yeah!"
207 border="0" hspace="8"/></a>