本文整理汇总了PHP中PlayerUtil::sendMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerUtil::sendMessage方法的具体用法?PHP PlayerUtil::sendMessage怎么用?PHP PlayerUtil::sendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerUtil
的用法示例。
在下文中一共展示了PlayerUtil::sendMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run()
{
if (Config::get(ROOT_UNI)->ref_active != 1) {
return null;
}
/** @var $langObjects Language[] */
$langObjects = array();
$db = Database::get();
$sql = 'SELECT `username`, `ref_id`, `id`, `lang`, user.`universe`
FROM %%USERS%% user
INNER JOIN %%STATPOINTS%% as stats
ON stats.`id_owner` = user.`id` AND stats.`stat_type` = :type AND stats.`total_points` >= :points
WHERE user.`ref_bonus` = 1;';
$userArray = $db->select($sql, array(':type' => 1, ':points' => Config::get(ROOT_UNI)->ref_minpoints));
foreach ($userArray as $user) {
if (!isset($langObjects[$user['lang']])) {
$langObjects[$user['lang']] = new Language($user['lang']);
$langObjects[$user['lang']]->includeData(array('L18N', 'INGAME', 'TECH', 'CUSTOM'));
}
$userConfig = Config::get($user['universe']);
$LNG = $langObjects[$user['lang']];
$sql = 'UPDATE %%USERS%% SET `darkmatter` = `darkmatter` + :bonus WHERE `id` = :userId;';
$db->update($sql, array(':bonus' => $userConfig->ref_bonus, ':userId' => $user['ref_id']));
$sql = 'UPDATE %%USERS%% SET `ref_bonus` = 0 WHERE `id` = :userId;';
$db->update($sql, array(':userId' => $user['id']));
$Message = sprintf($LNG['sys_refferal_text'], $user['username'], pretty_number($userConfig->ref_minpoints), pretty_number($userConfig->ref_bonus), $LNG['tech'][921]);
PlayerUtil::sendMessage($user['ref_id'], '', $LNG['sys_refferal_from'], 4, sprintf($LNG['sys_refferal_title'], $user['username']), $Message, TIMESTAMP);
}
return true;
}
示例2: send
function send()
{
global $USER, $LNG;
$ticketID = HTTP::_GP('id', 0);
$message = HTTP::_GP('message', '', true);
$change = HTTP::_GP('change_status', 0);
$ticketDetail = $GLOBALS['DATABASE']->getFirstRow("SELECT ownerID, subject, status FROM " . TICKETS . " WHERE ticketID = " . $ticketID . ";");
$status = $change ? $ticketDetail['status'] <= 1 ? 2 : 1 : 1;
if (!$change && empty($message)) {
HTTP::redirectTo('admin.php?page=support&mode=view&id=' . $ticketID);
}
$subject = "RE: " . $ticketDetail['subject'];
if ($change && $status == 1) {
$this->ticketObj->createAnswer($ticketID, $USER['id'], $USER['username'], $subject, $LNG['ti_admin_open'], $status);
}
if (!empty($message)) {
$this->ticketObj->createAnswer($ticketID, $USER['id'], $USER['username'], $subject, $message, $status);
}
if ($change && $status == 2) {
$this->ticketObj->createAnswer($ticketID, $USER['id'], $USER['username'], $subject, $LNG['ti_admin_close'], $status);
}
$subject = sprintf($LNG['sp_answer_message_title'], $ticketID);
$text = sprintf($LNG['sp_answer_message'], $ticketID);
PlayerUtil::sendMessage($ticketDetail['ownerID'], $USER['id'], $USER['username'], 4, $subject, $text, TIMESTAMP, NULL, 1, Universe::getEmulated());
HTTP::redirectTo('admin.php?page=support');
}
示例3: ReturnEvent
function ReturnEvent()
{
$LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
$Message = sprintf($LNG['sys_stat_mess'], GetStartAddressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['tech'][901], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['tech'][902], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['tech'][903]);
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 4, $LNG['sys_mess_fleetback'], $Message, $this->_fleet['fleet_end_time'], NULL, 1, $this->_fleet['fleet_universe']);
$this->RestoreFleet();
}
示例4: ShowSendMessagesPage
function ShowSendMessagesPage()
{
global $USER, $LNG;
$ACTION = HTTP::_GP('action', '');
if ($ACTION == 'send') {
switch ($USER['authlevel']) {
case AUTH_MOD:
$class = 'mod';
break;
case AUTH_OPS:
$class = 'ops';
break;
case AUTH_ADM:
$class = 'admin';
break;
default:
$class = '';
break;
}
$Subject = HTTP::_GP('subject', '', true);
$Message = HTTP::_GP('text', '', true);
$Mode = HTTP::_GP('mode', 0);
$Lang = HTTP::_GP('lang', '');
if (!empty($Message) && !empty($Subject)) {
require 'includes/classes/BBCode.class.php';
if ($Mode == 0 || $Mode == 2) {
$From = '<span class="' . $class . '">' . $LNG['user_level'][$USER['authlevel']] . ' ' . $USER['username'] . '</span>';
$pmSubject = '<span class="' . $class . '">' . $Subject . '</span>';
$pmMessage = '<span class="' . $class . '">' . BBCode::parse($Message) . '</span>';
$USERS = $GLOBALS['DATABASE']->query("SELECT `id`, `username` FROM " . USERS . " WHERE `universe` = '" . Universe::getEmulated() . "'" . (!empty($Lang) ? " AND `lang` = '" . $GLOBALS['DATABASE']->sql_escape($Lang) . "'" : "") . ";");
while ($UserData = $GLOBALS['DATABASE']->fetch_array($USERS)) {
$sendMessage = str_replace('{USERNAME}', $UserData['username'], $pmMessage);
PlayerUtil::sendMessage($UserData['id'], $USER['id'], $From, 50, $pmSubject, $sendMessage, TIMESTAMP, NULL, 1, Universe::getEmulated());
}
}
if ($Mode == 1 || $Mode == 2) {
require 'includes/classes/Mail.class.php';
$userList = array();
$USERS = $GLOBALS['DATABASE']->query("SELECT `email`, `username` FROM " . USERS . " WHERE `universe` = '" . Universe::getEmulated() . "'" . (!empty($Lang) ? " AND `lang` = '" . $GLOBALS['DATABASE']->sql_escape($Lang) . "'" : "") . ";");
while ($UserData = $GLOBALS['DATABASE']->fetch_array($USERS)) {
$userList[$UserData['email']] = array('username' => $UserData['username'], 'body' => BBCode::parse(str_replace('{USERNAME}', $UserData['username'], $Message)));
}
Mail::multiSend($userList, strip_tags($Subject));
}
exit($LNG['ma_message_sended']);
} else {
exit($LNG['ma_subject_needed']);
}
}
$sendModes = $LNG['ma_modes'];
if (Config::get()->mail_active == 0) {
unset($sendModes[1]);
unset($sendModes[2]);
}
$template = new template();
$template->assign_vars(array('langSelector' => array_merge(array('' => $LNG['ma_all']), $LNG->getAllowedLangs(false)), 'modes' => $sendModes));
$template->show('SendMessagesPage.tpl');
}
示例5: ReturnEvent
function ReturnEvent()
{
$LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
$sql = 'SELECT name FROM %%PLANETS%% WHERE id = :planetId;';
$planetName = Database::get()->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_start_id']), 'name');
$Message = sprintf($LNG['sys_fleet_won'], $planetName, GetTargetAdressLink($this->_fleet, ''), pretty_number($this->_fleet['fleet_resource_metal']), $LNG['tech'][901], pretty_number($this->_fleet['fleet_resource_crystal']), $LNG['tech'][902], pretty_number($this->_fleet['fleet_resource_deuterium']), $LNG['tech'][903]);
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 4, $LNG['sys_mess_fleetback'], $Message, $this->_fleet['fleet_end_time'], NULL, 1, $this->_fleet['fleet_universe']);
$this->RestoreFleet();
}
示例6: ReturnEvent
function ReturnEvent()
{
$LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
$sql = 'SELECT name FROM %%PLANETS%% WHERE id = :planetId;';
$planetName = Database::get()->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_start_id']), 'name');
$Message = sprintf($LNG['sys_tran_mess_back'], $planetName, GetStartAddressLink($this->_fleet, ''));
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 4, $LNG['sys_mess_fleetback'], $Message, $this->_fleet['fleet_end_time'], NULL, 1, $this->_fleet['fleet_universe']);
$this->RestoreFleet();
}
示例7: ReturnEvent
function ReturnEvent()
{
$LNG = $this->getLanguage(NULL, $this->_fleet['fleet_owner']);
if ($this->_fleet['fleet_resource_darkmatter'] > 0) {
$message = sprintf($LNG['sys_expe_back_home_with_dm'], $LNG['tech'][921], pretty_number($this->_fleet['fleet_resource_darkmatter']), $LNG['tech'][921]);
$this->UpdateFleet('fleet_array', '220,0;');
} else {
$message = $LNG['sys_expe_back_home_without_dm'];
}
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 4, $LNG['sys_mess_fleetback'], $message, $this->_fleet['fleet_end_time'], NULL, 1, $this->_fleet['fleet_universe']);
$this->RestoreFleet();
}
示例8: _activeUser
private function _activeUser()
{
global $LNG;
$validationID = HTTP::_GP('i', 0);
$validationKey = HTTP::_GP('k', '');
$db = Database::get();
$sql = "SELECT * FROM %%USERS_VALID%%\n\t\tWHERE validationID\t= :validationID\n\t\tAND validationKey\t= :validationKey\n\t\tAND universe\t\t= :universe;";
$userData = $db->selectSingle($sql, array(':validationKey' => $validationKey, ':validationID' => $validationID, ':universe' => Universe::current()));
if (empty($userData)) {
$this->printMessage($LNG['vertifyNoUserFound']);
}
$config = Config::get();
$sql = "DELETE FROM %%USERS_VALID%% WHERE validationID = :validationID;";
$db->delete($sql, array(':validationID' => $validationID));
list($userID, $planetID) = PlayerUtil::createPlayer($userData['universe'], $userData['userName'], $userData['password'], $userData['email'], $userData['language']);
if ($config->mail_active == 1) {
require 'includes/classes/Mail.class.php';
$MailSubject = sprintf($LNG['registerMailCompleteTitle'], $config->game_name, Universe::current());
$MailRAW = $LNG->getTemplate('email_reg_done');
$MailContent = str_replace(array('{USERNAME}', '{GAMENAME}', '{GAMEMAIL}'), array($userData['userName'], $config->game_name . ' - ' . $config->uni_name, $config->smtp_sendmail), $MailRAW);
try {
Mail::send($userData['email'], $userData['userName'], $MailSubject, $MailContent);
} catch (Exception $e) {
// This mail is wayne.
}
}
if (!empty($userData['referralID'])) {
$sql = "UPDATE %%USERS%% SET\n\t\t\t`ref_id`\t= :referralId,\n\t\t\t`ref_bonus`\t= 1\n\t\t\tWHERE\n\t\t\t`id`\t\t= :userID;";
$db->update($sql, array(':referralId' => $userData['referralID'], ':userID' => $userID));
}
if (!empty($userData['externalAuthUID'])) {
$sql = "INSERT INTO %%USERS_AUTH%% SET\n\t\t\t`id`\t\t= :userID,\n\t\t\t`account`\t= :externalAuthUID,\n\t\t\t`mode`\t\t= :externalAuthMethod;";
$db->insert($sql, array(':userID' => $userID, ':externalAuthUID' => $userData['externalAuthUID'], ':externalAuthMethod' => $userData['externalAuthMethod']));
}
$senderName = $LNG['registerWelcomePMSenderName'];
$subject = $LNG['registerWelcomePMSubject'];
$message = sprintf($LNG['registerWelcomePMText'], $config->game_name, $userData['universe']);
PlayerUtil::sendMessage($userID, 1, $senderName, 1, $subject, $message, TIMESTAMP);
return array('userID' => $userID, 'userName' => $userData['userName'], 'planetID' => $planetID);
}
示例9: getACSPageData
public function getACSPageData($fleetID)
{
global $USER, $LNG;
$db = Database::get();
$sql = "SELECT fleet_start_time, fleet_end_id, fleet_group, fleet_mess FROM %%FLEETS%% WHERE fleet_id = :fleetID;";
$fleetData = $db->selectSingle($sql, array(':fleetID' => $fleetID));
if ($db->rowCount() != 1) {
return array();
}
if ($fleetData['fleet_mess'] == 1 || $fleetData['fleet_start_time'] <= TIMESTAMP) {
return array();
}
if ($fleetData['fleet_group'] == 0) {
$acsData = $this->createACS($fleetID, $fleetData);
} else {
$acsData = $this->loadACS($fleetData);
}
if (empty($acsData)) {
return array();
}
$acsName = HTTP::_GP('acsName', '', UTF8_SUPPORT);
if (!empty($acsName)) {
if (PlayerUtil::isNameValid($acsName)) {
$this->sendJSON($LNG['fl_acs_newname_alphanum']);
}
$sql = "UPDATE %%AKS%% SET name = acsName WHERE id = :acsID;";
$db->update($sql, array(':acsName' => $acsName, ':acsID' => $acsData['id']));
$this->sendJSON(false);
}
$invitedUsers = array();
$sql = "SELECT id, username FROM %%USERS_ACS%% INNER JOIN %%USERS%% ON userID = id WHERE acsID = :acsID;";
$userResult = $db->select($sql, array(':acsID' => $acsData['id']));
foreach ($userResult as $userRow) {
$invitedUsers[$userRow['id']] = $userRow['username'];
}
$newUser = HTTP::_GP('username', '', UTF8_SUPPORT);
$statusMessage = "";
if (!empty($newUser)) {
$sql = "SELECT id FROM %%USERS%% WHERE universe = :universe AND username = :username;";
$newUserID = $db->selectSingle($sql, array(':universe' => Universe::current(), ':username' => $newUser), 'id');
if (empty($newUserID)) {
$statusMessage = $LNG['fl_player'] . " " . $newUser . " " . $LNG['fl_dont_exist'];
} elseif (isset($invitedUsers[$newUserID])) {
$statusMessage = $LNG['fl_player'] . " " . $newUser . " " . $LNG['fl_already_invited'];
} else {
$statusMessage = $LNG['fl_player'] . " " . $newUser . " " . $LNG['fl_add_to_attack'];
$sql = "INSERT INTO %%USERS_ACS%% SET acsID = :acsID, userID = :newUserID;";
$db->insert($sql, array(':acsID' => $acsData['id'], ':newUserID' => $newUserID));
$invitedUsers[$newUserID] = $newUser;
$inviteTitle = $LNG['fl_acs_invitation_title'];
$inviteMessage = $LNG['fl_player'] . $USER['username'] . $LNG['fl_acs_invitation_message'];
PlayerUtil::sendMessage($newUserID, $USER['id'], TIMESTAMP, 1, $USER['username'], $inviteTitle, $inviteMessage);
}
}
return array('invitedUsers' => $invitedUsers, 'acsName' => $acsData['name'], 'mainFleetID' => $fleetID, 'statusMessage' => $statusMessage);
}
示例10: SetNextQueueTechOnTop
public function SetNextQueueTechOnTop()
{
global $resource, $LNG;
if (empty($this->USER['b_tech_queue'])) {
$this->USER['b_tech'] = 0;
$this->USER['b_tech_id'] = 0;
$this->USER['b_tech_planet'] = 0;
$this->USER['b_tech_queue'] = '';
return false;
}
$CurrentQueue = unserialize($this->USER['b_tech_queue']);
$Loop = true;
while ($Loop == true) {
$ListIDArray = $CurrentQueue[0];
$isAnotherPlanet = $ListIDArray[4] != $this->PLANET['id'];
if ($isAnotherPlanet) {
$sql = 'SELECT * FROM %%PLANETS%% WHERE id = :planetId;';
$PLANET = Database::get()->selectSingle($sql, array(':planetId' => $ListIDArray[4]));
$RPLANET = new ResourceUpdate(true, false);
list(, $PLANET) = $RPLANET->CalcResource($this->USER, $PLANET, false, $this->USER['b_tech']);
} else {
$PLANET = $this->PLANET;
}
$PLANET[$resource[31] . '_inter'] = self::getNetworkLevel($this->USER, $PLANET);
$Element = $ListIDArray[0];
$Level = $ListIDArray[1];
$costResources = BuildFunctions::getElementPrice($this->USER, $PLANET, $Element);
$BuildTime = BuildFunctions::getBuildingTime($this->USER, $PLANET, $Element, $costResources);
$HaveResources = BuildFunctions::isElementBuyable($this->USER, $PLANET, $Element, $costResources);
$BuildEndTime = $this->USER['b_tech'] + $BuildTime;
$CurrentQueue[0] = array($Element, $Level, $BuildTime, $BuildEndTime, $PLANET['id']);
if ($HaveResources == true) {
if (isset($costResources[901])) {
$PLANET[$resource[901]] -= $costResources[901];
}
if (isset($costResources[902])) {
$PLANET[$resource[902]] -= $costResources[902];
}
if (isset($costResources[903])) {
$PLANET[$resource[903]] -= $costResources[903];
}
if (isset($costResources[921])) {
$this->USER[$resource[921]] -= $costResources[921];
}
$this->USER['b_tech_id'] = $Element;
$this->USER['b_tech'] = $BuildEndTime;
$this->USER['b_tech_planet'] = $PLANET['id'];
$this->USER['b_tech_queue'] = serialize($CurrentQueue);
$Loop = false;
} else {
if ($this->USER['hof'] == 1) {
if (!isset($costResources[901])) {
$costResources[901] = 0;
}
if (!isset($costResources[902])) {
$costResources[902] = 0;
}
if (!isset($costResources[903])) {
$costResources[903] = 0;
}
$Message = sprintf($LNG['sys_notenough_money'], $PLANET['name'], $PLANET['id'], $PLANET['galaxy'], $PLANET['system'], $PLANET['planet'], $LNG['tech'][$Element], pretty_number($PLANET['metal']), $LNG['tech'][901], pretty_number($PLANET['crystal']), $LNG['tech'][902], pretty_number($PLANET['deuterium']), $LNG['tech'][903], pretty_number($costResources[901]), $LNG['tech'][901], pretty_number($costResources[902]), $LNG['tech'][902], pretty_number($costResources[903]), $LNG['tech'][903]);
PlayerUtil::sendMessage($this->USER['id'], 0, $this->USER['b_tech'], 99, $LNG['sys_techlist'], $LNG['sys_buildlist_fail'], $Message);
}
array_shift($CurrentQueue);
if (count($CurrentQueue) == 0) {
$this->USER['b_tech'] = 0;
$this->USER['b_tech_id'] = 0;
$this->USER['b_tech_planet'] = 0;
$this->USER['b_tech_queue'] = '';
$Loop = false;
} else {
$BaseTime = $BuildEndTime - $BuildTime;
$NewQueue = array();
foreach ($CurrentQueue as $ListIDArray) {
$ListIDArray[2] = BuildFunctions::getBuildingTime($this->USER, $PLANET, $ListIDArray[0]);
$BaseTime += $ListIDArray[2];
$ListIDArray[3] = $BaseTime;
$NewQueue[] = $ListIDArray;
}
$CurrentQueue = $NewQueue;
}
}
if ($isAnotherPlanet) {
$RPLANET->SavePlanetToDB($this->USER, $PLANET);
$RPLANET = NULL;
unset($RPLANET);
} else {
$this->PLANET = $PLANET;
}
}
return true;
}
示例11: TargetEvent
function TargetEvent()
{
global $pricelist, $reslist, $resource;
$db = Database::get();
$sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;';
$senderUser = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner']));
$targetUser = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_target_owner']));
$sql = 'SELECT * FROM %%PLANETS%% WHERE id = :planetId;';
$targetPlanet = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id']));
$sql = 'SELECT name FROM %%PLANETS%% WHERE id = :planetId;';
$senderPlanetName = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_start_id']), 'name');
$LNG = $this->getLanguage($senderUser['lang']);
$senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']);
$targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
$planetUpdater = new ResourceUpdate();
list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
$sql = 'SELECT * FROM %%FLEETS%% WHERE fleet_end_id = :planetId AND fleet_mission = 5 AND fleet_end_stay > :time;';
$targetStayFleets = $db->select($sql, array(':planetId' => $this->_fleet['fleet_end_id'], ':time' => $this->_fleet['fleet_start_time']));
foreach ($targetStayFleets as $fleetRow) {
$fleetData = FleetFunctions::unserialize($fleetRow['fleet_array']);
foreach ($fleetData as $shipId => $shipAmount) {
$targetPlanet[$resource[$shipId]] += $shipAmount;
}
}
$fleetAmount = $this->_fleet['fleet_amount'] * (1 + $senderUser['factor']['SpyPower']);
$senderSpyTech = max($senderUser['spy_tech'], 1);
$targetSpyTech = max($targetUser['spy_tech'], 1);
$techDifference = abs($senderSpyTech - $targetSpyTech);
$MinAmount = ($senderSpyTech > $targetSpyTech ? -1 : 1) * pow($techDifference * SPY_DIFFENCE_FACTOR, 2);
$SpyFleet = $fleetAmount >= $MinAmount;
$SpyDef = $fleetAmount >= $MinAmount + 1 * SPY_VIEW_FACTOR;
$SpyBuild = $fleetAmount >= $MinAmount + 3 * SPY_VIEW_FACTOR;
$SpyTechno = $fleetAmount >= $MinAmount + 5 * SPY_VIEW_FACTOR;
$classIDs[900] = array_merge($reslist['resstype'][1], $reslist['resstype'][2]);
if ($SpyFleet) {
$classIDs[200] = $reslist['fleet'];
}
if ($SpyDef) {
$classIDs[400] = array_merge($reslist['defense'], $reslist['missile']);
}
if ($SpyBuild) {
$classIDs[0] = $reslist['build'];
}
if ($SpyTechno) {
$classIDs[100] = $reslist['tech'];
}
$targetChance = mt_rand(0, min($fleetAmount / 4 * ($targetSpyTech / $senderSpyTech), 100));
$spyChance = mt_rand(0, 100);
$spyData = array();
foreach ($classIDs as $classID => $elementIDs) {
foreach ($elementIDs as $elementID) {
if (isset($targetUser[$resource[$elementID]])) {
$spyData[$classID][$elementID] = $targetUser[$resource[$elementID]];
} else {
$spyData[$classID][$elementID] = $targetPlanet[$resource[$elementID]];
}
}
if ($senderUser['spyMessagesMode'] == 1) {
$spyData[$classID] = array_filter($spyData[$classID]);
}
}
// I'm use template class here, because i want to exclude HTML in PHP.
require_once 'includes/classes/class.template.php';
$template = new template();
$template->caching = true;
$template->compile_id = $senderUser['lang'];
$template->loadFilter('output', 'trimwhitespace');
list($tplDir) = $template->getTemplateDir();
$template->setTemplateDir($tplDir . 'game/');
$template->assign_vars(array('spyData' => $spyData, 'targetPlanet' => $targetPlanet, 'targetChance' => $targetChance, 'spyChance' => $spyChance, 'isBattleSim' => ENABLE_SIMULATOR_LINK == true && isModuleAvailable(MODULE_SIMULATOR), 'title' => sprintf($LNG['sys_mess_head'], $targetPlanet['name'], $targetPlanet['galaxy'], $targetPlanet['system'], $targetPlanet['planet'], _date($LNG['php_tdformat'], $this->_fleet['fleet_end_time'], $targetUser['timezone'], $LNG))));
$template->assign_vars(array('LNG' => $LNG), false);
$spyReport = $template->fetch('shared.mission.spyReport.tpl');
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_qg'], 0, $LNG['sys_mess_spy_report'], $spyReport, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
$LNG = $this->getLanguage($targetUser['lang']);
$targetMessage = $LNG['sys_mess_spy_ennemyfleet'] . " " . $senderPlanetName;
if ($this->_fleet['fleet_start_type'] == 3) {
$targetMessage .= $LNG['sys_mess_spy_report_moon'] . ' ';
}
$text = '<a href="game.php?page=galaxy&galaxy=%1$s&system=%2$s">[%1$s:%2$s:%3$s]</a> %7$s
%8$s <a href="game.php?page=galaxy&galaxy=%4$s&system=%5$s">[%4$s:%5$s:%6$s]</a> %9$s';
$targetMessage .= sprintf($text, $this->_fleet['fleet_start_galaxy'], $this->_fleet['fleet_start_system'], $this->_fleet['fleet_start_planet'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $LNG['sys_mess_spy_seen_at'], $targetPlanet['name'], $LNG['sys_mess_spy_seen_at2']);
PlayerUtil::sendMessage($this->_fleet['fleet_target_owner'], 0, $LNG['sys_mess_spy_control'], 0, $LNG['sys_mess_spy_activity'], $targetMessage, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
if ($targetChance >= $spyChance) {
$config = Config::get($this->_fleet['fleet_universe']);
$whereCol = $this->_fleet['fleet_end_type'] == 3 ? "id_luna" : "id";
$sql = 'UPDATE %%PLANETS%% SET
der_metal = der_metal + :metal,
der_crystal = der_crystal + :crystal
WHERE ' . $whereCol . ' = :planetId;';
$db->update($sql, array(':metal' => $fleetAmount * $pricelist[210]['cost'][901] * $config->Fleet_Cdr / 100, ':crystal' => $fleetAmount * $pricelist[210]['cost'][902] * $config->Fleet_Cdr / 100, ':planetId' => $this->_fleet['fleet_end_id']));
$this->KillFleet();
} else {
$this->setState(FLEET_RETURN);
$this->SaveFleet();
}
}
示例12: accept
function accept()
{
global $USER, $LNG;
$id = HTTP::_GP('id', 0);
$db = Database::get();
$sql = "DELETE FROM %%BUDDY_REQUEST%% WHERE id = :id;";
$db->delete($sql, array(':id' => $id));
$sql = "SELECT sender, u.username FROM %%BUDDY%% b INNER JOIN %%USERS%% u ON sender = u.id WHERE b.id = :id;";
$sender = $db->selectSingle($sql, array(':id' => $id));
PlayerUtil::sendMessage($sender['sender'], $USER['id'], $USER['username'], 4, $LNG['bu_accepted_request_title'], sprintf($LNG['bu_accepted_request_body'], $sender['username'], $USER['username']), TIMESTAMP);
$this->redirectTo("game.php?page=buddyList");
}
示例13: TargetEvent
function TargetEvent()
{
$db = Database::get();
$sql = 'SELECT * FROM %%USERS%% WHERE `id` = :userId;';
$senderUser = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner']));
$senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']);
$LNG = $this->getLanguage($senderUser['lang']);
$checkPosition = PlayerUtil::checkPosition($this->_fleet['fleet_universe'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']);
$isPositionFree = PlayerUtil::isPositionFree($this->_fleet['fleet_universe'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']);
if (!$isPositionFree || !$checkPosition) {
$message = sprintf($LNG['sys_colo_notfree'], GetTargetAddressLink($this->_fleet, ''));
} else {
$allowPlanetPosition = PlayerUtil::allowPlanetPosition($this->_fleet['fleet_end_planet'], $senderUser);
if (!$allowPlanetPosition) {
$message = sprintf($LNG['sys_colo_notech'], GetTargetAddressLink($this->_fleet, ''));
} else {
$sql = 'SELECT COUNT(*) as state
FROM %%PLANETS%%
WHERE `id_owner` = :userId
AND `planet_type` = :type
AND `destruyed` = :destroyed;';
$currentPlanetCount = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner'], ':type' => 1, ':destroyed' => 0), 'state');
$maxPlanetCount = PlayerUtil::maxPlanetCount($senderUser);
if ($currentPlanetCount >= $maxPlanetCount) {
$message = sprintf($LNG['sys_colo_maxcolo'], GetTargetAddressLink($this->_fleet, ''), $maxPlanetCount);
} else {
$NewOwnerPlanet = PlayerUtil::createPlanet($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $this->_fleet['fleet_universe'], $this->_fleet['fleet_owner'], $LNG['fcp_colony'], false, $senderUser['authlevel']);
if ($NewOwnerPlanet === false) {
$message = sprintf($LNG['sys_colo_badpos'], GetTargetAddressLink($this->_fleet, ''));
$this->setState(FLEET_RETURN);
} else {
$this->_fleet['fleet_end_id'] = $NewOwnerPlanet;
$message = sprintf($LNG['sys_colo_allisok'], GetTargetAddressLink($this->_fleet, ''));
$this->StoreGoodsToPlanet();
if ($this->_fleet['fleet_amount'] == 1) {
$this->KillFleet();
} else {
$CurrentFleet = explode(";", $this->_fleet['fleet_array']);
$NewFleet = '';
foreach ($CurrentFleet as $Group) {
if (empty($Group)) {
continue;
}
$Class = explode(",", $Group);
if ($Class[0] == 208 && $Class[1] > 1) {
$NewFleet .= $Class[0] . "," . ($Class[1] - 1) . ";";
} elseif ($Class[0] != 208 && $Class[1] > 0) {
$NewFleet .= $Class[0] . "," . $Class[1] . ";";
}
}
$this->UpdateFleet('fleet_array', $NewFleet);
$this->UpdateFleet('fleet_amount', $this->_fleet['fleet_amount'] - 1);
$this->UpdateFleet('fleet_resource_metal', 0);
$this->UpdateFleet('fleet_resource_crystal', 0);
$this->UpdateFleet('fleet_resource_deuterium', 0);
}
}
}
}
}
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_colo_mess_from'], 4, $LNG['sys_colo_mess_report'], $message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
$this->setState(FLEET_RETURN);
$this->SaveFleet();
}
示例14: TargetEvent
function TargetEvent()
{
global $resource, $reslist;
$db = Database::get();
$sqlFields = array();
$elementIDs = array_merge($reslist['defense'], $reslist['missile']);
foreach ($elementIDs as $elementID) {
$sqlFields[] = '%%PLANETS%%.`' . $resource[$elementID] . '`';
}
$sql = 'SELECT lang, shield_tech,
%%PLANETS%%.id, name, id_owner, ' . implode(', ', $sqlFields) . '
FROM %%PLANETS%%
INNER JOIN %%USERS%% ON id_owner = %%USERS%%.id
WHERE %%PLANETS%%.id = :planetId;';
$targetData = $db->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_end_id']));
if ($this->_fleet['fleet_end_type'] == 3) {
$sql = 'SELECT ' . $resource[502] . ' FROM %%PLANETS%% WHERE id_luna = :moonId;';
$targetData[$resource[502]] = $db->selectSingle($sql, array(':moonId' => $this->_fleet['fleet_end_id']), $resource[502]);
}
$sql = 'SELECT lang, military_tech FROM %%USERS%% WHERE id = :userId;';
$senderData = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner']));
if (!in_array($this->_fleet['fleet_target_obj'], $reslist['defense']) || !in_array($this->_fleet['fleet_target_obj'], $reslist['missile']) || $this->_fleet['fleet_target_obj'] == 502 || $this->_fleet['fleet_target_obj'] == 0) {
$primaryTarget = 401;
} else {
$primaryTarget = $this->_fleet['fleet_target_obj'];
}
$targetDefensive = array();
foreach ($elementIDs as $elementID) {
$targetDefensive[$elementID] = $targetData[$resource[$elementID]];
}
unset($targetDefensive[502]);
$LNG = $this->getLanguage(Config::get($this->_fleet['fleet_universe'])->lang, array('L18N', 'FLEET', 'TECH'));
if ($targetData[$resource[502]] >= $this->_fleet['fleet_amount']) {
$message = $LNG['sys_irak_no_att'];
$where = $this->_fleet['fleet_end_type'] == 3 ? 'id_luna' : 'id';
$sql = 'UPDATE %%PLANETS%% SET ' . $resource[502] . ' = ' . $resource[502] . ' - :amount WHERE ' . $where . ' = :planetId;';
$db->update($sql, array(':amount' => $this->_fleet['fleet_amount'], ':planetId' => $targetData['id']));
} else {
if ($targetData[$resource[502]] > 0) {
$where = $this->_fleet['fleet_end_type'] == 3 ? 'id_luna' : 'id';
$sql = 'UPDATE %%PLANETS%% SET ' . $resource[502] . ' = :amount WHERE ' . $where . ' = :planetId;';
$db->update($sql, array(':amount' => 0, ':planetId' => $targetData['id']));
}
$targetDefensive = array_filter($targetDefensive);
if (!empty($targetDefensive)) {
require_once 'includes/classes/missions/functions/calculateMIPAttack.php';
$result = calculateMIPAttack($targetData["shield_tech"], $senderData["military_tech"], $this->_fleet['fleet_amount'], $targetDefensive, $primaryTarget, $targetData[$resource[502]]);
$result = array_filter($result);
$message = sprintf($LNG['sys_irak_def'], $targetData[$resource[502]]) . '<br><br>';
ksort($result, SORT_NUMERIC);
foreach ($result as $Element => $destroy) {
$message .= sprintf('%s (- %d)<br>', $LNG['tech'][$Element], $destroy);
$sql = 'UPDATE %%PLANETS%% SET ' . $resource[$Element] . ' = ' . $resource[$Element] . ' - :amount WHERE id = :planetId;';
$db->update($sql, array(':planetId' => $targetData['id'], ':amount' => $destroy));
}
} else {
$message = $LNG['sys_irak_no_def'];
}
}
$sql = 'SELECT name FROM %%PLANETS%% WHERE id = :planetId;';
$planetName = Database::get()->selectSingle($sql, array(':planetId' => $this->_fleet['fleet_start_id']), 'name');
$ownerLink = $planetName . " " . GetStartAddressLink($this->_fleet);
$targetLink = $targetData['name'] . " " . GetTargetAddressLink($this->_fleet);
$message = sprintf($LNG['sys_irak_mess'], $this->_fleet['fleet_amount'], $ownerLink, $targetLink) . $message;
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_tower'], 3, $LNG['sys_irak_subject'], $message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
PlayerUtil::sendMessage($this->_fleet['fleet_target_owner'], 0, $LNG['sys_mess_tower'], 3, $LNG['sys_irak_subject'], $message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
$this->KillFleet();
}
示例15: adminDiplomacyCreateProcessor
protected function adminDiplomacyCreateProcessor()
{
global $LNG, $USER;
if (!$this->rights['DIPLOMATIC']) {
$this->redirectToHome();
}
$db = Database::get();
$id = HTTP::_GP('ally_id', '', UTF8_SUPPORT);
$sql = "SELECT id, ally_name, ally_owner, ally_tag, (SELECT level FROM %%DIPLO%% WHERE (owner_1 = :id AND owner_2 = :allianceId) OR (owner_2 = :id AND owner_1 = :allianceId)) as diplo FROM %%ALLIANCE%% WHERE ally_universe = :universe AND id = :id;";
$targetAlliance = $db->selectSingle($sql, array(':allianceId' => $USER['ally_id'], ':id' => $id, ':universe' => Universe::current()));
if (empty($targetAlliance)) {
$this->sendJSON(array('error' => true, 'message' => sprintf($LNG['al_diplo_no_alliance'], $targetAlliance['id'])));
}
if (!empty($targetAlliance['diplo'])) {
$this->sendJSON(array('error' => true, 'message' => sprintf($LNG['al_diplo_exists'], $targetAlliance['ally_name'])));
}
if ($targetAlliance['id'] == $this->allianceData['id']) {
$this->sendJSON(array('error' => true, 'message' => $LNG['al_diplo_same_alliance']));
}
$this->setWindow('ajax');
$level = HTTP::_GP('level', 0);
$text = HTTP::_GP('text', '', true);
if ($level == 5) {
PlayerUtil::sendMessage($targetAlliance['ally_owner'], $USER['id'], TIMESTAMP, 1, $LNG['al_circular_alliance'] . $this->allianceData['ally_tag'], $LNG['al_diplo_war'], sprintf($LNG['al_diplo_war_mes'], "[" . $this->allianceData['ally_tag'] . "] " . $this->allianceData['ally_name'], "[" . $targetAlliance['ally_tag'] . "] " . $targetAlliance['ally_name'], $LNG['al_diplo_level'][$level], $text));
} else {
PlayerUtil::sendMessage($targetAlliance['ally_owner'], $USER['id'], TIMESTAMP, 1, $LNG['al_circular_alliance'] . $this->allianceData['ally_tag'], $LNG['al_diplo_ask'], sprintf($LNG['al_diplo_ask_mes'], $LNG['al_diplo_level'][$level], "[" . $this->allianceData['ally_tag'] . "] " . $this->allianceData['ally_name'], "[" . $targetAlliance['ally_tag'] . "] " . $targetAlliance['ally_name'], $text));
}
$sql = "INSERT INTO %%DIPLO%% SET owner_1 = :allianceId, owner_2 = :allianceTargetID, level\t= :level, accept = 0, accept_text = :text, universe\t= :universe";
$db->insert($sql, array(':allianceId' => $USER['ally_id'], ':allianceTargetID' => $targetAlliance['id'], ':level' => $level, ':text' => $text, ':universe' => Universe::current()));
$this->sendJSON(array('error' => false, 'message' => $LNG['al_diplo_create_done']));
}