Ejemplo n.º 1
0
 //~ var_dump($_SERVER);
 $db = new DBConnector('palma-test.db');
 $db->resetTables();
 //~ http://stackoverflow.com/questions/1964233/does-sqlite3-support-a-trigger-to-automatically-update-an-updated-on-datetime
 //~ https://www.sqlite.org/lang_createtrigger.html
 // TODO: Test database triggers (can be used in db.php).
 //~ $db->createFunction('dbModifiedCallback', 'dbModifiedCallback', 0);
 // {AFTER | BEFORE} {DELETE | INSERT | UPDATE } ON table
 //~ $db->exec("CREATE TRIGGER dbchange AFTER UPDATE ON user
 //~ BEGIN
 //~ dbModifiedCallback();
 //~ END");
 //~ $db = new DBConnector('palma.db');
 echo "Tables=" . $db->querySingle('SELECT count(*) FROM sqlite_master WHERE type="table"') . "\n";
 var_dump($db->query("SELECT * from sqlite_master"));
 $address = $db->ipAddress();
 $db->addUser('testuser1', $address);
 //~ $db->addUser('testuser2', $address);
 //~ $db->addUser('testuser3', $address);
 //~ $db->addUser('testuser4', $address);
 $users = $db->getUsers();
 $db->enableUser('testuser1');
 var_dump($users);
 $db->delUser('haenger', $address);
 $db->delUser('ivwz', $address);
 $db->delUser('skrieg', $address);
 $db->delUser('testuser1', $address);
 $db->delUser('testuser2', $address);
 $db->delUser('testuser3', $address);
 $db->delUser('testuser4', $address);
 echo "Query=" . $db->querySingle('select name from user') . "\n";
Ejemplo n.º 2
0
<?php

// Copyright (C) 2014 Universitätsbibliothek Mannheim
// See file LICENSE for license details.
// Datenbankanbindung initialisieren.
require_once 'DBConnector.class.php';
$dbcon = new DBConnector();
session_start();
if (isset($_SESSION['username'])) {
    $username = $_SESSION['username'];
    $dbcon->delUser($username, $dbcon->ipAddress());
}
session_destroy();
header('Location: index.php');
/*
    // Alternate code, currently unused, not working with Apache2 proxy.
    $hostname = $_SERVER['HTTP_HOST'];
    $path = dirname($_SERVER['PHP_SELF']);
    header('Location: http://'.$hostname.($path == '/' ? '' : $path).'/login.php');
*/
Ejemplo n.º 3
0
 }
 if (CONFIG_PIN) {
     $posted_pin = escapeshellcmd($_POST['pin']);
     $pin = $dbcon->querySingle("SELECT value FROM setting WHERE key = 'pin'");
 }
 if (CONFIG_PASSWORD && !checkCredentials($username, $password)) {
     // Invalid username or password.
 } else {
     if (CONFIG_PIN && $pin != $posted_pin) {
         trace("access denied for user '{$username}', wrong pin {$posted_pin}");
         $errtext = _('Invalid PIN.');
     } else {
         // Successfully checked username, password and PIN.
         trace("access granted for user '{$username}'");
         $_SESSION['username'] = $username;
         $_SESSION['address'] = $dbcon->ipAddress();
         $_SESSION['pin'] = $pin;
         $_SESSION['starturl'] = CONFIG_START_URL;
         $_SESSION['monitor'] = CONFIG_STATIONNAME;
         $dbcon->addUser($username, $dbcon->ipAddress(), getDevice());
         // Weiterleitung zur geschützten Startseite
         if ($_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1') {
             if (php_sapi_name() == 'cgi') {
                 header('Status: 303 See Other');
             } else {
                 header('HTTP/1.1 303 See Other');
             }
         }
         header('Location: ' . CONFIG_START_URL);
         exit;
     }