vue Mettre en place des Bots - Page 4
Kommunauty
Connexion
Inscription

Mettre en place des Bots


RitzzKnight Messages : 9

merci de t'as réponse sur un topic d'un ans

alors voila la ligne 440 :


$Planetes = $db->fetchquery("SELECT * FROM ".PLANETS." WHERE `id_owner` != '".$IdBot."' && `planet_type` = '1'" ) or die(print_r($db->erroInfo()));
mardi 16 janvier 2018 (Dernière édition mercredi 17 janvier 2018)

RitzzKnight Messages : 9

Voila ma founction MakeStats si sa t'aide :


final public function MakeStats()
{






// - Gestion des attaques Auto du Bot
        if (TIMESTAMP >= ($CONF['stat_last_update'] + (60 * $CONF['stat_update_time'])))
        {
            $IdBot = 2; // ID du Bot
            $IdPlaneteBot = 2; // ID de la planete du bot
            $Pourcent = 100; // Pourcentage de changde de lancer l'attaque
            
            $Chance = mt_rand(0,100);
if($Chance<$Pourcent)
{
// Génération de la flotte d'attaque
$V204 = mt_rand(1,100);
$V205 = mt_rand(1,80);
$V206 = mt_rand(1,60);
$V207 = mt_rand(1,40);
$V211 = mt_rand(1,30);
$V213 = mt_rand(1,20);
$V214 = mt_rand(1,10);
$FleetCount = $V204+$V205+$V206+$V207+$V211+$V213+$V214;
$FleetArray = "204,$V204;205,$V205;206,$V206;207,$V207;211,$V211;213,$V213;214,$V214;";

// Recuperation des infos planètes + selection aléatoir de la planete cible
$Planetes = $db->fetchquery("SELECT * FROM ".PLANETS." WHERE `id_owner` != '".$IdBot."' && `planet_type` = '1'" ) or die(print_r($db->erroInfo()));
$PlaneteBot = $db->fetchquery("SELECT * FROM ".PLANETS." WHERE `id` = '".$IdPlaneteBot."'");
$PlaneteBot = $PlaneteBot[0];
$PlaneteCible = $Planetes[mt_rand(0,(count($Planetes)-1))];                           

// Génération array pour requete Fleet
$FleetQRY      = "`".$resource[204] . "` = `".$resource[204]."` - '".floattostring($V204)."', ";
$FleetQRY     .= "`".$resource[205] . "` = `".$resource[205]."` - '".floattostring($V205)."', ";
$FleetQRY     .= "`".$resource[206] . "` = `".$resource[206]."` - '".floattostring($V206)."', ";
$FleetQRY     .= "`".$resource[207] . "` = `".$resource[207]."` - '".floattostring($V207)."', ";
$FleetQRY     .= "`".$resource[211] . "` = `".$resource[211]."` - '".floattostring($V211)."', ";
$FleetQRY     .= "`".$resource[213] . "` = `".$resource[213]."` - '".floattostring($V213)."', ";
$FleetQRY     .= "`".$resource[214] . "` = `".$resource[214]."` - '".floattostring($V214)."'";

// Ajout de la flotte necessaire à l'attaque
$FleetQRY2 = str_replace ("-","+", $FleetQRY);
$db->query("UPDATE ".PLANETS." SET ".$FleetQRY2." WHERE `id` = '".$PlaneteBot['id']."';");

// Calcul de la distance
if (($PlaneteBot['galaxy'] - $PlaneteCible['galaxy']) != 0)
$distance = abs($PlaneteBot['galaxy'] - $PlaneteCible['galaxy']) * 20000;
elseif (($PlaneteBot['system'] - $PlaneteCible['system']) != 0)
$distance = abs($PlaneteBot['system'] - $PlaneteCible['system']) * 95 + 2700;
elseif (($PlaneteBot['planet'] - $PlaneteCible['planet']) != 0)
$distance = abs($PlaneteBot['planet'] - $PlaneteCible['planet']) * 5 + 1000;
else
$distance = 5;
// Calcul du temps de vol + trajet
$TempsVol = round(max(((3500  * pow($distance * 10 / 20000, 0.5) + 10) / ($CONF['fleet_speed']/2500)), 5));
$Arrivee = TIMESTAMP + $TempsVol;
$Retour = TIMESTAMP + $TempsVol * 2;

// Lancement de l'attaque
$QryInsertFleet  = "LOCK TABLE ".FLEETS." WRITE, ".PLANETS." WRITE;
INSERT INTO ".FLEETS." SET
`fleet_owner` = '".$IdBot."',
`fleet_mission` = '1',
`fleet_amount` = '".$FleetCount."',
`fleet_array` = '".$FleetArray."',
`fleet_universe` = '".$PlaneteCible['universe']."',
`fleet_start_time` = '".$Arrivee."',
`fleet_start_id` = '".$PlaneteBot['id']."',
`fleet_start_galaxy` = '".$PlaneteBot['galaxy']."',
`fleet_start_system` = '".$PlaneteBot['system']."',
`fleet_start_planet` = '".$PlaneteBot['planet']."',
`fleet_start_type` = '".$PlaneteBot['planet_type']."',
`fleet_end_time` = '".$Retour."',
`fleet_end_stay` = '0',
`fleet_end_id` = '".$PlaneteCible['id']."',
`fleet_end_galaxy` = '".$PlaneteCible['galaxy']."',
`fleet_end_system` = '".$PlaneteCible['system']."',
`fleet_end_planet` = '".$PlaneteCible['planet']."',
`fleet_end_type` = '".$PlaneteCible['planet_type']."',
`fleet_resource_metal` = '0',
`fleet_resource_crystal` = '0',
`fleet_resource_deuterium` = '0',
`fleet_resource_norio` = '0',
`fleet_target_owner` = '".$PlaneteCible['id_owner']."',
`fleet_group` = '0',
`start_time` = '".TIMESTAMP."';
UPDATE `".PLANETS."` SET
".$FleetQRY."
WHERE
`id` = ".$IdBot." LIMIT 1;
UNLOCK TABLES;";

$db->multi_query($QryInsertFleet);
}
}

















global $db, $CONF;
$this->DeleteSome();
$AllyPoints = array();
$UserPoints = array();
$TotalData = $this->GetUsersInfosFromDB();
$FinalSQL = 'TRUNCATE TABLE '.STATPOINTS.';';
$FinalSQL .= "INSERT INTO ".STATPOINTS." (`id_owner`, `id_ally`, `stat_type`, `universe`, `tech_old_rank`, `tech_points`, `tech_count`, `build_old_rank`, `build_points`, `build_count`, `defs_old_rank`, `defs_points`, `defs_count`, `fleet_old_rank`, `fleet_points`, `fleet_count`, `total_old_rank`, `total_points`, `total_count`) VALUES ";

while($PlanetData = $db->fetch_array($TotalData['Planets']))
{
if((in_array($CONF['stat'], array(1, 2)) && $PlanetData['authlevel'] >= $CONF['stat_level']) || !empty($PlanetData['bana'])) continue;

  if(!isset($UserPoints[$PlanetData['id_owner']]))
$UserPoints[$PlanetData['id_owner']]['build']['count'] = $UserPoints[$PlanetData['id_owner']]['build']['points'] = $UserPoints[$PlanetData['id_owner']]['fleet']['count'] = $UserPoints[$PlanetData['id_owner']]['fleet']['points'] = $UserPoints[$PlanetData['id_owner']]['defense']['count'] = $UserPoints[$PlanetData['id_owner']]['defense']['points'] = 0;

$BuildPoints = $this->GetBuildPoints($PlanetData);
$FleetPoints = $this->GetFleetPoints($PlanetData);
$DefensePoints = $this->GetDefensePoints($PlanetData);

$UserPoints[$PlanetData['id_owner']]['build']['count'] += $BuildPoints['count'];
$UserPoints[$PlanetData['id_owner']]['build']['points'] += $BuildPoints['points'];
$UserPoints[$PlanetData['id_owner']]['fleet']['count'] += $FleetPoints['count'];
$UserPoints[$PlanetData['id_owner']]['fleet']['points'] += $FleetPoints['points'];
$UserPoints[$PlanetData['id_owner']]['defense']['count'] += $DefensePoints['count'];
$UserPoints[$PlanetData['id_owner']]['defense']['points'] += $DefensePoints['points'];

}

$db->free_result($TotalData['Planets']);

$UniData = array();

while($UserData = $db->fetch_array($TotalData['Users']))
{
if(!isset($UniData[$UserData['universe']]))
$UniData[$UserData['universe']] = 0;

$UniData[$UserData['universe']]++;

if ((in_array($CONF['stat'], array(1, 2)) && $UserData['authlevel'] >= $CONF['stat_level']) || !empty($UserData['bana']))
{
$FinalSQL  .= "(".$UserData['id'].",".$UserData['ally_id'].",1,".$UserData['universe'].",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), ";
continue;
}

$TechnoPoints = $this->GetTechnoPoints($UserData);

$UserPoints[$UserData['id']]['techno']['count'] = $TechnoPoints['count'];
$UserPoints[$UserData['id']]['techno']['points'] = $TechnoPoints['points'];

if(isset($TotalData['Fleets'][$UserData['id']]))
{
foreach($TotalData['Fleets'][$UserData['id']] as $FleetArray)
{
$FlyingFleetPoints = $this->GetFlyingFleetPoints($FleetArray);
$UserPoints[$UserData['id']]['fleet']['count'] += $FlyingFleetPoints['count'];
$UserPoints[$UserData['id']]['fleet']['points'] += $FlyingFleetPoints['points'];
}
}

$UserPoints[$UserData['id']]['total']['count'] = $UserPoints[$UserData['id']]['techno']['count'] + $UserPoints[$UserData['id']]['build']['count'] + $UserPoints[$UserData['id']]['defense']['count'] + $UserPoints[$UserData['id']]['fleet']['count'];
$UserPoints[$UserData['id']]['total']['points'] = $UserPoints[$UserData['id']]['techno']['points'] + $UserPoints[$UserData['id']]['build']['points'] + $UserPoints[$UserData['id']]['defense']['points'] + $UserPoints[$UserData['id']]['fleet']['points'];

if($UserData['ally_id'] != 0)
{
if(!isset($AllyPoints[$UserData['ally_id']]))
$AllyPoints[$UserData['ally_id']]['build']['count'] = $AllyPoints[$UserData['ally_id']]['build']['points'] = $AllyPoints[$UserData['ally_id']]['fleet']['count'] = $AllyPoints[$UserData['ally_id']]['fleet']['points'] = $AllyPoints[$UserData['ally_id']]['defense']['count'] = $AllyPoints[$UserData['ally_id']]['defense']['points'] = $AllyPoints[$UserData['ally_id']]['techno']['count'] = $AllyPoints[$UserData['ally_id']]['techno']['points'] = $AllyPoints[$UserData['ally_id']]['total']['count'] = $AllyPoints[$UserData['ally_id']]['total']['points'] = 0;

$AllyPoints[$UserData['ally_id']]['build']['count'] += $UserPoints[$UserData['id']]['build']['count'];
$AllyPoints[$UserData['ally_id']]['build']['points'] += $UserPoints[$UserData['id']]['build']['points'];
$AllyPoints[$UserData['ally_id']]['fleet']['count'] += $UserPoints[$UserData['id']]['fleet']['count'];
$AllyPoints[$UserData['ally_id']]['fleet']['points'] += $UserPoints[$UserData['id']]['fleet']['points'];
$AllyPoints[$UserData['ally_id']]['defense']['count'] += $UserPoints[$UserData['id']]['defense']['count'];
$AllyPoints[$UserData['ally_id']]['defense']['points'] += $UserPoints[$UserData['id']]['defense']['points'];
$AllyPoints[$UserData['ally_id']]['techno']['count'] += $UserPoints[$UserData['id']]['techno']['count'];
$AllyPoints[$UserData['ally_id']]['techno']['points'] += $UserPoints[$UserData['id']]['techno']['points'];
$AllyPoints[$UserData['ally_id']]['total']['count'] += $UserPoints[$UserData['id']]['total']['count'];
$AllyPoints[$UserData['ally_id']]['total']['points'] += $UserPoints[$UserData['id']]['total']['points'];
}

$FinalSQL  .= "('".$UserData['id']."','".$UserData['ally_id']."', 1, ".$UserData['universe'].", '".(int)$UserData['old_tech_rank']."', '".floattostring($UserPoints[$UserData['id']]['techno']['points'])."', '".floattostring($UserPoints[$UserData['id']]['techno']['count'])."', '".(int)$UserData['old_build_rank']."','".floattostring($UserPoints[$UserData['id']]['build']['points'])."', '".floattostring($UserPoints[$UserData['id']]['build']['count'])."', '".(int)$UserData['old_defs_rank']."', '".floattostring($UserPoints[$UserData['id']]['defense']['points'])."', '".floattostring($UserPoints[$UserData['id']]['defense']['count'])."', '".(int)$UserData['old_fleet_rank']."', '".floattostring($UserPoints[$UserData['id']]['fleet']['points'])."', '".floattostring($UserPoints[$UserData['id']]['fleet']['count'])."', '".(int)$UserData['old_total_rank']."', '".floattostring($UserPoints[$UserData['id']]['total']['points'])."', '".floattostring($UserPoints[$UserData['id']]['total']['count'])."'), ";
}

$db->free_result($TotalData['Users']);

$FinalSQL = substr($FinalSQL, 0, -2).';';

$this->SaveDataIntoDB($FinalSQL);
unset($UserPoints);

if(count($AllyPoints) != 0)
{
$AllySQL = "INSERT INTO ".STATPOINTS." (`id_owner`, `id_ally`, `stat_type`, `universe`, `tech_old_rank`, `tech_points`, `tech_count`, `build_old_rank`, `build_points`, `build_count`, `defs_old_rank`, `defs_points`, `defs_count`, `fleet_old_rank`, `fleet_points`, `fleet_count`, `total_old_rank`, `total_points`, `total_count`) VALUES ";
while($AllianceData = $db->fetch_array($TotalData['Alliance']))
{
$AllySQL  .= "('".$AllianceData['id']."', 0, 2, ".$AllianceData['ally_universe'].",'".(int)$AllyPoints['old_tech_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['techno']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['techno']['count'])."', '".(int)$AllianceData['old_build_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['build']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['build']['count'])."', '".(int)$AllianceData['old_defs_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['defense']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['defense']['count'])."', '".(int)$AllianceData['old_fleet_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['fleet']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['fleet']['count'])."', '".(int)$AllianceData['old_total_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['total']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['total']['count'])."'), ";
}
unset($AllyPoints);
$AllySQL = substr($AllySQL, 0, -2).';';
$this->SaveDataIntoDB($AllySQL);
}

$db->free_result($TotalData['Alliance']);

$RankSQL    = $this->SetNewRanks();



$this->SaveDataIntoDB($RankSQL);
$this->CheckUniverseAccounts($UniData);
$this->BuildRecordCache();
$this->AnotherCronJobs();













return $this->SomeStatsInfos();
}

mardi 16 janvier 2018 (Dernière édition mercredi 17 janvier 2018)

Homer Messages : 1925

Hello, ça ne m'aide pas, peux tu me copier tout le fichier class.statbuilder.php ?

PS: pense à mettre le code entre balise [ code] [ /code] (sans espace)

mercredi 17 janvier 2018

RitzzKnight Messages : 9

d'accord le voila :

 
<?php

/**
 _  _/ | | /¯¯   / /    |¯¯) |_¯   / /¯¯ |  |   |´¯|¯` | /¯¯ | |5
 ¯  /¯ | | __/  / /--   |¯¯ |__  /  __/ |__ _/   |   | __/ | |Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @author web: http://www.bnarvaez.com
 * @link: http://www.xnovarev.com

 * @package 2Moons
 * @author Slaver <slaver7@gmail.com>
 * @copyright 2009 Lucky <douglas@crockford.com> (XGProyecto)
 * @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/

 * Please do not remove the credits
*/

require(ROOT_PATH.'includes/classes/class.Records.php');

class statbuilder extends records
{
function __construct()
{

global $db, $CONF;

$this->starttime    = microtime(true);
$this->memory = array(round(memory_get_usage() / 1024,1),round(memory_get_usage(1) / 1024,1));
$this->time    = TIMESTAMP;
}

private function SomeStatsInfos()
{
global $db;
return array(
'stats_time' => $this->time,
'totaltime'     => round(microtime(true) - $this->starttime, 7),
'memory_peak' => array(round(memory_get_peak_usage() / 1024,1), round(memory_get_peak_usage(1) / 1024,1)),
'initial_memory' => $this->memory,
'end_memory' => array(round(memory_get_usage() / 1024,1), round(memory_get_usage(1) / 1024,1)),
'sql_count' => $db->get_sql(),
);
}

private function AnotherCronJobs()
{

}

private function CheckUniverseAccounts($UniData)
{
foreach($UniData as $Uni => $Amount)
{
update_config(array('users_amount' => $Amount), false, $Uni);
}
}

private function DeleteSome()
{
global $db;

$db->query("LOCK TABLES ".ALLIANCE." WRITE, ".BUDDY." WRITE, ".CONFIG." WRITE, ".FLEETS." WRITE, ".NOTES." WRITE, ".MESSAGES." WRITE, ".PLANETS." WRITE, ".RW." WRITE, ".SESSION." WRITE,  ".SUPP." WRITE, ".STATPOINTS." WRITE, ".TOPKB." WRITE, ".USERS." WRITE;");

//Delete old messages
$del_before = strtotime("-3 day");
$del_inactive = strtotime("-30 day");
$del_deleted = strtotime("-7 day");

$db->multi_query("DELETE FROM `".MESSAGES."` WHERE `message_time` < '". $del_before ."';DELETE FROM ".SUPP." WHERE `time` < '".$del_before."' AND `status` = 0;DELETE FROM ".ALLIANCE." WHERE `ally_members` = '0';DELETE FROM ".PLANETS." WHERE `destruyed` < ".TIMESTAMP." AND `destruyed` != 0;UPDATE ".USERS." SET `email_2` = `email` WHERE `setmail` < '".TIMESTAMP."';DELETE FROM ".SESSION." WHERE `user_lastactivity` < '".(TIMESTAMP - SESSION_LIFETIME)."';UPDATE ".USERS." SET `banaday` = '0', `bana` = '0' WHERE `banaday` <= '".TIMESTAMP."';");

$ChooseToDelete = $db->query("SELECT `id` FROM `".USERS."` WHERE `authlevel` = '".AUTH_USR."' AND ((`db_deaktjava` != 0 AND `db_deaktjava` < '".$del_deleted."') OR `onlinetime` < '".$del_inactive."');");
/*echo "Debuginfo:<br>";
var_dump("SELECT `id` FROM `".USERS."` WHERE `authlevel` = '".AUTH_USR."' AND ((`db_deaktjava` != 0 AND `db_deaktjava` < '".$del_deleted."') OR `onlinetime` < '".$del_inactive."');", $ChooseToDelete, $del_before, $del_inactive, $del_deleted, $CONF['del_oldstuff'], $CONF['del_user_automatic'], $CONF['del_user_manually'], $UNI);
echo "<br>Fin";
exit;*/

if(isset($ChooseToDelete))
{
include_once(ROOT_PATH.'includes/functions/DeleteSelectedUser.php');
while($delete = $db->fetch_array($ChooseToDelete))
{
DeleteSelectedUser($delete['id']);
}
}

$db->free_result($ChooseToDelete);

$DelRW = $db->query("SELECT `rid` FROM ".RW." WHERE `time` < '". $del_before ."';");

if(isset($DelRW))
{
while($RID = $db->fetch_array($DelRW))
{
if(file_exists(ROOT_PATH.'raports/raport_'.$RID['rid'].'.php'))
unlink(ROOT_PATH.'raports/raport_'.$RID['rid'].'.php');
}
$db->query("DELETE FROM ".RW." WHERE `time` < '". $del_before ."';");
}
$db->free_result($DelRW);

$TopKBLow = $db->uniquequery("SELECT gesamtunits FROM ".TOPKB." ORDER BY gesamtunits DESC LIMIT 99,1;");
if(isset($TopKBLow))
{
$TKBRW = $db->query("SELECT `rid` FROM ".TOPKB." WHERE `gesamtunits` < '".((isset($TopKBLow)) ? $TopKBLow['gesamtunits'] : 0)."';");
if(isset($TKBRW))
{
while($RID = $db->fetch_array($TKBRW))
{
if(file_exists(ROOT_PATH.'raports/topkb_'.$RID['rid'].'.php'))
unlink(ROOT_PATH.'raports/topkb_'.$RID['rid'].'.php');
}
$db->query("DELETE FROM ".TOPKB." WHERE `gesamtunits` < '".((isset($TopKBLow)) ? $TopKBLow['gesamtunits'] : 0)."';");
}

$db->free_result($TKBRW);
}

$db->query("UNLOCK TABLES;");
}

private function GetUsersInfosFromDB()
{
global $db, $resource, $reslist;
$select_defenses = '';
$select_buildings = '';
$selected_tech = '';
$select_fleets = '';

foreach($reslist['build'] as $Building){
$select_buildings .= " p.".$resource[$Building].",";
}

foreach($reslist['tech'] as $Techno){
$selected_tech .= " u.".$resource[$Techno].",";
}

foreach($reslist['fleet'] as $Fleet){
$select_fleets .= " p.".$resource[$Fleet].",";
}

foreach($reslist['defense'] as $Defense){
$select_defenses .= " p.".$resource[$Defense].",";
}
$FlyingFleets = array();
$SQLFleets = $db->query('SELECT fleet_array, fleet_owner FROM '.FLEETS.';');
while ($CurFleets = $db->fetch_array($SQLFleets))
{
$FlyingFleets[$CurFleets['fleet_owner']][] = $CurFleets['fleet_array'];
}

$db->free_result($SQLFleets);

$Return['Fleets'] = $FlyingFleets;
$Return['Planets'] = $db->query('SELECT SQL_BIG_RESULT DISTINCT '.$select_buildings.$select_fleets.$select_defenses.'p.id, p.universe, p.id_owner, u.authlevel, u.bana, u.username FROM '.PLANETS.' as p LEFT JOIN '.USERS.' as u ON u.id = p.id_owner;');
$Return['Users'] = $db->query('SELECT SQL_BIG_RESULT DISTINCT '.$selected_tech.' u.id, u.ally_id, u.authlevel, u.bana, u.universe, u.username, s.tech_rank AS old_tech_rank, s.build_rank AS old_build_rank, s.defs_rank AS old_defs_rank, s.fleet_rank AS old_fleet_rank, s.total_rank AS old_total_rank FROM '.USERS.' as u LEFT JOIN '.STATPOINTS.' as s ON s.stat_type = 1 AND s.id_owner = u.id GROUP BY s.id_owner, u.id, u.authlevel;');
$Return['Alliance'] = $db->query('SELECT SQL_BIG_RESULT DISTINCT a.id, a.ally_universe, s.tech_rank AS old_tech_rank, s.build_rank AS old_build_rank, s.defs_rank AS old_defs_rank, s.fleet_rank AS old_fleet_rank, s.total_rank AS old_total_rank FROM '.ALLIANCE.' as a LEFT JOIN '.STATPOINTS.' as s ON s.stat_type = 2 AND s.id_owner = a.id;');

return $Return;
}

private function SaveDataIntoDB($Data)
{
global $db;
if(!empty($Data))
$db->multi_query($Data);
}

private function GetTechnoPoints($CurrentUser)
{
global $resource, $reslist, $pricelist, $CONF;
$TechCounts = 0;
$TechPoints = 0;

foreach($reslist['tech'] as $Techno)
{
if($CurrentUser[$resource[$Techno]] == 0) continue;

$this->SetIfRecord($Techno, $CurrentUser[$resource[$Techno]], $CurrentUser);

$Units = $pricelist[$Techno]['metal'] + $pricelist[$Techno]['crystal'] + $pricelist[$Techno]['deuterium'] + $pricelist[$Techno]['norio'];
for($Level = 1; $Level <= $CurrentUser[$resource[$Techno]]; $Level++)
{
$TechPoints += $Units * pow($pricelist[$Techno]['factor'], $Level);
}
$TechCounts += $CurrentUser[$resource[$Techno]];
}

return array('count' => $TechCounts, 'points' => ($TechPoints / $CONF['stat_settings']));
}

private function GetBuildPoints($CurrentPlanet)
{
global $resource, $reslist, $pricelist, $CONF;
$BuildCounts = 0;
$BuildPoints = 0;

foreach($reslist['build'] as $Build)
{
if($CurrentPlanet[$resource[$Build]] == 0) continue;

$this->SetIfRecord($Build, $CurrentPlanet[$resource[$Build]], $CurrentPlanet);

$Units = $pricelist[$Build]['metal'] + $pricelist[$Build]['crystal'] + $pricelist[$Build]['deuterium'] + $pricelist[$Build]['norio'];
for($Level = 1; $Level <= $CurrentPlanet[$resource[$Build]]; $Level++)
{
$BuildPoints += $Units * pow($pricelist[$Build]['factor'], $Level);
}
$BuildCounts += $CurrentPlanet[$resource[$Build]];
}
return array('count' => $BuildCounts, 'points' => ($BuildPoints / $CONF['stat_settings']));
}

private function GetDefensePoints($CurrentPlanet)
{
global $resource, $reslist, $pricelist, $CONF;
$DefenseCounts = 0;
$DefensePoints = 0;

foreach($reslist['defense'] as $Defense) {
$this->SetIfRecord($Defense, $CurrentPlanet[$resource[$Defense]], $CurrentPlanet);

$Units = $pricelist[$Defense]['metal'] + $pricelist[$Defense]['crystal'] + $pricelist[$Defense]['deuterium'] + $pricelist[$Defense]['norio'];
$DefensePoints += $Units * $CurrentPlanet[$resource[$Defense]];
$DefenseCounts += $CurrentPlanet[$resource[$Defense]];
}

return array('count' => $DefenseCounts, 'points' => ($DefensePoints / $CONF['stat_settings']));
}

private function GetFleetPoints($CurrentPlanet)
{
global $resource, $reslist, $pricelist, $CONF;
$FleetCounts = 0;
$FleetPoints = 0;

foreach($reslist['fleet'] as $Fleet) {

$this->SetIfRecord($Fleet, $CurrentPlanet[$resource[$Fleet]], $CurrentPlanet);

$Units = $pricelist[$Fleet]['metal'] + $pricelist[$Fleet]['crystal'] + $pricelist[$Fleet]['deuterium'] + $pricelist[$Fleet]['norio'];
$FleetPoints   += $Units * $CurrentPlanet[$resource[$Fleet]];
$FleetCounts   += $CurrentPlanet[$resource[$Fleet]];
}

return array('count' => $FleetCounts, 'points' => ($FleetPoints / $CONF['stat_settings']));
}

private function GetFlyingFleetPoints($FleetArray)
{
global $resource, $reslist, $pricelist, $CONF;
$FleetRec    = explode(";", $FleetArray);
$FleetCounts = 0;
$FleetPoints = 0;

if(!is_array($FleetRec))
{
$RetValue['count'] = 0;
$RetValue['points'] = 0;
return $RetValue;

}

foreach($FleetRec as $Item => $Group)
{
if (empty($Group)) continue;

$Ship        = explode(",", $Group);
$Units         = $pricelist[$Ship[0]]['metal'] + $pricelist[$Ship[0]]['crystal'] + $pricelist[$Ship[0]]['deuterium'] + $pricelist[$Ship[0]]['norio'];
$FleetPoints   += $Units * $Ship[1];
$FleetCounts   += $Ship[1];
}

return array('count' => $FleetCounts, 'points' => ($FleetPoints / $CONF['stat_settings']));
}

private function SetNewRanks()
{
global $db, $CONF;
$Unis = array($CONF['uni']);
$Query = $db->query("SELECT `uni` FROM ".CONFIG." WHERE `uni` != '".$CONF['uni']."' ORDER BY `uni` ASC;");
while($Uni = $db->fetch_array($Query)) {
$Unis[] = $Uni['uni'];
}


$QryUpdateStats = "";
foreach($Unis as $Uni)
{
$tech = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s, ".USERS." as u WHERE s.`universe` = '".$Uni."' AND s.`stat_type` = '1' AND s.`id_owner` = `u`.id ".(($CONF['stat'] == 2)?'AND u.`authlevel` < '.$CONF['stat_level'].' ':'')." ORDER BY `tech_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$tech[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$build = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s, ".USERS." as u WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '1' AND s.`id_owner` = `u`.id ".(($CONF['stat'] == 2)?'AND u.`authlevel` < '.$CONF['stat_level'].' ':'')." ORDER BY `build_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$build[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$defs = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s, ".USERS." as u WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '1' AND s.`id_owner` = `u`.id ".(($CONF['stat'] == 2)?'AND u.`authlevel` < '.$CONF['stat_level'].' ':'')." ORDER BY `defs_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$defs[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$fleet = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s, ".USERS." as u WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '1' AND s.`id_owner` = `u`.id ".(($CONF['stat'] == 2)?'AND u.`authlevel` < '.$CONF['stat_level'].' ':'')." ORDER BY `fleet_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$fleet[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s, ".USERS." as u WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '1' AND s.`id_owner` = `u`.id ".(($CONF['stat'] == 2)?'AND u.`authlevel` < '.$CONF['stat_level'].' ':'')." ORDER BY `total_points` DESC;");

while($CurUser = $db->fetch_array($RankQry))
{
$QryUpdateStats .= "UPDATE ".STATPOINTS." SET `tech_rank` = '". $tech[$CurUser['id_owner']] ."', `build_rank` = '". $build[$CurUser['id_owner']] ."', `defs_rank` = '". $defs[$CurUser['id_owner']] ."', `fleet_rank` = '". $fleet[$CurUser['id_owner']] ."', `total_rank` = '". $Rank ."' WHERE `stat_type` = '1' AND `id_owner` = '". $CurUser['id_owner'] ."';";
$Rank++;
}

$db->free_result($RankQry);


$tech = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '2' ORDER BY `tech_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$tech[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$build = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '2' ORDER BY `build_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$build[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$defs = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '2' ORDER BY `defs_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$defs[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$fleet = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '2' ORDER BY `fleet_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$fleet[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s WHERE s.`universe` = '".$Uni."' AND s.`stat_type` = '2' ORDER BY `total_points` DESC;");

while($CurUser = $db->fetch_array($RankQry))
{
$QryUpdateStats .= "UPDATE ".STATPOINTS." SET `tech_rank` = '". $tech[$CurUser['id_owner']] ."', `build_rank` = '". $build[$CurUser['id_owner']] ."', `defs_rank` = '". $defs[$CurUser['id_owner']] ."', `fleet_rank` = '". $fleet[$CurUser['id_owner']] ."', `total_rank` = '". $Rank ."' WHERE `stat_type` = '2' AND `id_owner` = '". $CurUser['id_owner'] ."';";
$Rank++;
}

$db->free_result($RankQry);
}
return $QryUpdateStats;
}

final public function MakeStats()
{






// - Gestion des attaques Auto du Bot
        if (TIMESTAMP >= ($CONF['stat_last_update'] + (60 * $CONF['stat_update_time'])))
        {
            $IdBot = 2; // ID du Bot
            $IdPlaneteBot = 2; // ID de la planete du bot
            $Pourcent = 100; // Pourcentage de changde de lancer l'attaque
            
            $Chance = mt_rand(0,100);
if($Chance<$Pourcent)
{
// Génération de la flotte d'attaque
$V204 = mt_rand(1,100);
$V205 = mt_rand(1,80);
$V206 = mt_rand(1,60);
$V207 = mt_rand(1,40);
$V211 = mt_rand(1,30);
$V213 = mt_rand(1,20);
$V214 = mt_rand(1,10);
$FleetCount = $V204+$V205+$V206+$V207+$V211+$V213+$V214;
$FleetArray = "204,$V204;205,$V205;206,$V206;207,$V207;211,$V211;213,$V213;214,$V214;";

// Recuperation des infos planètes + selection aléatoir de la planete cible
$Planetes = $db->fetchquery("SELECT * FROM ".PLANETS." WHERE `id_owner` != '".$IdBot."' && `planet_type` = '1'" ) or die(print_r($db->erroInfo()));
$PlaneteBot = $db->fetchquery("SELECT * FROM ".PLANETS." WHERE `id` = '".$IdPlaneteBot."'");
$PlaneteBot = $PlaneteBot[0];
$PlaneteCible = $Planetes[mt_rand(0,(count($Planetes)-1))];                           

// Génération array pour requete Fleet
$FleetQRY      = "`".$resource[204] . "` = `".$resource[204]."` - '".floattostring($V204)."', ";
$FleetQRY     .= "`".$resource[205] . "` = `".$resource[205]."` - '".floattostring($V205)."', ";
$FleetQRY     .= "`".$resource[206] . "` = `".$resource[206]."` - '".floattostring($V206)."', ";
$FleetQRY     .= "`".$resource[207] . "` = `".$resource[207]."` - '".floattostring($V207)."', ";
$FleetQRY     .= "`".$resource[211] . "` = `".$resource[211]."` - '".floattostring($V211)."', ";
$FleetQRY     .= "`".$resource[213] . "` = `".$resource[213]."` - '".floattostring($V213)."', ";
$FleetQRY     .= "`".$resource[214] . "` = `".$resource[214]."` - '".floattostring($V214)."'";

// Ajout de la flotte necessaire à l'attaque
$FleetQRY2 = str_replace ("-","+", $FleetQRY);
$db->query("UPDATE ".PLANETS." SET ".$FleetQRY2." WHERE `id` = '".$PlaneteBot['id']."';");

// Calcul de la distance
if (($PlaneteBot['galaxy'] - $PlaneteCible['galaxy']) != 0)
$distance = abs($PlaneteBot['galaxy'] - $PlaneteCible['galaxy']) * 20000;
elseif (($PlaneteBot['system'] - $PlaneteCible['system']) != 0)
$distance = abs($PlaneteBot['system'] - $PlaneteCible['system']) * 95 + 2700;
elseif (($PlaneteBot['planet'] - $PlaneteCible['planet']) != 0)
$distance = abs($PlaneteBot['planet'] - $PlaneteCible['planet']) * 5 + 1000;
else
$distance = 5;
// Calcul du temps de vol + trajet
$TempsVol = round(max(((3500  * pow($distance * 10 / 20000, 0.5) + 10) / ($CONF['fleet_speed']/2500)), 5));
$Arrivee = TIMESTAMP + $TempsVol;
$Retour = TIMESTAMP + $TempsVol * 2;

// Lancement de l'attaque
$QryInsertFleet  = "LOCK TABLE ".FLEETS." WRITE, ".PLANETS." WRITE;
INSERT INTO ".FLEETS." SET
`fleet_owner` = '".$IdBot."',
`fleet_mission` = '1',
`fleet_amount` = '".$FleetCount."',
`fleet_array` = '".$FleetArray."',
`fleet_universe` = '".$PlaneteCible['universe']."',
`fleet_start_time` = '".$Arrivee."',
`fleet_start_id` = '".$PlaneteBot['id']."',
`fleet_start_galaxy` = '".$PlaneteBot['galaxy']."',
`fleet_start_system` = '".$PlaneteBot['system']."',
`fleet_start_planet` = '".$PlaneteBot['planet']."',
`fleet_start_type` = '".$PlaneteBot['planet_type']."',
`fleet_end_time` = '".$Retour."',
`fleet_end_stay` = '0',
`fleet_end_id` = '".$PlaneteCible['id']."',
`fleet_end_galaxy` = '".$PlaneteCible['galaxy']."',
`fleet_end_system` = '".$PlaneteCible['system']."',
`fleet_end_planet` = '".$PlaneteCible['planet']."',
`fleet_end_type` = '".$PlaneteCible['planet_type']."',
`fleet_resource_metal` = '0',
`fleet_resource_crystal` = '0',
`fleet_resource_deuterium` = '0',
`fleet_resource_norio` = '0',
`fleet_target_owner` = '".$PlaneteCible['id_owner']."',
`fleet_group` = '0',
`start_time` = '".TIMESTAMP."';
UPDATE `".PLANETS."` SET
".$FleetQRY."
WHERE
`id` = ".$IdBot." LIMIT 1;
UNLOCK TABLES;";

$db->multi_query($QryInsertFleet);
}
}

















global $db, $CONF;
$this->DeleteSome();
$AllyPoints = array();
$UserPoints = array();
$TotalData = $this->GetUsersInfosFromDB();
$FinalSQL = 'TRUNCATE TABLE '.STATPOINTS.';';
$FinalSQL .= "INSERT INTO ".STATPOINTS." (`id_owner`, `id_ally`, `stat_type`, `universe`, `tech_old_rank`, `tech_points`, `tech_count`, `build_old_rank`, `build_points`, `build_count`, `defs_old_rank`, `defs_points`, `defs_count`, `fleet_old_rank`, `fleet_points`, `fleet_count`, `total_old_rank`, `total_points`, `total_count`) VALUES ";

while($PlanetData = $db->fetch_array($TotalData['Planets']))
{
if((in_array($CONF['stat'], array(1, 2)) && $PlanetData['authlevel'] >= $CONF['stat_level']) || !empty($PlanetData['bana'])) continue;

  if(!isset($UserPoints[$PlanetData['id_owner']]))
$UserPoints[$PlanetData['id_owner']]['build']['count'] = $UserPoints[$PlanetData['id_owner']]['build']['points'] = $UserPoints[$PlanetData['id_owner']]['fleet']['count'] = $UserPoints[$PlanetData['id_owner']]['fleet']['points'] = $UserPoints[$PlanetData['id_owner']]['defense']['count'] = $UserPoints[$PlanetData['id_owner']]['defense']['points'] = 0;

$BuildPoints = $this->GetBuildPoints($PlanetData);
$FleetPoints = $this->GetFleetPoints($PlanetData);
$DefensePoints = $this->GetDefensePoints($PlanetData);

$UserPoints[$PlanetData['id_owner']]['build']['count'] += $BuildPoints['count'];
$UserPoints[$PlanetData['id_owner']]['build']['points'] += $BuildPoints['points'];
$UserPoints[$PlanetData['id_owner']]['fleet']['count'] += $FleetPoints['count'];
$UserPoints[$PlanetData['id_owner']]['fleet']['points'] += $FleetPoints['points'];
$UserPoints[$PlanetData['id_owner']]['defense']['count'] += $DefensePoints['count'];
$UserPoints[$PlanetData['id_owner']]['defense']['points'] += $DefensePoints['points'];

}

$db->free_result($TotalData['Planets']);

$UniData = array();

while($UserData = $db->fetch_array($TotalData['Users']))
{
if(!isset($UniData[$UserData['universe']]))
$UniData[$UserData['universe']] = 0;

$UniData[$UserData['universe']]++;

if ((in_array($CONF['stat'], array(1, 2)) && $UserData['authlevel'] >= $CONF['stat_level']) || !empty($UserData['bana']))
{
$FinalSQL  .= "(".$UserData['id'].",".$UserData['ally_id'].",1,".$UserData['universe'].",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), ";
continue;
}

$TechnoPoints = $this->GetTechnoPoints($UserData);

$UserPoints[$UserData['id']]['techno']['count'] = $TechnoPoints['count'];
$UserPoints[$UserData['id']]['techno']['points'] = $TechnoPoints['points'];

if(isset($TotalData['Fleets'][$UserData['id']]))
{
foreach($TotalData['Fleets'][$UserData['id']] as $FleetArray)
{
$FlyingFleetPoints = $this->GetFlyingFleetPoints($FleetArray);
$UserPoints[$UserData['id']]['fleet']['count'] += $FlyingFleetPoints['count'];
$UserPoints[$UserData['id']]['fleet']['points'] += $FlyingFleetPoints['points'];
}
}

$UserPoints[$UserData['id']]['total']['count'] = $UserPoints[$UserData['id']]['techno']['count'] + $UserPoints[$UserData['id']]['build']['count'] + $UserPoints[$UserData['id']]['defense']['count'] + $UserPoints[$UserData['id']]['fleet']['count'];
$UserPoints[$UserData['id']]['total']['points'] = $UserPoints[$UserData['id']]['techno']['points'] + $UserPoints[$UserData['id']]['build']['points'] + $UserPoints[$UserData['id']]['defense']['points'] + $UserPoints[$UserData['id']]['fleet']['points'];

if($UserData['ally_id'] != 0)
{
if(!isset($AllyPoints[$UserData['ally_id']]))
$AllyPoints[$UserData['ally_id']]['build']['count'] = $AllyPoints[$UserData['ally_id']]['build']['points'] = $AllyPoints[$UserData['ally_id']]['fleet']['count'] = $AllyPoints[$UserData['ally_id']]['fleet']['points'] = $AllyPoints[$UserData['ally_id']]['defense']['count'] = $AllyPoints[$UserData['ally_id']]['defense']['points'] = $AllyPoints[$UserData['ally_id']]['techno']['count'] = $AllyPoints[$UserData['ally_id']]['techno']['points'] = $AllyPoints[$UserData['ally_id']]['total']['count'] = $AllyPoints[$UserData['ally_id']]['total']['points'] = 0;

$AllyPoints[$UserData['ally_id']]['build']['count'] += $UserPoints[$UserData['id']]['build']['count'];
$AllyPoints[$UserData['ally_id']]['build']['points'] += $UserPoints[$UserData['id']]['build']['points'];
$AllyPoints[$UserData['ally_id']]['fleet']['count'] += $UserPoints[$UserData['id']]['fleet']['count'];
$AllyPoints[$UserData['ally_id']]['fleet']['points'] += $UserPoints[$UserData['id']]['fleet']['points'];
$AllyPoints[$UserData['ally_id']]['defense']['count'] += $UserPoints[$UserData['id']]['defense']['count'];
$AllyPoints[$UserData['ally_id']]['defense']['points'] += $UserPoints[$UserData['id']]['defense']['points'];
$AllyPoints[$UserData['ally_id']]['techno']['count'] += $UserPoints[$UserData['id']]['techno']['count'];
$AllyPoints[$UserData['ally_id']]['techno']['points'] += $UserPoints[$UserData['id']]['techno']['points'];
$AllyPoints[$UserData['ally_id']]['total']['count'] += $UserPoints[$UserData['id']]['total']['count'];
$AllyPoints[$UserData['ally_id']]['total']['points'] += $UserPoints[$UserData['id']]['total']['points'];
}

$FinalSQL  .= "('".$UserData['id']."','".$UserData['ally_id']."', 1, ".$UserData['universe'].", '".(int)$UserData['old_tech_rank']."', '".floattostring($UserPoints[$UserData['id']]['techno']['points'])."', '".floattostring($UserPoints[$UserData['id']]['techno']['count'])."', '".(int)$UserData['old_build_rank']."','".floattostring($UserPoints[$UserData['id']]['build']['points'])."', '".floattostring($UserPoints[$UserData['id']]['build']['count'])."', '".(int)$UserData['old_defs_rank']."', '".floattostring($UserPoints[$UserData['id']]['defense']['points'])."', '".floattostring($UserPoints[$UserData['id']]['defense']['count'])."', '".(int)$UserData['old_fleet_rank']."', '".floattostring($UserPoints[$UserData['id']]['fleet']['points'])."', '".floattostring($UserPoints[$UserData['id']]['fleet']['count'])."', '".(int)$UserData['old_total_rank']."', '".floattostring($UserPoints[$UserData['id']]['total']['points'])."', '".floattostring($UserPoints[$UserData['id']]['total']['count'])."'), ";
}

$db->free_result($TotalData['Users']);

$FinalSQL = substr($FinalSQL, 0, -2).';';

$this->SaveDataIntoDB($FinalSQL);
unset($UserPoints);

if(count($AllyPoints) != 0)
{
$AllySQL = "INSERT INTO ".STATPOINTS." (`id_owner`, `id_ally`, `stat_type`, `universe`, `tech_old_rank`, `tech_points`, `tech_count`, `build_old_rank`, `build_points`, `build_count`, `defs_old_rank`, `defs_points`, `defs_count`, `fleet_old_rank`, `fleet_points`, `fleet_count`, `total_old_rank`, `total_points`, `total_count`) VALUES ";
while($AllianceData = $db->fetch_array($TotalData['Alliance']))
{
$AllySQL  .= "('".$AllianceData['id']."', 0, 2, ".$AllianceData['ally_universe'].",'".(int)$AllyPoints['old_tech_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['techno']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['techno']['count'])."', '".(int)$AllianceData['old_build_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['build']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['build']['count'])."', '".(int)$AllianceData['old_defs_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['defense']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['defense']['count'])."', '".(int)$AllianceData['old_fleet_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['fleet']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['fleet']['count'])."', '".(int)$AllianceData['old_total_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['total']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['total']['count'])."'), ";
}
unset($AllyPoints);
$AllySQL = substr($AllySQL, 0, -2).';';
$this->SaveDataIntoDB($AllySQL);
}

$db->free_result($TotalData['Alliance']);

$RankSQL    = $this->SetNewRanks();



$this->SaveDataIntoDB($RankSQL);
$this->CheckUniverseAccounts($UniData);
$this->BuildRecordCache();
$this->AnotherCronJobs();













return $this->SomeStatsInfos();
}
}

?>
jeudi 18 janvier 2018

Homer Messages : 1925

essai ça :

<?php
/**
 _  _/ | | /¯¯   / /    |¯¯) |_¯   / /¯¯ |  |   |´¯|¯` | /¯¯ | |5
 ¯  /¯ | | __/  / /--   |¯¯ |__  /  __/ |__ _/   |   | __/ | |Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @author web: http://www.bnarvaez.com
 * @link: http://www.xnovarev.com

 * @package 2Moons
 * @author Slaver <slaver7@gmail.com>
 * @copyright 2009 Lucky <douglas@crockford.com> (XGProyecto)
 * @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/

 * Please do not remove the credits
*/

require(ROOT_PATH.'includes/classes/class.Records.php');

class statbuilder extends records
{
function __construct()
{

global $db, $CONF;

$this->starttime    = microtime(true);
$this->memory = array(round(memory_get_usage() / 1024,1),round(memory_get_usage(1) / 1024,1));
$this->time    = TIMESTAMP;
}

private function SomeStatsInfos()
{
global $db;
return array(
'stats_time' => $this->time,
'totaltime'     => round(microtime(true) - $this->starttime, 7),
'memory_peak' => array(round(memory_get_peak_usage() / 1024,1), round(memory_get_peak_usage(1) / 1024,1)),
'initial_memory' => $this->memory,
'end_memory' => array(round(memory_get_usage() / 1024,1), round(memory_get_usage(1) / 1024,1)),
'sql_count' => $db->get_sql(),
);
}

private function AnotherCronJobs()
{

}

private function CheckUniverseAccounts($UniData)
{
foreach($UniData as $Uni => $Amount)
{
update_config(array('users_amount' => $Amount), false, $Uni);
}
}

private function DeleteSome()
{
global $db;

$db->query("LOCK TABLES ".ALLIANCE." WRITE, ".BUDDY." WRITE, ".CONFIG." WRITE, ".FLEETS." WRITE, ".NOTES." WRITE, ".MESSAGES." WRITE, ".PLANETS." WRITE, ".RW." WRITE, ".SESSION." WRITE,  ".SUPP." WRITE, ".STATPOINTS." WRITE, ".TOPKB." WRITE, ".USERS." WRITE;");

//Delete old messages
$del_before = strtotime("-3 day");
$del_inactive = strtotime("-30 day");
$del_deleted = strtotime("-7 day");

$db->multi_query("DELETE FROM `".MESSAGES."` WHERE `message_time` < '". $del_before ."';DELETE FROM ".SUPP." WHERE `time` < '".$del_before."' AND `status` = 0;DELETE FROM ".ALLIANCE." WHERE `ally_members` = '0';DELETE FROM ".PLANETS." WHERE `destruyed` < ".TIMESTAMP." AND `destruyed` != 0;UPDATE ".USERS." SET `email_2` = `email` WHERE `setmail` < '".TIMESTAMP."';DELETE FROM ".SESSION." WHERE `user_lastactivity` < '".(TIMESTAMP - SESSION_LIFETIME)."';UPDATE ".USERS." SET `banaday` = '0', `bana` = '0' WHERE `banaday` <= '".TIMESTAMP."';");

$ChooseToDelete = $db->query("SELECT `id` FROM `".USERS."` WHERE `authlevel` = '".AUTH_USR."' AND ((`db_deaktjava` != 0 AND `db_deaktjava` < '".$del_deleted."') OR `onlinetime` < '".$del_inactive."');");
/*echo "Debuginfo:<br>";
var_dump("SELECT `id` FROM `".USERS."` WHERE `authlevel` = '".AUTH_USR."' AND ((`db_deaktjava` != 0 AND `db_deaktjava` < '".$del_deleted."') OR `onlinetime` < '".$del_inactive."');", $ChooseToDelete, $del_before, $del_inactive, $del_deleted, $CONF['del_oldstuff'], $CONF['del_user_automatic'], $CONF['del_user_manually'], $UNI);
echo "<br>Fin";
exit;*/

if(isset($ChooseToDelete))
{
include_once(ROOT_PATH.'includes/functions/DeleteSelectedUser.php');
while($delete = $db->fetch_array($ChooseToDelete))
{
DeleteSelectedUser($delete['id']);
}
}

$db->free_result($ChooseToDelete);

$DelRW = $db->query("SELECT `rid` FROM ".RW." WHERE `time` < '". $del_before ."';");

if(isset($DelRW))
{
while($RID = $db->fetch_array($DelRW))
{
if(file_exists(ROOT_PATH.'raports/raport_'.$RID['rid'].'.php'))
unlink(ROOT_PATH.'raports/raport_'.$RID['rid'].'.php');
}
$db->query("DELETE FROM ".RW." WHERE `time` < '". $del_before ."';");
}
$db->free_result($DelRW);

$TopKBLow = $db->uniquequery("SELECT gesamtunits FROM ".TOPKB." ORDER BY gesamtunits DESC LIMIT 99,1;");
if(isset($TopKBLow))
{
$TKBRW = $db->query("SELECT `rid` FROM ".TOPKB." WHERE `gesamtunits` < '".((isset($TopKBLow)) ? $TopKBLow['gesamtunits'] : 0)."';");
if(isset($TKBRW))
{
while($RID = $db->fetch_array($TKBRW))
{
if(file_exists(ROOT_PATH.'raports/topkb_'.$RID['rid'].'.php'))
unlink(ROOT_PATH.'raports/topkb_'.$RID['rid'].'.php');
}
$db->query("DELETE FROM ".TOPKB." WHERE `gesamtunits` < '".((isset($TopKBLow)) ? $TopKBLow['gesamtunits'] : 0)."';");
}

$db->free_result($TKBRW);
}

$db->query("UNLOCK TABLES;");
}

private function GetUsersInfosFromDB()
{
global $db, $resource, $reslist;
$select_defenses = '';
$select_buildings = '';
$selected_tech = '';
$select_fleets = '';

foreach($reslist['build'] as $Building){
$select_buildings .= " p.".$resource[$Building].",";
}

foreach($reslist['tech'] as $Techno){
$selected_tech .= " u.".$resource[$Techno].",";
}

foreach($reslist['fleet'] as $Fleet){
$select_fleets .= " p.".$resource[$Fleet].",";
}

foreach($reslist['defense'] as $Defense){
$select_defenses .= " p.".$resource[$Defense].",";
}
$FlyingFleets = array();
$SQLFleets = $db->query('SELECT fleet_array, fleet_owner FROM '.FLEETS.';');
while ($CurFleets = $db->fetch_array($SQLFleets))
{
$FlyingFleets[$CurFleets['fleet_owner']][] = $CurFleets['fleet_array'];
}

$db->free_result($SQLFleets);

$Return['Fleets'] = $FlyingFleets;
$Return['Planets'] = $db->query('SELECT SQL_BIG_RESULT DISTINCT '.$select_buildings.$select_fleets.$select_defenses.'p.id, p.universe, p.id_owner, u.authlevel, u.bana, u.username FROM '.PLANETS.' as p LEFT JOIN '.USERS.' as u ON u.id = p.id_owner;');
$Return['Users'] = $db->query('SELECT SQL_BIG_RESULT DISTINCT '.$selected_tech.' u.id, u.ally_id, u.authlevel, u.bana, u.universe, u.username, s.tech_rank AS old_tech_rank, s.build_rank AS old_build_rank, s.defs_rank AS old_defs_rank, s.fleet_rank AS old_fleet_rank, s.total_rank AS old_total_rank FROM '.USERS.' as u LEFT JOIN '.STATPOINTS.' as s ON s.stat_type = 1 AND s.id_owner = u.id GROUP BY s.id_owner, u.id, u.authlevel;');
$Return['Alliance'] = $db->query('SELECT SQL_BIG_RESULT DISTINCT a.id, a.ally_universe, s.tech_rank AS old_tech_rank, s.build_rank AS old_build_rank, s.defs_rank AS old_defs_rank, s.fleet_rank AS old_fleet_rank, s.total_rank AS old_total_rank FROM '.ALLIANCE.' as a LEFT JOIN '.STATPOINTS.' as s ON s.stat_type = 2 AND s.id_owner = a.id;');

return $Return;
}

private function SaveDataIntoDB($Data)
{
global $db;
if(!empty($Data))
$db->multi_query($Data);
}

private function GetTechnoPoints($CurrentUser)
{
global $resource, $reslist, $pricelist, $CONF;
$TechCounts = 0;
$TechPoints = 0;

foreach($reslist['tech'] as $Techno)
{
if($CurrentUser[$resource[$Techno]] == 0) continue;

$this->SetIfRecord($Techno, $CurrentUser[$resource[$Techno]], $CurrentUser);

$Units = $pricelist[$Techno]['metal'] + $pricelist[$Techno]['crystal'] + $pricelist[$Techno]['deuterium'] + $pricelist[$Techno]['norio'];
for($Level = 1; $Level <= $CurrentUser[$resource[$Techno]]; $Level++)
{
$TechPoints += $Units * pow($pricelist[$Techno]['factor'], $Level);
}
$TechCounts += $CurrentUser[$resource[$Techno]];
}

return array('count' => $TechCounts, 'points' => ($TechPoints / $CONF['stat_settings']));
}

private function GetBuildPoints($CurrentPlanet)
{
global $resource, $reslist, $pricelist, $CONF;
$BuildCounts = 0;
$BuildPoints = 0;

foreach($reslist['build'] as $Build)
{
if($CurrentPlanet[$resource[$Build]] == 0) continue;

$this->SetIfRecord($Build, $CurrentPlanet[$resource[$Build]], $CurrentPlanet);

$Units = $pricelist[$Build]['metal'] + $pricelist[$Build]['crystal'] + $pricelist[$Build]['deuterium'] + $pricelist[$Build]['norio'];
for($Level = 1; $Level <= $CurrentPlanet[$resource[$Build]]; $Level++)
{
$BuildPoints += $Units * pow($pricelist[$Build]['factor'], $Level);
}
$BuildCounts += $CurrentPlanet[$resource[$Build]];
}
return array('count' => $BuildCounts, 'points' => ($BuildPoints / $CONF['stat_settings']));
}

private function GetDefensePoints($CurrentPlanet)
{
global $resource, $reslist, $pricelist, $CONF;
$DefenseCounts = 0;
$DefensePoints = 0;

foreach($reslist['defense'] as $Defense) {
$this->SetIfRecord($Defense, $CurrentPlanet[$resource[$Defense]], $CurrentPlanet);

$Units = $pricelist[$Defense]['metal'] + $pricelist[$Defense]['crystal'] + $pricelist[$Defense]['deuterium'] + $pricelist[$Defense]['norio'];
$DefensePoints += $Units * $CurrentPlanet[$resource[$Defense]];
$DefenseCounts += $CurrentPlanet[$resource[$Defense]];
}

return array('count' => $DefenseCounts, 'points' => ($DefensePoints / $CONF['stat_settings']));
}

private function GetFleetPoints($CurrentPlanet)
{
global $resource, $reslist, $pricelist, $CONF;
$FleetCounts = 0;
$FleetPoints = 0;

foreach($reslist['fleet'] as $Fleet) {

$this->SetIfRecord($Fleet, $CurrentPlanet[$resource[$Fleet]], $CurrentPlanet);

$Units = $pricelist[$Fleet]['metal'] + $pricelist[$Fleet]['crystal'] + $pricelist[$Fleet]['deuterium'] + $pricelist[$Fleet]['norio'];
$FleetPoints   += $Units * $CurrentPlanet[$resource[$Fleet]];
$FleetCounts   += $CurrentPlanet[$resource[$Fleet]];
}

return array('count' => $FleetCounts, 'points' => ($FleetPoints / $CONF['stat_settings']));
}

private function GetFlyingFleetPoints($FleetArray)
{
global $resource, $reslist, $pricelist, $CONF;
$FleetRec    = explode(";", $FleetArray);
$FleetCounts = 0;
$FleetPoints = 0;

if(!is_array($FleetRec))
{
$RetValue['count'] = 0;
$RetValue['points'] = 0;
return $RetValue;

}

foreach($FleetRec as $Item => $Group)
{
if (empty($Group)) continue;

$Ship        = explode(",", $Group);
$Units         = $pricelist[$Ship[0]]['metal'] + $pricelist[$Ship[0]]['crystal'] + $pricelist[$Ship[0]]['deuterium'] + $pricelist[$Ship[0]]['norio'];
$FleetPoints   += $Units * $Ship[1];
$FleetCounts   += $Ship[1];
}

return array('count' => $FleetCounts, 'points' => ($FleetPoints / $CONF['stat_settings']));
}

private function SetNewRanks()
{
global $db, $CONF;
$Unis = array($CONF['uni']);
$Query = $db->query("SELECT `uni` FROM ".CONFIG." WHERE `uni` != '".$CONF['uni']."' ORDER BY `uni` ASC;");
while($Uni = $db->fetch_array($Query)) {
$Unis[] = $Uni['uni'];
}


$QryUpdateStats = "";
foreach($Unis as $Uni)
{
$tech = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s, ".USERS." as u WHERE s.`universe` = '".$Uni."' AND s.`stat_type` = '1' AND s.`id_owner` = `u`.id ".(($CONF['stat'] == 2)?'AND u.`authlevel` < '.$CONF['stat_level'].' ':'')." ORDER BY `tech_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$tech[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$build = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s, ".USERS." as u WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '1' AND s.`id_owner` = `u`.id ".(($CONF['stat'] == 2)?'AND u.`authlevel` < '.$CONF['stat_level'].' ':'')." ORDER BY `build_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$build[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$defs = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s, ".USERS." as u WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '1' AND s.`id_owner` = `u`.id ".(($CONF['stat'] == 2)?'AND u.`authlevel` < '.$CONF['stat_level'].' ':'')." ORDER BY `defs_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$defs[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$fleet = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s, ".USERS." as u WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '1' AND s.`id_owner` = `u`.id ".(($CONF['stat'] == 2)?'AND u.`authlevel` < '.$CONF['stat_level'].' ':'')." ORDER BY `fleet_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$fleet[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s, ".USERS." as u WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '1' AND s.`id_owner` = `u`.id ".(($CONF['stat'] == 2)?'AND u.`authlevel` < '.$CONF['stat_level'].' ':'')." ORDER BY `total_points` DESC;");

while($CurUser = $db->fetch_array($RankQry))
{
$QryUpdateStats .= "UPDATE ".STATPOINTS." SET `tech_rank` = '". $tech[$CurUser['id_owner']] ."', `build_rank` = '". $build[$CurUser['id_owner']] ."', `defs_rank` = '". $defs[$CurUser['id_owner']] ."', `fleet_rank` = '". $fleet[$CurUser['id_owner']] ."', `total_rank` = '". $Rank ."' WHERE `stat_type` = '1' AND `id_owner` = '". $CurUser['id_owner'] ."';";
$Rank++;
}

$db->free_result($RankQry);


$tech = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '2' ORDER BY `tech_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$tech[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$build = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '2' ORDER BY `build_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$build[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$defs = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '2' ORDER BY `defs_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$defs[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$fleet = array();
$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s WHERE s.`universe` = '".$Uni."' AND  s.`stat_type` = '2' ORDER BY `fleet_points` DESC;");
while ($CurUser = $db->fetch_array($RankQry))
{
$fleet[$CurUser['id_owner']] = $Rank;
$Rank++;
}

$db->free_result($RankQry);

$Rank           = 1;
$RankQry        = $db->query("SELECT s.`id_owner` FROM ".STATPOINTS." as s WHERE s.`universe` = '".$Uni."' AND s.`stat_type` = '2' ORDER BY `total_points` DESC;");

while($CurUser = $db->fetch_array($RankQry))
{
$QryUpdateStats .= "UPDATE ".STATPOINTS." SET `tech_rank` = '". $tech[$CurUser['id_owner']] ."', `build_rank` = '". $build[$CurUser['id_owner']] ."', `defs_rank` = '". $defs[$CurUser['id_owner']] ."', `fleet_rank` = '". $fleet[$CurUser['id_owner']] ."', `total_rank` = '". $Rank ."' WHERE `stat_type` = '2' AND `id_owner` = '". $CurUser['id_owner'] ."';";
$Rank++;
}

$db->free_result($RankQry);
}
return $QryUpdateStats;
}

public function MakeStats()
{
global $db, $CONF;
// - Gestion des attaques Auto du Bot
        if (TIMESTAMP >= ($CONF['stat_last_update'] + (60 * $CONF['stat_update_time'])))
        {
            $IdBot = 2; // ID du Bot
            $IdPlaneteBot = 2; // ID de la planete du bot
            $Pourcent = 100; // Pourcentage de changde de lancer l'attaque
            
            $Chance = mt_rand(0,100);
if($Chance<$Pourcent)
{
// Génération de la flotte d'attaque
$V204 = mt_rand(1,100);
$V205 = mt_rand(1,80);
$V206 = mt_rand(1,60);
$V207 = mt_rand(1,40);
$V211 = mt_rand(1,30);
$V213 = mt_rand(1,20);
$V214 = mt_rand(1,10);
$FleetCount = $V204+$V205+$V206+$V207+$V211+$V213+$V214;
$FleetArray = "204,$V204;205,$V205;206,$V206;207,$V207;211,$V211;213,$V213;214,$V214;";

// Recuperation des infos planètes + selection aléatoir de la planete cible
$Planetes = $db->fetchquery("SELECT * FROM ".PLANETS." WHERE `id_owner` != '".$IdBot."' && `planet_type` = '1'" ) or die(print_r($db->erroInfo()));
$PlaneteBot = $db->fetchquery("SELECT * FROM ".PLANETS." WHERE `id` = '".$IdPlaneteBot."'");
$PlaneteBot = $PlaneteBot[0];
$PlaneteCible = $Planetes[mt_rand(0,(count($Planetes)-1))];                           

// Génération array pour requete Fleet
$FleetQRY      = "`".$resource[204] . "` = `".$resource[204]."` - '".floattostring($V204)."', ";
$FleetQRY     .= "`".$resource[205] . "` = `".$resource[205]."` - '".floattostring($V205)."', ";
$FleetQRY     .= "`".$resource[206] . "` = `".$resource[206]."` - '".floattostring($V206)."', ";
$FleetQRY     .= "`".$resource[207] . "` = `".$resource[207]."` - '".floattostring($V207)."', ";
$FleetQRY     .= "`".$resource[211] . "` = `".$resource[211]."` - '".floattostring($V211)."', ";
$FleetQRY     .= "`".$resource[213] . "` = `".$resource[213]."` - '".floattostring($V213)."', ";
$FleetQRY     .= "`".$resource[214] . "` = `".$resource[214]."` - '".floattostring($V214)."'";

// Ajout de la flotte necessaire à l'attaque
$FleetQRY2 = str_replace ("-","+", $FleetQRY);
$db->query("UPDATE ".PLANETS." SET ".$FleetQRY2." WHERE `id` = '".$PlaneteBot['id']."';");

// Calcul de la distance
if (($PlaneteBot['galaxy'] - $PlaneteCible['galaxy']) != 0)
$distance = abs($PlaneteBot['galaxy'] - $PlaneteCible['galaxy']) * 20000;
elseif (($PlaneteBot['system'] - $PlaneteCible['system']) != 0)
$distance = abs($PlaneteBot['system'] - $PlaneteCible['system']) * 95 + 2700;
elseif (($PlaneteBot['planet'] - $PlaneteCible['planet']) != 0)
$distance = abs($PlaneteBot['planet'] - $PlaneteCible['planet']) * 5 + 1000;
else
$distance = 5;
// Calcul du temps de vol + trajet
$TempsVol = round(max(((3500  * pow($distance * 10 / 20000, 0.5) + 10) / ($CONF['fleet_speed']/2500)), 5));
$Arrivee = TIMESTAMP + $TempsVol;
$Retour = TIMESTAMP + $TempsVol * 2;

// Lancement de l'attaque
$QryInsertFleet  = "LOCK TABLE ".FLEETS." WRITE, ".PLANETS." WRITE;
INSERT INTO ".FLEETS." SET
`fleet_owner` = '".$IdBot."',
`fleet_mission` = '1',
`fleet_amount` = '".$FleetCount."',
`fleet_array` = '".$FleetArray."',
`fleet_universe` = '".$PlaneteCible['universe']."',
`fleet_start_time` = '".$Arrivee."',
`fleet_start_id` = '".$PlaneteBot['id']."',
`fleet_start_galaxy` = '".$PlaneteBot['galaxy']."',
`fleet_start_system` = '".$PlaneteBot['system']."',
`fleet_start_planet` = '".$PlaneteBot['planet']."',
`fleet_start_type` = '".$PlaneteBot['planet_type']."',
`fleet_end_time` = '".$Retour."',
`fleet_end_stay` = '0',
`fleet_end_id` = '".$PlaneteCible['id']."',
`fleet_end_galaxy` = '".$PlaneteCible['galaxy']."',
`fleet_end_system` = '".$PlaneteCible['system']."',
`fleet_end_planet` = '".$PlaneteCible['planet']."',
`fleet_end_type` = '".$PlaneteCible['planet_type']."',
`fleet_resource_metal` = '0',
`fleet_resource_crystal` = '0',
`fleet_resource_deuterium` = '0',
`fleet_resource_norio` = '0',
`fleet_target_owner` = '".$PlaneteCible['id_owner']."',
`fleet_group` = '0',
`start_time` = '".TIMESTAMP."';
UPDATE `".PLANETS."` SET
".$FleetQRY."
WHERE
`id` = ".$IdBot." LIMIT 1;
UNLOCK TABLES;";

$db->multi_query($QryInsertFleet);
}
}

$this->DeleteSome();
$AllyPoints = array();
$UserPoints = array();
$TotalData = $this->GetUsersInfosFromDB();
$FinalSQL = 'TRUNCATE TABLE '.STATPOINTS.';';
$FinalSQL .= "INSERT INTO ".STATPOINTS." (`id_owner`, `id_ally`, `stat_type`, `universe`, `tech_old_rank`, `tech_points`, `tech_count`, `build_old_rank`, `build_points`, `build_count`, `defs_old_rank`, `defs_points`, `defs_count`, `fleet_old_rank`, `fleet_points`, `fleet_count`, `total_old_rank`, `total_points`, `total_count`) VALUES ";

while($PlanetData = $db->fetch_array($TotalData['Planets']))
{
if((in_array($CONF['stat'], array(1, 2)) && $PlanetData['authlevel'] >= $CONF['stat_level']) || !empty($PlanetData['bana'])) continue;

  if(!isset($UserPoints[$PlanetData['id_owner']]))
$UserPoints[$PlanetData['id_owner']]['build']['count'] = $UserPoints[$PlanetData['id_owner']]['build']['points'] = $UserPoints[$PlanetData['id_owner']]['fleet']['count'] = $UserPoints[$PlanetData['id_owner']]['fleet']['points'] = $UserPoints[$PlanetData['id_owner']]['defense']['count'] = $UserPoints[$PlanetData['id_owner']]['defense']['points'] = 0;

$BuildPoints = $this->GetBuildPoints($PlanetData);
$FleetPoints = $this->GetFleetPoints($PlanetData);
$DefensePoints = $this->GetDefensePoints($PlanetData);

$UserPoints[$PlanetData['id_owner']]['build']['count'] += $BuildPoints['count'];
$UserPoints[$PlanetData['id_owner']]['build']['points'] += $BuildPoints['points'];
$UserPoints[$PlanetData['id_owner']]['fleet']['count'] += $FleetPoints['count'];
$UserPoints[$PlanetData['id_owner']]['fleet']['points'] += $FleetPoints['points'];
$UserPoints[$PlanetData['id_owner']]['defense']['count'] += $DefensePoints['count'];
$UserPoints[$PlanetData['id_owner']]['defense']['points'] += $DefensePoints['points'];

}

$db->free_result($TotalData['Planets']);

$UniData = array();

while($UserData = $db->fetch_array($TotalData['Users']))
{
if(!isset($UniData[$UserData['universe']]))
$UniData[$UserData['universe']] = 0;

$UniData[$UserData['universe']]++;

if ((in_array($CONF['stat'], array(1, 2)) && $UserData['authlevel'] >= $CONF['stat_level']) || !empty($UserData['bana']))
{
$FinalSQL  .= "(".$UserData['id'].",".$UserData['ally_id'].",1,".$UserData['universe'].",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), ";
continue;
}

$TechnoPoints = $this->GetTechnoPoints($UserData);

$UserPoints[$UserData['id']]['techno']['count'] = $TechnoPoints['count'];
$UserPoints[$UserData['id']]['techno']['points'] = $TechnoPoints['points'];

if(isset($TotalData['Fleets'][$UserData['id']]))
{
foreach($TotalData['Fleets'][$UserData['id']] as $FleetArray)
{
$FlyingFleetPoints = $this->GetFlyingFleetPoints($FleetArray);
$UserPoints[$UserData['id']]['fleet']['count'] += $FlyingFleetPoints['count'];
$UserPoints[$UserData['id']]['fleet']['points'] += $FlyingFleetPoints['points'];
}
}

$UserPoints[$UserData['id']]['total']['count'] = $UserPoints[$UserData['id']]['techno']['count'] + $UserPoints[$UserData['id']]['build']['count'] + $UserPoints[$UserData['id']]['defense']['count'] + $UserPoints[$UserData['id']]['fleet']['count'];
$UserPoints[$UserData['id']]['total']['points'] = $UserPoints[$UserData['id']]['techno']['points'] + $UserPoints[$UserData['id']]['build']['points'] + $UserPoints[$UserData['id']]['defense']['points'] + $UserPoints[$UserData['id']]['fleet']['points'];

if($UserData['ally_id'] != 0)
{
if(!isset($AllyPoints[$UserData['ally_id']]))
$AllyPoints[$UserData['ally_id']]['build']['count'] = $AllyPoints[$UserData['ally_id']]['build']['points'] = $AllyPoints[$UserData['ally_id']]['fleet']['count'] = $AllyPoints[$UserData['ally_id']]['fleet']['points'] = $AllyPoints[$UserData['ally_id']]['defense']['count'] = $AllyPoints[$UserData['ally_id']]['defense']['points'] = $AllyPoints[$UserData['ally_id']]['techno']['count'] = $AllyPoints[$UserData['ally_id']]['techno']['points'] = $AllyPoints[$UserData['ally_id']]['total']['count'] = $AllyPoints[$UserData['ally_id']]['total']['points'] = 0;

$AllyPoints[$UserData['ally_id']]['build']['count'] += $UserPoints[$UserData['id']]['build']['count'];
$AllyPoints[$UserData['ally_id']]['build']['points'] += $UserPoints[$UserData['id']]['build']['points'];
$AllyPoints[$UserData['ally_id']]['fleet']['count'] += $UserPoints[$UserData['id']]['fleet']['count'];
$AllyPoints[$UserData['ally_id']]['fleet']['points'] += $UserPoints[$UserData['id']]['fleet']['points'];
$AllyPoints[$UserData['ally_id']]['defense']['count'] += $UserPoints[$UserData['id']]['defense']['count'];
$AllyPoints[$UserData['ally_id']]['defense']['points'] += $UserPoints[$UserData['id']]['defense']['points'];
$AllyPoints[$UserData['ally_id']]['techno']['count'] += $UserPoints[$UserData['id']]['techno']['count'];
$AllyPoints[$UserData['ally_id']]['techno']['points'] += $UserPoints[$UserData['id']]['techno']['points'];
$AllyPoints[$UserData['ally_id']]['total']['count'] += $UserPoints[$UserData['id']]['total']['count'];
$AllyPoints[$UserData['ally_id']]['total']['points'] += $UserPoints[$UserData['id']]['total']['points'];
}

$FinalSQL  .= "('".$UserData['id']."','".$UserData['ally_id']."', 1, ".$UserData['universe'].", '".(int)$UserData['old_tech_rank']."', '".floattostring($UserPoints[$UserData['id']]['techno']['points'])."', '".floattostring($UserPoints[$UserData['id']]['techno']['count'])."', '".(int)$UserData['old_build_rank']."','".floattostring($UserPoints[$UserData['id']]['build']['points'])."', '".floattostring($UserPoints[$UserData['id']]['build']['count'])."', '".(int)$UserData['old_defs_rank']."', '".floattostring($UserPoints[$UserData['id']]['defense']['points'])."', '".floattostring($UserPoints[$UserData['id']]['defense']['count'])."', '".(int)$UserData['old_fleet_rank']."', '".floattostring($UserPoints[$UserData['id']]['fleet']['points'])."', '".floattostring($UserPoints[$UserData['id']]['fleet']['count'])."', '".(int)$UserData['old_total_rank']."', '".floattostring($UserPoints[$UserData['id']]['total']['points'])."', '".floattostring($UserPoints[$UserData['id']]['total']['count'])."'), ";
}

$db->free_result($TotalData['Users']);

$FinalSQL = substr($FinalSQL, 0, -2).';';

$this->SaveDataIntoDB($FinalSQL);
unset($UserPoints);

if(count($AllyPoints) != 0)
{
$AllySQL = "INSERT INTO ".STATPOINTS." (`id_owner`, `id_ally`, `stat_type`, `universe`, `tech_old_rank`, `tech_points`, `tech_count`, `build_old_rank`, `build_points`, `build_count`, `defs_old_rank`, `defs_points`, `defs_count`, `fleet_old_rank`, `fleet_points`, `fleet_count`, `total_old_rank`, `total_points`, `total_count`) VALUES ";
while($AllianceData = $db->fetch_array($TotalData['Alliance']))
{
$AllySQL  .= "('".$AllianceData['id']."', 0, 2, ".$AllianceData['ally_universe'].",'".(int)$AllyPoints['old_tech_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['techno']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['techno']['count'])."', '".(int)$AllianceData['old_build_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['build']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['build']['count'])."', '".(int)$AllianceData['old_defs_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['defense']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['defense']['count'])."', '".(int)$AllianceData['old_fleet_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['fleet']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['fleet']['count'])."', '".(int)$AllianceData['old_total_rank']."', '".floattostring($AllyPoints[$AllianceData['id']]['total']['points'])."', '".floattostring($AllyPoints[$AllianceData['id']]['total']['count'])."'), ";
}
unset($AllyPoints);
$AllySQL = substr($AllySQL, 0, -2).';';
$this->SaveDataIntoDB($AllySQL);
}

$db->free_result($TotalData['Alliance']);

$RankSQL    = $this->SetNewRanks();



$this->SaveDataIntoDB($RankSQL);
$this->CheckUniverseAccounts($UniData);
$this->BuildRecordCache();
$this->AnotherCronJobs();













return $this->SomeStatsInfos();
}
}

Par contre je doute que ce bout de code soit au bon emplacement, as-tu bien suivi les messages précedent du topic ?

jeudi 18 janvier 2018 (Dernière édition jeudi 18 janvier 2018)

RitzzKnight Messages : 9

j'ai essayer la ou avant :

return $this->SomeStatsInfos();

Mais sa marche pas, pas de flotte en vol.

jeudi 18 janvier 2018

RitzzKnight Messages : 9

car j'avais suivis sur le sujet BOT Pirate mais j'ai pas de :

public function MakeStats()

dans mon class.template.php :


<?php

/**
 _  _/ | | /¯¯   / /    |¯¯) |_¯   / /¯¯ |  |   |´¯|¯` | /¯¯ | |5
 ¯  /¯ | | __/  / /--   |¯¯ |__  /  __/ |__ _/   |   | __/ | |Core.
 * @author: Copyright (C) 2011 by Brayan Narvaez (Prinick) developer of xNova Revolution
 * @author web: http://www.bnarvaez.com
 * @link: http://www.xnovarev.com

 * @package 2Moons
 * @author Slaver <slaver7@gmail.com>
 * @copyright 2009 Lucky <douglas@crockford.com> (XGProyecto)
 * @copyright 2011 Slaver <slaver7@gmail.com> (Fork/2Moons)
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.3 (2011-01-21)
 * @link http://code.google.com/p/2moons/

 * Please do not remove the credits
*/
 
class template
{
function __construct()
{
$this->jsscript = array();
$this->script = array();
$this->vars = array();
$this->cache = false;
$this->cachedir = is_writable(ROOT_PATH.'cache/') ? ROOT_PATH.'cache/' : sys_get_temp_dir();
$this->file = '';
$this->cachefile = '';
$this->phpself = '';
$this->Popup = false;
$this->Dialog = false;
}

public function render()
{
global $CONF;
require(ROOT_PATH.'includes/libs/Smarty/Smarty.class.php');
$TMP = new Smarty();
$TMP->force_compile = false;
$TMP->compile_dir = $this->cachedir;
$TMP->caching = false;
$TMP->compile_check = true; #Set false for production!
$TMP->template_dir = $this->template_dir;
$TMP->assign($this->vars);
$PAGE = $TMP->fetch($this->file);
if($this->cache && $CONF['debug'] == 0)
{
file_put_contents($this->cachefile, $PAGE);
}
return $PAGE;
}

public function isDialog() {
$this->Dialog = true;
}

public function getplanets()
{
global $USER;
$this->UserPlanets = SortUserPlanets($USER);
}

public function loadscript($script)
{
$this->jsscript[] = substr($script, 0, -3);
}

public function execscript($script)
{
$this->script[] = $script;
}

public function assign_vars($var = array())
{
$this->vars = array_merge($this->vars, $var);
}

private function Menus()
{
global $PLANET, $LNG, $USER, $CONF;

//PlanetMenu
if(empty($this->UserPlanets))
$this->getplanets();

$this->loadscript("planetmenu.js");
$this->loadscript("topnav.js");
$this->execscript("PlanetMenu();");
$this->phpself = "?page=".request_var('page', '')."&mode=".request_var('mode', '');
$PlanetSelect = array();
$Scripttime = array();
foreach($this->UserPlanets as $CurPlanetID => $PlanetQuery)
{
if(!empty($PlanetQuery['b_building_id']))
{
$QueueArray = explode(";", $PlanetQuery['b_building_id']);
$ActualCount = count($QueueArray);
for ($ID = 0; $ID < $ActualCount; $ID++)
{
$ListIDArray = explode(",", $QueueArray[$ID]);

if($ListIDArray[3] > TIMESTAMP)
$Scripttime[$PlanetQuery['id']][] = $ListIDArray[3];
}
}

$Planetlist[$PlanetQuery['id']] = array(
'url' => $this->phpself."&cp=".$PlanetQuery['id'],
'name' => $PlanetQuery['name'].(($PlanetQuery['planet_type'] == 3) ? " (".$LNG['fcm_moon'].")":""),
'image' => $PlanetQuery['image'],
'galaxy' => $PlanetQuery['galaxy'],
'system' => $PlanetQuery['system'],
'planet' => $PlanetQuery['planet'],
'ptype' => $PlanetQuery['planet_type'],
);

$PlanetSelect[$this->phpself."&cp=".$PlanetQuery['id']] = $PlanetQuery['name'].(($PlanetQuery['planet_type'] == 3) ? " (" . $LNG['fcm_moon'] . ")":"")." [".$PlanetQuery['galaxy'].":".$PlanetQuery['system'].":".$PlanetQuery['planet']."]  ";
}


if($USER['urlaubs_modus'] == 1) {
$CONF['metal_basic_income']     = 0;
$CONF['crystal_basic_income']   = 0;
$CONF['deuterium_basic_income'] = 0;
$CONF['norio_basic_income'] = 0;
}

if($PLANET['metal'] >= $PLANET["metal_max"]) {
$cantidad_metal = colorRed(pretty_number($PLANET['metal']));
} else {
$cantidad_metal = pretty_number($PLANET['metal']);
}
if($PLANET['crystal'] >= $PLANET["crystal_max"]) {
$cantidad_cristal = colorRed(pretty_number($PLANET['crystal']));
} else {
$cantidad_cristal = pretty_number($PLANET['crystal']);
}
if($PLANET['deuterium'] >= $PLANET["deuterium_max"]) {
$cantidad_deuterio = colorRed(pretty_number($PLANET['deuterium']));
} else {
$cantidad_deuterio = pretty_number($PLANET['deuterium']);
}
if($PLANET['norio'] >= $PLANET["norio_max"]) {
$cantidad_norio = colorRed(pretty_number($PLANET['norio']));
} else {
$cantidad_norio = pretty_number($PLANET['norio']);
}

$this->assign_vars(array(
'PlanetMenu' => $Planetlist,
'metales' => $cantidad_metal,
'cristales' => $cantidad_cristal,
'deuterios' => $cantidad_deuterio,
'norios'     => $cantidad_norio,
'almacenes' => $LNG['rs_storage_capacity'],
'show_planetmenu' => $LNG['show_planetmenu'],
'current_pid' => $PLANET['id'],
'Scripttime' => json_encode($Scripttime),
'lm_overview' => $LNG['lm_overview'],
'lm_buildings' => $LNG['lm_buildings'],
'lm_bonus' => $LNG['lm_bonus'],
'lm_resources' => $LNG['lm_resources'],
'lm_trader' => $LNG['lm_trader'],
'lm_fleettrader' => $LNG['lm_fleettrader'],
'lm_research' => $LNG['lm_research'],
'lm_shipshard' => $LNG['lm_shipshard'],
'lm_fleet' => $LNG['lm_fleet'],
'lm_technology' => $LNG['lm_technology'],
'lm_galaxy' => $LNG['lm_galaxy'],
'lm_defenses' => $LNG['lm_defenses'],
'lm_alliance' => $LNG['lm_alliance'],
'lm_forums' => $LNG['lm_forums'],
'lm_officiers' => $LNG['lm_officiers'],
'lm_statistics' => $LNG['lm_statistics'],
'lm_records' => $LNG['lm_records'],
'lm_topkb' => $LNG['lm_topkb'],
'lm_search' => $LNG['lm_search'],
'lm_battlesim' => $LNG['lm_battlesim'],
'lm_messages' => $LNG['lm_messages'],
'lm_notes' => $LNG['lm_notes'],
'lm_buddylist' => $LNG['lm_buddylist'],
'lm_chat' => $LNG['lm_chat'],
'lm_support' => $LNG['lm_support'],
'lm_faq' => $LNG['lm_faq'],
'lm_options' => $LNG['lm_options'],
'lm_banned' => $LNG['lm_banned'],
'lm_rules' => $LNG['lm_rules'],
'lm_logout' => $LNG['lm_logout'],
'lm_credits' => $LNG['lm_credits'],
'new_message' => $USER['new_message'],
'forum_url' => $CONF['forum_url'],
'lm_administration' => $LNG['lm_administration'],
'topnav' => true,
'metal' => $PLANET['metal'],
'crystal' => $PLANET['crystal'],
'deuterium' => $PLANET['deuterium'],
'norio'     => $PLANET['norio'],
'energy' => (($PLANET["energy_max"] + $PLANET["energy_used"]) < 0) ? pretty_number($PLANET["energy_max"] + $PLANET["energy_used"]) : pretty_number($PLANET["energy_max"] + $PLANET["energy_used"]),
'energy_maxx' => pretty_number($PLANET["energy_max"]),
'energia' => (($PLANET["energy_max"] + $PLANET["energy_used"]) < 0) ? colorRed(pretty_number($PLANET["energy_max"] + $PLANET["energy_used"])) : pretty_number($PLANET["energy_max"] + $PLANET["energy_used"]),
'darkmatter' => pretty_number($USER["darkmatter"]),
'metal_max' => pretty_number($PLANET["metal_max"]),
'crystal_max' => pretty_number($PLANET["crystal_max"]),
'deuterium_max' => pretty_number($PLANET["deuterium_max"]),
'norio_max'     => pretty_number($PLANET["norio_max"]),
'alt_metal_max' => pretty_number($PLANET["metal_max"]),
'alt_crystal_max' => pretty_number($PLANET["crystal_max"]),
'alt_deuterium_max' => pretty_number($PLANET["deuterium_max"]),
'alt_norio_max'     => pretty_number($PLANET["norio_max"]),
'js_metal_max' => floattostring($PLANET["metal_max"]),
'js_crystal_max' => floattostring($PLANET["crystal_max"]),
'js_deuterium_max' => floattostring($PLANET["deuterium_max"]),
'js_norio_max'    => floattostring($PLANET["norio_max"]),
'js_metal_hr' => $PLANET['planet_type'] == 1 ? floattostring($PLANET['metal_perhour'] + $CONF['metal_basic_income'] * $CONF['resource_multiplier']) : 0,
'js_crystal_hr' => $PLANET['planet_type'] == 1 ? floattostring($PLANET['crystal_perhour'] + $CONF['crystal_basic_income'] * $CONF['resource_multiplier']) : 0,
'js_deuterium_hr' => $PLANET['planet_type'] == 1 ? floattostring($PLANET['deuterium_perhour'] + $CONF['deuterium_basic_income'] * $CONF['resource_multiplier']) : 0,
'js_norio_hr' => $PLANET['planet_type'] == 1 ? floattostring($PLANET['norio_perhour'] + $CONF['norio_basic_income'] * $CONF['resource_multiplier']) : 0,
'current_planet' => $this->phpself."&cp=".$PLANET['id'],
'tn_vacation_mode' => $LNG['tn_vacation_mode'],
'closed' => !$CONF['game_disable'] ? $LNG['ov_closed'] : false,
'vacation' => $USER['urlaubs_modus'] ? date(TDFORMAT,$USER['urlaubs_until']) : false,
'delete' => $USER['db_deaktjava'] ? sprintf($LNG['tn_delete_mode'], date(TDFORMAT, strtotime("+7 day", $USER['db_deaktjava']))) : false,
'image' => $PLANET['image'],
'settings_tnstor' => $USER['settings_tnstor'],
'PlanetSelect' => $PlanetSelect,
'Metal' => $LNG['Metal'],
'Crystal' => $LNG['Crystal'],
'Deuterium' => $LNG['Deuterium'],
'Norio'     => $LNG['Norio'],
'Darkmatter' => $LNG['Darkmatter'],
'Energy' => $LNG['Energy'],
));
}

    private function main()
    {
global $USER, $CONF, $LANG, $LNG, $THEME;
      
      $navegador = $_SERVER['HTTP_USER_AGENT'];
      $usa_navegador = strrpos($navegador, "MSIE");
      
      if ($usa_navegador === false) {
         $IE = false;
      } else {
         $IE = true;
      }
      
      if($IE) {
         $css_style = "formato_IE";
      } else {
         $css_style = "formato";
      }
  
  if($USER['raza'] == 0) {
                        $raza_tipo = $LNG['Raza_0'];
$skin_raza = "gultra";
                } elseif ($USER['raza'] == 1) {
                        $raza_tipo = $LNG['Raza_1'];
$skin_raza = "voltra";
                }


if($USER['commander'] >= 1) {
$imperio = "<li>
<span class="menu_icon">
<img width="38" height="29" src="./styles/theme/". $skin_raza ."/imagenes/navegacion/menu_icon.png">
        </span>
<a class="menu_boton" href="javascript:OpenPopup('?page=imperium','" .$LNG['lm_empire'] ."', 1024, 768);"><span>" .$LNG['lm_empire'] ."</span></a>
</li>";
$comandante_icon = "600.png";
} else {
$imperio = "";
$comandante_icon = "600_off.png";
}
if($USER['engineer'] >= 1) {
$ingeniero_icon = "603.png";
} else {
$ingeniero_icon = "603_off.png";
}
if($USER['admiral'] >= 1) {
$almirante_icon = "602.png";
} else {
$almirante_icon = "602_off.png";
}
if($USER['geologe'] >= 1) {
$geologo_icon = "601.png";
} else {
$geologo_icon = "601_off.png";
}
if($USER['technocratic'] >= 1) {
$tecnocrata_icon = "604.png";
} else {
$tecnocrata_icon = "604_off.png";
}
      
        $this->assign_vars(array(
'Comandante' => $comandante_icon,
'Tecnocrata' => $tecnocrata_icon,
'Ingeniero' => $ingeniero_icon,
'Almirante' => $almirante_icon,
'Geologo' => $geologo_icon,
'comandante' => $LNG['comandante'],
'tecnocrata' => $LNG['tecnocrata'],
'ingeniero' => $LNG['ingeniero'],
'almirante' => $LNG['almirante'],
'geologo' => $LNG['geologo'],
            'title'            => $CONF['game_name'],
            'css_style'       => $css_style,
         'uni_name'         => $CONF['uni_name'],
            'dpath' => $THEME->getTheme(),
            'vmode' => $USER['urlaubs_modus'],
            'is_pmenu' => $USER['settings_planetmenu'],
'authlevel' => $USER['authlevel'],
            'lang'     => $LANG->getUser(),
            'ready'     => $LNG['ready'],
'date' => explode("|", date('Y|n|j|G|i|s|Z', TIMESTAMP)),
'cron' => GetCrons(),
'ga_active' => $CONF['ga_active'],
'ga_key' => $CONF['ga_key'],
'debug' => $CONF['debug'],
'min_js' => $CONF['min_js'],
'fcm_info' => $LNG['fcm_info'],
'VERSION' => $CONF['VERSION'],
'REV' => substr($CONF['VERSION'], -4),
'Raza'                          => $LNG['Raza'],
            'Raza_tipo'        => $raza_tipo,
'Raza_skin'      => $skin_raza,
'imperio' => $imperio,
));
}

private function adm_main()
{
global $LNG, $CONF;
$this->assign_vars(array(
'scripts' => $this->script,
'title' => $CONF['game_name'].' - '.$LNG['adm_cp_title'],
'fcm_info' => $LNG['fcm_info'],
'gotoinsec' => false,
'goto' => false,
));
}

public function login_main()
{
global $USER, $CONF, $LNG, $LANG, $UNI;
$this->assign_vars(array(
'cappublic' => $CONF['cappublic'],
'servername' => $CONF['game_name'],
'forum_url' => $CONF['forum_url'],
'fb_active' => $CONF['fb_on'],
'fb_key' => $CONF['fb_apikey'],
'forum' => $LNG['forum'],
'register_closed' => $LNG['register_closed'],
'fb_perm' => sprintf($LNG['fb_perm'], $CONF['game_name']),
'menu_index' => $LNG['menu_index'],
'menu_news' => $LNG['menu_news'],
'menu_rules' => $LNG['menu_rules'],
'menu_agb' => $LNG['menu_agb'],
'menu_pranger' => $LNG['menu_pranger'],
'menu_top100' => $LNG['menu_top100'],
'menu_disclamer' => $LNG['menu_disclamer'],
'music_off' => $LNG['music_off'],
'music_on' => $LNG['music_on'],
'game_captcha' => $CONF['capaktiv'],
'reg_close' => $CONF['reg_closed'],
'ga_active' => $CONF['ga_active'],
'ga_key' => $CONF['ga_key'],
'bgm_active' => $CONF['bgm_active'],
'bgm_file' => $CONF['bgm_file'],
'mail_active' => $CONF['mail_active'],
'getajax' => request_var('getajax', 0),
'lang' => $LANG->getUser(),
'UNI' => $UNI,
'langs' => Language::getAllowedLangs(),
));
}

public function isPopup()
{
$this->Popup = true;
}

public function show($file)
{
global $USER, $PLANET, $CONF, $LNG, $db;

if(!defined('INSTALL')) {
if(defined('IN_ADMIN')) {
$this->adm_main();
} elseif(defined('LOGIN')) {
$this->login_main();
} elseif(!$this->Dialog) {
if(!defined('AJAX')) {
$_SESSION['USER'] = $USER;
$_SESSION['PLANET'] = $PLANET;
}
$this->main();
if($this->Popup === false)
$this->Menus();
}
}
$this->assign_vars(array(
'scripts' => $this->jsscript,
'execscript' => implode("n", $this->script),
));

$this->display($file);
}

public function gotoside($dest, $time = 3)
{
$this->assign_vars(array(
'gotoinsec' => $time,
'goto' => $dest,
));
}

public function display($file)
{
global $THEME;
$this->file = $file;
$this->template_dir = $THEME->getTemplatePath();
if($this->cache && $GLOBALS['CONF']['debug'] == 0)
{
$this->cachefile = $this->cachedir.md5($this->template_dir.$this->file .r_implode('', $this->vars)).'.tpl.php';
if(file_exists($this->cachefile))
echo file_get_contents($this->cachefile);
else
echo $this->render();
} else {
echo $this->render();
}
}

public function message($mes, $dest = false, $time = 3, $Fatal = false)
{
global $LNG, $THEME;
if($Fatal)
$this->isPopup(true);

$this->assign_vars(array(
'mes' => $mes,
'fcm_info' => $LNG['fcm_info'],
'Fatal' => $Fatal,
            'dpath' => $THEME->getTheme(),
));

$this->gotoside($dest, $time);
if (defined('IN_ADMIN')) {
$this->show('adm/error_message_body.tpl');
exit;
}
$this->show('error_message_body.tpl');
}
}














































?>
jeudi 18 janvier 2018

RitzzKnight Messages : 9

après avoir un peux chercher je suis arriver à bien le placer mais j'obtiens ce résultat :

Error: SQL Error: Unknown column '' in 'field list'

Query Code: UPDATE uni1_planets SET `` = `` + '47', `` = `` + '9', `` = `` + '10', `` = `` + '3', `` = `` + '28', `` = `` + '2', `` = `` + '10' WHERE `id` = '2';_

File: /srv/filer02/myhomesys2/www/eximius/includes/classes/class.MySQLi.php_

Line: 87_

PHP-Version: 5.4.45_

PHP-API: cgi-fcgi_

XNOVA Version: 1.0 Redesign_

Debug Backtrace:

#0 .eximius/includes/classes/class.statbuilder.php(460): DB_mysqli->query('UPDATE uni1_pla...')

#1 .eximius/includes/pages/adm/ShowStatUpdatePage.php(27): statbuilder->MakeStats()

#2 .eximius/admin.php(129): ShowStatUpdatePage()

#3 {main}_

Voici la ligne 460 :

$db->query("UPDATE ".PLANETS." SET ".$FleetQRY2." WHERE `id` = '".$PlaneteBot['id']."';"); 
dimanche 21 janvier 2018

RitzzKnight Messages : 9

Voila sa marche, jai fait sauter :


// Recuperation des infos planètes + selection aléatoir de la planete cible
$Planetes = mysql_query("SELECT * FROM "uni1_planets" WHERE `id_owner` != '".$IdBot."' && `planet_type` = '1'" );
$PlaneteBot = mysql_query("SELECT * FROM "uni1_planets" WHERE `id` = '".$IdPlaneteBot."'");
$PlaneteBot = $PlaneteBot[0];
$PlaneteCible = $Planetes[mt_rand(0,(count($Planetes)-1))];   

// Génération array pour requete Fleet
$FleetQRY      = "`".$resource[204] . "` = `".$resource[204]."` - '".floattostring($V204)."', ";
$FleetQRY     .= "`".$resource[205] . "` = `".$resource[205]."` - '".floattostring($V205)."', ";
$FleetQRY     .= "`".$resource[206] . "` = `".$resource[206]."` - '".floattostring($V206)."', ";
$FleetQRY     .= "`".$resource[207] . "` = `".$resource[207]."` - '".floattostring($V207)."', ";
$FleetQRY     .= "`".$resource[211] . "` = `".$resource[211]."` - '".floattostring($V211)."', ";
$FleetQRY     .= "`".$resource[213] . "` = `".$resource[213]."` - '".floattostring($V213)."', ";
$FleetQRY     .= "`".$resource[214] . "` = `".$resource[214]."` - '".floattostring($V214)."'";

et modifier :


//$V214 = mt_rand(1,10); Vaisseau ORI
//$FleetCount = $V204+$V205+$V206+$V207+$V211+$V213+$V214;
//$FleetArray = "204,$V204;205,$V205;206,$V206;207,$V207;211,$V211;213,$V213;214,$V214;";

car il corresponder chez moi au vaisseaux ori et sa fesais des BOT trop puissant, depuis sa marche bien merci de l'aide en tous cas

dimanche 21 janvier 2018

Pinotleclaire Messages : 1

Félicitation! moi même, je ne serais pas arriver. En voyant tous ces codes j'ai mal à la tête.

jeudi 1 février 2018

Répondre Pour répondre, tu dois d'abord t'inscrire rapidement sur Kommunauty. Rejoins-nous vite !