summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/comment.inc186
-rw-r--r--includes/conf.php16
-rw-r--r--includes/node.inc10
-rw-r--r--includes/theme.inc22
-rw-r--r--includes/xmlrpc.inc1236
-rw-r--r--includes/xmlrpcs.inc434
-rw-r--r--index.php5
-rw-r--r--modules/blog.module11
-rw-r--r--modules/blog/blog.module11
-rw-r--r--modules/comment.module2
-rw-r--r--modules/comment/comment.module2
-rw-r--r--modules/node.module6
-rw-r--r--modules/node/node.module6
-rw-r--r--modules/poll.module2
-rw-r--r--modules/poll/poll.module2
-rw-r--r--modules/story.module2
-rw-r--r--modules/story/story.module2
-rw-r--r--modules/tracker.module2
-rw-r--r--modules/tracker/tracker.module2
-rw-r--r--modules/user.module2
-rw-r--r--modules/user/user.module2
-rw-r--r--node.php5
-rw-r--r--updates/3.00-to-x.xx.sql14
23 files changed, 1003 insertions, 979 deletions
diff --git a/includes/comment.inc b/includes/comment.inc
index a680d476e..cea35102f 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -10,33 +10,29 @@ $cmodes = array(1 => "List - min", 2 => "List - max", 3 => "Threaded - min", 4 =
$corder = array(1 => "Date - new", 2 => "Date - old", 3 => "Rate - high", 4 => "Rate - low");
class Comment {
- function Comment($uid, $name, $subject, $comment, $timestamp, $url, $score, $votes, $cid, $lid) {
+ function Comment($uid, $name, $subject, $comment, $timestamp, $url, $cid, $lid) {
$this->uid = $uid;
$this->name = $name;
$this->subject = $subject;
$this->comment = $comment;
$this->timestamp = $timestamp;
$this->url = $url;
- $this->score = $score;
- $this->votes = $votes;
$this->cid = $cid;
$this->lid = $lid;
}
}
function comment_moderate($moderate) {
- global $user, $comment_votes;
+ global $user;
if ($user->uid && $moderate) {
- $none = $comment_votes[key($comment_votes)];
-
- foreach ($moderate as $id=>$vote) {
- if ($vote != $comment_votes[$none]) {
- $id = check_output($id);
- $vote = check_output($vote);
- $comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = '$id'"));
- if ($comment && !field_get($comment->users, $user->uid)) {
- $result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1, users = '". field_set($comment->users, $user->uid, $vote) ."' WHERE cid = '$id'");
+ foreach ($moderate as $cid => $score) {
+ if ($score > 0 && $score < 6) {
+ if (db_fetch_object(db_query("SELECT * FROM moderate WHERE uid = '". check_query($user->uid) ."' AND cid = '". check_query($cid) ."'"))) {
+ db_query("UPDATE moderate SET score = '". check_query($score) ."' WHERE uid = '". check_query($user->uid) ."' AND cid = '". check_query($cid) ."'");
+ }
+ else {
+ db_query("INSERT INTO moderate (uid, cid, score, timestamp) VALUES ('". check_query($user->uid) ."', '". check_query($cid) ."', '". check_query($score) ."', '". time() ."')");
}
}
}
@@ -83,7 +79,7 @@ function comment_reply($pid, $id) {
if ($pid) {
$item = db_fetch_object(db_query("SELECT c.*, u.name FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.cid = '$pid'"));
- comment_view(new Comment($item->uid, $item->name, $item->subject, $item->comment, $item->timestamp, $item->url, comment_score($comment), $comment->votes, $item->cid, $item->lid), t("reply to this comment"));
+ comment_view(new Comment($item->uid, $item->name, $item->subject, $item->comment, $item->timestamp, $item->url, $item->cid, $item->lid), t("reply to this comment"));
}
else {
node_view(node_get_object(array("nid" => $id)));
@@ -128,7 +124,7 @@ function comment_post($edit) {
watchdog("special", "comment: added '$edit[subject]'");
// add comment to database:
- db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('". check_input($edit[id]) ."', '". check_input($edit[pid]) ."', '$user->uid', '". check_input($edit[subject]) ."', '". check_input($edit[comment]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->name ? 1 : 0) ."')");
+ db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp) VALUES ('". check_input($edit[id]) ."', '". check_input($edit[pid]) ."', '$user->uid', '". check_input($edit[subject]) ."', '". check_input($edit[comment]) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
// clear cache:
cache_clear();
@@ -136,96 +132,112 @@ function comment_post($edit) {
}
}
-function comment_score($comment) {
- $value = ($comment->votes) ? ($comment->score / $comment->votes) : (($comment->score) ? $comment->score : 0);
- return ((strpos($value, ".")) ? substr($value ."00", 0, 4) : $value .".00");
-}
-
function comment_num_replies($id, $count = 0) {
+
$result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = '$id'");
return ($result) ? db_result($result, 0) : 0;
+
}
function comment_moderation($comment) {
- global $comment_votes, $op, $user;
+ global $user;
- if ($op == "reply") {
- // preview comment:
- $output .= "&nbsp;";
- }
- else if ($user->uid && $user->name != $comment->name && !field_get($comment->users, $user->uid)) {
- // comment hasn't been moderated yet:
- foreach ($comment_votes as $key=>$value) $options .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
- $output .= "<SELECT NAME=\"moderate[$comment->cid]\">$options</SELECT>\n";
- }
- else {
- // comment has already been moderated:
- $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD ALIGN=\"right\">". t("score") .":</TD><TD>". check_output($comment->score) ."</TD></TR><TR><TD ALIGN=\"right\">". t("votes") .":</TD><TD>". check_output($comment->votes) ."</TD></TR></TABLE>\n";
+ $values = array("--", 1, 2, 3, 4, 5);
+
+ $moderate = db_fetch_object(db_query("SELECT * FROM moderate WHERE cid = '$comment->cid' AND uid = '$user->uid'"));
+
+ foreach ($values as $key => $value) {
+ $options .= " <option value=\"$key\"". ($moderate->score == $key ? " selected=\"selected\"" : "") .">$value</option>\n";
}
+ $output .= "<div align=\"center\">";
+ $output .= " <select name=\"moderate[comment][$comment->cid]\">$options</select><br />". ($comment->score ? $comment->score : "--") ." / $comment->votes";
+ $output .= "</div>";
+
return $output;
}
function comment_threshold($threshold) {
- for ($i = -1; $i < 6; $i++) $options .= " <OPTION VALUE=\"$i\"". ($threshold == $i ? " SELECTED" : "") .">". t("Filter") ." - $i</OPTION>";
- return "<SELECT NAME=\"threshold\">$options</SELECT>\n";
+ for ($i = 0; $i < 6; $i++) $options .= " <option value=\"$i\"". ($threshold == $i ? " SELECTED" : "") .">". t("Visibility") ." - $i</option>";
+ return "<select name=\"threshold\">$options</select>\n";
}
function comment_mode($mode) {
global $cmodes;
- foreach ($cmodes as $key=>$value) $options .= " <OPTION VALUE=\"$key\"". ($mode == $key ? " SELECTED" : "") .">$value</OPTION>\n";
- return "<SELECT NAME=\"mode\">$options</SELECT>\n";
+
+ foreach ($cmodes as $key=>$value) $options .= " <option value=\"$key\"". ($mode == $key ? " SELECTED" : "") .">$value</option>\n";
+ return "<select name=\"mode\">$options</select>\n";
}
function comment_order($order) {
global $corder;
- foreach ($corder as $key=>$value) $options .= " <OPTION VALUE=\"$key\"". ($order == $key ? " SELECTED" : "") .">$value</OPTION>\n";
- return "<SELECT NAME=\"order\">$options</SELECT>\n";
+
+ foreach ($corder as $key=>$value) $options .= " <option value=\"$key\"". ($order == $key ? " SELECTED" : "") .">$value</option>\n";
+ return "<select name=\"order\">$options</select>\n";
}
function comment_query($lid, $order, $pid = -1) {
- $query .= "SELECT u.*, c.* FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.lid = '$lid'";
- if ($pid >= 0) $query .= " AND pid = '$pid'";
- if ($order == 1) $query .= " ORDER BY c.timestamp DESC";
- else if ($order == 2) $query .= " ORDER BY c.timestamp";
- else if ($order == 3) $query .= " ORDER BY c.score DESC";
- else if ($order == 4) $query .= " ORDER BY c.score";
+
+ $query .= "SELECT u.*, c.*, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN user u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.lid = '$lid'";
+
+ if ($pid >= 0) {
+ $query .= " AND pid = '$pid'";
+ }
+
+ $query .= " GROUP BY c.cid";
+
+ if ($order == 1) {
+ $query .= " ORDER BY c.timestamp DESC";
+ }
+ else if ($order == 2) {
+ $query .= " ORDER BY c.timestamp";
+ }
+ else if ($order == 3) {
+ $query .= " ORDER BY score DESC";
+ }
+ else if ($order == 4) {
+ $query .= " ORDER BY score";
+ }
+
return db_query($query);
-}
-function comment_visible($comment, $threshold = 0) {
- if ($comment->votes == 0 && $comment->score >= $threshold) return 1;
- else if ($comment->votes > 0 && $comment->score / $comment->votes >= $threshold) return 1;
- else return 0;
}
-function comment_uri($args = 0) {
- global $mod;
- if ($args) return ($mod) ? "module.php?mod=$mod;$args" : "node.php?$args";
- else return ($mod) ? "module.php?mod=$mod" : "node.php";
+function comment_visible($comment, $threshold = 0) {
+ if ($comment->votes == 0 || $comment->score >= $threshold) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
}
function comment_links($comment, $return = 1) {
global $theme;
- if ($return) return "<A HREF=\"". comment_uri("id=$comment->lid#$comment->cid") ."\"><FONT COLOR=\"$theme->type\">". t("return") ."</FONT></A> | <A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->type\">". t("reply to this comment") ."</FONT></A>";
- else return "<A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->type\">". t("reply to this comment") ."</FONT></A>";
+
+ if ($return) {
+ return "<a href=\"node.php?id=$comment->lid#$comment->cid\"><font color=\"$theme->type\">". t("return") ."</font></a> | <a href=\"node.php?op=reply&id=$comment->lid&pid=$comment->cid\"><font color=\"$theme->type\">". t("reply to this comment") ."</font></a>";
+ }
+ else {
+ return "<a href=\"node.php?op=reply&id=$comment->lid&pid=$comment->cid\"><font color=\"$theme->type\">". t("reply to this comment") ."</font></a>";
+ }
}
function comment_view($comment, $folded = 0) {
global $theme;
- // calculate comment's score:
- $comment->score = comment_score($comment);
-
- // display comment:
- if ($folded) $theme->comment($comment, $folded);
- else print "<A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A> by ". format_name($comment) ." <SMALL>($comment->score)</SMALL><P>";
+ if ($folded) {
+ $theme->comment($comment, $folded);
+ }
+ else {
+ print "<a href=\"node.php?id=$comment->lid&cid=$comment->cid#$comment->cid\">". check_output($comment->subject) ."</a> by ". format_name($comment) ." <small>(". ($comment->score ? $comment->score : "--") ." / $comment->votes)</small><p />";
+ }
}
function comment_thread_min($cid, $threshold) {
global $user;
- $result = db_query("SELECT u.*, c.* FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid");
+ $result = db_query("SELECT u.*, c.*, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN user u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.pid = '$cid' GROUP BY c.cid ORDER BY c.timestamp, c.cid");
while ($comment = db_fetch_object($result)) {
print "<ul>";
@@ -239,15 +251,15 @@ function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) {
global $user;
/*
- ** We had quite a few browser specific issues with expanded comments below
- ** the top level getting truncated on the right hand side. A range of
- ** solutions have been suggested and tried but either the right margins of
- ** the comments didn't line up as well, or the heavily nested tables made
- ** for slow rendering and cluttered HTML. This is the best work-around in
- ** terms of speed and size.
+ ** We had quite a few browser specific issues: expanded comments below
+ ** the top level got truncated on the right hand side. A range of
+ ** solutions have been proposed and tried but either the right margins of
+ ** the comments didn't line up well, or the heavily nested tables made
+ ** for slow rendering and cluttered HTML. This is the best work-around
+ ** in terms of speed and size.
*/
- $result = db_query("SELECT u.*, c.* FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.pid = '$cid' ORDER BY c.timestamp, c.cid");
+ $result = db_query("SELECT u.*, c.*, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN user u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.pid = '$cid' GROUP BY c.cid ORDER BY c.timestamp, c.cid");
while ($comment = db_fetch_object($result)) {
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td width=\"". ($level * 25) ."\">&nbsp;</td><td>\n";
@@ -265,7 +277,7 @@ function comment_render($lid, $cid) {
if (user_access("access comments")) {
/*
- ** pre-process variables:
+ ** Pre-process variables:
*/
if (empty($lid)) {
@@ -273,7 +285,7 @@ function comment_render($lid, $cid) {
}
if (empty($cid)) {
- $cide = 0;
+ $cid = 0;
}
if (empty($mode)) {
@@ -288,19 +300,17 @@ function comment_render($lid, $cid) {
$threshold = $user->uid ? $user->threshold : variable_get(default_comment_threshold, 3);
}
+ print "<form method=\"post\" action=\"$REQUEST_URI\">\n";
+ // print " <INPUT TYPE=\"hidden\" NAME=\"id\" value=\"$lid\">\n";
+
/*
- ** Render comment control:
+ ** Render control panel:
*/
- $theme->box(t("Comment control"), $theme->comment_controls($threshold, $mode, $order));
-
- if ($user->uid) {
- // Print moderation form:
- print "<FORM METHOD=\"post\" ACTION=\"$REQUEST_URI\">\n";
- }
+ $theme->box(t("Control panel"), $theme->comment_controls($threshold, $mode, $order));
if ($cid > 0) {
- $result = db_query("SELECT u.*, c.* FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE cid = '$cid'");
+ $result = db_query("SELECT u.*, c.*, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM comments c LEFT JOIN user u ON c.author = u.uid LEFT JOIN moderate m ON c.cid = m.cid WHERE c.cid = '$cid' GROUP BY c.cid");
if ($comment = db_fetch_object($result)) {
comment_view($comment, comment_links($comment));
}
@@ -308,14 +318,14 @@ function comment_render($lid, $cid) {
else {
if ($mode == 1) {
$result = comment_query($lid, $order);
- print "<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
- print " <TR><TH>Subject</TH><TH>Author</TH><TH>Date</TH><TH>Score</TH></TR>\n";
+ print "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
+ print " <tr><th>Subject</th><th>Author</th><th>Date</th><th>Score</th></tr>\n";
while ($comment = db_fetch_object($result)) {
if (comment_visible($comment, $threshold)) {
- print " <TR><TD><A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A></TD><TD>". format_name($comment) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD>". comment_score($comment) ."</TD></TR>\n";
+ print " <tr><td><a href=\"node.php?id=$comment->lid&cid=$comment->cid#$comment->cid\">". check_output($comment->subject) ."</a></td><td>". format_name($comment) ."</td><td>". format_date($comment->timestamp, "small") ."</td><td>$comment->score</td></tr>\n";
}
}
- print "</TABLE>\n";
+ print "</table>\n";
}
else if ($mode == 2) {
$result = comment_query($lid, $order);
@@ -339,12 +349,8 @@ function comment_render($lid, $cid) {
}
}
- if ($user->uid) {
- // Print moderation form:
- print " <INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$lid\">\n";
- print " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Moderate comments") ."\">\n";
- print "</FORM>\n";
- }
+ print "</form>";
+
}
}
diff --git a/includes/conf.php b/includes/conf.php
index bd13a9539..fe04ad2a3 100644
--- a/includes/conf.php
+++ b/includes/conf.php
@@ -9,22 +9,6 @@ $db_pass = "drop"; // password
$db_name = "database"; // database
#
-# Comment votes:
-# The keys of this associative array are displayed in each comment's
-# selection box whereas the corresponding values represent the
-# mathematical calculation to be performed to update a comment's
-# value.
-#
-$comment_votes = array("none" => "none",
- "-1" => "- 1",
- "0" => "+ 0",
- "+1" => "+ 1",
- "+2" => "+ 2",
- "+3" => "+ 3",
- "+4" => "+ 4",
- "+5" => "+ 5");
-
-#
# Themes:
#
$themes = array("UnConeD" => array(
diff --git a/includes/node.inc b/includes/node.inc
index 76aa83586..bc138b34d 100644
--- a/includes/node.inc
+++ b/includes/node.inc
@@ -4,7 +4,10 @@ $status = array(dumped => 0, expired => 1, queued => 2, posted => 3);
$rstatus = array(0 => dumped, 1 => expired, 2 => queued, 3 => posted);
function _node_get($conditions) {
- foreach ($conditions as $key=>$value) $cond[] = "n.". check_query($key) ." = '". check_query($value) ."'";
+ foreach ($conditions as $key=>$value) {
+ $cond[] = "n.". check_query($key) ." = '". check_query($value) ."'";
+ }
+
$where = implode(" AND ", $cond);
if ($conditions[type]) {
@@ -16,7 +19,7 @@ function _node_get($conditions) {
}
if ($type) {
- return db_query("SELECT n.*, l.*, u.uid, u.name FROM node n LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN user u ON n.author = u.uid WHERE $where ORDER BY n.timestamp DESC");
+ return db_query("SELECT n.*, l.*, u.uid, u.name, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM node n LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN user u ON n.author = u.uid LEFT JOIN moderate m ON m.nid = n.nid WHERE $where GROUP BY n.nid ORDER BY n.timestamp DESC");
}
}
@@ -267,7 +270,8 @@ function node_moderation($nid) {
$options .= " <option value=\"$key\"". ($moderate->score == $key ? " selected=\"selected\"" : "") .">$value</option>\n";
}
- $output .= " <select name=\"moderate[node][$node->nid]\">$options</select> (". ($node->score ? $node->score : "--") ." / $node->votes)";
+ $output .= "accumulated rating: ". ($node->score ? $node->score : "--") ." / $node->votes<br />";
+ $output .= "<select name=\"moderate[node][$node->nid]\">$options</select>";
return $output;
}
diff --git a/includes/theme.inc b/includes/theme.inc
index 1a582cf3d..7b9d58055 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -10,16 +10,18 @@ class BaseTheme {
}
function comment_controls($threshold = 1, $mode = 3, $order = 1) {
- global $REQUEST_URI, $user;
- $output .= "<DIV ALIGN=\"CENTER\">\n";
- $output .= "<FORM METHOD=\"post\" ACTION=\"$REQUEST_URI\">\n";
- $output .= comment_mode(($user->uid ? $user->mode : $mode));
- $output .= comment_order(($user->uid ? $user->sort : $order));
- $output .= comment_threshold(($user->uid ? $user->threshold : $threshold));
- $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Update settings") ."\">\n";
- $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Add comment") ."\">\n";
- $output .= "</FORM>\n";
- $output .= "</DIV>\n";
+ global $user, $id;
+
+ if ($user->uid) {
+ $output .= form_item(t("Node rating"), node_moderation($id) ." <input type=\"submit\" name=\"op\" value=\"". t("Update ratings") ."\" />", t("Nodes and comments can be moderated by assigning them a score: content with a high rating is made more visible."));
+ }
+
+ $output .= form_item(t("Comment viewing options"), comment_mode($mode) . comment_order($order) . comment_threshold($threshold) ." <input type=\"submit\" name=\"op\" value=\"". t("Update settings") ."\" />", t("Select your prefered way to display the comments and click 'Update settings' to active your changes."));
+
+ if (user_access("post comment")) {
+ $output .= form_item(t("Add a comment"), "<input type=\"submit\" name=\"op\" value=\"". t("Add comment") ."\" />", t("Click 'Add comment' to start a new thread in the discussion."));
+ }
+
return $output;
}
diff --git a/includes/xmlrpc.inc b/includes/xmlrpc.inc
index a8b5e1165..a7989a801 100644
--- a/includes/xmlrpc.inc
+++ b/includes/xmlrpc.inc
@@ -1,4 +1,4 @@
-<?php // -*-c++-*-
+<?php // -*-c++-*-
// by Edd Dumbill (C) 1999-2001
// <edd@usefulinc.com>
// $Id$
@@ -38,11 +38,11 @@
if (!function_exists('xml_parser_create')) {
// Win 32 fix. From: "Leo West" <lwest@imaginet.fr>
- if($WINDIR) {
- dl("php3_xml.dll");
- } else {
- dl("xml.so");
- }
+ if($WINDIR) {
+ dl("php3_xml.dll");
+ } else {
+ dl("xml.so");
+ }
}
$xmlrpcI4="i4";
@@ -57,20 +57,20 @@ $xmlrpcStruct="struct";
$xmlrpcTypes=array($xmlrpcI4 => 1,
- $xmlrpcInt => 1,
- $xmlrpcBoolean => 1,
- $xmlrpcString => 1,
- $xmlrpcDouble => 1,
- $xmlrpcDateTime => 1,
- $xmlrpcBase64 => 1,
- $xmlrpcArray => 2,
- $xmlrpcStruct => 3);
-
-$xmlEntities=array( "amp" => "&",
- "quot" => '"',
- "lt" => "<",
- "gt" => ">",
- "apos" => "'");
+ $xmlrpcInt => 1,
+ $xmlrpcBoolean => 1,
+ $xmlrpcString => 1,
+ $xmlrpcDouble => 1,
+ $xmlrpcDateTime => 1,
+ $xmlrpcBase64 => 1,
+ $xmlrpcArray => 2,
+ $xmlrpcStruct => 3);
+
+$xmlEntities=array( "amp" => "&",
+ "quot" => '"',
+ "lt" => "<",
+ "gt" => ">",
+ "apos" => "'");
$xmlrpcerr["unknown_method"]=1;
$xmlrpcstr["unknown_method"]="Unknown method";
@@ -95,7 +95,7 @@ $xmlrpcName="XML-RPC for PHP";
$xmlrpcVersion="1.01";
// let user errors start at 800
-$xmlrpcerruser=800;
+$xmlrpcerruser=800;
// let XML parse errors start at 100
$xmlrpcerrxml=100;
@@ -119,234 +119,234 @@ $_xh=array();
function xmlrpc_entity_decode($string) {
$top=split("&", $string);
$op="";
- $i=0;
+ $i=0;
while($i<sizeof($top)) {
- if (ereg("^([#a-zA-Z0-9]+);", $top[$i], $regs)) {
- $op.=ereg_replace("^[#a-zA-Z0-9]+;",
- xmlrpc_lookup_entity($regs[1]),
- $top[$i]);
- } else {
- if ($i==0)
- $op=$top[$i];
- else
- $op.="&" . $top[$i];
- }
- $i++;
+ if (ereg("^([#a-zA-Z0-9]+);", $top[$i], $regs)) {
+ $op.=ereg_replace("^[#a-zA-Z0-9]+;",
+ xmlrpc_lookup_entity($regs[1]),
+ $top[$i]);
+ } else {
+ if ($i==0)
+ $op=$top[$i];
+ else
+ $op.="&" . $top[$i];
+ }
+ $i++;
}
return $op;
}
function xmlrpc_lookup_entity($ent) {
global $xmlEntities;
-
+
if (isset($xmlEntities[strtolower($ent)]))
- return $xmlEntities[strtolower($ent)];
+ return $xmlEntities[strtolower($ent)];
if (ereg("^#([0-9]+)$", $ent, $regs))
- return chr($regs[1]);
+ return chr($regs[1]);
return "?";
}
function xmlrpc_se($parser, $name, $attrs) {
- global $_xh, $xmlrpcDateTime, $xmlrpcString;
-
- switch($name) {
- case "STRUCT":
- case "ARRAY":
- $_xh[$parser]['st'].="array(";
- $_xh[$parser]['cm']++;
- // this last line turns quoting off
- // this means if we get an empty array we'll
- // simply get a bit of whitespace in the eval
- $_xh[$parser]['qt']=0;
- break;
- case "NAME":
- $_xh[$parser]['st'].="'"; $_xh[$parser]['ac']="";
- break;
- case "FAULT":
- $_xh[$parser]['isf']=1;
- break;
- case "PARAM":
- $_xh[$parser]['st']="";
- break;
- case "VALUE":
- $_xh[$parser]['st'].="new xmlrpcval(";
- $_xh[$parser]['vt']=$xmlrpcString;
- $_xh[$parser]['ac']="";
- $_xh[$parser]['qt']=0;
- $_xh[$parser]['lv']=1;
- // look for a value: if this is still 1 by the
- // time we reach the first data segment then the type is string
- // by implication and we need to add in a quote
- break;
-
- case "I4":
- case "INT":
- case "STRING":
- case "BOOLEAN":
- case "DOUBLE":
- case "DATETIME.ISO8601":
- case "BASE64":
- $_xh[$parser]['ac']=""; // reset the accumulator
-
- if ($name=="DATETIME.ISO8601" || $name=="STRING") {
- $_xh[$parser]['qt']=1;
- if ($name=="DATETIME.ISO8601")
- $_xh[$parser]['vt']=$xmlrpcDateTime;
- } else if ($name=="BASE64") {
- $_xh[$parser]['qt']=2;
- } else {
- // No quoting is required here -- but
- // at the end of the element we must check
- // for data format errors.
- $_xh[$parser]['qt']=0;
- }
- break;
- case "MEMBER":
- $_xh[$parser]['ac']="";
- break;
- default:
- break;
- }
-
- if ($name!="VALUE") $_xh[$parser]['lv']=0;
+ global $_xh, $xmlrpcDateTime, $xmlrpcString;
+
+ switch($name) {
+ case "STRUCT":
+ case "ARRAY":
+ $_xh[$parser]['st'].="array(";
+ $_xh[$parser]['cm']++;
+ // this last line turns quoting off
+ // this means if we get an empty array we'll
+ // simply get a bit of whitespace in the eval
+ $_xh[$parser]['qt']=0;
+ break;
+ case "NAME":
+ $_xh[$parser]['st'].="'"; $_xh[$parser]['ac']="";
+ break;
+ case "FAULT":
+ $_xh[$parser]['isf']=1;
+ break;
+ case "PARAM":
+ $_xh[$parser]['st']="";
+ break;
+ case "VALUE":
+ $_xh[$parser]['st'].="new xmlrpcval(";
+ $_xh[$parser]['vt']=$xmlrpcString;
+ $_xh[$parser]['ac']="";
+ $_xh[$parser]['qt']=0;
+ $_xh[$parser]['lv']=1;
+ // look for a value: if this is still 1 by the
+ // time we reach the first data segment then the type is string
+ // by implication and we need to add in a quote
+ break;
+
+ case "I4":
+ case "INT":
+ case "STRING":
+ case "BOOLEAN":
+ case "DOUBLE":
+ case "DATETIME.ISO8601":
+ case "BASE64":
+ $_xh[$parser]['ac']=""; // reset the accumulator
+
+ if ($name=="DATETIME.ISO8601" || $name=="STRING") {
+ $_xh[$parser]['qt']=1;
+ if ($name=="DATETIME.ISO8601")
+ $_xh[$parser]['vt']=$xmlrpcDateTime;
+ } else if ($name=="BASE64") {
+ $_xh[$parser]['qt']=2;
+ } else {
+ // No quoting is required here -- but
+ // at the end of the element we must check
+ // for data format errors.
+ $_xh[$parser]['qt']=0;
+ }
+ break;
+ case "MEMBER":
+ $_xh[$parser]['ac']="";
+ break;
+ default:
+ break;
+ }
+
+ if ($name!="VALUE") $_xh[$parser]['lv']=0;
}
function xmlrpc_ee($parser, $name) {
- global $_xh,$xmlrpcTypes,$xmlrpcString;
-
- switch($name) {
- case "STRUCT":
- case "ARRAY":
- if ($_xh[$parser]['cm'] && substr($_xh[$parser]['st'], -1) ==',') {
- $_xh[$parser]['st']=substr($_xh[$parser]['st'],0,-1);
- }
- $_xh[$parser]['st'].=")";
- $_xh[$parser]['vt']=strtolower($name);
- $_xh[$parser]['cm']--;
- break;
- case "NAME":
- $_xh[$parser]['st'].= $_xh[$parser]['ac'] . "' => ";
- break;
- case "BOOLEAN":
- // special case here: we translate boolean 1 or 0 into PHP
- // constants true or false
- if ($_xh[$parser]['ac']=='1')
- $_xh[$parser]['ac']="true";
- else
- $_xh[$parser]['ac']="false";
- $_xh[$parser]['vt']=strtolower($name);
- // Drop through intentionally.
- case "I4":
- case "INT":
- case "STRING":
- case "DOUBLE":
- case "DATETIME.ISO8601":
- case "BASE64":
- if ($_xh[$parser]['qt']==1) {
- // we use double quotes rather than single so backslashification works OK
- $_xh[$parser]['st'].="\"". $_xh[$parser]['ac'] . "\"";
- } else if ($_xh[$parser]['qt']==2) {
- $_xh[$parser]['st'].="base64_decode('". $_xh[$parser]['ac'] . "')";
- } else if ($name=="BOOLEAN") {
- $_xh[$parser]['st'].=$_xh[$parser]['ac'];
- } else {
- // we have an I4, INT or a DOUBLE
- // we must check that only 0123456789-.<space> are characters here
- if (!ereg("^\-?[0123456789 \t\.]+$", $_xh[$parser]['ac'])) {
- // TODO: find a better way of throwing an error
- // than this!
- error_log("XML-RPC: non numeric value received in INT or DOUBLE");
- $_xh[$parser]['st'].="ERROR_NON_NUMERIC_FOUND";
- } else {
- // it's ok, add it on
- $_xh[$parser]['st'].=$_xh[$parser]['ac'];
- }
- }
- $_xh[$parser]['ac']=""; $_xh[$parser]['qt']=0;
- $_xh[$parser]['lv']=3; // indicate we've found a value
- break;
- case "VALUE":
- // deal with a string value
- if (strlen($_xh[$parser]['ac'])>0 &&
- $_xh[$parser]['vt']==$xmlrpcString) {
- $_xh[$parser]['st'].="\"". $_xh[$parser]['ac'] . "\"";
- }
- // This if() detects if no scalar was inside <VALUE></VALUE>
- // and pads an empty "".
- if($_xh[$parser]['st'][strlen($_xh[$parser]['st'])-1] == '(') {
- $_xh[$parser]['st'].= '""';
- }
- $_xh[$parser]['st'].=", '" . $_xh[$parser]['vt'] . "')";
- if ($_xh[$parser]['cm']) $_xh[$parser]['st'].=",";
- break;
- case "MEMBER":
- $_xh[$parser]['ac']=""; $_xh[$parser]['qt']=0;
- break;
- case "DATA":
- $_xh[$parser]['ac']=""; $_xh[$parser]['qt']=0;
- break;
- case "PARAM":
- $_xh[$parser]['params'][]=$_xh[$parser]['st'];
- break;
- case "METHODNAME":
- $_xh[$parser]['method']=ereg_replace("^[\n\r\t ]+", "",
- $_xh[$parser]['ac']);
- break;
- case "BOOLEAN":
- // special case here: we translate boolean 1 or 0 into PHP
- // constants true or false
- if ($_xh[$parser]['ac']=='1')
- $_xh[$parser]['ac']="true";
- else
- $_xh[$parser]['ac']="false";
- $_xh[$parser]['vt']=strtolower($name);
- break;
- default:
- break;
- }
- // if it's a valid type name, set the type
- if (isset($xmlrpcTypes[strtolower($name)])) {
- $_xh[$parser]['vt']=strtolower($name);
- }
-
+ global $_xh,$xmlrpcTypes,$xmlrpcString;
+
+ switch($name) {
+ case "STRUCT":
+ case "ARRAY":
+ if ($_xh[$parser]['cm'] && substr($_xh[$parser]['st'], -1) ==',') {
+ $_xh[$parser]['st']=substr($_xh[$parser]['st'],0,-1);
+ }
+ $_xh[$parser]['st'].=")";
+ $_xh[$parser]['vt']=strtolower($name);
+ $_xh[$parser]['cm']--;
+ break;
+ case "NAME":
+ $_xh[$parser]['st'].= $_xh[$parser]['ac'] . "' => ";
+ break;
+ case "BOOLEAN":
+ // special case here: we translate boolean 1 or 0 into PHP
+ // constants true or false
+ if ($_xh[$parser]['ac']=='1')
+ $_xh[$parser]['ac']="true";
+ else
+ $_xh[$parser]['ac']="false";
+ $_xh[$parser]['vt']=strtolower($name);
+ // Drop through intentionally.
+ case "I4":
+ case "INT":
+ case "STRING":
+ case "DOUBLE":
+ case "DATETIME.ISO8601":
+ case "BASE64":
+ if ($_xh[$parser]['qt']==1) {
+ // we use double quotes rather than single so backslashification works OK
+ $_xh[$parser]['st'].="\"". $_xh[$parser]['ac'] . "\"";
+ } else if ($_xh[$parser]['qt']==2) {
+ $_xh[$parser]['st'].="base64_decode('". $_xh[$parser]['ac'] . "')";
+ } else if ($name=="BOOLEAN") {
+ $_xh[$parser]['st'].=$_xh[$parser]['ac'];
+ } else {
+ // we have an I4, INT or a DOUBLE
+ // we must check that only 0123456789-.<space> are characters here
+ if (!ereg("^\-?[0123456789 \t\.]+$", $_xh[$parser]['ac'])) {
+ // TODO: find a better way of throwing an error
+ // than this!
+ error_log("XML-RPC: non numeric value received in INT or DOUBLE");
+ $_xh[$parser]['st'].="ERROR_NON_NUMERIC_FOUND";
+ } else {
+ // it's ok, add it on
+ $_xh[$parser]['st'].=$_xh[$parser]['ac'];
+ }
+ }
+ $_xh[$parser]['ac']=""; $_xh[$parser]['qt']=0;
+ $_xh[$parser]['lv']=3; // indicate we've found a value
+ break;
+ case "VALUE":
+ // deal with a string value
+ if (strlen($_xh[$parser]['ac'])>0 &&
+ $_xh[$parser]['vt']==$xmlrpcString) {
+ $_xh[$parser]['st'].="\"". $_xh[$parser]['ac'] . "\"";
+ }
+ // This if() detects if no scalar was inside <VALUE></VALUE>
+ // and pads an empty "".
+ if($_xh[$parser]['st'][strlen($_xh[$parser]['st'])-1] == '(') {
+ $_xh[$parser]['st'].= '""';
+ }
+ $_xh[$parser]['st'].=", '" . $_xh[$parser]['vt'] . "')";
+ if ($_xh[$parser]['cm']) $_xh[$parser]['st'].=",";
+ break;
+ case "MEMBER":
+ $_xh[$parser]['ac']=""; $_xh[$parser]['qt']=0;
+ break;
+ case "DATA":
+ $_xh[$parser]['ac']=""; $_xh[$parser]['qt']=0;
+ break;
+ case "PARAM":
+ $_xh[$parser]['params'][]=$_xh[$parser]['st'];
+ break;
+ case "METHODNAME":
+ $_xh[$parser]['method']=ereg_replace("^[\n\r\t ]+", "",
+ $_xh[$parser]['ac']);
+ break;
+ case "BOOLEAN":
+ // special case here: we translate boolean 1 or 0 into PHP
+ // constants true or false
+ if ($_xh[$parser]['ac']=='1')
+ $_xh[$parser]['ac']="true";
+ else
+ $_xh[$parser]['ac']="false";
+ $_xh[$parser]['vt']=strtolower($name);
+ break;
+ default:
+ break;
+ }
+ // if it's a valid type name, set the type
+ if (isset($xmlrpcTypes[strtolower($name)])) {
+ $_xh[$parser]['vt']=strtolower($name);
+ }
+
}
function xmlrpc_cd($parser, $data)
-{
+{
global $_xh, $xmlrpc_backslash;
//if (ereg("^[\n\r \t]+$", $data)) return;
// print "adding [${data}]\n";
- if ($_xh[$parser]['lv']!=3) {
- // "lookforvalue==3" means that we've found an entire value
- // and should discard any further character data
- if ($_xh[$parser]['lv']==1) {
- // if we've found text and we're just in a <value> then
- // turn quoting on, as this will be a string
- $_xh[$parser]['qt']=1;
- // and say we've found a value
- $_xh[$parser]['lv']=2;
- }
- // replace characters that eval would
- // do special things with
- $_xh[$parser]['ac'].=str_replace('$', '\$',
- str_replace('"', '\"', str_replace(chr(92),
- $xmlrpc_backslash, $data)));
- }
+ if ($_xh[$parser]['lv']!=3) {
+ // "lookforvalue==3" means that we've found an entire value
+ // and should discard any further character data
+ if ($_xh[$parser]['lv']==1) {
+ // if we've found text and we're just in a <value> then
+ // turn quoting on, as this will be a string
+ $_xh[$parser]['qt']=1;
+ // and say we've found a value
+ $_xh[$parser]['lv']=2;
+ }
+ // replace characters that eval would
+ // do special things with
+ $_xh[$parser]['ac'].=str_replace('$', '\$',
+ str_replace('"', '\"', str_replace(chr(92),
+ $xmlrpc_backslash, $data)));
+ }
}
function xmlrpc_dh($parser, $data)
{
global $_xh;
if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") {
- if ($_xh[$parser]['lv']==1) {
- $_xh[$parser]['qt']=1;
- $_xh[$parser]['lv']=2;
- }
- $_xh[$parser]['ac'].=str_replace('$', '\$',
- str_replace('"', '\"', str_replace(chr(92),
- $xmlrpc_backslash, $data)));
+ if ($_xh[$parser]['lv']==1) {
+ $_xh[$parser]['qt']=1;
+ $_xh[$parser]['lv']=2;
+ }
+ $_xh[$parser]['ac'].=str_replace('$', '\$',
+ str_replace('"', '\"', str_replace(chr(92),
+ $xmlrpc_backslash, $data)));
}
}
@@ -361,17 +361,17 @@ class xmlrpc_client {
var $password="";
var $cert="";
var $certpass="";
-
+
function xmlrpc_client($path, $server, $port=0) {
$this->port=$port; $this->server=$server; $this->path=$path;
}
function setDebug($in) {
- if ($in) {
- $this->debug=1;
- } else {
- $this->debug=0;
- }
+ if ($in) {
+ $this->debug=1;
+ } else {
+ $this->debug=0;
+ }
}
function setCredentials($u, $p) {
@@ -387,51 +387,51 @@ class xmlrpc_client {
function send($msg, $timeout=0, $method='http') {
// where msg is an xmlrpcmsg
$msg->debug=$this->debug;
-
+
if ($method == 'https') {
return $this->sendPayloadHTTPS($msg,
- $this->server,
- $this->port, $timeout,
- $this->username, $this->password,
- $this->cert,
- $this->certpass);
+ $this->server,
+ $this->port, $timeout,
+ $this->username, $this->password,
+ $this->cert,
+ $this->certpass);
} else {
return $this->sendPayloadHTTP10($msg, $this->server, $this->port,
- $timeout, $this->username,
- $this->password);
+ $timeout, $this->username,
+ $this->password);
}
}
function sendPayloadHTTP10($msg, $server, $port, $timeout=0,
- $username="", $password="") {
+ $username="", $password="") {
if ($port==0) $port=80;
if($timeout>0)
$fp=fsockopen($server, $port,
- &$this->errno, &$this->errstr, $timeout);
+ &$this->errno, &$this->errstr, $timeout);
else
$fp=fsockopen($server, $port,
- &$this->errno, &$this->errstr);
- if (!$fp) {
+ &$this->errno, &$this->errstr);
+ if (!$fp) {
return 0;
}
// Only create the payload if it was not created previously
if(empty($msg->payload)) $msg->createPayload();
-
+
// thanks to Grant Rauscher <grant7@firstworld.net>
// for this
$credentials="";
if ($username!="") {
$credentials="Authorization: Basic " .
- base64_encode($username . ":" . $password) . "\r\n";
+ base64_encode($username . ":" . $password) . "\r\n";
}
-
+
$op= "POST " . $this->path. " HTTP/1.0\r\nUser-Agent: PHP XMLRPC 1.0\r\n" .
"Host: ". $this->server . "\r\n" .
- $credentials .
+ $credentials .
"Content-Type: text/xml\r\nContent-Length: " .
strlen($msg->payload) . "\r\n\r\n" .
$msg->payload;
-
+
if (!fputs($fp, $op, strlen($op))) {
$this->errstr="Write error";
return 0;
@@ -444,23 +444,23 @@ class xmlrpc_client {
// contributed by Justin Miller <justin@voxel.net>
// requires curl to be built into PHP
function sendPayloadHTTPS($msg, $server, $port, $timeout=0,
- $username="", $password="", $cert="",
- $certpass="") {
+ $username="", $password="", $cert="",
+ $certpass="") {
global $xmlrpcerr, $xmlrpcstr;
if ($port == 0) $port = 443;
-
+
// Only create the payload if it was not created previously
if(empty($msg->payload)) $msg->createPayload();
-
+
if (!function_exists("curl_init")) {
$r=new xmlrpcresp(0, $xmlrpcerr["no_ssl"],
- $xmlrpcstr["no_ssl"]);
+ $xmlrpcstr["no_ssl"]);
return $r;
}
$curl = curl_init("https://" . $server . ':' . $port .
- $this->path);
-
+ $this->path);
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// results into variable
if ($this->debug) {
@@ -477,24 +477,24 @@ class xmlrpc_client {
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
// required for XMLRPC
if ($timeout) curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 :
- $timeout - 1);
+ $timeout - 1);
// timeout is borked
if ($username && $password) curl_setopt($curl, CURLOPT_USERPWD,
- "$username:$password");
+ "$username:$password");
// set auth stuff
if ($cert) curl_setopt($curl, CURLOPT_SSLCERT, $cert);
// set cert file
if ($certpass) curl_setopt($curl, CURLOPT_SSLCERTPASSWD,
- $certpass);
+ $certpass);
// set cert password
-
+
$result = curl_exec($curl);
-
+
if (!$result) {
- $resp=new xmlrpcresp(0,
- $xmlrpcerr["curl_fail"],
- $xmlrpcstr["curl_fail"]. ": ".
- curl_error($curl));
+ $resp=new xmlrpcresp(0,
+ $xmlrpcerr["curl_fail"],
+ $xmlrpcstr["curl_fail"]. ": ".
+ curl_error($curl));
} else {
$resp = $msg->parseResponse($result);
}
@@ -521,20 +521,20 @@ class xmlrpcresp {
}
}
- function faultCode() {
- if (isset($this->fn))
- return $this->fn;
- else
- return 0;
- }
+ function faultCode() {
+ if (isset($this->fn))
+ return $this->fn;
+ else
+ return 0;
+ }
function faultString() { return $this->fs; }
function value() { return $this->xv; }
- function serialize() {
- $rs="<methodResponse>\n";
- if ($this->fn) {
- $rs.="<fault>
+ function serialize() {
+ $rs="<methodResponse>\n";
+ if ($this->fn) {
+ $rs.="<fault>
<value>
<struct>
<member>
@@ -548,12 +548,12 @@ class xmlrpcresp {
</struct>
</value>
</fault>";
- } else {
- $rs.="<params>\n<param>\n" . $this->xv->serialize() .
- "</param>\n</params>";
- }
- $rs.="\n</methodResponse>";
- return $rs;
+ } else {
+ $rs.="<params>\n<param>\n" . $this->xv->serialize() .
+ "</param>\n</params>";
+ }
+ $rs.="\n</methodResponse>";
+ return $rs;
}
}
@@ -564,47 +564,47 @@ class xmlrpcmsg {
var $debug=0;
function xmlrpcmsg($meth, $pars=0) {
- $this->methodname=$meth;
- if (is_array($pars) && sizeof($pars)>0) {
- for($i=0; $i<sizeof($pars); $i++)
- $this->addParam($pars[$i]);
- }
+ $this->methodname=$meth;
+ if (is_array($pars) && sizeof($pars)>0) {
+ for($i=0; $i<sizeof($pars); $i++)
+ $this->addParam($pars[$i]);
+ }
}
function xml_header() {
- return "<?xml version=\"1.0\"?>\n<methodCall>\n";
+ return "<?xml version=\"1.0\"?>\n<methodCall>\n";
}
function xml_footer() {
- return "</methodCall>\n";
+ return "</methodCall>\n";
}
function createPayload() {
- $this->payload=$this->xml_header();
- $this->payload.="<methodName>" . $this->methodname . "</methodName>\n";
- // if (sizeof($this->params)) {
- $this->payload.="<params>\n";
- for($i=0; $i<sizeof($this->params); $i++) {
- $p=$this->params[$i];
- $this->payload.="<param>\n" . $p->serialize() .
- "</param>\n";
- }
- $this->payload.="</params>\n";
- // }
- $this->payload.=$this->xml_footer();
- $this->payload=str_replace("\n", "\r\n", $this->payload);
+ $this->payload=$this->xml_header();
+ $this->payload.="<methodName>" . $this->methodname . "</methodName>\n";
+ // if (sizeof($this->params)) {
+ $this->payload.="<params>\n";
+ for($i=0; $i<sizeof($this->params); $i++) {
+ $p=$this->params[$i];
+ $this->payload.="<param>\n" . $p->serialize() .
+ "</param>\n";
+ }
+ $this->payload.="</params>\n";
+ // }
+ $this->payload.=$this->xml_footer();
+ $this->payload=str_replace("\n", "\r\n", $this->payload);
}
function method($meth="") {
- if ($meth!="") {
- $this->methodname=$meth;
- }
- return $this->methodname;
+ if ($meth!="") {
+ $this->methodname=$meth;
+ }
+ return $this->methodname;
}
function serialize() {
- $this->createPayload();
- return $this->payload;
+ $this->createPayload();
+ return $this->payload;
}
function addParam($par) { $this->params[]=$par; }
@@ -612,102 +612,102 @@ class xmlrpcmsg {
function getNumParams() { return sizeof($this->params); }
function parseResponseFile($fp) {
- $ipd="";
+ $ipd="";
- while($data=fread($fp, 32768)) {
- $ipd.=$data;
- }
- return $this->parseResponse($ipd);
+ while($data=fread($fp, 32768)) {
+ $ipd.=$data;
+ }
+ return $this->parseResponse($ipd);
}
function parseResponse($data="") {
- global $_xh,$xmlrpcerr,$xmlrpcstr;
- global $xmlrpc_defencoding;
-
-
- $parser = xml_parser_create($xmlrpc_defencoding);
-
- $_xh[$parser]=array();
-
- $_xh[$parser]['st']="";
- $_xh[$parser]['cm']=0;
- $_xh[$parser]['isf']=0;
- $_xh[$parser]['ac']="";
- $_xh[$parser]['qt']="";
-
- xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
- xml_set_element_handler($parser, "xmlrpc_se", "xmlrpc_ee");
- xml_set_character_data_handler($parser, "xmlrpc_cd");
- xml_set_default_handler($parser, "xmlrpc_dh");
- $xmlrpc_value=new xmlrpcval;
-
- $hdrfnd=0;
- if ($this->debug)
- print "<PRE>---GOT---\n" . htmlspecialchars($data) .
- "\n---END---\n</PRE>";
- if ($data=="") {
- error_log("No response received from server.");
- $r=new xmlrpcresp(0, $xmlrpcerr["no_data"],
- $xmlrpcstr["no_data"]);
- xml_parser_free($parser);
- return $r;
- }
- // see if we got an HTTP 200 OK, else bomb
- // but only do this if we're using the HTTP protocol.
- if (ereg("^HTTP",$data) &&
- !ereg("^HTTP/[0-9\.]+ 200 ", $data)) {
- $errstr= substr($data, 0, strpos($data, "\n")-1);
- error_log("HTTP error, got response: " .$errstr);
- $r=new xmlrpcresp(0, $xmlrpcerr["http_error"],
- $xmlrpcstr["http_error"]. " (" . $errstr . ")");
- xml_parser_free($parser);
- return $r;
- }
- // gotta get rid of headers here
- if ((!$hdrfnd) && ereg("^(.*)\r\n\r\n",$data,$_xh[$parser]['ha'])) {
- $data=ereg_replace("^.*\r\n\r\n", "", $data);
- $hdrfnd=1;
- }
-
- if (!xml_parse($parser, $data, sizeof($data))) {
- // thanks to Peter Kocks <peter.kocks@baygate.com>
- if((xml_get_current_line_number($parser)) == 1)
- $errstr = "XML error at line 1, check URL";
- else
- $errstr = sprintf("XML error: %s at line %d",
- xml_error_string(xml_get_error_code($parser)),
- xml_get_current_line_number($parser));
- error_log($errstr);
- $r=new xmlrpcresp(0, $xmlrpcerr["invalid_return"],
- $xmlrpcstr["invalid_return"]);
- xml_parser_free($parser);
- return $r;
- }
- xml_parser_free($parser);
- if ($this->debug) {
- print "<PRE>---EVALING---[" .
- strlen($_xh[$parser]['st']) . " chars]---\n" .
- htmlspecialchars($_xh[$parser]['st']) . ";\n---END---</PRE>";
- }
- if (strlen($_xh[$parser]['st'])==0) {
- // then something odd has happened
- // and it's time to generate a client side error
- // indicating something odd went on
- $r=new xmlrpcresp(0, $xmlrpcerr["invalid_return"],
- $xmlrpcstr["invalid_return"]);
- } else {
- eval('$v=' . $_xh[$parser]['st'] . '; $allOK=1;');
- if ($_xh[$parser]['isf']) {
- $f=$v->structmem("faultCode");
- $fs=$v->structmem("faultString");
- $r=new xmlrpcresp($v, $f->scalarval(),
- $fs->scalarval());
- } else {
- $r=new xmlrpcresp($v);
- }
- }
- $r->hdrs=split("\r?\n", $_xh[$parser]['ha'][1]);
- return $r;
+ global $_xh,$xmlrpcerr,$xmlrpcstr;
+ global $xmlrpc_defencoding;
+
+
+ $parser = xml_parser_create($xmlrpc_defencoding);
+
+ $_xh[$parser]=array();
+
+ $_xh[$parser]['st']="";
+ $_xh[$parser]['cm']=0;
+ $_xh[$parser]['isf']=0;
+ $_xh[$parser]['ac']="";
+ $_xh[$parser]['qt']="";
+
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
+ xml_set_element_handler($parser, "xmlrpc_se", "xmlrpc_ee");
+ xml_set_character_data_handler($parser, "xmlrpc_cd");
+ xml_set_default_handler($parser, "xmlrpc_dh");
+ $xmlrpc_value=new xmlrpcval;
+
+ $hdrfnd=0;
+ if ($this->debug)
+ print "<PRE>---GOT---\n" . htmlspecialchars($data) .
+ "\n---END---\n</PRE>";
+ if ($data=="") {
+ error_log("No response received from server.");
+ $r=new xmlrpcresp(0, $xmlrpcerr["no_data"],
+ $xmlrpcstr["no_data"]);
+ xml_parser_free($parser);
+ return $r;
+ }
+ // see if we got an HTTP 200 OK, else bomb
+ // but only do this if we're using the HTTP protocol.
+ if (ereg("^HTTP",$data) &&
+ !ereg("^HTTP/[0-9\.]+ 200 ", $data)) {
+ $errstr= substr($data, 0, strpos($data, "\n")-1);
+ error_log("HTTP error, got response: " .$errstr);
+ $r=new xmlrpcresp(0, $xmlrpcerr["http_error"],
+ $xmlrpcstr["http_error"]. " (" . $errstr . ")");
+ xml_parser_free($parser);
+ return $r;
+ }
+ // gotta get rid of headers here
+ if ((!$hdrfnd) && ereg("^(.*)\r\n\r\n",$data,$_xh[$parser]['ha'])) {
+ $data=ereg_replace("^.*\r\n\r\n", "", $data);
+ $hdrfnd=1;
+ }
+
+ if (!xml_parse($parser, $data, sizeof($data))) {
+ // thanks to Peter Kocks <peter.kocks@baygate.com>
+ if((xml_get_current_line_number($parser)) == 1)
+ $errstr = "XML error at line 1, check URL";
+ else
+ $errstr = sprintf("XML error: %s at line %d",
+ xml_error_string(xml_get_error_code($parser)),
+ xml_get_current_line_number($parser));
+ error_log($errstr);
+ $r=new xmlrpcresp(0, $xmlrpcerr["invalid_return"],
+ $xmlrpcstr["invalid_return"]);
+ xml_parser_free($parser);
+ return $r;
+ }
+ xml_parser_free($parser);
+ if ($this->debug) {
+ print "<PRE>---EVALING---[" .
+ strlen($_xh[$parser]['st']) . " chars]---\n" .
+ htmlspecialchars($_xh[$parser]['st']) . ";\n---END---</PRE>";
+ }
+ if (strlen($_xh[$parser]['st'])==0) {
+ // then something odd has happened
+ // and it's time to generate a client side error
+ // indicating something odd went on
+ $r=new xmlrpcresp(0, $xmlrpcerr["invalid_return"],
+ $xmlrpcstr["invalid_return"]);
+ } else {
+ eval('$v=' . $_xh[$parser]['st'] . '; $allOK=1;');
+ if ($_xh[$parser]['isf']) {
+ $f=$v->structmem("faultCode");
+ $fs=$v->structmem("faultString");
+ $r=new xmlrpcresp($v, $f->scalarval(),
+ $fs->scalarval());
+ } else {
+ $r=new xmlrpcresp($v);
+ }
+ }
+ $r->hdrs=split("\r?\n", $_xh[$parser]['ha'][1]);
+ return $r;
}
}
@@ -717,279 +717,279 @@ class xmlrpcval {
var $mytype=0;
function xmlrpcval($val=-1, $type="") {
- global $xmlrpcTypes;
- $this->me=array();
- $this->mytype=0;
- if ($val!=-1 || $type!="") {
- if ($type=="") $type="string";
- if ($xmlrpcTypes[$type]==1) {
- $this->addScalar($val,$type);
- }
- else if ($xmlrpcTypes[$type]==2)
- $this->addArray($val);
- else if ($xmlrpcTypes[$type]==3)
- $this->addStruct($val);
- }
+ global $xmlrpcTypes;
+ $this->me=array();
+ $this->mytype=0;
+ if ($val!=-1 || $type!="") {
+ if ($type=="") $type="string";
+ if ($xmlrpcTypes[$type]==1) {
+ $this->addScalar($val,$type);
+ }
+ else if ($xmlrpcTypes[$type]==2)
+ $this->addArray($val);
+ else if ($xmlrpcTypes[$type]==3)
+ $this->addStruct($val);
+ }
}
function addScalar($val, $type="string") {
- global $xmlrpcTypes, $xmlrpcBoolean;
-
- if ($this->mytype==1) {
- echo "<B>xmlrpcval</B>: scalar can have only one value<BR>";
- return 0;
- }
- $typeof=$xmlrpcTypes[$type];
- if ($typeof!=1) {
- echo "<B>xmlrpcval</B>: not a scalar type (${typeof})<BR>";
- return 0;
- }
-
- if ($type==$xmlrpcBoolean) {
- if (strcasecmp($val,"true")==0 ||
- $val==1 || ($val==true &&
- strcasecmp($val,"false"))) {
- $val=1;
- } else {
- $val=0;
- }
- }
-
- if ($this->mytype==2) {
- // we're adding to an array here
- $ar=$this->me["array"];
- $ar[]=new xmlrpcval($val, $type);
- $this->me["array"]=$ar;
- } else {
- // a scalar, so set the value and remember we're scalar
- $this->me[$type]=$val;
- $this->mytype=$typeof;
- }
- return 1;
+ global $xmlrpcTypes, $xmlrpcBoolean;
+
+ if ($this->mytype==1) {
+ echo "<B>xmlrpcval</B>: scalar can have only one value<BR>";
+ return 0;
+ }
+ $typeof=$xmlrpcTypes[$type];
+ if ($typeof!=1) {
+ echo "<B>xmlrpcval</B>: not a scalar type (${typeof})<BR>";
+ return 0;
+ }
+
+ if ($type==$xmlrpcBoolean) {
+ if (strcasecmp($val,"true")==0 ||
+ $val==1 || ($val==true &&
+ strcasecmp($val,"false"))) {
+ $val=1;
+ } else {
+ $val=0;
+ }
+ }
+
+ if ($this->mytype==2) {
+ // we're adding to an array here
+ $ar=$this->me["array"];
+ $ar[]=new xmlrpcval($val, $type);
+ $this->me["array"]=$ar;
+ } else {
+ // a scalar, so set the value and remember we're scalar
+ $this->me[$type]=$val;
+ $this->mytype=$typeof;
+ }
+ return 1;
}
function addArray($vals) {
- global $xmlrpcTypes;
- if ($this->mytype!=0) {
- echo "<B>xmlrpcval</B>: already initialized as a [" .
- $this->kindOf() . "]<BR>";
- return 0;
- }
-
- $this->mytype=$xmlrpcTypes["array"];
- $this->me["array"]=$vals;
- return 1;
+ global $xmlrpcTypes;
+ if ($this->mytype!=0) {
+ echo "<B>xmlrpcval</B>: already initialized as a [" .
+ $this->kindOf() . "]<BR>";
+ return 0;
+ }
+
+ $this->mytype=$xmlrpcTypes["array"];
+ $this->me["array"]=$vals;
+ return 1;
}
function addStruct($vals) {
- global $xmlrpcTypes;
- if ($this->mytype!=0) {
- echo "<B>xmlrpcval</B>: already initialized as a [" .
- $this->kindOf() . "]<BR>";
- return 0;
- }
- $this->mytype=$xmlrpcTypes["struct"];
- $this->me["struct"]=$vals;
- return 1;
+ global $xmlrpcTypes;
+ if ($this->mytype!=0) {
+ echo "<B>xmlrpcval</B>: already initialized as a [" .
+ $this->kindOf() . "]<BR>";
+ return 0;
+ }
+ $this->mytype=$xmlrpcTypes["struct"];
+ $this->me["struct"]=$vals;
+ return 1;
}
function dump($ar) {
- reset($ar);
- while ( list( $key, $val ) = each( $ar ) ) {
- echo "$key => $val<br>";
- if ($key == 'array')
- while ( list( $key2, $val2 ) = each( $val ) ) {
- echo "-- $key2 => $val2<br>";
- }
- }
+ reset($ar);
+ while ( list( $key, $val ) = each( $ar ) ) {
+ echo "$key => $val<br>";
+ if ($key == 'array')
+ while ( list( $key2, $val2 ) = each( $val ) ) {
+ echo "-- $key2 => $val2<br>";
+ }
+ }
}
function kindOf() {
- switch($this->mytype) {
- case 3:
- return "struct";
- break;
- case 2:
- return "array";
- break;
- case 1:
- return "scalar";
- break;
- default:
- return "undef";
- }
+ switch($this->mytype) {
+ case 3:
+ return "struct";
+ break;
+ case 2:
+ return "array";
+ break;
+ case 1:
+ return "scalar";
+ break;
+ default:
+ return "undef";
+ }
}
function serializedata($typ, $val) {
- $rs="";
- global $xmlrpcTypes, $xmlrpcBase64, $xmlrpcString,
- $xmlrpcBoolean;
- switch($xmlrpcTypes[$typ]) {
- case 3:
- // struct
- $rs.="<struct>\n";
- reset($val);
- while(list($key2, $val2)=each($val)) {
- $rs.="<member><name>${key2}</name>\n";
- $rs.=$this->serializeval($val2);
- $rs.="</member>\n";
- }
- $rs.="</struct>";
- break;
- case 2:
- // array
- $rs.="<array>\n<data>\n";
- for($i=0; $i<sizeof($val); $i++) {
- $rs.=$this->serializeval($val[$i]);
- }
- $rs.="</data>\n</array>";
- break;
- case 1:
- switch ($typ) {
- case $xmlrpcBase64:
- $rs.="<${typ}>" . base64_encode($val) . "</${typ}>";
- break;
- case $xmlrpcBoolean:
- $rs.="<${typ}>" . ($val ? "1" : "0") . "</${typ}>";
- break;
- case $xmlrpcString:
- $rs.="<${typ}>" . htmlspecialchars($val). "</${typ}>";
- break;
- default:
- $rs.="<${typ}>${val}</${typ}>";
- }
- break;
- default:
- break;
- }
- return $rs;
+ $rs="";
+ global $xmlrpcTypes, $xmlrpcBase64, $xmlrpcString,
+ $xmlrpcBoolean;
+ switch($xmlrpcTypes[$typ]) {
+ case 3:
+ // struct
+ $rs.="<struct>\n";
+ reset($val);
+ while(list($key2, $val2)=each($val)) {
+ $rs.="<member><name>${key2}</name>\n";
+ $rs.=$this->serializeval($val2);
+ $rs.="</member>\n";
+ }
+ $rs.="</struct>";
+ break;
+ case 2:
+ // array
+ $rs.="<array>\n<data>\n";
+ for($i=0; $i<sizeof($val); $i++) {
+ $rs.=$this->serializeval($val[$i]);
+ }
+ $rs.="</data>\n</array>";
+ break;
+ case 1:
+ switch ($typ) {
+ case $xmlrpcBase64:
+ $rs.="<${typ}>" . base64_encode($val) . "</${typ}>";
+ break;
+ case $xmlrpcBoolean:
+ $rs.="<${typ}>" . ($val ? "1" : "0") . "</${typ}>";
+ break;
+ case $xmlrpcString:
+ $rs.="<${typ}>" . htmlspecialchars($val). "</${typ}>";
+ break;
+ default:
+ $rs.="<${typ}>${val}</${typ}>";
+ }
+ break;
+ default:
+ break;
+ }
+ return $rs;
}
function serialize() {
- return $this->serializeval($this);
+ return $this->serializeval($this);
}
function serializeval($o) {
- global $xmlrpcTypes;
- $rs="";
- $ar=$o->me;
- reset($ar);
- list($typ, $val) = each($ar);
- $rs.="<value>";
- $rs.=$this->serializedata($typ, $val);
- $rs.="</value>\n";
- return $rs;
+ global $xmlrpcTypes;
+ $rs="";
+ $ar=$o->me;
+ reset($ar);
+ list($typ, $val) = each($ar);
+ $rs.="<value>";
+ $rs.=$this->serializedata($typ, $val);
+ $rs.="</value>\n";
+ return $rs;
}
function structmem($m) {
- $nv=$this->me["struct"][$m];
- return $nv;
+ $nv=$this->me["struct"][$m];
+ return $nv;
+ }
+
+ function structreset() {
+ reset($this->me["struct"]);
}
- function structreset() {
- reset($this->me["struct"]);
- }
-
- function structeach() {
- return each($this->me["struct"]);
- }
+ function structeach() {
+ return each($this->me["struct"]);
+ }
function getval() {
- // UNSTABLE
- global $xmlrpcBoolean, $xmlrpcBase64;
- reset($this->me);
- list($a,$b)=each($this->me);
- // contributed by I Sofer, 2001-03-24
- // add support for nested arrays to scalarval
- // i've created a new method here, so as to
- // preserve back compatibility
-
- if (is_array($b)) {
- foreach ($b as $id => $cont) {
- $b[$id] = $cont->scalarval();
- }
- }
-
- // add support for structures directly encoding php objects
- if (is_object($b)) {
- $t = get_object_vars($b);
- foreach ($t as $id => $cont) {
- $t[$id] = $cont->scalarval();
- }
- foreach ($t as $id => $cont) {
- eval('$b->'.$id.' = $cont;');
- }
- }
- // end contrib
- return $b;
+ // UNSTABLE
+ global $xmlrpcBoolean, $xmlrpcBase64;
+ reset($this->me);
+ list($a,$b)=each($this->me);
+ // contributed by I Sofer, 2001-03-24
+ // add support for nested arrays to scalarval
+ // i've created a new method here, so as to
+ // preserve back compatibility
+
+ if (is_array($b)) {
+ foreach ($b as $id => $cont) {
+ $b[$id] = $cont->scalarval();
+ }
+ }
+
+ // add support for structures directly encoding php objects
+ if (is_object($b)) {
+ $t = get_object_vars($b);
+ foreach ($t as $id => $cont) {
+ $t[$id] = $cont->scalarval();
+ }
+ foreach ($t as $id => $cont) {
+ eval('$b->'.$id.' = $cont;');
+ }
+ }
+ // end contrib
+ return $b;
}
function scalarval() {
- global $xmlrpcBoolean, $xmlrpcBase64;
- reset($this->me);
- list($a,$b)=each($this->me);
- return $b;
+ global $xmlrpcBoolean, $xmlrpcBase64;
+ reset($this->me);
+ list($a,$b)=each($this->me);
+ return $b;
}
function scalartyp() {
- global $xmlrpcI4, $xmlrpcInt;
- reset($this->me);
- list($a,$b)=each($this->me);
- if ($a==$xmlrpcI4)
- $a=$xmlrpcInt;
- return $a;
+ global $xmlrpcI4, $xmlrpcInt;
+ reset($this->me);
+ list($a,$b)=each($this->me);
+ if ($a==$xmlrpcI4)
+ $a=$xmlrpcInt;
+ return $a;
}
function arraymem($m) {
- $nv=$this->me["array"][$m];
- return $nv;
+ $nv=$this->me["array"][$m];
+ return $nv;
}
function arraysize() {
- reset($this->me);
- list($a,$b)=each($this->me);
- return sizeof($b);
+ reset($this->me);
+ list($a,$b)=each($this->me);
+ return sizeof($b);
}
}
// date helpers
function iso8601_encode($timet, $utc=0) {
- // return an ISO8601 encoded string
- // really, timezones ought to be supported
- // but the XML-RPC spec says:
- //
- // "Don't assume a timezone. It should be specified by the server in its
+ // return an ISO8601 encoded string
+ // really, timezones ought to be supported
+ // but the XML-RPC spec says:
+ //
+ // "Don't assume a timezone. It should be specified by the server in its
// documentation what assumptions it makes about timezones."
- //
- // these routines always assume localtime unless
- // $utc is set to 1, in which case UTC is assumed
- // and an adjustment for locale is made when encoding
- if (!$utc) {
- $t=strftime("%Y%m%dT%H:%M:%S", $timet);
- } else {
- if (function_exists("gmstrftime"))
- // gmstrftime doesn't exist in some versions
- // of PHP
- $t=gmstrftime("%Y%m%dT%H:%M:%S", $timet);
- else {
- $t=strftime("%Y%m%dT%H:%M:%S", $timet-date("Z"));
- }
- }
- return $t;
+ //
+ // these routines always assume localtime unless
+ // $utc is set to 1, in which case UTC is assumed
+ // and an adjustment for locale is made when encoding
+ if (!$utc) {
+ $t=strftime("%Y%m%dT%H:%M:%S", $timet);
+ } else {
+ if (function_exists("gmstrftime"))
+ // gmstrftime doesn't exist in some versions
+ // of PHP
+ $t=gmstrftime("%Y%m%dT%H:%M:%S", $timet);
+ else {
+ $t=strftime("%Y%m%dT%H:%M:%S", $timet-date("Z"));
+ }
+ }
+ return $t;
}
function iso8601_decode($idate, $utc=0) {
- // return a timet in the localtime, or UTC
- $t=0;
- if (ereg("([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})",
- $idate, $regs)) {
- if ($utc) {
- $t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
- } else {
- $t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
- }
- }
- return $t;
+ // return a timet in the localtime, or UTC
+ $t=0;
+ if (ereg("([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})",
+ $idate, $regs)) {
+ if ($utc) {
+ $t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
+ } else {
+ $t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
+ }
+ }
+ return $t;
}
/****************************************************************
@@ -1011,7 +1011,7 @@ function xmlrpc_decode($xmlrpc_val) {
for($i = 0; $i < $size; $i++) {
$arr[]=xmlrpc_decode($xmlrpc_val->arraymem($i));
}
- return $arr;
+ return $arr;
}
else if($kind == "struct") {
$xmlrpc_val->structreset();
@@ -1073,11 +1073,11 @@ function xmlrpc_encode($php_val) {
// </G_Giunta_2001-02-29>
case "unknown type":
default:
- // giancarlo pinerolo <ping@alt.it>
- // it has to return
+ // giancarlo pinerolo <ping@alt.it>
+ // it has to return
// an empty object in case (which is already
- // at this point), not a boolean.
- break;
+ // at this point), not a boolean.
+ break;
}
return $xmlrpc_val;
}
diff --git a/includes/xmlrpcs.inc b/includes/xmlrpcs.inc
index 4425946e8..8c43b7634 100644
--- a/includes/xmlrpcs.inc
+++ b/includes/xmlrpcs.inc
@@ -39,265 +39,265 @@
// requires: xmlrpc.inc
// listMethods: either a string, or nothing
-$_xmlrpcs_listMethods_sig=array(array($xmlrpcArray, $xmlrpcString),
- array($xmlrpcArray));
+$_xmlrpcs_listMethods_sig=array(array($xmlrpcArray, $xmlrpcString),
+ array($xmlrpcArray));
$_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch';
function _xmlrpcs_listMethods($server, $m) {
- global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
- $v=new xmlrpcval();
- $dmap=$server->dmap;
- $outAr=array();
- for(reset($dmap); list($key, $val)=each($dmap); ) {
- $outAr[]=new xmlrpcval($key, "string");
- }
- $dmap=$_xmlrpcs_dmap;
- for(reset($dmap); list($key, $val)=each($dmap); ) {
- $outAr[]=new xmlrpcval($key, "string");
- }
- $v->addArray($outAr);
- return new xmlrpcresp($v);
+ global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
+ $v=new xmlrpcval();
+ $dmap=$server->dmap;
+ $outAr=array();
+ for(reset($dmap); list($key, $val)=each($dmap); ) {
+ $outAr[]=new xmlrpcval($key, "string");
+ }
+ $dmap=$_xmlrpcs_dmap;
+ for(reset($dmap); list($key, $val)=each($dmap); ) {
+ $outAr[]=new xmlrpcval($key, "string");
+ }
+ $v->addArray($outAr);
+ return new xmlrpcresp($v);
}
$_xmlrpcs_methodSignature_sig=array(array($xmlrpcArray, $xmlrpcString));
$_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
function _xmlrpcs_methodSignature($server, $m) {
- global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
+ global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
- $methName=$m->getParam(0);
- $methName=$methName->scalarval();
- if (ereg("^system\.", $methName)) {
- $dmap=$_xmlrpcs_dmap; $sysCall=1;
- } else {
- $dmap=$server->dmap; $sysCall=0;
- }
- // print "<!-- ${methName} -->\n";
- if (isset($dmap[$methName])) {
- if ($dmap[$methName]["signature"]) {
- $sigs=array();
- $thesigs=$dmap[$methName]["signature"];
- for($i=0; $i<sizeof($thesigs); $i++) {
- $cursig=array();
- $inSig=$thesigs[$i];
- for($j=0; $j<sizeof($inSig); $j++) {
- $cursig[]=new xmlrpcval($inSig[$j], "string");
- }
- $sigs[]=new xmlrpcval($cursig, "array");
- }
- $r=new xmlrpcresp(new xmlrpcval($sigs, "array"));
- } else {
- $r=new xmlrpcresp(new xmlrpcval("undef", "string"));
- }
- } else {
- $r=new xmlrpcresp(0,
- $xmlrpcerr["introspect_unknown"],
- $xmlrpcstr["introspect_unknown"]);
- }
- return $r;
+ $methName=$m->getParam(0);
+ $methName=$methName->scalarval();
+ if (ereg("^system\.", $methName)) {
+ $dmap=$_xmlrpcs_dmap; $sysCall=1;
+ } else {
+ $dmap=$server->dmap; $sysCall=0;
+ }
+ // print "<!-- ${methName} -->\n";
+ if (isset($dmap[$methName])) {
+ if ($dmap[$methName]["signature"]) {
+ $sigs=array();
+ $thesigs=$dmap[$methName]["signature"];
+ for($i=0; $i<sizeof($thesigs); $i++) {
+ $cursig=array();
+ $inSig=$thesigs[$i];
+ for($j=0; $j<sizeof($inSig); $j++) {
+ $cursig[]=new xmlrpcval($inSig[$j], "string");
+ }
+ $sigs[]=new xmlrpcval($cursig, "array");
+ }
+ $r=new xmlrpcresp(new xmlrpcval($sigs, "array"));
+ } else {
+ $r=new xmlrpcresp(new xmlrpcval("undef", "string"));
+ }
+ } else {
+ $r=new xmlrpcresp(0,
+ $xmlrpcerr["introspect_unknown"],
+ $xmlrpcstr["introspect_unknown"]);
+ }
+ return $r;
}
$_xmlrpcs_methodHelp_sig=array(array($xmlrpcString, $xmlrpcString));
$_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string';
function _xmlrpcs_methodHelp($server, $m) {
- global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
+ global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
- $methName=$m->getParam(0);
- $methName=$methName->scalarval();
- if (ereg("^system\.", $methName)) {
- $dmap=$_xmlrpcs_dmap; $sysCall=1;
- } else {
- $dmap=$server->dmap; $sysCall=0;
- }
- // print "<!-- ${methName} -->\n";
- if (isset($dmap[$methName])) {
- if ($dmap[$methName]["docstring"]) {
- $r=new xmlrpcresp(new xmlrpcval($dmap[$methName]["docstring"]),
- "string");
- } else {
- $r=new xmlrpcresp(new xmlrpcval("", "string"));
- }
- } else {
- $r=new xmlrpcresp(0,
- $xmlrpcerr["introspect_unknown"],
- $xmlrpcstr["introspect_unknown"]);
- }
- return $r;
+ $methName=$m->getParam(0);
+ $methName=$methName->scalarval();
+ if (ereg("^system\.", $methName)) {
+ $dmap=$_xmlrpcs_dmap; $sysCall=1;
+ } else {
+ $dmap=$server->dmap; $sysCall=0;
+ }
+ // print "<!-- ${methName} -->\n";
+ if (isset($dmap[$methName])) {
+ if ($dmap[$methName]["docstring"]) {
+ $r=new xmlrpcresp(new xmlrpcval($dmap[$methName]["docstring"]),
+ "string");
+ } else {
+ $r=new xmlrpcresp(new xmlrpcval("", "string"));
+ }
+ } else {
+ $r=new xmlrpcresp(0,
+ $xmlrpcerr["introspect_unknown"],
+ $xmlrpcstr["introspect_unknown"]);
+ }
+ return $r;
}
$_xmlrpcs_dmap=array(
- "system.listMethods" =>
- array("function" => "_xmlrpcs_listMethods",
- "signature" => $_xmlrpcs_listMethods_sig,
- "docstring" => $_xmlrpcs_listMethods_doc),
- "system.methodHelp" =>
- array("function" => "_xmlrpcs_methodHelp",
- "signature" => $_xmlrpcs_methodHelp_sig,
- "docstring" => $_xmlrpcs_methodHelp_doc),
- "system.methodSignature" =>
- array("function" => "_xmlrpcs_methodSignature",
- "signature" => $_xmlrpcs_methodSignature_sig,
- "docstring" => $_xmlrpcs_methodSignature_doc)
- );
+ "system.listMethods" =>
+ array("function" => "_xmlrpcs_listMethods",
+ "signature" => $_xmlrpcs_listMethods_sig,
+ "docstring" => $_xmlrpcs_listMethods_doc),
+ "system.methodHelp" =>
+ array("function" => "_xmlrpcs_methodHelp",
+ "signature" => $_xmlrpcs_methodHelp_sig,
+ "docstring" => $_xmlrpcs_methodHelp_doc),
+ "system.methodSignature" =>
+ array("function" => "_xmlrpcs_methodSignature",
+ "signature" => $_xmlrpcs_methodSignature_sig,
+ "docstring" => $_xmlrpcs_methodSignature_doc)
+ );
$_xmlrpc_debuginfo="";
function xmlrpc_debugmsg($m) {
- global $_xmlrpc_debuginfo;
- $_xmlrpc_debuginfo=$_xmlrpc_debuginfo . $m . "\n";
+ global $_xmlrpc_debuginfo;
+ $_xmlrpc_debuginfo=$_xmlrpc_debuginfo . $m . "\n";
}
class xmlrpc_server {
var $dmap=array();
function xmlrpc_server($dispMap, $serviceNow=1) {
- global $HTTP_RAW_POST_DATA;
- // dispMap is a despatch array of methods
- // mapped to function names and signatures
- // if a method
- // doesn't appear in the map then an unknown
- // method error is generated
- $this->dmap=$dispMap;
- if ($serviceNow) {
- $this->service();
- }
+ global $HTTP_RAW_POST_DATA;
+ // dispMap is a despatch array of methods
+ // mapped to function names and signatures
+ // if a method
+ // doesn't appear in the map then an unknown
+ // method error is generated
+ $this->dmap=$dispMap;
+ if ($serviceNow) {
+ $this->service();
+ }
}
- function serializeDebug() {
- global $_xmlrpc_debuginfo;
- if ($_xmlrpc_debuginfo!="")
- return "<!-- DEBUG INFO:\n\n" .
- $_xmlrpc_debuginfo . "\n-->\n";
- else
- return "";
- }
+ function serializeDebug() {
+ global $_xmlrpc_debuginfo;
+ if ($_xmlrpc_debuginfo!="")
+ return "<!-- DEBUG INFO:\n\n" .
+ $_xmlrpc_debuginfo . "\n-->\n";
+ else
+ return "";
+ }
- function service() {
- $r=$this->parseRequest();
- $payload="<?xml version=\"1.0\"?>\n" .
- $this->serializeDebug() .
- $r->serialize();
- Header("Content-type: text/xml\r\nContent-length: " .
- strlen($payload));
- print $payload;
- }
+ function service() {
+ $r=$this->parseRequest();
+ $payload="<?xml version=\"1.0\"?>\n" .
+ $this->serializeDebug() .
+ $r->serialize();
+ Header("Content-type: text/xml\r\nContent-length: " .
+ strlen($payload));
+ print $payload;
+ }
- function verifySignature($in, $sig) {
- for($i=0; $i<sizeof($sig); $i++) {
- // check each possible signature in turn
- $cursig=$sig[$i];
- if (sizeof($cursig)==$in->getNumParams()+1) {
- $itsOK=1;
- for($n=0; $n<$in->getNumParams(); $n++) {
- $p=$in->getParam($n);
- // print "<!-- $p -->\n";
- if ($p->kindOf() == "scalar") {
- $pt=$p->scalartyp();
- } else {
- $pt=$p->kindOf();
- }
- // $n+1 as first type of sig is return type
- if ($pt != $cursig[$n+1]) {
- $itsOK=0;
- $pno=$n+1; $wanted=$cursig[$n+1]; $got=$pt;
- break;
- }
- }
- if ($itsOK)
- return array(1);
- }
- }
- return array(0, "Wanted ${wanted}, got ${got} at param ${pno})");
- }
+ function verifySignature($in, $sig) {
+ for($i=0; $i<sizeof($sig); $i++) {
+ // check each possible signature in turn
+ $cursig=$sig[$i];
+ if (sizeof($cursig)==$in->getNumParams()+1) {
+ $itsOK=1;
+ for($n=0; $n<$in->getNumParams(); $n++) {
+ $p=$in->getParam($n);
+ // print "<!-- $p -->\n";
+ if ($p->kindOf() == "scalar") {
+ $pt=$p->scalartyp();
+ } else {
+ $pt=$p->kindOf();
+ }
+ // $n+1 as first type of sig is return type
+ if ($pt != $cursig[$n+1]) {
+ $itsOK=0;
+ $pno=$n+1; $wanted=$cursig[$n+1]; $got=$pt;
+ break;
+ }
+ }
+ if ($itsOK)
+ return array(1);
+ }
+ }
+ return array(0, "Wanted ${wanted}, got ${got} at param ${pno})");
+ }
function parseRequest($data="") {
- global $_xh,$HTTP_RAW_POST_DATA;
- global $xmlrpcerr, $xmlrpcstr, $xmlrpcerrxml, $xmlrpc_defencoding,
- $_xmlrpcs_dmap;
+ global $_xh,$HTTP_RAW_POST_DATA;
+ global $xmlrpcerr, $xmlrpcstr, $xmlrpcerrxml, $xmlrpc_defencoding,
+ $_xmlrpcs_dmap;
-
- if ($data=="") {
- $data=$HTTP_RAW_POST_DATA;
- }
- $parser = xml_parser_create($xmlrpc_defencoding);
- $_xh[$parser]=array();
- $_xh[$parser]['st']="";
- $_xh[$parser]['cm']=0;
- $_xh[$parser]['isf']=0;
- $_xh[$parser]['params']=array();
- $_xh[$parser]['method']="";
+ if ($data=="") {
+ $data=$HTTP_RAW_POST_DATA;
+ }
+ $parser = xml_parser_create($xmlrpc_defencoding);
+
+ $_xh[$parser]=array();
+ $_xh[$parser]['st']="";
+ $_xh[$parser]['cm']=0;
+ $_xh[$parser]['isf']=0;
+ $_xh[$parser]['params']=array();
+ $_xh[$parser]['method']="";
- // decompose incoming XML into request structure
+ // decompose incoming XML into request structure
- xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
- xml_set_element_handler($parser, "xmlrpc_se", "xmlrpc_ee");
- xml_set_character_data_handler($parser, "xmlrpc_cd");
- xml_set_default_handler($parser, "xmlrpc_dh");
- if (!xml_parse($parser, $data, 1)) {
- // return XML error as a faultCode
- $r=new xmlrpcresp(0,
- $xmlrpcerrxml+xml_get_error_code($parser),
- sprintf("XML error: %s at line %d",
- xml_error_string(xml_get_error_code($parser)),
- xml_get_current_line_number($parser)));
- xml_parser_free($parser);
- } else {
- xml_parser_free($parser);
- $m=new xmlrpcmsg($_xh[$parser]['method']);
- // now add parameters in
- for($i=0; $i<sizeof($_xh[$parser]['params']); $i++) {
- //print "<!-- " . $_xh[$parser]['params'][$i]. "-->\n";
- $plist.="$i - " . $_xh[$parser]['params'][$i]. " \n";
- eval('$m->addParam(' . $_xh[$parser]['params'][$i]. ");");
- }
- // uncomment this to really see what the server's getting!
- // xmlrpc_debugmsg($plist);
- // now to deal with the method
- $methName=$_xh[$parser]['method'];
- if (ereg("^system\.", $methName)) {
- $dmap=$_xmlrpcs_dmap; $sysCall=1;
- } else {
- $dmap=$this->dmap; $sysCall=0;
- }
- if (isset($dmap[$methName]['function'])) {
- // dispatch if exists
- if (isset($dmap[$methName]['signature'])) {
- $sr=$this->verifySignature($m,
- $dmap[$methName]['signature'] );
- }
- if ( (!isset($dmap[$methName]['signature']))
- || $sr[0]) {
- // if no signature or correct signature
- if ($sysCall) {
- eval('$r=' . $dmap[$methName]['function'] .
- '($this, $m);');
- } else {
- eval('$r=' . $dmap[$methName]['function'] .
- '($m);');
- }
- } else {
- $r=new xmlrpcresp(0,
- $xmlrpcerr["incorrect_params"],
- $xmlrpcstr["incorrect_params"].": ". $sr[1]);
- }
- } else {
- // else prepare error response
- $r=new xmlrpcresp(0,
- $xmlrpcerr["unknown_method"],
- $xmlrpcstr["unknown_method"]);
- }
- }
- return $r;
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
+ xml_set_element_handler($parser, "xmlrpc_se", "xmlrpc_ee");
+ xml_set_character_data_handler($parser, "xmlrpc_cd");
+ xml_set_default_handler($parser, "xmlrpc_dh");
+ if (!xml_parse($parser, $data, 1)) {
+ // return XML error as a faultCode
+ $r=new xmlrpcresp(0,
+ $xmlrpcerrxml+xml_get_error_code($parser),
+ sprintf("XML error: %s at line %d",
+ xml_error_string(xml_get_error_code($parser)),
+ xml_get_current_line_number($parser)));
+ xml_parser_free($parser);
+ } else {
+ xml_parser_free($parser);
+ $m=new xmlrpcmsg($_xh[$parser]['method']);
+ // now add parameters in
+ for($i=0; $i<sizeof($_xh[$parser]['params']); $i++) {
+ //print "<!-- " . $_xh[$parser]['params'][$i]. "-->\n";
+ $plist.="$i - " . $_xh[$parser]['params'][$i]. " \n";
+ eval('$m->addParam(' . $_xh[$parser]['params'][$i]. ");");
+ }
+ // uncomment this to really see what the server's getting!
+ // xmlrpc_debugmsg($plist);
+ // now to deal with the method
+ $methName=$_xh[$parser]['method'];
+ if (ereg("^system\.", $methName)) {
+ $dmap=$_xmlrpcs_dmap; $sysCall=1;
+ } else {
+ $dmap=$this->dmap; $sysCall=0;
+ }
+ if (isset($dmap[$methName]['function'])) {
+ // dispatch if exists
+ if (isset($dmap[$methName]['signature'])) {
+ $sr=$this->verifySignature($m,
+ $dmap[$methName]['signature'] );
+ }
+ if ( (!isset($dmap[$methName]['signature']))
+ || $sr[0]) {
+ // if no signature or correct signature
+ if ($sysCall) {
+ eval('$r=' . $dmap[$methName]['function'] .
+ '($this, $m);');
+ } else {
+ eval('$r=' . $dmap[$methName]['function'] .
+ '($m);');
+ }
+ } else {
+ $r=new xmlrpcresp(0,
+ $xmlrpcerr["incorrect_params"],
+ $xmlrpcstr["incorrect_params"].": ". $sr[1]);
+ }
+ } else {
+ // else prepare error response
+ $r=new xmlrpcresp(0,
+ $xmlrpcerr["unknown_method"],
+ $xmlrpcstr["unknown_method"]);
+ }
+ }
+ return $r;
}
function echoInput() {
- global $HTTP_RAW_POST_DATA;
+ global $HTTP_RAW_POST_DATA;
- // a debugging routine: just echos back the input
- // packet as a string value
+ // a debugging routine: just echos back the input
+ // packet as a string value
- $r=new xmlrpcresp;
- $r->xv=new xmlrpcval( "'Aha said I: '" . $HTTP_RAW_POST_DATA, "string");
- print $r->serialize();
+ $r=new xmlrpcresp;
+ $r->xv=new xmlrpcval( "'Aha said I: '" . $HTTP_RAW_POST_DATA, "string");
+ print $r->serialize();
}
}
diff --git a/index.php b/index.php
index 6eb0eb02f..1feea7cfb 100644
--- a/index.php
+++ b/index.php
@@ -4,14 +4,9 @@ include_once "includes/common.inc";
page_header();
-
-//$theme->header();
-
$function = variable_get("site_frontpage", "node") ."_page";
$function();
-//$theme->footer();
-
page_footer();
?>
diff --git a/modules/blog.module b/modules/blog.module
index a7ca6cea0..8688ee5ac 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -14,6 +14,15 @@ function blog_help() {
<?php
}
+function blog_cron() {
+ $result = db_query("SELECT n.nid, n.timestamp, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM node n LEFT JOIN moderate m ON m.nid = n.nid WHERE n.type = 'blog' AND n.status = '". node_status("posted") ."' GROUP BY n.nid ORDER BY n.timestamp DESC LIMIT 30");
+ while ($node = db_fetch_object($result)) {
+ if ($node->score > 3 && $node->votes > 4) {
+ db_query("UPDATE node SET promote = '1' WHERE nid = '$node->nid'");
+ }
+ }
+}
+
function blog_perm() {
return array("administer blogs", "access blogs", "post blogs");
}
@@ -358,7 +367,7 @@ function blog_search($keys) {
$result = db_query("SELECT n.*, b.* FROM blog b LEFT JOIN node n ON n.nid = b.nid AND n.lid = b.lid WHERE (n.title LIKE '%$keys%' OR b.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
while ($blog = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($blog->title), "link" => ($PHP_SELF == "/admin.php" ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->name, "date" => $blog->timestamp);
+ $find[$i++] = array("title" => check_output($blog->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->name, "date" => $blog->timestamp);
}
return $find;
}
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index a7ca6cea0..8688ee5ac 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -14,6 +14,15 @@ function blog_help() {
<?php
}
+function blog_cron() {
+ $result = db_query("SELECT n.nid, n.timestamp, SUM(m.score) / COUNT(m.cid) AS score, COUNT(m.cid) AS votes FROM node n LEFT JOIN moderate m ON m.nid = n.nid WHERE n.type = 'blog' AND n.status = '". node_status("posted") ."' GROUP BY n.nid ORDER BY n.timestamp DESC LIMIT 30");
+ while ($node = db_fetch_object($result)) {
+ if ($node->score > 3 && $node->votes > 4) {
+ db_query("UPDATE node SET promote = '1' WHERE nid = '$node->nid'");
+ }
+ }
+}
+
function blog_perm() {
return array("administer blogs", "access blogs", "post blogs");
}
@@ -358,7 +367,7 @@ function blog_search($keys) {
$result = db_query("SELECT n.*, b.* FROM blog b LEFT JOIN node n ON n.nid = b.nid AND n.lid = b.lid WHERE (n.title LIKE '%$keys%' OR b.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
while ($blog = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($blog->title), "link" => ($PHP_SELF == "/admin.php" ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->name, "date" => $blog->timestamp);
+ $find[$i++] = array("title" => check_output($blog->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->name, "date" => $blog->timestamp);
}
return $find;
}
diff --git a/modules/comment.module b/modules/comment.module
index 448f1ff32..d420e5b69 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -4,7 +4,7 @@ function comment_search($keys) {
global $PHP_SELF;
$result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20");
while ($comment = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($comment->subject), "link" => ($PHP_SELF == "/admin.php" ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp);
+ $find[$i++] = array("title" => check_output($comment->subject), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp);
}
return $find;
}
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 448f1ff32..d420e5b69 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -4,7 +4,7 @@ function comment_search($keys) {
global $PHP_SELF;
$result = db_query("SELECT c.*, u.name FROM comments c LEFT JOIN user u ON c.author = u.uid WHERE c.subject LIKE '%$keys%' OR c.comment LIKE '%$keys%' ORDER BY c.timestamp DESC LIMIT 20");
while ($comment = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($comment->subject), "link" => ($PHP_SELF == "/admin.php" ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp);
+ $find[$i++] = array("title" => check_output($comment->subject), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=comment&op=edit&id=$comment->cid" : "node.php?id=$comment->lid&cid=$comment->cid"), "user" => $comment->name, "date" => $comment->timestamp);
}
return $find;
}
diff --git a/modules/node.module b/modules/node.module
index aae7afdaf..e856a17ec 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -188,16 +188,16 @@ function node_save_content($edit, $type) {
function node_delete($id) {
return (node_del(array("nid" => $id)) ? "node has been deleted." : "failed to delete node.");
}
-
+
function node_delete_confirmation($id) {
-
+
$node = node_get_object(array("nid" => $id));
$form .= form_item(t("Do you really want to delete this node"), check_output($node->title));
$form .= form_submit("Delete node");
$form .= form_submit("Keep node");
-
+
return form("admin.php?mod=node&id=$node->nid", $form);
}
diff --git a/modules/node/node.module b/modules/node/node.module
index aae7afdaf..e856a17ec 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -188,16 +188,16 @@ function node_save_content($edit, $type) {
function node_delete($id) {
return (node_del(array("nid" => $id)) ? "node has been deleted." : "failed to delete node.");
}
-
+
function node_delete_confirmation($id) {
-
+
$node = node_get_object(array("nid" => $id));
$form .= form_item(t("Do you really want to delete this node"), check_output($node->title));
$form .= form_submit("Delete node");
$form .= form_submit("Keep node");
-
+
return form("admin.php?mod=node&id=$node->nid", $form);
}
diff --git a/modules/poll.module b/modules/poll.module
index 579a43314..bd7d58f5a 100644
--- a/modules/poll.module
+++ b/modules/poll.module
@@ -78,7 +78,7 @@ function poll_search($keys) {
global $PHP_SELF, $status;
$result = db_query("SELECT n.*, p.* FROM poll p LEFT JOIN node n ON n.nid = p.nid AND n.lid = p.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%') LIMIT 20");
while ($poll = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($poll->title), "link" => ($PHP_SELF == "/admin.php" ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->name, "date" => $poll->timestamp);
+ $find[$i++] = array("title" => check_output($poll->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->name, "date" => $poll->timestamp);
}
return $find;
}
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 579a43314..bd7d58f5a 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -78,7 +78,7 @@ function poll_search($keys) {
global $PHP_SELF, $status;
$result = db_query("SELECT n.*, p.* FROM poll p LEFT JOIN node n ON n.nid = p.nid AND n.lid = p.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%') LIMIT 20");
while ($poll = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($poll->title), "link" => ($PHP_SELF == "/admin.php" ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->name, "date" => $poll->timestamp);
+ $find[$i++] = array("title" => check_output($poll->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=poll&op=edit&id=$poll->nid" : "node.php?id=$poll->nid"), "user" => $poll->name, "date" => $poll->timestamp);
}
return $find;
}
diff --git a/modules/story.module b/modules/story.module
index 4fbd630fa..8a7497a65 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -16,7 +16,7 @@ function story_search($keys) {
global $PHP_SELF, $status;
$result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
while ($story = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($story->title), "link" => ($PHP_SELF == "/admin.php" ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "date" => $story->timestamp);
+ $find[$i++] = array("title" => check_output($story->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "date" => $story->timestamp);
}
return $find;
}
diff --git a/modules/story/story.module b/modules/story/story.module
index 4fbd630fa..8a7497a65 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -16,7 +16,7 @@ function story_search($keys) {
global $PHP_SELF, $status;
$result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
while ($story = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($story->title), "link" => ($PHP_SELF == "/admin.php" ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "date" => $story->timestamp);
+ $find[$i++] = array("title" => check_output($story->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "date" => $story->timestamp);
}
return $find;
}
diff --git a/modules/tracker.module b/modules/tracker.module
index 46d2fee48..21ad284a1 100644
--- a/modules/tracker.module
+++ b/modules/tracker.module
@@ -30,7 +30,7 @@ function tracker_comments($id = 0) {
$output .= "<ul>";
while ($comment = db_fetch_object($cresult)) {
- $output .= " <li><a href=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</a> (". t("replies") .": ". comment_num_replies($comment->cid) .", ". t("votes") .": $comment->votes, ". t("score") .": ". comment_score($comment) .")</li>\n";
+ $output .= " <li><a href=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</a> (". t("replies") .": ". comment_num_replies($comment->cid) .")</li>\n";
}
$output .= " </ul>\n";
}
diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module
index 46d2fee48..21ad284a1 100644
--- a/modules/tracker/tracker.module
+++ b/modules/tracker/tracker.module
@@ -30,7 +30,7 @@ function tracker_comments($id = 0) {
$output .= "<ul>";
while ($comment = db_fetch_object($cresult)) {
- $output .= " <li><a href=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</a> (". t("replies") .": ". comment_num_replies($comment->cid) .", ". t("votes") .": $comment->votes, ". t("score") .": ". comment_score($comment) .")</li>\n";
+ $output .= " <li><a href=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</a> (". t("replies") .": ". comment_num_replies($comment->cid) .")</li>\n";
}
$output .= " </ul>\n";
}
diff --git a/modules/user.module b/modules/user.module
index 87133ee06..ee5754b7b 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -219,7 +219,7 @@ function user_search($keys) {
global $PHP_SELF;
$result = db_query("SELECT * FROM user WHERE name LIKE '%$keys%' LIMIT 20");
while ($account = db_fetch_object($result)) {
- $find[$i++] = array("title" => $account->name, "link" => ($PHP_SELF == "/admin.php" ? "admin.php?mod=user&op=edit&id=$account->uid" : "module.php?mod=user&op=view&id=$account->uid"), "user" => $account->name);
+ $find[$i++] = array("title" => $account->name, "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=user&op=edit&id=$account->uid" : "module.php?mod=user&op=view&id=$account->uid"), "user" => $account->name);
}
return $find;
}
diff --git a/modules/user/user.module b/modules/user/user.module
index 87133ee06..ee5754b7b 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -219,7 +219,7 @@ function user_search($keys) {
global $PHP_SELF;
$result = db_query("SELECT * FROM user WHERE name LIKE '%$keys%' LIMIT 20");
while ($account = db_fetch_object($result)) {
- $find[$i++] = array("title" => $account->name, "link" => ($PHP_SELF == "/admin.php" ? "admin.php?mod=user&op=edit&id=$account->uid" : "module.php?mod=user&op=view&id=$account->uid"), "user" => $account->name);
+ $find[$i++] = array("title" => $account->name, "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=user&op=edit&id=$account->uid" : "module.php?mod=user&op=view&id=$account->uid"), "user" => $account->name);
}
return $find;
}
diff --git a/node.php b/node.php
index fa066e6b8..2e0c9dc89 100644
--- a/node.php
+++ b/node.php
@@ -40,8 +40,9 @@ function node_render($node) {
comment_render($id, $cid);
$theme->footer();
break;
- case t("Moderate comments"):
- comment_moderate($moderate);
+ case t("Update ratings"):
+ node_moderate($moderate["node"]);
+ comment_moderate($moderate["comment"]);
$theme->header();
node_view($node);
comment_render($id, $cid);
diff --git a/updates/3.00-to-x.xx.sql b/updates/3.00-to-x.xx.sql
index 2340b6328..4beb5d8b8 100644
--- a/updates/3.00-to-x.xx.sql
+++ b/updates/3.00-to-x.xx.sql
@@ -32,3 +32,17 @@ CREATE TABLE access (
UNIQUE mask (mask),
PRIMARY KEY (aid)
);
+
+CREATE TABLE moderate (
+ cid int(10) DEFAULT '0' NOT NULL,
+ nid int(10) DEFAULT '0' NOT NULL,
+ uid int(10) DEFAULT '0' NOT NULL,
+ score int(2) DEFAULT '0' NOT NULL,
+ timestamp int(11) DEFAULT '0' NOT NULL,
+ INDEX (cid),
+ INDEX (nid)
+);
+
+ALTER TABLE comments DROP score;
+ALTER TABLE comments DROP votes;
+ALTER TABLE comments DROP users;