code:
<?php

if (!defined("IN_MOD"))

{

	die("Nah, I won't serve that file to you.");

}
		$mitsuba->admin->reqPermission("user.inbox");

if ((!empty($_POST['to'])) && (!empty($_POST['title'])) && (!empty($_POST['text'])))

		{

			$mitsuba->admin->ui->checkToken($_POST['token']);

			$result = $conn->query("SELECT * FROM users WHERE username='".$conn->real_escape_string($_POST['to'])."'");

			if ($result->num_rows == 1)

			{

				$row = $result->fetch_assoc();

				$text = processEntry($conn, $_POST['text']);

				$title = $conn->real_escape_string($_POST['title']);

				$conn->query("INSERT INTO pm (created, from_user, to_user, title, text, read_msg, resto) VALUES (".time().", ".$_SESSION['id'].", ".$row['id'].", '".$title."', '".$text."', 0, 0)");

			?>

<?php $mitsuba->admin->ui->startSection($lang['mod/msg_sent']); ?>

<?php echo $lang['mod/back']; ?>

<?php $mitsuba->admin->ui->endSection(); ?>

			<?php

			} else {

			?>

<?php $mitsuba->admin->ui->startSection($lang['mod/user_not_found']); ?>

<?php echo $lang['mod/back']; ?>

<?php $mitsuba->admin->ui->endSection(); ?>

			<?php

			}

		} else {

		$username = "";

		$title = "";

		if ((!empty($_GET['id'])) && (is_numeric($_GET['id'])))

		{

			$result = $conn->query("SELECT users.username, pm.* FROM pm LEFT JOIN users ON pm.from_user=users.id WHERE pm.to_user=".$_SESSION['id']." AND pm.id=".$_GET['id']);

			if ($result->num_rows == 1)

			{

				$row = $result->fetch_assoc();

				$username = $row['username'];

				$title = "Re: ".$row['title'];

			}

		}

		?>

<?php $mitsuba->admin->ui->startSection($lang['mod/send_message']); ?>

<form action="?/inbox/new" method="POST">

<?php $mitsuba->admin->ui->getToken($path); ?>

<?php $uNames = $conn->query("SELECT * from users WHERE `username` <> '".$_SESSION["username"]."'"); ?>
<?php echo $lang['mod/to']; ?>: <select name="to">
	<?php while ($row = $uNames->fetch_assoc()){
		echo "<option value='{$row['username']}'>{$row['username']}</option>";
	}
	?>

</select>

<?php echo $lang['mod/title']; ?>: <input type="text" name="title" value="<?php echo $title; ?>" />

<?php echo $lang['mod/text']; ?>:

<textarea name="text" cols=40 rows=9></textarea>

<input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

</form>

<?php $mitsuba->admin->ui->endSection(); ?>

		<?php

		}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

        $mitsuba->admin->reqPermission("user.inbox");

if ((!empty($_GET['id'])) && (is_numeric($_GET['id']))) {

    $result = $conn->query("SELECT users.username, pm.* FROM pm LEFT JOIN users ON pm.from_user=users.id WHERE (pm.to_user=".$_SESSION['id']." OR pm.from_user=".$_SESSION['id'].") AND pm.id=".$_GET['id']);

    if ($result->num_rows == 1) {

        $row = $result->fetch_assoc();

        if (($row['read_msg'] != 1) && ($row['to_user']==$_SESSION['id'])) {

            $conn->query("UPDATE pm SET read_msg=1 WHERE id=".$_GET['id']);

        }

        ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/read_msg']); ?>

    <?php echo $lang['mod/from']; ?>: <?php echo $row['username']; ?>

    <?php echo $lang['mod/title']; ?>: <?php echo strip_tags($row['title']); ?>

    <?php echo strip_tags($lang['mod/text']); ?>:

    <?php echo $row['text']; ?>

  <a href="?/inbox/new&id=<?php $_GET['id']; ?>">[ <?php echo $lang['mod/reply']; ?> ]

    <?php $mitsuba->admin->ui->endSection(); ?>

                <?php

    }

}

?>

license: mit


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("info.view");

if ((!empty($_GET['ip'])) && (filter_var($_GET['ip'], FILTER_VALIDATE_IP))) {

?>
<?php $mitsuba->admin->ui->startSection(sprintf($lang['mod/ip_info'], $_GET['ip'])); ?>
<?php
if ($mitsuba->admin->checkPermission("search.ip")) {
?>
<a href="?/search/ip&ip=<?php echo $_GET['ip']; ?>"><?php echo $lang['mod/search_ip']; ?>

<?php
}
?>
<?php printf($lang['mod/recent_bans_ip'], 15); ?>

<?php echo $lang['mod/ip']; ?>
<?php echo $lang['mod/reason']; ?>
<?php echo $lang['mod/staff_note']; ?>
<?php echo $lang['mod/created']; ?>
<?php echo $lang['mod/expires']; ?>
<?php echo $lang['mod/boards']; ?>
<?php echo $lang['mod/delete']; ?>

<?php
    $_data = $conn->query("SELECT short FROM boards");
    $_boards = array();
while ($row = $_data->fetch_assoc()) { $_boards[] = $row['short'];
}
    $result = $conn->query("SELECT * FROM bans WHERE ip='".$_GET['ip']."' ORDER BY created LIMIT 0, 15;");
while ($row = $result->fetch_assoc()){
    echo "
";
    echo "".$row['ip']."	";
    echo "".$row['reason']."	";
    echo "".$row['note']."	";
    echo "".date("d/m/Y @ H:i", $row['created'])."	";
    if ($row['expires'] != 0) {
        echo "".date("d/m/Y @ H:i", $row['expires'])."	";
    }else{
        echo "nevertd>";
    }
    if ($row['boards']=="%") {
        echo "All boards	";
    }else{
        $banBoards = explode(',', $row['boards']);
        if (0.6 * sizeof($_boards) < sizeof($banBoards)) {
            echo "All boards excluding: ".implode(', ', array_diff($_boards, $banBoards))."	";
        } else {
            echo "".implode(', ', $banBoards)."	";
        }

    }

    if ($mitsuba->admin->checkPermission("bans.delete")) {

        echo "".$lang['mod/delete']."	";

    } else {

        echo "	";

    }

    echo "
";

}

?>

<?php echo $lang['mod/notes_ip']; ?>

<?php echo $lang['mod/created']; ?>

<?php echo $lang['mod/note']; ?>

<?php echo $lang['mod/delete']; ?>

<?php

$result = $conn->query("SELECT * FROM ip_notes WHERE ip='".$_GET['ip']."';");

while ($row = $result->fetch_assoc())

{

    echo "
";

    echo "".date("d/m/Y(D)H:i:s", $row['created'])."	";

    echo "".$row['text']."	";

    echo "".$lang['mod/delete']."	";

    echo "	";

}

?>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/add_note']); ?>

<form action="?/ipnotes/add&ip=<?php echo $_GET['ip']; ?>" method="POST">

<?php $mitsuba->admin->ui->getToken($path); ?>

<textarea name="note" cols=70 rows=12></textarea>

<input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

</form>

<?php $mitsuba->admin->ui->endSection(); ?>

    <?php

}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("ipnotes.add");

$IPAddress = "";

if ((!empty($_GET['ip'])) && (filter_var($_GET['ip'], FILTER_VALIDATE_IP))) {

    $IPAddress = $_GET['ip'];

}

if ((!empty($_POST['ip'])) && (filter_var($_POST['ip'], FILTER_VALIDATE_IP))) {

    $IPAddress = $_POST['ip'];

}

if (empty($IPAddress)) {

    ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/no_ip']); ?>

<?php echo $lang['mod/back']; ?>

<?php $mitsuba->admin->ui->endSection(); ?>

    <?php

} else {

    if ((!empty($IPAddress)) && (!empty($_POST['note']))) {

        $mitsuba->admin->ui->checkToken($_POST['token']);

        $note = processEntry($conn, $_POST['note']);

        $conn->query("INSERT INTO ip_notes (ip, text, created, mod_id) VALUES ('".$IPAddress."', '".$note."', ".time().", ".$_SESSION['id'].")");

        ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/ip_note_added']); ?>

 <?php echo $lang['mod/back']; ?>

    <?php $mitsuba->admin->ui->endSection(); ?>

                <?php

    }

}

if (empty($_POST['note'])) {

    ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/fill_all_fields']); ?>

<?php echo $lang['mod/back']; ?>

<?php $mitsuba->admin->ui->endSection(); ?>

    <?php

}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("ipnotes.view");

?>

<?php $mitsuba->admin->ui->startSection($lang['mod/all_ip_notes']); ?>

<?php echo $lang['mod/created']; ?>

<?php echo $lang['mod/note']; ?>

<?php echo $lang['mod/delete']; ?>

<?php

$result = $conn->query("SELECT * FROM ip_notes;");

while ($row = $result->fetch_assoc())

{

    echo "
";

    echo "".date("d/m/Y(D)H:i:s", $row['created'])."	";

    echo "".$row['text']."	";

    if ($_SESSION['type']>=2) {

        echo "".$lang['mod/delete']."	";

    } else {

        echo "	";

    }

    echo "
";

}

?>

<?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("ipnotes.delete");

if ((!empty($_GET['id'])) && (is_numeric($_GET['id']))) {

    $conn->query("DELETE FROM ip_notes WHERE id=".$_GET['id']);

}

    ?>

        <meta http-equiv="refresh" content="0;URL='?/ipnotes'" />


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("ipnotes.view");

?>

<?php $mitsuba->admin->ui->startSection(''); ?>

<?php echo $lang['mod/recent_ip_notes']?>

                <?php printf($lang['mod/showing_notes'], 15); ?> <?php echo $lang['mod/show_all']; ?>

                  <?php echo $lang['mod/created']; ?>
                  IP Address
                  <?php echo $lang['mod/note']; ?>
                  <?php echo $lang['mod/delete']; ?>

<?php

$result = $conn->query("SELECT * FROM ip_notes LIMIT 0, 15;");
if($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()){
        echo "
";
        echo "".date("d/m/Y(D)H:i:s", $row['created'])."	";
        echo "".$row['ip']."	";
        echo "".$row['text']."	";
        echo "".$lang['mod/delete']."	";
        echo "
";
    }
}else{

}

?>

<?php // $mitsuba->admin->ui->startSection("");?>

<?php echo $lang['mod/add_ip_note']?>

            <form role="form" action="?/ipnotes/add" method="POST">
                <?php $mitsuba->admin->ui->getToken($path); ?>

                  <?php echo $lang['mod/ip']; ?>
                  <input type="text" name="ip" class="form-control" id="IPAddr" placeholder="Enter IP Address">

                  IP Note
                  <textarea name="note" class="form-control" id="IPNote" placeholder="Enter note for IP" cols="70" rows="12"></textarea>

                <button type="submit" class="btn btn-primary">Submit</button>

            </form>

<?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}
if($mitsuba->admin->canBoard("%")) {
    $mitsuba->admin->reqPermission("links.add");

    if (isset($_GET['p'])) {

        $id = $conn->real_escape_string($_GET['p']);

        $cat = $conn->query("SELECT * FROM links WHERE url='' AND id=".$id);

        if ($cat->num_rows == 1) {

            if (empty($_POST['title'])) {

            ?>

        <?php $mitsuba->admin->ui->startSection($lang['mod/add_link']); ?>

        <?php echo $lang['mod/rebuild_notice']; ?>

        <form action="?/links/add&p=<?php echo $id; ?>" method="POST">

        <?php $mitsuba->admin->ui->getToken($path); ?>

        <?php echo $lang['mod/short']; ?>: <input type="text" name="short" value="" />

        <?php echo $lang['mod/url']; ?>: <input type="text" name="url" value="./" />

        <?php echo $lang['mod/title']; ?>: <input type="text" name="title" value="" />

        <?php echo $lang['mod/relativity']; ?>: <input type="radio" name="relative" value="0" />Absolute <input type="radio" name="relative" value="1" checked/>Relative (to board index/mod.php) <input type="radio" name="relative" value="2" />Board link

<input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

        </form>

        <?php $mitsuba->admin->ui->endSection(); ?>

        <?php

            } else {

                //$parent, $url, $url_thread, $title, $short

                if (($_POST['relative'] == 2) && (!$mitsuba->common->isBoard($_POST['url']))) {

                    $mitsuba->admin->ui->startSection(sprintf($lang['mod/board_not_exists'], $_POST['url']));

                    ?>

           <?php echo $lang['mod/back']; ?>

                    <?php

                    $mitsuba->admin->ui->endSection();

                } else {

                    $mitsuba->admin->ui->checkToken($_POST['token']);

                    $mitsuba->admin->links->addBoardLink($id, $_POST['url'], $_POST['relative'],  $_POST['title'], $_POST['short']);

                    ?>

                 <meta http-equiv="refresh" content="0;URL='?/links'" />

                    <?php

                }

            }

        } else {

        ?>

        <meta http-equiv="refresh" content="0;URL='?/links'" />

        <?php

        }

    } else {

    ?>

    <meta http-equiv="refresh" content="0;URL='?/links'" />

    <?php

    }
}else{
    echo "Sorry, but due to abuse, this feature is only for Global Admins.";
}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}
if($mitsuba->admin->canBoard("%")) {
    $mitsuba->admin->reqPermission("links.update");

    if (isset($_GET['i'])) {

        $id = $conn->real_escape_string($_GET['i']);

        $link = $conn->query("SELECT * FROM links WHERE id=".$id);

        if ($link->num_rows == 1) {

            $data = $link->fetch_assoc();

            if (empty($_POST['title'])) {

                $mitsuba->admin->ui->startSection($lang['mod/edit_link']);

            ?>

        <?php echo $lang['mod/rebuild_notice']; ?>

        <form action="?/links/edit&i=<?php echo $id; ?>" method="POST">

        <?php $mitsuba->admin->ui->getToken($path); ?>

        <?php echo $lang['mod/short']; ?>: <input type="text" name="short" value="<?php echo $data['short']; ?>" />

        <?php echo $lang['mod/url']; ?>: <input type="text" name="url" value="<?php echo $data['url']; ?>" />

        <?php echo $lang['mod/title']; ?>: <input type="text" name="title" value="<?php echo $data['title']; ?>" />

        <?php echo $lang['mod/relativity']; ?>: <input type="radio" name="relative" value="0" <?php if ($data['relative']==0) { echo "checked";
        } ?>/>Absolute <input type="radio" name="relative" value="1"  <?php if ($data['relative']==1) { echo "checked";
} ?>/>Relative (to board index/mod.php) <input type="radio" name="relative" value="2"  <?php if ($data['relative']==2) { echo "checked";
} ?>/>Board link

<input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

        </form>

        <?php $mitsuba->admin->ui->endSection(); ?>

        <?php

            } else {

                if (($_POST['relative'] == 2) && (!$mitsuba->common->isBoard($_POST['url']))) {

                    $mitsuba->admin->ui->startSection(sprintf($lang['mod/board_not_exists'], $_POST['url']));

                    ?>

           <?php echo $lang['mod/back']; ?>

                    <?php

                    $mitsuba->admin->ui->endSection();

                } else {

                    $mitsuba->admin->ui->checkToken($_POST['token']);

                    $mitsuba->admin->links->updateBoardLink($id, $_POST['url'], $_POST['relative'], $_POST['title'], $_POST['short']);

                    ?>

                 <meta http-equiv="refresh" content="0;URL='?/links'" />

                    <?php

                }

                        ?>

                       <meta http-equiv="refresh" content="0;URL='?/links'" />

                        <?php

            }

        } else {

        ?>

        <meta http-equiv="refresh" content="0;URL='?/links'" />

        <?php

        }

    } else {

    ?>

    <meta http-equiv="refresh" content="0;URL='?/links'" />

    <?php

    }
}else{
    echo "Sorry, but due to abuse, this feature is only for Global Admins.";
}
?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}
if($mitsuba->admin->canBoard("%")) {
    $mitsuba->admin->reqPermission("links.view");

    if (!empty($_GET['m'])) {

        if ($_GET['m'] == "del") {

            $mitsuba->admin->reqPermission("links.delete");

            if (!empty($_GET['i'])) {

                $id = $conn->real_escape_string($_GET['i']);

                $mitsuba->admin->links->deleteBoardLink($id);

            }

        }

        if ($_GET['m'] == "addc") {

            $mitsuba->admin->reqPermission("links.add");

            $mitsuba->admin->ui->checkToken($_POST['token']);

            if (!empty($_POST['title'])) {

                $mitsuba->admin->links->addLinkCategory($_POST['title']);

            }

        }

        if ($_GET['m'] == "up") {

            $mitsuba->admin->reqPermission("links.move");

            if (!empty($_GET['l'])) {

                $id = $conn->real_escape_string($_GET['l']);

                $mitsuba->admin->links->moveUpCategory($id);

            }

        }

        if ($_GET['m'] == "down") {

            $mitsuba->admin->reqPermission("links.move");

            if (!empty($_GET['l'])) {

                $id = $conn->real_escape_string($_GET['l']);

                $mitsuba->admin->links->moveDownCategory($id);

            }

        }

    }

    ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/manage_board_links']); ?>

<?php echo $lang['mod/rebuild_notice']; ?>

<?php

echo $mitsuba->admin->links->getLinkTable(-1);

?>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/add_link_category']); ?>

<?php echo $lang['mod/rebuild_notice']; ?>

<form action="?/links&m=addc" method="POST">

<?php $mitsuba->admin->ui->getToken($path); ?>

<?php echo $lang['mod/name']; ?>: <input type="text" name="title" value="<?php echo $lang['mod/category']; ?>" /><input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

</form>

<?php $mitsuba->admin->ui->endSection();
}else{
    echo "Sorry, but due to abuse, this feature is only for Global Admins. Contact a global admin to add your board.";
}
?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("post.closed");

?>

<?php $mitsuba->admin->ui->startSection($lang['mod/locked']); ?>

<?php echo $lang['mod/id']; ?>

<?php echo $lang['mod/comment']; ?>

<?php echo $lang['mod/unlock']; ?>

    <?php

    require_once "libs/jbbcode/Parser.php";

    $parser = new \JBBCode\Parser();

    $bbcode = $conn->query("SELECT * FROM bbcodes;");

    while ($row = $bbcode->fetch_assoc())

    {

        $parser->addBBCode($row['name'], $row['code']);

    }

    $threads = $conn->query("SELECT * FROM posts WHERE locked=1 AND resto=0 ORDER BY lastbumped DESC;");

    while ($thread = $threads->fetch_assoc())

    {

        echo "
";

        echo "/".$thread['board']."/".$thread['id']."	";

        if ($thread['raw'] == 0) {

            echo "".$mitsuba->caching->processComment($thread['board'], $thread['comment'], $parser, 2)."	";

        } elseif ($thread['raw'] == 2) {

            echo "".$mitsuba->caching->processComment($thread['board'], $thread['comment'], $parser, 2, 0)."	";

        } else {

            echo "".$thread['comment']."	";

        }

        echo "".$lang['mod/unlock']."	";

        echo "
";

    }

    ?>

<?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("post.closed");

if ((!empty($_GET['b'])) && (!empty($_GET['t'])) && ($mitsuba->common->isBoard($_GET['b'])) && (is_numeric($_GET['t']))) {

    $mitsuba->admin->canBoard($_GET['b']);

    $result = $conn->query("SELECT * FROM posts WHERE id=".$_GET['t']." AND resto=0 AND board='".$_GET['b']."'");

    if ($result->num_rows == 1) {

        $pdata = $result->fetch_assoc();

        if ($pdata['locked'] == 1) {

            $conn->query("UPDATE posts SET locked=0 WHERE id=".$_GET['t']." AND board='".$_GET['b']."'");

            $mitsuba->caching->generatePost($_GET['b'], $_GET['t']);

        ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/t_unlocked']); ?>

    <meta http-equiv="refresh" content="1;URL='./<?php echo $_GET['b']."/res/".$_GET['t']; ?>.html'" />

    <?php $mitsuba->admin->ui->endSection(); ?>

        <?php

        } else {

            $conn->query("UPDATE posts SET locked=1 WHERE id=".$_GET['t']." AND board='".$_GET['b']."'");

            $mitsuba->caching->generatePost($_GET['b'], $_GET['t']);

                ?>

            <?php $mitsuba->admin->ui->startSection($lang['mod/t_locked']); ?>

            <meta http-equiv="refresh" content="1;URL='./<?php echo $_GET['b']."/res/".$_GET['t']; ?>.html'" />

            <?php $mitsuba->admin->ui->endSection(); ?>

        <?php

        }

    } else {

    ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/thread_not_found']); ?>

    <?php $mitsuba->admin->ui->endSection(); ?>

    <?php

    }

} else {

}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("logs.view");

?>

<?php $mitsuba->admin->ui->startSection(null); ?>

Action Log

            User

            Event

            Date

    <?php

    $log = $conn->query("SELECT log.*, users.username FROM log LEFT JOIN users ON log.mod_id=users.id ORDER BY date DESC");

    while ($row = $log->fetch_assoc())

    {

        echo "
";

        echo "".$row['username']."	";

        echo "".$row['event']."	";

        echo "".date("d/m/Y(D)H:i:s", $row['date'])."	";

        echo "
";

    }

    ?>

<?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

if ((!empty($_POST['username'])) && (!empty($_POST['password']))) {

    $username = $conn->real_escape_string($_POST['username']);
    $result = $conn->query("SELECT * FROM users WHERE username='".$username."'");
    if ($result->num_rows == 1) {

        $data = $result->fetch_assoc();
        if($data['group'] == 4) {
            die("
You are currently suspended.
 Please talk to a global administrator to discuss lifting the suspension. You will now be redirected back to the login panel.
 Thank you for any service you have provided!
");
        }
        //$mitsuba->admin->reqPermission("user.login", $data['id']);
        $password = hash("sha512", $_POST['password'].$data['salt']);
        if ($data['password'] == $password) {

            $group = $conn->query("SELECT * FROM groups WHERE id=".$data['group']);

            $gdata = $group->fetch_assoc();

            $_SESSION['logged'] = 1;

            $_SESSION['id'] = $data['id'];

            $_SESSION['username'] = $username;

            $_SESSION['group'] = $data['group'];

            $_SESSION['boards'] = $data['boards'];

            $_SESSION['ip'] = $mitsuba->common->getIP();

            $_SESSION['capcode_text'] = $gdata['capcode'];

            $_SESSION['capcode_style'] = $gdata['capcode_style'];

            $_SESSION['capcode_icon'] = $gdata['capcode_icon'];

            $_SESSION['group_name'] = $gdata['name'];

            $_SESSION['cookie_set'] = 2;

            $mitsuba->admin->logAction(sprintf($lang['log/logged_in'], $mitsuba->common->getIP()));

            header("Location: ./mod.php");

        } else {

            $IPAddress = $mitsuba->common->getIP();

            $result = $conn->query("SELECT * FROM bruteforce_tries WHERE ip='".$IPAddress."';");

            if ($result->num_rows >= 1) {

                $row = $result->fetch_assoc();

                if ($row['lasttry'] > (time() - 3600)) {

                    $conn->query("UPDATE bruteforce_tries SET tries=tries+1, lasttry=".time()." WHERE ip='".$IPAddress."';");

                    $conn->query("DELETE FROM bruteforce_tries WHERE lasttry<".(time() - 3600));

                    if ($row['tries'] > 3) {

                        die($lang['mod/bad_password']);

                    }

                } else {

                    $conn->query("UPDATE bruteforce_tries SET tries=1, lasttry=".time()." WHERE ip='".$IPAddress."';");

                    $conn->query("DELETE FROM bruteforce_tries WHERE lasttry<".(time() - 3600));

                }

            }

            die($lang['mod/bad_password']);

        }

    } else {

        $IPAddress = $mitsuba->common->getIP();

        $result = $conn->query("SELECT * FROM bruteforce_tries WHERE ip='".$IPAddress."';");

        if ($result->num_rows >= 1) {

            $row = $result->fetch_assoc();

            if ($row['lasttry'] > (time() - 3600)) {

                $conn->query("UPDATE bruteforce_tries SET tries=tries+1, lasttry=".time()." WHERE ip='".$IPAddress."';");

                $conn->query("DELETE FROM bruteforce_tries WHERE lasttry<".(time() - 3600));

                if ($row['tries'] > 3) {

                    die($lang['mod/bad_password']);

                }

            } else {

                $conn->query("UPDATE bruteforce_tries SET tries=1, lasttry=".time()." WHERE ip='".$IPAddress."';");

                $conn->query("DELETE FROM bruteforce_tries WHERE lasttry<".(time() - 3600));

            }

        }

        die($lang['mod/bad_password']);

    }

} else {

    die($lang['mod/error']);

}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}
if($mitsuba->admin->canBoard("%")) {
    $mitsuba->admin->reqPermission("config.global_message");

    if (isset($_POST['message'])) {

        $mitsuba->admin->ui->checkToken($_POST['token']);

        $mitsuba->updateConfigValue("global_message", $_POST['message']);

    ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/global_message_updated']); ?>

  <?php echo $lang['mod/rebuild_notice']; ?>

  <?php echo $lang['mod/back']; ?>

    <?php $mitsuba->admin->ui->endSection(); ?>

    <?php

    } else {

        $config = $mitsuba->config;

        $msg = $config['global_message'];

    ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/edit_global_message']); ?>

  <?php echo $lang['mod/rebuild_notice']; ?>

    <form action="?/message" method="POST">

    <?php $mitsuba->admin->ui->getToken($path); ?>

    <textarea cols=70 rows=14 name="message"><?php echo $msg; ?></textarea>

    <input type="submit" value="<?php echo $lang['mod/submit']; ?>">

    </form>

    <?php $mitsuba->admin->ui->endSection(); ?>

    <?php

    }
}else{
    echo "I'm sorry, this is only for global administrators!";
}
?>


code:
<?php
//READ: IF YOU ARENT RUNNING PHP 7.x+ UNCOMMENT ALL `break;` LINES; 7.0 DEPRECATED THIS
if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("modules.view");

        $search = "";

        $replace = "";

if ((!empty($_GET['cfg'])) && ($_GET['cfg'] == 1) && (!empty($_GET['n']))) {

    $mitsuba->admin->reqPermission("modules.config");

    $result = $conn->query("SELECT * FROM modules WHERE namespace='".$conn->real_escape_string($_GET['n'])."';");

    if ($result->num_rows != 1) {

        echo "".$lang['mod/module_not_installed']."";

    } else {

        $dir = "./modules/".$_GET['n'];

        include $dir."/install.php";

        $installer = new $json->install_class($conn, $mitsuba);

        $installer->uninstall();

        exit;

    }

}

if ((!empty($_POST['mode'])) && ($_POST['mode'] == "upload")) {

    $mitsuba->admin->reqPermission("modules.upload");

    $mitsuba->admin->ui->checkToken($_POST['token']);

    if (empty($_FILES['upfile']['tmp_name'])) {

        echo "".$lang['mod/no_file']."";

    } else {

        $filename = strtolower(preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '', $_FILES['upfile']['name']));

        //Zip file checks

        $tmpname = $_FILES['upfile']['tmp_name'];

        $zip = new ZipArchive();

        if ($zip->open($tmpname) !== true) {

            echo "".$lang['mod/no_file']."";

        } elseif (is_null($zip->locateName("module.json"))) {

            echo "".$lang['mod/invalid_module']." 1 ";

        } elseif ((is_null($zip->locateName("install.php"))) || (is_null($zip->locateName("config.php")))) //Does the archive contain install.php and config.php?

        {

            echo "".$lang['mod/invalid_module']." 2 ";

        } else {

            //Is the JSON valid?
            $json = json_decode($zip->getFromIndex($zip->locateName("flags/module.json")));
            //var_dump($zip->getFromIndex($zip->locateName("module.json")));

            if (is_null($json)) {

                echo "".$lang['mod/invalid_module']." 3 ";

            } elseif ((empty($json->name)) || (empty($json->namespace)) || (empty($json->description)) || (empty($json->author)) || (empty($json->version)) || (empty($json->install_class)) || (empty($json->config_class))) {

                echo "".$lang['mod/invalid_module']." 4 ";

            } elseif (is_dir("./modules/".$json->namespace."/")) {

                echo "".sprintf($lang['mod/module_dir_exists'], $json->namespace)."";

            } else {

                mkdir("./modules/".$json->namespace);

                $zip->extractTo("./modules/".$json->namespace."/");

                echo "".$lang['mod/module_uploaded']."";

            }

        }

        $zip->close();

    }

}

if ((!empty($_GET['ins'])) && ($_GET['ins'] == 1) && (!empty($_GET['n']))) {

    $mitsuba->admin->reqPermission("modules.install");

    $result = $conn->query("SELECT * FROM modules WHERE namespace='".$conn->real_escape_string($_GET['n'])."';");

    if ($result->num_rows == 1) {

        echo "".$lang['mod/module_already_installed']."";

    } else {

        $dir = "./modules/".$_GET['n'];

        //Validate JSON

        if ((is_dir($dir)) &&(file_exists($dir."/module.json")) && (file_exists($dir."/install.php")) && (file_exists($dir."/config.php"))) {

            $json = json_decode(file_get_contents($dir."/module.json"));

            if ((!is_null($json)) && (!empty($json->name)) && (!empty($json->namespace)) && (!empty($json->description)) && (!empty($json->author)) && (!empty($json->version)) && (!empty($json->install_class)) && (!empty($json->config_class))) {

                //We can haz module!

                $continue = 1;

                //Check post fields

                if ($continue) {

                    if ((!empty($json->new_post_fields)) && (is_array($json->new_post_fields))) {

                        $all_fields = $conn->query("SHOW COLUMNS FROM posts;");

                        $fields = array();

                        while ($row = $all_fields->fetch_assoc())

                        {

                            $fields[$row['Field']] = 1;

                        }

                        foreach ($json->new_post_fields as $field) {

                            if (!empty($fields[$field->name])) {

                                //We haz a conflicting field o_O

                                echo "".$lang['mod/module_install_error'].sprintf($lang['mod/module_post_field_conflict'], $field->name)."";

                                $continue = 0;

                                //break;

                            }

                        }

                    }

                }

                //Check permissions

                if ($continue) {

                    if ((!empty($json->new_permissions)) && (is_array($json->new_permissions))) {

                        $all_permissions = $conn->query("SELECT * FROM permissions");

                        $permissions = array();

                        while ($row = $all_permissions->fetch_assoc())

                        {

                            $permissions[$row['name']] = 1;

                        }

                        foreach ($json->new_permissions as $permission) {

                            if (!empty($permissions["modules.".$json->namespace.".".$permission->name])) {

                                echo "".$lang['mod/module_install_error'].sprintf($lang['mod/module_permission_conflict'], "modules.".$json->namespace.".".$permission->name)."";

                                $continue = 0;

                                //break;

                            }

                        }

                    }

                }

                //Check config

                if ($continue) {

                    if ((!empty($json->new_config)) && (is_array($json->new_config))) {

                        $all_config = $conn->query("SELECT * FROM module_config WHERE namespace='".$conn->real_escape_string($json->namespace)."'");

                        $econfig = array();

                        while ($row = $all_config->fetch_assoc())

                        {

                            $econfig[$row['name']] = 1;

                        }

                        foreach ($json->new_config as $config) {

                            if (!empty($econfig[$config->name])) {

                                echo "".$lang['mod/module_install_error'].sprintf($lang['mod/module_config_conflict'], $config->name)."";

                                $continue = 0;

                                //break;

                            }

                        }

                    }

                }

                //Check board config

                if ($continue) {

                    if ((!empty($json->new_boardconfig)) && (is_array($json->new_boardconfig))) {

                        $all_fields = $conn->query("SHOW COLUMNS FROM boards;");

                        $fields = array();

                        while ($row = $all_fields->fetch_assoc())

                        {

                            $fields[$row['Field']] = 1;

                        }

                        foreach ($json->new_boardconfig as $field) {

                            if (!empty($fields[$field->name])) {

                                //We haz a conflicting field o_O

                                echo "".$lang['mod/module_install_error'].sprintf($lang['mod/module_board_field_conflict'], $field->name)."";

                                $continue = 0;

                                //break;

                            }

                        }

                    }

                }

                //Check new classes

                if ($continue) {

                    if ((!empty($json->new_classes)) && (is_array($json->new_classes))) {

                        foreach ($json->new_classes as $field) {

                            $name = $field->name;

                            if (!empty($mitsuba->$name)) {

                                //We haz a conflicting field o_O

                                echo "".$lang['mod/module_install_error'].sprintf($lang['mod/module_class_conflict'], $field->name)."";

                                $continue = 0;

                                //break;

                            }

                        }

                    }

                }

                //Check extra tables

                if ($continue) {

                    if ((!empty($json->new_tables)) && (is_array($json->new_tables))) {

                        $all_fields = $conn->query("SHOW TABLES;");

                        $fields = array();

                        while ($row = $all_fields->fetch_row())

                        {

                            $fields[$row[0]] = 1;

                        }

                        foreach ($json->new_tables as $table) {

                            if (!empty($fields[$table])) {

                                //We haz a conflicting field o_O

                                echo "".$lang['mod/module_install_error'].sprintf($lang['mod/module_table_conflict'], $table)."";

                                $continue = 0;

                                //break;

                            }

                        }

                    }

                }

                //Check panel pages

                if ($continue) {

                    if ((!empty($json->panel_pages)) && (is_array($json->panel_pages))) {

                        $all_fields = $conn->query("SELECT * FROM module_pages;");

                        $fields = array();

                        while ($row = $all_fields->fetch_assoc())

                        {

                            $fields[$row['url']] = 1;

                        }

                        foreach ($json->panel_pages as $pages) {

                            if (!empty($fields[$pages->url])) {

                                //We haz a conflicting field o_O

                                echo "".$lang['mod/module_install_error'].sprintf($lang['mod/module_page_conflict'], $field->page)."";

                                $continue = 0;

                                //break;

                            }

                        }

                    }

                }

                $continue = 1;

                $undo_queries = array();

                //Create post fields

                if ($continue) {
                  var_dump("test");
                    if ((!empty($json->new_post_fields)) && (is_array($json->new_post_fields))) {

                        foreach ($json->new_post_fields as $field) {

                            if (!$conn->query("ALTER TABLE posts ADD `".$conn->real_escape_string($field->name)."` ".$conn->real_escape_string($field->definition))) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_install_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "ALTER TABLE posts DROP `".$conn->real_escape_string($field->name)."`;";

                                if (!$conn->query("INSERT INTO module_fields (`namespace`, `name`, `type`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($field->name)."', 'postfield');")) {

                                    //Oh crap we haz an error!

                                    $continue = 0;

                                    echo "".$lang['mod/module_install_error'].$conn->error."";

                                    foreach ($undo_queries as $query) {

                                        $conn->query($query);

                                    }

                                    //break;

                                } else {

                                    $undo_queries[] = "DELETE FROM module_fields WHERE namespace='".$conn->real_escape_string($json->namespace)."' AND name='".$conn->real_escape_string($field->name)."';";

                                }

                            }

                        }

                    }

                }

                //Create permissions

                if ($continue) {

                    if ((!empty($json->new_permissions)) && (is_array($json->new_permissions))) {

                        $id = $conn->query("SELECT * FROM permissions_categories WHERE name='module';")->fetch_assoc()['id'];

                        foreach ($json->new_permissions as $permission) {

                            if (!$conn->query("INSERT INTO `permissions` (`name`, `description`, `category`) VALUES ('".$conn->real_escape_string($permission->name)."', '".$conn->real_escape_string($permission->description)."', ".$id.")")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_install_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "DELETE FROM `permissions` WHERE name='".$conn->real_escape_string($permission->name)."';";

                            }

                        }

                    }

                }

                //Create config

                if ($continue) {

                    if ((!empty($json->new_config)) && (is_array($json->new_config))) {

                        foreach ($json->new_config as $config) {

                            if (!$conn->query("INSERT INTO `module_config` (`namespace`, `name`, `description`, `default_value`, `value`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($config->name)."', '".$conn->real_escape_string($config->description)."', '".$conn->real_escape_string($config->default_value)."', '".$conn->real_escape_string($config->default_value)."')")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_install_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "DELETE FROM `module_config` WHERE name='".$conn->real_escape_string($config->name)."' AND namespace='".$conn->real_escape_string($json->namespace)."';";

                            }

                        }

                    }

                }

                //Create board config

                if ($continue) {

                    if ((!empty($json->new_boardconfig)) && (is_array($json->new_boardconfig))) {

                        foreach ($json->new_boardconfig as $config) {

                            if (!$conn->query("INSERT INTO `module_boardconfig` (`namespace`, `name`, `description`, `default_value`, `value`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($config->name)."', '".$conn->real_escape_string($config->description)."', '".$conn->real_escape_string($config->default_value)."', '".$conn->real_escape_string($config->default_value)."')")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_install_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "DELETE FROM `module_boardconfig` WHERE name='".$conn->real_escape_string($config->name)."' AND namespace='".$conn->real_escape_string($json->namespace)."';";

                                if (!$conn->query("ALTER TABLE boards ADD `".$conn->real_escape_string($config->name)."` ".$conn->real_escape_string($config->definition))) {

                                    //Oh crap we haz an error!

                                    $continue = 0;

                                    echo "".$lang['mod/module_install_error'].$conn->error."";

                                    foreach ($undo_queries as $query) {

                                        $conn->query($query);

                                    }

                                    //break;

                                } else {

                                    $undo_queries[] = "ALTER TABLE posts DROP `".$conn->real_escape_string($config->name)."`;";

                                }

                            }

                        }

                    }

                }

                //Create new classes

                if ($continue) {

                    if ((!empty($json->new_classes)) && (is_array($json->new_classes))) {

                        foreach ($json->new_classes as $class) {

                            if (!$conn->query("INSERT INTO `module_classes` (`namespace`, `name`, `file`, `class`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($class->name)."', '".$conn->real_escape_string($class->file)."', '".$conn->real_escape_string($class->class)."')")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_install_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "DELETE FROM `module_classes` WHERE name='".$conn->real_escape_string($class->name)."';";

                            }

                        }

                    }

                }

                //Create panel pages

                if ($continue) {

                    if ((!empty($json->panel_pages)) && (is_array($json->panel_pages))) {

                        foreach ($json->panel_pages as $page) {

                            if (!$conn->query("INSERT INTO `module_pages` (`namespace`, `url`, `file`, `class`, `method`) VALUES ('".$conn->real_escape_string($page->namespace)."', '".$conn->real_escape_string($page->url)."', '".$conn->real_escape_string($page->file)."', '".$conn->real_escape_string($page->class)."', '".$conn->real_escape_string($page->method)."')")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_install_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "DELETE FROM `module_pages` WHERE url='".$conn->real_escape_string($page->url)."' AND namespace='".$conn->real_escape_string($json->namespace)."';";

                            }

                        }

                    }

                }

                //Create events

                if ($continue) {

                    if ((!empty($json->events)) && (is_array($json->events))) {

                        foreach ($json->events as $event) {

                            if (!$conn->query("INSERT INTO `module_events` (`namespace`, `event`, `file`, `class`, `method`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($event->event)."', '".$conn->real_escape_string($event->file)."', '".$conn->real_escape_string($event->class)."', '".$conn->real_escape_string($event->method)."')")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_install_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "DELETE FROM `module_events` WHERE event='".$conn->real_escape_string($event->event)."' AND namespace='".$conn->real_escape_string($json->namespace)."';";

                            }

                        }

                    }

                }

                //Add to modules table

                if ($continue) {

                    if (!$conn->query("INSERT INTO `modules` (`namespace`, `name`, `description`, `author`, `version`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($json->name)."', '".$conn->real_escape_string($json->description)."', '".$conn->real_escape_string($json->author)."', '".$conn->real_escape_string($json->version)."');")) {

                        //Oh crap we haz an error!

                        $continue = 0;

                        echo "".$lang['mod/module_install_error'].$conn->error."";

                        foreach ($undo_queries as $query) {

                            $conn->query($query);

                        }

                        //break;

                    } else {

                        $undo_queries[] = "DELETE FROM `modules` WHERE namespace='".$conn->real_escape_string($json->namespace)."';";

                    }

                }

                //Execute install.php (create extra tables etc.)

                if ($continue) {

                    include $dir."/install.php";

                    $installer = new $json->install_class($conn, $mitsuba);

                    $installer->install();

                    echo "".$lang['mod/module_installed']."";

                }

            } else {

                echo "".$lang['mod/module_invalid_json']."";

            }

        } else {

            echo "".$lang['mod/module_no_file']."";

        }

    }

}

if ((!empty($_GET['unins'])) && ($_GET['unins'] == 1) && (!empty($_GET['n']))) {

    $mitsuba->admin->reqPermission("modules.uninstall");

    $result = $conn->query("SELECT * FROM modules WHERE namespace='".$conn->real_escape_string($_GET['n'])."';");

    if ($result->num_rows != 1) {

        echo "".$lang['mod/module_not_installed']."";

    } else {

        $dir = "./modules/".$_GET['n'];

        //Validate JSON

        if ((is_dir($dir)) &&(file_exists($dir."/module.json")) && (file_exists($dir."/install.php")) && (file_exists($dir."/config.php"))) {

            $json = json_decode(file_get_contents($dir."/module.json"));

            if ((!is_null($json)) && (!empty($json->name)) && (!empty($json->namespace)) && (!empty($json->description)) && (!empty($json->author)) && (!empty($json->version)) && (!empty($json->install_class)) && (!empty($json->config_class))) {

                $continue = 1;

                $undo_queries = array();

                //Create post fields

                if ($continue) {

                    if ((!empty($json->new_post_fields)) && (is_array($json->new_post_fields))) {

                        foreach ($json->new_post_fields as $field) {

                            if (!$conn->query("ALTER TABLE posts DROP `".$conn->real_escape_string($field->name)."`;")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_uninstall_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "ALTER TABLE posts ADD `".$conn->real_escape_string($field->name)."` ".$conn->real_escape_string($field->definition);

                                if (!$conn->query("DELETE FROM module_fields WHERE namespace='".$conn->real_escape_string($json->namespace)."' AND name='".$conn->real_escape_string($field->name)."';")) {

                                    //Oh crap we haz an error!

                                    $continue = 0;

                                    echo "".$lang['mod/module_uninstall_error'].$conn->error."";

                                    foreach ($undo_queries as $query) {

                                        $conn->query($query);

                                    }

                                    //break;

                                } else {

                                    $undo_queries[] = "INSERT INTO module_fields (`namespace`, `name`, `type`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($field->name)."', 'postfield');";

                                }

                            }

                        }

                    }

                }

                //Create permissions

                if ($continue) {

                    if ((!empty($json->new_permissions)) && (is_array($json->new_permissions))) {

                        $id = $conn->query("SELECT * FROM permissions_categories WHERE name='module';")->fetch_assoc()['id'];

                        foreach ($json->new_permissions as $permission) {

                            if (!$conn->query("DELETE FROM `permissions` WHERE name='".$conn->real_escape_string($permission->name)."';")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_uninstall_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "INSERT INTO `permissions` (`name`, `description`, `category`) VALUES ('".$conn->real_escape_string($permission->name)."', '".$conn->real_escape_string($permission->description)."', ".$id.")";

                            }

                        }

                    }

                }

                //Create config

                if ($continue) {

                    if ((!empty($json->new_config)) && (is_array($json->new_config))) {

                        foreach ($json->new_config as $config) {

                            if (!$conn->query("DELETE FROM `module_config` WHERE name='".$conn->real_escape_string($config->name)."' AND namespace='".$conn->real_escape_string($json->namespace)."';")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_uninstall_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "INSERT INTO `module_config` (`namespace`, `name`, `description`, `default_value`, `value`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($config->name)."', '".$conn->real_escape_string($config->description)."', '".$conn->real_escape_string($config->default_value)."', '".$conn->real_escape_string($config->default_value)."')";

                            }

                        }

                    }

                }

                //Create board config

                if ($continue) {

                    if ((!empty($json->new_boardconfig)) && (is_array($json->new_boardconfig))) {

                        foreach ($json->new_boardconfig as $config) {

                            if (!$conn->query("DELETE FROM `module_boardconfig` WHERE name='".$conn->real_escape_string($config->name)."' AND namespace='".$conn->real_escape_string($json->namespace)."';")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_uninstall_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "INSERT INTO `module_boardconfig` (`namespace`, `name`, `description`, `default_value`, `value`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($config->name)."', '".$conn->real_escape_string($config->description)."', '".$conn->real_escape_string($config->default_value)."', '".$conn->real_escape_string($config->default_value)."')";

                                if (!$conn->query("ALTER TABLE posts DROP `".$conn->real_escape_string($config->name)."`;")) {

                                    //Oh crap we haz an error!

                                    $continue = 0;

                                    echo "".$lang['mod/module_uninstall_error'].$conn->error."";

                                    foreach ($undo_queries as $query) {

                                        $conn->query($query);

                                    }

                                    //break;

                                } else {

                                    $undo_queries[] = "ALTER TABLE boards ADD `".$conn->real_escape_string($config->name)."` ".$conn->real_escape_string($config->definition);

                                }

                            }

                        }

                    }

                }

                //Create new classes

                if ($continue) {

                    if ((!empty($json->new_classes)) && (is_array($json->new_classes))) {

                        foreach ($json->new_classes as $class) {

                            if (!$conn->query("DELETE FROM `module_classes` WHERE name='".$conn->real_escape_string($class->name)."';")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_uninstall_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "INSERT INTO `module_classes` (`namespace`, `name`, `file`, `class`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($class->name)."', '".$conn->real_escape_string($class->file)."', '".$conn->real_escape_string($class->class)."')";

                            }

                        }

                    }

                }

                //Create panel pages

                if ($continue) {

                    if ((!empty($json->panel_pages)) && (is_array($json->panel_pages))) {

                        foreach ($json->panel_pages as $page) {

                            if (!$conn->query("DELETE FROM `module_pages` WHERE url='".$conn->real_escape_string($page->url)."' AND namespace='".$conn->real_escape_string($json->namespace)."';")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_uninstall_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "INSERT INTO `module_pages` (`namespace`, `url`, `file`, `class`, `method`) VALUES ('".$conn->real_escape_string($page->namespace)."', '".$conn->real_escape_string($page->url)."', '".$conn->real_escape_string($page->file)."', '".$conn->real_escape_string($page->class)."', '".$conn->real_escape_string($page->method)."')";

                            }

                        }

                    }

                }

                //Create events

                if ($continue) {

                    if ((!empty($json->events)) && (is_array($json->events))) {

                        foreach ($json->events as $event) {

                            if (!$conn->query("DELETE FROM `module_events` WHERE event='".$conn->real_escape_string($event->event)."' AND namespace='".$conn->real_escape_string($json->namespace)."';")) {

                                //Oh crap we haz an error!

                                $continue = 0;

                                echo "".$lang['mod/module_uninstall_error'].$conn->error."";

                                foreach ($undo_queries as $query) {

                                    $conn->query($query);

                                }

                                //break;

                            } else {

                                $undo_queries[] = "INSERT INTO `module_events` (`namespace`, `event`, `file`, `class`, `method`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($event->event)."', '".$conn->real_escape_string($event->file)."', '".$conn->real_escape_string($event->class)."', '".$conn->real_escape_string($event->method)."')";

                            }

                        }

                    }

                }

                //Add to modules table

                if ($continue) {

                    if (!$conn->query("DELETE FROM `modules` WHERE namespace='".$conn->real_escape_string($json->namespace)."';")) {

                        //Oh crap we haz an error!

                        $continue = 0;

                        echo "".$lang['mod/module_uninstall_error'].$conn->error."";

                        foreach ($undo_queries as $query) {

                            $conn->query($query);

                        }

                        //break;

                    } else {

                        $undo_queries[] = "INSERT INTO `modules` (`namespace`, `name`, `description`, `author`, `version`) VALUES ('".$conn->real_escape_string($json->namespace)."', '".$conn->real_escape_string($json->name)."', '".$conn->real_escape_string($json->description)."', '".$conn->real_escape_string($json->author)."', '".$conn->real_escape_string($json->version)."');";

                    }

                }

                //Execute install.php (create extra tables etc.)

                if ($continue) {

                    include $dir."/install.php";

                    $installer = new $json->install_class($conn, $mitsuba);

                    $installer->uninstall();

                    echo "".$lang['mod/module_uninstalled']."";

                }

            } else {

                echo "".$lang['mod/module_invalid_json']."";

            }

        } else {

            echo "".$lang['mod/module_no_file']."";

        }

    }

}

if ((!empty($_GET['del'])) && ($_GET['del'] == 1) && (!empty($_GET['n']))) {

    $mitsuba->admin->reqPermission("modules.delete");

    $result = $conn->query("SELECT * FROM modules WHERE namespace='".$conn->real_escape_string($_GET['n'])."';");

    if ($result->num_rows == 1) {

        echo "".$lang['mod/module_installed_delete']."";

    } else {

        $dir = "./modules/".$_GET['n'];

        $mitsuba->common->delTree("./".$dir);

        echo "".$lang['mod/module_deleted']."";

    }

}

    ?>

<?php echo $lang['mod/rebuild_notice']; ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/manage_modules']); ?>

<?php echo $lang['mod/name']; ?>

<?php echo $lang['mod/description']; ?>

<?php echo $lang['mod/author']; ?>

<?php echo $lang['mod/version']; ?>

<?php echo $lang['mod/actions']; ?>

<?php

$installed = array();

$result = $conn->query("SELECT * FROM modules ORDER BY name ASC");

while ($row = $result->fetch_assoc())

{

    $installed[$row['namespace']] = 1;

    echo "
";

    echo "".htmlspecialchars($row['name'])."	";

    echo "".htmlspecialchars($row['description'])."	";

    echo "".htmlspecialchars($row['author'])."	";

    echo "".htmlspecialchars($row['version'])."	";

    echo "".$lang['mod/uninstall']."	";

    echo "
";

}

?>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/uninstalled_modules']); ?>

<?php echo $lang['mod/name']; ?>

<?php echo $lang['mod/description']; ?>

<?php echo $lang['mod/author']; ?>

<?php echo $lang['mod/version']; ?>

<?php echo $lang['mod/actions']; ?>

<?php

$dirs = array_filter(glob('./modules/*'), 'is_dir');

foreach ($dirs as $dir) {

    if (file_exists($dir."/module.json")) {

        $json = json_decode(file_get_contents($dir."/module.json"));

        if ((!is_null($json)) && (!empty($json->name)) && (!empty($json->namespace)) && (!empty($json->description)) && (!empty($json->author)) && (!empty($json->version)) && (!empty($json->install_class)) && (!empty($json->config_class))) {

            if (!empty($installed[$json->namespace])) {

                continue;

            }

            echo "
";

            echo "".$json->name."	";

            echo "".$json->description."	";

            echo "".$json->author."	";

            echo "".$json->version."	";

            echo "namespace."'>".$lang['mod/install']." namespace."'>".$lang['mod/delete']."	";

            echo "
";

        }

    }

}

?>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/upload_module']); ?>

<form action="?/modules" method="POST" enctype="multipart/form-data">

<?php $mitsuba->admin->ui->getToken($path); ?>

<input type="hidden" name="MAX_FILE_SIZE" value="2097152">

<input type="hidden" name="mode" value="upload">

<?php echo $lang['mod/file']; ?>: <input id="postFile" name="upfile" type="file">

<input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

</form>

<?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$menu = array();

$reports = $conn->query("SELECT * FROM reports;")->num_rows;

$appeals = $conn->query("SELECT * FROM appeals;")->num_rows;

$breqs = $conn->query("SELECT * FROM ban_requests;")->num_rows;

$pms = $conn->query("SELECT * FROM pm WHERE to_user=".$_SESSION['id']." AND read_msg=0")->num_rows;

$menu['acc'] = array(

    'name' => $lang['mod/account'],

    'children' => array()

);

$menu['gen'] = array(

    'name' => $lang['mod/general'],

    'children' => array()

);

$menu['adm'] = array(

    'name' => $lang['mod/administration'],

    'children' => array()

);

$menu['brd'] = array(

    'name' => $lang['mod/boards'],

    'children' => array()

);

$menu['acc']['children'][] = array(

    'url' => '?/inbox/new',

    'name' => $lang['mod/send_message'],

    'show' => $mitsuba->admin->checkPermission("user.inbox")

);

$menu['acc']['children'][] = array(

    'url' => '?/inbox',

    'name' => $lang['mod/inbox'].' ('.$pms.')',

    'show' => $mitsuba->admin->checkPermission("user.inbox")

);

$menu['acc']['children'][] = array(

    'url' => '?/outbox',

    'name' => $lang['mod/outbox'],

    'show' => $mitsuba->admin->checkPermission("user.inbox")

);

$menu['acc']['children'][] = array(

    'url' => '?/password',

    'name' => $lang['mod/change_password'],

    'show' => $mitsuba->admin->checkPermission("user.change_password")

);

$menu['gen']['children'][] = array(

    'url' => '?/announcements',

    'name' => $lang['mod/announcements'],

    'show' => $mitsuba->admin->checkPermission("announcements.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/news',

    'name' => $lang['mod/news'],

    'show' => $mitsuba->admin->checkPermission("news.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/notes',

    'name' => $lang['mod/notes'],

    'show' => $mitsuba->admin->checkPermission("notes.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/ipnotes',

    'name' => $lang['mod/ip_notes'],

    'show' => $mitsuba->admin->checkPermission("ipnotes.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/recent/posts',

    'name' => $lang['mod/recent_posts'],

    'show' => $mitsuba->admin->checkPermission("recent.posts")

);

$menu['gen']['children'][] = array(

    'url' => '?/recent/files',

    'name' => $lang['mod/recent_images'],

    'show' => $mitsuba->admin->checkPermission("recent.files")

);

$menu['gen']['children'][] = array(

    'url' => '?/reports',

    'name' => $lang['mod/report_queue'].' ('.$reports.')',

    'show' => $mitsuba->admin->checkPermission("reports.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/bans',

    'name' => $lang['mod/banlist'],

    'show' => $mitsuba->admin->checkPermission("bans.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/warnings',

    'name' => $lang['mod/warnings'],

    'show' => $mitsuba->admin->checkPermission("warnings.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/whitelist',

    'name' => $lang['mod/manage_whitelist'],

    'show' => $mitsuba->admin->checkPermission("whitelist.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/bans/add',

    'name' => $lang['mod/add_ban'],

    'show' => $mitsuba->admin->checkPermission("bans.add")

);

$menu['gen']['children'][] = array(

    'url' => '?/warnings/add',

    'name' => $lang['mod/add_warning'],

    'show' => $mitsuba->admin->checkPermission("warnings.add")

);

$menu['gen']['children'][] = array(

    'url' => '?/ban_requests',

    'name' => $lang['mod/ban_requests'].' ('.$breqs.')',

    'show' => $mitsuba->admin->checkPermission("requests.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/appeals',

    'name' => $lang['mod/appeals'].' ('.$appeals.')',

    'show' => $mitsuba->admin->checkPermission("appeals.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/rangebans',

    'name' => $lang['mod/manage_range_bans'],

    'show' => $mitsuba->admin->checkPermission("range.view")

);

$menu['gen']['children'][] = array(

    'url' => '?/rangebans/add',

    'name' => $lang['mod/add_range_ban'],

    'show' => $mitsuba->admin->checkPermission("range.add")

);

$menu['gen']['children'][] = array(

    'url' => '?/announcements/add',

    'name' => $lang['mod/new_announcement'],

    'show' => $mitsuba->admin->checkPermission("announcements.add")

);

$menu['gen']['children'][] = array(

    'url' => '?/news/add',

    'name' => $lang['mod/add_news'],

    'show' => $mitsuba->admin->checkPermission("news.add")

);

$menu['gen']['children'][] = array(

    'url' => '?/locked',

    'name' => $lang['mod/locked'],

    'show' => $mitsuba->admin->checkPermission("post.closed")

);

$menu['gen']['children'][] = array(

    'url' => '?/sticky',

    'name' => $lang['mod/sticky'],

    'show' => $mitsuba->admin->checkPermission("post.sticky")

);

$menu['adm']['children'][] = array(

    'url' => '?/config',

    'name' => $lang['mod/configuration'],

    'show' => $mitsuba->admin->checkPermission("config.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/boards',

    'name' => $lang['mod/manage_boards'],

    'show' => $mitsuba->admin->checkPermission("boards.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/ads',

    'name' => $lang['mod/manage_ads'],

    'show' => $mitsuba->admin->checkPermission("ads.list")

);

$menu['adm']['children'][] = array(

    'url' => '?/pages',

    'name' => $lang['mod/manage_pages'],

    'show' => $mitsuba->admin->checkPermission("pages.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/links',

    'name' => $lang['mod/manage_board_links'],

    'show' => $mitsuba->admin->checkPermission("links.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/users',

    'name' => $lang['mod/manage_users'],

    'show' => $mitsuba->admin->checkPermission("users.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/news/manage',

    'name' => $lang['mod/manage_news_entries'],

    'show' => $mitsuba->admin->checkPermission("news.manage")

);

$menu['adm']['children'][] = array(

    'url' => '?/announcements/manage',

    'name' => $lang['mod/manage_announcements'],

    'show' => $mitsuba->admin->checkPermission("announcements.manage")

);

$menu['adm']['children'][] = array(

    'url' => '?/bbcodes',

    'name' => $lang['mod/manage_bbcodes'],

    'show' => $mitsuba->admin->checkPermission("bbcodes.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/embeds',

    'name' => $lang['mod/manage_embeds'],

    'show' => $mitsuba->admin->checkPermission("embeds.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/styles',

    'name' => $lang['mod/manage_styles'],

    'show' => $mitsuba->admin->checkPermission("styles.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/wordfilter',

    'name' => $lang['mod/manage_wordfilter'],

    'show' => $mitsuba->admin->checkPermission("wordfilter.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/spamfilter',

    'name' => $lang['mod/manage_spamfilter'],

    'show' => $mitsuba->admin->checkPermission("spamfilter.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/modules',

    'name' => $lang['mod/manage_modules'],

    'show' => $mitsuba->admin->checkPermission("modules.view")

);

$menu['adm']['children'][] = array(

    'url' => '?/message',

    'name' => $lang['mod/global_message'],

    'show' => $mitsuba->admin->checkPermission("config.global_message")

);

$menu['adm']['children'][] = array(

    'url' => '?/rebuild',

    'name' => $lang['mod/rebuild_cache'],

    'show' => $mitsuba->admin->checkPermission("config.rebuild")

);

$menu['adm']['children'][] = array(

    'url' => '?/cleaner',

    'name' => $lang['mod/cleaner'],

    'show' => $mitsuba->admin->checkPermission("config.cleaner")

);

$menu['adm']['children'][] = array(

    'url' => '?/log',

    'name' => $lang['mod/action_log'],

    'show' => $mitsuba->admin->checkPermission("logs.view")

);

$result = $conn->query("SELECT * FROM boards ORDER BY short ASC;");

if ($_SESSION['boards'] != "%") {

    $boards = explode(",", $_SESSION['boards']);

} else {

    $boards = "%";

}

while ($row = $result->fetch_assoc())

{

    if (($boards == "%") || (in_array($row['short'], $boards))) {

        if ($row['hidden']==1) {

            $menu['brd']['children'][] = array(

            'url' => '?/board&b='.$row['short'],

            'name' => '/'.$row['short'].'/ - '.$row['name'],

            'show' => true

            );

        } else {

            $menu['brd']['children'][] = array(

            'url' => './'.$row['short'].'/',

            'name' => '/'.$row['short'].'/ - '.$row['name'],

            'show' => true

            );

        }

    }

}

?>

                <?php

                foreach ($menu as $key => $category) {

                ?>

<?php echo $category['name']; ?>

    <?php

    foreach ($category['children'] as $item){

        if ($item['show']) {

            if (strpos($_SERVER['REQUEST_URI'], $item['url']) !== false) {

                echo '
'.$item['name'].'
';

            }else{

                echo '
'.$item['name'].'
';

            }

        }

    }

                ?>

                <?php

                }

    ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("news.add");

if (empty($_POST['text'])) {

    ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/add_news']); ?>

<form action="?/news/add" method="POST">

<?php $mitsuba->admin->ui->getToken($path); ?>

<?php echo $lang['mod/by']; ?>: <input type="text" name="who" value="<?php echo $_SESSION['username']; ?>" />

<?php echo $lang['mod/title']; ?>: <input type="text" name="title"/>

<?php echo $lang['mod/text']; ?>:

<textarea name="text" cols="70" rows="10"></textarea>

<input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

</form>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/your_entries']); ?>

<?php echo $lang['mod/title']; ?>

<?php echo $lang['mod/date']; ?>

<?php echo $lang['mod/edit']; ?>

<?php echo $lang['mod/delete']; ?>

<?php

$result = $conn->query("SELECT * FROM news WHERE mod_id=".$_SESSION['id']." ORDER BY date DESC;");

while ($row = $result->fetch_assoc())

{

    echo "
";

    echo "".$row['title']."	";

    echo "".date("d/m/Y @ H:i", $row['date'])."	";

    echo "".$lang['mod/edit']."	";

    echo "".$lang['mod/delete']."	";

    echo "	";

}

$mitsuba->caching->generateNews();

?>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php

} else {

    $mitsuba->admin->ui->checkToken($_POST['token']);

    $text = processEntry($conn, $_POST['text']);

    $who = $_SESSION['username'];

    if (!empty($_POST['who'])) { $who = $_POST['who'];
    }

    $conn->query("INSERT INTO news (date, who, title, text, mod_id) VALUES (".time().", '".$who."', '".$conn->real_escape_string(htmlspecialchars($_POST['title']))."', '".$text."', ".$_SESSION['id'].");");

    $mitsuba->caching->generateNews();

    ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/post_added']); ?>

<?php echo $lang['mod/back']; ?><?php $mitsuba->admin->ui->endSection(); ?>

    <?php

}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

if (isset($_GET['b'])) {

    deleteEntry($conn, 1, $_GET['b']);

    ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/post_deleted']); ?>

<?php echo $lang['mod/back']; ?><?php $mitsuba->admin->ui->endSection(); ?>

    <?php

}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

if ((isset($_GET['b'])) && (is_numeric($_GET['b']))) {

    $result = $conn->query("SELECT * FROM news WHERE id=".$_GET['b']);

    if ($result->num_rows != 0) {

        if (empty($_POST['text'])) {

            $data = $result->fetch_assoc();

        ?>

        <?php $mitsuba->admin->ui->startSection($lang['mod/edit_news_entry']); ?>

       <form action="?/news/edit&b=<?php echo $_GET['b']; ?>" method="POST">

        <?php $mitsuba->admin->ui->getToken($path); ?>

        <?php echo $lang['mod/by']; ?>: <input type="text" name="who" value="<?php echo $data['who']; ?>" />

        <?php echo $lang['mod/title']; ?>: <input type="text" name="title" value="<?php echo $data['title']; ?>"/>

        <?php echo $lang['mod/text']; ?>:

       <textarea name="text" cols="70" rows="10"><?php echo $data['text']; ?></textarea>

       <input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

       </form>

        <?php $mitsuba->admin->ui->endSection(); ?>

    <?php

        } else {

            $mitsuba->admin->ui->checkToken($_POST['token']);

            updateEntry($conn, 1, $_GET['b'], $_POST['who'], $_POST['title'], $_POST['text']);

            ?>

        <?php $mitsuba->admin->ui->startSection($lang['mod/post_updated']); ?>

       <?php echo $lang['mod/back']; ?><?php $mitsuba->admin->ui->endSection(); ?>

            <?php

        }

    } else {

    ?>

    <meta http-equiv="refresh" content="0;URL='?/news'" />

    <?php

    }

} else {

    ?>

    <meta http-equiv="refresh" content="0;URL='?/news'" />

    <?php

}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("news.view");

?>

<?php $mitsuba->admin->ui->startSection($lang['mod/news']); ?>
<?php if($mitsuba->admin->canBoard("%")) {?>
[Add News Entry / Manage News Entries]
<?php }?>

<?php

$result = $conn->query("SELECT * FROM news ORDER BY date DESC;");

while ($row = $result->fetch_assoc())

{
    echo '
';

    echo '
'.$row['title'].' by '.$row['who'].' - '.date("d/m/Y @ H:i", $row['date']).' [Edit]
';

    echo $row['text'];

    echo '
';

}

?>

<?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("news.manage");

    ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/all_news_entries']); ?>

<?php echo $lang['mod/title']; ?>

<?php echo $lang['mod/date']; ?>

<?php echo $lang['mod/edit']; ?>

<?php echo $lang['mod/delete']; ?>

<?php

$result = $conn->query("SELECT * FROM news ORDER BY date DESC;");

while ($row = $result->fetch_assoc())

{

    echo "
";

    echo "".$row['title']."	";

    echo "".date("d/m/Y @ H:i", $row['date'])."	";

    echo "".$lang['mod/edit']."	";

    echo "".$lang['mod/delete']."	";

    echo "
";

}

?>

<?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("notes.add");

if (!empty($_POST['note'])) {

    $mitsuba->admin->ui->checkToken($_POST['token']);

    $note = $conn->real_escape_string($_POST['note']);

    $conn->query("INSERT INTO notes (mod_id, note, created) VALUES (".$_SESSION['id'].", '".$note."', ".time().")");

    ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/note_added']); ?>

<?php echo $lang['mod/back']; ?>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php

} else {

                ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/fill_all_fields']); ?>

<?php echo $lang['mod/back']; ?>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php

}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("notes.delete");

if ((!empty($_GET['id'])) && (is_numeric($_GET['id']))) {

    $note = $conn->query("SELECT * FROM notes WHERE id=".$_GET['id']);

    if ($note->num_rows == 1) {

        $info = $note->fetch_assoc();

        if ($info['mod_id'] == $_SESSION['id']) {

            $conn->query("DELETE FROM notes WHERE id=".$_GET['id']);

            ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/note_deleted']); ?>

    <?php echo $lang['mod/back']; ?>

    <?php $mitsuba->admin->ui->endSection(); ?>

    <?php

        } else {

                ?>

            <?php $mitsuba->admin->ui->startSection($lang['mod/error']); ?>

            <?php echo $lang['mod/back']; ?>

            <?php $mitsuba->admin->ui->endSection(); ?>

            <?php

        }

    } else {

    ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/error']); ?>

 <?php echo $lang['mod/back']; ?>

    <?php $mitsuba->admin->ui->endSection(); ?>

    <?php

    }

} else {

                ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/error']); ?>

<?php echo $lang['mod/back']; ?>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php

}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("notes.view");

?>

<?php $mitsuba->admin->ui->startSection($lang['mod/your_notes']); ?>

<?php

$result = $conn->query("SELECT * FROM notes WHERE mod_id=".$_SESSION['id']." ORDER BY created DESC;");

while ($row = $result->fetch_assoc())

{

    echo '
';

    echo '
'.date("d/m/Y @ H:i", $row['created']).' Delete
';

    echo $row['note'];

    echo '
';

}

?>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/add_note']); ?>

<form action="?/notes/add" method="POST">

<?php $mitsuba->admin->ui->getToken($path); ?>

<textarea name="note" cols=70 rows=12></textarea>

<input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

</form>

<?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("user.inbox");

?>

<?php $mitsuba->admin->ui->startSection($lang['mod/outbox']); ?>

    <?php

    $pms = $conn->query("SELECT users.username, pm.* FROM pm LEFT JOIN users ON pm.to_user=users.id WHERE pm.from_user=".$_SESSION['id']." ORDER BY pm.created DESC");

    while ($row = $pms->fetch_assoc())

    {

        echo "
";

        if ($row['read_msg']==0) {

            echo "".$row['title']."	";

        } else {

            echo "".$row['title']."	";

        }

        echo "".date("d/m/Y @ H:i", $row['created'])."	";

        echo "".$row['username']."	";

        echo "
";

    }

    ?>

<?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

	ini_set('display_errors', 'On');

	error_reporting(E_ALL);

if (!defined("IN_MOD"))

{

	die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("pages.update");

	if (!empty($_GET['b']))

	{

	$result = $conn->query("SELECT * FROM pages WHERE name='".$_GET['b']."'");

	if ($result->num_rows != 0)

	{

	if ((empty($_POST['text'])) || (empty($_POST['name'])))

	{

	$data = $result->fetch_assoc();

	?>

<?php $mitsuba->admin->ui->startSection($lang['mod/edit_page']); ?>

<form action="?/pages/edit&b=<?php echo $_GET['b']; ?>" method="POST">

<?php $mitsuba->admin->ui->getToken($path); ?>

<?php echo $lang['mod/name']; ?>: <input type="text" name="name" value="<?php echo $data['name']; ?>" />

<?php echo $lang['mod/title']; ?>: <input type="text" name="title" value="<?php echo $data['title']; ?>"/>

<?php echo $lang['mod/text']; ?>:

<textarea name="text" cols="70" rows="10"><?php echo $data['text']; ?></textarea>

<input type="checkbox" name="raw" value="1" <?php if ($data['raw'] == 1) { echo "checked='checked'"; }?> /><?php echo $lang['mod/raw_html']; ?>

<input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

</form>

<?php $mitsuba->admin->ui->endSection(); ?>

	<?php

	} else {

			$mitsuba->admin->ui->checkToken($_POST['token']);

		//what the hell is this doing here?

		//if ($_SESSION['type']==2){

			if (($_POST['name']=="news") || ($_POST['name']=="frontpage") || ($_POST['name']=="index"))

			{

				die($lang['mod/page_wrong_name']);

			}

			$result = $conn->query("UPDATE pages SET name='".$conn->real_escape_string($_POST['name'])."', title='".$conn->real_escape_string($_POST['title'])."', text='".$conn->real_escape_string($_POST['text'])."' WHERE name='".$conn->real_escape_string($_GET['b'])."'");

			if ($result)

			{

				$mitsuba->caching->generatePage($_POST['name']);

				?>

<?php $mitsuba->admin->ui->startSection($lang['mod/page_updated']); ?>

<?php echo $lang['mod/back']; ?><?php $mitsuba->admin->ui->endSection(); ?>

				<?php

			} else {

				?>

<?php $mitsuba->admin->ui->startSection($lang['mod/error']); ?>

<?php echo $lang['mod/back']; ?><?php $mitsuba->admin->ui->endSection(); ?>

				<?php

			}

		//}

	}

	} else {

		echo($conn->error);

	?>

	<meta http-equiv="refresh" content="0;URL='?/pages'" />

	<?php

	}

	} else {

	?>

	<meta http-equiv="refresh" content="0;URL='?/pages'" />

	<?php

	}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("pages.view");
if($mitsuba->admin->canBoard("%")) {
    if (!empty($_GET['m'])) {

        switch ($_GET['m'])

        {

        case "add":

            $mitsuba->admin->reqPermission("pages.add");

            $mitsuba->admin->ui->checkToken($_POST['token']);

            if (!empty($_POST['name'])) {

                if (($_POST['name']=="news") || ($_POST['name']=="frontpage") || ($_POST['name']=="index")) {

                    echo $lang['mod/page_wrong_name'];

                } else {

                    $result = $conn->query("INSERT INTO pages (`name`,`title`,`text`) VALUES ('".$conn->real_escape_string($_POST['name'])."', '".$conn->real_escape_string($_POST['title'])."', '".$conn->real_escape_string($_POST['text'])."')");

                    $mitsuba->caching->generatePage($_POST['name']);

                }

            } else {

                echo $lang['mod/fill_all_fields'];

            }

            break;

        case "delete":

            $mitsuba->admin->reqPermission("pages.delete");

            $conn->query("DELETE FROM pages WHERE name='".$conn->real_escape_string($_GET['b'])."'");

            if (file_exists("./".$_GET['b'].".html")) {

                unlink("./".$_GET['b'].".html");

            }

            break;

        }

    }

    ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/all_pages']); ?>

<?php echo $lang['mod/title']; ?>

<?php echo $lang['mod/name']; ?>

<?php echo $lang['mod/edit']; ?>

<?php echo $lang['mod/delete']; ?>

<?php

$result = $conn->query("SELECT * FROM pages ORDER BY name ASC;");

while ($row = $result->fetch_assoc())

{

    echo "
";

    echo "".$row['title']."	";

    echo "".$row['name'].".html	";

    echo "".$lang['mod/edit']."	";

    echo "".$lang['mod/delete']."	";

    echo "
";

}

?>

<?php $mitsuba->admin->ui->endSection(); ?>

<?php $mitsuba->admin->ui->startSection($lang['mod/add_page']); ?>

<form action="?/pages&m=add" method="POST">

<?php $mitsuba->admin->ui->getToken($path); ?>

<?php echo $lang['mod/name']; ?>: <input type="text" name="name" /> [will be located at /name.html and is case sensitive]

<?php echo $lang['mod/title']; ?>: <input type="text" name="title" /> [Text in title HTML element and header text]

<?php echo $lang['mod/text']; ?>:  [Text will be rendered using Markdown, unless "<?php echo $lang['mod/raw_html']; ?>" is checked.]

<textarea name="text" cols="70" rows="10"></textarea>

<input type="checkbox" name="raw" value="1" /><?php echo $lang['mod/raw_html']; ?>

<input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

</form>

<?php $mitsuba->admin->ui->endSection(); ?>
<?php }else{
    echo "Sorry. That feature is currently for Global Admins only.";
}
?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("user.change_password");

if ((!empty($_POST['old'])) && (!empty($_POST['new'])) && (!empty($_POST['new2']))) {

    $mitsuba->admin->ui->checkToken($_POST['token']);

    if ($_POST['new']==$_POST['new2']) {

        $result = $conn->query("SELECT password,salt FROM users WHERE id=".$_SESSION['id']);

        $row = $result->fetch_assoc();

        if ($row['password'] != hash("sha512", $_POST['old'].$row['salt'])) {

            ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/pwd_no_match']); ?>

    <?php echo $lang['mod/back']; ?><?php $mitsuba->admin->ui->endSection(); ?>

        <?php

        } else {

            $conn->query("UPDATE users SET password='".hash("sha512", $_POST['new'].$row['salt'])."' WHERE id=".$_SESSION['id']);

                ?>

            <?php $mitsuba->admin->ui->startSection($lang['mod/pwd_updated']); ?>

            <?php echo $lang['mod/back']; ?><?php $mitsuba->admin->ui->endSection(); ?>

                <?php

        }

    } else {

        ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/pwd_wrong']); ?>

 <?php echo $lang['mod/back']; ?><?php $mitsuba->admin->ui->endSection(); ?>

    <?php

    }

} else {

    ?>

<?php $mitsuba->admin->ui->startSection(""); ?>

<?php echo $lang['mod/pwd_change'];?>

              <form action="?/password" method="POST">

            <?php $mitsuba->admin->ui->getToken($path); ?>

                    <?php echo $lang['mod/pwd_current']; ?>

                    <input type="password" class="form-control" name="old">

                    <?php echo $lang['mod/pwd_new']; ?>

                    <input type="password" class="form-control" name="new" id="password">
         <meter max="4" id="password-strength-meter"></meter>

                    <?php echo $lang['mod/pwd_confirm']; ?>

                    <input type="password" class="form-control" name="new2">

                  <button type="submit" class="btn btn-primary">Submit</button>

              </form>

<?php $mitsuba->admin->ui->endSection(); ?>

    <?php

}

?>


code:
<?php

$mitsuba->admin->reqPermission("range.add");

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

if (empty($_POST['ip'])) {

    $IPAddress = "";

    $title = "";

    $title = $lang['mod/add_range_ban'];

    $mitsuba->admin->ui->startSection($title);

    ?>

<form action="?/rangebans/add" method="POST">

<?php $mitsuba->admin->ui->getToken($path); ?>

<?php echo $lang['mod/ip']; ?>: <input type="text" name="ip" value="<?php echo $IPAddress; ?>"/>

<?php echo $lang['mod/reason']; ?>: <input type="text" name="reason" />

<?php echo $lang['mod/staff_note']; ?>: <input type="text" name="note" />

<?php echo $lang['mod/expires_eg']; ?>: <input type="text" name="expires" />

<?php $mitsuba->admin->ui->getBoardList(); ?>

<input type="submit" value="<?php echo $lang['mod/submit']; ?>" />

</form>

<?php $mitsuba->admin->ui->endSection(); ?>

    <?php

} else {

    $mitsuba->admin->ui->checkToken($_POST['token']);

    $boards = "";

    if ((!empty($_POST['all'])) && ($_POST['all']==1)) {

        $boards = "%";

    } else {

        if (!empty($_POST['boards'])) {

            foreach ($_POST['boards'] as $board)

            {

                $boards .= $board.",";

            }

        } else {

            $boards = "%";

        }

    }

    if ($boards != "%") { $boards = substr($boards, 0, strlen($boards) - 1);
    }

    $result = $mitsuba->admin->bans->addRangeBan($_POST['ip'], $_POST['reason'], $_POST['note'], $_POST['expires'], $boards);

    if ($result == 1) {

    ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/user_banned']); ?>

  <?php echo $lang['mod/back']; ?><?php $mitsuba->admin->ui->endSection(); ?>

                <?php

    } else {

    ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/filled_wrong']); ?>

  <?php echo $lang['mod/back']; ?><?php $mitsuba->admin->ui->endSection(); ?>

                <?php

    }

}

?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("range.view");

$delete = $mitsuba->admin->checkPermission("bans.delete");

$logs = $mitsuba->admin->checkPermission("logs.view");

?>

<?php $mitsuba->admin->ui->startSection($lang['mod/all_range_bans']); ?>

    <?php echo $lang['mod/ip']; ?>

    <?php echo $lang['mod/reason']; ?>

    <?php echo $lang['mod/staff_note']; ?>

    <?php echo $lang['mod/created']; ?>

    <?php echo $lang['mod/expires']; ?>

    <?php echo $lang['mod/boards']; ?>

    <?php echo $lang['mod/delete']; ?>

    <?php

    if ($logs) { echo "".$lang['mod/staff_member']."	";
    }

    ?>

    <?php

    if ($logs) {

        $result = $conn->query("SELECT rangebans.*, users.username FROM rangebans LEFT JOIN users ON rangebans.mod_id=users.id ORDER BY created DESC;");

    } else {

        $result = $conn->query("SELECT * FROM rangebans ORDER BY created;");

    }

    while ($row = $result->fetch_assoc())

    {

        echo "
";

        echo "".$row['ip']."	";

        echo "".$row['reason']."	";

        echo "".$row['note']."	";

        echo "".date("d/m/Y @ H:i", $row['created'])."	";

        if ($row['expires'] != 0) {

            echo "".date("d/m/Y @ H:i", $row['expires'])."	";

        } else {

            echo "never	";

        }

        if ($row['boards']=="%") {

            echo "All boards	";

        } else {

            echo "".$row['boards']."	";

        }

        if ($delete) {

            echo "".$lang['mod/delete']."	";

        } else {

            echo "	";

        }

        if ($logs) {

            echo "".$row['username']."	";

        }

        echo "
";

    }

    ?>

    <?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("range.view");

$delete = $mitsuba->admin->checkPermission("bans.delete");

$logs = $mitsuba->admin->checkPermission("logs.view");

if ((isset($_GET['del'])) && ($_GET['del']==1)) {

    $mitsuba->admin->reqPermission("range.delete");

    if ((!empty($_GET['b'])) && (is_numeric($_GET['b']))) {

        $conn->query("DELETE FROM rangebans WHERE id=".$_GET['b']);

    }

}

    ?>

    <?php $mitsuba->admin->ui->startSection($lang['mod/range_bans']); ?>

    <?php echo $lang['mod/ip']; ?>

    <?php echo $lang['mod/reason']; ?>

    <?php echo $lang['mod/staff_note']; ?>

    <?php echo $lang['mod/created']; ?>

    <?php echo $lang['mod/expires']; ?>

    <?php echo $lang['mod/boards']; ?>

    <?php echo $lang['mod/delete']; ?>

    <?php

    if ($logs) { echo "".$lang['mod/staff_member']."	";
    }

    ?>

    <?php

    if ($logs) {

        $result = $conn->query("SELECT rangebans.*, users.username FROM rangebans LEFT JOIN users ON rangebans.mod_id=users.id ORDER BY created DESC LIMIT 0, 15;");

    } else {

        $result = $conn->query("SELECT * FROM rangebans ORDER BY created LIMIT 0, 15;");

    }

    while ($row = $result->fetch_assoc())

    {

        echo "
";

        echo "".$row['ip']."	";

        echo "".$row['reason']."	";

        echo "".$row['note']."	";

        echo "".date("d/m/Y @ H:i", $row['created'])."	";

        if ($row['expires'] != 0) {

            echo "".date("d/m/Y @ H:i", $row['expires'])."	";

        } else {

            echo "never	";

        }

        if ($row['boards']=="%") {

            echo "All boards	";

        } else {

            echo "".$row['boards']."	";

        }

        if ($delete) {

            echo "".$lang['mod/delete']."	";

        } else {

            echo "	";

        }

        if ($logs) {

            echo "".$row['username']."	";

        }

        echo "
";

    }

    ?>

    <?php printf($lang['mod/showing_bans'], 15); ?> <?php echo $lang['mod/show_all']; ?> <?php printf($lang['mod/show_recent'], 100); ?>

    <?php $mitsuba->admin->ui->endSection(); ?>


code:
<?php

if (!defined("IN_MOD")) {

    die("Nah, I won't serve that file to you.");

}

$mitsuba->admin->reqPermission("range.view");

$delete = $mitsuba->admin->checkPermission("bans.delete");

$logs = $mitsuba->admin->checkPermission("logs.view");

if ((!empty($_GET['c'])) && (is_numeric($_GET['c']))) {

    $mitsuba->admin->ui->startSection(sprintf($lang['mod/recent_range_bans'], $_GET['c']));

    ?>

    <?php echo $lang['mod/ip']; ?>

    <?php echo $lang['mod/reason']; ?>

    <?php echo $lang['mod/staff_note']; ?>

    <?php echo $lang['mod/created']; ?>

    <?php echo $lang['mod/expires']; ?>

    <?php echo $lang['mod/boards']; ?>

    <?php echo $lang['mod/delete']; ?>

    <?php

    if ($logs) { echo "".$lang['mod/staff_member']."	";
    }

    ?>

    <?php

    if ($logs) {

        $result = $conn->query("SELECT rangebans.*, users.username FROM rangebans LEFT JOIN users ON rangebans.mod_id=users.id ORDER BY created DESC LIMIT 0, ".$_GET['c'].";");

    } else {

        $result = $conn->query("SELECT * FROM rangebans ORDER BY created LIMIT 0, ".$_GET['c'].";");

    }

    while ($row = $result->fetch_assoc())

    {

        echo "
";

        echo "".$row['ip']."	";

        echo "".$row['reason']."	";

        echo "".$row['note']."	";

        echo "".date("d/m/Y @ H:i", $row['created'])."	";

        if ($row['expires'] != 0) {

            echo "".date("d/m/Y @ H:i", $row['expires'])."	";

        } else {

            echo "never	";

        }

        if ($row['boards']=="%") {

            echo "All boards	";

        } else {

            echo "".$row['boards']."	";

        }

        if ($delete) {

            echo "".$lang['mod/delete']."	";

        } else {

            echo "	";

        }

        if ($logs) {

            echo "".$row['username']."	";

        }

        echo "
";

    }

    ?>

    <?php $mitsuba->admin->ui->endSection(); ?>

    <?php

}

?>