Ejemplo n.º 1
0
 /**
  * @return Bengine_Admin_Controller_News
  */
 protected function indexAction()
 {
     if ($this->getParam("add")) {
         $this->add($this->getParam("language_id"), $this->getParam("title"), $this->getParam("text"));
     }
     $first = true;
     $i = 1;
     $news = array();
     $result = Core::getQuery()->select("news", array("news_id", "title", "text", "time", "enabled", "sort_index"), "", "", "sort_index ASC, news_id DESC");
     $total = $result->rowCount();
     foreach ($result->fetchAll() as $row) {
         $down = "";
         $up = "";
         if (!$first) {
             $up = Image::getImage("admin/up.gif", "", 16, 16);
             $up = Link::get("admin/news/moveup/" . $row["news_id"], $up);
         }
         $first = false;
         if ($i < $total) {
             $down = Image::getImage("admin/down.gif", "", 16, 16);
             $down = Link::get("admin/news/movedown/" . $row["news_id"], $down);
         }
         $i++;
         $news[] = array("news_id" => $row["news_id"], "title" => $row["title"], "text" => $row["text"], "time" => Date::timeToString(1, $row["time"]), "enabled" => $row["enabled"], "edit" => Link::get("admin/news/edit/" . $row["news_id"], Core::getLang()->get("Edit")), "delete" => Link::get("admin/news/delete/" . $row["news_id"], Core::getLang()->get("Delete")), "enable" => Link::get("admin/news/enable/" . $row["news_id"], Core::getLang()->get("Enable"), "", "green"), "disable" => Link::get("admin/news/disable/" . $row["news_id"], Core::getLang()->get("Disable"), "", "red"), "down" => $down, "up" => $up);
     }
     Core::getTemplate()->addLoop("news", $news);
     $languages = $this->getLanguages();
     Core::getTPL()->assign("languageCount", count($languages));
     if (count($languages) == 1) {
         Core::getTPL()->assign("languages", key($languages));
     } else {
         Core::getTPL()->assign("languages", $this->getLanguageSelect());
     }
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Returns only the date (without time).
  *
  * @return string
  */
 public function getDate()
 {
     if (!$this->exists("date")) {
         $this->set("date", Date::timeToString(2, $this->getTime()));
     }
     return $this->get("date");
 }
Ejemplo n.º 3
0
 /**
  * Sends the reminder mails.
  *
  * @return Bengine_Game_Cronjob_Reminder
  */
 protected function sendReminders()
 {
     $time = TIME - Core::getConfig()->get("REMINDER_MAIL_TIME") * 86400;
     $select = new Recipe_Database_Select();
     $select->from("user")->attributes(array("username", "email", "last"))->where("last < ?", $time);
     $result = $select->getStatement();
     Core::getLang()->load(array("Registration"));
     foreach ($result->fetchAll() as $row) {
         Core::getLang()->assign("username", $row["username"]);
         Core::getLang()->assign("reminderLast", Date::timeToString(2, $row["last"]));
         $template = new Recipe_Email_Template("reminder");
         $mail = new Email(array($row["email"] => $row["username"]), Core::getLang()->get("REMINDER_MAIL_SUBJECT"));
         $template->send($mail);
     }
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Bans an user.
  *
  * @param integer $ban
  * @param integer $timeEnd
  * @param string $reason
  * @param boolean $forceUmode
  *
  * @return Bengine_Game_Controller_Moderator
  */
 protected function proceedBan($ban, $timeEnd, $reason, $forceUmode)
 {
     $to = TIME + $ban * $timeEnd;
     if ($to > 9999999999) {
         $to = 9999999999;
     }
     Hook::event("BanUser", array(&$to, $reason, $forceUmode));
     $spec = array("userid" => $this->userid, "from" => TIME, "to" => $to, "reason" => $reason, "modid" => Core::getUser()->get("userid"));
     Core::getQuery()->insert("ban_u", $spec);
     if ($forceUmode) {
         Core::getQuery()->update("user", array("umode" => 1), "userid = ?", array($this->userid));
         setProdOfUser($this->userid, 0);
     }
     Core::getQuery()->update("sessions", array("logged" => 0), "userid = ?", array($this->userid));
     $user = Game::getModel("game/user")->load($this->userid);
     Core::getTemplate()->assign("banReason", $reason);
     Core::getLang()->assign("banDate", Date::timeToString(1, $to, "", 0));
     Core::getLang()->assign("username", $user->get("username"));
     $template = new Recipe_Email_Template("ban_notification");
     $mail = new Email(array($user->get("email") => $user->get("username")), Core::getLanguage()->getItem("BAN_NOTIFICATION_MAIL_SUBJECT"));
     $template->send($mail);
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Parses an event.
  *
  * @param Bengine_Game_Model_Event $f
  *
  * @return array	Parsed event data
  */
 protected function parseEvent(Bengine_Game_Model_Event $f)
 {
     if ($f->getCode() == "game/alliedFleet" && $f->getUserid() != Core::getUser()->get("userid")) {
         return false;
         // Hide foreign formations
     }
     $event = array();
     $event["time_r"] = $f->getTimeLeft();
     $event["time"] = $f->getFormattedTimeLeft();
     $event["eventid"] = $f->getEventid();
     $event["time_finished"] = Date::timeToString(1, $f->getTime());
     $event["raw_coordinates"] = $f->getDestinationCoords(false);
     Core::getLanguage()->assign("rockets", $f->getData("rockets", 0));
     Core::getLanguage()->assign("planet", !$f->getData("oldmode") || $f->getData("oldmode") != 9 ? $f->getPlanetname() : Core::getLanguage()->getItem("DEBRIS"));
     // TODO: Old mode should be translated to code
     Core::getLanguage()->assign("coords", $f->getPlanetCoords());
     Core::getLanguage()->assign("target", $f->getCode() != "game/recycling" ? $f->getDestinationPlanetname() : Core::getLanguage()->getItem("DEBRIS"));
     Core::getLanguage()->assign("targetcoords", $f->getDestinationCoords());
     Core::getLanguage()->assign("metal", fNumber($f->getData("metal", 0)));
     Core::getLanguage()->assign("silicon", fNumber($f->getData("silicon", 0)));
     Core::getLanguage()->assign("hydrogen", fNumber($f->getData("hydrogen", 0)));
     Core::getLanguage()->assign("username", $f->getUsername());
     Core::getLanguage()->assign("message", Link::get("game/" . SID . "/MSG/Write/" . rawurlencode($f->getUsername()), Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE"))));
     Core::getLanguage()->assign("mission", $f->getCode() == "game/return" ? $f->getOrgModeName() : $f->getModeName());
     Core::getLanguage()->assign("fleet", $f->getFleetString());
     $event["class"] = $f->getCssClass();
     if ($f->getCode() == "game/allianceAttack") {
         if ($f->getUserid() == Core::getUser()->get("userid")) {
             $event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OWN");
         } else {
             $event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OTHER");
         }
         $allyFleets = Game::getEH()->getFormationFleets($f->getEventid());
         foreach ($allyFleets as $af) {
             $coords = $af->getPlanetCoords();
             $msg = Core::getLanguage()->getItem("FLEET_MESSAGE_FORMATION");
             $msg = sprintf($msg, $af->getUsername(), $af->getPlanetname(), $coords, $af->getFleetString());
             $event["message"] .= $msg;
         }
     } else {
         if ($f->getCode() == "game/alliedFleet") {
             $mainFleet = Game::getModel("game/event")->load($f->getParentId());
             if ($mainFleet->getUsierid() == Core::getUser()->get("userid")) {
                 return false;
             }
             $event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OWN");
             $allyFleets = Game::getEH()->getFormationFleets($mainFleet->getEventid());
             $allyFleets->add($mainFleet);
             foreach ($allyFleets as $af) {
                 if ($af->getUserid() == Core::getUser()->get("userid")) {
                     continue;
                 }
                 $coords = $af->getPlanetCoords();
                 $msg = Core::getLanguage()->getItem("FLEET_MESSAGE_FORMATION");
                 $msg = sprintf($msg, $af->getUsername(), $af->getPlanetname(), $coords, $af->getFleetString());
                 $event["message"] .= $msg;
             }
         } else {
             if ($f->getCode() == "game/holding" && $f->getUserid() == Core::getUser()->get("userid")) {
                 $event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_HOLDING_1");
             } else {
                 if ($f->getCode() == "game/holding") {
                     $event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_HOLDING_2");
                 } else {
                     if ($f->getCode() == "game/return" && $f->getUserid() == Core::getUser()->get("userid")) {
                         $event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_RETURN");
                     } else {
                         if ($f->getUserid() == Core::getUser()->get("userid") && $f->getCode() == "game/missileAttack") {
                             $event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_ROCKET_ATTACK");
                         } else {
                             if ($f->getCode() == "game/missileAttack") {
                                 $event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_ROCKET_ATTACK_FOREIGN");
                             } else {
                                 if ($f->getUserid() == Core::getUser()->get("userid")) {
                                     $event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OWN");
                                 } else {
                                     $event["message"] = Core::getLanguage()->getItem("FLEET_MESSAGE_OTHER");
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $event;
 }
Ejemplo n.º 6
0
 /**
  * Shows the candidates and their application.
  *
  * @return Bengine_Game_Controller_Alliance
  */
 protected function showCandidatesAction()
 {
     if ($this->isPost()) {
         $this->manageCadidates($this->getParam("receipt"), $this->getParam("refuse"), $this->getParam("users"));
     }
     if ($this->getRights(array("CAN_SEE_APPLICATIONS"))) {
         $apps = array();
         $result = Core::getQuery()->select("allyapplication a", array("a.userid", "a.date", "a.application ", "u.username", "u.points", "g.galaxy", "g.system", "g.position"), "LEFT JOIN " . PREFIX . "user u ON (u.userid = a.userid) LEFT JOIN " . PREFIX . "galaxy g ON (g.planetid = u.hp)", Core::getDB()->quoteInto("a.aid = ?", $this->aid), "u.username ASC, a.date ASC");
         foreach ($result->fetchAll() as $row) {
             $apps[$row["userid"]]["date"] = Date::timeToString(1, $row["date"]);
             $apps[$row["userid"]]["message"] = Link::get("game/" . SID . "/MSG/Write/" . $row["username"], Image::getImage("pm.gif", Core::getLanguage()->getItem("WRITE_MESSAGE")));
             $apps[$row["userid"]]["apptext"] = nl2br($row["application"]);
             $apps[$row["userid"]]["userid"] = $row["userid"];
             $apps[$row["userid"]]["username"] = $row["username"];
             $apps[$row["userid"]]["points"] = fNumber(floor($row["points"]));
             $apps[$row["userid"]]["position"] = getCoordLink($row["galaxy"], $row["system"], $row["position"]);
         }
         Core::getTPL()->assign("candidates", sprintf(Core::getLanguage()->getItem("CANDIDATES"), $result->rowCount()));
         $result->closeCursor();
         Hook::event("ShowAllianceCandidates", array(&$apps));
         Core::getTPL()->addLoop("applications", $apps);
     }
     return $this;
 }
Ejemplo n.º 7
0
 /**
  * Fetches all bans.
  *
  * @param int $offset
  * @param int $count
  * @return array
  */
 protected function getBans($offset, $count)
 {
     $offset = (int) $offset;
     $count = (int) $count;
     $bans = array();
     $attr = array("b.`banid`", "b.`from`", "b.`to`", "b.`reason`", "u.`username`", "m.`username` AS moderator");
     $joins = "LEFT JOIN `" . PREFIX . "user` u ON (u.`userid` = b.`userid`) ";
     $joins .= "LEFT JOIN `" . PREFIX . "user` m ON (m.`userid` = b.`modid`)";
     $result = Core::getQuery()->select("ban_u b", $attr, $joins, "", "b.`from` DESC, b.`banid` DESC", $offset . ", " . $count);
     foreach ($result->fetchAll() as $row) {
         $bans[] = array("counter" => $row["banid"], "from" => Date::timeToString(1, $row["from"]), "to" => Date::timeToString(1, $row["to"]), "reason" => $row["reason"], "username" => $row["username"], "moderator" => $row["moderator"], "date" => Date::timeToString(3, $row["from"], "D, d M Y H:i:s O", false), "author" => $row["moderator"], "title" => $row["username"], "text" => $row["username"] . " &ndash; " . $row["reason"], "link" => "", "date_atom" => Date::timeToString(3, $row["from"], "c", false), "guid" => md5($row["from"]));
     }
     return $bans;
 }
Ejemplo n.º 8
0
 /**
  * This starts the missions and shows a quick overview of the flight.
  *
  * @param integer $mode
  * @param integer $metal
  * @param integer $silicon
  * @param integer $hydrogen
  * @param integer $holdingTime
  * @throws Recipe_Exception_Generic
  * @return Bengine_Game_Controller_Mission
  */
 protected function sendFleet($mode, $metal, $silicon, $hydrogen, $holdingTime)
 {
     $this->noAction = true;
     $fleetEvents = Game::getEH()->getOwnFleetEvents();
     if ($fleetEvents && Game::getResearch(14) + 1 <= count(Game::getEH()->getOwnFleetEvents())) {
         throw new Recipe_Exception_Generic("Too many fleets on missions.");
     }
     $result = Core::getQuery()->select("temp_fleet", "data", "", Core::getDB()->quoteInto("planetid = ?", Core::getUser()->get("curplanet")));
     if ($row = $result->fetchRow()) {
         $result->closeCursor();
         $temp = unserialize($row["data"]);
         if (!in_array($mode, $temp["amissions"])) {
             Logger::dieMessage("UNKNOWN_MISSION");
         }
         $data["ships"] = $temp["ships"];
         $data["galaxy"] = $temp["galaxy"];
         $data["system"] = $temp["system"];
         $data["position"] = $temp["position"];
         $data["sgalaxy"] = Game::getPlanet()->getData("galaxy");
         $data["ssystem"] = Game::getPlanet()->getData("system");
         $data["sposition"] = Game::getPlanet()->getData("position");
         $data["maxspeed"] = $temp["maxspeed"];
         $distance = Game::getDistance($data["galaxy"], $data["system"], $data["position"]);
         $data["consumption"] = Game::getFlyConsumption($temp["consumption"], $distance, $temp["speed"]);
         if (Game::getPlanet()->getData("hydrogen") - $data["consumption"] < 0) {
             Logger::dieMessage("NOT_ENOUGH_FUEL");
         }
         if ($temp["capacity"] < $data["consumption"]) {
             Logger::dieMessage("NOT_ENOUGH_CAPACITY");
         }
         $data["metal"] = (int) abs($metal);
         $data["silicon"] = (int) abs($silicon);
         $data["hydrogen"] = (int) abs($hydrogen);
         if ($data["metal"] > Game::getPlanet()->getData("metal")) {
             $data["metal"] = _pos(Game::getPlanet()->getData("metal"));
         }
         if ($data["silicon"] > Game::getPlanet()->getData("silicon")) {
             $data["silicon"] = _pos(Game::getPlanet()->getData("silicon"));
         }
         if ($data["hydrogen"] > Game::getPlanet()->getData("hydrogen") - $data["consumption"]) {
             $data["hydrogen"] = _pos(Game::getPlanet()->getData("hydrogen") - $data["consumption"]);
         }
         if ($mode == 13) {
             $data["duration"] = _pos($holdingTime);
             if ($data["duration"] > 24) {
                 $data["duration"] = 24;
             }
             $data["duration"] *= 3600;
         }
         $capa = $temp["capacity"] - $data["consumption"] - $data["metal"] - $data["silicon"] - $data["hydrogen"];
         // Reduce used capacity automatically
         if ($capa < 0) {
             if ($capa + $data["hydrogen"] > 0) {
                 $data["hydrogen"] -= abs($capa);
             } else {
                 $capa += $data["hydrogen"];
                 $data["hydrogen"] = 0;
                 if ($capa + $data["silicon"] > 0 && $capa < 0) {
                     $data["silicon"] -= abs($capa);
                 } else {
                     if ($capa < 0) {
                         $capa += $data["silicon"];
                         $data["silicon"] = 0;
                         if ($capa + $data["metal"] && $capa < 0) {
                             $data["metal"] -= abs($capa);
                         } else {
                             if ($capa < 0) {
                                 $data["metal"] = 0;
                             }
                         }
                     }
                 }
             }
         }
         $data["capacity"] = $temp["capacity"] - $data["consumption"] - $data["metal"] - $data["silicon"] - $data["hydrogen"];
         if ($data["capacity"] < 0) {
             Logger::dieMessage("NOT_ENOUGH_CAPACITY");
         }
         // If mission is recycling, get just the capacity of the recyclers.
         if ($mode == 9 && $data["capacity"] > 0) {
             $_result = Core::getQuery()->select("ship_datasheet", "capicity", "", "unitid = '37'");
             // It is __capacity__ and not capicity
             $_row = $_result->fetchRow();
             $_result->closeCursor();
             $recCapa = $_row["capicity"] * $temp["ships"][37]["quantity"];
             if ($data["capacity"] >= $recCapa) {
                 $data["capacity"] = $recCapa;
             }
         }
         $time = Game::getFlyTime($distance, $data["maxspeed"], $temp["speed"]);
         $data["time"] = $time;
         if ($mode == 18) {
             $data["alliance_attack"] = $temp["alliance_attack"];
             $mainFleet = Game::getEH()->getMainFormationFleet($data["alliance_attack"]["eventid"]);
             $allFleets = Game::getEH()->getFormationFleets($data["alliance_attack"]["eventid"]);
             $numFleets = 1;
             $formationUser[$mainFleet->get("user")] = true;
             /* @var Bengine_Game_Model_Fleet $oneFleet */
             foreach ($allFleets as $oneFleet) {
                 $numFleets++;
                 $formationUser[$oneFleet->get("user")] = true;
             }
             unset($formationUser[Core::getUser()->get("userid")]);
             if ($numFleets >= Core::getOptions()->get("MAX_FORMATION_FLEETS")) {
                 Logger::dieMessage("MAX_FORMATION_FLEETS_EXCEEDED");
             }
             if (count($formationUser) >= Core::getOptions()->get("MAX_FORMATION_USER")) {
                 Logger::dieMessage("MAX_FORMATION_USER_EXCEEDED");
             }
             if ($data["time"] + TIME > ($mainFleet["time"] - TIME) * (1 + Core::getOptions()->get("MAX_FORMATION_DELAY")) + TIME) {
                 Logger::dieMessage("MAX_FORMATION_DELAY_EXCEEDED");
             }
         }
         Hook::event("SendFleet", array(&$data, &$time, &$temp, $distance));
         Core::getQuery()->delete("temp_fleet", "planetid = ?", null, null, array(Core::getUser()->get("curplanet")));
         $handler = Game::getEH()->addEvent($mode, $time + TIME, Core::getUser()->get("curplanet"), Core::getUser()->get("userid"), isset($temp["destination"]) ? $temp["destination"] : null, $data);
         Core::getTPL()->assign("mission", Game::getMissionName($mode));
         Core::getTPL()->assign("mode", $mode);
         Core::getTPL()->assign("distance", fNumber($distance));
         Core::getTPL()->assign("speed", fNumber($temp["maxspeed"]));
         Core::getTPL()->assign("consume", fNumber($data["consumption"]));
         Core::getTPL()->assign("start", Game::getPlanet()->getCoords(false));
         Core::getTPL()->assign("target", $data["galaxy"] . ":" . $data["system"] . ":" . $data["position"]);
         Core::getTPL()->assign("arrival", Date::timeToString(1, $handler->getFinishTime()));
         if ($returnTime = $handler->getReturnTime()) {
             Core::getTPL()->assign("return", Date::timeToString(1, $returnTime));
         }
         $fleet = array();
         foreach ($data["ships"] as $key => $value) {
             $fleet[$key]["name"] = Core::getLanguage()->getItem($value["name"]);
             $fleet[$key]["quantity"] = fNumber($value["quantity"]);
         }
         Core::getTPL()->addLoop("fleet", $fleet);
         $this->setTemplate("mission/step4");
     }
     return $this;
 }
Ejemplo n.º 9
0
 /**
  * Returns the formatted registration date.
  *
  * @return string
  */
 public function getFormattedRegDate()
 {
     return Date::timeToString(2, $this->getRegtime());
 }
Ejemplo n.º 10
0
 /**
  * Returns the formatted time, when event will be finished.
  *
  * @return string
  */
 public function getFormattedStartTime()
 {
     return Date::timeToString(1, $this->getStart());
 }
Ejemplo n.º 11
0
 /**
  * Deletes messages.
  *
  * @param integer $folder	Folder id
  * @param integer $option	Mode to delete content
  * @param array $msgs		Messages
  *
  * @return Bengine_Game_Controller_MSG
  */
 protected function deleteMessages($folder, $option, array $msgs)
 {
     $pagination = $this->getPagination($folder);
     $deltime = 604800;
     if (is_numeric(Core::getOptions()->get("DEL_MESSAGE_DAYS")) && Core::getOptions()->get("DEL_MESSAGE_DAYS") > 0) {
         $deltime = (int) Core::getOptions()->get("DEL_MESSAGE_DAYS") * 86400;
     }
     $deltime = TIME - $deltime;
     Core::getQuery()->delete("message", "time <= ?", null, null, array($deltime));
     switch ($option) {
         case 1:
             foreach ($msgs as $msgid) {
                 Core::getQuery()->delete("message", "msgid = ? AND receiver = ?", null, null, array($msgid, Core::getUser()->get("userid")));
             }
             break;
         case 2:
             $where = Core::getDB()->quoteInto("receiver = ? AND mode = ?", array(Core::getUser()->get("userid"), $folder));
             $result = Core::getQuery()->select("message", "msgid", "", $where, "time DESC", $pagination->getStart() . ", " . Core::getOptions()->get("MAX_PMS"));
             foreach ($result->fetchAll() as $row) {
                 if (!in_array($row["msgid"], $msgs)) {
                     Core::getQuery()->delete("message", "msgid = ?", null, null, array($row["msgid"]));
                 }
             }
             $result->closeCursor();
             break;
         case 3:
             $where = Core::getDB()->quoteInto("receiver = ? AND mode = ?", array(Core::getUser()->get("userid"), $folder));
             $result = Core::getQuery()->select("message", array("msgid"), "", $where, "time DESC", $pagination->getStart() . ", " . Core::getOptions()->get("MAX_PMS"));
             foreach ($result->fetchAll() as $row) {
                 Core::getQuery()->delete("message", "msgid = ?", null, null, array($row["msgid"]));
             }
             break;
         case 4:
             Core::getQuery()->delete("message", "receiver = ? AND mode = ?", null, null, array(Core::getUser()->get("userid"), $folder));
             break;
         case 5:
             $reports = array();
             $modId = Game::getRandomModerator();
             foreach ($msgs as $msgid) {
                 $where = Core::getDB()->quoteInto("m.msgid = ? AND m.receiver = ?", array($msgid, Core::getUser()->get("userid")));
                 $result = Core::getQuery()->select("message m", array("m.sender", "m.mode", "m.message", "m.time", "u.username"), "LEFT JOIN " . PREFIX . "user u ON (u.userid = m.sender)", $where);
                 if ($row = $result->fetchRow()) {
                     if (($row["sender"] > 0 || $row["mode"] == 5) && $row["sender"] != $modId) {
                         $reports[] = $row;
                     }
                 }
             }
             if (count($reports) > 0) {
                 Core::getLang()->assign("reportSender", Core::getUser()->get("username"));
                 foreach ($reports as $report) {
                     Core::getLang()->assign("reportMessage", $report["message"]);
                     Core::getLang()->assign("reportUser", $report["username"]);
                     Core::getLang()->assign("reportSendTime", Date::timeToString(1, $report["time"], "", false));
                     if ($report["mode"] == 5) {
                         $assault = Game::getModel("game/assault")->load((int) $report["message"]);
                         $url = BASE_URL . Core::getLang()->getOpt("langcode") . "/combat/report/" . $assault->get("assaultid") . "/" . $assault->get("key");
                         $gentime = $assault->get("gentime") / 1000;
                         $label = Core::getLanguage()->getItem("ASSAULT_REPORT") . " (A: " . fNumber($assault->get("lostunits_attacker")) . ", D: " . fNumber($assault->get("lostunits_defender")) . ") " . $gentime . "s";
                         Core::getLang()->assign("reportLink", "<span class=\"assault-report\" onclick=\"window.open('" . $url . "')\">" . $label . "</span>");
                         $message = Core::getDB()->escape(Core::getLang()->get("MODERATOR_REPORT_COMBAT"));
                     } else {
                         richText($message = Core::getLang()->get("MODERATOR_REPORT_MESSAGE"));
                     }
                     $subject = Core::getLang()->get("MODERATOR_REPORT_SUBJECT");
                     $spec = array("sender" => null, "mode" => 1, "subject" => $subject, "message" => $message, "receiver" => $modId, "time" => TIME, "read" => 0);
                     Core::getQuery()->insert("message", $spec);
                 }
                 Logger::addMessage("MESSAGES_REPORTED", "success");
             }
             break;
     }
     return $this;
 }
Ejemplo n.º 12
0
 /**
  * Returns the last messages for the user.
  *
  * @param integer $offset
  * @param integer $count
  *
  * @return array
  */
 protected function getItems($offset, $count)
 {
     $folderClassCache = array();
     $items = array();
     /* @var Bengine_Game_Model_Collection_Message $messages */
     $messages = Comm::getCollection("game/message");
     $messages->addTimeOrder()->addReceiverFilter($this->user_id)->addFolderJoin();
     $select = $messages->getSelect();
     $select->limit($offset, $count);
     $select->where("m.mode != ?", self::OUTBOX_FOLDER_ID);
     /* @var Bengine_Game_Model_Message $message */
     foreach ($messages as $message) {
         /* @var Bengine_Game_MessageFolder_Abstract $folderObj */
         $folderCode = $message->get("folder_class");
         if (!isset($folderClassCache[$folderCode])) {
             $folderClass = explode("/", $folderCode);
             $folderClass = $folderClass[0] . "/messageFolder_" . $folderClass[1];
             $folderObj = Application::factory($folderClass);
             $folderClassCache[$folderCode] = $folderObj;
         } else {
             $folderObj = $folderClassCache[$folderCode];
         }
         $folderObj->formatMessage($message, true);
         $items[] = array("date" => Date::timeToString(3, $message->getTime(), "D, d M Y H:i:s O", false), "author" => $message->get("username") ? $message->get("username") : "System", "title" => strip_tags($message->get("subject")), "text" => $message->get("message"), "link" => $message->get("link"), "date_atom" => Date::timeToString(3, $message->getTime(), "c", false), "guid" => $message->getId());
     }
     return $items;
 }
Ejemplo n.º 13
0
 /**
  * Index action.
  *
  * @return Bengine_Game_Controller_Preferences
  */
 protected function indexAction()
 {
     /* @var Bengine_Game_Model_Collection_Event $events */
     $events = Game::getCollection("game/event");
     $events->addVacationModeFilter(Core::getUser()->get("userid"));
     if ($this->isPost()) {
         if (!Core::getUser()->get("umode") && $this->getParam("saveuserdata")) {
             $this->updateUserData($this->getParam("username"), $this->getParam("usertitle"), $this->getParam("email"), $this->getParam("password"), $this->getParam("theme"), $this->getParam("language"), $this->getParam("templatepackage"), $this->getParam("umode"), $this->getParam("delete"), $this->getParam("ipcheck"), $this->getParam("esps"), $this->getParam("generate_key"), $this->getParam("js_interface"));
         } else {
             if (TIME > Core::getUser()->get("umodemin") && $this->getParam("disable_umode")) {
                 $this->disableUmode();
             }
         }
         if ($this->getParam("update_deletion")) {
             $this->updateDeletion($this->getParam("delete"));
         }
     }
     if (Core::getUser()->get("delete") > 0) {
         $delmsg = Date::timeToString(2, Core::getUser()->get("delete"), "", false);
         $delmsg = sprintf(Core::getLanguage()->getItem("DELETE_DATE"), $delmsg);
         Core::getTPL()->assign("delmessage", $delmsg);
     }
     if (Core::getUser()->get("umode")) {
         $canDisableUmode = true;
         if (Core::getUser()->get("umodemin") > TIME) {
             $canDisableUmode = false;
             $umodemsg = Date::timeToString(1, Core::getUser()->get("umodemin"), "", false);
             $umodemsg = sprintf(Core::getLanguage()->getItem("UMODE_DATE"), $umodemsg);
             Core::getTPL()->assign("umode_to", $umodemsg);
         }
         Core::getTPL()->assign("can_disable_umode", $canDisableUmode);
     }
     $packs = array();
     $excludedPackages = explode(",", Core::getOptions()->get("EXCLUDE_TEMPLATE_PACKAGE"));
     $excludedPackages = array_map("trim", $excludedPackages);
     $excludedPackages[] = "default";
     $excludedPackages[] = Core::getOptions()->get("templatepackage");
     $dir = new DirectoryIterator(APP_ROOT_DIR . "app/templates/");
     /* @var DirectoryIterator $package */
     foreach ($dir as $package) {
         if (!$package->isDot() && $package->isDir() && !in_array($package->getBasename(), $excludedPackages)) {
             $directoryName = $package->getFilename();
             $templateName = Core::getLang()->exists("TEMPLATE_NAME_" . $directoryName) ? Core::getLang()->get("TEMPLATE_NAME_" . $directoryName) : $directoryName;
             $packs[] = array("value" => $directoryName, "name" => $templateName);
         }
     }
     Hook::event("LoadTemplatePackages", array(&$packs));
     Core::getTPL()->addLoop("templatePacks", $packs);
     $result = Core::getQuery()->select("languages", array("languageid", "title"), "", "", "title ASC");
     Core::getTPL()->addLoop("langs", $result->fetchAll());
     $result = Core::getQuery()->select("feed_keys", array("feed_key"), "", Core::getDB()->quoteInto("user_id = ?", Core::getUser()->get("userid")));
     if ($result->rowCount() > 0) {
         $feed_key = $result->fetchColumn();
         $link = Core::getLang()->getOpt("langcode") . "/feed/{type}/" . Core::getUser()->get("userid") . "/" . $feed_key;
         $rss = Str::replace("{type}", "rss", $link);
         $atom = Str::replace("{type}", "atom", $link);
         $this->assign("rss_feed_url", Link::get($rss, BASE_URL . $rss, "", "", "target=\"_blank\""));
         $this->assign("atom_feed_url", Link::get($atom, BASE_URL . $atom, "", "", "target=\"_blank\""));
     } else {
         $this->assign("rss_feed_url", "-");
         $this->assign("atom_feed_url", "-");
     }
     $this->assign("goToSignature", Link::get("game/" . SID . "/Preferences/Signature", Core::getLang()->get("GO_TO_SIGNATURE")));
     return $this;
 }