1 |
rabit |
1.1 |
<?php |
2 |
|
|
/*------------------------------------------------------------------------------ |
3 |
|
|
--- www.netfrag.org |
4 |
|
|
--- Setup and common functions include file. |
5 |
|
|
-------------------------------------------------------------------------------- |
6 |
|
|
--- rabit, 21:23 31.08.2004 |
7 |
rabit |
1.2 |
--- $Id: otd_html1.php.inc,v 1.1 2004/09/01 20:43:44 rabit Exp $ |
8 |
rabit |
1.1 |
------------------------------------------------------------------------------*/ |
9 |
|
|
|
10 |
|
|
//- REQUIRED: |
11 |
|
|
//- common, cms, xmlcp |
12 |
|
|
|
13 |
|
|
//------------------------------------------------------------------------------ |
14 |
|
|
//- Name of content render function: |
15 |
|
|
|
16 |
|
|
$otd_render = 'otd_html1_renderpage'; |
17 |
|
|
|
18 |
|
|
//------------------------------------------------------------------------------ |
19 |
|
|
|
20 |
|
|
//common_benchmark_addstep('otd_html1: ...'); |
21 |
|
|
|
22 |
|
|
//------------------------------------------------------------------------------ |
23 |
|
|
|
24 |
|
|
//---------------------------------------------------------- |
25 |
|
|
//- XMLCP callbacks setup: |
26 |
|
|
|
27 |
|
|
xmlcp_registertagcallbacks('b', 'otd_html1_cb_xmlcp_start_bold', 'otd_html1_cb_xmlcp_end_bold'); |
28 |
|
|
xmlcp_registertagcallbacks('h', 'otd_html1_cb_xmlcp_start_headline', 'otd_html1_cb_xmlcp_end_headline'); |
29 |
|
|
//xmlcp_registertagcallbacks('page', 'otd_html1_cb_xmlcp_start_page', 'otd_html1_cb_xmlcp_end_page'); |
30 |
|
|
xmlcp_registertagcallbacks('p', 'otd_html1_cb_xmlcp_start_paragraph', 'otd_html1_cb_xmlcp_end_paragraph'); |
31 |
|
|
|
32 |
|
|
function otd_html1_cb_xmlcp_start_bold($h_parser, $tagname, $attribs) { |
33 |
|
|
|
34 |
|
|
global $xmlcp_cdata; |
35 |
|
|
|
36 |
|
|
$xmlcp_cdata .= '<b>'; |
37 |
|
|
|
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
function otd_html1_cb_xmlcp_end_bold($h_parser, $tagname) { |
41 |
|
|
|
42 |
|
|
global $xmlcp_cdata; |
43 |
|
|
|
44 |
|
|
$xmlcp_cdata .= '</b>'; |
45 |
|
|
|
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
function otd_html1_cb_xmlcp_start_headline($h_parser, $tagname, $attribs) { |
49 |
|
|
|
50 |
|
|
global $xmlcp_cdata; |
51 |
|
|
|
52 |
|
|
$xmlcp_cdata = ''; |
53 |
|
|
|
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
function otd_html1_cb_xmlcp_end_headline($h_parser, $tagname) { |
57 |
|
|
|
58 |
|
|
global $xmlcp_cdata; |
59 |
|
|
|
60 |
|
|
otd_html1_headline(trim($xmlcp_cdata)); |
61 |
|
|
|
62 |
|
|
$xmlcp_cdata = ''; |
63 |
|
|
|
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
/* |
67 |
|
|
function otd_html1_cb_xmlcp_start_page($h_parser, $tagname, $attribs) { |
68 |
|
|
|
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
function otd_html1_cb_xmlcp_end_page($h_parser, $tagname) { |
72 |
|
|
|
73 |
|
|
} |
74 |
|
|
*/ |
75 |
|
|
|
76 |
|
|
function otd_html1_cb_xmlcp_start_paragraph($h_parser, $tagname, $attribs) { |
77 |
|
|
|
78 |
|
|
global $xmlcp_cdata; |
79 |
|
|
|
80 |
|
|
$xmlcp_cdata = ''; |
81 |
|
|
|
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
function otd_html1_cb_xmlcp_end_paragraph($h_parser, $tagname) { |
85 |
|
|
|
86 |
|
|
global $xmlcp_cdata; |
87 |
|
|
|
88 |
|
|
otd_html1_paragraph(trim($xmlcp_cdata)); |
89 |
|
|
|
90 |
|
|
$xmlcp_cdata = ''; |
91 |
|
|
|
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
//---------------------------------------------------------- |
95 |
|
|
//- Content render functions: |
96 |
|
|
|
97 |
|
|
function otd_html1_renderpage($keyname, $language_id = 0) { |
98 |
|
|
|
99 |
|
|
global $common; |
100 |
|
|
|
101 |
|
|
common_benchmark_addstep('otd_html1: render: start'); |
102 |
|
|
|
103 |
|
|
$list = cms_getlist('xmlpage', $keyname); |
104 |
|
|
|
105 |
|
|
common_benchmark_addstep('otd_html1: render: CMS get list'); |
106 |
|
|
|
107 |
|
|
$contentdata = cms_getcontent('xmlpage', $keyname, $language_id); |
108 |
|
|
|
109 |
|
|
common_benchmark_addstep('otd_html1: render: CMS get content'); |
110 |
|
|
|
111 |
|
|
$xml = $contentdata['content']; |
112 |
|
|
|
113 |
rabit |
1.2 |
otd_html1_pagehead(); |
114 |
|
|
|
115 |
|
|
common_benchmark_addstep('otd_html1: render: head'); |
116 |
|
|
|
117 |
rabit |
1.1 |
otd_html1_pageheader(); |
118 |
|
|
|
119 |
|
|
common_benchmark_addstep('otd_html1: render: header'); |
120 |
|
|
|
121 |
|
|
if($xml) { |
122 |
|
|
|
123 |
|
|
$titledata = ''; |
124 |
|
|
|
125 |
|
|
for($i = 0; $i < count($list); $i++) { |
126 |
|
|
|
127 |
|
|
$imgtag = '<img alt="' . $list[$i][4] . '" border="0" height="12" src="' . $common['site']['gfxurl'] . 'icons/flags/' . $list[$i][3] . '.gif" width="17" />'; |
128 |
|
|
|
129 |
|
|
$titledata .= ($i ? ' |
130 |
|
|
' : '') . (($language_id == $list[$i][3]) ? $imgtag : '<a href="?li=' . $list[$i][3] . '" title="' . $list[$i][4] . '">' . $imgtag . '</a>'); |
131 |
|
|
|
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
otd_html1_pagetitle($contentdata['description'], $titledata . '<br />'); |
135 |
|
|
|
136 |
rabit |
1.2 |
$res = xmlcp_parse($xml); |
137 |
rabit |
1.1 |
|
138 |
rabit |
1.2 |
common_benchmark_addstep('otd_html1: render: xmlpc_parse() = ' . $res); |
139 |
rabit |
1.1 |
|
140 |
|
|
/* |
141 |
|
|
otd_html1_headline('$list array, readable:'); |
142 |
|
|
otd_html1_codeparagraph('$list = ' . nl2br(htmlentities(print_r($list, true)))); |
143 |
|
|
|
144 |
|
|
otd_html1_headline('$contentdata array, readable:'); |
145 |
|
|
otd_html1_codeparagraph('$contentdata = ' . nl2br(htmlentities(print_r($contentdata, true)))); |
146 |
|
|
|
147 |
|
|
otd_html1_headline('$common array, readable:'); |
148 |
|
|
otd_html1_codeparagraph('$common = ' . nl2br(htmlentities(print_r($common, true)))); |
149 |
|
|
|
150 |
|
|
otd_html1_headline('$common_sessiondata array, readable:'); |
151 |
|
|
otd_html1_codeparagraph('$common_sessiondata = ' . nl2br(htmlentities(print_r($common_sessiondata, true)))); |
152 |
|
|
|
153 |
|
|
otd_html1_headline('Content XML:'); |
154 |
|
|
otd_html1_codeparagraph(nl2br(htmlentities($xml))); |
155 |
|
|
|
156 |
|
|
*/ |
157 |
|
|
|
158 |
|
|
// Only show the informations when "devstate" is set: |
159 |
rabit |
1.2 |
// if($common['hostsetup']['devstate']) { |
160 |
rabit |
1.1 |
|
161 |
|
|
otd_html1_paragraph('<small> |
162 |
|
|
<b>Content informations:</b><br /> |
163 |
|
|
<br /> |
164 |
|
|
Description: "<b>' . $contentdata['description'] . '</b>" (Type: "xmlpage")<br /> |
165 |
|
|
Creator: "<b>' . $contentdata['creator_name'] . '</b>"<br /> |
166 |
|
|
Date, Time: "<b>' . date('d.m.Y, H:i:s', $contentdata['unixtime']) . '</b>"<br /> |
167 |
|
|
Language: "<b>' . $contentdata['language_name'] . '</b>"<br /> |
168 |
|
|
XML content size: <b>' . strlen($xml) . '</b> bytes |
169 |
|
|
</small>', 'box2'); |
170 |
|
|
|
171 |
rabit |
1.2 |
// } |
172 |
rabit |
1.1 |
|
173 |
|
|
} else { |
174 |
|
|
|
175 |
|
|
otd_html1_pagetitle('Bad content request'); |
176 |
|
|
|
177 |
|
|
otd_html1_paragraph('Sorry, but the requested content is unknown.'); |
178 |
|
|
|
179 |
|
|
} |
180 |
|
|
|
181 |
|
|
common_benchmark_addstep('otd_html1: render: content'); |
182 |
|
|
|
183 |
|
|
otd_html1_pagefooter(); |
184 |
|
|
|
185 |
rabit |
1.2 |
common_benchmark_addstep('otd_html1: render: footer'); |
186 |
|
|
|
187 |
|
|
// Only show the benchmark list when "devstate" is set: |
188 |
|
|
if($common['hostsetup']['devstate']) { |
189 |
|
|
|
190 |
|
|
otd_html1_benchmarkbox(); |
191 |
|
|
|
192 |
|
|
} |
193 |
|
|
|
194 |
|
|
otd_html1_pagefoot(); |
195 |
|
|
|
196 |
rabit |
1.1 |
} |
197 |
|
|
|
198 |
|
|
//---------------------------------------------------------- |
199 |
|
|
//- HTML Output functions: |
200 |
|
|
|
201 |
|
|
function otd_html1_authbox() { |
202 |
|
|
|
203 |
|
|
global $common_sessiondata; |
204 |
|
|
|
205 |
rabit |
1.2 |
$boxheight = 48; |
206 |
|
|
$boxwidth = 280; |
207 |
|
|
|
208 |
|
|
if($common_sessiondata['userdata']['authorised']) { |
209 |
|
|
|
210 |
|
|
echo '<table cellspacing="0" cellpadding="2" class="f22" width="' . $boxwidth . '"> |
211 |
rabit |
1.1 |
<tr> |
212 |
rabit |
1.2 |
<th class="box2" height="' . $boxheight . '" width="44"><b>User<br />login</b></th> |
213 |
|
|
<td valign="top" style="padding:4px;"> |
214 |
|
|
<small> |
215 |
|
|
You are logged in the ' . $common_sessiondata['userdata']['logincount'] . '. time as <b>' . $common_sessiondata['userdata']['name'] . '</b>. Login time was <b>' . date('H:i:s (d.m.Y)', $common_sessiondata['userdata']['logintime']) . '</b>.<br/ > |
216 |
|
|
Your rights are "<b>' . $common_sessiondata['userdata']['rights'] . '</b>". |
217 |
|
|
</small> |
218 |
|
|
</td> |
219 |
|
|
</table> |
220 |
|
|
'; |
221 |
|
|
|
222 |
|
|
} else { |
223 |
|
|
|
224 |
|
|
echo '<form action="" method="post" style="margin:0;"> |
225 |
|
|
<table cellspacing="0" cellpadding="0" class="f22" width="' . $boxwidth . '"> |
226 |
|
|
<tr> |
227 |
|
|
<th class="box2" height="' . $boxheight . '" rowspan="2" width="44"><b>User<br />login</b></th> |
228 |
|
|
<td align="right">User name:</td> |
229 |
rabit |
1.1 |
<td rowspan="2"> </td> |
230 |
rabit |
1.2 |
<td><input name="un" size="10" type="text" value="' . $common_sessiondata['userdata']['name'] . '" /></td> |
231 |
|
|
<th class="box2" rowspan="2"><input type="submit" value="OK" /></th> |
232 |
rabit |
1.1 |
</tr> |
233 |
|
|
<tr> |
234 |
rabit |
1.2 |
<td align="right">Password:</td><td><input name="pw" size="10" type="password" /></td> |
235 |
rabit |
1.1 |
</tr> |
236 |
|
|
</table> |
237 |
|
|
</form> |
238 |
|
|
'; |
239 |
|
|
|
240 |
rabit |
1.2 |
} |
241 |
|
|
|
242 |
rabit |
1.1 |
} |
243 |
|
|
|
244 |
rabit |
1.2 |
function otd_html1_benchmarkbox() { |
245 |
|
|
|
246 |
|
|
global $common; |
247 |
rabit |
1.1 |
|
248 |
rabit |
1.2 |
$contents = ''; |
249 |
|
|
|
250 |
|
|
for($i = 0; $i < count($common['benchmark']); $i++) { |
251 |
rabit |
1.1 |
|
252 |
rabit |
1.2 |
$mtimesegs = explode(' ', $common['benchmark'][$i][1]); |
253 |
|
|
$contents .= substr('0' . ($i + 1), -2) . ': "<b>' . $common['benchmark'][$i][0] . '</b>": '; |
254 |
rabit |
1.1 |
|
255 |
rabit |
1.2 |
if($i) { |
256 |
rabit |
1.1 |
|
257 |
rabit |
1.2 |
$timediff = (float)($mtimesegs[1] - $lastmtimesegs[1]); |
258 |
|
|
$timediff += $mtimesegs[0] - $lastmtimesegs[0]; |
259 |
rabit |
1.1 |
|
260 |
rabit |
1.2 |
$contents .= '<b>+' . round($timediff * 1000000) / 1000 . '</b> ms<br /> |
261 |
rabit |
1.1 |
'; |
262 |
|
|
|
263 |
rabit |
1.2 |
} else { |
264 |
rabit |
1.1 |
|
265 |
rabit |
1.2 |
$contents .= 'Start time: <b>' . date('H:i:s', $mtimesegs[1]) . substr($mtimesegs[0], 1, 4) . '</b><br /> |
266 |
|
|
'; |
267 |
rabit |
1.1 |
|
268 |
rabit |
1.2 |
} |
269 |
rabit |
1.1 |
|
270 |
rabit |
1.2 |
$lastmtimesegs = $mtimesegs; |
271 |
rabit |
1.1 |
|
272 |
rabit |
1.2 |
} |
273 |
rabit |
1.1 |
|
274 |
rabit |
1.2 |
otd_html1_paragraph('<small> |
275 |
|
|
<b>Partial execution times:</b><br /> |
276 |
|
|
<br /> |
277 |
|
|
' . $contents . '</small>', 'box2'); |
278 |
rabit |
1.1 |
|
279 |
rabit |
1.2 |
} |
280 |
rabit |
1.1 |
|
281 |
rabit |
1.2 |
function otd_html1_codeparagraph($contents) { |
282 |
rabit |
1.1 |
|
283 |
rabit |
1.2 |
echo '<p align="justify" class="hl11"> |
284 |
|
|
<code> |
285 |
|
|
' . $contents . ' |
286 |
|
|
</code> |
287 |
|
|
</p> |
288 |
rabit |
1.1 |
'; |
289 |
|
|
|
290 |
rabit |
1.2 |
} |
291 |
rabit |
1.1 |
|
292 |
rabit |
1.2 |
function otd_html1_headline($caption) { |
293 |
|
|
|
294 |
|
|
echo '<big><u>' . $caption . '</u></big> |
295 |
rabit |
1.1 |
'; |
296 |
|
|
|
297 |
rabit |
1.2 |
} |
298 |
|
|
|
299 |
|
|
function otd_html1_pagefoot() { |
300 |
rabit |
1.1 |
|
301 |
rabit |
1.2 |
echo '</body> |
302 |
rabit |
1.1 |
|
303 |
rabit |
1.2 |
</html> |
304 |
|
|
'; |
305 |
rabit |
1.1 |
|
306 |
rabit |
1.2 |
} |
307 |
rabit |
1.1 |
|
308 |
rabit |
1.2 |
function otd_html1_pagefooter() { |
309 |
rabit |
1.1 |
|
310 |
rabit |
1.2 |
global $common; |
311 |
rabit |
1.1 |
|
312 |
|
|
$endmtimesegs = explode(' ', microtime()); |
313 |
|
|
$startmtimesegs = explode(' ', $common['benchmark'][0][1]); |
314 |
|
|
$timediff = (float)($endmtimesegs[1] - $startmtimesegs[1]); |
315 |
|
|
$timediff += $endmtimesegs[0] - $startmtimesegs[0]; |
316 |
|
|
|
317 |
|
|
$devstate = $common['hostsetup']['devstate']; |
318 |
|
|
|
319 |
rabit |
1.2 |
echo '</td> |
320 |
|
|
<td class="bg11" width="8" rowspan="2" style="padding:0;"></td> |
321 |
|
|
</tr> |
322 |
rabit |
1.1 |
<tr> |
323 |
rabit |
1.2 |
<td class="bg11" nowrap="nowrap" style="border-bottom:2px solid #40e8e0;" valign="bottom"> |
324 |
|
|
<div class="box2" style="margin-bottom:8px;"><big>Tools</big></div> |
325 |
|
|
• Benchmark list: [' . ($devstate ? '<a href="?devstate=0">off</a>' : '<a href="?devstate=1">on</a>') . '] |
326 |
rabit |
1.1 |
</td> |
327 |
|
|
</tr> |
328 |
rabit |
1.2 |
<tr class="bg11"> |
329 |
|
|
<td align="center"> |
330 |
|
|
<small> |
331 |
|
|
Page execution time:<br /> |
332 |
|
|
</small> |
333 |
|
|
<code>' . round($timediff * 100000) / 100 . '</code> ms.<br /> |
334 |
|
|
</td> |
335 |
|
|
<td align="right" colspan="2"> |
336 |
|
|
<a href="http://validator.w3.org/check?uri=referer" target="_blank"><img alt="This page is valid XHTML 1.0" border="0" height="31" src="http://www.w3.org/Icons/valid-xhtml10" width="88" /></a> |
337 |
|
|
<a href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /></a> |
338 |
rabit |
1.1 |
</td> |
339 |
|
|
</tr> |
340 |
|
|
</table> |
341 |
|
|
'; |
342 |
|
|
|
343 |
|
|
} |
344 |
|
|
|
345 |
rabit |
1.2 |
function otd_html1_pagehead() { |
346 |
rabit |
1.1 |
|
347 |
|
|
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
348 |
|
|
|
349 |
|
|
<html xmlns="http://www.w3.org/1999/xhtml"> |
350 |
|
|
|
351 |
|
|
<head> |
352 |
|
|
<title>www.netfrag.org</title> |
353 |
|
|
<style type="text/css"><!-- |
354 |
|
|
body { margin:0; } |
355 |
|
|
body, input, table { font: 10pt verdana, serif; } |
356 |
|
|
input { border:1px; } |
357 |
|
|
.bg11, .box1, .f11, .hl11 { background-color:#50f8f0; } |
358 |
|
|
.bg12, .f12 { background-color:#40e8e0; } |
359 |
|
|
.bg13 { background-color:#20a0c0; } |
360 |
|
|
.bg21, .box2, .f21, .hl21 { background-color:#90fff0; } |
361 |
|
|
.bg22, .f22 { background-color:#80f0e0; } |
362 |
|
|
.bg23 { background-color:#40c080; } |
363 |
|
|
.box1, .f11, .f12 { border:2px solid #20a0c0; } |
364 |
|
|
.box2, .f21, .f22 { border:1px solid #40c080; } |
365 |
|
|
.box1, .box2, .hl11, .hl21 { padding:4px; } |
366 |
|
|
--></style> |
367 |
|
|
</head> |
368 |
|
|
|
369 |
|
|
<body> |
370 |
|
|
'; |
371 |
|
|
|
372 |
|
|
} |
373 |
|
|
|
374 |
rabit |
1.2 |
function otd_html1_pageheader() { |
375 |
rabit |
1.1 |
|
376 |
rabit |
1.2 |
echo '<table cellspacing="0" cellpadding="8" style="border-bottom:2px solid #40e8e0;" width="100%"> |
377 |
|
|
<tr> |
378 |
|
|
<td class="bg11" colspan="3"> |
379 |
|
|
<table cellspacing="0" cellpadding="0" width="100%"> |
380 |
rabit |
1.1 |
<tr class="bg11"> |
381 |
rabit |
1.2 |
<th width="100%"> |
382 |
|
|
<span style="border-bottom:2px solid black; font-size:24pt; letter-spacing:-2pt; padding-bottom:3px;"> |
383 |
|
|
www.<font color="#107080">n</font>et<font color="#107080">f</font>rag.<font color="#107080">o</font>rg</span> |
384 |
|
|
<p style="margin-top:4px;"> |
385 |
|
|
<small>NetFrag and friends</small> |
386 |
|
|
</p> |
387 |
rabit |
1.1 |
</th> |
388 |
rabit |
1.2 |
<td> </td> |
389 |
|
|
<td> |
390 |
rabit |
1.1 |
'; |
391 |
|
|
|
392 |
|
|
otd_html1_authbox(); |
393 |
|
|
|
394 |
|
|
echo '</td> |
395 |
|
|
</tr> |
396 |
rabit |
1.2 |
</table> |
397 |
|
|
</td> |
398 |
|
|
</tr> |
399 |
|
|
<tr> |
400 |
|
|
<td class="bg11" nowrap="nowrap" style="border-top:2px solid #40e8e0;" valign="top" width="160"> |
401 |
|
|
'; |
402 |
rabit |
1.1 |
|
403 |
rabit |
1.2 |
echo '<div class="box2" style="margin-bottom:8px;"><big>Navigation</big></div> |
404 |
|
|
<a href="">Home page</a> |
405 |
rabit |
1.1 |
</td> |
406 |
rabit |
1.2 |
<td rowspan="2" style="border:2px solid #20a0c0; padding:8px;"> |
407 |
|
|
'; |
408 |
|
|
|
409 |
|
|
} |
410 |
rabit |
1.1 |
|
411 |
rabit |
1.2 |
function otd_html1_pagetitle($title, $additionalcontents = '') { |
412 |
rabit |
1.1 |
|
413 |
rabit |
1.2 |
echo '<p class="box2"> |
414 |
rabit |
1.1 |
<big><b>• ' . $title . '</b> </big> |
415 |
|
|
' . ($additionalcontents ? $additionalcontents . ' |
416 |
|
|
' : '') . '</p> |
417 |
|
|
'; |
418 |
|
|
|
419 |
|
|
} |
420 |
|
|
|
421 |
|
|
function otd_html1_paragraph($contents, $class = '') { |
422 |
|
|
|
423 |
|
|
echo '<p align="justify"' . ($class ? ' class="' . $class . '"' : '') . '> |
424 |
|
|
' . $contents . ' |
425 |
|
|
</p> |
426 |
|
|
'; |
427 |
|
|
|
428 |
|
|
} |
429 |
|
|
|
430 |
|
|
//------------------------------------------------------------------------------ |
431 |
|
|
|
432 |
|
|
?> |