Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    includere fil esteno con "allow_url_fopen off"

    Ciao,

    io devo riuscire a eseguire un file ed ottenere il risultato (quello che mi scrive). Il file si trova sullo stesso server e l'idea è di caricarlo con l'url completo (http://...)

    Il problema è che il server è pieno di restrizioni, tra cui allow_url_fopen è off, quindi non posso usare né include, né file_get_contents.

    Qualcuno ha qualche idea di come posso ottenere il contenuto del file?
    E se usassi un socket? Mi rallenterebbe di molto lo script? È complicato da effettuare? ..e soprattutto, ci possono essere restrizioni anche su questo metodo?

    grazie mille

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    ma perché se è sullo stesso server vuoi andare a prenderlo via http? Oppure ti sei dimenticato un "non"?
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  3. #3
    perché è uno script che funziona come cgi per poter avere dei privilegi sui file, solo che devo poterlo richiamare da php per poter avere l'output.

  4. #4
    Ho risolto visitando questo sito http://www.hiveminds.co.uk/node/3198 , e in particolare con questa classe che copio per chi avesse il mio stesso problema:
    Codice PHP:
    <?php

    #usage:
    $r = new HTTPRequest('http://www.php.net');
    echo 
    $r->DownloadToString();
    class 
    HTTPRequest
    {
       var 
    $_fp;        // HTTP socket
       
    var $_url;        // full URL
       
    var $_host;        // HTTP host
       
    var $_protocol;    // protocol (HTTP/HTTPS)
       
    var $_uri;        // request URI
       
    var $_port;        // port
       // scan url
       
    function _scan_url()
       {
           
    $req $this->_url;
           
    $pos strpos($req'://');
           
    $this->_protocol strtolower(substr($req0$pos));
           
    $req substr($req$pos+3);
           
    $pos strpos($req'/');
           if(
    $pos === false)
               
    $pos strlen($req);
           
    $host substr($req0$pos);
           if(
    strpos($host':') !== false)
           {
               list(
    $this->_host$this->_port) = explode(':'$host);
           }
           else
           {
               
    $this->_host $host;
               
    $this->_port = ($this->_protocol == 'https') ? 443 80;
           }
           
    $this->_uri substr($req$pos);
           if(
    $this->_uri == '')
               
    $this->_uri '/';
       }
       
    // constructor
       
    function HTTPRequest($url)
       {
           
    $this->_url $url;
           
    $this->_scan_url();
       }
       
    // download URL to string
       
    function DownloadToString()
       {
           
    $crlf "\r\n";
           
    // generate request
           
    $req 'GET ' $this->_uri ' HTTP/1.0' $crlf
               
    .    'Host: ' $this->_host $crlf
               
    .    $crlf;
           
    // fetch
           
    $this->_fp fsockopen(($this->_protocol == 'https' 'ssl://' '') . $this->_host$this->_port);
           
    fwrite($this->_fp$req);
           while(
    is_resource($this->_fp) && $this->_fp && !feof($this->_fp))
               
    $response .= fread($this->_fp1024);
           
    fclose($this->_fp);
           
    // split header and body
           
    $pos strpos($response$crlf $crlf);
           if(
    $pos === false)
               return(
    $response);
           
    $header substr($response0$pos);
           
    $body substr($response$pos strlen($crlf));
           
    // parse headers
           
    $headers = array();
           
    $lines explode($crlf$header);
           foreach(
    $lines as $line)
               if((
    $pos strpos($line':')) !== false)
                   
    $headers[strtolower(trim(substr($line0$pos)))] = trim(substr($line$pos+1));
           
    // redirection?
           
    if(isset($headers['location']))
           {
               
    $http = new HTTPRequest($headers['location']);
               return(
    $http->DownloadToString($http));
           }
           else
           {
               return(
    $body);
           }
       }
    }
    ?>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.