phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] phpgwapi/inc class.config.inc.php,1.7.2.1.2.5


From: skwashd
Subject: [Phpgroupware-cvs] phpgwapi/inc class.config.inc.php,1.7.2.1.2.5
Date: Wed, 3 Aug 2005 10:40:00 +0200

Update of phpgwapi/inc

Modified Files:
     Branch: Version-0_9_16-branch
            class.config.inc.php lines: +28 -18

Log Message:
fix slashes and tidy up, modernize etc

====================================================
Index: phpgwapi/inc/class.config.inc.php
diff -u phpgwapi/inc/class.config.inc.php:1.7.2.1.2.4 
phpgwapi/inc/class.config.inc.php:1.7.2.1.2.5
--- phpgwapi/inc/class.config.inc.php:1.7.2.1.2.4       Thu Jan  6 01:01:57 2005
+++ phpgwapi/inc/class.config.inc.php   Wed Aug  3 08:40:31 2005
@@ -2,6 +2,7 @@
        /**
        * Application configuration in a centralized location
        * @author Joseph Engo <address@hidden>
+       * @author Dave Hall - skwashd at phpgroupware.org
        * @copyright Copyright (C) 2000-2004 Free Software Foundation, Inc. 
http://www.fsf.org/
        * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General 
Public License
        * @package phpgwapi
@@ -37,41 +38,50 @@
                        $this->db->query("select * from phpgw_config where 
config_app='" . $this->appname . "'",__LINE__,__FILE__);
                        while ($this->db->next_record())
                        {
-                               $test = 
@unserialize($this->db->f('config_value'));
+                               $test = 
@unserialize($this->db->f('config_value', true));
                                if($test)
                                {
                                        
$this->config_data[$this->db->f('config_name')] = $test;
                                }
                                else
                                {
-                                       
$this->config_data[$this->db->f('config_name')] = $this->db->f('config_value');
+                                       
$this->config_data[$this->db->f('config_name')] = $this->db->f('config_value', 
true);
                                }
                        }
                }

                function save_repository()
                {
-                       $config_data = $this->config_data;
-
-                       if ($config_data)
+                       if ( is_array($this->config_data) && 
count($this->config_data) )
                        {
-                               
$this->db->lock(array('phpgw_config','phpgw_app_sessions'));
-                               //$this->db->query("delete from phpgw_config 
where config_app='" . $this->appname . "'",__LINE__,__FILE__); this is 
dangerous!
+                               $config_data =& $this->config_data;
+
+                               $this->db->lock(array('phpgw_config', 
'phpgw_app_sessions'));
+                               //$this->db->query("DELETE FROM phpgw_config 
WHERE config_app = '{$this->appname}'",__LINE__,__FILE__); //someone removed 
this without a proper explanation!
                                if($this->appname == 'phpgwapi')
                                {
-                                       $this->db->query("delete from 
phpgw_app_sessions where sessionid = '0' and loginid = '0' and app = 
'".$this->appname."' and location = 'config'",__LINE__,__FILE__);
+                                       $this->db->query('DELETE FROM 
phpgw_app_sessions'
+                                               . ' WHERE sessionid = \'0\''
+                                                       . ' AND loginid = 0'
+                                                       . " AND app = 
'{$this->appname}"
+                                                       . ' AND location = 
\'config\'',
+                                               __LINE__, __FILE__);
                                }
-                               while (list($name,$value) = each($config_data))
+
+                               foreach($config_data as $name => $value)
                                {
-                                       if(is_array($value))
+                                       if( is_array($value) || 
is_object($value) )
                                        {
                                                $value = serialize($value);
                                        }
-                                       $name  = addslashes($name);
-                                       $value = addslashes($value);
-                                       $this->db->query("DELETE from 
phpgw_config WHERE config_app='" . $this->appname . "' AND config_name='" . 
$name . "'",__LINE__,__FILE__);
-                                       $query = "insert into phpgw_config 
(config_app,config_name,config_value) " . "values ('" . $this->appname . "','" 
. $name . "','" . $value . "')";
-                                       
$this->db->query($query,__LINE__,__FILE__);
+
+                                       $name  = 
$this->db->db_addslashes($name);
+                                       $value = 
$this->db->db_addslashes($value);
+                                       $this->db->query("DELETE FROM 
phpgw_config WHERE config_name='{$name}'", __LINE__, __FILE__);
+
+                                       $query = "INSERT INTO phpgw_config 
(config_app,config_name,config_value)"
+                                               . " VALUES ('{$this->appname}', 
'{$name}', '{$value}')";
+                                       $this->db->query($query, __LINE__, 
__FILE__);
                                }
                                $this->db->unlock();
                        }
@@ -79,10 +89,10 @@

                function delete_repository()
                {
-                       $this->db->query("delete from phpgw_config where 
config_app='" . $this->appname . "'",__LINE__,__FILE__);
+                       $this->db->query("DELETE FROM phpgw_config WHERE 
config_app = '{$this->appname}'", __LINE__, __FILE__);
                }

-               function value($variable_name,$variable_data)
+               function value($variable_name, $variable_data)
                {
                        $this->config_data[$variable_name] = $variable_data;
                }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]