function camila_utf8_encode_array(&$arr) { foreach (array_keys($arr) as $k) { if (!is_array($arr[$k])) { if (!isUTF8($arr[$k])) { $arr[$k] = utf8_encode($arr[$k]); } } else { camila_utf8_encode_array($arr[$k]); } } }
// HTTP/1.1 header("Pragma: no-cache"); // HTTP/1.0 header("Content-Type: application/json"); $query = 'select distinct ' . $_REQUEST['field'] . ' as value'; $where = $_REQUEST['field'] . ' LIKE ' . $_CAMILA['db']->qstr('%' . $_REQUEST['input'] . '%'); // if ($_REQUEST['objectid'] != '') // $where = 'id='.$_CAMILA['db']->qstr($_REQUEST['objectid']); $result = $_CAMILA['db']->SelectLimit($query . ' from ' . $_REQUEST['table'] . ' where ' . $where, $_REQUEST['maxresults']); if ($result === false) { camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $_CAMILA['db']->ErrorMsg()); } $count = 0; while (!$result->EOF) { $count++; $result->fields['id'] = $result->fields['value']; $result->fields['info'] = ''; $fields[] = $result->fields; $result->MoveNext(); } if ($count > 0) { $json = new Services_JSON(); camila_utf8_encode_array($fields); echo $json->encode(array('results' => $fields)); } else { echo "{\"results\": ["; echo "]}"; } exit; } require_once '../camila/footer.php';
camila_stripslashes_array($_GET); camila_stripslashes_array($_POST); camila_stripslashes_array($_REQUEST); camila_stripslashes_array($_COOKIE); } if (!camila_isUTF8($_GET)) { camila_utf8_encode_array($_GET); } if (!camila_isUTF8($_POST)) { camila_utf8_encode_array($_POST); } if (!camila_isUTF8($_REQUEST)) { camila_utf8_encode_array($_REQUEST); } if (!camila_isUTF8($_COOKIE)) { camila_utf8_encode_array($_COOKIE); } if (isset($_REQUEST[CAMILA_APPLICATION_NAME])) { session_id($_REQUEST[CAMILA_APPLICATION_NAME]); } //session_set_cookie_params(3600); ini_set("magic_quotes_runtime", 0); $old_error_handler = set_error_handler('camila_error_handler'); if (!isset($_REQUEST['camila_session_id'])) { session_start(); } $_CAMILA['user_level'] = CAMILA_DEFAULT_USER_LEVEL; $_CAMILA['user_group'] = ''; $_CAMILA['page_login'] = 0; $_CAMILA['javascript_enabled'] = 0; $_CAMILA['skin'] = 0;