UTF-8 encoding cleanups
This commit is contained in:
1 parent
5125540d7e
commit
06814d481c
4 files changed
+2
-30
No files matched your search
@@ -23,12 +23,6 @@ function return_json_response($data, $response_code=200) {
|
||||
die(json_encode($data));
|
||||
}
|
||||
|
||||
|
||||
function is_valid_utf8($text) {
|
||||
return mb_check_encoding($text, 'utf-8');
|
||||
}
|
||||
|
||||
|
||||
function get_db_connection($fetch_mode=NULL, $options=NULL) {
|
||||
if($options == NULL) {
|
||||
$options = array(
|
||||
@@ -133,9 +127,6 @@ function get_user_data($ids) {
|
||||
$u_groups = explode(",",$value);
|
||||
foreach($u_groups as $g) {
|
||||
list($id,$name) = explode(";", $g);
|
||||
if( !is_valid_utf8($name) ) {
|
||||
$name = utf8_encode($name);
|
||||
}
|
||||
if($id == $ACTIVE_GROUP_ID) {
|
||||
$is_active = "1";
|
||||
}
|
||||
@@ -153,10 +144,6 @@ function get_user_data($ids) {
|
||||
}
|
||||
$result[$key] = _get_cards($value);
|
||||
}
|
||||
/* Encoding issues? oh yes, utf-8 please */
|
||||
elseif( !is_valid_utf8($value) ) {
|
||||
$result[$key] = utf8_encode($value);
|
||||
}
|
||||
}
|
||||
$result['is_active'] = $is_active;
|
||||
$results[] = $result;
|
||||
|
||||
+1
-13
@@ -17,23 +17,11 @@ $sql = "SELECT g.name as group_name, g.id as group_id, g.posix_group, g.mailingl
|
||||
ORDER BY g.name";
|
||||
$res = $conn->getAll($sql);
|
||||
|
||||
/* Encode */
|
||||
$results = array();
|
||||
foreach($res as $result) {
|
||||
foreach($result as $key => $value) {
|
||||
/* Encoding issues? oh yes, utf-8 please */
|
||||
if(is_string($value)) {
|
||||
$result[$key] = utf8_encode($value);
|
||||
}
|
||||
}
|
||||
$results[] = $result;
|
||||
}
|
||||
|
||||
if( DB::isError($res) ) {
|
||||
set_response_code(500);
|
||||
echo json_encode(array('error' => $res->getMessage().". DEBUG: ".$res->getDebugInfo()));
|
||||
die();
|
||||
}
|
||||
echo json_encode(array('results' => $results));
|
||||
echo json_encode(array('results' => $res));
|
||||
|
||||
?>
|
||||
+1
-3
@@ -29,6 +29,4 @@ if( DB::isError($res) ) {
|
||||
}
|
||||
$userExists = $res->numRows() > 0;
|
||||
|
||||
echo json_encode(array('result' => $userExists));
|
||||
|
||||
?>
|
||||
echo json_encode(array('result' => $userExists));
|
||||
@@ -42,4 +42,3 @@ if( count($res) === 1 ) {
|
||||
'result' => ""
|
||||
));
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user