Beispiel #1
0
         } else {
             $onload = manageOnLoad('moderate');
             $text .= manageModeratePostForm();
         }
     } elseif (isset($_GET['sticky']) && isset($_GET['setsticky'])) {
         if ($_GET['sticky'] > 0) {
             $post = postByID($_GET['sticky']);
             if ($post && $post['parent'] == TINYIB_NEWTHREAD) {
                 stickyThreadByID($post['id'], intval($_GET['setsticky']));
                 threadUpdated($post['id']);
                 $text .= manageInfo('Thread No.' . $post['id'] . ' ' . (intval($_GET['setsticky']) == 1 ? 'stickied' : 'un-stickied') . '.');
             } else {
                 fancyDie("Sorry, there doesn't appear to be a thread with that ID.");
             }
         } else {
             fancyDie("Form data was lost. Please go back and try again.");
         }
     } elseif (isset($_GET["rawpost"])) {
         $onload = manageOnLoad("rawpost");
         $text .= manageRawPostForm();
     } elseif (isset($_GET["logout"])) {
         $_SESSION['tinyib'] = '';
         session_destroy();
         die('--&gt; --&gt; --&gt;<meta http-equiv="refresh" content="0;url=' . $returnlink . '?manage">');
     }
     if ($text == '') {
         $text = manageStatus();
     }
 } else {
     $onload = manageOnLoad('login');
     $text .= manageLogInForm();
Beispiel #2
0
function createThumbnail($file_location, $thumb_location, $new_w, $new_h)
{
    if (TINYIB_THUMBNAIL == 'gd') {
        $system = explode(".", $thumb_location);
        $system = array_reverse($system);
        if (preg_match("/jpg|jpeg/", $system[0])) {
            $src_img = imagecreatefromjpeg($file_location);
        } else {
            if (preg_match("/png/", $system[0])) {
                $src_img = imagecreatefrompng($file_location);
            } else {
                if (preg_match("/gif/", $system[0])) {
                    $src_img = imagecreatefromgif($file_location);
                } else {
                    return false;
                }
            }
        }
        if (!$src_img) {
            fancyDie("Unable to read uploaded file during thumbnailing. A common cause for this is an incorrect extension when the file is actually of a different type.");
        }
        $old_x = imageSX($src_img);
        $old_y = imageSY($src_img);
        $percent = $old_x > $old_y ? $new_w / $old_x : $new_h / $old_y;
        $thumb_w = round($old_x * $percent);
        $thumb_h = round($old_y * $percent);
        $dst_img = imagecreatetruecolor($thumb_w, $thumb_h);
        if (preg_match("/png/", $system[0]) && imagepng($src_img, $thumb_location)) {
            imagealphablending($dst_img, false);
            imagesavealpha($dst_img, true);
            $color = imagecolorallocatealpha($dst_img, 0, 0, 0, 0);
            imagefilledrectangle($dst_img, 0, 0, $thumb_w, $thumb_h, $color);
            imagecolortransparent($dst_img, $color);
            imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
        } else {
            fastimagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
        }
        if (preg_match("/png/", $system[0])) {
            if (!imagepng($dst_img, $thumb_location)) {
                return false;
            }
        } else {
            if (preg_match("/jpg|jpeg/", $system[0])) {
                if (!imagejpeg($dst_img, $thumb_location, 70)) {
                    return false;
                }
            } else {
                if (preg_match("/gif/", $system[0])) {
                    if (!imagegif($dst_img, $thumb_location)) {
                        return false;
                    }
                }
            }
        }
        imagedestroy($dst_img);
        imagedestroy($src_img);
    } else {
        // imagemagick
        $discard = '';
        $exit_status = 1;
        exec("convert {$file_location} -auto-orient -thumbnail '" . $new_w . "x" . $new_h . "' -coalesce -layers OptimizeFrame -depth 4 -type palettealpha {$thumb_location}", $discard, $exit_status);
        if ($exit_status != 0) {
            return false;
        }
    }
    return true;
}
Beispiel #3
0
<?php

if (!isset($tinyib)) {
    die('');
}
$link = mysql_connect($mysql_host, $mysql_username, $mysql_password);
if (!$link) {
    fancyDie("Could not connect to database: " . mysql_error());
}
$db_selected = mysql_select_db($mysql_database, $link);
if (!$db_selected) {
    fancyDie("Could not select database: " . mysql_error());
}
// Create the posts table if it does not exist
if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $mysql_posts_table . "'")) == 0) {
    mysql_query("CREATE TABLE `" . $mysql_posts_table . "` (\n\t\t`id` mediumint(7) unsigned NOT NULL auto_increment,\n\t\t`parent` mediumint(7) unsigned NOT NULL,\n\t\t`timestamp` int(20) NOT NULL,\n\t\t`bumped` int(20) NOT NULL,\n\t\t`ip` varchar(15) NOT NULL,\n\t\t`name` varchar(75) NOT NULL,\n\t\t`tripcode` varchar(10) NOT NULL,\n\t\t`email` varchar(75) NOT NULL,\n\t\t`nameblock` varchar(255) NOT NULL,\n\t\t`subject` varchar(75) NOT NULL,\n\t\t`message` text NOT NULL,\n\t\t`password` varchar(255) NOT NULL,\n\t\t`file` varchar(75) NOT NULL,\n\t\t`file_hex` varchar(75) NOT NULL,\n\t\t`file_original` varchar(255) NOT NULL,\n\t\t`file_size` int(20) unsigned NOT NULL default '0',\n\t\t`file_size_formatted` varchar(75) NOT NULL,\n\t\t`image_width` smallint(5) unsigned NOT NULL default '0',\n\t\t`image_height` smallint(5) unsigned NOT NULL default '0',\n\t\t`thumb` varchar(255) NOT NULL,\n\t\t`thumb_width` smallint(5) unsigned NOT NULL default '0',\n\t\t`thumb_height` smallint(5) unsigned NOT NULL default '0',\n\t\tPRIMARY KEY\t(`id`),\n\t\tKEY `parent` (`parent`),\n\t\tKEY `bumped` (`bumped`)\n\t) ENGINE=MyISAM");
}
// Create the bans table if it does not exist
if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $mysql_bans_table . "'")) == 0) {
    mysql_query("CREATE TABLE `" . $mysql_bans_table . "` (\n\t\t`id` mediumint(7) unsigned NOT NULL auto_increment,\n\t\t`ip` varchar(15) NOT NULL,\n\t\t`timestamp` int(20) NOT NULL,\n\t\t`expire` int(20) NOT NULL,\n\t\t`reason` text NOT NULL,\n\t\tPRIMARY KEY\t(`id`),\n\t\tKEY `ip` (`ip`)\n\t) ENGINE=MyISAM");
}
# Post Functions
function uniquePosts()
{
    $row = mysql_fetch_row(mysql_query("SELECT COUNT(DISTINCT(`ip`)) FROM " . $GLOBALS['mysql_posts_table']));
    return $row[0];
}
function postByID($id)
{
    $result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_posts_table'] . "` WHERE `id` = '" . mysql_real_escape_string($id) . "' LIMIT 1");
    while ($post = mysql_fetch_assoc($result)) {
Beispiel #4
0
<?php

if (!defined('TINYIB_BOARD')) {
    die('');
}
if (!function_exists('mysqli_connect')) {
    fancyDie("MySQL library is not installed");
}
$link = @mysqli_connect(TINYIB_DBHOST, TINYIB_DBUSERNAME, TINYIB_DBPASSWORD);
if (!$link) {
    fancyDie("Could not connect to database: " . (is_object($link) ? mysqli_error($link) : (($link_error = mysqli_connect_error()) ? $link_error : '(unknown error)')));
}
$db_selected = @mysqli_query($link, "USE " . constant('TINYIB_DBNAME'));
if (!$db_selected) {
    fancyDie("Could not select database: " . (is_object($link) ? mysqli_error($link) : (($link_error = mysqli_connect_error()) ? $link_error : '(unknown error')));
}
// Create the posts table if it does not exist
if (mysqli_num_rows(mysqli_query($link, "SHOW TABLES LIKE '" . TINYIB_DBPOSTS . "'")) == 0) {
    mysqli_query($link, $posts_sql);
}
// Create the bans table if it does not exist
if (mysqli_num_rows(mysqli_query($link, "SHOW TABLES LIKE '" . TINYIB_DBBANS . "'")) == 0) {
    mysqli_query($link, $bans_sql);
}
# Post Functions
function uniquePosts()
{
    global $link;
    $row = mysqli_fetch_row(mysqli_query($link, "SELECT COUNT(DISTINCT(`ip`)) FROM " . TINYIB_DBPOSTS));
    return $row[0];
}
Beispiel #5
0
if (TINYIB_DBDSN == '') {
    // Build a default (likely MySQL) DSN
    $dsn = TINYIB_DBDRIVER . ":host=" . TINYIB_DBHOST;
    if (TINYIB_DBPORT > 0) {
        $dsn .= ";port=" . TINYIB_DBPORT;
    }
    $dsn .= ";dbname=" . TINYIB_DBNAME;
} else {
    // Use a custom DSN
    $dsn = TINYIB_DBDSN;
}
$options = array(PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
try {
    $dbh = new PDO($dsn, TINYIB_DBUSERNAME, TINYIB_DBPASSWORD, $options);
} catch (PDOException $e) {
    fancyDie("Failed to connect to the database: " . $e->getMessage());
}
// Create the posts table if it does not exist
$dbh->query("SHOW TABLES LIKE " . $dbh->quote(TINYIB_DBPOSTS));
if ($dbh->query("SELECT FOUND_ROWS()")->fetchColumn() == 0) {
    $dbh->exec($posts_sql);
}
// Create the bans table if it does not exist
$dbh->query("SHOW TABLES LIKE " . $dbh->quote(TINYIB_DBBANS));
if ($dbh->query("SELECT FOUND_ROWS()")->fetchColumn() == 0) {
    $dbh->exec($bans_sql);
}
# Utililty
function pdoQuery($sql, $params = false)
{
    global $dbh;
Beispiel #6
0
             deletePostByID($post['id']);
             rebuildIndexes();
             if ($post['parent'] > 0) {
                 rebuildThread($post['parent']);
             }
             $text .= '<b>Post No.' . $post['id'] . ' successfully deleted.</b>';
         } else {
             fancyDie("Sorry, there doesn't appear to be a post with that ID.");
         }
     } elseif (isset($_GET["moderate"])) {
         if ($_GET['moderate'] > 0) {
             $post = postByID($_GET['moderate']);
             if ($post) {
                 $text .= manageModeratePost($post);
             } else {
                 fancyDie("Sorry, there doesn't appear to be a post with that ID.");
             }
         } else {
             $onload = manageOnLoad('moderate');
             $text .= manageModeratePostForm();
         }
     } elseif (isset($_GET["logout"])) {
         $_SESSION['tinyib'] = '';
         session_destroy();
         die('--&gt; --&gt; --&gt;<meta http-equiv="refresh" content="0;url=' . $returnlink . '?manage">');
     }
     if ($text == '') {
         $text = 'Thread count: ' . countThreads() . ' &middot; Ban count: ' . count(allBans());
     }
 } else {
     $onload = manageOnLoad('login');
Beispiel #7
0
<?php

if (!defined('TINYIB_BOARD')) {
    die('');
}
if (!function_exists('sqlite_open')) {
    fancyDie("SQLite library is not installed");
}
if (!($db = sqlite_open('tinyib.db', 0666, $error))) {
    fancyDie("Could not connect to database: " . $error);
}
// Create the posts table if it does not exist
$result = sqlite_query($db, "SELECT name FROM sqlite_master WHERE type='table' AND name='" . TINYIB_DBPOSTS . "'");
if (sqlite_num_rows($result) == 0) {
    sqlite_query($db, "CREATE TABLE " . TINYIB_DBPOSTS . " (\n\t\tid INTEGER PRIMARY KEY,\n\t\tparent INTEGER NOT NULL,\n\t\ttimestamp TIMESTAMP NOT NULL,\n\t\tbumped TIMESTAMP NOT NULL,\n\t\tip TEXT NOT NULL,\n\t\tname TEXT NOT NULL,\n\t\ttripcode TEXT NOT NULL,\n\t\temail TEXT NOT NULL,\n\t\tnameblock TEXT NOT NULL,\n\t\tsubject TEXT NOT NULL,\n\t\tmessage TEXT NOT NULL,\n\t\tpassword TEXT NOT NULL,\n\t\tfile TEXT NOT NULL,\n\t\tfile_hex TEXT NOT NULL,\n\t\tfile_original TEXT NOT NULL,\n\t\tfile_size INTEGER NOT NULL DEFAULT '0',\n\t\tfile_size_formatted TEXT NOT NULL,\n\t\timage_width INTEGER NOT NULL DEFAULT '0',\n\t\timage_height INTEGER NOT NULL DEFAULT '0',\n\t\tthumb TEXT NOT NULL,\n\t\tthumb_width INTEGER NOT NULL DEFAULT '0',\n\t\tthumb_height INTEGER NOT NULL DEFAULT '0'\n\t)");
}
// Create the bans table if it does not exist
$result = sqlite_query($db, "SELECT name FROM sqlite_master WHERE type='table' AND name='" . TINYIB_DBBANS . "'");
if (sqlite_num_rows($result) == 0) {
    sqlite_query($db, "CREATE TABLE " . TINYIB_DBBANS . " (\n\t\tid INTEGER PRIMARY KEY,\n\t\tip TEXT NOT NULL,\n\t\ttimestamp TIMESTAMP NOT NULL,\n\t\texpire TIMESTAMP NOT NULL,\n\t\treason TEXT NOT NULL\n\t)");
}
// Add stickied column if it isn't present
sqlite_query($db, "ALTER TABLE " . TINYIB_DBPOSTS . " ADD COLUMN stickied INTEGER");
# Post Functions
function uniquePosts()
{
    return sqlite_fetch_single(sqlite_query($GLOBALS["db"], "SELECT COUNT(ip) FROM (SELECT DISTINCT ip FROM " . TINYIB_DBPOSTS . ")"));
}
function postByID($id)
{
    $result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT * FROM " . TINYIB_DBPOSTS . " WHERE id = '" . sqlite_escape_string($id) . "' LIMIT 1"), SQLITE_ASSOC);
Beispiel #8
0
function createThumbnail($name, $filename, $new_w, $new_h)
{
    $system = explode(".", $filename);
    $system = array_reverse($system);
    if (preg_match("/jpg|jpeg/", $system[0])) {
        $src_img = imagecreatefromjpeg($name);
    } else {
        if (preg_match("/png/", $system[0])) {
            $src_img = imagecreatefrompng($name);
        } else {
            if (preg_match("/gif/", $system[0])) {
                $src_img = imagecreatefromgif($name);
            } else {
                return false;
            }
        }
    }
    if (!$src_img) {
        fancyDie("Unable to read uploaded file during thumbnailing. A common cause for this is an incorrect extension when the file is actually of a different type.");
    }
    $old_x = imageSX($src_img);
    $old_y = imageSY($src_img);
    if ($old_x > $old_y) {
        $percent = $new_w / $old_x;
    } else {
        $percent = $new_h / $old_y;
    }
    $thumb_w = round($old_x * $percent);
    $thumb_h = round($old_y * $percent);
    $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);
    fastImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
    if (preg_match("/png/", $system[0])) {
        if (!imagepng($dst_img, $filename)) {
            return false;
        }
    } else {
        if (preg_match("/jpg|jpeg/", $system[0])) {
            if (!imagejpeg($dst_img, $filename, 70)) {
                return false;
            }
        } else {
            if (preg_match("/gif/", $system[0])) {
                if (!imagegif($dst_img, $filename)) {
                    return false;
                }
            }
        }
    }
    imagedestroy($dst_img);
    imagedestroy($src_img);
    return true;
}