File: auth.inc

package info (click to toggle)
php3 1%3A3.0-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 6,512 kB
  • ctags: 6,320
  • sloc: ansic: 58,611; sh: 2,279; yacc: 1,090; php: 1,031; makefile: 911; cpp: 529; perl: 411; awk: 90; sql: 11
file content (23 lines) | stat: -rw-r--r-- 799 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?
    cfunction authenticate() {
        Header("WWW-authenticate: basic realm=\"Photo Album\"");
        Header("HTTP/1.0 401 Unauthorized");
        $title="Invalid Login";
        include "include/header.inc";?>
        In order to proceed you will need a valid username/password.
        <?include "include/footer.inc";
        exit;
    }

    if(!isset($PHP_AUTH_USER)) {
        authenticate();
    } else {
        mysql_pconnect("localhost","nobody","") or die("Unable to connect to SQL server");
        mysql_select_db("rasmus") or die("Unable to select database");
        $id=strtolower($PHP_AUTH_USER);
        $query = mysql_query("select * from users where id='$id' and password='$PHP_AUTH_PW'");
        if(!mysql_num_rows($query)) {
            authenticate();
        }
    }
?>