Example #1
0
/**
 * 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("&gt;", ">", $singleban['postdata']);
                $fixbody = str_replace("&amp;gt;", ">", $fixbody);
                $fixbody = str_replace("&lt;", "<", $fixbody);
                $fixbody = str_replace("&amp;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;
    }
}
Example #2
0
function upgrade_bans_table()
{
    $dbi = new ThornDBI();
    // First verify if the table is already upgraded.
    $result = $dbi->myquery("SHOW COLUMNS FROM `" . THbans_table . "` LIKE 'ip_octet3'");
    if (mysql_num_rows($result) > 0) {
        die("Database has already been modified!");
    }
    // Get all of the old bans from the DB
    $bans = $dbi->mymultiarray("SELECT * FROM `" . THbans_table . "` WHERE 1");
    // This could take a while.
    // Store them in a temp file
    file_put_contents(THpath . "upgrade_install_temp.php", var_export($bans, true), FILE_TEXT) or die("Could not open upgrade_install_temp.php for writing.");
    // Convert to a new type
    $bans_new = array();
    // This will hold the converted ones.
    $octets = array();
    // Used to hold IP octets
    $single_ban = array();
    // Used to hold a converted ban
    foreach ($bans as $old_ban) {
        // Convert the IP (in long integer format) from the old ban,
        // and segment it into the new octet fields
        $octets = explode(".", long2ip($old_ban['ip']), 4);
        $single_ban['ip_octet1'] = intval($octets[0]);
        $single_ban['ip_octet2'] = intval($octets[1]);
        $single_ban['ip_octet3'] = intval($octets[2]);
        // If subnet in the old ban is true, set the
        // new ban's 4th octet to be the wildcard value of -1,
        // otherwise proceed as normal
        if ($old_ban['subnet'] != 0) {
            $single_ban['ip_octet4'] = -1;
        } else {
            $single_ban['ip_octet4'] = intval($octets[3]);
        }
        // Everything else is a straight copyover
        $single_ban['publicreason'] = $old_ban['publicreason'];
        $single_ban['privatereason'] = $old_ban['privatereason'];
        $single_ban['adminreason'] = $old_ban['adminreason'];
        $single_ban['postdata'] = $old_ban['postdata'];
        $single_ban['duration'] = $old_ban['duration'];
        $single_ban['bantime'] = $old_ban['bantime'];
        $single_ban['bannedby'] = $old_ban['bannedby'];
        $bans_new[] = $single_ban;
        // Add it into the array
    }
    $bans = null;
    // Clean up
    // Drop old bans table
    $result = $dbi->myquery("DROP TABLE `" . THbans_table . "`");
    if ($result === null) {
        die("DROP Error " . mysql_errno($dbi->cxn) . ": " . mysql_error($dbi->cxn) . "\n");
    }
    // Insert new bans table
    $query = "CREATE TABLE `" . THbans_table . "` \r\n\t\t( \r\n\t\t`id` int unsigned NOT NULL auto_increment, \r\n\t\t`ip_octet1` int NOT NULL, \r\n\t\t`ip_octet2` int NOT NULL, \r\n\t\t`ip_octet3` int NOT NULL, \r\n\t\t`ip_octet4` int NOT NULL, \r\n\t\t`publicreason` text  NOT NULL, \r\n\t\t`privatereason` text  NOT NULL, \r\n\t\t`adminreason` text  NOT NULL, \r\n\t\t`postdata` longtext  NOT NULL, \r\n\t\t`duration` int(11) NOT NULL default '-1', \r\n\t\t`bantime` int(11) unsigned NOT NULL, \r\n\t\t`bannedby` varchar(100)  NOT NULL, \r\n\t\tPRIMARY KEY  (`id`) \r\n\t\t) ENGINE=MyISAM character set utf8 collate utf8_unicode_ci;";
    $result = $dbi->myquery($query);
    if ($result === null) {
        die("CREATE Error " . mysql_errno($dbi->cxn) . ": " . mysql_error($dbi->cxn) . "\n");
    }
    // Insert converted bans
    $successful = 1;
    // set to 0 when one of these insert queries fails
    foreach ($bans_new as $insert) {
        $banquery = "insert into `" . THbans_table . "` \r\n\t\t\tset ip_octet1=" . $insert['ip_octet1'] . ",\r\n\t\t\tip_octet2=" . $insert['ip_octet2'] . ",\r\n\t\t\tip_octet3=" . $insert['ip_octet3'] . ",\r\n\t\t\tip_octet4=" . $insert['ip_octet4'] . ",\r\n\t\t\tprivatereason='" . $dbi->clean($insert['privatereason']) . "', \r\n\t\t\tpublicreason='" . $dbi->clean($insert['publicreason']) . "', \r\n\t\t\tadminreason='" . $dbi->clean($insert['adminreason']) . "', \r\n\t\t\tpostdata='" . $dbi->clean($insert['postdata']) . "', \r\n\t\t\tduration=" . $insert['duration'] . ", \r\n\t\t\tbantime=" . $insert['bantime'] . ", \r\n\t\t\tbannedby='" . $dbi->clean($insert['bannedby']) . "'";
        $result = $dbi->myquery($banquery);
        if ($result === null) {
            printf("Insert Error for %d.%d.%d.%s: #%d: %s<br />\n", $insert['ip_octet1'], $insert['ip_octet2'], $insert['ip_octet3'], $insert['ip_octet4'] == -1 ? "*" : $insert['ip_octet4'], mysql_errno($dbi->cxn), mysql_error($dbi->cxn));
            $successful = 0;
            // One bad insert ruins the lot.
        }
    }
    // Did it work?
    if ($successful == 1) {
        echo "Success!";
        unlink("upgrade_install_temp.php");
    }
}
Example #3
0
/*
		drydock imageboard script (http://code.573chan.org/)
		File:           		drydock.php
		Description:	This is used to access the site.
		Unless otherwise stated, this code is copyright 2008
		by the drydock developers and is released under the
		Artistic License 2.0:
		http://www.opensource.org/licenses/artistic-license-2.0.php
	*/
//Configure script still here?  Crap, this isn't good, let's deny access, just in case someone didn't read the directions
if (file_exists("install.php") && DDDEBUG != 1) {
    if (file_exists("config.php")) {
        die("This script cannot be run with the configuration utility still sitting here!  Please delete the configuration scripts (install.php and upgrade_install.php)!");
    } else {
        header("Location: install.php");
    }
}
//Like above, but with the upgrade script
if (file_exists("upgrade_install.php") && DDDEBUG != 1) {
    die("This script cannot be run with the upgrade utility still sitting here!  Please delete the upgrade script!");
}
require_once "common.php";
$db = new ThornDBI();
//Drop them out right now if they are banned! - tyam
if ($db->checkban()) {
    THdie("PObanned");
} else {
    //whole file
    if (isset($_GET['b']) == true) {
        $boardid = $db->getboardnumber($_GET['b']);
Example #4
0
/* 	Orphaned image deleter - a pile of garbage that only works in the sense that it will find the images that are orphaned and help you remove them
	Alternatively, CPKILLER.


	This needs to be rewritten in places and optimized.

	Based heavily (as in 95% of it) on Thornlight
*/
require_once "config.php";
require_once "common.php";
require_once "auth-common.php";
if (!$_SESSION['admin'] && !$_SESSION['moderator']) {
    THdie("Sorry, you do not have the proper permissions set to be here, or you are not logged in.");
} else {
    $db = new ThornDBI();
    // SELECT COUNT(*) FROM 'img'
    $count = $db->myresult("SELECT COUNT(*) FROM " . THimages_table);
    $offset = 0;
    $orpha = 20;
    //how many on each page
    if (isset($_GET['offset'])) {
        $offset = intval($_GET['offset']);
        if ($offset < 0) {
            $offset = 0;
        }
    }
    $beginning = $count - $orpha - $offset;
    if ($beginning < 0) {
        $beginning = 0;
    }
Example #5
0
		<div class="pgtitle">
			News Page <?php 
    if (THnewsboard != 0) {
        echo '<a href="' . THurl . 'rss.xml"><img src="' . THurl . 'static/rss.png" border="0"></a>';
    }
    ?>
		</div>
		<div>
<?php 
    include "rss2html.php";
    if (THuserewrite) {
        $archivelink = '<a class="info" href="' . THurl;
    } else {
        $archivelink = '<a class="info" href="' . THurl . 'drydock.php?b=';
    }
    $db = new ThornDBI();
    $archivelink .= $db->getboardname(THnewsboard) . '">Full News Archive</a>';
    //make our link
    ?>
		</div>
	</div>
</div>
<?php 
    include "menu.php";
    ?>

<?php 
    if ($archivelink) {
        echo '<div style="text-align: center;" style="font-family:verdana,century;font-size:10px;padding-bottom: 10px;">- ' . $archivelink . " -</div>\n";
    }
    //Otherwise, we'll use static pages
Example #6
0
/**
 * Rebuild the linkbar file (in linkbar.php), which
 * spans the top/bottom of pages
 */
function rebuild_linkbars()
{
    $db = new ThornDBI();
    $looper = 1;
    $boards = $db->getvisibleboards();
    $showcount = count($boards);
    $sidelinks = fopen("linkbar.php", "w") or die("Could not open linkbar.php for writing.");
    fwrite($sidelinks, '<table style="width: 100%;"><tr><td style="text-align: left;">[');
    foreach ($boards as $boardentry) {
        if (THuserewrite) {
            fwrite($sidelinks, '<a class="info" href="' . THurl);
        } else {
            fwrite($sidelinks, '<a class="info" href="' . THurl . 'drydock.php?b=');
        }
        fwrite($sidelinks, $boardentry['folder'] . '">' . $boardentry['folder'] . '<span>' . $boardentry['name'] . " - " . $boardentry['about'] . "</span></a>\n");
        //finish it up
        if ($looper < $showcount) {
            fwrite($sidelinks, '/');
        }
        $looper++;
    }
    fwrite($sidelinks, ']</td><td style="text-align: right;">[');
    if (THnewsboard > 0) {
        if (THuserewrite) {
            fwrite($sidelinks, ' <a class=info href="' . THurl);
        } else {
            fwrite($sidelinks, ' <a class=info href="' . THurl . 'drydock.php?b=');
        }
        fwrite($sidelinks, $db->getboardname(THnewsboard) . '">' . $db->getboardname(THnewsboard) . "</a> /\n");
    }
    //uncomment this out if you have the irc stuff installed - we don't ship it ~tyam
    //THuseirc doesn't exist, it's a placeholder for future integration
    /*
    		if (THnewsboard>0 && THuseirc ) { fwrite($sidelinks, '/'); };
    		if irc {
    			fwrite($sidelinks, ' <a class=info href="'.THurl.'irc/">irc</a> /'."\n");
    		}//if irc
    */
    fwrite($sidelinks, ' <a class=info href="' . THurl . '">idx</a> ]</td>');
    fwrite($sidelinks, '</tr></table>');
    fclose($sidelinks);
}