| 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 |
|
|
| 67 |
|
// Paths: |
| 68 |
$common['site']['docroot'] = $_SERVER['DOCUMENT_ROOT'] . $common['hostsetup']['urlrel']; |
$common['site']['docroot'] = $_SERVER['DOCUMENT_ROOT'] . $common['hostsetup']['urlrel']; |
| 69 |
$common['site']['incroot'] = $common['site']['docroot'] . 'inc/'; |
$common['site']['incroot'] = $common['site']['docroot'] . 'inc/'; |
| 70 |
|
$common['site']['libroot'] = $common['site']['docroot'] . 'libs/'; |
| 71 |
|
|
| 72 |
|
// URLs: |
| 73 |
|
$common['site']['url'] = 'http://' . $_SERVER['HTTP_HOST'] . $common['hostsetup']['urlrel']; |
| 74 |
|
$common['site']['gfxurl'] = $common['site']['url'] . 'gfx/'; |
| 75 |
|
|
| 76 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
| 77 |
//- Page variable setups: |
//- Page variable setups: |
| 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(!isset($common['client']['session_enabled'])) { |
|
session_cache_limiter('nocache'); |
|
| 106 |
|
|
| 107 |
// This is neccessary to make the $_SESSION global available: |
// Neither proxies, nor the clients are allowed to cache session data: |
| 108 |
session_start(); |
session_cache_limiter('nocache'); |
| 109 |
|
|
| 110 |
|
// This is neccessary to make the $_SESSION global available: |
| 111 |
|
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 |
|
|
| 125 |
'birthtime' => time(), |
'birthtime' => time(), |
| 126 |
'firstrequest' => 1, // Mark the very first page request. |
'firstrequest' => 1, // Mark the very first page request. |
| 127 |
|
|
| 128 |
|
// User data and authorisation: |
| 129 |
|
'user_auth' => array( |
| 130 |
|
'name' => '', |
| 131 |
|
'password' => '', |
| 132 |
|
'authorised' => false |
| 133 |
|
), |
| 134 |
|
|
| 135 |
|
// User preferences and preferred settings: |
| 136 |
|
'user_prefs' => array( |
| 137 |
|
'benchlist' => null, |
| 138 |
|
'debug' => null, |
| 139 |
|
'language_id' => null, |
| 140 |
|
'outputtype' => null |
| 141 |
|
), |
| 142 |
|
|
| 143 |
|
// Content related additional data: |
| 144 |
'additionaldata' => array() |
'additionaldata' => array() |
| 145 |
|
|
| 146 |
); |
); |
| 147 |
|
|
| 148 |
common_benchmark_addstep('COMMON: New session: create session'); |
common_benchmark_addstep('common: New session: create session'); |
| 149 |
|
|
| 150 |
// Protocol the visitors hit and store the columns insertion ID: |
// Protocol the visitors hit and store the columns insertion ID: |
| 151 |
$common_sessiondata['hit_id'] = common_protocolhit(); |
$common_sessiondata['hit_id'] = common_protocolhit(); |
| 152 |
|
|
| 153 |
common_benchmark_addstep('COMMON: New session: protocol hit'); |
common_benchmark_addstep('common: New session: protocol hit'); |
| 154 |
|
|
| 155 |
// Store a reference to the session data array: |
// Store a reference to the session data array: |
| 156 |
$_SESSION['common_sessiondata'] = &$common_sessiondata; |
$_SESSION['common_sessiondata'] = &$common_sessiondata; |
| 157 |
|
|
| 158 |
common_benchmark_addstep('COMMON: New session: store session/end'); |
common_benchmark_addstep('common: New session: store session/end'); |
| 159 |
|
|
| 160 |
} else { |
} else { |
| 161 |
|
|
| 167 |
|
|
| 168 |
// Update the request count in the "hits" table: |
// Update the request count in the "hits" table: |
| 169 |
|
|
| 170 |
$sql = "UPDATE hits SET requestcount=requestcount+1 WHERE id='" . $common_sessiondata['hit_id'] . "';"; |
$sql = "UPDATE hits SET requestcount=requestcount+1, lastrequest=NOW() WHERE id='" . $common_sessiondata['hit_id'] . "';"; |
| 171 |
|
|
| 172 |
mysql_query($sql); |
common_dbc_query($sql); |
| 173 |
|
|
| 174 |
common_benchmark_addstep('COMMON: session/hit data updated'); |
common_benchmark_addstep('common: session/hit data updated'); |
| 175 |
|
|
| 176 |
} |
} |
| 177 |
|
|
| 178 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
| 179 |
//- Functions: |
//- Functions: |
| 180 |
|
|
| 181 |
function common_protocolhit() { |
function common_authorise($username, $password) { |
| 182 |
|
|
| 183 |
global $common, $common_sessiondata; |
global $common_sessiondata; |
| 184 |
|
|
| 185 |
$address = $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER["REMOTE_PORT"]; |
if((strlen($username) < 2) || (strlen($password) < 2)) return false; |
|
$entryurl = $_SERVER['REQUEST_URI']; |
|
|
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''); |
|
|
$sessionid = session_id(); |
|
|
$unixtime = $common_sessiondata['birthtime']; |
|
|
$timestamp = date('YmdHis', $common_sessiondata['birthtime']); |
|
|
$useragent = $_SERVER['HTTP_USER_AGENT']; |
|
| 186 |
|
|
| 187 |
$sql = "INSERT INTO hits (id, timestamp, address, entryurl, referer, sessionid, useragent, requestcount) VALUES (DEFAULT, FROM_UNIXTIME('$unixtime'), '$address', '$entryurl', '$referer', '$sessionid', '$useragent', '1');"; |
$sql = "SELECT id, rights, logincount, lastlogin FROM users WHERE name='$username' AND password='$password';"; |
| 188 |
|
|
| 189 |
$res = mysql_query($sql); |
$res = common_dbc_query($sql); |
| 190 |
|
|
| 191 |
if(!$res) return false; |
if(!$res) return false; |
| 192 |
|
|
| 193 |
return mysql_insert_id($common['dbc']['h_myqsllink']); |
if(!($row = mysql_fetch_row($res))) return false; |
| 194 |
|
|
| 195 |
} |
// Congratulations - authorisation suxxessful! |
| 196 |
|
|
| 197 |
//---------------------------------------------------------- |
$common_sessiondata['user_auth']['authorised'] = true; |
| 198 |
|
|
| 199 |
//- Database functions: |
$common_sessiondata['user_auth']['name'] = $username; |
| 200 |
|
$common_sessiondata['user_auth']['password'] = $password; |
| 201 |
|
|
| 202 |
function common_dbc_connect() { |
$logintime = time(); |
| 203 |
|
|
| 204 |
global $common; |
$userid = $row[0]; |
| 205 |
|
$rights = $row[1]; |
| 206 |
|
$logincount = $row[2] + 1; |
| 207 |
|
$lastlogin = $row[3]; |
| 208 |
|
|
| 209 |
$common['dbc']['connected'] = false; |
$common_sessiondata['user_auth']['id'] = $userid; |
| 210 |
|
$common_sessiondata['user_auth']['lastlogin'] = $lastlogin; |
| 211 |
|
$common_sessiondata['user_auth']['rights'] = $rights; |
| 212 |
|
|
| 213 |
$h_myqsllink = mysql_pconnect( |
// Break if the user already has authorised in this session: |
| 214 |
$common['hostsetup']['mysql_host'], |
if(isset($common_sessiondata['user_auth']['logintime'])) return false; |
|
$common['hostsetup']['mysql_user'], |
|
|
$common['hostsetup']['mysql_pass'] |
|
|
); |
|
|
|
|
|
if(!$h_myqsllink) return false; |
|
| 215 |
|
|
| 216 |
$common['dbc']['connected'] = true; |
$common_sessiondata['user_auth']['logincount'] = $logincount; |
| 217 |
$common['dbc']['h_myqsllink'] = $h_myqsllink; |
$common_sessiondata['user_auth']['logintime'] = $logintime; |
| 218 |
|
|
| 219 |
return true; |
// Protocol the login: |
| 220 |
|
common_protocollogin(); |
| 221 |
|
|
| 222 |
} |
$sql = "UPDATE users SET logincount='$logincount', lastlogin=FROM_UNIXTIME('$logintime') WHERE id='$userid';"; |
| 223 |
|
|
| 224 |
function common_dbc_selectdb() { |
$res = common_dbc_query($sql); |
| 225 |
|
|
| 226 |
global $common; |
if(!$res) return false; |
|
|
|
|
$common['dbc']['dbselected'] = false; |
|
|
|
|
|
if( |
|
|
!mysql_selectdb($common['hostsetup']['mysql_db']) |
|
|
) return false; |
|
|
|
|
|
$common['dbc']['dbselected'] = true; |
|
| 227 |
|
|
| 228 |
return true; |
return true; |
| 229 |
|
|
| 230 |
} |
} |
| 231 |
|
|
| 232 |
function common_dbc_connectdb() { |
//------------------------------------------------------------------------------ |
|
|
|
|
return (common_dbc_connect() && common_dbc_selectdb()); |
|
|
|
|
|
} |
|
|
|
|
|
//---------------------------------------------------------- |
|
|
|
|
|
//- File functions: |
|
|
|
|
|
function common_include($filename) { |
|
|
|
|
|
global $common; |
|
|
|
|
|
return include($common['site']['incroot'] . $filename); |
|
|
|
|
|
} |
|
|
|
|
|
//---------------------------------------------------------- |
|
|
|
|
|
//- 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) { |
|
| 233 |
|
|
| 234 |
global $xmlcp_cdata; |
function common_protocolhit() { |
| 235 |
|
|
| 236 |
common_headline(trim($xmlcp_cdata)); |
global $common, $common_sessiondata; |
| 237 |
|
|
| 238 |
$xmlcp_cdata = ''; |
$address = $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER["REMOTE_PORT"]; |
| 239 |
|
$entryurl = $_SERVER['REQUEST_URI']; |
| 240 |
|
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''); |
| 241 |
|
$sessionid = session_id(); |
| 242 |
|
$unixtime = $common_sessiondata['birthtime']; |
| 243 |
|
$useragent = $_SERVER['HTTP_USER_AGENT']; |
| 244 |
|
|
| 245 |
} |
$sql = "INSERT INTO hits (id, timestamp, address, entryurl, referer, sessionid, useragent, requestcount, lastrequest) VALUES (NULL, FROM_UNIXTIME('$unixtime'), '$address', '$entryurl', '$referer', '$sessionid', '$useragent', '1', FROM_UNIXTIME('$unixtime'));"; |
| 246 |
|
|
| 247 |
function common_cb_xmlcp_start_headline($h_parser, $tagname, $attribs) { |
$res = common_dbc_query($sql); |
| 248 |
|
|
| 249 |
global $xmlcp_cdata; |
if(!$res) return false; |
| 250 |
|
|
| 251 |
$xmlcp_cdata = ''; |
return mysql_insert_id($common['dbc']['h_myqsllink']); |
| 252 |
|
|
| 253 |
} |
} |
| 254 |
|
|
| 255 |
function common_cb_xmlcp_end_paragraph($h_parser, $tagname) { |
function common_protocollogin() { |
| 256 |
|
|
| 257 |
global $xmlcp_cdata; |
global $common_sessiondata; |
| 258 |
|
|
| 259 |
common_paragraph(trim($xmlcp_cdata)); |
$hitid = $common_sessiondata['hit_id']; |
| 260 |
|
$sessionid = session_id(); |
| 261 |
$xmlcp_cdata = ''; |
$logintime = $common_sessiondata['user_auth']['logintime']; |
| 262 |
|
$userid = $common_sessiondata['user_auth']['id']; |
| 263 |
|
|
| 264 |
} |
$sql = "INSERT INTO logins (id, timestamp, user_id, sessionid, hit_id) VALUES (NULL, FROM_UNIXTIME('$logintime'), '$userid', '$sessionid', '$hitid');"; |
| 265 |
|
|
| 266 |
function common_cb_xmlcp_start_paragraph($h_parser, $tagname, $attribs) { |
$res = common_dbc_query($sql); |
| 267 |
|
|
| 268 |
global $xmlcp_cdata; |
if(!$res) return false; |
| 269 |
|
|
| 270 |
$xmlcp_cdata = ''; |
return true; |
| 271 |
|
|
| 272 |
} |
} |
| 273 |
|
|
| 274 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
| 275 |
|
//- Database functions: |
| 276 |
|
|
| 277 |
//- ML functions: |
function common_dbc_connect() { |
|
|
|
|
function common_codeparagraph($contents) { |
|
|
|
|
|
echo '<p align="justify" class="hl"> |
|
|
<code> |
|
|
' . $contents . ' |
|
|
</code> |
|
|
</p> |
|
| 278 |
|
|
| 279 |
'; |
global $common; |
| 280 |
|
|
| 281 |
} |
$common['dbc']['connected'] = false; |
| 282 |
|
|
| 283 |
//---------------------------------------------------------- |
$h_myqsllink = mysql_pconnect( |
| 284 |
|
$common['hostsetup']['mysql_host'], |
| 285 |
|
$common['hostsetup']['mysql_user'], |
| 286 |
|
$common['hostsetup']['mysql_pass'] |
| 287 |
|
); |
| 288 |
|
|
| 289 |
function common_headline($caption) { |
if(!$h_myqsllink) return false; |
| 290 |
|
|
| 291 |
echo '<h4>' . $caption . '</h4> |
$common['dbc']['connected'] = true; |
| 292 |
|
$common['dbc']['h_myqsllink'] = $h_myqsllink; |
| 293 |
|
|
| 294 |
'; |
return true; |
| 295 |
|
|
| 296 |
} |
} |
| 297 |
|
|
| 298 |
//---------------------------------------------------------- |
function common_dbc_selectdb() { |
|
|
|
|
function common_page($keyname, $language_id = 0) { |
|
| 299 |
|
|
| 300 |
global $common; |
global $common; |
| 301 |
|
|
| 302 |
common_benchmark_addstep('COMMON: PAGE: start'); |
$common['dbc']['dbselected'] = 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++) { |
|
|
|
|
|
$titledata .= ($i ? ' · ' : '') . '<a href="?li=' . $list[$i][3] . '">' . $list[$i][4] . '</a>'; |
|
|
|
|
|
} |
|
|
|
|
|
common_pagetitle($contentdata['description'], $titledata); |
|
|
|
|
|
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)))); |
|
|
|
|
|
common_headline('$common_sessiondata array, readable:'); |
|
|
common_codeparagraph('$common_sessiondata = ' . nl2br(htmlentities(print_r($common_sessiondata, true)))); |
|
|
|
|
|
common_headline('Content XML:'); |
|
|
common_codeparagraph(nl2br(htmlentities($xml))); |
|
|
|
|
|
*/ |
|
|
|
|
|
// Only show the informations when "devstate" is set: |
|
|
if($common['hostsetup']['devstate']) { |
|
|
|
|
|
common_paragraph('<small> |
|
|
<b>Content informations:</b><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.'); |
|
| 303 |
|
|
| 304 |
} |
if( |
| 305 |
|
!mysql_selectdb($common['hostsetup']['mysql_db']) |
| 306 |
|
) return false; |
| 307 |
|
|
| 308 |
common_benchmark_addstep('COMMON: PAGE: content'); |
$common['dbc']['dbselected'] = true; |
| 309 |
|
|
| 310 |
common_pagefooter(); |
return true; |
| 311 |
|
|
| 312 |
} |
} |
| 313 |
|
|
| 314 |
//---------------------------------------------------------- |
function common_dbc_connectdb() { |
|
|
|
|
function common_pageheader() { |
|
| 315 |
|
|
| 316 |
global $common; |
global $common; |
| 317 |
|
|
| 318 |
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
$common['dbc']['dbconnected'] = (common_dbc_connect() && common_dbc_selectdb()); |
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
|
|
|
|
<head> |
|
|
<title>www.netfrag.org</title> |
|
|
<style type="text/css"><!-- |
|
|
body { font: 11pt verdana, serif; } |
|
|
h2 { text-align:center; } |
|
|
h2, .box, .box2, .hl { padding:8px; } |
|
|
h2, .box, .hl { background-color:#40f0f0; } |
|
|
h2, .box { border:2px solid #20a0c0; } |
|
|
h4 { font-size:12pt; } |
|
|
small { font-size:8pt; } |
|
|
.box2 { background-color:#80fff0; border:1px solid #40c080; } |
|
|
--></style> |
|
|
</head> |
|
| 319 |
|
|
| 320 |
<body> |
return $common['dbc']['dbconnected']; |
|
|
|
|
<h2>www.netfrag.org</h2> |
|
|
|
|
|
'; |
|
| 321 |
|
|
| 322 |
} |
} |
| 323 |
|
|
| 324 |
//---------------------------------------------------------- |
function common_dbc_query($sql) { |
|
|
|
|
function common_pagefooter() { |
|
| 325 |
|
|
| 326 |
global $common; |
global $common; |
| 327 |
|
|
| 328 |
// Only show the benchmark list when "devstate" is set: |
if(!$common['dbc']['dbconnected']) return false; |
|
if($common['hostsetup']['devstate']) { |
|
|
|
|
|
$contents = ''; |
|
|
|
|
|
for($i = 0; $i < count($common['benchmark']); $i++) { |
|
| 329 |
|
|
| 330 |
$mtimesegs = explode(' ', $common['benchmark'][$i][1]); |
$res = mysql_query($sql); |
|
$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 /> |
|
|
'; |
|
|
|
|
|
} else { |
|
|
|
|
|
$contents .= 'Start time: <b>' . date('H:i:s', $mtimesegs[1]) . substr($mtimesegs[0], 1, 4) . '</b><br /> |
|
|
'; |
|
|
|
|
|
} |
|
| 331 |
|
|
| 332 |
$lastmtimesegs = $mtimesegs; |
if($errormsg = mysql_error()) { |
| 333 |
|
|
| 334 |
} |
// >>> MTC <<< |
| 335 |
|
|
| 336 |
common_paragraph('<small> |
echo $errormsg . '<br /> |
|
<b>Partial execution times:</b><br /> |
|
| 337 |
<br /> |
<br /> |
| 338 |
' . $contents . '</small>', 'box2'); |
'; |
| 339 |
|
|
| 340 |
} |
} |
| 341 |
|
|
| 342 |
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]; |
|
|
|
|
|
echo '<table cellspacing="0" cellpadding="0" class="box" width="100%"> |
|
|
<tr> |
|
|
<td valign="top"> |
|
|
Page execution time: <code>' . round($timediff * 100000) / 100 . '</code> ms. |
|
|
</td> |
|
|
<td align="right"><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> |
|
| 343 |
|
|
| 344 |
</html> |
return $res; |
|
'; |
|
| 345 |
|
|
| 346 |
} |
} |
| 347 |
|
|
| 348 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
| 349 |
|
//- File functions: |
|
function common_pagetitle($title, $additionalcontents = '') { |
|
|
|
|
|
echo '<p class="box2"> |
|
|
<big><b>• ' . $title . '</b></big><br /> |
|
|
' . ($additionalcontents ? $additionalcontents . ' |
|
|
' : '') . '</p> |
|
|
|
|
|
'; |
|
|
|
|
|
} |
|
| 350 |
|
|
| 351 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
| 352 |
|
//- Utility functions: |
| 353 |
|
|
| 354 |
function common_paragraph($contents, $class = '') { |
function common_get_baseurl() { |
| 355 |
|
|
| 356 |
echo '<p align="justify"' . ($class ? ' class="' . $class . '"' : '') . '> |
global $common; |
|
' . $contents . ' |
|
|
</p> |
|
| 357 |
|
|
| 358 |
'; |
return $common['site']['url']; |
| 359 |
|
|
| 360 |
} |
} |
| 361 |
|
|
| 362 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
| 363 |
|
|
| 364 |
common_benchmark_addstep('COMMON: end'); |
common_benchmark_addstep('common: end'); |
| 365 |
|
|
| 366 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
| 367 |
|
|