Merge branch 'master' of git://github.com/Yousha/Tinyboard into yousha
This commit is contained in:
commit
a9562075f6
11
README.md
11
README.md
@ -1,6 +1,8 @@
|
|||||||
Tinyboard -- A lightweight PHP imageboard.
|
Tinyboard - A lightweight PHP imageboard.
|
||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
|
About
|
||||||
|
------------
|
||||||
Tinyboard is a light-weight, fast, highly configurable and user-friendly
|
Tinyboard is a light-weight, fast, highly configurable and user-friendly
|
||||||
imageboard software package released under a non-restrictive open-source
|
imageboard software package released under a non-restrictive open-source
|
||||||
license. It is written in PHP and has few dependencies.
|
license. It is written in PHP and has few dependencies.
|
||||||
@ -19,8 +21,11 @@ it need one.
|
|||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
Use GitHub to submit a pull request. If you need help developing a patch, join
|
* Use GitHub to submit a pull request.
|
||||||
our IRC channel.
|
* Send feedbacks
|
||||||
|
* Fix bugs or add features
|
||||||
|
* Write/Edit the Wiki
|
||||||
|
If you need help developing a patch, join our IRC channel.
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
-------------
|
-------------
|
||||||
|
@ -202,59 +202,56 @@ function _create_antibot($board, $thread) {
|
|||||||
|
|
||||||
function checkSpam(array $extra_salt = array()) {
|
function checkSpam(array $extra_salt = array()) {
|
||||||
global $config, $pdo;
|
global $config, $pdo;
|
||||||
|
|
||||||
if (!isset($_POST['hash']))
|
if (!isset($_POST['hash']))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
$hash = $_POST['hash'];
|
$hash = $_POST['hash'];
|
||||||
|
|
||||||
if (!empty($extra_salt)) {
|
if (!empty($extra_salt)) {
|
||||||
// create a salted hash of the "extra salt"
|
// create a salted hash of the "extra salt"
|
||||||
$extra_salt = implode(':', $extra_salt);
|
$extra_salt = implode(':', $extra_salt);
|
||||||
} else {
|
} else {
|
||||||
$extra_salt = '';
|
$extra_salt = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconsturct the $inputs array
|
// Reconsturct the $inputs array
|
||||||
$inputs = array();
|
$inputs = array();
|
||||||
|
|
||||||
foreach ($_POST as $name => $value) {
|
foreach ($_POST as $name => $value) {
|
||||||
if (in_array($name, $config['spam']['valid_inputs']))
|
if (in_array($name, $config['spam']['valid_inputs']))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$inputs[$name] = $value;
|
$inputs[$name] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the inputs in alphabetical order (A-Z)
|
// Sort the inputs in alphabetical order (A-Z)
|
||||||
ksort($inputs);
|
ksort($inputs);
|
||||||
|
|
||||||
$_hash = '';
|
$_hash = '';
|
||||||
|
|
||||||
// Iterate through each input
|
// Iterate through each input
|
||||||
foreach ($inputs as $name => $value) {
|
foreach ($inputs as $name => $value) {
|
||||||
$_hash .= $name . '=' . $value;
|
$_hash .= $name . '=' . $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a salt to the hash
|
// Add a salt to the hash
|
||||||
$_hash .= $config['cookies']['salt'];
|
$_hash .= $config['cookies']['salt'];
|
||||||
|
|
||||||
// Use SHA1 for the hash
|
// Use SHA1 for the hash
|
||||||
$_hash = sha1($_hash . $extra_salt);
|
$_hash = sha1($_hash . $extra_salt);
|
||||||
|
|
||||||
if ($hash != $_hash)
|
if ($hash != $_hash)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
$query = prepare('SELECT `passed` FROM `antispam` WHERE `hash` = :hash');
|
$query = prepare('SELECT `passed` FROM `antispam` WHERE `hash` = :hash');
|
||||||
$query->bindValue(':hash', $hash);
|
$query->bindValue(':hash', $hash);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
if (($passed = $query->fetchColumn(0)) === false) {
|
if ((($passed = $query->fetchColumn(0)) === false) || ($passed > $config['spam']['hidden_inputs_max_pass'])) {
|
||||||
// there was no database entry for this hash. most likely expired.
|
// there was no database entry for this hash. most likely expired.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($passed > $config['spam']['hidden_inputs_max_pass'])
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,5 +260,3 @@ function incrementSpamHash($hash) {
|
|||||||
$query->bindValue(':hash', $hash);
|
$query->bindValue(':hash', $hash);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ function prepare($query) {
|
|||||||
|
|
||||||
if ($config['debug'])
|
if ($config['debug'])
|
||||||
return new PreparedQueryDebug($query);
|
return new PreparedQueryDebug($query);
|
||||||
|
|
||||||
return $pdo->prepare($query);
|
return $pdo->prepare($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,19 +94,19 @@ function query($query) {
|
|||||||
'time' => '~' . $time
|
'time' => '~' . $time
|
||||||
);
|
);
|
||||||
return $query;
|
return $query;
|
||||||
} else {
|
|
||||||
return $pdo->query($query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $pdo->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function db_error($PDOStatement=null) {
|
function db_error($PDOStatement=null) {
|
||||||
global $pdo;
|
global $pdo;
|
||||||
|
|
||||||
if (isset($PDOStatement)) {
|
if (isset($PDOStatement)) {
|
||||||
$err = $PDOStatement->errorInfo();
|
$err = $PDOStatement->errorInfo();
|
||||||
return $err[2];
|
return $err[2];
|
||||||
} else {
|
|
||||||
$err = $pdo->errorInfo();
|
|
||||||
return $err[2];
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
$err = $pdo->errorInfo();
|
||||||
|
return $err[2];
|
||||||
|
}
|
||||||
|
@ -241,6 +241,7 @@ function create_antibot($board, $thread = null) {
|
|||||||
function rebuildThemes($action) {
|
function rebuildThemes($action) {
|
||||||
// List themes
|
// List themes
|
||||||
$query = query("SELECT `theme` FROM `theme_settings` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error());
|
$query = query("SELECT `theme` FROM `theme_settings` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error());
|
||||||
|
|
||||||
while ($theme = $query->fetch()) {
|
while ($theme = $query->fetch()) {
|
||||||
rebuildTheme($theme['theme'], $action);
|
rebuildTheme($theme['theme'], $action);
|
||||||
}
|
}
|
||||||
@ -327,6 +328,7 @@ function setupBoard($array) {
|
|||||||
|
|
||||||
function openBoard($uri) {
|
function openBoard($uri) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if ($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) {
|
if ($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) {
|
||||||
setupBoard($board);
|
setupBoard($board);
|
||||||
return true;
|
return true;
|
||||||
@ -341,7 +343,9 @@ function openBoard($uri) {
|
|||||||
cache::set('board_' . $uri, $board);
|
cache::set('board_' . $uri, $board);
|
||||||
setupBoard($board);
|
setupBoard($board);
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function boardTitle($uri) {
|
function boardTitle($uri) {
|
||||||
@ -356,7 +360,9 @@ function boardTitle($uri) {
|
|||||||
|
|
||||||
if ($title = $query->fetch()) {
|
if ($title = $query->fetch()) {
|
||||||
return $title['title'];
|
return $title['title'];
|
||||||
} else return false;
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function purge($uri) {
|
function purge($uri) {
|
||||||
@ -546,9 +552,9 @@ function until($timestamp) {
|
|||||||
return ($num = round($difference/(60*60*24))) . ' day' . ($num != 1 ? 's' : '');
|
return ($num = round($difference/(60*60*24))) . ' day' . ($num != 1 ? 's' : '');
|
||||||
} elseif ($difference < 60*60*24*365) {
|
} elseif ($difference < 60*60*24*365) {
|
||||||
return ($num = round($difference/(60*60*24*7))) . ' week' . ($num != 1 ? 's' : '');
|
return ($num = round($difference/(60*60*24*7))) . ' week' . ($num != 1 ? 's' : '');
|
||||||
} else {
|
|
||||||
return ($num = round($difference/(60*60*24*365))) . ' year' . ($num != 1 ? 's' : '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ($num = round($difference/(60*60*24*365))) . ' year' . ($num != 1 ? 's' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function ago($timestamp) {
|
function ago($timestamp) {
|
||||||
@ -563,9 +569,9 @@ function ago($timestamp) {
|
|||||||
return ($num = round($difference/(60*60*24))) . ' day' . ($num != 1 ? 's' : '');
|
return ($num = round($difference/(60*60*24))) . ' day' . ($num != 1 ? 's' : '');
|
||||||
} elseif ($difference < 60*60*24*365) {
|
} elseif ($difference < 60*60*24*365) {
|
||||||
return ($num = round($difference/(60*60*24*7))) . ' week' . ($num != 1 ? 's' : '');
|
return ($num = round($difference/(60*60*24*7))) . ' week' . ($num != 1 ? 's' : '');
|
||||||
} else {
|
|
||||||
return ($num = round($difference/(60*60*24*365))) . ' year' . ($num != 1 ? 's' : '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ($num = round($difference/(60*60*24*365))) . ' year' . ($num != 1 ? 's' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayBan($ban) {
|
function displayBan($ban) {
|
||||||
@ -683,7 +689,9 @@ function threadExists($id) {
|
|||||||
|
|
||||||
if ($query->rowCount()) {
|
if ($query->rowCount()) {
|
||||||
return true;
|
return true;
|
||||||
} else return false;
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function post(array $post) {
|
function post(array $post) {
|
||||||
@ -841,10 +849,7 @@ function rebuildPost($id) {
|
|||||||
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
if (!$post = $query->fetch())
|
if ((!$post = $query->fetch()) || !$post['body_nomarkup'])
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!$post['body_nomarkup'])
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
markup($body = &$post['body_nomarkup']);
|
markup($body = &$post['body_nomarkup']);
|
||||||
@ -1101,10 +1106,7 @@ function makerobot($body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkRobot($body) {
|
function checkRobot($body) {
|
||||||
if (empty($body))
|
if (empty($body) || event('check-robot', $body))
|
||||||
return true;
|
|
||||||
|
|
||||||
if (event('check-robot', $body))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
$body = makerobot($body);
|
$body = makerobot($body);
|
||||||
@ -1114,14 +1116,13 @@ function checkRobot($body) {
|
|||||||
|
|
||||||
if ($query->fetch()) {
|
if ($query->fetch()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
// Insert new hash
|
|
||||||
|
|
||||||
$query = prepare("INSERT INTO `robot` VALUES (:hash)");
|
|
||||||
$query->bindValue(':hash', $body);
|
|
||||||
$query->execute() or error(db_error($query));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert new hash
|
||||||
|
$query = prepare("INSERT INTO `robot` VALUES (:hash)");
|
||||||
|
$query->bindValue(':hash', $body);
|
||||||
|
$query->execute() or error(db_error($query));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function numPosts($id) {
|
function numPosts($id) {
|
||||||
@ -1197,7 +1198,6 @@ function checkMute() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function buildIndex() {
|
function buildIndex() {
|
||||||
global $board, $config;
|
global $board, $config;
|
||||||
|
|
||||||
@ -1536,11 +1536,11 @@ function buildThread($id, $return=false, $mod=false) {
|
|||||||
'boardlist' => createBoardlist($mod),
|
'boardlist' => createBoardlist($mod),
|
||||||
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['uri'] . '/' . $config['file_index'])
|
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['uri'] . '/' . $config['file_index'])
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($return)
|
if ($return)
|
||||||
return $body;
|
return $body;
|
||||||
else
|
|
||||||
file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $id), $body);
|
file_write($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $id), $body);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rrmdir($dir) {
|
function rrmdir($dir) {
|
||||||
@ -1634,8 +1634,6 @@ function fraction($numerator, $denominator, $sep) {
|
|||||||
return "{$numerator}{$sep}{$denominator}";
|
return "{$numerator}{$sep}{$denominator}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getPostByHash($hash) {
|
function getPostByHash($hash) {
|
||||||
global $board;
|
global $board;
|
||||||
$query = prepare(sprintf("SELECT `id`,`thread` FROM `posts_%s` WHERE `filehash` = :hash", $board['uri']));
|
$query = prepare(sprintf("SELECT `id`,`thread` FROM `posts_%s` WHERE `filehash` = :hash", $board['uri']));
|
||||||
@ -1706,4 +1704,3 @@ function DNS($host) {
|
|||||||
|
|
||||||
return $ip_addr;
|
return $ip_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
install.sql
14
install.sql
@ -44,7 +44,7 @@ CREATE TABLE IF NOT EXISTS `antispam` (
|
|||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `bans` (
|
CREATE TABLE IF NOT EXISTS `bans` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`ip` varchar(45) NOT NULL,
|
`ip` varchar(45) NOT NULL,
|
||||||
`mod` int(11) NOT NULL COMMENT 'which mod made the ban',
|
`mod` int(11) NOT NULL COMMENT 'which mod made the ban',
|
||||||
`set` int(11) NOT NULL,
|
`set` int(11) NOT NULL,
|
||||||
@ -97,7 +97,7 @@ CREATE TABLE IF NOT EXISTS `cites` (
|
|||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `ip_notes` (
|
CREATE TABLE IF NOT EXISTS `ip_notes` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`ip` varchar(45) NOT NULL,
|
`ip` varchar(45) NOT NULL,
|
||||||
`mod` int(11) DEFAULT NULL,
|
`mod` int(11) DEFAULT NULL,
|
||||||
`time` int(11) NOT NULL,
|
`time` int(11) NOT NULL,
|
||||||
@ -128,7 +128,7 @@ CREATE TABLE IF NOT EXISTS `modlogs` (
|
|||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `mods` (
|
CREATE TABLE IF NOT EXISTS `mods` (
|
||||||
`id` smallint(6) NOT NULL AUTO_INCREMENT,
|
`id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`username` varchar(30) NOT NULL,
|
`username` varchar(30) NOT NULL,
|
||||||
`password` char(40) NOT NULL COMMENT 'SHA1',
|
`password` char(40) NOT NULL COMMENT 'SHA1',
|
||||||
`type` smallint(1) NOT NULL COMMENT '0: janitor, 1: mod, 2: admin',
|
`type` smallint(1) NOT NULL COMMENT '0: janitor, 1: mod, 2: admin',
|
||||||
@ -163,7 +163,7 @@ CREATE TABLE IF NOT EXISTS `mutes` (
|
|||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `news` (
|
CREATE TABLE IF NOT EXISTS `news` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`name` text NOT NULL,
|
`name` text NOT NULL,
|
||||||
`time` int(11) NOT NULL,
|
`time` int(11) NOT NULL,
|
||||||
`subject` text NOT NULL,
|
`subject` text NOT NULL,
|
||||||
@ -179,7 +179,7 @@ CREATE TABLE IF NOT EXISTS `news` (
|
|||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `noticeboard` (
|
CREATE TABLE IF NOT EXISTS `noticeboard` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`mod` int(11) NOT NULL,
|
`mod` int(11) NOT NULL,
|
||||||
`time` int(11) NOT NULL,
|
`time` int(11) NOT NULL,
|
||||||
`subject` text NOT NULL,
|
`subject` text NOT NULL,
|
||||||
@ -194,7 +194,7 @@ CREATE TABLE IF NOT EXISTS `noticeboard` (
|
|||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `pms` (
|
CREATE TABLE IF NOT EXISTS `pms` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`sender` int(11) NOT NULL,
|
`sender` int(11) NOT NULL,
|
||||||
`to` int(11) NOT NULL,
|
`to` int(11) NOT NULL,
|
||||||
`message` text NOT NULL,
|
`message` text NOT NULL,
|
||||||
@ -210,7 +210,7 @@ CREATE TABLE IF NOT EXISTS `pms` (
|
|||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `reports` (
|
CREATE TABLE IF NOT EXISTS `reports` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`time` int(11) NOT NULL,
|
`time` int(11) NOT NULL,
|
||||||
`ip` varchar(45) NOT NULL,
|
`ip` varchar(45) NOT NULL,
|
||||||
`board` varchar(120) DEFAULT NULL,
|
`board` varchar(120) DEFAULT NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user