php脚本查询港澳通行证办理进度

<?php

/*
Version:1.0;

Author:kerwin;

Date:2014-05-01;

//调用phpmailler类做邮件处理
*/

require(‘/home/kerwin/php/PHPMailer_v5.1/class.phpmailer.php’);  //请先下载phpmailler的类

echo “==========================================n”;

echo “||   欢迎使用港澳通行证办理进度查询系统          ||n”;

echo “==========================================n”;

echo “n”;

echo “请输入你的姓名 :n”;
//while(1){

$stdin = fopen(‘php://stdin’,’r’);

$some = trim(fgets($stdin ,100));

fclose($stdin);
$name = $some;

//echo “你的名字是: ” .$some.”n”;

echo “n”;

echo “n”;

echo “现在请继续输入你的身份证号码 :n “;
while(1){

$stdin = fopen(‘php://stdin’,’r’);

$num = trim(fgets($stdin,100));
fclose($stdin);

$id = $num;

if (!is_numeric($num))
{
echo “你输入的非数字,请重输: n” ;

continue;
}
elseif (strlen($num) < 18)
{
echo “你输入的号码位数不够,请重输:n” ;

continue;
}
else
{
echo “n”;
echo “n”;
echo “你输入的信息是 姓名: $name 身份证号码:$num n”;
}

break;

}

echo “n”;

echo “n”;

echo “系统正在查询你的港澳通行证办理进度,请稍后…………………….n”;

echo “n”;

echo “n”;

$url = “http://www.gdcrj.com/wsyw/tcustomer/tcustomer.do?&method=find&applyid=”;

$handle = fopen($url.$id,”r”);

$contents = stream_get_contents($handle);

fclose($handle);

preg_match(‘(<td class=”news_font”>([^<td]+)</td>)’,$contents,$result);

echo “亲爱的”.$name.” :”;

print_r(trim($result[1]));

echo “n”;

echo “n”;

echo “假如想将办证的进度信息发送至你邮箱,请输入你的邮箱账户n”;

while(1){

$stdin = fopen(‘php://stdin’,’r’);

$email = trim(fgets($stdin ,100));

fclose($stdin);

if (!ereg(“/^[a-zA-Z0-9][a-zA-Z0-9._-]*@[a-zA-Z0-9]+.[a-zA-Z0-9.]+$/A”,$email))

{

echo “邮箱不合法,请重输入: n”;

continue;
}

else
// echo “已记录你的邮箱,正在尝试发送……n”;

break;

}
$mail = new PHPMailer();

$mail->IsSMTP(); // set mailer to use SMTP

$mail->Host = “smtp.126.com”; // specify main and backup server,这里指的是用126的服务器做转发

$mail->SMTPAuth = true; // turn on SMTP authentication

$mail->Username = “email-user”; // SMTP username  邮箱用户名

$mail->Password = “email-passwd”; // SMTP password   邮箱密码

$mail->From = “email”;

$mail->FromName = “kerwin”;

$mail->AddAddress(“$email”);

$mail->Subject = “请查收”.$name.”通行证办理进度”;

$mail->Body = “$result[1]“;

if(!$mail->Send())
{
echo “发送邮件失败。”;
echo “失败原因: ” . $mail->ErrorInfo;
exit;
}

echo “通行证办理进度信息邮件成功发送!n”;

?>

执行结果如下: 会报出php warning的警告项,那是我时区未设置的原因,这个可以忽略。

phpmail

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>