deadly
03-24-2007, 03:50 AM
Alright, here's the code.. and what i know i need..
include('lib.php');
if (isset($_GET["do"])) {
if ($_GET["do"] == "login") { login(); }
elseif ($_GET["do"] == "logout") { logout(); }
}
function login() {
include('config.php');
$link = opendb();
if (isset($_POST["submit"])) {
$query = doquery("SELECT * FROM {{table}} WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1", "users");
if (mysql_num_rows($query) != 1) { die("Invalid username or password. Please go back and try again."); }
$row = mysql_fetch_array($query);
if (isset($_POST["rememberme"])) { $expiretime = time()+31536000; $rememberme = 1; } else { $expiretime = 0; $rememberme = 0; }
$cookie = $row["id"] . " " . $row["username"] . " " . md5($row["password"] . "--" . $dbsettings["secretword"]) . " " . $rememberme;
setcookie("dkgame", $cookie, $expiretime, "/", "", 0);
header("Location: index.php");
die();
}
$page = gettemplate("login");
$title = "Log In";
display($page, $title, false, false, false, false);
}
function logout() {
setcookie("dkgame", "", time()-100000, "/", "", 0);
header("Location: login.php?do=login");
die();
}
Minus the php tags.
Now..heres what i need to add, i've pretty much figured this part out..
Before the Header(index.php)
Now.. everytime a SQL query is made..its in the form.. DOQUERY.. Using MYSQL breaks the page, or, the game.
mysql_query("UPDATE user SET ip='".getenv('REMOTE_ADDR')."' WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1", "users"
$users=mysql_query("SELECT * FROM user");
$last=0;
$next=1;
while($user=mysql_fetch_array($users)) {
for($i=0;$i [less-than] $last && !$found;$i++) {
if($player[ip]==$IP[$i][0]) {
echo $IP[$i][1];
$found=1;
}
}
if(!$found) {
echo $next;
$IP[$last][0]=$user[ip];
$IP[$last][1]=$next;
$last++;
$next++;
}
}
and that..
NOW.. Do i need to put that last part in the Index(header)
..or in the member list(where im wanting to View everyones IP.)
Also there is a $userrow[ip] <--Database on all users.
But i cant seem to get it to Post their IP's there.
then i could just easly do
$ip=$userrow[ip]????
Anyone got any idea's?
I've spent 3 full days of coding trying to get this working.
include('lib.php');
if (isset($_GET["do"])) {
if ($_GET["do"] == "login") { login(); }
elseif ($_GET["do"] == "logout") { logout(); }
}
function login() {
include('config.php');
$link = opendb();
if (isset($_POST["submit"])) {
$query = doquery("SELECT * FROM {{table}} WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1", "users");
if (mysql_num_rows($query) != 1) { die("Invalid username or password. Please go back and try again."); }
$row = mysql_fetch_array($query);
if (isset($_POST["rememberme"])) { $expiretime = time()+31536000; $rememberme = 1; } else { $expiretime = 0; $rememberme = 0; }
$cookie = $row["id"] . " " . $row["username"] . " " . md5($row["password"] . "--" . $dbsettings["secretword"]) . " " . $rememberme;
setcookie("dkgame", $cookie, $expiretime, "/", "", 0);
header("Location: index.php");
die();
}
$page = gettemplate("login");
$title = "Log In";
display($page, $title, false, false, false, false);
}
function logout() {
setcookie("dkgame", "", time()-100000, "/", "", 0);
header("Location: login.php?do=login");
die();
}
Minus the php tags.
Now..heres what i need to add, i've pretty much figured this part out..
Before the Header(index.php)
Now.. everytime a SQL query is made..its in the form.. DOQUERY.. Using MYSQL breaks the page, or, the game.
mysql_query("UPDATE user SET ip='".getenv('REMOTE_ADDR')."' WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1", "users"
$users=mysql_query("SELECT * FROM user");
$last=0;
$next=1;
while($user=mysql_fetch_array($users)) {
for($i=0;$i [less-than] $last && !$found;$i++) {
if($player[ip]==$IP[$i][0]) {
echo $IP[$i][1];
$found=1;
}
}
if(!$found) {
echo $next;
$IP[$last][0]=$user[ip];
$IP[$last][1]=$next;
$last++;
$next++;
}
}
and that..
NOW.. Do i need to put that last part in the Index(header)
..or in the member list(where im wanting to View everyones IP.)
Also there is a $userrow[ip] <--Database on all users.
But i cant seem to get it to Post their IP's there.
then i could just easly do
$ip=$userrow[ip]????
Anyone got any idea's?
I've spent 3 full days of coding trying to get this working.