/** * Returns default view data. * * @static * @return array */ public static function defaults() { if (is_null(static::$viewDefaults) or php_sapi_name() == 'cli') { // Get all site configuration $site = Site::config(); // Get system active status. This is done in order to ensure // that 1.x features are available $active = System::version($site->general->version) > 0; static::$viewDefaults = array('site' => $site, 'active' => $active, 'error' => Session::get('messages.error'), 'success' => Session::get('messages.success'), 'global' => Session::get('messages.global'), 'context' => System::action(), 'container' => Input::has('ajax') ? 'wrapper' : 'page'); // Inject user and role information on active systems if ($active) { static::$viewDefaults = array_merge(static::$viewDefaults, array('auth' => Auth::user(), 'role' => Auth::roles())); } } return static::$viewDefaults; }
/** * Flood control for Sticky Notes. * This disallowes a user to create pastes in less than 5 second intervals. * * @access private * @return bool */ private function runNoflood() { $posted = Session::get('form.posted'); $threshold = Site::config('antispam')->floodThreshold; if (time() - $posted >= $threshold) { Session::put('form.posted', time()); return TRUE; } return FALSE; }
/** * Gets or sets installer messages * * @static * @param string $version * @param string $message * @return array|null */ public static function messages($version = NULL, $message = NULL) { $messages = Session::has('setup.messages') ? Session::get('setup.messages') : array(); if (is_null($message)) { return is_null($version) ? $messages : $messages[$version]; } else { if (!is_null($version)) { $messages[$version] = $message; } } Session::put('setup.messages', $messages); }