/** * Generate an error page for whatever reason. If $err is * equal to "ADbanned" or "PObanned" it looks up the ban data * and displays that. Otherwise it uses the standard error * Smarty template. * * @param string $err The kind of error that occurred */ function THdie($err) { //die($err); if ($err == "ADbanned" || $err == "PObanned") { $db = new ThornDBI(); // Get bans associated with an IP (there could be multiple bans) $bans = $db->getban(); $unbanned = 1; // boolean to indicate whether they've been unbanned or not, gets changed in the foreach loop if appropriate echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'; echo '<head>'; echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; echo '<meta http-equiv="Content-Style-Type" content="text/css" />'; echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>'; echo '<link rel="stylesheet" type="text/css" href="href="' . THurl . 'tpl/' . THtplset . '" title="Stylesheet" />'; echo '<title>b&</title>'; echo '</head>'; echo '<body>'; echo '<div style="text-align: center;">You have been banned.<br /></div>'; foreach ($bans as $singleban) { // Display wildcards as appropriate. printf("Associated IP: %d.%d.%s.%s<br />\n", $singleban['ip_octet1'], $singleban['ip_octet2'], $singleban['ip_octet3'] == -1 ? "*" : $singleban['ip_octet3'], $singleban['ip_octet4'] == -1 ? "*" : $singleban['ip_octet4']); if ($singleban['postdata']) { $fixbody = str_replace(">", ">", $singleban['postdata']); $fixbody = str_replace("&gt;", ">", $fixbody); $fixbody = str_replace("<", "<", $fixbody); $fixbody = str_replace("&lt;", "<", $fixbody); echo 'Associated post:<br />' . nl2br($fixbody) . '<br /><br />'; } $reason = ""; if (!$singleban['privatereason']) { $reason = $singleban['publicreason']; } else { $reason = $singleban['privatereason']; } if (!$reason) { $reason = 'No reason given'; } else { echo 'Reason given: ' . $reason . '<br /><br />'; } if ($singleban['duration'] == 0) { echo 'This is only a warning and will be removed from the active bans list. Keep in mind however that if you are warned multiple times you may be permabanned.'; } else { if ($singleban['duration'] == -1) { echo 'This ban will not expire.<br /><br />'; $unbanned = 0; // still banned } else { //we'll need to know the difference between the ban time and the duration for actually expiring the bans $offset = THtimeoffset * 60; $now = time() + $offset; $banoffset = $singleban['duration'] * 3600; // convert to hours $expiremath = $banoffset + $singleban['bantime']; if ($now > $expiremath) { echo 'This ban has expired. Keep in mind that you may be rebanned at any time.<br /><br />'; } else { echo 'This ban duration was set to ' . $singleban['duration'] . ' hours. The ban will expire on ' . strftime(THdatetimestring, $expiremath) . '<br /><br />'; $unbanned = 0; // still banned } } } } if ($unbanned == 1) { echo '<div style="text-align: center;"><a href="' . THurl . '">Continue to the main index</a></div>'; } else { echo "If you feel this ban is in error, please email an administrator."; } echo '</body></html>'; } else { $sm = sminit("error.tpl", $err); $sm->assign_by_ref("error", $err); $sm->display("error.tpl", null); die; } }