当前位置: 首页>>代码示例>>PHP>>正文


PHP http_class::SendRequest方法代码示例

本文整理汇总了PHP中http_class::SendRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP http_class::SendRequest方法的具体用法?PHP http_class::SendRequest怎么用?PHP http_class::SendRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在http_class的用法示例。


在下文中一共展示了http_class::SendRequest方法的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('&amp;', '&', $matches[1]);
            $retval = urldecode($url);
        }
    }
    return $retval;
}
开发者ID:spacequad,项目名称:glfusion,代码行数:66,代码来源:lib-pingback.php

示例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;
 }
开发者ID:risis-eu,项目名称:RISIS_LinkedDataAPI,代码行数:59,代码来源:phphttpclient.class.php

示例3: _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;
}
开发者ID:NewRoute,项目名称:glfusion,代码行数:51,代码来源:sfs.php

示例4: 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;
 }
开发者ID:jdrzaic,项目名称:joomla-dummy,代码行数:79,代码来源:http.php

示例5: 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;
    }
}
开发者ID:spacequad,项目名称:glfusion,代码行数:27,代码来源:sectest.php

示例6: 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;
 }
开发者ID:spacequad,项目名称:glfusion,代码行数:53,代码来源:SFSbase.class.php

示例7: 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;
 }
开发者ID:emente,项目名称:kataii---kata-framework-2.x,代码行数:39,代码来源:akismet.php

示例8: _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;
 }
开发者ID:spacequad,项目名称:glfusion,代码行数:25,代码来源:oauthhelper.class.php

示例9: array

$http = new http_class();
$http->timeout = 0;
$http->data_timeout = 0;
$http->debug = 0;
$http->html_debug = 1;
$url = "http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echoraw.cgi";
$error = $http->GetRequestArguments($url, $arguments);
$arguments["RequestMethod"] = "POST";
$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/";
echo "<H2><LI>Opening connection to:</H2>\n<PRE>", HtmlEntities($arguments["HostName"]), "</PRE>\n";
flush();
$error = $http->Open($arguments);
if ($error == "") {
    $error = $http->SendRequest($arguments);
    if ($error == "") {
        echo "<H2><LI>Request:</LI</H2>\n<PRE>\n" . HtmlEntities($http->request) . "</PRE>\n";
        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";
        echo "<H2><LI>Request body:</LI</H2>\n<PRE>\n" . HtmlEntities($http->request_body) . "</PRE>\n";
开发者ID:3nj0y,项目名称:webvulscan,代码行数:31,代码来源:test_http_post.php

示例10: _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...
//.........这里部分代码省略.........
开发者ID:NewRoute,项目名称:glfusion,代码行数:101,代码来源:lib-glfusion.php

示例11: 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();
//.........这里部分代码省略.........
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:101,代码来源:updater.php

示例12: 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();
//.........这里部分代码省略.........
开发者ID:rcmarotz,项目名称:pydio-core,代码行数:101,代码来源:class.HttpDownloader.php

示例13: array

    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 = 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;
                    }
                }
开发者ID:3nj0y,项目名称:webvulscan,代码行数:31,代码来源:test_http_cookies.php

示例14: 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));
         }
     }
 }
开发者ID:thermalpaste,项目名称:pydio-core,代码行数:94,代码来源:class.PixlrEditor.php

示例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;
}
开发者ID:spacequad,项目名称:glfusion,代码行数:64,代码来源:lib-trackback.php


注:本文中的http_class::SendRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。