From 30bcea7a11d23accff7e5c06f598c98942c89655 Mon Sep 17 00:00:00 2001 From: Sergey Briskin Date: Sat, 8 Mar 2014 13:07:07 +0400 Subject: Fixed emtpty value response --- ifconfig.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ifconfig.php') diff --git a/ifconfig.php b/ifconfig.php index 3cf3b05..fd0f876 100644 --- a/ifconfig.php +++ b/ifconfig.php @@ -2,7 +2,6 @@ /* * User connection info * - * Version: 1.1 2014/03/08 * License: GPL v2 (https://www.gnu.org/licenses/gpl-2.0.html) * * Copyright (C) 2014 Sergey Briskin (http://briskin.org) @@ -47,11 +46,11 @@ $user = array( $query=trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($_GET['q'])))))); // Return single value on request & die -if (isset($query) && !empty($user[$query]) && array_key_exists($query, $user)) { - die($user[$query]."\n"); +if (isset($query) && array_key_exists($query, $user)) { + empty($user[$query]) ? die() : die($user[$query]."\n"); } // Return full output in one of supported formats (html, text, xml, json. default: html) -elseif (isset($query) && ($query=="text")) { +elseif (isset($query) && (($query=="text") || ($query=="all"))) { header('Content-Type: text/plain'); foreach($user as $key => $value) { echo $key.": ".$value."\n"; @@ -106,7 +105,7 @@ echo array_to_xml($user, new SimpleXMLElement(''))->asXML(); $value) { - echo '

'.$key.': '.$value.'

'."\n"; + echo '

'.$key.': '.$value.'

'."\n"; } ?>
@@ -117,4 +116,4 @@ echo array_to_xml($user, new SimpleXMLElement(''))->asXML(); \ No newline at end of file +?> -- cgit v1.2.3-70-g09d2