Beispiel #1
0
            }
        } 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();
    }
    echo managePage($text, $onload);
} elseif (!file_exists('index.html') || countThreads() == 0) {
    rebuildIndexes();
} elseif (isset($_GET['json']) && TINYIB_JSON) {
    $redirect = false;
    $json = $_GET['json'];
    if ($json == '') {
        echo '{"id": ' . 0 . ', "name": "' . TINYIB_BOARD . '", "threads":' . getJSON(allThreads(true)) . '}';
    } else {
        echo '{"id": ' . $json . ', "posts":' . getJSON(postsInThreadByID($json, true, true)) . '}';
    }
}
if ($redirect) {
    echo '--&gt; --&gt; --&gt;<meta http-equiv="refresh" content="' . (isset($slow_redirect) ? '3' : '0') . ';url=' . (is_string($redirect) ? $redirect : 'index.html') . '">';
}
Beispiel #2
0
 if (TINYIB_DBMODE == 'flatfile') {
     if (function_exists('mysqli_connect')) {
         $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')));
         }
         if (mysqli_num_rows(mysqli_query($link, "SHOW TABLES LIKE '" . TINYIB_DBPOSTS . "'")) == 0) {
             if (mysqli_num_rows(mysqli_query($link, "SHOW TABLES LIKE '" . TINYIB_DBBANS . "'")) == 0) {
                 mysqli_query($link, $posts_sql);
                 mysqli_query($link, $bans_sql);
                 $max_id = 0;
                 $threads = allThreads();
                 foreach ($threads as $thread) {
                     $posts = postsInThreadByID($thread['id']);
                     foreach ($posts as $post) {
                         mysqli_query($link, "INSERT INTO `" . TINYIB_DBPOSTS . "` (`id`, `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`, `stickied`) VALUES (" . $post['id'] . ", " . $post['parent'] . ", " . time() . ", " . time() . ", '" . $_SERVER['REMOTE_ADDR'] . "', '" . mysqli_real_escape_string($link, $post['name']) . "', '" . mysqli_real_escape_string($link, $post['tripcode']) . "',\t'" . mysqli_real_escape_string($link, $post['email']) . "',\t'" . mysqli_real_escape_string($link, $post['nameblock']) . "', '" . mysqli_real_escape_string($link, $post['subject']) . "', '" . mysqli_real_escape_string($link, $post['message']) . "', '" . mysqli_real_escape_string($link, $post['password']) . "', '" . $post['file'] . "', '" . $post['file_hex'] . "', '" . mysqli_real_escape_string($link, $post['file_original']) . "', " . $post['file_size'] . ", '" . $post['file_size_formatted'] . "', " . $post['image_width'] . ", " . $post['image_height'] . ", '" . $post['thumb'] . "', " . $post['thumb_width'] . ", " . $post['thumb_height'] . ", " . $post['stickied'] . ")");
                         $max_id = max($max_id, $post['id']);
                     }
                 }
                 if ($max_id > 0 && !mysqli_query($link, "ALTER TABLE `" . TINYIB_DBPOSTS . "` AUTO_INCREMENT = " . ($max_id + 1))) {
                     $text .= '<p><b>Warning:</b> Unable to update the AUTO_INCREMENT value for table ' . TINYIB_DBPOSTS . ', please set it to ' . ($max_id + 1) . '.</p>';
                 }
                 $max_id = 0;
                 $bans = allBans();
                 foreach ($bans as $ban) {
                     $max_id = max($max_id, $ban['id']);
                     mysqli_query($link, "INSERT INTO `" . TINYIB_DBBANS . "` (`id`, `ip`, `timestamp`, `expire`, `reason`) VALUES ('" . mysqli_real_escape_string($link, $ban['id']) . "', '" . mysqli_real_escape_string($link, $ban['ip']) . "', '" . mysqli_real_escape_string($link, $ban['timestamp']) . "', '" . mysqli_real_escape_string($link, $ban['expire']) . "', '" . mysqli_real_escape_string($link, $ban['reason']) . "')");
Beispiel #3
0
function trimThreads()
{
    if (TINYIB_MAXTHREADS > 0) {
        $numthreads = countThreads();
        if ($numthreads > TINYIB_MAXTHREADS) {
            $allthreads = allThreads();
            for ($i = TINYIB_MAXTHREADS; $i < $numthreads; $i++) {
                deletePostByID($allthreads[$i]['id']);
            }
        }
    }
}
Beispiel #4
0
function rebuildIndexes()
{
    $page = 0;
    $i = 0;
    $htmlposts = '';
    $threads = allThreads();
    $pages = ceil(count($threads) / TINYIB_THREADSPERPAGE) - 1;
    foreach ($threads as $thread) {
        $replies = postsInThreadByID($thread['id']);
        $thread['omitted'] = max(0, count($replies) - TINYIB_PREVIEWREPLIES - 1);
        // Build replies for preview
        $htmlreplies = array();
        for ($j = count($replies) - 1; $j > $thread['omitted']; $j--) {
            $htmlreplies[] = buildPost($replies[$j], TINYIB_INDEXPAGE);
        }
        $htmlposts .= buildPost($thread, TINYIB_INDEXPAGE) . implode('', array_reverse($htmlreplies)) . "<br clear=\"left\">\n<hr>";
        if (++$i >= TINYIB_THREADSPERPAGE) {
            $file = $page == 0 ? 'index.html' : $page . '.html';
            writePage($file, buildPage($htmlposts, 0, $pages, $page));
            $page++;
            $i = 0;
            $htmlposts = '';
        }
    }
    if ($page == 0 || $htmlposts != '') {
        $file = $page == 0 ? 'index.html' : $page . '.html';
        writePage($file, buildPage($htmlposts, 0, $pages, $page));
    }
}
Beispiel #5
0
        } 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');
        $text .= manageLogInForm();
    }
    echo managePage($text, $onload);
} elseif (!file_exists('index.html') || count(allThreads()) == 0) {
    rebuildIndexes();
}
if ($redirect) {
    echo '--&gt; --&gt; --&gt;<meta http-equiv="refresh" content="0;url=index.html">';
}
Beispiel #6
0
function rebuildIndexes()
{
    global $mysql_posts_table;
    $htmlposts = "";
    $page = 0;
    $i = 0;
    $pages = ceil(countThreads() / 10) - 1;
    $threads = allThreads();
    foreach ($threads as $thread) {
        $htmlreplies = array();
        $replies = latestRepliesInThreadByID($thread['id']);
        foreach ($replies as $reply) {
            $htmlreplies[] = buildPost($reply, False);
        }
        if (count($htmlreplies) == 3) {
            $thread["omitted"] = count(postsInThreadByID($thread['id'])) - 4;
        } else {
            $thread["omitted"] = 0;
        }
        $htmlposts .= buildPost($thread, False);
        $htmlposts .= implode("", array_reverse($htmlreplies));
        $htmlposts .= "<br clear=\"left\">\n" . "<hr>";
        $i += 1;
        if ($i == 10) {
            $file = $page == 0 ? "index.html" : $page . ".html";
            writePage($file, buildPage($htmlposts, 0, $pages, $page));
            $page += 1;
            $i = 0;
            $htmlposts = "";
        }
    }
    if ($page == 0 || $htmlposts != "") {
        $file = $page == 0 ? "index.html" : $page . ".html";
        writePage($file, buildPage($htmlposts, 0, $pages, $page));
    }
}
Beispiel #7
0
function trimThreads()
{
    global $tinyib;
    if ($tinyib['maxthreads'] > 0) {
        $numthreads = countThreads();
        if ($numthreads > $tinyib['maxthreads']) {
            $allthreads = allThreads();
            for ($i = $tinyib['maxthreads']; $i < $numthreads; $i++) {
                deletePostByID($allthreads[$i]['id']);
            }
        }
    }
}