FWIW, this change breaks one of my commercial plugins. That plugin returns an ***array ***of information to an AJAX request and the suggestion of simply casting the result to a string wrecks havoc!
Here's the change that I made, allowing the return values to be string-value-containing-names or array elements:
<?php
/**
* ajax front controller
*
* @package core
* @copyright Copyright 2003-2015 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version GIT: $Id: Author: Ian Wilson Modified in v1.6.0 $
*/
require ('includes/application_top.php');
//-bof-lat9 *** 1 of 2 ***
function htmlentities_mixed ($mixed_value, $flags, $encoding = 'utf-8', $double_encode = true) {
if (!is_array ($mixed_value)) {
$result = htmlentities ((string)$mixed_value, $flags, $encoding, $double_encode);
} else {
$result = array ();
foreach ($mixed_value as $key => $value) {
$result[$key] = htmlentities_mixed ($value, $flags, $encoding, $double_encode);
}
}
return $result;
}
//-eof-lat9 *** 1 of 2 ***
$language_page_directory = DIR_WS_LANGUAGES.$_SESSION['language'].'/';
if (isset ($_GET['act'])&&isset ($_GET['method'])) {
$className = 'zc'.ucfirst ($_GET['act']);
$classFile = $className.'.php';
if (file_exists (DIR_FS_CATALOG.DIR_WS_CLASSES.'ajax/'.$classFile)) {
require (DIR_FS_CATALOG.DIR_WS_CLASSES.'ajax/'.$classFile);
$class = new $className ();
if (method_exists ($class, $_GET['method'])) {
$result = call_user_func (array(
$class,
$_GET['method']
));
//-bof-lat9 *** 2 of 2 ***
$result = htmlentities_mixed ($result, ENT_QUOTES, 'utf-8', FALSE);
//-eof-lat9 *** 2 of 2 ***
echo json_encode ($result);exit();
} else {
echo 'method error';
}
}
}