include "includes/inc_db.php"; $db = new DB; $db1 = new DB; $db2 = new DB; // to disable further logins set to false if (true OR $allow) { $try = $_COOKIE["hsTry"]; if(!$try) setcookie ("hsTry","1",0,"/"); if ($sbmt && $cnUsername){ $cnUsername = addslashes($cnUsername); $cnPassword = addslashes($cnPassword); // check username and password // $pwd = sha1($cnPassword); use if we encrypt the password within the DB $db->query("SELECT cnId from contacts WHERE cnPassword = '$cnPassword' AND cnUsername = '$cnUsername' AND (cnArchived = 0 OR cnId = 65 OR cnId=52)"); $result = $db->num_rows(); $db->next_record(); if($result) { list($cnId) = $db->Record; //User logged in successfully set cookie and proceed to home page // -------Log users details------------------- // Retrieve senders name $query1 ="SELECT coId FROM companies, contacts WHERE coId=cnCoId AND cnId = '$cnId'"; $coName = $db2->getval($query1, "coId"); $ip=@$REMOTE_ADDR; $db1->query("INSERT INTO userlog SET usCnId='$cnId', usDate=CURRENT_DATE, usTime=CURRENT_TIME, usCoName='$coName', usIp='$ip'"); // ------------------------------------------- $SessionId = md5(rand()); $db->query("UPDATE contacts SET cnSession = '$SessionId' WHERE cnId = '$cnId'"); $expires = ($remember) ? 31536000 : 0; $test = setcookie ("$sessionVar", $SessionId, $expires,"/"); if ($test) { setcookie ('hsTry',1,0,"/"); $redirect = "system/index.php"; } else $error = "Your browser appears not to accept cookies. You must enable cookies in order to use this system. For more information please contact Home Serve on 01384 473000"; } else { $msg=1; $try++; } } // end if submit with username and password setcookie ('hsTry',$try,0,"/"); } else $error ="The system is currently being updated. Please come back shortly."; if($msg == 1) $error = "Your username or password are incorrect, please try again."; if($msg == 2) $error = "Your session has expired, please log back in."; if($msg == 3) {setcookie ("$sessionVar", "",0,"/"); setcookie("hsCurrentPage", "../dashboards/master.php" , 0, "/"); $error = "You are now logged out.";} ?>