Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2010
    Posts
    160
    Thanks
    10
    Thanked 1 Time in 1 Post

    Cron Download Script not working

    Hi

    I am trying to get the following file to download everyday using Plesk Cron but keep getting this error

    PHP Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0 PHP Warning: file_put_contents(urchin.js): failed to open stream: Permission denied in /var/www/vhosts/website.com/httpdocs/scripts/analytics/update_analytics2.php on line 3

    PHP Code:
    <?php
    $file 
    file_get_contents("http://www.google-analytics.com/urchin.js");
    file_put_contents("urchin.js"$file);
    ?>
    What is the best way to achieve what I want.

    Thanks
    Roy

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,298
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    You have safe_mode turned on and php is warning you that the feature is deprecated (I think it's going to be removed in v6).

    With safe mode turned on, you can't use sockets so file_get_contents() is out of use.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    Regular Coder
    Join Date
    Jan 2010
    Posts
    160
    Thanks
    10
    Thanked 1 Time in 1 Post
    Hi

    Is there anything that will work than can replace this.

    I tried this script and same thing.

    PHP Code:

    <?php
        $url  
    'http://www.google-analytics.com/urchin.jsp';
        
    $path 'urchin.jsp';
     
        
    $ch curl_init($url);
        
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
     
        
    $data curl_exec($ch);
     
        
    curl_close($ch);
     
        
    file_put_contents($path$data);
    ?>
    Thanks
    Roy

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,298
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Unfortunately if sockets are disabled on your server then nothing will work. Thats because no matter what you use, curl, file_get_contents, ftp etc all use sockets.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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