forked from GithubBackups/tinyib
Moving settings to constants rather than variables
This commit is contained in:
parent
9b999c3d2c
commit
f0540cd221
14
imgboard.php
14
imgboard.php
@ -24,7 +24,7 @@ require 'settings.php';
|
|||||||
|
|
||||||
// Check directories are writable by the script
|
// Check directories are writable by the script
|
||||||
$writedirs = array("res", "src", "thumb");
|
$writedirs = array("res", "src", "thumb");
|
||||||
if ($tinyib['databasemode'] == 'flatfile') { $writedirs[] = "inc/flatfile"; }
|
if (TINYIB_DBMODE == 'flatfile') { $writedirs[] = "inc/flatfile"; }
|
||||||
foreach ($writedirs as $dir) {
|
foreach ($writedirs as $dir) {
|
||||||
if (!is_writable($dir)) {
|
if (!is_writable($dir)) {
|
||||||
fancyDie("Directory '" . $dir . "' can not be written to! Please modify its permissions.");
|
fancyDie("Directory '" . $dir . "' can not be written to! Please modify its permissions.");
|
||||||
@ -32,9 +32,9 @@ foreach ($writedirs as $dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$includes = array("inc/functions.php", "inc/html.php");
|
$includes = array("inc/functions.php", "inc/html.php");
|
||||||
if ($tinyib['databasemode'] == 'flatfile') {
|
if (TINYIB_DBMODE == 'flatfile') {
|
||||||
$includes[] = 'inc/database_flatfile.php';
|
$includes[] = 'inc/database_flatfile.php';
|
||||||
} elseif ($tinyib['databasemode'] == 'mysql') {
|
} elseif (TINYIB_DBMODE == 'mysql') {
|
||||||
$includes[] = 'inc/database_mysql.php';
|
$includes[] = 'inc/database_mysql.php';
|
||||||
} else {
|
} else {
|
||||||
fancyDie("Unknown database mode specificed");
|
fancyDie("Unknown database mode specificed");
|
||||||
@ -44,8 +44,8 @@ foreach ($includes as $include) {
|
|||||||
include $include;
|
include $include;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tinyib['tripseed'] == '' || $tinyib['adminpassword'] == '') {
|
if (TINYIB_TRIPSEED == '' || TINYIB_ADMINPASS == '') {
|
||||||
fancyDie('$tinyib[\'tripseed\'] and $tinyib[\'adminpassword\'] still need to be configured!');
|
fancyDie('TINYIB_TRIPSEED and TINYIB_ADMINPASS must be configured!');
|
||||||
}
|
}
|
||||||
|
|
||||||
$redirect = true;
|
$redirect = true;
|
||||||
@ -96,9 +96,7 @@ if (isset($_POST["message"]) || isset($_POST["file"])) {
|
|||||||
$post['parent'] = $parent;
|
$post['parent'] = $parent;
|
||||||
$post['ip'] = $_SERVER['REMOTE_ADDR'];
|
$post['ip'] = $_SERVER['REMOTE_ADDR'];
|
||||||
|
|
||||||
$nt = nameAndTripcode($_POST["name"]);
|
list($post['name'], $post['tripcode']) = nameAndTripcode($_POST["name"]);
|
||||||
$post['name'] = $nt[0];
|
|
||||||
$post['tripcode'] = $nt[1];
|
|
||||||
|
|
||||||
$post['name'] = cleanString(substr($post['name'], 0, 75));
|
$post['name'] = cleanString(substr($post['name'], 0, 75));
|
||||||
$post['email'] = cleanString(str_replace('"', '"', substr($_POST["email"], 0, 75)));
|
$post['email'] = cleanString(str_replace('"', '"', substr($_POST["email"], 0, 75)));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!isset($tinyib)) { die(''); }
|
if (!defined('TINYIB_BOARD')) { die(''); }
|
||||||
|
|
||||||
# Post Structure
|
# Post Structure
|
||||||
define('POSTS_FILE', '.posts');
|
define('POSTS_FILE', '.posts');
|
||||||
@ -181,12 +181,11 @@ function deletePostByID($id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function trimThreads() {
|
function trimThreads() {
|
||||||
global $tinyib;
|
if (TINYIB_MAXTHREADS > 0) {
|
||||||
if ($tinyib['maxthreads'] > 0) {
|
|
||||||
$numthreads = countThreads();
|
$numthreads = countThreads();
|
||||||
if ($numthreads > $tinyib['maxthreads']) {
|
if ($numthreads > TINYIB_MAXTHREADS) {
|
||||||
$allthreads = allThreads();
|
$allthreads = allThreads();
|
||||||
for ($i=$tinyib['maxthreads'];$i<$numthreads;$i++) {
|
for ($i=TINYIB_MAXTHREADS;$i<$numthreads;$i++) {
|
||||||
deletePostByID($allthreads[$i]['id']);
|
deletePostByID($allthreads[$i]['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!isset($tinyib)) { die(''); }
|
if (!defined('TINYIB_BOARD')) { die(''); }
|
||||||
|
|
||||||
$link = mysql_connect($mysql_host, $mysql_username, $mysql_password);
|
$link = mysql_connect($mysql_host, $mysql_username, $mysql_password);
|
||||||
if (!$link) {
|
if (!$link) {
|
||||||
@ -11,8 +11,8 @@ if (!$db_selected) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the posts table if it does not exist
|
// Create the posts table if it does not exist
|
||||||
if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $mysql_posts_table . "'")) == 0) {
|
if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . TINYIB_DBPOSTS . "'")) == 0) {
|
||||||
mysql_query("CREATE TABLE `" . $mysql_posts_table . "` (
|
mysql_query("CREATE TABLE `" . TINYIB_DBPOSTS . "` (
|
||||||
`id` mediumint(7) unsigned NOT NULL auto_increment,
|
`id` mediumint(7) unsigned NOT NULL auto_increment,
|
||||||
`parent` mediumint(7) unsigned NOT NULL,
|
`parent` mediumint(7) unsigned NOT NULL,
|
||||||
`timestamp` int(20) NOT NULL,
|
`timestamp` int(20) NOT NULL,
|
||||||
@ -42,8 +42,8 @@ if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $mysql_posts_table . "'"))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the bans table if it does not exist
|
// Create the bans table if it does not exist
|
||||||
if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $mysql_bans_table . "'")) == 0) {
|
if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . TINYIB_DBBANS . "'")) == 0) {
|
||||||
mysql_query("CREATE TABLE `" . $mysql_bans_table . "` (
|
mysql_query("CREATE TABLE `" . TINYIB_DBBANS . "` (
|
||||||
`id` mediumint(7) unsigned NOT NULL auto_increment,
|
`id` mediumint(7) unsigned NOT NULL auto_increment,
|
||||||
`ip` varchar(15) NOT NULL,
|
`ip` varchar(15) NOT NULL,
|
||||||
`timestamp` int(20) NOT NULL,
|
`timestamp` int(20) NOT NULL,
|
||||||
@ -56,37 +56,37 @@ if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $mysql_bans_table . "'"))
|
|||||||
|
|
||||||
# Post Functions
|
# Post Functions
|
||||||
function uniquePosts() {
|
function uniquePosts() {
|
||||||
$row = mysql_fetch_row(mysql_query("SELECT COUNT(DISTINCT(`ip`)) FROM " . $GLOBALS['mysql_posts_table']));
|
$row = mysql_fetch_row(mysql_query("SELECT COUNT(DISTINCT(`ip`)) FROM " . TINYIB_DBPOSTS));
|
||||||
return $row[0];
|
return $row[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function postByID($id) {
|
function postByID($id) {
|
||||||
$result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `id` = '" . mysql_real_escape_string($id) . "' LIMIT 1");
|
$result = mysql_query("SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `id` = '" . mysql_real_escape_string($id) . "' LIMIT 1");
|
||||||
while ($post = mysql_fetch_assoc($result)) {
|
while ($post = mysql_fetch_assoc($result)) {
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function threadExistsByID($id) {
|
function threadExistsByID($id) {
|
||||||
return mysql_result(mysql_query("SELECT COUNT(*) FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `id` = '" . mysql_real_escape_string($id) . "' AND `parent` = 0 LIMIT 1"), 0, 0) > 0;
|
return mysql_result(mysql_query("SELECT COUNT(*) FROM `" . TINYIB_DBPOSTS . "` WHERE `id` = '" . mysql_real_escape_string($id) . "' AND `parent` = 0 LIMIT 1"), 0, 0) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertPost($post) {
|
function insertPost($post) {
|
||||||
mysql_query("INSERT INTO `" . $GLOBALS['mysql_posts_table'] . "` (`parent`, `timestamp`, `bumped`, `ip`, `name`, `tripcode`, `email`, `nameblock`, `subject`, `message`, `password`, `file`, `file_hex`, `file_original`, `file_size`, `file_size_formatted`, `image_width`, `image_height`, `thumb`, `thumb_width`, `thumb_height`) VALUES (" . $post['parent'] . ", " . time() . ", " . time() . ", '" . $_SERVER['REMOTE_ADDR'] . "', '" . mysql_real_escape_string($post['name']) . "', '" . mysql_real_escape_string($post['tripcode']) . "', '" . mysql_real_escape_string($post['email']) . "', '" . mysql_real_escape_string($post['nameblock']) . "', '" . mysql_real_escape_string($post['subject']) . "', '" . mysql_real_escape_string($post['message']) . "', '" . mysql_real_escape_string($post['password']) . "', '" . $post['file'] . "', '" . $post['file_hex'] . "', '" . mysql_real_escape_string($post['file_original']) . "', " . $post['file_size'] . ", '" . $post['file_size_formatted'] . "', " . $post['image_width'] . ", " . $post['image_height'] . ", '" . $post['thumb'] . "', " . $post['thumb_width'] . ", " . $post['thumb_height'] . ")");
|
mysql_query("INSERT INTO `" . TINYIB_DBPOSTS . "` (`parent`, `timestamp`, `bumped`, `ip`, `name`, `tripcode`, `email`, `nameblock`, `subject`, `message`, `password`, `file`, `file_hex`, `file_original`, `file_size`, `file_size_formatted`, `image_width`, `image_height`, `thumb`, `thumb_width`, `thumb_height`) VALUES (" . $post['parent'] . ", " . time() . ", " . time() . ", '" . $_SERVER['REMOTE_ADDR'] . "', '" . mysql_real_escape_string($post['name']) . "', '" . mysql_real_escape_string($post['tripcode']) . "', '" . mysql_real_escape_string($post['email']) . "', '" . mysql_real_escape_string($post['nameblock']) . "', '" . mysql_real_escape_string($post['subject']) . "', '" . mysql_real_escape_string($post['message']) . "', '" . mysql_real_escape_string($post['password']) . "', '" . $post['file'] . "', '" . $post['file_hex'] . "', '" . mysql_real_escape_string($post['file_original']) . "', " . $post['file_size'] . ", '" . $post['file_size_formatted'] . "', " . $post['image_width'] . ", " . $post['image_height'] . ", '" . $post['thumb'] . "', " . $post['thumb_width'] . ", " . $post['thumb_height'] . ")");
|
||||||
return mysql_insert_id();
|
return mysql_insert_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
function bumpThreadByID($id) {
|
function bumpThreadByID($id) {
|
||||||
mysql_query("UPDATE `" . $GLOBALS['mysql_posts_table'] . "` SET `bumped` = " . time() . " WHERE `id` = " . $id . " LIMIT 1");
|
mysql_query("UPDATE `" . TINYIB_DBPOSTS . "` SET `bumped` = " . time() . " WHERE `id` = " . $id . " LIMIT 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
function countThreads() {
|
function countThreads() {
|
||||||
return mysql_result(mysql_query("SELECT COUNT(*) FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `parent` = 0"), 0, 0);
|
return mysql_result(mysql_query("SELECT COUNT(*) FROM `" . TINYIB_DBPOSTS . "` WHERE `parent` = 0"), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function allThreads() {
|
function allThreads() {
|
||||||
$threads = array();
|
$threads = array();
|
||||||
$result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `parent` = 0 ORDER BY `bumped` DESC");
|
$result = mysql_query("SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `parent` = 0 ORDER BY `bumped` DESC");
|
||||||
while ($thread = mysql_fetch_assoc($result)) {
|
while ($thread = mysql_fetch_assoc($result)) {
|
||||||
$threads[] = $thread;
|
$threads[] = $thread;
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ function allThreads() {
|
|||||||
|
|
||||||
function postsInThreadByID($id) {
|
function postsInThreadByID($id) {
|
||||||
$posts = array();
|
$posts = array();
|
||||||
$result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `id` = " . $id . " OR `parent` = " . $id . " ORDER BY `id` ASC");
|
$result = mysql_query("SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `id` = " . $id . " OR `parent` = " . $id . " ORDER BY `id` ASC");
|
||||||
while ($post = mysql_fetch_assoc($result)) {
|
while ($post = mysql_fetch_assoc($result)) {
|
||||||
$posts[] = $post;
|
$posts[] = $post;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ function postsInThreadByID($id) {
|
|||||||
|
|
||||||
function latestRepliesInThreadByID($id) {
|
function latestRepliesInThreadByID($id) {
|
||||||
$posts = array();
|
$posts = array();
|
||||||
$replies = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `parent` = " . $id . " ORDER BY `id` DESC LIMIT 3");
|
$replies = mysql_query("SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `parent` = " . $id . " ORDER BY `id` DESC LIMIT 3");
|
||||||
while ($post = mysql_fetch_assoc($replies)) {
|
while ($post = mysql_fetch_assoc($replies)) {
|
||||||
$posts[] = $post;
|
$posts[] = $post;
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ function latestRepliesInThreadByID($id) {
|
|||||||
|
|
||||||
function postsByHex($hex) {
|
function postsByHex($hex) {
|
||||||
$posts = array();
|
$posts = array();
|
||||||
$result = mysql_query("SELECT `id`, `parent` FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `file_hex` = '" . mysql_real_escape_string($hex) . "' LIMIT 1");
|
$result = mysql_query("SELECT `id`, `parent` FROM `" . TINYIB_DBPOSTS . "` WHERE `file_hex` = '" . mysql_real_escape_string($hex) . "' LIMIT 1");
|
||||||
while ($post = mysql_fetch_assoc($result)) {
|
while ($post = mysql_fetch_assoc($result)) {
|
||||||
$posts[] = $post;
|
$posts[] = $post;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ function deletePostByID($id) {
|
|||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
if ($post['id'] != $id) {
|
if ($post['id'] != $id) {
|
||||||
deletePostImages($post);
|
deletePostImages($post);
|
||||||
mysql_query("DELETE FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `id` = " . $post['id'] . " LIMIT 1");
|
mysql_query("DELETE FROM `" . TINYIB_DBPOSTS . "` WHERE `id` = " . $post['id'] . " LIMIT 1");
|
||||||
} else {
|
} else {
|
||||||
$thispost = $post;
|
$thispost = $post;
|
||||||
}
|
}
|
||||||
@ -135,14 +135,13 @@ function deletePostByID($id) {
|
|||||||
@unlink('res/' . $thispost['id'] . '.html');
|
@unlink('res/' . $thispost['id'] . '.html');
|
||||||
}
|
}
|
||||||
deletePostImages($thispost);
|
deletePostImages($thispost);
|
||||||
mysql_query("DELETE FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `id` = " . $thispost['id'] . " LIMIT 1");
|
mysql_query("DELETE FROM `" . TINYIB_DBPOSTS . "` WHERE `id` = " . $thispost['id'] . " LIMIT 1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function trimThreads() {
|
function trimThreads() {
|
||||||
global $tinyib;
|
if (TINYIB_MAXTHREADS > 0) {
|
||||||
if ($tinyib['maxthreads'] > 0) {
|
$result = mysql_query("SELECT `id` FROM `" . TINYIB_DBPOSTS . "` WHERE `parent` = 0 ORDER BY `bumped` DESC LIMIT " . TINYIB_MAXTHREADS. ", 10");
|
||||||
$result = mysql_query("SELECT `id` FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `parent` = 0 ORDER BY `bumped` DESC LIMIT " . $tinyib['maxthreads']. ", 10");
|
|
||||||
while ($post = mysql_fetch_assoc($result)) {
|
while ($post = mysql_fetch_assoc($result)) {
|
||||||
deletePostByID($post['id']);
|
deletePostByID($post['id']);
|
||||||
}
|
}
|
||||||
@ -150,7 +149,7 @@ function trimThreads() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function lastPostByIP() {
|
function lastPostByIP() {
|
||||||
$replies = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `ip` = '" . $_SERVER['REMOTE_ADDR'] . "' ORDER BY `id` DESC LIMIT 1");
|
$replies = mysql_query("SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `ip` = '" . $_SERVER['REMOTE_ADDR'] . "' ORDER BY `id` DESC LIMIT 1");
|
||||||
while ($post = mysql_fetch_assoc($replies)) {
|
while ($post = mysql_fetch_assoc($replies)) {
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
@ -158,14 +157,14 @@ function lastPostByIP() {
|
|||||||
|
|
||||||
# Ban Functions
|
# Ban Functions
|
||||||
function banByID($id) {
|
function banByID($id) {
|
||||||
$result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `id` = '" . mysql_real_escape_string($id) . "' LIMIT 1");
|
$result = mysql_query("SELECT * FROM `" . TINYIB_DBBANS . "` WHERE `id` = '" . mysql_real_escape_string($id) . "' LIMIT 1");
|
||||||
while ($ban = mysql_fetch_assoc($result)) {
|
while ($ban = mysql_fetch_assoc($result)) {
|
||||||
return $ban;
|
return $ban;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function banByIP($ip) {
|
function banByIP($ip) {
|
||||||
$result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `ip` = '" . mysql_real_escape_string($ip) . "' LIMIT 1");
|
$result = mysql_query("SELECT * FROM `" . TINYIB_DBBANS . "` WHERE `ip` = '" . mysql_real_escape_string($ip) . "' LIMIT 1");
|
||||||
while ($ban = mysql_fetch_assoc($result)) {
|
while ($ban = mysql_fetch_assoc($result)) {
|
||||||
return $ban;
|
return $ban;
|
||||||
}
|
}
|
||||||
@ -173,7 +172,7 @@ function banByIP($ip) {
|
|||||||
|
|
||||||
function allBans() {
|
function allBans() {
|
||||||
$bans = array();
|
$bans = array();
|
||||||
$result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_bans_table'] . "` ORDER BY `timestamp` DESC");
|
$result = mysql_query("SELECT * FROM `" . TINYIB_DBBANS . "` ORDER BY `timestamp` DESC");
|
||||||
while ($ban = mysql_fetch_assoc($result)) {
|
while ($ban = mysql_fetch_assoc($result)) {
|
||||||
$bans[] = $ban;
|
$bans[] = $ban;
|
||||||
}
|
}
|
||||||
@ -181,19 +180,19 @@ function allBans() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function insertBan($ban) {
|
function insertBan($ban) {
|
||||||
mysql_query("INSERT INTO `" . $GLOBALS['mysql_bans_table'] . "` (`ip`, `timestamp`, `expire`, `reason`) VALUES ('" . mysql_real_escape_string($ban['ip']) . "', " . time() . ", '" . mysql_real_escape_string($ban['expire']) . "', '" . mysql_real_escape_string($ban['reason']) . "')");
|
mysql_query("INSERT INTO `" . TINYIB_DBBANS . "` (`ip`, `timestamp`, `expire`, `reason`) VALUES ('" . mysql_real_escape_string($ban['ip']) . "', " . time() . ", '" . mysql_real_escape_string($ban['expire']) . "', '" . mysql_real_escape_string($ban['reason']) . "')");
|
||||||
return mysql_insert_id();
|
return mysql_insert_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearExpiredBans() {
|
function clearExpiredBans() {
|
||||||
$result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `expire` > 0 AND `expire` <= " . time());
|
$result = mysql_query("SELECT * FROM `" . TINYIB_DBBANS . "` WHERE `expire` > 0 AND `expire` <= " . time());
|
||||||
while ($ban = mysql_fetch_assoc($result)) {
|
while ($ban = mysql_fetch_assoc($result)) {
|
||||||
mysql_query("DELETE FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `id` = " . $ban['id'] . " LIMIT 1");
|
mysql_query("DELETE FROM `" . TINYIB_DBBANS . "` WHERE `id` = " . $ban['id'] . " LIMIT 1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteBanByID($id) {
|
function deleteBanByID($id) {
|
||||||
mysql_query("DELETE FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `id` = " . mysql_real_escape_string($id) . " LIMIT 1");
|
mysql_query("DELETE FROM `" . TINYIB_DBBANS . "` WHERE `id` = " . mysql_real_escape_string($id) . " LIMIT 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!isset($tinyib)) { die(''); }
|
if (!defined('TINYIB_BOARD')) { die(''); }
|
||||||
|
|
||||||
function cleanString($string) {
|
function cleanString($string) {
|
||||||
$search = array("<", ">");
|
$search = array("<", ">");
|
||||||
@ -58,8 +58,6 @@ function convertBytes($number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nameAndTripcode($name) {
|
function nameAndTripcode($name) {
|
||||||
global $tinyib;
|
|
||||||
|
|
||||||
if (preg_match("/(#|!)(.*)/", $name, $regs)) {
|
if (preg_match("/(#|!)(.*)/", $name, $regs)) {
|
||||||
$cap = $regs[2];
|
$cap = $regs[2];
|
||||||
$cap_full = '#' . $regs[2];
|
$cap_full = '#' . $regs[2];
|
||||||
@ -103,7 +101,7 @@ function nameAndTripcode($name) {
|
|||||||
$tripcode .= "!";
|
$tripcode .= "!";
|
||||||
}
|
}
|
||||||
|
|
||||||
$tripcode .= "!" . substr(md5($cap_secure . $tinyib['tripseed']), 2, 10);
|
$tripcode .= "!" . substr(md5($cap_secure . TINYIB_TRIPSEED), 2, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(preg_replace("/(" . $cap_delimiter . ")(.*)/", "", $name), $tripcode);
|
return array(preg_replace("/(" . $cap_delimiter . ")(.*)/", "", $name), $tripcode);
|
||||||
@ -135,9 +133,7 @@ function nameBlock($name, $tripcode, $email, $timestamp, $modposttext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function writePage($filename, $contents) {
|
function writePage($filename, $contents) {
|
||||||
global $tinyib;
|
$tempfile = tempnam('res/', TINYIB_BOARD . 'tmp'); /* Create the temporary file */
|
||||||
|
|
||||||
$tempfile = tempnam('res/', $tinyib['board'] . 'tmp'); /* Create the temporary file */
|
|
||||||
$fp = fopen($tempfile, 'w');
|
$fp = fopen($tempfile, 'w');
|
||||||
fwrite($fp, $contents);
|
fwrite($fp, $contents);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
@ -168,21 +164,20 @@ function deletePostImages($post) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function manageCheckLogIn() {
|
function manageCheckLogIn() {
|
||||||
global $tinyib;
|
|
||||||
$loggedin = false; $isadmin = false;
|
$loggedin = false; $isadmin = false;
|
||||||
if (isset($_POST['password'])) {
|
if (isset($_POST['password'])) {
|
||||||
if ($_POST['password'] == $tinyib['adminpassword']) {
|
if ($_POST['password'] == TINYIB_ADMINPASS) {
|
||||||
$_SESSION['tinyib'] = $tinyib['adminpassword'];
|
$_SESSION['tinyib'] = TINYIB_ADMINPASS;
|
||||||
} elseif ($tinyib['modpassword'] != '' && $_POST['password'] == $tinyib['modpassword']) {
|
} elseif (TINYIB_MODPASS != '' && $_POST['password'] == TINYIB_MODPASS) {
|
||||||
$_SESSION['tinyib'] = $tinyib['modpassword'];
|
$_SESSION['tinyib'] = TINYIB_MODPASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SESSION['tinyib'])) {
|
if (isset($_SESSION['tinyib'])) {
|
||||||
if ($_SESSION['tinyib'] == $tinyib['adminpassword']) {
|
if ($_SESSION['tinyib'] == TINYIB_ADMINPASS) {
|
||||||
$loggedin = true;
|
$loggedin = true;
|
||||||
$isadmin = true;
|
$isadmin = true;
|
||||||
} elseif ($tinyib['modpassword'] != '' && $_SESSION['tinyib'] == $tinyib['modpassword']) {
|
} elseif (TINYIB_MODPASS != '' && $_SESSION['tinyib'] == TINYIB_MODPASS) {
|
||||||
$loggedin = true;
|
$loggedin = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
28
inc/html.php
28
inc/html.php
@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!isset($tinyib)) { die(''); }
|
if (!defined('TINYIB_BOARD')) { die(''); }
|
||||||
|
|
||||||
function pageHeader() {
|
function pageHeader() {
|
||||||
global $tinyib;
|
$return = <<<EOF
|
||||||
return <<<EOF
|
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>
|
<title>
|
||||||
${tinyib['boarddescription']}
|
EOF;
|
||||||
|
$return .= TINYIB_BOARDDESC . <<<EOF
|
||||||
</title>
|
</title>
|
||||||
<link rel="shortcut icon" href="favicon.ico">
|
<link rel="shortcut icon" href="favicon.ico">
|
||||||
<link rel="stylesheet" type="text/css" href="css/global.css">
|
<link rel="stylesheet" type="text/css" href="css/global.css">
|
||||||
@ -19,6 +19,7 @@ function pageHeader() {
|
|||||||
<meta http-equiv="expires" content="-1">
|
<meta http-equiv="expires" content="-1">
|
||||||
</head>
|
</head>
|
||||||
EOF;
|
EOF;
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pageFooter() {
|
function pageFooter() {
|
||||||
@ -112,7 +113,6 @@ EOF;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildPage($htmlposts, $parent, $pages=0, $thispage=0) {
|
function buildPage($htmlposts, $parent, $pages=0, $thispage=0) {
|
||||||
global $tinyib;
|
|
||||||
$managelink = basename($_SERVER['PHP_SELF']) . "?manage";
|
$managelink = basename($_SERVER['PHP_SELF']) . "?manage";
|
||||||
|
|
||||||
$postingmode = "";
|
$postingmode = "";
|
||||||
@ -162,8 +162,8 @@ EOF;
|
|||||||
[<a href="$managelink">Manage</a>]
|
[<a href="$managelink">Manage</a>]
|
||||||
</div>
|
</div>
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
${tinyib['logo']}
|
EOF;
|
||||||
${tinyib['boarddescription']}
|
$body .= TINYIB_LOGO . TINYIB_BOARDDESC . <<<EOF
|
||||||
</div>
|
</div>
|
||||||
<hr width="90%" size="1">
|
<hr width="90%" size="1">
|
||||||
$postingmode
|
$postingmode
|
||||||
@ -238,7 +238,9 @@ EOF;
|
|||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<form id="delform" action="imgboard.php?delete" method="post">
|
<form id="delform" action="imgboard.php?delete" method="post">
|
||||||
<input type="hidden" name="board" value="${tinyib['board']}">
|
<input type="hidden" name="board"
|
||||||
|
EOF;
|
||||||
|
$body .= 'value="' . TINYIB_BOARD . '">' . <<<EOF
|
||||||
$htmlposts
|
$htmlposts
|
||||||
<table class="userdelete">
|
<table class="userdelete">
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -257,8 +259,6 @@ EOF;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function rebuildIndexes() {
|
function rebuildIndexes() {
|
||||||
global $mysql_posts_table;
|
|
||||||
|
|
||||||
$htmlposts = "";
|
$htmlposts = "";
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -300,8 +300,6 @@ function rebuildIndexes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function rebuildThread($id) {
|
function rebuildThread($id) {
|
||||||
global $mysql_posts_table;
|
|
||||||
|
|
||||||
$htmlposts = "";
|
$htmlposts = "";
|
||||||
$posts = postsInThreadByID($id);
|
$posts = postsInThreadByID($id);
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
@ -326,8 +324,6 @@ function adminBar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function managePage($text, $onload='') {
|
function managePage($text, $onload='') {
|
||||||
global $tinyib;
|
|
||||||
|
|
||||||
$adminbar = adminBar();
|
$adminbar = adminBar();
|
||||||
$body = <<<EOF
|
$body = <<<EOF
|
||||||
<body$onload>
|
<body$onload>
|
||||||
@ -335,8 +331,8 @@ function managePage($text, $onload='') {
|
|||||||
$adminbar
|
$adminbar
|
||||||
</div>
|
</div>
|
||||||
<div class="logo">
|
<div class="logo">
|
||||||
${tinyib['logo']}
|
EOF;
|
||||||
${tinyib['boarddescription']}
|
$body .= TINYIB_LOGO . TINYIB_BOARDDESC . <<<EOF
|
||||||
</div>
|
</div>
|
||||||
<hr width="90%" size="1">
|
<hr width="90%" size="1">
|
||||||
<div class="replymode">Manage mode</div>
|
<div class="replymode">Manage mode</div>
|
||||||
|
@ -1,19 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
$tinyib = array();
|
define('TINYIB_BOARD', "b"); // Unique identifier for this board using only letters and numbers
|
||||||
$tinyib['board'] = "b"; // Unique identifier for this board using only letters and numbers
|
define('TINYIB_BOARDDESC', "TinyIB"); // Displayed in the logo area
|
||||||
$tinyib['boarddescription'] = "TinyIB"; // Displayed in the logo area
|
define('TINYIB_MAXTHREADS', 100); // Set this to limit the number of threads allowed before discarding older threads. 0 to disable
|
||||||
$tinyib['maxthreads'] = 100; // Set this to limit the number of threads allowed before discarding older threads. 0 to disable
|
define('TINYIB_LOGO', ""); // Logo HTML
|
||||||
$tinyib['logo'] = ""; // Logo HTML
|
define('TINYIB_TRIPSEED', ""); // Text to use when generating secure tripcodes
|
||||||
$tinyib['tripseed'] = ""; // Text to use when generating secure tripcodes
|
define('TINYIB_ADMINPASS', ""); // Text entered at the manage prompt to gain administrator access
|
||||||
$tinyib['adminpassword'] = ""; // Text entered at the manage prompt to gain administrator access
|
define('TINYIB_MODPASS', ""); // Same as above, but only has access to delete posts. Blank ("") to disable
|
||||||
$tinyib['modpassword'] = ""; // Same as above, but only has access to delete posts. Blank ("") to disable
|
define('TINYIB_DBMODE', "flatfile"); // flatfile or mysql
|
||||||
$tinyib['databasemode'] = "flatfile"; // flatfile or mysql
|
|
||||||
|
|
||||||
// mysql settings
|
// mysql settings - only edit if not using flatfile
|
||||||
$mysql_host = "localhost";
|
define('TINYIB_DBHOST', "localhost");
|
||||||
$mysql_username = "";
|
define('TINYIB_DBUSERNAME', "");
|
||||||
$mysql_password = "";
|
define('TINYIB_DBPASSWORD', "");
|
||||||
$mysql_database = "";
|
define('TINYIB_DBNAME', "");
|
||||||
$mysql_posts_table = $tinyib['board'] . "_posts";
|
define('TINYIB_DBPOSTS', TINYIB_BOARD . "_posts");
|
||||||
$mysql_bans_table = "bans";
|
define('TINYIB_DBBANS', "bans");
|
||||||
?>
|
?>
|
Loading…
x
Reference in New Issue
Block a user