| 4 |
--- Setup and common functions include file. |
--- Setup and common functions include file. |
| 5 |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
| 6 |
--- rabit, 04:31 24.08.2004 |
--- rabit, 04:31 24.08.2004 |
| 7 |
--- $$id$$ |
--- $Id$ |
| 8 |
------------------------------------------------------------------------------*/ |
------------------------------------------------------------------------------*/ |
| 9 |
|
|
| 10 |
|
//------------------------------------------------------------------------------ |
| 11 |
|
//- Benchmarking: |
| 12 |
|
|
| 13 |
|
// Create the benchmark steps array inside "$common": |
| 14 |
|
$common['benchmark'] = array(); |
| 15 |
|
|
| 16 |
|
function common_benchmark_addstep($caption) { |
| 17 |
|
|
| 18 |
|
global $common; |
| 19 |
|
|
| 20 |
|
$step = array($caption, microtime()); |
| 21 |
|
|
| 22 |
|
array_push($common['benchmark'], $step); |
| 23 |
|
|
| 24 |
|
} |
| 25 |
|
|
| 26 |
|
// The starting entry in the benchmark steps list: |
| 27 |
|
common_benchmark_addstep('COMMON: start'); |
| 28 |
|
|
| 29 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
| 30 |
//- Developer host setup: |
//- Developer host setups: |
| 31 |
|
|
| 32 |
$cfg['hostsetups'] = array( |
$hostsetups = array( |
| 33 |
|
|
| 34 |
'default' => array( |
'default' => array( |
| 35 |
'urlrel' => '/nfo/', |
'urlrel' => '/nfo/', |
| 36 |
|
'devstate' => false, |
| 37 |
|
'mysql_host' => 'localhost', |
| 38 |
|
'mysql_user' => 'nfo', |
| 39 |
|
'mysql_pass' => 'b2-cV5RF', |
| 40 |
|
'mysql_db' => 'nfo' |
| 41 |
), |
), |
| 42 |
|
|
| 43 |
'psl.no-ip.com' => array( |
'psl.no-ip.com' => array( |
| 44 |
'urlrel' => '/work/www.netfrag.org/', |
'urlrel' => '/work/www.netfrag.org/', |
| 45 |
|
'devstate' => true, |
| 46 |
|
'mysql_host' => 'localhost', |
| 47 |
|
'mysql_user' => 'php', |
| 48 |
|
'mysql_pass' => 'A289tpQ1', |
| 49 |
|
'mysql_db' => 'nfo' |
| 50 |
), |
), |
| 51 |
|
|
| 52 |
); |
); |
| 53 |
|
|
| 54 |
if(isset($cfg['hostsetups'][$_SERVER['SERVER_NAME']])) { |
// Set the default host setup: |
| 55 |
|
$common['hostsetup'] = $hostsetups['default']; |
| 56 |
|
|
| 57 |
|
// Set the host setup if a listed host name is given: |
| 58 |
|
if(isset($hostsetups[$_SERVER['SERVER_NAME']])) $common['hostsetup'] = $hostsetups[$_SERVER['SERVER_NAME']]; |
| 59 |
|
|
| 60 |
|
unset($hostsetups); |
| 61 |
|
|
| 62 |
|
//---------------------------------------------------------- |
| 63 |
|
//- Site variable setups: |
| 64 |
|
|
| 65 |
|
// Paths: |
| 66 |
|
$common['site']['docroot'] = $_SERVER['DOCUMENT_ROOT'] . $common['hostsetup']['urlrel']; |
| 67 |
|
$common['site']['incroot'] = $common['site']['docroot'] . 'inc/'; |
| 68 |
|
$common['site']['libroot'] = $common['site']['docroot'] . 'libs/'; |
| 69 |
|
|
| 70 |
|
// URLs: |
| 71 |
|
$common['site']['url'] = 'http://' . $_SERVER['HTTP_HOST'] . $common['hostsetup']['urlrel']; |
| 72 |
|
$common['site']['gfxurl'] = $common['site']['url'] . 'gfx/'; |
| 73 |
|
|
| 74 |
|
//---------------------------------------------------------- |
| 75 |
|
//- Page variable setups: |
| 76 |
|
|
| 77 |
|
$common['page']['filename'] = substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], '/') + 1); |
| 78 |
|
$common['page']['url'] = $_SERVER['PHP_SELF']; |
| 79 |
|
|
| 80 |
|
common_benchmark_addstep('COMMON: setup'); |
| 81 |
|
|
| 82 |
|
//------------------------------------------------------------------------------ |
| 83 |
|
//- Includes: |
| 84 |
|
|
| 85 |
|
//common_include('cfg/cfg.php.inc'); |
| 86 |
|
//common_benchmark_addstep('COMMON: CFG included'); |
| 87 |
|
|
| 88 |
|
common_include('xmlcp/xmlcp.php.inc'); |
| 89 |
|
common_benchmark_addstep('COMMON: XMLCP included'); |
| 90 |
|
|
| 91 |
|
common_include('cms/cms.php.inc'); |
| 92 |
|
common_benchmark_addstep('COMMON: CMS included'); |
| 93 |
|
|
| 94 |
|
//------------------------------------------------------------------------------ |
| 95 |
|
//- MySQL connection: |
| 96 |
|
|
| 97 |
|
$common['dbc']['dbconnected'] = common_dbc_connectdb(); |
| 98 |
|
|
| 99 |
|
common_benchmark_addstep('COMMON: connect database'); |
| 100 |
|
|
| 101 |
|
//------------------------------------------------------------------------------ |
| 102 |
|
//- Session setup: |
| 103 |
|
|
| 104 |
|
// Neither proxies, nor the clients are allowed to cache session data: |
| 105 |
|
session_cache_limiter('nocache'); |
| 106 |
|
|
| 107 |
$cfg['hostsetup'] = $cfg['hostsetups'][$_SERVER['SERVER_NAME']]; |
// This is neccessary to make the $_SESSION global available: |
| 108 |
|
session_start(); |
| 109 |
|
|
| 110 |
|
common_benchmark_addstep('COMMON: session init'); |
| 111 |
|
|
| 112 |
|
if(!isset($_SESSION['common_sessiondata'])) { |
| 113 |
|
|
| 114 |
|
// The session variable isn't set, create it: |
| 115 |
|
|
| 116 |
|
common_benchmark_addstep('COMMON: New session: start'); |
| 117 |
|
|
| 118 |
|
$common_sessiondata = array( |
| 119 |
|
|
| 120 |
|
'birthtime' => time(), |
| 121 |
|
'firstrequest' => 1, // Mark the very first page request. |
| 122 |
|
|
| 123 |
|
// Empty user data sub array: |
| 124 |
|
'userdata' => array( |
| 125 |
|
'name' => '', |
| 126 |
|
'password' => '', |
| 127 |
|
'authorised' => false, |
| 128 |
|
), |
| 129 |
|
|
| 130 |
|
// Content related additional data: |
| 131 |
|
'additionaldata' => array() |
| 132 |
|
|
| 133 |
|
); |
| 134 |
|
|
| 135 |
|
common_benchmark_addstep('COMMON: New session: create session'); |
| 136 |
|
|
| 137 |
|
// Protocol the visitors hit and store the columns insertion ID: |
| 138 |
|
$common_sessiondata['hit_id'] = common_protocolhit(); |
| 139 |
|
|
| 140 |
|
common_benchmark_addstep('COMMON: New session: protocol hit'); |
| 141 |
|
|
| 142 |
|
// Store a reference to the session data array: |
| 143 |
|
$_SESSION['common_sessiondata'] = &$common_sessiondata; |
| 144 |
|
|
| 145 |
|
common_benchmark_addstep('COMMON: New session: store session/end'); |
| 146 |
|
|
| 147 |
} else { |
} else { |
| 148 |
|
|
| 149 |
$cfg['hostsetup'] = $cfg['hostsetups']['default']; |
// Restore the session data array reference: |
| 150 |
|
$common_sessiondata = &$_SESSION['common_sessiondata']; |
| 151 |
|
|
| 152 |
} |
// Reset the first page request flag: |
| 153 |
|
$common_sessiondata['firstrequest'] = null; |
| 154 |
|
|
| 155 |
$documentroot = $_SERVER['DOCUMENT_ROOT'] . $cfg['hostsetup']['urlrel']; |
// Update the request count in the "hits" table: |
| 156 |
|
|
| 157 |
|
$sql = "UPDATE hits SET requestcount=requestcount+1 WHERE id='" . $common_sessiondata['hit_id'] . "';"; |
| 158 |
|
|
| 159 |
|
mysql_query($sql); |
| 160 |
|
|
| 161 |
|
common_benchmark_addstep('COMMON: session/hit data updated'); |
| 162 |
|
|
| 163 |
|
} |
| 164 |
|
|
| 165 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
| 166 |
//- Configuration include file: |
//- URL parameter flags and variables: |
| 167 |
|
|
| 168 |
|
if(isset($_GET['devstate'])) $common_sessiondata['userdata']['devstate'] = $_GET['devstate']; |
| 169 |
|
|
| 170 |
include($documentroot . 'inc/cfg/cfg.php.inc'); |
if(isset($common_sessiondata['userdata']['devstate'])) $common['hostsetup']['devstate'] = $common_sessiondata['userdata']['devstate']; |
| 171 |
|
|
| 172 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
| 173 |
//- Functions: |
//- Functions: |
| 174 |
|
|
| 175 |
|
function common_checkauthorisation() { |
| 176 |
|
|
| 177 |
|
global $common_sessiondata; |
| 178 |
|
|
| 179 |
|
$username = $common_sessiondata['userdata']['name']; |
| 180 |
|
$password = $common_sessiondata['userdata']['password']; |
| 181 |
|
|
| 182 |
|
if((strlen($username) < 2) || (strlen($password) < 2)) return false; |
| 183 |
|
|
| 184 |
|
$sql = "SELECT id, rights, logincount, lastlogin FROM users WHERE name='$username' AND password='$password';"; |
| 185 |
|
|
| 186 |
|
$res = mysql_query($sql); |
| 187 |
|
|
| 188 |
|
if(!$res) return false; |
| 189 |
|
|
| 190 |
|
if(!($row = mysql_fetch_row($res))) return false; |
| 191 |
|
|
| 192 |
|
// Congratulations - authorisation suxxessful! |
| 193 |
|
|
| 194 |
|
$logintime = time(); |
| 195 |
|
|
| 196 |
|
$userid = $row[0]; |
| 197 |
|
$rights = $row[1]; |
| 198 |
|
$logincount = $row[2] + 1; |
| 199 |
|
$lastlogin = $row[3]; |
| 200 |
|
|
| 201 |
|
$common_sessiondata['userdata']['authorised'] = true; |
| 202 |
|
|
| 203 |
|
$common_sessiondata['userdata']['id'] = $userid; |
| 204 |
|
$common_sessiondata['userdata']['lastlogin'] = $lastlogin; |
| 205 |
|
$common_sessiondata['userdata']['rights'] = $rights; |
| 206 |
|
|
| 207 |
|
// Break if the user already has authorised in this session: |
| 208 |
|
if(isset($common_sessiondata['userdata']['logintime'])) return false; |
| 209 |
|
|
| 210 |
|
$common_sessiondata['userdata']['logincount'] = $logincount; |
| 211 |
|
$common_sessiondata['userdata']['logintime'] = $logintime; |
| 212 |
|
|
| 213 |
|
// print_r($common_sessiondata['userdata']); |
| 214 |
|
|
| 215 |
|
$sql = "UPDATE users SET logincount='$logincount', lastlogin=FROM_UNIXTIME('$logintime') WHERE id='$userid';"; |
| 216 |
|
|
| 217 |
|
$res = mysql_query($sql); |
| 218 |
|
|
| 219 |
|
if(!$res) return false; |
| 220 |
|
|
| 221 |
|
return true; |
| 222 |
|
|
| 223 |
|
} |
| 224 |
|
|
| 225 |
|
//------------------------------------------------------------------------------ |
| 226 |
|
|
| 227 |
|
function common_protocolhit() { |
| 228 |
|
|
| 229 |
|
global $common, $common_sessiondata; |
| 230 |
|
|
| 231 |
|
$address = $_SERVER['REMOTE_ADDR'] . ':' . $_SERVER["REMOTE_PORT"]; |
| 232 |
|
$entryurl = $_SERVER['REQUEST_URI']; |
| 233 |
|
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''); |
| 234 |
|
$sessionid = session_id(); |
| 235 |
|
$unixtime = $common_sessiondata['birthtime']; |
| 236 |
|
$useragent = $_SERVER['HTTP_USER_AGENT']; |
| 237 |
|
|
| 238 |
|
$sql = "INSERT INTO hits (id, timestamp, address, entryurl, referer, sessionid, useragent, requestcount) VALUES (NULL, FROM_UNIXTIME('$unixtime'), '$address', '$entryurl', '$referer', '$sessionid', '$useragent', '1');"; |
| 239 |
|
|
| 240 |
|
$res = mysql_query($sql); |
| 241 |
|
|
| 242 |
|
if ($errstr = mysql_error()) { |
| 243 |
|
|
| 244 |
|
print $errstr . "\n"; |
| 245 |
|
|
| 246 |
|
} |
| 247 |
|
|
| 248 |
|
if(!$res) return false; |
| 249 |
|
|
| 250 |
|
return mysql_insert_id($common['dbc']['h_myqsllink']); |
| 251 |
|
|
| 252 |
|
} |
| 253 |
|
|
| 254 |
|
//---------------------------------------------------------- |
| 255 |
|
|
| 256 |
|
//- Database functions: |
| 257 |
|
|
| 258 |
|
function common_dbc_connect() { |
| 259 |
|
|
| 260 |
|
global $common; |
| 261 |
|
|
| 262 |
|
$common['dbc']['connected'] = false; |
| 263 |
|
|
| 264 |
|
$h_myqsllink = mysql_pconnect( |
| 265 |
|
$common['hostsetup']['mysql_host'], |
| 266 |
|
$common['hostsetup']['mysql_user'], |
| 267 |
|
$common['hostsetup']['mysql_pass'] |
| 268 |
|
); |
| 269 |
|
|
| 270 |
|
if(!$h_myqsllink) return false; |
| 271 |
|
|
| 272 |
|
$common['dbc']['connected'] = true; |
| 273 |
|
$common['dbc']['h_myqsllink'] = $h_myqsllink; |
| 274 |
|
|
| 275 |
|
return true; |
| 276 |
|
|
| 277 |
|
} |
| 278 |
|
|
| 279 |
|
function common_dbc_selectdb() { |
| 280 |
|
|
| 281 |
|
global $common; |
| 282 |
|
|
| 283 |
|
$common['dbc']['dbselected'] = false; |
| 284 |
|
|
| 285 |
|
if( |
| 286 |
|
!mysql_selectdb($common['hostsetup']['mysql_db']) |
| 287 |
|
) return false; |
| 288 |
|
|
| 289 |
|
$common['dbc']['dbselected'] = true; |
| 290 |
|
|
| 291 |
|
return true; |
| 292 |
|
|
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
function common_dbc_connectdb() { |
| 296 |
|
|
| 297 |
|
return (common_dbc_connect() && common_dbc_selectdb()); |
| 298 |
|
|
| 299 |
|
} |
| 300 |
|
|
| 301 |
|
//---------------------------------------------------------- |
| 302 |
|
|
| 303 |
|
//- File functions: |
| 304 |
|
|
| 305 |
|
function common_include($filename) { |
| 306 |
|
|
| 307 |
|
global $common; |
| 308 |
|
|
| 309 |
|
return include($common['site']['incroot'] . $filename); |
| 310 |
|
|
| 311 |
|
} |
| 312 |
|
|
| 313 |
|
//---------------------------------------------------------- |
| 314 |
|
|
| 315 |
|
//- XMLCP setup: |
| 316 |
|
|
| 317 |
|
xmlcp_registertagcallbacks('b', 'common_cb_xmlcp_start_bold', 'common_cb_xmlcp_end_bold'); |
| 318 |
|
xmlcp_registertagcallbacks('h', 'common_cb_xmlcp_start_headline', 'common_cb_xmlcp_end_headline'); |
| 319 |
|
xmlcp_registertagcallbacks('p', 'common_cb_xmlcp_start_paragraph', 'common_cb_xmlcp_end_paragraph'); |
| 320 |
|
xmlcp_registertagcallbacks('page', 'common_cb_xmlcp_start_page', 'common_cb_xmlcp_end_page'); |
| 321 |
|
|
| 322 |
|
function common_cb_xmlcp_end_bold($h_parser, $tagname) { |
| 323 |
|
|
| 324 |
|
global $xmlcp_cdata; |
| 325 |
|
|
| 326 |
|
$xmlcp_cdata .= '</b>'; |
| 327 |
|
|
| 328 |
|
} |
| 329 |
|
|
| 330 |
|
function common_cb_xmlcp_start_bold($h_parser, $tagname, $attribs) { |
| 331 |
|
|
| 332 |
|
global $xmlcp_cdata; |
| 333 |
|
|
| 334 |
|
$xmlcp_cdata .= '<b>'; |
| 335 |
|
|
| 336 |
|
} |
| 337 |
|
|
| 338 |
|
function common_cb_xmlcp_end_page($h_parser, $tagname) { |
| 339 |
|
|
| 340 |
|
} |
| 341 |
|
|
| 342 |
|
function common_cb_xmlcp_start_page($h_parser, $tagname, $attribs) { |
| 343 |
|
|
| 344 |
|
} |
| 345 |
|
|
| 346 |
|
function common_cb_xmlcp_end_headline($h_parser, $tagname) { |
| 347 |
|
|
| 348 |
|
global $xmlcp_cdata; |
| 349 |
|
|
| 350 |
|
common_headline(trim($xmlcp_cdata)); |
| 351 |
|
|
| 352 |
|
$xmlcp_cdata = ''; |
| 353 |
|
|
| 354 |
|
} |
| 355 |
|
|
| 356 |
|
function common_cb_xmlcp_start_headline($h_parser, $tagname, $attribs) { |
| 357 |
|
|
| 358 |
|
global $xmlcp_cdata; |
| 359 |
|
|
| 360 |
|
$xmlcp_cdata = ''; |
| 361 |
|
|
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
function common_cb_xmlcp_end_paragraph($h_parser, $tagname) { |
| 365 |
|
|
| 366 |
|
global $xmlcp_cdata; |
| 367 |
|
|
| 368 |
|
common_paragraph(trim($xmlcp_cdata)); |
| 369 |
|
|
| 370 |
|
$xmlcp_cdata = ''; |
| 371 |
|
|
| 372 |
|
} |
| 373 |
|
|
| 374 |
|
function common_cb_xmlcp_start_paragraph($h_parser, $tagname, $attribs) { |
| 375 |
|
|
| 376 |
|
global $xmlcp_cdata; |
| 377 |
|
|
| 378 |
|
$xmlcp_cdata = ''; |
| 379 |
|
|
| 380 |
|
} |
| 381 |
|
|
| 382 |
|
//---------------------------------------------------------- |
| 383 |
|
|
| 384 |
|
//- ML functions: |
| 385 |
|
|
| 386 |
|
function common_codeparagraph($contents) { |
| 387 |
|
|
| 388 |
|
echo '<p align="justify" class="hl11"> |
| 389 |
|
<code> |
| 390 |
|
' . $contents . ' |
| 391 |
|
</code> |
| 392 |
|
</p> |
| 393 |
|
|
| 394 |
|
'; |
| 395 |
|
|
| 396 |
|
} |
| 397 |
|
|
| 398 |
|
//---------------------------------------------------------- |
| 399 |
|
|
| 400 |
function common_headline($caption) { |
function common_headline($caption) { |
| 401 |
|
|
| 402 |
echo '<h5>' . $caption . '</h5> |
echo '<h4>' . $caption . '</h4> |
| 403 |
|
|
| 404 |
'; |
'; |
| 405 |
|
|
| 407 |
|
|
| 408 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
| 409 |
|
|
| 410 |
|
function common_page($keyname, $language_id = 0) { |
| 411 |
|
|
| 412 |
|
global $common; |
| 413 |
|
|
| 414 |
|
common_benchmark_addstep('COMMON: PAGE: start'); |
| 415 |
|
|
| 416 |
|
$list = cms_getlist('xmlpage', $keyname); |
| 417 |
|
|
| 418 |
|
common_benchmark_addstep('COMMON: PAGE: CMS get list'); |
| 419 |
|
|
| 420 |
|
$contentdata = cms_getcontent('xmlpage', $keyname, $language_id); |
| 421 |
|
|
| 422 |
|
common_benchmark_addstep('COMMON: PAGE: CMS get content'); |
| 423 |
|
|
| 424 |
|
$xml = $contentdata['content']; |
| 425 |
|
|
| 426 |
|
common_pageheader(); |
| 427 |
|
|
| 428 |
|
common_benchmark_addstep('COMMON: PAGE: header'); |
| 429 |
|
|
| 430 |
|
if($xml) { |
| 431 |
|
|
| 432 |
|
$titledata = ''; |
| 433 |
|
|
| 434 |
|
for($i = 0; $i < count($list); $i++) { |
| 435 |
|
|
| 436 |
|
$imgtag = '<img border="0" height="12" src="' . $common['site']['gfxurl'] . 'icons/flags/' . $list[$i][3] . '.gif" width="17" />'; |
| 437 |
|
|
| 438 |
|
$titledata .= ($i ? ' |
| 439 |
|
' : '') . (($language_id == $list[$i][3]) ? $imgtag : '<a href="?li=' . $list[$i][3] . '">' . $imgtag . '</a>'); |
| 440 |
|
|
| 441 |
|
} |
| 442 |
|
|
| 443 |
|
common_pagetitle($contentdata['description'], $titledata . '<br />'); |
| 444 |
|
|
| 445 |
|
xmlcp_xmlpage2html($xml); |
| 446 |
|
|
| 447 |
|
common_benchmark_addstep('COMMON: PAGE: xmlpage2html'); |
| 448 |
|
|
| 449 |
|
/* |
| 450 |
|
common_headline('$list array, readable:'); |
| 451 |
|
common_codeparagraph('$list = ' . nl2br(htmlentities(print_r($list, true)))); |
| 452 |
|
|
| 453 |
|
common_headline('$contentdata array, readable:'); |
| 454 |
|
common_codeparagraph('$contentdata = ' . nl2br(htmlentities(print_r($contentdata, true)))); |
| 455 |
|
|
| 456 |
|
common_headline('$common array, readable:'); |
| 457 |
|
common_codeparagraph('$common = ' . nl2br(htmlentities(print_r($common, true)))); |
| 458 |
|
|
| 459 |
|
common_headline('$common_sessiondata array, readable:'); |
| 460 |
|
common_codeparagraph('$common_sessiondata = ' . nl2br(htmlentities(print_r($common_sessiondata, true)))); |
| 461 |
|
|
| 462 |
|
common_headline('Content XML:'); |
| 463 |
|
common_codeparagraph(nl2br(htmlentities($xml))); |
| 464 |
|
|
| 465 |
|
*/ |
| 466 |
|
|
| 467 |
|
// Only show the informations when "devstate" is set: |
| 468 |
|
if($common['hostsetup']['devstate']) { |
| 469 |
|
|
| 470 |
|
common_paragraph('<small> |
| 471 |
|
<b>Content informations:</b><br /> |
| 472 |
|
<br /> |
| 473 |
|
Description: "<b>' . $contentdata['description'] . '</b>" (Type: "xmlpage")<br /> |
| 474 |
|
Creator: "<b>' . $contentdata['creator_name'] . '</b>"<br /> |
| 475 |
|
Date, Time: "<b>' . date('d.m.Y, H:i:s', $contentdata['unixtime']) . '</b>"<br /> |
| 476 |
|
Language: "<b>' . $contentdata['language_name'] . '</b>"<br /> |
| 477 |
|
XML content size: <b>' . strlen($xml) . '</b> bytes |
| 478 |
|
</small>', 'box2'); |
| 479 |
|
|
| 480 |
|
} |
| 481 |
|
|
| 482 |
|
} else { |
| 483 |
|
|
| 484 |
|
common_pagetitle('Bad content request'); |
| 485 |
|
|
| 486 |
|
common_paragraph('Sorry, but the requested content is unknown.'); |
| 487 |
|
|
| 488 |
|
} |
| 489 |
|
|
| 490 |
|
common_benchmark_addstep('COMMON: PAGE: content'); |
| 491 |
|
|
| 492 |
|
common_pagefooter(); |
| 493 |
|
|
| 494 |
|
} |
| 495 |
|
|
| 496 |
|
//---------------------------------------------------------- |
| 497 |
|
|
| 498 |
function common_pageheader() { |
function common_pageheader() { |
| 499 |
|
|
| 500 |
|
global $common, $common_sessiondata; |
| 501 |
|
|
| 502 |
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 503 |
|
|
| 504 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 506 |
<head> |
<head> |
| 507 |
<title>www.netfrag.org</title> |
<title>www.netfrag.org</title> |
| 508 |
<style type="text/css"><!-- |
<style type="text/css"><!-- |
| 509 |
body { font: 10pt tahoma, serif; } |
body, input, table { font: 10pt verdana, serif; } |
| 510 |
h2, .box, .hl { background-color:#e0e0e0; padding:8px; } |
h4 { font-size:12pt; } |
| 511 |
h2, .box { border:1px solid #a0a0a0; } |
input { border:1px; } |
| 512 |
|
small { font-size:8pt; } |
| 513 |
|
.bg11, .box1, .f11, .hl11 { background-color:#50f8f0; } |
| 514 |
|
.bg12, .f12 { background-color:#40e8e0; } |
| 515 |
|
.bg13 { background-color:#20a0c0; } |
| 516 |
|
.bg21, .box2, .f21, .hl21 { background-color:#90fff0; } |
| 517 |
|
.bg22, .f22 { background-color:#80f0e0; } |
| 518 |
|
.bg23 { background-color:#40c080; } |
| 519 |
|
.box1, .f11, .f12 { border:2px solid #20a0c0; } |
| 520 |
|
.box2, .f21, .f22 { border:1px solid #40c080; } |
| 521 |
|
.box1, .box2, .hl11, .hl21 { padding:4px; } |
| 522 |
--></style> |
--></style> |
| 523 |
</head> |
</head> |
| 524 |
|
|
| 525 |
<body> |
<body> |
| 526 |
|
|
| 527 |
<h2>www.netfrag.org</h2> |
<form action="" method="post"> |
| 528 |
|
<table cellspacing="0" cellpadding="0" width="100%"> |
| 529 |
<h3>• Home</h3> |
<tr> |
| 530 |
|
<th class="box1" width="100%"> |
| 531 |
|
<font size="5" style="letter-spacing:4pt;"><b>www.netfrag.org</b></font> |
| 532 |
|
</td> |
| 533 |
|
<td> </td> |
| 534 |
|
<td> |
| 535 |
|
<table cellspacing="0" cellpadding="2" class="f22"> |
| 536 |
|
<tr> |
| 537 |
|
<th class="box2" rowspan="2"><b>User<br />login</b></th> |
| 538 |
|
<td> User:</td><td><input name="un" size="8" type="text" value="' . $common_sessiondata['userdata']['name'] . '" /></td> |
| 539 |
|
<td rowspan="2"><input type="submit" value="Go" /> </td> |
| 540 |
|
<tr> |
| 541 |
|
<td> Pass:</td><td><input name="pw" size="8" type="password" /></td> |
| 542 |
|
</tr> |
| 543 |
|
</table> |
| 544 |
|
</td> |
| 545 |
|
</tr> |
| 546 |
|
</table> |
| 547 |
|
</form> |
| 548 |
|
|
| 549 |
'; |
'; |
| 550 |
|
|
| 554 |
|
|
| 555 |
function common_pagefooter() { |
function common_pagefooter() { |
| 556 |
|
|
| 557 |
echo '<p align="center" class="box"> |
global $common; |
| 558 |
(foot notes) |
|
| 559 |
</p> |
// Only show the benchmark list when "devstate" is set: |
| 560 |
|
if($common['hostsetup']['devstate']) { |
| 561 |
|
|
| 562 |
|
$contents = ''; |
| 563 |
|
|
| 564 |
|
for($i = 0; $i < count($common['benchmark']); $i++) { |
| 565 |
|
|
| 566 |
|
$mtimesegs = explode(' ', $common['benchmark'][$i][1]); |
| 567 |
|
$contents .= '"<b>' . $common['benchmark'][$i][0] . '</b>": '; |
| 568 |
|
|
| 569 |
|
if($i) { |
| 570 |
|
|
| 571 |
|
$timediff = (float)($mtimesegs[1] - $lastmtimesegs[1]); |
| 572 |
|
$timediff += $mtimesegs[0] - $lastmtimesegs[0]; |
| 573 |
|
|
| 574 |
|
$contents .= '<b>+' . round($timediff * 1000000) / 1000 . '</b> ms<br /> |
| 575 |
|
'; |
| 576 |
|
|
| 577 |
|
} else { |
| 578 |
|
|
| 579 |
|
$contents .= 'Start time: <b>' . date('H:i:s', $mtimesegs[1]) . substr($mtimesegs[0], 1, 4) . '</b><br /> |
| 580 |
|
'; |
| 581 |
|
|
| 582 |
|
} |
| 583 |
|
|
| 584 |
|
$lastmtimesegs = $mtimesegs; |
| 585 |
|
|
| 586 |
|
} |
| 587 |
|
|
| 588 |
|
common_paragraph('<small> |
| 589 |
|
<b>Partial execution times:</b><br /> |
| 590 |
|
<br /> |
| 591 |
|
' . $contents . '</small>', 'box2'); |
| 592 |
|
|
| 593 |
|
} |
| 594 |
|
|
| 595 |
|
common_benchmark_addstep('COMMON: page footer'); |
| 596 |
|
|
| 597 |
|
$endmtimesegs = explode(' ', microtime()); |
| 598 |
|
$startmtimesegs = explode(' ', $common['benchmark'][0][1]); |
| 599 |
|
$timediff = (float)($endmtimesegs[1] - $startmtimesegs[1]); |
| 600 |
|
$timediff += $endmtimesegs[0] - $startmtimesegs[0]; |
| 601 |
|
|
| 602 |
|
$devstate = $common['hostsetup']['devstate']; |
| 603 |
|
|
| 604 |
|
echo '<table cellspacing="0" cellpadding="0" class="box1" width="100%"> |
| 605 |
|
<tr> |
| 606 |
|
<td valign="top"> |
| 607 |
|
Page execution time: <code>' . round($timediff * 100000) / 100 . '</code> ms.<br /> |
| 608 |
|
[ ' . ($devstate ? '<a href="?devstate=0">devstate off</a>' : '<a href="?devstate=1">devstate on</a>') . ' ] |
| 609 |
|
</td> |
| 610 |
|
<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> |
| 611 |
|
<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> |
| 612 |
|
</tr> |
| 613 |
|
</table> |
| 614 |
|
|
| 615 |
</body> |
</body> |
| 616 |
|
|
| 621 |
|
|
| 622 |
//---------------------------------------------------------- |
//---------------------------------------------------------- |
| 623 |
|
|
| 624 |
|
function common_pagetitle($title, $additionalcontents = '') { |
| 625 |
|
|
| 626 |
|
echo '<p class="box2"> |
| 627 |
|
<big><b>• ' . $title . '</b> </big> |
| 628 |
|
' . ($additionalcontents ? $additionalcontents . ' |
| 629 |
|
' : '') . '</p> |
| 630 |
|
|
| 631 |
|
'; |
| 632 |
|
|
| 633 |
|
} |
| 634 |
|
|
| 635 |
|
//---------------------------------------------------------- |
| 636 |
|
|
| 637 |
function common_paragraph($contents, $class = '') { |
function common_paragraph($contents, $class = '') { |
| 638 |
|
|
| 639 |
echo '<p align="justify"' . ($class ? ' class="' . $class . '"' : '') . '> |
echo '<p align="justify"' . ($class ? ' class="' . $class . '"' : '') . '> |
| 646 |
|
|
| 647 |
//------------------------------------------------------------------------------ |
//------------------------------------------------------------------------------ |
| 648 |
|
|
|
?> |
|
| 649 |
|
common_benchmark_addstep('COMMON: end'); |
| 650 |
|
|
| 651 |
|
//------------------------------------------------------------------------------ |
| 652 |
|
|
| 653 |
|
?> |