phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] CVS: brewer/inc class.brew.inc.php,1.5,1.6 class.reci


From: Miles Lott <address@hidden>
Subject: [Phpgroupware-cvs] CVS: brewer/inc class.brew.inc.php,1.5,1.6 class.recipe.inc.php,1.7,1.8 class.std.inc.php,1.6,1.7
Date: Fri, 08 Feb 2002 00:59:14 -0500

Update of /cvsroot/phpgroupware/brewer/inc
In directory subversions:/tmp/cvs-serv26878

Modified Files:
        class.brew.inc.php class.recipe.inc.php class.std.inc.php 
Log Message:
Use the global db object, gettype changes



Index: class.brew.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/brewer/inc/class.brew.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** class.brew.inc.php  11 Sep 2001 12:38:28 -0000      1.5
--- class.brew.inc.php  8 Feb 2002 05:59:12 -0000       1.6
***************
*** 285,289 ****
                function save_sessiondata($data='')
                {
!                       if (gettype($data) == 'array')
                        {
                                
$GLOBALS['phpgw']->session->appsession('session_data','brewer',$data);
--- 285,289 ----
                function save_sessiondata($data='')
                {
!                       if (is_array($data))
                        {
                                
$GLOBALS['phpgw']->session->appsession('session_data','brewer',$data);

Index: class.recipe.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/brewer/inc/class.recipe.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** class.recipe.inc.php        11 Sep 2001 12:38:28 -0000      1.7
--- class.recipe.inc.php        8 Feb 2002 05:59:12 -0000       1.8
***************
*** 230,234 ****
                                        if($a != 'id')
                                        {
!                                               if(gettype($this->recipe[$b]) 
== 'array')
                                                {
                                                        $data = 
serialize($this->recipe[$b]);
--- 230,234 ----
                                        if($a != 'id')
                                        {
!                                               if(is_array($this->recipe[$b]))
                                                {
                                                        $data = 
serialize($this->recipe[$b]);
***************
*** 252,256 ****
                                        }
                                        if($DEBUG) { echo '<br>Checking: ' . 
$val . '=' .$this->recipe[$val]; }
!                                       if(gettype($this->recipe[$val]) == 
'array')
                                        {
                                                $values[$key] = 
serialize($this->recipe[$val]);
--- 252,256 ----
                                        }
                                        if($DEBUG) { echo '<br>Checking: ' . 
$val . '=' .$this->recipe[$val]; }
!                                       if(is_array($this->recipe[$val]))
                                        {
                                                $values[$key] = 
serialize($this->recipe[$val]);

Index: class.std.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/brewer/inc/class.std.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** class.std.inc.php   11 Sep 2001 12:38:28 -0000      1.6
--- class.std.inc.php   8 Feb 2002 05:59:12 -0000       1.7
***************
*** 83,95 ****
                function std($tbldef='')
                {
-                       /* Set the db object */
-                       $this->db = $GLOBALS['phpgw']->db;
- 
                        /* check for tablename */
!                       if (gettype($tbldef) == 'array')
                        {
                                /* Set the table name */
                                $this->table  = $tbldef[0];
!                               if(gettype($tbldef[1]) == 'array')
                                {
                                        /* Set the field list */
--- 83,92 ----
                function std($tbldef='')
                {
                        /* check for tablename */
!                       if (is_array($tbldef))
                        {
                                /* Set the table name */
                                $this->table  = $tbldef[0];
!                               if(is_array($tbldef[1]))
                                {
                                        /* Set the field list */
***************
*** 106,125 ****
                        $fields = $this->_get_fields();
                        $fieldstr = implode(',',$fields);
!                       if (!$id)
                        {
                                $id = $this->id;
                        }
  
!                       $sql = "SELECT " . $fieldstr . " FROM " . $this->table 
. " WHERE id=" . $id;
  
                        $this->_debug('<br>get(): ' . $sql);
  
!                       $this->db->query($sql,__LINE__,__FILE__);
!                       $this->db->next_record();
  
                        @reset($fields);
                        while(list($a,$b) = each($fields))
                        {
!                               $c = unserialize($this->db->f($b));
                                $d = gettype($c);
                                if(($d == 'array' || $d == 'object') && 
$unserial)
--- 103,122 ----
                        $fields = $this->_get_fields();
                        $fieldstr = implode(',',$fields);
!                       if(!$id)
                        {
                                $id = $this->id;
                        }
  
!                       $sql = 'SELECT ' . $fieldstr . ' FROM ' . $this->table 
. ' WHERE id=' . $id;
  
                        $this->_debug('<br>get(): ' . $sql);
  
!                       $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
!                       $GLOBALS['phpgw']->db->next_record();
  
                        @reset($fields);
                        while(list($a,$b) = each($fields))
                        {
!                               $c = unserialize($GLOBALS['phpgw']->db->f($b));
                                $d = gettype($c);
                                if(($d == 'array' || $d == 'object') && 
$unserial)
***************
*** 129,135 ****
                                else
                                {
!                                       $e = $this->db->f($b);
                                }
!                               $this->data[$this->db->f('id')][$b] = $e;
                        }
                        return $this->data;
--- 126,132 ----
                                else
                                {
!                                       $e = $GLOBALS['phpgw']->db->f($b);
                                }
!                               $this->data[$GLOBALS['phpgw']->db->f('id')][$b] 
= $e;
                        }
                        return $this->data;
***************
*** 143,152 ****
                        if($id)
                        {
!                               $sql = "UPDATE " . $this->table . " SET ";
                                while(list($a,$b) = each($this->data))
                                {
!                                       if ($a != 'id' && gettype($a) != 
'integer')
                                        {
!                                               if((gettype($b) == 'array') && 
$serial)
                                                {
                                                        $b = serialize($c);
--- 140,149 ----
                        if($id)
                        {
!                               $sql = 'UPDATE ' . $this->table . ' SET ';
                                while(list($a,$b) = each($this->data))
                                {
!                                       if($a != 'id' && !is_int($a))
                                        {
!                                               if(is_array($b) && $serial)
                                                {
                                                        $b = serialize($c);
***************
*** 155,166 ****
                                        }
                                }
!                               $sql = substr($sql,0,-1) . " WHERE id=" . $id;
                        }
                        else
                        {
                                $values = "'" . implode("','",$this->data) . 
"'";
!                               $sql = "INSERT INTO " . $this->table . "(" . 
$fieldstr . ") VALUES (" . $values . ")";
                        }
!                       $ret = $this->db->query($sql,__LINE__,__FILE__);
                        return $ret;
                }
--- 152,163 ----
                                        }
                                }
!                               $sql = substr($sql,0,-1) . ' WHERE id=' . $id;
                        }
                        else
                        {
                                $values = "'" . implode("','",$this->data) . 
"'";
!                               $sql = 'INSERT INTO ' . $this->table . '(' . 
$fieldstr . ') VALUES (' . $values . ')';
                        }
!                       $ret = 
$GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
                        return $ret;
                }
***************
*** 183,187 ****
                        }
  
!                       $sql = "SELECT " . $fieldstr . " FROM " . $this->table 
. $querystr;
  
                        if($sort && $order)
--- 180,184 ----
                        }
  
!                       $sql = 'SELECT ' . $fieldstr . ' FROM ' . $this->table 
. $querystr;
  
                        if($sort && $order)
***************
*** 196,208 ****
                        if($limit)
                        {
!                               $qfunc = '$this->db->limit_query("' . $sql . 
$sort . '",' . $start . ',__LINE__,__FILE__);';
                        }
                        else
                        {
!                               $qfunc = '$this->db->query("' . $sql . $sort . 
'",__LINE__,__FILE__);';
                        }
  
!                       $this->db->query($sql,__LINE__,__FILE__);
!                       $this->total = $this->db->num_rows();
  
                        eval($qfunc);
--- 193,205 ----
                        if($limit)
                        {
!                               $qfunc = 
"\$GLOBALS['phpgw']->db->limit_query(\"" . $sql . $sort . '",' . $start . 
',__LINE__,__FILE__);';
                        }
                        else
                        {
!                               $qfunc = "\$GLOBALS['phpgw']->db->query(\"" . 
$sql . $sort . '",__LINE__,__FILE__);';
                        }
  
!                       $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
!                       $this->total = $GLOBALS['phpgw']->db->num_rows();
  
                        eval($qfunc);
***************
*** 210,223 ****
                        $this->_debug('<br>get_list(): ' . $sql);
  
!                       if($this->db->num_rows())
                        {
                                $this->data = array();
                        }
!                       while ($this->db->next_record())
                        {
                                @reset($fields);
                                while(list($a,$b) = @each($fields))
                                {
!                                       $c = unserialize($this->db->f($b));
                                        $d = gettype($c);
                                        if(($d == 'array' || $d == 'object') && 
$unserial)
--- 207,220 ----
                        $this->_debug('<br>get_list(): ' . $sql);
  
!                       if($GLOBALS['phpgw']->db->num_rows())
                        {
                                $this->data = array();
                        }
!                       while ($GLOBALS['phpgw']->db->next_record())
                        {
                                @reset($fields);
                                while(list($a,$b) = @each($fields))
                                {
!                                       $c = 
unserialize($GLOBALS['phpgw']->db->f($b));
                                        $d = gettype($c);
                                        if(($d == 'array' || $d == 'object') && 
$unserial)
***************
*** 227,234 ****
                                        else
                                        {
!                                               $e = $this->db->f($b);
                                        }
!                                       
$this->_debug('<br>get_list()$this->data[' . $this->db->f('id') . '][' . $b . 
'] is : ',$e);
!                                       $this->data[$this->db->f('id')][$b] = 
$e;
                                }
                        }
--- 224,231 ----
                                        else
                                        {
!                                               $e = 
$GLOBALS['phpgw']->db->f($b);
                                        }
!                                       
$this->_debug('<br>get_list()$this->data[' . $GLOBALS['phpgw']->db->f('id') . 
'][' . $b . '] is : ',$e);
!                                       
$this->data[$GLOBALS['phpgw']->db->f('id')][$b] = $e;
                                }
                        }
***************
*** 239,243 ****
                function formatted_list($id=0,$name='',$java=True)
                {
!                       if (!$name)
                        {
                                return False;
--- 236,240 ----
                function formatted_list($id=0,$name='',$java=True)
                {
!                       if(!$name)
                        {
                                return False;
***************
*** 245,249 ****
                        $list = $this->get_list(0,'','ASC','',False);
  
!                       if ($java)
                        {
                                $jselect = ' onChange="this.form.submit();"';
--- 242,246 ----
                        $list = $this->get_list(0,'','ASC','',False);
  
!                       if($java)
                        {
                                $jselect = ' onChange="this.form.submit();"';
***************
*** 252,259 ****
                        $select  = "\n" .'<select name="newval[' . $name . ']"' 
. $jselect . ">\n";
                        $select .= '<option value="0">' . lang('Please Select') 
. '</option>'."\n";
!                       while (list($key,$val) = each($list))
                        {
                                $select .= '<option value="' . $val['id'] . '"';
!                               if ($val['id'] == $id)
                                {
                                        $select .= ' selected';
--- 249,256 ----
                        $select  = "\n" .'<select name="newval[' . $name . ']"' 
. $jselect . ">\n";
                        $select .= '<option value="0">' . lang('Please Select') 
. '</option>'."\n";
!                       while(list($key,$val) = each($list))
                        {
                                $select .= '<option value="' . $val['id'] . '"';
!                               if($val['id'] == $id)
                                {
                                        $select .= ' selected';
***************
*** 286,290 ****
                        {
                                @reset($this->fields);
!                               while (list($key,$val) = each($this->fields))
                                {
                                        $fields[] = $key;
--- 283,287 ----
                        {
                                @reset($this->fields);
!                               while(list($key,$val) = each($this->fields))
                                {
                                        $fields[] = $key;
***************
*** 297,301 ****
                function _makequery($query='')
                {
!                       if (!$query || $this->qstr)
                        {
                                return;
--- 294,298 ----
                function _makequery($query='')
                {
!                       if(!$query || $this->qstr)
                        {
                                return;
***************
*** 310,319 ****
                        }
  
!                       $s = " WHERE (";
  
                        $fields = $this->_get_fields();
!                       while (list($key,$val) = each($fields))
                        {
!                               if ($val != 'id')
                                {
                                        $s .= $val . " LIKE '%$look%' OR ";
--- 307,316 ----
                        }
  
!                       $s = ' WHERE (';
  
                        $fields = $this->_get_fields();
!                       while(list($key,$val) = each($fields))
                        {
!                               if($val != 'id')
                                {
                                        $s .= $val . " LIKE '%$look%' OR ";
***************
*** 321,325 ****
                        }
                        $s = substr($s,0,-4);
!                       $s .= ")";
  
                        return $s;
--- 318,322 ----
                        }
                        $s = substr($s,0,-4);
!                       $s .= ')';
  
                        return $s;
***************
*** 339,404 ****
                                        var_dump($var);
                                }
-                       }
-               }
- 
-               /*!
-               @function is_serialized
-               @abstract find out if something is already serialized
-               @param $data could be almost anything
-               */
-               function is_serialized($data)
-               {
-                       /* not totally complete: currently works with strings, 
arrays, and booleans (update this if more is added) */
-               
-                        /* FUTURE: detect a serialized data that had 
addslashes appplied AFTER it was serialized
-                        you can NOT unserialize that data until those 
post-serialization slashes are REMOVED */
- 
-                       //echo 'is_serialized initial input [' .$data .']<br>';
-                       //echo 'is_serialized unserialized input [' 
.unserialize($data) .']<br>';
- 
-                       if (is_array($data))
-                       {
-                               // arrays types are of course not serialized 
(at least not at the top level)
-                               // BUT there  may be serialization INSIDE in a 
sub part
-                               return False;
-                       }
-                       elseif (is_bool($data))
-                       {
-                               // a boolean type is of course not serialized
-                               return False;
-                       }
-                       elseif ((is_string($data))
-                       && (($data == 'b:0;') || ($data == 'b:1;')) )
-                       {
-                               // check for easily identifiable serialized 
boolean values
-                               return True;
-                       }
-                       elseif ((is_string($data))
-                       && (unserialize($data) == False))
-                       {
-                               // when you unserialize a normal 
(not-serialized) string, you get False
-                               return False;
-                       }
-                       elseif ((is_string($data))
-                       && (ereg('^s:[0-9]+:"',$data) == True))
-                       {
-                               // identify pattern of a serialized string 
(that did NOT have slashes added AFTER serialization )
-                               return True;
-                       }
-                       elseif ((is_string($data))
-                       && (is_array(unserialize($data))))
-                       {
-                               // if unserialization produces an array out of 
a string, it was serialized
-                               //(ereg('^a:[0-9]+:\{',$data) == True))  also 
could work
-                               return True;
-                       }
-                       //Best Guess - UNKNOWN / ERROR / NOY YET SUPPORTED TYPE
-                       elseif (is_string($data))
-                       {
-                               return True;
-                       }
-                       else
-                       {
-                               return False;
                        }
                }
--- 336,339 ----




reply via email to

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