-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler.php
executable file
·44 lines (33 loc) · 1.03 KB
/
scheduler.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
<?php
$config = parse_ini_file("settings.ini", TRUE);
$file = file_get_contents($config["db"]["schedule"]);
// RESET THE OUT LIST && REMOVE OLD VACATION DAYS
$file = preg_replace('@^#(.*$)@m', '${1}', $file);
$yesterday = date("n/j",strtotime("-1 days")) . ",";
$file = preg_replace('@'.$yesterday.'@m', '', $file);
$save = file_put_contents($config["db"]["schedule"], $file);
// FIND WHO IS OUT
$row = 1;
$out = array();
if (($handle = fopen($config["db"]["schedule"], "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
// CHECK DATES
$dates = explode(",", $data[12]);
$today = date("n/j");
for ($i = 0; $i < count($dates); $i++) {
if ($dates[$i] == $today) {
$out[] = $data[0];
}
}
}
fclose($handle);
}
// MARK OUT
foreach ($out as $name) {
$name = escapeshellcmd($name);
$file = preg_replace('@(^'.$name.'.*$)@m', '#${1}', $file);
}
$save = file_put_contents($config["db"]["schedule"], $file);
?>