Пример #1
0
            $message['error'] .= '<li>CSRF Token not correct.</li>';
        }
        config('views.root', 'system/admin/views');
        render('edit-page', array('title' => 'Edit page - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'error' => '<ul>' . $message['error'] . '</ul>', 'oldfile' => $oldfile, 'postTitle' => $title, 'postUrl' => $url, 'postContent' => $content, 'static' => $static, 'sub' => $sub, 'bodyclass' => 'editpage', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; Edit page'));
    }
});
// Delete sub static page
get('/:static/:sub/delete', function ($static, $sub) {
    if (login()) {
        config('views.root', 'system/admin/views');
        $post = get_static_post($static);
        if (!$post) {
            not_found();
        }
        $post = $post[0];
        $page = get_static_sub_post($static, $sub);
        if (!$page) {
            not_found();
        }
        $page = $page[0];
        render('delete-page', array('title' => 'Delete page - ' . blog_title(), 'description' => blog_description(), 'canonical' => site_url(), 'bodyclass' => 'deletepage', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; <a href="' . $post->url . '">' . $post->title . '</a>' . $page->title, 'p' => $page, 'type' => 'subPage'));
    } else {
        $login = site_url() . 'login';
        header("location: {$login}");
    }
});
// Submitted data from delete sub static page
post('/:static/:sub/delete', function () {
    $proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
    if ($proper && login()) {
        $file = from($_REQUEST, 'file');
Пример #2
0
function get_user_pages()
{
    if (isset($_SESSION[config("site.url")]['user'])) {
        $posts = get_static_post(null);
        if (!empty($posts)) {
            krsort($posts);
            echo '<table class="post-list">';
            echo '<tr class="head"><th>Title</th>';
            if (config("views.counter") == "true") {
                echo '<th>Views</th>';
            }
            echo '<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>';
                if (config("views.counter") == "true") {
                    echo '<td>' . $p->views . '</td>';
                }
                echo '<td><a href="' . $p->url . '/add?destination=admin">Add Sub</a> <a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
                echo '</tr>';
                $shortUrl = substr($p->url, strrpos($p->url, "/") + 1);
                $subPages = get_static_sub_post($shortUrl, null);
                foreach ($subPages as $sp) {
                    echo '<tr class="' . $class . '">';
                    echo '<td> &raquo;<a target="_blank" href="' . $sp->url . '">' . $sp->title . '</a></td>';
                    if (config("views.counter") == "true") {
                        echo '<td>' . $sp->views . '</td>';
                    }
                    echo '<td><a href="' . $sp->url . '/edit?destination=admin">Edit</a> <a href="' . $sp->url . '/delete?destination=admin">Delete</a></td>';
                    echo '</tr>';
                }
            }
            echo '</table>';
        }
    }
}
Пример #3
0
        if (empty($content)) {
            $message['error'] .= '<li>Content field is required.</li>';
        }
        if (!$proper) {
            $message['error'] .= '<li>CSRF Token not correct.</li>';
        }
        config('views.root', 'system/admin/views');
        render('add-page', array('head_contents' => head_contents('Add page - ' . blog_title(), blog_description(), site_url()), 'error' => '<ul>' . $message['error'] . '</ul>', 'postTitle' => $title, 'postUrl' => $url, 'postContent' => $content, 'bodyclass' => 'addpage', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; <a href="' . $post->url . '">' . $post->title . '</a> Add page'));
    }
});
get('/:static/:sub', function ($static, $sub) {
    $father_post = get_static_post($static);
    if (!$father_post) {
        not_found();
    }
    $post = get_static_sub_post($static, $sub);
    if (!$post) {
        not_found();
    }
    $post = $post[0];
    if (config("views.counter") == "true") {
        add_view($post->file);
    }
    if (!login()) {
        file_cache($_SERVER['REQUEST_URI']);
    }
    render('static', array('head_contents' => head_contents($post->title . ' - ' . blog_title(), $post->description, $post->url), 'bodyclass' => 'inpage', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> &#187; <a href="' . $father_post[0]->url . '">' . $father_post[0]->title . '</a> &#187; ' . $post->title, 'p' => $post, 'type' => 'staticpage'));
});
// If we get here, it means that
// nothing has been matched above
get('.*', function () {