Bug 550544 - Babel server is not ready for PHP 7

Change-Id: Ia5311e2cc952a0fec9d533fc2848fe49c69896f1
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 3fff6b3..59bf1e5 100644
--- a/classes/export/import_js_translations.php
+++ b/classes/export/import_js_translations.php
@@ -78,8 +78,7 @@
 			$file_contents = preg_replace("/\\/\\/\\$/", "", $file_contents);
 			$file_contents = preg_replace("/((.*?(\n))+.*?)define\(/", "define(", $file_contents);
 			$file_contents = preg_replace("/define\(((.*?(\n))+.*?)\)\;/", "$1", $file_contents);
-			$jsons = new Services_JSON();
-			$lines = $jsons->decode($file_contents);
+			$lines = $json_decode($file_contents, true, 10);
 			foreach($lines as $key => $value) {
 							# Get the matching string name
 							$SQL = "SELECT s.string_id, s.value, tr.value as tr_last, tr.possibly_incorrect as tr_last_fuzzy, trv.value as ever_tr_value
diff --git a/classes/file/file.class.php b/classes/file/file.class.php
index 8ea76f9..b882f40 100755
--- a/classes/file/file.class.php
+++ b/classes/file/file.class.php
@@ -1,6 +1,6 @@
 <?php
 /*******************************************************************************
- * Copyright (c) 2007-2013 Eclipse Foundation, IBM Corporation and others.
+ * Copyright (c) 2007-2019 Eclipse Foundation, 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
@@ -15,9 +15,9 @@
  *    Kit Lo (IBM) - Bug 299402, Extract properties files from Eclipse project update sites for translation
  *    Kit Lo (IBM) - [402215] Extract Orion JavaScript files for translation
  *    Kit Lo (IBM) - [413459] Received "Cannot deactivate string" messages during process_project_source_locations.php
+ *    Denis Roy (Eclipse Foundation) - Bug 550544 - Babel server is not ready for PHP 7
  *******************************************************************************/
 
-require_once("/home/data/httpd/babel.eclipse.org/html/json_encode.php");
 require(dirname(__FILE__) . "/../system/language.class.php"); 
 require(dirname(__FILE__) . "/../system/release_train.class.php"); 
 
@@ -110,7 +110,7 @@
 			$sql = "SELECT * from strings WHERE is_active = 1 AND file_id = $this->file_id";
 			$rs_strings = mysqli_query($dbh, $sql);
 			while ($myrow_strings = mysqli_fetch_assoc($rs_strings)) {
-			  $string = new String();
+			  $string = new BabelString();
 			  $string->string_id = $myrow_strings['string_id'];
 			  $string->file_id = $myrow_strings['file_id'];
 			  $string->name = $myrow_strings['name'];
@@ -165,7 +165,7 @@
 								
 								$rValue .= $tags[0];
 								
-								$String = new String();
+								$String = new BabelString();
 								$String->file_id 	= $this->file_id;
 								$String->name 		= $tags[0];
 								$String->value 		= $tags[1];
@@ -204,7 +204,7 @@
 			$sql = "SELECT * from strings WHERE is_active = 1 AND file_id = $this->file_id";
 			$rs_strings = mysqli_query($dbh, $sql);
 			while ($myrow_strings = mysqli_fetch_assoc($rs_strings)) {
-			  $string = new String();
+			  $string = new BabelString();
 			  $string->string_id = $myrow_strings['string_id'];
 			  $string->file_id = $myrow_strings['file_id'];
 			  $string->name = $myrow_strings['name'];
@@ -220,14 +220,13 @@
 			$file_contents = preg_replace("/\\/\\/\\$/", "", $file_contents);
 			$file_contents = preg_replace("/((.*?(\n))+.*?)define\(/", "define(", $file_contents);
 			$file_contents = preg_replace("/define\(((.*?(\n))+.*?)\)\;/", "$1", $file_contents);
-			$jsons = new Services_JSON();
-			$lines = $jsons->decode($file_contents);
+			$lines = $json_decode($file_contents, true, 10);
 			foreach($lines as $key => $value) {
 				# escape newlines and tabs
 				$value = preg_replace("/\\n/", "\\\\n", $value);
 				$value = preg_replace("/\\t/", "\\\\t", $value);

 
-				$String = new String();
+				$String = new BabelString();
 				$String->file_id 	= $this->file_id;
 				$String->name 		= $key;
 				$String->value 		= $value;
diff --git a/classes/string/string.class.php b/classes/string/string.class.php
index 378b913..7e4c0ab 100755
--- a/classes/string/string.class.php
+++ b/classes/string/string.class.php
@@ -1,6 +1,6 @@
 <?php
 /*******************************************************************************
- * Copyright (c) 2007-2013 Eclipse Foundation, IBM Corporation and others.
+ * Copyright (c) 2007-2019 Eclipse Foundation, 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
@@ -11,11 +11,12 @@
  *    Kit Lo (IBM) - 272661 - Pseudo translations change " to ', breaking link texts
  *    Kit Lo (IBM) - [402215] Extract Orion JavaScript files for translation
  *    Kit Lo (IBM) - [413459] Received "Cannot deactivate string" messages during process_project_source_locations.php
+ *    Denis Roy (Eclipse Foundation) - Bug 550544 - Babel server is not ready for PHP 7
  *******************************************************************************/
 
-class String {
+class BabelString {
   public $errStrs;
-  
+
   public $string_id		= 0;
   public $file_id		= 0;
   public $name			= '';
@@ -128,7 +129,7 @@
 	 * @return String String object
 	 */
 	function getStringFromName($_file_id, $_name) {
-		$rValue = new String();
+		$rValue = new BabelString();
 		if($_file_id > 0 && $_name != "") {
 			global $dbh;
 
@@ -142,7 +143,7 @@
 			$result = mysqli_query($dbh, $sql);
 			if($result && mysqli_num_rows($result) > 0) {
 				$myrow = mysqli_fetch_assoc($result);
-				$String = new String();
+				$String = new BabelString();
 				$String->string_id 	= $myrow['string_id'];
 				$String->file_id 	= $myrow['file_id'];
 				$String->name 		= $myrow['name'];
@@ -157,7 +158,7 @@
 	}
 	
 	function getStringFromNameJs($_file_id, $_name) {
-		$rValue = new String();
+		$rValue = new BabelString();
 		if($_file_id > 0 && $_name != "") {
 			global $dbh;
 
@@ -171,7 +172,7 @@
 			$result = mysqli_query($dbh, $sql);
 			if($result && mysqli_num_rows($result) > 0) {
 				$myrow = mysqli_fetch_assoc($result);
-				$String = new String();
+				$String = new BabelString();
 				$String->string_id 	= $myrow['string_id'];
 				$String->file_id 	= $myrow['file_id'];
 				$String->name 		= $myrow['name'];
@@ -186,7 +187,7 @@
 	}
 	
 	function getStringFromStringId($_file_id, $_string_id) {
-		$rValue = new String();
+		$rValue = new BabelString();
 		if($_file_id > 0 && $_string_id != "") {
 			global $dbh;
 
@@ -199,7 +200,7 @@
 			$result = mysqli_query($dbh, $sql);
 			if($result && mysqli_num_rows($result) > 0) {
 				$myrow = mysqli_fetch_assoc($result);
-				$String = new String();
+				$String = new BabelString();
 				$String->string_id 	= $myrow['string_id'];
 				$String->file_id 	= $myrow['file_id'];
 				$String->name 		= $myrow['name'];
@@ -232,7 +233,7 @@
 
 			$result = mysqli_query($dbh, $sql);
 			while($myrow = mysqli_fetch_assoc($result)) {
-				$String = new String();
+				$String = new BabelString();
 				$String->string_id 	= $myrow['string_id'];
 				$String->file_id 	= $myrow['file_id'];
 				$String->name 		= $myrow['name'];
diff --git a/html/content/en_recent_html_list.php b/html/content/en_recent_html_list.php
index e9d1eeb..73ede20 100644
--- a/html/content/en_recent_html_list.php
+++ b/html/content/en_recent_html_list.php
@@ -23,7 +23,7 @@
 }
 </style>
 
-<?include 'en_recent_html_common.php' ?>
+<?php include 'en_recent_html_common.php' ?>
 <ul>
 <?php
 	$prev_date = "";
diff --git a/html/content/en_recent_html_table.php b/html/content/en_recent_html_table.php
index d7079df..998b650 100644
--- a/html/content/en_recent_html_table.php
+++ b/html/content/en_recent_html_table.php
@@ -24,7 +24,7 @@
 }
 </style>
 
-<?include 'en_recent_html_common.php' ?>
+<?php include 'en_recent_html_common.php' ?>
 <table cellspacing=1 cellpadding=2 border=0>
 <tr class="head">
 <?php