-
Notifications
You must be signed in to change notification settings - Fork 0
/
prayer.php
147 lines (133 loc) · 3.88 KB
/
prayer.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
function __autoload($class){
$class_lower = strtolower($class);
$file = getWorkingDir().'/Tasks/'.$class.'.php';
if(file_exists($file)){
include_once $file;
} else {
$file = getWorkingDir().'/'.$class.'.php';
if (file_exists($file)){
include_once $file;
}else{
echo "Error: Can't Load: ".$class;
}
}
}
function getWorkingDir($htmlPath = false, $file = __FILE__ ){
$dir = dirname($file).'/';
if($htmlPath){
$rootLenght = strlen($_SERVER['DOCUMENT_ROOT']);
$dir = substr($dir, $rootLenght);
}
return $dir;
}
// include_once "/home2/jjprogra/public_html/pray/database.php";
// include_once "/home2/jjprogra/public_html/pray/person.php";
// include_once "/home2/jjprogra/public_html/pray/Tasks/SaintOfTheDay.php";
// include_once "/home2/jjprogra/public_html/pray/Tasks/PrayerIntension.php";
function getGET($name){
if(isset($_GET[$name]))
return $_GET[$name];
else
return null;
}
function getPOST($name){
if(isset($_POST[$name]))
return $_POST[$name];
else
return null;
}
class PrayerEng
{
// //Table Names and Task Names
// const SAINT_OF_THE_DAY = "SaintOfTheDay";
// const PRAYER_INTENSION = "PrayerIntension";
// const GOALS = "Goals";
const SCHEDULE = "Schedule";
const USERS = "Users";
// const EXAM = "Exam";
// const VIRTUE_VICE = "VirtuesAndVices";
// const DAILY_CHALLENGE = "DailyChallenge";
// const CARRIER = "vtext.com" ;
protected $database;
// protected $UsersToRun;
// protected $Number;
// protected $User;
public $UserId;
public $CurrentDate;
public $CurrentPerson;
function __construct() {
$cxnInfo = array(
"host" => "localhost",
"user" => "jjprogra_prayers",
"pass" => "JJPRO_prayers",
"db" => "jjprogra_prayers" );
$this->database = new Database();
$this->database->setCxn($cxnInfo);
// $Number = "";
// $User = "";
// $Timezone = "";
}
public function Run(){
$this->UsersToRun = $this->_LoadUsers();
//print_r($this->UsersToRun);
foreach($this->UsersToRun as $User){
$this->CurrentPerson = $User;
$tasks = $this->CurrentPerson->ScriptsToRun();
print_r($tasks);
if(getGET("test")){
$tasks[] = getGET("test");
}
if($tasks){
foreach($tasks as $task){
echo "Running: ".$task;
try{
$t = new $task();
$t->Run($this->CurrentPerson);
}catch(Exception $e){
echo "Error!: Class ".$Task." Doesn't Exsit";
}
}
}else{
echo "No task to Run!";
}
}
}
private function _LoadUsers(){
$query = "SELECT `Id` FROM `".PrayerEng::USERS."`";
if(!$this->database->runQuery($query))
return false;
if ($this->database->numRows > 0){
$results = $this->database->getResultsAssoc();
$users = array();
foreach($results as $user){
//print_r( $user);
$users[$user["Id"]] = new Person($user["Id"]);
}
return $users;
}else {
return false;
}
}
//---------------------------------------------------------------------------------------------------
// --------------------------------- TASKS ----------------------------------------------------------
//---------------------------------------------------------------------------------------------------
public function Exam(){
$msg = '<a href="jjprograms.com/pray/exam.php?='.$this->CurrentDate.'"&UserId='.$this->UserId.'>Daily Exam</a>';
$this->_sendTextMsg("Daily Exam", $msg);
}
//---------------------------------------------------------------------------------------
//----------------------------------------- Examination ---------------------------------
//---------------------------------------------------------------------------------------
public function GetVirtueAndViceList($virtue){
$query = "SELECT * FROM `".PrayerEng::VIRTUE_VICE."` WHERE `Virtue` = ".$virtue;
if(!$this->database->runQuery($query))
return false;
if ($this->database->numRows > 0){
$results = $this->database->getResultsAssoc();
return $results;
}else {
return false;
}
}
}