/*
options
*/
//the list url
$expUrl='http://hbcms/user/list_resource.php';
//the user info to be registered
$regUser='jiong';
$regPass='jiong';
$regMail='jiong@jiong.com';
$regUrl=str_replace('list_resource.php','register.php',$expUrl);
// options for image upload
$fileDir='@D:imgb.jpg';
$fileTitle='aaaaaaaaaaaaa';
$fileDesc='aaaaaaaaaaaaadesc';
$uploadImgUrl=str_replace('list_resource.php','add_resource.php',$expUrl);
/*
register function
*/
function reg($regurl,$u,$p,$m)
{
$ch = curl_init();
$options=array(
CURLOPT_URL=>$regurl,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_POST=>true,
CURLOPT_POSTFIELDS=>'mod=register_now&next_url=index.php&addon_app=&referrer_id=&login_name='.$u.'&login_pass='.$p.'&confirm_login_pass='.$p.'&login_email='.$m.'&nickname=&gender=0&qq=&mobile=&telephone=&true_name=&website_name=&website_url=&my_question=&my_answer=',
CURLOPT_COOKIESESSION=>true,
CURLOPT_HEADER=>true,
CURLOPT_COOKIEJAR=>'c:cookie.txt'
);
curl_setopt_array($ch,$options);
$data = curl_exec($ch);
if(strpos($data,'成功')){
printf("register ok :)n");
curl_close($ch);
return true;
}else{
printf("register failed:(n");
curl_close($ch);
return false;
}
}
/*
image uploading function
*/
function uploadImg($uploadimgurl,$filedir,$filetitle,$filedesc)
{
$ch = curl_init();
$options=array(
CURLOPT_COOKIEFILE=>'c:cookie.txt',
CURLOPT_URL=>$uploadimgurl,
CURLOPT_RETURNTRANSFER=>1,
CURLOPT_POST=>1,
CURLOPT_POSTFIELDS=>http_build_query(array(
'MAX_FILE_SIZE'=>'33554432',
'preview_area_id'=>'upload_file',
'editor_area_id'=>'body',
'js_function'=>'',
'resource_id'=>'',
'show_top_part'=>'no',
'file_1'=>$filedir,
'file_title_1'=>$filetitle,
'file_desc_1'=>$filedesc
))
);
curl_setopt_array($ch,$options);
$data = curl_exec($ch);
if(strpos($data,'注意')){
printf("upload ok :)n");
}else{
printf("upload failed :(n");
}
curl_close($ch);
}
if(reg($regUrl,$regUser,$regPass,$regMail) != false)
{
uploadImg($uploadImgUrl,$fileDir,$fileTitle,$fileDesc);
}