function drpap_run()
{
    global $session;
    $c = get_module_pref("count");
    // if ($c){
    // if (is_module_active("medals")){
    // require_once "modules/medals.php";
    // medals_award_medal("sexchange","Gender Reassignment","This player switched their gender at Doc Paprika's office!","medal_museumquest.png");
    // }
    // }
    $t = get_module_setting("times");
    $gold = get_module_setting("gold");
    $gems = get_module_setting("gems");
    $op = httpget('op');
    $dec = httpget('dec');
    $gen = translate_inline($session['user']['sex'] == 0 ? "sir" : "madam");
    $ngen = translate_inline($session['user']['sex'] == 1 ? "sir" : "madam");
    $g = translate_inline($gems == 1 ? "Gem" : "Gems");
    page_header("Dr Paprika's Office");
    switch ($op) {
        case "enter":
            if ($c < $t) {
                output("`3Subtle tunes play in the background; classic rock.");
                output("In the Center of the waiting room, is a large table - covered with out-of-date magazines.");
                output("A beautiful receptionist looks at you, across a pane of glass.");
                output("She glances at you, and waves, \"`%Hello there %s.", $gen);
                output("Are you here to see `QDr Paprika`%?");
                output("He is the only doctor in %s, excelling in the field of `\$Gender Changes`%.`3\"", get_module_setting("paploc"));
                addnav("Where to?");
                addnav("Dr Paprika's Room", "runmodule.php?module=drpap&op=office");
                addnav("Waiting Room", "runmodule.php?module=drpap&op=waitroom");
            } else {
                output("`3\"`%I am sorry %s, but you have already had %s `\$Gender Changes`%.", $gen, $c);
                output("Since the limit is %s, we are able to deny you service now.", $t);
                output("Please take care.`3\"");
                if (get_module_setting("reset") == 1) {
                    output("`3The receptionist adds, \"`%If you come back with some `@dragon's blood`%, we might be able to work something out.`3\"");
                }
            }
            break;
        case "office":
            if ($dec != "yes") {
                if ($session['user']['gold'] >= $gold && $session['user']['gems'] >= $gems) {
                    output("`3You walk in a white room, very white.");
                    output("A long operating table, is accompanied by a small swivel chair.");
                    output("Strutting out from the shadows, `QDr Paprika `3appears, and shakes your hand.");
                    output("\"`\$So, you wish to have a `%Gender Change `\$operation?`3\"");
                    addnav("Choices");
                    addnav("Yes", "runmodule.php?module=drpap&op=office&dec=yes");
                    addnav("Return to the Waiting Room", "runmodule.php?module=drpap&op=waitroom");
                } else {
                    output("`QDr Paprika `3stares at your blankly.");
                    output("\"`\$I am sorry %s, but you do not have the proper funds for this operation.`3\"", $gen);
                    output("`QDr Paprika `3points to a sign, stating \"`%Gender Operations cost `^%s `%Gold and `5%s `%%s.`3\"", $gold, $gems, $g);
                }
            } else {
                output("`QDr Paprika `3nods and begins to prep himself.");
                output("\"`\$Please lay down on the operating table... I will be with your shortly...`3\"");
                output("`QDr Paprika `3hovers over you and then pulls out a tiny bottle of ether.");
                output("He presses it to your nose and instructs, \"`\$Please count to One Hundred...`3\"");
                output("You begin to count...`n`n");
                for ($i = 1; $i <= $session['user']['level']; $i++) {
                    output("%s...`n", $i);
                }
                if ($session['user']['sex'] == 0) {
                    $session['user']['sex'] = 1;
                } else {
                    $session['user']['sex'] = 0;
                }
                $c++;
                set_module_pref("count", $c);
                $session['user']['gold'] -= $gold;
                $session['user']['gems'] -= $gems;
                require_once "lib/titles.php";
                $newtitle = get_dk_title($session['user']['dragonkills'], $session['user']['sex']);
                require_once "lib/names.php";
                $newname = change_player_title($newtitle);
                $session['user']['title'] = $newtitle;
                $session['user']['name'] = $newname;
                output("`nYou awaken hours later, your muscles shuddering.");
                output("You grasp the mirror to your side, and then look at yourself.");
                output("Surprisingly, you are now a healthy looking %s.", $ngen);
                output("You stand quickly, and shake `QDr Paprika's `3hand, thanking him profusely.");
                output("Taking up your clothes, you strut out from the office, smiling happily.");
            }
            break;
        case "waitroom":
            output("`3All around you, people are sitting.");
            output("Some are thumbing through magazines, whilst others are tapping their feet in anticipation.`n`n");
            require_once "lib/commentary.php";
            addcommentary();
            viewcommentary("drpap", "Nervous People are Around", 15, "says");
            addnav("Return to Lobby", "runmodule.php?module=drpap&op=enter");
            break;
    }
    addnav("Leave");
    villagenav();
    page_footer();
}
コード例 #2
0
 $session['user']['dragonage'] = $session['user']['age'];
 if ($session['user']['dragonage'] < $session['user']['bestdragonage'] || $session['user']['bestdragonage'] == 0) {
     $session['user']['bestdragonage'] = $session['user']['dragonage'];
 }
 $number = db_num_rows($result);
 for ($i = 0; $i < $number; $i++) {
     $row = db_fetch_assoc($result);
     if (array_key_exists($row['Field'], $nochange) && $nochange[$row['Field']]) {
     } elseif ($row['Field'] == "location") {
         $session['user'][$row['Field']] = getsetting("villagename", LOCATION_FIELDS);
     } else {
         $session['user'][$row['Field']] = $row["Default"];
     }
 }
 $session['user']['gold'] = getsetting("newplayerstartgold", 50);
 $newtitle = get_dk_title($session['user']['dragonkills'], $session['user']['sex']);
 $restartgold = $session['user']['gold'] + getsetting("newplayerstartgold", 50) * $session['user']['dragonkills'];
 $restartgems = 0;
 if ($restartgold > getsetting("maxrestartgold", 300)) {
     $restartgold = getsetting("maxrestartgold", 300);
     $restartgems = max(0, $session['user']['dragonkills'] - getsetting("maxrestartgold", 300) / getsetting("newplayerstartgold", 50) - 1);
     if ($restartgems > getsetting("maxrestartgems", 10)) {
         $restartgems = getsetting("maxrestartgems", 10);
     }
 }
 $session['user']['gold'] = $restartgold;
 $session['user']['gems'] += $restartgems;
 if ($flawless) {
     $session['user']['gold'] += 3 * getsetting("newplayerstartgold", 50);
     $session['user']['gems'] += 1;
 }
 }
 if (!$blockaccount) {
     $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE login='******'";
     $result = db_query($sql);
     if (db_num_rows($result) > 0) {
         output("`\$Error`^: Someone is already known by that name in this realm, please try again.");
         $op = "";
     } else {
         $sex = (int) httppost('sex');
         // Inserted the following line to prevent hacking
         // Reported by Eliwood
         if ($sex != SEX_MALE) {
             $sex = SEX_FEMALE;
         }
         require_once "lib/titles.php";
         $title = get_dk_title(0, $sex);
         if (getsetting("requirevalidemail", 0)) {
             $emailverification = md5(date("Y-m-d H:i:s") . $email);
         }
         $refer = httpget('r');
         if ($refer > "") {
             $sql = "SELECT acctid FROM " . db_prefix("accounts") . " WHERE login='******'";
             $result = db_query($sql);
             $ref = db_fetch_assoc($result);
             $referer = $ref['acctid'];
         } else {
             $referer = 0;
         }
         $dbpass = "";
         if (substr($pass1, 0, 5) == "!md5!") {
             $dbpass = md5(substr($pass1, 5));
} elseif ($op == "reset") {
    require_once "lib/titles.php";
    require_once "lib/names.php";
    output("`^Rebuilding all titles.`0`n`n");
    $sql = "SELECT name,title,dragonkills,acctid,sex,ctitle FROM " . db_prefix("accounts");
    $result = db_query($sql);
    $number = db_num_rows($result);
    for ($i = 0; $i < $number; $i++) {
        $row = db_fetch_assoc($result);
        $oname = $row['name'];
        $dk = $row['dragonkills'];
        $otitle = $row['title'];
        $dk = (int) $row['dragonkills'];
        if (!valid_dk_title($otitle, $dk, $row['sex'])) {
            $sex = translate_inline($row['sex'] ? "female" : "male");
            $newtitle = get_dk_title($dk, (int) $row['sex']);
            $newname = change_player_title($newtitle, $row);
            $id = $row['acctid'];
            if ($oname != $newname) {
                output("`@Changing `^%s`@ to `^%s `@(%s`@ [%s,%s])`n", $oname, $newname, $newtitle, $dk, $sex);
                if ($session['user']['acctid'] == $row['acctid']) {
                    $session['user']['title'] = $newtitle;
                    $session['user']['name'] = $newname;
                } else {
                    $sql = "UPDATE " . db_prefix("accounts") . " SET name='" . addslashes($newname) . "', title='" . addslashes($newtitle) . "' WHERE acctid='{$id}'";
                    db_query($sql);
                }
            } elseif ($otitle != $newtitle) {
                output("`@Changing only the title (not the name) of `^%s`@ `@(%s`@ [%s,%s])`n", $oname, $newtitle, $dk, $sex);
                if ($session['user']['acctid'] == $row['acctid']) {
                    $session['user']['title'] = $newtitle;
function homepage_run()
{
    require_once "common.php";
    require_once "lib/is_email.php";
    require_once "lib/checkban.php";
    require_once "lib/http.php";
    page_header("Welcome to Improbable Island");
    global $session;
    $r = httpget('r');
    $name = sanitize_name(getsetting("spaceinname", 0), httppost('name'));
    $pass1 = httppost('pass1');
    $pass2 = httppost('pass2');
    $sex = httppost('gender');
    $email = httppost('email');
    $passlen = (int) httppost("passlen");
    if (substr($pass1, 0, 5) != "!md5!" && substr($pass1, 0, 6) != "!md52!") {
        $passlen = strlen($pass1);
    }
    if (!$sex) {
        $outputgender = "man";
    } else {
        $outputgender = "woman";
    }
    switch (httpget('op')) {
        case "changeskin":
            $skin = httpget('skin');
            if ($skin > "") {
                setcookie("template", $skin, strtotime("+45 days"));
                $_COOKIE['template'] = $skin;
            }
            redirect("index.php?r={$r}", "Home page module changing skin");
            break;
        case "gamecredits":
            page_header("Game Credits");
            output("Improbable Island's plot, characters, Stamina system, Item system, ScrapBots system, Races, Implants, Mounts and probably a few other things were created by Dan Hall, AKA Admin CavemanJoe.`nMany monsters were written by Improbable Island's players.`nImprobable Island runs on a modified version of Legend of the Green Dragon 1.1.1, DragonPrime Edition, which was created by the good folks at dragonprime.com.`nThe DragonPrime Edition was based on the original Legend of the Green Dragon, created by Eric Stevens and J.T. Traub as a homage to Legend of the Red Dragon by Seth Able.`n`nPut simply, Improbable Island is a hodgepodged Frankenstein of a game, but we get by.`n`nThe source code to Legend of the Green Dragon 1.1.1 +DP is available at dragonprime.net.`nThe source code to the most recent version of Legend of the Green Dragon written by Stevens and Traub (upon which the DragonPrime edition is based) is available at lotgd.net.`nThe source code of Improbable Island will be made available on Improbable Labs shortly - for now, it is available on request.`n`nFor more information about Improbable Island and Legend of the Green Dragon, check out the links to the left.");
            addnav("Further Reading");
            addnav("Module Credits", "about.php?op=listmodules&r=" . $r);
            addnav("Creative Commons License Info", "about.php?op=license&r=" . $r);
            addnav("Original Legend of the Green Dragon \"About\" page", "about.php?r=" . $r);
            addnav("Back to the Home Page");
            addnav("Back", "home.php?r=" . $r);
            break;
        case 0:
            $tripfilter = 0;
            $sname = strtolower($name);
            if (substr_count($sname, "nigger") || substr_count($sname, "c**t") || substr_count($sname, "dick") && !substr_count($sname, "dicke") || substr_count($sname, "f****t") || substr_count($sname, "v****a") || substr_count($sname, "pussy") || substr_count($sname, "shit") || substr_count($sname, "wank") || substr_count($sname, "bollocks") || substr_count($sname, "clitoris") || substr_count($sname, "f**k") || substr_count($sname, "d***o") || substr_count($sname, "t**s") || substr_count($sname, "piss") || substr_count($sname, "penis")) {
                output("The gatekeeper's biro stops mid-scrawl.  He looks up at you.  \"`6Seriously?`0\" he asks.  \"`6You're gonna walk into a pub, are you, and espy some sweet young thing who puts your heart all aflutter, and when they ask you your name, you're gonna say \"My name's %s, what's yours?\"  Is that right?`0\"`n`nYou shuffle your feet sheepishly.  Let's try this again.`n`n", $name);
                $redoform = 1;
            }
            //todo: redirect when numbers appear in name
            $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE login='******'";
            $result = db_query($sql);
            if (db_num_rows($result) > 0) {
                output("\"`6Oh, dear...`0\" says the gatekeeper.  \"`6See, we've already got a %s drafted in, here.`0\"`n`nYou stare at him for a moment.  \"`#What in the hell difference does `ithat`i make?!`0\"`n`n\"`6Well, you see, it's easier if everyone has different names, and, well, the computer that handles these forms...`0\" he shrugs.  \"`6It's not particularly bright.`0\"`n`nYou nod.  Computers haven't been terribly bright since the EMP wars.`n`n\"`6Just put down any old thing,`0\" says the gatekeeper.  \"`6I doubt it'll matter much.`0\"`n`n", $name);
                $redoform = 1;
            } else {
                if (strlen($name) < 3) {
                    output("\"`6Oh, dear...`0\" says the gatekeeper.  \"`6I'm afraid that name's just too short.`0\"`n`nYou stare at him for a moment.  \"`#What in the hell difference does `ithat`i make?!`0\"`n`n\"`6Well, you see, the computer that handles these forms...`0\" he shrugs.  \"`6It's not particularly bright.`0\"`n`nYou nod.  Computers haven't been terribly bright since the EMP wars.`n`n\"`6Just put down any old thing,`0\" says the gatekeeper.  \"`6I doubt it'll matter much.`0\"`n`n");
                    $redoform = 1;
                } else {
                    if (strlen($name) > 25) {
                        output("\"`6Oh, dear...`0\" says the gatekeeper.  \"`6I'm afraid that name's just too long.`0\"`n`nYou stare at him for a moment.  \"`#What in the hell difference does `ithat`i make?!`0\"`n`n\"`6Well, you see, the computer that handles these forms...`0\" he shrugs.  \"`6It's not particularly bright.`0\"`n`nYou nod.  Computers haven't been terribly bright since the EMP wars.`n`n\"`6Just put down any old thing,`0\" says the gatekeeper.  \"`6I doubt it'll matter much.`0\"`n`n");
                        $redoform = 1;
                    }
                }
            }
            if ($redoform) {
                rawoutput("<form action='runmodule.php?module=homepage&op=0&r={$r}' method='POST'\">\"<span class=\"colLtCyan\">Well then, I suppose you can call me <input name='name' id=\"name\" accesskey='u' size='12'>.</span>\"  Like you're gonna give him your real name anyway.");
                rawoutput("<br /><div align=\"center\"><input type='submit' value='Carry On' class='button'></div><br /><br /></form>");
                addnav("", "runmodule.php?module=homepage&op=0&r=" . $r);
            } else {
                output("The gatekeeper smiles.  \"`6Okay, %s - now, if you don't mind my asking, are you over eighteen?`0\"`n`n", $name);
                output("You grimace.  \"`#Mate, I've been drafted into some sort of war.  If I'm under eighteen, `isomeone's`i in trouble.`0\"`n`n\"`6That as may be,\"`0 says the gatekeeper, \"`6I've got to ask anyway, before we go any further.  Just to make sure.`0\"`n`n`n");
                rawoutput("<table width=80% align=center style=\"border: 1px solid #990000;\"><tr><td class=\"trlight\">");
                output("`c`\$`bWARNING`b`c`7Although most folks would consider Improbable Island to be work-safe by virtue of it being entirely text-based, I should warn you that you probably wouldn't want to invite the vicar over for tea and scones while playing.`n`nImprobable Island contains `bfoetid Midget Brothels`b and other rather adult (but very silly) situations, and is intended for equally silly `badults`b.  If you're not an adult yet, why not check out Kingdom of Loathing, zOMG, Legends of Zork, Puzzle Pirates, Adventure Quest - there's loads of other browser games, really.`n`n");
                output("And if you `iare`i an adult, and want to carry on - knowing that you're about to be subjected to a barrage of sex, drugs and sausage rolls - by all means, continue with the story and have fun.`0");
                rawoutput("</td></tr></table>");
                output("`n`nYou realise you've been staring off into space for a moment, and you blink a couple of times.  \"`#Sorry, I think I spaced out for a minute there.`0\"");
                rawoutput("<form action='runmodule.php?module=homepage&op=1&r={$r}' method='POST'\">");
                rawoutput("<input type='hidden' name='name' value=\"{$name}\">");
                rawoutput("<br /><div align=\"center\"><input type='submit' value='Yes, I am indeed over eighteen.  Now how about some pants?' class='button'></div></form>");
                addnav("", "runmodule.php?module=homepage&op=1&r=" . $r);
            }
            break;
        case 1:
            output("\"`6Yes, yes, we'll sort you out with some pants in just a minute, %s, don't you worry.`0\"  He reaches down out of sight, and pulls up a sheet of paper and a pen.  You see the words \"CONTESTANT REGISTRATION AND PANTS REQUEST FORM 3A\" printed at the top of the page.  Hell, maybe we're getting somewhere.`n`n\"`6Now, might I ask your gender?`0\"`n`nYou hesitate, dumbstruck.  \"`#I'm stood here `istark naked`i, right in front of you.`0\"`n`n\"`6And thanks to all those bloody Zap grenades going off all the time, all I see is a person-shaped blur who won't be getting any pants until they help me fill out this bloody form!`0\" replies the gatekeeper.`n`n", $name);
            rawoutput("<form action='runmodule.php?module=homepage&op=2&r={$r}' method='POST'\"><input type='radio' name='gender' value='0' checked>\"<span class=\"colLtCyan\"><em>Male</em>, thank you very much.</span>\"<br /><input type='radio' name='gender' value='1'>\"<span class=\"colLtCyan\"><em>Female</em>, thank you very much.</span>\"");
            rawoutput("<input type='hidden' name='name' value=\"{$name}\">");
            rawoutput("<br /><div align=\"center\"><input type='submit' value='And is my voice really that androgynous?' class='button'></div><br /><br /></form>");
            addnav("", "runmodule.php?module=homepage&op=2&r=" . $r);
            break;
        case 2:
            output("\"`6No, %s, you `ido`i sound like a %s, but I like a little joke.`0\" the gatekeeper grins.  ", $name, $outputgender);
            output("\"`6Now, can I just take your E-mail address, please?`0\"`n`nMentally, you file the man under \"Nutters.\"  \"`#Hell, we only got `itelevision`i back about a year ago!  You know full well that computers don't work any more.`0\"`n`n\"`6And they haven't done since the EMP bombings years back, yes.  That's the interesting thing -`0\" he leans forward and lowers his voice.  \"`6I've heard tell that there `iare`i some working computers here.  Proper `isilicon`i ones, not these silly relay-and-vacuum-tube monstrosities we use today, where you think you're rich if you've got sixteen bytes of RAM to play with.  We're talking `iterabytes`i, here!  Just `iimagine`i what we could do with that sort of power!`0\"`n`nYou remember what you did with those resources when you had them, only a few years ago.  You played silly browser games on the Internet.`n`n\"`6Anyway - it's an old, old form, from back in the day when it mattered.  Let's take your E-mail address, so we can have something in the space.`0\"  He grins.  \"`6It's not like I'm going to send you any spam, now, is it?`0\"`n`n");
            rawoutput("<form action='runmodule.php?module=homepage&op=3&r={$r}' method='POST'\">\"<span class=\"colLtCyan\">Fine - as far as I remember, it's <input name='email' id=\"email\" accesskey='e' size='25'>.</span>\"");
            rawoutput("<input type='hidden' name='name' value=\"{$name}\">");
            rawoutput("<input type='hidden' name='gender' value=\"{$sex}\">");
            rawoutput("<br /><div align=\"center\"><input type='submit' value='NOW may I have some pants?' class='button'></div></form>");
            rawoutput("<br /><br /><table width=80% align=center style=\"border: 1px solid #990000;\"><tr><td class=\"trlight\">");
            output("`7He ain't kidding - Improbable Island doesn't spam.  Your E-mail address is used to recover your password if you forget it, and (optionally) to let you know if someone sends you a message in-game - that's it.  We don't use it for anything else, and we never let anyone else see it.`n`nOr, you can continue without entering an E-mail address - but you won't be notified of anything, and you won't be able to recover your password if you lose it!`n");
            rawoutput("<form action='runmodule.php?module=homepage&op=3&override=1&r={$r}' method='POST'\"><input name='email' type='hidden' value='not given'>");
            rawoutput("<input type='hidden' name='name' value=\"{$name}\">");
            rawoutput("<input type='hidden' name='gender' value=\"{$sex}\">");
            rawoutput("<br /><div align=\"center\"><input type='submit' value='Continue without an E-mail address' class='button'></div></form>");
            rawoutput("</td></tr></table>");
            addnav("", "runmodule.php?module=homepage&op=3&override=1&r=" . $r);
            break;
        case 3:
            if ($sexdisplay = "Male") {
                $formalgenderdisplay = "man";
            } else {
                $formalgenderdisplay = "lady";
            }
            if (httpget('override') == 1) {
                output("\"`6Fair enough, then, fair enough - I guess it's pretty pointless asking for an E-mail address when they're impossible to use anyway.`0\"`n`n");
                $carryon = 1;
            } else {
                //validate E-mail
                if (!is_email($email)) {
                    output("The gatekeeper frowns.  \"`6That certainly doesn't `isound`i like an E-mail address.  Are you sure that's right?`0\"`n`nLet's try that again.`n");
                } else {
                    //check for duplicates
                    $sql = "SELECT login FROM " . db_prefix("accounts") . " WHERE emailaddress='{$email}'";
                    $result = db_query($sql);
                    if (db_num_rows($result) > 0) {
                        output("The gatekeeper frowns.  \"`6Are you taking the mick, my good %s?  That E-mail is already in my book, here.  You can only sign up once, you know.`0\"`n`nLet's try that again.`n", $formalgenderdisplay);
                    } else {
                        //email is good, request password
                        output("The gatekeeper grins. \"`6I'm sure if you find those computers, you'll be using that address again soon.`0\"`n`n");
                        $carryon = 1;
                    }
                }
            }
            if ($carryon) {
                rawoutput("<script language='JavaScript' src='lib/md5.js'></script>");
                rawoutput("<script language='JavaScript'>\r\n\t\t\t\t<!--\r\n\t\t\t\tfunction md5pass(){\r\n\t\t\t\t\t// encode passwords\r\n\t\t\t\t\tvar plen = document.getElementById('passlen');\r\n\t\t\t\t\tvar pass1 = document.getElementById('pass1');\r\n\t\t\t\t\tplen.value = pass1.value.length;\r\n\r\n\t\t\t\t\tif(pass1.value.substring(0, 5) != '!md5!') {\r\n\t\t\t\t\t\tpass1.value = '!md5!'+hex_md5(pass1.value);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar pass2 = document.getElementById('pass2');\r\n\t\t\t\t\tif(pass2.value.substring(0, 5) != '!md5!') {\r\n\t\t\t\t\t\tpass2.value = '!md5!'+hex_md5(pass2.value);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\t\t\t\t//-->\r\n\t\t\t\t</script>");
                if (httpget('override')) {
                    rawoutput("<form action='runmodule.php?module=homepage&op=4&override=1&r={$r}' method='POST' onSubmit=\"md5pass();\">");
                } else {
                    rawoutput("<form action='runmodule.php?module=homepage&op=4&r={$r}' method='POST' onSubmit=\"md5pass();\">");
                }
                rawoutput("<input type='hidden' name='passlen' id='passlen' value='0'>");
                rawoutput("<input type='hidden' name='name' value=\"{$name}\">");
                rawoutput("<input type='hidden' name='gender' value=\"{$sex}\">");
                rawoutput("<input type='hidden' name='email' value=\"{$email}\">");
                output("You hear a rustling in the bushes behind you, and turn to look.  Branches sway a couple of feet above head-height - there's something there.`n`nYou're suddenly even more aware that you're naked and unarmed.`n`nYou turn back to the gatekeeper.  \"`#Is this going to take long?`0\"`n`n\"`6No, no, we're nearly done now.`0\"  He reaches down beneath his counter, and brings up a stack of shiny silver coins.  \"`6Here's eighty Requisition tokens to get you started.`0\"`n`nYou consider asking him where the hell he thinks you're going to keep them, but a low `4`igrowling`i`0 sound changes your mind very quickly.`n`n\"`#Let me in.  Forget the pants, just let me in.`0\"`n`n\"`6One moment, sunshine, one moment.  I need a password from you.`0\"`n`n\"`#You're kidding me!  Did you `ihear`i that?!`0\"`n`n\"`6Yes, I heard it, and you'll get inside faster if you listen to me.  You need to make up a password - at least four characters in length.  I know, it sounds like a silly thing to ask, but there's a very good reason for it - you see...`0\"  The growling intensifies, and you look back towards the jungle.`n`nThere's a face.  It's looking at you from between the very leafy branches of a tree.  It's eight feet off the ground and shaped like a gas mask, its eyes as big as fists and deep, bright orange, shining against its jet black carapace.`n`n\"`#Don't care,`0\" you say quietly.  \"`#Really, really don't care.  Just put down ");
                rawoutput("<input type='password' name='pass1' id='pass1'>");
                output(".`0\"`n`nThe gatekeeper scribbles on his form.  \"`6Sorry, just run that past me again?`0\"`n`n\"`#I said ");
                rawoutput("<input type='password' name='pass2' id='pass2'>");
                output("!`0\"`n`n");
                rawoutput("<div align=\"center\"><input type='submit' value='Now let me in, damn it!' class='button'></div></form>");
            } else {
                //output the E-mail form again
                rawoutput("<form action='runmodule.php?module=homepage&op=3&r={$r}' method='POST'\">\"<span class=\"colLtCyan\">Fine - as far as I remember, it's <input name='email' id=\"email\" accesskey='e' size='25'>.</span>\"");
                rawoutput("<input type='hidden' name='name' value=\"{$name}\">");
                rawoutput("<input type='hidden' name='gender' value=\"{$sex}\">");
                rawoutput("<br /><div align=\"center\"><input type='submit' value='NOW may I have some pants?' class='button'></div></form>");
                rawoutput("<br /><br /><table width=80% align=center style=\"border: 1px solid #990000;\"><tr><td class=\"trlight\">");
                output("`7He ain't kidding - Improbable Island doesn't spam.  Your E-mail address is used to recover your password if you forget it, and (optionally) to let you know if someone sends you a message in-game - that's it.  We don't use it for anything else, and we never let anyone else see it.`n`nOr, you can continue without entering an E-mail address - but you won't be notified of anything, and you won't be able to recover your password if you lose it!`n");
                rawoutput("<form action='runmodule.php?module=homepage&op=3&override=1&r={$r}' method='POST'\"><input name='email' type='hidden' value='Not Given'>");
                rawoutput("<input type='hidden' name='name' value=\"{$name}\">");
                rawoutput("<input type='hidden' name='gender' value=\"{$sex}\">");
                rawoutput("<br /><div align=\"center\"><input type='submit' value='Continue without an E-mail address' class='button'></div></form>");
                rawoutput("</td></tr></table>");
                addnav("", "runmodule.php?module=homepage&op=3&override=1&r=" . $r);
            }
            break;
        case 4:
            output("`0The thing steps out from behind the trees.  Its chitinous body is thin, shiny, and angular.  There are no hands or feet; its legs and arms terminate in sharp points.  Each time it takes a step, it leaves a deep, round piercing in the ground.  You back up against the gatekeeper's hut, unable to take your eyes off the beast.`n`n");
            if ($passlen <= 3) {
                output("\"`6I'm not sure you heard me right, mate,`0\" says the gatekeeper quietly from behind you.  \"`6I need four characters or more.  No rush.`0\"`n`n");
                $tryagain = true;
            }
            if ($pass1 != $pass2) {
                output("\"`6Sorry, mate, I think I heard two different things,`0\" says the gatekeeper quietly from behind you.  \"`6Wanna repeat that?  No rush.`0\"`n`n");
                $tryagain = true;
            }
            if ($tryagain) {
                rawoutput("<script language='JavaScript' src='lib/md5.js'></script>");
                rawoutput("<script language='JavaScript'>\r\n\t\t\t\t<!--\r\n\t\t\t\tfunction md5pass(){\r\n\t\t\t\t\t// encode passwords\r\n\t\t\t\t\tvar plen = document.getElementById('passlen');\r\n\t\t\t\t\tvar pass1 = document.getElementById('pass1');\r\n\t\t\t\t\tplen.value = pass1.value.length;\r\n\r\n\t\t\t\t\tif(pass1.value.substring(0, 5) != '!md5!') {\r\n\t\t\t\t\t\tpass1.value = '!md5!'+hex_md5(pass1.value);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar pass2 = document.getElementById('pass2');\r\n\t\t\t\t\tif(pass2.value.substring(0, 5) != '!md5!') {\r\n\t\t\t\t\t\tpass2.value = '!md5!'+hex_md5(pass2.value);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\t\t\t\t//-->\r\n\t\t\t\t</script>");
                if (httpget('override')) {
                    rawoutput("<form action='runmodule.php?module=homepage&op=4&override=1&r={$r}' method='POST' onSubmit=\"md5pass();\">");
                } else {
                    rawoutput("<form action='runmodule.php?module=homepage&op=4&r={$r}' method='POST' onSubmit=\"md5pass();\">");
                }
                rawoutput("<input type='hidden' name='passlen' id='passlen' value='0'>");
                rawoutput("<input type='hidden' name='name' value=\"{$name}\">");
                rawoutput("<input type='hidden' name='gender' value=\"{$sex}\">");
                rawoutput("<input type='hidden' name='email' value=\"{$email}\">");
                output("\"`#`iSeriously, mate,`i just put down ");
                rawoutput("<input type='password' name='pass1' id='pass1'>");
                output(".`0\"`n`nThe gatekeeper scribbles on his form.  \"`6Sorry, just run that past me again?`0\"`n`n\"`#I said ");
                rawoutput("<input type='password' name='pass2' id='pass2'>");
                output("!`0\"`n`n");
                rawoutput("<div align=\"center\"><input type='submit' value='Now let me in, damn it!' class='button'></div></form>");
            } else {
                //perform a final test on all supplied information, as in create.php
                //password already checked
                $createaccount = 1;
                //check name
                $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE login='******'";
                $result = db_query($sql);
                //name exists
                if (db_num_rows($result) > 0) {
                    output("name");
                    $createaccount = 0;
                }
                //name too short or too long
                if (strlen($name) < 3 || strlen($name) > 25) {
                    output("name");
                    $createaccount = 0;
                }
                //gender not set
                if ($sex != 1 && $sex != 0) {
                    output("sex is %s", $sex);
                    $createaccount = 0;
                }
                //email
                if (!httpget('override')) {
                    //not overriden
                    //not an E-mail address
                    if (!is_email($email)) {
                        $createaccount = 0;
                        output("email not an email");
                    }
                    //already exists
                    $sql = "SELECT login FROM " . db_prefix("accounts") . " WHERE emailaddress='{$email}'";
                    $result = db_query($sql);
                    if (db_num_rows($result) > 0) {
                        $createaccount = 0;
                        output("email found already");
                    }
                }
                $args = modulehook("check-create", httpallpost());
                if (isset($args['blockaccount']) && $args['blockaccount']) {
                    $msg .= $args['msg'];
                    $createaccount = 0;
                }
                if ($createaccount) {
                    //create the account
                    require_once "lib/titles.php";
                    $title = get_dk_title(0, $sex);
                    $refer = httpget('r');
                    if ($refer > "") {
                        $sql = "SELECT acctid FROM " . db_prefix("accounts") . " WHERE login='******'";
                        $result = db_query($sql);
                        $ref = db_fetch_assoc($result);
                        $referer = $ref['acctid'];
                    } else {
                        $referer = 0;
                    }
                    $dbpass = "";
                    if (substr($pass1, 0, 5) == "!md5!") {
                        $dbpass = md5(substr($pass1, 5));
                    } else {
                        $dbpass = md5(md5($pass1));
                    }
                    $sql = "INSERT INTO " . db_prefix("accounts") . "\r\n\t\t\t\t\t\t(name, superuser, title, password, sex, login, laston, uniqueid, lastip, gold, emailaddress, emailvalidation, referer, regdate, race, location)\r\n\t\t\t\t\t\tVALUES\r\n\t\t\t\t\t\t('{$title} {$name}', '" . getsetting("defaultsuperuser", 0) . "', '{$title}', '{$dbpass}', '{$sex}', '{$name}', '" . date("Y-m-d H:i:s", strtotime("-1 day")) . "', '" . $_COOKIE['lgi'] . "', '" . $_SERVER['REMOTE_ADDR'] . "', " . getsetting("newplayerstartgold", 50) . ", '{$email}', '{$emailverification}', '{$referer}', NOW(), 'Human', 'NewHome')";
                    db_query($sql);
                    if (db_affected_rows(LINK) <= 0) {
                        output("`\$Error`^: Your account was not created for an unknown reason, please try again. ");
                    } else {
                        $sql = "SELECT acctid FROM " . db_prefix("accounts") . " WHERE login='******'";
                        $result = db_query($sql);
                        $row = db_fetch_assoc($result);
                        $args = httpallpost();
                        $args['acctid'] = $row['acctid'];
                        //insert output
                        $sql_output = "INSERT INTO " . db_prefix("accounts_output") . " VALUES ({$row['acctid']},'');";
                        db_query($sql_output);
                        //end
                        modulehook("process-create", $args);
                        //Project Wonderful Conversion Code
                        $pwcode = "<!-- Beginning of Project Wonderful conversion code: -->\r\n\t\t\t\t\t\t<!-- Conversion Track ID: 12 -->\r\n\t\t\t\t\t\t<script type=\"text/javascript\">\r\n\t\t\t\t\t\t<!--var d=document;\r\n\t\t\t\t\t\td.projectwonderful_conversion_id = \"12\";\r\n\t\t\t\t\t\td.projectwonderful_label = \"\";\r\n\t\t\t\t\t\td.projectwonderful_value = \"\";\r\n\t\t\t\t\t\t//-->\r\n\t\t\t\t\t\t</script>\r\n\t\t\t\t\t\t<script type=\"text/javascript\" \r\n\t\t\t\t\t\tsrc=\"http://www.projectwonderfuladservices.com/conversion.js\">\r\n\t\t\t\t\t\t</script>\r\n\t\t\t\t\t\t<!-- End of Project Wonderful ad code. -->";
                        rawoutput($pwcode);
                        if ($emailverification != "") {
                            $subj = translate_mail("LoGD Account Verification", 0);
                            $msg = translate_mail(array("Login name: %s `n`nIn order to verify your account, you will need to click on the link below.`n`n http://%s?op=val&id=%s `n`nThanks for playing!", $shortname, $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] == 80 ? "" : ":" . $_SERVER['SERVER_PORT']) . $_SERVER['SCRIPT_NAME'], $emailverification), 0);
                            mail($email, $subj, str_replace("`n", "\n", $msg), "From: " . getsetting("gameadminemail", "*****@*****.**"));
                            output("`4An email was sent to `\$%s`4 to validate your address.  Click the link in the email to activate your account.`0`n`n", $email);
                        } else {
                            output("\"`#`iLET ME IN!  RIGHT THE HELL NOW!`i`0\"`n`n\"`6Hmm?`0\"  The gatekeeper looks up from his forms.  \"`6Oh!  Yes, I see what you mean.  Wow!`0\" he smiles, as the beast plods closer.  \"`6That's a big one!  Geez, look at the `isize`i of 'im!`0\"`n`n\"`#`iPlease!`i`0\"`n`n\"`6Oh, oh, yes.  Of course.`0\"  He pulls a lever, and the outpost gates swing open.  \"`6In you go, then.`0\"`n`nYou tear through the gates and into the Outpost.`n`nThe gatekeeper chuckles.  \"`6Nice one, Harry!`0\"`n`nGrinning, the monster takes a bow.  \"`4It `inever`i gets old, this,`0\" it says in a broad Yorkshire accent. \"`4You in the pub later?`0\"`n`n\"`6Of course, it's darts night.`0\"`n`n\"`4Right-ho, then.  Ta-raa.`0\"`n`n\"`6See you, Harry.`0\"  The gatekeeper sits back in his chair, lights a cigarette, and carries on with his crossword.`n");
                            rawoutput("<div align='center'><form action='login.php' method='POST'>");
                            rawoutput("<input name='name' value=\"{$name}\" type='hidden'>");
                            rawoutput("<input name='password' value=\"{$pass1}\" type='hidden'>");
                            $click = translate_inline("Venture into Improbable Island!");
                            rawoutput("<input type='submit' class='button' value='{$click}'>");
                            rawoutput("</form></div>");
                            output_notl("`n");
                            savesetting("newestplayer", $row['acctid']);
                        }
                    }
                } else {
                    output("Whoops!  Did you use the back and/or forward buttons?  It looks like your account is already set up.  Head back to the home page and log yourself in!");
                    addnav("D'oh!");
                    addnav("Back to the homepage", "home.php");
                }
            }
            break;
    }
    if ($name) {
        addnav("Character Information");
        addnav(array("Character name: %s", $name), "");
        if (httpget('op') != 1 && httpget('op') != 0) {
            if ($sex) {
                addnav("Gender: Female", "");
            } else {
                if (isset($sex)) {
                    addnav("Gender: Male", "");
                }
            }
            if ($email) {
                addnav(array("E-mail address: %s", $email), "");
            }
        }
    }
    page_footer();
    return true;
}