From 9a5e960638f32b977bfeaf2dcc430c7274f71f83 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Wed, 4 Oct 2000 10:25:08 +0000
Subject: [PATCH] * Reorganised a few things and fixed the theme-update bug
 reported by UCD.

---
 account.php    |  6 +++---
 admin.inc      |  1 +
 admin.php      |  6 ++++++
 diary.php      |  4 +---
 discussion.php |  2 --
 faq.php        |  1 -
 function.inc   | 14 +++++++++++++-
 index.php      |  1 -
 search.php     |  1 -
 submission.php |  1 -
 submit.php     |  1 -
 theme.inc      | 10 ++--------
 12 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/account.php b/account.php
index 2de4c412af18..c6fbd0f27cf2 100644
--- a/account.php
+++ b/account.php
@@ -1,7 +1,5 @@
 <?
 
-include "function.inc";
-include "config.inc";
 include "theme.inc";
 
 function account_getUser($uname) {
@@ -87,7 +85,7 @@ function showUser($uname) {
   }
 }
 
-function newUser($user = "", $error="") {
+function newUser($user = "", $error = "") {
   global $theme;
 
   $output .= "<FORM ACTION=\"account.php\" METHOD=post>\n";
@@ -328,6 +326,8 @@ function account_track_comments() {
       $data[signature] = $edit[signature];
       dbsave("users", $data, $user->id);
       user_rehash();
+
+      header("account.php");
     }
     showUser($user->userid);
     break;
diff --git a/admin.inc b/admin.inc
index e81bd21e1fa2..2fafaf668cb3 100644
--- a/admin.inc
+++ b/admin.inc
@@ -24,6 +24,7 @@ function admin_header() {
        <LI><A HREF="admin.php?section=bans">bans</A></LI>
        <LI><A HREF="admin.php?section=logs">logs</A></LI>
        <LI><A HREF="admin.php?section=stories">stories</A></LI>
+       <LI><A HREF="admin.php?section=info">info</A></LI>
       <P>
        <LI><A HREF="">home</A></LI>
      </TD>
diff --git a/admin.php b/admin.php
index 8de5a5c847b2..f69dc2c6e9d8 100644
--- a/admin.php
+++ b/admin.php
@@ -375,6 +375,10 @@ function story_display($order = "date") {
   print $output;
 }
 
+function info_display() {
+  phpinfo();
+}
+
 include "function.inc";
 include "admin.inc";
 
@@ -440,6 +444,8 @@ function story_display($order = "date") {
         story_display();
     }
     break;
+  case "info":
+    info_display();
   default:
     print "Welcome to the adminstration page!";
 }
diff --git a/diary.php b/diary.php
index 767a3e1a9e96..2ca2f320f242 100644
--- a/diary.php
+++ b/diary.php
@@ -1,8 +1,6 @@
 <?
-include "function.inc";
-include "config.inc";
-include "theme.inc";
 
+include "theme.inc";
 
 function diary_overview($num = 20) {
   global $theme, $user;
diff --git a/discussion.php b/discussion.php
index 8a2cbd5ce336..f94a7ac2ca55 100644
--- a/discussion.php
+++ b/discussion.php
@@ -302,8 +302,6 @@ function comment_post($pid, $sid, $subject, $comment) {
   }
 }
 
-include "function.inc";
-include "config.inc";
 include "theme.inc";
 
 switch($op) {  
diff --git a/faq.php b/faq.php
index 1cf4aa3ecb9c..c53ffb8ccc21 100644
--- a/faq.php
+++ b/faq.php
@@ -1,5 +1,4 @@
 <?
-include "function.inc";
 include "theme.inc";
 
 $output = "
diff --git a/function.inc b/function.inc
index 2c69e4fb9b94..a3fb0111a6ba 100644
--- a/function.inc
+++ b/function.inc
@@ -1,6 +1,5 @@
 <?
 
-include "config.inc";
 include "database.inc";
 include "log.inc";
 
@@ -21,6 +20,19 @@ function dbsave($dbase, $data, $id=0) {
   else { db_query("INSERT INTO $dbase SET $query") or die(mysql_error()); return mysql_insert_id(); }
 }
 
+function load_theme() {
+  global $user, $themes;
+
+  if ($user->theme && file_exists($themes[$user->theme][0])) {
+    include $themes[$user->theme][0];     
+  }
+  else {
+    include $themes[key($themes)][0];
+  }
+ 
+  return new Theme();
+}
+
 function check_input($message) {
   return str_replace("\"", "&quot;", stripslashes($message));
 }
diff --git a/index.php b/index.php
index ec5dd58c1081..9f6167d6aee1 100644
--- a/index.php
+++ b/index.php
@@ -1,6 +1,5 @@
 <?
 
-include "function.inc";
 include "theme.inc";
 
 ### Initialize/pre-process variables:
diff --git a/search.php b/search.php
index fb616cab0b95..004848bebfdd 100644
--- a/search.php
+++ b/search.php
@@ -1,6 +1,5 @@
 <?
 
- include "function.inc";
  include "theme.inc";
 
  $theme->header();
diff --git a/submission.php b/submission.php
index ad61af4221dc..35db5290d6ed 100644
--- a/submission.php
+++ b/submission.php
@@ -1,6 +1,5 @@
 <?
 include "submission.inc";
-include "function.inc";
 include "theme.inc";
 
 function submission_displayMain() {
diff --git a/submit.php b/submit.php
index b921c6a3f89c..052dd90f5f7b 100644
--- a/submit.php
+++ b/submit.php
@@ -146,7 +146,6 @@ function submit_submit($subject, $abstract, $article, $category) {
   watchdog(1, "added new submission with subject `$subject'.");
 }
 
-include "function.inc";
 include "theme.inc";
 
 switch($op) {
diff --git a/theme.inc b/theme.inc
index eedf5e2bb67e..9d0b5a0a66c1 100644
--- a/theme.inc
+++ b/theme.inc
@@ -1,17 +1,11 @@
 <?
 
 include "config.inc";
+include "function.inc";
 include "template.inc";
 
 global $user;
 
-if ($user->theme && file_exists($themes[$user->theme][0])) {
-  include $themes[$user->theme][0];	
-}
-else {
-  include $themes[key($themes)][0];
-}
-
-$theme = new Theme();
+$theme = load_theme();
 
 ?>
\ No newline at end of file
-- 
GitLab