/** * ============================================================= * REGISTER NEW VARIABLE(S) * ============================================================= * * -- CODE: ---------------------------------------------------- * * Config::set('foo', 'bar'); * * ------------------------------------------------------------- * * Config::set(array( * 'a' => 1, * 'b' => 2 * )); * * ------------------------------------------------------------- * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Parameter | Type | Description * --------- | ------ | --------------------------------------- * $key | string | Key of data to be called * $key | array | Array of data's key and value * $value | mixed | The value of your data key * --------- | ------ | --------------------------------------- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * */ public static function set($key, $value = "") { if (is_object($key)) { $key = Mecha::A($key); } if (is_object($value)) { $value = Mecha::A($value); } $cargo = array(); if (!is_array($key)) { Mecha::SVR($cargo, $key, $value); } else { foreach ($key as $k => $v) { Mecha::SVR($cargo, $k, $v); } } Mecha::extend(self::$bucket, $cargo); }
public static function set($session, $value = "", $expire = 1, $path = '/', $domain = "", $secure = false, $http_only = false) { if (strpos($session, 'cookie:') === 0) { $name = substr($session, 7); $expire = time() + 60 * 60 * 24 * $expire; if (strpos($name, '.') !== false) { $parts = explode('.', $name); $name = array_shift($parts); $old = Converter::strEval(isset($_COOKIE[$name]) ? $_COOKIE[$name] : array()); if (is_object($value)) { $value = Mecha::A($value); } Mecha::SVR($old, implode('.', $parts), $value); $value = $old; } setcookie($name, base64_encode(json_encode($value, true)), $expire, $path, $domain, $secure, $http_only); setcookie('__' . $name, base64_encode(json_encode(array($expire, $path, $domain, $secure, $http_only), true)), $expire, '/', "", false, false); } else { Mecha::SVR($_SESSION, $session, $value); } }
Config::set(array('page_title' => $speak->configs . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.config.php')); if ($request = Request::post()) { Guardian::checkToken($request['token']); $bools = array('comments.allow' => false, 'comments.moderation' => false, 'widget_include_css' => false, 'widget_include_js' => false, 'html_parser.active' => Request::post('html_parser.active', false)); $pages = array('index' => 'article', 'tag' => 'tag', 'archive' => 'archive', 'search' => 'search', 'manager' => 'manager'); $slugs = array(); if ($files = Get::pages()) { foreach ($files as $file) { list($_time, $_kind, $_slug) = explode('_', File::N($file), 3); $slugs[$_slug] = 1; } unset($files); } foreach ($bools as $bool => $fallback) { // Fix(es) for checkbox input(s) Mecha::SVR($request, $bool, Request::post($bool, $fallback)); } foreach ($pages as $page => $default) { // Fix(es) for slug pattern input(s) $request[$page]['slug'] = Text::parse(Request::post($page . '.slug', $default), '->slug'); if (Request::post($page . '.per_page') < 1 || floor(Request::post($page . '.per_page')) != Request::post($page . '.per_page')) { Notify::error($speak->notify_invalid_per_page_number); Guardian::memorize($request); } // Check if slug already exists on static page(s) if (isset($slugs[$request[$page]['slug']])) { Notify::error(Config::speak('notify_error_slug_exist', $request[$page]['slug'])); Guardian::memorize($request); } } if (Request::post('per_page') < 1 || floor(Request::post('per_page')) != Request::post('per_page')) {