<?php session_start(); require_once "class.db.Log.php"; if (isset($_POST["action"])) { if ($_POST["action"] == "sliderlog") { //slider.php的点击事件记录 $data['event'] = 'click'; $data['page'] = 'slider.php'; $data['description'] = $_POST["description"]; $data['username'] = $_SESSION["email"]; $data['ip'] = getIP(); $db = new LogDB(); if ($db->insertLog($data)) { echo "Y"; } else { echo "N"; } } } function getIP() { global $ip; if (getenv("HTTP_CLIENT_IP")) { $ip = getenv("HTTP_CLIENT_IP"); } else { if (getenv("HTTP_X_FORWARDED_FOR")) { $ip = getenv("HTTP_X_FORWARDED_FOR"); } else { if (getenv("REMOTE_ADDR")) { $ip = getenv("REMOTE_ADDR");
function processLogin() { /*if(isset($_GET["username"]) and $_GET["username"]=="guest"){ $_SESSION["username"]="******"; $_SESSION["email"]="CY0000"; header("Location:home.php"); }*/ if (isset($_POST["email"]) and isset($_POST["password"])) { require_once "class.db.Utils.php"; require_once "class.LDAP.php"; require_once "class.MD5.php"; require_once "class.db.Log.php"; $ldap = new LDAP(); $md5 = new MD5(); $email = $_POST["email"]; if ($email != "") { if (!strpos($email, "@cyou-inc.com")) { $email = $email . '@cyou-inc.com'; } if ($_POST["password"] != "") { $usermsg = ""; $usermsg = $ldap->login($email, $_POST["password"]); if ($usermsg) { $email = substr($_POST["email"], 0, strpos($_POST["email"], "@")); $username = $usermsg["username"]; $employee_id = $usermsg["employee_id"]; $department = $usermsg["department"]; $db = new UserDB(); $user = $db->hasUser($_POST["email"]); //如果数据库里修改了用户名则使用修改后的,否则使用num值 if ($user) { $username = $user["username"]; } else { $db->insertLDAP(array("email" => $_POST["email"], "username" => $username, "employee_id" => $employee_id, "department" => $department)); } //保存session $_SESSION["username"] = $username; $_SESSION["email"] = $email; $_SESSION["password"] = $md5->string2secret($_POST["password"]); //保存cookie setcookie("email", $_SESSION["email"], time() + 3600 * 24 * 7); setcookie("username", $_SESSION["username"], time() + 3600 * 24 * 7); setcookie("password", $_SESSION["password"], time() + 3600 * 24 * 7); //记录登陆日志 $data['event'] = 'login'; $data['page'] = 'login.php'; $data['description'] = 'login success'; $data['username'] = $_SESSION["email"]; $data['ip'] = getIP(); $db = new LogDB(); $db->insertLog($data); header("Location: home.php"); } else { displayLoginForm("您输入的帐号或密码有误,请重试"); } } else { displayLoginForm("密码不能为空"); } } else { displayLoginForm("帐号不能为空"); } } else { displayLoginForm("登陆失败,请稍后重试"); } }
$domain = $_POST['site']; } elseif (isset($_REQUEST['site'])) { $domain = $_REQUEST['site']; } else { $domain = SITENAME; } LoadConfigFile(ROOT . "config/auth.cfg"); include ROOT . "api/helpers/pwdhash.php"; /* CLEAR_OLD_SESSION=true @session_start(); session_destroy(); session_start(); */ $dbLink = getSysDBLink(); $dbLogLink = LogDB::singleton()->getLogDBCon(); if (!$dbLink->isOpen()) { relink("Database Connection Error", $domain); } if ($userid == '') { relink('Login ID missing', $domain); } if ($pwd == '') { relink('Password missing', $domain); } $date = date('Y-m-d'); $userFields = explode(",", USERID_FIELDS); $q1 = "SELECT id, guid, userid, pwd, site, privilege, access, name, email, mobile, blocked, avatar, avatar_type FROM " . _dbTable("users", true) . " where (expires IS NULL OR expires='0000-00-00' OR expires > now())"; // AND blocked='false' //$q1="SELECT id, guid, userid, pwd, site, privilege, access, name, email, mobile, blocked FROM "._dbTable("users",true)." where userid='$userid' AND blocked='false' AND (expires IS NULL OR expires='0000-00-00' OR expires > now())";// AND blocked='false' if (CASE_SENSITIVE_AUTH == "true") {
public function WriteLog($message) { $msg = $this->processing_message($message); $strmsg = $this->get_str_msg($msg); $strmsgdate = $msg['date']; $db = new LogDB($this->DB, $this->TableName, $this->host, $this->user, $this->pass); $db->write($strmsg, $strmsgdate); }