summaryrefslogtreecommitdiff
path: root/includes/inc_auth.php
blob: 1545b7c251ee7e9db50b28078313da5c78d241f7 (plain)
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
<?php

global $user, $pass;

session_start();

if (isset($_COOKIE['istream']))
{
       if(sha1($pass) == $_COOKIE['istream'] ) {
 		setcookie ("istream", sha1($pass), time()+60*60*24*30);
		$authorized = true;
	} else {
		$authorised = false;
	}
}

# checkup login and password
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']))
{
    if (($user == $_SERVER['PHP_AUTH_USER']) && ($pass == ($_SERVER['PHP_AUTH_PW'])) )
    {
    setcookie ("istream", sha1($pass), time()+60*60*24*30);
    $authorized = true;
    }
}

# login
if (!$authorized)
{
    header('WWW-Authenticate: Basic Realm="Login please"');
    header('HTTP/1.0 401 Unauthorized');
    echo "Login";
    exit;
}

?>