public function getBody() { $timeframe = Neuron_Core_Tools::getInput('_GET', 'timeframe', 'int', 60 * 60 * 48); $db = Neuron_DB_Database::__getInstance(); $page = new Neuron_Core_Template(); $page->set('timeframe', $timeframe); // Fetch all doubles $data = $db->query("\n\t\t\tSELECT\n\t\t\t\tn_login_log.l_ip,\n\t\t\t\t\n\t\t\t\tGROUP_CONCAT(DISTINCT n_login_log.l_plid) AS plids,\n\t\t\t\tGROUP_CONCAT(DISTINCT n_players.nickname) AS nicknames,\n\t\t\t\t\n\t\t\t\tGROUP_CONCAT(c.pac_plid1) AS cleared_1,\n\t\t\t\tGROUP_CONCAT(c.pac_plid2) AS cleared_2,\n\t\t\t\tGROUP_CONCAT(c.pac_reason) AS cleared_reason,\n\t\t\t\t\n\t\t\t\tCOUNT(DISTINCT l_plid) AS aantal\n\t\t\tFROM\n\t\t\t\tn_login_log\n\t\t\tLEFT JOIN\n\t\t\t\tn_players ON n_login_log.l_plid = n_players.plid\n\t\t\tLEFT JOIN\n\t\t\t\tn_players_admin_cleared c ON (c.pac_plid1 = n_login_log.l_plid OR c.pac_plid2 = n_login_log.l_plid)\n\t\t\tWHERE\n\t\t\t\tn_login_log.l_datetime > FROM_UNIXTIME(" . (NOW - $timeframe) . ") AND\n\t\t\t\tn_players.isPlaying = 1\n\t\t\tGROUP BY\n\t\t\t\tl_ip\n\t\t\tHAVING\n\t\t\t\taantal > 1\n\t\t"); foreach ($data as $row) { $plids = explode(',', $row['plids']); $nicknames = explode(',', $row['nicknames']); // Check clearances. $clearances = $this->getClearancesFromRow($row); $players = array(); $combinedlogs = ""; foreach ($plids as $k => $v) { $players[] = array('id' => $plids[$k], 'name' => isset($nicknames[$k]) ? $nicknames[$k] : 'no-nickname-set', 'url' => $this->getUrl('user', array('id' => $plids[$k])), 'logs_url' => $this->getUrl('gamelogs', array('players' => $plids[$k]))); $combinedlogs .= $plids[$k] . "|"; } // Check for cleared accounts $allcleared = true; foreach ($players as $k => $v) { $players[$k]['cleared'] = $this->isCleared($clearances, $v, $players); if ($allcleared && !$players[$k]['cleared']) { $allcleared = false; } } $combinedlogs = substr($combinedlogs, 0, -1); $page->addListValue('players', array('ip' => $row['l_ip'], 'players' => $players, 'combined_logs_url' => $this->getUrl('gamelogs', array('players' => $combinedlogs)), 'clearmultis' => $this->getUrl('clearmultis', array('players' => $combinedlogs)), 'cleared' => $allcleared, 'amount' => $row['aantal'])); } $page->usortList('players', array($this, 'sortcompare')); return $page->parse('pages/admin/multis.phpt'); }
public static function set(Neuron_GameServer_Player $player, $key, $value) { $db = Neuron_DB_Database::getInstance(); $data = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tn_players_registry\n\t\t\tWHERE\n\t\t\t\tplid = {$player->getId()} AND \n\t\t\t\tpr_name = '{$db->escape($key)}'\n\t\t"); if (count($data) == 0) { $db->query("\n\t\t\t\tINSERT INTO\n\t\t\t\t\tn_players_registry\n\t\t\t\tSET\n\t\t\t\t\tplid = {$player->getId()},\n\t\t\t\t\tpr_name = '{$db->escape($key)}',\n\t\t\t\t\tpr_value = '{$db->escape($value)}'\n\t\t\t"); } else { $db->query("\n\t\t\t\tUPDATE\n\t\t\t\t\tn_players_registry\n\t\t\t\tSET\n\t\t\t\t\tpr_value = '{$db->escape($value)}'\n\t\t\t\tWHERE\n\t\t\t\t\tplid = {$player->getId()} AND\n\t\t\t\t\tpr_name = '{$db->escape($key)}'\n\t\t\t\t\t\n\t\t\t"); } }
public function evaluate() { $db = Neuron_DB_Database::getInstance(); foreach ($this->getPendingQuests() as $v) { if ($v->isFinished($this->objProfile)) { $v->onComplete($this->objProfile); $db->query("\n\t\t\t\t\tUPDATE\n\t\t\t\t\t\tn_players_quests\n\t\t\t\t\tSET\n\t\t\t\t\t\tq_finished = '1'\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tq_id = {$v->getId()} AND\n\t\t\t\t\t\tplid = {$this->objProfile->getId()}\n\t\t\t\t"); } } }
public static function getTimeSinceLastCheckpointSide(Dolumar_Underworld_Models_Mission $mission, Neuron_GameServer_Map_Location $location) { $db = Neuron_DB_Database::getInstance(); $time = $db->query("\n\t\t\tSELECT\n\t\t\t\tUNIX_TIMESTAMP(uc_date) AS datum\n\t\t\tFROM\n\t\t\t\tunderworld_checkpoints\n\t\t\tWHERE\n\t\t\t\tum_id = {$mission->getId()} AND\n\t\t\t\tuc_x = {$location->x()} AND\n\t\t\t\tuc_y = {$location->y()}\n\t\t"); if (count($time) > 0) { return NOW - $time[0]['datum']; } else { return 0; } }
private static function getAllQuests() { $db = Neuron_DB_Database::getInstance(); $data = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tn_quests\n\t\t"); $out = array(); foreach ($data as $v) { $out[$v['q_id']] = $v['q_class']; } return $out; }
public function __construct($sTable) { $this->sTable = $sTable; $db = Neuron_DB_Database::getInstance(); $this->dbObj = $db->getConnection(); //$this->dbObj = new Mysqli (DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $this->objMemcache = Neuron_Core_Memcache::getInstance(); $server = Neuron_GameServer::getServer(); $this->iServer = $server->getServerId(); }
private function getAllImages() { $page = new Neuron_Core_Template(); $db = Neuron_DB_Database::getInstance(); $data = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tplayers_tiles\n\t\t\tORDER BY\n\t\t\t\tt_id DESC\n\t\t"); foreach ($data as $v) { $page->addListValue('tiles', array('src' => PUBLIC_URL . $v['t_imagename'])); } return $page->parse('pages/customsign/list.phpt'); }
public function addModeratorAction($sAction, $mParams, $reason, Neuron_GameServer_Player $player, $isDone = false) { $db = Neuron_DB_Database::getInstance(); $login = Neuron_Core_Login::getInstance(); $userid = intval($login->getUserId()); $isDone = $isDone ? true : false; $processed = $isDone ? 1 : 0; $executed = $isDone ? 1 : 0; $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tn_mod_actions\n\t\t\tSET\n\t\t\t\tma_action = '" . $db->escape($sAction) . "',\n\t\t\t\tma_data = '" . $db->escape(json_encode($mParams)) . "',\n\t\t\t\tma_plid = {$userid},\n\t\t\t\tma_date = NOW(),\n\t\t\t\tma_reason = '" . $db->escape($reason) . "',\n\t\t\t\tma_target = '{$player->getId()}',\n\t\t\t\tma_processed = {$processed},\n\t\t\t\tma_executed = {$executed}\n\t\t"); }
public function ban($sChannel = 'chat', $duration = 3600, $ban = true) { $db = Neuron_DB_Database::getInstance(); $db->query("\n\t\t\tDELETE FROM\n\t\t\t\tn_players_banned\n\t\t\tWHERE\n\t\t\t\tplid = {$this->objProfile->getId()} AND\n\t\t\t\tbp_channel = '{$db->escape($sChannel)}'\n\t\t"); $this->bans = null; // First unban if ($ban) { $db->query("\n\t\t\t\tINSERT INTO\n\t\t\t\t\tn_players_banned\n\t\t\t\tSET\n\t\t\t\t\tplid = {$this->objProfile->getId()},\n\t\t\t\t\tbp_channel = '{$db->escape($sChannel)}',\n\t\t\t\t\tbp_end = FROM_UNIXTIME(" . (time() + $duration) . ")\n\t\t\t"); } }
public function setPreference($sKey, $sValue) { $db = Neuron_DB_Database::getInstance(); // Check if exist $check = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tn_players_preferences\n\t\t\tWHERE\n\t\t\t\tp_key = '{$db->escape($sKey)}'\n\t\t\t\tAND p_plid = {$this->objProfile->getId()}\n\t\t"); if (count($check) == 0) { $db->query("\n\t\t\t\tINSERT INTO\n\t\t\t\t\tn_players_preferences\n\t\t\t\tSET\n\t\t\t\t\tp_key = '{$db->escape($sKey)}',\n\t\t\t\t\tp_value = '{$db->escape($sValue)}',\n\t\t\t\t\tp_plid = {$this->objProfile->getId()}\n\t\t\t"); } else { $db->query("\n\t\t\t\tUPDATE\n\t\t\t\t\tn_players_preferences\n\t\t\t\tSET\n\t\t\t\t\tp_value = '{$db->escape($sValue)}'\n\t\t\t\tWHERE\n\t\t\t\t\tp_key = '{$db->escape($sKey)}' AND\n\t\t\t\t\tp_plid = {$this->objProfile->getId()}\n\t\t\t"); } }
public function registerVisit($village) { $db = Neuron_DB_Database::getInstance(); // Check if exists $chk = $db->query("\n\t\t\tSELECT\n\t\t\t\tvi_id\n\t\t\tFROM\n\t\t\t\tvillages_visits\n\t\t\tWHERE\n\t\t\t\tv_id = {$this->objProfile->getId()} AND \n\t\t\t\tvi_v_id = {$village->getId()} \n\t\t"); if (count($chk) > 0) { $db->query("\n\t\t\t\tUPDATE\n\t\t\t\t\tvillages_visits\n\t\t\t\tSET\n\t\t\t\t\tvi_date = NOW()\n\t\t\t\tWHERE\n\t\t\t\t\tv_id = {$this->objProfile->getId()} AND \n\t\t\t\t\tvi_v_id = {$village->getId()} \n\t\t\t"); } else { $db->query("\n\t\t\t\tINSERT INTO\n\t\t\t\t\tvillages_visits\n\t\t\t\tSET\n\t\t\t\t\tvi_date = NOW(),\n\t\t\t\t\tv_id = {$this->objProfile->getId()},\n\t\t\t\t\tvi_v_id = {$village->getId()}\n\t\t\t"); } }
public function setSocialStatus(Neuron_GameServer_Player $player, $status) { $db = Neuron_DB_Database::getInstance(); $status = intval($status); // Check if already in here. $chk = $db->query("\n\t\t\tSELECT\n\t\t\t\tps_status\n\t\t\tFROM\n\t\t\t\tn_players_social\n\t\t\tWHERE\n\t\t\t\tps_plid = {$this->getId()} \n\t\t\t\tAND ps_targetid = {$player->getId()}\n\t\t"); if (count($chk) == 0) { $db->query("\n\t\t\t\tINSERT INTO\n\t\t\t\t\tn_players_social\n\t\t\t\tSET\n\t\t\t\t\tps_plid = {$this->getId()},\n\t\t\t\t\tps_targetid = {$player->getId()},\n\t\t\t\t\tps_status = '{$status}'\n\t\t\t"); } else { $db->query("\n\t\t\t\tUPDATE\n\t\t\t\t\tn_players_social\n\t\t\t\tSET\n\t\t\t\t\tps_status = '{$status}'\n\t\t\t\tWHERE\n\t\t\t\t\tps_targetid = {$player->getId()} AND\n\t\t\t\t\tps_plid = {$this->getId()}\n\t\t\t"); } }
public static function getObject($id) { $db = Neuron_DB_Database::getInstance(); $id = intval($id); $data = $db->query("\n\t\t\tSELECT\n\t\t\t\tai_class,\n\t\t\t\tai_identifier\n\t\t\tFROM\n\t\t\t\tn_id\n\t\t\tWHERE\n\t\t\t\tai_id = {$id}\n\t\t"); if (count($data) > 0) { $class = Andromeda_Mappers_ClassMapper::getClass($data[0]['ai_class']); return $class::getFromIdentifiableString($data[0]['ai_identifier']); } else { throw new Exception("Object not found in IDMapper."); } }
private function processAction($id, $bExecute) { $id = intval($id); $bExecute = $bExecute ? true : false; $db = Neuron_DB_Database::getInstance(); if ($bExecute) { $input = $db->query("\n\t\t\t\tSELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\tn_mod_actions\n\t\t\t\tWHERE\n\t\t\t\t\tma_id = {$id}\n\t\t\t"); if (count($input) == 1) { $this->executeAction($input[0]); } } $db->query("\n\t\t\tUPDATE\n\t\t\t\tn_mod_actions\n\t\t\tSET\n\t\t\t\tma_processed = 1,\n\t\t\t\tma_executed = " . ($bExecute ? '1' : '0') . "\n\t\t\tWHERE\n\t\t\t\tma_id = {$id}\n\t\t"); }
public static function getEffects() { $db = Neuron_DB_Database::getInstance(); $data = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\teffects\n\t\t"); $out = array(); foreach ($data as $v) { $tmp = self::getFromId($v['e_id']); if ($tmp) { $out[] = $tmp; } } return $out; }
private function getPublicBuildings() { $db = Neuron_DB_Database::getInstance(); $data = $db->query("\n\t\t\tSELECT\n\t\t\t\t*,\n\t\t\t\tUNIX_TIMESTAMP(t_startDate) AS startdatum,\n\t\t\t\tUNIX_TIMESTAMP(t_endDate) AS einddatum\n\t\t\tFROM\n\t\t\t\tplayers_tiles\n\t\t\tWHERE\n\t\t\t\tt_isPublic = 1 AND\n\t\t\t\t(t_startDate IS NULL OR t_startDate < FROM_UNIXTIME(" . NOW . ")) AND\n\t\t\t\t(t_endDate IS NULL OR t_endDate > FROM_UNIXTIME(" . NOW . "))\n\t\t"); $out = array(); foreach ($data as $v) { if (file_exists(PUBLIC_PATH . $v['t_imagename'])) { $building = Dolumar_Buildings_Building::getBuilding(100, $this->village->getRace(), 0, 0); $building->setBonusBuildingId($v['t_id']); $out[] = array('id' => $v['t_id'], 'image_url' => PUBLIC_URL . $v['t_imagename'], 'start_date' => $v['startdatum'], 'end_date' => $v['einddatum'], 'name' => $building->getName(), 'description' => $building->getCustomContent(), 'credits' => self::CREDIT_COST); } } return $out; }
public function withdrawHonour($amount) { $db = Neuron_DB_Database::__getInstance(); $amount *= -1; // A village gets 1 honour every hour: $duration = abs($amount) * 60 * 60; // Duration should take longer depending on the current honour $duration += min(0, 100 - $this->getHonour()) * 60 * 60; $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tvillages_morale\n\t\t\tSET\n\t\t\t\tm_vid = " . $this->objProfile->getId() . ",\n\t\t\t\tm_amount = " . $amount . ",\n\t\t\t\tm_start = FROM_UNIXTIME(" . NOW . "),\n\t\t\t\tm_end = FROM_UNIXTIME(" . (NOW + ceil($duration)) . ")\n\t\t"); // Clean the mess $db->query("\n\t\t\tDELETE FROM\n\t\t\t\tvillages_morale\n\t\t\tWHERE\n\t\t\t\tm_end < FROM_UNIXTIME(" . NOW . ")\n\t\t"); // Reset the honour $this->honour = null; }
public static function insert(Dolumar_Underworld_Models_Mission $mission, Dolumar_Underworld_Models_Battle $battle) { $data = $battle->getData(); $db = Neuron_DB_Database::getInstance(); $f = $battle->getAttacker()->getLocation(); $t = $battle->getDefender()->getLocation(); $fx = $f->x(); $fy = $f->y(); $tx = $t->x(); $ty = $t->y(); $as = $battle->getAttacker()->getSide()->getId(); $ds = $battle->getDefender()->getSide()->getId(); $id = $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tunderworld_log_battles\n\t\t\tSET\n\t\t\t\tuat_attacker = {$data['uat_attacker']},\n\t\t\t\tuat_defender = {$data['uat_defender']},\n\t\t\t\tuat_startdate = FROM_UNIXTIME({$data['startdate']}),\n\t\t\t\tuat_enddate = FROM_UNIXTIME({$data['enddate']}),\n\t\t\t\tuat_fightlog = '{$db->escape($data['uat_fightlog'])}',\n\t\t\t\tuat_from_x = {$fx},\n\t\t\t\tuat_from_y = {$fy},\n\t\t\t\tuat_to_x = {$tx},\n\t\t\t\tuat_to_y = {$ty},\n\t\t\t\tum_id = {$mission->getId()},\n\t\t\t\tuat_attacker_side = {$as},\n\t\t\t\tuat_defender_side = {$ds}\n\t\t"); $battle->setId($id); }
public function openPortal($village) { if ($village->equals($this->village)) { throw new Neuron_Core_Error('Can\'t open portal to own village.'); } $race = $village->getRace(); $building = Dolumar_Buildings_Portal::getBuilding(60, $race); $date = NOW + self::PORTAL_LIFESPAN_HOURES * 60 * 60 / GAME_SPEED_EFFECTS; $loc1 = $this->openPortalNearVillage($this->village, $building, $date); $loc2 = $this->openPortalNearVillage($village, $building, $date); $db = Neuron_DB_Database::getInstance(); $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tmap_portals\n\t\t\tSET\n\t\t\t\tp_caster_v_id = {$this->village->getId()},\n\t\t\t\tp_target_v_id = {$village->getId()},\n\t\t\t\tp_caster_x = {$loc1[0]},\n\t\t\t\tp_caster_y = {$loc1[1]},\n\t\t\t\tp_target_x = {$loc2[0]},\n\t\t\t\tp_target_y = {$loc2[1]},\n\t\t\t\tp_caster_b_id = {$loc1[2]},\n\t\t\t\tp_target_b_id = {$loc2[2]},\n\t\t\t\tp_endDate = FROM_UNIXTIME({$date})\n\t\t"); $logs = Dolumar_Players_Logs::getInstance(); $logs->addOpenPortalLog($this->village, $village, $date); }
public static function getId(Andromeda_Interfaces_Identifiable $object) { static $classnames; if (!isset($classnames)) { $classes = self::getClasses(); $classnames = $classes['names']; } $class = get_class($object); if (!isset($classnames[$class])) { $db = Neuron_DB_Database::getInstance(); $db->query("\n\t\t\t\tINSERT INTO\n\t\t\t\t\tn_classes\n\t\t\t\tSET\n\t\t\t\t\tac_name = '{$db->escape($class)}'\n\t\t\t"); $classes = self::getClasses(true); $classnames = $classes['names']; } return $classnames[$class]; }
public static function getFromId($id) { $db = Neuron_DB_Database::getInstance(); $data = explode(':', $id); $id = intval($data[0]); $level = isset($data[1]) ? intval($data[1]) : 1; $amount = isset($data[2]) ? intval($data[2]) : 0; $data = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tequipment\n\t\t\tWHERE\n\t\t\t\te_id = {$id}\n\t\t"); if (count($data) == 1) { $equipment = new self($data[0]['e_name'], $level); $equipment->addAmount($amount); return $equipment; } else { return false; } }
/** * Return all data from one given order ID */ public function speedupBuild($id, $amount) { $db = Neuron_DB_Database::getInstance(); $profiler = Neuron_Profiler_Profiler::__getInstance(); $profiler->start('Speeding up training of ' . $id . ' with ' . $amount . ' seconds.'); $data = $this->getTrainingStatus($id); if ($data) { $timeLeft = $data['timeLeft']; if ($amount > $timeLeft) { $amount = $timeLeft; } } $db->query("\n\t\t\tUPDATE\n\t\t\t\tvillages_units\n\t\t\tSET\n\t\t\t\tendTraining = endTraining - {$amount}\n\t\t\tWHERE\n\t\t\t\tuid = {$id}\n\t\t"); $profiler->stop(); return; }
public function addMapUpdate(Neuron_GameServer_Map_Location $location, $action) { $x = $location->x(); $y = $location->y(); switch ($action) { case 'BUILD': case 'DESTROY': break; default: $action = 'BUILD'; break; } $db = Neuron_DB_Database::getInstance(); $x = intval($x); $y = intval($y); $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tn_map_updates\n\t\t\tSET\n\t\t\t\tmu_action = '{$action}',\n\t\t\t\tmu_x = {$x},\n\t\t\t\tmu_y = {$y},\n\t\t\t\tmu_date = FROM_UNIXTIME(" . NOW . ")\n\t\t"); }
public function addQueueAction($sAction, $aData) { $owner = $this->village->getOwner(); if (!$owner->isPremium()) { $this->error = 'not_premium'; return false; } $db = Neuron_DB_Database::__getInstance(); // Check for maximum $chk = $db->query("\n\t\t\tSELECT\n\t\t\t\tCOUNT(pq_id) AS aantal\n\t\t\tFROM\n\t\t\t\tpremium_queue\n\t\t\tWHERE\n\t\t\t\tpq_vid = {$this->village->getId()}\n\t\t"); if (count($chk) == 1 && $chk[0]['aantal'] < 3) { $result = $db->query("\n\t\t\t\tINSERT INTO\n\t\t\t\t\tpremium_queue\n\t\t\t\tSET\n\t\t\t\t\tpq_vid = {$this->village->getId()},\n\t\t\t\t\tpq_action = '{$db->escape($sAction)}',\n\t\t\t\t\tpq_data = '" . $db->escape(json_encode($aData)) . "',\n\t\t\t\t\tpq_date = FROM_UNIXTIME(" . time() . ")\n\t\t\t"); return $result > 0; } else { $this->error = 'queuelimit'; return false; } }
public function getRefresh() { $data = $this->getRequestData(); if (!isset($data['lastlog'])) { $data['lastlog'] = $this->getInitialLogID(); } else { // Update all map areas that have been changed $db = Neuron_DB_Database::getInstance(); $ll = intval($data['lastlog']); $q = $db->query("\n\t\t\t\tSELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\tn_map_updates\n\t\t\t\tWHERE\n\t\t\t\t\tmu_id > {$ll}\n\t\t\t"); foreach ($q as $v) { //$this->alert ('reloading ' . $v['mu_x'] . ',' . $v['mu_y']); $this->reloadLocation($v['mu_x'], $v['mu_y']); if ($v['mu_id'] > $data['lastlog']) { $data['lastlog'] = $v['mu_id']; } } } $this->updateRequestData($data); //$this->updateContent (); }
public function prepare() { // Fetch a random target $networth = $this->getVillage()->getScore(); $minscore = floor($networth * 0.75); $maxscore = ceil($networth * 1.25); $db = Neuron_DB_Database::getInstance(); $myclanlist = ""; foreach ($this->getVillage()->getOwner()->getClans() as $v) { $myclanlist .= $v->getId() . ","; } $myclanlist = substr($myclanlist, 0, -1); $chk = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tvillages v\n\t\t\tLEFT JOIN\n\t\t\t\tn_players p USING(plid)\n\t\t\tLEFT JOIN\n\t\t\t\tclan_members cm ON cm.plid = p.plid AND cm.c_id IN ({$myclanlist})\n\t\t\tWHERE\n\t\t\t\tv.networth > {$minscore} AND\n\t\t\t\tv.networth < {$maxscore} AND\n\t\t\t\tv.plid != {$this->getVillage()->getOwner()->getId()} AND\n\t\t\t\tv.isActive = 1 AND\n\t\t\t\tp.startVacation IS NULL AND\n\t\t\t\tcm.c_id IS NULL\n\t\t\tORDER BY\n\t\t\t\tRAND()\n\t\t\tLIMIT\n\t\t\t\t1\n\t\t"); //die ($db->getLastQuery ()); if (count($chk) > 0) { $village = Dolumar_Players_Village::getVillage($chk[0]['vid']); $this->setTarget($village); } else { $this->setCastable(false); $this->setError(Dolumar_Effects_Effect::ERROR_NO_TARGET_FOUND); } }
public function getBody() { $db = Neuron_DB_Database::getInstance(); $data = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tn_players\n\t\t\tWHERE\n\t\t\t\tpremiumEndDate > FROM_UNIXTIME('" . NOW . "')\n\t\t"); $refund = Neuron_Core_Tools::getInput('_GET', 'refund', 'int'); $refund = $refund == 1; $page = new Neuron_Core_Template(); foreach ($data as $v) { $player = Neuron_GameServer::getPlayer($v['plid'], $v); $date = $player->getPremiumEndDate(); $diff = $date - NOW; $amounts = ceil($diff / (60 * 60 * 24 * 15)); $credits = $amounts * PREMIUM_COST_CREDITS; if ($refund) { $amref = $player->refundCredits($credits, 'premium account refund'); } else { $amref = false; } $page->addListValue('players', array('name' => $player->getDisplayName(), 'enddate' => date('d m Y H:i:s', $date), 'credits' => $credits, 'refunded' => $amref)); } return $page->parse('pages/admin/premium/premium.phpt'); }
public function checkBuildLocation($village, $x, $y, $bradius = MAXBUILDINGRADIUS) { $db = Neuron_DB_Database::getInstance(); $x = floor($x); $y = floor($y); $distance = MAXBUILDINGRADIUS * MAXBUILDINGRADIUS; /* $l = $db->query (" SELECT 1 FROM (SELECT 1) t WHERE EXISTS ( SELECT * FROM map_buildings WHERE ((xas - $x) * (xas - $x)) + ((yas - $y) * (yas - $y)) < ($distance) AND buildingType = 1 AND destroyDate = 0 ) "); */ $query = "\n\t\t\tSELECT\n\t\t\t\t1\n\t\t\tFROM \n\t\t\t\t(SELECT 1) t\n\t\t\tWHERE EXISTS\n\t\t\t(\n\t\t\t\tSELECT\n\t\t\t\t\txas\n\t\t\t\tFROM\n\t\t\t\t\tmap_buildings\n\t\t\t\tWHERE\n\t\t\t\t\txas BETWEEN " . ($x - $bradius) . " AND " . ($x + $bradius) . "\n\t\t\t\t\tAND yas BETWEEN " . ($y - $bradius) . " AND " . ($y + $bradius) . "\n\t\t\t\t\tAND (buildingType = 1 OR buildingType = 3) \n\t\t\t\t\tAND destroyDate = 0\n\t\t\t)\n\t\t"; $l = $db->query($query); if (count($l) > 0) { return array(false, 'minimalRange'); } $location = Dolumar_Map_Location::getLocation($x, $y); if ($location->canBuildBuilding()) { return array(true, array($x, $y)); } else { return array(false, 'minimalRange'); } }
public function getAdditionalContent($page) { $page = new Neuron_Core_Template(); $modes = Neuron_GameServer_Player::getAdminModes(); $out = array(); $db = Neuron_DB_Database::getInstance(); $i = 0; foreach ($modes as $k => $v) { if ($k > 0 && $k < 8) { $out[$v] = array(); $k = intval($k); $sql = $db->query("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tplid\n\t\t\t\t\tFROM\n\t\t\t\t\t\tn_players\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tp_admin = {$k}\n\t\t\t\t"); foreach ($sql as $vv) { $player = Neuron_GameServer::getPlayer($vv['plid']); $out[$v][] = $player->getDisplayName(); $i++; } } } $page->set('moderators', $out); $page->set('hasmods', $i > 0); return $page->parse('neuron/imprint/imprint.phpt'); }
public function getBody() { $myself = Neuron_GameServer::getPlayer(); if (!$myself->isAdmin()) { return '<p>You are not allowed to execute the commands. Only admins are.</p>'; } $page = new Neuron_Core_Template(); $login = Neuron_Core_Login::getInstance(); if (!$login->isLogin()) { $userid = 0; } else { $userid = $login->getUserId(); } $text = Neuron_Core_Text::getInstance(); $content = array(); foreach ($text->getLanguages() as $v) { $page->addListValue('languages', $v); $content[$v] = array('title' => Neuron_Core_Tools::getInput('_POST', 'title_' . $v, 'varchar'), 'description' => Neuron_Core_Tools::getInput('_POST', 'description_' . $v, 'varchar')); } if (isset($_FILES['imagefile'])) { $im = $this->getImageFromInput($_FILES['imagefile']); if ($im) { $new = $this->getGeneratedImage($im); if (!is_dir(PUBLIC_PATH . 'signs/')) { mkdir(PUBLIC_PATH . 'signs/'); chmod(PUBLIC_PATH . 'signs/', 0755); } $filename = $userid . '_' . date('dmYHis') . '.png'; imagepng($new, PUBLIC_PATH . 'signs/' . $filename); chmod(PUBLIC_PATH . 'signs/' . $filename, 0755); $db = Neuron_DB_Database::getInstance(); $db->query("\n\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\tplayers_tiles\n\t\t\t\t\tSET\n\t\t\t\t\t\tt_userid = " . intval($userid) . ",\n\t\t\t\t\t\tt_imagename = 'signs/" . $db->escape($filename) . "',\n\t\t\t\t\t\tt_isPublic = 1,\n\t\t\t\t\t\tt_description = '{$db->escape(json_encode($content))}'\n\t\t\t\t"); } } return $page->parse('dolumar/pages/admin/bonusbuilding/bonusbuilding.phpt'); }