/** * Converts an array, object, or string to an array. * * @param mixed $thing Array, object, or string (JSON, serialized, or XML). * @return array */ function to_array($thing) { if (is_array($thing)) { return array_build($thing); } if (is_object($thing)) { return array_build(object_to_array($thing)); } if (is_string($thing)) { if (is_json($thing)) { return json_decode($thing, true); } if (is_serialized($thing)) { return to_array(unserialize($thing)); } if (is_xml($thing)) { return xml_decode($thing, true); } } return (array) $thing; }
protected function is_xml(&$response) { if (defined('STRICT_TYPES') && CAMEL_CASE == '1') { return (bool) self::parameters(['response' => DT::TEXT])->call(__FUNCTION__)->with($response)->returning(DT::BOOL); } else { return (bool) is_xml($response); } }
/** * Decode a request result. * * @param $body * @return mixed */ private function decode($body) { if (is_json($body)) { return json_decode($body, true); } if (is_xml($body)) { return xml_to_json($body); } return $body; }
exit; } if (trim(get_link($_SERVER['REQUEST_URI'])[0]) == '') { header('Location:/' . md5(session_id() . date('Ymdhs'))); } function __($value = '') { return $value; } $hash = mysql_real_escape_string(get_link($_SERVER['REQUEST_URI'])[0]); $files = SQL::execute("SELECT * FROM files WHERE hash='{$hash}';"); if (is_json()) { header("Content-Type: application/json"); echo json_encode($files); exit; } elseif (is_xml()) { header("Content-Type: application/rss+xml;"); // $xml = new SimpleXMLElement('<root/>'); // array_walk_recursive($files, array ($xml, 'addChild')); // print $xml->asXML(); echo array_to_xml($files); exit; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo !empty($title) ? $title : __('Файловая хранилище') . ' KTGA.KZ'; ?>
/** * Converts an array, object, or string to an array. * * @param mixed $thing Array, object, or string (JSON, serialized, or XML). * @return array */ public static function to($thing) { if (is_array($thing)) { return static::build($thing); } if (is_object($thing)) { return is_callable(array($thing, 'toArray')) ? $thing->toArray() : static::build($thing); } if (is_string($thing)) { if (is_json($thing)) { return json_decode($thing, true); } else { if (is_serialized($thing)) { return static::to(unserialize($thing)); } else { if (is_xml($thing)) { return xml2array($thing); } } } } return (array) $thing; }