aboutsummaryrefslogtreecommitdiffstats
path: root/toj/php/connect.inc.php
blob: 3eebe89260da91c6313ac29ef23631e776215bf2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

define('DB_NAME','xxxxx');
define('DB_USER','xxxxx');
define('DB_PASSWORD','xxxxx');
define('SEC_SALT','xxxxx');

define('SMTP_HOST','xxxxx');
define('SMTP_USER','xxxxx');
define('SMTP_PASS','xxxxx');

const CENTER_SOCKET_PORT = 2501;

function sec_is_login()
{
    if(!isset($_COOKIE['uid']) || !isset($_COOKIE['usec'])){
        return false;
    }

    $userid = $_COOKIE['uid'];
    $usersec = $_COOKIE['usec'];

    if($userid == '' || $usersec == '' || strval(intval($userid)) != $userid || hash('sha512',$userid.SEC_SALT) != $usersec){
        return false;
    }

    return true;
}

function db_connect($dbn = DB_NAME)
{
    return pg_connect('host=localhost port=5432 dbname='.$dbn.' user='.DB_USER.' password='.DB_PASSWORD);
}

function db_close($sqlcx)
{
    pg_close($sqlcx);
}

?>