/var/www/hkosl.com/littleark/webadmin/user_profile_modify.php


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
<?php
$page_settings 
= array(
    
'formid'     => 'Upf_UserProfile'// for permission
    
'section'    => 'User'// parent/page title
    
'subsection' => 'Profile'// page title
    
'domain'     => 'user_profile'// table/model name
    
'access'     => 'GNr'// for permission
);

require_once 
"check_login.php";
require_once 
'function_auth.php';

// TODO: require to verify by existing password
$user SysCmsLogin::where('cmsloginid''=', (int) $_SESSION["cmsloginid"])->first();

$message "";
if (empty(
$_POST["username"])) {
    
$message .= _lang("Please enter User Name.") . "\\n\\n";
}

// if (empty($_POST["loginname"])) {
//     $message .= _lang("Please enter Login Name.") . "\\n\\n";
// }

if (strlen($_POST["loginpw_new"]) && ($_POST["loginpw_new"] != $_POST["loginpw_confirm"])) {
    
$message .= _lang("Please verify the password.") . "\\n\\n";
}

if (
$user->cmsloginpw !== Password::hash($_POST['loginpw'])) {
    
$message .= _lang("Please verify the password.") . "\\n\\n";
}

if (!empty(
$message)) {
    echo 
"<script>alert('" $message "'); history.back();</script>";
    exit;
}

// vdump(Password::hash($_POST['loginpw']), $valid);
// exit;

$user->fill([
    
'cmsusername' => $_POST['username'],
]);

if (
strlen($_POST["loginpw_new"]) > 0) {
    
$strength Password::strength($_POST["loginpw_new"], $_POST["username"]);
    if (!
$strength) {
        exit(
_lang('Insufficient password strength'));
    }
    
$user->cmsloginpw Password::hash($_POST["loginpw_new"]);
}

$user->save();
// dq(1,1);

header("Location: {$page_settings['domain']}_modifyform.php?msg=2");
exit;