private function RessToImgAndText($key) { $inf = false; foreach ($this->ress as $v) { if (p_stripos($v['Field'], $key, 0) !== false) { $inf = $v; } } if (!$inf) { return ''; } return "<img src='{$inf['Image']}'/> {$inf['Nom']}"; }
function GetInner($data, $from, $to = '') { $l = p_strlen($from); $f = p_stripos($data, $from, 0); $t = p_stripos($data, $to, $l + $f); if ($f === false) { $inner = $data; } elseif ($t === false) { $inner = p_substr($data, $f + $l, -1); } else { $inner = p_substr($data, $f + $l, $t - $f - $l); } return trim($inner); }
* Dernière modification: $Id$ * @license GNU Public License 3.0 ( http://www.gnu.org/licenses/gpl-3.0.txt ) * @license Creative Commons 3.0 BY-SA ( http://creativecommons.org/licenses/by-sa/3.0/deed.fr ) * **/ require_once './init.php'; require_once INCLUDE_PATH . 'Script.php'; require_once CLASS_PATH . 'parser.class.php'; Members::CheckPermsOrDie('PERSO'); $lng = language::getinstance()->GetLngBlock('personal'); if (isset($_POST['importation'])) { // $data = file_get_contents('./test/data/mafiche_ff.txt'); $data = gpc_esc($_POST['importation']); $parser = parser::getinstance(); // simple détection... if (p_stripos($parser->GetValueByLabel($data, $lng['ident']), $_SESSION['_login'], 0) !== false) { $matrix = explode("\n", trim($data)); $info = array(); $info['GameGrade'] = trim($matrix[0]); $info['Race'] = $parser->GetValueByLabel($data, $lng['Race']); $info['Titre'] = $parser->GetValueByLabel($data, $lng['Titre']); $info['Commerce'] = $parser->GetValueByLabel($data, $lng['Commerce']); $info['Recherche'] = $parser->GetValueByLabel($data, $lng['Recherche']); $info['Combat'] = $parser->GetValueByLabel($data, $lng['Combat']); $info['Construction'] = $parser->GetValueByLabel($data, $lng['Construction']); $info['Economie'] = $parser->GetValueByLabel($data, $lng['Economie']); $info['Navigation'] = $parser->GetValueByLabel($data, $lng['Navigation']); $info['POINTS'] = DataEngine::strip_number($parser->GetValueByLabel($data, $lng['POINTS'])); $info['pts_architecte'] = DataEngine::strip_number($parser->GetValueByLabel($data, $lng['pts_architecte'])); $info['pts_mineur'] = DataEngine::strip_number($parser->GetValueByLabel($data, $lng['pts_mineur'])); $info['pts_science'] = DataEngine::strip_number($parser->GetValueByLabel($data, $lng['pts_science']));
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']; }