Beispiel #1
1
 public function get($id)
 {
     require_once 'DataBase.php';
     $data = new DataBase();
     $data->open();
     $sql = "BEGIN GETRUTACONDUCTOR(:p_id, :rc); END;";
     $sent = oci_parse($data->getConn(), $sql);
     $refcur = oci_new_cursor($data->getConn());
     $this->id = $id;
     oci_bind_by_name($sent, ':p_id', $this->id);
     oci_bind_by_name($sent, ':rc', $refcur, -1, OCI_B_CURSOR);
     if (!oci_execute($sent)) {
         return false;
     }
     if (!oci_execute($refcur)) {
         return false;
     }
     while (($row = oci_fetch_array($refcur, OCI_ASSOC + OCI_RETURN_NULLS)) != false) {
         $this->ruta = $row['ID_RUTA'];
         $this->conductor = $row['ID_CONDUCTOR'];
         $this->kilometraje = $row['KILOMETRAJE'];
         $this->descripcion = $row['DESCRIPCION'];
     }
     oci_free_statement($refcur);
     $data->free($sent);
     $data->close();
     return true;
 }
Beispiel #2
0
 public function saveToDB($poiId, $componentId, $stageRating)
 {
     global $secKeys;
     $now = date("Y-m-d H:i:s");
     try {
         DataBase::connect('localhost', $secKeys->cakeVars->{'dbUsr'}, $secKeys->cakeVars->{'dbPw'}, $secKeys->cakeVars->{'dbCake'});
         $sql = "INSERT INTO stages (component_id, poi_id, created, modified, rating) VALUES (:component_id, :poi_id, :tstamp, :tstamp, :rating)";
         $para = array('component_id' => $componentId, 'poi_id' => $poiId, 'tstamp' => $now, 'rating' => $stageRating);
         DataBase::fire($sql, $para);
         $this->savedStagesCount = DataBase::lastInsertId();
         DataBase::close();
     } catch (Exception $e) {
         die('Fehler bei .... Fehler: ' . $e->getMessage());
     }
 }
Beispiel #3
0
 public function get($id)
 {
     require_once 'DataBase.php';
     $data = new DataBase();
     $data->open();
     $sql = "BEGIN GETPLANIFICACION(:id, :nombre, :distancia, :ruta); END;";
     $sent = oci_parse($data->getConn(), $sql);
     $this->id = $id;
     oci_bind_by_name($sent, ':id', $this->id);
     oci_bind_by_name($sent, ':nombre', $this->nombre);
     oci_bind_by_name($sent, ':distancia', $this->distancia);
     oci_bind_by_name($sent, ':ruta', $this->ruta);
     oci_execute($sent);
     $data->free($sent);
     $data->close();
 }
Beispiel #4
0
 public function getBook($id)
 {
     require_once 'dbm.php';
     $data = new DataBase();
     $data->open();
     $query = "SELECT * FROM `archivo` WHERE `id_archivo` = {$id}";
     $result = mysqli_query($data->get_connect(), $query);
     $row = mysqli_fetch_array($result);
     $this->id = $row[0];
     $this->user = $row[1];
     $this->title = $row[2];
     $this->path = $row[5];
     $this->description = $row[3];
     $this->punteo = $row[6];
     $data->close();
 }
 static function handle()
 {
     $bd = new DataBase();
     $gestor = new ManageRelations($bd);
     $action = Request::req("action");
     $do = Request::req("do");
     $metodo = $action . ucfirst($do);
     if (method_exists(get_class(), $metodo)) {
         //ucfirst pone la primera en mayuscula
         echo 'El método existe';
         self::$metodo($gestor);
     } else {
         echo 'la función no existe';
         self::readView($gestor);
     }
     $bd->close();
 }
Beispiel #6
0
 public function get($courriel)
 {
     $cnx = DataBase::getInstance();
     $pstmt = $cnx->prepare("SELECT * FROM user WHERE courriel = :c");
     $pstmt->execute(array('c' => $courriel));
     $result = $pstmt->fetch(PDO::FETCH_OBJ);
     if ($result) {
         $u = new User();
         $u->loadFromObject($result);
         $pstmt->closeCursor();
         DataBase::close();
         return $u;
     }
     $pstmt->closeCursor();
     DataBase::close();
     return NULL;
 }
Beispiel #7
0
 function getComentarios($id_archivo)
 {
     require_once 'dbm.php';
     require_once 'user.php';
     $data = new DataBase();
     $data->open();
     $comentarios = array();
     $query = "SELECT comentario.id_usuario, comentario.texto FROM comentario WHERE comentario.id_archivo = {$id_archivo} ORDER BY comentario.id_comentario DESC";
     $result = mysqli_query($data->get_connect(), $query);
     while ($row = mysqli_fetch_array($result)) {
         $elemento = new Comment();
         $usuario = new User();
         $usuario->getUser($row[0]);
         $elemento->setComentario($usuario->getNombre(), $row[1]);
         $comentarios[] = $elemento;
     }
     $data->close();
     return $comentarios;
 }
Beispiel #8
0
 public function findAll()
 {
     $liste = array();
     $cnx = DataBase::getInstance();
     $pstmt = $cnx->prepare("SELECT * FROM alerts ORDER BY active=1 DESC");
     $pstmt->execute();
     while ($result = $pstmt->fetch(PDO::FETCH_OBJ)) {
         $p = new Alert();
         $p->setId($result->id);
         $p->setTitle($result->title);
         $p->setText($result->text);
         $p->setDate($result->date);
         $p->setActive($result->active);
         array_push($liste, $p);
     }
     $pstmt->closeCursor();
     DataBase::close();
     return $liste;
 }
?>
> Admin<br>
						<br/><br/>
						<input type="submit" value="Save" id="guardarperfil"/>
					</fieldset>
				</form>
				<form action="php/phpdeleteuser.php" method="post">
					<br/><br/><br/>
					<fieldset>
						<legend>Delete user</legend><br/>
						<input type="hidden" name="email" value="<?php 
echo $usuario->getEmail();
?>
"/>
						<input type="checkbox" name="confirm" value="yes"> Confirm delete user<br>
						<input type="submit" value="Delete" id="eliminarmensaje"/>
					</fieldset>
				</form>
			</div>
   		</div>
   		
   		<footer>
   			<h class="left">Copyright by Socializate</h>
   			<h class="right">Designed by David Gamarra</h>
   		</footer>
    </body>
</html>

<?php 
$db->close();
Beispiel #10
0
<?php

$username = $_POST['user'];
$password = $_POST['pass'];
$rol = 0;
require_once 'DataBase.php';
$data = new DataBase();
$data->open();
$id = 0;
$sql = "BEGIN LOGIN(:user, :pass, :rol, :id); END;";
$sent = oci_parse($data->getConn(), $sql);
oci_bind_by_name($sent, ':user', $username);
oci_bind_by_name($sent, ':pass', $password);
oci_bind_by_name($sent, ':rol', $rol);
oci_bind_by_name($sent, ':id', $id);
oci_execute($sent);
$data->free($sent);
$data->close();
if ($rol > 0 && $id > 0) {
    session_start();
    $_SESSION['id'] = $id;
    $_SESSION['user'] = $username;
    $_SESSION['rol'] = $rol;
    header('Location: index.php');
} else {
    header('Location: loginform.php?error=1');
}
Beispiel #11
0
 public function delete($id)
 {
     require_once 'DataBase.php';
     $data = new DataBase();
     $data->open();
     $sql = "BEGIN DELUSUARIO(:id); END;";
     $sent = oci_parse($data->getConn(), $sql);
     oci_bind_by_name($sent, ':id', $id);
     if (!oci_execute($sent)) {
         return false;
     }
     $data->free($sent);
     $data->close();
     return true;
 }
Beispiel #12
0
 public function findBySeasonAndCategory($categ, $season, $page = 0, $taille = 0, $visibleOnly = 1)
 {
     $liste = array();
     $where = "";
     if ($visibleOnly) {
         $where = " AND hidden=0";
     }
     $cnx = DataBase::getInstance();
     if ($page == 0) {
         $pstmt = $cnx->prepare("SELECT * FROM photo WHERE season=:s AND category=:c" . $where);
     } else {
         $debut = $taille * ($page - 1);
         $pstmt = $cnx->prepare("SELECT * FROM photo WHERE season=:s AND category=:c" . $where . " LIMIT " . $debut . "," . $taille);
     }
     $pstmt->execute(array('s' => $season, 'c' => $categ));
     while ($result = $pstmt->fetch(PDO::FETCH_OBJ)) {
         $p = new Photo();
         $p->loadFromObject($result);
         array_push($liste, $p);
     }
     $pstmt->closeCursor();
     DataBase::close();
     return $liste;
 }
<?php

require '../clases/AutoCarga.php';
$bd = new DataBase();
$gestorUsuario = new ManageUser($bd);
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link href="../css/estilos.css" rel="stylesheet">
    </head>
    <body>
        <form action="phpregister.php" method="POST" >
            <div class="logo"></div>
            <div class="login-block">
            <label for="email">Email: </label><input type="email" name="email" value="" /><br/>
            <label for="password">Password: </label><input type="password" name="clave" value="" /><br/>           
            <input type="submit" value="Registrar"/>
            </div>
        </form>
    </body>
</html>
<?php 
$bd->close();
Beispiel #14
0
 public function Delete()
 {
     require_once 'dbm.php';
     $data = new DataBase();
     $data->open();
     $query = "DELETE FROM categoria WHERE id_categoria = {$this->id}";
     $result = mysqli_query($data->get_connect(), $query);
     $data->close();
     if ($result) {
         $this->id = null;
         $this->nombre = null;
         $this->descripcion = null;
         return true;
     } else {
         return false;
     }
 }
Beispiel #15
0
 function getForceBalance($account = "", $from = "", $to = "")
 {
     //Connect
     $sql = new DataBase();
     $sql->connect();
     //Objects
     $json = array();
     $accounts = $this->get(50, $account);
     //Data
     foreach ($accounts as $acc) {
         //Query
         $balance = 0;
         $query = "SELECT transaction.amount, transaction.account_to_id FROM transactions transaction";
         $query .= " WHERE (transaction.account_from_id = '" . $acc['id'] . "' OR transaction.account_to_id = '" . $acc['id'] . "')";
         if (!empty($from)) {
             $query .= " AND transaction.date >= '" . $from . "' ";
         }
         if (!empty($to)) {
             $query .= " AND transaction.date <= '" . $to . "' ";
         }
         //execute
         $sql->query($query);
         //Data
         while ($data = mysql_fetch_array($sql->result)) {
             if ($data["account_to_id"] == $acc["id"]) {
                 $balance -= $data["amount"];
             } else {
                 $balance += $data["amount"];
             }
         }
         $balance += $acc["initial_balance"];
         //Array
         $acc['balance'] = round($balance, 2);
         $array = $acc;
         array_push($json, $array);
     }
     return $json;
     $sql->close();
 }
Beispiel #16
0
                // $loggedInUser->redirect = 'false';
                // $loggedInUser->remember_me_sessid = generateHash(uniqid(rand(), true));
                // //Update last sign in
                // $loggedInUser->updatelast_sign_in();
                // if($loggedInUser->remember_me == 0)
                // 	$_SESSION["userPieUser"] = $loggedInUser;
                // 	else if($loggedInUser->remember_me == 1) {
                // 	$db->sql_query("INSERT INTO ".$db_table_prefix."sessions VALUES('".time()."', '".serialize($loggedInUser)."', '".$loggedInUser->remember_me_sessid."')");
                // 	setcookie("userPieUser", $loggedInUser->remember_me_sessid, time()+parseLength($remember_me_length));
                // }
                //LOG
                $sql4->query("INSERT INTO log(type,message,application_id,profile_id) VALUES ('login','O usuario logou no sistema. Token: " . $generateToken . "','" . $data['id'] . "','" . $userdetails['id'] . "')");
                //Retorno
                /*if($data['return_url'] != '' && !isset($_DATA['redirect'])):
                			header("Location: ".$data['return_url']."?token=".$generateToken);
                		else:*/
                echo $generateToken;
                /*endif;*/
                break;
            }
            $sql->close();
            break;
        }
        break;
        /////////////////////////////////////DEFAULT
    /////////////////////////////////////DEFAULT
    default:
        RestUtils::sendResponse('405');
        exit;
        break;
}
Beispiel #17
0
 function list_of_files()
 {
     // Esta funcion devolvera un arreglo de objetos para los archivos
     require_once 'dbm.php';
     $data = new DataBase();
     $userid = $this->userid;
     $query = "SELECT * FROM archivo WHERE id_usuario = {$userid}";
     $data->open();
     $result = mysqli_query($data->get_connect(), $query);
     $list_of_files = array();
     while ($row = mysqli_fetch_array($result)) {
         $elemento = new element_book($row[1], $row[2], $row[3], $row[4]);
         $elemento->setId($row[0]);
         $list_of_files[] = $elemento;
     }
     $data->close();
     return $list_of_files;
 }
Beispiel #18
0
 public function get($id)
 {
     require_once 'DataBase.php';
     $data = new DataBase();
     $data->open();
     $sql = "BEGIN UPDATECONDUCTOR(:id, :nombre, :cui, :direccion, :telefono, :fechanac); END;";
     $sent = oci_parse($data->getConn(), $sql);
     $this->id = $id;
     oci_bind_by_name($sent, ':id', $id);
     oci_bind_by_name($sent, ':nombre', $this->nombre);
     oci_bind_by_name($sent, ':cui', $this->cui);
     oci_bind_by_name($sent, ':direccion', $this->direccion);
     oci_bind_by_name($sent, ':telefono', $this->telefono);
     oci_bind_by_name($sent, ':fechanac', $this->fechanac);
     oci_execute($sent);
     $data->free($sent);
     $data->close();
 }
Beispiel #19
0
 function delete()
 {
     //Connect
     $sql = new DataBase();
     $sql->connect();
     //Close connection
     $sql->close();
 }
Beispiel #20
0
 public function getAll()
 {
     $respuesta = array();
     require_once 'DataBase.php';
     $data = new DataBase();
     $data->open();
     $sql = "BEGIN GETALLRUTAS(:rc); END;";
     $sent = oci_parse($data->getConn(), $sql);
     $refcur = oci_new_cursor($data->getConn());
     oci_bind_by_name($sent, ':rc', $refcur, -1, OCI_B_CURSOR);
     if (!oci_execute($sent)) {
         return false;
     }
     if (!oci_execute($refcur)) {
         return false;
     }
     while (($row = oci_fetch_array($refcur, OCI_ASSOC + OCI_RETURN_NULLS)) != false) {
         $elemento = new Ruta();
         $elemento->id = $row['ID_RUTA'];
         $elemento->nombre = $row['NOMBRE'];
         $respuesta[] = $elemento;
     }
     oci_free_statement($refcur);
     $data->free($sent);
     $data->close();
     return $respuesta;
 }
Beispiel #21
0
 public function saveToDB($filterdQueryData)
 {
     global $secKeys;
     ControlFunctions::forDebug($filterdQueryData, "Gefilterte Pois");
     // for ($i = 0; $i < 5; $i++) {
     for ($i = 0; $i < count($filterdQueryData); $i++) {
         $now = date("Y-m-d H:i:s");
         try {
             DataBase::connect('localhost', $secKeys->cakeVars->{'dbUsr'}, $secKeys->cakeVars->{'dbPw'}, $secKeys->cakeVars->{'dbCake'});
             $sql = "INSERT INTO pois (created, modified, name, lat, lng, google_place, icon, rating, vicinity) VALUES (:tstamp, :tstamp, :name, :lat, :lng, :google_place, :icon, :rating, :vicinity)";
             $para = array('tstamp' => $now, 'name' => $filterdQueryData[$i]->name, 'lat' => $filterdQueryData[$i]->geometry->location->lat, 'lng' => $filterdQueryData[$i]->geometry->location->lng, 'google_place' => $filterdQueryData[$i]->place_id, 'icon' => $filterdQueryData[$i]->icon, 'rating' => isset($filterdQueryData[$i]->rating) ? $filterdQueryData[$i]->rating : null, 'vicinity' => $filterdQueryData[$i]->vicinity);
             DataBase::fire($sql, $para);
             $lastPoisId = DataBase::lastInsertId();
             echo ControlFunctions::tagIt("h1", "Letzter Eintrag: " . $lastPoisId);
             foreach ($filterdQueryData[$i]->types as $tag) {
                 $tagId = null;
                 // Check if tag is already present
                 $sql = "SELECT EXISTS(SELECT 1 FROM tags WHERE title LIKE '%" . $tag . "%')";
                 $rows = DataBase::fire($sql);
                 $tagPresent = current(current($rows)) == "1" ? true : false;
                 ControlFunctions::forDebug($rows, "Ausgabe für Tag {$tag}");
                 echo $tagPresent ? "Wert für {$tag} ist: vorhanden" : "Wert für {$tag} ist: Nicht existent!";
                 if ($tagPresent) {
                     $sql = "SELECT id FROM tags WHERE title LIKE '%" . $tag . "%'";
                     $rows = DataBase::fire($sql);
                     $tagId = current(current($rows));
                     ControlFunctions::forDebug($rows, "Ausgabe für Tag {$tag}, tag ID: ");
                     echo ControlFunctions::tagIt("h1", "{$tag} ID: {$tagId}");
                 } else {
                     // Paste Tag
                     $sql = "INSERT INTO tags (title, created, modified) VALUES (:title, :tstamp, :tstamp)";
                     $para = array('title' => $tag, 'tstamp' => $now);
                     DataBase::fire($sql, $para);
                     // Save ID
                     $tagId = DataBase::lastInsertId();
                 }
                 // Paste Relation
                 $sql = "INSERT INTO pois_tags (poi_id, tag_id) VALUES (:poi_id, :tag_id)";
                 $para = array('poi_id' => $lastPoisId, 'tag_id' => $tagId);
                 DataBase::fire($sql, $para);
                 echo ControlFunctions::tagIt("h1", "Letzter Eintrag: " . DataBase::lastInsertId());
             }
             DataBase::close();
         } catch (Exception $e) {
             die('Fehler bei .... Fehler: ' . $e->getMessage());
         }
     }
 }
Beispiel #22
0
 function get($id)
 {
     require_once 'DataBase.php';
     $data = new DataBase();
     $data->open();
     $sql = "BEGIN GETVEHICULO(:id, :rc); END;";
     $sent = oci_parse($data->getConn(), $sql);
     $refcur = oci_new_cursor($data->getConn());
     $this->id = $id;
     oci_bind_by_name($sent, ':id', $this->id);
     oci_bind_by_name($sent, ':rc', $refcur, -1, OCI_B_CURSOR);
     if (!oci_execute($sent)) {
         return false;
     }
     if (!oci_execute($refcur)) {
         return false;
     }
     while (($row = oci_fetch_array($refcur, OCI_ASSOC + OCI_RETURN_NULLS)) != false) {
         $this->id = $row['ID_VEHICULO'];
         $this->placa = $row['PLACA'];
         $this->kilometraje = $row['KILOMETRAJE'];
         $this->serie = $row['SERIE'];
         $this->motor = $row['MOTOR'];
         $this->anio = $row['ANIO'];
         $this->color = $row['COLOR'];
         $this->marca = $row['MARCA'];
     }
     oci_free_statement($refcur);
     $data->free($sent);
     $data->close();
     return true;
 }
Beispiel #23
0
 public function update()
 {
     if ($this->factura != "" && $this->proveedor != "" && $this->id != 0) {
         require_once 'DataBase.php';
         $data = new DataBase();
         $data->open();
         $sql = "BEGIN UPDMANTENIMIENTO(:id, :factura, :proveedor, :fecha, :monto, :descripcion, :vehiculo, :tipo); END;";
         $sent = oci_parse($data->getConn(), $sql);
         oci_bind_by_name($sent, ':id', $this->id);
         oci_bind_by_name($sent, ':factura', $this->factura);
         oci_bind_by_name($sent, ':proveedor', $this->proveedor);
         oci_bind_by_name($sent, ':fecha', $this->fecha);
         oci_bind_by_name($sent, ':monto', $this->monto);
         oci_bind_by_name($sent, ':descripcion', $this->descripcion);
         oci_bind_by_name($sent, ':vehiculo', $this->vehiculo);
         oci_bind_by_name($sent, ':tipo', $this->tipoMantenimiento);
         if (!oci_execute($sent)) {
             return false;
         }
         $data->free($sent);
         $data->close();
         return true;
     } else {
         return false;
     }
 }
Beispiel #24
0
 function getTransactionTags($count, $id)
 {
     $sql = new DataBase();
     $sql->connect();
     $sql->query("\r\n\t\tSELECT tag.*\r\n\t\tFROM tags tag, transactions_has_tags tht\r\n\t\tWHERE tht.transaction_id = '" . $id . "' AND tag.profile_id = " . CurrentUser::getId() . "\r\n\t\tAND tag.id = tht.tag_id\r\n\t\tLIMIT " . $count . "\r\n\t\t");
     //Objects
     $json = array();
     //Data
     while ($data = mysql_fetch_array($sql->result)) {
         $array = array("id" => $data["id"], "name" => $data["name"]);
         array_push($json, $array);
     }
     //Close connection
     $sql->close();
     //Return
     return $json;
 }
 private static function loginUser()
 {
     $db = new DataBase();
     $manager = new ManageUser($db);
     $user = Request::post("email");
     $pass = Request::post("pass");
     $usuario = $manager->get($user);
     $sesion = new Session();
     if ($usuario !== null && $usuario->getPass() === sha1($pass)) {
         $sesion->setUser($user);
         self::viewIndex();
     } else {
         $sesion->destroy();
         self::viewLogin("Login incorrecto");
     }
     $db->close();
 }