diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 3ec4c3933a14480cedf2548061fc431d584aaa68..f36f9e6ad2f0d9fff75f24bce386091746825b18 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -31,6 +31,22 @@
  */
 
 
+if (! function_exists('json_encode'))
+{
+    /**
+     * Implement json_encode for PHP that does not support it
+     *
+     * @param	mixed	$elements		PHP Object to json encode
+     * @return 	string					Json encoded string
+     */
+    function json_encode($elements)
+    {
+        if (is_array($elements)) return '["' . join('","', $elements) . '"]';
+        else return '"'.$elements.'"';
+    }
+}
+
+
 /**
  * Return a DoliDB instance (database handler).
  *
@@ -52,18 +68,6 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
 }
 
 
-/**
- *  This function output memory used by PHP and exit everything. Used for debugging purpose.
- *
- *  @return	void
- */
-function dol_stopwithmem()
-{
-    print memory_get_usage();
-    llxFooter();
-    exit;
-}
-
 /**
  *  Function called at end of web php process
  *
@@ -77,6 +81,7 @@ function dol_shutdown()
     dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].($disconnectdone?' (Warn: db disconnection forced)':''), ($disconnectdone?LOG_WARNING:LOG_DEBUG));
 }
 
+
 /**
  *  Return value of a param into GET or POST supervariable
  *
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 27bed102c632b5d45785903bf650806bdb984b42..19ff6392f4158e0d67d68429191870ab5fe526ad 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -232,7 +232,6 @@ if (! empty($conf->file->main_force_https))
 if (! defined('NOREQUIREMENU')) require_once(DOL_DOCUMENT_ROOT ."/core/class/menu.class.php");			// Need 10ko memory (11ko in 2.2)
 if (! defined('NOREQUIREHTML')) require_once(DOL_DOCUMENT_ROOT ."/core/class/html.form.class.php");	    // Need 660ko memory (800ko in 2.2)
 if (! defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) require_once(DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php');	// Need 22ko memory
-//dol_stopwithmem();
 
 // If install or upgrade process not done or not completely finished, we call the install page.
 if (! empty($conf->global->MAIN_NOT_INSTALLED) || ! empty($conf->global->MAIN_NOT_UPGRADED))