-
Notifications
You must be signed in to change notification settings - Fork 0
/
cron.php
54 lines (48 loc) · 1.22 KB
/
cron.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Cron file
* The aim of this file is to send automatically mails on regular time
* and perform other regular tasks
*
* @author Pierre HUBERT
*/
/**
* Initializate the page
*/
require(__DIR__."/system/init.inc.php");
/**
* Security - Opening this file from a browser is prohibited
*/
if(isset($_SERVER['HTTP_HOST'])){
//The error code is the unique indication we'll give to user
http_response_code(401);
//But we log the error
$amss->log->logMessage(__FILE__, "ACCESS DENIED - Trying to run cron job from a browser !");
//Now we quit script
exit();
}
/**
* Try to send a mail
*/
if(!$amss->mails->isThereMailToSend()){
//There isn't any mail to be sent
$amss->log->logMessage(__FILE__, "There isn't any mail to send.");
}
elseif($amss->mails->sendAmail()){
//A mail was sent
$amss->log->logMessage(__FILE__, "A mail was sent.");
}
else {
//An error happened
$amss->log->logMessage(__FILE__, "ERROR - An error occurred while trying to send a mail !");
}
/**
* Clean logs
*/
if(!$amss->log->clean()){
//Couldn't clean logs
$amss->log->logMessage(__FILE__, "ERROR - Couldn't clean log folder.");
}
else{
$amss->log->logMessage(__FILE__, "Log folder was cleaned.");
}