智能自动表单提交

<?php

class SiteController extends Controller
{

public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$this->render('index');
}
//添加网站
public function actionAdd()
{
$reg_info=array(
'email'=>'test@test.com',
'pass'=>'123456',
'user'=>'test1234567'
);
$tt=array(
'form'=>array(
'method'=>'post',
'action'=>'http://www.dzhai.com/User/UserRegOk.asp',
'name'=>'regsiter',
),
'data'=>array(
'UserMail'=>array(
'text'=>"用户名(邮箱)",
'type'=>'text',
'value'=>'{$email}',
'validate'=>'email',
),
'CheckMail'=>array(
'text'=>'',
'type'=>'hidden',
'value'=>'CheckMail',
'validate'=>'',
),
'UserPassword'=>array(
'text'=>'密码',
'type'=>'text',
'value'=>'{$pass}',
'validate'=>'',
),
'UserpasswordRe'=>array(
'text'=>'确认密码',
'type'=>'text',
'value'=>'{$pass}',
'validate'=>'',
),
'UserName'=>array(
'text'=>'用户名',
'type'=>'text',
'value'=>'{$user}',
'validate'=>'',
),
'UserSite'=>array(
'text'=>'网站地址',
'type'=>'text',
'value'=>'',
'validate'=>'',
),
'UserQQ'=>array(
'text'=>'QQ',
'type'=>'text',
'value'=>'',
'validate'=>'',
),
'UserSex'=>array(
'text'=>'性别',
'type'=>'text',
'value'=>'2',
'validate'=>'',
),
'VerifyCode'=>array(
'text'=>'验证码',
'type'=>'text',
'value'=>'{$yzm}',
'validate'=>'yzm',
'src'=>'http://www.dzhai.com/Config/CLS_GetCode.asp?0.47499612625688314'
),
'UserReg'=>array(
'text'=>'',
'type'=>'submit',
'value'=>'免费注册',
'validate'=>'',
)
)
);
if(Yii::app()->request->isPostRequest)
{
$reg_info['yzm']=$_POST['VerifyCode'];
Yii::import('application.vendors.*');
require_once("Snoopy.class.php");
$snoopy=new Snoopy();
$snoopy->rawheaders["Accept-Charset"] = "ISO-8859-1,utf-8,gb2312"; 
$snoopy->rawheaders["Accept-Language"] = "zh-cn,en"; 
$snoopy->rawheaders["UA-CPU"] = "x86"; 
$snoopy->rawheaders["Pragma"] = "no-cache"; //cache 的http头信息   
$snoopy->rawheaders["Cache-Control"] = "private"; //cache 的http头信息  
$snoopy->host='www.dzhai.com';
$snoopy->referer = 'http://www.dzhai.com/User/UserReg.asp'; //伪装来源页地址 http_referer
$snoopy->agent = "Baiduspider+(+http://www.baidu.com/search/spider.htm)"; 
$snoopy->cookies["DIRCMSCookieSetting"] = 'ViewType=Hide';
$snoopy->cookies["DIRCMS"] = 'MemHashKey=&MemName=&MemMail=';
$snoopy->cookies["ASPSESSIONIDQQAQQDCC"] = 'IIPFAAADLDNKLBEMEJJCOAEI';
$snoopy->rawheaders['X_FORWARDED_FOR']='184.105.131.17';
$data=array();
foreach ($tt['data'] as $k1=>$v1)
{
preg_match('/{\$(.*?)}/', $v1['value'],$tmp_info);
if(isset($tmp_info[1]))
{
$data[$k1]=$reg_info[$tmp_info[1]];
}
else 
{
$data[$k1]=$v1['value'];
}
}
// echo file_get_contents('');exit;

$snoopy->fetch('http://www.adminso.com');
print_r($snoopy->results);exit;
}
$this->render('add',array('tt'=>$tt));
}
public function act()
{
array(
'form'=>array(
'method'=>'post',
'action'=>'www.dzhai.com/User/UserRegOk.asp',
'name'=>'regsiter',
),
'data'=>array(
'UserMail'=>array(
'text'=>'用户名(邮箱)',
'type'=>'text',
'value'=>'{$email}',
'validate'=>'email',
),
'CheckMail'=>array(
'text'=>'',
'type'=>'hidden',
'value'=>'CheckMail',
'validate'=>'',
),
'UserPassword'=>array(
'text'=>'密码',
'type'=>'password',
'value'=>'{$pass}',
'validate'=>'',
),
'UserpasswordRe'=>array(
'text'=>'确认密码',
'type'=>'password',
'value'=>'{$pass}',
'validate'=>'',
),
'UserName'=>array(
'text'=>'用户名',
'type'=>'text',
'value'=>'{$user}',
'validate'=>'',
),
'UserSite'=>array(
'text'=>'网站',
'type'=>'text',
'value'=>'',
'validate'=>'',
),
'UserQQ'=>array(
'text'=>'QQ',
'type'=>'text',
'value'=>'',
'validate'=>'',
),
'UserSex'=>array(
'text'=>'性别',
'type'=>'text',
'value'=>'2',
'validate'=>'',
),
'VerifyCode'=>array(
'text'=>'验证码',
'type'=>'text',
'value'=>'{$yzm}',
'validate'=>'yzm',
'src'=>'http://www.dzhai.com/Config/CLS_GetCode.asp?0.47499612625688314'
)
)
);
}
}

转载于:https://my.oschina.net/qeecoo/blog/57976

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值