public static function instance() { if (!self::$instance) { self::$instance = new seo(); } return self::$instance; }
public function action_leaderboard() { $active = DB::query(Database::SELECT, "\n\t SELECT users.id, COUNT(talkreplies.user_id) as posts\n\t FROM talkreplies\n\t LEFT JOIN users ON users.id = talkreplies.user_id\n\t GROUP BY talkreplies.user_id\n\t ORDER BY posts DESC\n\t LIMIT 10\n\t ")->execute()->as_array(); $streaks = ORM::factory('User')->order_by('current_streak', 'DESC')->limit(10)->find_all(); $points = DB::query(Database::SELECT, "\n\t\t\tSELECT (SUM(page.points)+user.points) as points, page.user_id AS id FROM `pages` AS page\n\t\t\tJOIN `users` AS user ON user.id = page.user_id\n\t\t\tGROUP BY page.user_id\n\t\t\tORDER BY points DESC\n\t\t\tLIMIT 10\n\t\t")->execute()->as_array(); seo::instance()->title("Morning Pages leaderboard"); seo::instance()->description("Morning Pages leaderboard"); $this->bind('active', $active); $this->bind('streaks', $streaks); $this->bind('points', $points); }
public function action_404() { seo::instance()->title("Page not found"); seo::instance()->description("Morning Pages is about writing three pages of stream of consciousness thought every day. Become a better person by using MorninPages.net"); $error = ORM::factory('Error'); $error->type = '404'; $error->url = URL::site(request::detect_uri() . (isset($_GET) && !empty($_GET) ? '?' . http_build_query($_GET) : ''), request::factory()); $error->ip = $_SERVER['REMOTE_ADDR']; $error->client = $_SERVER['HTTP_USER_AGENT']; $error->server = serialize($_SERVER); $error->referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; $error->time = time(); $error->save(); // 404 HTTP response $this->response->status(404); }
public function action_options() { $this->require_login(true); $errors = false; if ($_POST) { try { $user = user::get(); $user->update_user($_POST, array('email', 'bio', 'website', 'password')); $user->save(); $options = $user->option; $options->timezone_id = (int) arr::get($_POST, 'timezone_id', 152); $options->language = (int) arr::get($_POST, 'language', 1); $options->save(); notes::success('Your info has been updated!'); user::redirect('options'); } catch (ORM_Validation_Exception $e) { $errors = $e->errors('models'); } } $this->bind('errors', $errors); seo::instance()->title("Morning Pages User Options"); seo::instance()->description("Use these settings to adjust privacy levels, change writing settings, or more."); }
public function action_talk() { $tag = $this->request->param('tag'); $talk = $this->request->param('talk'); if (user::logged()) { // Iterate views if ($talk->user_id != user::get()->id) { $talk->views = $talk->views + 1; try { $talk->save(); } catch (ORM_Validation_Exception $e) { //var_dump($e->errors()); } } // Set when the user last saw the topic $user = user::get(); $viewed = $user->talkviews->where('talk_id', '=', $talk->id)->find(); if (!$viewed->loaded()) { $viewed->user_id = $user->id; $viewed->talk_id = $talk->id; } $viewed->last = time(); $viewed->save(); } $replies = $talk->replies->where('op', '!=', 1); $counter = $talk->replies->where('op', '!=', 1); $limit = Kohana::$config->load('talk')->get('pagination_limit'); $numreplies = $counter->count_all(); $numpages = ceil($numreplies / $limit); $page = (int) arr::get($_GET, 'page', 0); if ($_POST) { $this->require_login(); $reply = ORM::factory('Talkreply'); $reply->values($_POST); $reply->user_id = user::get()->id; $reply->talk_id = $talk->id; try { $reply->save(); $page = $numpages; $talk->last_reply = time(); $talk->save(); $subscriptions = $talk->subscriptions->find_all(); if ((bool) $subscriptions->count()) { foreach ($subscriptions as $subscription) { if ($subscription->user_id != $reply->user_id) { mail::create('talkreplyposted')->to($subscription->user->email)->tokenize(array('username' => $subscription->user->username, 'sendername' => $reply->user->username, 'title' => $talk->title, 'reply' => $reply->content, 'link' => HTML::anchor(URL::site($talk->url() . '?page=' . $page . '#comment-' . $reply->id, 'http'), $talk->title)))->send(); } } } $vote = ORM::factory('User_Talkvote'); $vote->type = 'talkreply'; $vote->user_id = user::get()->id; $vote->object_id = $reply->id; $vote->save(); notes::success('Your reply has been posted.'); site::redirect($talk->url() . '?page=' . $page . '#comment-' . $reply->id); } catch (ORM_Validation_Exception $e) { notes::error('Whoops! Your submission contained errors. Please review it and submit again'); $errors = $e->errors(); } } if ($page < 1) { $page = 1; } if ($page > $numpages) { $page = $numpages; } $replies = $replies->limit($limit); if ($page - 1 > 0) { $replies = $replies->offset($limit * ($page - 1)); } $replies = $replies->find_all(); $this->bind('tag', $tag); $this->bind('talk', $talk); $this->bind('replies', $replies); $this->bind('tags', ORM::factory('Talktag')->find_all()); $this->bind('numpages', $numpages); $this->bind('currentpage', $page); seo::instance()->title($talk->title); seo::instance()->description("Talk About Morning Pages, or anything else you might find interesting. Use this area to ask questions, make friends, or find out information about Morning Pages."); }
<!DOCTYPE html> <html lang="en"> <head> <title>Morning Pages - Free online journaling platform</title> <?php /* <script src="//use.typekit.net/rod6iku.js"></script> <script>try{Typekit.load();}catch(e){}</script> */ ?> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta content="Morning Pages" name="name"> <meta content="<?php echo seo::instance()->description(); ?> " name="description"> <meta name="google-site-verification" content="GRSH_5xF1zNVylG4dVPeMMzbAd-3x5snMapOlZwfNp8" /> <link href="<?php echo URL::site('media/img/favicon.ico'); ?> " rel="shortcut icon" /> <link rel="apple-touch-icon" href="<?php echo URL::site('media/img/favicon.png'); ?> " /> <link rel="stylesheet" type="text/css" id="mainstyles" href="<?php echo URL::site('media/css/style.css'); ?> " /> </head> <?php $theme = '';
public function action_index() { seo::instance()->title("Morning Pages"); seo::instance()->description("Morning Pages is a website in which users write three pages of stream of consciousness thought and earn rewards, gain self-enlightenment, and most importantly, have fun! Begin writing with no registration!"); }
public function action_faq() { seo::instance()->title("Morning Pages Questions"); seo::instance()->description("Frequently asked questions regarding your Morning Pages, the Morning Pages website, and more. Don't see your listed? Check the Morning Pages forum for more info."); }
public function action_notpublic() { seo::instance()->title("Morning Pages Profile"); seo::instance()->description("This Morning Pages profile is private."); }
public function action_pagestats() { seo::instance()->title("Page stats"); $this->bind('page', $this->request->param('page')); }