/
step_gall_7.php
executable file
·255 lines (178 loc) · 11.5 KB
/
step_gall_7.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
<?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.
*/
$_page_title = $step_desc[$language]." ".(array_search($_GET['step'], $_SESSION['steps'])+1)." - ".$webgen_showhtml_title[$language];
// spracovanie formulara
if (count($_POST)) {
// sem spracovanie/osetrenie prislich premennych
$_SESSION['step_gall_7'] = array();
foreach ($_POST as $key => $value) {
$_SESSION['step_gall_7']["$key"] = $value;
}
$r = "/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/";
if ($_SESSION['step_gall_7']['send_choice'] == 'd') {
$url = getUrl($_SESSION['step_all_2']['user_name'], $_SESSION['step_all_4']['presentation_name'], $fname);
header("Location: {$url}");
exit();
} elseif (strlen($_SESSION['step_gall_7']['email_send_data']) == 0 || !preg_match($r, $_SESSION['step_gall_7']['email_send_data'])) {
$next_step = $_GET['step'];
$next_type = $_GET['type'];
header("Location: ./index.php?step={$next_step}&type={$next_type}");
exit();
}
}
echo "<h1>".$webgen_showhtml_title[$language]."</h1>";
$r = "/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/";
if (isset($_SESSION['step_gall_7']['email_send_data']) && $_SESSION['step_gall_7']['send_choice'] != "d") {
if (strlen($_SESSION['step_gall_7']['email_send_data']) == 0) {
echo "<h2 class=\"error\">".$webgen_contact_email_empty[$language]."</h2>";
} elseif (!preg_match($r, $_SESSION['step_gall_7']['email_send_data'])) {
echo "<h2 class=\"error\">".$webgen_contact_email_invalid[$language]."</h2>";
}
}
?>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
<?php
// **********************************************
// ************ GENEROVANI XML ******************
// **********************************************
$dirname = "./presentations/".$_SESSION['step_all_2']['user_name']."/".$_SESSION['step_all_4']['presentation_name'];
$fname = $dirname."/".$_SESSION['step_all_4']['presentation_name'].".xml";
umask(0000);
if (!file_exists("./presentations/".$_SESSION['step_all_2']['user_name'])) {
mkdir("./presentations/".$_SESSION['step_all_2']['user_name'], 0777);
}
if (!file_exists($dirname)) {
mkdir($dirname, 0777);
}
if (!file_exists($dirname."/img")) {
mkdir($dirname."/img", 0777);
}
$file=fopen($fname,"w");
fwrite($file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?".">\n");
fwrite($file, "<presentation lastModified=\"".date("d. m. Y")."\" author=\"".$_SESSION['step_all_2']['user_name']."\" presentationName=\"".$_SESSION['step_all_4']['presentation_name']."\" presentationType=\"gall\" xsi:noNamespaceSchemaLocation=\"c:\web\WWW\local\xml\scheme\webgen.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n");
fwrite($file, "\t<style>\n");
fwrite($file, "\t\t<language>".$language."</language>\n");
fwrite($file, "\t\t<css>".$_SESSION['step_gall_6']['css_choice'].".css</css>\n");
fwrite($file, "\t\t<xsl>gall.xslt</xsl>\n");
fwrite($file, "\t</style>\n\n");
fwrite($file, "\t<galleryData>\n");
fwrite($file, "\t\t<name>".$_SESSION['step_gall_5']['gall_name_data']."</name>\n");
fwrite($file, "\t\t<person>\n");
fwrite($file, "\t\t\t<fullName>".$_SESSION['step_gall_5']['user_name_data']."</fullName>\n");
fwrite($file, "\t\t</person>\n");
fwrite($file, "\t\t<collections>\n");
fwrite($file, "\t\t\t<collection>\n");
fwrite($file, "\t\t\t\t<title>".correctOutput($_SESSION['step_gall_5']['gall_name_data'])."</title>\n");
fwrite($file, "\t\t\t\t<rowPhotos>".correctOutput($_SESSION['step_gall_5']['gall_photo_count_row'][$pom])."</rowPhotos>\n");
fwrite($file, "\t\t\t\t<date>".date("d. m. Y")."</date>\n");
fwrite($file, "\t\t\t\t<photos>\n");
$pom = 0;
while (!empty($_SESSION['step_gall_5']['gall_photo_alt_data'][$pom])) {
if ($_SESSION['step_gall_5']['gall_photo_type_data'] == "a") {
fwrite($file, "\t\t\t\t\t<photo>\n");
fwrite($file, "\t\t\t\t\t\t<url>".correctOutput(addHttp($_SESSION['step_gall_5']['gall_photo_src_data'][$pom]))."</url>\n");
fwrite($file, "\t\t\t\t\t\t<alt>".correctOutput($_SESSION['step_gall_5']['gall_photo_alt_data'][$pom])."</alt>\n");
fwrite($file, "\t\t\t\t\t</photo>\n");
}
else {
}
$pom++;
}
fwrite($file, "\t\t\t\t</photos>\n");
fwrite($file, "\t\t\t</collection>\n");
fwrite($file, "\t\t</collections>\n");
fwrite($file, "\t</galleryData>\n");
fwrite($file, "</presentation>\n");
fclose($file);
chmod($fname, 0777);
// ***************** KOPIROVANI SOUBORU ************************************
// ikonky informujici o validite stranky
copy("./icons/xhtml.png", $dirname."/img/xhtml.png");
chmod($dirname."/img/xhtml.png", 0777);
copy("./icons/css.png", $dirname."/img/css.png");
chmod($dirname."/img/css.png", 0777);
// ********************* gall1 *************************************************
if ($_SESSION['step_gall_6']['css_choice'] == "gall1") {
copy("./themes/gall1/style.css", $dirname."/gall1.css");
chmod($dirname."/gall1.css", 0777);
copy("./themes/gall1/img/xbg.gif", $dirname."/img/xbg.gif");
chmod($dirname."/img/xbg.gif", 0777);
}
// ********************* gall2 **************************************************
//else if ($_SESSION['step_gall_6']['css_choice'] == "gall2") {
// copy("./themes/gall2/style.css", $dirname."/gall2.css");
// chmod($dirname."/gall2.css", 0777);
//copy("./themes/gall2/img/bar.gif", $dirname."/img/bar.gif");
//chmod($dirname."/img/bar.gif", 0777);
//}
// ******************* PROVEDENI XSL TRANSFORMACE HLAVNI STRANKA ********************************
// naètení dokumentu XML
$xml = new DomDocument();
$xml->load($fname);
// naètení stylu XSLT dle vybraneho jazyka
$xsl = new DomDocument();
if ('czech' == $_SESSION['step_all_1']['language']) {
$xsl->load("./xml/xslt/gall_cz.xsl");
} else {
$xsl->load("./xml/xslt/gall_en.xsl");
}
// vytvoøení procesoru XSLT
$proc = new xsltprocessor();
$proc->registerPhpFunctions();
$proc->importStylesheet($xsl);
// provedení transformace a vypsání výsledku
$newdom = $proc->transformToDoc($xml);
$newdom->save($dirname."/".$_SESSION['step_all_4']['presentation_name'].".php");
deleteXmlHeading($dirname."/".$_SESSION['step_all_4']['presentation_name'].".php");
chmod($dirname."/".$_SESSION['step_all_4']['presentation_name'].".php", 0744);
// ***************** ZJISTI URL VYSLEDNE STRANKY ****************************************************
$url = getUrl($_SESSION['step_all_2']['user_name'], $_SESSION['step_all_4']['presentation_name'], $fname);
$_SESSION['step_gall_7']['page_url'] = $url;
?>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
<ul class="clear">
<li>
<label>
<?php echo $webgen_showhtml_choice[$language].":"; ?>
<select name="send_choice" onkeyup="analyze_send_choice(this, '<?php echo $webgen_showhtml_link_valid[$language]; ?>', '<?php echo $webgen_showhtml_button[$language]; ?>', '<?php echo $webgen_send_to_button[$language]; ?>')" onclick="analyze_send_choice(this, '<?php echo $webgen_showhtml_link_valid[$language]; ?>', '<?php echo $webgen_showhtml_button[$language]; ?>', '<?php echo $webgen_send_to_button[$language]; ?>')" >
<option value="a" <?php if ($_SESSION['step_gall_7']['send_choice'] == 'a') { echo "selected=\"selected\""; } ?> ><?php echo $webgen_showhtml_choice_a[$language]; ?></option>
<option value="b" <?php if ($_SESSION['step_gall_7']['send_choice'] == 'b') { echo "selected=\"selected\""; } ?> ><?php echo $webgen_showhtml_choice_b[$language]; ?></option>
<option value="c" <?php if ($_SESSION['step_gall_7']['send_choice'] == 'c') { echo "selected=\"selected\""; } ?> ><?php echo $webgen_showhtml_choice_c[$language]; ?></option>
<option value="d" <?php if ($_SESSION['step_gall_7']['send_choice'] == 'd') { echo "selected=\"selected\""; } ?> ><?php echo $webgen_showhtml_choice_d[$language]; ?></option>
</select>
</label>
</li>
<li id="email_send" <?php if ($_SESSION['step_gall_7']['send_choice'] == "d") { echo "style=\"display: none;\""; } ?> >
<label>
<span id="span_email"></span> <?php echo $webgen_contact_email[$language]; ?>
<input type="text" name="email_send_data" onkeyup="prompt_check(this, 'span_submit_button', '<?php echo $webgen_contact_email_empty[$language]; ?>', '<?php echo $webgen_contact_email_valid[$language]; ?>', '<?php echo $webgen_contact_email_invalid[$language]; ?>', '<?php echo $button[$language]." ".$webgen_showhtml_button[$language]; ?>', 'email')" <?php if (isset($_SESSION['step_pp_20']['email_send_data'])) { echo "value=\"".$_SESSION['step_pp_20']['email_send_data']."\""; } ?> />
</label>
</li>
</ul>
<div id="button_send">
<label>
<span id="span_submit_button"></span> <span id="span_submit_button_info"></span>
<input id="submit_button" type="submit" value="<?php if ($_SESSION['step_pp_20']['send_choice'] == "d") { echo $webgen_send_to_button[$language]; } else { echo $webgen_showhtml_button[$language]; } ?>" />
</label>
</div>
</form>