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(); }
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; }
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); }
public function getMessageById($id, $user = NULL) { $userid = !empty($user) ? $user : $this->user; $sql = "SELECT id FROM *PREFIX*collab_user_message WHERE mid = " . $id . " AND uid = '" . $userid . "'"; $um = $this->connect->query($sql); if (empty($um['id'])) { $this->createStatus($id, $userid, 0); } $sql = "SELECT um.id as id, m.date, m.title, m.text, m.attachements, m.author, m.subscribers, um.mid as mid, um.status" . " FROM *PREFIX*collab_user_message um" . " INNER JOIN *PREFIX*collab_messages m ON m.id = um.mid" . " WHERE um.mid = " . $id . " AND um.uid = '" . $userid . "'" . " ORDER BY m.date DESC"; $message = $this->connect->query($sql); return $message; }
function adminId() { $query = "SELECT adminId FROM Admins WHERE email='{$this->email}'"; $adminIdArr = parent::query($query); $size = sizeof($adminIdArr); return parent::validateIndexes($adminArr, 0, 'adminId'); }
public function getDataSP($flag, $criterio = '', $page = 1, $regxpag = 10) { $DB = new Connect(); $sql = "CALL dataGrid('" . $flag . "','" . $criterio . "','" . $page . "','" . $regxpag . "')"; // ejecutamos $data = $DB->query($sql); $result = $data->fetchAll(PDO::FETCH_ASSOC); // que sea un array asociativo return $result; }
function storeId() { $query = "SELECT storeId FROM Stores WHERE name='{$this->storeName}'"; $storeIdArr = parent::query($query); $size = sizeof($storeIdArr); if ($size == 0) { return 0; } else { return $storeIdArr[0]['storeId']; } }
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); }
function read($sessId) { $prefs = new Preferences(); $idle = $prefs->idleTime(); $expiry = time() - $idle; $query = "SELECT data FROM Sessions WHERE sessId='{$sessId}' AND lastAccess >= {$expiry}"; $data = parent::query($query); if (isset($data[0])) { return $data[0]['data']; } else { return ''; } }
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); }
public function getData($flag,$criterio=''){ $DB = new Connect(); if($flag == 'P'){ $sql = "SELECT nombres,apellidos FROM f_trabajador"; if(!empty($criterio)){ $sql .= " WHERE CONCAT(nombres,' ',apellidos) LIKE '%".$criterio."%' "; } $data = $DB->query($sql); $result = $data->fetchAll(PDO::FETCH_ASSOC); } return $result; }
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); }
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; } }
/** * Inserts uploaded file into database * @param array $file */ public function newFile($file, $path) { $sql = "SELECT id FROM *PREFIX*mimetypes WHERE mimetype = '" . $file['mimetype'] . "'"; $res = $this->connect->query($sql); $mimetype = $res['id']; $sql = "SELECT numeric_id FROM *PREFIX*storages WHERE id = 'home::" . $file['owner'] . "'"; $res = $this->connect->query($sql); $storageid = $res['numeric_id']; $sql = "SELECT fileid FROM *PREFIX*filecache WHERE path = '" . $file['path'] . "'"; $res = $this->connect->query($sql); $parent = $res['fileid']; //$path = '/var/www/owncloud.loc/data/admin/files/Photos/San Francisco.jpg'; list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($path . '/' . $file['filename']); $etag = $storage->getETag($internalPath); $data = array('storage' => $storageid, 'path' => $file['path'] . '/' . $file['filename'], 'path_hash' => md5($file['path'] . '/' . $file['filename']), 'parent' => $parent, 'name' => $file['filename'], 'mimetype' => $mimetype, 'mimepart' => 5, 'size' => $file['size'], 'mtime' => $file['mtime'], 'storage_mtime' => $file['storage_mtime'], 'etag' => $etag, 'permissions' => \OCP\Constants::PERMISSION_ALL); $filecache = $this->save($data); /* file_put_contents('/tmp/inb.log', "\nPath : /\n", FILE_APPEND); try { $fileInfo = \OC\Files\Filesystem::getFileInfo('/', false); } catch (\Exception $e) { file_put_contents('/tmp/inb.log', "\nGet File Info error : " . $e->getMessage() . "\n", FILE_APPEND); } file_put_contents('/tmp/inb.log', "\nFile info : " . print_r($fileInfo, true) . "\n", FILE_APPEND); try { $icon = \OCA\Files\Helper::determineIcon($fileInfo); } catch (\Exception $e) { file_put_contents('/tmp/inb.log', "\nDetermine Icon error : " . $e->getMessage() . "\n", FILE_APPEND); } */ $activity = array('activity_id' => NULL, 'timestamp' => $file['mtime'], 'priority' => 30, 'type' => 'file_created', 'user' => $file['owner'], 'affecteduser' => $file['owner'], 'app' => 'files', 'subject' => 'created_self', 'subjectparams' => '["\\/' . $file['filename'] . '"]', 'message' => '', 'messageparams' => '[]', 'file' => '/' . $file['filename'], 'link' => $file['domain'] . '/index.php/apps/files?dir=%2F', 'object_type' => 'files', 'object_id' => $filecache); $id = $this->connect->insert('*PREFIX*activity', $activity); if ($id) { return $filecache; } else { return false; } }
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'); }
function discountAmount($subtotal, $discountId) { if (!isset($discountId)) { return 0; } $query = "SELECT discountAmount,discountPercentage FROM Discounts WHERE discountId ='{$discountId}'"; $dadp = parent::query($query); //print $dadp[0]['discountAmount'] . "<br>"; //print $dadp[0]['discountPercentage'] . "<br>"; if (isset($dadp[0]['discountAmount']) && isset($dadp[0]['discountPercentage'])) { if ($dadp[0]['discountAmount'] == 0 && $dadp[0]['discountPercentage'] == 0) { return number_format(0, 2, '.', ' '); } elseif ($dadp[0]['discountAmount'] != 0 && $dadp[0]['discountPercentage'] == 0) { return $dadp[0]['discountAmount']; } elseif ($dadp[0]['discountAmount'] == 0 && $dadp[0]['discountPercentage'] != 0) { return number_format($subtotal * ($dadp[0]['discountPercentage'] / 100), 2, '.', ' '); } elseif ($dadp[0]['discountAmount'] != 0 && $dadp[0]['discountPercentage'] != 0) { return number_format($dadp[0]['discountAmount'] + $subtotal * ($dadp[0]['discountPercentage'] / 100), 2, '.', ' '); } else { return 0; } } }
function paymentInfoByOid($orderId) { $query = "SELECT name, paymentCost, paymentAmount FROM OrderToPaymentMeths, PaymentMethods\n\t\t\t\t\tWHERE orderId='{$orderId}' AND OrderToPaymentMeths.paymentId = PaymentMethods.paymentMethId"; return parent::query($query); }
function prodInfoByOid($orderId) { $query = "SELECT name, price*productQuantity, productQuantity FROM OrderToProds, Products \n\t\t\t\t\tWHERE OrderToProds.orderId='{$orderId}' AND OrderToProds.productId=Products.productId"; return parent::query($query); }
/** * Get one record by name * @param $name * @return mixed */ public function findByName($name) { $sql = "SELECT * , DATE_FORMAT( `start_date`, '%d-%m-%Y %H:%i:%s') as start_date\n FROM `{$this->tableName}` WHERE `name` = ?"; return $this->connect->query($sql, [$name]); }
public function getByReply($id) { $sql = "SELECT um.id as id, um.mid as mid, m.date, m.title, m.text, m.attachements, m.author, m.subscribers, um.status" . " FROM oc_collab_user_message um" . " INNER JOIN oc_collab_messages m ON m.id = um.mid" . " WHERE um.mid = " . $id . " ORDER BY m.date DESC"; $message = $this->connect->query($sql); return $message; }
public function getByEmail($email) { $sql = "SELECT *\n FROM *PREFIX*preferences\n WHERE appid = 'settings' AND configkey = 'email' AND configvalue = :email"; return $this->connect->query($sql, [':email' => $email]); }
function ordersByDate($min, $max, $maxOrdersPP) { $query = "SELECT Orders.orderId,storeId,orderDate,currency,subTotal from Orders,OrderToFinances \n\t\t\t\t\tWHERE Orders.orderId=OrderToFinances.orderId BETWEEN {$min} AND {$max} ORDER BY orderDate DESC LIMIT {$maxOrdersPP}"; return parent::query($query); }
function allById($userId) { $query = "SELECT * FROM Users WHERE userId='{$userId}'"; $user = parent::query($query); return parent::validateIndex($user, 0); }
/** * Get last id * @return mixed */ public function getLastId() { $data = $this->connect->query("SELECT id FROM `{$this->tableName}` ORDER BY id DESC LIMIT 1"); return !$data ? 1 : $data['id']; }
function isUser($email) { $query = "SELECT email FROM Users WHERE email='{$email}'"; $user = parent::query($query); return parent::validateIndexes($user, 0, 'email'); }
function prefValues($prefId) { $query = "SELECT values FROM PrefOptions WHERE prefId='{$prefId}'"; $rs = parent::query($query); }
/** * @param $uid * @return mixed */ public function getUserEmail($uid) { $sql = "SELECT * FROM oc_preferences\n WHERE configkey = 'email'\n AND appid = 'settings'\n AND userid = :uid"; return $this->connect->query($sql, [':uid' => $uid]); }
function prefValue($prefName) { $query = "SELECT value FROM Preferences WHERE name='{$prefName}'"; $rs = parent::query($query); return $rs[0]['value']; }
/** * @param $uid * @param $mimetype * @return mixed [mimetype_id, mimetype, storage_id, filecache_id] */ public function getParseFileData($uid, $mimetype) { $sql = "SELECT\n mt.id as mimetype_id,\n mt.mimetype as mimetype,\n sg.numeric_id as storage_id,\n fch.fileid as filecache_id\n FROM *PREFIX*mimetypes mt\n LEFT JOIN *PREFIX*storages sg ON (sg.id = :uid)\n LEFT JOIN *PREFIX*filecache fch ON (fch.path = 'files/Talks')\n WHERE mt.mimetype = :mimetype"; return $this->connect->query($sql, [':uid' => 'home::' . $uid, ':mimetype' => $mimetype]); }
function taxRate($storeId) { $query = "SELECT rate from Tax WHERE storeId='{$storeId}'"; return parent::query($query); }