Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
2.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaro2709 committed Jan 12, 2020
1 parent 773bb04 commit 9a3cca6
Show file tree
Hide file tree
Showing 23 changed files with 485 additions and 373 deletions.
2 changes: 1 addition & 1 deletion adm/AdminFunctions/Autorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

$QueryModeration = read_config ( 'moderation' );
$QueryModerationEx = explode ( ";" , $QueryModeration[1] );
$QueryModerationEx = explode ( ";" , $QueryModeration );
$Moderator = explode ( "," , $QueryModerationEx[0] );
$Operator = explode ( "," , $QueryModerationEx[1] );
$Administrator = explode ( "," , $QueryModerationEx[2] );
Expand Down
24 changes: 12 additions & 12 deletions adm/Log/ConfigLog.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@

El usuario cambio la siguiente configuración:
¿Servidor cerrado? :
¿Modo DEBUG activado? :
El usuario cambio la siguiente configuración:
¿Servidor cerrado? :
¿Modo DEBUG activado? :
Nombre del juego : XG Proyect
URL del foro : http://www.xgproyect.net/
Velocidad del juego : x1
Velocidad de flota : x1
Velocidad de producción : x1
Velocidad de producción : x1
Campos iniciales : 163
Básico de metal por hora : 20
Básico de cristal por hora : 10
Básico de deuterio por hora : 0
¿Protección contra administradores activado? :
Básico de metal por hora : 20
Básico de cristal por hora : 10
Básico de deuterio por hora : 0
¿Protección contra administradores activado? :
Lenguaje : spanish
Nombre de la cookie : XGProyect
Defensas a escombros : 30%
Naves a escombros : 30%
¿Protección contra novatos activado? :
Tiempo de protección contra novato : 5000
Limite de puntos para la protección de novato : 5
Operación realizada el: 20-12-2011 22:17:36
¿Protección contra novatos activado? :
Tiempo de protección contra novato : 5000
Limite de puntos para la protección de novato : 5
Operación realizada el: 02-04-2012 19:04:23
5 changes: 3 additions & 2 deletions adm/Log/GeneralLog.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

<font color=lime>||| LISTA DE ERRORES |||</font>
El usuario lucky ha borrado todos los mensajes de error
Operaci&oacute;n realizada el: 05-01-2012 04:16:21
El usuario lucky ha borrado un error
Operaci&oacute;n realizada el: 02-04-2012 18:53:27
5-01-2012 04:16:21
: 23-11-2011 01:45:07
5
21:15:04
Expand Down
15 changes: 15 additions & 0 deletions adm/Log/ModerationLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

<font color=lime>||| SISTEMA DE MODERACI&oacute;N |||</font>
El usuario lucky modifico los siguientes datos:
Los moderadores podran ver...
&iquest;Herramientas?:
&iquest;Editar?:
&iquest;Ver menu de Observaci&oacute;n?:
&iquest;Configurar opciones de juego?:

Los operadores podran ver...
&iquest;Herramientas?:
&iquest;Editar?:
&iquest;Ver menu de Observaci&oacute;n?:
&iquest;Configurar opciones de juego?:
Operaci&oacute;n realizada el: 23-03-2012 22:52:41
2 changes: 1 addition & 1 deletion adm/Moderation.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
if ($_GET['moderation'] == '1')
{
$QueryModeration = read_config ( 'moderation' );
$QueryModerationEx = explode(";", $QueryModeration[1]);
$QueryModerationEx = explode(";", $QueryModeration);
$Moderator = explode(",", $QueryModerationEx[0]);
$Operator = explode(",", $QueryModerationEx[1]);
$Administrator = explode(",", $QueryModerationEx[2]); // Solo sirve para el historial
Expand Down
8 changes: 5 additions & 3 deletions adm/OverviewPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ function check_updates()
{
if ( function_exists ( 'file_get_contents' ) )
{
$current = @file_get_contents ( 'http://www.xgproyect.net/xgproyect/current.php' );

if ( str_replace ( '.' , '' , $current ) > str_replace ( '.' , '' , read_config ( 'version' ) ) )
$current_v = @file_get_contents ( 'http://xgproyect.xgproyect.net/current.php' );
$current_v = str_replace ( '.' , '' , $current );
$system_v = str_replace ( '.' , '' , read_config ( 'version' ) );

if ( $current_v > $system_v )
{
return TRUE;
}
Expand Down
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"pass" => "root", // MySQL password.
"name" => "ogame", // MySQL database name.
"prefix" => "xgp_", // Tables prefix.
"secretword" => "XGProyect875208701"); // Cookies.
"secretword" => "XGProyect543856441"); // Cookies.
?>
4 changes: 2 additions & 2 deletions includes/GeneralFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function unset_vars ( $prefix )

function read_config ( $config_name = '' , $all = FALSE )
{
$configs = new xml ( 'config.xml' );
$configs = xml::getInstance ( 'config.xml' );

if ( $all )
{
Expand All @@ -40,7 +40,7 @@ function read_config ( $config_name = '' , $all = FALSE )

function update_config ( $config_name, $config_value )
{
$configs = new xml ( 'config.xml' );
$configs = xml::getInstance ( 'config.xml' );

$configs->write_config ( $config_name , $config_value );
}
Expand Down
27 changes: 17 additions & 10 deletions includes/classes/class.FlyingFleetHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,24 @@ public static function calculateAKSSteal($attackFleets, $defenderPlanet, $ForSim

$AllCapacity = array_sum($SortFleets);
$QryUpdateFleet = "";

foreach($SortFleets as $FleetID => $Capacity)
if ( $AllCapacity != 0 )
{
$QryUpdateFleet = 'UPDATE {{table}} SET ';
$QryUpdateFleet .= '`fleet_resource_metal` = `fleet_resource_metal` + '.floattostring($steal['metal'] * ($Capacity / $AllCapacity)).', ';
$QryUpdateFleet .= '`fleet_resource_crystal` = `fleet_resource_crystal` +'.floattostring($steal['crystal'] * ($Capacity / $AllCapacity)).', ';
$QryUpdateFleet .= '`fleet_resource_deuterium` = `fleet_resource_deuterium` +'.floattostring($steal['deuterium'] * ($Capacity / $AllCapacity)).' ';
$QryUpdateFleet .= 'WHERE fleet_id = '.$FleetID.' ';
$QryUpdateFleet .= 'LIMIT 1;';
doquery($QryUpdateFleet, 'fleets');

foreach($SortFleets as $FleetID => $Capacity)
{
$QryUpdateFleet = 'UPDATE {{table}} SET ';
$QryUpdateFleet .= '`fleet_resource_metal` = `fleet_resource_metal` + '.floattostring($steal['metal'] * ($Capacity / $AllCapacity)).', ';
$QryUpdateFleet .= '`fleet_resource_crystal` = `fleet_resource_crystal` +'.floattostring($steal['crystal'] * ($Capacity / $AllCapacity)).', ';
$QryUpdateFleet .= '`fleet_resource_deuterium` = `fleet_resource_deuterium` +'.floattostring($steal['deuterium'] * ($Capacity / $AllCapacity)).' ';
$QryUpdateFleet .= 'WHERE fleet_id = '.$FleetID.' ';
$QryUpdateFleet .= 'LIMIT 1;';
doquery($QryUpdateFleet, 'fleets');

}
}
else
{
$steal = 0;
}

return $steal;
Expand Down
209 changes: 129 additions & 80 deletions includes/classes/class.xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,91 +3,140 @@
/**
* @project XG Proyect
* @version 2.10.x build 0000
* @copyright Copyright (C) 2008 - 2012
* @copyright Copyright (C) 2008 - 2016
*/

if(!defined('INSIDE')){ die(header ( 'location:../../' ));}

/**
*
* @author Jstar
* @version v2
* @tutorial
* $c=xml::getInstance('config.xml');
* echo $c->get_config('version');
* $c->write_config('version','blabla');
* echo $c->get_config('version');
*/
class xml
{
// INSTANCIA DE simplexml
private $instance_xml = NULL;
private $sheet = NULL;

// ABRE LA HOJA y LA LEE
public function __construct ( $sheet )
{
$this->sheet = $sheet; // PASAMOS LA HOJA A TOMAR

// SETEAMOS EL DIRECTORIO BASE DE LECTURA.
$path = "http://" . $_SERVER['HTTP_HOST'];
$path .= preg_replace ( '@/+$@' , '' , dirname ( $_SERVER['SCRIPT_NAME'] ) ) . '/includes/xml/';
$path = str_replace ( array ( '/adm' , '/install' ) , '' , $path );

// CHECK instance_xml EXISTENCE
if ( !$this->instance_xml )
{
// START DOM
$document = new DOMDocument("1.0");
$document->load ( $path . $this->sheet );

// ERROR
if ( $document == FALSE )
{
die ( 'Error nº1: Problems loading the page content.' );
}
//an istance of this class: see singleton pattern
private static $instance = null;
//the complete path to xml config: used to load and save it
private $path;
//SimpleXMLElement object that rappresent xml config
private $config;

// CREA UN OBJETO DOM
$this->instance_xml = $document;
}
}
/**
* xml::__construct()
* Constructor: access is private to enable class istancing only by getInstance() method, to ensure better performace
*
* @param String $sheet
* @return null
*/
private function __construct($sheet)
{
$this->path = XGP_ROOT . 'includes' . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . $sheet;
$this->config = simplexml_load_file($this->path);
}
/**
* xml::doXpathQuery()
* This function execute a Xpath query
*
* @param String $query
* @return Array
*/
public function doXpathQuery($query)
{
return $this->config->xpath($query);
}
/**
* xml::get_xml_entity()
* Search in the xml for a entity rappresented by $config_name
*
* @param String $config_name: the key
* @return SimpleXMLElement object
*/
private function get_xml_entity($config_name)
{
//searching inside <configurations> and where config name=$config_name
$result = $this->doXpathQuery('/configurations/config[name="' . $config_name . '"]');
//if multiple result are returned so key is not unique
if (!$result || count($result) !== 1)
{
throw new Exception(sprintf('Item with id "%s" does not exists or is not unique.', $config_name));
}
list($result) = $result;
return $result;
}
/**
* xml::get_config()
* This function search in loaded xml for a value according to specific configuration name passed
*
* @param String $config_name
* @return String: the configuration value of given key
*/
public function get_config($config_name)
{
// (string) is a cast to String type from SimpleXMLElement object: we need this to extract value
return (string) $this->get_xml_entity($config_name)->value;
}
/**
* xml::get_configs()
* This function return all configurations loaded from xml file
*
* @return Array: an associative array of key-value
*/
public function get_configs()
{
$config = array();
$x = $this->config->children();
foreach ($x as $xmlObject)
{
$config[(string) $xmlObject->name] = (string) $xmlObject->value;
}
return $config;
}
/**
* xml::write_config()
* This function write the xml configuration file updating one or multiple key-value at time
*
* @param mixed $config_name : String for single update or an associative array of key=>value
* @param String $config_value : The value that will be setted in corrispective key $config_name
* @return null
*/
public function write_config($config_name, $config_value)
{
//if $config_name is an array, then we wont update all values and do single save task at the end
if (is_array($config_name))
{
foreach ($config_name as $key => $value)
{
$this->get_xml_entity($key)->value = $value;
}
}
else
{
$this->get_xml_entity($config_name)->value = $config_value;
}
$this->config->asXML($this->path);
}
/**
* xml::getInstance()
* Static function used to istance this class: implements singleton pattern to avoid multiple xml parsing.
*
* @param String $sheet : the complete name of xml configuration file.
* @return xml object
*/
public static function getInstance($sheet)
{
if (self::$instance == null)
{
//make new istance of this class and save it to field for next usage
$c = __class__;
self::$instance = new $c($sheet);
}

// OBTIENE LOS ELEMENTOS DE ACUERDO A LA ETIQUETA PASADA
private function get_elements ( $element )
{
return $this->instance_xml->getElementsByTagName( $element );
}

// RETORNA LAS CONFIGURACIONES
public function get_configs ()
{
$configs = $this->get_elements ( 'config' );

foreach ( $configs as $config )
{
$name = $config->getElementsByTagName( "name" )->item(0)->nodeValue;
$value = $config->getElementsByTagName( "value" )->item(0)->nodeValue;
$config_array[$name] = $value;
}

return $config_array;
}

// RETORNA UNA CONFIGURACION ESPECIFICA
public function get_config ( $config_name )
{
$xpath = new DOMXPath ( $this->instance_xml );
$result = $xpath->query ( '/configurations/config[name="' . $config_name . '"]/value' );
return $result->item(0)->nodeValue;
}

// ESCRIBE LA CONFIGURACION
public function write_config ( $config_name , $config_value )
{
$xpath = new DOMXPath ( $this->instance_xml );
$result = $xpath->query ( '/configurations/config[name="' . $config_name . '"]/value' );
$result->item(0)
->nodeValue = $config_value;

// header ( "Content-type: text/xml" );
if ( $this->instance_xml->save ( XGP_ROOT . "includes/xml/" . $this->sheet ) )
{
return TRUE;
}
else
{
return FALSE;
}
}
return self::$instance;
}
}

?>
2 changes: 1 addition & 1 deletion includes/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if ( !defined('INSIDE') ) die(header("location:../"));

// VERSION
define('SYSTEM_VERSION' , '2.10.0');
define('SYSTEM_VERSION' , '2.10.1');

// TEMPLATES DEFAULT SETTINGS
define('SKIN_PATH' , 'styles/skins/');
Expand Down
Loading

0 comments on commit 9a3cca6

Please sign in to comment.