发短信 汉字编码 utf-8 UCS-2BE

<?
function utf82unicode($str)  
{
    return iconv("utf-8", "UCS-2BE", $str);
}
function hex2str($hexstring)  
{
    $str = '';
    for($i = 0, $len = strlen($hexstring); $i < $len; $i++)
    {
        $str .= sprintf("%02X", ord(substr($hexstring, $i, 1)));
    }
    return $str;
}
if($_POST['call'])
{
 $all=$_POST['phone_call'];
}
if($_POST['stop'])
{
 $all=$_POST['tel_uncall'];
}
if($_POST['send'])
{
$num=$_POST['meg_num'];
$msg=$_POST['msg'];
$msg=hex2str(utf82unicode($msg));
$all=$num."+".$msg;
}
$length=100;
$server_ip="192.168.1.50";
$port = 3333;
$sockfd=socket_create(AF_INET,SOCK_STREAM,SOL_TCP)or die("创建失败");
    socket_connect($sockfd,$server_ip,$port)or die("连接失败");
socket_write($sockfd,$all,$length)or die("传送失败");
socket_close($socket);
echo ("<script>alert('提交成功!');window.history.back();</script>");
exit();
?>

<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(997) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
posted @ 2016-03-30 10:38  张同光  阅读(296)  评论(0编辑  收藏  举报