24 |
} |
} |
25 |
|
|
26 |
// The starting entry in the benchmark steps list: |
// The starting entry in the benchmark steps list: |
27 |
common_benchmark_addstep('COMMON: start'); |
common_benchmark_addstep('common: start'); |
28 |
|
|
29 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
30 |
//- Developer host setups: |
//- Developer host setups: |
59 |
|
|
60 |
unset($hostsetups); |
unset($hostsetups); |
61 |
|
|
62 |
|
common_benchmark_addstep('common: host setup'); |
63 |
|
|
64 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
65 |
//- Site variable setups: |
//- Site variable setups: |
66 |
|
|
79 |
$common['page']['filename'] = substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], '/') + 1); |
$common['page']['filename'] = substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], '/') + 1); |
80 |
$common['page']['url'] = $_SERVER['PHP_SELF']; |
$common['page']['url'] = $_SERVER['PHP_SELF']; |
81 |
|
|
82 |
common_benchmark_addstep('COMMON: setup'); |
common_benchmark_addstep('common: site/page setup'); |
83 |
|
|
84 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
85 |
//- Includes: |
//- Includes: |
86 |
|
|
87 |
//common_include('cfg/cfg.php.inc'); |
//common_include('cfg/cfg.php.inc'); |
88 |
//common_benchmark_addstep('COMMON: CFG included'); |
//common_benchmark_addstep('common: CFG included'); |
89 |
|
|
90 |
common_include('xmlcp/xmlcp.php.inc'); |
include($common['site']['incroot'] . 'xmlcp/xmlcp.php.inc'); |
91 |
common_benchmark_addstep('COMMON: XMLCP included'); |
common_benchmark_addstep('common: XMLCP included'); |
92 |
|
|
93 |
common_include('cms/cms.php.inc'); |
include($common['site']['incroot'] . 'cms/cms.php.inc'); |
94 |
common_benchmark_addstep('COMMON: CMS included'); |
common_benchmark_addstep('common: CMS included'); |
95 |
|
|
96 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
97 |
//- MySQL connection: |
//- MySQL connection: |
98 |
|
|
99 |
$common['dbc']['dbconnected'] = common_dbc_connectdb(); |
common_dbc_connectdb(); |
100 |
|
common_benchmark_addstep('common: connect database'); |
|
common_benchmark_addstep('COMMON: connect database'); |
|
101 |
|
|
102 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
103 |
//- Session setup: |
//- Session setup: |
104 |
|
|
105 |
// Neither proxies, nor the clients are allowed to cache session data: |
if ($common['client']['session_enabled']) { |
106 |
session_cache_limiter('nocache'); |
|
107 |
|
// Neither proxies, nor the clients are allowed to cache session data: |
108 |
|
session_cache_limiter('nocache'); |
109 |
|
|
110 |
// This is neccessary to make the $_SESSION global available: |
// This is neccessary to make the $_SESSION global available: |
111 |
session_start(); |
session_start(); |
112 |
|
|
113 |
|
} |
114 |
|
|
115 |
common_benchmark_addstep('COMMON: session init'); |
common_benchmark_addstep('common: session init'); |
116 |
|
|
117 |
if(!isset($_SESSION['common_sessiondata'])) { |
if(!isset($_SESSION['common_sessiondata'])) { |
118 |
|
|
119 |
// The session variable isn't set, create it: |
// The session variable isn't set, create it: |
120 |
|
|
121 |
common_benchmark_addstep('COMMON: New session: start'); |
common_benchmark_addstep('common: New session: start'); |
122 |
|
|
123 |
$common_sessiondata = array( |
$common_sessiondata = array( |
124 |
|
|
137 |
|
|
138 |
); |
); |
139 |
|
|
140 |
common_benchmark_addstep('COMMON: New session: create session'); |
common_benchmark_addstep('common: New session: create session'); |
141 |
|
|
142 |
// Protocol the visitors hit and store the columns insertion ID: |
// Protocol the visitors hit and store the columns insertion ID: |
143 |
$common_sessiondata['hit_id'] = common_protocolhit(); |
$common_sessiondata['hit_id'] = common_protocolhit(); |
144 |
|
|
145 |
common_benchmark_addstep('COMMON: New session: protocol hit'); |
common_benchmark_addstep('common: New session: protocol hit'); |
146 |
|
|
147 |
// Store a reference to the session data array: |
// Store a reference to the session data array: |
148 |
$_SESSION['common_sessiondata'] = &$common_sessiondata; |
$_SESSION['common_sessiondata'] = &$common_sessiondata; |
149 |
|
|
150 |
common_benchmark_addstep('COMMON: New session: store session/end'); |
common_benchmark_addstep('common: New session: store session/end'); |
151 |
|
|
152 |
} else { |
} else { |
153 |
|
|
161 |
|
|
162 |
$sql = "UPDATE hits SET requestcount=requestcount+1 WHERE id='" . $common_sessiondata['hit_id'] . "';"; |
$sql = "UPDATE hits SET requestcount=requestcount+1 WHERE id='" . $common_sessiondata['hit_id'] . "';"; |
163 |
|
|
164 |
mysql_query($sql); |
common_dbc_query($sql); |
165 |
|
|
166 |
common_benchmark_addstep('COMMON: session/hit data updated'); |
common_benchmark_addstep('common: session/hit data updated'); |
167 |
|
|
168 |
} |
} |
169 |
|
|
188 |
|
|
189 |
$sql = "SELECT id, rights, logincount, lastlogin FROM users WHERE name='$username' AND password='$password';"; |
$sql = "SELECT id, rights, logincount, lastlogin FROM users WHERE name='$username' AND password='$password';"; |
190 |
|
|
191 |
$res = mysql_query($sql); |
$res = common_dbc_query($sql); |
192 |
|
|
193 |
if(!$res) return false; |
if(!$res) return false; |
194 |
|
|
219 |
|
|
220 |
$sql = "UPDATE users SET logincount='$logincount', lastlogin=FROM_UNIXTIME('$logintime') WHERE id='$userid';"; |
$sql = "UPDATE users SET logincount='$logincount', lastlogin=FROM_UNIXTIME('$logintime') WHERE id='$userid';"; |
221 |
|
|
222 |
$res = mysql_query($sql); |
$res = common_dbc_query($sql); |
223 |
|
|
224 |
if(!$res) return false; |
if(!$res) return false; |
225 |
|
|
242 |
|
|
243 |
$sql = "INSERT INTO hits (id, timestamp, address, entryurl, referer, sessionid, useragent, requestcount) VALUES (NULL, FROM_UNIXTIME('$unixtime'), '$address', '$entryurl', '$referer', '$sessionid', '$useragent', '1');"; |
$sql = "INSERT INTO hits (id, timestamp, address, entryurl, referer, sessionid, useragent, requestcount) VALUES (NULL, FROM_UNIXTIME('$unixtime'), '$address', '$entryurl', '$referer', '$sessionid', '$useragent', '1');"; |
244 |
|
|
245 |
$res = mysql_query($sql); |
$res = common_dbc_query($sql); |
|
|
|
|
if ($errstr = mysql_error()) { |
|
|
|
|
|
print $errstr . "\n"; |
|
|
|
|
|
} |
|
246 |
|
|
247 |
if(!$res) return false; |
if(!$res) return false; |
248 |
|
|
251 |
} |
} |
252 |
|
|
253 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
|
|
|
254 |
//- Database functions: |
//- Database functions: |
255 |
|
|
256 |
function common_dbc_connect() { |
function common_dbc_connect() { |
292 |
|
|
293 |
function common_dbc_connectdb() { |
function common_dbc_connectdb() { |
294 |
|
|
|
return (common_dbc_connect() && common_dbc_selectdb()); |
|
|
|
|
|
} |
|
|
|
|
|
//---------------------------------------------------------- |
|
|
|
|
|
//- File functions: |
|
|
|
|
|
function common_include($filename) { |
|
|
|
|
295 |
global $common; |
global $common; |
296 |
|
|
297 |
return include($common['site']['incroot'] . $filename); |
$common['dbc']['dbconnected'] = (common_dbc_connect() && common_dbc_selectdb()); |
|
|
|
|
} |
|
|
|
|
|
//---------------------------------------------------------- |
|
|
|
|
|
//- XMLCP setup: |
|
|
|
|
|
xmlcp_registertagcallbacks('b', 'common_cb_xmlcp_start_bold', 'common_cb_xmlcp_end_bold'); |
|
|
xmlcp_registertagcallbacks('h', 'common_cb_xmlcp_start_headline', 'common_cb_xmlcp_end_headline'); |
|
|
xmlcp_registertagcallbacks('p', 'common_cb_xmlcp_start_paragraph', 'common_cb_xmlcp_end_paragraph'); |
|
|
xmlcp_registertagcallbacks('page', 'common_cb_xmlcp_start_page', 'common_cb_xmlcp_end_page'); |
|
|
|
|
|
function common_cb_xmlcp_end_bold($h_parser, $tagname) { |
|
|
|
|
|
global $xmlcp_cdata; |
|
|
|
|
|
$xmlcp_cdata .= '</b>'; |
|
|
|
|
|
} |
|
|
|
|
|
function common_cb_xmlcp_start_bold($h_parser, $tagname, $attribs) { |
|
|
|
|
|
global $xmlcp_cdata; |
|
|
|
|
|
$xmlcp_cdata .= '<b>'; |
|
|
|
|
|
} |
|
|
|
|
|
function common_cb_xmlcp_end_page($h_parser, $tagname) { |
|
|
|
|
|
} |
|
|
|
|
|
function common_cb_xmlcp_start_page($h_parser, $tagname, $attribs) { |
|
|
|
|
|
} |
|
|
|
|
|
function common_cb_xmlcp_end_headline($h_parser, $tagname) { |
|
|
|
|
|
global $xmlcp_cdata; |
|
|
|
|
|
common_headline(trim($xmlcp_cdata)); |
|
|
|
|
|
$xmlcp_cdata = ''; |
|
|
|
|
|
} |
|
|
|
|
|
function common_cb_xmlcp_start_headline($h_parser, $tagname, $attribs) { |
|
|
|
|
|
global $xmlcp_cdata; |
|
|
|
|
|
$xmlcp_cdata = ''; |
|
|
|
|
|
} |
|
|
|
|
|
function common_cb_xmlcp_end_paragraph($h_parser, $tagname) { |
|
|
|
|
|
global $xmlcp_cdata; |
|
|
|
|
|
common_paragraph(trim($xmlcp_cdata)); |
|
|
|
|
|
$xmlcp_cdata = ''; |
|
|
|
|
|
} |
|
|
|
|
|
function common_cb_xmlcp_start_paragraph($h_parser, $tagname, $attribs) { |
|
|
|
|
|
global $xmlcp_cdata; |
|
|
|
|
|
$xmlcp_cdata = ''; |
|
|
|
|
|
} |
|
|
|
|
|
//---------------------------------------------------------- |
|
|
|
|
|
//- ML functions: |
|
|
|
|
|
function common_codeparagraph($contents) { |
|
|
|
|
|
echo '<p align="justify" class="hl11"> |
|
|
<code> |
|
|
' . $contents . ' |
|
|
</code> |
|
|
</p> |
|
298 |
|
|
299 |
'; |
return $common['dbc']['dbconnected']; |
|
|
|
|
} |
|
|
|
|
|
//---------------------------------------------------------- |
|
|
|
|
|
function common_headline($caption) { |
|
|
|
|
|
echo '<h4>' . $caption . '</h4> |
|
|
|
|
|
'; |
|
300 |
|
|
301 |
} |
} |
302 |
|
|
303 |
//---------------------------------------------------------- |
function common_dbc_query($sql) { |
|
|
|
|
function common_page($keyname, $language_id = 0) { |
|
304 |
|
|
305 |
global $common; |
global $common; |
306 |
|
|
307 |
common_benchmark_addstep('COMMON: PAGE: start'); |
if(!$common['dbc']['dbconnected']) return false; |
|
|
|
|
$list = cms_getlist('xmlpage', $keyname); |
|
|
|
|
|
common_benchmark_addstep('COMMON: PAGE: CMS get list'); |
|
|
|
|
|
$contentdata = cms_getcontent('xmlpage', $keyname, $language_id); |
|
|
|
|
|
common_benchmark_addstep('COMMON: PAGE: CMS get content'); |
|
|
|
|
|
$xml = $contentdata['content']; |
|
|
|
|
|
common_pageheader(); |
|
|
|
|
|
common_benchmark_addstep('COMMON: PAGE: header'); |
|
|
|
|
|
if($xml) { |
|
|
|
|
|
$titledata = ''; |
|
|
|
|
|
for($i = 0; $i < count($list); $i++) { |
|
|
|
|
|
$imgtag = '<img border="0" height="12" src="' . $common['site']['gfxurl'] . 'icons/flags/' . $list[$i][3] . '.gif" width="17" />'; |
|
|
|
|
|
$titledata .= ($i ? ' |
|
|
' : '') . (($language_id == $list[$i][3]) ? $imgtag : '<a href="?li=' . $list[$i][3] . '">' . $imgtag . '</a>'); |
|
|
|
|
|
} |
|
|
|
|
|
common_pagetitle($contentdata['description'], $titledata . '<br />'); |
|
|
|
|
|
xmlcp_xmlpage2html($xml); |
|
|
|
|
|
common_benchmark_addstep('COMMON: PAGE: xmlpage2html'); |
|
|
|
|
|
/* |
|
|
common_headline('$list array, readable:'); |
|
|
common_codeparagraph('$list = ' . nl2br(htmlentities(print_r($list, true)))); |
|
|
|
|
|
common_headline('$contentdata array, readable:'); |
|
|
common_codeparagraph('$contentdata = ' . nl2br(htmlentities(print_r($contentdata, true)))); |
|
|
|
|
|
common_headline('$common array, readable:'); |
|
|
common_codeparagraph('$common = ' . nl2br(htmlentities(print_r($common, true)))); |
|
308 |
|
|
309 |
common_headline('$common_sessiondata array, readable:'); |
$res = mysql_query($sql); |
|
common_codeparagraph('$common_sessiondata = ' . nl2br(htmlentities(print_r($common_sessiondata, true)))); |
|
|
|
|
|
common_headline('Content XML:'); |
|
|
common_codeparagraph(nl2br(htmlentities($xml))); |
|
310 |
|
|
311 |
*/ |
if($errormsg = mysql_error()) { |
312 |
|
|
313 |
// Only show the informations when "devstate" is set: |
// >>> MTC <<< |
|
if($common['hostsetup']['devstate']) { |
|
314 |
|
|
315 |
common_paragraph('<small> |
echo $errormsg . '<br /> |
|
<b>Content informations:</b><br /> |
|
316 |
<br /> |
<br /> |
|
Description: "<b>' . $contentdata['description'] . '</b>" (Type: "xmlpage")<br /> |
|
|
Creator: "<b>' . $contentdata['creator_name'] . '</b>"<br /> |
|
|
Date, Time: "<b>' . date('d.m.Y, H:i:s', $contentdata['unixtime']) . '</b>"<br /> |
|
|
Language: "<b>' . $contentdata['language_name'] . '</b>"<br /> |
|
|
XML content size: <b>' . strlen($xml) . '</b> bytes |
|
|
</small>', 'box2'); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
common_pagetitle('Bad content request'); |
|
|
|
|
|
common_paragraph('Sorry, but the requested content is unknown.'); |
|
|
|
|
|
} |
|
|
|
|
|
common_benchmark_addstep('COMMON: PAGE: content'); |
|
|
|
|
|
common_pagefooter(); |
|
|
|
|
|
} |
|
|
|
|
|
//---------------------------------------------------------- |
|
|
|
|
|
function common_pageheader() { |
|
|
|
|
|
global $common, $common_sessiondata; |
|
|
|
|
|
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
|
|
|
|
<head> |
|
|
<title>www.netfrag.org</title> |
|
|
<style type="text/css"><!-- |
|
|
body, input, table { font: 10pt verdana, serif; } |
|
|
h4 { font-size:12pt; } |
|
|
input { border:1px; } |
|
|
small { font-size:8pt; } |
|
|
.bg11, .box1, .f11, .hl11 { background-color:#50f8f0; } |
|
|
.bg12, .f12 { background-color:#40e8e0; } |
|
|
.bg13 { background-color:#20a0c0; } |
|
|
.bg21, .box2, .f21, .hl21 { background-color:#90fff0; } |
|
|
.bg22, .f22 { background-color:#80f0e0; } |
|
|
.bg23 { background-color:#40c080; } |
|
|
.box1, .f11, .f12 { border:2px solid #20a0c0; } |
|
|
.box2, .f21, .f22 { border:1px solid #40c080; } |
|
|
.box1, .box2, .hl11, .hl21 { padding:4px; } |
|
|
--></style> |
|
|
</head> |
|
|
|
|
|
<body> |
|
|
|
|
|
<form action="" method="post"> |
|
|
<table cellspacing="0" cellpadding="0" width="100%"> |
|
|
<tr> |
|
|
<th class="box1" width="100%"> |
|
|
<font size="5" style="letter-spacing:4pt;"><b>www.netfrag.org</b></font> |
|
|
</td> |
|
|
<td> </td> |
|
|
<td> |
|
|
<table cellspacing="0" cellpadding="2" class="f22"> |
|
|
<tr> |
|
|
<th class="box2" rowspan="2"><b>User<br />login</b></th> |
|
|
<td> User:</td><td><input name="un" size="8" type="text" value="' . $common_sessiondata['userdata']['name'] . '" /></td> |
|
|
<td rowspan="2"><input type="submit" value="Go" /> </td> |
|
|
<tr> |
|
|
<td> Pass:</td><td><input name="pw" size="8" type="password" /></td> |
|
|
</tr> |
|
|
</table> |
|
|
</td> |
|
|
</tr> |
|
|
</table> |
|
|
</form> |
|
|
|
|
|
'; |
|
|
|
|
|
} |
|
|
|
|
|
//---------------------------------------------------------- |
|
|
|
|
|
function common_pagefooter() { |
|
|
|
|
|
global $common; |
|
|
|
|
|
// Only show the benchmark list when "devstate" is set: |
|
|
if($common['hostsetup']['devstate']) { |
|
|
|
|
|
$contents = ''; |
|
|
|
|
|
for($i = 0; $i < count($common['benchmark']); $i++) { |
|
|
|
|
|
$mtimesegs = explode(' ', $common['benchmark'][$i][1]); |
|
|
$contents .= '"<b>' . $common['benchmark'][$i][0] . '</b>": '; |
|
|
|
|
|
if($i) { |
|
|
|
|
|
$timediff = (float)($mtimesegs[1] - $lastmtimesegs[1]); |
|
|
$timediff += $mtimesegs[0] - $lastmtimesegs[0]; |
|
|
|
|
|
$contents .= '<b>+' . round($timediff * 1000000) / 1000 . '</b> ms<br /> |
|
317 |
'; |
'; |
318 |
|
|
|
} else { |
|
|
|
|
|
$contents .= 'Start time: <b>' . date('H:i:s', $mtimesegs[1]) . substr($mtimesegs[0], 1, 4) . '</b><br /> |
|
|
'; |
|
|
|
|
|
} |
|
|
|
|
|
$lastmtimesegs = $mtimesegs; |
|
|
|
|
|
} |
|
|
|
|
|
common_paragraph('<small> |
|
|
<b>Partial execution times:</b><br /> |
|
|
<br /> |
|
|
' . $contents . '</small>', 'box2'); |
|
|
|
|
319 |
} |
} |
320 |
|
|
321 |
common_benchmark_addstep('COMMON: page footer'); |
if(!$res) return false; |
|
|
|
|
$endmtimesegs = explode(' ', microtime()); |
|
|
$startmtimesegs = explode(' ', $common['benchmark'][0][1]); |
|
|
$timediff = (float)($endmtimesegs[1] - $startmtimesegs[1]); |
|
|
$timediff += $endmtimesegs[0] - $startmtimesegs[0]; |
|
|
|
|
|
$devstate = $common['hostsetup']['devstate']; |
|
|
|
|
|
echo '<table cellspacing="0" cellpadding="0" class="box1" width="100%"> |
|
|
<tr> |
|
|
<td valign="top"> |
|
|
Page execution time: <code>' . round($timediff * 100000) / 100 . '</code> ms.<br /> |
|
|
[ ' . ($devstate ? '<a href="?devstate=0">devstate off</a>' : '<a href="?devstate=1">devstate on</a>') . ' ] |
|
|
</td> |
|
|
<td align="right" valign="middle"><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> |
|
|
<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></td> |
|
|
</tr> |
|
|
</table> |
|
|
|
|
|
</body> |
|
322 |
|
|
323 |
</html> |
return $res; |
|
'; |
|
324 |
|
|
325 |
} |
} |
326 |
|
|
327 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
328 |
|
//- File functions: |
|
function common_pagetitle($title, $additionalcontents = '') { |
|
|
|
|
|
echo '<p class="box2"> |
|
|
<big><b>• ' . $title . '</b> </big> |
|
|
' . ($additionalcontents ? $additionalcontents . ' |
|
|
' : '') . '</p> |
|
|
|
|
|
'; |
|
|
|
|
|
} |
|
329 |
|
|
330 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
331 |
|
//- Utility functions: |
332 |
function common_paragraph($contents, $class = '') { |
function common_get_baseurl() { |
333 |
|
$baseurl = "http://" . $_SERVER['SERVER_NAME'] . "" . $_SERVER['SCRIPT_NAME'] . "/"; |
334 |
echo '<p align="justify"' . ($class ? ' class="' . $class . '"' : '') . '> |
return $baseurl; |
|
' . $contents . ' |
|
|
</p> |
|
|
|
|
|
'; |
|
|
|
|
335 |
} |
} |
336 |
|
|
337 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
338 |
|
|
339 |
common_benchmark_addstep('COMMON: end'); |
common_benchmark_addstep('common: end'); |
340 |
|
|
341 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
342 |
|
|