-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·56 lines (46 loc) · 1.44 KB
/
functions.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
55
56
<?php
require_once('globals.php');
function sendMsg($toAddress,$msgFile) {
$msgText = file_get_contents($msgFile)."\r\n\r\n";
$msgText = $msgText."= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ="."\r\n\r\n";
if (file_exists(globals::footerFile)) {
$msgText = $msgText.file_get_contents(globals::footerFile)."\r\n\r\n";
};
$msgText = $msgText.globals::webPath.'/checkin.php?token='.getToken()."\r\n\r\n";
$subject = globals::subjectPrefix.basename($msgFile);
$fromAddress = 'From: '.globals::mailFrom;
mail($toAddress,$subject,$msgText,$fromAddress);
};
function getDay() {
if (file_exists(globals::dataFile)) {
$dataFile=file(globals::dataFile);
$dayNum=$dataFile[0];
} else {
$dayNum = 0;
};
return (intval($dayNum,10)+1);
};
function writeDay($dayNum) {
$fp=fopen(globals::dataFile,"w");
fputs($fp,$dayNum);
fclose($fp);
};
function getToken() {
if (file_exists(globals::tokenFile)) {
$token=file(globals::tokenFile);
} else {
$token[0]=0;
};
return(intval($token[0],10));
};
function randomizeToken() {
$fp=fopen(globals::tokenFile,'w');
fputs($fp,rand(1048576,134217728));
fclose($fp);
};
function resetDayNum() {
$fp=fopen(globals::dataFile,'w');
fputs($fp,'0');
fclose($fp);
};
?>