- fixed bug in common.inc: throttle()
- streamlined method invocation in node.inc - added node_status() function to modules - added NEW (mostly static) page module - added NEW settings module3-00
							parent
							
								
									8213f5b262
								
							
						
					
					
						commit
						38806b4a39
					
				| 
						 | 
				
			
			@ -2,13 +2,8 @@
 | 
			
		|||
# Apache/PHP/site settings:
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
# Archive feature:
 | 
			
		||||
<Files archive>
 | 
			
		||||
  ForceType application/x-httpd-php
 | 
			
		||||
</Files>
 | 
			
		||||
 | 
			
		||||
# Protect files and directories from prying eyes:
 | 
			
		||||
<Files ~ "(class|conf|CVS|database|Entries|inc|modules|*.module|Repository|Root|script|sh|sql|theme)">
 | 
			
		||||
<Files ~ "(class|conf|CVS|database|Entries|inc|modules|*\.module|Repository|Root|script|sh|sql|theme)">
 | 
			
		||||
  order deny,allow
 | 
			
		||||
  deny from all
 | 
			
		||||
</Files>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -168,6 +168,15 @@ CREATE TABLE node (
 | 
			
		|||
  PRIMARY KEY (nid)
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
DROP TABLE IF EXISTS page;
 | 
			
		||||
CREATE TABLE page (
 | 
			
		||||
  lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
 | 
			
		||||
  nid int(10) unsigned DEFAULT '0' NOT NULL,
 | 
			
		||||
  body text NOT NULL,
 | 
			
		||||
  format tinyint(2) DEFAULT '0' NOT NULL,
 | 
			
		||||
  PRIMARY KEY (lid)
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
DROP TABLE IF EXISTS sections;
 | 
			
		||||
CREATE TABLE sections (
 | 
			
		||||
  name varchar(64) DEFAULT '' NOT NULL,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@ function watchdog($type, $message) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
function throttle($type, $rate) {
 | 
			
		||||
  global $user;
 | 
			
		||||
  if (!(user_access($user, "watchdog") || user_access($user, "comment") || user_access($user, "node"))) {
 | 
			
		||||
    if ($throttle = db_fetch_object(db_query("SELECT * FROM watchdog WHERE type = '$type' AND hostname = '". getenv("REMOTE_ADDR") ."' AND ". time() ." - timestamp < $rate"))) {
 | 
			
		||||
      watchdog("warning", "throttle: '". getenv("REMOTE_ADDR") ."' exceeded submission rate - $throttle->type");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
$status = array(dumped => 0, expired => 1, queued => 2, posted => 3);
 | 
			
		||||
$rstatus = array(0 => dumped, 1 => expired, 2 => queued, 3 => posted);
 | 
			
		||||
 | 
			
		||||
function _node_get($field, $value) {
 | 
			
		||||
  $result = db_query("SELECT lid, type FROM node WHERE $field = '$value'");
 | 
			
		||||
| 
						 | 
				
			
			@ -119,18 +120,23 @@ function node_save($node) {
 | 
			
		|||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function node_invoke($node, $name, $arg = 0) {
 | 
			
		||||
  if ($node[type]) $function = $node[type] ."_$name";
 | 
			
		||||
  if ($node->type) $function = $node->type ."_$name";
 | 
			
		||||
  if ($function) return ($arg ? $function($node) : $function($node, $arg));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function node_view($node, $page) {
 | 
			
		||||
  if ($node->type) {
 | 
			
		||||
    $function = $node->type ."_view";
 | 
			
		||||
    return $function($node, $page);
 | 
			
		||||
  }
 | 
			
		||||
  return node_invoke($node, "view", $page);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function node_form($node) {
 | 
			
		||||
  if ($node[type]) {
 | 
			
		||||
    $function = $node[type] ."_form";
 | 
			
		||||
    return $function($node);
 | 
			
		||||
  }
 | 
			
		||||
  return node_invoke($node, "form");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function node_status($node) {
 | 
			
		||||
  return node_invoke($node, "status");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function node_control($node) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,10 @@ function book_timout_threshold($node, $default) {
 | 
			
		|||
  return $default;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function book_status() {
 | 
			
		||||
  return array(dumped, expired, queued, posted);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function book_location($node, $nodes = array()) {
 | 
			
		||||
  $parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.nid = '$node->parent'"));
 | 
			
		||||
  if ($parent->title) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,10 @@ function book_timout_threshold($node, $default) {
 | 
			
		|||
  return $default;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function book_status() {
 | 
			
		||||
  return array(dumped, expired, queued, posted);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function book_location($node, $nodes = array()) {
 | 
			
		||||
  $parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.nid = '$node->parent'"));
 | 
			
		||||
  if ($parent->title) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,18 +2,15 @@
 | 
			
		|||
 | 
			
		||||
$module = array("admin" => "node_admin");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
$nstatus = array(0 => dumped, 1 => expired, 2 => queued, 3 => posted);
 | 
			
		||||
 | 
			
		||||
function node_overview($query = 0) {
 | 
			
		||||
  global $user, $nstatus;
 | 
			
		||||
  global $user, $rstatus;
 | 
			
		||||
 | 
			
		||||
  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id ". ($query ? "WHERE $query" : "") ." ORDER BY n.timestamp DESC");
 | 
			
		||||
 | 
			
		||||
  $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
 | 
			
		||||
  $output .= " <TR><TH>title</TH><TH>type</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"3\">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\">$node->type</TD><TD>". $nstatus[$node->status] ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp) ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=view&id=$node->nid\">view node</A></TD>" : "view node") ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</A></TD>" : "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></TD>" : "edit $node->type") ."</TD></TR>\n";
 | 
			
		||||
    $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". $rstatus[$node->status] ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp) ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=view&id=$node->nid\">view node</A></TD>" : "view node") ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</A></TD>" : "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></TD>" : "edit $node->type") ."</TD></TR>\n";
 | 
			
		||||
  }
 | 
			
		||||
  $output .= "</TABLE>\n";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -21,14 +18,14 @@ function node_overview($query = 0) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
function node_admin_view($id) {
 | 
			
		||||
  global $nstatus;
 | 
			
		||||
  global $rstatus;
 | 
			
		||||
 | 
			
		||||
  $node = node_get_object("nid", $id);
 | 
			
		||||
 | 
			
		||||
  $output .= "<FORM ACTION=\"admin.php?mod=node&id=$node->nid\" METHOD=\"post\">\n";
 | 
			
		||||
  $output .= "<B>Title:</B><BR>". check_output($node->title) ."<P>\n";
 | 
			
		||||
  $output .= "<B>Author:</B><BR>". format_username($node->userid) ."<P>\n";
 | 
			
		||||
  $output .= "<B>Status:</B><BR>". $nstatus[$node->status] ."<P>\n";
 | 
			
		||||
  $output .= "<B>Status:</B><BR>". $rstatus[$node->status] ."<P>\n";
 | 
			
		||||
  $output .= "<B>Date:</B><BR>". format_date($node->timestamp) ."<P>\n";
 | 
			
		||||
  $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Edit node\">\n";
 | 
			
		||||
  $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Delete node\">\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -38,13 +35,13 @@ function node_admin_view($id) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
function node_admin_edit($id) {
 | 
			
		||||
  global $status, $user;
 | 
			
		||||
  global $user, $status;
 | 
			
		||||
 | 
			
		||||
  $node = node_get_object("nid", $id);
 | 
			
		||||
 | 
			
		||||
  foreach (array($node->userid => $node->author, $user->userid => $user->id) as $value=>$key) $author .= " <OPTION VALUE=\"$key\"". (($node->author == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  foreach (array(format_date($node->timestamp) ." (original)" => $node->timestamp, format_date(time()) ." (current)" => time()) as $value=>$key) $timestamp .= " <OPTION VALUE=\"$key\"". (($node->timestamp == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  foreach ($status as $value=>$key) $statuz .= " <OPTION VALUE=\"$key\"". (($node->status == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  foreach (node_status($node) as $value) $statuz .= " <OPTION VALUE=\"". $status[$value] ."\"". (($node->status == $status[$value]) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<FORM ACTION=\"admin.php?mod=node&id=$node->nid\" METHOD=\"post\">\n";
 | 
			
		||||
  $output .= "<B>Title:</B><BR>". check_output($node->title) ."<P>\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +57,7 @@ function node_admin_edit($id) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
function node_delete($id) {
 | 
			
		||||
  return (node_del("nid", $id) ? "failed to delete node: node must be dumped first." : "node has been deleted.");
 | 
			
		||||
  return (node_del("nid", $id) ? "node has been deleted." : "failed to delete node: node must be dumped first.");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function node_admin() {
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +76,7 @@ function node_admin() {
 | 
			
		|||
      break;
 | 
			
		||||
    case "Save node":
 | 
			
		||||
      print status(node_save($edit));
 | 
			
		||||
      print node_overview();
 | 
			
		||||
      print node_admin_view($id);
 | 
			
		||||
      break;
 | 
			
		||||
    case "View node":
 | 
			
		||||
    case "view":
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,18 +2,15 @@
 | 
			
		|||
 | 
			
		||||
$module = array("admin" => "node_admin");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
$nstatus = array(0 => dumped, 1 => expired, 2 => queued, 3 => posted);
 | 
			
		||||
 | 
			
		||||
function node_overview($query = 0) {
 | 
			
		||||
  global $user, $nstatus;
 | 
			
		||||
  global $user, $rstatus;
 | 
			
		||||
 | 
			
		||||
  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id ". ($query ? "WHERE $query" : "") ." ORDER BY n.timestamp DESC");
 | 
			
		||||
 | 
			
		||||
  $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
 | 
			
		||||
  $output .= " <TR><TH>title</TH><TH>type</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH COLSPAN=\"3\">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\">$node->type</TD><TD>". $nstatus[$node->status] ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp) ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=view&id=$node->nid\">view node</A></TD>" : "view node") ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</A></TD>" : "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></TD>" : "edit $node->type") ."</TD></TR>\n";
 | 
			
		||||
    $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". $rstatus[$node->status] ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp) ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=view&id=$node->nid\">view node</A></TD>" : "view node") ."</TD><TD>". (user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</A></TD>" : "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></TD>" : "edit $node->type") ."</TD></TR>\n";
 | 
			
		||||
  }
 | 
			
		||||
  $output .= "</TABLE>\n";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -21,14 +18,14 @@ function node_overview($query = 0) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
function node_admin_view($id) {
 | 
			
		||||
  global $nstatus;
 | 
			
		||||
  global $rstatus;
 | 
			
		||||
 | 
			
		||||
  $node = node_get_object("nid", $id);
 | 
			
		||||
 | 
			
		||||
  $output .= "<FORM ACTION=\"admin.php?mod=node&id=$node->nid\" METHOD=\"post\">\n";
 | 
			
		||||
  $output .= "<B>Title:</B><BR>". check_output($node->title) ."<P>\n";
 | 
			
		||||
  $output .= "<B>Author:</B><BR>". format_username($node->userid) ."<P>\n";
 | 
			
		||||
  $output .= "<B>Status:</B><BR>". $nstatus[$node->status] ."<P>\n";
 | 
			
		||||
  $output .= "<B>Status:</B><BR>". $rstatus[$node->status] ."<P>\n";
 | 
			
		||||
  $output .= "<B>Date:</B><BR>". format_date($node->timestamp) ."<P>\n";
 | 
			
		||||
  $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Edit node\">\n";
 | 
			
		||||
  $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Delete node\">\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -38,13 +35,13 @@ function node_admin_view($id) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
function node_admin_edit($id) {
 | 
			
		||||
  global $status, $user;
 | 
			
		||||
  global $user, $status;
 | 
			
		||||
 | 
			
		||||
  $node = node_get_object("nid", $id);
 | 
			
		||||
 | 
			
		||||
  foreach (array($node->userid => $node->author, $user->userid => $user->id) as $value=>$key) $author .= " <OPTION VALUE=\"$key\"". (($node->author == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  foreach (array(format_date($node->timestamp) ." (original)" => $node->timestamp, format_date(time()) ." (current)" => time()) as $value=>$key) $timestamp .= " <OPTION VALUE=\"$key\"". (($node->timestamp == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  foreach ($status as $value=>$key) $statuz .= " <OPTION VALUE=\"$key\"". (($node->status == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  foreach (node_status($node) as $value) $statuz .= " <OPTION VALUE=\"". $status[$value] ."\"". (($node->status == $status[$value]) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<FORM ACTION=\"admin.php?mod=node&id=$node->nid\" METHOD=\"post\">\n";
 | 
			
		||||
  $output .= "<B>Title:</B><BR>". check_output($node->title) ."<P>\n";
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +57,7 @@ function node_admin_edit($id) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
function node_delete($id) {
 | 
			
		||||
  return (node_del("nid", $id) ? "failed to delete node: node must be dumped first." : "node has been deleted.");
 | 
			
		||||
  return (node_del("nid", $id) ? "node has been deleted." : "failed to delete node: node must be dumped first.");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function node_admin() {
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +76,7 @@ function node_admin() {
 | 
			
		|||
      break;
 | 
			
		||||
    case "Save node":
 | 
			
		||||
      print status(node_save($edit));
 | 
			
		||||
      print node_overview();
 | 
			
		||||
      print node_admin_view($id);
 | 
			
		||||
      break;
 | 
			
		||||
    case "View node":
 | 
			
		||||
    case "view":
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,83 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
$module = array("page" => "page_page",
 | 
			
		||||
                "admin" => "page_admin");
 | 
			
		||||
 | 
			
		||||
$format = array(0 => HTML, 1 => PHP, 2 => text);
 | 
			
		||||
 | 
			
		||||
function page_view($node) {
 | 
			
		||||
  global $format, $theme;
 | 
			
		||||
 | 
			
		||||
  switch ($format[$node->format]) {
 | 
			
		||||
    case "PHP":
 | 
			
		||||
      $output = eval($node->body);
 | 
			
		||||
      break;
 | 
			
		||||
    case "text":
 | 
			
		||||
      $output = nl2br(htmlentities($node->body));
 | 
			
		||||
      break;
 | 
			
		||||
    default:
 | 
			
		||||
      $output = check_output($node->body, 1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  $theme->header();
 | 
			
		||||
  $theme->box(check_output($node->title), $output);
 | 
			
		||||
  $theme->footer();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function page_status() {
 | 
			
		||||
  return array(dumped, posted);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function page_form($edit = array()) {
 | 
			
		||||
  global $format;
 | 
			
		||||
 | 
			
		||||
  $output .= "<FORM ACTION=\"admin.php?mod=page\" METHOD=\"post\">\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Name:</B><BR>\n";
 | 
			
		||||
  $output .= "<INPUT NAME=\"edit[title]\" SIZE=\"55\" VALUE=\"". check_textfield($edit[title]) ."\"><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Body:</B><BR>\n";
 | 
			
		||||
  $output .= "<TEXTAREA NAME=\"edit[body]\" COLS=\"55\" ROWS=\"10\" WRAP=\"virtual\">". check_textarea($edit[body]) ."</TEXTAREA><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Type:</B><BR>\n";
 | 
			
		||||
  foreach ($format as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". ($edit[format] == $key ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  $output .= "<SELECT NAME=\"edit[format]\">$options</SELECT><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save page\">\n";
 | 
			
		||||
  $output .= "</FORM>\n";
 | 
			
		||||
 | 
			
		||||
  return $output;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function page_save($edit) {
 | 
			
		||||
  global $status;
 | 
			
		||||
  node_save(array_merge($edit, array(type => "page", status => $status[posted])));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function page_overview() {
 | 
			
		||||
  return node_overview("type = 'page'");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function page_admin() {
 | 
			
		||||
  global $id, $op, $edit;
 | 
			
		||||
 | 
			
		||||
  print "<SMALL><A HREF=\"admin.php?mod=page&op=add\">add new page</A> | <A HREF=\"admin.php?mod=page\">overview</A> | <A HREF=\"admin.php?mod=page&op=help\">help</A></SMALL><HR>\n";
 | 
			
		||||
 | 
			
		||||
  switch ($op) {
 | 
			
		||||
    case "add":
 | 
			
		||||
      print page_form();
 | 
			
		||||
      break;
 | 
			
		||||
    case "edit":
 | 
			
		||||
      print page_form(node_get_array(nid, $id));
 | 
			
		||||
      break;
 | 
			
		||||
   case "Save page":
 | 
			
		||||
      print status(page_save($edit));
 | 
			
		||||
      // fall through:
 | 
			
		||||
    default:
 | 
			
		||||
      print page_overview();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,83 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
$module = array("page" => "page_page",
 | 
			
		||||
                "admin" => "page_admin");
 | 
			
		||||
 | 
			
		||||
$format = array(0 => HTML, 1 => PHP, 2 => text);
 | 
			
		||||
 | 
			
		||||
function page_view($node) {
 | 
			
		||||
  global $format, $theme;
 | 
			
		||||
 | 
			
		||||
  switch ($format[$node->format]) {
 | 
			
		||||
    case "PHP":
 | 
			
		||||
      $output = eval($node->body);
 | 
			
		||||
      break;
 | 
			
		||||
    case "text":
 | 
			
		||||
      $output = nl2br(htmlentities($node->body));
 | 
			
		||||
      break;
 | 
			
		||||
    default:
 | 
			
		||||
      $output = check_output($node->body, 1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  $theme->header();
 | 
			
		||||
  $theme->box(check_output($node->title), $output);
 | 
			
		||||
  $theme->footer();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function page_status() {
 | 
			
		||||
  return array(dumped, posted);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function page_form($edit = array()) {
 | 
			
		||||
  global $format;
 | 
			
		||||
 | 
			
		||||
  $output .= "<FORM ACTION=\"admin.php?mod=page\" METHOD=\"post\">\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Name:</B><BR>\n";
 | 
			
		||||
  $output .= "<INPUT NAME=\"edit[title]\" SIZE=\"55\" VALUE=\"". check_textfield($edit[title]) ."\"><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Body:</B><BR>\n";
 | 
			
		||||
  $output .= "<TEXTAREA NAME=\"edit[body]\" COLS=\"55\" ROWS=\"10\" WRAP=\"virtual\">". check_textarea($edit[body]) ."</TEXTAREA><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Type:</B><BR>\n";
 | 
			
		||||
  foreach ($format as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". ($edit[format] == $key ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  $output .= "<SELECT NAME=\"edit[format]\">$options</SELECT><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save page\">\n";
 | 
			
		||||
  $output .= "</FORM>\n";
 | 
			
		||||
 | 
			
		||||
  return $output;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function page_save($edit) {
 | 
			
		||||
  global $status;
 | 
			
		||||
  node_save(array_merge($edit, array(type => "page", status => $status[posted])));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function page_overview() {
 | 
			
		||||
  return node_overview("type = 'page'");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function page_admin() {
 | 
			
		||||
  global $id, $op, $edit;
 | 
			
		||||
 | 
			
		||||
  print "<SMALL><A HREF=\"admin.php?mod=page&op=add\">add new page</A> | <A HREF=\"admin.php?mod=page\">overview</A> | <A HREF=\"admin.php?mod=page&op=help\">help</A></SMALL><HR>\n";
 | 
			
		||||
 | 
			
		||||
  switch ($op) {
 | 
			
		||||
    case "add":
 | 
			
		||||
      print page_form();
 | 
			
		||||
      break;
 | 
			
		||||
    case "edit":
 | 
			
		||||
      print page_form(node_get_array(nid, $id));
 | 
			
		||||
      break;
 | 
			
		||||
   case "Save page":
 | 
			
		||||
      print status(page_save($edit));
 | 
			
		||||
      // fall through:
 | 
			
		||||
    default:
 | 
			
		||||
      print page_overview();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,115 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
$module = array("admin" => "settings_admin");
 | 
			
		||||
 | 
			
		||||
function settings_conf() {
 | 
			
		||||
  global $conf, $cmodes, $corder;
 | 
			
		||||
 | 
			
		||||
  $output .= "<H3>General settings</H3>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Sitename:</B><BR>\n";
 | 
			
		||||
  $output .= "<INPUT NAME=\"edit[site_name]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"". variable_get(site_name, "drupal") ."\"><BR>\n";
 | 
			
		||||
  $output .= "<I><SMALL>The name of this website.</SMALL></I><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>E-mail address:</B><BR>\n";
 | 
			
		||||
  $output .= "<INPUT NAME=\"edit[site_mail]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"". variable_get(site_mail, "root@localhost") ."\"><BR>\n";
 | 
			
		||||
  $output .= "<I><SMALL>A valid e-mail address for this website, used by the auto-mailer to when creating new user accounts.</SMALL></I><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>URL of site:</B><BR>\n";
 | 
			
		||||
  $output .= "<INPUT NAME=\"edit[site_url]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"". variable_get(site_url, "http://drupal/") ."\"><BR>\n";
 | 
			
		||||
  $output .= "<I><SMALL>The fully qualified URL of this website: starts with \"http://\" and ends with a trailing slash!</SMALL></I><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Anonymous user:</B><BR>\n";
 | 
			
		||||
  $output .= "<INPUT NAME=\"edit[anonymous]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"". variable_get(anonymous, "Anonymous") ."\"><BR>\n";
 | 
			
		||||
  $output .= "<I><SMALL>The name displayed for anonymous users.</SMALL></I><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<HR>\n";
 | 
			
		||||
  $output .= "<H3>Comment system</H3>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Default display mode:</B><BR>\n";
 | 
			
		||||
  foreach ($cmodes as $key=>$value) $options1 .= "<OPTION VALUE=\"$key\"". ($conf[default_comment_mode] == $key ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  $output .= "<SELECT NAME=\"edit[default_comment_mode]\">$options1</SELECT><BR>\n";
 | 
			
		||||
  $output .= "<I><SMALL>The default mode in which comments are displayed.</SMALL></I><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Default display mode:</B><BR>\n";
 | 
			
		||||
  foreach ($corder as $key=>$value) $options2 .= "<OPTION VALUE=\"$key\"". ($conf[default_comment_order] == $key ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  $output .= "<SELECT NAME=\"edit[default_comment_order]\">$options2</SELECT><BR>\n";
 | 
			
		||||
  $output .= "<I><SMALL>The default mode in which comments are displayed.</SMALL></I><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Default threshold:</B><BR>\n";
 | 
			
		||||
  for ($i = -1; $i < 6; $i++) $options3 .= " <OPTION VALUE=\"$i\"". ($conf[default_comment_threshold] == $i ? " SELECTED" : "") .">Filter - $i</OPTION>";
 | 
			
		||||
  $output .= "<SELECT NAME=\"edit[default_comment_threshold]\">$options3</SELECT><BR>\n";
 | 
			
		||||
  $output .= "<I><SMALL>The default threshold used to filter comments.</SMALL></I><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<HR>\n";
 | 
			
		||||
  $output .= "<H3>Submission system</H3>\n";
 | 
			
		||||
 | 
			
		||||
  $size = array(1000 => "1.000 characters", 5000 => "5.000 characters", 10000 => "10.000 characters", 15000 => "15.000 characters", 30.000 => "30.000 characters", 50000 => "50.000 characters", 100000 => "100.000 characters");
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Maximum submission size:</B><BR>\n";
 | 
			
		||||
  foreach ($size as $key=>$value) $options4 .= " <OPTION VALUE=\"$key\"". ((variable_get(max_input_size, 10000) == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  $output .= "<SELECT NAME=\"edit[max_input_size]\">$options4</SELECT><BR>\n";
 | 
			
		||||
  $output .= "<I><SMALL>The maximum number of characters someone can enter in a form.</SMALL></I><P>\n";
 | 
			
		||||
 | 
			
		||||
  $rate = array(1 => "maximum 1 every second", 5 => "maximum 1 every 5 seconds", 15 => "maximum 1 every 15 seconds", 30 => "maximum 1 every 30 seconds", 60 => "maximum 1 every minute", 300 => "maximum 1 every 5 minutes", 900 => "maximum 1 every 15 minutes", 1800 => "maximum 1 every 30 minutes", 3600 => "maximum 1 every hour", 21600 => "maximum 1 every 6 hour", 43200 => "maximum 1 every 12 hour");
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Maximum node rate:</B><BR>\n";
 | 
			
		||||
  foreach ($rate as $key=>$value) $options5 .= " <OPTION VALUE=\"$key\"". ((variable_get(max_node_rate, 900) == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  $output .= "<SELECT NAME=\"edit[max_node_rate]\">$options5</SELECT><BR>\n";
 | 
			
		||||
  $output .= "<I><SMALL>The maximum submission rate for nodes.  Its purpose is to stop potential abuse or denial of service attacks.</SMALL></I><P>\n";
 | 
			
		||||
 | 
			
		||||
  $output .= "<B>Maximum comment rate:</B><BR>\n";
 | 
			
		||||
  foreach ($rate as $key=>$value) $options6 .= " <OPTION VALUE=\"$key\"". ((variable_get(max_comment_rate, 120) == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
 | 
			
		||||
  $output .= "<SELECT NAME=\"edit[max_comment_rate]\"$options6</SELECT><BR>\n";
 | 
			
		||||
  $output .= "<I><SMALL>The maximum submission rate for comments.  Its purpose is to stop potential abuse or denial of service attacks.</SMALL></I><P>\n";
 | 
			
		||||
 | 
			
		||||
  return $output;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function settings_save($edit) {
 | 
			
		||||
  global $conf;
 | 
			
		||||
  if ($edit) {
 | 
			
		||||
    db_query("DELETE FROM variable");
 | 
			
		||||
    foreach ($edit as $name=>$value) db_query("INSERT INTO variable (name, value) VALUES ('". check_input($name) ."', '". check_input($value) ."')");
 | 
			
		||||
  }
 | 
			
		||||
  $conf = variable_init();
 | 
			
		||||
  return "all settings have been saved.";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function settings_module($name, $module) {
 | 
			
		||||
  global $settings;
 | 
			
		||||
 | 
			
		||||
  if ($module["conf"]) {
 | 
			
		||||
    $settings .= "<H3>". ucfirst($name) ." module</H3>\n";
 | 
			
		||||
    $settings .= $module["conf"]();
 | 
			
		||||
    $settings .= "<HR>\n";
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function settings_overview() {
 | 
			
		||||
  global $settings;
 | 
			
		||||
 | 
			
		||||
  module_iterate("settings_module");
 | 
			
		||||
 | 
			
		||||
  $output .= "<FORM ACTION=\"admin.php?mod=settings\" METHOD=\"post\">\n";
 | 
			
		||||
  $output .= settings_conf();
 | 
			
		||||
  $output .= $settings;
 | 
			
		||||
  $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save settings\">\n";
 | 
			
		||||
  $output .= "</FORM>\n";
 | 
			
		||||
 | 
			
		||||
  return $output;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function settings_admin() {
 | 
			
		||||
  global $edit, $op;
 | 
			
		||||
 | 
			
		||||
  switch ($op) {
 | 
			
		||||
    case "Save settings":
 | 
			
		||||
      print status(settings_save($edit));
 | 
			
		||||
      // fall through:
 | 
			
		||||
    default;
 | 
			
		||||
      print settings_overview();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
| 
						 | 
				
			
			@ -31,6 +31,10 @@ function story_timout_threshold($node, $default) {
 | 
			
		|||
  return section_timout_threshold($node->section, $default);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function story_status() {
 | 
			
		||||
  return array(dumped, queued, posted);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function story_find($keys) {
 | 
			
		||||
  global $status, $user;
 | 
			
		||||
  $find = array();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,6 +31,10 @@ function story_timout_threshold($node, $default) {
 | 
			
		|||
  return section_timout_threshold($node->section, $default);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function story_status() {
 | 
			
		||||
  return array(dumped, queued, posted);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function story_find($keys) {
 | 
			
		||||
  global $status, $user;
 | 
			
		||||
  $find = array();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,12 @@
 | 
			
		|||
# 05/04/2001:
 | 
			
		||||
# 07/04/2001:
 | 
			
		||||
CREATE TABLE page (
 | 
			
		||||
  lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
 | 
			
		||||
  nid int(10) unsigned DEFAULT '0' NOT NULL,
 | 
			
		||||
  body text NOT NULL,
 | 
			
		||||
  format tinyint(2) DEFAULT '0' NOT NULL,
 | 
			
		||||
  PRIMARY KEY (lid)
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
CREATE TABLE variable (
 | 
			
		||||
  name varchar(32) DEFAULT '' NOT NULL,
 | 
			
		||||
  value varchar(128) DEFAULT '' NOT NULL,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue