Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7705747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:56:19+00:00 2026-05-31T23:56:19+00:00

I realize there are similar posts to this out there, but rest assured, this

  • 0

I realize there are similar posts to this out there, but rest assured, this isn’t a duplicate post!

I have a site on a godaddy server. I DO NOT have access to the outside of the root of my server (everything is public).

I have a file delete.php that needs to run on CRON, and only by CRON. The file should not execute manually at all by anyone for any reason.

Given the above, I am trying to secure my file as much as possible so let’smake this an experiment in security.

So far, I have the following with the goal of making the file as secure as possible:

<?php
$isCLI = ( php_sapi_name() == 'cli' );

if (!$isCLI) {
    die("cannot run!");
} else {
    if(!isset($_SERVER['REQUEST_METHOD'])){
        // Do the task here
    }else{
        die("cannot run!");
    }
}
?>

So, is this logically secure? How can it be made even more secure? godaddy can only allow me to set a date/time to run a file, nothing more.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:56:20+00:00Added an answer on May 31, 2026 at 11:56 pm

    Checking for the cli SAPI is sufficient; a user executing it via apache (be it mod_php or fastcgi or cgi) will never cause PHP to be called through the CLI sapi. You can get rid of the ugly else {} around your real code though; if you exit; at the end of the then block there is no need for an else block.

    However, not putting that kind of script in the document root at all would be much cleaner. If that’s not possible, also consider using .htaccess:

    Order deny,allow
    Deny from all
    

    If the files are in a folder which shouldn’t be locked down completely, wrap those lines in <Files whatever.php>...</Files>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize there are many questions similar to mine on this site, but because
I realize there are similar questions on this topic, but I still cannot find
I realize there are similar questions out there, but I am at a loss.
I realize that there are other posts asking similar questions, but do not quite
I realize there is a similar question to this, but it really has no
I realize that there was a similar question asked here , but this is
I realize that there are many similar questions, but most involve scaling down the
I realize there are tonnes of similar questions already up here but I cannot
I realize there are a lot of similar questions as this one , however
I know there a similar threads around, but this is really the first time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.