From 51675e7a9bf4d5055ed45b37bac964f788800399 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Fri, 13 Apr 2012 00:18:19 +1000 Subject: code cleanup --- inc/mod.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'inc/mod.php') diff --git a/inc/mod.php b/inc/mod.php index 1b52840c..9065bb82 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -4,7 +4,7 @@ * Copyright (c) 2010-2012 Tinyboard Development Group */ -if(realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) { +if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) { // You cannot request this file directly. exit; } @@ -13,7 +13,7 @@ if(realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) { function mkhash($username, $password, $salt = false) { global $config; - if(!$salt) { + if (!$salt) { // create some sort of salt for the hash $salt = substr(base64_encode(sha1(rand() . time(), true) . $config['cookies']['salt']), 0, 15); @@ -23,7 +23,7 @@ function mkhash($username, $password, $salt = false) { // generate hash (method is not important as long as it's strong) $hash = substr(base64_encode(md5($username . sha1($username . $password . $salt . ($config['mod']['lock_ip'] ? $_SERVER['REMOTE_ADDR'] : ''), true), true)), 0, 20); - if(isset($generated_salt)) + if (isset($generated_salt)) return Array($hash, $salt); else return $hash; @@ -33,7 +33,7 @@ function login($username, $password, $makehash=true) { global $mod; // SHA1 password - if($makehash) { + if ($makehash) { $password = sha1($password); } @@ -42,7 +42,7 @@ function login($username, $password, $makehash=true) { $query->bindValue(':password', $password); $query->execute() or error(db_error($query)); - if($user = $query->fetch()) { + if ($user = $query->fetch()) { return $mod = Array( 'id' => $user['id'], 'type' => $user['type'], @@ -55,7 +55,7 @@ function login($username, $password, $makehash=true) { function setCookies() { global $mod, $config; - if(!$mod) + if (!$mod) error('setCookies() was called for a non-moderator!'); setcookie($config['cookies']['mod'], @@ -79,7 +79,7 @@ function create_pm_header() { $query->bindValue(':id', $mod['id'], PDO::PARAM_INT); $query->execute() or error(db_error($query)); - if($pm = $query->fetch()) { + if ($pm = $query->fetch()) { return Array('id' => $pm['id'], 'waiting' => $query->rowCount() - 1); } @@ -93,15 +93,15 @@ function modLog($action, $_board=null) { $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':time', time(), PDO::PARAM_INT); $query->bindValue(':text', $action); - if(isset($_board)) + if (isset($_board)) $query->bindValue(':board', $_board); - elseif(isset($board)) + elseif (isset($board)) $query->bindValue(':board', $board['uri']); else $query->bindValue(':board', null, PDO::PARAM_NULL); $query->execute() or error(db_error($query)); - if($config['syslog']) + if ($config['syslog']) _syslog(LOG_INFO, '[mod/' . $mod['username'] . ']: ' . $action); } @@ -115,7 +115,7 @@ function ulBoards() { // List of boards $boards = listBoards(); - foreach($boards as &$b) { + foreach ($boards as &$b) { $body .= '
  • ' . '' . _('Create new board') . '
  • '; } return $body; @@ -140,7 +140,7 @@ function form_newBan($ip=null, $reason='', $continue=false, $delete=false, $boar $boards = listBoards(); $__boards = '
  • '; - foreach($boards as &$_board) { + foreach ($boards as &$_board) { $__boards .= '
  • ' . '' . '