/
index.php
executable file
·192 lines (148 loc) · 7.99 KB
/
index.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
<?php
/*
Copyright (c) 2009 Jaromír Plhák
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
session_start('webgen');
error_reporting(E_ALL ^ E_NOTICE);
// defaultny jazyk uzivatela
$userlang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2);
// callback funkcia, ktora sa aplikuje na zdrojovy subor vygenerovanej stranky
function callback($buffer) {
return preg_replace('/%page-title%/', $GLOBALS['_page_title'], $buffer);
}
ob_start('callback');
// rozne pomocne funkcie
require_once 'functions.php';
// jazykove mutace
include_once './langs/langs.php';
// nastaveni jazyka po nacteni od uzivatele PROBLEM: language se SESSION proste nejak vytrati :-(
if (!empty($_SESSION['step_all_1']['language'])) {
$language = $_SESSION['step_all_1']['language'];
}
// jen test, co se deje, pak smazat ...
else {
$language = 'english';
}
// inicializacia krokov
if (empty($_GET['step'])) {
$_GET['step'] = '1';
$_GET['type'] = 'all';
$_SESSION['steps'] = array('1', '2', '3', '4');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs">
<head>
<title>%page-title% - WebGen - <?php echo $webgen_info[$language]; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="cs" />
<meta http-equiv="Pragma" content="no-cache" />
<?php
if (empty($_SESSION['step_all_2']['css_choice']) || $_SESSION['step_all_2']['css_choice'] != 'blind' || $_GET['step'] < 3) {
echo "<link href=\"./css/base.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />";
}
// kvuli nacitani souboru pp kdyz neni k dispozici ppedit
// puvodni $_GET['type'] ulozim do $TYPE ktere se pouzije ve zbytku index.php pro nacitani souboru J. Uhyrek
$TYPE = $_GET['type'];
// pokud probiha edtace a soubor s type ppedit neexistuje pouzije se soubor s type pp J. Uhyrek
if ($TYPE == 'ppedit' && !is_readable("./step_{$TYPE}_{$_GET['step']}.php")) {
$TYPE = 'pp';
}
// styl pre konkretny krok
if (is_readable("./css/step_{$TYPE}_{$_GET['step']}.css")) {
echo "<link href=\"./css/step_{$TYPE}_{$_GET['step']}.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />\n";
}
if (!empty($_SESSION['step_all_2']['css_choice']) && $_SESSION['step_all_2']['css_choice'] == 'glasses') {
echo "<link href=\"./css/glasses.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />\n";
}
?>
<link rel="bookmark" href="http://lsd.fi.muni.cz/webgen/" title="<?php echo $webgen_info[$language]; ?>" />
<script type="text/javascript">
<?php
// promenne ze SESSION do JS
// nejprve pridame vsem prvkum ve vzbranych polich addslashes()
$_SESSION = array_htmlspecialchars_decode(array_map_r( 'addslashes', $_SESSION));
// nahrajeme promenne do JS
getJavascriptArray($_SESSION, 'session', $result);
// vratime na puvodni hodnotu pomoci stripslashes()
$_SESSION = array_htmlspecialchars(array_map_r( 'stripslashes', $_SESSION));
// ulozim si aktualni krok, kvuli napovede
getJavascriptArray($_GET, 'get', $result);
// nacteni nekterych promluv do js promennych
getJavascriptArray($webgen_basic_info, 'webgen_basic_info', $result);
getJavascriptArray($feat_answ_next, 'feat_answ_next', $result);
getJavascriptArray($webgen_u_r_day, 'webgen_u_r_day', $result);
getJavascriptArray($webgen_u_s_project_next, 'webgen_u_s_project_next', $result);
getJavascriptArray($webgen_u_s_project_coauthor_next, 'webgen_u_s_project_coauthor_next', $result);
getJavascriptArray($webgen_firm_direction_another, 'webgen_firm_direction_another', $result);
getJavascriptArray($webgen_firm_workload_another, 'webgen_firm_workload_another', $result);
getJavascriptArray($hobby_next, 'hobby_next', $result);
getJavascriptArray($knowledge_next, 'knowledge_next', $result);
getJavascriptArray($webgen_cv_edu_from, 'webgen_cv_edu_from', $result);
getJavascriptArray($webgen_cv_lang_type, 'webgen_cv_lang_type', $result);
getJavascriptArray($webgen_links_undef_description, 'webgen_links_undef_description', $result);
echo $result;
//console.log(session);
?>
</script>
<script type="text/javascript" src="./jsc/jquery.js"></script>
<script type="text/javascript" src="./jsc/webgen.js"></script>
<?php
$_SESSION = array_map_r('stripslashes', $_SESSION );
// javascript pre konkretny krok
if (is_readable("./jsc/step_{$TYPE}_{$_GET['step']}.js")) {
echo "<script type=\"text/javascript\" src=\"./jsc/step_{$TYPE}_{$_GET['step']}.js\"></script>\n";
}
?>
</head>
<body id="webgen">
<div id="page-container">
<?php
// ak je pozadovana stranka fyzicky pritomna na disku, zobrazim prednostne ju
// v pripade, ze nie je, generujem chybu 404
if (is_readable("./step_{$TYPE}_{$_GET['step']}.php")) {
// kontrola, zda je uživatel zalogován
if (($_GET['step'] != '1' && $_GET['step'] != '2') && $_SESSION['user_loged_in'] != true) {
require_once './401.php';
exit();
}
else {
require_once "./step_{$TYPE}_{$_GET['step']}.php";
// po spracovani odoslaneho formulara je redirect na dalsi krok
if (count($_POST)) {
$next_step = $_SESSION['steps'][array_search($_GET['step'], $_SESSION['steps']) + 1];
if (!isset($next_type)) {
$next_type = $_GET['type']; // tady se necha puvodni $_GET['type'] J. Uhyrek
}
header("Location: ./index.php?step={$next_step}&type={$next_type}");
exit();
}
}
} else {
require_once './404.php';
}
?>
</div>
</body>
</html>
<?php
ob_end_flush();
?>