public function __construct() { $this->BASE_FILE = ROOT_URL . 'pillage.php'; $this->ress = DataEngine::a_ressources(); $this->lng = language::getinstance()->GetLngBlock('pillage'); parent::__construct(); }
public function __construct() { $this->lng = language::getinstance()->GetLngBlock('ownuniverse'); foreach (DataEngine::a_ressources() as $v) { $this->ressourcesnames[$v['Field']] = $v['Nom']; } $this->BatimentsName = DataEngine::a_batiments(); $this->parser = parser::getinstance(); }
} } $newvalue = array('sort' => array($v => $invert_sort[$_GET['sort'][$v]])); $tpl->AddToRow(Get_string($newvalue), 'sort_' . $v); } $tpl->PushRow(); $sql = <<<sql SELECT udate, c.`ID`, c.`TYPE`, c.`POSIN`, c.`POSOUT`, c.`COORDET`, c.`COORDETOUT`, j.`USER`, j.`EMPIRE`, j.`INFOS`, c.`NOTE`, p.`water`, \tj.`batiments`, j.`troop`, j.`troop_date`, c.`UTILISATEUR`, p.`pID`, p.`Titane`, p.`Cuivre`, p.`Fer`, p.`Aluminium`, p.`Mercure`, p.`Silicium`, p.`Uranium`, p.`Krypton`, \tp.`Azote`, p.`Hydrogene` from `SQL_PREFIX_Coordonnee` c left outer join `SQL_PREFIX_Coordonnee_Joueurs` j on (c.`ID`=j.`jID`) left outer join `SQL_PREFIX_Coordonnee_Planetes` p on (c.`ID`=p.`pID`) {$where}{$sort}{$limit} sql; $mysql_result = DataEngine::sql($sql); $lngmain = language::getinstance()->GetLngBlock('dataengine'); $a_Ress = DataEngine::a_ressources(); $stype = $lngmain['types']['string']; $i = 0; $cmdinput = '<input class="color_row%%rowA%%" type="checkbox" value="1" id="item[%%id%%][%%cmd%%]" name="item[%%id%%][%%cmd%%]" %%bulle%%/>'; while ($ligne = mysql_fetch_assoc($mysql_result)) { $coords = $ligne['POSIN'] . '-' . $ligne['COORDET']; switch ($ligne['TYPE']) { case 1: $coords = $ligne['POSIN'] . '-' . $ligne['COORDET'] . '<br/>' . $ligne['POSOUT'] . '-' . $ligne['COORDETOUT']; case 6: $tpl->SetRowModelTypeC(); break; case 2: case 4: $tpl->SetRowModelTypeA(); foreach ($a_Ress as $k => $v) {
function AddPillage_log($mode, $idate, $msg) { // check si existant $sql = sprintf('SELECT `pid` FROM SQL_PREFIX_troops_pillage WHERE Player=\'%s\' AND date=%d', sqlesc($_SESSION['_login']), $idate); $result = DataEngine::sql($sql); if (mysql_numrows($result) > 0) { return $this->lng['log_allreadyexists']; } // Type du log/bataille // Puis recherche de la bataille (coords+participation) if ($mode == 'defender') { preg_match($this->lng['defender_regex'], $msg, $info); $ident = $this->lng['defender_ident']; if (!($planets = ownuniverse::getinstance()->get_coordswithname())) { return $this->lng['battle_error_ownuniverse']; } foreach ($planets as $v) { if ($v['Name'] == $info[$this->lng[$mode . '_regex_planetid']]) { cartographie::getinstance()->FormatId($v['Coord'], $idsys, $iddet, 'troops::AddPillage_log(def,1)'); break; } } $sql = sprintf('SELECT `ID` FROM `SQL_PREFIX_troops_attack` WHERE `type`=\'%s\' AND ' . '`coords_ss`=\'%s\' AND `coords_3p`=\'%s\' AND `when`<=%d AND `when`>=%d' . ' AND `players_defender` LIKE \'%%"%s"%%\' AND `players_attack` LIKE \'%%"%s"%%\'' . 'ORDER BY `when` DESC LIMIT 1', sqlesc($mode), $idsys, $iddet, $idate, $idate - 604800, sqlesc($_SESSION['_login']), sqlesc($info[$this->lng[$mode . '_regex_userid']])); $result = DataEngine::sql($sql); if (mysql_numrows($result) < 1) { return $this->lng['log_battlenofound']; } $line = mysql_fetch_assoc($result); $mid = $line['ID']; } else { preg_match($this->lng['attacker_regex'], $msg, $info); $ident = $this->lng['attacker_ident']; $sql = <<<sql SELECT `POSIN`, `COORDET` FROM `SQL_PREFIX_Coordonnee` LEFT JOIN `SQL_PREFIX_Coordonnee_Joueurs` on `ID`=`jID` WHERE `TYPE` in (0,3,5) AND `USER`='%s' AND `INFOS`='%s' sql; $sql = sprintf($sql, $info[$this->lng[$mode . '_regex_userid']], $info[$this->lng[$mode . '_regex_planetid']]); $result = DataEngine::sql($sql); if (mysql_numrows($result) < 1) { return $this->lng['log_coordsnotfound']; } if (mysql_numrows($result) > 1) { return $this->lng['log_multiplecoords']; } $line = mysql_fetch_assoc($result); $idsys = $line['POSIN']; $iddet = $line['COORDET']; $sql = sprintf('SELECT `ID` FROM `SQL_PREFIX_troops_attack` WHERE `type`=\'%s\' AND ' . '`coords_ss`=\'%s\' AND `coords_3p`=\'%s\' AND `when`<%d AND `when`>%d AND ' . '`players_attack` LIKE \'%%"%s"%%\' AND `players_defender` LIKE \'%%"%s"%%\'', sqlesc($mode), $idsys, $iddet, $idate, $idate - 604800, sqlesc($_SESSION['_login']), sqlesc($info[$this->lng[$mode . '_regex_userid']])); $result = DataEngine::sql($sql); if (mysql_numrows($result) < 1) { return $this->lng['log_battlenofound']; } if (mysql_numrows($result) > 1) { return 'Error battle result > 1 (omfg)'; } $line = mysql_fetch_assoc($result); $mid = $line['ID']; } // Info à ajouter $amsg = explode("\n", trim(p_substr($msg, p_stripos($msg, $ident, 0) + p_strlen($ident), -1))); $ares = DataEngine::a_ressources(); $fields = array(); $sets = array(); $fields[] = 'date'; $sets[] = $idate; $fields[] = 'mid'; $sets[] = $mid; $fields[] = 'Player'; $sets[] = '\'' . sqlesc($_SESSION['_login']) . '\''; foreach ($ares as $k => $v) { foreach ($amsg as $line) { list($key, $value) = explode(':', $line); if ($v['Nom'] == trim($key)) { $fields[] = 'ress' . $k; $sets[] = DataEngine::strip_number($value); break; } } } $fields = implode(',', $fields); $sets = implode(',', $sets); $sql = 'INSERT INTO `SQL_PREFIX_troops_pillage` (' . $fields . ') VALUES (' . $sets . ')'; $result = DataEngine::sql($sql); return $this->lng['log_added']; }