/[cvs]/nfo/site/htdocs/inc/otdef/otd_html1/otd_html1.php.inc
ViewVC logotype

Annotation of /nfo/site/htdocs/inc/otdef/otd_html1/otd_html1.php.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations)
Sun Sep 5 06:02:11 2004 UTC (20 years ago) by rabit
Branch: MAIN
Changes since 1.8: +15 -6 lines
+ HTTP authosiation test (moved from "index.php"); U otd_html1_headline(): design/CSS.

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.9 --- $Id: otd_html1.php.inc,v 1.8 2004/09/05 03:21:49 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 rabit 1.7 //- Configuration:
20 rabit 1.1
21 rabit 1.7 //- Colour sceme:
22    
23     $otd_html1['colours'] = array(
24    
25     'bg' => 'white',
26     'text' => 'black',
27    
28     'text2' => '#107080',
29    
30     // Link colours:
31     'a' => '#506040',
32     'a:hover' => '#5060a0',
33     // 'a:visited' => '#506040',
34    
35     // Content colours:
36     'bg11' => '#40d8c0',
37     'bg12' => '#40e8e0',
38     'border1' => '#20a0b0',
39    
40     // Page frame colours:
41     'bg21' => '#a0c090',
42     'bg22' => '#40c8b0',
43     'border2' => '#40a080',
44    
45     );
46 rabit 1.1
47     //------------------------------------------------------------------------------
48 rabit 1.9 //- Authorisation via HTTP:
49    
50     if(isset($_POST['un']) && isset($_POST['pw'])) {
51    
52     common_authorise($_POST['un'], $_POST['pw']);
53    
54     common_benchmark_addstep('otd_html1: authorisation test');
55    
56     }
57    
58     //------------------------------------------------------------------------------
59 rabit 1.8 //- GET/POST variable encapsulation:
60 rabit 1.1
61 rabit 1.8 if(isset($_GET['debug']))
62     $common_sessiondata['user_prefs']['debug'] = $_GET['debug'];
63    
64     if(isset($_GET['benchlist']))
65     $common_sessiondata['user_prefs']['benchlist'] = $_GET['benchlist'];
66    
67     //------------------------------------------------------------------------------
68 rabit 1.1 //- XMLCP callbacks setup:
69    
70     xmlcp_registertagcallbacks('b', 'otd_html1_cb_xmlcp_start_bold', 'otd_html1_cb_xmlcp_end_bold');
71     xmlcp_registertagcallbacks('h', 'otd_html1_cb_xmlcp_start_headline', 'otd_html1_cb_xmlcp_end_headline');
72     //xmlcp_registertagcallbacks('page', 'otd_html1_cb_xmlcp_start_page', 'otd_html1_cb_xmlcp_end_page');
73     xmlcp_registertagcallbacks('p', 'otd_html1_cb_xmlcp_start_paragraph', 'otd_html1_cb_xmlcp_end_paragraph');
74 joko 1.4 xmlcp_registertagcallbacks('link', 'otd_html1_cb_xmlcp_start_link', 'otd_html1_cb_xmlcp_end_link');
75 rabit 1.1
76 rabit 1.8 //----------------------------------------------------------
77     //- XMLCP callbacks:
78    
79 rabit 1.1 function otd_html1_cb_xmlcp_start_bold($h_parser, $tagname, $attribs) {
80    
81     global $xmlcp_cdata;
82    
83     $xmlcp_cdata .= '<b>';
84    
85     }
86    
87     function otd_html1_cb_xmlcp_end_bold($h_parser, $tagname) {
88    
89     global $xmlcp_cdata;
90    
91     $xmlcp_cdata .= '</b>';
92    
93     }
94    
95     function otd_html1_cb_xmlcp_start_headline($h_parser, $tagname, $attribs) {
96    
97     global $xmlcp_cdata;
98    
99     $xmlcp_cdata = '';
100    
101     }
102    
103     function otd_html1_cb_xmlcp_end_headline($h_parser, $tagname) {
104    
105     global $xmlcp_cdata;
106    
107     otd_html1_headline(trim($xmlcp_cdata));
108    
109     $xmlcp_cdata = '';
110    
111     }
112    
113     /*
114 rabit 1.8 function otd_html1_cb_xmlcp_start_page($h_parser, $tagname, $attribs) { }
115 rabit 1.1
116 rabit 1.8 function otd_html1_cb_xmlcp_end_page($h_parser, $tagname) { }
117 rabit 1.1 */
118    
119     function otd_html1_cb_xmlcp_start_paragraph($h_parser, $tagname, $attribs) {
120    
121     global $xmlcp_cdata;
122    
123     $xmlcp_cdata = '';
124    
125     }
126    
127     function otd_html1_cb_xmlcp_end_paragraph($h_parser, $tagname) {
128    
129     global $xmlcp_cdata;
130    
131     otd_html1_paragraph(trim($xmlcp_cdata));
132    
133     $xmlcp_cdata = '';
134    
135 joko 1.4 }
136    
137     function otd_html1_cb_xmlcp_start_link($h_parser, $tagname, $attribs) {
138    
139 rabit 1.6 global $xmlcp_cdata;
140    
141     if(isset($attribs['keyname'])) {
142    
143 joko 1.4 $attribs['url'] = common_get_baseurl() . '?ck=' . $attribs['keyname'];
144 rabit 1.6
145 joko 1.4 }
146 rabit 1.6
147     $link = '<a href="' . $attribs['url'] . '">'; // . trim($xmlcp_cdata);
148 joko 1.4
149     $xmlcp_cdata .= $link;
150 rabit 1.6
151 joko 1.4 }
152    
153     function otd_html1_cb_xmlcp_end_link($h_parser, $tagname) {
154 rabit 1.6
155     global $xmlcp_cdata;
156    
157     $xmlcp_cdata .= '</a>';
158    
159 rabit 1.1 }
160    
161 rabit 1.8 //------------------------------------------------------------------------------
162 rabit 1.1 //- Content render functions:
163    
164     function otd_html1_renderpage($keyname, $language_id = 0) {
165    
166 rabit 1.6 global $common, $common_sessiondata;
167 rabit 1.1
168     common_benchmark_addstep('otd_html1: render: start');
169    
170     $list = cms_getlist('xmlpage', $keyname);
171    
172     common_benchmark_addstep('otd_html1: render: CMS get list');
173    
174     $contentdata = cms_getcontent('xmlpage', $keyname, $language_id);
175    
176     common_benchmark_addstep('otd_html1: render: CMS get content');
177    
178     $xml = $contentdata['content'];
179    
180 rabit 1.2 otd_html1_pagehead();
181    
182     common_benchmark_addstep('otd_html1: render: head');
183    
184 rabit 1.8 otd_html1_pageheader('', '&bull; <a href="' . common_get_baseurl() . 'pages/otd_html1/userinfo.php">User info</a>');
185 rabit 1.1
186     common_benchmark_addstep('otd_html1: render: header');
187    
188     if($xml) {
189    
190     $titledata = '';
191    
192     for($i = 0; $i < count($list); $i++) {
193    
194 rabit 1.8 $imgtag = otd_html1_get_imgtag('icons/flags/' . $list[$i][3] . '.gif', $list[$i][4], 14, 21);
195 rabit 1.1
196 rabit 1.8 $titledata .= (($language_id == $list[$i][3]) ? $imgtag : '<a href="?li=' . $list[$i][3] . '" title="' . $list[$i][4] . '">' . $imgtag . '</a>') . '&nbsp;';
197 rabit 1.1
198     }
199    
200     otd_html1_pagetitle($contentdata['description'], $titledata . '<br />');
201    
202 rabit 1.2 $res = xmlcp_parse($xml);
203 rabit 1.1
204 rabit 1.3 common_benchmark_addstep('otd_html1: render: xmlcp_parse() = ' . $res);
205 rabit 1.1
206 rabit 1.6 // Only show debug outputs when set as preference:
207     if($common_sessiondata['user_prefs']['debug']) {
208 rabit 1.1
209 rabit 1.6 otd_html1_headline('Content list array:');
210 rabit 1.3 otd_html1_codeparagraph('$list = ' . nl2br(htmlentities(print_r($list, true))));
211 rabit 1.1
212 rabit 1.6 otd_html1_headline('Content query result array:');
213 rabit 1.3 otd_html1_codeparagraph('$contentdata = ' . nl2br(htmlentities(print_r($contentdata, true))));
214 rabit 1.1
215 rabit 1.6 otd_html1_headline('User preferences array:');
216     otd_html1_codeparagraph('$common_sessiondata[user_prefs] = ' . nl2br(htmlentities(print_r($common_sessiondata['user_prefs'], true))));
217 rabit 1.1
218 rabit 1.3 }
219    
220 rabit 1.8 $extrapageinfocontents = 'Content item "<b>' . $contentdata['description'] . '</b>" (language: "<b>' . $contentdata['language_name'] . '</b>") created by <b>' . $contentdata['creator_name'] . '</b> on <b>' . date('Y/m/d, H:i:s', $contentdata['unixtime']) . '</b>. Last changes by <b>' . $contentdata['creator_name'] . '</b> on <b>' . date('d.m.Y, H:i:s', $contentdata['unixtime']) . '</b>.<br />
221     Page created by <b>rabit</b> on <b>2004/08/31, 21:23</b>.
222     ';
223 rabit 1.1
224     } else {
225    
226     otd_html1_pagetitle('Bad content request');
227    
228 rabit 1.6 otd_html1_paragraph('Sorry, but the requested content is unknown. Please check your query and if the problem occours again try to contact a site administrator.');
229 rabit 1.1
230     }
231    
232     common_benchmark_addstep('otd_html1: render: content');
233    
234 rabit 1.8 otd_html1_pagefooter($extrapageinfocontents);
235 rabit 1.1
236 rabit 1.2 common_benchmark_addstep('otd_html1: render: footer');
237    
238     otd_html1_pagefoot();
239    
240 rabit 1.1 }
241    
242 rabit 1.8 //------------------------------------------------------------------------------
243 rabit 1.6 //- HTML return functions:
244    
245     function otd_html1_get_imgtag($relativeurl, $alt, $height = '', $width = '') {
246    
247     global $common;
248    
249     return '<img alt="' . $alt . '" src="' . $common['site']['gfxurl'] . $relativeurl . '" style="border:0;' . ($height ? ' height:' . $height . 'px;' : '') . ($width ? ' width:' . $width . 'px;' : '') . '" />';
250    
251     }
252    
253 rabit 1.8 //------------------------------------------------------------------------------
254 rabit 1.6 //- HTML output functions:
255 rabit 1.1
256     function otd_html1_authbox() {
257    
258     global $common_sessiondata;
259    
260 rabit 1.2 $boxheight = 48;
261 rabit 1.7 $boxwidth = 240;
262 rabit 1.2
263 rabit 1.6 if($common_sessiondata['user_auth']['authorised']) {
264 rabit 1.2
265     echo '<table cellspacing="0" cellpadding="2" class="f22" width="' . $boxwidth . '">
266 rabit 1.1 <tr>
267 rabit 1.7 <th class="box2" height="' . $boxheight . '" width="40"><b>User<br />login</b></th>
268 rabit 1.3 <td align="center" valign="top" style="padding:4px;">
269 rabit 1.2 <small>
270 rabit 1.6 You are logged in the ' . $common_sessiondata['user_auth']['logincount'] . '. time as <b>' . $common_sessiondata['user_auth']['name'] . '</b>. Login time was <b>' . date('H:i:s, d.m.Y', $common_sessiondata['user_auth']['logintime']) . '</b>.<br/ >
271     Your rights are "<b>' . $common_sessiondata['user_auth']['rights'] . '</b>".
272 rabit 1.2 </small>
273     </td>
274     </table>
275     ';
276    
277     } else {
278    
279 rabit 1.7 echo '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" style="margin:0;">
280 rabit 1.2 <table cellspacing="0" cellpadding="0" class="f22" width="' . $boxwidth . '">
281     <tr>
282 rabit 1.7 <th class="box2" height="' . $boxheight . '" rowspan="2" width="40"><b>User<br />login</b></th>
283 rabit 1.2 <td align="right">User name:</td>
284 rabit 1.1 <td rowspan="2">&nbsp;</td>
285 rabit 1.7 <td><input name="un" size="8" type="text" tabindex="1" /></td>
286 rabit 1.5 <th class="box2" rowspan="2"><input type="submit" value="OK" tabindex="3" /></th>
287 rabit 1.1 </tr>
288     <tr>
289 rabit 1.7 <td align="right">Password:</td><td><input name="pw" size="8" type="password" tabindex="2" /></td>
290 rabit 1.1 </tr>
291     </table>
292     </form>
293     ';
294    
295 rabit 1.2 }
296    
297 rabit 1.1 }
298    
299 rabit 1.2 function otd_html1_benchmarkbox() {
300    
301     global $common;
302 rabit 1.1
303 rabit 1.2 $contents = '';
304    
305     for($i = 0; $i < count($common['benchmark']); $i++) {
306 rabit 1.1
307 rabit 1.2 $mtimesegs = explode(' ', $common['benchmark'][$i][1]);
308     $contents .= substr('0' . ($i + 1), -2) . ': "<b>' . $common['benchmark'][$i][0] . '</b>": ';
309 rabit 1.1
310 rabit 1.2 if($i) {
311 rabit 1.1
312 rabit 1.2 $timediff = (float)($mtimesegs[1] - $lastmtimesegs[1]);
313     $timediff += $mtimesegs[0] - $lastmtimesegs[0];
314 rabit 1.1
315 rabit 1.2 $contents .= '<b>+' . round($timediff * 1000000) / 1000 . '</b> ms<br />
316 rabit 1.1 ';
317    
318 rabit 1.2 } else {
319 rabit 1.1
320 rabit 1.2 $contents .= 'Start time: <b>' . date('H:i:s', $mtimesegs[1]) . substr($mtimesegs[0], 1, 4) . '</b><br />
321     ';
322 rabit 1.1
323 rabit 1.2 }
324 rabit 1.1
325 rabit 1.2 $lastmtimesegs = $mtimesegs;
326 rabit 1.1
327 rabit 1.2 }
328 rabit 1.1
329 rabit 1.2 otd_html1_paragraph('<small>
330     <b>Partial execution times:</b><br />
331     <br />
332 rabit 1.3 ' . $contents . '</small>', 'box1');
333 rabit 1.1
334 rabit 1.2 }
335 rabit 1.1
336 rabit 1.2 function otd_html1_codeparagraph($contents) {
337 rabit 1.1
338 rabit 1.3 echo '<p align="justify" class="hl12">
339 rabit 1.2 <code>
340     ' . $contents . '
341     </code>
342     </p>
343 rabit 1.1 ';
344    
345 rabit 1.2 }
346 rabit 1.1
347 rabit 1.2 function otd_html1_headline($caption) {
348    
349 rabit 1.8 global $otd_html1;
350    
351 rabit 1.9 echo '<p><span style="border-bottom:1px solid ' . $otd_html1['colours']['border1'] . '; padding-bottom:1px;"><b>' . $caption . '</b></span></p>
352 rabit 1.1 ';
353    
354 rabit 1.2 }
355    
356     function otd_html1_pagefoot() {
357 rabit 1.1
358 rabit 1.8 global $common_sessiondata;
359    
360     // As last show the benchmark list when set as preference:
361     if($common_sessiondata['user_prefs']['benchlist']) {
362    
363     otd_html1_benchmarkbox();
364    
365     }
366    
367 rabit 1.2 echo '</body>
368 rabit 1.1
369 rabit 1.2 </html>
370     ';
371 rabit 1.1
372 rabit 1.2 }
373 rabit 1.1
374 rabit 1.8 function otd_html1_pagefooter($extrapageinfocontents = '') {
375 rabit 1.1
376 rabit 1.8 global $common, $ID;
377 rabit 1.1
378 rabit 1.7 $contentheight = 240; // Minimum height of content and navigation.
379    
380 rabit 1.1 $endmtimesegs = explode(' ', microtime());
381     $startmtimesegs = explode(' ', $common['benchmark'][0][1]);
382     $timediff = (float)($endmtimesegs[1] - $startmtimesegs[1]);
383     $timediff += $endmtimesegs[0] - $startmtimesegs[0];
384    
385 rabit 1.8 otd_html1_paragraph('<small>
386     ' . ($extrapageinfocontents ? $extrapageinfocontents . '<br />
387     ' : '') . 'CVS ID: "<b>' . $ID . '</b>"
388     </small>', 'box1');
389    
390 rabit 1.2 echo '</td>
391 rabit 1.6 <td class="bg11" style="padding:0;">
392 rabit 1.7 ' . otd_html1_get_imgtag('blank.gif', '', $contentheight, 8) . '
393 rabit 1.1 </td>
394     </tr>
395 rabit 1.2 <tr class="bg11">
396     <td align="center">
397     <small>
398     Page execution time:<br />
399     </small>
400     <code>' . round($timediff * 100000) / 100 . '</code> ms.<br />
401     </td>
402 rabit 1.8 <td align="center" colspan="2">
403     <a href="http://validator.w3.org/check?uri=referer" target="_blank"><img alt="This page is valid XHTML 1.0" src="http://www.w3.org/Icons/valid-xhtml10" style="border:0;width:88px;height:31px;" /></a>&nbsp;&nbsp;&nbsp;<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>
404 rabit 1.1 </td>
405     </tr>
406     </table>
407     ';
408    
409     }
410    
411 rabit 1.2 function otd_html1_pagehead() {
412 rabit 1.1
413 rabit 1.7 global $otd_html1;
414    
415 rabit 1.1 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
416    
417     <html xmlns="http://www.w3.org/1999/xhtml">
418    
419     <head>
420     <title>www.netfrag.org</title>
421     <style type="text/css"><!--
422 rabit 1.7 a { color:' . $otd_html1['colours']['a'] . '; font-weight:bold; text-decoration:none; }
423     a:hover { color:' . $otd_html1['colours']['a:hover'] . '; }
424     body { background-color:' . $otd_html1['colours']['bg'] . '; color:' . $otd_html1['colours']['text'] . '; margin:0; }
425     body, input, table { font: 8pt verdana, serif; }
426 rabit 1.1 input { border:1px; }
427 rabit 1.7 .bg11, .f11, .hl11 { background-color:' . $otd_html1['colours']['bg11'] . '; }
428     .bg12, .box1, .f12, .hl12 { background-color:' . $otd_html1['colours']['bg12'] . '; }
429     .bg21, .box2, .f21, .hl21 { background-color:' . $otd_html1['colours']['bg21'] . '; }
430     .bg22, .f22, .hl22 { background-color:' . $otd_html1['colours']['bg22'] . '; }
431     .box1, .f11, .f12 { border:1px solid ' . $otd_html1['colours']['border1'] . '; }
432     .box2, .f21, .f22 { border:1px solid ' . $otd_html1['colours']['border2'] . '; }
433     .box1, .box2, .hl11, .hl12, .hl21, .hl22 { padding:4px; }
434     .c2 { color:' . $otd_html1['colours']['text2'] . '; }
435 rabit 1.1 --></style>
436     </head>
437    
438     <body>
439     ';
440    
441     }
442    
443 rabit 1.8 function otd_html1_pageheader($extranavbarcontents = '', $extratoolbarcontents = '') {
444 rabit 1.1
445 rabit 1.7 global $common_sessiondata, $otd_html1, $request_contentkey;
446 rabit 1.6
447 rabit 1.7 $leftbarwidth = 144; // Inner width (w/o padding) of left bar.
448 rabit 1.6
449     $benchlist = $common_sessiondata['user_prefs']['benchlist'];
450     $debug = $common_sessiondata['user_prefs']['debug'];
451    
452 rabit 1.7 $urlprefix = $_SERVER['PATH_INFO'] . '?ck=' . $request_contentkey . '&';
453    
454     echo '<table cellspacing="0" cellpadding="8" style="border-bottom:2px solid ' . $otd_html1['colours']['border2'] . '; border-top:2px solid ' . $otd_html1['colours']['border2'] . '; width:100%;">
455 rabit 1.2 <tr>
456     <td class="bg11" colspan="3">
457 rabit 1.6 <table cellspacing="0" cellpadding="0" style="width:100%">
458 rabit 1.1 <tr class="bg11">
459 rabit 1.2 <th width="100%">
460 rabit 1.9 <span style="border-bottom:2px solid black; font-size:22pt; letter-spacing:-2pt; padding-bottom:3px;">
461     www.<span class="c2">N</span>et<span class="c2">F</span>rag.<span class="c2">o</span>rg</span>
462 rabit 1.7 <p style="margin-top:6px;">
463 rabit 1.2 <small>NetFrag and friends</small>
464     </p>
465 rabit 1.1 </th>
466 rabit 1.7 <td>
467     ' . otd_html1_get_imgtag('blank.gif', '', 1, 8) . '
468     </td>
469 rabit 1.2 <td>
470 rabit 1.1 ';
471    
472     otd_html1_authbox();
473    
474     echo '</td>
475     </tr>
476 rabit 1.2 </table>
477     </td>
478     </tr>
479     <tr>
480 rabit 1.7 <td class="bg11" style="border-top:2px solid ' . $otd_html1['colours']['border1'] . ';" valign="top">
481 rabit 1.8 <div class="box2" style="margin-bottom:16px;"><big><b>N</b>a<b>F</b>igati<b>o</b>n:</big></div>
482 rabit 1.7 <div style="margin-bottom:32px;">
483 rabit 1.8 &bull; <a href="' . common_get_baseurl() . '">Home page</a><br />
484 rabit 1.6 ' . otd_html1_get_imgtag('blank.gif', '', 1, $leftbarwidth) . '
485 rabit 1.7 </div>
486 rabit 1.8 <div class="box2" style="margin-bottom:16px;"><big>Info &amp; tools:</big></div>
487     ' . ($extratoolbarcontents ? $extratoolbarcontents . '<br />
488     <br />
489     ' : '') . '&bull; Benchmark list: [<a href="' . $urlprefix . 'benchlist=' . ($benchlist ? '0">off' : '1">on') . '</a>]<br />
490 rabit 1.7 &bull; Debug outputs: [<a href="' . $urlprefix . 'debug=' . ($debug ? '0">off' : '1">on') . '</a>]<br />
491 rabit 1.1 </td>
492 rabit 1.6 <td style="border:2px solid #3090a8; padding:8px;" valign="top">
493 rabit 1.2 ';
494    
495     }
496 rabit 1.1
497 rabit 1.8 function otd_html1_pagetitle($title, $extracontents = '') {
498 rabit 1.1
499 rabit 1.8 echo '<table cellspacing="0" cellpadding="4" class="box1" style="width:100%;">
500     <tr>
501     <td><big><b>&bull; ' . $title . '</b>&nbsp;</big></td>
502     <td align="right">' . ($extracontents ? $extracontents : '') . '</td>
503     </tr>
504     </table>
505 rabit 1.1 ';
506    
507     }
508    
509     function otd_html1_paragraph($contents, $class = '') {
510    
511     echo '<p align="justify"' . ($class ? ' class="' . $class . '"' : '') . '>
512     ' . $contents . '
513     </p>
514     ';
515    
516     }
517    
518     //------------------------------------------------------------------------------
519    
520     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed