SO 1-final
[specialops1.git] / config.php
blob3f866cfda57d662faddbdea83ad62307fc1803a7
1 <?php
2 /*
3 * Special Ops One message boards
4 * Copyright © 2002-2005 Anthony Parsons
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * See file docs/LICENSE for full license terms.
23 ob_start();
25 if ( version_compare(PHP_VERSION, '5.0', '<') ) {
26 header('HTTP/1.1 500 Internal Server Error');
27 die('PHP 5.0 or higher is required.');
30 error_reporting(E_ALL|E_STRICT);
32 // DB Connection
33 require 'include/sqlconn.php';
35 // Timer thing at bottom of page
36 define('START_TIME', microtime(1));
38 // Board text strings
39 $strings = array(
40 'name' => 'MINESWEEPERBOARDOJ',
41 'cookies' => 'Aura',
42 'points' => 'Vim'
45 // Image strings
46 $cfg['img'] = array(
47 '<img src="imglib/add" alt="Added '.$strings['cookies'].'" class="imgadd"/>',
48 '<img src="imglib/take" alt="Taken '.$strings['cookies'].'" class="imgtake"/>',
49 '<img src="imglib/closed" alt="*Closed*" class="imgclose"/>',
50 '<img src="imglib/deleted" alt="*Deleted*" class="imgdel"/>'
53 //custom header strings
54 $cfg['headers'] = array(
55 'Text-Only' => 'Special Ops Boards'
58 $cfg['headers2'] = array_values($cfg['headers']);
60 //userlevel defines
61 $cfg['levels'] = array(
62 -3 => 'KOS',
63 -2 => 'BANNED_USER',
64 -1 => 'SUSPENDED_USER',
65 0 => 'PENDING_EMAIL',
66 2 => 'CLOSED',
67 3 => 'PENDING_CLOSE',
68 4 => 'INACTIVE_USER',
69 10 => 'NEW_USER',
70 15 => 'REG_USER',
71 20 => 'VET_USER',
72 30 => 'ELI_USER',
73 40 => 'VIP_USER',
74 50 => 'MOD',
75 55 => 'ADMIN',
76 60 => 'ADMIN2'
78 foreach ( $cfg['levels'] as $number => $level )
79 define($level, $number);
81 // user stuff
82 if ( isset($_COOKIE['userid'], $_COOKIE['password']) )
83 $u = mysql_fetch_assoc(mysql_unbuffered_query('SELECT * FROM `users` WHERE `user` = '.intval($_COOKIE['userid']).' LIMIT 1'));
85 isset($_SERVER['HTTP_USER_AGENT']) ? null : $_SERVER['HTTP_USER_AGENT'] = '-';
87 if ( !empty($u) && $u['password'] === $_COOKIE['password'] ) {
88 $userinfo = $u;
89 $userinfo['level'] = intval($userinfo['level']);
90 mysql_query('UPDATE `users` SET
91 `last_active` = NOW(),
92 `last_ip` = INET_ATON(\''.$_SERVER['REMOTE_ADDR'].'\'),
93 `useragent` = \''.mysql_real_escape_string(htmlentities($_SERVER['HTTP_USER_AGENT'])).'\'
94 WHERE `user` = '.$userinfo['user'].' LIMIT 1');
96 $userinfo['timeoffset'] = $userinfo['timezone'] * 3600; //bitfields are gay
98 else
100 setcookie('userid', '-', 1);
101 setcookie('password', '-', 1);
102 $userinfo = array('header' => 0, 'timezone' => 0, 'topics_page' => 35, 'messages_page' => 35, 'level' => PENDING_EMAIL);
105 /* Global Functions */
106 // Bar shader
107 function colour()
109 static $c = 0;
110 return '"c'.(1+(++$c&1)).'"';
113 // Date formatting
114 function date2($timestamp = 0)
116 global $userinfo;
117 if ( empty($userinfo['dateformat']) )
118 return gmdate('Y-m-d H:i:s', $timestamp + $userinfo['timezone']);
119 return gmdate($userinfo['dateformat'], $timestamp + $userinfo['timezone']);
122 // Page exit
123 function stop ($msg = '')
125 echo $msg;
126 trigger_error('Use of stop() is deprecated - echo the message and call footer() directly', E_USER_WARNING);
127 print_r(debug_backtrace());
128 footer();
131 $urlstring = isset($_GET['b']) ? 'b='.intval($_GET['b']).( isset($_GET['t']) ? ';t='.intval($_GET['t']) : '' ) : '';
132 define('URL_STRING', '?'.$urlstring);
133 define('URL_APPEND', ';'.$urlstring);
135 // Returns idletime (not used much now)
136 function idletime($lastsec)
138 return(time() - $lastsec > 86400 ? floor((time() - $lastsec) / 86400).'d ' : '').gmdate('G\hi\ms\s', time() - $lastsec);
141 // Makes userids into links
142 function userlink($id, $name = null)
144 if ( empty($id) )
145 return '';
147 static $users;
148 global $userinfo;
150 if ( empty($users[$id]) )
151 if ( empty($name) )
152 list($users[$id]) = mysql_fetch_row(mysql_query('SELECT `name` FROM `users` WHERE `user` = '.intval($id)));
153 else
154 $users[$id] = $name;
155 if ( empty($userinfo['user']) )
156 return $users[$id];
157 else
158 return '<a href="whois?u='.$id.URL_APPEND.'">'.$users[$id].'</a>';
161 function footer()
164 </div>
166 <p><a href="http://specialops.ath.cx/">Special Ops 1.25-dev</a> |
167 <?php echo round(microtime(1) - START_TIME, 4) ?>s |
168 © 2003-2005 <a href="http://specialops.ath.cx/contact">Ant P</a></p>
169 </body>
170 </html>
171 <?php
172 exit;