|
@@ -10,18 +10,19 @@ if ($act == "logout") {
|
|
|
$currentTime = date('Y-m-d H:i:s');
|
|
|
$loginAct = $employeeName . " " . $currentTime . "从" . $ip . "退出系统";
|
|
|
|
|
|
- $stmt = $conn->prepare("INSERT INTO logrecord (loginName, loginTime, loginAct) VALUES (?, ?, ?)");
|
|
|
- $stmt->bind_param("sss", $employeeName, $currentTime, $loginAct);
|
|
|
- $stmt->execute();
|
|
|
+ // 使用传统SQL拼接替代参数绑定
|
|
|
+ $sql = "INSERT INTO logrecord (loginName, loginTime, loginAct) VALUES ('$employeeName', '$currentTime', '$loginAct')";
|
|
|
+ $conn->query($sql);
|
|
|
|
|
|
// 清除所有session变量
|
|
|
$sessionVars = ['employee_id', 'employee_name', 't', 't1', 't2', 't3', 't4', 'd1', 'd2'];
|
|
|
foreach ($sessionVars as $var) {
|
|
|
unset($_SESSION[$var]);
|
|
|
}
|
|
|
+ unset($_SESSION['employee_id']);
|
|
|
}
|
|
|
|
|
|
-unset($_SESSION['employee_id']);
|
|
|
+
|
|
|
|
|
|
if ($act == "login") {
|
|
|
|
|
@@ -44,12 +45,9 @@ if ($act == "login") {
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
- // 查询用户
|
|
|
-
|
|
|
- $stmt = $conn->prepare("SELECT id, em_user, em_password, em_role, em_code, em_email, em_tel, lastIp FROM employee WHERE em_user = ?");
|
|
|
- $stmt->bind_param("s", $loginuser);
|
|
|
- $stmt->execute();
|
|
|
- $result = $stmt->get_result();
|
|
|
+ // 查询用户 - 使用传统SQL拼接
|
|
|
+ $sql = "SELECT id, em_user, em_password, em_role, em_permission_role_id, em_code, em_email, em_tel, lastIp FROM employee WHERE em_user = '$loginuser'";
|
|
|
+ $result = $conn->query($sql);
|
|
|
|
|
|
if ($result->num_rows == 0) {
|
|
|
echo "4";
|
|
@@ -64,25 +62,24 @@ if ($act == "login") {
|
|
|
|
|
|
$_SESSION['employee_id'] = (int)$row['id'];
|
|
|
$_SESSION['employee_name'] = $row['em_user'];
|
|
|
+ $_SESSION['em_permission_role_id'] = $row['em_permission_role_id']??0;//权限角色ID
|
|
|
+
|
|
|
+
|
|
|
echo "7";
|
|
|
|
|
|
- // 更新最后登录IP
|
|
|
- $stmt = $conn->prepare("UPDATE employee SET lastIp = ? WHERE id = ?");
|
|
|
- $stmt->bind_param("si", $ip, $_SESSION['employee_id']);
|
|
|
- $stmt->execute();
|
|
|
+ // 更新最后登录IP - 使用传统SQL拼接
|
|
|
+ $sql = "UPDATE employee SET lastIp = '$ip' WHERE id = " . $_SESSION['employee_id'];
|
|
|
+ $conn->query($sql);
|
|
|
|
|
|
- // 处理回收客户
|
|
|
+ // 处理回收客户 - 使用传统SQL拼接
|
|
|
$backToSeaStr = "SELECT id, cs_updatetime, cs_claimdate, cs_claimFrom, cs_chain
|
|
|
FROM customer
|
|
|
WHERE cs_claimFrom != ''
|
|
|
AND cs_claimdate > '2023-01-01'
|
|
|
AND cs_deal != 3
|
|
|
- AND cs_belong = ?";
|
|
|
+ AND cs_belong = " . $_SESSION['employee_id'];
|
|
|
|
|
|
- $stmt = $conn->prepare($backToSeaStr);
|
|
|
- $stmt->bind_param("i", $_SESSION['employee_id']);
|
|
|
- $stmt->execute();
|
|
|
- $result = $stmt->get_result();
|
|
|
+ $result = $conn->query($backToSeaStr);
|
|
|
|
|
|
while ($row = $result->fetch_assoc()) {
|
|
|
$updateTime = strtotime($row['cs_updatetime']);
|
|
@@ -97,45 +94,47 @@ if ($act == "login") {
|
|
|
$row['cs_claimFrom'] :
|
|
|
$row['cs_chain'] . "," . $row['cs_claimFrom'];
|
|
|
|
|
|
- $updateStmt = $conn->prepare("UPDATE customer SET cs_belong = ?, cs_chain = ? WHERE id = ?");
|
|
|
- $updateStmt->bind_param("isi", $row['cs_claimFrom'], $cs_chain, $row['id']);
|
|
|
- $updateStmt->execute();
|
|
|
+ // 使用传统SQL拼接
|
|
|
+ $updateSql = "UPDATE customer SET cs_belong = " . $row['cs_claimFrom'] . ", cs_chain = '$cs_chain' WHERE id = " . $row['id'];
|
|
|
+ $conn->query($updateSql);
|
|
|
} elseif ($updateTime > $claimDate) {
|
|
|
- $updateStmt = $conn->prepare("UPDATE customer SET cs_claimdate = '2022-12-31' WHERE id = ?");
|
|
|
- $updateStmt->bind_param("i", $row['id']);
|
|
|
- $updateStmt->execute();
|
|
|
+ // 使用传统SQL拼接
|
|
|
+ $updateSql = "UPDATE customer SET cs_claimdate = '2022-12-31' WHERE id = " . $row['id'];
|
|
|
+ $conn->query($updateSql);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 统计数据
|
|
|
+ // 统计数据 - 使用传统SQL拼接
|
|
|
$counts = [
|
|
|
- 't' => "SELECT COUNT(id) FROM customer WHERE cs_belong = ?",
|
|
|
- 't1' => "SELECT COUNT(id) FROM customer WHERE cs_type = 1 AND cs_belong = ?",
|
|
|
- 't2' => "SELECT COUNT(id) FROM customer WHERE cs_type = 2 AND cs_belong = ?",
|
|
|
- 't3' => "SELECT COUNT(id) FROM customer WHERE cs_type = 3 AND cs_belong = ?",
|
|
|
- 't4' => "SELECT COUNT(id) FROM customer WHERE cs_type = 4 AND cs_belong = ?",
|
|
|
- 'd1' => "SELECT COUNT(id) FROM customer WHERE cs_deal = 3 AND cs_belong = ?",
|
|
|
- 'd2' => "SELECT COUNT(id) FROM customer WHERE cs_deal = 2 AND cs_belong = ?",
|
|
|
- 'd3' => "SELECT COUNT(id) FROM customer WHERE DATEDIFF(NOW(), cs_updatetime) > 120 AND cs_belong = ?"
|
|
|
+ 't' => "SELECT COUNT(id) FROM customer WHERE cs_belong = " . $_SESSION['employee_id'],
|
|
|
+ 't1' => "SELECT COUNT(id) FROM customer WHERE cs_type = 1 AND cs_belong = " . $_SESSION['employee_id'],
|
|
|
+ 't2' => "SELECT COUNT(id) FROM customer WHERE cs_type = 2 AND cs_belong = " . $_SESSION['employee_id'],
|
|
|
+ 't3' => "SELECT COUNT(id) FROM customer WHERE cs_type = 3 AND cs_belong = " . $_SESSION['employee_id'],
|
|
|
+ 't4' => "SELECT COUNT(id) FROM customer WHERE cs_type = 4 AND cs_belong = " . $_SESSION['employee_id'],
|
|
|
+ 'd1' => "SELECT COUNT(id) FROM customer WHERE cs_deal = 3 AND cs_belong = " . $_SESSION['employee_id'],
|
|
|
+ 'd2' => "SELECT COUNT(id) FROM customer WHERE cs_deal = 2 AND cs_belong = " . $_SESSION['employee_id'],
|
|
|
+ 'd3' => "SELECT COUNT(id) FROM customer WHERE DATEDIFF(NOW(), cs_updatetime) > 120 AND cs_belong = " . $_SESSION['employee_id']
|
|
|
];
|
|
|
|
|
|
foreach ($counts as $key => $query) {
|
|
|
- $stmt = $conn->prepare($query);
|
|
|
- $stmt->bind_param("i", $_SESSION['employee_id']);
|
|
|
- $stmt->execute();
|
|
|
- $result = $stmt->get_result();
|
|
|
+ $result = $conn->query($query);
|
|
|
$_SESSION[$key] = $result->fetch_row()[0];
|
|
|
}
|
|
|
|
|
|
- // 记录登录日志
|
|
|
- $date=date('Y-m-d H:i:s');
|
|
|
- $stmt = $conn->prepare("INSERT INTO logrecord (loginName, loginTime, loginAct) VALUES (?, ?, ?)");
|
|
|
+ // 记录登录日志 - 使用传统SQL拼接
|
|
|
+ $date = date('Y-m-d H:i:s');
|
|
|
$loginAct = $_SESSION['employee_name'] . " " . date('Y-m-d H:i:s') . "从" . $ip . "登录";
|
|
|
- $stmt->bind_param("sss", $_SESSION['employee_name'],$date , $loginAct);
|
|
|
- $stmt->execute();
|
|
|
+ $sql = "INSERT INTO logrecord (loginName, loginTime, loginAct) VALUES ('" . $_SESSION['employee_name'] . "', '$date', '$loginAct')";
|
|
|
+ $conn->query($sql);
|
|
|
|
|
|
exit;
|
|
|
}
|
|
|
+
|
|
|
+if(isset($_SESSION['employee_id'])){
|
|
|
+ header("Location: home.php");
|
|
|
+ exit;
|
|
|
+}
|
|
|
+
|
|
|
?>
|
|
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|