diff --git a/inc/database.php b/inc/database.php index 792eae58..014c2e1e 100644 --- a/inc/database.php +++ b/inc/database.php @@ -29,12 +29,6 @@ } } - function sql_close() { - global $pdo, $config; - if(!$config['db']['persistent']) - $pdo = NULL; - } - function prepare($query) { global $pdo, $debug, $config; if($config['debug']) { @@ -65,4 +59,4 @@ return $err[2]; } } -?> \ No newline at end of file +?> diff --git a/inc/display.php b/inc/display.php index 43892686..b63fbbf1 100644 --- a/inc/display.php +++ b/inc/display.php @@ -65,8 +65,6 @@ function error($message) { global $board, $mod, $config; - if(function_exists('sql_close')) sql_close(); - if(defined('STDIN')) { // Running from CLI die('Error: ' . $message); @@ -89,7 +87,6 @@ function loginForm($error=false, $username=false, $redirect=false) { global $config; - if(function_exists('sql_close')) sql_close(); die(Element('page.html', Array( 'index'=>$config['root'], 'title'=>'Login', diff --git a/install.php b/install.php index 3dace266..2877d498 100644 --- a/install.php +++ b/install.php @@ -100,10 +100,7 @@ $page['title'] = 'Already installed'; $page['body'] = '
It appears that Tinyboard is already installed (' . $version . ') and there is nothing to upgrade! Delete ' . $config['has_installed'] . ' to reinstall.
'; break; - } - - sql_close(); - + } die(Element('page.html', $page)); } @@ -414,8 +411,6 @@ buildIndex(); } - sql_close(); - $page['title'] = 'Installation complete'; $page['body'] = 'Thank you for using Tinyboard. Please remember to report any bugs you discover.
'; diff --git a/mod.php b/mod.php index b9aadf94..2169bbf9 100644 --- a/mod.php +++ b/mod.php @@ -5,8 +5,6 @@ require 'inc/database.php'; require 'inc/user.php'; - sql_open(); - // Check if banned checkBan(); @@ -52,9 +50,6 @@ header('Location: ' . $_POST['redirect'], true, $config['redirect_http']); else header('Location: ?' . $config['mod']['default'], true, $config['redirect_http']); - - // Close connection - sql_close(); } else { loginForm(false, false, '?' . $query); } @@ -181,7 +176,7 @@ if(!$version = @file_get_contents('.installed')) error('Could not find current version! (Check .installed)'); if(isset($_SESSION['update']) && time() - $_SESSION['update']['time'] < $config['check_updates_time']) { - $latest = $_SESSION['update']['latest']; + $latest = unserialize($_SESSION['update']['latest']); } else { $ctx = stream_context_create(array( 'http' => array( @@ -189,13 +184,9 @@ ) ) ); - $latest = @file_get_contents('http://tinyboard.org/latest.txt', 0, $ctx); - if(preg_match('/^v(\d+)\.(\d)\.(\d+)$/', $latest, $m)) { - $newer = Array( - 'massive' => (int)$m[1], - 'major' => (int)$m[2], - 'minor' => (int)$m[3] - ); + + if($code = @file_get_contents('http://tinyboard.org/version.txt', 0, $ctx)) { + eval($code); if(preg_match('/v(\d+)\.(\d)\.(\d+)(-dev.+)?$/', $version, $m)) { $current = Array( 'massive' => (int)$m[1], @@ -208,22 +199,29 @@ } } // Check if it's newer - if( $newer['massive'] > $current['massive'] || - $newer['major'] > $current['major'] || - ($newer['massive'] == $current['massive'] && - $newer['major'] == $current['major'] && - $newer['minor'] > $current['minor'] + if( $latest['massive'] > $current['massive'] || + $latest['major'] > $current['major'] || + ($latest['massive'] == $current['massive'] && + $latest['major'] == $current['major'] && + $latest['minor'] > $current['minor'] )) { $latest = $latest; } else $latest = false; - } else $latest = false; - - $_SESSION['update'] = Array('time' => time(), 'latest' => $latest); + } else { + // Couldn't get latest version + // TODO: Display some sort of warning message + $latest = false; + } + $_SESSION['update'] = Array('time' => time(), 'latest' => serialize($latest)); } if($latest) { - $latest = trim($latest); - $fieldset['Update'] .= '