public static function get($param = null, $fallback = false, $str_eval = true) { if (is_null($param)) { return $_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET) && !empty($_GET) ? $str_eval ? Converter::strEval($_GET, false) : $_GET : $fallback; } $output = Mecha::GVR($_GET, $param, $fallback); return $output === '0' || !empty($output) ? $str_eval ? Converter::strEval($output, false) : $output : $fallback; }
public static function inspect($path, $output = null, $fallback = false) { $path = self::path($path); $n = self::N($path); $e = self::E($path); $update = self::T($path); $update_date = !is_null($update) ? date('Y-m-d H:i:s', $update) : null; $results = array('path' => $path, 'name' => $n, 'url' => self::url($path), 'extension' => is_file($path) ? $e : null, 'update_raw' => $update, 'update' => $update_date, 'size_raw' => file_exists($path) ? filesize($path) : null, 'size' => file_exists($path) ? self::size($path) : null, 'is' => array('hidden' => strpos($n, '__') === 0 || strpos($n, '.') === 0, 'file' => is_file($path), 'folder' => is_dir($path))); return !is_null($output) ? Mecha::GVR($results, $output, $fallback) : $results; }
public static function get($session = null, $fallback = "") { if (is_null($session)) { return $_SESSION; } if ($session === 'cookies') { return Converter::strEval($_COOKIE); } if (strpos($session, 'cookie:') === 0) { $name = substr($session, 7); $cookie = isset($_COOKIE) ? Converter::strEval($_COOKIE) : $fallback; $value = Mecha::GVR($cookie, $name, $fallback); return !is_array($value) && !is_null(json_decode(base64_decode($value), true)) ? json_decode(base64_decode($value), true) : $value; } return Mecha::GVR($_SESSION, $session, $fallback); }
/** * ============================================================= * GET CONFIGURATION VALUE BY ITS KEY * ============================================================= * * -- CODE: ---------------------------------------------------- * * echo Config::get('url'); * * ------------------------------------------------------------- * * echo Config::get('index')->slug; * * ------------------------------------------------------------- * * echo Config::get('index.slug'); * * ------------------------------------------------------------- * * $config = Config::get(); * * echo $config->url; * echo $config->index->slug; * * ------------------------------------------------------------- * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Parameter | Type | Description * --------- | ------ | --------------------------------------- * $key | string | Key of data to be called * $fallback | mixed | Fallback value if data does not exist * --------- | ------ | --------------------------------------- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * */ public static function get($key = null, $fallback = false) { if (is_null($key)) { return Mecha::O(self::$bucket); } if (is_string($key) && strpos($key, '.') !== false) { $output = Mecha::GVR(self::$bucket, $key, $fallback); return is_array($output) ? Mecha::O($output) : $output; } return array_key_exists($key, self::$bucket) ? Mecha::O(self::$bucket[$key]) : $fallback; }
/** * ==================================================================== * INSPECT A ZIP FILE * ==================================================================== * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Parameter | Type | Description * --------- | ------ | ---------------------------------------------- * $key | string | Key of the resulted array data * $fallback | mixed | Fallback value if array value is not available * --------- | ------ | ---------------------------------------------- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * */ public static function inspect($key = null, $fallback = false) { $results = array(); if (self::$zip->open(self::$open) === true) { $results = array_merge(File::inspect(self::$open), array('status' => self::$zip->status, 'total' => self::$zip->numFiles)); for ($i = 0; $i < $results['total']; ++$i) { $data = self::$zip->statIndex($i); $data['name'] = str_replace(DS . DS, DS, File::path($data['name'])); $results['files'][$i] = $data; } self::$zip->close(); } if (!is_null($key)) { return Mecha::GVR($results, $key, $fallback); } return !empty($results) ? $results : $fallback; }
/** * ============================================================ * SPELL THE STORED DATA * ============================================================ * * -- CODE: --------------------------------------------------- * * echo Guardian::wayback('name'); * * ------------------------------------------------------------ * */ public static function wayback($name = null, $fallback = "") { $memory = Session::get(self::$form); self::forget($name); return !is_null($name) ? Mecha::GVR($memory, $name, $fallback) : $memory; }
/** * ============================================================ * SPELL THE STORED DATA * ============================================================ * * -- CODE: --------------------------------------------------- * * echo Guardian::wayback('name'); * * ------------------------------------------------------------ * */ public static function wayback($name = null, $fallback = "") { $form = Session::get(self::$form); if (is_null($name)) { self::forget(); return $form; } $value = Mecha::GVR($form, $name, $fallback); Session::kill(self::$form . '.' . $name); return $value; }
if ($file = File::exist(LANGUAGE . DS . Config::get('language') . DS . 'yapping' . DS . $key . '.txt')) { $wizard = Text::toPage(File::open($file)->read(), 'content', 'wizard:'); return $wizard['content']; } else { if ($file = File::exist(ROOT . DS . $key . '.txt')) { $wizard = Text::toPage(File::open($file)->read(), 'content', 'wizard:'); return $wizard['content']; } } return ""; } if (!is_array($vars)) { $vars = array_slice(func_get_args(), 1); } if (strpos($key, '.') !== false) { $value = Mecha::GVR($speak, $key, $fallback); return vsprintf($value, $vars); } return isset($speak[$key]) ? vsprintf($speak[$key], $vars) : vsprintf($fallback, $vars); }); /** * ============================================================= * GET URL DATA * ============================================================= * * -- CODE: ---------------------------------------------------- * * echo Config::url(); * * ------------------------------------------------------------- *
/** * ============================================================= * GET CONFIGURATION DATA BY ITS KEY * ============================================================= * * -- CODE: ---------------------------------------------------- * * echo Config::get('url'); * * ------------------------------------------------------------- * * echo Config::get('index')->slug; * * ------------------------------------------------------------- * * echo Config::get('index.slug'); * * ------------------------------------------------------------- * * $config = Config::get(); * * echo $config->url; * echo $config->index->slug; * * ------------------------------------------------------------- * * $bucket = Config::get(array('foo', 'bar', 'baz')); * * ------------------------------------------------------------- * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Parameter | Type | Description * --------- | ------ | --------------------------------------- * $key | string | Key of data to be called * $fallback | mixed | Fallback value if data does not exist * --------- | ------ | --------------------------------------- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * */ public static function get($key = null, $fallback = false) { if (is_null($key)) { return Mecha::O(self::$bucket); } if (is_array($key)) { $results = array(); foreach ($key as $k => $v) { $f = is_array($fallback) && array_key_exists($k, $fallback) ? $fallback[$k] : $fallback; $results[$v] = self::get($v, $f); } return (object) $results; } if (is_string($key) && strpos($key, '.') !== false) { $output = Mecha::GVR(self::$bucket, $key, $fallback); return is_array($output) ? Mecha::O($output) : $output; } return array_key_exists($key, self::$bucket) ? Mecha::O(self::$bucket[$key]) : $fallback; }
/** * ==================================================================== * INSPECT A ZIP FILE * ==================================================================== * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Parameter | Type | Description * --------- | ------ | ---------------------------------------------- * $key | string | Key of the resulted array data * $fallback | mixed | Fallback value if array value is not available * --------- | ------ | ---------------------------------------------- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * */ public static function getInfo($key = null, $fallback = false) { $results = array(); $zip = new ZipArchive(); if (File::exist(self::$open) && $zip->open(self::$open)) { $results = array_merge(File::inspect(self::$open), array('status' => $zip->status, 'total' => $zip->numFiles)); for ($i = 0; $i < $results['total']; ++$i) { $results['files'][$i] = $zip->statIndex($i); } $zip->close(); } if (!is_null($key)) { return Mecha::GVR($results, $key, $fallback); } return !empty($results) ? $results : $fallback; }
* $key | string | Key of language data to be called * $vars | array | Array of value used in PHP `vsprintf()` * --------- | ------ | --------------------------------------- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * */ Config::plug('speak', function ($key = "", $vars = array()) { if (!$key) { return Config::get('speak'); } if (!is_array($vars)) { $vars = array_slice(func_get_args(), 1); } $speak = Mecha::A(Config::get('speak')); if (strpos($key, '.') !== false) { $value = Mecha::GVR($speak, $key, $key); return vsprintf($value, $vars); } if (isset($speak[$key])) { return !is_array($speak[$key]) ? vsprintf($speak[$key], $vars) : Mecha::O($speak[$key]); } return $key; }); /** * ============================================================= * GET URL DATA * ============================================================= * * -- CODE: ---------------------------------------------------- * * echo Config::url();