示例#1
0
文件: pages.php 项目: csnxs/disciple
 function sn_page_header($title = 'Disciple')
 {
     echo "\n<!DOCTYPE html>\n<html>\n\t<head>\n\t\t<meta charset='utf-8' />\n\t\t<title>{$title} &mdash; Disciple</title>\n\n\t\t<script src='/assets/jquery.js'></script>\n\t\t<script src='/assets/jqueryui.js'></script>\n\t\t<script src='/assets/fe.js'></script>\n\n\t\t<link href='//fonts.googleapis.com/css?family=Roboto|Roboto+Mono|Material+Icons' rel='stylesheet' type='text/css' />\n\t\t<link href='/assets/jqueryui.css' rel='stylesheet' type='text/css' />\n\t\t<link href='/assets/shared.css' rel='stylesheet' type='text/css' />\n\t\t<link href='/assets/fe.css' rel='stylesheet' type='text/css' />\n\n\t\t<meta name='theme-color' content='#B71C1C' />\n\t</head>\n\t<body>\n\t\t<header id='main'>\n\t\t\t<div id='title'>" . disciple_json()->site_shortname . "</div>\n\n\t\t\t<nav id='left'>\n\t\t\t\t<a href='/'>Home</a>\n\t\t\t\t<a href='/wads'>WADs</a>\n\t\t\t\t<a href='/bans'>Bans</a>\n\t\t\t</nav>\n\t\t\t<nav id='right'>";
     if (isAuthed()) {
         echo "\n\t\t\t\t<a href='/me'>" . $_SESSION['user'] . "</a>\n\t\t\t\t<a href='/logout'>Log out</a>\n\t\t\t\t";
     } else {
         echo "\n\t\t\t\t<a href='/register'>Register</a>\n\t\t\t\t<a href='/login'>Log in</a>\n\t\t\t\t";
     }
     echo "\n\t\t\t</nav>\n\t\t</header>\n";
     if (!isset($_COOKIE['okcookie'])) {
         echo "\n\t\t\t\t\t<div id='shittyeucookienoticebar'>\n\t\t\t\t\t\t<a href='javascript:acceptCookies();'><img src='/images/clear.svg' style='width:16px;height:16px'/></a>\n\t\t\t\t\t\tThis site uses cookies to remember your identity.\n\t\t\t\t\t</div>\n\t\t\t\t";
     }
 }
示例#2
0
<?php

require 'header.php';
?>
    <div class="mw300 center">
    <form>
        <input type="text" name="username" placeholder="Brugernavn" />
        <input type="password" name="password" placeholder="Kodeord" />
        <input type="submit" value="login" />
    </form>
        <?php 
if (isAuthed()) {
    ?>
        <a href="/admin">Administrator panel</a>
        <?php 
}
?>
    </div>

    <script>
        $('form').on('submit', function(e) {e.preventDefault();});
        $('input[type="submit"]').click(function() {
            $.post("/api/", {
                action: 'user_login',
                username: $('input[name="username"]').val(),
                password: $('input[name="password"]').val()
            },
            function(data) {
                if(JSON.parse(data).success)
                    window.location = '/';
            });