HEX
Server: Apache/2.4.59 (Debian)
System: Linux keymana 4.19.0-21-cloud-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64
User: lijunjie (1003)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/doco2/wp-content/themes/ormedia/page-api-tio-login.php
<?php
//Template Name: api-tio-login
get_header();
require_once('JwtAuthClass.php');
require_once('tio_stone_functions.php');

//INPUT
$username = $_REQUEST['login'];
$password = $_REQUEST['password'];

$rv = new stdClass();
$rv->rc = 0;
$rv->msg ="";

if (!empty($username)&&!empty($password)) {
    $user = get_tio_user($username);

    if(!empty($user)){
        $check_pass_result = wp_check_password($password, $user->user_pass);

        if($check_pass_result) {
            $payload_new=
                array('iss'=>'keylab',
                'iat'=>time(),      //創建時間
                'exp'=>time()+3600, //過期時間
                'nbf'=>time()+4200, //可刷新時間
                'sub'=>'keylab.cc',
                'jti'=>md5(uniqid('JWT').time())); //token獨立標識
            $new_token=JwtAuthClass::getToken($payload_new);

            $old_token = r_token($user->id);
            if($old_token->token != null){
                if(JwtAuthClass::verifyToken($old_token->token) == 1){
                    $rv->token = $old_token->token;
                }else{
                    u_token($user->id, $new_token);
                    u_token_pass($user->id, $old_token->token);

                    $rv->token = $new_token;
                }
            }else{
                u_token($user->id, $new_token);
                $rv->token = $new_token;
            }

            $rv->rc = 0;
            $rv->msg = 'Success';
            $rv->user_id = $user->id;

        }else{
            $rv->rc = -3;
            $rv->msg = 'Password is not correct';
        }
    }else{
        $rv->rc = -2;
        $rv->msg = 'Login is not found';
    }



}else{
    $rv->rc = -1;
    $rv->msg = 'URL parameter missing';
}
echo json_encode($rv);
?>