[php]代码库
function curl_request($url, $sim = true, $method = "get", $postfields = NULL) {
$sim or $url .= "&sim_request=1";
$ci = curl_init ();
curl_setopt ( $ci, CURLOPT_URL, $url );
curl_setopt ( $ci, CURLOPT_HEADER, FALSE );
curl_setopt ( $ci, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt ( $ci, CURLOPT_USERAGENT, $_SERVER ['HTTP_USER_AGENT'] );
curl_setopt ( $ci, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt ( $ci, CURLOPT_SSL_VERIFYHOST, 0 );
if ('post' == strtolower ( $method )) {
curl_setopt ( $ci, CURLOPT_POST, TRUE );
if (is_array ( $postfields )) {
$field_str = "";
foreach ( $postfields as $k => $v ) {
$field_str .= "&$k=" . urlencode ( $v );
}
curl_setopt ( $ci, CURLOPT_POSTFIELDS, $field_str );
}
}
$response = curl_exec ( $ci );
if (curl_errno ( $ci )) {
throw new Exception ( curl_error ( $ci ), 0 );
} else {
$httpStatusCode = curl_getinfo ( $ci, CURLINFO_HTTP_CODE );
if (200 !== $httpStatusCode) {
throw new Exception ( $response, $httpStatusCode );
}
}
curl_close ( $ci );
return $response;
}
$param=array();
$param['username'] = rtrim($users[$i],"\r");
$param['action']='deleteuser';
$url = $aduseropt_url."/ldapInterface.php";
$res = curl_request($url,true,'post',$param);