Prevent cron job page

Discussion in 'PHP' started by Om ji Kesharwani, Sep 5, 2011.

  1. #1
    I have created a php page having some code, it has been set to run once a day through cpanel cron job feature.How can i prevent this page from direct run through the browser? Is there any feature in cpanel or i have to write some code in php?



    Thank you
     
    Om ji Kesharwani, Sep 5, 2011 IP
  2. articlesdirectory

    articlesdirectory Greenhorn

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    18
    #2
    Make your file ip specific..
    ...
    IF(Your Server IP == '1212121212')
    -- execute your file
    ELSE
    --- no action.
     
    articlesdirectory, Sep 5, 2011 IP
  3. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for quick reply
    Let me try this.
     
    Om ji Kesharwani, Sep 5, 2011 IP
  4. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #4
    MayurGondaliya, Sep 5, 2011 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    Put the file outside the web root - browsers can't access above the root, but cron can access anything on the computer. Or you could add the file to .htaccess and deny all. Since cron jobs don't run in the web server, .htaccess doesn't affect them.
     
    Rukbat, Sep 5, 2011 IP
  6. Om ji Kesharwani

    Om ji Kesharwani Peon

    Messages:
    211
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks to all i got the solution.
     
    Om ji Kesharwani, Sep 13, 2011 IP
  7. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #7
    Rukbat's solution is the best, create a directory outside of your web root for the cron job scripts, in that way any of these files can't be executed by using a browser..
     
    JohnnySchultz, Sep 13, 2011 IP