本文整理汇总了PHP中http_class::ReadReplyBody方法的典型用法代码示例。如果您正苦于以下问题:PHP http_class::ReadReplyBody方法的具体用法?PHP http_class::ReadReplyBody怎么用?PHP http_class::ReadReplyBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http_class
的用法示例。
在下文中一共展示了http_class::ReadReplyBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_request
public function send_request($request)
{
$response_code = '0';
$response_info = array();
$response_headers = array();
$error = '';
$http = new http_class();
$http->follow_redirect = 1;
$http->redirection_limit = 5;
$http->prefer_curl = 0;
$error = $http->GetRequestArguments($request->uri, $arguments);
if ($request->credentials != null) {
$http->authentication_mechanism = "Digest";
$arguments['AuthUser'] = $request->credentials->get_username();
$arguments['AuthPassword'] = $request->credentials->get_password();
}
$arguments["RequestMethod"] = $request->method;
foreach ($request->headers as $k => $v) {
$arguments["Headers"][$k] = $v;
}
if ($request->body != null) {
$arguments["Body"] = $request->body;
}
$error = $http->Open($arguments);
if (!$error) {
$error = $http->SendRequest($arguments);
}
if (!$error) {
$error = $http->ReadReplyHeaders($response_headers);
$response_code = $http->response_status;
$response_body = '';
for (;;) {
$error = $http->ReadReplyBody($body, 1000);
if ($error != "" || strlen($body) == 0) {
break;
}
$response_body .= $body;
}
} else {
if ($request->_cache && $cached_response) {
return $cached_response;
}
$response_body = "Request failed: " . $error;
}
$http->Close();
$response = new HttpResponse();
$response->status_code = $response_code;
$response->headers = $response_headers;
$response->body = $response_body;
$response->info = $response_info;
//ID20100317 $response->request = $request;
$response->request_method = $request->method;
$response->request_uri = $request->uri;
$response->request_headers = $request->headers;
$response->request_body = $request->body;
$key = spl_object_hash($request);
$this->responses[$key] = $response;
return $key;
}
示例2: _checkSFS
function _checkSFS($username, $email, $ip = '')
{
global $_TABLES, $_SPX_CONF, $LANG_SX00;
$rc = 0;
$arguments = array();
$response = '';
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->debug = 0;
$http->html_debug = 0;
$http->user_agent = 'glFusion/' . GVERSION;
$url = "http://www.stopforumspam.com/api";
$requestArgs = '?f=serial&';
if ($ip != '') {
$requestArgs .= 'ip=' . $ip . '&';
}
if ($email != '') {
$requestArgs .= 'email=' . urlencode($email) . '&';
}
if ($username != '') {
$requestArgs .= 'username=' . urlencode($username) . '&';
}
$requestArgs .= 'cmd=display';
$url = $url . $requestArgs;
$error = $http->GetRequestArguments($url, $arguments);
$error = $http->Open($arguments);
$error = $http->SendRequest($arguments);
if ($error == "") {
$error = $http->ReadReplyBody($body, 1024);
if ($error != "" || strlen($body) == 0) {
break;
}
$response = $response . $body;
$result = @unserialize($response);
if (!$result) {
return 0;
}
// invalid data, assume ok
if (isset($result['email']) && $result['email']['appears'] == 1) {
$rc = $rc + 1;
}
if (isset($result['ip']) && $result['ip']['appears'] == 1) {
$rc = $rc + 2;
}
if (isset($result['username']) && $result['username']['appears'] == 1) {
$rc = $rc + 4;
}
}
return $rc;
}
示例3: CheckForSpam
/**
* Check for spam links
*
* @param string $post post to check for spam
* @return boolean true = spam found, false = no spam
*
* Note: Also returns 'false' in case of problems communicating with SFS.
* Error messages are logged in glFusion's error.log
*
*/
function CheckForSpam($post)
{
global $_SPX_CONF, $REMOTE_ADDR;
$retval = false;
$ip = $REMOTE_ADDR;
if (empty($post) || $ip == '') {
return $retval;
}
$arguments = array();
$response = '';
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->debug = 0;
$http->html_debug = 0;
$http->user_agent = 'glFusion/' . GVERSION;
$url = "http://www.stopforumspam.com/api";
$requestArgs = '?f=serial&';
if ($ip != '') {
$requestArgs .= 'ip=' . $ip . '&';
}
$requestArgs .= 'cmd=display';
$url = $url . $requestArgs;
$error = $http->GetRequestArguments($url, $arguments);
$error = $http->Open($arguments);
$error = $http->SendRequest($arguments);
if ($error == "") {
$error = $http->ReadReplyBody($body, 1024);
if ($error == "" || strlen($body) > 0) {
$response = $response . $body;
$result = @unserialize($response);
if (!$result) {
return 0;
}
// invalid data, assume ok
if (isset($result['ip']) && $result['ip']['appears'] == 1 && $result['ip']['confidence'] > (double) 25) {
$retval = true;
SPAMX_log("SFS: spam detected");
}
}
}
return $retval;
}
示例4: array
function open_url($type, $params = array())
{
$http = new http_class();
$http->request_method = 'POST';
$http->user_agent = "cesar-rodas/1.0 | Akismet-Class/" . CLASS_VERSION;
$http->follow_redirect = 1;
$http->redirection_limit = 5;
$http->exclude_address = "";
$http->protocol_version = "1.1";
$http->GetRequestArguments($this->get_url($type), $arguments);
$arguments['PostValues'] = $params;
$this->err = $http->Open($arguments);
if ($this->err != "") {
return false;
}
$this->err = $http->SendRequest($arguments);
if ($this->err != "") {
return false;
}
$this->err = $http->ReadReplyHeaders($gHeaders);
if ($this->err != "") {
return false;
}
if ($http->response_status != 200) {
$this->err = "Pages status: " . $http->response_status;
$http->Close();
return false;
}
$response = '';
for (;;) {
$this->error = $http->ReadReplyBody($body, 1000);
if ($this->error != "" || strlen($body) == 0) {
break;
}
$response .= $body;
}
$http->close();
return $response;
}
示例5: UpdateStep4
function UpdateStep4()
{
global $clang, $scriptname, $homedir, $buildnumber, $updatebuild, $debug, $rootdir, $publicdir, $tempdir, $database_exists, $databasetype, $action, $demoModeOnly;
echo '<div class="header ui-widget-header">'.sprintf($clang->gT('ComfortUpdate step %s'),'4').'</div><div class="updater-background"><br />';
if (!isset( $_SESSION['updateinfo']))
{
echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').'<br />';
if ($updateinfo['error']==1)
{
setGlobalSetting('updatekey','');
echo $clang->gT('Your update key is invalid and was removed. ').'<br />';
}
else
echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').'<br />';
}
else
{
$updateinfo=$_SESSION['updateinfo'];
}
// this is the last step - Download the zip file, unpack it and replace files accordingly
// Create DB and file backups now
require_once("classes/pclzip/pclzip.lib.php");
// require_once('classes/pclzip/pcltrace.lib.php');
// require_once('classes/pclzip/pclzip-trace.lib.php');
// PclTraceOn(2);
require_once($homedir."/classes/http/http.php");
$downloaderror=false;
$http=new http_class;
// Allow redirects
$http->follow_redirect=1;
/* Connection timeout */
$http->timeout=0;
/* Data transfer timeout */
$http->data_timeout=0;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$http->GetRequestArguments("http://update.limesurvey.org/updates/download/{$updateinfo['downloadid']}",$arguments);
$http->RestoreCookies($_SESSION['updatesession']);
$error=$http->Open($arguments);
$error=$http->SendRequest($arguments);
$http->ReadReplyHeaders($headers);
if ($headers['content-type']=='text/html')
{
@unlink($tempdir.'/update.zip');
}
elseif($error=='') {
$body='';
$pFile = fopen($tempdir.'/update.zip', 'w');
for(;;){
$error = $http->ReadReplyBody($body,100000);
if($error != "" || strlen($body)==0) break;
fwrite($pFile, $body);
}
fclose($pFile);
}
else
{
print( $error );
}
// Now remove all files that are to be deleted according to update process
foreach ($updateinfo['files'] as $afile)
{
if ($afile['type']=='D' && file_exists($rootdir.$afile['file']))
{
if (is_file($rootdir.$afile['file']))
{
unlink($rootdir.$afile['file']);
}
else{
rmdirr($rootdir.$afile['file']);
}
echo sprintf($clang->gT('File deleted: %s'),$afile['file']).'<br />';
}
}
//Now unzip the new files over the existing ones.
if (file_exists($tempdir.'/update.zip')){
$archive = new PclZip($tempdir.'/update.zip');
if ($archive->extract(PCLZIP_OPT_PATH, $rootdir.'/', PCLZIP_OPT_REPLACE_NEWER)== 0) {
die("Error : ".$archive->errorInfo(true));
}
else
{
echo $clang->gT('New files were successfully installed.').'<br />';
unlink($tempdir.'/update.zip');
}
}
else
{
echo $clang->gT('There was a problem downloading the update file. Please try to restart the update process.').'<br />';
$downloaderror=true;
}
// PclTraceDisplay();
//.........这里部分代码省略.........
示例6: _checkVersion
function _checkVersion()
{
global $_CONF, $_USER, $_PLUGIN_INFO;
// build XML request
require_once $_CONF['path'] . 'lib/http/http.php';
$result = '';
$http = new http_class();
$http->timeout = 5;
$http->data_timeout = 5;
$http->debug = 0;
$http->html_debug = 0;
$http->user_agent = 'glFusion/' . GVERSION;
$url = "http://www.glfusion.org/versions/index.php";
$error = $http->GetRequestArguments($url, $arguments);
$arguments["RequestMethod"] = "POST";
$arguments["PostValues"] = array("v" => "v" . GVERSION . PATCHLEVEL);
if ($_CONF['send_site_data']) {
$arguments["PostValues"]['s'] = $_CONF['site_url'];
}
$error = $http->Open($arguments);
if ($error == "") {
$error = $http->SendRequest($arguments);
if ($error == "") {
for (;;) {
$error = $http->ReadReplyBody($body, 1000);
if ($error != "" || strlen($body) == 0) {
break;
}
$result = $result . $body;
}
}
}
if (!$result) {
return array(-1, -1, array());
}
// parse XML response
$response = xml2array($result);
if (isset($response['response'])) {
if (isset($response['response']['glfusion'])) {
$latest = $response['response']['glfusion']['version'];
} else {
$latest = 'unknown';
}
if (isset($response['response']['glfusion']['date'])) {
$releaseDate = $response['response']['glfusion']['date'];
} else {
$releaseDate = 'unknown';
}
}
// check glFusion CMS version
$current = GVERSION . PATCHLEVEL;
list($latestMajor, $latestMinor, $latestRev, $latestExtra) = explode('.', $latest . '....');
list($currentMajor, $currentMinor, $currentRev, $currentExtra) = explode('.', $current . '....');
$glFusionUpToDate = 0;
if ($currentMajor >= $latestMajor) {
if ($currentMajor > $latestMajor) {
$glFusionUpToDate = 2;
} else {
if ($currentMinor >= $latestMinor) {
if ($currentMinor > $latestMinor) {
$glFusionUpToDate = 2;
} else {
if ($currentRev >= $latestRev) {
if ($currentRev > $latestRev) {
$glFusionUpToDate = 2;
} else {
if ($currentExtra != '' || $latestExtra != '') {
if (strcmp($currentExtra, $latestExtra) == 0) {
$glFusionUpToDate = 1;
}
} else {
$glFusionUpToDate = 1;
}
}
}
}
}
}
}
// run through all our active plugins and see if any are out of date
$pluginsUpToDate = 1;
$done = 0;
if (is_array($response['response']['plugin'])) {
foreach ($_PLUGIN_INFO as $iPlugin => $iPluginVer) {
$upToDate = 0;
foreach ($response['response']['plugin'] as $plugin) {
if (strcmp($plugin['name'], $iPlugin) == 0) {
if (_upToDate($plugin['version'], $iPluginVer) == 0) {
$pluginsUpToDate = 0;
$done = 1;
break;
}
}
}
if ($done) {
break;
}
}
}
// build data if we need it...
//.........这里部分代码省略.........
示例7: acc_doPostRequest
function acc_doPostRequest($request, $params = false, $proxy = false, $auth = false)
{
require_once 'modules/Accounting/sasl/http.php';
$authentication = "";
$realm = "";
$workstation = "";
set_time_limit(120);
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->follow_redirect = 1;
$http->debug = 0;
$http->html_debug = 1;
if ($auth !== false || $proxy !== false) {
require_once "modules/Accounting/sasl/sasl.php";
}
// Basic Authentication
if ($auth !== false) {
$user = $auth["user"];
$password = $auth["password"];
$realm = $auth["realm"];
// Authentication realm or domain
$workstation = $auth["workstation"];
// Workstation for NTLM authentication
$authentication = strlen($user) ? UrlEncode($user) . ":" . UrlEncode($password) . "@" : "";
}
$url = $request['scheme'] . "://" . $authentication . $request['url'];
$url = trim($url, " ");
$error = $http->GetRequestArguments($url, $arguments);
if ($error != "") {
return false;
}
$arguments["RequestMethod"] = $request['method'];
if ($request['method'] == 'POST') {
$arguments["PostValues"] = $params;
} else {
$url .= "?";
foreach ($params as $param => $value) {
$url .= $param . "=" . $value . "&";
}
$url = rtrim($url, "&");
}
// Auth
if ($auth !== false) {
$arguments["AuthRealm"] = $realm;
}
if ($auth !== false) {
$arguments["AuthWorkstation"] = $workstation;
}
$arguments["Headers"]["Pragma"] = "nocache";
// Proxy
if ($proxy !== false) {
$arguments["ProxyHostName"] = isset($proxy["host"]) ? $proxy["host"] : "";
$arguments["ProxyHostPort"] = isset($proxy["port"]) ? $proxy["port"] : 0;
$arguments["ProxyUser"] = isset($proxy["user"]) ? $proxy["user"] : "";
$arguments["ProxyPassword"] = isset($proxy["password"]) ? $proxy["password"] : "";
$arguments["ProxyRealm"] = isset($proxy["realm"]) ? $proxy["realm"] : "";
// Proxy authentication realm or domain
$arguments["ProxyWorkstation"] = isset($proxy["workstation"]) ? $proxy["workstation"] : "";
// Workstation for NTLM proxy authentication
$http->proxy_authentication_mechanism = isset($proxy["mechanism"]) ? $proxy["mechanism"] : "";
// force a given proxy authentication mechanism;
}
$result = false;
$error = $http->Open($arguments);
if ($error == "") {
$error = $http->SendRequest($arguments);
if ($error == "") {
$headers = array();
$error = $http->ReadReplyHeaders($headers);
if ($error == "") {
for (;;) {
$error = $http->ReadReplyBody($body, 1000);
if ($error != "" || strlen($body) == 0) {
break;
}
$result .= $body;
}
}
}
$http->Close();
}
return $result;
}
示例8: http_adv_get
function http_adv_get($qtype, $url, $extra = array(), $headers = array())
{
$http = new http_class();
$http->debug = 0;
$http->html_debug = 0;
$http->request_method = $qtype;
$http->GetRequestArguments($url, $args);
$err = $http->Open($args);
foreach ($extra as $key => $value) {
$args[$key] = $value;
}
$body = "";
foreach ($headers as $key => $value) {
$args['Headers'][$key] = $value;
}
if ($err == "") {
$err = $http->Open($args);
$err = $http->SendRequest($args);
$http->ReadReplyHeaders($headers);
if ($err == "") {
if ($err == "") {
for (;;) {
$err = $http->ReadReplyBody($acc, 2000);
if ($err != "" || $acc == "") {
break;
}
$body .= $acc;
}
}
}
$http->close();
}
return array($headers, $body);
}
示例9: get
/**
* Fetch a remote URI then return results.
*
* If this method is triggered without the second parameter, <b>$target</b>, then
* result will be return in the following format:
*
* <pre>array(
* 'header' => array(
* 'header_1' => 'header_value_1',
* 'header_2' => 'header_value_2',
* etc...
* ),
* 'body' => 'fetched response body'
* )</pre>
*
* Otherwise, the fetched response body will be saved to the local file specified
* by the variable <b>$target</b>. The example below will download the remote image
* <b>http://placehold.it/300x200.gif</b> then save to the local file
* <b>/tmp/downloaded_image.gif</b>:
*
* <pre>JSNUtilsHttp::get(
* 'http://placehold.it/300x200.gif',
* '/tmp/downloaded_image.gif'
* );</pre>
*
* When the second parameter is set in method call, the method will always return
* the boolean value <b>true</b> if file is successfully saved or <b>false</b>
* if file is not saved.
*
* @param string $uri Remote URI for fetching content.
* @param string $target Set to a file path to save fetched content as local file.
* @param boolean $validateHeader Check for 200 OK header or not?
*
* @return array array('header' => 'Associative array of fetched header', 'body' => 'Fetched content')
*/
public static function get($uri, $target = '', $validateHeader = false)
{
// Preset return result
$result = array();
// Initialize HTTP client
$http = new http_class();
$http->follow_redirect = 1;
$http->redirection_limit = 5;
$http->GetRequestArguments($uri, $arguments);
// Open connection
if (($error = $http->Open($arguments)) == '') {
if (($error = $http->SendRequest($arguments)) == '') {
// Get response header
$header = array();
if (($error = $http->ReadReplyHeaders($header)) != '') {
throw new Exception(JText::sprintf('JSN_EXTFW_HTTP_CONNECTION_ERROR', $error));
}
$result['header'] = $header;
// Validate header
if ($validateHeader) {
foreach ($result['header'] as $header => $value) {
if (strtolower(substr($header, 0, 5)) == 'http/' and strpos($header, '200') === false) {
throw new Exception(JText::sprintf('JSN_EXTFW_HTTP_CONNECTION_ERROR', substr($header, strpos($header, ' '))));
}
}
}
// Get response body
$result['body'] = '';
while (true) {
if (($error = $http->ReadReplyBody($body, 1000)) != '' or strlen($body) == 0) {
break;
}
$result['body'] .= $body;
}
} else {
throw new Exception(JText::sprintf('JSN_EXTFW_HTTP_CONNECTION_ERROR', $error));
}
// Close connection
$http->Close();
} else {
throw new Exception(JText::sprintf('JSN_EXTFW_HTTP_CONNECTION_ERROR', $error));
}
return !empty($target) ? JFile::write($target, $result['body']) : $result;
}
示例10: testFetch
function testFetch($url)
{
$http = new http_class();
owa_coreAPI::debug('hello owa_http testfetch method');
/* Connection timeout */
$http->timeout = 0;
/* Data transfer timeout */
$http->data_timeout = 0;
/* Output debugging information about the progress of the connection */
$http->debug = 1;
$http->user_agent = owa_coreAPI::getSetting('base', 'owa_user_agent');
$http->follow_redirect = 1;
$http->redirection_limit = 5;
$http->exclude_address = "";
$http->prefer_curl = 0;
$arguments = array();
$error = $http->GetRequestArguments($url, $arguments);
$error = $http->Open($arguments);
//for(;;)
// {
$error = $http->ReadReplyBody($body, 50000);
if ($error != "" || strlen($body) == 0) {
owa_coreAPI::debug(HtmlSpecialChars($body));
}
// }
}
示例11: array
set_time_limit(0);
$http_connection = new http_class();
$error = $http_connection->Open(array("HostName" => $host_name));
if ($error == "") {
$error = $http_connection->SendRequest(array("RequestURI" => $uri, "RequestMethod" => "POST", "PostValues" => array("alias" => $user, "password" => $password, "Submit" => "Login", "dologin" => 1)));
if ($error == "") {
$error = $http_connection->ReadReplyHeaders(&$headers);
if ($error == "") {
for ($header = 0, Reset($headers); $header < count($headers); Next($headers), $header++) {
if (Key($headers) == "set-cookie") {
break;
}
}
if ($header < count($headers)) {
for (;;) {
$error = $http_connection->ReadReplyBody(&$body, 1000);
if ($error != "" || strlen($body) == 0) {
break;
}
}
} else {
$error = "This page did not set a cookie";
}
}
if ($error == "" && ($error = $http_connection->Close()) == "" && ($error = $http_connection->Open(array("HostName" => $host_name))) == "" && ($error = $http_connection->SendRequest(array("RequestURI" => $uri, "RequestMethod" => "GET"))) == "" && ($error = $http_connection->ReadReplyHeaders(&$headers)) == "") {
for (;;) {
$error = $http_connection->ReadReplyBody(&$body, 1000);
if ($error != "" || strlen($body) == 0) {
break;
}
echo $body;
示例12: get
/**
* Fetch a remote URI then return results.
*
* If this method is triggered without the second parameter, <b>$target</b>, then
* result will be return in the following format:
*
* <pre>array(
* 'header' => array(
* 'header_1' => 'header_value_1',
* 'header_2' => 'header_value_2',
* etc...
* ),
* 'body' => 'fetched response body'
* )</pre>
*
* Otherwise, the fetched response body will be saved to the local file specified
* by the variable <b>$target</b>. The example below will download the remote image
* <b>http://placehold.it/300x200.gif</b> then save to the local file
* <b>/tmp/downloaded_image.gif</b>:
*
* <pre>JSNUtilsHttp::get(
* 'http://placehold.it/300x200.gif',
* '/tmp/downloaded_image.gif'
* );</pre>
*
* When the second parameter is set in method call, the method will always return
* the boolean value <b>true</b> if file is successfully saved or <b>false</b>
* if file is not saved.
*
* @param string $uri Remote URI for fetching content.
* @param string $target Set to a file path to save fetched content as local file.
* @param boolean $validateHeader Check for 200 OK header or not?
* @param array $options Custom options to pass to http_class object.
*
* @return array array('header' => 'Associative array of fetched header', 'body' => 'Fetched content')
*/
public static function get($uri, $target = '', $validateHeader = true, $options = array())
{
// Preset return result
$result = array();
// Initialize HTTP client
$http = new http_class();
$http->follow_redirect = 1;
$http->redirection_limit = 5;
$http->GetRequestArguments($uri, $arguments);
// Set custom options
if (is_array($options) and count($options)) {
foreach ($options as $k => $v) {
$arguments[$k] = $v;
}
}
// Open connection
if (($error = $http->Open($arguments)) == '') {
if (($error = $http->SendRequest($arguments)) == '') {
// Get response header
$header = array();
if (($error = $http->ReadReplyHeaders($header)) != '') {
throw new Exception(JText::sprintf('JSN_TPLFW_HTTP_CONNECTION_ERROR', $error));
}
$result['header'] = $header;
// Validate header
if ($validateHeader) {
foreach ($result['header'] as $header => $value) {
if (strtolower(substr($header, 0, 5)) == 'http/' and strpos($header, '200') === false) {
throw new Exception(JText::sprintf('JSN_TPLFW_HTTP_CONNECTION_ERROR', substr($header, strpos($header, ' '))));
}
}
}
// Get response body
$result['body'] = '';
while (true) {
if (($error = $http->ReadReplyBody($body, 1000)) != '' or strlen($body) == 0) {
break;
}
$result['body'] .= $body;
}
// Validate header
if (is_array($validateHeader)) {
foreach ($validateHeader as $k => $v) {
foreach ($result['header'] as $header => $value) {
if (strcasecmp($header, $k) == 0) {
is_array($v) or $v = array($v);
if (!in_array($value, $v)) {
throw new Exception($result['body']);
}
}
}
}
}
} else {
throw new Exception(JText::sprintf('JSN_TPLFW_HTTP_CONNECTION_ERROR', $error));
}
// Close connection
$http->Close();
} else {
throw new Exception(JText::sprintf('JSN_TPLFW_HTTP_CONNECTION_ERROR', $error));
}
// Write to local file if target is given
empty($target) or JFile::write($target, $result['body']);
return $result;
//.........这里部分代码省略.........
示例13: _RunUpdaterUpdate
private function _RunUpdaterUpdate()
{
$versionnumber = Yii::app()->getConfig("versionnumber");
$buildnumber = Yii::app()->getConfig("buildnumber");
$tempdir = Yii::app()->getConfig("tempdir");
require_once APPPATH . '/third_party/http/http.php';
$oHTTPRequest = new http_class();
$oHTTPRequest->proxy_host_name = Yii::app()->getConfig("proxy_host_name", "");
$oHTTPRequest->proxy_host_port = Yii::app()->getConfig("proxy_host_port", 80);
/* Connection timeout */
$oHTTPRequest->timeout = 0;
/* Data transfer timeout */
$oHTTPRequest->data_timeout = 0;
$oHTTPRequest->user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$oHTTPRequest->GetRequestArguments($this->getProtocol() . "update.limesurvey.org?updaterbuild={$buildnumber}", $arguments);
$updateinfo = false;
$error = $oHTTPRequest->Open($arguments);
$error = $oHTTPRequest->SendRequest($arguments);
$oHTTPRequest->ReadReplyHeaders($headers);
if ($error == "") {
$body = '';
$full_body = '';
for (;;) {
$error = $oHTTPRequest->ReadReplyBody($body, 10000);
if ($error != "" || strlen($body) == 0) {
break;
}
$full_body .= $body;
}
$updateinfo = json_decode($full_body, true);
if ($oHTTPRequest->response_status != '200') {
$updateinfo['errorcode'] = $oHTTPRequest->response_status;
$updateinfo['errorhtml'] = $full_body;
}
} else {
$updateinfo['errorcode'] = $error;
$updateinfo['errorhtml'] = $error;
}
unset($oHTTPRequest);
if ((int) $updateinfo['UpdaterRevision'] <= $buildnumber) {
// There is no newer updater version on the server
return true;
}
if (!is_writable($tempdir) || !is_writable(APPPATH . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'update.php')) {
$error = true;
}
// Download the zip file, unpack it and replace the updater file accordingly
// Create DB and file backups now
$downloaderror = false;
require_once APPPATH . '/third_party/http/http.php';
$oHTTPRequest = new http_class();
$oHTTPRequest->proxy_host_name = Yii::app()->getConfig("proxy_host_name", "");
$oHTTPRequest->proxy_host_port = Yii::app()->getConfig("proxy_host_port", 80);
$oHTTPRequest->proxy_host_name = Yii::app()->getConfig("proxy_host_name", "");
$oHTTPRequest->proxy_host_port = Yii::app()->getConfig("proxy_host_port", 80);
// Allow redirects
$oHTTPRequest->follow_redirect = 1;
/* Connection timeout */
$oHTTPRequest->timeout = 0;
/* Data transfer timeout */
$oHTTPRequest->data_timeout = 0;
$oHTTPRequest->user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$oHTTPRequest->GetRequestArguments($this->getProtocol() . "update.limesurvey.org/updates/downloadupdater/{$updateinfo['UpdaterRevision']}", $arguments);
$oHTTPRequesterror = $oHTTPRequest->Open($arguments);
$oHTTPRequesterror = $oHTTPRequest->SendRequest($arguments);
$oHTTPRequest->ReadReplyHeaders($headers);
if ($headers['content-type'] == 'text/html') {
@unlink($tempdir . '/updater.zip');
} elseif ($oHTTPRequesterror == '') {
$body = '';
$full_body = '';
for (;;) {
$oHTTPRequesterror = $oHTTPRequest->ReadReplyBody($body, 100000);
if ($oHTTPRequesterror != "" || strlen($body) == 0) {
break;
}
$full_body .= $body;
}
file_put_contents($tempdir . '/updater.zip', $full_body);
}
$aData['httperror'] = $oHTTPRequesterror;
//Now unzip the new updater over the existing ones.
if (file_exists($tempdir . '/updater.zip')) {
Yii::app()->loadLibrary("admin/pclzip", array('p_zipname' => $tempdir . '/updater.zip'));
$archive = new PclZip(array('p_zipname' => $tempdir . '/updater.zip'));
if ($archive->extract(PCLZIP_OPT_PATH, APPPATH . '/controllers/admin/', PCLZIP_OPT_REPLACE_NEWER) == 0) {
die("Error : " . $archive->errorInfo(true));
} else {
unlink($tempdir . '/updater.zip');
}
$updater_exists = true;
} else {
$updater_exists = false;
$error = true;
}
$aData['updater_exists'] = $updater_exists;
}
示例14: ReadPage
function ReadPage()
{
$this->pagecontent = "";
set_time_limit(0);
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->debug = 0;
$http->html_debug = 1;
$url = $this->protocol . "://" . $this->host . "/";
$error = $http->GetRequestArguments($url, $arguments);
//$arguments["Headers"]["Pragma"]="nocache";
$arguments["RequestURI"] = $this->source;
//echo HtmlEntities($arguments["HostName"]);
flush();
$error = $http->Open($arguments);
if ($error == "") {
//echo "Sending request for page: ";
//echo HtmlEntities($arguments["RequestURI"]);
flush();
$error = $http->SendRequest($arguments);
if ($error == "") {
//echo "<H2><LI>Request:</LI</H2>\n<PRE>\n".HtmlEntities($http->request)."</PRE>\n";
//$dummy = $http->request;
//echo "<H2><LI>Request headers:</LI</H2>\n<PRE>\n";
for (Reset($http->request_headers), $header = 0; $header < count($http->request_headers); Next($http->request_headers), $header++) {
$header_name = Key($http->request_headers);
if (GetType($http->request_headers[$header_name]) == "array") {
for ($header_value = 0; $header_value < count($http->request_headers[$header_name]); $header_value++) {
}
//echo $header_name.": ".$http->request_headers[$header_name][$header_value],"\r\n";
} else {
}
//echo $header_name.": ".$http->request_headers[$header_name],"\r\n";
}
//echo "</PRE>\n";
flush();
$headers = array();
$error = $http->ReadReplyHeaders($headers);
if ($error == "") {
$redirect = 0;
//echo "<H2><LI>Response headers:</LI</H2>\n<PRE>\n";
for (Reset($headers), $header = 0; $header < count($headers); Next($headers), $header++) {
$header_name = Key($headers);
if (preg_match("/302/", $header_name)) {
$redirect = 1;
}
if (GetType($headers[$header_name]) == "array") {
$fp1 = fopen("redirect.txt", "a");
fwrite($fp1, "\r\n");
for ($header_value = 0; $header_value < count($headers[$header_name]); $header_value++) {
fwrite($fp1, $headers[$header_name][$header_value] . "\r\n");
//echo "!".$header_name."!".": ".$headers[$header_name][$header_value],"\r\n\n";
//echo "<br>";
preg_match_all("@\\/\\/(.*?)\\/@", $headers[$header_name][$header_value], $temp);
//echo $temp[1][0];
$this->source = $headers[$header_name][$header_value];
$this->source = preg_replace("@.*?\\/\\/.*?\\/@", "/", $this->source);
$this->host = $temp[1][0];
//echo $this->host."<br>";
//echo $this->source."<br>";
}
fclose($fp1);
} else {
//echo $header_name.": ".$headers[$header_name],"\r\n";
if ($header_name == "location") {
//echo "Neue Adresse: ".$headers[$header_name],"\r\n";
preg_match_all("@\\/\\/(.*?)\\/@", $headers[$header_name], $temp);
//echo $temp[1][0];
$this->source = $headers[$header_name];
$this->source = preg_replace("@.*?\\/\\/.*?\\/@", "/", $this->source);
$this->host = $temp[1][0];
//echo $this->host."<br>";
//echo $this->source."<br>";
}
}
}
flush();
if ($redirect == 0) {
for (;;) {
$error = $http->ReadReplyBody($body, 2048);
if ($error != "" || strlen($body) == 0) {
break;
}
$this->pagecontent = $this->pagecontent . $body;
}
flush();
}
}
}
$http->Close();
}
if (strlen($error)) {
echo "<CENTER><H2>Error: ", $error, "</H2><CENTER>\n";
$time = $datum = date("Y.m.d.H.i.s", time());
$fp = fopen("err.txt", "a");
fwrite($fp, "Am: " . $time . "\r\n");
fwrite($fp, "Server: " . $this - host . "\r\n");
fwrite($fp, "Fehler: " . $error . "\r\n");
fwrite($fp, "\r\n");
//.........这里部分代码省略.........
示例15: _saveUserPhoto
protected function _saveUserPhoto($from, $to)
{
$ret = 0;
$img = '';
$arguments = array();
$http = new http_class();
$http->user_agent = 'glFusion/' . GVERSION;
$error = $http->GetRequestArguments($from, $arguments);
$error = $http->Open($arguments);
if ($error == "") {
$error = $http->SendRequest($arguments);
if ($error == "") {
for (;;) {
$error = $http->ReadReplyBody($body, 10240);
if ($error != "" || strlen($body) == 0) {
break;
}
$img = $img . $body;
}
$ret = file_put_contents($to, $img);
}
}
$http->Close();
return $ret;
}