Beispiel #1
0
 public function __construct()
 {
     $db = new Connect();
     $act = $db->query("SELECT ultima_act FROM generales LIMIT 1;");
     $actualizacion = $db->recorrer($act);
     if (time() >= $actualizacion[0]) {
         $tops = $db->query("SELECT id,puntos FROM usuarios ORDER by puntos DESC;");
         $tope = 1;
         $psql = "UPDATE usuarios SET top = ? WHERE id = ? LIMIT 1;";
         $prepare_query = $db->prepare($psql);
         $prepare_query->bind_param('ii', $nuevo_top, $id_user);
         while ($top = $db->recorrer($tops)) {
             $nuevo_top = $tope++;
             $id_user = $top['id'];
             $prepare_query->execute();
         }
         $timer = time() + 30;
         $query = $db->query("UPDATE generales SET ultima_act='{$timer}' LIMIT 1;");
         $prepare_query->close();
         unset($actualizar, $tops, $timer, $tope, $query);
     } else {
         unset($actualizacion);
     }
     $db->liberar($act);
     $db->close();
 }
Beispiel #2
0
 public function Register()
 {
     try {
         if ($_POST['user'] and $_POST['pass'] and $_POST['email']) {
             $db = new Connect();
             $this->user = $db->real_escape_string($_POST['user']);
             $this->email = $db->real_escape_string($_POST['email']);
             $this->pass = sha1($_POST['pass']);
             $sql = $db->query("SELECT usuario,email FROM usuarios \n                WHERE usuario='{$this->user}' OR email='{$this->email}' LIMIT 1;");
             if ($db->rows($sql) == 0) {
                 $sql2 = $db->query("SELECT COUNT(id) FROM usuarios LIMIT 1;");
                 $top = $db->recorrer($sql2);
                 $top = $top[0] + 1;
                 $sql3 = $db->query("INSERT INTO usuarios (usuario,password,email,faccion,top) \n                    VALUES ('{$this->user}','{$this->pass}','{$this->email}','1','{$top}');");
                 $sql4 = $db->query("SELECT MAX(id) AS id FROM usuarios LIMIT 1;");
                 $id = $db->recorrer($sql4);
                 $id = $id[0];
                 $db->liberar($sql, $sql2, $sql3, $sql4);
                 require 'core/models/class.GeneratePlanet.php';
                 $planeta = new GeneratePlanet();
                 $planeta->RegisterPlanet($id);
                 $planet = $db->query("SELECT id_planeta FROM planetas WHERE id_dueno='{$id}' LIMIT 1;");
                 $id_planet = $db->recorrer($planet);
                 $id_planet = $id_planet[0];
                 $_SESSION['id_planet'] = $id_planet;
                 $_SESSION['user'] = $this->user;
                 $_SESSION['id'] = $id;
                 unset($sql, $sql2, $sql3, $sql4, $top, $db, $id, $this->email, $this->pass);
                 echo 1;
                 $db->liberar($planet);
                 $db->close();
             } else {
                 $dato = $db->recorrer($sql);
                 $db->liberar($sql);
                 $db->close();
                 $lng = new Lang();
                 if (strtolower($dato[1]) == strtolower($this->email) and strtolower($dato[0]) != strtolower($this->user)) {
                     throw new Exception($lng->e_email_existe);
                 } else {
                     if (strtolower($dato[1]) != strtolower($this->email) and strtolower($dato[0]) == strtolower($this->user)) {
                         throw new Exception($lng->e_user_existe);
                     } else {
                         throw new Exception($lng->e_user_email_existe);
                     }
                 }
                 unset($sql, $db, $lng, $dato, $this->user, $this->email, $this->pass);
             }
         } else {
             throw new Exception('error');
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     exit;
 }
Beispiel #3
0
 public function Register()
 {
     if (!empty($_POST['user']) and !empty($_POST['pass']) and !empty($_POST['email'])) {
         $db = new Connect();
         $this->user = $db->real_escape_string($_POST['user']);
         $this->email = $db->real_escape_string($_POST['email']);
         $this->pass = sha1($_POST['pass']);
         $sql = $db->query("SELECT usuario,email FROM usuarios \n            WHERE usuario='{$this->user}' OR email='{$this->email}' LIMIT 1;");
         if ($db->rows($sql) == 0) {
             $sql2 = $db->query("SELECT COUNT(id) FROM usuarios LIMIT 1;");
             $top = $db->recorrer($sql2);
             $top = $top[0] + 1;
             $sql3 = $db->query("INSERT INTO usuarios (usuario,password,email,faccion,top) \n                VALUES ('{$this->user}','{$this->pass}','{$this->email}','1','{$top}');");
             $sql4 = $db->query("SELECT MAX(id) AS id FROM usuarios LIMIT 1;");
             $id = $db->recorrer($sql4);
             $id = $id[0];
             $db->liberar($sql, $sql2, $sql3, $sql4);
             require 'core/models/class.GeneratePlanet.php';
             $planeta = new GeneratePlanet();
             $planeta->RegisterPlanet($id);
             $planet = $db->query("SELECT id_planeta FROM planetas WHERE id_dueno='{$id}' LIMIT 1;");
             $id_planet = $db->recorrer($planet);
             $id_planet = $id_planet[0];
             $_SESSION['id_planet'] = $id_planet;
             $_SESSION['user'] = $this->user;
             $_SESSION['id'] = $id;
             $login = '******';
             $db->liberar($planet);
             $db->close();
             unset($sql, $sql2, $sql3, $sql4, $top, $db, $id, $this->email, $this->pass);
         } else {
             $dato = $db->recorrer($sql);
             $db->liberar($sql);
             $db->close();
             $lng = new Lang();
             if (strtolower($dato[1]) == strtolower($this->email) and strtolower($dato[0]) != strtolower($this->user)) {
                 $login = $lng->e_email_existe;
             } else {
                 if (strtolower($dato[1]) != strtolower($this->email) and strtolower($dato[0]) == strtolower($this->user)) {
                     $login = $lng->e_user_existe;
                 } else {
                     $login = $lng->e_user_email_existe;
                 }
             }
             unset($sql, $db, $lng, $dato, $this->user, $this->email, $this->pass);
         }
     } else {
         $lng = new Lang();
         $login = $lng->e_datos_vac;
         unset($lng);
     }
     echo $login;
     unset($login);
 }
Beispiel #4
0
 public function __construct($id_planet)
 {
     parent::__construct($id_planet);
     $db = new Connect();
     $sql = $db->query("SELECT imagen,nombre,campos,campos_usados,temperatura,pos,sistema,metal,cristal,tritio,materia\n        FROM planetas WHERE id_planeta='{$id_planet}' LIMIT 1;");
     $planeta = $db->recorrer($sql);
     $this->planet = array('image' => $planeta['imagen'], 'name' => $planeta['nombre'], 'fields' => $planeta['campos'], 'used_fields' => $planeta['campos_usados'], 'temperature' => $planeta['temperatura'], 'orbit' => $planeta['pos'], 'solar' => $planeta['sistema'], 'metal' => $planeta['metal'], 'cristal' => $planeta['cristal'], 'tritio' => $planeta['tritio'], 'matter' => $planeta['materia']);
     $db->liberar($sql);
     $db->close();
     unset($planeta, $db, $sql);
 }
Beispiel #5
0
 public function __construct($id_user)
 {
     $this->id = $id_user;
     $db = new Connect();
     $sql = $db->query("SELECT usuario,email,faccion,puntos,alianza,top FROM usuarios WHERE id='{$this->id}' LIMIT 1;");
     $usuario = $db->recorrer($sql);
     $this->user = $usuario['usuario'];
     $this->email = $usuario['email'];
     $this->faction = $usuario['faccion'];
     $this->points = $usuario['puntos'];
     $this->alliance = $usuario['alianza'];
     $this->rank = $usuario['top'];
     $db->liberar($sql);
     $db->close();
     unset($sql, $db, $usuario, $this->id);
 }
Beispiel #6
0
 public function __construct($register)
 {
     if ($register === true) {
         //si esto es true, es porque se está pasando del registro
         $db = new Connect();
         $sql = $db->query("SELECT ultima_pos,ultimo_sis FROM generales LIMIT 1;");
         $coordenada = $db->recorrer($sql);
         $db->liberar($sql);
         $db->close();
         $this->u_orbit = $coordenada['ultima_pos'];
         $this->u_system = $coordenada['ultimo_sis'];
         $this->register = true;
         unset($sql, $db, $coordenada);
     } else {
         $this->u_orbit = 'LA ORBITA DE LA MISIO';
         $this->u_system = 'EL SISTEMA DE LA MISIÓN';
         $this->register = false;
     }
 }
Beispiel #7
0
 public function __construct($id_planeta)
 {
     $this->id = $id_planeta;
     $db = new Connect();
     $sql = $db->query("SELECT edificios.fuente_base, edificios.planta_energia, edificios.reactor_fusion, \n        edificios.mina_metal, edificios.mina_cristal, edificios.mina_tritio, \n        edificios.almacen_metal, edificios.almacen_cristal, edificios.almacen_tritio, \n        edificios.satelites, edificios.modulos, edificios.almacen_materia, edificios.distribuidor, edificios.nanobots,\n        planetas.metal, planetas.cristal, planetas.tritio, \n        planetas.ultima_act, planetas.temp_promd FROM edificios, planetas WHERE edificios.id_planeta='{$this->id}' \n        AND planetas.id_planeta='{$this->id}' LIMIT 1;");
     $dat = $db->recorrer($sql);
     $this->niveles = array('mina_metal' => $dat['mina_metal'], 'mina_cristal' => $dat['mina_cristal'], 'mina_tritio' => $dat['mina_tritio'], 'reactor_fusion' => $dat['reactor_fusion'], 'planta_energia' => $dat['planta_energia'], 'distribuidor' => $dat['distribuidor'], 'satelites' => $dat['satelites'], 'modulos' => $dat['modulos'], 'almacen_metal' => $dat['almacen_metal'], 'almacen_cristal' => $dat['almacen_cristal'], 'almacen_tritio' => $dat['almacen_tritio'], 'almacen_materia' => $dat['almacen_materia'], 'nanobots' => $dat['nanobots']);
     $this->metal = $dat['metal'];
     $this->cristal = $dat['cristal'];
     $this->tritio = $dat['tritio'];
     $tiempo = time();
     $time = $tiempo - $dat['ultima_act'];
     parent::__construct($time, $this->niveles, $dat['fuente_base'], $dat['temp_promd'], $this->tritio);
     $prod_metal = $this->metal >= $this->getMetalCapacity() ? 0 : $this->getMetalProd();
     $prod_cristal = $this->cristal >= $this->getCristalCapacity() ? 0 : $this->getCristalProd();
     $prod_tritio = $this->tritio >= $this->getTritioCapacity() ? 0 : $this->getTritioProd();
     $this->prod_resources = array('metal' => $prod_metal, 'cristal' => $prod_cristal, 'tritio' => $prod_tritio);
     //Actualizacion de recursos cada tano
     $update = $db->query("UPDATE planetas SET ultima_act='{$tiempo}', metal= metal + '{$prod_metal}', \n        cristal= cristal + '{$prod_cristal}', tritio= tritio + '{$prod_tritio}' WHERE id_planeta='{$this->id}'");
     $db->liberar($sql, $update);
     $db->close();
     unset($prod_metal, $prod_cristal, $prod_tritio, $tiempo, $db);
 }
Beispiel #8
0
 private function __construct()
 {
     require 'core/models/class.User.php';
     require 'core/models/implement.Menu.php';
     require 'core/models/class.Planet.php';
     require 'core/models/implement.Topnav.php';
     global $id_user, $id_planet;
     $lng = new Lang();
     $menu = new Menu($id_user);
     $topnav = new Topnav($id_planet, $id_user);
     $user = new User($id_user);
     $planet = new Planet($id_planet);
     require 'core/functions/class.UpdateStats.php';
     $update = new UpdateStats();
     $db = new Connect();
     $sql = $db->query("SELECT COUNT(*) id FROM usuarios;");
     $total_rank = $db->recorrer($sql);
     $db->liberar($sql);
     $db->close();
     $template = new Smarty();
     $template->assign(array('usuario_email' => $user->UserEmail(), 'usuario_faccion' => $user->UserFaction(), 'usuario_puntos' => $user->UserPoints(), 'usuario_top' => $user->TopUser(), 'total_rank' => number_format($total_rank[0], '0', ',', '.'), 'campos' => $planet->PlanetFields(), 'diametro' => $planet->PlanetDiameter(), 'temperatura' => $planet->PlanetTemperature(), 'p' => $planet->PlanetOrbit(), 's' => $planet->PlanetSystem(), 'nombre_planeta' => $planet->PlanetName(), 'imagen_planeta' => $planet->PlanetImage()));
     $template->display('overview/overview.xnv');
 }
Beispiel #9
0
 private function __construct()
 {
     require 'core/models/class.User.php';
     require 'core/models/implement.Menu.php';
     require 'core/models/class.Planet.php';
     require 'core/models/implement.Topnav.php';
     global $id_user, $id_planet;
     $lng = new Lang();
     $menu = new Menu($id_user);
     $topnav = new Topnav($id_planet, $id_user);
     $user = new User($id_user);
     $db = new Connect();
     $sql = $db->query("SELECT sistema FROM planetas WHERE id_planeta='{$id_planet}' LIMIT 1;");
     $system = $db->recorrer($sql);
     $db->liberar($sql);
     if (isset($_GET['sistema']) and is_numeric($_GET['sistema']) and $_GET['sistema'] > 0 and $_GET['sistema'] <= 700) {
         $this->system_id = intval($_GET['sistema']);
     } else {
         $this->system_id = intval($system['sistema']);
     }
     unset($system, $sql);
     $x = 1;
     $psql = "SELECT SQL_BIG_RESULT DISTINCT id_planeta, pos, nombre, imagen, usuario, id_dueno \n            FROM planetas JOIN usuarios \n            ON planetas.id_dueno=usuarios.id WHERE sistema=? \n            AND pos=? ORDER BY pos ASC LIMIT 1;";
     $prepare_sql = $db->prepare($psql);
     $prepare_sql->bind_param('ii', $orbit, $system_id);
     while ($x < 16) {
         $orbit = $x;
         $system_id = $this->system_id;
         $prepare_sql->execute();
         $id_planeta = '';
         $pos = '';
         $nombre = '';
         $imagen = '';
         $usuario = '';
         $id_dueno = '';
         $prepare_sql->bind_result($id_planeta, $pos, $nombre, $imagen, $usuario, $id_dueno);
         $prepare_sql->fetch();
         $o_s = "&o={$x}&s={$this->system_id}";
         if ($x != $pos) {
             if ($x == 1 or $x == 5 or $x == 9 or $x == 13) {
                 $universe[] = array('posicion' => $x, 'nombre' => 'Brecha', 'imagen' => 'brecha_espacio', 'usuario' => 'Agujero de gusano', 'escombros' => 'no_in', 'luna' => 'no_in', 'habitado' => 'deshabitado', 'accion' => '<a href=\'?core=fleets&mision=saltar' . $o_s . '\'>' . $lng->x_saltar . '</a>');
             } else {
                 $universe[] = array('posicion' => $x, 'nombre' => 'Planeta Habitable', 'imagen' => 'planeta_desconocido', 'usuario' => 'La atmósfera es apta para colonizar', 'escombros' => 'no_in', 'luna' => 'no_in', 'habitado' => 'deshabitado', 'accion' => '<a href=\'?view=flotas&mision=colonizar' . $o_s . '\'>' . $lng->x_colonizar . '</a>');
             }
         } else {
             if ($id_dueno == $id_user and $id_planeta != $id_planet) {
                 $universe[] = array('posicion' => $pos, 'nombre' => $nombre, 'imagen' => $imagen, 'usuario' => $usuario, 'escombros' => 'no_es', 'luna' => 'no_es', 'habitado' => 'habitado', 'accion' => '<a href=\'?view=flotas&mision=transportar' . $o_s . '\'>' . $lng->x_transportar . '</a> |
                                 <a href=\'?view=flotas&mision=desplegar' . $o_s . '\'>' . $lng->x_desplegar . '</a>');
             } else {
                 if ($id_planeta == $id_planet and $id_dueno == $id_user) {
                     $universe[] = array('posicion' => $pos, 'nombre' => $nombre, 'imagen' => $imagen, 'usuario' => $usuario, 'escombros' => 'no_es', 'luna' => 'no_es', 'habitado' => 'habitado', 'accion' => '<br />' . $lng->x_no_hay . '');
                 } else {
                     $universe[] = array('posicion' => $pos, 'nombre' => $nombre, 'imagen' => $imagen, 'usuario' => $usuario, 'escombros' => 'no_es', 'luna' => 'no_es', 'habitado' => 'habitado', 'accion' => '<a href=\'?view=flotas&mision=transportar' . $o_s . '\'>' . $lng->x_transportar . '</a> |
                                 <a href=\'?view=flotas&mision=desplegar' . $o_s . '\'>' . $lng->x_desplegar . '</a> | <br /> 
                                 <a href=\'?view=flotas&mision=tomar_recursos' . $o_s . '\'>' . $lng->x_tomar_recursos . '</a> |  
                                 <a href=\'?view=flotas&mision=defender' . $o_s . '\'>' . $lng->x_defender . '</a> <br />
                                 <a href=\'?view=flotas&mision=espiar' . $o_s . '\'>' . $lng->x_espiar . '</a> |
                                 <a href=\'?view=flotas&mision=atacar' . $o_s . '\'>' . $lng->x_atacar . '</a> |
                                 <a href=\'?view=flotas&mision=sac' . $o_s . '\'>' . $lng->x_sac . '</a>');
                 }
             }
         }
         $x++;
         //bucle increment
     }
     $prepare_sql->close();
     $db->close();
     $template = new Smarty();
     $template->assign(array('sistema' => $this->system_id, 'x_ir' => $lng->x_ir, 'x_anterior' => $lng->x_anterior, 'x_siguiente' => $lng->x_siguiente, 'x_orbita' => $lng->x_orbita, 'x_planeta' => $lng->x_planeta, 'x_emperador' => $lng->x_emperador, 'x_accion' => $lng->x_accion, 'universe' => $universe));
     $template->display('universe/universe.xnv');
     unset($x, $template);
 }