Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universe #38

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
$db->sql_close();
?>
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo ($lang['MOD_XTENSE_LANG']); ?>" lang="<?php echo ($lang['MOD_XTENSE_LANG']); ?>">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="<?php echo ($lang['MOD_XTENSE_LANG']); ?>" lang="<?php echo ($lang['MOD_XTENSE_LANG']); ?>">

<head>
<title><?php echo $lang['MOD_XTENSE_TITLE'] . " " . $version; ?></title>
Expand Down Expand Up @@ -427,7 +427,7 @@
<p><?php echo ($lang['MOD_XTENSE_AUTHOR']); ?></a></p>
<p><?php echo ($lang['MOD_XTENSE_FORUM']); ?> : <a href="https://forum.ogsteam.eu/" onclick="return winOpen(this);" target="_blank" rel="noopener"><?php echo ($lang['MOD_XTENSE_TITLE']); ?></a>
</p>
<p><?php echo ($lang['MOD_XTENSE_ICONS']); ?> "Silk icons" <a href="http://www.famfamfam.com/lab/icons/silk/">FamFamFam</a></p>
<p><?php echo ($lang['MOD_XTENSE_ICONS']); ?> "Silk icons" <a href="https://www.famfamfam.com/lab/icons/silk/">FamFamFam</a></p>

<div class="sep"></div>
<h2><?php echo ($lang['MOD_XTENSE_CHANGELOG']); ?></h2>
Expand Down
46 changes: 39 additions & 7 deletions xtense.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,15 +587,35 @@

foreach ($system_data as $row => $v) {
$statusTemp = (Check::player_status_forbidden($v['status']) ? "" : $v['status']); //On supprime les status qui sont subjectifs

//default player_id/ally_id à -1 (cf shemas SQL)
$v['player_id'] = (isset($v['player_id']) ? (int)$v['player_id'] : -1);
$v['ally_id'] = (isset($v['ally_id']) ? (int)$v['ally_id'] : -1);
$v['ally_id'] = ((int)$v['ally_id'] == 0) ? -1 : $v['ally_id'];

//Lors de l'insert ou de l'update il y a l'insert ou l'update de la table game_ally et game_player
// phase transitoire avec doublon d information antre table universe(1) et game_player(2)
//Table universe(1)
if (!isset($update[$row]))
$db->sql_query("INSERT INTO " . TABLE_UNIVERSE . " (`galaxy`, `system`, `row`, `name`, `player`, `ally`, `status`, `last_update`, `last_update_user_id`, `moon`)
VALUES (" . $galaxy . ", " . $system . ", " . $row . ", '" . $v['planet_name'] . "', '" . $v['player_name'] . "', '" . $v['ally_tag'] . "', '" . $statusTemp . "', " . $time . ", " . $user_data['user_id'] . ", '" . $v['moon'] . "')");
$db->sql_query("INSERT INTO " . TABLE_UNIVERSE . " (`galaxy`, `system`, `row`, `name`, `player`, `player_id`, `ally`, `ally_id`, `status`, `last_update`, `last_update_user_id`, `moon`)
VALUES (" . $galaxy . ", " . $system . ", " . $row . ", '" . $v['planet_name'] . "', '" . $v['player_name'] . "', '" . $v['player_id'] . "', '" . $v['ally_tag'] . "', '" . $v['ally_id'] . "', '" . $statusTemp . "', " . $time . ", " . $user_data['user_id'] . ", '" . $v['moon'] . "')");
else {
$db->sql_query(
"UPDATE " . TABLE_UNIVERSE . " SET name = '" . $v['planet_name'] . "', player = '" . $v['player_name'] . "' , ally = '" . $v['ally_tag'] . "', status = '" . $statusTemp . "', moon = '" . $v['moon'] . "', last_update = " . $time . ", last_update_user_id = " . $user_data['user_id']
"UPDATE " . TABLE_UNIVERSE . " SET name = '" . $v['planet_name'] . "', player = '" . $v['player_name'] . "' , player_id = '" . $v['player_id'] . "' , ally = '" . $v['ally_tag'] . "', ally_id = '" . $v['ally_id'] . "', status = '" . $statusTemp . "', moon = '" . $v['moon'] . "', last_update = " . $time . ", last_update_user_id = " . $user_data['user_id']
. " WHERE galaxy = " . $galaxy . " AND system = " . $system . " AND row = " . $row
);
}
//Table Game_player(2)
if( $v['player_id'] != -1)
{
$db->sql_query(
"REPLACE INTO " . TABLE_GAME_PLAYER . "
( player_id , player, status , ally_id , datadate )
VALUES
( " . $v['player_id'] . " , '" . $v['player_name'] . "' , '" . $statusTemp . "' , " . $v['ally_id'] . " , " . $time . ")
");
}
//La table game ally ne peut se mettre à jour, champs ally non alimenté (toutes les infos sont dans page rank)
}

if (!empty($delete)) {
Expand Down Expand Up @@ -765,11 +785,17 @@
}
}
} else {
$fields = 'datadate, rank, ally, ally_id, points, sender_id, number_member, points_per_member';
$Ranks_fields = 'datadate, rank, ally, ally_id, points, sender_id, number_member, points_per_member';
$Game_Ally_fields = 'datadate, ally_id, ally, tag, number_member';
foreach ($n as $i => $val) {
$data = $n[$i];
$data['ally_tag'] = filter_var($data['ally_tag'], FILTER_DEFAULT);

if (isset($data['ally'])) {
$data['ally'] = filter_var($data['ally'], FILTER_DEFAULT);
} else {
throw new UnexpectedValueException("Ranking Ally: Alliance Name not found");
}
if (isset($data['ally_id'])) {
$data['ally_id'] = filter_var($data['ally_id'], FILTER_SANITIZE_NUMBER_INT);
} else {
Expand All @@ -791,12 +817,18 @@
throw new UnexpectedValueException("Ranking Ally: Nb players not found");
}

$query[] = "({$timestamp}, {$data['rank']} , '{$data['ally_tag']}' , {$data['ally_id']} , {$data['points']} , {$user_data['user_id']} , {$data['members']} ,{$data['mean']} )";
$Ranks_query[] = "({$timestamp}, {$data['rank']} , '{$data['ally_tag']}' , {$data['ally_id']} , {$data['points']} , {$user_data['user_id']} , {$data['members']} ,{$data['mean']} )";
$Game_Ally_query[] = "({$timestamp}, {$data['ally_id']} , '{$data['ally']}' , '{$data['ally_tag']}' , {$data['members']} )";
$datas[] = $data;
$total++;
}
if (!empty($query)) {
$db->sql_query("REPLACE INTO " . $table . " (" . $fields . ") VALUES " . implode(',', $query));
//Table Rank
if (!empty($Ranks_query)) {
$db->sql_query("REPLACE INTO " . $table . " (" . $Ranks_fields . ") VALUES " . implode(',', $Ranks_query));
}
//Table game_ally
if (!empty($Ranks_query)) {
$db->sql_query("REPLACE INTO " . TABLE_GAME_ALLY . " (" . $Game_Ally_fields . ") VALUES " . implode(',', $Game_Ally_query));
}
}

Expand Down
Loading