Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
fix(docker): Check for cli execution with php_sapi_name since
Browse files Browse the repository at this point in the history
we won't have all the environment variables loaded

Signed-off-by: Francisco Miguel Biete <[email protected]>
  • Loading branch information
Francisco Miguel Biete committed Apr 2, 2015
1 parent 79fff50 commit ee57662
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions backend/zarafa/listfolders.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ function main() {

function listfolders_configure() {

if (!isset($_SERVER["TERM"]) || !isset($_SERVER["LOGNAME"])) {
echo "This script should not be called in a browser.\n";
if (php_sapi_name() != "cli") {
printf("This script should not be called in a browser. Called from: %s\n", php_sapi_name());
exit(1);
}

Expand Down Expand Up @@ -181,4 +181,4 @@ function listfolders_getlist ($adminStore, $session, $user) {
}
}

?>
?>
6 changes: 3 additions & 3 deletions tools/migrate-2.0.x-2.1.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
* MAIN
*/
try {
if (!isset($_SERVER["TERM"]) || !isset($_SERVER["LOGNAME"]))
die("This script should not be called in a browser.");
if (php_sapi_name() != "cli")
die(sprintf("This script should not be called in a browser. Called from: %s", php_sapi_name()));

if (!defined('ZPUSH_BASE_PATH') || !file_exists(ZPUSH_BASE_PATH . "/config.php"))
die("ZPUSH_BASE_PATH not set correctly or no config.php file found\n");
Expand Down Expand Up @@ -214,4 +214,4 @@ public function DoMigration() {
}
}

?>
?>
6 changes: 3 additions & 3 deletions z-push-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ static public function UsageInstructions() {
* @access public
*/
static public function CheckEnv() {
if (!isset($_SERVER["TERM"]) || !isset($_SERVER["LOGNAME"]))
self::$errormessage = "This script should not be called in a browser.";
if (php_sapi_name() != "cli")
self::$errormessage = sprintf("This script should not be called in a browser. Called from: %s", php_sapi_name());

if (!function_exists("getopt"))
self::$errormessage = "PHP Function getopt not found. Please check your PHP version and settings.";
Expand Down Expand Up @@ -903,4 +903,4 @@ static private function printDeviceData($deviceId, $user) {
}


?>
?>

This comment has been minimized.

Copy link
@gmta

gmta Apr 8, 2015

Contributor

Instead of adding a newline at the end of PHP source files, it is generally accepted to just leave off the closing "?>" tag - also leaving the file to end with a newline

1 comment on commit ee57662

@fmbiete
Copy link
Owner

@fmbiete fmbiete commented on ee57662 Apr 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. The echampet branch (soon to be merged into master) removes all the closing "?>" tags, and cleans the ending newlines.
This will remove some bizarre errors about headers being sent already.

Please sign in to comment.