Example #1
0
function include_war_room2_text()
{
    // Secure / Validate Input
    if ($_SERVER['REQUEST_METHOD'] != 'POST') {
        require_once 'inc/pages/logout.inc.php';
        include_logout_text();
    }
    $objSrcUser = $GLOBALS['objSrcUser'];
    $strType = $objSrcUser->get_stat('type');
    $objSrcAlli = $objSrcUser->get_alliance();
    $arrSrcWars = $objSrcAlli->get_wars();
    $iSrcTarget = $arrSrcWars['target'];
    // M: Surrender war
    if (isset($_POST['surrender']) && $iSrcTarget != 0 && isElder($strType)) {
        $objTrgAlli = new clsAlliance($iSrcTarget);
        // Surrender
        $arrLosses = doWarSurrender($objSrcAlli, $objTrgAlli);
        $strLosses = getSurrenderReport($arrLosses);
        $strReport = "<p>You surrender in the war with alliance #{$iSrcTarget}!" . "</p>" . $strLosses;
    } elseif (isset($_POST['declare']) && intval($_POST['target']) > 0 && $iSrcTarget == 0 && isElder($strType)) {
        // Check if war is possible
        $iNewTarget = intval($_POST['target']);
        $objTrgAlli = new clsAlliance($iNewTarget);
        $arrWarPossible = testWarPossible($objSrcAlli, $objTrgAlli);
        $bWarPossible = $arrWarPossible[0];
        if ($_SERVER['SERVER_NAME'] != DEV_SERVER_NAME && !$bWarPossible) {
            $strReport = $arrWarPossible[1];
        } else {
            doWarDeclare($objSrcAlli, $objTrgAlli);
            $strReport = "<p>We have declared war with alliance #" . $objTrgAlli->get_allianceid() . "!</p>";
        }
    } elseif (isset($_POST['victory']) && $iSrcTarget != 0) {
        // Check if war is won
        $objTrgAlli = new clsAlliance($iSrcTarget);
        if ($arrGains = testWarVictory($objSrcAlli, $objTrgAlli)) {
            $strLosses = getVictoryReport($arrGains);
            $strReport = "<p>You have won the war with alliance #{$iSrcTarget}!" . "</p>" . $strLosses;
        } else {
            $strReport = "<p>You can't claim victory since you haven't any war.</p>";
        }
    } elseif (isset($_POST['atruce']) && $iSrcTarget != 0 && isElder($strType)) {
        $objTrgAlli = new clsAlliance($iSrcTarget);
        doWarTruce($objSrcAlli, $objTrgAlli);
        $strReport = "<p>You accept the truce and the war with alliance #" . "{$iSrcTarget} is over.</p>";
    } elseif (isset($_POST['ctruce']) && $iSrcTarget != 0 && isElder($strType)) {
        $objSrcAlli->set_war('truce_offer', 0);
        $strReport = "<p>We have withdrawn our offer to truce with alliance #" . "{$iSrcTarget}.</p>";
    } elseif (isset($_POST['otruce']) && $iSrcTarget != 0 && isElder($strType)) {
        $objSrcAlli->set_war('truce_offer', 1);
        $strReport = "<p>An offer to truce has been sent to alliance #{$iSrcTarget}.</p>";
    } else {
        header('location: main.php?cat=game&page=war_room');
        return;
    }
    // M: Show report
    echo '<div id="textMedium">' . '<h2>War Room Report</h2>' . $strReport . '<p><a href="main.php?cat=game&amp;page=war_room">Continue</a></p>' . '</div>';
}
function include_reset_account_text()
{
    global $Host;
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $arrStats = $objSrcUser->get_stats();
    $iUserid = $objSrcUser->get_userid();
    $arrRaces = getActiveRaces();
    if ($arrStats[RESET_OPTION] == 'yes' || $arrStats[KILLED] > 0) {
        if (isset($_POST['submit'])) {
            $tribe = $_POST['tribe'];
            $tribe = addslashes(strip_tags(trim($tribe)));
            $race = $_POST['race'];
            // Leader should only be submitted 1 time, right after signing up
            if (isset($_POST['alias']) && !empty($_POST['alias'])) {
                $alias = $_POST['name'];
                $alias = addslashes(strip_tags(trim($alias)));
            } else {
                $alias = $arrStats[NAME];
            }
            // Validate form input
            if (!empty($tribe) && !empty($race) && in_array($race, $arrRaces)) {
                // Check that the new tribe name isn't already taken
                $check = mysql_query("SELECT * FROM " . TBL_STAT . " WHERE tribe = '{$tribe}' AND id != {$iUserid}");
                $check = mysql_fetch_array($check);
                $stat_search2 = mysql_query("SELECT * FROM " . TBL_STAT . " WHERE name = '{$alias}' AND id != {$iUserid}");
                $stat_search2 = mysql_fetch_array($stat_search2);
                if (isset($check[TRIBE])) {
                    $strDiv = '<div id="textSmall">' . '<p>' . 'Sorry, but that tribe name is already taken.' . '<br /><br />' . '<a href="main.php?cat=game&amp;page=reset_account">' . 'Try Again?' . '</a>' . '</p>' . '</div>';
                    echo $strDiv;
                } elseif (isset($stat_search2[NAME])) {
                    $strDiv = '<div id="textSmall">' . '<p>' . 'Sorry, but that leader name is already taken.' . '<br /><br />' . '<a href="main.php?cat=game&amp;page=reset_account">' . 'Try Again?' . '</a>' . '</p>' . '</div>';
                    echo $strDiv;
                } else {
                    //==========================================================
                    //                       Recoded November 07, 2007 by Martel
                    // Infinity: bonus on age death, Classic: bonus if killed
                    // Cause of death, 2=killed, 1=age, 0=reset
                    //==========================================================
                    $bBonus = FALSE;
                    if ($_SERVER['SERVER_NAME'] != DINAH_SERVER_NAME && $arrStats[KILLED] == 1) {
                        $bBonus = TRUE;
                    } elseif ($_SERVER['SERVER_NAME'] == DINAH_SERVER_NAME && $arrStats[KILLED] == 2) {
                        $bBonus = TRUE;
                    }
                    // Race housing effeciency
                    $arrBuildVariables = getBuildingVariables($race);
                    $homes_hold = $arrBuildVariables['housing'][1];
                    $ratio = 1;
                    // Death Bonus "Heritage"          Martel, November 07, 2007
                    if ($bBonus && $objSrcUser->get_kill(LAND) > STARTING_LAND) {
                        $arrKill = $objSrcUser->get_kills();
                        $ratio = $homes_hold / $arrKill[POP];
                        $iLand = $arrKill[LAND];
                        $arrCost = getUnitVariables($race);
                        $arrCost = $arrCost['gold'];
                        // New Heritage     (Age9) AI+Martel, September 25, 2007
                        $iLand = round(pow(max(0, $iLand - STARTING_LAND), 0.80459611995) + STARTING_LAND);
                        if ($iLand > 2000) {
                            $iLand = 2000;
                        } elseif ($iLand < STARTING_LAND) {
                            $iLand = $iLand;
                        }
                        // Buildings
                        $arrBonusValues[LAND] = $iLand;
                        // Goods
                        $arrBonusValues[RESEARCH] = 0;
                        //round(($arrKill[RESEARCH] / $arrKill[LAND]) * $land);
                        // Citizens
                        $arrBonusValues[CITIZENS] = round($iLand * 15 * $ratio);
                        // Fame
                        $arrBonusValues[FAME] = round($arrKill[FAME] * 0.04);
                        // Market Goods
                        $arrBonusValues[MONEY] = round($arrKill[CASH] * $ratio);
                        $arrBonusValues[UNIT1] = round($arrKill[BASICS] * $ratio);
                        $arrBonusValues[CREDITS] = round(2 * $arrBonusValues[MONEY] + (2 * $arrCost[2] + 15) * $arrBonusValues[UNIT1]);
                    } else {
                        $arrBonusValues[LAND] = 0;
                        $arrBonusValues[RESEARCH] = 0;
                        $arrBonusValues[CITIZENS] = 0;
                        $arrBonusValues[FAME] = 0;
                    }
                    //==========================================================
                    // Reset Tables (excluded from this reset is TBL_USER,
                    // TBL_STATS and TBL_PREFERENCES)
                    //==========================================================
                    $iNewLand = STARTING_LAND + $arrBonusValues[LAND];
                    include_once 'inc/functions/reset_account.php';
                    $arrStartValues = getStartValues($race, $iNewLand);
                    // User table (save old but set updates to start now)
                    $arrUsers = $objSrcUser->get_user_infos();
                    $arrNewUsers = array(HOURS => 0, LAST_LOGIN => date('Y-m-d H:i:s'), LAST_UPDATE_HOUR => date('H'), LAST_UPDATE_DAY => date('d'));
                    $objSrcUser->set_user_infos($arrNewUsers);
                    // Build Table
                    mysql_query("DELETE FROM build WHERE id = {$iUserid}") or die("build1");
                    mysql_query("INSERT INTO build SET id = {$iUserid}") or die("build2");
                    // add land + buildings (overrides hardcoded DB defaults)
                    $arrBuildsNew = array(LAND => $arrStartValues[LAND], HOMES => $arrStartValues[HOMES], FARMS => $arrStartValues[FARMS], MARKETS => $arrStartValues[MARKETS], YARDS => $arrStartValues[YARDS], GUILDS => $arrStartValues[GUILDS], HIDEOUTS => $arrStartValues[HIDEOUTS]);
                    $objSrcUser->set_builds($arrBuildsNew);
                    // Army Table
                    mysql_query("DELETE FROM army WHERE id = {$iUserid}") or die("army");
                    mysql_query("INSERT INTO army SET id = {$iUserid}") or die("army2");
                    // add military units (overrides hardcoded DB defaults)
                    $arrArmysNew = array(UNIT1 => $arrStartValues[UNIT1], UNIT2 => $arrStartValues[UNIT2], UNIT3 => $arrStartValues[UNIT3], UNIT4 => $arrStartValues[UNIT4], UNIT5 => $arrStartValues[UNIT5]);
                    $objSrcUser->set_armys($arrArmysNew);
                    // ArmyMercs Table
                    mysql_query("DELETE FROM army_mercs WHERE id = {$iUserid}") or die("army");
                    if ($race == "Oleg Hai" || $race == "Mori Hai") {
                        mysql_query("INSERT INTO army_mercs SET id = {$iUserid}") or die("army2");
                        if ($race == "Oleg Hai") {
                            mysql_query("UPDATE army SET unit4 = 0 WHERE id = {$iUserid}");
                        }
                    }
                    // Milreturn Table
                    mysql_query("DELETE FROM milreturn WHERE id = {$iUserid}") or die("milreturn");
                    mysql_query("INSERT INTO milreturn SET id = {$iUserid}") or die("milreturn2");
                    // Population Table
                    $iNewCitz = $arrStartValues[CITIZENS] + $arrBonusValues[CITIZENS];
                    $objSrcUser->set_pop(CITIZENS, $iNewCitz);
                    // Personal Rankings
                    mysql_query("DELETE FROM rankings_personal WHERE id = {$iUserid}") or die("milreturn");
                    mysql_query("INSERT INTO rankings_personal SET id = {$iUserid}") or die("milreturn2");
                    // Goods Table
                    mysql_query("DELETE FROM goods WHERE id = {$iUserid}") or die("goods");
                    mysql_query("INSERT INTO goods SET id = {$iUserid}") or die("goods2");
                    // Add modified starting values to Goods
                    $arrGoodsNew = array(MONEY => $arrStartValues[MONEY], FOOD => $arrStartValues[FOOD], WOOD => $arrStartValues[WOOD], RESEARCH => $arrStartValues[RESEARCH] + $arrBonusValues[RESEARCH]);
                    $objSrcUser->set_goods($arrGoodsNew);
                    // Spells Table
                    mysql_query("DELETE FROM spells WHERE id = {$iUserid}") or die("spells");
                    mysql_query("INSERT INTO spells SET id = {$iUserid}") or die("spells2");
                    // add basic self spells (overrides hardcoded DB defaults)
                    $arrSpellsNew = array(POPULATION => $arrStartValues[POPULATION], GROWTH => $arrStartValues[GROWTH], FOOD => $arrStartValues['matawaska'], INCOME => $arrStartValues[INCOME]);
                    $objSrcUser->set_spells($arrSpellsNew);
                    // Thievery Table
                    mysql_query("DELETE FROM thievery WHERE id = {$iUserid}") or die("thievery");
                    mysql_query("INSERT INTO thievery SET id = {$iUserid}") or die("thievery2");
                    // Kill Table
                    mysql_query("DELETE FROM kills WHERE id = {$iUserid}");
                    mysql_query("INSERT INTO kills SET id = {$iUserid}");
                    // Stats table (save old but update new tribe name & race)
                    $arrStats = $objSrcUser->get_stats();
                    $arrStatsNew = array(KILLED => 0, TRIBE => $tribe, RACE => $race, FAME => $arrStartValues[FAME] + $arrBonusValues[FAME], RESET_OPTION => "no", INVESTED => 0, KILLS => 0, TWG_VOTE => 0);
                    $objSrcUser->set_stats($arrStatsNew);
                    //==========================================================
                    // Add bonus to build, tribe goods & alliance market
                    //==========================================================
                    if ($bBonus) {
                        // add kill bonus to market credits
                        $arrGoodsNew = array(MARKET_MONEY => $arrBonusValues[MONEY], MARKET_SOLDIERS => $arrBonusValues[UNIT1], CREDITS => $arrBonusValues[CREDITS]);
                        $objSrcUser->set_goods($arrGoodsNew);
                        // alliance object
                        include_once 'inc/classes/clsAlliance.php';
                        $iAllianceId = $objSrcUser->get_stat(ALLIANCE);
                        $objSrcAlliance = new clsAlliance($iAllianceId);
                        // add bonus to alliance market
                        $arrAllianceInfos = $objSrcAlliance->get_alliance_infos();
                        $arrNewAllianceInfos = array(MONEY => $arrAllianceInfos[MONEY] + $arrBonusValues[MONEY], SOLDIERS => $arrAllianceInfos[SOLDIERS] + $arrBonusValues[UNIT1]);
                        $objSrcAlliance->set_alliance_infos($arrNewAllianceInfos);
                    }
                    // Update rankings (forced = yes)
                    include_once 'inc/functions/update_ranking.php';
                    doUpdateRankings($objSrcUser, 'yes');
                    $strDiv = '<div id="textSmall">' . '<p>' . 'Account updated =)' . '<br /><br />' . '<a href="main.php?cat=game&amp;page=tribe">' . 'Continue' . '</a>' . '</p>' . '</div>';
                    echo $strDiv;
                }
            } else {
                $strDiv = '<div id="textSmall">' . '<p>' . 'You forgot to enter a new tribe name and/or forgot to ' . 'choose a race.' . '<br /><br />' . '<a href="main.php?cat=game&amp;page=reset_account">' . 'Try Again?' . '</a>' . '</p>' . '</div>';
                echo $strDiv;
            }
        } else {
            $picture = 'defeat';
            if ($arrStats[KILLED] == 2) {
                $strMessage = '<p>' . stripslashes($arrStats[NAME]) . ', it seems that <strong class="negative">your last ' . 'citizens have left your tribe</strong>. ' . 'With them the last of your power is gone and so is your physical presence in the lands of Orkfia. But, within ' . PROTECTION_HOURS . ' ' . 'months you could once again do battle with your allies. ' . '</p>';
                $picture = 'defeat';
            } elseif ($arrStats[KILLED] == 0) {
                $strMessage = '<p>' . stripslashes($arrStats[NAME]) . ', it seems that <strong class="negative">you have ' . 'decided to reset</strong>. ' . 'The last of your power is gone and so is your physical presence in the lands of Orkfia. But, within ' . PROTECTION_HOURS . ' ' . 'months you could once again do battle with your allies. ' . '</p>';
                $picture = 'defeat';
            } elseif ($arrStats[KILLED] == 1) {
                $strMessage = '<p>' . stripslashes($arrStats[NAME]) . ', it seems that <strong class="positive">the leader ' . 'of your tribe has died due to age</strong>. ' . 'The last of your power is gone and so is your physical presence in the lands of Orkfia. But, within ' . PROTECTION_HOURS . ' ' . 'months you could once again do battle with your allies. ' . '</p>';
                $picture = 'victory';
            } elseif ($arrStats[KILLED] == 3) {
                $strMessage = '<p>' . 'Welcome! It seems that <strong class="positive">you are ' . 'about to create your first tribe in Orkfia</strong>. ' . 'Currently you have no physical presence in these lands. But, within ' . PROTECTION_HOURS . ' ' . 'months you could do battle together with your allies. ' . '</p>' . '<p>' . '<label for="1">' . 'Leader Name: ' . '</label>' . '<input id="1" name="name" size="20" maxLength="20">' . '</p>';
                $picture = 'victory';
            }
            $strForm = '<form method="POST" ' . 'action="main.php?cat=game&amp;page=reset_account">' . '<div id="textMedium">' . '<p style="text-align: center">' . '<img src="' . $Host . $picture . '_small.gif">' . '</p>' . $strMessage . '<p>' . 'Your account is now paused, time will start running once you submit the information below.' . '</p>' . '<p>' . '<label for="2">' . 'New Tribe Name: ' . '</label>' . '<input id="2" name="tribe" size="20" maxLength="20" value="' . stripslashes($arrStats[TRIBE]) . '">' . '</p>' . '<p>' . '<label for="3">' . 'Select Race: ' . '</label>' . '<select id="3" size="1" name="race">';
            foreach ($arrRaces as $strCurRace) {
                $strAdd = '';
                if ($arrStats[RACE] == $strCurRace) {
                    $strAdd = ' selected';
                }
                $strForm .= "<option value=\"{$strCurRace}\"{$strAdd}>" . $strCurRace . "</option>";
            }
            $strForm .= '</select> ' . '<a href="http://guide.orkfia.org/races.php?chapter=4" class="newWindowLink" target="_blank" style="cursor: help">Races</a>' . '</p>' . '<p>' . '<input type="submit" name="submit" value="Return to Orkfia!">' . '</p>' . '</div>' . '</form>';
            echo $strForm;
        }
    } else {
        // Kick someone in the butt for finding this page through address field
        include_once "inc/pages/logout.inc.php";
        include_logout_text();
    }
}
Example #3
0
function include_alliance_text()
{
    // This bugs pretty badly if the alliance tables are missing
    // Same thing further down too, but for target alliance obj.
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $objSrcAlli = $objSrcUser->get_alliance();
    //==========================================================================
    // Martel: Validate the alliance number so we get an absolutely safe one
    //==========================================================================
    $iAid = intval($objSrcUser->get_stat(ALLIANCE));
    if (isset($_POST['aid'])) {
        $iAid = intval($_POST['aid']);
        if (strlen($_POST['aid']) > 4) {
            require_once 'inc/pages/logout.inc.php';
            include_logout_text();
        }
    } elseif (isset($_GET['aid'])) {
        $iAid = intval($_GET['aid']);
        if (strlen($_GET['aid']) > 4) {
            require_once 'inc/pages/logout.inc.php';
            include_logout_text();
        }
    }
    if ($iAid < 1) {
        $iAid = 1;
    }
    //==========================================================================
    $result = mysql_query("SELECT alli_id FROM rankings_personal WHERE alli_id < {$iAid} ORDER BY alli_id DESC LIMIT 1");
    if (mysql_num_rows($result) == '0') {
        $prevAlli['0'] = $iAid;
    } else {
        $prevAlli = mysql_fetch_row($result);
    }
    $result = mysql_query("SELECT alli_id FROM rankings_personal WHERE alli_id > {$iAid} ORDER BY alli_id ASC LIMIT 1");
    if (mysql_num_rows($result) == '0') {
        $nextAlli['0'] = $iAid;
    } else {
        $nextAlli = mysql_fetch_row($result);
    }
    echo $chooseAlliance = "<div class=\"tableLinkMini\">" . "<a href=\"main.php?cat=game&amp;page=alliance\">Home</a>" . "</div>" . "<form method=\"post\" action=\"main.php?cat=game&amp;page=alliance\" style=\"margin-top: 0pt;\">" . "<table cellpadding=\"0\" cellspacing=\"0\" class=\"mini\">" . "<tr class=\"header\">" . "<th colspan=\"4\">" . "Alliance" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<td>" . "<a id=\"arrowl\" href=\"main.php?cat=game&amp;page=alliance&amp;aid=" . $prevAlli[0] . "\">" . "<span class=\"alt\">" . "&#60;" . "</span>" . "</a>" . "</td>" . "<td>" . "<input type=\"text\" name=\"aid\" size=\"4\" maxlength=\"4\" value=\"" . $iAid . "\" />" . "</td>" . "<td>" . "<input type=\"submit\" name=\"submit\" value=\"View\" />" . "</td>" . "<td>" . "<a id=\"arrowr\" href=\"main.php?cat=game&amp;page=alliance&amp;aid=" . $nextAlli[0] . "\">" . "<span class=\"alt\">" . "&#62;" . "</span>" . "</a>" . "</td>" . "</tr>" . "</table>" . "</form>";
    $res = mysql_query("SELECT COUNT(id) AS cnt FROM rankings_personal WHERE alli_id = {$iAid}");
    $line = mysql_fetch_assoc($res);
    if ($line["cnt"] == '0') {
        $res = mysql_query("SELECT id FROM rankings_alliance ORDER BY id DESC LIMIT 1");
        $max = mysql_fetch_assoc($res);
        $res = mysql_query("SELECT id FROM rankings_alliance ORDER BY id ASC LIMIT 1");
        $min = mysql_fetch_assoc($res);
        echo "Selections range from " . $min["id"] . "-" . $max["id"];
        include_game_down();
        exit;
    }
    ?>
    <div class="center">
<?php 
    //==========================================================================
    // Alliance Banner
    //==========================================================================
    $objTrgAlli = new clsAlliance($iAid);
    $arrAlliance = $objTrgAlli->get_alliance_infos();
    $arrRankingsAlliance = $objTrgAlli->get_rankings_alliances();
    if (trim($arrAlliance[IMAGE]) != '') {
        $arrAlliance[IMAGE] = stripslashes($arrAlliance[IMAGE]);
        $arrAlliance[IMAGE] = htmlspecialchars($arrAlliance[IMAGE]);
        $arrAlliance[IMAGE] = escapeshellcmd($arrAlliance[IMAGE]);
        echo "<img src =\"" . $arrAlliance[IMAGE] . "\" width =\"" . $arrAlliance[IMAGEWIDTH] . "\" height =\"" . $arrAlliance[IMAGEHEIGHT] . "\" alt=\"\" /><br />";
    }
    //==========================================================================
    // War status display
    //==========================================================================
    $arrSrcWar = $objTrgAlli->get_wars();
    if ($arrSrcWar[TARGET] != 0) {
        $targetLink = " (<a href=\"main.php?cat=game&amp;page=alliance&amp;aid=" . $arrSrcWar[TARGET] . "\">#" . $arrSrcWar[TARGET] . "</a>)";
        $objWarTrg = new clsAlliance($arrSrcWar[TARGET]);
        $strAlliName = stripslashes($objWarTrg->get_rankings_alliance('alli_name'));
        echo '<br /><strong class="negative">At war with ' . $strAlliName . $targetLink . '</strong>';
    }
    //==========================================================================
    if ($iAid < 10) {
        $iSpan = 3;
        ?>
        <span style="font-size: 0.8em"><a href="main.php?cat=game&amp;page=message&amp;alliance=<?php 
        echo $iAid;
        ?>
">Submit a report here</a>.</span>
        <br />
<?php 
    } else {
        $iSpan = 6;
        if ($iAid == $objSrcUser->get_stat(ALLIANCE)) {
            $iSpan = 7;
        }
        // bootcamp indication
        if ($arrAlliance[BOOTCAMP] == 'yes') {
            ?>
        <br /><strong class='positive'>[ Boot Camp ]</strong><br />

<?php 
        }
        // M: Graveyard indication
        if ($iAid == 10) {
            echo '<h2>The Graveyard in #10 - Beware of the DEAD.</h2>';
        }
        ?>

<?php 
    }
    ?>
    </div>
    <br />
    <table cellpadding="0" cellspacing="0" class="big">
        <tr class="header">
            <th colspan="<?php 
    echo $iSpan;
    ?>
">
<?php 
    $strAllianceName = stripslashes($arrRankingsAlliance[ALLI_NAME]);
    echo "{$strAllianceName} (#{$iAid})";
    if (trim($arrRankingsAlliance[ALLI_DESC]) != '') {
        $allianceDesc = stripslashes(trim($arrRankingsAlliance[ALLI_DESC]));
        ?>
                <br /><span style="font-size: 0.8em;"><?php 
        echo $allianceDesc;
        ?>
</span>
<?php 
    }
    if ($iAid < 10) {
        ?>
            </th>
        </tr>
        <tr class="subheader">
            <th width="17"></th>
            <td align="left" class="left" width="34%">Staff Tribe</td>
            <td align="left" class="left">Online < 48 hours ago</td>
        </tr>
<?php 
        // Martel: Sort 1-10 on staff ranks and name instead of acres
        $res = mysql_query("SELECT rankings_personal.id, alli_id, tribe_name, hours, rankings_personal.race, land, nw, rankings_personal.fame, player_type, stats.level FROM rankings_personal, stats WHERE alli_id = {$iAid} AND stats.id = rankings_personal.id ORDER BY level DESC, tribe_name ASC");
    } else {
        // Output alliance Rankings
        include_once 'inc/functions/alli_ranking.php';
        if ($iAid != 10) {
            $arrRanking = get_rank_data($iAid);
            echo "<br />Land: " . $arrRanking[LAND] . " &nbsp;&nbsp; Strength: " . $arrRanking[STRENGTH] . " &nbsp;&nbsp; Fame: " . $arrRanking[FAME];
        }
        ?>
            </th>
        </tr>
        <tr class="subheader">
            <th width="17"></th>
            <th>Tribe Name</th>
<?php 
        if ($iAid == $objSrcUser->get_stat(ALLIANCE)) {
            echo '
            <td><em>Ruler Age</em></td>
            ';
        }
        ?>
            <td>Race</td>
            <td>Size</td>
            <td>Strength</td>
            <td>Fame</td>
        </tr>
<?php 
        // Sort tribes by acreage, strength, fame
        $res = mysql_query("SELECT id FROM rankings_personal WHERE alli_id = {$iAid} ORDER BY land DESC, nw DESC, fame DESC");
    }
    $inactivitycheck = $objSrcUser->get_rankings_personals();
    $iCount = 0;
    $inactiveCounter = 0;
    $objTmpUser = new clsUser(0);
    while ($line = mysql_fetch_assoc($res)) {
        // Clear the temporary object to assign a new user
        $iUserid = $line[ID];
        $objTmpUser->set_userid($iUserid);
        $arrTmpRanking = $objTmpUser->get_rankings_personals();
        $arrTmpRanking[TRIBE_NAME] = stripslashes($arrTmpRanking[TRIBE_NAME]);
        $strFame = (string) number_format($arrTmpRanking[FAME]);
        if ($arrTmpRanking[FAME] < 5000) {
            $strFame = '<span class="negative">' . $strFame . '</span>';
        } elseif ($arrTmpRanking[FAME] > 5000) {
            $strFame = '<span class="positive">' . $strFame . '</span>';
        }
        ?>
        <tr class="data">
            <th>
<?php 
        $online = $objTmpUser->get_onlines();
        $old = date(TIMESTAMP_FORMAT, strtotime('-5 minutes'));
        // Martel: New inactivity check.
        // Works with both month changes and leap years ;)
        $inactive = date(TIMESTAMP_FORMAT, strtotime('-2 days'));
        if ($online['time'] < $inactive && $inactivitycheck[PLAYER_TYPE] == "elder" && $inactivitycheck[ALLI_ID] == $iAid) {
            ?>
                <img src="<?php 
            echo HOST_PICS;
            ?>
tribe_inactive.gif" alt="*" height="13" width="13" />
<?php 
        } elseif ($online['time'] < $old) {
            ?>
                <img src="<?php 
            echo HOST_PICS;
            ?>
tribe_offline.gif" alt="" height="13" width="13" />
<?php 
        } else {
            $inactiveCounter++;
            ?>
                <img src="<?php 
            echo HOST_PICS;
            ?>
tribe_online.gif" alt="»" height="13" width="13" />
<?php 
        }
        ?>
            </th>
            <th>
<?php 
        // Begin output of <tr> for each tribe
        if ($iAid >= 10) {
            $strClass = $arrTmpRanking[PLAYER_TYPE] . "";
            if ($objTmpUser->isPaused() || $arrTmpRanking[HOURS] < PROTECTION_HOURS) {
                $strClass = "protected";
            }
            echo '<a href="main.php?cat=game&amp;page=external_affairs&amp;tribe=' . $arrTmpRanking[ID] . "&amp;aid=" . $arrTmpRanking[ALLI_ID] . '" class="' . $strClass . '">' . $arrTmpRanking[TRIBE_NAME] . '</a></th>';
            if ($iAid == $objSrcUser->get_stat(ALLIANCE)) {
                echo "<td><em>" . $objTmpUser->get_ruler_age() . "</em></td>";
            }
            echo "<td>" . $arrTmpRanking[RACE] . "</td>" . "<td>" . number_format($arrTmpRanking[LAND]) . "</td>" . "<td>" . number_format($arrTmpRanking[NW]) . "</td>" . "<td>" . $strFame . "</td>" . "</tr>";
        } else {
            $strClass = "staff";
            if ($objTmpUser->get_stat(LEVEL) > 5) {
                $strClass = "admin";
            } elseif ($objTmpUser->get_stat(LEVEL) == 5) {
                $strClass = "head";
            }
            echo '<a href="main.php?cat=game&amp;page=message&amp;tribe=' . $arrTmpRanking[ID] . "&amp;alliance=" . $arrTmpRanking[ALLI_ID] . '" class="' . $strClass . '">' . $arrTmpRanking[TRIBE_NAME] . '</a></th>';
            if ($online['time'] < $inactive) {
                echo '<td class="left"><em>No</em></td>';
            } else {
                echo '<td class="left"><em class="positive">Yes</em></td>';
            }
            echo '</tr>';
        }
        $iCount++;
    }
    ?>
    </table>

    <div class="center" style="font-size: 0.8em">
        There are <?php 
    echo $iCount;
    ?>
 tribes in this alliance.
    </div>

    <br />

    <table cellpadding="0" cellspacing="0" class="small">
        <tr class="header">
            <th colspan="2">Legend</th>
        </tr>
        <tr class="subheader">
            <th>Mark</th>
            <td>Meaning</td>
        </tr>
<?php 
    if ($iAid >= 10) {
        ?>
        <tr class="data">
            <th class="elder">Gold:</th>
            <td>Elder</td>
        </tr>
        <tr class="data">
            <th class="coelder">Copper:</th>
            <td>Co-elder</td>
        </tr>
        <tr class="data">
            <th class="protected">Light Green:</th>
            <td>In Protection</td>
        </tr>

<?php 
    } else {
        ?>
        <tr class="data">
            <th class="admin">White:</th>
            <td>Orkfian God</td>
        </tr>
        <tr class="data">
            <th class="head">Pink:</th>
            <td>Orkfian Lord</td>
        </tr>
        <tr class="data">
            <th class="staff">Blue:</th>
            <td>ORKFiA Staff</td>
        </tr>
<?php 
    }
    ?>
        <tr class="data">
            <th><img src="<?php 
    echo HOST_PICS;
    ?>
tribe_online.gif" alt="»" height="13" width="13" /></th>
            <td>Online</td>
        </tr>
<?php 
    if ($inactivitycheck[PLAYER_TYPE] == "elder" && $inactivitycheck['alli_id'] == $iAid && $inactiveCounter > 0) {
        ?>
        <tr class="data">
            <th><img src="<?php 
        echo HOST_PICS;
        ?>
tribe_inactive.gif" alt="*" height="13" width="13" /></th>
            <td>Inactive</td>
        </tr>
<?php 
    }
    ?>
    </table>

<?php 
}
Example #4
0
    $my_visitors = new Count_visitors();
    $my_visitors->delay = 720;
    // how often (in hours) a visitor is registered
    $my_visitors->insert_new_visit();
    // That's all
}
//==============================================================================
// Initiate the upper part of main page / ingame layout
//==============================================================================
$page_up();
//==============================================================================
// Check if the requested file exist
//==============================================================================
if (!file_exists('inc/pages/' . $page . '.inc.php')) {
    include_once 'inc/pages/logout.inc.php';
    include_logout_text();
} else {
    include_once 'inc/pages/' . $page . '.inc.php';
}
//==============================================================================
// Show content and bottom of page
//==============================================================================
$page_text();
$page_down();
//==============================================================================
// stop execution of script on 'STOP'
// Do we really care? it's not like anything else will be executed - AI 30/09/06
//==============================================================================
/*
if ($cat == 'game')
{
Example #5
0
function include_raze_army2_text()
{
    // M: Secure / Validate Input
    if ($_SERVER['REQUEST_METHOD'] != 'POST' || !isset($_POST['released'])) {
        require_once 'inc/pages/logout.inc.php';
        include_logout_text();
    }
    $objUser =& $GLOBALS["objSrcUser"];
    $arrArmys = $objUser->get_armys();
    $arrUsers = $objUser->get_user_infos();
    $objRace = $objUser->get_race();
    $arrUnitVariables = $objRace->getUnitVariables();
    $arrUnitNames = $objRace->getUnitNames();
    $arrToRelease = $_POST['released'];
    $arrToRelease[UNIT1] = max(0, floor(intval($arrToRelease[UNIT1])));
    $arrToRelease[UNIT2] = max(0, floor(intval($arrToRelease[UNIT2])));
    $arrToRelease[UNIT3] = max(0, floor(intval($arrToRelease[UNIT3])));
    $arrToRelease[UNIT4] = max(0, floor(intval($arrToRelease[UNIT4])));
    $arrToRelease[UNIT5] = max(0, floor(intval($arrToRelease[UNIT5])));
    //     $arrToRelease[UNIT6] = max(0, floor(intval($arrToRelease[UNIT6])));
    // Maximum military releasable
    $arrMax = getMaxRelease($objUser);
    foreach ($arrToRelease as $unitx => $doesntmatter) {
        if ($arrToRelease[$unitx] > $arrMax[$unitx]) {
            $arrToRelease[$unitx] = $arrMax[$unitx];
        }
    }
    if ($objRace->getRaceName() != "Oleg Hai") {
        $iSumRelease = array_sum($arrToRelease);
        $iToCitizens = $arrToRelease[UNIT1];
        $iToBasics = $iSumRelease - $iToCitizens;
    } else {
        $iSumRelease = array_sum($arrToRelease);
        $iToCitizens = $arrToRelease[UNIT1] + $arrToRelease[UNIT4];
        $iToBasics = $iSumRelease - $iToCitizens;
    }
    // Release all into citizens option
    if (isset($_POST['citizens'])) {
        $iSumRelease = array_sum($arrToRelease);
        $iToCitizens = $iSumRelease;
        $iToBasics = 0;
    }
    if ($iSumRelease <= 0) {
        header('location: main.php?cat=game&page=raze_army&error=empty');
        exit;
    } elseif ($arrUsers[HOURS] > $objRace->getLifespan()) {
        header('location: main.php?cat=game&page=raze_army&error=too_old');
        exit;
    }
    // Save to DB (Update Military)
    foreach ($arrToRelease as $unitx => $iToRelease) {
        if ($iToRelease > 0) {
            // Release "in training 4 hours" BEFORE releasing "trained military"
            if ($arrArmys[$unitx . '_t4'] > 0) {
                // New value for incoming_t4
                $arrArmys[$unitx . '_t4'] -= $iToRelease;
                // Save left-overs to remove from army "at home"
                if ($arrArmys[$unitx . '_t4'] <= 0) {
                    $iToRelease = abs($arrArmys[$unitx . '_t4']);
                    $arrArmys[$unitx . '_t4'] = 0;
                } else {
                    $iToRelease = 0;
                }
            }
            $arrArmys[$unitx] -= $iToRelease;
            $arrArmys[$unitx] = max(0, $arrArmys[$unitx]);
        }
    }
    // Add units that were "degraded" to basics
    $arrArmys[UNIT1] += $iToBasics;
    // Update military
    $objUser->set_armys($arrArmys);
    // Update Oleg Hai Mercs (M: Reused and modified old code, can be improved.)
    if ($objRace->getRaceName() == "Oleg Hai" && $arrToRelease[UNIT4] > 0) {
        $arrArmyMercs = $objUser->get_army_mercs();
        $iMercsToRelease = $arrToRelease[UNIT4];
        if ($iMercsToRelease > $arrArmyMercs[MERC_T1]) {
            $iMercsToRelease -= $arrArmyMercs[MERC_T1];
            if ($iMercsToRelease > $arrArmyMercs[MERC_T2]) {
                $iMercsToRelease -= $arrArmyMercs[MERC_T2];
                if ($iMercsToRelease > $arrArmyMercs[MERC_T3]) {
                    $iMercsToRelease -= $arrArmyMercs[MERC_T3];
                    $arrArmyMercs[MERC_T3] -= $iMercsToRelease;
                    $arrArmyMercs[MERC_T3] = max(0, $arrArmyMercs[MERC_T3]);
                }
                $arrArmyMercs[MERC_T2] -= $iMercsToRelease;
                $arrArmyMercs[MERC_T2] = max(0, $arrArmyMercs[MERC_T2]);
            }
            $arrArmyMercs[MERC_T1] -= $iMercsToRelease;
            $arrArmyMercs[MERC_T1] = max(0, $arrArmyMercs[MERC_T1]);
        }
        $arrArmyMercs[MERC_T0] -= $iMercsToRelease;
        $arrArmyMercs[MERC_T0] = max(0, $arrArmyMercs[MERC_T0]);
        $objUser->set_army_mercs($arrArmyMercs);
    }
    // Update citizens
    $iOldCitizens = $objUser->get_pop(CITIZENS);
    $iNewCitizens = max(200, $iOldCitizens + $iToCitizens);
    $objUser->set_pop(CITIZENS, $iNewCitizens);
    // Create list with units released
    $strUnitList = '<ul>';
    $j = 1;
    foreach ($arrUnitVariables as $unitx) {
        if (isset($arrToRelease[$unitx]) && ($iTrained = $arrToRelease[$unitx]) > 0) {
            $strUnitName = $arrUnitNames[$j];
            $plural = 's';
            if ($strUnitName == 'Swordmen') {
                $plural = '';
            }
            if ($strUnitName == 'Pikemen') {
                $plural = '';
            }
            if ($strUnitName == 'Crossbowmen') {
                $plural = '';
            }
            if ($strUnitName == 'Longbowmen') {
                $plural = '';
            }
            if ($strUnitName == 'Thief') {
                $strUnitName = 'Thieve';
            }
            if ($strUnitName == 'Priestess') {
                $plural = 'es';
            }
            if ($strUnitName == 'Mummy') {
                $strUnitName = 'Mummie';
            }
            if ($strUnitName == 'Harpy') {
                $strUnitName = 'Harpie';
            }
            if ($iTrained == 1) {
                $plural = '';
            }
            $strUnitList .= '<li>' . number_format($iTrained) . ' ' . $strUnitName . $plural . '</li>';
        }
        $j++;
    }
    $strUnitList .= '</ul>';
    $strHarpyText = '';
    if ($objRace->getRaceName() == "Oleg Hai" && $arrToRelease[UNIT4] > 0) {
        $strHarpyText = '<p>' . number_format($arrToRelease[UNIT4]) . ' harpy mercenaries have left our army camp.</p>';
    }
    $strReport = '<div id="textMedium">' . '<h2>Training Report</h2>' . '<p>The following military have been released from their duties.</p>' . $strUnitList . '<p>' . 'You have released <strong>' . number_format($iSumRelease) . ' ' . 'units.</strong> These units have been degraded to: <strong>' . number_format($iToCitizens) . ' ' . $arrUnitNames[1] . 's</strong> and <strong>' . number_format($iToBasics) . ' ' . $arrUnitNames[2] . 's</strong>.' . '</p>' . $strHarpyText . '<p>' . '<a href="main.php?cat=game&amp;page=raze_army">Back To Releasing</a>' . '</p>' . '</div>';
    echo $strReport;
}