Exemplo n.º 1
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 
}
Exemplo n.º 2
0
function get_market_history_table(&$objAlliance)
{
    $strMarketHistoryTable = "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"5\">" . "Market History" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Tribe" . "</th>" . "<td>" . "Money" . "</td>" . "<td>" . "Food" . "</td>" . "<td>" . "Wood" . "</td>" . "<td>" . "Soldiers" . "</td>" . "</tr>";
    $arrSum = array(MARKET_MONEY => 0, MARKET_FOOD => 0, MARKET_WOOD => 0, MARKET_SOLDIERS => 0);
    $objTmpUser = new clsUser(1);
    foreach ($objAlliance->get_userids() as $iUser) {
        $objTmpUser->set_userid($iUser);
        // This might speed it up a bit.. Reuse
        $arrTmpGoods = $objTmpUser->get_goods();
        $arrTmpStats = $objTmpUser->get_stats();
        $strMarketHistoryTable .= "<tr class=\"data\">" . "<th>" . stripslashes($arrTmpStats[TRIBE]) . "</th>" . "<td>" . number_format($arrTmpGoods[MARKET_MONEY]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_FOOD]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_WOOD]) . "</td>" . "<td>" . number_format($arrTmpGoods[MARKET_SOLDIERS]) . "</td>" . "</tr>";
        // M: Add to total for each resource type
        foreach ($arrSum as $str => $i) {
            $arrSum[$str] += $arrTmpGoods[$str];
        }
    }
    $arrAlli = $objAlliance->get_alliance_infos();
    $strMarketHistoryTable .= "<tr class=\"data\">" . "<th class=bsup>" . "Unaccounted For:" . "</th>" . "<td class=bsup>" . number_format($arrAlli[MONEY] - $arrSum[MARKET_MONEY]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[FOOD] - $arrSum[MARKET_FOOD]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[WOOD] - $arrSum[MARKET_WOOD]) . "</td>" . "<td class=bsup>" . number_format($arrAlli[SOLDIERS] - $arrSum[MARKET_SOLDIERS]) . "</td>" . "</tr>" . "</table>";
    return $strMarketHistoryTable;
}
Exemplo n.º 3
0
function include_vote_text()
{
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $iSrcVote = $objSrcUser->get_stat(VOTE);
    $objSrcAlli = $objSrcUser->get_alliance();
    $arrUserIds = $objSrcAlli->get_userids();
    // M: Show advisor text
    $strAdvisorText = '<div id="textMedium" style="margin-top: 0;">' . '<p>' . "Please vote for whom you think should be the elder and control your alliance." . '</p>' . '</div><br />';
    echo $strAdvisorText;
    // M: Populate arrVotes - this array contains information about all voters
    $objTmpUser = new clsUser(1);
    foreach ($arrUserIds as $iUserId) {
        $objTmpUser->set_userid($iUserId);
        $arrVotes[$iUserId]["tribename"] = $objTmpUser->get_stat(TRIBE);
        $arrVotes[$iUserId]["playertype"] = $objTmpUser->get_stat(TYPE);
        $arrVotes[$iUserId]["votes"] = 0;
        $arrVotes[$iUserId]["votefor"] = '';
    }
    // M: Count their votes (also verify that they voted for an alliance member)
    $iValidVotes = 0;
    foreach ($arrUserIds as $iUserId) {
        $objTmpUser->set_userid($iUserId);
        $iTmpVote = $objTmpUser->get_stat(VOTE);
        if ($iTmpVote > 0 && in_array($iTmpVote, $arrUserIds)) {
            $iValidVotes++;
            $arrVotes[$iTmpVote]["votes"]++;
            $arrVotes[$iUserId]["votefor"] = stripslashes($arrVotes[$iTmpVote]["tribename"]);
        }
    }
    // M: Create table rows for each tribe
    $strTableRows = '';
    foreach ($arrUserIds as $iUserId) {
        $objTmpUser->set_userid($iUserId);
        $arrTmpStats = $objTmpUser->get_stats();
        $strTmpTribe = stripslashes($arrTmpStats[TRIBE]);
        // M: Fetch information about this tribe's votes
        $strVoted = stripslashes($arrVotes[$iUserId]["votefor"]);
        $strType = $arrVotes[$iUserId]["playertype"];
        $iVotes = $arrVotes[$iUserId]["votes"];
        if ($iSrcVote == $iUserId) {
            $strChecked = " checked";
        } else {
            $strChecked = "";
        }
        // M: Column for elder to elect co-elder
        $strCoelderTD = '';
        if ($objSrcUser->get_stat(TYPE) == 'elder') {
            if ($strType == "coelder") {
                $strChecked2 = " checked";
            } else {
                $strChecked2 = "";
            }
            $strCoelderTD = '<td>' . '<input type="checkbox" name="voteforcoelder[]" value="' . $iUserId . '"' . $strChecked2 . " />" . "</td>";
        }
        $strTableRows .= '<tr class="data">' . '<th>' . '<label>' . '<input type="radio" name="votefor" value="' . $iUserId . '"' . $strChecked . ' /> <span class="' . $strType . '">' . $strTmpTribe . '</span></label>' . '</th>' . '<td class="left">' . floor($iVotes / max(1, $iValidVotes) * 100) . '%' . '</td>' . '<td class="left">' . $strVoted . '</td>' . $strCoelderTD . "</tr>";
    }
    // M: Vote for donkey (default)
    if ($iSrcVote == '' || $iSrcVote == 0) {
        $strChecked = " checked";
    } else {
        $strChecked = '';
    }
    // M: Extra column for elder to elect co-elders
    if ($objSrcUser->get_stat(TYPE) == 'elder') {
        $iColumns = '4';
        $strThCoelder = "<th class=\"center\">" . "Co-elder" . "</td>";
    } else {
        $iColumns = '3';
        $strThCoelder = '';
    }
    // M: "Elect your elder"-table
    $strElderTable = "<form method=\"post\" action=\"main.php?cat=game&amp;page=vote2\" id=\"center\">" . "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<tr class=\"header\">" . "<th colspan=\"" . $iColumns . "\">" . "Elect Your Elder" . "</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Tribe" . "</th>" . "<th>" . "Votes" . "</th>" . "<th>" . "Voted For" . "</th>" . $strThCoelder . "</tr>" . $strTableRows . "<tr class=\"data\">" . '<th class="bsup" colspan="' . $iColumns . '">' . "<input type=\"radio\" name=\"votefor\" value=\"0\" id=\"0\"" . $strChecked . " /> " . "<label for=\"0\">" . "No Vote" . "</label>" . "</th>" . "</tr>" . "</table><br />" . "<input type=\"submit\" value=\"Vote\" />" . "</form>";
    echo $strElderTable;
}
Exemplo n.º 4
0
function include_research_text()
{
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $arrStats = $objSrcUser->get_stats();
    // M: Navigation links
    $strPurchase = '';
    if ($arrStats[TYPE] == "elder" || $arrStats[TYPE] == "coelder") {
        $strPurchase = "<a href='main.php?cat=game&amp;page=research&amp;action=buy'>Purchase</a> | ";
    }
    $topLinks = '<div class="center">' . '| <a href="main.php?cat=game&amp;page=research&amp;action=view">View/Invest</a> | ' . $strPurchase . '<a href="main.php?cat=game&amp;page=research&amp;action=history">History</a> |' . '</div>';
    echo $topLinks;
    // M: User Tables
    $arrGoods = $objSrcUser->get_goods();
    $arrUserInfos = $objSrcUser->get_user_infos();
    // M: Alliance Tables
    $objSrcAlli = $objSrcUser->get_alliance();
    $arrAlli = $objSrcAlli->get_alliance_infos();
    $arrSci = $objSrcAlli->get_alliance_sciences();
    // M: Get rounded %'s
    foreach ($arrSci as $str => $iBonus) {
        $arrSciMod[$str] = round($iBonus * 100, 2);
    }
    $do = '';
    if (isset($_GET['do']) && !empty($_GET['do'])) {
        $do = strval($_GET['do']);
    }
    $action = 'view';
    if (isset($_GET['action']) && !empty($_GET['action'])) {
        $action = strval($_GET['action']);
    }
    switch ($action) {
        case 'view':
            if ($do == "invest") {
                $invest = max(0, $arrGoods[RESEARCH]);
                if ($arrUserInfos[HOURS] < PROTECTION_HOURS) {
                    echo '<br /><div class="center">' . "Sorry, you can only invest research points once you have left protection.</div><br />";
                    return;
                } elseif ($invest == 0) {
                    echo '<br /><div class="center">' . "I'm sure you meant well, but investing 0 rps will do nothing for our research.</div><br />";
                    return;
                } else {
                    $arrStats[INVESTED] += $invest;
                    $arrAlli[RESEARCH] += $invest;
                    $objSrcUser->set_good(RESEARCH, 0);
                    $objSrcUser->set_stat(INVESTED, $arrStats[INVESTED]);
                    $objSrcAlli->set_alliance_info(RESEARCH, $arrAlli[RESEARCH]);
                    header('location:main.php?cat=game&page=research&action=view&do=thank');
                    exit;
                }
            }
            if ($arrGoods[RESEARCH] > 0) {
                $strMessage = "Our researchers have been working very hard." . "<br />" . "Would you like to invest their produced research points?" . "<form method=\"post\" action=\"main.php?cat=game&amp;page=research&amp;action=view&amp;do=invest\">" . '<label>Available: </label><strong><span class="indicator">' . $arrGoods[RESEARCH] . '</span> rps</strong> ' . "<input type=\"submit\" value=\"Invest\" name=\"invest\" />" . "</form>";
            } elseif ($do == 'thank') {
                $strMessage = "You have invested your research. Your alliance thanks you!";
            } else {
                $strMessage = "We have no research points for you to invest at this moment.";
            }
            $strAdvisorText = '<div id="textMedium">' . "<p>Good morning " . stripslashes($arrStats[NAME]) . "!<br />" . $strMessage . '</p>' . '</div><br />';
            echo $strAdvisorText;
            // M: Show alliance research (new function shared with spells)
            echo get_alliance_science_table($objSrcAlli);
            // M: Show guide link + advice
            include_once 'inc/pages/advisors.inc.php';
            echo get_guide_link($objSrcUser, 'research', 'textMedium');
            break;
        case "buy":
            // M: Restrict access to elders and co-elders
            if ($arrStats[TYPE] == "player") {
                echo "<div class=\"center\">Only your elected elder can purchase the research points you have invested.<br /><br />";
                echo "| <a  href=main.php?cat=game&amp;page=research&action=view style=\"text-decoration:none\">Return To Investing</a> |</div>";
                return;
            }
            // M: Handle POST action
            if ($do == "buy") {
                // M: Clean POST-data
                $invest_prod = max(0, floor(intval($_POST['invest_prod'])));
                $invest_eng = max(0, floor(intval($_POST['invest_eng'])));
                $invest_def = max(0, floor(intval($_POST['invest_def'])));
                $invest_off = max(0, floor(intval($_POST['invest_off'])));
                $iToPurchase = $invest_off + $invest_def + $invest_eng + $invest_prod;
                if ($iToPurchase == 0) {
                    echo "<div class=\"center\">I'm sure you meant well, but purchasing 0 rps will do nothing for our science.</div><br />";
                } elseif ($iToPurchase < 0 || $iToPurchase > 9999999 || $invest_eng < 0 || $invest_eng > 9999999 || $invest_prod < 0 || $invest_prod > 9999999 || $invest_def < 0 || $invest_def > 9999999 || $invest_off < 0 || $invest_off > 9999999) {
                    echo "<div class=\"center\">It's impossible to invest that amount.</div><br />";
                } elseif ($iToPurchase > $arrAlli[RESEARCH]) {
                    echo "<div class=\"center\">How can you purchase research points that you don't have?</div><br />";
                } else {
                    // M: New research
                    $iNewResearch = max(0, $arrAlli[RESEARCH] - $iToPurchase);
                    $arrNewAlliInfos = array(RESEARCH => $iNewResearch, HOME_BONUS => $arrAlli[HOME_BONUS] + $invest_eng, INCOME_BONUS => $arrAlli[INCOME_BONUS] + $invest_prod, DEFENCE_BONUS => $arrAlli[DEFENCE_BONUS] + $invest_def, OFFENCE_BONUS => $arrAlli[OFFENCE_BONUS] + $invest_off);
                    // M: Save to DB
                    $objSrcAlli->set_alliance_infos($arrNewAlliInfos);
                    // M: Show report
                    $strReport = '<div id="textMedium">' . '<h2>Purchase Report</h2>' . "<p>" . "Thank you " . stripslashes($arrStats[NAME]) . ", our research has been updated!" . "</p>" . "<p>" . "You had <strong>" . number_format($arrAlli[RESEARCH]) . " research points</strong> and you used up " . "<strong>" . number_format($iToPurchase) . "</strong>." . "</p>" . "<p>" . '<a href="main.php?cat=game&amp;page=research' . '&amp;action=buy">Return To Purchasing</a>' . '</p>' . '</div>';
                    echo $strReport;
                    include_game_down();
                    exit;
                }
            }
            // M: Show "advisor" text
            if ($arrAlli['research'] != 0) {
                $strMessage = "<br />Our alliance has been working very hard.<br />" . "In what branch of sciences would you like to purchase?";
            } else {
                $strMessage = "<br />We have no research points for you to " . "purchase at this moment.";
            }
            $strAdvisorText = '<div id="textMedium">' . '<p>Good morning ' . $arrStats[NAME] . '!' . $strMessage . '</p>' . '</div><br />';
            echo $strAdvisorText;
            // M: Show purchase interface
            $left = '<img src="' . HOST_PICS . 'bar_left.gif" alt="" />' . '<img src="' . HOST_PICS . 'bar_mid.gif" height="12" width="';
            $right = '%" alt="" /><img src="' . HOST_PICS . 'bar_right.gif" alt="" />';
            $researchPurchase = "<table cellspacing=\"0\" cellpadding=\"0\" class=\"medium\">" . "<form method=\"post\" action=\"main.php?cat=game&amp;page=research&amp;action=buy&amp;do=buy\">" . "<tr class=\"header\">" . "<th colspan=\"4\">Alliance Research</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th width=\"33%\">" . "Type" . "</th>" . "<th>" . "Amount" . "</th>" . "<th width=\"10%\" class=\"center\">" . "%" . "</th>" . "<th width=\"20%\" class=\"right\">" . "Purchase" . "</th>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Production:" . "</th>" . "<td class=\"left\">" . $left . floor($arrSciMod['prod'] * 1.4) . $right . "</td>" . "<td class=\"center\">" . $arrSciMod['prod'] . "</td>" . "<td>" . "<input type=\"text\" name=\"invest_prod\" size=\"8\" maxlength=\"7\" value=\"0\" />" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Engineering:" . "</th>" . "<td class=\"left\">" . $left . floor($arrSciMod['eng'] * 1.4) . $right . "</td>" . "<td class=\"center\">" . $arrSciMod['eng'] . "</td>" . "<td>" . "<input type=\"text\" name=\"invest_eng\" size=\"8\" maxlength=\"7\" value=\"0\" />" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "Defence Tactics:" . "</th>" . "<td class=\"left\">" . $left . floor($arrSciMod['def'] * 1.4) . $right . "</td>" . "<td class=\"center\">" . $arrSciMod['def'] . "</td>" . "<td>" . "<input type=\"text\" name=\"invest_def\" size=\"8\" maxlength=\"7\" value=\"0\" />" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th>" . "War Tactics:" . "</th>" . "<td class=\"left\">" . $left . floor($arrSciMod['war'] * 1.4) . $right . "</td>" . "<td class=\"center\">" . $arrSciMod['war'] . "</td>" . "<td>" . "<input type=\"text\" name=\"invest_off\" size=\"8\" maxlength=\"7\" value=\"0\" />" . "</td>" . "</tr>" . "<tr class=\"data\">" . "<th class=\"bsup\">" . "Available:" . "</th>" . "<td class=\"bsup left\" colspan=\"2\"><strong><span class=\"indicator\">" . number_format($arrAlli['research']) . "</span> rps</strong>" . "</td>" . "<td class=\"bsup\">" . "<input type=\"submit\" value=\"Purchase\" name=\"submit\" />" . "</td>" . "</tr>" . "</form>" . "</table>";
            echo $researchPurchase;
            break;
        case "history":
            echo '<br />';
            $arrUserids = $objSrcAlli->get_userids();
            $objTmpUser = new clsUser(0);
            $strTribesInvested = '';
            foreach ($arrUserids as $iTmpUserid) {
                // M: Clear temporary object (first time trying this method :))
                $objTmpUser->set_userid($iTmpUserid);
                $arrTmpStats = $objTmpUser->get_stats();
                $iTmpAcres = $objTmpUser->get_build(LAND);
                $strTribesInvested .= "<tr class=\"data\">" . "<th>" . stripslashes($arrTmpStats[TRIBE]) . "</th>" . "<td>" . round($arrTmpStats[INVESTED] / $iTmpAcres) . "</td>" . "<td>" . number_format($arrTmpStats[INVESTED]) . " rps</td>" . "</tr>";
            }
            $researchHistoryTable = '<table cellspacing="0" cellpadding="0" class="medium">' . "<tr class=\"header\">" . "<th colspan=\"4\">Investment History</th>" . "</tr>" . "<tr class=\"subheader\">" . "<th>" . "Tribe" . "</th>" . "<th class=\"right\">" . "RPA" . "</th>" . "<th class=\"right\">" . "Amount" . "</th>" . "</tr>" . $strTribesInvested . '</table>';
            echo $researchHistoryTable;
            echo '<div id="textMedium">' . '<h3>What does it mean?</h3>' . '<ul><li>RPA - Research Per Acre' . '</li>' . '<li>rps - research points' . '</li><ul>' . '</div>';
            break;
    }
}
Exemplo n.º 5
0
function get_sponsor_list($strItemId = 'Blue Dragon')
{
    $strReturn = '';
    $objTmpUser = new clsUser(1);
    $resSQL = mysql_query("SELECT item_number as rank, quantity, option_selection1 as username, unix_timestamp, payment_gross as money FROM phpsuppo_3.paypal WHERE (item_name = 'One Week Sponsorship' OR item_name = 'Three Months Sponsorship') AND item_number = '{$strItemId}' AND payment_status = 'Completed' ORDER BY unix_timestamp DESC") or die(mysql_error());
    while ($arrPayPal = mysql_fetch_array($resSQL)) {
        if (check_valid_sponsor($arrPayPal) && $arrPayPal['username'] != 'NULL') {
            $strSafe = quote_smart($arrPayPal['username']);
            $resSQL2 = mysql_query("SELECT id FROM " . TBL_USER . " WHERE username = {$strSafe}") or die(mysql_error());
            $arrRes2 = mysql_fetch_array($resSQL2);
            if ($arrRes2[ID] > 0) {
                $objTmpUser->set_userid($arrRes2[ID]);
                $strReturn .= stripslashes($objTmpUser->get_stat(NAME)) . '<br />';
            } else {
                // Missing an acc in one server, or if deleted (missing user)
                //                 $strReturn .= 'Fierce ' . $arrPayPal['rank'] . '<br />';
            }
        } elseif (check_valid_sponsor($arrPayPal)) {
            $strReturn .= 'Anonymous ' . $arrPayPal['rank'] . '<br />';
        }
    }
    return $strReturn;
}
Exemplo n.º 6
0
function notify_forum_users(&$objSrcUser, $posttype)
{
    switch ($posttype) {
        case 0:
            // Alliance
            // One way to highlight a whole alliance -Martel, September 13, 2007
            include_once 'inc/classes/clsUser.php';
            $objTmpUser = new clsUser(1);
            //M:small performance increaser, reuse
            $objSrcAlliance = $objSrcUser->get_alliance();
            $arrIds = $objSrcAlliance->get_userids();
            foreach ($arrIds as $iUserId) {
                $objTmpUser->set_userid($iUserId);
                $objTmpUser->set_preference(NEW_A, 1);
            }
            break;
        case 1:
            // Staff
            // A way to highlight several alliances... There must be something
            // better, but now it works. Maybe add a method in alliance class
            // to affect all members. Martel, September 13, 2007
            include_once 'inc/classes/clsUser.php';
            $objTmpUser = new clsUser(1);
            //M:small performance increaser, reuse
            $strSQL = "SELECT id FROM " . TBL_STAT . " WHERE level > 1";
            $resSQL = mysql_query($strSQL) or die(mysql_error());
            while ($arrPrefs = mysql_fetch_array($resSQL)) {
                $objTmpUser->set_userid($arrPrefs[ID]);
                $objTmpUser->set_preference(NEW_S, 1);
            }
            break;
        case 2:
            // adding world entry - AI 31/10/06
            // Note: This is bad, because we ignore user objects for performance
            mysql_query("UPDATE " . TBL_PREFERENCES . " SET " . NEW_W . " = 1 WHERE " . NEW_W . " = 0") or die(mysql_error());
            break;
        case 3:
            // Announcements
            // Note: This is bad, because we ignore user objects for performance
            mysql_query("UPDATE " . TBL_PREFERENCES . " SET " . NEW_N . " = 1 WHERE " . NEW_N . " = 0") or die(mysql_error());
            break;
        case 4:
            // Law & Order
            // One way to highlight a whole alliance -Martel, September 13, 2007
            include_once 'inc/classes/clsUser.php';
            $objTmpUser = new clsUser(1);
            //M:small performance increaser, reuse
            include_once 'inc/classes/clsAlliance.php';
            $objSrcAlliance = new clsAlliance(2);
            // Hardcoded alliance id
            $arrIds = (array) $objSrcAlliance->get_userids();
            foreach ($arrIds as $iUserId) {
                $objTmpUser->set_userid($iUserId);
                $objTmpUser->set_preference(NEW_L, 1);
            }
            break;
        case 5:
            // Operations
            // One way to highlight a whole alliance -Martel, September 13, 2007
            include_once 'inc/classes/clsUser.php';
            $objTmpUser = new clsUser(1);
            //M:small performance increaser, reuse
            include_once 'inc/classes/clsAlliance.php';
            $objSrcAlliance = new clsAlliance(3);
            // Hardcoded alliance id
            $arrIds = (array) $objSrcAlliance->get_userids();
            foreach ($arrIds as $iUserId) {
                $objTmpUser->set_userid($iUserId);
                $objTmpUser->set_preference(NEW_O, 1);
            }
            break;
        case 6:
            // Development
            // One way to highlight a whole alliance -Martel, September 13, 2007
            include_once 'inc/classes/clsUser.php';
            $objTmpUser = new clsUser(1);
            //M:small performance increaser, reuse
            include_once 'inc/classes/clsAlliance.php';
            $objSrcAlliance = new clsAlliance(1);
            // Hardcoded alliance id
            $arrIds = (array) $objSrcAlliance->get_userids();
            foreach ($arrIds as $iUserId) {
                $objTmpUser->set_userid($iUserId);
                $objTmpUser->set_preference(NEW_D, 1);
            }
            break;
        case 7:
            // Game Talk
            // Note: This is bad, because we ignore user objects for performance
            mysql_query("UPDATE " . TBL_PREFERENCES . " SET " . NEW_G . " = 1 WHERE " . NEW_G . " = 0") or die(mysql_error());
            break;
        case 8:
            // Dragon Lair (game sponsors)
            $strLogins = "'martel'";
            // hardcoded for sponsor notify SQL string
            $strSQL3 = "SELECT option_selection1 FROM phpsuppo_3.paypal WHERE option_selection1 != 'NULL' GROUP BY option_selection1";
            $resSQL3 = mysql_query($strSQL3);
            while ($arrSQL3 = mysql_fetch_row($resSQL3)) {
                $strLogins .= ", " . quote_smart($arrSQL3[0]);
            }
            // A way to highlight several alliances... There must be something
            // better, but now it works. Maybe add a method in alliance class
            // to affect all members. Martel, September 13, 2007
            include_once 'inc/classes/clsUser.php';
            $objTmpUser = new clsUser(1);
            //M:small performance increaser, reuse
            $strSQL = "SELECT id FROM " . TBL_USER . " WHERE username IN ({$strLogins})";
            $resSQL = mysql_query($strSQL) or die(mysql_error());
            while ($arrPrefs = mysql_fetch_array($resSQL)) {
                $objTmpUser->set_userid($arrPrefs[ID]);
                $objTmpUser->set_preference(NEW_DR, 1);
            }
            break;
    }
}
Exemplo n.º 7
0
function doWarSurrender(&$objSuxAlli, &$objWinAlli)
{
    global $orkTime;
    $winner = $objWinAlli->get_allianceid();
    $looser = $objSuxAlli->get_allianceid();
    // Clear events
    $iEventid1 = $objWinAlli->get_war('event_id');
    $iEventid2 = $objSuxAlli->get_war('event_id');
    clearEvents($iEventid1, $iEventid2);
    // Get game hours
    require_once 'inc/classes/clsGame.php';
    $objGame = new clsGame();
    $arrGameTime = $objGame->get_game_times();
    // M: Update winner alli
    $arrWinWar = $objWinAlli->get_wars();
    $arrNewWinWar = array('target' => 0, 'last_target' => $looser, 'last_outgoing' => 'victory', 'last_end' => $arrGameTime['hour_counter'], 'victory' => $arrWinWar['victory'] + 1, 'event_id' => '');
    $objWinAlli->set_wars($arrNewWinWar);
    // M: Update looser alli
    $arrSuxWar = $objSuxAlli->get_wars();
    $arrNewSuxWar = array('target' => 0, 'last_target' => $winner, 'last_outgoing' => 'surrender', 'last_end' => $arrGameTime['hour_counter'], 'surrender' => $arrSuxWar['surrender'] + 1, 'event_id' => '');
    $objSuxAlli->set_wars($arrNewSuxWar);
    // M: Update winner alli fame
    $objTmpUser = new clsUser(0);
    $arrUserId = $objWinAlli->get_userids();
    foreach ($arrUserId as $iUserid) {
        $objTmpUser->set_userid($iUserid);
        $iNewFame = $objTmpUser->get_stat('fame') + WAR_SURRENDER_FAME;
        $objTmpUser->set_stat('fame', $iNewFame);
    }
    // M: Update looser alli fame
    $arrUserId = $objSuxAlli->get_userids();
    foreach ($arrUserId as $iUserid) {
        $objTmpUser->set_userid($iUserid);
        $iNewFame = max(0, $objTmpUser->get_stat('fame') - WAR_SURRENDER_FAME);
        $objTmpUser->set_stat('fame', $iNewFame);
    }
    // M: Transfer research
    $arrResearch = moveResearch($objSuxAlli, $objWinAlli, WAR_SURRENDER_LOSSES);
    // M: Transfer market goods (Atm this is the same % as regular victory)
    $arrMarket = moveMarketGoods($objSuxAlli, $objWinAlli, WAR_VICTORY_GOODS);
    // News for winner, looser and global
    mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'war-end', '0', '0', '1', '', '<strong class=\"positive\">We were victorious in the war with alliance #{$looser}!</strong>', '{$winner}', '')");
    mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'war-end', '0', '0', '1', '', '<strong class=\"negative\">We have surrendered in the war with #{$winner}!</strong>', '{$looser}', '')");
    mysql_query("INSERT INTO news (id, time, ip, type, duser, ouser, result, text, kingdom_text, kingdoma, kingdomb) VALUES ('', '{$orkTime}', '---', 'global', '0', '0', '1', '', '<strong class=\"positive\">Alliance #{$looser} have surrendered! #{$winner} wins!</strong>', '0', '')");
    return array($arrResearch, $arrMarket);
}