function gCalcTickTime() { global $db; $sql = "SELECT value FROM misc WHERE name = 'ticktime'"; $result = $db->query($sql); $value = $db->result($result, 0); if (!$value) { $value = time(); } $ticktime = $value + 3600; return gCalcTimeDif($ticktime, time(), FALSE); }
$numrows = $db->num_rows($result); if ($numrows == 0) { echo 'No creatures found.'; } else { tBegin(); unset($array); while ($row = $db->fetch_array($result)) { $creature = new creature($row); $array[count($array)] = $row; $array[count($array) - 1]["skill"] = $creature->data["sortskill"]; } gSortCreatures($array); for ($m = 0; $m < count($array); $m++) { $creature = new creature($array[$m]); $alliedtime = $creature->data["hidden"]; if ($timeleft = gCalcTimeDif($alliedtime, time())) { $url = array("#creaturename", " ({$prefix} <a href=\"index.php?page=playerinfo&action=viewinfo&aid=", "#accid", "\">", "#accname", "</a>, {$timeleft['days']} days, {$timeleft['hours']} hours left)"); } else { $url = array("#creaturename", " ({$prefix} <a href=\"index.php?page=playerinfo&action=viewinfo&aid=", "#accid", "\">", "#accname", "</a>, no time left, cannot defend anymore)"); } $creature->echoCreature($url); } echo '</table>'; } } if ($action == "newslotconfig") { $sql = "SELECT count(*) FROM slotconfig WHERE account = '{$acc['id']}'"; $result = $db->query($sql); $numrows = $db->result($result, 0); if ($numrows < gdMaxItemConfigs) { $numrows++;
$array = array(); while ($row = $db->fetch_array($result)) { $array[] = $row; } $sql = "SELECT kdb.id, kdb.time, k.name, k.id AS kid, kdb.kingdom FROM kdbattles AS kdb, kingdoms AS k WHERE kdb.kingdom = '{$acc['kingdom']}' AND kdb.target = k.id AND kdb.status = '1' ORDER BY kdb.time DESC"; $result = $db->query($sql); while ($row = $db->fetch_array($result)) { $array[] = $row; } $array = gSortArray($array, "time", "DESC"); for ($m = 0; $m < count($array); $m++) { $row = $array[$m]; if ($row["time"] + $gdKingdomBattlesTime - time() < 0) { $display = "none"; } else { $timeleft = gCalcTimeDif($row["time"] + $gdKingdomBattlesTime, time()); $display = "{$timeleft['days']} days, {$timeleft['hours']} hrs, {$timeleft['minutes']} mins"; } if ($row["kingdom"] == $acc["kingdom"]) { echo 'Outgoing kingdom battle vs <a href="index.php?page=kingdominfo&action=viewinfo&kid=', $row["kid"], '">', $row["name"], '</a>. <a href="index.php?page=kingdom&action=kdbattleinfo&kdbid=', $row["id"], '">Battle info.</a> Time left: ', $display, '.<br>'; } elseif ($row["kingdom"] != $acc["kingdom"]) { echo 'Incoming kingdom battle vs <a href="index.php?page=kingdominfo&action=viewinfo&kid=', $row["kid"], '">', $row["name"], '</a>. <a href="index.php?page=kingdom&action=kdbattleinfo&kdbid=', $row["id"], '">Battle info.</a> Time left: ', $display, '.<br>'; } } if (count($array) == 0) { echo 'No incoming or outgoing kingdom battles.<br>'; } tEnd(); tBegin("New Kingdom Battles"); if (!$newoffset) { $newoffset = 0;
} if ($no == 0) { $acc["status"] = 1; $acc["vacationtime"] = time(); $sql = "UPDATE accounts SET status = '1', vacationtime = '{$acc['vacationtime']}', arcanechamber = '0' WHERE id = '{$acc['id']}'"; $result = $db->query($sql); $sql = "UPDATE castcurses SET shards = '0' WHERE account = '{$acc['id']}'"; $result = $db->query($sql); $sql = "DELETE FROM accshards WHERE account = '{$acc['id']}' AND castcurse != '0'"; $result = $db->query($sql); $output .= 'You have successfully entered vacation mode!<br><br>'; } } if ($action == "leavevacation") { $no = 0; if ($array = gCalcTimeDif($acc["vacationtime"] + $gdMinimumVacationTime, time(), FALSE)) { $output .= 'You can\'t leave vacation mode before ' . $array["hours"] . ' hours have passed.<br>'; $no = 1; } if ($no == 0) { $acc["status"] = 0; $sql = "UPDATE accounts SET status = '0' WHERE id = '{$acc['id']}'"; $result = $db->query($sql); $cursetimebonus = time() - $acc["vacationtime"]; $where = ""; // curse on you if ($acc["castcurse"] != 0) { if ($where != "") { $where .= " OR "; } $where .= "id = '{$acc['castcurse']}'";
'; } } else { echo ' WARNING: resetting your account can not be undone in any way.<br> This is not a complete reset: you will keep your friends list and pub posts.<br> This option is for people that think they have made big mistakes during their character development and want to start all over again.<br> You can only reset once every week.<br><br> <a href="index.php?page=options&action=reset">Click here to start the reset process.</a><br> '; } tEnd(); tBegin("Kill Account"); if ($acc["killtime"] != 0) { $timeleft = gCalcTimeDif($acc["killtime"] + gdKillTime * 3600, time()); echo ' Your account will be killed in ', $timeleft["days"], ' day(s) and ', $timeleft["hours"], ' hour(s).<br> <a href="index.php?page=options&action=cancelkill">Cancel the killing process.</a><br> '; } else { echo ' WARNING: killing your account can not be undone in any way.<br> By killing your account, you remove your account completely from the game.<br> The difference between resetting and killing your account is that you will never be able to play with this account again and that the e-mail adress used for this account will become available for another registration.<br> <b>Your account name will NOT become available again!</b><br><br> <a href="index.php?page=options&action=kill">Click here to start the killing process.</a><br> '; } tEnd();
$row["url"] = "index.php?page=spellbook&action=castcurse&type=dispell&tid={$acc['id']}&target=mage&cid=0"; $array[] = $row; } } // curse on one of your creatures $sql = "SELECT ca.*, a.id AS aid, a.name AS aname, c.name AS creaturename, s.id AS sid, c.id AS cid FROM castcurses AS ca, summons AS s, creatures AS c, accounts AS a WHERE s.account = '{$acc['id']}' AND s.castcurse != '0' AND s.castcurse = ca.id AND s.creature = c.id AND ca.account = a.id"; $result = $db->query($sql); while ($row = $db->fetch_array($result)) { $row["cursename"] = $creaturename . " " . $gdCurses[$row["curse"]]["name"]; $row["url"] = "index.php?page=spellbook&action=castcurse&type=dispell&tid={$row['sid']}&target=creature&cid={$row['cid']}"; $array[] = $row; } $curses = gSortArray($array, "cursename", "ASC"); foreach ($curses as $curse) { $remove = FALSE; $timeleft = gCalcTimeDif($curse["time"], time()); // no time left if (!$timeleft) { $display = "no time"; $remove = TRUE; } else { $display = $timeleft["days"] . ' days, ' . $timeleft["hours"] . ' hours, ' . $timeleft["minutes"] . ' minutes'; } // no shards left if ($curse["shards"] == 0) { $remove = TRUE; } // no time left or no shards left if ($remove) { $removeall = TRUE; $addon = ', <a href="index.php?page=spellbook&action=removecurse&cuid=' . $curse["id"] . '">remove curse</a>';
$targetid = $battle["target"]; $otherid = $battle["target"]; } $sql = "SELECT count(*) FROM summons WHERE type = '4' AND target = '{$bid}' AND hidden = '0'"; $result = $db->query($sql); $numrows = $db->result($result, 0); if ($numrows != 0) { $hidden = 0; } else { $hidden = 1; } if ($hiddenwave != $hidden && $action != "raid") { echo 'You are defending the wrong wave. Please do not use the back button but go to the battles page and click defend again.<br>'; $no = 1; } if ($action == "raid" && gCalcTimeDif($battle["time"] + $gdBattlesTime, time())) { echo 'You are too early.<br>You can\'t raid that battle already.<br>'; $no = 1; } if ($action == "submitdefend") { $addon = "AND s.hidden = '{$hidden}'"; } else { $addon = ""; } // select attackers $sql = "SELECT {$gdCreatureSelect} FROM (summons AS s, creatures AS c, races AS r) LEFT JOIN accitems AS ai ON s.item = ai.id LEFT JOIN items AS i ON ai.item = i.id WHERE s.creature = c.id AND c.race = r.id AND s.type = '4' AND s.target = '{$bid}' {$addon}"; $result = $db->query($sql); $numrows = $db->num_rows($result); if ($numrows == 0) { echo 'Invalid creatures!<br>'; $no = 1;
$kingdom = $acc["tkd"]; } else { die("Messing around?"); } $sql = "SELECT pb.banner, pb.id, pb.time, pb.timelimit, a.id AS aid, a.name, a2.name AS bannername FROM pubbans AS pb, accounts AS a, accounts AS a2 WHERE pb.kingdom = '{$kingdom}' AND pb.account = a.id AND pb.banner = a2.id ORDER BY a.name ASC"; $result = $db->query($sql); tBegin("Banlist"); while ($row = $db->fetch_array($result)) { $date = date("Y-m-d @ H:i", $row["time"]); if (!$gdSpecialKingdoms[$kingdom]) { $addon = ""; } else { if ($row["timelimit"] == 0) { $addon = " for unlimited time"; } else { $dif = gCalcTimeDif($row["timelimit"], $row["time"]); $addon = " for {$dif['days']} days"; } $addon .= ", <a href=\"index.php?page=kingdom&action=changebandays&aid={$row['aid']}\">change</a>"; } echo '<a href="index.php?page=playerinfo&action=viewinfo&aid=', $row["aid"], '">', $row["name"], '</a> by <a href="index.php?page=playerinfo&action=viewinfo&aid=', $row["banner"], '">', $row["bannername"], '</a> (since ', $date, '', $addon, ') - <a href="index.php?page=kingdom&action=unban&pbid=', $row["id"], '">unban</a><br>'; } tEnd(); tBegin("Ban Account"); fTitle("index.php?page=kingdom&action=ban"); fText("Name:", "name"); fEnd("Ban"); tEnd(); if (in_array($acc["id"], $moderators)) { tBegin("Violations"); $sql = "SELECT id, subject, days FROM violations ORDER BY subject ASC";
if ($numrows != 1) { echo 'Invalid data.<br>'; $no = 1; } if ($no == 0) { $row = $db->fetch_array($result); tBegin("Status"); if ($row["resource"] == "powerbalance") { $row["resource"] = "power balance"; } if ($row["resource"] == "arcane") { $row["resource"] = "the arcane chamber"; } echo 'We are attacking <a href="index.php?page=playerinfo&action=viewinfo&aid=', $row["aid"], '">', $row["aname"], '</a> from kingdom <a href="index.php?page=kingdominfo&action=viewinfo&kid=', $row["kid"], '">', $row["kname"], '</a>.<br>'; echo 'We are concentrating on ', $row["resource"], '.<br>'; if ($timeleft = gCalcTimeDif($row["time"] + $gdBattlesTime, time())) { echo ' ', $row["aname"], ' has ', $timeleft["hours"], ':', $timeleft["minutes"], ' time left to react.<br> <a href="index.php?page=battles&action=withdraw&bid=', $row["id"], '">Withdraw your creatures.</a> '; } else { // encryption include_once "functions/javascript.php"; $toencrypt = md5($acc["id"] . $row["id"] . $acc["name"]); echo ' ', $row["aname"], ' didn\'t react in time.<br> You can <script language="JavaScript"> document.write("<a href=\\"index.php?page=battles&action=raid&bid=', $row["id"], '&key="); F1("', $toencrypt, '"); document.write("\\"\\>");
$online = "online"; } else { $online = "offline"; } if ($row["status"] == 1) { $status = "<font class=\"alert\">{$row['name']} is currently in vacation mode.</font><br>"; } elseif ($row["status"] == 2) { $status = "<font class=\"alert\">This account has been killed by its owner or has been removed from the game after violating the <a href=\"index.php?page=rules\">game rules</a>.</font><br>"; } elseif ($row["status"] == 98 || $row["status"] == 99) { $status = "This player hasn't completed his registration yet.<br>"; } else { $time = time() - $gdOnlineTime; if ($row["time"] > $time) { $status = "{$row['name']} is currently online.<br>"; } else { $array = gCalcTimeDif(time(), $row["time"], FALSE); $addon = ""; if ($array["minutes"] > 0) { $addon = "{$array['minutes']} minutes"; } if ($array["hours"] > 0) { $addon = "{$array['hours']} hours" . ($addon == "" ? "" : ", ") . $addon; } if ($array["days"] > 0) { $addon = "{$array['days']} days" . ($addon == "" ? "" : ", ") . $addon; } if ($array["years"] > 0) { $addon = "{$array['years']} years" . ($addon == "" ? "" : ", ") . $addon; } $status = "{$row['name']} is currently offline ({$addon} since last time online).<br>"; }