From 3e8305ea055c4216e542187e93bba831accd9fd5 Mon Sep 17 00:00:00 2001 From: Anthony Parsons Date: Sat, 14 Jan 2006 20:25:20 +0000 Subject: [PATCH] New readme, updated some inconsistency in the invite code. --- README.xml | 120 ++++++++++++++++++++++++------------------------- css/gfh2.css | 2 +- lib/class.anonuser.php | 15 +++++-- lib/class.authuser.php | 9 ++-- lib/class.reguser.php | 6 ++- 5 files changed, 81 insertions(+), 71 deletions(-) rewrite README.xml (83%) diff --git a/README.xml b/README.xml dissimilarity index 83% index 466b720..cb49a01 100644 --- a/README.xml +++ b/README.xml @@ -1,61 +1,59 @@ - - - - - -SO2 Readme - - - - -
-

Special Ops 2 Documentation

-

Last modification: $Id$

-
- -

Intro

-
-

This project is based on mBoard, a GameFAQs spinoff I started writing one day to try out SQLite. - I had it working in 7 hours and left it at that. Over time it gained users in the

-

The code in mBoard as well as SO1.x was a pile of cack, so I threw it all out and rewrote it from scratch.

-

With this being my third attempt at writing a message board, the design is a lot better thought-out.

- - - -
- -

Requirements

-
-

You need PHP 5, MySQL 5, the PHP extensions mysqli and SPL, and an operating system designed for use on the Internet.

-
- -

Installation

-
-

The DB files are in res/.

-

Setup is the same as GFH, except there's no board editor. You don't have to set yourself to admin either (well you can if you want).

-

You can turn off various features by ripping out code and deleting files.

-
- -

To Do list (major)

-
-

*shrug*

-
- -

Dev info

-
-

The latest public version of the source is at -http://specialops.ath.cx/repos/so2/trunk/. -This is a Subversion repository, so you can checkout the source and poke around using whatever SVN client you prefer. -Of course there's nothing stopping people from being retarded and trying to download it in a web browser, - but when it doesn't work because you leeched the files when someone commits changes, you get to keep the pieces you spent forever downloading.

-

Source is formatted for tab indents, width 4.

-

Bugs, suggestions, fan mail and death threats can be sent to the IRC server. - Register a username if you want to get in. Any WDPers can go fuck themselves in the arse with a <marquee> tag.

-
- - - - + + + +SO2 Readme + + + + + + +

Intro

+

This project is based on mBoard, a GameFAQs spinoff I started writing one day to try out SQLite. + I had it working in 7 hours and left it at that. Unfortunately it had one major flaw: people were using it. + Since I never bothered to optimise the SQLite code it ran painfully slow.

+

The code in mBoard and the other board I had at the time, SO1, was a huge mess. So I rewrote from scratch.

+

A lot of work has gone into doing things correctly this time, such as testing the code before it's used. + All other spinoffs blindly pile on more and more features without a thought to making them secure. + SQL injection for instance, one of the most common exploits in spinoff boards, is impossible by design in SO2.

+ +

Requirements

+

You need PHP 5, MySQL 5 installed. In PHP, make sure the MySQLi, SPL and libxml extensions are enabled.

+

Also you'll need an operating system with a POSIX-compliant file system such as Solaris, BSD, MacOS X and Linux. + These are freely downloadable from the Internet if you don't already use one for some perverse reason.

+ +

Installation

+

The DB files are in res/. Setup is the same as GFH except for a few things:

+
    +
  1. No board editor. You'll have to use phpMyAdmin and add them manually. This may be added in the future.
  2. +
  3. The admin userlevel doesn't actually do anything right now.
  4. +
  5. The DB password is in mysql.php. An example file is in res/.
  6. +
+

You can turn off various features usually by removing code and deleting files.

+ +

To Do list Roadmap

+ + +

Dev Info

+

The latest version of the source is at http://specialops.ath.cx/repos/so2/. +This is a Subversion repository, so just do svn co http://specialops.ath.cx/repos/so2/trunk/ to get the latest copy.

+

The code is formatted for tab indents, width 4. There isn't any formal line length limit.

+

Bugs, suggestions, fan mail and death threats can be sent to the IRC server.

+ +

Contributors

+ + + + + diff --git a/css/gfh2.css b/css/gfh2.css index f10ccaa..a97bced 100644 --- a/css/gfh2.css +++ b/css/gfh2.css @@ -45,7 +45,7 @@ th, dt, .nl, #footer { color: #fff; background: #667; font-weight: bold } #footer { padding: 0; margin: 0 } #footer p { padding: 0.5em; margin: 0 } #footer fieldset { margin: 0; border: none; float: right; background: #667; -moz-border-radius: 0 0 1em 1em } -#footer legend { display: none; background: #667 } +#footer legend { display: none } #footer label, #footer label ~ button { display: block } #footer:target fieldset { color: #000; background: #ff0 } diff --git a/lib/class.anonuser.php b/lib/class.anonuser.php index e752574..e3a112a 100644 --- a/lib/class.anonuser.php +++ b/lib/class.anonuser.php @@ -8,6 +8,9 @@ */ class anonuser { + /** + * Links displayed in div#userheader, in label => url format. + */ public $userlinks = array( 'Log In' => '#footer', 'Register' => 'register', @@ -81,7 +84,7 @@ class anonuser global $DB; if ( empty($this->namecache[$id]) ) { - if ( $name === null ) { + if ( null === $name ) { list($name) = $DB->query('SELECT `alias` FROM `users` WHERE `userid` = '.$id)->fetch_row(); } @@ -109,14 +112,20 @@ class anonuser /** * Turn a Unix timestamp into a human-readable date. * Outputs UTC time in ISO-8601 format. + * + * @param int $timestamp Unix timestamp to display */ public function fdate($timestamp) { - return ( $timestamp == 0 ? 'N/A' : gmdate('Y-m-d H:i:s', $timestamp) ); + return ( 0 == $timestamp ? 'N/A' : gmdate('Y-m-d H:i:s', $timestamp) ); } /** - * User privilege check thing - since this is an anonymous user they have none + * User privilege check, replacement for userlevel system. + * The one in authuser makes more use of this. + * + * @param string $name The thing to check for + * @return bool True if they have it, false otherwise */ public function has_priv($name) { diff --git a/lib/class.authuser.php b/lib/class.authuser.php index 6449af1..dac014e 100644 --- a/lib/class.authuser.php +++ b/lib/class.authuser.php @@ -2,7 +2,7 @@ // $Id$ /** - * Class for the current user. + * Class for the current logged in user. */ class authuser extends reguser { @@ -19,13 +19,14 @@ class authuser extends reguser $this->namecache[$this->attrcache['userid']] = $this->attrcache['alias']; - // Update user info - if ( strpos($this->options, 'alwaysonline') !== false || 'POST' === $_SERVER['REQUEST_METHOD'] ) + /* Update last active info if they sent a HTTP POST or explicitly stated they want to break HTTP convention */ + if ( strpos($this->options, 'alwaysonline') !== false || 'POST' === $_SERVER['REQUEST_METHOD'] ) { $DB->query('UPDATE `users` SET `useragent` = '.$DB->string(substr($_SERVER['HTTP_USER_AGENT'], 0, 130)).', `last_active_date` = UNIX_TIMESTAMP(), `last_ip` = INET_ATON("'.$_SERVER['REMOTE_ADDR'].'") WHERE `userid` = @userid'); + } $this->userlinks = array( /* Username link*/ @@ -33,7 +34,7 @@ class authuser extends reguser => 'user', /* Online Users link */ vsprintf('Online Users: %d', $DB->query('SELECT COUNT(*) AS `c` FROM `users` - WHERE `last_active_date` > (UNIX_TIMESTAMP() - 600)')->fetch_row() ) + WHERE `last_active_date` > UNIX_TIMESTAMP() - 600')->fetch_row() ) => 'userlist?online' ); } diff --git a/lib/class.reguser.php b/lib/class.reguser.php index ba1b95a..098ef00 100644 --- a/lib/class.reguser.php +++ b/lib/class.reguser.php @@ -76,8 +76,10 @@ class reguser extends anonuser $value = "AES_ENCRYPT('$value', `reg_ip`)"; break; case 'points': - if ( 20 < $value && sqrt($value) == floor(sqrt($value)) && $DB->query('SELECT COUNT(*) AS `c` FROM `items` - WHERE `item` = "invite" AND `userid` = '.$this->userid)->fetch_object()->c < 5 ) { + if ( is_int(sqrt($value)) && sqrt($value) > $this->attrcache['invites'] && + $DB->query('SELECT COUNT(*) AS `c` FROM `items` + WHERE `item` = "invite" + AND `userid` = '.$this->userid)->fetch_object()->c < 5 ) { $DB->query('INSERT INTO `items` VALUES (NULL, '.$this->attrcache['userid'].', "invite", UUID())'); $DB->query('UPDATE `users` SET `invites` = (`invites` + 1) WHERE `userid` = '.$this->attrcache['userid']); } -- 2.11.4.GIT