Results 1 to 3 of 3

Thread: File_Get_Contents

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    107

    File_Get_Contents

    OK, simple enough command

    $string = file_get_contents ( "http://www.google.com" );

    And it used to work superbly! however now my computer must use a proxy server to access the internet and this doesnt work anymore!

    Please does anyone know how I can tell this command to use http://myproxyserver:8080 note I also have to type in a username password and domain name when I am connecting through this, so is there a way I can put this in as well.

    Thanks In Advanced
    I am not suffering from insanity......... ...........I am loving every minute of it.

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    Have u tryed using fopen?

    http://uk.php.net/manual/en/function.fopen.php

    There is also a comment on how to use a proxy server there.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Location
    UK
    Posts
    107

    Cheers

    I wont be able to test until I am back in work... but just a little question, from the code below how will I get the source code of "www.google.com" into $string? (I am a newbie)

    Code:
    Based on a previous code, here is the getThroughProxy function, with proxy Basic authentification :
    function getthroughproxy
    ($myfiles,
     $proxyhost="0.0.0.0",
     $proxyport=0,
     $proxyuser = '',
     $proxypass = ''
     )
       {
           $errno = '';
           $errstr = '';
           $datei = fsockopen($proxyhost, $proxyport, &$errno, &$errstr,30); 
           if( !$datei ) 
           {
               return array('headers'=>false,
                             'content'=>false,
                             'errno'=>$errno,
                             'errstr'=>$errstr);
           // ^^^ proxy not available
           } else 
           {
               fputs($datei,"GET $myfiles HTTP/1.0\n"); 
               if ('' !== $proxyuser)
               {                
                   fputs($datei, 'Proxy-Authorization: Basic '.base64_encode("$proxyuser:$proxypass")."\n");
               }
               fputs($datei, "\n\n");
               $zeile = '';
               while (!feof($datei)) 
               {
                     $zeile =$zeile.fread($datei,4096);
               }
           }
           fclose($datei);
           return array('headers'=>substr($zeile,0,strpos($zeile,"\r\n\r\n")),
           'content'=>substr($zeile,strpos($zeile,"\r\n\r\n")+4),
           'errno'=>$errno,
           'errstr'=>$errstr);
       }
    I am not suffering from insanity......... ...........I am loving every minute of it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width