Replace functions deprecated in PHP 5.3
authorNozomi Anzai <anzai at sraoss.co.jp>
Thu, 15 Jul 2010 04:02:31 +0000 (04:02 +0000)
committerNozomi Anzai <anzai at sraoss.co.jp>
Thu, 15 Jul 2010 04:02:31 +0000 (04:02 +0000)
 - ereg -> preg_match
 - split -> explode
 - ereg_replace -> str_replace

common.php
pgconfig.php
procInfo.php

index aa8385a872f0519a8be1c31228594432a6de1796..4b2d8874b32cdcc866d8dd89f37358c53826bcf4 100644 (file)
@@ -91,7 +91,7 @@ $messageList = array();
 
 $res_dir = opendir('lang/');
 while($file_name = readdir( $res_dir )) {
-    if(ereg('.*\.lang\.php$', $file_name)) {
+    if(preg_match('/.*\.lang\.php$/', $file_name)) {
         if(@is_file('lang/' . $file_name)) {
             include('lang/' . $file_name);
             $messageList[$message['lang']] = $message['strLang']; 
@@ -344,14 +344,14 @@ function readConfigParams($paramList = FALSE) {
     foreach ($configFile as $line_num => $line) {
         $line = trim($line);
         if(preg_match("/^\w/", $line)) {
-            list($key, $value) = split("=", $line);
+            list($key, $value) = explode("=", $line);
             
             $key = trim($key);
             $value = trim($value);
             
             if(preg_match("/^backend_hostname/", $key)) {
                 $num = str_replace('backend_hostname', '', $key);
-                $configParam['backend_hostname'][$num] = ereg_replace("'", "", $value);
+                $configParam['backend_hostname'][$num] = str_replace("'", "", $value);
             }
             else if(preg_match("/^backend_port/", $key)) {
                 $num = str_replace('backend_port', '', $key);
@@ -363,10 +363,10 @@ function readConfigParams($paramList = FALSE) {
             }
             else if(preg_match("/^backend_data_directory/", $key)) {
                 $num = str_replace('backend_data_directory', '', $key);
-                $configParam['backend_data_directory'][$num] = ereg_replace("'", "", $value);
+                $configParam['backend_data_directory'][$num] =str_replace("'", "", $value);
             }
             else {
-                $configParam[$key] = ereg_replace("'", "", $value);
+                $configParam[$key] = str_replace("'", "", $value);
             }
         }
     }
index 56b5d3e85bb5dea16748dd1ec96e1d87b2383a62..8e70e97e90f71a4b6bc2b6fd0d319481fcfb97e1 100644 (file)
@@ -308,11 +308,11 @@ function check($key, $value, &$configParam ,&$error) {
  */
 function checkString($str, $pattern)
 {
-    if(ereg($pattern, $str)) {
+    if(preg_match("/$pattern/", $str)) {
         return true;
     } else {
         return false;
-        }
+    }
 }
 
 /**
@@ -328,7 +328,7 @@ function checkInteger($str, $min, $max)
     if(is_numeric($str)) {
         $minLen = strlen($min);
         $maxLen = strlen($max);
-        if(ereg("^[0-9]{".$minLen.",".$maxLen."}$", $str)) {
+        if(preg_match('/^[0-9]{'.$minLen.','.$maxLen.'}$/', $str)) {
             if($str < $min || $str > $max) {
                 return false;
             } else {
@@ -389,7 +389,7 @@ function writeConfigFile($configValue, $pgpoolConfigParam)
     for($i=0; $i < count($configFile); $i++) {
         $line = $configFile[$i];
         if(preg_match("/^\w/", $line)) {
-            list($key, $value) = split("=", $line);
+            list($key, $value) = explode("=", $line);
             $key = trim($key);
             if(!preg_match("/^backend_hostname/", $key)
             && !preg_match("/^backend_port/", $key)
index 1b4d418247f174b58687c93b61f36ce8405ca4e9..01a883969dcf5a83c11f8c15cf65622817b95c1d 100644 (file)
@@ -36,7 +36,7 @@ if(!array_key_exists('SUCCESS', $ret)) {
     $tpl->display('innerError.tpl');
     exit();
 } else {
-        $procPids = split(" ", $ret['SUCCESS']);
+        $procPids = explode(" ", $ret['SUCCESS']);
 }
 
 for($i=0; $i<count($procPids); $i++) {