Bug 550544 - Babel server is not ready for PHP 7

Change-Id: Ibb1442f2fd9e336c01ca3fd4ae05144412fda852
Signed-off-by: droy <denis.roy@eclipse-foundation.org>
diff --git a/classes/export/import_js_translations.php b/classes/export/import_js_translations.php
index 59bf1e5..d2cc61a 100644
--- a/classes/export/import_js_translations.php
+++ b/classes/export/import_js_translations.php
@@ -73,7 +73,7 @@
 			$content = fread($fh, $size);
 			# echo $content . "<br/>";
 			fclose($fh);
-			$file_contents = ereg_replace("\r\n?", "\n", $content);
+			$file_contents = preg_replace("\r\n?", "\n", $content);
 			$file_contents = preg_replace("/NON-NLS-(.*)/", "", $file_contents);
 			$file_contents = preg_replace("/\\/\\/\\$/", "", $file_contents);
 			$file_contents = preg_replace("/((.*?(\n))+.*?)define\(/", "define(", $file_contents);
diff --git a/classes/export/syncup.php b/classes/export/syncup.php
index 400cc22..5719a94 100644
--- a/classes/export/syncup.php
+++ b/classes/export/syncup.php
@@ -24,14 +24,6 @@
 
 require_once(dirname(__FILE__) . "/../system/backend_functions.php");
 
-if( !function_exists('json_encode') ){
-	require("/home/data/httpd/babel.eclipse.org/html/json_encode.php");
-	function json_encode($encode){
- 		$jsons = new Services_JSON();
-		return $jsons->encode($encode);
-	}
-}
-
 $User = getSyncupUser();
 
 echo "Connection established. Ready to begin. The syncup user id is: $User->userid\n";
diff --git a/classes/system/addons_management.php b/classes/system/addons_management.php
index 3e1e77c..b5d7e21 100644
--- a/classes/system/addons_management.php
+++ b/classes/system/addons_management.php
@@ -1,6 +1,6 @@
 <?php
 /*******************************************************************************
- * Copyright (c) 2007-2009 Intalio, Inc.
+ * Copyright (c) 2007-2019 Intalio, Inc. and others
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -8,25 +8,26 @@
  *
  * Contributors:
  *    Antoine Toulme, Intalio Inc.
+ *    Denis Roy (Eclipse Foundation) - Bug 550544 - Babel server is not ready for PHP 7
 *******************************************************************************/
 
 class AddonsManagement {
 
     private $addon;
     private $hooks = array();
-  
+
     /**
      * Constructor. Registers the addon name to use.
      * The addon name should be the name of the folder in use.
      * You can directly pass the addon name, or have it be consumed
      * from a properties file as a separate location, under the key "addon".
      */
-    function AddonsManagement($addon = null) {
+    function __construct($addon = null) {
         if (!isSet($addon)) {
             if (!isSet($ini_file_path)) {
                 $ini_file_path = dirname(__FILE__) . '/../../addons/addons.conf';
             }
-            
+
             if (($ini = @parse_ini_file($ini_file_path)) && isSet($ini['addons'])) {
                 $addon = $ini['addons'];
             }
@@ -39,7 +40,7 @@
         }
         $this->addon = $addon;
     }
-    
+
     /**
      * Loads the addon, register the hooks for html functions.
      */
@@ -50,7 +51,7 @@
             call_user_func($register_function_html, $this);
         }
     }
-    
+
     /**
      * Loads the addon, register the hooks for backend functions.
      */
@@ -61,7 +62,7 @@
             call_user_func($register_function_backend, $this);
         }
     }
-    
+
     /**
      * Registers a function for a specific key.
      * The function will be called later on.
@@ -69,19 +70,19 @@
     public function register($hook_key, $function_name) {
         $this->hooks[$hook_key] = $function_name;
     }
-    
+
     /**
      * Returns the name of the function to be used in the hook.
      */ 
     public function hook($hook_key) {
         return $this->hooks[$hook_key];
     }
-    
+
     /**
      * Executes the function associated with the hook and returns the result
      */ 
     public function callHook($hook_key, $args = array()) {
-    	return call_user_func_array($this->hook($hook_key), $args);
+        return call_user_func_array($this->hook($hook_key), $args);
     }
 }
 
@@ -91,4 +92,4 @@
 global $addon;
 $addon = new AddonsManagement();
 
-?>
+?>
\ No newline at end of file
diff --git a/html/process_map_files.php b/html/process_map_files.php
index 0d739da..fc22e67 100755
--- a/html/process_map_files.php
+++ b/html/process_map_files.php
@@ -1,6 +1,6 @@
 <?php
 /*******************************************************************************
- * Copyright (c) 2008 Eclipse Foundation and others.
+ * Copyright (c) 2008-2019 Eclipse Foundation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@
  *    Kit Lo (IBM) - Bug 257332, NLS warnings appear unnecessarily in runtime log
  *    Kit Lo (IBM) - Bug 302834, Add plugin filtering supports to map files process
  *    Kit Lo (IBM) - [382800] CSSUIPluginResources.properties is missing on translator tool
+ *    Denis Roy (Eclipse Foundation) - Bug 550544 - Babel server is not ready for PHP 7
 *******************************************************************************/
 $temp_dir = "/tmp/tmp-babel/";
 $files = array();
@@ -100,11 +101,11 @@
   }
   mkdir($tmpdir) || die("Cannot create working directory $tmpdir !");
   chdir($tmpdir) || die("Cannot write to $tmpdir !"); 
-    
+
   $h = fopen($myrow_maps['location'], "rb");
   $file_contents = stream_get_contents($h);
   fclose($h);
-  $file_contents = ereg_replace("\r\n?", "\n", $file_contents);
+  $file_contents = preg_replace("/\r\n?/", "\n", $file_contents);
   $aLines = split("\n", $file_contents);
 
   foreach ($aLines as $line) {
diff --git a/html/process_project_source_locations.php b/html/process_project_source_locations.php
index a8a27b7..c70fec9 100644
--- a/html/process_project_source_locations.php
+++ b/html/process_project_source_locations.php
@@ -1,6 +1,6 @@
 <?php
 /*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
+ * Copyright (c) 2013-2019 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
  *
  * Contributors:
  *    Kit Lo (IBM) - [402192] Extract project source files from Git repositories for translation
+ *    Denis Roy (Eclipse Foundation) - Bug 550544 - Babel server is not ready for PHP 7
  *******************************************************************************/
 
 /*
@@ -169,7 +170,7 @@
       if (!$file->save()) {
         echo "***ERROR: Cannot save file $file->name\n";
       } else {
-        $file_contents = ereg_replace("\r\n?", "\n", file_get_contents($file_name));
+        $file_contents = preg_replace("/\r\n?/", "\n", file_get_contents($file_name));
         $file->parseProperties($file_contents);
         echo "  $properties_file_name\n";
       }
@@ -221,7 +222,7 @@
       if (!$file->save()) {
         echo "***ERROR: Cannot save file $file->name\n";
       } else {
-        $file_contents = ereg_replace("\r\n?", "\n", file_get_contents($file_name));
+        $file_contents = preg_replace("/\r\n?/", "\n", file_get_contents($file_name));
         $file->parseJs($file_contents);
         echo "  $js_file_name\n";
       }
diff --git a/html/process_update_sites.php b/html/process_update_sites.php
index a3b2052..a74ec82 100644
--- a/html/process_update_sites.php
+++ b/html/process_update_sites.php
@@ -1,6 +1,6 @@
 <?php
 /*******************************************************************************
- * Copyright (c) 2010 Eclipse Foundation and others.
+ * Copyright (c) 2010-2019 Eclipse Foundation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
  *    Kit Lo (IBM) - Initial API and implementation
  *    Kit Lo (IBM) - [299402] Extract properties files from Eclipse project update sites for translation
  *    Kit Lo (IBM) - [382800] CSSUIPluginResources.properties is missing on translator tool
+ *    Denis Roy (Eclipse Foundation) - Bug 550544 - Babel server is not ready for PHP 7
 *******************************************************************************/
 /*
  * Extract properties files from update sites 
@@ -180,7 +181,7 @@
         echo "***ERROR: Cannot save file $file->name\n";
       } else {
         $file_name = $temp_unzip_dir . $properties_file_name;
-        $file_contents = ereg_replace("\r\n?", "\n", file_get_contents($file_name));
+        $file_contents = preg_replace("/\r\n?/", "\n", file_get_contents($file_name));
         $file->parseProperties($file_contents);
         echo "  $properties_file_name\n";
       }