Jeremy Newman : fix depreciated code

Jeremy Newman jnewman at winehq.org
Thu Apr 12 15:06:11 CDT 2012


Module: website
Branch: master
Commit: 60ee8a13cac1a942c6df1376ef0b451e522222fb
URL:    http://source.winehq.org/git/website.git/?a=commit;h=60ee8a13cac1a942c6df1376ef0b451e522222fb

Author: Jeremy Newman <jnewman at codeweavers.com>
Date:   Thu Apr 12 15:00:22 2012 -0500

fix depreciated code

---

 include/config.php |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/include/config.php b/include/config.php
index aa80daa..80f3311 100644
--- a/include/config.php
+++ b/include/config.php
@@ -6,9 +6,10 @@
   by Jeremy Newman <jnewman at codeweavers.com>
 */
 
-class config 
-{ 
-    function config ()
+class config
+{
+    // constructor
+    public function __construct ()
     {
         // get files passed
         $files = func_get_args();
@@ -19,31 +20,30 @@ class config
             // read global config file
             $this->readConfig($path);
         }
-    // end of config()
     }
-    
+
     // reads config from text file
-    function readConfig ($file)
+    private function readConfig ($file)
     {
         if (file_exists($file))
         {
             $fd = fopen ($file, "r");
             while (!feof ($fd)) {
                 $buffer = trim(fgets($fd, 4096));
-                if (ereg('^\#', $buffer)) continue;
+                if (preg_match('/^\#/', $buffer)) continue;
                 if ($buffer == "") continue;
                 $arr = preg_split('/:\s+/',$buffer,2);
                 $arr[1] = preg_replace("/<br>/","\n",$arr[1]);
-                if (ereg('^\@', $arr[0]))
+                if (preg_match('/^\@/', $arr[0]))
                 {
                     // array
-                    $arr[0] = ereg_replace('\@', '', $arr[0]); 
+                    $arr[0] = preg_replace('/\@/', '', $arr[0]); 
                     $this->$arr[0] = preg_split('/,\s+/', $arr[1]);
                 }
-                else if (ereg('^\%', $arr[0]))
+                else if (preg_match('/^\%/', $arr[0]))
                 {
                     // assoc array
-                    $arr[0] = ereg_replace('\%', '', $arr[0]);
+                    $arr[0] = preg_replace('/\%/', '', $arr[0]);
                     $this->$arr[0] = array();
                     $params = preg_split('/,\s+/', $arr[1]);
                     while (list($n, $m) = each($params))
@@ -59,7 +59,7 @@ class config
                     {
                         // load other vars into existing var
                         $arr[1] = preg_replace('/(.*)\{\$([a-z0-9_]+)\}(.*)/', "\\1,\\2,\\3", $arr[1]);
-                        list($a,$b,$c) = split(",", $arr[1], 3);
+                        list($a,$b,$c) = preg_split("/\,/", $arr[1], 3);
                         if ($b and isset($this->$b))
                             $arr[1] = $a.$this->$b.$c;
                         else
@@ -72,7 +72,8 @@ class config
         }
         else
         {
-            trigger_error("Unable to read config: ".$file);
+            trigger_error("ERROR: Unable to read config!", E_USER_ERROR);
+            exit();
         }
     // end of readConfig
     }




More information about the wine-cvs mailing list