function trimThreads() { global $tinyib; if ($tinyib['maxthreads'] > 0) { $result = mysql_query("SELECT `id` FROM `b_posts` WHERE `parent` = 0 ORDER BY `bumped` DESC LIMIT " . $tinyib['maxthreads'] . ", 10"); while ($post = mysql_fetch_assoc($result)) { deletePostByID($post['id']); } } }
} else { fancyDie('Set TINYIB_DBMODE to flatfile and enter in your MySQL settings in settings.php before migrating.'); } } else { $text .= '<p>This tool currently only supports migration from a flat file database to MySQL. Your original database will not be deleted. If the migration fails, disable the tool and your board will be unaffected. See the <a href="https://github.com/tslocum/TinyIB#migrating" target="_blank">README</a> <small>(<a href="README.md" target="_blank">alternate link</a>)</small> for instructions.</a><br><br><a href="?manage&dbmigrate&go"><b>Start the migration</b></a></p>'; } } else { fancyDie('Set TINYIB_DBMIGRATE to true in settings.php to use this feature.'); } } } } if (isset($_GET['delete'])) { $post = postByID($_GET['delete']); if ($post) { deletePostByID($post['id']); rebuildIndexes(); if ($post['parent'] != TINYIB_NEWTHREAD) { rebuildThread($post['parent']); } $text .= manageInfo('Post No.' . $post['id'] . ' deleted.'); } else { fancyDie("Sorry, there doesn't appear to be a post with that ID."); } } elseif (isset($_GET['approve'])) { if ($_GET['approve'] > 0) { $post = postByID($_GET['approve']); if ($post) { approvePostByID($post['id']); $thread_id = $post['parent'] == TINYIB_NEWTHREAD ? $post['id'] : $post['parent']; if (strtolower($post['email']) != 'sage' && (TINYIB_MAXREPLIES == 0 || numRepliesToThreadByID($thread_id) <= TINYIB_MAXREPLIES)) {
function trimThreads() { global $link; if (TINYIB_MAXTHREADS > 0) { $result = mysqli_query($link, "SELECT `id` FROM `" . TINYIB_DBPOSTS . "` WHERE `parent` = 0 AND `moderated` = 1 ORDER BY `stickied` DESC, `bumped` DESC LIMIT " . TINYIB_MAXTHREADS . ", 10"); if ($result) { while ($post = mysqli_fetch_assoc($result)) { deletePostByID($post['id']); } } } }
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']); } } } }
function trimThreads() { $limit = (int) TINYIB_MAXTHREADS; if ($limit > 0) { $results = pdoQuery("SELECT id FROM " . TINYIB_DBPOSTS . " WHERE parent = 0 AND moderated = 1 ORDER BY stickied DESC, bumped DESC LIMIT 100 OFFSET " . $limit); # old mysql, sqlite3: SELECT id FROM $table ORDER BY bumped LIMIT $limit,100 # mysql, postgresql, sqlite3: SELECT id FROM $table ORDER BY bumped LIMIT 100 OFFSET $limit # oracle: SELECT id FROM ( SELECT id, rownum FROM $table ORDER BY bumped) WHERE rownum >= $limit # MSSQL: WITH ts AS (SELECT ROWNUMBER() OVER (ORDER BY bumped) AS 'rownum', * FROM $table) SELECT id FROM ts WHERE rownum >= $limit foreach ($results as $post) { deletePostByID($post['id']); } } }
function trimThreads() { if (TINYIB_MAXTHREADS > 0) { $result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT id FROM " . TINYIB_DBPOSTS . " WHERE parent = 0 ORDER BY stickied DESC, bumped DESC LIMIT " . TINYIB_MAXTHREADS . ", 10"), SQLITE_ASSOC); foreach ($result as $post) { deletePostByID($post['id']); } } }
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']); } } } }