-
Notifications
You must be signed in to change notification settings - Fork 0
/
e.php
executable file
·133 lines (110 loc) · 3.45 KB
/
e.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
<?php
//------------------------------------------------------------------------------
/// Filename: e.php
/// Description: Examfilter edit event file
/// Authors: Tommy Sparber
///
/// Created: 14.10.2012
//------------------------------------------------------------------------------
error_reporting(E_ALL|E_STRICT);
require_once('./classes/template.class.php');
require_once('./classes/tools.class.php');
require_once('./classes/form.class.php');
require_once('./classes/caltools.class.php');
main();
//------------------------------------------------------------------------------
function main()
{
$template = new Template();
$template->setTitle("ExamFilter - TUGRAZ");
$ids = CalTools::loadIds();
$id = $_GET['id'];
$eid = intval(isset($_GET['eid'])?$_GET['eid']:0);
if(!in_array($id, $ids))
{
header('HTTP/1.0 403 Forbidden');
$template->addContent('403 Forbidden');
}
else
{
$data = CalTools::getData();
$events = CalTools::parseCalendar($data);
$sevent = 0;
foreach($events as $key => $event)
{
$match = array();
if(preg_match('/^https:\/\/online.tugraz.at\/tug_online\/wbregisterexam\.lv_termine\?cstp_sp_nr=([0-9]+)&cheader=J&pLvGroupFlag=J$/', $event['URL'], $match))
{
if($eid == $match[1])
{
$sevent = $event;
break;
}
}
}
$form = new Form('filter');
$ignore = file("./storage/cal_$id.txt", FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
if($sevent != 0)
{
$template->addContent('<h2>'.$sevent['SUMMARY'].'</h2>');
$form->addSubmit('submit_filter', 'Diese LV filtern');
$form->addSubmit('submit_register', 'Zur Prüfungsanmeldung');
}
buildSelect($ignore, $form);
$form->addSubmit('submit_rem_filter', 'Filter löschen');
if($form->isReady())
{
$fields = $form->getFields();
if(isset($fields['submit_register']) && $fields['submit_register']['clicked'] != 0)
{
header("Location: https://online.tugraz.at/tug_online/wbregisterexam.lv_termine?cstp_sp_nr=$eid&cheader=J&pLvGroupFlag=J", true, 303);
exit;
}
else if(isset($fields['submit_filter']) && $fields['submit_filter']['clicked'] != 0)
{
if(!in_array(trim($sevent['SUMMARY']), $ignore))
{
$ignore[] = trim($sevent['SUMMARY']);
}
Tools::arrayToFile($ignore, $id);
buildSelect($ignore, $form);
$template->addMsg('ok', 'LV eingetragen');
$template->addContent($form->getFormHTML());
}
else if($fields['submit_rem_filter']['clicked'] != 0)
{
if($fields['rem_filter']['value'] != '-')
{
foreach($ignore as $key => $value)
{
if($value == $fields['rem_filter']['value'])
{
$template->addMsg('ok', 'LV ausgetragen');
unset($ignore[$key]);
break;
}
}
Tools::arrayToFile($ignore, $id);
}
buildSelect($ignore, $form);
$template->addContent($form->getFormHTML());
}
}
else
{
$template->addContent($form->getFormHTML());
}
}
print $template->out();
}
function buildSelect($ignore, $form)
{
$options = array();
$options[] = array('desc' => '-', 'value' => '-');
foreach($ignore as $line)
{
$options[] = array('desc' => $line, 'value' => $line);
}
$form->addSelect('rem_filter', 'Filter löschen: ', $options, '-', false);
}
?>