From 3d73a48edcf62bed0033fcea1aebcedb23e7c197 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Sun, 17 Jun 2001 20:35:48 +0000
Subject: [PATCH] - Merged "system settings" and "module settings" into one
 page.  IMHO   it wasn't a good idea to split them up in first place, and it
 turned   out to be quite hard to decide where to put some variables.

  Also moved some variables around and even renamed a few variables
  while doing so.

- Added a page_header() and page_footer() to all top-level .php pages.
---
 account.php              |  8 +++----
 includes/common.inc      | 10 +++++++--
 includes/theme.inc       |  2 +-
 module.php               |  2 ++
 modules/account.module   |  7 ++++++-
 modules/conf.module      | 45 +++++++++++++---------------------------
 modules/node.module      |  5 +++++
 modules/node/node.module |  5 +++++
 search.php               |  4 ++++
 submit.php               |  4 ++++
 10 files changed, 53 insertions(+), 39 deletions(-)

diff --git a/account.php b/account.php
index 7035a49a23f4..bc4703b6c7e6 100644
--- a/account.php
+++ b/account.php
@@ -133,7 +133,7 @@ function account_site_edit() {
   }
   else {
     $theme->header();
-    if (variable_get("account_reg_allow", 1)) $theme->box(t("Create user account"), account_create());
+    if (variable_get("account_register", 1)) $theme->box(t("Create user account"), account_create());
     $theme->box(t("E-mail new password"), account_email());
     $theme->footer();
   }
@@ -202,7 +202,7 @@ function account_user($uname) {
   }
   elseif ($uname && $account = account_get_user($uname)) {
     $output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
-    $output .= " <TR><TD ALIGN=\"right\"><B>". t("Username") .":</B></TD><TD>$account->userid</TD></TR>\n";
+    $output .= " <TR><TD ALIGN=\"right\"><B>". t("Username") .":</B></TD><TD>". check_output($account->userid) ."</TD></TR>\n";
     $output .= " <TR><TD ALIGN=\"right\"><B>". t("E-mail") .":</B></TD><TD>". format_email($account->fake_email) ."</TD></TR>\n";
     $output .= " <TR><TD ALIGN=\"right\"><B>". t("Homepage") .":</B></TD><TD>". format_url($account->url) ."</TD></TR>\n";
     $output .= " <TR><TD ALIGN=\"right\"><B>". t("Bio") .":</B></TD><TD>". check_output($account->bio) ."</TD></TR>\n";
@@ -216,7 +216,7 @@ function account_user($uname) {
   else {
     // Display login form:
     $theme->header();
-    if (variable_get("account_reg_allow", 1)) $theme->box(t("Create user account"), account_create());
+    if (variable_get("account_register", 1)) $theme->box(t("Create user account"), account_create());
     $theme->box(t("E-mail new password"), account_email());
     $theme->footer();
   }
@@ -405,7 +405,7 @@ function account_track_site() {
     account_email_submit(check_input($userid), check_input($email));
     break;
   case t("Create account"):
-    if (variable_get("account_reg_allow", 1)) account_create_submit(check_input($userid), check_input($email));
+    if (variable_get("account_register", 1)) account_create_submit(check_input($userid), check_input($email));
     break;
   case t("Save user information"):
     account_user_save($edit);
diff --git a/includes/common.inc b/includes/common.inc
index 54e19bd6c063..ac78a5d4ccd9 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -250,11 +250,17 @@ function timer_print() {
 }
 
 function page_header() {
-  if (variable_get("dev_timer", 0)) timer_start();
+  global $user;
+
+  if (variable_get("dev_timer", 0)) {
+    timer_start();
+  }
 }
 
 function page_footer() {
-  if (variable_get("dev_timer", 0)) timer_print();
+  if (variable_get("dev_timer", 0)) {
+    timer_print();
+  }
 }
 
 $conf = conf_init();
diff --git a/includes/theme.inc b/includes/theme.inc
index c6e397d1a971..ff0e9316752c 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -81,7 +81,7 @@ function theme_account($theme) {
     $output .= "  <B>". t("Username") .":</B><BR><INPUT NAME=\"userid\" SIZE=\"15\"><P>\n";
     $output .= "  <B>". t("Password") .":</B><BR><INPUT NAME=\"passwd\" SIZE=\"15\" TYPE=\"password\"><BR>\n";
     $output .= "  <INPUT TYPE=\"submit\" VALUE=\"". t("Login") ."\"><BR>\n";
-    if (variable_get("account_reg_allow", 1)) $output .= "  <A HREF=\"account.php\">". t("REGISTER") ."</A>\n";
+    if (variable_get("account_register", 1)) $output .= "  <A HREF=\"account.php\">". t("REGISTER") ."</A>\n";
     $output .= " </FORM>\n";
     $output .= "</DIV>\n";
 
diff --git a/module.php b/module.php
index 13aca87e2b28..ac6d50852379 100644
--- a/module.php
+++ b/module.php
@@ -3,7 +3,9 @@
 include_once "includes/common.inc";
 
 page_header();
+
 module_invoke($mod, "page");
+
 page_footer();
 
 ?>
diff --git a/modules/account.module b/modules/account.module
index fe654f5a6e9a..56ad34737d29 100644
--- a/modules/account.module
+++ b/modules/account.module
@@ -32,6 +32,11 @@ function account_help() {
  <?php
 }
 
+function account_conf_options() {
+  $output .= form_select(t("Public accounts"), "account_register", variable_get("account_register", 1), array("Disabled", "Enabled"), "If enabled, everyone can create a new user account.  If disabled, new user accounts can only be created by site administrators.");
+  return $output;
+}
+
 function account_password($min_length=6) {
   mt_srand((double)microtime() * 1000000);
   $words = array("foo","bar","guy","neo","tux","moo","sun","asm","dot","god","axe","geek","nerd","fish","hack","star","mice","warp","moon","hero","cola","girl","fish","java","perl","boss","dark","sith","jedi","drop","mojo");
@@ -291,7 +296,7 @@ function account_query($type = "") {
 function account_admin() {
   global $op, $edit, $id, $mod, $keys, $order, $name, $query;
 
-  print "<SMALL><A HREF=\"admin.php?mod=account&op=access\">access control</A> | <A HREF=\"admin.php?mod=account&op=listing\">account listings</A> | <A HREF=\"admin.php?mod=account&op=search\">search account</A> | <A HREF=\"admin.php?mod=account&op=add\">add account</A> | <A HREF=\"admin.php?mod=account\">overview</A> | <A HREF=\"admin.php?mod=account&op=help\">help</A></SMALL><HR>";
+  print "<SMALL><A HREF=\"admin.php?mod=account&op=access\">access control</A> | <A HREF=\"admin.php?mod=account&op=add\">add new account</A> | <A HREF=\"admin.php?mod=account&op=listing\">account listings</A> | <A HREF=\"admin.php?mod=account&op=search\">search account</A> | <A HREF=\"admin.php?mod=account\">overview</A> | <A HREF=\"admin.php?mod=account&op=help\">help</A></SMALL><HR>";
 
   $query = $query ? $query : 0;
   $name = $name ? $name : $edit[name];
diff --git a/modules/conf.module b/modules/conf.module
index 340308c90429..4a03a1a99eda 100644
--- a/modules/conf.module
+++ b/modules/conf.module
@@ -12,7 +12,7 @@ function conf_help() {
  <?php
 }
 
-function conf_view_system() {
+function conf_view_options() {
   global $conf, $cmodes, $corder, $themes;
 
   // general settings:
@@ -24,14 +24,13 @@ function conf_view_system() {
   $output .= form_textfield(t("Anonymous user"), "anonymous", variable_get("anonymous", "Anonymous"), 30, 55, t("The name used to indicate anonymous users."));
   $output .= "<HR>\n";
 
-  // account settings:
-  $output .= "<H3>Account settings</H3>\n";
-  $output .= form_select(t("Allow registrations"), "account_reg_allow", variable_get("account_reg_allow", 1), array("Disabled", "Enabled"));
-  $output .= "<HR>\n";
-
-  // node settings:
-  $output .= "<H3>Node settings</H3>\n";
-  $output .= form_select(t("Default number of nodes to display"), "default_nodes_main", variable_get("default_nodes_main", 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 =>  5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), t("The default maximum number of nodes to display on the main page."));
+  // submission settings:
+  $output .= "<H3>Submission settings</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 .= form_select(t("Maximum submission size"), "max_input_size", variable_get("max_input_size", 10000), $size, t("The maximum number of characters someone can enter in a form."));
+  $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 .= form_select(t("Maximum node rate"), "max_node_rate", variable_get("max_node_rate", 900), $rate, t("The maximum submission rate for nodes.  Its purpose is to stop potential abuse or denial of service attacks."));
+  $output .= form_select(t("Maximum comment rate"), "max_comment_rate", variable_get("max_comment_rate", 120), $rate, t("The maximum submission rate for comments.  Its purpose is to stop potential abuse or denial of service attacks."));
   $output .= "<HR>\n";
 
   // comment settings:
@@ -42,17 +41,8 @@ function conf_view_system() {
   $output .= form_select(t("Default filter threshold"), "default_comment_threshold", $conf[default_comment_threshold], $threshold, t("The default threshold used to filter comments."));
   $output .= "<HR>\n";
 
-  // submission settings:
-  $output .= "<H3>Submission settings</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 .= form_select(t("Maximum submission size"), "max_input_size", variable_get("max_input_size", 10000), $size, t("The maximum number of characters someone can enter in a form."));
-  $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 .= form_select(t("Maximum node rate"), "max_node_rate", variable_get("max_node_rate", 900), $rate, t("The maximum submission rate for nodes.  Its purpose is to stop potential abuse or denial of service attacks."));
-  $output .= form_select(t("Maximum comment rate"), "max_comment_rate", variable_get("max_comment_rate", 120), $rate, t("The maximum submission rate for comments.  Its purpose is to stop potential abuse or denial of service attacks."));
-  $output .= "<HR>\n";
-
-  // theme settings:
-  $output .= "<H3>Theme settings</H3>\n";
+  // layout settings:
+  $output .= "<H3>Layout settings</H3>\n";
   foreach ($themes as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". (variable_get("theme_default", key($themes)) == $key ? " SELECTED" : "") .">$key</OPTION>\n";
   $output .= form_item(t("Default theme"), "<SELECT NAME=\"edit[theme_default]\">$options</SELECT>", t("The default theme as seen by new visitors and anonymous users."));
   $output .= "<HR>\n";
@@ -62,10 +52,6 @@ function conf_view_system() {
   $output .= form_select(t("Display timer information"), "dev_timer", variable_get("dev_timer", 0), array("Disabled", "Enabled"), t("Display the time it took to generate a page.  For Drupal development only."));
   $output .= "<HR>\n";
 
-  return $output;
-}
-
-function conf_view_module() {
   foreach (module_list() as $name) {
     if (module_hook($name, "conf_options")) {
       $output .= "<H3>". ucfirst($name) ." settings</H3>". module_invoke($name, "conf_options") ."<HR>\n";
@@ -74,7 +60,7 @@ function conf_view_module() {
   return $output;
 }
 
-function conf_view_filter() {
+function conf_view_filters() {
   foreach (module_list() as $name) {
     if (module_hook($name, "conf_filters")) {
       $output .= module_invoke($name, "conf_filters");
@@ -98,13 +84,10 @@ function conf_view($type) {
 
   switch ($type) {
     case "filter":
-      $form = conf_view_filter();
-      break;
-    case "module":
-      $form = conf_view_module();
+      $form = conf_view_filters();
       break;
     default:
-      $form = conf_view_system();
+      $form = conf_view_options();
   }
 
   $form .= form_submit("Save configuration");
@@ -116,7 +99,7 @@ function conf_view($type) {
 function conf_admin() {
   global $edit, $op, $type;
 
-  print "<SMALL><A HREF=\"admin.php?mod=conf&type=system\">system settings</A> | <A HREF=\"admin.php?mod=conf&type=module\">module settings</A> | <A HREF=\"admin.php?mod=conf&type=filter\">content filters</A> | <A HREF=\"admin.php?mod=conf&op=help\">help</A></SMALL><HR>\n";
+  print "<SMALL><A HREF=\"admin.php?mod=conf&type=options\">site settings</A> | <A HREF=\"admin.php?mod=conf&type=filter\">content filters</A> | <A HREF=\"admin.php?mod=conf&op=help\">help</A></SMALL><HR>\n";
 
   switch ($op) {
     case "help":
diff --git a/modules/node.module b/modules/node.module
index 5a68ec7dd3a1..3415a9fc221f 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -26,6 +26,11 @@ function node_help() {
   }
 }
 
+function node_conf_options() {
+  $output .= form_select(t("Default number of nodes to display"), "default_nodes_main", variable_get("default_nodes_main", 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 =>  5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), t("The default maximum number of nodes to display on the main page."));
+  return $output;
+}
+
 function node_conf_filters() {
   $output .= form_select(t("Enable 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."));
diff --git a/modules/node/node.module b/modules/node/node.module
index 5a68ec7dd3a1..3415a9fc221f 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -26,6 +26,11 @@ function node_help() {
   }
 }
 
+function node_conf_options() {
+  $output .= form_select(t("Default number of nodes to display"), "default_nodes_main", variable_get("default_nodes_main", 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 =>  5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), t("The default maximum number of nodes to display on the main page."));
+  return $output;
+}
+
 function node_conf_filters() {
   $output .= form_select(t("Enable 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."));
diff --git a/search.php b/search.php
index 59b5aace17b5..bfd5e60c3571 100644
--- a/search.php
+++ b/search.php
@@ -2,6 +2,8 @@
 
 include_once "includes/common.inc";
 
+page_header();
+
 function find_module($name) {
   global $options, $type;
   if (module_hook($name, "search")) $options .= "<OPTION VALUE=\"$name\"". ($name == $type ? " SELECTED" : "") .">$name</OPTION>\n";
@@ -22,4 +24,6 @@ function find_module($name) {
 $theme->box(t("Result"), $output);
 $theme->footer();
 
+page_footer();
+
 ?>
\ No newline at end of file
diff --git a/submit.php b/submit.php
index 726439a38a41..2a78a68191b8 100644
--- a/submit.php
+++ b/submit.php
@@ -2,6 +2,8 @@
 
 include_once "includes/common.inc";
 
+page_header();
+
 $theme->header();
 
 if ($user->id) {
@@ -28,4 +30,6 @@
 
 $theme->footer();
 
+page_footer();
+
 ?>
-- 
GitLab