public function index($param) { // get installed CSS themes $files = Fari_File::listing('/public'); $themes = array(); foreach ($files as $file) { $css = end(explode('/', $file['path'])); // its cheap if ($file['type'] == 'file' && substr($css, -4) == '.css') { $themes[] = substr($css, 0, -4); } } natsort(&$themes); $this->view->themes = $themes; // are we saving changes? if ($_POST) { $css = Fari_Escape::text($_POST['css']); $title = Fari_Escape::text($_POST['title']); Fari_Db::update('settings', array('value' => $css), array('name' => 'theme')); Fari_Db::update('settings', array('value' => $title), array('name' => 'title')); Fari_Message::success('Settings change successful.'); } $this->view->messages = Fari_Message::get(); $this->view->settings = Fari_Db::toKeyValues(Fari_Db::select('settings', 'name, value'), 'name'); $this->view->display('settings'); }
public function edit($article) { if (!Fari_User::isAuthenticated('realname') or $article == NULL) { Fari_Message::fail('You need to authenticate first'); $this->redirect('/blog/login/'); } else { // are we saving updates? if (!empty($_POST['slug'])) { Fari_Db::update('articles', array('text' => Fari_Escape::quotes($_POST['text']), 'status' => $_POST['status']), array('slug' => $_POST['slug'])); Fari_Message::success('Changes saved'); } // pickup messages for us $this->view->messages = Fari_Message::get(); // a specific article $article = Fari_Escape::URL($article); $this->view->article = $article = Fari_Db::selectRow('articles', '*', array('slug' => $article)); $this->view->display('/themes/' . BLOG_THEME . '/edit'); } }
public function star($slug) { $result = Fari_Db::selectRow('kb', '*', array('slug' => $slug)); if (empty($result)) { // text not found $this->redirect('/error404'); die; } // switch the star for the text we have already fetched & update in the db if ($result['starred'] == 'full') { $result['starred'] = 'empty'; // switch in the current set Fari_Db::update('kb', array('starred' => 'empty'), array('id' => $result['id'])); } else { $result['starred'] = 'full'; // switch in the current set Fari_Db::update('kb', array('starred' => 'full'), array('id' => $result['id'])); } // return back header('Location: ' . $_SERVER['HTTP_REFERER']); }