summaryrefslogtreecommitdiff
path: root/includes/inc_auth.php
blob: 92f0fc822244ecb41a5d13204c160e9d905a7b1d (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
<?php

global $user, $pass;

session_start();

if (isset($_COOKIE['istream']))
{
        $authorized=true;
}

# 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'])) && isset($_SESSION['auth']))
    {
    $authorized = true;
    setcookie ("istream", "true", time()+60*60*24*30);
    }
}

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

?>