Example #1
0
 public function __construct()
 {
     $this->view = ViewManager::getInstance();
     // get the current user and put it to the view
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     if (isset($_SESSION["currentuser"])) {
         $this->currentUser = new User(NULL, $_SESSION["currentuser"]);
         //add current user to the view, since some views require it
         $usermapper = new UserMapper();
         $this->tipo = $usermapper->buscarPorLogin($_SESSION["currentuser"]);
         /* print_r($this->tipo);
            die();*/
         $this->view->setVariable("tipo", $this->tipo);
         $this->view->setVariable("currentusername", $this->currentUser->getLogin());
     }
     if (isset($_SESSION["currentcod1"]) && isset($_SESSION["currentcod2"]) && isset($_SESSION["currentcod3"])) {
         $codigomapper1 = new CodigoMapper();
         $this->currentCod1 = $codigomapper1->buscarPinchoPorCodigo($_SESSION["currentcod1"]);
         $codigomapper2 = new CodigoMapper();
         $this->currentCod2 = $codigomapper2->buscarPinchoPorCodigo($_SESSION["currentcod2"]);
         $codigomapper3 = new CodigoMapper();
         $this->currentCod3 = $codigomapper3->buscarPinchoPorCodigo($_SESSION["currentcod3"]);
     }
 }
 public function create($login, $password)
 {
     $user = new User();
     $set = $user->setLogin($login);
     if ($set === true) {
         $set = $user->setPassword($password);
         if ($set === true) {
             $login = mysqli_real_escape_string($this->database, $user->getLogin());
             $password = mysqli_real_escape_string($this->database, $user->getHash());
             $query = "INSERT INTO user (login, password) VALUES ('" . $login . "', '" . $password . "')";
             $result = mysqli_query($this->database, $query);
             if ($result) {
                 $id = mysqli_insert_id($this->database);
                 if ($id) {
                     return $this->findById($id);
                 } else {
                     return "Erreur serveur.";
                 }
             } else {
                 return mysqli_error();
             }
         } else {
             return $set;
         }
     } else {
         return $set;
     }
 }
 public function formPreferences()
 {
     $user = new User($this->data->id);
     $this->data->title = $user->getLogin() . ' :: Preferences';
     $this->data->save = "@fnbr20/auth/user/savePreferences|formPreferences";
     $userLevel = $user->getUserLevel();
     if ($userLevel == 'BEGINNER') {
         $this->data->isBeginner = true;
         $this->data->idJunior = $user->getConfigData('fnbr20JuniorUser');
         $this->data->junior = $user->getUsersOfLevel('JUNIOR');
         mdump($this->data);
     }
     if ($userLevel == 'JUNIOR') {
         $this->data->isJunior = true;
         $this->data->idSenior = $user->getConfigData('fnbr20SeniorUser');
         $this->data->senior = $user->getUsersOfLevel('SENIOR');
         mdump($this->data);
     }
     if ($userLevel == 'SENIOR') {
         $this->data->isSenior = true;
         $this->data->idMaster = $user->getConfigData('fnbr20MasterUser');
         $this->data->master = $user->getUsersOfLevel('MASTER');
         mdump($this->data);
     }
     $this->data->userLevel = $userLevel;
     $this->render();
 }
Example #4
0
 public function checkPasswordUser(User $user)
 {
     $STH = $this->DBH->prepare("SELECT * FROM Users WHERE login=:login and password=:password ");
     $STH->bindValue(":login", $user->getLogin());
     $STH->bindValue(":password", $user->getPassword());
     $STH->execute();
     $STH->setFetchMode(PDO::FETCH_CLASS, 'user');
     return $STH->fetch();
 }
 public function getUserInfo(User $user)
 {
     if (!Config::exist('oss_url')) {
         return false;
     }
     if (Config::get('oss_url') == '') {
         return false;
     }
     $data = file_get_contents(Config::get('oss_url') . (strpos(Config::get('oss_url'), '?') > 0 ? '&' : '?') . 'mac=' . $user->getMac() . '&serial_number=' . $user->getSerialNumber() . '&type=' . $user->getStbType() . '&locale=' . $user->getLocale() . '&login=' . $user->getLogin() . '&portal=' . (empty($_SERVER['HTTP_HOST']) ? '' : $_SERVER['HTTP_HOST']) . '&verified=' . intval($user->isVerified()) . '&ip=' . $user->getIp());
     return $this->parseResult($data, Config::getSafe('strict_oss_url_check', true));
 }
Example #6
0
 public function auth(User $loginUser)
 {
     $imap = true;
     if (!$imap) {
         return FALSE;
     } else {
         if ($user = $this->db->fetchAssoc("SELECT p.id, p.heslo, p.meno, p.role, t.rocnik, t.kod, p.trieda_id FROM pouzivatelia AS p LEFT JOIN triedy AS t ON p.trieda_id = t.id WHERE p.login = ?", array($loginUser->getLogin()))) {
             return $user['heslo'] === md5($loginUser->getPassword()) ? $user : FALSE;
         } else {
             return FALSE;
         }
     }
 }
Example #7
0
 public function update(User $user)
 {
     $id = $user->getId();
     $login = $this->db->quote($user->getLogin());
     $password = $this->db->quote($user->getPassword());
     $email = $this->db->quote($user->getEmail());
     $avatar = $this->db->quote($user->getAvatar());
     $query = "UPDATE\t user \n\t\t\t\t\t\tSET \tlogin\t\t='" . $login . "', \n\t\t\t\t\t\t\t\tpassword\t='" . $password . "',\n\t\t\t\t\t\t\t\temail\t\t='" . $email . "', \n\t\t\t\t\t\t\t\tavatar\t\t='" . $avatar . "' \n\t\t\t\t\t\t\t\tWHERE id\t='" . $id . "'";
     $res = $this->db->exec($query);
     if ($res) {
         return $this->findById($id);
     } else {
         throw new Exception("Internal Server Error");
     }
 }
Example #8
0
 public function update(User $user)
 {
     $id = $user->getId();
     $login = mysqli_real_escape_string($this->db, $user->getLogin());
     $password = mysqli_real_escape_string($this->db, $user->getHash());
     $email = mysqli_real_escape_string($this->db, $user->getEmail());
     $avatar = mysqli_real_escape_string($this->db, $user->getAvatar());
     /*/!\*/
     $query = "UPDATE user SET login='" . $login . "', password='" . $password . "', email='" . $email . "', avatar='" . $avatar . "' WHERE id='" . $id . "'";
     $res = mysqli_query($this->db, $query);
     if ($res) {
         return $this->findById($id);
     } else {
         return "Internal Server Error";
     }
 }
Example #9
0
 public function editAction()
 {
     if ($this->_hasParam('id')) {
         $userId = $this->_getParam('id');
         if ($this->_request->isPost()) {
             if ($this->_request->getPost('user')) {
                 $this->changeUser($userId);
             }
             if ($this->_request->getPost('addPerm')) {
                 $this->addPermission($userId);
             }
             if ($this->_request->getPost('updatePerms')) {
                 $this->updatePermissions($userId);
             }
         }
         $user = new User($userId);
         $controllers = new ControllersHandler();
         $contList = $controllers->getControllersList($this->getSiteId());
         $permissions = $this->users->listUserPermissions($userId);
         foreach ($permissions as $perm) {
             if (isset($contList['list'][$perm['uc_controller_id']])) {
                 unset($contList['list'][$perm['uc_controller_id']]);
             }
         }
         foreach ($permissions as $key => $value) {
             if (strstr($value['uc_permission'], 'r')) {
                 $permissions[$key]['read'] = true;
             }
             if (strstr($value['uc_permission'], 'w')) {
                 $permissions[$key]['write'] = true;
             }
             if (strstr($value['uc_permission'], 'd')) {
                 $permissions[$key]['delete'] = true;
             }
         }
         $this->tplVars['users']['val']['login'] = $user->getLogin();
         $this->tplVars['users']['val']['group'] = $user->getGroupId();
         $this->tplVars['users']['groupsList'] = $this->users->listGroups();
         $this->tplVars['users']['controllers'] = $contList['list'];
         $this->tplVars['users']['permissions'] = $permissions;
         $this->tplVars['header']['actions']['names'][] = array('name' => 'edit', 'menu_name' => 'Edit User');
         array_push($this->viewIncludes, 'users/usersEdit.tpl');
         array_push($this->viewIncludes, 'users/usersPermissions.tpl');
     } else {
         $this->_redirect('/users/list/');
     }
 }
Example #10
0
 public function create($login, $email, $password, $avatar)
 {
     $user = new User($this->link);
     $user->setLogin($login);
     $user->setEmail($email);
     $user->setPassword($password);
     $user->setAvatar($avatar);
     $login = mysqli_real_escape_string($this->link, $user->getLogin());
     $email = mysqli_real_escape_string($this->link, $user->getEmail());
     $password = mysqli_real_escape_string($this->link, $user->getPassword());
     $avatar = mysqli_real_escape_string($this->link, $user->getAvatar());
     $request = "INSERT INTO user VALUES(NULL, '" . $login . "', '" . $email . "', '" . $password . "', '" . $avatar . "','')";
     $res = mysqli_query($this->link, $request);
     if ($res) {
         return $this->select(mysqli_insert_id($this->link));
     } else {
         throw new Exception("Internal server error");
     }
 }
 public function update(User $user)
 {
     $id = $user->getId();
     // $login = mysqli_real_escape_string($this->db, $user->getLogin());
     $login = $this->db->quote($user->getLogin());
     // $password = mysqli_real_escape_string($this->db, $user->getHash());
     $password = $this->db->quote($user->getHash());
     // $email = mysqli_real_escape_string($this->db, $user->getEmail());
     $email = $this->db->quote($user->getEmail());
     // $name = mysqli_real_escape_string($this->db, $user->getName());
     $name = $this->db->quote($user->getName());
     // $surname = mysqli_real_escape_string($this->db, $user->getSurname());
     $surname = $this->db->quote($user->getSurname());
     $date_birth = $user->getDateBirth();
     $query = "UPDATE user SET login=" . $login . ", password=" . $password . ", email=" . $email . ", name=" . $name . ", surname=" . $surname . ", date_birth=" . $date_birth . " WHERE id=" . $id . "";
     // $res = mysqli_query($this->db, $query);
     $res = $this->db->exec($query);
     if ($res) {
         return $this->findById($id);
     } else {
         return "Internal Server Error";
     }
 }
Example #12
0
 public function set($stanza, $parent = false)
 {
     if ($stanza->body || $stanza->subject) {
         $jid = explode('/', (string) $stanza->attributes()->from);
         $to = current(explode('/', (string) $stanza->attributes()->to));
         // This is not very beautiful
         $user = new \User();
         $this->session = $user->getLogin();
         $this->jidto = $to;
         $this->jidfrom = $jid[0];
         if (isset($jid[1])) {
             $this->resource = $jid[1];
         }
         $this->type = 'chat';
         if ($stanza->attributes()->type) {
             $this->type = (string) $stanza->attributes()->type;
         }
         $this->body = (string) $stanza->body;
         $this->subject = (string) $stanza->subject;
         $images = (bool) ($this->type == 'chat');
         /*if($stanza->html) {
               $this->html = \cleanHTMLTags($stanza->html->body->asXML());
               $this->html = \fixSelfClosing($this->html);
               $this->html = \prepareString($this->html, false, $images);
           } else {*/
         $this->html = \prepareString($this->body, false, $images);
         //}
         if ($stanza->delay) {
             $this->published = gmdate('Y-m-d H:i:s', strtotime($stanza->delay->attributes()->stamp));
         } elseif ($parent && $parent->delay) {
             $this->published = gmdate('Y-m-d H:i:s', strtotime($parent->delay->attributes()->stamp));
         } else {
             $this->published = gmdate('Y-m-d H:i:s');
         }
         $this->delivered = gmdate('Y-m-d H:i:s');
     }
 }
 /**
  * 
  * @param User $user
  * @return int id of the User inserted in base. False if it didn't work.
  */
 public static function flush($user)
 {
     $userId = $user->getId();
     $login = $user->getLogin();
     $password = $user->getPassword();
     $mail = $user->getMail();
     $inscriptionDate = $user->getInscriptionDate();
     $firstName = $user->getFirstName();
     $lastName = $user->getLastName();
     $birthDate = $user->getBirthDate();
     $address = $user->getAddress();
     $phoneNumber = $user->getPhoneNumber();
     $avatar = $user->getAvatar();
     $role = $user->getRole()->getId();
     if ($userId > 0) {
         $sql = 'UPDATE user u SET ' . 'u.login = ?, ' . 'u.passwd = ?, ' . 'u.mail = ?, ' . 'u.inscription_date = ?, ' . 'u.first_name = ?, ' . 'u.last_name = ?, ' . 'u.birth_date = ?, ' . 'u.address = ?, ' . 'u.phone_number = ?, ' . 'u.avatar = ?, ' . 'u.ROLE_id_role = ? ' . 'WHERE u.id_user = ?';
         $params = array('ssssssssssii', &$login, &$password, &$mail, &$inscriptionDate, &$firstName, &$lastName, &$birthDate, &$address, &$phoneNumber, &$avatar, &$role, &$userId);
     } else {
         $sql = 'INSERT INTO user ' . '(login, passwd, mail, inscription_date, first_name, ' . 'last_name, birth_date, address, phone_number, avatar, ROLE_id_role) ' . 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
         $params = array('ssssssssssi', &$login, &$password, &$mail, &$inscriptionDate, &$firstName, &$lastName, &$birthDate, &$address, &$phoneNumber, &$avatar, &$role);
     }
     $idInsert = BaseSingleton::insertOrEdit($sql, $params);
     if ($idInsert !== false && $userId > 0) {
         $idInsert = $userId;
     }
     return $idInsert;
 }
Example #14
0
 /**
  * Créer la Popup d'édition d'un utilisateur
  * @param User $p_oUser Utilisateur concerné
  * @param \Rank $p_aRanks Rangs possibles
  * @return string Code HTML de la PopUp
  */
 private function createEditPopup($p_oUser, $p_aRanks)
 {
     //Création de la popup d'édition
     $oPopup = new View('popup');
     $oPopup->addData('id', $p_oUser->getId());
     $oPopup->addData('buttonstyle', 'btn-primary');
     $oPopup->addData('buttonicon', 'fa-edit');
     $oPopup->addData('buttontext', 'Editer');
     $oPopup->addData('title', 'Edition de l\'utilisateur');
     //Création du formulaire
     $oFormEdit = new FormGenerator();
     $oFormEdit->setAction('index.php?p=adminusers&edit=' . $p_oUser->getId());
     $oFormEdit->addInput('Identifiant', 'login', true, false, 'text', '', $p_oUser->getLogin());
     $oFormEdit->addInput('Password', 'password', false, false, 'password', 'Non modifié');
     $oFormEdit->addInput('Confirmation', 'confirmation', false, false, 'password', 'Non modifié');
     $oFormEdit->addInput('Email', 'mail', true, false, 'text', '', $p_oUser->getMail());
     $oFormEdit->addSelect('Rang', 'rank', $p_aRanks, $p_oUser->getIdRank());
     $oFormEdit->addCheckbox('Supprimer', 'delete');
     $oFormEdit->create();
     $oPopup->addData('content', $oFormEdit->getCode());
     $oPopup->create();
     return $oPopup->getCode();
 }
Example #15
0
 /**
  * @test
  * @testdox Try update user
  */
 public function update()
 {
     $login = 'UpdateLogin';
     $pass = 'UpdatePassword';
     $this->setModelAttributes();
     $id = $this->model->save();
     $this->model->setId($id);
     $this->model->setLogin($login);
     $this->model->setPassword($pass);
     $this->model->update();
     $retrieved = new User($this->pdo);
     $retrieved->setLogin($login);
     $retrieved->setPassword($pass);
     $retrieved->retrieveByCredential();
     $this->assertEquals($this->model->getLogin(), $retrieved->getLogin(), 'Could not update login');
     $this->assertEquals($this->model->getPassword(), $retrieved->getPassword(), 'Could not update password');
 }
 /**
  * Making User activation hash.
  * @param User $user
  * @return string
  */
 private function makeActivationHash(User $user)
 {
     return HashGenerator::generateMD5($user->getLogin() . $user->getEmail() . $user->getPassword());
 }
Example #17
0
<?php

require_once 'classes/User.php';
$user = new User();
$login = $user->isLoggedIn() ? $user->getLogin() : "";
?>

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>

    <title>gpsHub: Sign In</title>

    <script src="resources/js/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="resources/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="resources/js/sha256.js"></script>
    <script src="resources/js/user.js" type="text/javascript"></script>

    <link rel="StyleSheet" type="text/css" href="resources/css/bootstrap.min.css">
    <link rel="StyleSheet" type="text/css" href="resources/css/main.css">

    <style>
        body {
            background: url(resources/images/bg.jpg) no-repeat center center fixed;
            -webkit-background-size: cover;
            -moz-background-size: cover;
            -o-background-size: cover;
            background-size: cover;
        }
Example #18
0
 /**
  * bool insert(User $user)
  *
  * Inserts a new application user access into the database.
  *
  * @param User $user application user data
  * @return boolean returns false, if error occurs
  * @access public
  */
 function insert($user)
 {
     $sql = "INSERT INTO " . $this->_table;
     $sql .= " (id_user, login, access_date, id_profile) VALUES (";
     $sql .= $user->getIdUser() . ", ";
     $sql .= "'" . urlencode($user->getLogin()) . "', ";
     $sql .= "NOW(), ";
     $sql .= $user->getIdProfile() . ");";
     return $this->exec($sql);
 }
Example #19
0
 public function isMine()
 {
     $user = new \User();
     if ($this->aid == $user->getLogin() || $this->origin == $user->getLogin()) {
         return true;
     } else {
         return false;
     }
 }
Example #20
0
    include_once "../auth/login_check.php";
    loginCheck(OPEN_PROFILE_ADMINISTRATOR);
}
/**
 * Validate data
 */
require_once "../model/Query/User.php";
$user = new User();
$user->setIdUser($_POST["id_user"]);
require_once "../admin/user_validate_post.php";
/**
 * Update user
 */
$userQ = new Query_User();
if ($userQ->existLogin($user->getLogin(), $user->getIdMember())) {
    $loginUsed = true;
    FlashMsg::add(sprintf(_("Login, %s, already exists. The changes have no effect."), $user->getLogin()), OPEN_MSG_WARNING);
} else {
    $userQ->update($user);
    FlashMsg::add(sprintf(_("User, %s, has been updated."), $user->getLogin()));
    /**
     * updating session variables if user is current user
     */
    if (isset($_POST["all"])) {
        $_SESSION['auth']['login_session'] = $user->getLogin();
        $_SESSION['auth']['user_theme'] = $user->getIdTheme();
    }
}
if ($changePwd && !$loginUsed) {
    if (!$userQ->verifySignOn($_POST["login"], $_POST["md5_old"], true)) {
        $userQ->close();
Example #21
0
File: rss.php Project: Jatax/TKS
    ini_set('display_errors', 0);
}
// Fusion des paramètres GET et POST de la requête
$oRequest = new Request(array_merge($_GET, $_POST));
//On récupère le Passkey
if ($oRequest->existParam('pk')) {
    $sPasskey = $oRequest->getParam('pk', 'string');
} else {
    die;
}
//Création de l'utilisateur à partir du Passkey
$oCurrentUser = new User();
$oCurrentUser->loadFromPasskey($sPasskey);
//On vérifie les droits d'accès
if (!$oCurrentUser->checkAccess('rss')) {
    echo $oCurrentUser->getLogin() . "Vous n'aves pas les droits.";
    die;
}
//On regarde si on a demandé un flux en particulier
if ($oRequest->existParam('cat')) {
    if ($oRequest->getParam('cat', 'string') == 'autoget') {
        $bAutoget = true;
    } else {
        $iCat = $oRequest->getParam('cat', 'int');
        $bAutoget = false;
    }
} else {
    $iCat = 0;
    $bAutoget = false;
}
//Création du fichier RSS
Example #22
0
 private function __construct()
 {
     // Saving the user's login.
     $user = new User();
     $this->login = $user->getLogin();
 }
Example #23
0
<?php

$user_id = '3';
$u = new User();
$u->load($user_id);
$rolle = $u->getRole();
//html::showAll($rolle);
$vname = $rolle->getVorname();
$nname = $rolle->getNachname();
$geburtstag_db = $u->getGeburtstag();
$nick = $u->getLogin();
$email = $u->getEmail();
$beschreibung = $rolle->getBeschreibung();
$klasse_id = $rolle->getKlasse_Id();
$k = new Klasse();
$k->load($klasse_id);
$klasse = $k->getName();
//Umwandlung der DB-Schreibweise in die EU-Schreibweise
$geburtstag = html::buildDateFromMysql($geburtstag_db);
//Errechung des Alters
$alter = html::buildDateToAge($geburtstag);
?>

<html>
<head>
<title>Profil &auml;ndern</title>
</head>
<body>
	<form method="post" action="index.phpaction=save&what=edituser">
    <input type="hidden" name="user_id" value="<?php 
echo $user_id;
Example #24
0
 /**
  *
  * @return Message
  */
 public function postMessage(User $objRecipient, $strContent)
 {
     $strContent = trim($strContent);
     if ($objRecipient->isBanned() || $objRecipient->getId() == $this->getId()) {
         throw new Exception('Can\'t send message to ' . $objRecipient->getLogin());
     }
     if (empty($strContent)) {
         throw new Exception('Can\'t send empty message to ' . $objRecipient->getLogin());
     }
     $objMessage = new Message(['sender_id' => $this->getId(), 'recipient_id' => $objRecipient->getId(), 'unread' => 1, 'message' => $strContent]);
     $objMessage->save();
     return $objMessage;
 }
Example #25
0
 public function set($stanza, $parent = false)
 {
     if ($stanza->body || $stanza->subject) {
         $jid = explode('/', (string) $stanza->attributes()->from);
         $to = current(explode('/', (string) $stanza->attributes()->to));
         if (isset($stanza->attributes()->id)) {
             $this->id = (string) $stanza->attributes()->id;
         }
         // This is not very beautiful
         $user = new \User();
         $this->session = $user->getLogin();
         $this->jidto = $to;
         $this->jidfrom = $jid[0];
         if (isset($jid[1])) {
             $this->__set('resource', $jid[1]);
         }
         $this->type = 'chat';
         if ($stanza->attributes()->type) {
             $this->type = (string) $stanza->attributes()->type;
         }
         if ($stanza->body) {
             $this->__set('body', (string) $stanza->body);
         }
         if ($stanza->subject) {
             $this->__set('subject', (string) $stanza->subject);
         }
         if ($stanza->html) {
             $xml = \simplexml_load_string((string) $stanza->html->body);
             if ($xml) {
                 $results = $xml->xpath('//img/@src');
                 if (is_array($results) && !empty($results)) {
                     if (substr((string) $results[0], 0, 10) == 'data:image') {
                         $str = explode('base64,', $results[0]);
                         if (isset($str[1])) {
                             $p = new \Picture();
                             $p->fromBase(urldecode($str[1]));
                             $key = sha1(urldecode($str[1]));
                             $p->set($key, 'png');
                             $this->sticker = $key;
                         }
                     } else {
                         $this->sticker = getCid((string) $results[0]);
                     }
                 }
             }
         }
         if ($stanza->replace) {
             $this->newid = $this->id;
             $this->id = (string) $stanza->replace->attributes()->id;
             $this->edited = true;
         }
         if ($stanza->delay) {
             $this->published = gmdate('Y-m-d H:i:s', strtotime($stanza->delay->attributes()->stamp));
         } elseif ($parent && $parent->delay) {
             $this->published = gmdate('Y-m-d H:i:s', strtotime($parent->delay->attributes()->stamp));
         } else {
             $this->published = gmdate('Y-m-d H:i:s');
         }
         $this->checkPicture();
     }
 }
Example #26
0
 public function isMine()
 {
     $user = new \User();
     return $this->aid == $user->getLogin() || $this->origin == $user->getLogin();
 }
Example #27
0
 public function insert(User $O_user)
 {
     if (!is_null($O_user->getLogin() && $O_user->getPassword() && $O_user->getProfileId() && $O_user->getPerPage())) {
         $S_login = $O_user->getLogin();
         $S_password = $O_user->getPassword();
         $I_operator_id = $O_user->getOperatorId();
         $I_inspector_id = $O_user->getInspectorId();
         $I_profile_id = $O_user->getProfileId();
         $S_sql = 'INSERT INTO user (login, password, operator_id, inspector_id, profile_id) VALUES (?, ?, ?, ?, ?)';
         $A_params = array($S_login, $S_password, $I_operator_id, $I_inspector_id, $I_profile_id);
         $O_connection = new Connection();
         if ($I_userId = $O_connection->requestDb($S_sql, $A_params)) {
             return $I_userId;
         } else {
             throw new Exception("Des informations obligatoires sont manquantes, nous ne pouvons pas créer l'utilisateur");
         }
     }
 }
Example #28
0
 private function startingSession()
 {
     $s = \Sessionx::start();
     $s->load();
     $user = new User();
     $db = modl\Modl::getInstance();
     $db->setUser($user->getLogin());
 }
Example #29
0
 /**
  * Constructor of class Handler.
  *
  * @return void
  */
 public static function handle($child)
 {
     $_instances = 'empty';
     $user = new \User();
     $db = \Modl\Modl::getInstance();
     $db->setUser($user->getLogin());
     $id = '';
     $element = '';
     // Id verification in the returned stanza
     if (in_array($child->getName(), array('iq', 'presence', 'message'))) {
         $id = (string) $child->attributes()->id;
     }
     $sess = \Session::start();
     if ($id != '' && $sess->get($id) == false || $id == '') {
         Utils::log("Handler : Memory instance not found for {$id}");
         Utils::log('Handler : Not an XMPP ACK');
         Handler::handleNode($child);
         foreach ($child->children() as $s1) {
             Handler::handleNode($s1, $child);
             foreach ($s1->children() as $s2) {
                 Handler::handleNode($s2, $child);
             }
         }
     } elseif ($id != '' && $sess->get($id) != false) {
         // We search an existent instance
         Utils::log("Handler : Memory instance found for {$id}");
         $instance = $sess->get($id);
         $action = unserialize($instance->object);
         $error = false;
         // Handle specific query error
         if ($child->query->error) {
             $error = $child->query->error;
         } elseif ($child->error) {
             $error = $child->error;
         }
         // XMPP returned an error
         if ($error) {
             $errors = $error->children();
             $errorid = Handler::formatError($errors->getName());
             $message = false;
             if ($error->text) {
                 $message = (string) $error->text;
             }
             Utils::log('Handler : ' . get_class($action) . ' ' . $id . ' - ' . $errorid);
             /* If the action has defined a special handler
              * for this error
              */
             if (method_exists($action, $errorid)) {
                 $action->method($errorid);
                 $action->{$errorid}($errorid, $message);
             }
             // We also call a global error handler
             if (method_exists($action, 'error')) {
                 Utils::log('Handler : Global error - ' . $id . ' - ' . $errorid);
                 $action->method('error');
                 $action->error($errorid, $message);
             }
         } else {
             // We launch the object handle
             $action->method('handle');
             $action->handle($child);
         }
         // We clean the object from the cache
         $sess->remove($id);
     }
 }
 public function modify(User $user)
 {
     $sql = "UPDATE utilisateur\n\t\t\tSET login = :login,\n\t\t\tpwd = :pwd,\n\t\t\tnom = :nom,\n\t\t\tprenom = :prenom,\n\t\t\tadresse = :adresse\n\t\t\tWHERE idUtilisateur = :idUtilisateur";
     $id = $user->getIdUtilisateur();
     $log = $user->getLogin();
     $password = $user->getPwd();
     $name = $user->getNom();
     $surname = $user->getPrenom();
     $adress = $user->getAdresse();
     $req = $this->_db->prepare($sql);
     $req->bindParam(':idUtilisateur', $id, PDO::PARAM_STR);
     $req->bindParam(':login', $log, PDO::PARAM_STR);
     $req->bindParam(':pwd', $password, PDO::PARAM_STR);
     $req->bindParam(':nom', $name, PDO::PARAM_STR);
     $req->bindParam(':prenom', $surname, PDO::PARAM_STR);
     $req->bindParam(':adresse', $adress, PDO::PARAM_STR);
     $req->execute();
     $nbTupleObt = $req->rowCount();
     $req->closeCursor();
     if ($nbTupleObt < 1) {
         return false;
     }
     return true;
 }