convert AuthUtils to a non-static class and instantiate it as an object, support...
[authserver.git] / authsystem.inc.php
CommitLineData
133aecbe 1<?php
d46a42f1
RK
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
133aecbe
RK
6// error reporting (for testing)
7ini_set('display_errors', 1); error_reporting(E_ALL);
8
9// Read DB settings
10$dbdata = json_decode(file_get_contents('/etc/kairo/auth_db.json'), true);
11if (!is_array($dbdata)) { trigger_error('DB configuration not found', E_USER_ERROR); }
12
13// Extended DOM document class
14require_once('../kairo/include/cbsm/util/document.php-class');
b19743bc
RK
15// Class for sending emails
16require_once('../kairo/include/classes/email.php-class');
d46a42f1
RK
17// Class for sending emails
18require_once(__DIR__.'/authutils.php-class');
ac442755 19$utils = new AuthUtils(array());
133aecbe
RK
20
21bindtextdomain('kairo_auth', 'en'); // XXX: Should negotiate locale.
22bind_textdomain_codeset('kairo_auth', 'utf-8');
23
d26d08a1
RK
24// Connect to our MySQL DB
25$db = new PDO($dbdata['dsn'], $dbdata['username'], $dbdata['password']);
26
27/* Creating the DB tables:
d46a42f1
RK
28CREATE TABLE `auth_sessions` (
29 `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT ,
30 `sesskey` VARCHAR(150) NOT NULL DEFAULT '' ,
31 `user` MEDIUMINT UNSIGNED NULL DEFAULT NULL ,
32 `logged_in` BOOLEAN NOT NULL DEFAULT FALSE ,
33 `time_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
34 `time_expire` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
35 PRIMARY KEY (`id`),
36 INDEX (`sesskey`),
37 INDEX (`time_expire`)
38);
39CREATE TABLE `auth_users` (
40 `id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT ,
41 `email` VARCHAR(255) NOT NULL ,
42 `pwdhash` VARCHAR(255) NOT NULL ,
43 `status` ENUM('unverified','ok') NOT NULL DEFAULT 'unverified' ,
44 `verify_hash` VARCHAR(150) NULL DEFAULT NULL ,
45 PRIMARY KEY (`id`),
46 UNIQUE (`email`)
47);
d26d08a1
RK
48*/
49
133aecbe
RK
50// include our OAuth2 Server object
51require_once(__DIR__.'/server.inc.php');
52?>