some steps to get an actual authentication going, consolidate includes, put DB config...
[authserver.git] / index.php
CommitLineData
133aecbe
RK
1<?php
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6// Include the common auth system files (including the OAuth2 Server object).
7require_once(__DIR__.'/authsystem.inc.php');
8
9// Start HTML document as a DOM object.
10extract(ExtendedDocument::initHTML5()); // sets $document, $html, $head, $title, $body
11$document->formatOutput = true; // we want a nice output
12
13$style = $head->appendElement('link');
14$style->setAttribute('rel', 'stylesheet');
15$style->setAttribute('href', 'authsystem.css');
16
17$title->appendText('KaiRo.at Authentication Server');
18$h1 = $body->appendElement('h1', 'KaiRo.at Authentication Server');
19
20$logged_in = false;
21$user_id = 0;
22$user_email = '';
23
24if ($logged_in) {
25 $div = $body->appendElement('div', $user_email);
26 $div->setAttribute('class', 'loginheader');
27 $div = $body->appendElement('div');
28 $div->setAttribute('class', 'loginlinks');
29 $link = $div->appendLink('?logout', _('Log out'));
30 $link->setAttribute('title', _('Log out user of the system'));
31}
32else { // not logged in
33 $form = $body->appendForm('#', 'POST', 'loginform');
34 $form->setAttribute('class', 'loginarea');
35 $label = $form->appendLabel('login_email', _('Email').':');
36 $label->setAttribute('id', 'emailprompt');
37 $label->setAttribute('class', 'loginprompt');
38 $inptxt = $form->appendInputText('form[email]', 30, 20, 'login_email', (intval($user_id)?$user_email:''));
39 $inptxt->setAttribute('class', 'login');
40 $form->appendElement('br');
41 $label = $form->appendLabel('login_pwd', _('Password').':');
42 $label->setAttribute('id', 'pwdprompt');
43 $label->setAttribute('class', 'loginprompt');
44 $inptxt = $form->appendInputPassword('form[pwd]', 20, 20, 'login_pwd', '');
45 $inptxt->setAttribute('class', 'login');
46 $form->appendElement('br');
47 $cbox = $form->appendInputCheckbox('form[remember]', 'login_remember', 'true', false);
48 $cbox->setAttribute('class', 'logincheck');
49 $label = $form->appendLabel('login_remember', _('Remember me'));
50 $label->setAttribute('id', 'rememprompt');
51 $label->setAttribute('class', 'loginprompt');
52 $form->appendElement('br');
53 $submit = $form->appendInputSubmit(_('Log in'));
54 $submit->setAttribute('class', 'loginbutton');
55}
56
57// Send HTML to client.
58print($document->saveHTML());
59?>