Example #1
0
 public static function connect()
 {
     if (!self::$isConnected) {
         mysql_connect(self::$host, self::$username, self::$password) or die("Cannot connect to server");
         mysql_select_db(self::$db_name) or die("Cannot select DB");
         self::$isConnected = true;
     }
 }
Example #2
0
<?php

require_once 'database.inc.php';
require_once "mysql_connect_data.inc.php";
$db = new Database($host, $userName, $password, $database);
$db->openConnection();
if (!$db->isConnected()) {
    header("Location: cannotConnect.html");
    exit;
}
$userId = $_REQUEST['userId'];
if (!$db->userExists($userId)) {
    $db->closeConnection();
    header("Location: noSuchUser.html");
    exit;
}
$db->closeConnection();
session_start();
$_SESSION['db'] = $db;
$_SESSION['userId'] = $userId;
header("Location: booking1.php");
Example #3
0
 private static function connect()
 {
     $connect = @mysql_connect(self::HOST, self::USER, self::PASSWORD) or die("Невозможно установить соединение" . mysql_error());
     mysql_select_db(self::DATABASE, $connect) or die("Невозможно выбрать указанную базу" . mysql_error());
     self::$isConnected = true;
 }
function user_login($username, $password, $ishashed = 0)
{
    if (Database::isConnected()) {
        global $db;
        $db->close();
    }
    $twtapi = user_getTWTAPI();
    $result = $twtapi->query('twt.login', array('username' => $username, 'password' => $password, 'ishashed' => $ishashed));
    if ($result) {
        user_touch($result->twtname, $result->auth_key, $result->realname, $result->uid);
        if ($db) {
            global $db;
            $db->conn();
            load_model('user.func');
            user_APISync($result);
        }
    }
    return $result;
}