function declineOrganization($getPage_connection2) { if (strlen($_SESSION["action"]) >= 1) { if ($_SESSION["action"] == "decline") { if ($_SESSION["nation_id"] >= 1) { $nationInfoSelect = getNationInfo($getPage_connection2, $_SESSION["nation_id"]); if ($_SESSION["org"] >= 1) { $organizationInfoSelect = getOrganizationInfo($getPage_connection2, $_SESSION["org"]); $new_invites = array(0 => 0); $counter = 0; $nationInfoM = getNationInfo($getPage_connection2, $_SESSION["nation_id"]); for ($z = 0; $z < count($nationInfoM["invites"]); $z++) { if ($_SESSION["org"] != $nationInfoM["invites"][$z]) { $new_invites[$counter] = $nationInfoM["invites"][$z]; $counter++; } // if } // for setNationInfo($getPage_connection2, $nationInfoSelect["id"], $nationInfoSelect["name"], $nationInfoSelect["home"], $nationInfoSelect["formal"], $nationInfoSelect["flag"], $nationInfoSelect["production"], $nationInfoSelect["money"], $nationInfoSelect["debt"], $nationInfoSelect["happiness"], $nationInfoSelect["food"], $nationInfoSelect["authority"], $nationInfoSelect["authorityChanged"], $nationInfoSelect["economy"], $nationInfoSelect["economyChanged"], $nationInfoSelect["organizations"], $new_invites, $nationInfoSelect["goods"], $nationInfoSelect["resources"], $nationInfoSelect["population"], $nationInfoSelect["strike"]); $new_pending = array(0 => 0); $counter = 0; $organizationInfoM = getOrganizationInfo($getPage_connection2, $_SESSION["org"]); for ($z = 0; $z < count($organizationInfoM["pending"]); $z++) { if ($_SESSION["nation_id"] != $organizationInfoM["pending"][$z]) { $new_pending[$counter] = $organizationInfoM["pending"][$z]; $counter++; } // if } // for setOrganizationInfo($getPage_connection2, $_SESSION["org"], $organizationInfoSelect["name"], $organizationInfoSelect["members"], $organizationInfoSelect["managers"], $new_pending, $organizationInfoSelect["ranking"]); $_SESSION["success_message"] = "Nation has declined organization successfully!"; } else { $_SESSION["warning_message"] = "Cannot complete action: organization is not valid."; } // else } else { $_SESSION["warning_message"] = "Cannot complete action: nation is not valid."; } // else } else { $_SESSION["warning_message"] = "Cannot complete action: action is not valid."; } // else } else { $_SESSION["warning_message"] = "Cannot complete action: action is not valid."; } // else }
function showPoliciesInfo($getPage_connection2) { $nationInfo = getNationInfo($getPage_connection2, $_SESSION["nation_id"]); $continentInfo = getContinentInfo($getPage_connection2, $nationInfo["home"]); $productionInfo = getProductionInfo($getPage_connection2, $_SESSION["nation_id"]); $authorityReport = getAuthorityReport($nationInfo["authority"]); $economyReport = getEconomyReport($nationInfo["economy"]); $rankingInfo = getRankingInfo($getPage_connection2, $_SESSION["nation_id"]); echo " <div class=\"spacing-from-menu well well-lg standard-text\">\n"; echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"View basic govermental policies.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">Government <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseGovernment\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseGovernment\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; echo " <h3>" . $nationInfo["formal"] . "</h3>\n"; echo " <br />\n"; if (strlen($nationInfo["flag"]) >= 1) { echo " <img class=\"info_flag\" src=\"" . $nationInfo["flag"] . "\" alt=\"Flag of " . $nationInfo["name"] . "\" />\n"; } else { echo " <img class=\"info_flag\" src=\"images/blank.png\" alt=\"Flag of " . $nationInfo["name"] . "\" />\n"; } // else echo " <br />\n"; echo " <br />\n"; echo " <br />\n"; echo " Home Continent: " . $continentInfo["name"] . " (" . $nationInfo["home"] . ") \n"; echo " <br />\n"; echo " Authority: " . $nationInfo["authority"] . "/10\n"; echo " <br />\n"; echo " " . $authorityReport . "\n"; echo " <br />\n"; echo " Economy: " . $nationInfo["economy"] . "/10\n"; echo " <br />\n"; echo " " . $economyReport . "\n"; echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Change basic govermental policies.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">Change Policies <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseChange\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseChange\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; echo " <label class=\"control-label\">Reform Government:</label> \n"; echo " <form action=\"index.php?page=policies\" method=\"post\">\n"; echo " <input type=\"hidden\" name=\"page\" value=\"policies\" />\n"; if ($nationInfo["authorityChanged"] == 0) { echo " <div class=\"form-group form-group-sm\">\n"; if ($nationInfo["authority"] > 0) { echo " <button onclick=\"loadButton(this)\" data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Decrease authority. This will mean less state control of society.\" value=\"aminus\" name=\"action\" id=\"authority_decrease\" type=\"submit\" class=\"btn btn-md btn-primary\"><span class=\"glyphicon glyphicon-minus\"></span></button>\n"; } // if echo " Authority\n"; if ($nationInfo["authority"] < 10) { echo " <button onclick=\"loadButton(this)\" data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Increase authority. This will mean more state control of society.\" value=\"aplus\" name=\"action\" id=\"authority_increase\" type=\"submit\" class=\"btn btn-md btn-primary\"><span class=\"glyphicon glyphicon-plus\"></span></button>\n"; } // if echo " </div>\n"; } else { echo " Authority has already been reformed this turn. <br />\n"; } // else if ($nationInfo["economyChanged"] == 0) { echo " <div class=\"form-group form-group-sm\">\n"; if ($nationInfo["economy"] > 0) { echo " <button onclick=\"loadButton(this)\" data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Decrease economic control. This will mean less state intervention in the economy.\" value=\"eminus\" name=\"action\" id=\"economy_decrease\" type=\"submit\" class=\"btn btn-md btn-primary\"><span class=\"glyphicon glyphicon-minus\"></span></button>\n"; } // if echo " Economy\n"; if ($nationInfo["economy"] < 10) { echo " <button onclick=\"loadButton(this)\" data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Increase economic control. This will mean more state intervention in the economy.\" value=\"eplus\" name=\"action\" id=\"economy_increase\" type=\"submit\" class=\"btn btn-md btn-primary\"><span class=\"glyphicon glyphicon-plus\"></span></button>\n"; } // if echo " </div>\n"; } else { echo " Economy has already been reformed this turn. <br />\n"; } // else echo " <div class=\"form-group form-group-sm\">\n"; echo " <label class=\"control-label\" for=\"formal\">Formal Name:</label>\n"; echo " <input name=\"formalname\" type=\"text\" class=\"form-control input-md\" id=\"formal\" placeholder=\"New Formal Name of Nation\" />\n"; echo " <button onclick=\"loadButton(this)\" data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Change long formal name of nation. This will not affect the regular short name of your nation!\" value=\"formal\" name=\"action\" id=\"formal_change\" type=\"submit\" class=\"btn btn-md btn-primary\">Change Formal Name</button>\n"; echo " </div>\n"; echo " </form>\n"; echo " <form action=\"index.php?page=policies&action=flag\" method=\"post\" enctype=\"multipart/form-data\">\n"; echo " <div class=\"form-group form-group-sm\">\n"; echo " <label class=\"control-label\" for=\"fileToUpload\">Upload New Flag:</label>\n"; echo " <br />\n"; echo " <span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Select an image file from your computer to be your new flag.\" class=\"btn btn-med btn-default btn-file\">\n"; echo " Browse <input type=\"file\" name=\"fileToUpload\" id=\"fileToUpload\" />\n"; echo " </span>\n"; echo " <button onclick=\"loadButton(this)\" data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Upload your new flag.\" value=\"flag\" name=\"action\" type=\"submit\" class=\"btn btn-md btn-primary\">Change Flag</button>\n"; echo " </div>\n"; echo " </form>\n"; echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Change production expenditure and prioritization.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">Production <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseProduction\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseProduction\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; echo " <form action=\"index.php?page=policies\" method=\"post\">\n"; echo " <div class=\"form-group form-group-sm\">\n"; echo " <input type=\"hidden\" name=\"page\" value=\"policies\" />\n"; echo " <label class=\"control-label\" for=\"slider1\">Production Spending Percentage:</label>\n"; echo " <input data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Change the amount of production you spend for this turn. Remember that production does not transfer over to the next turn!\" name=\"prod-percent\" id=\"slider1\" type=\"range\" min=\"0\" max=\"100\" step=\"5\" value=\"" . $productionInfo["spending"] . "\" class=\"\" />\n"; echo " <br />\n"; $productionInfo1 = getProductionInfo($getPage_connection2, $_SESSION["nation_id"]); if ($productionInfo1["id"] >= 1) { for ($k = 0; $k < count($productionInfo1["goods"]) + 1; $k++) { $new_index = $k + 1; $goodsInfo2 = getGoodsInfo($getPage_connection2, $new_index); if ($goodsInfo2["id"] >= 1) { echo " <label class=\"control-label\" for=\"slider_prod-" . $goodsInfo2["name"] . "\">Emphasize " . $goodsInfo2["name"] . ":</label>\n"; echo " " . round($goodsInfo2["productionRequired"], 2, PHP_ROUND_HALF_UP) . " Production, " . round($goodsInfo2["foodRequired"], 2, PHP_ROUND_HALF_UP) . " Food"; for ($t = 0; $t < count($goodsInfo2["resourceTypesRequired"]); $t++) { if ($goodsInfo2["resourceTypesRequired"][$t] >= 1) { echo ", "; $resourceTypeInfo1 = getResourceTypeInfo($getPage_connection2, $goodsInfo2["resourceTypesRequired"][$t]); echo $goodsInfo2["resourceQuantitiesRequired"][$t] . " " . $resourceTypeInfo1["name"]; } // if } // for echo "\n"; $productionType = $goodsInfo2["id"]; if (strlen($productionType) >= 1) { echo " <input data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Change prioritization of producing this good.\" name=\"prod[" . $k . "]\" id=\"slider_prod-" . $productionType . "\" type=\"range\" min=\"0\" max=\"3\" step=\"1\" value=\"" . $productionInfo1["goods"][$k] . "\" />\n"; } else { echo " <input data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Change prioritization of producing this good.\" name=\"prod[" . $k . "]\" id=\"slider_prod-" . $productionType . "\" type=\"range\" min=\"0\" max=\"3\" step=\"1\" value=\"0\" />\n"; } // else } // if } // for } // if echo " <button onclick=\"loadButton(this)\" data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"Submit changes to production expenditure and prioritization.\" value=\"prod\" name=\"action\" id=\"prod_change\" type=\"submit\" class=\"btn btn-md btn-primary\">Set Production</button>\n"; echo " </div>\n"; echo " </form>\n"; echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"View general information about nation.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">General <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseGeneral\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseGeneral\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; echo " Production: " . $nationInfo["production"] . ", #" . $rankingInfo["production"] . " in world\n"; echo " <br />\n"; echo " Money: " . $nationInfo["money"] . ", #" . $rankingInfo["money"] . " in world\n"; echo " <br />\n"; echo " Debt: " . $nationInfo["debt"] . "\n"; echo " <br />\n"; if ($nationInfo["happiness"] >= 4) { echo " Happiness: <img src=\"images/happiness/4.png\" alt=\"Very Happy\" />" . $nationInfo["happiness"] . ", #" . $rankingInfo["happiness"] . " in world\n"; } else { if ($nationInfo["happiness"] >= 3) { echo " Happiness: <img src=\"images/happiness/3.png\" alt=\"Happy\" />" . $nationInfo["happiness"] . ", #" . $rankingInfo["happiness"] . " in world\n"; } else { if ($nationInfo["happiness"] >= 2) { echo " Happiness: <img src=\"images/happiness/2.png\" alt=\"Neutral\" />" . $nationInfo["happiness"] . ", #" . $rankingInfo["happiness"] . " in world\n"; } else { echo " Happiness: <img src=\"images/happiness/1.png\" alt=\"Unhappy\" />" . $nationInfo["happiness"] . ", #" . $rankingInfo["happiness"] . " in world\n"; } } } // else echo " <br />\n"; echo " Food: " . round($nationInfo["food"], 2, PHP_ROUND_HALF_UP) . ", #" . $rankingInfo["food"] . " in world\n"; echo " <br />\n"; echo " Population: " . $nationInfo["population"] . ", #" . $rankingInfo["population"] . " in world\n"; echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"View goods inventory statistics of nation.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">Goods <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseGoods\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseGoods\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; for ($zz = 0; $zz < count($nationInfo["goods"]); $zz++) { $goodsInfoK = getGoodsInfo($getPage_connection2, $zz + 1); echo " " . $goodsInfoK["name"] . ": " . $nationInfo["goods"][$zz] . "\n"; echo " <br />\n"; } // for echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"View resources inventory statistics of nation.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">Resources <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseResources\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseResources\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; for ($zz = 0; $zz < count($nationInfo["resources"]); $zz++) { $resourceTypeInfoK = getResourceTypeInfo($getPage_connection2, $zz + 1); echo " " . $resourceTypeInfoK["name"] . ": " . $nationInfo["resources"][$zz] . "\n"; echo " <br />\n"; } // for echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"View organizations that nation is currently a member of.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">Organizations <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseOrganizations\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseOrganizations\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; echo " "; $belongstoOrgs = false; for ($z = 0; $z < count($nationInfo["organizations"]); $z++) { if ($z >= 1 && $nationInfo["organizations"][0] > 0) { echo ", "; } // if if ($nationInfo["organizations"][$z] >= 1) { $organizationInfo1 = getOrganizationInfo($getPage_connection2, $nationInfo["organizations"][$z]); echo "<a href=\"index.php?page=info&section=orgs&info_id=" . $organizationInfo1["id"] . "\">" . $organizationInfo1["name"] . "</a>"; if (strlen($organizationInfo1["name"]) >= 1) { $belongsToOrgs = true; } // if } // if } // for echo " \n"; echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; }
function showInfoInfo($getPage_connection2) { echo " <div class=\"spacing-from-menu well well-lg standard-text\">\n"; if ($_SESSION["section"] == "nations") { $nationInfo = getNationInfo($getPage_connection2, $_SESSION["info_id"]); $continentInfo = getContinentInfo($getPage_connection2, $nationInfo["home"]); $authorityReport = getAuthorityReport($nationInfo["authority"]); $economyReport = getEconomyReport($nationInfo["economy"]); $rankingInfo = getRankingInfo($getPage_connection2, $_SESSION["info_id"]); echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"View basic govermental policies.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">Government <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseGovernment\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseGovernment\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; echo " <h3>" . $nationInfo["formal"] . "</h3>\n"; echo " <br />\n"; if (strlen($nationInfo["flag"]) >= 1) { echo " <img class=\"info_flag\" src=\"" . $nationInfo["flag"] . "\" alt=\"Flag of " . $nationInfo["name"] . "\" />\n"; } else { echo " <img class=\"info_flag\" src=\"images/blank.png\" alt=\"Flag of " . $nationInfo["name"] . "\" />\n"; } // else echo " <br />\n"; echo " <br />\n"; echo " <br />\n"; echo " Home Continent: " . $continentInfo["name"] . " (" . $nationInfo["home"] . ") \n"; echo " <br />\n"; echo " Authority: " . $nationInfo["authority"] . "/10\n"; echo " <br />\n"; echo " " . $authorityReport . "\n"; echo " <br />\n"; echo " Economy: " . $nationInfo["economy"] . "/10\n"; echo " <br />\n"; echo " " . $economyReport . "\n"; echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"View general information about nation.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">General <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseGeneral\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseGeneral\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; echo " Production: " . $nationInfo["production"] . ", #" . $rankingInfo["production"] . " in world\n"; echo " <br />\n"; echo " Money: " . $nationInfo["money"] . ", #" . $rankingInfo["money"] . " in world\n"; echo " <br />\n"; echo " Debt: " . $nationInfo["debt"] . "\n"; echo " <br />\n"; if ($nationInfo["happiness"] >= 4) { echo " Happiness: <img src=\"images/happiness/4.png\" alt=\"Very Happy\" />" . $nationInfo["happiness"] . ", #" . $rankingInfo["happiness"] . " in world\n"; } else { if ($nationInfo["happiness"] >= 3) { echo " Happiness: <img src=\"images/happiness/3.png\" alt=\"Happy\" />" . $nationInfo["happiness"] . ", #" . $rankingInfo["happiness"] . " in world\n"; } else { if ($nationInfo["happiness"] >= 2) { echo " Happiness: <img src=\"images/happiness/2.png\" alt=\"Neutral\" />" . $nationInfo["happiness"] . ", #" . $rankingInfo["happiness"] . " in world\n"; } else { echo " Happiness: <img src=\"images/happiness/1.png\" alt=\"Unhappy\" />" . $nationInfo["happiness"] . ", #" . $rankingInfo["happiness"] . " in world\n"; } } } // else echo " <br />\n"; echo " Food: " . round($nationInfo["food"], 2, PHP_ROUND_HALF_UP) . ", #" . $rankingInfo["food"] . " in world\n"; echo " <br />\n"; echo " Population: " . $nationInfo["population"] . ", #" . $rankingInfo["population"] . " in world\n"; echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"View organizations that nation is currently a member of.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">Organizations <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseOrganizations\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseOrganizations\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; echo " "; $belongstoOrgs = false; for ($z = 0; $z < count($nationInfo["organizations"]); $z++) { if ($z >= 1 && $nationInfo["organizations"][0] > 0) { echo ", "; } // if if ($nationInfo["organizations"][$z] >= 1) { $organizationInfo1 = getOrganizationInfo($getPage_connection2, $nationInfo["organizations"][$z]); echo "<a href=\"index.php?page=info&section=orgs&info_id=" . $organizationInfo1["id"] . "\">" . $organizationInfo1["name"] . "</a>"; if (strlen($organizationInfo1["name"]) >= 1) { $belongsToOrgs = true; } // if } // if } // for echo " \n"; echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; } else { $organizationInfo = getOrganizationInfo($getPage_connection2, $_SESSION["info_id"]); echo " <div class=\"panel panel-info\">\n"; echo " <div data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"View general information about organization.\" class=\"panel-heading\">\n"; echo " <h3 class=\"panel-title\">General <button type=\"button\" class=\"btn btn-default btn-md collapsed\" data-toggle=\"collapse\" data-target=\"#collapseGeneral\"><span class=\"glyphicon glyphicon-plus\"></span>/<span class=\"glyphicon glyphicon-minus\"></span></button></h3>\n"; echo " </div>\n"; echo " <div id=\"collapseGeneral\" class=\"panel-body collapse in\">\n"; echo " <div class=\"col-md-8 col-center\">\n"; echo " <h3>" . $organizationInfo["name"] . "</h3>\n"; echo " <br />\n"; echo " Ranking: " . $organizationInfo["ranking"] . " \n"; echo " <br />\n"; echo " <br />\n"; echo " Managers: " . count($organizationInfo["managers"]) . "\n"; echo " <br />\n"; for ($z = 0; $z < count($organizationInfo["managers"]); $z++) { if ($z >= 1) { echo ", "; } // if if ($organizationInfo["managers"][$z] >= 1) { $nationInfo1 = getNationInfo($getPage_connection2, $organizationInfo["managers"][$z]); echo "<a href=\"index.php?page=info&section=nations&info_id=" . $nationInfo1["id"] . "\">" . $nationInfo1["name"] . "</a>"; } // if } // for echo " <br />\n"; echo " Members: " . count($organizationInfo["members"]) . "\n"; echo " <br />\n"; for ($za = 0; $z < count($organizationInfo["members"]); $za++) { if ($za >= 1) { echo ", "; } // if if ($organizationInfo["members"][$za] >= 1) { $nationInfo1 = getNationInfo($getPage_connection2, $organizationInfo["members"][$za]); echo "<a href=\"index.php?page=info&section=nations&info_id=" . $nationInfo1["id"] . "\">" . $nationInfo1["name"] . "</a>"; } // if } // for echo " </div>\n"; echo " </div>\n"; echo " </div>\n"; } // else echo " </div>\n"; }
function processSearch($getPage_connection2, $searchTerms) { $validSearch = false; $foundSomething = false; $output = "Results for "; for ($a = 0; $a < count($searchTerms); $a++) { $output .= " \"{$searchTerms[$a]}\" \n"; } // for $output .= "<br /><br />\n"; $stringSearchTerms = implode(" ", $searchTerms); if (strlen($stringSearchTerms) > 5 && strlen($stringSearchTerms) < 75) { $validSearch = true; } else { $validSearch = false; } // else if ($validSearch === true) { $stringSearchTerms = strtolower($stringSearchTerms); $stringSearchTerms1 = "%" . $stringSearchTerms . "%"; // nation search // go through 4 possibilities for ($qa = 0; $qa < 4; $qa++) { $offset = $qa; $nationSearchInfo1 = array("id" => 0, "name" => ""); // first, search for exact match if ($stmt = $getPage_connection2->prepare("SELECT id FROM nations WHERE LOWER(name) LIKE ? OR LOWER(formal) LIKE ? LIMIT 1 OFFSET ?")) { $stmt->bind_param("ssi", $stringSearchTerms, $stringSearchTerms, $offset); $stmt->execute(); $stmt->bind_result($r_id); $stmt->fetch(); $nationSearchInfo1["id"] = $r_id; $stmt->close(); } else { } // else // if exact match found, if ($nationSearchInfo1["id"] > 0) { $foundSomething = true; $resultsInfo1 = getNationInfo($getPage_connection2, $nationSearchInfo1["id"]); $output .= "Nation: <a href=\"index.php?page=info&section=nations&info_id=" . $resultsInfo1["id"] . "\">" . $resultsInfo1["name"] . "</a> <br />\n"; break; // otherwise look for rough match, } else { // second, search for inclusive match if ($stmt = $getPage_connection2->prepare("SELECT id FROM nations WHERE LOWER(name) LIKE ? OR LOWER(formal) LIKE ? LIMIT 1 OFFSET ?")) { $stmt->bind_param("ssi", $stringSearchTerms1, $stringSearchTerms1, $offset); $stmt->execute(); $stmt->bind_result($r_id); $stmt->fetch(); $nationSearchInfo1["id"] = $r_id; $stmt->close(); } else { } // else // if match found, if ($nationSearchInfo1["id"] > 0) { $foundSomething = true; $resultsInfo1 = getNationInfo($getPage_connection2, $nationSearchInfo1["id"]); $output .= "Nation: <a href=\"index.php?page=info&section=nations&info_id=" . $resultsInfo1["id"] . "\">" . $resultsInfo1["name"] . "</a> <br />\n"; } else { } // else } // else } // for // organizations search // go through 4 possibilities for ($qb = 0; $qb < 4; $qb++) { $offset = $qb; $orgSearchInfo1 = array("id" => 0, "name" => ""); // first, search for exact match if ($stmt = $getPage_connection2->prepare("SELECT id FROM organizations WHERE LOWER(name) LIKE ? LIMIT 1 OFFSET ?")) { $stmt->bind_param("si", $stringSearchTerms, $offset); $stmt->execute(); $stmt->bind_result($r_id); $stmt->fetch(); $orgSearchInfo1["id"] = $r_id; $stmt->close(); } else { } // else // if exact match found, if ($orgSearchInfo1["id"] > 0) { $foundSomething = true; $resultsInfo2 = getOrganizationInfo($getPage_connection2, $orgSearchInfo1["id"]); $output .= "Organization: <a href=\"index.php?page=info&section=nations&info_id=" . $resultsInfo2["id"] . "\">" . $resultsInfo2["name"] . "</a> <br />\n"; break; // otherwise look for rough match, } else { // second, search for inclusive match if ($stmt = $getPage_connection2->prepare("SELECT id FROM organizations WHERE LOWER(name) LIKE ? LIMIT 1 OFFSET ?")) { $stmt->bind_param("si", $stringSearchTerms1, $offset); $stmt->execute(); $stmt->bind_result($r_id); $stmt->fetch(); $orgSearchInfo1["id"] = $r_id; $stmt->close(); } else { } // else // if match found, if ($orgSearchInfo1["id"] > 0) { $foundSomething = true; $resultsInfo2 = getOrganizationInfo($getPage_connection2, $orgSearchInfo1["id"]); $output .= "Organization: <a href=\"index.php?page=info&section=orgs&info_id=" . $resultsInfo2["id"] . "\">" . $resultsInfo2["name"] . "</a> <br />\n"; } else { } // else } // else } // for if ($foundSomething === false) { $output .= "No results found."; } // if } else { $output .= "Search length requirements are not met! Search must be 5-75 characters long.\n"; } // else return $output; }
function updateGlobe($getPage_connection2) { // change requirements of luxury and basic goods // set luxurygoods $goodsInfoW = getGoodsInfo($getPage_connection2, 5); if ($goodsInfoW["productionRequired"] - 2 > 1) { $new_productionRequired = mt_rand($goodsInfoW["productionRequired"] - 2, $goodsInfoW["productionRequired"] + 2); } else { $new_productionRequired = mt_rand(1, $goodsInfoW["productionRequired"] + 2); } // else if ($new_productionRequired < 1) { $new_productionRequired = 1; } // if $rand_metals = 2; $rand_wood = 1; $rand_metals = mt_rand(2, 10); $rand_wood = mt_rand(2, 10); $new_resourceTypesRequired = array(0 => 0); $new_resourceQuantitiesRequired = array(0 => 0); if ($rand_wood > 0) { $new_resourceTypesRequired[0] = 1; $new_resourceQuantitiesRequired[0] = $rand_wood; } // if if ($rand_metals > 0) { $new_resourceTypesRequired[1] = 2; $new_resourceQuantitiesRequired[1] = $rand_metals; } // if setGoodsInfo($getPage_connection2, $goodsInfoW["id"], $goodsInfoW["name"], $new_productionRequired, $goodsInfoW["foodRequired"], $new_resourceTypesRequired, $new_resourceQuantitiesRequired, $goodsInfoW["improvementTypesRequired"], $goodsInfoW["improvementQuantitiesRequired"], $goodsInfoW["improvementLevelRequired"], $goodsInfoW["buyStrength"], $goodsInfoW["sellStrength"]); // set basicgoods $goodsInfoW = getGoodsInfo($getPage_connection2, 6); if ($goodsInfoW["productionRequired"] - 2 > 1) { $new_productionRequired = mt_rand($goodsInfoW["productionRequired"] - 2, $goodsInfoW["productionRequired"] + 2); } else { $new_productionRequired = mt_rand(0, $goodsInfoW["productionRequired"] + 2); } // else if ($new_productionRequired < 1) { $new_productionRequired = 1; } // if $rand_metals = 1; $rand_wood = 1; $rand_metals = mt_rand(1, 8); $rand_wood = mt_rand(1, 8); $new_resourceTypesRequired = array(0 => 0); $new_resourceQuantitiesRequired = array(0 => 0); if ($rand_wood > 0) { $new_resourceTypesRequired[0] = 1; $new_resourceQuantitiesRequired[0] = $rand_wood; } // if if ($rand_metals > 0) { $new_resourceTypesRequired[1] = 2; $new_resourceQuantitiesRequired[1] = $rand_metals; } // if setGoodsInfo($getPage_connection2, $goodsInfoW["id"], $goodsInfoW["name"], $new_productionRequired, $goodsInfoW["foodRequired"], $new_resourceTypesRequired, $new_resourceQuantitiesRequired, $goodsInfoW["improvementTypesRequired"], $goodsInfoW["improvementQuantitiesRequired"], $goodsInfoW["improvementLevelRequired"], $goodsInfoW["buyStrength"], $goodsInfoW["sellStrength"]); // set new market rates if ($stmt = $getPage_connection2->prepare("SELECT id FROM goods ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_result); while ($stmt->fetch()) { $next_goods = $r_result; $goodsInfoW = getGoodsInfo($getPage_connection2, $next_goods); $marketInfoW = getMarketInfo($getPage_connection2, $next_goods); $rate = 0; // if buy strength is more, increase rate, otherwise decrease or remain constant if ($goodsInfoW["buyStrength"] > $goodsInfoW["sellStrength"]) { $randRateBonus = mt_rand(1, 4); $rate = $marketInfoW["rate"] + $randRateBonus; } else { if ($goodsInfoW["buyStrength"] < $goodsInfoW["sellStrength"]) { $randFlux = mt_rand(1, 4); // random drop or rise (75% more likely drop) if ($randFlux == 1) { $randRateBonus = mt_rand(1, 2); $rate = $marketInfoW["rate"] + $randRateBonus; } else { $randRateBonus = mt_rand(1, 4); $rate = $marketInfoW["rate"] - $randRateBonus; } // else } else { $randFlux = mt_rand(1, 2); // random drop or rise (50/50) if ($randFlux == 1) { $randRateBonus = mt_rand(1, 2); $rate = $marketInfoW["rate"] + $randRateBonus; } else { $randRateBonus = mt_rand(1, 2); $rate = $marketInfoW["rate"] - $randRateBonus; } // else } } // else if ($rate >= 1) { setMarketInfo($getPage_connection2, $next_goods, $marketInfoW["name"], $rate); } else { setMarketInfo($getPage_connection2, $next_goods, $marketInfoW["name"], 0); } // else // reset strength of good for next turn (no reset for now) //setGoodsInfo($getPage_connection2,$goodsInfoW["id"],$goodsInfoW["name"],$goodsInfoW["productionRequired"],$goodsInfoW["foodRequired"],$goodsInfoW["resourceTypesRequired"],$goodsInfoW["resourceQuantitiesRequired"],$goodsInfoW["improvementTypesRequired"],$goodsInfoW["improvementQuantitiesRequired"],$goodsInfoW["improvementLevelRequired"],100,100); } // while $stmt->close(); } else { } // else // add to turn counter for trade offers if ($stmt = $getPage_connection2->prepare("SELECT id FROM offers ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_result); while ($stmt->fetch()) { $next_offers = $r_result; $offerInfo1 = getOfferInfo($getPage_connection2, $next_offers); $new_counter = $offerInfo1["counter"] + 1; setOfferInfo($getPage_connection2, $offerInfo1["id"], $offerInfo1["fromNation"], $offerInfo1["toNation"], $offerInfo1["givingItems"], $offerInfo1["receivingItems"], $offerInfo1["givingQuantities"], $offerInfo1["receivingQuantities"], $offerInfo1["givingTypes"], $offerInfo1["receivingTypes"], $offerInfo1["turns"], $new_counter, $offerInfo1["status"]); } // while $stmt->close(); } else { } // else // remove empty organizations, automatically appoint new manager if there is no manager (new manager is the oldest joined member) if ($stmt = $getPage_connection2->prepare("SELECT id FROM organizations ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_result); while ($stmt->fetch()) { $next_organizations = $r_result; $organizationInfo1 = getOrganizationInfo($getPage_connection2, $next_organizations); $new_managers = array(0 => 0); if (count($organizationInfo1["members"]) == 1) { if ($organizationInfo1["members"][0] == 0) { deleteOrganizationInfo($getPage_connection2, $next_organizations); } // if } else { if (count($organizationInfo1["members"]) > 1) { if (count($organizationInfo1["managers"]) == 1) { if ($organizationInfo1["managers"][0] == 0) { $new_managers[0] = $organizationInfo1["members"][0]; setOrganizationInfo($getPage_connection2, $next_organizations, $organizationInfo1["name"], $organizationInfo1["members"], $new_managers, $organizationInfo1["pending"], $organizationInfo1["ranking"]); } // if } else { } // else } else { deleteOrganizationInfo($getPage_connection2, $next_organizations); } } // else } // while $stmt->close(); } else { } // else // set rankings if ($stmt = $getPage_connection2->prepare("SELECT id FROM nations ORDER BY id ASC")) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($r_result); $offset = 0; while ($stmt->fetch()) { $next_nations = $r_result; $rank = $offset + 1; // production if ($stmt11 = $getPage_connection2->prepare("SELECT id FROM nations ORDER BY production DESC LIMIT 1 OFFSET ?")) { $stmt11->bind_param("i", $offset); $stmt11->execute(); $stmt11->bind_result($r_result); $stmt11->fetch(); $next_production_nation = $r_result; $stmt11->close(); } else { } // else if ($stmt11 = $getPage_connection2->prepare("UPDATE rankings SET production=? WHERE nation=?")) { $stmt11->bind_param("ii", $rank, $next_production_nation); $stmt11->execute(); $stmt11->close(); } else { } // else // money if ($stmt11 = $getPage_connection2->prepare("SELECT id FROM nations ORDER BY money DESC LIMIT 1 OFFSET ?")) { $stmt11->bind_param("i", $offset); $stmt11->execute(); $stmt11->bind_result($r_result); $stmt11->fetch(); $next_money_nation = $r_result; $stmt11->close(); } else { } // else if ($stmt11 = $getPage_connection2->prepare("UPDATE rankings SET money=? WHERE nation=?")) { $stmt11->bind_param("ii", $rank, $next_money_nation); $stmt11->execute(); $stmt11->close(); } else { } // else // happiness if ($stmt11 = $getPage_connection2->prepare("SELECT id FROM nations ORDER BY happiness DESC LIMIT 1 OFFSET ?")) { $stmt11->bind_param("i", $offset); $stmt11->execute(); $stmt11->bind_result($r_result); $stmt11->fetch(); $next_happiness_nation = $r_result; $stmt11->close(); } else { } // else if ($stmt11 = $getPage_connection2->prepare("UPDATE rankings SET happiness=? WHERE nation=?")) { $stmt11->bind_param("ii", $rank, $next_happiness_nation); $stmt11->execute(); $stmt11->close(); } else { } // else // food if ($stmt11 = $getPage_connection2->prepare("SELECT id FROM nations ORDER BY food DESC LIMIT 1 OFFSET ?")) { $stmt11->bind_param("i", $offset); $stmt11->execute(); $stmt11->bind_result($r_result); $stmt11->fetch(); $next_food_nation = $r_result; $stmt11->close(); } else { } // else if ($stmt11 = $getPage_connection2->prepare("UPDATE rankings SET food=? WHERE nation=?")) { $stmt11->bind_param("ii", $rank, $next_food_nation); $stmt11->execute(); $stmt11->close(); } else { } // else // population if ($stmt11 = $getPage_connection2->prepare("SELECT id FROM nations ORDER BY population DESC LIMIT 1 OFFSET ?")) { $stmt11->bind_param("i", $offset); $stmt11->execute(); $stmt11->bind_result($r_result); $stmt11->fetch(); $next_population_nation = $r_result; $stmt11->close(); } else { } // else if ($stmt11 = $getPage_connection2->prepare("UPDATE rankings SET population=? WHERE nation=?")) { $stmt11->bind_param("ii", $rank, $next_population_nation); $stmt11->execute(); $stmt11->close(); } else { } // else $offset++; } // while $stmt->close(); } else { $next_offers = 0; } // else }