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']) . "')"); } if ($max_id > 0 && !mysqli_query($link, "ALTER TABLE `" . TINYIB_DBBANS . "` AUTO_INCREMENT = " . ($max_id + 1))) { $text .= '<p><b>Warning:</b> Unable to update the AUTO_INCREMENT value for table ' . TINYIB_DBBANS . ', please set it to ' . ($max_id + 1) . '.</p>'; } $text .= '<p><b>Database migration complete</b>. Set TINYIB_DBMODE to mysqli and TINYIB_DBMIGRATE to false, then click <b>Rebuild All</b> above and ensure everything looks the way it should.</p>'; } else { fancyDie('Bans table (' . TINYIB_DBBANS . ') already exists! Please DROP this table and try again.'); } } else { fancyDie('Posts table (' . TINYIB_DBPOSTS . ') already exists! Please DROP this table and try again.'); } } else {
} 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('--> --> --><meta http-equiv="refresh" content="0;url=' . $returnlink . '?manage">'); } if ($text == '') { $text = 'Thread count: ' . countThreads() . ' · 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 '--> --> --><meta http-equiv="refresh" content="0;url=index.html">'; }
function manageStatus() { global $isadmin; $threads = countThreads(); $bans = count(allBans()); $info = $threads . ' ' . plural('thread', $threads) . ', ' . $bans . ' ' . plural('ban', $bans); $output = ''; if ($isadmin && TINYIB_DBMODE == 'mysql' && function_exists('mysqli_connect')) { // Recommend MySQLi $output .= <<<EOF \t<fieldset> \t<legend>Notice</legend> \t<p><b>TINYIB_DBMODE</b> is currently <b>mysql</b> in <b>settings.php</b>, but <a href="http://www.php.net/manual/en/book.mysqli.php">MySQLi</a> is installed. Please change it to <b>mysqli</b>. This will not affect your data.</p> \t</fieldset> EOF; } $reqmod_html = ''; if (TINYIB_REQMOD != 'disable') { $reqmod_post_html = ''; $reqmod_posts = latestPosts(false); foreach ($reqmod_posts as $post) { if ($reqmod_post_html != '') { $reqmod_post_html .= '<tr><td colspan="2"><hr></td></tr>'; } $reqmod_post_html .= '<tr><td>' . buildPost($post, TINYIB_INDEXPAGE) . '</td><td valign="top" align="right"> <table border="0"><tr><td> <form method="get" action="?"><input type="hidden" name="manage" value=""><input type="hidden" name="approve" value="' . $post['id'] . '"><input type="submit" value="Approve" class="managebutton"></form> </td><td> <form method="get" action="?"><input type="hidden" name="manage" value=""><input type="hidden" name="moderate" value="' . $post['id'] . '"><input type="submit" value="More Info" class="managebutton"></form> </td></tr><tr><td align="right" colspan="2"> <form method="get" action="?"><input type="hidden" name="manage" value=""><input type="hidden" name="delete" value="' . $post['id'] . '"><input type="submit" value="Delete" class="managebutton"></form> </td></tr></table> </td></tr>'; } if ($reqmod_post_html != '') { $reqmod_html = <<<EOF \t<fieldset> \t<legend>Pending posts</legend> \t<table border="0" cellspacing="0" cellpadding="0" width="100%"> \t{$reqmod_post_html} \t</table> \t</fieldset> EOF; } } $post_html = ''; $posts = latestPosts(true); foreach ($posts as $post) { if ($post_html != '') { $post_html .= '<tr><td colspan="2"><hr></td></tr>'; } $post_html .= '<tr><td>' . buildPost($post, TINYIB_INDEXPAGE) . '</td><td valign="top" align="right"><form method="get" action="?"><input type="hidden" name="manage" value=""><input type="hidden" name="moderate" value="' . $post['id'] . '"><input type="submit" value="Moderate" class="managebutton"></form></td></tr>'; } $output .= <<<EOF \t<fieldset> \t<legend>Status</legend> \t \t<fieldset> \t<legend>Info</legend> \t<table border="0" cellspacing="0" cellpadding="0" width="100%"> \t<tbody> \t<tr><td> \t\t{$info} \t</td> EOF; if ($isadmin) { $output .= <<<EOF \t<td valign="top" align="right"> \t\t<form method="get" action="?"> \t\t\t<input type="hidden" name="manage"> \t\t\t<input type="hidden" name="update"> \t\t\t<input type="submit" value="Update TinyIB" class="managebutton"> \t\t</form> \t</td> EOF; } $output .= <<<EOF \t</tr> \t</tbody> \t</table> \t</fieldset> \t{$reqmod_html} \t \t<fieldset> \t<legend>Recent posts</legend> \t<table border="0" cellspacing="0" cellpadding="0" width="100%"> \t{$post_html} \t</table> \t</fieldset> \t \t</fieldset> \t<br> EOF; return $output; }
function manageBansTable() { $text = ''; $allbans = allBans(); if (count($allbans) > 0) { $text .= '<table border="1"><tr><th>IP Address</th><th>Set At</th><th>Expires</th><th>Reason Provided</th><th> </th></tr>'; foreach ($allbans as $ban) { $expire = $ban['expire'] > 0 ? date('y/m/d(D)H:i:s', $ban['expire']) : 'Never'; $reason = $ban['reason'] == '' ? ' ' : htmlentities($ban['reason']); $text .= '<tr><td>' . $ban['ip'] . '</td><td>' . date('y/m/d(D)H:i:s', $ban['timestamp']) . '</td><td>' . $expire . '</td><td>' . $reason . '</td><td><a href="?manage&bans&lift=' . $ban['id'] . '">lift</a></td></tr>'; } $text .= '</table>'; } return $text; }