| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 | <?phpinclude_once '../../config.php';
 include_once('../../check_login.php');
 require_once('../../function_auth.php');
 
 if (strlen($_POST["loginpw"]) > 0) {
 $strength = Password::strength($_POST["loginpw"], $_POST["username"]);
 if (!$strength) {
 exit('Insufficient password strength');
 }
 $loginpw = Password::hash($_POST["loginpw"]);
 
 }
 $nowdate = date("Y-m-d H:i:s");
 //print_r($_POST); exit;
 
 $sth1 = $dbh->prepare("SELECT * FROM sys_cms_login where cmsloginname = ? AND cmsloginid<> ? ");
 //$sth1 -> execute(array($_POST["loginname"],$_POST["cmsloginid"]));
 if (!$sth1->execute(array($_POST["loginname"], $_POST["cmsloginid"])))
 throw new Exception('[' . $sth1->errorCode() . ']: ' . $sth1->errorInfo());
 
 if ($sth1->fetchColumn() > 0) {
 header("Location: sys_cms_user_index.php?msg=此登入名稱已有人使用");
 exit;
 }
 
 // Modify
 
 if (strlen($_POST["loginpw"]) > 0) {
 $sql       = "update sys_cms_login set cmsusername=?, cmsloginname=?, lastupdate=?, cmsloginpw=? where cmsloginid=?";
 $sth2      = $dbh->prepare($sql);
 $parameter = array($_POST["username"], $_POST["loginname"], $nowdate, $loginpw, $_POST["cmsloginid"]);
 
 
 if (!$sth2->execute($parameter))
 throw new Exception('[' . $sth1->errorCode() . ']: ' . $sth1->errorInfo());
 else {
 unset($_SESSION['loginname']);
 unset($_SESSION['password']);
 unset($_SESSION['loginid']);
 unset($_SESSION['cmsloginid']);
 unset($_SESSION['role']);
 unset($_SESSION['cmsrole']);
 
 header("Location: http://".$_SERVER['HTTP_HOST']."/ergofito/webadmin/login.php");
 exit;
 }
 
 
 } else {
 $sql       = "update sys_cms_login set cmsusername=?, cmsloginname=?, lastupdate=? where cmsloginid=?";
 $sth2      = $dbh->prepare($sql);
 $parameter = array($_POST["username"], $_POST["loginname"], $nowdate, $_POST["cmsloginid"]);
 
 if (!$sth2->execute($parameter))
 throw new Exception('[' . $sth1->errorCode() . ']: ' . $sth1->errorInfo());
 else
 header("Location: sys_cms_user_index.php?msg=更新成功");
 }
 
 
 $dbh = null;
 
 ?>
 
 |