C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$RXQR0TV\calaccess.inc.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<?
/* ©2004 Proverbs, LLC. All rights reserved. */ 

if (eregi("calaccess.inc.php"$_SERVER['PHP_SELF']))
{
    
// redirect to calendar page
    
header("Location: calendar.php");
    exit;
}

if(!
defined("CALENDAR_DATABASE")) 

    
define("CALENDAR_DATABASE"TRUE); 

    require(
'db_mysql.inc.php');
    require(
'setup.inc.php');

    class 
caldbaccess extends DB_Sql
    
{
        
// - host & database info
        
var $Host;
        var 
$Database;
        var 
$User;
        var 
$Password;

        
// - table names - used to avoid having to change a tablename in multiple places
        
var $tbl_bydate                     'calendardate';
        var 
$tbl_recurring                 'calendarday';
        var 
$tbl_users                     'calendarusers';

        
// Constructor
        
function caldbaccess()
        {
            require(
'config.inc.php');
            
$config = new cal_config;

            
$this->Host            $config->databasehost;
            
$this->Database    $config->databasename;
            
$this->User            $config->databaseuser;
            
$this->Password    $config->databasepassword;
        }

        function 
TableName($var)
        {
            return 
$this->$var;
        }

        function 
RemoveJunkTags($oldtext)
        {
            
// create the setup object
            
$conf = new layout_setup;
            
$retvalue str_replace("'""`"str_replace('"'''str_replace('\\'''strip_tags($oldtext$conf->allowed_html_tags))));
            return 
$retvalue;
        }

        function 
CheckForEvents($checkday$checkmonth$checkyear)
        {
            
$a $this->tbl_bydate;
            
$b $this->tbl_recurring;

            
$startofday gmmktime(000$checkmonth$checkday$checkyear);
            
$endofday gmmktime(235959$checkmonth$checkday$checkyear);
            
$mstartofday gmmktime(0007$checkday1971);
            
$mendofday gmmktime(2359597$checkday1971);
            
$ystartofday gmmktime(000$checkmonth$checkday1972);
            
$yendofday gmmktime(235959$checkmonth$checkday1972);

            
$dayofweek gmdate("w"$startofday);
            
$weeknumber intval($checkday 7.1) + 1;

            
$query  "SELECT COUNT(*) FROM $a WHERE ($a.event_date >= $startofday AND $a.event_date <= $endofday) OR ";
            
$query .= "($a.event_date >= $mstartofday AND $a.event_date <= $mendofday) OR ";
            
$query .= "($a.event_date >= $ystartofday AND $a.event_date <= $yendofday)";

            
$arr $this->getrows($query);

            
$hasid 0;
            if (isset(
$arr[0]['COUNT(*)'] ))
                
$hasid $arr[0]['COUNT(*)'] ;

            if (
$hasid 0)
                return 
TRUE;

            
$query  "SELECT COUNT(*) FROM $b WHERE ($b.weekday = $dayofweek AND ($b.month = $checkmonth OR $b.month = 0) AND ";
            
$query .= "($b.period = $weeknumber OR $b.period = 0))";

            
$arr $this->getrows($query);

            
$hasid 0;
            if (isset(
$arr[0]['COUNT(*)'] ))
                
$hasid $arr[0]['COUNT(*)'] ;

            if (
$hasid 0)
                return 
TRUE;
            return 
FALSE;
        }

        function 
GetCalendarDateEvents($checkday$checkmonth$checkyear)
        {
            
$a $this->tbl_bydate;

            
$startofday gmmktime(000$checkmonth$checkday$checkyear);
            
$endofday gmmktime(235959$checkmonth$checkday$checkyear);
            
$mstartofday gmmktime(0007$checkday1971);
            
$mendofday gmmktime(2359597$checkday1971);
            
$ystartofday gmmktime(000$checkmonth$checkday1972);
            
$yendofday gmmktime(235959$checkmonth$checkday1972);

            
$query  "SELECT short_description FROM $a WHERE (event_date >= $startofday AND event_date <= $endofday) OR ";
            
$query .= "(event_date >= $mstartofday AND event_date <= $mendofday) OR ";
            
$query .= "(event_date >= $ystartofday AND event_date <= $yendofday) ORDER BY event_date";

            
$this->query($query);
            return 
$this->affected_rows();
        }

        function 
GetCalendarDayEvents($checkday$checkmonth$checkyear)
        {
            
$a $this->tbl_recurring;

            
$dayofweek gmdate("w"gmmktime(000$checkmonth$checkday$checkyear));
            
$weeknumber intval($checkday 7.1) + 1;

            
$query  "SELECT short_description FROM $a WHERE weekday = $dayofweek AND ";
            
$query .= "(month = $checkmonth OR month = 0) AND (period = $weeknumber OR period = 0) ORDER BY event_time";

            
$this->query($query);
            return 
$this->affected_rows();
        }

        function 
GetScheduleDateEvents($checkday$checkmonth$checkyear)
        {
            
$a $this->tbl_bydate;

            
$startofday gmmktime(000$checkmonth$checkday$checkyear);
            
$endofday gmmktime(235959$checkmonth$checkday$checkyear);
            
$mstartofday gmmktime(0007$checkday1971);
            
$mendofday gmmktime(2359597$checkday1971);
            
$ystartofday gmmktime(000$checkmonth$checkday1972);
            
$yendofday gmmktime(235959$checkmonth$checkday1972);

            
$query  "SELECT event_date, duration, short_description, long_description FROM $a WHERE ";
            
$query .= "(event_date >= $startofday AND event_date <= $endofday) OR ";
            
$query .= "(event_date >= $mstartofday AND event_date <= $mendofday) OR ";
            
$query .= "(event_date >= $ystartofday AND event_date <= $yendofday) ORDER BY event_date";

            
$this->query($query);
            return 
$this->affected_rows();
        }

        function 
GetScheduleDayEvents($checkday$checkmonth$checkyear)
        {
            
$a $this->tbl_recurring;

            
$dayofweek gmdate("w"gmmktime(000$checkmonth$checkday$checkyear));
            
$weeknumber intval($checkday 7.1) + 1;

            
$query  "SELECT event_time, duration, short_description, long_description FROM $a WHERE weekday = $dayofweek ";
            
$query .= "AND (month = $checkmonth OR month = 0) AND (period = $weeknumber OR period = 0) ORDER BY event_time";

            
$this->query($query);
            return 
$this->affected_rows();
        }

        function 
GetBetweenDates($startdate$enddate)
        {
            
$a $this->tbl_bydate;

            
$sday gmdate("j"$startdate);
            
$eday gmdate("j"$enddate);
            
$smonth gmdate("n"$startdate);
            
$emonth gmdate("n"$enddate);
            
$mdiff $emonth $smonth + ((gmdate("Y"$enddate) - gmdate("Y"$startdate)) * 12);
            if (
$mdiff != 0)
            {
                
$sday 1;
                
$eday 31;
                if (
$mdiff 11)
                {
                    
$smonth 1;
                    
$emonth 12;
                }
                else
                {
                    while (!
checkdate($emonth$eday1972) && $eday 28)
                    {
                        
$emonth--;
                    }
                }
            }

            
$mstartofday gmmktime(0007$sday1971);
            
$mendofday gmmktime(2359597$eday1971);
            
$ystartofday gmmktime(000$smonth$sday1972);
            
$yendofday gmmktime(235959$emonth$eday1972);

            
$query  "SELECT * FROM $a WHERE ";
            
$query .= "(event_date >= $startdate AND event_date <= $enddate) OR ";
            
$query .= "(event_date >= $mstartofday AND event_date <= $mendofday) OR ";
            
$query .= "(event_date >= $ystartofday AND event_date <= $yendofday) ORDER BY event_date";

            
$this->query($query);
            return 
$this->affected_rows();
        }

        function 
GetAllRecurring()
        {
            
$a $this->tbl_recurring;
            
$query "SELECT * FROM $a";
            
$this->query($query);
            return 
$this->affected_rows();
        }

        function 
GetSelfBetweenDates($userid$startdate$enddate)
        {
            
$a $this->tbl_bydate;

            
$sday gmdate("j"$startdate);
            
$eday gmdate("j"$enddate);
            
$smonth gmdate("n"$startdate);
            
$emonth gmdate("n"$enddate);
            
$mdiff $emonth $smonth + ((gmdate("Y"$enddate) - gmdate("Y"$startdate)) * 12);
            if (
$mdiff != 0)
            {
                
$sday 1;
                
$eday 31;
                if (
$mdiff 11)
                {
                    
$smonth 1;
                    
$emonth 12;
                }
                else
                {
                    while (!
checkdate($emonth$eday1972) && $eday 28)
                    {
                        
$emonth--;
                    }
                }
            }

            
$mstartofday gmmktime(0007$sday1971);
            
$mendofday gmmktime(2359597$eday1971);
            
$ystartofday gmmktime(000$smonth$sday1972);
            
$yendofday gmmktime(235959$emonth$eday1972);

            
$query  "SELECT * FROM $a WHERE userid = '$userid' AND ";
            
$query .= "(event_date >= $startdate AND event_date <= $enddate) OR ";
            
$query .= "(event_date >= $mstartofday AND event_date <= $mendofday) OR ";
            
$query .= "(event_date >= $ystartofday AND event_date <= $yendofday) ORDER BY event_date";

            
$this->query($query);
            return 
$this->affected_rows();
        }

        function 
GetSelfRecurring($userid)
        {
            
$a $this->tbl_recurring;
            
$query "SELECT * FROM $a WHERE userid = '$userid'";
            
$this->query($query);
            return 
$this->affected_rows();
        }

        function 
AddByDate($evdate$title$detail$duration$userid)
        {
            
$a $this->tbl_bydate;
            
$title $this->RemoveJunkTags($title);
            
$detail $this->RemoveJunkTags($detail);
            
$query  "INSERT INTO $a (event_date, short_description, long_description, duration, userid) ";
            
$query .= "VALUES ($evdate, '$title', '$detail', $duration, '$userid')";
            return 
$this->query($query);
        }

        function 
AddRecurring($weekday$evtime$period$month$title$detail$duration$userid)
        {
            
$a $this->tbl_recurring;
            
$title $this->RemoveJunkTags($title);
            
$detail $this->RemoveJunkTags($detail);
            
$query  "INSERT INTO $a (weekday, event_time, period, month, short_description, long_description, duration, userid) ";
            
$query .= "VALUES ($weekday, '$evtime', $period$month, '$title', '$detail', $duration, '$userid')";
            return 
$this->query($query);
        }

        function 
DeleteDateEvent($id)
        {
            
$a $this->tbl_bydate;
            
$query "DELETE FROM $a WHERE id=$id";
            
$this->query($query);
        }

        function 
DeleteDayEvent($id)
        {
            
$a $this->tbl_recurring;
            
$query "DELETE FROM $a WHERE id=$id";
            
$this->query($query);
        }

        function 
SQLLogin($userid$password)
        {
            
$a $this->tbl_users;
            
$userid $this->RemoveJunkTags($userid);
            
$password $this->RemoveJunkTags($password);
            
$query "SELECT userid, level FROM $a WHERE userid='$userid' AND password='$password'";

            
$arr = Array();
            
$arr $this->getrows($query);
            if (isset(
$arr[0]))
                
$retuser $arr[0];
            else
                
$retuser false;

            return 
$retuser;
        }

        function 
GetUserData($userid)
        {
            
$a $this->tbl_users;
            
$userid $this->RemoveJunkTags($userid);
            
$query "SELECT userid, level FROM $a WHERE userid='$userid'";

            
$arr = Array();
            
$arr $this->getrows($query);
            if (isset(
$arr[0]))
                
$retuser $arr[0];
            else
                
$retuser false;

            return 
$retuser;
        }

        function 
GetAllUsers()
        {
            
$a $this->tbl_users;
            
$query "SELECT userid, level FROM $a";
            
$this->query($query);
            return 
$this->affected_rows();
        }

        function 
AddNewUser($accountid$accesslevel$accountpassword)
        {
            
$a $this->tbl_users;
            
$accountid $this->RemoveJunkTags($accountid);

            if (!
$accountpassword)
                
$query "INSERT INTO $a (userid, level) VALUES ('$accountid', $accesslevel)";
            else
            {
                
$accountpassword $this->RemoveJunkTags($accountpassword);
                
$query "INSERT INTO $a (userid, password, level) VALUES ('$accountid', '$accountpassword', $accesslevel)";
            }
            return 
$this->query($query);
        }

        function 
UpdateUser($accountid$existingid$accesslevel$accountpassword)
        {
            
$a $this->tbl_users;
            
$accountid $this->RemoveJunkTags($accountid);
            
$existingid $this->RemoveJunkTags($existingid);

            if (!
$accountpassword)
                
$query "UPDATE $a SET userid='$accountid', level=$accesslevel WHERE userid='$existingid'";
            else
            {
                
$accountpassword $this->RemoveJunkTags($accountpassword);
                
$query "UPDATE $a SET userid='$accountid', password='$accountpassword', level=$accesslevel WHERE userid='$existingid'";
            }
            
$this->query($query);
        }

        function 
DeleteUser($accountid)
        {
            
$a $this->tbl_users;
            
$accountid $this->RemoveJunkTags($accountid);

            
$query "DELETE FROM $a WHERE userid='$accountid'";
            
$this->query($query);
        }
    }
}
?>