function addRepMessage($com, $id) { $Messagerie = new Messagerie(); $BD = new BD('messagerie'); $BD->update("luAuteur", 1, "idmessage", $id); $BD->update("luDestinataire", 1, "idmessage", $id); $BD->update("timestamp", time(), "idmessage", $id); $userMessage = $Messagerie->recupUser($_SESSION['iduser']); $message = $Messagerie->infoConvers($_GET['id']); $msg = '<div class="line3 frame white2"> <img class="avatar-com" src="' . $userMessage->avatar . '" alt="default"> <div class="inline-block vt-top"> <p class="line2"> <a class="txt-dec-none c-black1" href="index.php?page=profil&nom=' . $userMessage->pseudo . '"><strong>' . $userMessage->pseudo . '</strong></a> , le <i>' . date('d/m/y H:i', time()) . '</i> </p> <div class="line2"> <p>' . $com . '</p> </div> </div> </div><!-- .frame -->'; $fp = fopen(Config::$path['messagerie'] . $message->link . $message->idauteur . $message->iddestinataire . '.msg', "r+"); $contenu_message = ''; while (($buffer = fgets($fp, 4096)) !== false) { $contenu_message .= $buffer; } fwrite($fp, $msg); fclose($fp); }
function updateUser($pseudo, $nom, $prenom, $email) { $BD = new BD('user'); $BD->update('pseudo', $pseudo, 'iduser', $_SESSION['iduser']); $BD->update('nom', $nom, 'iduser', $_SESSION['iduser']); $BD->update('prenom', $prenom, 'iduser', $_SESSION['iduser']); $BD->update('mail', $email, 'iduser', $_SESSION['iduser']); }
function activation($Mail, $Tokens) { $BD = new BD("user"); $user = $BD->select("mail", $Mail); if ($user->tokens == $Tokens) { $BD->update("banni", 0, "iduser", $user->iduser); $BD->update("tokens", 0, "iduser", $user->iduser); return "ok"; } else { return "Validation impossible ..."; } }
function inscrit($Nom, $Prenom, $Age, $Sexe, $Pass, $Tel, $Mail, $Permis) { $BD = new BD("user"); $BD->addUser($Nom, $Prenom, $Age, $Sexe, $Pass, $Tel, $Mail, $Permis); $BD->update("banni", 1, "mail", $Mail); $token = uniqid(rand(), true); $token = sha1($token); $BD->update("tokens", $token, "mail", $Mail); $BD->update("avatar", "avatar/default.png", "mail", $Mail); $link = "http://62.210.110.24/S2go/dev/login.php?mail=" . $Mail . "&tok=" . $token; $mail = new mail($Mail, "Share2go : Validation de votre compte !", "Reservation", $link); }
function changepass($Mail, $Tokens, $Pass) { $BD = new BD("user"); $user = $BD->select("mail", $Mail); if ($user->tokens == $Tokens) { $Pass2 = sha1($Pass); $BD->update("mdp", $Pass2, "iduser", $user->iduser); $BD->update("tokens", NULL, "iduser", $user->iduser); return "ok"; } else { return "Changement impossible ..."; } }
function updateTrajet($Date, $villedep, $villearr, $hdep, $prix, $place, $nocig, $music, $bag, $bavar, $com, $idvehicule, $oldtrajet) { $BD = new BD('trajet'); if ($oldtrajet->Date != $Date) { $BD->update("date", $Date, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->villedep != $villedep) { $BD->update("villedep", $villedep, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->villearr != $villearr) { $BD->update("villearr", $villearr, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->heuredep != $hdep) { $BD->update("heuredep", $hdep, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->prix != $prix) { $BD->update("prix", $prix, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->nbplace != $place) { $BD->update("nbplace", $place, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->nonfumeur != $nocig) { $BD->update("nonfumeur", $nocig, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->musique != $music) { $BD->update("musique", $music, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->valise != $bag) { $BD->update("valise", $bag, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->bavar != $bavar) { $BD->update("bavar", $bavar, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->com != $com) { $BD->update("com", $com, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->valise != $bag) { $BD->update("valise", $bag, "idtrajet", $oldtrajet->idtrajet); } if ($oldtrajet->idvehicule != $idvehicule) { $BD->update("idvehicule", $idvehicule, "idtrajet", $oldtrajet->idtrajet); } }
<?php session_start(); ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); require_once '../../app/Config.class.php'; require_once '../../app/Bd.class.php'; header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: application/json'); $return = array(); extract($_GET); if (!isset($image) || !preg_match('/^http[s]?:\\/\\/[-a-zA-Z0-9_.]*\\/[-a-zA-Z0-9\\/_.]*\\.(jp[e]?g|png|gif)$/', $image)) { $return['error'] = "Url invalide"; } else { $img = get_headers($image, 1); if ($img['Content-Length'] > 356000) { $return['error'] = "Image trop lourde...300ko max"; } else { $BD = new BD('user'); $BD->update('avatar', $image, 'iduser', $_SESSION['iduser']); $return['url'] = $image; } } $_SESSION['avatar'] = $image; echo json_encode($return);
* Time: 10:47 */ include_once "first_all.php"; if (isset($_POST) && $_POST != "") { $bd = new BD(); $bd->start_transaction(); if ($_POST['id'] == 0) { $dados['status'] = "Ativo"; $bd->insert('produtos', $dados); $_POST['id'] = $bd->get("insert_id"); } //UPDATE - produtos $table = 'produtos'; $dados = array("nome_produto" => "'" . $_POST['nome_produto'] . "'", "detalhamento" => "'" . $_POST['detalhamento'] . "'", "cod_linha" => $_POST['linha'], "status" => "'" . $_POST['status'] . "'", "url" => "'" . $_POST['url'] . "'", "fios" => $_POST['fios'], "desconto" => "'" . $_POST['desconto'] . "'", "substituido" => $_POST['substituido_por']); $where = "codigo={$_POST['id']}"; $bd->update($table, $dados, $where); //DELETE - produto_aplicacao $table1 = "produto_aplicacao"; $where1 = "cod_produto={$_POST['id']}"; $bd->delete($table1, $where1); //INSERT - produto_aplicacao foreach (array_keys($_POST) as $k) { if (preg_match('/^aplicacao_/', $k)) { $dados2 = array("cod_produto" => $_POST['id'], "cod_aplicacao" => $_POST[$k]); $bd->insert($table1, $dados2); } } //DELETE - produto_veiculo $table2 = "produto_veiculo"; $str = ""; foreach (array_keys($_POST) as $k) {
<?php session_start(); ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); require_once '../../app/Config.class.php'; require_once '../../app/Bd.class.php'; extract($_GET); // recupération de l'item $BD = new BD('item'); $item = $BD->select('idiitem', $iditem); // ajout de l'item $BD->setUsedTable('equipement'); $BD->addItem($_SESSION['iduser'], $item->idiitem); //retrait de l'or $BD->setUsedTable('user'); $_SESSION['money'] -= $item->prix; $BD->update('money', $_SESSION['money'], 'iduser', $_SESSION['iduser']); echo json_encode($_SESSION['money']);
function putOffLine($iduser) { $BD = new BD('user'); $BD->update('online', 0, 'iduser', $iduser); }
<?php if (isset($_SESSION['login'])) { header('Location : index.php'); exit; } require_once Config::$path['model'] . 'login.php'; if (isset($_POST['login'])) { $BD = new BD('user'); if ($BD->isInDb("pseudo", $_POST['pseudo']) && (($User = $BD->select("pseudo", $_POST['pseudo'])) && $User->pass == sha1($_POST['password'])) && $User->rang != 0) { $BD->update("online", 1, "pseudo", $_POST['pseudo']); $iduser = $BD->select("pseudo", $_POST['pseudo']); $_SESSION['rang'] = $iduser->rang; $_SESSION['iduser'] = $iduser->iduser; $_SESSION['avatar'] = $iduser->avatar; $_SESSION['pseudo'] = htmlentities($_POST['pseudo']); $_SESSION['login'] = '******'; $_SESSION['msg'][0] = 'success'; $_SESSION['msg'][1] = "Vous êtes connecté !"; header('Location: index.php'); } else { echo "<div class='error'>Echec de connexion !!! </div>"; } } require_once Config::$path['views'] . 'login.php';
<?php /** * Created by PhpStorm. * User: rodrigo.martins * Date: 22/01/2016 * Time: 16:57 */ include_once "first_all.php"; $bd = new BD(); $bd->start_transaction(); $table = "aplicacao"; $dados = array(); $dados['ativo'] = "\"false\""; $where = "codigo=" . $_GET['codigo']; $bd->update($table, $dados, $where); $bd->record_log("log_login", 'delete_aplicacao', $_GET['codigo']); $bd->commit(); header('Location: ../pages/geral.php');
<?php include 'db.class.php'; $db = new BD(); //echo '<pre>',print_r($_REQUEST, 1),'</pre>'; $res = $db->update("UPDATE whiteliste SET \n\t\t\tcode = :code, \n\t\t\tdescription = :description \n\t\t\tWHERE id = :id", $_POST); header("Location:gererWhiteliste.php?whitelisteUpdate");
function updateCo($online, $Mail) { $BD = new BD("user"); $BD->update("online", $online, "mail", $Mail); }
foreach ($donnees as $value) { print_r($value); echo "</br>"; echo "{$value->nom}"; echo "</br>"; } /* Test Fonction addUser */ $BD->addUser("Jean", "test", 20, "homme", "testpass", 0750, "*****@*****.**"); echo "<h2>Test Fonction addUser </h2></br>"; $donnees = $BD->selectAll(); foreach ($donnees as $value) { print_r($value); echo "</br>"; } /* Test update */ $BD->update("nom", "Jeanne", "nom", "Jean"); echo "<h2>Test Fonction UPDATE </h2></br>"; $donnees = $BD->selectAll(); foreach ($donnees as $value) { print_r($value); echo "</br>"; echo "{$value->nom}"; echo "</br>"; } /* Test delete */ $BD->delete("nom", "Jeanne"); echo "<h2>Test Fonction DELETE </h2></br>"; $donnees = $BD->selectAll(); foreach ($donnees as $value) { print_r($value); echo "</br>";
<?php session_start(); ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); require_once '../../app/Config.class.php'; require_once '../../app/Bd.class.php'; extract($_GET); $BD = new BD('spaceship'); $spaceship = $BD->select('idspaceship', $idship); $BD->setUsedTable('vaisseau'); $BD->addVaisseau($spaceship->nom, $spaceship->desc, $spaceship->pv, $spaceship->attaque, $spaceship->defense, $spaceship->xp, $spaceship->nextlevel, $spaceship->type, $spaceship->image, $_SESSION['iduser']); $BD->setUsedTable('user'); $BD->update('rang', 1, 'iduser', $_SESSION['iduser']); $BD->setUsedTable('vaisseau'); $idvaisseau = $BD->select('iduser', $_SESSION['iduser']); $BD->setUsedTable('user'); $BD->update('idvaisseau', $idvaisseau->idvaisseau, 'iduser', $_SESSION['iduser']); $_SESSION['rang'] = 1;
<?php include 'db.class.php'; $db = new BD(); //echo '<pre>',print_r($_REQUEST, 1),'</pre>'; $res = $db->update('UPDATE user set pseudo = :pseudo, role = :role, pswd = :pswd WHERE id = :id', $_POST); header("Location:gererUser.php?userUpdate");
if ($_POST['id'] == 0) { $dados['logo'] = "../dist/img/representantes/padrao.png"; $bd->insert('representantes', $dados); $_POST['id'] = $bd->get("insert_id"); } //UPDATE - representantes $table = 'representantes'; $dados = $_POST; unset($dados['id']); foreach ($dados as $key => $value) { if ($key != 'linha') { $dados[$key] = "'" . $value . "'"; } } $where = "codigo={$_POST['id']}"; $bd->update($table, $dados, $where); $nome_input = "logo"; if (!empty($_FILES[$nome_input]['name'])) { $target_dir = "../dist/img/representantes/"; $file = $_FILES[$nome_input]["name"]; $name = basename($file, pathinfo($file, PATHINFO_EXTENSION)); $extension = pathinfo($file, PATHINFO_EXTENSION); $date = new DateTime(); $new_name = $name . "_" . $date->getTimestamp() . ".{$extension}"; $target_file = $target_dir . $new_name; $uploadOk = 1; $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); // Check if file already exists if (file_exists($target_file)) { echo "Desculpe, esse arquivo já existe."; $uploadOk = 0;
function validUser($Pseudo) { $BD = new BD('user'); $BD->update('rang', 1, 'pseudo', $Pseudo); }
$campos = array("id_persona" => $rs["id_persona"], "nombre" => $rs["pers_nombres"], "email" => $rs["pers_email"], "paterno" => $rs["pers_paterno"], "materno" => $rs["pers_materno"], "usuario" => $rs["usua_nombre_usuario"]); } } } catch (MyException $e) { $estado = "error"; $mensaje = $e->getMessage(); } $bd = NULL; $respuesta[] = array("estado" => $estado, "mensaje" => $mensaje, "campos" => $campos); } if ($accion == "update") { $bd = new BD(); try { $parametros = array("pers_nombres" => $nombre, "pers_paterno" => $apPaterno, "pers_materno" => $apMaterno, "pers_email" => $email, "pers_nombrecompleto" => $nombre . " " . $apPaterno . " " . $apMaterno); $condicion = array("id_persona" => $id_persona); $res = $bd->update(tablas::PERSONAS, $parametros, $condicion); if ($bd->myException->getEstado() == 0) { $estado = "ok"; $mensaje = "Usuario Actualizado Exitosamente"; } else { $estado = "error"; $mensaje = $bd->myException->getMensaje(); } } catch (MyException $ex) { $estado = "error"; $mensaje = $e->getMessage(); getMessage(); } $bd = NULL; $respuesta[] = array("estado" => $estado, "mensaje" => $mensaje); }
function changeUrl($id, $url) { $BD = new BD('user'); $BD->update('avatar', $url, 'iduser', $id); }
<?php session_start(); ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); require_once '../../app/Config.class.php'; require_once '../../app/Bd.class.php'; extract($_GET); // recupération du vaisseau $BD = new BD('spaceship'); $spaceship = $BD->select('idspaceship', $idship); // ajout du vaisseau $BD->setUsedTable('vaisseau'); $BD->addVaisseau($spaceship->nom, $spaceship->desc, $spaceship->pv, $spaceship->attaque, $spaceship->defense, $spaceship->xp, $spaceship->nextlevel, $spaceship->type, $spaceship->image, $_SESSION['iduser']); //retrait de l'or $BD->setUsedTable('user'); $_SESSION['money'] -= $spaceship->prix; $BD->update('money', $_SESSION['money'], 'iduser', $_SESSION['iduser']); // vaisseau définit comme vaisseau courant $BD->setUsedTable('vaisseau'); $idvaisseau = $BD->select('iduser', $_SESSION['iduser']); $BD->setUsedTable('user'); $BD->update('idvaisseau', $idvaisseau->idvaisseau, 'iduser', $_SESSION['iduser']); echo json_encode($_SESSION['money']);
<?php session_start(); ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); require_once '../../app/Config.class.php'; require_once '../../app/Bd.class.php'; extract($_GET); $levelUp = false; // on donne l'or recue en récompense $BD = new BD('user'); $user = $BD->select('iduser', $_SESSION['iduser']); $BD->update('points', $user->points + $points, 'iduser', $_SESSION['iduser']); //on définit le vaisseau utilisé comme vaisseau courant $BD->update('idvaisseau', $idvaisseau, 'iduser', $_SESSION['iduser']); $_SESSION['money'] += $money; $BD->update('money', $_SESSION['money'], 'iduser', $_SESSION['iduser']); // on ajoute la mission à la liste des missions effectuées $BD->setUsedTable('effectue'); // on test si la mission n'a pas déja été effectuée ? $nbFois = $BD->count2('iduser', $_SESSION['iduser'], 'idmission', $idmission); if ($nbFois == 0) { $BD->addEffectue($_SESSION['iduser'], $idmission); } // on met à jour l'xp du vaisseau $BD->setUsedTable('vaisseau'); $vaisseau = $BD->select('idvaisseau', $idvaisseau); $BD->update('xp', $vaisseau->xp + $xp, 'idvaisseau', $idvaisseau); $vaisseau = $BD->select('idvaisseau', $idvaisseau); // on verifie si le vaisseau à level up, si oui on augment ses stats de +5 atk, +2def, +20pv $newXp = $vaisseau->xp - $vaisseau->nextlevel;
<?php session_start(); ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); require_once '../../app/Config.class.php'; require_once '../../app/Bd.class.php'; extract($_GET); // on met a jour l'argent du joueur $BD = new BD('user'); $_SESSION['energie'] -= $energie; $BD->update('energie', $_SESSION['energie'], 'iduser', $_SESSION['iduser']); // on met la mission comme courante echo json_encode($_SESSION['energie']);
$da = date('Y-m-d', strtotime("-1 day", strtotime($d2))); } else { $da = date('Y-m-d', strtotime("+1 month", strtotime($da))); } } $dados_1['vencimento'] = $r; $dados_1['cod_contrato'] = $_POST['id']; $bd->insert($table_1, $dados_1); } } //UPDATE - fin_receber foreach (array_keys($_POST) as $k) { if (preg_match('/^data_baixa_/', $k)) { $dados_2 = array("data_baixa" => $_POST[$k], 'usuario_baixou' => $_SESSION['codigo']); $where_2 = "codigo =" . str_replace("data_baixa_", "", $k); $bd->update($table_1, $dados_2, $where_2); } if (preg_match('/^data_vencimento_/', $k)) { $dados_2 = array("vencimento" => $_POST[$k]); $where_2 = " codigo =" . str_replace("data_vencimento_", "", $k); $bd->update($table_1, $dados_2, $where_2); } if (preg_match('/^data_descricao_/', $k)) { $dados_2 = array("descricao" => $_POST[$k]); $where_2 = "codigo =" . str_replace("data_descricao_", "", $k); $bd->update($table_1, $dados_2, $where_2); } if (preg_match('/^data_valor_/', $k)) { $_POST[$k] = str_replace(".", "", $_POST[$k]); $_POST[$k] = str_replace(",", ".", $_POST[$k]); $dados_2 = array("valor" => $_POST[$k]);
<?php session_start(); ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); require_once '../../app/Config.class.php'; require_once '../../app/Bd.class.php'; $BD = new BD('connecté'); $BD->update('lastco', time(), 'iduser', $_SESSION['iduser']);
function updateEvent($nom, $type, $date, $heure, $localisation, $image, $jeux, $desc, $idevent) { $BD = new BD('event'); $BD->update('nom', $nom, 'idevent', $idevent); $BD->update('type', $type, 'idevent', $idevent); $date .= ' ' . $heure; $BD->update('date', $date, 'idevent', $idevent); $BD->update('localisation', $localisation, 'idevent', $idevent); $BD->update('image', $image, 'idevent', $idevent); $BD->update('idjeux', $jeux, 'idevent', $idevent); $BD->update('event.desc', $desc, 'idevent', $idevent); }
$d = array(); if (isset($_GET['action'])) { // si on a envoyé des données avec le formulaire /* * Envoi de message :) */ if ($_GET['action'] == 'send') { if (!empty($_GET['message'])) { // si les variables ne sont pas vides $message = htmlentities($_GET['message']); // on sécurise nos données // puis on entre les données en base de données : $BD = new BD('tchat'); $BD->addMessageInTchat($_SESSION['pseudo'], $_GET['message']); $BD->setUsedTable('user'); $BD->update("lastactivity", time(), "pseudo", $_SESSION['pseudo']); $d['erreur'] = 'ok'; } else { $d['erreur'] = "Vous avez oublié de remplir un des champs !"; } } /* * Recup des messages */ if ($_GET['action'] == 'recup') { extract($_GET); $lastid = floor($lastid); $BD = new BD('tchat'); $donnees = $BD->recupTchat($lastid); $d['result'] = ""; $d['lastid'] = $lastid;