public function action_index() { $data['settings'] = Settings::get_all(); if (\Input::method() == 'POST') { Controller_Settings::update(Input::Post()); $data['settings'] = Settings::get_all(true); } $data['blocked'] = $blacklist_item = Model_Blacklist::query()->get(); $keys = \Settings::Get('character_set'); if (empty($keys) === true) { $keys = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; } $random_length = \Settings::Get('random_url_length'); if (empty($random_length) === true) { $random_length = 5; } $url_sample_space = DB::select(DB::expr('count(id) as count'))->from('urls')->where(DB::expr('char_length(short_url)'), $random_length)->limit(1)->execute()->as_array(); $data['urls_left'] = Controller_Admin::mathFact(strlen($keys)) / (Controller_Admin::mathFact(strlen($keys) - $random_length) * Controller_Admin::mathFact($random_length)) - $url_sample_space[0]['count']; $this->template->content = View::Forge('admin/index', $data); }