Commit 30bcea7a11
Unsigned
Layout: unified · split
ifconfig.php +5 −6
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * User connection info | 3 | * User connection info |
| 4 | * | 4 | * |
| 5 | * Version: 1.1 2014/03/08 | ||
| 6 | * License: GPL v2 (https://www.gnu.org/licenses/gpl-2.0.html) | 5 | * License: GPL v2 (https://www.gnu.org/licenses/gpl-2.0.html) |
| 7 | * | 6 | * |
| 8 | * Copyright (C) 2014 Sergey Briskin (http://briskin.org) | 7 | * Copyright (C) 2014 Sergey Briskin (http://briskin.org) |
| @@ -47,11 +46,11 @@ $user = array( | |||
| 47 | $query=trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($_GET['q'])))))); | 46 | $query=trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($_GET['q'])))))); |
| 48 | 47 | ||
| 49 | // Return single value on request & die | 48 | // Return single value on request & die |
| 50 | if (isset($query) && !empty($user[$query]) && array_key_exists($query, $user)) { | 49 | if (isset($query) && array_key_exists($query, $user)) { |
| 51 | die($user[$query]."\n"); | 50 | empty($user[$query]) ? die() : die($user[$query]."\n"); |
| 52 | } | 51 | } |
| 53 | // Return full output in one of supported formats (html, text, xml, json. default: html) | 52 | // Return full output in one of supported formats (html, text, xml, json. default: html) |
| 54 | elseif (isset($query) && ($query=="text")) { | 53 | elseif (isset($query) && (($query=="text") || ($query=="all"))) { |
| 55 | header('Content-Type: text/plain'); | 54 | header('Content-Type: text/plain'); |
| 56 | foreach($user as $key => $value) { | 55 | foreach($user as $key => $value) { |
| 57 | echo $key.": ".$value."\n"; | 56 | echo $key.": ".$value."\n"; |
| @@ -106,7 +105,7 @@ echo array_to_xml($user, new SimpleXMLElement('<info/>'))->asXML(); | |||
| 106 | <body> | 105 | <body> |
| 107 | <? | 106 | <? |
| 108 | foreach($user as $key => $value) { | 107 | foreach($user as $key => $value) { |
| 109 | echo ' <p id='.$key.'>'.$key.': '.$value.'</p>'."\n"; | 108 | echo ' <p id="'.$key.'">'.$key.': '.$value.'</p>'."\n"; |
| 110 | } | 109 | } |
| 111 | ?> | 110 | ?> |
| 112 | <br/> | 111 | <br/> |
| @@ -117,4 +116,4 @@ echo array_to_xml($user, new SimpleXMLElement('<info/>'))->asXML(); | |||
| 117 | <? | 116 | <? |
| 118 | } | 117 | } |
| 119 | die(); | 118 | die(); |
| 120 | ?>\ No newline at end of file | 119 | ?> |