fix cookies
This commit is contained in:
parent
91271b9f00
commit
b6fadae2e5
@ -29,7 +29,7 @@ class User
|
|||||||
public static function getTawkToHash($email)
|
public static function getTawkToHash($email)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
if (!empty($config['tawkto_api_key']) && !Empty($email)) {
|
if (!empty($config['tawkto_api_key']) && !empty($email)) {
|
||||||
return hash_hmac('sha256', $email, $config['tawkto_api_key']);
|
return hash_hmac('sha256', $email, $config['tawkto_api_key']);
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
@ -169,11 +169,11 @@ class User
|
|||||||
public static function generateToken($uid, $validDays = 30)
|
public static function generateToken($uid, $validDays = 30)
|
||||||
{
|
{
|
||||||
global $db_pass;
|
global $db_pass;
|
||||||
if($validDays>=30){
|
if ($validDays >= 30) {
|
||||||
$time = time();
|
$time = time();
|
||||||
}else{
|
} else {
|
||||||
// for customer, deafult expired is 30 days
|
// for customer, deafult expired is 30 days
|
||||||
$time = strtotime('+ '.(30 - $validDays).' days');
|
$time = strtotime('+ ' . (30 - $validDays) . ' days');
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -187,7 +187,7 @@ class User
|
|||||||
global $db_pass;
|
global $db_pass;
|
||||||
if (isset($uid)) {
|
if (isset($uid)) {
|
||||||
$token = self::generateToken($uid);
|
$token = self::generateToken($uid);
|
||||||
setcookie('uid', $token['token'], time() + 86400 * 30);
|
setcookie('uid', $token['token'], time() + 86400 * 30, "/");
|
||||||
return $token;
|
return $token;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -197,7 +197,7 @@ class User
|
|||||||
public static function removeCookie()
|
public static function removeCookie()
|
||||||
{
|
{
|
||||||
if (isset($_COOKIE['uid'])) {
|
if (isset($_COOKIE['uid'])) {
|
||||||
setcookie('uid', '', time() - 86400);
|
setcookie('uid', '', time() - 86400, "/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,41 +277,43 @@ class User
|
|||||||
return $d;
|
return $d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setFormCustomField($uid = 0){
|
public static function setFormCustomField($uid = 0)
|
||||||
|
{
|
||||||
global $UPLOAD_PATH;
|
global $UPLOAD_PATH;
|
||||||
$fieldPath = $UPLOAD_PATH . DIRECTORY_SEPARATOR . "customer_field.json";
|
$fieldPath = $UPLOAD_PATH . DIRECTORY_SEPARATOR . "customer_field.json";
|
||||||
if(!file_exists($fieldPath)){
|
if (!file_exists($fieldPath)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$fields = json_decode(file_get_contents($fieldPath), true);
|
$fields = json_decode(file_get_contents($fieldPath), true);
|
||||||
foreach($fields as $field){
|
foreach ($fields as $field) {
|
||||||
if(!empty(_post($field['name']))){
|
if (!empty(_post($field['name']))) {
|
||||||
self::setAttribute($field['name'], _post($field['name']), $uid);
|
self::setAttribute($field['name'], _post($field['name']), $uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFormCustomField($ui, $register = false, $uid = 0){
|
public static function getFormCustomField($ui, $register = false, $uid = 0)
|
||||||
|
{
|
||||||
global $UPLOAD_PATH;
|
global $UPLOAD_PATH;
|
||||||
$fieldPath = $UPLOAD_PATH . DIRECTORY_SEPARATOR . "customer_field.json";
|
$fieldPath = $UPLOAD_PATH . DIRECTORY_SEPARATOR . "customer_field.json";
|
||||||
if(!file_exists($fieldPath)){
|
if (!file_exists($fieldPath)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$fields = json_decode(file_get_contents($fieldPath), true);
|
$fields = json_decode(file_get_contents($fieldPath), true);
|
||||||
$attrs = [];
|
$attrs = [];
|
||||||
if(!$register){
|
if (!$register) {
|
||||||
$attrs = self::getAttributes('', $uid);
|
$attrs = self::getAttributes('', $uid);
|
||||||
$ui->assign('attrs', $attrs);
|
$ui->assign('attrs', $attrs);
|
||||||
}
|
}
|
||||||
$html = '';
|
$html = '';
|
||||||
$ui->assign('register', $register);
|
$ui->assign('register', $register);
|
||||||
foreach($fields as $field){
|
foreach ($fields as $field) {
|
||||||
if($register){
|
if ($register) {
|
||||||
if($field['register']){
|
if ($field['register']) {
|
||||||
$ui->assign('field', $field);
|
$ui->assign('field', $field);
|
||||||
$html .= $ui->fetch('customer/custom_field.tpl');
|
$html .= $ui->fetch('customer/custom_field.tpl');
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$ui->assign('field', $field);
|
$ui->assign('field', $field);
|
||||||
$html .= $ui->fetch('customer/custom_field.tpl');
|
$html .= $ui->fetch('customer/custom_field.tpl');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user