This commit is contained in:
Savetheinternet 2011-08-15 00:49:52 +10:00
parent 2162238813
commit e3f2aa8da3
5 changed files with 23 additions and 49 deletions

View File

@ -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];
}
}
?>
?>

View File

@ -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',

View File

@ -100,10 +100,7 @@
$page['title'] = 'Already installed';
$page['body'] = '<p style="text-align:center">It appears that Tinyboard is already installed (' . $version . ') and there is nothing to upgrade! Delete <strong>' . $config['has_installed'] . '</strong> to reinstall.</p>';
break;
}
sql_close();
}
die(Element('page.html', $page));
}
@ -414,8 +411,6 @@
buildIndex();
}
sql_close();
$page['title'] = 'Installation complete';
$page['body'] = '<p style="text-align:center">Thank you for using Tinyboard. Please remember to report any bugs you discover.</p>';

47
mod.php
View File

@ -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'] .= '<li>A newer version of Tinyboard (<strong>' . $latest . '</strong>) is available! See <a href="http://tinyboard.org">http://tinyboard.org/</a> for download instructions.</li>';
$fieldset['Update'] .=
'<li>A newer version of Tinyboard (<strong>v' .
$latest['massive'] . '.' .
$latest['major'] . '.' .
$latest['minor'] .
'</strong>) is available! See <a href="http://tinyboard.org">http://tinyboard.org/</a> for download instructions.</li>';
}
}
@ -2283,8 +2281,5 @@
error($config['error']['404']);
}
}
// Close the connection in-case it's still open
sql_close();
?>

View File

@ -73,8 +73,6 @@
buildIndex();
sql_close();
$is_mod = isset($_POST['mod']) && $_POST['mod'];
$root = $is_mod ? $config['root'] . $config['file_mod'] . '?/' : $config['root'];
@ -128,8 +126,6 @@
}
}
sql_close();
$is_mod = isset($_POST['mod']) && $_POST['mod'];
$root = $is_mod ? $config['root'] . $config['file_mod'] . '?/' : $config['root'];
@ -544,8 +540,6 @@
rebuildThemes('post');
header('Location: ' . $redirect, true, $config['redirect_http']);
sql_close();
exit;
} else {
if(!file_exists($config['has_installed'])) {
@ -558,7 +552,6 @@
buildIndex();
}
sql_close();
touch($config['has_installed'], 0777);
die(Element('page.html', Array(