-
Notifications
You must be signed in to change notification settings - Fork 1
/
university.php
181 lines (128 loc) · 5.61 KB
/
university.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
<?php
require './classes/System.class.php';
require './classes/Session.class.php';
require './classes/Player.class.php';
require './classes/PC.class.php';
$session = new Session();
$system = new System();
$sub = 'University';
require 'template/contentStart.php';
$software = new SoftwareVPC();
$research = 'active';
$cert = '';
$center = '';
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST)){
$software->handlePost('university');
}
// Check for 'opt' GET parameter
if ($system->issetGet('opt')) {
$optInfo = $system->verifyStringGet('opt');
if ($optInfo['IS_NUMERIC'] == 1 || $optInfo['GET_VALUE'] != 'certification') {
$system->handleError('Invalid get.', 'university.php');
}
$research = '';
$cert = 'active';
$center = ' center';
}
// Check for 'learn' GET parameter
if ($system->issetGet('learn')) {
// Handle page for learning certification
$center = '';
}
?>
<!-- Start HTML structure -->
<div class="span12<?php echo $center; ?>">
<?php
// Display session message if set
if ($session->issetMsg()) {
$session->returnMsg();
}
?>
<!-- Widget box for certification content -->
<div class="widget-box">
<div class="widget-title">
<ul class="nav nav-tabs">
<li class="link <?php echo $research; ?>"><a href="university.php"><span class="icon-tab he16-research"></span><span class="hide-phone"><?php echo _("Research softwares"); ?></span></a></li>
<li class="link <?php echo $cert; ?>"><a href="university?opt=certification"><span class="icon-tab he16-certs"></span><span class="hide-phone"><?php echo _("Certifications"); ?></span></a></li>
<a href="<?php echo $session->help('university', 'research'); ?>"><span class="label label-info"><?php echo _("Help"); ?></span></a>
</ul>
</div>
<div class="cert-complete"></div>
<div class="widget-content padding noborder">
<?php
if($system->issetGet('opt')){
if($system->issetGet('learn')){
$player = new Player();
$ranking = new Ranking();
$learnInfo = $system->verifyNumericGet('learn');
if($learnInfo['IS_NUMERIC'] == 0 || $learnInfo['GET_VALUE'] < 1 || $learnInfo['GET_VALUE'] > 5){
$system->handleError('Invalid certification.', 'university?opt=certification');
}
$playerLearning = $player->playerLearning();
if($playerLearning == 0){
$system->handleError('You are not learning any certification. Did you bought it?', 'university?opt=certification');
}
if($playerLearning != $learnInfo['GET_VALUE']){
$system->handleError('You are busy learning this certification.', 'university?opt=certification&learn='.$playerLearning);
}
if(!$ranking->cert_validate2learn($learnInfo['GET_VALUE'])){
$system->handleError('Some error happened.', 'university?opt=certification');
}
if($system->issetGet('page')){
$pageInfo = $system->verifyNumericGet('page');
if($pageInfo['IS_NUMERIC'] == 0){
$system->handleError('Invalid page number.', 'university?opt=certification&learn='.$learnInfo['GET_VALUE']);
}
if($pageInfo['GET_VALUE'] > $ranking->cert_totalPages($learnInfo['GET_VALUE']) || $pageInfo['GET_VALUE'] < 1){
$system->handleError('Invalid page number.', 'university?opt=certification&learn='.$learnInfo['GET_VALUE']);
}
$page = $pageInfo['GET_VALUE'];
} else {
$page = 0;
}
$ranking->cert_showPage($learnInfo['GET_VALUE'], $page);
} elseif($system->issetGet('complete')){
$player = new Player();
$completeInfo = $system->verifyStringGet('complete');
$playerLearning = $player->playerLearning();
if($playerLearning == 0){
$system->handleError('You are not learning any certification. Did you bought it?', 'university?opt=certification');
}
if(strlen($completeInfo['GET_VALUE']) != '32'){
$system->handleError('Invalid page.', 'university?opt=certification');
}
if(md5('cert'.$playerLearning.$_SESSION['id']) != $completeInfo['GET_VALUE']){
$system->handleError('You are busy learning this certification.', 'university?opt=certification&learn='.$playerLearning);
}
if(!$ranking->cert_validate2learn($playerLearning)){
$system->handleError('Some error happened.', 'university?opt=certification');
}
$ranking->cert_add($playerLearning);
$ranking->cert_end($playerLearning);
$player->unsetPlayerLearning();
if($playerLearning == 1){
$player->setPlayerLearning(2);
}
header("Location:university?opt=certification");
exit();
} else {
$ranking->cert_list();
}
} elseif($system->issetGet('id')) {
$idInfo = $system->verifyNumericGet('id');
if($idInfo['IS_NUMERIC'] == 0 || $idInfo['GET_VALUE'] < 0){
$system->handleError('Invalid get', 'university.php');
}
if(!$software->issetSoftware($idInfo['GET_VALUE'], $_SESSION['id'], 'VPC')) {
$system->handleError('This software does not exists.', 'university.php');
}
$software->research_show($idInfo['GET_VALUE']);
} else {
$software->research_list();
}
?>
</div>
<div style="clear: both;" class="nav nav-tabs"> </div>
<?php
require 'template/contentEnd.php';
?>