public function index() { Cache::loadPage('', 30); $inputData = array(); $postid = 0; $curPage = 0; // Model::loadWithPath('home',System::getThemePath().'model/'); if ($match = Uri::match('page\\/(\\d+)')) { $curPage = (int) $match[1]; } $txtKeywords = addslashes(Request::get('txtKeywords', '')); if ($match = Uri::match('\\/keyword\\/(.*?)\\/page')) { $txtKeywords = base64_decode($match[1]); } $loadData = Post::get(array('limitShow' => 10, 'limitPage' => $curPage, 'cacheTime' => 30, 'where' => "where title LIKE '%{$txtKeywords}%'", 'orderby' => "order by postid desc")); if (!isset($loadData[0]['postid'])) { Redirect::to('404page'); } $inputData['newPost'] = $loadData; $inputData['keywords'] = $txtKeywords; $inputData['listPage'] = Misc::genPage('search/keyword/' . base64_encode($txtKeywords), $curPage); System::setTitle('Search result with keyword "' . $txtKeywords . '" results:'); self::makeContent('search', $inputData); Cache::savePage(); }
public function filter_user_client($client, $user) { if (intval($user->info->client) != 0) { $client = Post::get(array('id' => $user->info->client, 'ignore_permissions' => true)); } return $client; }
function listRss() { header("Content-Type: application/xml; charset=UTF-8"); $location = Url::rss(); if ($match = Uri::match('^(.*?)$')) { $location = ROOT_URL . $match[1]; $reLocation = base64_encode($location); if ($loadData = Cache::loadKey($reLocation, 60)) { $loadData = json_decode($loadData, true); return $loadData; } } $inputData = array('limitShow' => 15, 'limitPage' => 0); if ($match = Uri::match('\\/page\\/(\\d+)')) { $inputData['limitPage'] = $match[1]; } if ($match = Uri::match('\\/category\\/(\\d+)')) { $id = $match[1]; $inputData['where'] = "where catid='{$id}'"; } if ($match = Uri::match('rss\\/products')) { $loadData = Products::get($inputData); } else { $loadData = Post::get($inputData); } $reLocation = base64_encode($location); Cache::saveKey($reLocation, json_encode($loadData)); return $loadData; }
public function index() { Cache::loadPage('', 30); $inputData = array(); $postid = 0; Model::loadWithPath('post', System::getThemePath() . 'model/'); if (!($match = Uri::match('post\\/(.*?)\\.html$'))) { Redirect::to('404page'); } $friendly_url = addslashes($match[1]); $loadData = Post::get(array('cacheTime' => 30, 'where' => "where friendly_url='{$friendly_url}'")); if (!isset($loadData[0]['postid'])) { Redirect::to('404page'); } $inputData = $loadData[0]; if (Request::has('btnComment')) { try { sendComment($loadData[0]['postid']); $inputData['commentAlert'] = '<div class="alert alert-success">Send comment success.</div>'; } catch (Exception $e) { $inputData['commentAlert'] = '<div class="alert alert-warning">' . $e->getMessage() . '</div>'; } } $postid = $loadData[0]['postid']; $listTag = PostTags::renderToLink($postid); $inputData['listTag'] = $listTag; $inputData['listComments'] = Comments::get(array('where' => "where postid='{$postid}' AND status='1'", 'orderby' => "order by postid desc")); Post::upView($postid); System::setTitle(ucfirst($loadData[0]['title'])); $keywords = isset($loadData[0]['keywords'][4]) ? $loadData[0]['keywords'] : System::getKeywords(); System::setKeywords($keywords); self::makeContent('post', $inputData); Cache::savePage(); }
public function act($action) { if ($action == 'atom_feed') { if (!isset($this->handler_vars['index'])) { $this->handler_vars['index'] = 1; } $url = URL::get('atom_feed', $this->handler_vars, false); } else { if ($action == 'display_entry') { if (isset($this->handler_vars['slug'])) { $post = Post::get(array('slug' => $this->handler_vars['slug'])); // don't assume that a slug means a valid post if ($post !== false) { $url = URL::get('display_entry', $post, false); } else { $url = URL::get('display_404', $this->handler_vars->getArrayCopy(), false); } } else { $post = Post::get($this->handler_vars->getArrayCopy()); if ($post !== false) { $url = $post->permalink; } else { $url = URL::get('display_404', $this->handler_vars->getArrayCopy(), false); } } } else { $url = URL::get($action, $this->handler_vars->getArrayCopy(), false); } } header('Location: ' . $url, true, 301); }
/** * Exection hook * * @param Stencil_Interface $controller Controller that initiated this class. */ public function execute(Stencil_Interface $controller) { $list = array(); if (have_posts()) { while (have_posts()) { the_post(); $object = get_post(); /** * Respect post_as_object filter */ $post_as_object = Stencil_Environment::filter('post_as_object', true); if ($post_as_object) { /** * Apply fancy Human Made Post object if loaded */ if (class_exists('Post', false)) { $item = Post::get($object->ID); } else { $item = $object; } } else { $item = (array) $object; } // Add item to the list. $list[] = $item; // Clean up. unset($item); } } wp_reset_postdata(); $controller->set('posts', $list); }
function searchResult() { $curPage = 0; $keywords = ''; if ($matches = Uri::match('tag\\/(.*?)\\/page\\/(\\d+)')) { $curPage = $matches[2]; $keywords = $matches[1]; } elseif ($matches = Uri::match('tag\\/(.*?)$')) { $curPage = 0; $keywords = $matches[1]; } // $loadPostNode=PostTags::get(array( // 'limitShow'=>10, // 'limitPage'=>$curPage, // 'where'=>"where tag_title LIKE '%$keywords%'" // )); // // print_r($loadPostNode);die(); // $total=count($loadPostNode); // $listID=''; // for($i=0;$i<$total;$i++) // { // $listID.="'".$loadPostNode[$i]['postid']."', "; // } // $listID=substr($listID, 0, strlen($listID)-2); $loadData = Post::get(array('where' => "where postid IN (select postid from post_tags where title='{$keywords}')", 'orderby' => "group by postid order by date_added")); return $loadData; }
/** * Get Post object if available * * @param int $id Post ID. * * @return array|null|Post|WP_Post */ function convert_post_id_to_post_object($id) { if (class_exists('Post')) { return Post::get($id); } return get_post($id); }
/** * Redirects the link from an embedded player, feed, or an html * download link to the actual file * * @param PluginHandler $handler. Primarily used to get the handler vars * @return Nothing. * @TODO make sure $podcast actually holds a valid feed * @TODO make sure $method is valid */ public function action_plugin_act_podcast_media($handler) { // $podcast is the name of the podcast $podcast = $handler->handler_vars['podcast_name']; // $post is the post we're using $post = Post::get(array('slug' => $handler->handler_vars['post_name'])); // $method is the source of the link // embed - from an on-page player // download- from a download link under the player // feed - from a feed $method = $handler->handler_vars['method']; $info = $post->info->{"{$podcast}"}; if (!empty($info) && isset($info['enclosure'])) { $filename = $handler->handler_vars['filename']; $url = dirname($info['enclosure']) . '/' . $filename; // allow plugins to act. intended for stats Plugins::act('podcast_redirect', $podcast, $post, $method, rawurldecode($filename)); header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); header('Pragma:no-cache'); // HTTP/1.0 header('Content-type: ' . Utils::mimetype($url)); header('Content-Length: ' . $info['size']); Utils::redirect($url); } }
/** * Exection hook * * @param Stencil_Interface $controller Controller that initiated this class. */ public function execute(Stencil_Interface $controller) { $url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $controller->set('self', $url); // Loading post(s) as object or array. $post_as_object = Stencil_Environment::filter('post_as_object', true); $object = get_queried_object(); if ($object && is_a($object, 'WP_Post')) { /** * Filter to chose whether the 'post' variable is set as array or object */ if ($post_as_object) { if (class_exists('Post', false)) { $controller->set('post', Post::get($object->ID)); } else { $controller->set('post', $object); } } else { $controller->set('post', (array) $object); } // Additional handy variables. $controller->set('id', $object->ID); $controller->set('post_type', get_post_type($object)); } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->post_id = Post::get()->id; $this->paramarray = array('id' => 'foofoo', 'post_id' => $this->post_id, 'name' => 'test', 'email' => '*****@*****.**', 'url' => 'http://example.org', 'ip' => ip2long('127.0.0.1'), 'content' => 'test content', 'status' => Comment::STATUS_UNAPPROVED, 'date' => HabariDateTime::date_create(), 'type' => Comment::COMMENT); $this->comment = new Comment($this->paramarray); $this->comment->insert(); }
function countStats() { $resultData = array(); $today = date('Y-m-d'); $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post")); $resultData['post']['total'] = $loadData[0]['totalcount']; $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where DATE(date_added)='{$today}'")); $resultData['post']['today'] = $loadData[0]['totalcount']; $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where status='1'")); $resultData['post']['published'] = $loadData[0]['totalcount']; $loadData = Post::get(array('query' => "select count(postid)as totalcount from " . Database::getPrefix() . "post where status='0'")); $resultData['post']['pending'] = $loadData[0]['totalcount']; $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments")); $resultData['comments']['total'] = $loadData[0]['totalcount']; $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where DATE(date_added)='{$today}'")); $resultData['comments']['today'] = $loadData[0]['totalcount']; $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where status='1'")); $resultData['comments']['approved'] = $loadData[0]['totalcount']; $loadData = Comments::get(array('query' => "select count(commentid)as totalcount from " . Database::getPrefix() . "comments where status='0'")); $resultData['comments']['pending'] = $loadData[0]['totalcount']; $loadData = Contactus::get(array('query' => "select count(contactid)as totalcount from " . Database::getPrefix() . "contactus")); $resultData['contactus']['total'] = $loadData[0]['totalcount']; $loadData = Contactus::get(array('query' => "select count(contactid)as totalcount from " . Database::getPrefix() . "contactus where DATE(date_added)='{$today}'")); $resultData['contactus']['today'] = $loadData[0]['totalcount']; $loadData = Users::get(array('query' => "select count(userid)as totalcount from " . Database::getPrefix() . "users")); $resultData['users']['total'] = $loadData[0]['totalcount']; $loadData = Users::get(array('query' => "select count(userid)as totalcount from " . Database::getPrefix() . "users where DATE(date_added)='{$today}'")); $resultData['users']['today'] = $loadData[0]['totalcount']; return $resultData; }
/** * Deletes a post from the database. */ public function post_delete_post() { $extract = $this->handler_vars->filter_keys('id', 'nonce', 'timestamp', 'digest'); foreach ($extract as $key => $value) { ${$key} = $value; } $okay = true; if (empty($id) || empty($nonce) || empty($timestamp) || empty($digest)) { $okay = false; } $wsse = Utils::WSSE($nonce, $timestamp); if ($digest != $wsse['digest']) { $okay = false; } $post = Post::get(array('id' => $id, 'status' => Post::status('any'))); if (!ACL::access_check($post->get_access(), 'delete')) { $okay = false; } if (!$okay) { Utils::redirect(URL::get('admin', 'page=posts&type=' . Post::status('any'))); } $post->delete(); Session::notice(_t('Deleted the %1$s titled "%2$s".', array(Post::type_name($post->content_type), Utils::htmlspecialchars($post->title)))); Utils::redirect(URL::get('admin', 'page=posts&type=' . Post::status('any'))); }
public function index() { Cache::loadPage('', 30); $inputData = array(); $postid = 0; $curPage = 0; // Model::loadWithPath('home',System::getThemePath().'model/'); if (!($match = Uri::match('tag\\/(\\w+)\\/?'))) { Redirect::to('404page'); } $friendly_url = addslashes($match[1]); if ($match = Uri::match('page\\/(\\d+)')) { $curPage = (int) $match[1]; } $loadData = Post::get(array('limitShow' => 10, 'limitPage' => $curPage, 'cacheTime' => 30, 'where' => "where postid IN (select postid from post_tags where title='{$friendly_url}')", 'orderby' => "order by postid desc")); if (!isset($loadData[0]['postid'])) { Redirect::to('404page'); } $inputData['newPost'] = $loadData; $inputData['keywords'] = $friendly_url; $inputData['listPage'] = Misc::genPage('tag/' . $friendly_url, $curPage); System::setTitle('Tag "' . $friendly_url . '" results:'); self::makeContent('tag', $inputData); Cache::savePage(); }
public function action_comment_insert_after($comment) { // we should only execute on comments, not pingbacks // and don't bother if the comment is know to be spam if ($comment->type != Comment::COMMENT || $comment->status == Comment::STATUS_SPAM) { return; } $post = Post::get(array('id' => $comment->post_id)); $author = User::get_by_id($post->user_id); $status = $comment->status == Comment::STATUS_UNAPPROVED ? ' UNAPPROVED' : ' approved'; $title = sprintf(_t('[%1$s] New%3$s comment on: %2$s'), Options::get('title'), $post->title, $status); $message = <<<MESSAGE The following comment was added to the post "%1\$s". %2\$s Author: %3\$s <%4\$s> URL: %5\$s %6\$s ----- Moderate comments: %7\$s MESSAGE; $message = _t($message); $message = sprintf($message, $post->title, $post->permalink, $comment->name, $comment->email, $comment->url, $comment->content, URL::get('admin', 'page=comments')); $headers = array('MIME-Version: 1.0', 'Content-type: text/plain; charset=utf-8', 'Content-Transfer-Encoding: 8bit', 'From: ' . $this->mh_utf8($comment->name) . ' <' . $comment->email . '>'); mail($author->email, $this->mh_utf8($title), $message, implode("\r\n", $headers)); }
/** * Get the results from the database * * @param Int $forumHolderID ForumHolderID to limit it too * @param String $query need to make real escape for data safe * @param String $order * @param Int Offset * @param Int Limit * * @return DataSet Results of matching posts or empty DataSet if no results. */ public function getResults($forumHolderID, $query, $order = null, $offset = 0, $limit = 10) { //sanitise the query string to avoid XSS (Using the ORM will also help avoid this too). $query = Convert::raw2sql(trim($query)); //sanitise the order/sorting as it can be changed by the user in quesry string. $order = Convert::raw2sql(trim($order)); //explode the query into the multiple terms to search, supply as an array to pass into the ORM filter. $terms = explode(' ', $query); //Add the original full query as one of the keywords. $terms[] = $query; //Get posts (limitation is that it picks up the whole phase rather than a FULLTEXT SEARCH. //We are aiming to keep this as simple as possible). More complex impementations acheived with Solr. //Rquires the post be moderated, then Checks for any match of Author name or Content partial match. //Author name checks the full query whereas Content checks each term for matches. $posts = Post::get()->filter(array('Status' => 'Moderated', 'Forum.ParentID' => $forumHolderID))->filterAny(array('Author.Nickname:PartialMatch:nocase' => $query, 'Author.FirstName:PartialMatch:nocase' => $query, 'Author.Surname:PartialMatch:nocase' => $query, 'Content:PartialMatch:nocase' => $terms))->leftJoin('ForumThread', 'Post.ThreadID = ForumThread.ID'); // Work out what sorting method switch ($order) { case 'newest': $posts = $posts->sort('Created', 'DESC'); break; case 'oldest': break; case 'title': $posts = $posts->sort(array('Thread.Title' => 'ASC')); break; default: $posts = $posts->sort(array('Thread.Title' => 'ASC', 'Created' => 'DESC')); break; } return $posts ? $posts : new DataList(); }
/** * Filters the habminbar via Plugin API to add the edit menu item. * * @param array $menu The Habminbar array * @return array The modified Habminbar array */ public function filter_habminbar( $menu ) { if ( Controller::get_var('slug') ) { $post = Post::get('slug=' . Controller::get_var('slug')); $menu['write']= array( 'Edit', URL::get( 'admin', 'page=publish&id=' . $post->id ) ); } return $menu; }
public function hasone() { $post = Post::get()->first(); $author = $post->Author(); $content .= '$post = Post::get()->first(); <br>'; $content .= '$author = $post->Author(); <br>'; return $this->customise(new ArrayData(array('Title' => "Performance: {$this->dbType} has one", 'Content' => $content)))->renderWith(array('PerformanceController', 'AppController')); }
public function getIndex() { $posts = Post::get(); if (!$posts) { $posts = app('EmptyCollection'); } $data['data'] = $posts->toArray(); $this->layout->nest('content', 'ravel::admin.content.pages.home', $data); }
public function theme_route_event_ics($theme, $handler) { $slug = Controller::get_var('slug'); $theme->post = Post::get(array('slug' => $slug)); header('Content-type: text/x-vcalendar; charset=utf-8'); header('content-disposition: inline; filename=' . $slug . '.ics'); ob_end_clean(); $theme->display('eventone.ics'); }
public function test_should_update_datetime_correctly() { $params = array('title' => 'Expiring salutation', 'body' => 'Expiring Hello world!', 'expires_at(1i)' => '2007', 'expires_at(2i)' => '10', 'expires_at(3i)' => '15', 'expires_at(4i)' => '17', 'expires_at(5i)' => '30'); $Post = new Post(); $Post->setAttributes($params); $this->assertTrue($Post->save()); $Post->reload(); $this->assertEqual($Post->get('expires_at'), '2007-10-15 17:30:00'); }
public function filter_url_args($args, $post) { if ($post instanceof Post && $post->typename == 'proposal') { $client_user = User::get_by_id($post->info->client_contact); $client = Post::get(array('id' => $client_user->info->client, 'ignore_permissions' => true)); $args['client_slug'] = $client->slug; } return $args; }
public function filter_theme_act_display_home($handled, $theme) { $page = Options::get('staticfront__page'); if ($page && $page != 'none') { $post = Post::get(array('slug' => $page)); $theme->act_display(array('posts' => $post)); return TRUE; } return FALSE; }
public function index() { $post = new Post(); $data['posts'] = $post->get(); // Create the view $this->template->title = 'Posts'; $this->template->javascript->add('assets/js/masonry.min.js'); $this->template->content->view('posts/index', $data); $this->template->publish(); }
public function view() { $params = $this->getParams(); if (empty($params[0])) { throw new ActionControllerException('Undefined post id'); } $post_id = (int) $params[0]; $post = Post::get($post_id); $vars = array('title' => 'Title', 'description' => 'Description', 'post' => $post); $this->render('post', $vars); }
static function getPostUpdatePage() { if (isset(Router::get('ids')[0])) { $post = new Post(Router::get('ids')[0]); $id = $post->get('id'); $title = $post->get('title'); $content = $post->get('content'); $author = $post->get('author'); if (unserialize($_SESSION['user'])->get('id') != $author->get('id')) { http_response_code(403); die('<h1>403 Accès interdit !</h1><p>Vous ne pouvez pas modifier cet article, vous n\'en êtes pas l\'auteur.</p>'); } } else { $id = null; $title = null; $content = null; $author = null; } if (!(isset($_SESSION['user']) && $_SESSION['user'] != null)) { http_response_code(403); die('<h1>403 Accès interdit !</h1><p>Vous devez être connecté pour créer un article.</p><p><a href="' . Conf::$BASE_URL . '/user/login">Se connecter</a></p>'); } if ($_POST != null) { extract($_POST); $errors = Post::checkErrors($_POST); if (count($errors) == 0) { if (!isset(Router::get('ids')[0])) { $success = Post::create($title, $content, $author); } else { $success = Post::update(Router::get('ids')[0], $title, $content); } if ($success) { header('Location: ' . Conf::$BASE_URL . '/post/' . $success); } } } $action = Router::get('uri'); $wording = Router::get('uri') == '/post/create' ? 'Créer' : 'Modifier'; echo self::render('postUpdatePage', array('action' => $action, 'wording' => $wording, 'id' => $id, 'title' => $title, 'content' => $content, 'author' => $author)); }
public function filter_theme_act_display_home($handled, $theme) { $vars = Controller::get_handler_vars(); if (empty($vars['page'])) { $page = Options::get('criticalhit__home'); if ($page && $page != '--none--') { $post = Post::get(array('slug' => $page)); $theme->act_display(array('posts' => $post)); return true; } } return false; }
/** * Update all the posts to have a forum ID of their thread ID. */ function requireDefaultRecords() { $posts = Post::get()->filter(array('ForumID' => 0, 'ThreadID:GreaterThan' => 0)); if ($posts->exists()) { foreach ($posts as $post) { if ($post->ThreadID) { $post->ForumID = $post->Thread()->ForumID; $post->write(); } } DB::alteration_message(_t('Forum.POSTSFORUMIDUPDATED', 'Forum posts forum ID added'), 'created'); } }
function searchResult() { $curPage = 0; $keywords = ''; if ($matches = Uri::match('search\\/keyword\\/(.*?)\\/page\\/(\\d+)')) { $curPage = $matches[2]; $keywords = base64_decode($matches[1]); } else { $keywords = Request::get('txtKeywords', ''); } $loadData = Post::get(array('limitShow' => 24, 'limitPage' => $curPage, 'where' => "where title LIKE '%{$keywords}%'")); return $loadData; }
public function showWelcome() { //echo "Coming Soon"; try { DB::connection()->getDatabaseName(); $post = Post::get(); $cats = Category::orderBy('order_type')->get(); // i++ page count counter('home'); return View::make('index')->with('posts', $post)->with('cats', $cats); } catch (Exception $e) { return Redirect::route('install'); } }