本帖最后由 sk沧海一粟 于 2021-2-2 16:59 编辑
[PHP] 纯文本查看 复制代码 <?php
header("Content-type: text/html; charset=utf-8");
$statusStr = array(
"0" => "短信发送成功",
"-1" => "参数不全",
"-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!",
"30" => "密码错误",
"40" => "账号不存在",
"41" => "余额不足",
"42" => "帐户已过期",
"43" => "IP地址限制",
"50" => "内容含有敏感词"
);
date_default_timezone_set("PRC");
$time=date("Y-m-d H:i:s");
function get_client_ip()
{
$ip = $_SERVER['REMOTE_ADDR'];
if (isset($_SERVER['HTTP_CLIENT_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_CLIENT_IP']))
{
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (isset($_SERVER['HTTP_X_FORWARDED_FOR']) and preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches)) {
foreach ($matches[0] as $xip) {
if (!preg_match('#^(10|172\.16|192\.168)\.#', $xip))
{
$ip = $xip;
break;
}
}
}
return $ip;
}
$smsapi = "http://www.smsbao.com/"; //短信网关
$user = "xxxx"; //短信平台帐号
$pass = md5("xxx"); //短信平台密码
$content = "【狂怒科技】网站访问报表:您的网站正在被访问,时间" + $time +",访问"+get_client_ip();//要发送的短信内容
$phone = "13800000";
$sendurl = $smsapi . "sms?u=" . $user . "&p=" . $pass . "&m=" . $phone . "&c=" . urlencode($content);
$result = file_get_contents($sendurl);
echo $statusStr[$result];
?>
第一行 加了个页面编码 utf-8 不然提示乱码
|