Beginnings of the options menu
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 6 Jan 2000 00:48:05 +0000 (00:48 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 6 Jan 2000 00:48:05 +0000 (00:48 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@106 7612ce4b-ef26-0410-bec9-ea0150e637f0

INSTALL
data/default_pref [new file with mode: 0644]
functions/page_header.php
functions/prefs.php [new file with mode: 0644]
src/options.php [new file with mode: 0644]
src/webmail.php

diff --git a/INSTALL b/INSTALL
index a10c48668189d824d48d2ea9b602cc11c4379f07..5eba5aff399666b4725f16fef7b67932539eab0e 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -8,5 +8,14 @@ overview of how to install SquirrelMail.
 
 3.  Edit the config file, config/config.php
 
-4.  Point your browser to the location you specified in step 2.
+4.  Change the permissons for the "data/" directory so it's writable to
+    the web server.  Under Red Hat Linux 6.0, this is done by:
+
+    chown nobody data
+    chgrp nobody data
+
+    "nobody" is the user and group for the apache server for this
+    example.
+
+5.  Point your browser to the location you specified in step 2.
     In this example, it's:  http://YOURHOST/squirrelmail-0.1/index.html
diff --git a/data/default_pref b/data/default_pref
new file mode 100644 (file)
index 0000000..3ba5501
--- /dev/null
@@ -0,0 +1,3 @@
+theme=default_theme.php
+full_name=Luke Ehresman
+reply_to=luke@usa.om.org
\ No newline at end of file
index 815855702d2c276939ee63907258e78893d6e335..e8b360ea87020a7051cca28a0398884ca4749e05 100644 (file)
@@ -22,7 +22,7 @@
       echo "         <FONT FACE=\"Arial,Helvetica\"><A HREF=\"compose.php\">Compose</A></FONT>&nbsp&nbsp";
       echo "         <FONT FACE=\"Arial,Helvetica\">Addresses</FONT>&nbsp&nbsp";
       echo "         <FONT FACE=\"Arial,Helvetica\"><A HREF=\"folders.php\">Folders</A></FONT>&nbsp&nbsp";
-      echo "         <FONT FACE=\"Arial,Helvetica\">Options</FONT>&nbsp&nbsp";
+      echo "         <FONT FACE=\"Arial,Helvetica\"><A HREF=\"options.php\">Options</A></FONT>&nbsp&nbsp";
       echo "      </TD><TD ALIGN=right WIDTH=30%>";
       echo "         <FONT FACE=\"Arial,Helvetica\"><A HREF=\"http://squirrelmail.sourceforge.net\" TARGET=_top>SquirrelMail</A></FONT>";
       echo "      </TD>";
diff --git a/functions/prefs.php b/functions/prefs.php
new file mode 100644 (file)
index 0000000..1f6891b
--- /dev/null
@@ -0,0 +1,75 @@
+<?
+   /**
+    **  prefs.php
+    **
+    **  This contains functions for manipulating user preferences
+    **/
+
+   /** returns the value for $string **/
+   function getPref($username, $string) {
+      $filename = "../data/$username.pref";
+      $file = fopen($filename, "r");
+
+      /** read in all the preferences **/
+      for ($i=0; !feof($file); $i++) {
+         $pref = fgets($file, 1024);
+         if (substr($pref, 0, strpos($pref, "=")) == $string) {
+            fclose($file);
+            return substr($pref, strpos($pref, "=")+1);
+         }
+      }
+      fclose($file);
+      return "";
+   }
+
+   /** sets the pref, $string, to $set_to **/
+   function setPref($username, $string, $set_to) {
+      $filename = "../data/$username.pref";
+      $found = false;
+      if (!file_exists($filename)) {
+         echo "Preference file, $filename, does not exist.  Log out, and log back in to create a default preference file.<BR>";
+         exit;
+      }
+      $file = fopen($filename, "r");
+
+      /** read in all the preferences **/
+      for ($i=0; !feof($file); $i++) {
+         $pref[$i] = fgets($file, 1024);
+         if (substr($pref[$i], 0, strpos($pref[$i], "=")) == $string) {
+            $found = true;
+            $pos = $i;
+         }
+      }
+      fclose($file);
+
+      $file = fopen($filename, "w");
+      if ($found == true) {
+         for ($i=0; $i < count($pref); $i++) {
+            if ($i == $pos) {
+               fwrite($file, "$string=$set_to\n", 1024);
+            } else {
+               fwrite($file, "$pref[$i]", 1024);
+            }
+         }
+      } else {
+         for ($i=0; $i < count($pref); $i++) {
+            fwrite($file, "$pref[$i]", 1024);
+         }
+         fwrite($file, "$string=$set_to\n", 1024);
+      }
+
+      fclose($file);
+   }
+
+   /** This checks if there is a pref file, if there isn't, it will create it. **/
+   function checkForPrefs($username) {
+      $filename = "../data/default_pref";
+      if (!file_exists($filename)) {
+         if (!copy("../config/default.pref", $filename)) {
+            echo "Error opening $filename";
+            exit;
+         }
+      }
+      return;
+   }
+?>
\ No newline at end of file
diff --git a/src/options.php b/src/options.php
new file mode 100644 (file)
index 0000000..3a819a0
--- /dev/null
@@ -0,0 +1,23 @@
+<?
+   include("../config/config.php");
+   include("../functions/mailbox.php");
+   include("../functions/strings.php");
+   include("../functions/page_header.php");
+   include("../functions/display_messages.php");
+   include("../functions/imap.php");
+   include("../functions/array.php");
+   include("../functions/prefs.php");
+
+   echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+   displayPageHeader($color, "None");
+
+   echo "<TABLE WIDTH=100% COLS=1 ALIGN=CENTER>\n";
+   echo "   <TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER>\n";
+   echo "      <FONT FACE=\"Arial,Helvetica\">Options</FONT>\n";
+   echo "   </TD></TR>\n";
+   echo "</TABLE>\n";
+
+   echo getPref($username, "full_name");
+
+   echo "</BODY></HTML>";
+?>
\ No newline at end of file
index aaaaf785a0ffe7643d2ed728c415915705e4a3b2..8f11384b439c8a745ea94a5ad3d2af9809fb05ac 100644 (file)
@@ -19,6 +19,7 @@
 <TITLE>
 <?
    include ("../config/config.php");
+   include ("../functions/prefs.php");
    echo "$org_title";
 ?>
 </TITLE>
@@ -37,6 +38,8 @@
     we would like to use as little Javascript as possible.
 **/
 <?
+   checkForPrefs($username);
+
    if ($right_frame == "right_main.php") {
       $urlMailbox = urlencode($mailbox);
       echo "<FRAME SRC=\"left_main.php\" NAME=\"left\">";