Last active
February 7, 2020 07:59
-
-
Save gaffling/11c405031b9f0e29a3d2a3f6df9aa842 to your computer and use it in GitHub Desktop.
[Cronjob Returns] Returns of a Script that started via cronjob and processes background tasks #php #function #cronjob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* --------------------------------------------------------------------------------------------------------------------- */ | |
/* [Cronjob Returns] Returns of a Script that started via cronjob and processes background tasks #php #function #cronjob */ | |
/* --------------------------------------------------------------------------------------------------------------------- */ | |
// ...here the work is done... (use $status for feedback to browser) | |
if(php_sapi_name() == "cli") { | |
// if it is called over console maybe its a cronjob an no answer is given | |
header("Content-Type: text/plain"); | |
// exit script | |
exit; | |
} | |
else if(!empty($_SERVER["QUERY_STRING"])) { | |
// if it is called over <img src="cron.php?img"> an 1x1 pixel gif is shown | |
header('Content-Type: image/gif'); | |
echo base64_decode('R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw'); | |
// exit script | |
exit; | |
} else{ | |
// if its startet over the browser some infos are printed | |
header('Content-type: text/html'); | |
// SHOW INFOS | |
die($staus); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment