function get_user_posts() { if (isset($_SESSION[config("site.url")]['user'])) { $posts = get_profile_posts($_SESSION[config("site.url")]['user'], 1, 5); if (!empty($posts)) { echo '<table class="post-list">'; echo '<tr class="head"><th>Title</th><th>Published</th>'; if (config("views.counter") == "true") { echo '<th>Views</th>'; } echo '<th>Tag</th><th>Operations</th></tr>'; $i = 0; $len = count($posts); foreach ($posts as $p) { if ($i == 0) { $class = 'item first'; } elseif ($i == $len - 1) { $class = 'item last'; } else { $class = 'item'; } $i++; echo '<tr class="' . $class . '">'; echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>'; echo '<td>' . date('d F Y', $p->date) . '</td>'; if (config("views.counter") == "true") { echo '<td>' . $p->views . '</td>'; } echo '<td>' . $p->tag . '</td>'; echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>'; echo '</tr>'; } echo '</table>'; } } }
render('denied', array('title' => 'Popular posts - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'bodyclass' => 'denied', 'breadcrumb' => '')); } } else { $login = site_url() . 'login'; header("location: {$login}"); } }); // Show admin/mine get('/admin/mine', function () { if (login()) { config('views.root', 'system/admin/views'); $name = $_SESSION[config("site.url")]['user']; $page = from($_GET, 'page'); $page = $page ? (int) $page : 1; $perpage = config('profile.perpage'); $posts = get_profile_posts($name, $page, $perpage); $total = get_count($name, 'dirname'); $author = get_author($name); if (isset($author[0])) { $author = $author[0]; } else { $author = default_profile($name); } if (empty($posts) || $page < 1) { render('user-posts', array('title' => 'My blog posts - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'page' => $page, 'heading' => 'My posts', 'posts' => null, 'about' => $author->about, 'name' => $author->name, 'bodyclass' => 'userposts', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Profile for: ' . $author->name, 'pagination' => has_pagination($total, $perpage, $page))); die; } render('user-posts', array('title' => 'My blog posts - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'heading' => 'My posts', 'page' => $page, 'posts' => $posts, 'about' => $author->about, 'name' => $author->name, 'bodyclass' => 'userposts', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Profile for: ' . $author->name, 'pagination' => has_pagination($total, $perpage, $page))); } else { $login = site_url() . 'login'; header("location: {$login}");