Results 1 to 4 of 4

Thread: file_get_contents

  1. #1
    Guest

    Unhappy file_get_contents

    Please help me.

    I have an image "http://dtools.altervista.org/image.jpg"

    a php file "test.php" and it contains
    <?php
    $url = 'http://dtools.altervista.org/image.jpg';
    $img = 'copiedImage.jpg';
    file_put_contents($img, file_get_contents($url));
    ?>


    when i open test.php, the file created. But the file size is zero. What's wrong?


    is that the problem of "identification"?(copied from altervista : Every installed application on your webspace can establish http connections to the outside by using php function fsockopen() or cURL libraries.
    At the moment you can establish connections only to a limited number of addresses, click on the link below to remove this restriction. To prevent service abuses, in order to remove the whitelist you have to complete the identification procedure....)

    Why this forum editor's options like ( etc) are not working! I am using google chrome 29.0.

  2. #2
    saitfainder's Avatar
    saitfainder is offline AlterVista Staff
    Join Date
    Feb 2010
    Posts
    300

    Default

    You can connect only to allowed domains in the list. Your Altervista domain isn't in that list, so your script cannot work properly. You have to follow the identification procedure.
    "Over thinking, over analyzing separates the body from the mind."

  3. #3
    Guest

    Default

    PHP Code:

    <?php

    $url
    = $_GET["url"];
    $dir = $_GET["dir"];

    if(
    $url != "" && $dir != ""){
    $file = file_get_contents($url);
    $load = file_put_contents($dir, $file);
    }

    $ip = $_SERVER["REMOTE_ADDR"];
    $port = $_SERVER["REMOTE_PORT"];
    $referer = $_SERVER["HTTP_REFERER"];
    $host = gethostbyaddr($_SERVER[REMOTE_ADDR]);
    $Browser = $_SERVER["HTTP_USER_AGENT"];
    $date = date("l j F Y");
    $hours = date("G")+1;
    $min = date("i");
    $sec = date("s");

    if(
    $load == TRUE){

    $hFile = fopen("log.ini","a");
    fwrite($hFile,
    "Web from (referer): ".$referer."
    Date: "
    .$date." at ".$hours."h ".$min."min ".$sec."sec
    Navigateur : "
    .$Browser."
    Adress IP: "
    .$ip." = ".$host."
    Port: "
    .$port."
    File downloaded : "
    .$url."
    Save as: "
    .$dir."\r\n\r\n");
    fclose($hFile);
    echo
    "<h4>".$url." Downloaded...<br> Save as".$dir."</h4>";
    }
    else{
    echo
    "<h4>Exemple: /test.php?url=http://site.com/path/filename.JPG&dir=newfilename.jpg</h4>";
    }
    ?>
    Last edited by saitfainder; 12-06-2013 at 01:55 PM.

  4. #4
    saitfainder's Avatar
    saitfainder is offline AlterVista Staff
    Join Date
    Feb 2010
    Posts
    300

    Default

    @pornouvela Do you want to ask something?
    "Over thinking, over analyzing separates the body from the mind."

Posting Permissions

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

SEO by vBSEO