// frames _karchan_log("node--karchan " . $readme); fputs($fp, $frames . "\n"); $readme = fgets($fp, 128); // command _karchan_log("node--karchan " . $readme); fputs($fp, $command . "\n.\n"); // retrieve cookie that is always sent when attempting a login. $contents = ""; while (!feof($fp) && $readme != ".\n") { // echo $readme; _karchan_log("node--karchan " . $readme); $readme = fgets($fp, 128); $contents .= $readme; } _karchan_log("node--karchan " . $readme); fputs($fp, "\nOk\nOk\n"); fclose($fp); if (strcasecmp(trim($command), "quit") == 0 && substr(trim($contents), 0, 2) == "Ok") { // head over to the quit page. drupal_goto("/node/26"); } else { print str_replace("game.jsp", "24", $contents); } //<div class="form-textarea-wrapper"><textarea cols="60" rows="20"></textarea></div> ?> <form method="post" action="/node/24" id="CommandForm" name="CommandForm"> <?php // <img src="/images/christmas/noel7.gif" style="vertical-align:middle"> if (!$bigtalk) {
function mudnewchar($name, $password, $password2, $title, $realname, $email, $race, $sex, $age, $length, $width, $complexion, $eyes, $face, $hair, $beard, $arms, $legs) { _karchan_log("mudnewchar " . $name); $dbhandle = mmud_connect(); // check for offline mud if (file_exists("/home/karchan/offline.txt")) { $_SESSION["karchan_errormsg"] = "Karchan offline."; return; } // aName must match [A-Z|_|a-z]{3,} if (preg_match("/([A-Z]|_|[a-z]){3,}/", $name) == 0) { $_SESSION["karchan_errormsg"] = "Karchan new username wrong."; return; } // aPassword must length > 5 if (strlen($password) < 5) { $_SESSION["karchan_errormsg"] = "Karchan new password must be at least 5 characters long."; return; } // apassword must be the same as the second entered password if ($password != $password2) { $_SESSION["karchan_errormsg"] = "Karchan passwords are not identical."; return; } // is sqlGetBan1String > 0 => user banned $banned = false; $result = mysql_query("select count(name) as count from mm_sillynamestable \n\t\twhere '" . quote_smart($name) . "' like name", $dbhandle); $myrow = mysql_fetch_array($result); if ($myrow["count"] != "0") { $banned = true; } // sqlGetBan2String > 0 => user not banned $result = mysql_query("select count(name) as count from mm_unbantable \n\twhere name = '" . quote_smart($name) . "'", $dbhandle); $myrow = mysql_fetch_array($result); if ($myrow["count"] != "0") { $banned = false; } else { // sqlGetBan4String > 0 => user banned $result = mysql_query("select count(address) as count from mm_bantable \n\t\twhere '" . quote_smart(gethostbyaddr($_SERVER['REMOTE_ADDR'])) . "' like address or \n\t\t'" . quote_smart($_SERVER['REMOTE_ADDR']) . "' like address", $dbhandle); $myrow = mysql_fetch_array($result); if ($myrow["count"] != "0") { $banned = true; } // sqlGetBan3String > 0 => user banned $result = mysql_query("select count(*) as count from mm_bannednamestable \n\t\twhere name = '" . quote_smart($name) . "'", $dbhandle); $myrow = mysql_fetch_array($result); if ($myrow["count"] != "0") { $banned = true; } } if ($banned) { $_SESSION["karchan_errormsg"] = "You have been banned."; return; } // user must NOT exist in mm_usertable $result = mysql_query("select mm_usertable.name from mm_usertable\n\t\twhere mm_usertable.name = '" . quote_smart($name) . "'", $dbhandle); if (mysql_num_rows($result) != 0) { $_SESSION["karchan_errormsg"] = "Character already exists."; return; } // make that change. $query = "insert into mm_usertable " . "(name, address, password, title, realname, email, race, sex, age, \n\t\tlength, width, complexion, eyes, face, hair, beard, arm, leg, lok, \n\t\tactive, lastlogin, birth) " . "values(\"" . quote_smart($name) . "\", \"" . quote_smart($_SERVER['REMOTE_ADDR']) . "\", sha1(\"" . quote_smart($password) . "\"), \"" . quote_smart($title) . "\", \"" . quote_smart($realname) . "\", \"" . quote_smart($email) . "\", \"" . quote_smart($race) . "\", \"" . quote_smart($sex) . "\", \"" . quote_smart($age) . "\", \"" . quote_smart($length) . "\", \"" . quote_smart($width) . "\", \"" . quote_smart($complexion) . "\", \"" . quote_smart($eyes) . "\", \"" . quote_smart($face) . "\", \"" . quote_smart($hair) . "\", \"" . quote_smart($beard) . "\", \"" . quote_smart($arms) . "\", \"" . quote_smart($legs) . "\", null, 0, now(), now())"; if (!mysql_query($query, $dbhandle)) { writeLogLong($dbhandle, "Error creating new user " . $name . " from " . $_SERVER['REMOTE_ADDR'] . ".", $query . mysql_error()); $_SESSION["karchan_errormsg"] = "An error occurred creating the character."; } else { writeLogLong($dbhandle, "Created new user " . $name . " from " . $_SERVER['REMOTE_ADDR'] . ".", $query); $_SESSION["karchan_errormsg"] = "Ok."; } mysql_close($dbhandle); }
function mudlogin($name, $password, $frames = 1) { _karchan_log("mudlogin " . $name); // Hack prevention. // $headers = apache_request_headers(); // header() // setcookie(); // foreach ($headers as $header => $value) // { // echo "$header: $value <br />\n"; // } //$fp = fsockopen ($server_host, $server_port, $errno, $errstr, 30); $fp = fsockopen("localhost", 3340, $errno, $errstr, 30); if (!$fp) { $_SESSION["karchan_errormsg"] = "Could not open socket."; ob_end_flush(); return; } $readme = ""; $readme = fgets($fp, 128); // Mmud id _karchan_log("mudlogin " . $readme); $readme = fgets($fp, 128); // action _karchan_log("mudlogin " . $readme); fputs($fp, "logon\n"); $readme = fgets($fp, 128); // name _karchan_log("mudlogin " . $readme); fputs($fp, $name . "\n"); $readme = fgets($fp, 128); // password _karchan_log("mudlogin " . $readme); fputs($fp, $password . "\n"); $readme = fgets($fp, 128); // ip address _karchan_log("mudlogin " . $readme); fputs($fp, gethostbyaddr($_SERVER['REMOTE_ADDR']) . "\n"); $readme = fgets($fp, 128); // cookie _karchan_log("mudlogin " . $readme); if (isset($_COOKIE["karchanpassword"])) { fputs($fp, $_COOKIE["karchanpassword"] . "\n"); } else { fputs($fp, "\n"); } $readme = fgets($fp, 128); // frames _karchan_log("mudlogin " . $readme); fputs($fp, $frames . "\n"); // retrieve cookie that is always sent when attempting a login. $cookie = $readme = fgets($fp, 128); _karchan_log("mudlogin " . $readme); setcookie("karchanname", $name, 0, "/"); if (strstr($cookie, "sessionpassword="******"", -1, 1); setcookie("karchanpassword", $cookie, 0, "/"); $readline = fgets($fp, 128); $_SESSION["karchan_errormsg"] = $readline; } else { $_SESSION["karchan_errormsg"] = $cookie; } $readline = fgets($fp, 128); $contents = $readline; while (!feof($fp) && $readline != ".\n") { // echo $readline; _karchan_log("mudlogin " . $readline); $readline = fgets($fp, 128); $contents .= $readline; } _karchan_log("mudlogin " . $readline); fputs($fp, "\nOk\nOk\n"); fclose($fp); $_SESSION["frames"] = $frames; $_SESSION["karchan_contents"] = $contents; }