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

Diff of /nfo/site/htdocs/inc/common/common.php.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by rabit, Mon Aug 30 11:47:08 2004 UTC revision 1.6 by rabit, Tue Aug 31 02:41:40 2004 UTC
# Line 62  unset($hostsetups); Line 62  unset($hostsetups);
62  //----------------------------------------------------------  //----------------------------------------------------------
63  //- Site variable setups:  //- Site variable setups:
64    
65    // Paths:
66  $common['site']['docroot'] = $_SERVER['DOCUMENT_ROOT'] . $common['hostsetup']['urlrel'];  $common['site']['docroot'] = $_SERVER['DOCUMENT_ROOT'] . $common['hostsetup']['urlrel'];
67  $common['site']['incroot'] = $common['site']['docroot'] . 'inc/';  $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:  //- Page variable setups:
# Line 114  if(!isset($_SESSION['common_sessiondata' Line 120  if(!isset($_SESSION['common_sessiondata'
120     'birthtime' => time(),     'birthtime' => time(),
121     'firstrequest' => 1, // Mark the very first page request.     '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()     'additionaldata' => array()
132    
133    );    );
# Line 158  if(isset($common_sessiondata['userdata'] Line 172  if(isset($common_sessiondata['userdata']
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() {  function common_protocolhit() {
228    
229  global $common, $common_sessiondata;  global $common, $common_sessiondata;
# Line 167  global $common, $common_sessiondata; Line 233  global $common, $common_sessiondata;
233    $referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');    $referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
234    $sessionid = session_id();    $sessionid = session_id();
235    $unixtime = $common_sessiondata['birthtime'];    $unixtime = $common_sessiondata['birthtime'];
   $timestamp = date('YmdHis', $common_sessiondata['birthtime']);  
236    $useragent = $_SERVER['HTTP_USER_AGENT'];    $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');";    $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);    $res = mysql_query($sql);
241    
242    if ($errstr = mysql_error()) {    if ($errstr = mysql_error()) {
243    
244      print $errstr . "\n";      print $errstr . "\n";
245    
246    }    }
247    
248    if(!$res) return false;    if(!$res) return false;
# Line 317  global $xmlcp_cdata; Line 385  global $xmlcp_cdata;
385    
386  function common_codeparagraph($contents) {  function common_codeparagraph($contents) {
387    
388    echo '<p align="justify" class="hl">    echo '<p align="justify" class="hl11">
389  <code>  <code>
390  ' . $contents . '  ' . $contents . '
391  </code>  </code>
# Line 365  global $common; Line 433  global $common;
433    
434      for($i = 0; $i < count($list); $i++) {      for($i = 0; $i < count($list); $i++) {
435    
436        $titledata .= ($i ? ' · ' : '') . '<a href="?li=' . $list[$i][3] . '">' . $list[$i][4] . '</a>';        $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);      common_pagetitle($contentdata['description'], $titledata . '<br />');
444    
445      xmlcp_xmlpage2html($xml);      xmlcp_xmlpage2html($xml);
446    
# Line 426  XML content size: <b>' . strlen($xml) . Line 497  XML content size: <b>' . strlen($xml) .
497    
498  function common_pageheader() {  function common_pageheader() {
499    
500  global $common;  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    
# Line 435  global $common; Line 506  global $common;
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: 11pt verdana, serif; }  body, input, table { font: 10pt verdana, serif; }
 h2 { text-align:center; }  
 h2, .box, .box2, .hl { padding:8px; }  
 h2, .box, .hl { background-color:#40f0f0; }  
 h2, .box { border:2px solid #20a0c0; }  
510  h4 { font-size:12pt; }  h4 { font-size:12pt; }
511    input { border:1px; }
512  small { font-size:8pt; }  small { font-size:8pt; }
513  .box2 { background-color:#80fff0; border:1px solid #40c080; }  .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    <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>&nbsp;</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>&nbsp;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" />&nbsp;</td>
540    <tr>
541    <td>&nbsp;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    
# Line 503  global $common; Line 599  global $common;
599    $timediff = (float)($endmtimesegs[1] - $startmtimesegs[1]);    $timediff = (float)($endmtimesegs[1] - $startmtimesegs[1]);
600    $timediff += $endmtimesegs[0] - $startmtimesegs[0];    $timediff += $endmtimesegs[0] - $startmtimesegs[0];
601    
602    echo '<table cellspacing="0" cellpadding="0" class="box" width="100%">    $devstate = $common['hostsetup']['devstate'];
603    
604      echo '<table cellspacing="0" cellpadding="0" class="box1" width="100%">
605  <tr>  <tr>
606  <td valign="top">  <td valign="top">
607  Page execution time: <code>' . round($timediff * 100000) / 100 . '</code> ms.  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>  </td>
610  <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>  <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>  <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>  </tr>
613  </table>  </table>
# Line 525  Page execution time: <code>' . round($ti Line 624  Page execution time: <code>' . round($ti
624  function common_pagetitle($title, $additionalcontents = '') {  function common_pagetitle($title, $additionalcontents = '') {
625    
626    echo '<p class="box2">    echo '<p class="box2">
627  <big><b>&bull; ' . $title . '</b></big><br />  <big><b>&bull; ' . $title . '</b>&nbsp;</big>
628  ' . ($additionalcontents ? $additionalcontents . '  ' . ($additionalcontents ? $additionalcontents . '
629  ' : '') . '</p>  ' : '') . '</p>
630    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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