--- nfo/site/htdocs/inc/common/common.php.inc 2004/08/30 10:42:20 1.4 +++ nfo/site/htdocs/inc/common/common.php.inc 2004/08/31 02:41:40 1.6 @@ -4,7 +4,7 @@ --- Setup and common functions include file. -------------------------------------------------------------------------------- --- rabit, 04:31 24.08.2004 ---- $Id: common.php.inc,v 1.4 2004/08/30 10:42:20 bd Exp $ +--- $Id: common.php.inc,v 1.6 2004/08/31 02:41:40 rabit Exp $ ------------------------------------------------------------------------------*/ //------------------------------------------------------------------------------ @@ -62,8 +62,14 @@ //---------------------------------------------------------- //- Site variable setups: +// Paths: $common['site']['docroot'] = $_SERVER['DOCUMENT_ROOT'] . $common['hostsetup']['urlrel']; $common['site']['incroot'] = $common['site']['docroot'] . 'inc/'; +$common['site']['libroot'] = $common['site']['docroot'] . 'libs/'; + +// URLs: +$common['site']['url'] = 'http://' . $_SERVER['HTTP_HOST'] . $common['hostsetup']['urlrel']; +$common['site']['gfxurl'] = $common['site']['url'] . 'gfx/'; //---------------------------------------------------------- //- Page variable setups: @@ -114,6 +120,14 @@ 'birthtime' => time(), 'firstrequest' => 1, // Mark the very first page request. + // Empty user data sub array: + 'userdata' => array( + 'name' => '', + 'password' => '', + 'authorised' => false, + ), + + // Content related additional data: 'additionaldata' => array() ); @@ -149,8 +163,67 @@ } //------------------------------------------------------------------------------ +//- URL parameter flags and variables: + +if(isset($_GET['devstate'])) $common_sessiondata['userdata']['devstate'] = $_GET['devstate']; + +if(isset($common_sessiondata['userdata']['devstate'])) $common['hostsetup']['devstate'] = $common_sessiondata['userdata']['devstate']; + +//------------------------------------------------------------------------------ //- Functions: +function common_checkauthorisation() { + +global $common_sessiondata; + + $username = $common_sessiondata['userdata']['name']; + $password = $common_sessiondata['userdata']['password']; + + if((strlen($username) < 2) || (strlen($password) < 2)) return false; + + $sql = "SELECT id, rights, logincount, lastlogin FROM users WHERE name='$username' AND password='$password';"; + + $res = mysql_query($sql); + + if(!$res) return false; + + if(!($row = mysql_fetch_row($res))) return false; + + // Congratulations - authorisation suxxessful! + + $logintime = time(); + + $userid = $row[0]; + $rights = $row[1]; + $logincount = $row[2] + 1; + $lastlogin = $row[3]; + + $common_sessiondata['userdata']['authorised'] = true; + + $common_sessiondata['userdata']['id'] = $userid; + $common_sessiondata['userdata']['lastlogin'] = $lastlogin; + $common_sessiondata['userdata']['rights'] = $rights; + + // Break if the user already has authorised in this session: + if(isset($common_sessiondata['userdata']['logintime'])) return false; + + $common_sessiondata['userdata']['logincount'] = $logincount; + $common_sessiondata['userdata']['logintime'] = $logintime; + +// print_r($common_sessiondata['userdata']); + + $sql = "UPDATE users SET logincount='$logincount', lastlogin=FROM_UNIXTIME('$logintime') WHERE id='$userid';"; + + $res = mysql_query($sql); + + if(!$res) return false; + + return true; + +} + +//------------------------------------------------------------------------------ + function common_protocolhit() { global $common, $common_sessiondata; @@ -160,14 +233,16 @@ $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']; $sql = "INSERT INTO hits (id, timestamp, address, entryurl, referer, sessionid, useragent, requestcount) VALUES (NULL, FROM_UNIXTIME('$unixtime'), '$address', '$entryurl', '$referer', '$sessionid', '$useragent', '1');"; $res = mysql_query($sql); + if ($errstr = mysql_error()) { + print $errstr . "\n"; + } if(!$res) return false; @@ -310,7 +385,7 @@ function common_codeparagraph($contents) { - echo '

+ echo '

' . $contents . ' @@ -358,11 +433,14 @@ for($i = 0; $i < count($list); $i++) { - $titledata .= ($i ? ' · ' : '') . '' . $list[$i][4] . ''; + $imgtag = ''; + + $titledata .= ($i ? ' +' : '') . (($language_id == $list[$i][3]) ? $imgtag : '' . $imgtag . ''); } - common_pagetitle($contentdata['description'], $titledata); + common_pagetitle($contentdata['description'], $titledata . '
'); xmlcp_xmlpage2html($xml); @@ -419,7 +497,7 @@ function common_pageheader() { -global $common; +global $common, $common_sessiondata; echo ' @@ -428,20 +506,45 @@ www.netfrag.org -

www.netfrag.org

+
+ + + + + +
+www.netfrag.org + +  + + + + + + + + +
User
login
 User: 
 Pass:
+
+
'; @@ -496,12 +599,15 @@ $timediff = (float)($endmtimesegs[1] - $startmtimesegs[1]); $timediff += $endmtimesegs[0] - $startmtimesegs[0]; - echo ' + $devstate = $common['hostsetup']['devstate']; + + echo '
-
-Page execution time: ' . round($timediff * 100000) / 100 . ' ms. +Page execution time: ' . round($timediff * 100000) / 100 . ' ms.
+[ ' . ($devstate ? 'devstate off' : 'devstate on') . ' ]
This page is valid XHTML 1.0 +This page is valid XHTML 1.0 Valid CSS!
@@ -518,7 +624,7 @@ function common_pagetitle($title, $additionalcontents = '') { echo '

-• ' . $title . '
+• ' . $title . '  ' . ($additionalcontents ? $additionalcontents . ' ' : '') . '