145 lines
6.2 KiB
Plaintext
145 lines
6.2 KiB
Plaintext
<?php
|
|
|
|
class Node {
|
|
function Node($node) {
|
|
global $user;
|
|
$this->userid = $node[userid] ? $node[userid] : $user->userid;
|
|
$this->title = $node[title];
|
|
$this->timestamp = $node[timestamp] ? $node[timestamp] : time();
|
|
$this->cid = $node[cid];
|
|
$this->tid = $node[tid];
|
|
}
|
|
}
|
|
|
|
function node_conf_filters() {
|
|
$output .= form_select(t("Strip HTML tags"), "filter_html", variable_get("filter_html", 0), array("Disabled", "Enabled"), t("Strip HTML and PHP tags."));
|
|
$output .= form_textfield(t("Allowed HTML tags"), "allowed_html", variable_get("allowed_html", "<A><B><BLOCKQUOTE><DD><DL><DT><I><LI><OL><U><UL>"), 64, 128, t("If enabled, optionally specify tags which should not be stripped. 'STYLE' attributes, 'ON' attributes and unclosed tags are always stripped."));
|
|
$output .= "<HR>";
|
|
$output .= form_select(t("Strip link tags"), "filter_link", variable_get("filter_link", 0), array("Disabled", "Enabled"), t("Substitute special [[link]] tags."));
|
|
$output .= "<HR>";
|
|
return $output;
|
|
}
|
|
|
|
function node_filter_html($text) {
|
|
$text = eregi_replace("([ \f\r\t\n\'\"])style=[^>]+", "\\1", $text);
|
|
$text = eregi_replace("([ \f\r\t\n\'\"])on[a-z]+=[^>]+", "\\1", $text);
|
|
$text = strip_tags($text, variable_get("allowed_html", ""));
|
|
return $text;
|
|
}
|
|
|
|
function node_filter_link($text) {
|
|
$src = array("/\[\[(([^\|]*?)(\|([^\|]*?))?)\]\]/e"); // [link|description]
|
|
$dst = array(format_tag('\\2', '\\4')); // [link|description]
|
|
return preg_replace($src, $dst, $text);
|
|
}
|
|
|
|
function node_filter($text) {
|
|
if (variable_get("filter_html", 0)) $text = node_filter_html($text);
|
|
if (variable_get("filter_link", 0)) $text = node_filter_link($text);
|
|
return $text;
|
|
}
|
|
|
|
function node_overview($query = array()) {
|
|
global $user;
|
|
|
|
$result = db_query("SELECT n.*, u.userid, c.name AS category FROM node n LEFT JOIN users u ON n.author = u.id LEFT JOIN category c ON n.cid = c.cid $query[1] LIMIT 50");
|
|
|
|
$output .= status($query[0]);
|
|
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
|
|
$output .= " <TR><TH>title</TH><TH>category</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
|
|
while ($node = db_fetch_object($result)) {
|
|
$output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". check_output($node->category ? $node->category : $node->type) ."</TD><TD>". node_status($node, $node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</A>" : "edit node") ."</TD><TD>". (user_access($user, $node->type) ? "<A HREF=\"admin.php?mod=$node->type&op=edit&id=$node->nid\">edit $node->type</A>" : "edit $node->type") ."</TD></TR>\n";
|
|
}
|
|
$output .= "</TABLE>\n";
|
|
|
|
return $output;
|
|
}
|
|
|
|
function node_admin_view($id) {
|
|
$node = node_get_object(array("nid" => $id));
|
|
|
|
$form .= form_item("Title", check_output($node->title));
|
|
$form .= form_item("Author", format_username($node->userid));
|
|
$form .= form_item("Status", node_status($node, $node->status));
|
|
$form .= form_item("Comment", node_comment_status($node->comment));
|
|
$form .= form_item("Promote", node_promote_status($node->promote));
|
|
$form .= form_item("Moderate", check_output($node->moderate));
|
|
$form .= form_item("Date", format_date($node->timestamp));
|
|
$form .= form_submit("Edit node");
|
|
$form .= form_submit("Delete node");
|
|
|
|
return form("admin.php?mod=node&id=$node->nid", $form);
|
|
}
|
|
|
|
function node_admin_edit($id) {
|
|
global $user;
|
|
|
|
$node = node_get_object(array("nid" => $id));
|
|
|
|
$form .= form_item("Title", check_output($node->title));
|
|
$form .= form_select("Author", "author", $node->author, array($node->author => $node->userid, $user->id => $user->userid));
|
|
$form .= form_select("Status", "status", $node->status, node_status($node));
|
|
$form .= form_select("Comment", "comment", $node->comment, node_comment_status());
|
|
$form .= form_select("Promote", "promote", $node->promote, node_promote_status());
|
|
$form .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("Provide a comma-seperated list of the moderators their usernames."));
|
|
$form .= form_select("Date", "timestamp", $node->timestamp, array($node->timestamp => format_date($node->timestamp) ." (original)", time() => format_date(time()) ." (current)"));
|
|
$form .= form_hidden("nid", $node->nid);
|
|
$form .= form_submit("View node");
|
|
$form .= form_submit("Save node");
|
|
|
|
return form("admin.php?mod=node&id=$node->nid", $form);
|
|
}
|
|
|
|
function node_delete($id) {
|
|
return (node_del("nid", $id) ? "node has been deleted." : "failed to delete node: node must be dumped first.");
|
|
}
|
|
|
|
function node_query($type = "") {
|
|
global $status;
|
|
$queries = array(array("recent nodes", "ORDER BY n.timestamp DESC"), array("posted nodes", "WHERE n.status = '$status[posted]' ORDER BY n.timestamp DESC"), array("queued nodes", "WHERE n.status = '$status[queued]' ORDER BY n.timestamp DESC"), array("dumped nodes", "WHERE n.status = '$status[dumped]' ORDER BY n.timestamp DESC"));
|
|
return ($queries[$type] ? $queries[$type] : $queries);
|
|
}
|
|
|
|
function node_listing($queries) {
|
|
global $mod;
|
|
foreach ($queries as $key=>$array) {
|
|
$output .= "<LI><A HREF=\"admin.php?mod=$mod&type=$key\">$array[0]</A></LI>\n";
|
|
}
|
|
return "<OL>$output</OL>\n";
|
|
}
|
|
|
|
function node_admin() {
|
|
global $op, $id, $edit, $type;
|
|
|
|
print "<SMALL><A HREF=\"admin.php?mod=node&op=listing\">node listings</A> | <A HREF=\"admin.php?mod=node\">overview</A></SMALL><HR>\n";
|
|
|
|
$id = check_input($edit[nid] ? $edit[nid] : $id);
|
|
$type = ($type ? $type : 0);
|
|
|
|
switch ($op) {
|
|
case "Edit node":
|
|
case "edit":
|
|
print node_admin_edit($id);
|
|
break;
|
|
case "Delete node":
|
|
print status(node_delete($id));
|
|
print node_overview();
|
|
break;
|
|
case "listing":
|
|
print node_listing(node_query());
|
|
break;
|
|
case "Save node":
|
|
node_save($edit, array(uthor, comment, moderate, promote, status, timestamp));
|
|
print node_admin_view($id);
|
|
break;
|
|
case "View node":
|
|
case "view":
|
|
print node_admin_view($id);
|
|
break;
|
|
default:
|
|
print node_overview(node_query($type));
|
|
}
|
|
}
|
|
|
|
?>
|