示例#1
0
 /**
  * Handler for invalid URLs
  *
  * @param  int     $code         HTTP Status Code
  * @param  string  $title_prefix Prefix <title> with this string
  * @param  bool    $dump         Whether or not to include a dump of parsed URL
  * @return void
  */
 private function errorPage($code = 404, $title_prefix = 'Woops! Not found', $dump = true)
 {
     http_response_code($code);
     $this->status = $code;
     $this->request_path = '/' . join('/', $this->request_path);
     $this->description = 'No results for ' . $this->URLToString();
     $this->keywords = '';
     $this->title = $title_prefix . ' (' . $code . ')';
     $template = Core\Template::load('error_page');
     $template->home = URL;
     $template->message = "Nothing found for <wbr /><var>{$this->URLToString()}</var>";
     $template->link = $this->url;
     if ($dump) {
         $template->dump = print_r(parse_url($this->URLToString()), true);
     } else {
         $template->dump = null;
     }
     $this->content = "{$template}";
 }
示例#2
0
				FROM `users`
				WHERE `user` = :user
				LIMIT 1;')->bind(['user' => $login->user])->execute()->getResults(0);
            /*$title = urldecode(trim(strip_tags($_POST['title'])));
            		$description = trim($_POST['description']);
            		$keywords = urldecode(trim(strip_tags($_POST['keywords'])));
            		$content = trim($_POST['content']);*/
            $author = $user->name;
            $url = urlencode(strtolower(preg_replace('/\\W+/', ' ', $title)));
            $template = new \shgysk8zer0\Core\Template('posts');
            foreach (explode(',', $keywords) as $tag) {
                $template->tags .= '<a href="tags/' . trim(strtolower(preg_replace('/\\s/', '-', trim($tag)))) . '">' . trim(caps($tag)) . "</a>";
            }
            $stm = $DB->prepare("INSERT INTO `posts`(\n\t\t\t\t\t`title`,\n\t\t\t\t\t`description`,\n\t\t\t\t\t`keywords`,\n\t\t\t\t\t`author`,\n\t\t\t\t\t`author_url`,\n\t\t\t\t\t`content`,\n\t\t\t\t\t`url`,\n\t\t\t\t\t`created`\n\t\t\t\t) VALUE(\n\t\t\t\t\t:title,\n\t\t\t\t\t:description,\n\t\t\t\t\t:keywords,\n\t\t\t\t\t:author,\n\t\t\t\t\t:author_url,\n\t\t\t\t\t:content,\n\t\t\t\t\t:url,\n\t\t\t\t\t:created\n\t\t\t\t);")->bind(['title' => $title, 'description' => $description, 'keywords' => $keywords, 'author' => $user->name, 'author_url' => $user->g_plus, 'content' => $content, 'url' => $url, 'created' => date('Y-m-d H:i:s')]);
            if ($stm->execute()) {
                $template = \shgysk8zer0\Core\Template::load('posts');
                $template->title($title)->content($content)->author($user->name)->author_url($user->g_plus)->date(date('m/d/Y'))->datetime(time());
                $url = URL . '/posts/' . $url;
                $resp->notify('Post submitted', 'Check for new posts')->remove('main > :not(aside)')->prepend('body > header nav', "<a href=\"{$url}\">{$title}</a>")->prepend('main', "{$template}")->after('#main_menu > menu[label="Posts"] > menuitem[label="Home"]', "<menuitem label=\"{$title}\" icon=\"images/icons/coffee.svgz\" data-link=\"{$url}\"></menuitem>");
                $resp->remove('main > :not(aside)');
                update_sitemap();
                update_rss();
            } else {
                $resp->notify('Post failed', 'Look into what went wrong. See Developer console')->log($_POST);
            }
        } else {
            $resp->notify('Something went wrong...', 'There seems to be some missing info.');
        }
        break;
    case 'edit_post':
        require_login('admin');
示例#3
0
<?php

$template = \shgysk8zer0\Core\Template::load('recent_posts');
?>
<aside class="sidebar" rel="sidebar">
	<div class="recent posts">
		<h3 class="sticky">Recent Posts</h3>
		<?php 
echo array_reduce(get_recent_posts(15), function ($html = '', \stdClass $post) use($template, $URL) {
    return $html .= $template->title($post->title)->description($post->description)->link("{$URL}posts/{$post->url}");
});
?>
	</div>
	<div class="recent tags">
		<h3 class="sticky">Tags</h3>
		<?php 
echo array_reduce(get_all_tags(), 'recent_tags_list', $doc->appendChild($doc->createElement('ul')));
?>
	</div>
</aside>
<?php 
ob_flush();
flush();