forked from mlangill/biotorrents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
takelogin.php
39 lines (27 loc) · 910 Bytes
/
takelogin.php
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
<?php
//print_r($_POST);exit();
require_once("include/bittorrent.php");
if (!mkglobal("username:password"))
die();
session_start();
dbconn();
function bark($text = "Username or password incorrect")
{
stderr("Login failed!", $text);
}
$res = mysql_query("SELECT id, passhash, secret, enabled,status FROM users WHERE username = " . sqlesc($username) . "");
$row = mysql_fetch_assoc($res);
if (!$row)
bark();
if ($row["passhash"] != md5($row["secret"] . $password . $row["secret"]))
bark();
if($row["status"]=="pending")
bark('You have not confirmed your email address yet. More information is <a href="faq.php#user1">here</a>.');
if ($row["enabled"] == "no")
bark("This account has been disabled.");
logincookie($row["id"], $row["passhash"]);
if (!empty($_POST["returnto"]))
header("Location: $_POST[returnto]");
else
header("Location: browse.php");
?>