Jeremy Newman : cleanup, set method and property visibility, modernize constructor

Jeremy Newman jnewman at winehq.org
Mon Nov 21 08:38:07 CST 2016


Module: appdb
Branch: master
Commit: 634840878bb26990b0de005bba33b760f3e3c690
URL:    http://source.winehq.org/git/appdb.git/?a=commit;h=634840878bb26990b0de005bba33b760f3e3c690

Author: Jeremy Newman <jnewman at codeweavers.com>
Date:   Mon Nov 14 14:49:22 2016 -0600

cleanup, set method and property visibility, modernize constructor

---

 include/session.php | 50 +++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/include/session.php b/include/session.php
index 31b8761..0a90584 100644
--- a/include/session.php
+++ b/include/session.php
@@ -9,14 +9,14 @@
 class session
 {
     // defines
-    var $_server;
-    var $_expire;
-    var $_db;
-    var $name;
-    var $msg;
-    
+    private $_server;
+    private $_expire;
+    private $_db;
+    private $name;
+    public $msg;
+
     // create session object
-    function session ($name, $server = "127.0.0.1", $expire = 30)
+    public function __construct ($name, $server = "127.0.0.1", $expire = 30)
     {
         // set the connection server
         $this->_server = $server;
@@ -31,7 +31,7 @@ class session
         ini_set('session.name', $this->name);
         ini_set('session.use_cookies', true);
         ini_set('session.use_only_cookies', true);
-        
+
         // setup session object
         session_set_save_handler(
                                  array(&$this, "_open"), 
@@ -41,16 +41,16 @@ class session
                                  array(&$this, "_destroy"), 
                                  array(&$this, "_gc")
                                 );
-        
+
         // default lifetime on session cookie
         session_set_cookie_params(
                                   $this->_expire,
                                   '/'
                                  );
-        
+
         // start the loaded session
         session_start();
-        
+
         // make sure we have a valid memcache server connection
         if (!$this->_db->getVersion())
         {
@@ -59,26 +59,26 @@ class session
     }
 
     // register variables into session (dynamic load and save of vars)
-    function register ($var)
+    public function register ($var)
     {
         global $$var;
-        
+
         // load $var into memory
         if (isset($_SESSION[$var]))
             $$var = $_SESSION[$var];
-        
+
         // store var into session
         $_SESSION[$var] =& $$var;
     }
 
     // destroy session
-    function destroy ()
+    public function destroy ()
     {
         session_destroy();
     }
 
     // add alert message to buffer that will be displayed on the Next page view of the same user in html class
-    function addmsg ($text, $color = "black")
+    public function addmsg ($text, $color = "black")
     {
         if (!isset($_SESSION['_msg']))
             $_SESSION['_msg'] = array();
@@ -89,7 +89,7 @@ class session
     }
 
     // add alert message that will be displayed on the current page output in html class
-    function alert ($text, $color = "black")
+    public function alert ($text, $color = "black")
     {
         $this->msg[] = array(
                              'msg'   => $text,
@@ -98,14 +98,14 @@ class session
     }
 
     // clear session messages
-    function purgemsg ()
+    public function purgemsg ()
     {
         $this->msg[] = array();
         $_SESSION['_msg'][] = array();
     }
 
     // output msg_buffer and clear it.
-    function dumpmsgbuffer ()
+    public function dumpmsgbuffer ()
     {
         if (isset($_SESSION['_msg']) and is_array($_SESSION['_msg']))
         {
@@ -118,26 +118,26 @@ class session
     }
 
     // connect to session
-    function _open ($save_path, $session_name)
+    public function _open ($save_path, $session_name)
     {
         $this->_db = new Memcache;
         return $this->_db->connect($this->_server, "11211");
     }
 
     // close the session
-    function _close ()
+    public function _close ()
     {
         return $this->_db->close();
     }
 
     // restore a session from memory
-    function _read ($id)
+    public function _read ($id)
     {
         return $this->_db->get($id);
     }
 
     // write the session
-    function _write ($id, $data)
+    public function _write ($id, $data)
     {
         if ($this->_db->get($id))
         {
@@ -151,13 +151,13 @@ class session
     }
 
     // Delete the Session
-    function _destroy ($id)
+    public function _destroy ($id)
     {
         return $this->_db->delete($id, 0);
     }
 
     // Garbage Collector (Not Needed for MemCache)
-    function _gc ($maxlifetime)
+    public function _gc ($maxlifetime)
     {
         return true;
     }




More information about the wine-cvs mailing list