output_json(0, "请求成功", array("total" => $total, "page" => $page, "page_count" => $page_count, "list" => $list)); } elseif ($act == "add") { $id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0; if ($id) { $row = $db->get_row("select * from data where id = " . $id, ARRAY_A); $row["content"] = html_entity_decode($row["content"]); } else { $row = array("id" => 0, "name" => "", "sort" => 0, "dataclass_id" => 0, "content" => "", "type" => intval($_REQUEST['type'])); } $smarty->assign('row', $row); $smarty->display('admin/admin_data_add.html'); } elseif ($act == "addsubmit") { $list = array("name" => str_filter($_REQUEST["name"]), "content" => str_filter($_REQUEST["content"]), "sort" => intval($_REQUEST["sort"]), "dataclass_id" => intval($_REQUEST["dataclass_id"]), "type" => intval($_REQUEST["type"])); $id = isset($_REQUEST["id"]) ? intval($_REQUEST["id"]) : 0; if ($id) { $sql = SqlText::update("data", $list, "id=" . $id); $db->query($sql); output_json(0, "更新成功"); } else { $list["add_time"] = time(); $list["hits"] = 0; $sql = SqlText::insert("data", $list); $db->query($sql); output_json(0, "添加成功"); } } elseif ($act == "del") { $sql = "delete from data where id = " . intval($_REQUEST["id"]); $db->query($sql); output_json(0, "删除成功"); } else { exit("错误请求");
$id = intval($_REQUEST["id"]); if ($id == $_SESSION["curr_user"]["id"]) { output_json(1, "不能删除自己"); } else { $where = "id=" . $_REQUEST["id"]; $sql = SqlText::delete("user", $where); $db->query($sql); output_json(0, "删除成功"); } } elseif ($act == "pwd") { $smarty->display('admin/admin_admin_pwd.html'); } elseif ($act == "pwdsubmit") { $old_pwd = str_filter($_REQUEST["old_pwd"]); $pwd = str_filter($_REQUEST["pwd"]); $pwd2 = str_filter($_REQUEST["pwd2"]); if ($pwd == $pwd2) { $sql = SqlText::func("count", "id", "user", "name='" . $_SESSION["curr_user"]["name"] . "' and pwd='" . $old_pwd . "'"); $result = $db->get_var($sql); if ($result) { $list = array("pwd" => $pwd); $db->query(SqlText::update("user", $list, "name='" . $_SESSION["curr_user"]["name"] . "'")); output_json(0, "修改成功"); } else { output_json(1, "旧密码错误"); } } else { output_json(1, "第二次输入密码不正确"); } } else { exit("错误请求"); }
} unset($_SESSION["admin_vcode"]); } else { output_json(2); } } if ($user["pwd"] == $pwd) { unset($user["pwd"]); $_SESSION["curr_user"] = $user; $user["err_login"] = 0; $id = $user["id"]; unset($user["id"]); $db->query(SqlText::update("user", $user, "id = " . $id)); if (isset($_REQUEST["remember"]) && $_REQUEST["remember"] == 1) { setcookie("curr_user_name", urlencode(Encrypt::encode($user["name"])), time() + 86400 * 7); } output_json(0, "登录成功"); } else { $user["err_login"] += 1; $id = $user["id"]; unset($user["id"]); unset($user["pwd"]); $db->query(SqlText::update("user", $user, "id = " . $id)); output_json(1, "密码错误"); } } else { output_json(1, "没有此用户"); } } else { exit("错误请求"); }