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/page-push.php
<?php
/* Template Name: Push */

require_once 'key_alert_functions.php';

if($_REQUEST['js']==1){
	$title = $_REQUEST['title'];
	$content = $_REQUEST['content'];
	$rv = new stdClass();
	if(empty($title)||empty($content)){
		$rv->rc = -1;
		$rv->msg = "missing params";
	}else{
		$id = c_alert($title,$content);
		$alert = r_alert($id);
		$res = send_alert($alert);
		if($res){
			$rv->rc = 1;
			$rv->msg ="success";
		}else{
			$rv->rc = -2;
			$rv->msg ="failed to push a message";
		}
	}
	exit(json_encode($rv));
}

?>
<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
	<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.js"></script>
	<script type="text/javascript">
		function push(){
			var title = $(".jpush input[name=title]").val();
			var content = $(".jpush input[name=content]").val();
			var url = "<?php echo home_url('keyalert-push');?>";
			$.ajax({
                type: "post",
                dataType: "json",
                url: url,
                data: {
                	js: 1,
                    title: title,
                    content: content
                },
                success: function(res) {
                    console.log(res)
                    // $(".prompt").empty();
                    if (res.rc == 1) {
                        alert("Success!");
                    } else {
                        alert("Error: "+res.msg);
                    }
                }
            });
		}
	</script>
</head>
<body>
	<div class="w3-container w3-padding">
		<form class="w3-card-4 jpush" style="max-width: 1200px;margin: 50px auto;" onsubmit="return false;">
			<header class="w3-container w3-teal" style="text-align: center;">
				<h5>KeyAlert Push Test</h5>
			</header>
			<div class="w3-padding-large">
				<div class="w3-margin">
					<label class="w3-text-teal"><b>Title <span style="color: red;">*</span></b></label>
					<input class="w3-input w3-border w3-light-grey" type="text" required name="title">
				</div>
				<div class="w3-margin">
					<label class="w3-text-teal"><b>Content <span style="color: red;">*</span></b></label>
					<!-- <input class="w3-input w3-border w3-light-grey" type="text" required name="content"> -->
					<textarea name="content" class="w3-input w3-border w3-light-grey" style="height: 100px;"></textarea>
				</div>

				<!-- <div class="w3-margin">
					<label class="w3-text-teal"><b>Link</b></label>
					<input class="w3-input w3-border w3-light-grey" type="text" name="link">
				</div> -->
				<button type="submit" class="w3-btn w3-blue w3-margin" onclick="push()">Push</button>
			</div>
		</form>
	</div>
</body>
</html>