|
|
@@ -353,18 +353,53 @@ class utils {
|
|
|
* reset password link email sendEmailByResetPassword
|
|
|
*/
|
|
|
public static function sendEmailByResetPassword($data, $email) {
|
|
|
- $sql = "select subject, ra_content as content from ra_online_email_tpl where lower(ra_type) = 'forgotpw'";
|
|
|
+ $sql = "select subject, ra_content as content from ra_online_email_tpl where lower(ra_type) = 'kln_reset'";
|
|
|
$rs = common::excuteObjectSql($sql);
|
|
|
if (!empty($rs)) {
|
|
|
$subject = $rs['subject'];
|
|
|
$content = $rs['content'];
|
|
|
}
|
|
|
if (!empty($subject) && !empty($content)) {
|
|
|
-
|
|
|
- $verifcation_code = utils::AES_128_CBC_Encrypt($data['User_Login']);
|
|
|
- $link = SERVER_Vue_PAHT."login.php?action=login&operate=resetAndActivateInit&verifcation_code=".$verifcation_code;
|
|
|
+ $verifcation_code = utils::AES_128_CBC_Encrypt($data['user_login'],"USAIandy20244Q9X","0123456123456789");
|
|
|
+ //http://localhost:8080/k_new_online/login?state=reset&verifcation_code=XXX
|
|
|
+ $encoded = rawurlencode($verifcation_code);
|
|
|
+ $link = SERVER_Vue_PAHT."login?state=reset&name=".$data['user_login']."&verifcation_code=".$encoded;
|
|
|
+
|
|
|
+ $tplData = array("username"=>$data['user_login'],
|
|
|
+ "creation_date"=>$data['current_time'],
|
|
|
+ "link" =>$link);
|
|
|
+
|
|
|
+ // 动态构建替换数组(格式:[key] => value)
|
|
|
+ $replacements = [];
|
|
|
+ foreach ($tplData as $key => $value) {
|
|
|
+ $replacements["{{$key}}"] = $value;
|
|
|
+ $replacements["{{{$key}}}"] = $value;
|
|
|
+ }
|
|
|
+ $content = strtr($content, $replacements);
|
|
|
+ $content = common::check_input($content);
|
|
|
+
|
|
|
+ common::excuteUpdateSql("INSERT INTO public.email_record_forgotpassword(type, title, from_email, to_email, content, insert_date,
|
|
|
+ cc_email) VALUES ('forgot_password', '" . common::check_input($subject) . "', 'US.KApex.Online@kerryapex.com', '" .
|
|
|
+ common::check_input($email) . "', '" . $content . "', now(), '');
|
|
|
+ INSERT INTO public.customer_service_secret_key(secret_key, create_time) VALUES('".$verifcation_code."',now())");
|
|
|
+ return "success";
|
|
|
+ //return Mail::sendMail($email, $subject, $content);
|
|
|
+ } else
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- if(strtolower($data['user_type']) == "employee"){
|
|
|
+ /**
|
|
|
+ * reset password link email sendEmailByResetPassword
|
|
|
+ */
|
|
|
+ public static function sendEmailWithPasswordUpdate($user_login, $user_type) {
|
|
|
+ $sql = "select subject, ra_content as content from ra_online_email_tpl where lower(ra_type) = 'kln_passwordchange'";
|
|
|
+ $rs = common::excuteObjectSql($sql);
|
|
|
+ if (!empty($rs)) {
|
|
|
+ $subject = $rs['subject'];
|
|
|
+ $content = $rs['content'];
|
|
|
+ }
|
|
|
+ if (!empty($subject) && !empty($content)) {
|
|
|
+ if(strtolower($user_type) == "employee"){
|
|
|
$sql = "SELECT lower(ra_name) as ra_name, ra_value from ra_online_config where lower(ra_name) in ('employee_password_change_cycle')";
|
|
|
} else {
|
|
|
$sql = "SELECT lower(ra_name) as ra_name, ra_value from ra_online_config where lower(ra_name) in ('customer_password_change_cycle')";
|
|
|
@@ -374,12 +409,15 @@ class utils {
|
|
|
foreach ($rs1s as $rs1) {
|
|
|
$PASSWORD_CHANGE_CYCLE = $rs1['ra_value'];
|
|
|
}
|
|
|
- $expiry_date = common::excuteOneSql("select to_char((current_date + INTERVAL '".$PASSWORD_CHANGE_CYCLE." days'),'Mon-DD-YYYY');");
|
|
|
+ $dateInfo = common::excuteObjectSql("select
|
|
|
+ to_char(now(), 'Mon-DD-YYYY') as current_date,
|
|
|
+ to_char(now(), 'Mon-DD-YYYY HH:mm:ss') as current_time,
|
|
|
+ to_char((current_date + INTERVAL '".$PASSWORD_CHANGE_CYCLE." days'),'Mon-DD-YYYY') as expiry_date ;");
|
|
|
|
|
|
- $tplData = array("username"=>$data['User_Login'],
|
|
|
- "creation_date"=>$data['current_time'],
|
|
|
- "expiry_date"=>$expiry_date,
|
|
|
- "link" =>$link);
|
|
|
+ $tplData = array("username"=>$user_login,
|
|
|
+ "creation_date"=>$dateInfo['current_time'],
|
|
|
+ "update_date"=>$dateInfo['current_date'],
|
|
|
+ "expiry_date"=>$dateInfo['expiry_date']);
|
|
|
|
|
|
// 动态构建替换数组(格式:[key] => value)
|
|
|
$replacements = [];
|
|
|
@@ -390,12 +428,13 @@ class utils {
|
|
|
$content = strtr($content, $replacements);
|
|
|
$content = common::check_input($content);
|
|
|
|
|
|
- common::excuteUpdateSql("INSERT INTO public.email_record_forgotpassword(type, title, from_email, to_email, content, insert_date,
|
|
|
- cc_email) VALUES ('forgot_password', '" . common::check_input($subject) . "', 'US.KApex.Online@kerryapex.com', '" .
|
|
|
- common::check_input($email) . "', '" . common::check_input($content) . "', now(), '');
|
|
|
- insert customer_service_secret_key(secret_key,create_time) value('".$verifcation_code."',now())");
|
|
|
+ $email = _getLoginEamil();
|
|
|
+ $sql = "INSERT INTO email_record(type, title, from_email, to_email, content, insert_date, cc_email, attachment_path)
|
|
|
+ VALUES ('kln_passwordChange', '" . common::check_input($subject) . "', 'US.KApex.Online@kerryapex.com', '" .
|
|
|
+ common::check_input($email) . "', '" . common::check_input($content) . "', now(), '', '');";
|
|
|
+
|
|
|
+ common::excuteUpdateSql($sql);
|
|
|
return "success";
|
|
|
- //return Mail::sendMail($email, $subject, $content);
|
|
|
} else
|
|
|
return null;
|
|
|
}
|
|
|
@@ -1646,10 +1685,10 @@ class utils {
|
|
|
}
|
|
|
|
|
|
//AES 加密
|
|
|
- public static function AES_128_CBC_Encrypt($data){
|
|
|
- $key = 'fT5!R1k$7Mv@4Q9X'; // 密钥应该是16字节(128位),24字节(192位)或32字节(256位)
|
|
|
+ public static function AES_128_CBC_Encrypt($data,$key = "fT5!R1k$7Mv@4Q9X",$iv = '1234567890123456'){
|
|
|
+ //$key = 'fT5!R1k$7Mv@4Q9X'; // 密钥应该是16字节(128位),24字节(192位)或32字节(256位)
|
|
|
$method = 'AES-128-CBC';
|
|
|
- $iv = '1234567890123456';
|
|
|
+ //$iv = '1234567890123456';
|
|
|
// 加密
|
|
|
$encrypted = openssl_encrypt($data, $method, $key, OPENSSL_RAW_DATA, $iv);
|
|
|
// 编码为可打印的字符串,如Base64
|
|
|
@@ -1660,9 +1699,9 @@ class utils {
|
|
|
/**
|
|
|
* 解密decrypt
|
|
|
*/
|
|
|
- public static function AES_encrypted($encrypted_string,$isbase64_encode = true){
|
|
|
- $key = 'fT5!R1k$7Mv@4Q9X'; // 16 bytes key
|
|
|
- $iv = '1234567890123456'; // 16 bytes IV
|
|
|
+ public static function AES_encrypted($encrypted_string,$isbase64_encode = true,$key = "fT5!R1k$7Mv@4Q9X",$iv = '1234567890123456'){
|
|
|
+ //$key = 'fT5!R1k$7Mv@4Q9X'; // 16 bytes key
|
|
|
+ //$iv = '1234567890123456'; // 16 bytes IV
|
|
|
if($isbase64_encode){
|
|
|
$decrypted = openssl_decrypt(base64_decode($encrypted_string), 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv);
|
|
|
}else{
|