Browse Source

...

pull/40/head
Savetheinternet 13 years ago
parent
commit
e3f2aa8da3
  1. 8
      inc/database.php
  2. 3
      inc/display.php
  3. 7
      install.php
  4. 47
      mod.php
  5. 7
      post.php

8
inc/database.php

@ -29,12 +29,6 @@
} }
} }
function sql_close() {
global $pdo, $config;
if(!$config['db']['persistent'])
$pdo = NULL;
}
function prepare($query) { function prepare($query) {
global $pdo, $debug, $config; global $pdo, $debug, $config;
if($config['debug']) { if($config['debug']) {
@ -65,4 +59,4 @@
return $err[2]; return $err[2];
} }
} }
?> ?>

3
inc/display.php

@ -65,8 +65,6 @@
function error($message) { function error($message) {
global $board, $mod, $config; global $board, $mod, $config;
if(function_exists('sql_close')) sql_close();
if(defined('STDIN')) { if(defined('STDIN')) {
// Running from CLI // Running from CLI
die('Error: ' . $message); die('Error: ' . $message);
@ -89,7 +87,6 @@
function loginForm($error=false, $username=false, $redirect=false) { function loginForm($error=false, $username=false, $redirect=false) {
global $config; global $config;
if(function_exists('sql_close')) sql_close();
die(Element('page.html', Array( die(Element('page.html', Array(
'index'=>$config['root'], 'index'=>$config['root'],
'title'=>'Login', 'title'=>'Login',

7
install.php

@ -100,10 +100,7 @@
$page['title'] = 'Already installed'; $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>'; $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; break;
} }
sql_close();
die(Element('page.html', $page)); die(Element('page.html', $page));
} }
@ -414,8 +411,6 @@
buildIndex(); buildIndex();
} }
sql_close();
$page['title'] = 'Installation complete'; $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>'; $page['body'] = '<p style="text-align:center">Thank you for using Tinyboard. Please remember to report any bugs you discover.</p>';

47
mod.php

@ -5,8 +5,6 @@
require 'inc/database.php'; require 'inc/database.php';
require 'inc/user.php'; require 'inc/user.php';
sql_open();
// Check if banned // Check if banned
checkBan(); checkBan();
@ -52,9 +50,6 @@
header('Location: ' . $_POST['redirect'], true, $config['redirect_http']); header('Location: ' . $_POST['redirect'], true, $config['redirect_http']);
else else
header('Location: ?' . $config['mod']['default'], true, $config['redirect_http']); header('Location: ?' . $config['mod']['default'], true, $config['redirect_http']);
// Close connection
sql_close();
} else { } else {
loginForm(false, false, '?' . $query); loginForm(false, false, '?' . $query);
} }
@ -181,7 +176,7 @@
if(!$version = @file_get_contents('.installed')) if(!$version = @file_get_contents('.installed'))
error('Could not find current version! (Check .installed)'); error('Could not find current version! (Check .installed)');
if(isset($_SESSION['update']) && time() - $_SESSION['update']['time'] < $config['check_updates_time']) { if(isset($_SESSION['update']) && time() - $_SESSION['update']['time'] < $config['check_updates_time']) {
$latest = $_SESSION['update']['latest']; $latest = unserialize($_SESSION['update']['latest']);
} else { } else {
$ctx = stream_context_create(array( $ctx = stream_context_create(array(
'http' => 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)) { if($code = @file_get_contents('http://tinyboard.org/version.txt', 0, $ctx)) {
$newer = Array( eval($code);
'massive' => (int)$m[1],
'major' => (int)$m[2],
'minor' => (int)$m[3]
);
if(preg_match('/v(\d+)\.(\d)\.(\d+)(-dev.+)?$/', $version, $m)) { if(preg_match('/v(\d+)\.(\d)\.(\d+)(-dev.+)?$/', $version, $m)) {
$current = Array( $current = Array(
'massive' => (int)$m[1], 'massive' => (int)$m[1],
@ -208,22 +199,29 @@
} }
} }
// Check if it's newer // Check if it's newer
if( $newer['massive'] > $current['massive'] || if( $latest['massive'] > $current['massive'] ||
$newer['major'] > $current['major'] || $latest['major'] > $current['major'] ||
($newer['massive'] == $current['massive'] && ($latest['massive'] == $current['massive'] &&
$newer['major'] == $current['major'] && $latest['major'] == $current['major'] &&
$newer['minor'] > $current['minor'] $latest['minor'] > $current['minor']
)) { )) {
$latest = $latest; $latest = $latest;
} else $latest = false; } else $latest = false;
} else $latest = false; } else {
// Couldn't get latest version
$_SESSION['update'] = Array('time' => time(), 'latest' => $latest); // TODO: Display some sort of warning message
$latest = false;
}
$_SESSION['update'] = Array('time' => time(), 'latest' => serialize($latest));
} }
if($latest) { if($latest) {
$latest = trim($latest); $fieldset['Update'] .=
$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>'; '<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']); error($config['error']['404']);
} }
} }
// Close the connection in-case it's still open
sql_close();
?> ?>

7
post.php

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

Loading…
Cancel
Save