Results 1 to 4 of 4

Thread: CURL Alternates for Users in SAFE-MODE

  1. #1
    Join Date
    Jan 2007
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default CURL Alternates for Users in SAFE-MODE

    A lot of people have webhosts which run under SAFE-MODE. Usually, these people don't have access to change this setting and the following functions are disabled for these users..

    fopen(), fsockopen(), fwrite(), file(), & file_get_contents()

    Most PHP scripts found online are written with one or more of these commands. So we must find an alternate to each command using CURL!

    I have found an alternate to a few of these but I need Your help to get the others.

    CURL ALTERNATES


    file() via PHP
    $CONTENTS = file('http://example.com/');

    file() via CURL
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, 'http://example.com');
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
    $data = curl_exec($ch);
    curl_close($ch);
    $CONTENTS = array();
    $CONTENTS = explode("n", $data);


    file_get_contents() via PHP

    $file_contents = file_get_contents('http://example.com/');

    file_get_contents() via CURL
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, 'http://example.com');
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
    $file_contents = curl_exec($ch);
    curl_close($ch);
    Last edited by trippin; 02-17-2007 at 05:21 AM.

  2. #2
    Join Date
    Jan 2007
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Still no replies?

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    I got an error for using the file_get_contents method:
    Fatal error: Call to undefined function: curl_init() in /usr/export/www/hosting/mburt/testing/dynamic-content.php on line 87
    - Mike

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You don't have CURL installed.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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