Added a server error page, used it for SQL server errors
[specialops2.git] / lib / class.anonuser.php
bloba14e57e79d01a56a477ba21f1396e1709071b481
1 <?php
2 // $Id$
4 /* Anonymous user */
5 class anonuser
7 public $userlinks;
8 protected $attrcache;
9 protected $namecache;
11 function __construct()
13 $this->userlinks = array(
14 'Log In' => '#login_u'
17 $this->attrcache = array(
18 'level' => 0,
19 'points' => 0,
20 'theme' => null,
21 'msglist_layout' => 0,
22 'topiclist_layout' => 0,
23 'boardlist_layout' => 0,
24 'topics_page' => 10,
25 'msgs_page' => 5
29 function __get($varname)
31 if ( array_key_exists($varname, $this->attrcache) ) {
32 return $this->attrcache[$varname];
33 } else
34 throw new OutOfBoundsException('Error in $user->_get('.$varname.'): attribute not available.');
37 function userheader()
39 if ( ! ($GLOBALS['page']->headers & page::Pageheader) )
40 $GLOBALS['page']->pageheader();
42 if ( ! ($GLOBALS['page']->headers & page::Userheader) ) {
43 echo '<ul id="userheader" class="nl">',"\n";
44 foreach ( $this->userlinks as $text => $href )
45 echo ' <li><a href="',$href,'">',$text,"</a></li>\n";
46 echo "</ul>\n";
47 $GLOBALS['page']->headers |= page::Userheader;
51 function namelink($id, $name = null)
53 if ( empty($this->namecache[$id]) ) {
54 if ( $name === null )
55 $this->namecache[$id] = $GLOBALS['DB']->query('SELECT `alias` FROM `users`
56 WHERE `userid` = '.$id)->fetch_object()->alias;
57 else
58 $this->namecache[$id] = $name;
60 return $this->namecache[$id];
63 function fdate($timestamp)
65 return ( $timestamp == 0 ? 'N/A' : date('Y-m-d H:i:s', $timestamp) );