- a batch of updates, including some experimental changes to the moderation
of comments and nodes.4.0.x
parent
6cde632962
commit
4a0e498f52
modules
updates
|
@ -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 .= " ";
|
||||
}
|
||||
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";
|
||||
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) ."\"> </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>";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,22 +8,6 @@ $db_user = "drop"; // username
|
|||
$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:
|
||||
#
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
1208
includes/xmlrpc.inc
1208
includes/xmlrpc.inc
File diff suppressed because it is too large
Load Diff
|
@ -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);
|
||||
|
||||
// decompose incoming XML into request structure
|
||||
$_xh[$parser]=array();
|
||||
$_xh[$parser]['st']="";
|
||||
$_xh[$parser]['cm']=0;
|
||||
$_xh[$parser]['isf']=0;
|
||||
$_xh[$parser]['params']=array();
|
||||
$_xh[$parser]['method']="";
|
||||
|
||||
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;
|
||||
// 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;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
?>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
5
node.php
5
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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue