Example #1
0
<?php

//ini_set('session.save_path','tcp://localhost:6379');
require_once realpath($_SERVER['DOCUMENT_ROOT']) . '/includes/database.inc.php';
require_once realpath($_SERVER['DOCUMENT_ROOT']) . '/includes/functions.inc.php';
init_timezone();
/* Auth */
session_name('NSH');
if (!session_id()) {
    session_start();
}
if (!isset($_SESSION['loggedin'])) {
    $_SESSION['loggedin'] = null;
}
$err = array();
if (isset($_POST['login'])) {
    if (!$_POST['username'] || !$_POST['password']) {
        $err[] = 'All the fields must be filled in!';
    }
    if (!count($err)) {
        if ($_POST['username'] == credential(0) && check_pass($_POST['password'], credential(1))) {
            $_SESSION['loggedin'] = 1;
            header('location: ' . $_SERVER['HTTP_REFERER']);
        } else {
            if ($_POST['username'] != credential(0) || !check_pass($_POST['password'], credential(1))) {
                $err[] = 'Wrong username and/or password!';
            }
        }
    }
}
/* End Auth */
Example #2
0
function render_country_json()
{
    global $geoip_record;
    global $time_zone;
    init_timezone();
    $json_array = array('country' => $geoip_record->country_code, 'utc_offset' => $time_zone, 'timezone' => date_default_timezone_get());
    echo json_encode($json_array);
}