<?php

require_once "lib/pullurl.php";
$license = join("", pullurl("http://creativecommons.org/licenses/by-nc-sa/2.0/legalcode"));
$license = str_replace("\n", "", $license);
$license = str_replace("\r", "", $license);
$shortlicense = array();
preg_match_all("'<body[^>]*>(.*)</body>'", $license, $shortlicense);
$license = $shortlicense[1][0];
output("`@`c`bLicense Agreement`b`c`0");
output("`2Before continuing, you must read and understand the following license agreement.`0`n`n");
if (md5($license) == "484d213db9a69e79321feafb85915ff1") {
    rawoutput("<div style='width: 100%; height; 350px; max-height: 350px; overflow: auto; color: #FFFFFF; background-color: #000000; padding: 10px;'>");
    rawoutput("<base href='http://creativecommons.org/licenses/by-nc-sa/2.0/legalcode'>");
    rawoutput("<base target='_blank'>");
    rawoutput($license);
    rawoutput("</div>");
    rawoutput("<base href='http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "'>");
    rawoutput("<base target='_self'>");
} else {
    output("`^Warning, the Creative Commons license has changed, or could not be retrieved from the Creative Commons server.");
    output("You should check with the game authors to ensure that the below license agrees with the license under which it was released.");
    output("The license may be referenced at <a target='_blank' href='http://creativecommons.org/licenses/by-nc-sa/2.0/legalcode'>the Creative Commons site</a>.", true);
}
$license = join("", file("LICENSE.txt"));
$license = preg_replace("/[^\na-zA-Z0-9!?.,;:'\"\\/\\()@ -\\]\\[]/", "", $license);
$licensemd5s = array('e281e13a86d4418a166d2ddfcd1e8032' => true);
if (isset($licensemd5s[md5($license)])) {
    // Reload it so we get the right line breaks, etc.
    //$license = file("LICENSE.txt");
    $license = htmlentities($license, ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
 output("If you've been banned already, chances are you know why, and chances are we've got no interest in removing the ban.");
 output("We provide this free of charge, at the expense of considerable bandwidth and server load, so if you've had the gall to abuse our charity, don't expect it to be won back very easily.`n`n");
 output("If you are well behaved, we don't have an interest in blocking you from this listing. `0`n");
 rawoutput("<table border='0' cellpadding='1' cellspacing='0'>");
 rawoutput("<tr class='trhead'><td>");
 output("Server");
 rawoutput("</td><td>");
 output("Version");
 rawoutput("</td>");
 require_once "lib/pullurl.php";
 $u = getsetting("logdnetserver", "http://logdnet.logd.com/");
 if (!preg_match("/\\/\$/", $u)) {
     $u = $u . "/";
     savesetting("logdnetserver", $u);
 }
 $servers = pullurl($u . "logdnet.php?op=net");
 if (!$servers) {
     $servers = array();
 }
 $i = 0;
 while (list($key, $val) = each($servers)) {
     $row = unserialize($val);
     // If we aren't given an address, continue on.
     if (substr($row['address'], 0, 7) != "http://" && substr($row['address'], 0, 8) != "https://") {
         continue;
     }
     // Give undescribed servers a boring descriptionn
     if (trim($row['description']) == "") {
         $row['description'] = "Another boring and undescribed LotGD server";
     }
     // Strip out any embedded html.
session_start();
//unset($_SESSION['logdnet']);
//session_register("session");
if (isset($_GET['op']) && $_GET['op'] == "register") {
    if (!isset($_SESSION['logdnet']) || !isset($_SESSION['logdnet']['']) || $_SESSION['logdnet'][''] == "") {
        //register with LoGDnet
        $a = $_GET['a'];
        $c = $_GET['c'];
        $l = $_GET['l'];
        $d = $_GET['d'];
        $e = $_GET['e'];
        $v = $_GET['v'];
        $u = $_GET['u'];
        $url = $u . "logdnet.php?" . "addy=" . rawurlencode($a) . "&desc=" . rawurlencode($d) . "&version=" . rawurlencode($v) . "&admin=" . rawurlencode($e) . "&c=" . $c . "&v=2" . "&l=" . $l . "";
        require_once "../lib/pullurl.php";
        $info = @pullurl($url);
        if ($info !== false) {
            $info = base64_decode(join("", $info));
            $_SESSION['logdnet'] = unserialize($info);
            $_SESSION['logdnet']['when'] = date("Y-m-d H:i:s");
            $_SESSION['logdnet']['note'] = "\n// registered with logdnet successfully";
            $_SESSION['logdnet']['note'] .= "\n// " . $url;
        } else {
            $_SESSION['logdnet']['when'] = date("Y-m-d H:i:s");
            $_SESSION['logdnet']['note'] = "\n// There was trouble registering on logdnet.";
            $_SESSION['logdnet']['note'] .= "\n// " . $url;
        }
    } else {
        $info = true;
    }
    if ($info !== false) {
         output_notl("`b");
         output("For namespace '%s' the pull was `\$ not`0 successful (missing file)", $namespace);
         output_notl("`b`n`n");
     }
 }
 $sql = "SELECT modulename FROM " . db_prefix("modules") . ";";
 $result = db_query($sql);
 $listing = array("about", "armor", "badnav", "badword", "bank", "battle", "bio", "buffs", "claneditor", "clans", "commentary", "common", "configuration", "create", "creatures", "donation", "dragon", "events", "faq", "fightnav", "forest", "gardens", "graveyard", "gypsy", "healer", "hof", "home", "inn", "installer", "lib-commentary", "lib-pageparts", "list", "lodge", "logdnet", "login", "mail", "masters", "moderate", "modulemanage", "motd", "mountname", "mounts", "nav", "newday", "paylog", "petition", "prefs", "pvp", "rawsql", "referers", "referral", "retitle", "rock", "shades", "showform", "skill", "skills", "source", "stables", "stats", "superuser", "taunt", "train", "translatortool", "untranslated", "user", "village", "weapon");
 while ($row = db_fetch_assoc($result)) {
     array_push($listing, "module-" . $row['modulename']);
 }
 asort($listing);
 if (httppost('datecheck')) {
     $listing2 = $listing;
     while (list($key, $val) = each($listing2)) {
         $file = pullurl($chosenpath . $val . ".sql");
         if (strstr($file[0], "Verified")) {
             set_module_objpref("namespaces", 2, $val, substr($file[0], 0, 10), "translationwizard");
         } else {
             output_notl("`b");
             output("For namespace '%s' the pull was `\$ not`0 successful (missing file)", $val);
             output_notl("`b`n`n");
         }
     }
 }
 output("If you want to see what files we have currently on the server, visit `\$ %s`0", $lookuppath);
 output_notl("`n");
 rawoutput("<input type='submit' name='datecheck' value='" . translate_inline("Pull all dates") . "' class='button'>");
 output("If you pull only for those in the untranslated, you don't need to check anything.");
 output_notl("`n");
 output("Moduledate refers to the date in the file you pulled. That means when it was changed last as you pulled it.");