本文整理汇总了PHP中http_class::ReadReplyHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP http_class::ReadReplyHeaders方法的具体用法?PHP http_class::ReadReplyHeaders怎么用?PHP http_class::ReadReplyHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http_class
的用法示例。
在下文中一共展示了http_class::ReadReplyHeaders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PNB_getPingbackUrl
/**
* Get the Pingback URL for a given URL
*
* @param string $url URL to get the Pingback URL for
* @return string Pingback URL or empty string
*/
function PNB_getPingbackUrl($url)
{
$retval = '';
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->debug = 0;
$http->html_debug = 0;
$http->user_agent = 'glFusion/' . GVERSION;
$error = $http->GetRequestArguments($url, $arguments);
$error = $http->Open($arguments);
$error = $http->SendRequest($arguments);
if ($error == "") {
$http->ReadReplyHeaders($headers);
if (isset($headers['x-pingback'])) {
$retval = $headers['x-pingback'];
} else {
COM_errorLog("Pingback (HEAD): unable to locate x-pingback header");
}
} else {
COM_errorLog('Pingback (HEAD): ' . $error);
return false;
}
if (empty($retval)) {
// search for <link rel="pingback">
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->debug = 0;
$http->html_debug = 0;
$http->user_agent = 'glFusion/' . GVERSION;
$error = $http->GetRequestArguments($url, $arguments);
$error = $http->Open($arguments);
$error = $http->SendRequest($arguments);
if ($error == "") {
$http->ReadReplyHeaders($headers);
if ($http->response_status == 200) {
$error = $http->ReadWholeReplyBody($body);
if ($error != "" && strlen($body) === 0) {
COM_errorLog("Pingback (GET): unable to retrieve response body");
return false;
}
} else {
COM_errorLog("Pingback (GET): Got HTTP response code " . $http->response_status . " when requesting " . $url);
return false;
}
} else {
COM_errorLog("Pingback (GET): " . $error . " when requesting " . $url);
return false;
}
// only search for the first match - it doesn't make sense to have
// more than one pingback URL
$found = preg_match("/<link rel=\"pingback\"[^>]*href=[\"']([^\"']*)[\"'][^>]*>/i", $body, $matches);
if ($found === 1 && !empty($matches[1])) {
$url = str_replace('&', '&', $matches[1]);
$retval = urldecode($url);
}
}
return $retval;
}
示例2: 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;
}
示例3: 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;
}
示例4: doHeadRequest
/**
* Send an HTTP HEAD request for the given URL
*
* @param string $url URL to request
* @param string $errmsg error message, if any (on return)
* @return int HTTP response code or 777 on error
*
*/
function doHeadRequest($url, &$errmsg)
{
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->debug = 0;
$http->html_debug = 0;
$http->user_agent = 'glFusion/' . GVERSION;
$error = $http->GetRequestArguments($url, $arguments);
$error = $http->Open($arguments);
$error = $http->SendRequest($arguments);
if ($error == "") {
$http->ReadReplyHeaders($headers);
return $http->response_status;
} else {
$errmsg = $error;
return 777;
}
}
示例5: 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;
}
示例6: switchAction
public function switchAction($action, $httpVars, $fileVars)
{
//$this->logInfo("DL file", $httpVars);
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(false)) {
return false;
}
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$dir = AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . $dir . "/";
$dlURL = null;
if (isset($httpVars["file"])) {
$parts = parse_url($httpVars["file"]);
$getPath = $parts["path"];
$basename = basename($getPath);
$dlURL = $httpVars["file"];
}
if (isset($httpVars["dlfile"])) {
$dlFile = $streamData["protocol"] . "://" . $repository->getId() . AJXP_Utils::decodeSecureMagic($httpVars["dlfile"]);
$realFile = file_get_contents($dlFile);
if (empty($realFile)) {
throw new Exception("cannot find file {$dlFile} for download");
}
$parts = parse_url($realFile);
$getPath = $parts["path"];
$basename = basename($getPath);
$dlURL = $realFile;
}
switch ($action) {
case "external_download":
if (!ConfService::currentContextIsCommandLine() && ConfService::backgroundActionsSupported()) {
$unixProcess = AJXP_Controller::applyActionInBackground($repository->getId(), "external_download", $httpVars);
if ($unixProcess !== null) {
@file_put_contents($destStreamURL . "." . $basename . ".pid", $unixProcess->getPid());
}
AJXP_XMLWriter::header();
AJXP_XMLWriter::triggerBgAction("reload_node", array(), "Triggering DL ", true, 2);
AJXP_XMLWriter::close();
session_write_close();
exit;
}
require_once AJXP_BIN_FOLDER . "/http_class/http_class.php";
session_write_close();
$httpClient = new http_class();
$arguments = array();
$httpClient->GetRequestArguments($httpVars["file"], $arguments);
$err = $httpClient->Open($arguments);
$collectHeaders = array("ajxp-last-redirection" => "", "content-disposition" => "", "content-length" => "");
if (empty($err)) {
$err = $httpClient->SendRequest($arguments);
$httpClient->follow_redirect = true;
$pidHiddenFileName = $destStreamURL . "." . $basename . ".pid";
if (is_file($pidHiddenFileName)) {
$pid = file_get_contents($pidHiddenFileName);
@unlink($pidHiddenFileName);
}
if (empty($err)) {
$httpClient->ReadReplyHeaders($collectHeaders);
$totalSize = -1;
if (!empty($collectHeaders["content-disposition"]) && strstr($collectHeaders["content-disposition"], "filename") !== false) {
$ar = explode("filename=", $collectHeaders["content-disposition"]);
$basename = trim(array_pop($ar));
$basename = str_replace("\"", "", $basename);
// Remove quotes
}
if (!empty($collectHeaders["content-length"])) {
$totalSize = intval($collectHeaders["content-length"]);
$this->logDebug("Should download {$totalSize} bytes!");
}
if ($totalSize != -1) {
$node = new AJXP_Node($destStreamURL . $basename);
AJXP_Controller::applyHook("node.before_create", array($node, $totalSize));
}
$tmpFilename = $destStreamURL . $basename . ".dlpart";
$hiddenFilename = $destStreamURL . "__" . $basename . ".ser";
$filename = $destStreamURL . $basename;
$dlData = array("sourceUrl" => $getPath, "totalSize" => $totalSize);
if (isset($pid)) {
$dlData["pid"] = $pid;
}
//file_put_contents($hiddenFilename, serialize($dlData));
$fpHid = fopen($hiddenFilename, "w");
fputs($fpHid, serialize($dlData));
fclose($fpHid);
// NOW READ RESPONSE
$destStream = fopen($tmpFilename, "w");
while (true) {
$body = "";
$error = $httpClient->ReadReplyBody($body, 1000);
if ($error != "" || strlen($body) == 0) {
break;
}
fwrite($destStream, $body, strlen($body));
}
fclose($destStream);
rename($tmpFilename, $filename);
unlink($hiddenFilename);
}
$httpClient->Close();
//.........这里部分代码省略.........
示例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: PNB_handlePingback
/**
* Handle a pingback for an entry.
* Also takes care of the speedlimit and spam. Assumes that the caller of this
* function has already checked permissions!
*
* @param string $id ID of entry that got pinged
* @param string $type type of that entry ('article' for stories, etc.)
* @param string $url URL of the page that pinged us
* @param string $oururl URL that got pinged on our site
* @return object XML-RPC response
*/
function PNB_handlePingback($id, $type, $url, $oururl)
{
global $_CONF, $_TABLES, $PNB_ERROR;
require_once 'HTTP/Request.php';
if (!isset($_CONF['check_trackback_link'])) {
$_CONF['check_trackback_link'] = 2;
}
// handle pingbacks to articles on our own site
$skip_speedlimit = false;
if ($_SERVER['REMOTE_ADDR'] == $_SERVER['SERVER_ADDR']) {
if (!isset($_CONF['pingback_self'])) {
$_CONF['pingback_self'] = 0;
// default: skip self-pingbacks
}
if ($_CONF['pingback_self'] == 0) {
return new XML_RPC_Response(new XML_RPC_Value($PNB_ERROR['skipped']));
} elseif ($_CONF['pingback_self'] == 2) {
$skip_speedlimit = true;
}
}
COM_clearSpeedlimit($_CONF['commentspeedlimit'], 'pingback');
if (!$skip_speedlimit) {
$last = COM_checkSpeedlimit('pingback');
if ($last > 0) {
return new XML_RPC_Response(0, 49, sprintf($PNB_ERROR['speedlimit'], $last, $_CONF['commentspeedlimit']));
}
}
// update speed limit in any case
COM_updateSpeedlimit('pingback');
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
if ($_CONF['check_trackback_link'] & 4) {
$parts = parse_url($url);
if (empty($parts['host'])) {
TRB_logRejected('Pingback: No valid URL', $url);
return new XML_RPC_Response(0, 33, $PNB_ERROR['uri_invalid']);
} else {
$ip = gethostbyname($parts['host']);
if ($ip != $_SERVER['REMOTE_ADDR']) {
TRB_logRejected('Pingback: IP address mismatch', $url);
return new XML_RPC_Response(0, 49, $PNB_ERROR['spam']);
}
}
}
}
// See if we can read the page linking to us and extract at least
// the page's title out of it ...
$title = '';
$excerpt = '';
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->debug = 0;
$http->html_debug = 0;
$http->user_agent = 'glFusion/' . GVERSION;
$error = $http->GetRequestArguments($url, $arguments);
$error = $http->Open($arguments);
$error = $http->SendRequest($arguments);
if ($error == "") {
$http->ReadReplyHeaders($headers);
if ($http->response_status == 200) {
$error = $http->ReadWholeReplyBody($body);
if ($error == "" || strlen($body) > 0) {
if ($_CONF['check_trackback_link'] & 3) {
if (!TRB_containsBacklink($body, $oururl)) {
TRB_logRejected('Pingback: No link to us', $url);
$comment = TRB_formatComment($url);
PLG_spamAction($comment, $_CONF['spamx']);
return new XML_RPC_Response(0, 49, $PNB_ERROR['spam']);
}
}
preg_match(':<title>(.*)</title>:i', $body, $content);
if (empty($content[1])) {
$title = '';
// no title found
} else {
$title = trim(COM_undoSpecialChars($content[1]));
}
if ($_CONF['pingback_excerpt']) {
// Check which character set the site that sent the Pingback
// is using
$charset = 'ISO-8859-1';
// default, see RFC 2616, 3.7.1
$ctype = $headers['content-type'];
$c = explode(';', $ctype);
foreach ($c as $ct) {
$ch = explode('=', trim($ct));
if (count($ch) === 2) {
if (trim($ch[0]) === 'charset') {
$charset = trim($ch[1]);
//.........这里部分代码省略.........
示例9: testSslCertificate
function testSslCertificate($urlsToTest, $testId)
{
connectToDb($db);
updateStatus($db, "Testing {$urlsToTest} for untrustworthy SSL certificates...", $testId);
$log = new Logger();
$log->lfile('logs/eventlogs');
$log->lwrite("Starting SSL certificate verification function on {$urlsToTest}");
//Identify which URLs, if any, begin with https
$log->lwrite("Identifying which URLs, if any, begin with HTTPS");
updateStatus($db, "Identifying which URLs, if any, begin with HTTPS...", $testId);
$usingHttps = false;
$httpsUrl = '';
foreach ($urlsToTest as $currentUrl) {
if (substr($currentUrl, 0, 5) == 'https') {
$usingHttps = true;
$httpsUrl = $currentUrl;
echo "https url = {$currentUrl} <br>";
$log->lwrite("Found HTTPS URL: {$currentUrl}");
break;
}
}
if ($usingHttps) {
//Check if Mozilla's cacert.pem file is online and update our version of it if needed
$log->lwrite("Checking if cacert.pem is up to date");
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
//$http->debug=1;
$http->user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$http->follow_redirect = 1;
$http->redirection_limit = 5;
$cacertsUrl = "http://curl.haxx.se/ca/cacert.pem";
$error = $http->GetRequestArguments($cacertsUrl, $arguments);
$error = $http->Open($arguments);
$log->lwrite("URL to be requested is: {$cacertsUrl}");
if ($error == "") {
$log->lwrite("Sending HTTP request to {$cacertsUrl}");
$error = $http->SendRequest($arguments);
if ($error == "") {
$headers = array();
$error = $http->ReadReplyHeaders($headers);
if ($error == "") {
$responseCode = $http->response_status;
//This is a string
$log->lwrite("Received response code: {$responseCode}");
if (intval($responseCode) == 200) {
//Update cacerts.pem file
$cacerts = file_get_contents($cacertsUrl);
$oldCacerts = file_get_contents('tests/cacert.pem');
if ($cacerts != $oldCacerts) {
file_put_contents('tests/cacert.pem', $cacerts);
$log->lwrite("cacert.pem file updated");
} else {
$log->lwrite("cacert.pem is already up to date so was not updated");
}
} else {
$log->lwrite("Problem accessing Mozilla's URL containing cacert.pem file");
}
}
}
}
// Initialize session and set URL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $httpsUrl);
// Set so curl_exec returns the result instead of outputting it.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
//Check server's certificate against certificates specified in .pem file below
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
//If last parameter is 1, checks the SSL certificate for a comman name (the domain of the site sometimes specified in the certificate), e.g. the site that acquired the certificate
//If last parameter is 2, checks for the common name and, if it exists, checks that it matches the hostname provided
//Default is 2
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
//Using Mozillas certificate file with trusted certificates
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/cacert.pem");
// Get the response and close the channel.
$response = curl_exec($ch);
if ($db) {
incrementHttpRequests($db, $testId);
}
if (empty($response)) {
//The echo's here are for testing/debugging the function on its own
echo '<br>SSL Certificate is not trusted!<br>Url: ' . $httpsUrl . '<br>';
echo 'Method: GET <br>';
//echo 'Url Requested: ' . $testUrl . '<br>';
echo 'Error: ' . curl_error($ch) . '<br>';
$tableName = 'test' . $testId;
//Check if this vulnerability has already been found and added to DB. If it hasn't, add it to DB.
$query = "SELECT * FROM test_results WHERE test_id = {$testId} AND type = 'sslcert' AND method = 'get' AND url = '{$httpsUrl}' AND attack_str = '{$httpsUrl}'";
$result = $db->query($query);
if (!$result) {
$log->lwrite("Could not execute query {$query}");
} else {
$log->lwrite("Successfully executed query {$query}");
$numRows = $result->num_rows;
if ($numRows == 0) {
$log->lwrite("Number of rows is {$numRows} for query: {$query}");
insertTestResult($db, $testId, 'sslcert', 'get', $httpsUrl, $httpsUrl);
//.........这里部分代码省略.........
示例10: httpClientPost
function httpClientPost($url, $paramters)
{
//$url='https://login.yahoo.com/config/login?';
//$url="https://accounts.google.com/ServiceLogin";
//log echo '<br/> httpClient $url: '. $url ;
//log echo '<br/> httpClient $paramters: ' ;
//log var_dump($paramters);
$resultbody;
set_time_limit(0);
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->debug = 0;
$http->html_debug = 1;
//$url="https://login.yahoo.com/config/login";
if ($this->isDebug) {
echo "<br/>url:" . $url;
echo "<br/>arguments:<br/>";
var_dump($paramters);
}
$error = $http->GetRequestArguments($url, $arguments);
$arguments["RequestMethod"] = "POST";
//$arguments['Protocol']='https';
//$arguments['HostName']='login.yahoo.com';
//$arguments['HostPort']='443';
//$arguments['RequestMethod']='POST';
$arguments['PostValues'] = $paramters;
/*
$arguments["PostValues"]=array(
"somefield"=>"Upload forms",
"MAX_FILE_SIZE"=>"1000000"
);
$arguments["PostFiles"]=array(
"userfile"=>array(
"Data"=>"This is just a plain text attachment file named attachment.txt .",
"Name"=>"attachment.txt",
"Content-Type"=>"automatic/name",
),
"anotherfile"=>array(
"FileName"=>"test_http_post.php",
"Content-Type"=>"automatic/name",
)
);
$arguments["Referer"]="http://www.alltheweb.com/";
*/
if ($this->isDebug) {
echo "<H2><LI>Opening connection to:</H2>\n<PRE>", HtmlEntities($arguments["HostName"]), "</PRE>\n";
echo '<br/> <b>$arguments: </b><br/> ';
var_dump($arguments);
}
flush();
$error = $http->Open($arguments);
if ($this->isDebug) {
echo "<br/><br/>http->open:" . $error . "<br/>";
}
if ($error == "") {
$error = $http->SendRequest($arguments);
if ($this->isDebug) {
echo "<br/>[http->SendRequest:" . $error . "]<br/><br/>";
}
if ($error == "") {
//log echo "<H2><LI>Request:</LI</H2>\n<PRE>\n".HtmlEntities($http->request)."</PRE>\n";
//log 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++) {
//log echo $header_name.": ".$http->request_headers[$header_name][$header_value],"\r\n";
}
} else {
//log echo $header_name.": ".$http->request_headers[$header_name],"\r\n";
}
}
//log echo "</PRE>\n";
if ($this->isDebug) {
echo "<H4><LI>HTTP Request body:</LI></H4>error_code:\n" . $http->error_code . "<br/><PRE>request_body:\n" . HtmlEntities($http->request_body) . "</PRE>\n";
}
flush();
$headers = array();
$error = $http->ReadReplyHeaders($headers);
if ($error == "") {
//log 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 (GetType($headers[$header_name]) == "array") {
for ($header_value = 0; $header_value < count($headers[$header_name]); $header_value++) {
if ($this->isDebug) {
echo "http header:" . $header_name . ": " . $headers[$header_name][$header_value], "\r\n";
}
}
} else {
if ($this->isDebug) {
echo $header_name . ": " . $headers[$header_name], "\r\n";
}
}
}
//log echo "</PRE>\n";
flush();
//log echo "<H2><LI>Response body:</LI</H2>\n<PRE>\n";
for (;;) {
//.........这里部分代码省略.........
示例11: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
$selection = new UserSelection($repository, $httpVars);
$selectedNode = $selection->getUniqueNode();
$selectedNodeUrl = $selectedNode->getUrl();
if ($action == "post_to_server") {
// Backward compat
if (strpos($httpVars["file"], "base64encoded:") !== 0) {
$legacyFilePath = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"]));
$selectedNode = new AJXP_Node($selection->currentBaseUrl() . $legacyFilePath);
$selectedNodeUrl = $selectedNode->getUrl();
}
$target = rtrim(base64_decode($httpVars["parent_url"]), '/') . "/plugins/editor.pixlr";
$tmp = AJXP_MetaStreamWrapper::getRealFSReference($selectedNodeUrl);
$tmp = SystemTextEncoding::fromUTF8($tmp);
$this->logInfo('Preview', 'Sending content of ' . $selectedNodeUrl . ' to Pixlr server.', array("files" => $selectedNodeUrl));
AJXP_Controller::applyHook("node.read", array($selectedNode));
$saveTarget = $target . "/fake_save_pixlr.php";
if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
$saveTarget = $target . "/fake_save_pixlr_" . md5($httpVars["secure_token"]) . ".php";
}
$params = array("referrer" => "Pydio", "method" => "get", "loc" => ConfService::getLanguage(), "target" => $saveTarget, "exit" => $target . "/fake_close_pixlr.php", "title" => urlencode(basename($selectedNodeUrl)), "locktarget" => "false", "locktitle" => "true", "locktype" => "source");
require_once AJXP_BIN_FOLDER . "/http_class/http_class.php";
$arguments = array();
$httpClient = new http_class();
$httpClient->request_method = "POST";
$httpClient->GetRequestArguments("https://pixlr.com/editor/", $arguments);
$arguments["PostValues"] = $params;
$arguments["PostFiles"] = array("image" => array("FileName" => $tmp, "Content-Type" => "automatic/name"));
$err = $httpClient->Open($arguments);
if (empty($err)) {
$err = $httpClient->SendRequest($arguments);
if (empty($err)) {
$response = "";
while (true) {
$header = array();
$error = $httpClient->ReadReplyHeaders($header, 1000);
if ($error != "" || $header != null) {
break;
}
$response .= $header;
}
}
}
header("Location: {$header['location']}");
//$response");
} else {
if ($action == "retrieve_pixlr_image") {
$file = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
$selectedNode = new AJXP_Node($selection->currentBaseUrl() . $file);
$selectedNode->loadNodeInfo();
$this->logInfo('Edit', 'Retrieving content of ' . $file . ' from Pixlr server.', array("files" => $file));
AJXP_Controller::applyHook("node.before_change", array(&$selectedNode));
$url = $httpVars["new_url"];
$urlParts = parse_url($url);
$query = $urlParts["query"];
if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
$scriptName = basename($urlParts["path"]);
$token = str_replace(array("fake_save_pixlr_", ".php"), "", $scriptName);
if ($token != md5($httpVars["secure_token"])) {
throw new AJXP_Exception("Invalid Token, this could mean some security problem!");
}
}
$params = array();
parse_str($query, $params);
$image = $params['image'];
$headers = get_headers($image, 1);
$content_type = explode("/", $headers['Content-Type']);
if ($content_type[0] != "image") {
throw new AJXP_Exception("Invalid File Type");
}
$content_length = intval($headers["Content-Length"]);
if ($content_length != 0) {
AJXP_Controller::applyHook("node.before_change", array(&$selectedNode, $content_length));
}
$orig = fopen($image, "r");
$target = fopen($selectedNode->getUrl(), "w");
if (is_resource($orig) && is_resource($target)) {
while (!feof($orig)) {
fwrite($target, fread($orig, 4096));
}
fclose($orig);
fclose($target);
}
clearstatcache(true, $selectedNode->getUrl());
$selectedNode->loadNodeInfo(true);
AJXP_Controller::applyHook("node.change", array(&$selectedNode, &$selectedNode));
}
}
}
示例12: testForReflectedXSS
function testForReflectedXSS($urlToCheck, $urlOfSite, $testId)
{
connectToDb($db);
updateStatus($db, "Testing {$urlToCheck} for Reflected Cross-Site Scripting...", $testId);
$log = new Logger();
$log->lfile('logs/eventlogs');
$log->lwrite("Starting Reflected XXS test function on {$urlToCheck}");
$postUrl = $urlToCheck;
$postUrlPath = parse_url($postUrl, PHP_URL_PATH);
//Check URL is not responding with 5xx codes
$log->lwrite("Checking what response code is received from {$urlToCheck}");
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
//$http->debug=1;
$http->user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$http->follow_redirect = 1;
$http->redirection_limit = 5;
$http->setTestId($testId);
$error = $http->GetRequestArguments($urlToCheck, $arguments);
$error = $http->Open($arguments);
$log->lwrite("URL to be requested is: {$urlToCheck}");
if ($error == "") {
$log->lwrite("Sending HTTP request to {$urlToCheck}");
$error = $http->SendRequest($arguments);
if ($error == "") {
$headers = array();
$error = $http->ReadReplyHeaders($headers);
if ($error == "") {
$responseCode = $http->response_status;
//This is a string
$log->lwrite("Received response code: {$responseCode}");
if (intval($responseCode) >= 500 && intval($responseCode) < 600) {
$log->lwrite("Response code: {$responseCode} received from: {$urlToCheck}");
return;
}
}
}
$http->Close();
}
if (strlen($error)) {
echo "<H2 align=\"center\">Error: ", $error, "</H2>\n";
$log->lwrite("Error: {$error}");
}
$html = file_get_html($postUrl, $testId);
if (empty($html)) {
//This can happen due to file_get_contents returning a 500 code. Then the parser won't parse it
$log->lwrite("Problem getting contents from {$urlToCheck}");
return;
}
//Submit these
//If adding string to this array, add a corresponding string (to look for in response), with he same index, in the array below
//The response to look for can be the same as the payload or different.
$payloads = array('<webvulscan>', 'javascript:alert(webvulscan)');
//Look for these in response after submitting corresponding payload
$harmfulResponses = array('<webvulscan>', 'src="javascript:alert(webvulscan)"');
//First check does the URL passed into this function contain parameters and submit payloads as those parameters if it does
$parsedUrl = parse_url($urlToCheck);
$log->lwrite("Check if {$urlToCheck} contains parameters");
if ($parsedUrl) {
if (isset($parsedUrl['query'])) {
$log->lwrite("{$urlToCheck} does contain parameters");
$scheme = $parsedUrl['scheme'];
$host = $parsedUrl['host'];
$path = $parsedUrl['path'];
$query = $parsedUrl['query'];
parse_str($query, $parameters);
$originalQuery = $query;
$payloadIndex = 0;
foreach ($payloads as $currentPayload) {
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
//$http->debug=1;
$http->user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$http->follow_redirect = 1;
$http->redirection_limit = 5;
$http->setTestId($testId);
foreach ($parameters as $para) {
$query = $originalQuery;
$newQuery = str_replace($para, $currentPayload, $query);
$query = $newQuery;
$testUrl = $scheme . '://' . $host . $path . '?' . $query;
$log->lwrite("URL to be requested is: {$testUrl}");
$error = $http->GetRequestArguments($testUrl, $arguments);
$error = $http->Open($arguments);
echo "<br>Sending HTTP request to " . htmlspecialchars($testUrl) . "<br>";
if ($error == "") {
$log->lwrite("Sending HTTP request to {$testUrl}");
$error = $http->SendRequest($arguments);
if ($error == "") {
$headers = array();
$error = $http->ReadReplyHeaders($headers);
if ($error == "") {
$error = $http->ReadWholeReplyBody($body);
if (strlen($error) == 0) {
$indicatorStr = $harmfulResponses[$payloadIndex];
if (stripos($body, $indicatorStr)) {
echo '<br>Reflected XSS Present!<br>Query: ' . HtmlSpecialChars($urlToCheck) . '<br>';
echo 'Method: GET <br>';
//.........这里部分代码省略.........
示例13: array
if ($user == "") {
echo "PHP Classes site user was not specified in script " . __FILE__ . " line {$user_line}\n";
exit;
}
if ($password == "") {
echo "PHP Classes site password was not specified in script " . __FILE__ . " line {$password_line}\n";
exit;
}
require "http.php";
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";
示例14: array
}
if ($password == "") {
echo "PHP Classes site password was not specified in script " . __FILE__ . " line {$password_line}\n";
exit;
}
require "http.php";
set_time_limit(0);
$http = new http_class();
$http->GetRequestArguments($url, $arguments);
$error = $http->Open($arguments);
if ($error == "") {
$arguments["RequestMethod"] = "POST";
$arguments["PostValues"] = array("alias" => $user, "password" => $password, "Submit" => "Login", "dologin" => "1");
$error = $http->SendRequest($arguments);
if ($error == "") {
$error = $http->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->ReadReplyBody($body, 1000);
if ($error != "" || strlen($body) == 0) {
break;
}
}
} else {
$error = "This page did not set a cookie";
示例15: TRB_detectTrackbackUrl
/**
* Attempt to auto-detect the Trackback URL of a post.
*
* @param string $url URL of post with embedded RDF for the Trackback URL
* @return mixed Trackback URL, or false on error
* Note: The RDF, if found, is only parsed using a regular expression. Using
* the XML parser may be more successful on some occassions ...
*/
function TRB_detectTrackbackUrl($url)
{
$retval = false;
$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->debug = 0;
$http->html_debug = 0;
$http->user_agent = 'glFusion/' . GVERSION;
$error = $http->GetRequestArguments($url, $arguments);
$error = $http->Open($arguments);
$error = $http->SendRequest($arguments);
if ($error == "") {
$http->ReadReplyHeaders($headers);
if ($http->response_status == 200) {
$error = $http->ReadWholeReplyBody($page);
if ($error != "" && strlen($body) === 0) {
COM_errorLog("Trackback Detect TRB URL: unable to retrieve response body");
return false;
}
} else {
COM_errorLog("Trackback Detect TRB URL: Got HTTP response code " . $http->response_status . " when requesting " . $url);
return false;
}
} else {
COM_errorLog("Trackback Detect TRB URL: " . $error . " when requesting " . $url);
return false;
}
// search for the RDF first
$startPos = strpos($page, '<rdf:RDF ');
if ($startPos !== false) {
$endPos = strpos($page, '</rdf:RDF>', $startPos);
$endPos += strlen('</rdf:RDF>');
$rdf = substr($page, $startPos, $endPos - $startPos);
// Okay, we COULD fire up the XML parser now. But then again ...
if (preg_match('/trackback:ping="(.*)"/', $rdf, $matches) == 1) {
if (!empty($matches[1])) {
$retval = $matches[1];
}
}
}
// no luck with the RDF? try searching for a rel="trackback" link
if ($retval === false) {
// remove all linefeeds first to help the regexp below
$page = str_replace(array("\r", "\n"), '', $page);
preg_match_all("/<a[^>]*href=[\"']([^\"']*)[\"'][^>]*>(.*?)<\\/a>/i", $page, $matches);
for ($i = 0; $i < count($matches[0]); $i++) {
$link = $matches[0][$i];
if (strpos($link, 'rel="trackback"') !== false) {
$retval = $matches[1][$i];
break;
}
}
}
return $retval;
}