时间:2021-07-01 10:21:17 帮助过:14人阅读
// 连主库$link = mysql_connect(SAE_MYSQL_HOST_M .':'. SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
if($link)
{
mysql_select_db(SAE_MYSQL_DB,$link);
$getid = mysql_query("select max(Id_P) from --YOUR_DATATABLE--");
$row = mysql_fetch_array($getid);
$id = $row[0]+1;
$content = addslashes($_POST['content']);
$token = addslashes($_POST['token']);
if($content)
{
if($token == "--YOUR_TOKEN--")
{
mysql_query("INSERT INTO `--YOUR_DATABASE--`.`--YOUR_DATATABLE--` (`Id_P`, `Content`) VALUES ('$id', '$content')");
$smsapi = "--SMS_GATEWAY--"; //短信网关$user = "--SMS_ACCOUNT--"; //短信平台帐号$pass = "--SMS_PASSWORD--"; //短信平台密码$content = "【Active Defense】Sir , I get some thing:" . $content ;//要发送的短信内容$sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m="."--YOUR_PHONE--"."&c=".urlencode($content);
$result = file_get_contents($sendurl) ;
}
else
{
$msg = "token wrong!" . $content;
mysql_query("INSERT INTO `--YOUR_DATABASE--`.`--YOUR_DATATABLE--` (`Id_P`, `Content`) VALUES ('$id', '$msg')");
}
}
mysql_close($link);
}
echo"hello
";
?>
Python写的前端很简单,因为之后是要整合到主动防御的API里面去的,就没有添加那些花里胡哨的东西。
# -*- coding: utf-8 -*-import urllib2
import urllib
data = {}
data['token'] = '--YOUR_TOKEN--'
data['content'] = '--YOUR_MESSAGE--'url = "--PHP_ADDRESS--"
post_data = urllib.urlencode(data)
req = urllib2.urlopen(url, post_data)
print ("Finish")
以上就介绍了借助PHP服务器完成SMS信息转发,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。