Problem mit fsockopen()

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Problem mit fsockopen()

    Hallo,
    Ich habe folgenden Code um auf eine Seite (wie Rapidshare.de/com bzw. megaupload zu connecten ohne das man den Link namen sieht). Bei rapidshare.de/com klappt alles doch bei megaupload.com (wo eigentlich alle meine Projekte lagern) zeigt es nur wirre Zahlen an.

    Weis jemand eine Lösung für dieses Problem?
    Schonmal danke im vorraus.

    .capu-one

    Der oben benannte Code:
    PHP-Code:
    <?
    $repeat  = 1;
    $timeout = 100;
    $size    = 0;
    $host_ip = gethostbyname($row->hoster);
    $server  = $host_ip;
    $host    = '".$row->hoster."';
    $target  = "".$row->dir."";
    $referer = 'http://".$row->hoster."/';
    $port    = 80;
    $gets = array ( 'get_field_1' => 'somevalue',
                   'get_field_2' => 'somevalue' );
    $posts = array ( 'post_field_1' => 'somevalue',
                     'post_field_2' => 'somevalue' );
    $method = "GET";
    if ( is_array( $gets ) ) {
       $getValues = '?';
       foreach( $gets AS $name => $value ){
           $getValues .= urlencode( $name ) . "=" . urlencode( $value ) . '&';
       }
       $getValues = substr( $getValues, 0, -1 );
    } else {
       $getValues = '';
    }

    if ( is_array( $posts ) ) {
       foreach( $posts AS $name => $value ){
           $postValues .= urlencode( $name ) . "=" . urlencode( $value ) . '&';
       }
       $postValues = substr( $postValues, 0, -1 );
       $method = "POST";
    } else {
       $postValues = '';
    }

    $request  = "$method $target$getValues HTTP/1.1\r\n";
    $request .= "Host: $host\r\n";
    $request .= 'User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) ';
    $request .= "Gecko/20021204\r\n";
    $request .= 'Accept: text/xml,application/xml,application/xhtml+xml,';
    $request .= 'text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,';
    $request .= "image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1\r\n";
    $request .= "Accept-Language: en-us, en;q=0.50\r\n";
    $request .= "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n";
    $request .= "Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66\r\n";
    $request .= "Keep-Alive: 300\r\n";
    $request .= "Connection: keep-alive\r\n";
    $request .= "Referer: $referer\r\n";
    $request .= "Cache-Control: max-age=0\r\n";

    if ( $method == "POST" ) {
       $lenght = strlen( $postValues );
       $request .= "Content-Type: application/x-www-form-urlencoded\r\n";
       $request .= "Content-Length: $lenght\r\n";
       $request .= "\r\n";
       $request .= $postValues;
    }

    for ( $i = 0; $i < $repeat; $i++ ) {
       $socket  = fsockopen( $server, $port, $errno, $errstr, $timeout );
       fputs( $socket, $request );
       if ( $size > 0 ) {
           $ret = fgets( $socket, $size );
       } else {
           $ret = '';
           while ( !feof( $socket ) ) {
               $ret .= fgets( $socket, 4096 );
           }
       }
       fclose( $socket );
       echo "<hr> $i -- $content $ret";
       }
    ?>

  • #2
    error_reporting(E_ALL) bereits gemacht ?
    Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

    [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
    Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

    Kommentar


    • #3
      PHP-Code:
      $host    '".$row->hoster."';
      ..
      $referer 'http://".$row->hoster."/'
      und das geht? oO

      Kommentar


      • #4
        Also bei megaupload zeigt er mit error all nix ausser:

        HTTP/1.1 200 OK Date: Tue, 28 Nov 2006 21:38:35 GMT Server: Apache/2.0.54 (Debian GNU/Linux) PHP/5.2.0 X-Powered-By: PHP/5.2.0 Vary: Accept-Encoding Connection: close Transfer-Encoding: chunked Content-Type: text/html 1f4f body { text-align:center; padding:0; margin:0; background-image:url(gui2/bg.gif); color: #B2B8B8; font-family: tahoma; font-size: 11px; text-align: left; } #main { width:980px; position: relative; margin-top:0px; } #mu1 { width:16px; height: 581px; position: absolute; left:0px; top:0px; background-image:url(gui2/mu_01.gif); } #mu2 { width:742px; height:29px; position: absolute; left:16px; top:0px; background-image:url(gui2/mu_02.gif); } #mu3 { width:16px; height:581px; position: absolute; left:758px; top:0px; background-image:url(gui2/mu_03.gif); } #mu4 { width:742px; height:55px; position: absolute; left:16px; top:29px; background-image:url(gui2/mu_04.gif); } #mu5 { width:372px; height:42px; position: absolute; left:16px; top:84px; background-image:url(gui2/mu_05.gif); } #mu6 { width:370px; height:42px; position: absolute; left:388px; top:84px; background-image:url(gui2/mu_06.gif); } #mu7 { width:372px; height:87px; position: absolute; left:16px; top:126px; background-image:url(gui2/mu_07.gif); } #mu8 { width:370px; height:87px; position: absolute; left:388px; top:126px; background-color:#ffffff; } #mu9 { width:742px; height:263px; position: absolute; left:16px; top:213px; background-color:#ffffff; } #mu10 { width:742px; height:62px; position: absolute; left:16px; top:476px; background-image:url(gui2/mu_10.gif); } #mu11 { width:742px; height:44px; position: absolute; left:16px; top:538px; background-image:url(gui2/mu_11.gif); } #menu { position:absolute; top:546px; left: 24px; font-weight: bold; } #content

        Also hat mir leider nicht weitergeholfen. Wie gesagt bei Rapidshare.de geht es wunderbar.
        Zuletzt geändert von capu-one; 28.11.2006, 21:41.

        Kommentar

        Lädt...
        X