⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libcurlexternal.inc.php

📁 软件的主要特点: 1.专门针对有"验证码"要求的论坛. 2.可以完成如下功能: 自动发布新帖,自动回复指定帖,自动注册论坛帐号 (所有操作不能同时针对一个网站,因为有"验证码"要求的网站是每次打开一个
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		case CURLOPT_PUT:			$settings["upload-file"]["enabled"] = $value>0;			break;		case CURLOPT_INFILE:			if ($value==="") $value = false;						if (is_resource($value)) {								// Ugh, this is a terrible hack.  The CURL extension accepts a file handle, but				// the CURL binary obviously wants a filename.  Since you can't derive a filename				// from a file handle, we have to make a copy of the file from the file handle,				// then pass the temporary filename to the CURL binary.								$tmpfilename = tempnam("/tmp","cif");				$fp = @fopen($tmpfilename,"w");				if (!$fp) {					trigger_error("CURL emulation library could not create a temporary file for CURLOPT_INFILE; upload aborted",E_USER_WARNING);				} else {					while (!feof($value)) {						$contents = fread($value,8192);						fwrite($fp,$contents);					}					fclose($fp);					// if a temporary file was previously created, unlink it					if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"])) unlink($settings["upload-file"]["value"]);										// set the new upload-file filename					$settings["upload-file"]["value"] = $tmpfilename;				}			} else {				trigger_error("CURLOPT_INFILE must specify a valid file resource",E_USER_WARNING);			}						break;		case CURLOPT_MUTE:			// we're already mute, no?			break;		case CURLOPT_LOW_SPEED_LIMIT:			$settings["speed-limit"] = (int) $value;			break;		case CURLOPT_LOW_SPEED_TIME:			$settings["speed-time"] = (int) $value;			break;		case CURLOPT_RESUME_FROM:			$settings["continue-at"] = (int) $value;			break;		case CURLOPT_CAINFO:			if ($value==="") $value = false;			$settings["cacert"] = $value;			break;		case CURLOPT_SSLVERSION:			$value = (int) $value;			switch($value) {				case 2:				case 3:					unset($settings["sslv2"]);					unset($settings["sslv3"]);					$settings["sslv".$value] = true;					break;			}			break;		case CURLOPT_TIMECONDITION:			// untested - I'm lazy :)			if (!isset($settings["time-cond"]["enabled"])) $settings["time-cond"]["enabled"] = false;			if (!$settings["time-cond"]["value"]) $settings["time-cond"]["value"] = 1;			$settings["time-cond"]["value"] = abs($settings["time-cond"]["value"]);			if ($value==TIMECOND_ISUNMODSINCE) {				$settings["time-cond"]["value"] *= -1;			}									break;		case CURLOPT_TIMEVALUE:			// untested - I'm lazy :)			if ($settings["time-cond"]["value"]) {				$sign = $settings["time-cond"]["value"] / abs($settings["time-cond"]["value"]);			} else {				$sign = 1;			}			$settings["time-cond"]["value"] = (int) $value * $sign;			break;		case CURLOPT_FILE:			if (is_resource($value)) {				$opt["output_handle"] = $value;			} else {				trigger_error("CURLOPT_FILE must specify a valid file resource",E_USER_WARNING);			}			break;		case CURLOPT_WRITEHEADER:			if (is_resource($value)) {				$opt["header_handle"] = $value;			} else {				trigger_error("CURLOPT_WRITEHEADER must specify a valid file resource",E_USER_WARNING);			}			break;		case CURLOPT_STDERR:			// not implemented for now - not really relevant			break;		// FTP stuff not implemented		case CURLOPT_QUOTE:		case CURLOPT_POSTQUOTE:		case CURLOPT_UPLOAD:		case CURLOPT_FTPLISTONLY:		case CURLOPT_FTPAPPEND:		case CURLOPT_FTPPORT:		// Other stuff not implemented		case CURLOPT_NETRC:		default:			trigger_error("CURL emulation does not implement CURL option "._curlopt_name($option),E_USER_WARNING);			break;	}}// Perform a CURL emulation sessionfunction curl_exec($ch) {	$opt = &$GLOBALS["_CURLEXT_OPT"][$ch];	$url = $opt["url"];	$verbose = $opt["verbose"];		// ask commandline CURL to return its statistics at the end of its output	$opt["settings"]["write-out"] = "%{http_code}|%{time_total}|%{time_namelookup}|%{time_connect}|%{time_pretransfer}|%{time_starttransfer}|%{size_download}|%{size_upload}|%{size_header}|%{size_request}|%{speed_download}|%{speed_upload}|||||||%{content_type}|%{url_effective}";	$writeout_order = array(		CURLINFO_HTTP_CODE,		CURLINFO_TOTAL_TIME,		CURLINFO_NAMELOOKUP_TIME,		CURLINFO_CONNECT_TIME,		CURLINFO_PRETRANSFER_TIME,		CURLINFO_STARTTRANSFER_TIME,		CURLINFO_SIZE_DOWNLOAD,		CURLINFO_SIZE_UPLOAD,		CURLINFO_HEADER_SIZE,		CURLINFO_REQUEST_SIZE,		CURLINFO_SPEED_DOWNLOAD,		CURLINFO_SPEED_UPLOAD,		// the following 5 items are not provided by commandline CURL, and thus are left empty		CURLINFO_FILETIME,		CURLINFO_REDIRECT_TIME,		CURLINFO_SSL_VERIFYRESULT,		CURLINFO_CONTENT_LENGTH_DOWNLOAD,		CURLINFO_CONTENT_LENGTH_UPLOAD,		CURLINFO_REDIRECT_COUNT,		CURLINFO_CONTENT_TYPE,		CURLINFO_EFFECTIVE_URL,	);	// if the CURLOPT_NOBODY option was specified (to remove the body from the output),	// but an output file handle was set, we need to tell CURL to return the body so	// that we can write it to the output handle and strip it from the output	if ($opt["settings"]["head"] && $opt["output_handle"]) {		unset($opt["settings"]["head"]);		$strip_body = true;	}	// if the CURLOPT_HEADER option was NOT specified, but a header file handle was	// specified, we again need to tell CURL to return the headers so we can write	// them, then strip them from the output	if (!isset($opt["settings"]["include"]) && isset($opt["header_handle"])) {		$opt["settings"]["include"] = true;		$strip_headers = true;	}	// build the CURL argument list	$arguments = "";	foreach ($opt["args"] as $k=>$arg) {		list($argname,$argval) = explode('=',$arg,2);		$arguments .= "--$argname ".escapeshellarg($argval)." ";	}		foreach ($opt["settings"] as $argname=>$argval) {		if (is_array($argval)) {			if (isset($argval["enabled"]) && !$argval["enabled"]) continue;			$argval = $argval["value"];		}		if ($argval===false) continue;		if (is_bool($argval)) $argval = "";		$arguments .= "--$argname ".escapeshellarg($argval)." ";	}	// build the CURL commandline and execute it	$cmd = CURL_PATH." ".$arguments." ".escapeshellarg($url);		if ($verbose) echo "libcurlemu: Executing: $cmd\n";	exec($cmd,$output,$ret);		if ($verbose) {		echo "libcurlemu: Result: ";		var_dump($output);		echo "libcurlemu: Exit code: $ret\n";	}		// check for errors	$opt["errno"] = $ret;	if ($ret) $opt["error"] = "CURL error #$ret";		// die if CURLOPT_FAILONERROR is set and the HTTP result code is greater than 300	if ($opt["fail_on_error"]) {		if (preg_match("/^HTTP\/1.[0-9]+ ([0-9]{3}) /",$output[0],$matches)) {			$resultcode = (int) $matches[1];			if ($resultcode>300) die;		} else {			die; // couldn't get result code!		}	}		// pull the statistics out from the output	$stats = explode('|',array_pop($output));	foreach ($writeout_order as $k=>$item) {		$opt["stats"][$item] = $stats[$k];	}	// build the response string	$output = implode("\r\n",$output);		// find the header end position if needed	if ($strip_headers || $strip_body || isset($opt["header_handle"])) {		$headerpos = strpos($output,"\r\n\r\n");	}	// if a file handle was provided for header output, extract the headers	// and write them to the handle	if (isset($opt["header_handle"])) {		$headers = substr($output,0,$headerpos);		fwrite($opt["header_handle"],$headers);	}		// if the caller did not request headers in the output, strip them	if ($strip_headers) {		$output = substr($output,$headerpos+4);	}		// if the caller did not request the response body in the output, strip it	if ($strip_body) {		if ($strip_headers) {			$body = $output;			$output = "";		} else {			$body = substr($output,$headerpos+4);			$output = substr($output,0,$headerpos);		}	}		// if a file handle was provided for output, write the output to it	if (isset($opt["output_handle"])) {		fwrite($opt["output_handle"],$output);			// if the caller requested that the response be returned, return it	} elseif ($opt["return_transfer"]) {		return $output;			// otherwise, just echo the output to stdout	} else {		echo $output;	}	return true;}function curl_close($ch) {	$opt = &$GLOBALS["_CURLEXT_OPT"][$ch];		if ($opt["settings"]) {		$settings = &$opt["settings"];		// if the user used CURLOPT_INFILE to specify a file to upload, remove the		// temporary file created for the CURL binary		if ($settings["upload-file"]["value"] && file_exists($settings["upload-file"]["value"])) unlink($settings["upload-file"]["value"]);	}	unset($GLOBALS["_CURLEXT_OPT"][$ch]);}function curl_errno($ch) {	return (int) $GLOBALS["_CURLEXT_OPT"][$ch]["errno"];}function curl_error($ch) {	return $GLOBALS["_CURLEXT_OPT"][$ch]["error"];}function curl_getinfo($ch,$opt=NULL) {	if ($opt) {		return $GLOBALS["_CURLEXT_OPT"][$ch]["stats"][$opt];	} else {		$curlinfo_tags = array(			"url"=>CURLINFO_EFFECTIVE_URL,			"content_type"=>CURLINFO_CONTENT_TYPE,			"http_code"=>CURLINFO_HTTP_CODE,			"header_size"=>CURLINFO_HEADER_SIZE,			"request_size"=>CURLINFO_REQUEST_SIZE,			"filetime"=>CURLINFO_FILETIME,			"ssl_verify_result"=>CURLINFO_SSL_VERIFYRESULT,			"redirect_count"=>CURLINFO_REDIRECT_COUNT,			"total_time"=>CURLINFO_TOTAL_TIME,			"namelookup_time"=>CURLINFO_NAMELOOKUP_TIME,			"connect_time"=>CURLINFO_CONNECT_TIME,			"pretransfer_time"=>CURLINFO_PRETRANSFER_TIME,			"size_upload"=>CURLINFO_SIZE_UPLOAD,			"size_download"=>CURLINFO_SIZE_DOWNLOAD,			"speed_download"=>CURLINFO_SPEED_DOWNLOAD,			"speed_upload"=>CURLINFO_SPEED_UPLOAD,			"download_content_length"=>CURLINFO_CONTENT_LENGTH_DOWNLOAD,			"upload_content_length"=>CURLINFO_CONTENT_LENGTH_UPLOAD,			"starttransfer_time"=>CURLINFO_STARTTRANSFER_TIME,			"redirect_time"=>CURLINFO_REDIRECT_TIME		);		$res = array();		foreach ($curlinfo_tags as $tag=>$opt) {			$res[$tag] = $GLOBALS["_CURLEXT_OPT"][$ch]["stats"][$opt];		}		return $res;	}}function curl_version() {	return "libcurlemu/".CURLEXT_VERSION."-ext";}}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -