Skip to content

Commit

Permalink
Fix #10886: Use more robust method of determining php-cgi
Browse files Browse the repository at this point in the history
Use the php_sapi_name function to check if the script is being executed
from the command line. This is more robust than checking if the server
port variable is defined by PHP.

Thanks to ha17 for this suggestion.
  • Loading branch information
davidhicks committed Aug 31, 2009
1 parent 7b794df commit 8a1f1d0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions scripts/checkin.php
Expand Up @@ -22,8 +22,7 @@
require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'core.php' );

# Make sure this script doesn't run via the webserver
/** @todo This is a hack to detect php-cgi, there must be a better way. */
if( isset( $_SERVER['SERVER_PORT'] ) ) {
if( php_sapi_name() != 'cli' ) {
echo "checkin.php is not allowed to run through the webserver.\n";
exit( 1 );
}
Expand Down
3 changes: 1 addition & 2 deletions scripts/send_emails.php
Expand Up @@ -25,8 +25,7 @@
require_once( 'email_api.php' );

# Make sure this script doesn't run via the webserver
/** @todo This is a hack to detect php-cgi, there must be a better way. */
if( isset( $_SERVER['SERVER_PORT'] ) ) {
if( php_sapi_name() != 'cli' ) {
echo "send_emails.php is not allowed to run through the webserver.\n";
exit( 1 );
}
Expand Down

0 comments on commit 8a1f1d0

Please sign in to comment.