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/doco/keytest/wp-content/themes/ormedia/keyAlertData/alert/u_alert.php
<?php
if (isset($_REQUEST['checking_api_file'])){
    exit();
}
function is_alert_opened($uid, $msg_id)
{
	global $wpdb;
	$res = $wpdb->get_row($wpdb->prepare("select id from keylab_alert_opened where uid = %d and msg_id = %d", $uid, $msg_id));
	return $res != null;
}

date_default_timezone_set('Asia/Hong_Kong');
$uid = $_REQUEST['uid'];
$msg_id = $_REQUEST['msg_id'];
if (empty($uid) || empty($msg_id)) {
	$rv->rc = -1;
	$rv->msg = "missing params";
} else {
	if (is_alert_opened($uid, $msg_id)) {
		$rv->rc = -2;
		$rv->msg = "is opened";
	} else {
		$res = $wpdb->insert(
			'keylab_alert_opened',
			array(
				'uid' => $uid,
				'msg_id' => $msg_id,
				'creation_time' => current_time('mysql')
			),
			array('%d', '%d', '%s')
		);
		if ($res === false) {
			$rv->rc = -3;
			$rv->msg = "failed to insert a row";
		} else {
			$rv->rc = 1;
			$rv->msg = "success";
		}
	}
}
insert_log($_REQUEST['uid'], $token, 0, get_request_string(), "更新alert狀態:rc=" . $rv->rc . ",msg=" . $rv->msg);
echo json_encode($rv);