Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

Settings.php

Go to the documentation of this file.
00001 <?php
00002 /* $Id: Settings.php,v 1.1 2003/09/29 15:48:52 mikko Exp $ */
00003 /*
00004  * ImaComm - a web based photo album software
00005  * Copyright (C) 2003, Mikko Kokkonen
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or (at
00010  * your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020  */
00021 
00022 global $settings_file;
00023 $settings_file = realpath(dirname(__FILE__)."/../conf/")."/settings";
00024 // {{{ class Settingas
00025 class Settings
00026 {
00027         var $file;
00028         var $attributes;
00029         var $prefix;
00030 
00031         function Settings()
00032         {
00033         }
00034 
00035         function newFile()
00036         {
00037         }
00038 
00039         function saveFile()
00040         {
00041                 global $settings_file;
00042                 print "DG: $settings_file";
00043                 $buf = serialize($this);
00044                 // Open file...
00045                 // Do we support BZip2?
00046                 if (function_exists("bzopen") && function_exists("bzwrite") && function_exists("bzclose"))
00047                 {
00048                         $fp = bzopen($settings_file.".bz2", "w");
00049                         if ($fp)
00050                         {
00051                                 bzwrite($fp, $buf);
00052                                 bzclose($fp);
00053                         }
00054                 }
00055                 else
00056                 {
00057                         $fp = @fopen($settings_file, "w");
00058                         if ($fp)
00059                         {
00060                                 fputs($fp, $buf);
00061                                 fclose($fp);
00062                         }
00063                 }
00064         }
00065 
00066         
00067         function attribute($name, $value = null)
00068         {
00069                 if ($value == null)
00070                 {
00071                         return $this->attributes[$name];
00072                 }
00073                 $this->attributes[$name] = $value;
00074         }
00075 }
00076 // }}}
00077 
00078 function loadSettingsFile()
00079 {
00080         global $settings_file, $settings;
00081         // Are we having BZip2 file?
00082         if (file_exists("$settings_file.bz2") && function_exists("bzopen") && function_exists("bzread") && function_exists("bzclose"))
00083         {
00084                 $fp = bzopen($settings_file.".bz2", "r");
00085                 if ($fp)
00086                 {
00087                         while (!feof($fp))
00088                         {
00089                                 $buf .= bzread($fp, 4096);
00090                         }
00091                         bzclose($fp);
00092                 }
00093                 else
00094                 {
00095                         print "Could not open $settings_file.bz2!";
00096                 }
00097         }
00098         else
00099         {
00100                 $fp = fopen($settings_file, "r");
00101                 if ($fp)
00102                 {
00103                         $buf = fread($fp, filesize($settings_file));
00104                         fclose($fp);
00105                 }
00106         }
00107         $settings = unserialize($buf);
00108 }
00109 ?>

Generated on Sun Oct 19 11:08:00 2003 for ImaComm by doxygen1.3