Przeglądaj źródła

made data path relative

Luke Ehresman 25 lat temu
rodzic
commit
e787339ae0
7 zmienionych plików z 31 dodań i 16 usunięć
  1. 14 0
      config/config.php
  2. 7 7
      functions/prefs.php
  3. 2 2
      functions/smtp.php
  4. 2 1
      src/load_prefs.php
  5. 2 2
      src/options.php
  6. 3 3
      src/options_submit.php
  7. 1 1
      src/webmail.php

+ 14 - 0
config/config.php

@@ -104,4 +104,18 @@
 //  Whether or not to use META tags and automatically forward after an action has
 //  been completed.
     $auto_forward = true;
+
+//  Path to the data/ directory
+//    It is a possible security hole to have a writable directory under the web server's
+//    root directory (ex: /home/httpd/html).  For this reason, it is possible to put
+//    the data directory anywhere you would like.   The path name can be absolute or
+//    relative (to the config directory).  It doesn't matter.  Here are two examples:
+//
+//  Absolute:
+//    $data_dir = "/usr/local/squirrelmail/data/";
+//
+//  Relative (to the config directory):
+//    $data_dir = "../data/";
+
+    $data_dir = "../data/haha/";
 ?>

+ 7 - 7
functions/prefs.php

@@ -6,8 +6,8 @@
     **/
 
    /** returns the value for $string **/
-   function getPref($username, $string) {
-      $filename = "../data/$username.pref";
+   function getPref($data_dir, $username, $string) {
+      $filename = "$data_dir$username.pref";
       if (!file_exists($filename)) {
          echo "Preference file \"$filename\" not found.  Exiting abnormally";
          exit;
@@ -28,8 +28,8 @@
    }
 
    /** sets the pref, $string, to $set_to **/
-   function setPref($username, $string, $set_to) {
-      $filename = "../data/$username.pref";
+   function setPref($data_dir, $username, $string, $set_to) {
+      $filename = "$data_dir$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>";
@@ -67,10 +67,10 @@
    }
 
    /** This checks if there is a pref file, if there isn't, it will create it. **/
-   function checkForPrefs($username) {
-      $filename = "../data/$username.pref";
+   function checkForPrefs($data_dir, $username) {
+      $filename = "$data_dir$username.pref";
       if (!file_exists($filename)) {
-         if (!copy("../data/default_pref", $filename)) {
+         if (!copy("$data_dirdefault_pref", $filename)) {
             echo "Error opening $filename";
             exit;
          }

+ 2 - 2
functions/smtp.php

@@ -24,8 +24,8 @@
       $bcc = parseAddrs($b);
       $body = stripslashes($body);
       $from_addr = "$username@$domain";
-      $reply_to = getPref($username, "reply_to");
-      $from = getPref($username, "full_name");
+      $reply_to = getPref($data_dir, $username, "reply_to");
+      $from = getPref($data_dir, $username, "full_name");
       if ($from == "")
          $from = "<$from_addr>";
       else

+ 2 - 1
src/load_prefs.php

@@ -1,7 +1,8 @@
 <?
+   include("../config/config.php");
    include("../functions/prefs.php");
 
-   $chosen_theme = getPref($username, "chosen_theme");
+   $chosen_theme = getPref($data_dir, $username, "chosen_theme");
 
    if (isset($chosen_theme)) {
       require("$chosen_theme");

+ 2 - 2
src/options.php

@@ -14,8 +14,8 @@
    displayPageHeader($color, "None");
 
    /** load up some of the values from the pref file **/
-   $fullname = getPref($username, "full_name");
-   $replyto  = getPref($username, "reply_to");
+   $fullname = getPref($data_dir, $username, "full_name");
+   $replyto  = getPref($data_dir, $username, "reply_to");
    if ($replyto == "")
       $replyto = "$username@$domain";
 

+ 3 - 3
src/options_submit.php

@@ -13,9 +13,9 @@
    echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
    displayPageHeader($color, "None");
 
-   setPref($username, "full_name", $full_name);
-   setPref($username, "reply_to", $reply_to);
-   setPref($username, "chosen_theme", $chosentheme);
+   setPref($data_dir, $username, "full_name", $full_name);
+   setPref($data_dir, $username, "reply_to", $reply_to);
+   setPref($data_dir, $username, "chosen_theme", $chosentheme);
 
    echo "<FONT FACE=\"Arial,Helvetica\">";
    echo "<BR><BR><BR><CENTER><B>Options Saved!</B><BR><BR>";

+ 1 - 1
src/webmail.php

@@ -38,7 +38,7 @@
     we would like to use as little Javascript as possible.
 **/
 <?
-   checkForPrefs($username);
+   checkForPrefs($data_dir, $username);
 
    if ($right_frame == "right_main.php") {
       $urlMailbox = urlencode($mailbox);