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/html/wp-content/themes/ormedia/keylabData/users/send_reg_user_code.php
<?php
if(isset($_REQUEST['checking_api_file'])){
    exit();
}

$user_email = $_REQUEST['user_email'];
if(empty($user_email)) {
    $rv->rc = 1;
    $rv->msg = "Email is not vaild";
    exit(json_encode($rv));
}

function keylab_check_email($email) {
	$pattern_test = "/([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?/i";
	return  preg_match($pattern_test,$email);
}

if(!keylab_check_email($user_email)) {
    $rv->rc = 1;
    $rv->msg = "Email is not vaild";
    exit(json_encode($rv));
}

function generate_code($length = 6) {
    $min = pow(10 , ($length - 1));
    $max = pow(10, $length) - 1;
    return rand($min, $max);
}

function keylab_mail_code($toemail, $title) {
    global $wpdb;

    $generate_code = generate_code();

    $content = '
        <head>
        <base target="_blank" />
        <style type="text/css">::-webkit-scrollbar{ display: none; }</style>
        <style id="cloudAttachStyle" type="text/css">#divNeteaseBigAttach, #divNeteaseBigAttach_bak{display:none;}</style>
        <style id="blockquoteStyle" type="text/css">blockquote{display:none;}</style>
        <style type="text/css">
            body{font-size:14px;font-family:arial,verdana,sans-serif;line-height:1.666;padding:0;margin:0;overflow:auto;white-space:normal;word-wrap:break-word;min-height:100px}
            td, input, button, select, body{font-family:Helvetica, "Microsoft Yahei", verdana}
            pre {white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word;width:95%}
            th,td{font-family:arial,verdana,sans-serif;line-height:1.666}
            img{ border:0}
            header,footer,section,aside,article,nav,hgroup,figure,figcaption{display:block}
            blockquote{margin-right:0px}
        </style>
    </head>
    <body tabindex="0" role="listitem">
    <table width="700" border="0" align="center" cellspacing="0" style="width:700px;">
        <tbody>
        <tr>
            <td>
                <div style="width:700px;margin:0 auto;border-bottom:1px solid #ccc;margin-bottom:30px;">
                    <table border="0" cellpadding="0" cellspacing="0" width="700" height="39" style="font:12px Tahoma, Arial, 宋体;">
                        <tbody><tr><td width="210"></td></tr></tbody>
                    </table>
                </div>
                <div style="width:680px;padding:0 10px;margin:0 auto;">
                    <div style="line-height:1.5;font-size:18px;margin-bottom:25px;color:#4d4d4d;">
                        <strong style="display:block;margin-bottom:15px;">Dear User,<span style="color:#f60;font-size: 16px;"></span></strong>
                        <strong style="display:block;margin-bottom:15px;">
                            You are use KeyLab verification code. The verification code is: <span style="color:#f60;font-size: 24px">'.$generate_code.'</span>.
                        </strong>
                    </div>
                </div>
            </td>
        </tr>
        </tbody>
    </table>
    </body>
    ';

    if(wp_mail($toemail, $title, $content, 'Content-type: text/html')) {
        //记录code和email
        $wpdb->insert("keylab_email_log", [
            'email' => $toemail,
            'code' => $generate_code,
            'type' => 1,
            'title' => $title,
            'content' => $content,
            'status' => 1
        ]);
        return true;
    } else {
        $wpdb->insert("keylab_email_log", [
            'email' => $toemail,
            'code' => $generate_code,
            'type' => 1,
            'title' => $title,
            'content' => $content,
            'status' => 2
        ]);
        return false;
    }
}
if(keylab_mail_code($user_email, "KeyLab reg check")) {
    $rv->rc = 0;
    $rv->msg = $RC_MSG[0];
    exit(json_encode($rv));
} else {
    $rv->rc = 22;
    $rv->msg = $RC_MSG[22];
    exit(json_encode($rv));
}