public function findSharedElements($idUser = NULL, $path = 'all', $options = array())
 {
     $criteria = array('state' => (int) 1);
     if ($idUser != NULL) {
         $criteria['idUser'] = new MongoId($idUser);
     }
     //récupération des droits sur les éléments
     $rightPdoManager = new RightPdoManager();
     $rights = $rightPdoManager->find($criteria);
     $sharedElements = array();
     //pour chaque droit
     if (is_array($rights) && !array_key_exists('error', $rights)) {
         foreach ($rights as $key => $right) {
             $owner = NULL;
             $refRight = NULL;
             //Récupération de l'élément
             $elementCriteria = array('_id' => new MongoId($right->getElement()), 'state' => (int) 1);
             if ($path != 'all') {
                 if (isset($options['recursivePath']) && $options['recursivePath'] == TRUE) {
                     $elementCriteria['serverPath'] = new MongoRegex("/^{$path}/i");
                 } else {
                     $elementCriteria['serverPath'] = $path;
                 }
             }
             $element = self::findOne($elementCriteria);
             if ($element instanceof Element) {
                 /*
                  * Nécessaire si on veut lier un right à un element. On le fait même dans le cas où le retour
                  * du right n'est pas demandé; afin de limiter les traitements du retour de cette fonction (ne pas
                  * avoir à distinguer un cas retour de listes d'objets et retour de liste de tableaux).
                  */
                 $element = self::dismount($element);
                 if (!in_array($element, $sharedElements)) {
                     if (!empty($options)) {
                         if (isset($options['returnUserInfo']) && $options['returnUserInfo'] == TRUE) {
                             $userPdoManager = new UserPdoManager();
                             $userFieldsToReturn = array('state' => TRUE, 'lastName' => TRUE, 'firstName' => TRUE, 'email' => TRUE);
                             $owner = $userPdoManager->findById($element['idOwner'], $userFieldsToReturn);
                             if (!array_key_exists('error', $owner)) {
                                 $element['idOwner'] = $owner;
                             }
                         }
                         if (isset($options['returnRefElementInfo']) && $options['returnRefElementInfo'] == TRUE) {
                             $refElementPdoManager = new RefElementPdoManager();
                             $refElement = $refElementPdoManager->findById($element['idRefElement']);
                             if (!array_key_exists('error', $refElement)) {
                                 $refElement = self::dismount($refElement);
                                 $element['idRefElement'] = $refElement;
                             }
                         }
                         if (isset($options['returnRefRightInfo']) && $options['returnRefRightInfo'] == TRUE) {
                             $options['returnRightInfo'] = TRUE;
                         }
                         if (isset($options['returnRightInfo']) && $options['returnRightInfo'] == TRUE) {
                             $element['right'] = self::dismount($right);
                         }
                         if (isset($options['returnRefRightInfo']) && $options['returnRefRightInfo'] == TRUE && isset($element['right'])) {
                             $refRightPdoManager = new RefRightPdoManager();
                             $refRight = $refRightPdoManager->findById($element['right']['idRefRight']);
                             if (!array_key_exists('error', $refRight)) {
                                 $refRight = self::dismount($refRight);
                                 $element['right']['idRefRight'] = $refRight;
                             }
                         }
                     }
                     $sharedElements[] = $element;
                 }
             }
         }
         if (empty($sharedElements)) {
             return array('error' => 'No match found.');
         }
     }
     return $sharedElements;
 }
Beispiel #2
0
/**
 * Recharger une session avec les nouvelles données en bdd
 */
function refreshUserSession()
{
    //Initialise nos objets
    $userPdoManager = new UserPdoManager();
    $accountPdoManager = new AccountPdoManager();
    $refPlanPdoManager = new RefPlanPdoManager();
    //Récupère l'utilisateur inscrit avec l'id indiquée.
    $id = array('state' => (int) 1, '_id' => unserialize($_SESSION['user'])->getId());
    $user = $userPdoManager->findOne($id);
    if ($user instanceof User) {
        //On récupère le compte correspondant à l'utilisateur
        $accountCriteria = array('_id' => new MongoId($user->getCurrentAccount()), 'state' => (int) 1);
        $account = $accountPdoManager->findOne($accountCriteria);
        if ($account instanceof Account) {
            $refPlan = $refPlanPdoManager->findById($account->getRefPlan());
            if ($refPlan instanceof RefPlan) {
                $account->setRefPlan($refPlan);
                $user->setCurrentAccount($account);
                $u = $_SESSION['user'] = serialize($user);
                //met les infos user en session
                return $u;
            } else {
                $errorInfo = 'RefPlan with ID ' . $account->getRefPlan() . ' not found';
                return array('error' => $errorInfo);
            }
        } else {
            $errorInfo = 'No active account with ID ' . $user->getCurrentAccount() . ' for user ' . $user->getId();
            return array('error' => $errorInfo);
        }
    } else {
        $errorInfo = 'No ACTIVE user found for the following e-mail: ' . $id . ' Maybe you didn\'t activate your account?';
        return array('error' => $errorInfo);
    }
}
Beispiel #3
0
/**
 * Created by PhpStorm.
 * User: Harry
 * Date: 05/06/14
 * Time: 12:36
 */
header('Content-Type: text/html; charset=utf-8');
$projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/Nestbox';
require_once $projectRoot . '/required.php';
if (isset($_SESSION['userId'])) {
    $userId = $_SESSION['userId'];
}
if (isset($_POST['var']) && !empty($_POST['var'])) {
    $elementManager = new ElementPdoManager();
    $refElementManager = new RefElementPdoManager();
    $userManager = new UserPdoManager();
    $refElementEmptyDirectory = $refElementManager->findOne(array('code' => '4002', 'state' => 1));
    if ($refElementEmptyDirectory instanceof RefElement) {
        $idRefElementEmptyDirectory = $refElementEmptyDirectory->getId();
    } else {
        return $refElementEmptyDirectory;
    }
    $refElementNotEmptyDirectory = $refElementManager->findOne(array('code' => '4003', 'state' => 1));
    if ($refElementNotEmptyDirectory instanceof RefElement) {
        $idRefElementNotEmptyDirectory = $refElementNotEmptyDirectory->getId();
    } else {
        return $refElementNotEmptyDirectory;
    }
    $element = $elementManager->findById($_GET['id']);
    $refElement = $refElementManager->findById($element->getRefElement());
    $user = $userManager->findById($element->getOwner());
Beispiel #4
0
 $lastname = $_POST['lastname'];
 $password = $_POST['password'];
 $email = $_POST['email'];
 $geo = $_POST['geo'];
 $startDate = strtotime($_POST['startDate']);
 $endDate = strtotime($_POST['endDate']);
 $plan = $_POST['plan'];
 var_dump($startDate);
 var_dump($endDate);
 if ($startDate == FALSE || $endDate == FALSE) {
     $message = 'Invalid date. It may be because you are not using the YYYY-MM-DD format or your date is after Tuesday, 19th January 2038, date that is not handled';
     $_SESSION['editUserInvalidMessage'] = $message;
     header('Location: ../pages/users.php');
     die;
 }
 $userManager = new UserPdoManager();
 $accountManager = new AccountPdoManager();
 $planManager = new RefPlanPdoManager();
 //    $sDate = $userManager->formatMongoDate($startDate);
 //    $eDate = $userManager->formatMongoDate($endDate);
 $account = $accountManager->findById($id);
 //récupère l'idAccount
 $user = $account->getUser();
 //récupère l'idUser
 $user = $userManager->findById($user);
 //récupère ensuite les infos user byId
 $criteriaAccount = array('_id' => new MongoId($account->getId()));
 $criteriaUser = array('_id' => new MongoId($user->getId()));
 $updateFieldAccount = array('$set' => array('startDate' => new MongoDate($startDate), 'endDate' => new MongoDate($endDate), 'idRefPlan' => new MongoId(_sanitize($plan)), 'state' => new MongoInt32(1)));
 $updateFieldUser = array('$set' => array('firstName' => _sanitize($firstname), 'lastName' => _sanitize($lastname), 'password' => _sanitize($password), 'email' => _sanitize($email), 'geo' => _sanitize($geo), 'state' => new MongoInt32(1)));
 $options = array('new' => true);
Beispiel #5
0
 * User: Ken
 * Date: 01/05/14
 * Time: 23:08
 */
session_start();
$projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/Cubbyhole';
require_once $projectRoot . '/controller/functions.php';
require_once $projectRoot . '/required.php';
$cryptinstall = $projectRoot . '/controller/crypt/cryptographp.fct.php';
include $cryptinstall;
$loginOK = false;
if (isset($_POST['resetPassword'])) {
    $email = $_POST['resetEmail'];
    if (!empty($email)) {
        if (chk_crypt($_POST['code'])) {
            $userPdoManager = new UserPdoManager();
            $result = $userPdoManager->sendResetPasswordRequest($email);
            //http://www.php.net/manual/en/function.array-key-exists.php
            if (!array_key_exists('error', $result)) {
                $loginOK = true;
                $_SESSION['validMessageReset'] = $loginOK;
                //reste sur la page
                header('Location:/Cubbyhole/view/reset.php');
                die;
            } else {
                $_SESSION['errorMessageReset'] = $result['error'];
                header('Location:/Cubbyhole/view/reset.php');
                die;
            }
        } else {
            $errorCaptcha = 'Error, invalid captcha';
Beispiel #6
0
<?php

/**
 * Created by PhpStorm.
 * User: Ken
 * Date: 10/06/14
 * Time: 15:02
 * Permet la désactivation d'un Plan
 */
$projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/OwlEyes';
require_once $projectRoot . '/required.php';
$id = $_GET['id'];
var_dump($id);
$accountManager = new AccountPdoManager();
$userManager = new UserPdoManager();
$account = $accountManager->findById($id);
$user = $accountManager->findById($id);
//Critère de recherche pour le compte
$criteriaAccount = array('_id' => new MongoId($account->getId()));
//Critère de recherche pour le user
$criteriaUser = array('_id' => new MongoId($account->getUser()));
$updateCriteria = array('$set' => array('state' => new MongoInt32(0)));
var_dump($criteriaUser);
var_dump($updateCriteria);
$disableUserAccount = $accountManager->findAndModify($criteriaAccount, $updateCriteria, NULL, array('new' => TRUE));
$disableUser = $userManager->findAndModify($criteriaUser, $updateCriteria, NULL, array('new' => TRUE));
header('Location: ../pages/users.php');
include $projectRoot . '/header/header.php';
?>

<link rel="stylesheet" href="../../content/css/bootstrap/bootstrap.min.css"  />
<link rel="stylesheet" href="../../content/css/compiled/bootstrap-overrides.css" type="text/css" />
<link rel="stylesheet" href="../../content/css/compiled/theme.css" type="text/css" />
<link rel="stylesheet" href="../../content/css/style.css" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Lato:300,400,700,900,300italic,400italic,700italic,900italic' rel='stylesheet' type='text/css' />
<link rel="stylesheet" href="../../content/css/compiled/sign-up.css" type="text/css" media="screen" />
</head>
<?php 
if (isset($_POST['resetPass'])) {
    if (isset($_GET['email']) && isset($_GET['token'])) {
        $projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/Cubbyhole';
        require $projectRoot . '/required.php';
        $userPdoManager = new UserPdoManager();
        //champs password et confirmation
        $password = $_POST['password'];
        $passwordConfirmation = $_POST['passwordConfirmation'];
        $result = $userPdoManager->validatePasswordReset($_GET['email'], $_GET['token'], $password, $passwordConfirmation);
        if (is_array($result) && isset($result['error'])) {
            $_SESSION['errorMessageReset'] = $result['error'];
        } else {
            $_SESSION['validMessageReset'] = $result;
        }
    }
}
//appel de la barre menu
include $projectRoot . '/header/menu.php';
?>
Beispiel #8
0
<?php

/**
 * Created by PhpStorm.
 * User: Ken
 * Date: 09/06/14
 * Time: 15:02
 */
include '../header/header.php';
$usersManager = new UserPdoManager();
$accountManager = new AccountPdoManager();
$planManager = new RefPlanPdoManager();
$allUsers = $usersManager->findAll();
include '../header/menu.php';
?>
    <!-- bootstrap 3.0.2 -->
    <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- font Awesome -->
    <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <!-- Ionicons -->
    <link href="../css/ionicons.min.css" rel="stylesheet" type="text/css" />
    <!-- DATA TABLES -->
    <link href="../css/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="../css/datatables/dataTables.tableTools.css" rel="stylesheet" type="text/css" />
    <!-- Theme style -->
    <link href="../css/AdminLTE.css" rel="stylesheet" type="text/css" />

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
Beispiel #9
0
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
//$payment_status = 'Canceled_Reversal';
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$payment_date = $_POST['payment_date'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$custom = explode('|', $_POST['custom']);
//parse du champ custom, pour l'instant idUser | idRefPlan
//récupère le prix du plan en bdd pour une vérification avec Paypal
$refPlan = new RefPlanPdoManager();
$paymentPdoManager = new PaymentPdoManager();
$accountPdoManager = new AccountPdoManager();
$userPdoManager = new UserPdoManager();
if (!$fp) {
} else {
    fputs($fp, $header . $req);
    while (!feof($fp)) {
        $res = fgets($fp, 1024);
        if (strcmp($res, "VERIFIED") == 0) {
            // vérifier que payment_status a la valeur Completed
            if ($payment_status == "Completed") {
                //Vérifie si le mail du marchant est == au mail du receveur
                if ($emailAccount == $receiver_email) {
                    $refPrice = $refPlan->findById($custom[1])->getPrice();
                    //Vérifie la somme en bdd et celle enregistré sur Paypal
                    if ($refPrice == $payment_amount) {
                        /*
                         * Insertion en bdd du plan acheté (state(1), idUser, prix , date, retour paypal
Beispiel #10
0
if (isset($_POST['add_user'])) {
    $name = $_POST['name'];
    $firstName = $_POST['firstName'];
    $email = $_POST['email'];
    $password = $_POST['password'];
    $passwordConfirmation = $_POST['passwordConfirmation'];
    if (!empty($_POST['geolocation'])) {
        $geolocation = $_POST['geolocation'];
    } else {
        $geolocation = 'Not specified';
    }
    //Verifie si le champ correspondant a "nom" n'est pas vide, meme chose pour "password"
    //S'il ne sont pas vide=> debut de la condition
    if (!empty($name) && $password == $passwordConfirmation) {
        if (chk_crypt($_POST['code'])) {
            $userPdoManager = new UserPdoManager();
            /*$result = $userPdoManager->register($name, $firstName, $email, $password, $passwordConfirmation, $geolocation);*/
            $result = $userPdoManager->register(_sanitize($name), _sanitize($firstName), _sanitize($email), _sanitize($password), _sanitize($passwordConfirmation), _sanitize($geolocation));
            //http://www.php.net/manual/en/function.array-key-exists.php
            if (!array_key_exists('error', $result)) {
                $registerOK = true;
                $_SESSION['validMessageRegister'] = $registerOK;
                //reste sur la page
                header('Location:/Cubbyhole/view/register.php');
            } else {
                $_SESSION['errorMessageRegister'] = $result['error'];
                header('Location:../view/register.php');
                die;
            }
        } else {
            $errorCaptcha = 'Error, invalid captcha';
Beispiel #11
0
        $("#confirmDisable").empty();
        $("#confirmDisable").append(submitModifyRight);
    }
</script>


<div id="utils_fancybox">
    <div id="imageClose">
        <img src="./content/img/icon_close_box.png" onclick="closeBoxAndReload();"/>
    </div>
</div>
<?php 
if (isset($_POST['var']) && !empty($_POST['var'])) {
    $elementManager = new ElementPdoManager();
    $refElementManager = new RefElementPdoManager();
    $userManager = new UserPdoManager();
    $refRightManager = new RefRightPdoManager();
    $rightManager = new RightPdoManager();
    $element = $elementManager->findById($_GET['id']);
    $refElement = $refElementManager->findById($element->getRefElement());
    $user = $userManager->findById($element->getOwner());
    $refRightList = $refRightManager->findAll();
    $rightCriteria = array('idElement' => $element->getId(), 'state' => 1);
    $usersSharedElementList = $rightManager->find($rightCriteria);
    if (is_array($usersSharedElementList) && !array_key_exists('error', $usersSharedElementList)) {
        ?>
        <form id="modifyShare" method="POST">
            <?php 
        echo '<p><label name="nameRename">List of users who you shared this element:</label></p>';
        echo '<input type="hidden" name="idElement" id="idElement" value="' . $_GET['id'] . '" read-only>';
        foreach ($usersSharedElementList as $userSharedElement) {
Beispiel #12
0
<?php

//appel la session
session_start();
//variable de session a false
$loginOK = false;
$projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/OwlEyes';
//require $projectRoot.'/controller/functions.php';
require $projectRoot . '/required.php';
//On check si loginForm est bien defini
//S'il est defini alors on entre dans la condition
if (isset($_POST['loginForm'])) {
    $email = $_POST['email'];
    $password = $_POST['password'];
    //Avant de se logger on verifie bien que les champs mail et password ne sont pas vide
    if (!empty($email) && !empty($password)) {
        $userPdoManager = new UserPdoManager();
        $criteria = array('email' => $email, 'password' => $userPdoManager->encrypt($password), 'isAdmin' => true);
        $user = $userPdoManager->findOne($criteria);
        var_dump($user);
        if (!array_key_exists('error', $user)) {
            $_SESSION['owleyesOK'] = serialize($user);
            //redirection vers index
            header('Location:../index.php');
        } else {
            $_SESSION['errorMessageLogin'] = $user['error'];
            header('Location:../pages/login.php');
            die;
        }
    }
}
 */
$projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/Cubbyhole';
include $projectRoot . '/header/header.php';
?>
    <link rel="stylesheet" href="../../content/css/bootstrap/bootstrap.min.css"  />
    <link rel="stylesheet" href="../../content/css/compiled/bootstrap-overrides.css" type="text/css" />
    <link rel="stylesheet" href="../../content/css/compiled/theme.css" type="text/css" />
    <link rel="stylesheet" href="../../content/css/style.css" type="text/css" />
    <link href='http://fonts.googleapis.com/css?family=Lato:300,400,700,900,300italic,400italic,700italic,900italic' rel='stylesheet' type='text/css' />
    <link rel="stylesheet" href="../../content/css/compiled/sign-up.css" type="text/css" media="screen" />
    </head>
<?php 
if (isset($_GET['email']) && isset($_GET['token'])) {
    $projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/Cubbyhole';
    require $projectRoot . '/required.php';
    $userPdoManager = new UserPdoManager();
    $result = $userPdoManager->validateRegistration($_GET['email'], $_GET['token']);
    if (is_array($result) && isset($result['error'])) {
        $_SESSION['errorMessage'] = $result['error'];
    } else {
        $_SESSION['validMessage'] = $result;
    }
}
//appel de la barre menu
include $projectRoot . '/header/menu.php';
?>

<div id="sign_up1"">
    <?php 
if (isset($_SESSION['errorMessage'])) {
    ?>
Beispiel #14
0
function shareWithAnonymous($idElement, $idOwner, $recipientEmail = '')
{
    $idElement = new MongoId($idElement);
    $idOwner = new MongoId($idOwner);
    $elementPdoManager = new ElementPdoManager();
    $elementCriteria = array('state' => (int) 1, '_id' => $idElement);
    $element = $elementPdoManager->findOne($elementCriteria);
    if ($element->getDownloadLink() == '') {
        /*
         * vérification que l'idOwner en param de la fonction est le même que celui de l'element, la gestion des partages
         * n'étant dans cette version qu'accessible au propriétaire de l'élément
         */
        if ($idOwner == $element->getOwner()) {
            //vérification que l'email indiquée appartient bien à un utilisateur inscrit
            $userCriteria = array('state' => (int) 1, 'email' => $recipientEmail);
            $userPdoManager = new UserPdoManager();
            $recipientUser = $userPdoManager->findOne($userCriteria);
            /*
             * Tentative de génération de lien de téléchargement anonyme pour un utilsateur existant.
             * L'interdire ici ne résoudra cependant que partiellement cet éventuel problème,
             * mais au moins on limite la permissivité.
             */
            if ($recipientUser instanceof User) {
                return array('error' => 'The email you entered belongs to one of our users, please use the \'share with a user\' functionality.');
            }
            $downloadLink = $elementPdoManager->generateGUID();
            $updateDownloadLink = array('$set' => array('downloadLink' => $downloadLink));
            $updateStatus = $elementPdoManager->update($elementCriteria, $updateDownloadLink);
            if (is_bool($updateStatus) && $updateStatus == TRUE) {
                return array('downloadLink' => $downloadLink);
            } else {
                return $updateStatus;
            }
        } else {
            return array('error' => 'You are not the owner of this element, you cannot share it.');
        }
    } else {
        return array('error', 'There is already a download link for this element.');
    }
}
Beispiel #15
0
 $firstname = $_POST['firstname'];
 $lastname = $_POST['lastname'];
 $password = $_POST['password'];
 $email = $_POST['email'];
 $geo = $_POST['geo'];
 $plan = $_POST['plan'];
 $state = $_POST['state'];
 if (isset($_POST['isAdmin'])) {
     $isAdmin = $_POST['isAdmin'];
     $isAdmin = true;
     var_dump($isAdmin);
 } else {
     $isAdmin = false;
     var_dump($isAdmin);
 }
 $userManager = new UserPdoManager();
 $accountManager = new AccountPdoManager();
 $planManager = new RefPlanPdoManager();
 //Verifie la disponibilité de l'adresse mail
 if ($userManager->checkEmailAvailability($email) != FALSE) {
     $accountId = new MongoId();
     $userId = new MongoId();
     //crypte le password
     $password = $userManager->encrypt($password);
     //@link http://www.php.net/manual/en/class.mongodate.php
     $time = time();
     $end = $time + 30 * 24 * 60 * 60;
     // + 30 jours
     //info compte
     $account = array('_id' => $accountId, 'state' => new MongoInt32($state), 'idUser' => $userId, 'idRefPlan' => new MongoId($plan), 'storage' => (int) 0, 'ratio' => (int) 0, 'startDate' => new MongoDate($time), 'endDate' => new MongoDate($end));
     $isAccountAdded = $accountManager->create($account);
Beispiel #16
0
<?php

/**
 * Created by PhpStorm.
 * User: Crocell
 * Date: 31/03/14
 * Time: 15:17
 */
$projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/Cubbyhole';
require $projectRoot . '/required.php';
$userPdoManager = new UserPdoManager();
echo 'Utilisation du find<br />';
echo '____Retourne uniquement le champ state';
$userFind = $userPdoManager->find(array('state' => 1), array('state' => 0));
var_dump($userFind);
echo '____Retourne en objet';
$userFind = $userPdoManager->find(array('state' => 1));
var_dump($userFind);
echo '----------------------------------------<br />';
echo 'Utilisation du findOne';
$userFindOne = $userPdoManager->findOne($userFind[0], array('_id'));
var_dump($userFindOne);
echo '____equivalent du findById';
$userFindOne = $userPdoManager->findOne(array('_id' => $userFind[0]->getId()));
var_dump($userFindOne);
echo '----------------------------------------<br />';
echo 'Utilisation du findById avec un MongoId en parametre';
$userFoundById = $userPdoManager->findById(new MongoId('53388c1d09413a282e00002a'));
var_dump($userFoundById);
echo 'Utilisation du findById avec une string en parametre';
$userFoundById = $userPdoManager->findById('53388c1d09413a282e00002a');
Beispiel #17
0
//variable de session a false
$loginOK = false;
$projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/Cubbyhole';
require $projectRoot . '/controller/functions.php';
require $projectRoot . '/required.php';
$cryptinstall = $projectRoot . '/controller/crypt/cryptographp.fct.php';
include $cryptinstall;
//On check si loginForm est bien defini
//S'il est defini alors on entre dans la condition
if (isset($_POST['loginForm'])) {
    if (chk_crypt($_POST['code'])) {
        $email = $_POST['email'];
        $password = $_POST['password'];
        //Avant de se logger on verifie bien que les champs mail et password ne sont pas vide
        if (!empty($email) && !empty($password)) {
            $userPdoManager = new UserPdoManager();
            $user = $userPdoManager->authenticate($email, $password);
            //http://www.php.net/manual/en/function.array-key-exists.php
            if (!array_key_exists('error', $user)) {
                $loginOK = TRUE;
                $_SESSION['user'] = serialize($user);
                //redirection vers index
                header('Location:../index.php');
            } else {
                $_SESSION['errorMessageLogin'] = $user['error'];
                header('Location:../view/login.php');
                die;
            }
        }
    } else {
        $errorCaptcha = 'Error, invalid captcha';
Beispiel #18
0
<?php

/**
 * Created by PhpStorm.
 * User: Ken
 * Date: 09/06/14
 * Time: 15:02
 */
include '../header/header.php';
if (isset($_GET['id'])) {
    $id = $_GET['id'];
}
$userManager = new UserPdoManager();
$planManager = new RefPlanPdoManager();
$accountManager = new AccountPdoManager();
$allplan = $planManager->findAll();
$account = $accountManager->findById($id);
//id account
$accountUser = $account->getUser();
//id user
$currentPlan = $planManager->findById($account->getRefPlan());
//id du plan
$user = $userManager->findById($accountUser);
//récupère la collection user via id
/*********************************/
$criteria2014 = array('idUser' => $accountUser, 'startDate' => array('$gt' => new MongoDate(strtotime("2014-01-01 00:00:00")), '$lte' => new MongoDate(strtotime("2014-12-30 23:59:59"))));
$filterDate = $accountManager->find($criteria2014);
//foreach($filterDate as $thisAccount)
//{
//
//    var_dump($thisAccount->getStorage());
Beispiel #19
0
<?php

/**
 * Created by PhpStorm.
 * User: Ken
 * Date: 12/06/14
 * Time: 09:53
 */
$projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/OwlEyes';
require_once $projectRoot . '/required.php';
session_start();
$userManager = new UserPdoManager();
$planManager = new RefPlanPdoManager();
$accountManager = new AccountPdoManager();
if (isset($_SESSION['owleyesOK'])) {
    $userSession = unserialize($_SESSION['owleyesOK']);
    $user = $userManager->findById($userSession->getId());
    //retrouve l'user connecté grâce à l'id en session
    $userAccount = $accountManager->findById($user->getCurrentAccount());
    //retrouve le compte user
    $userPlan = $planManager->findById($userAccount->getRefPlan());
    //retrouve le plan user
    $startDateArray = $accountManager->formatMongoDate($userAccount->getStartDate());
    $endDateArray = $accountManager->formatMongoDate($userAccount->getEndDate());
} else {
    header('Location:/OwlEyes/pages/login.php');
}
?>
<!DOCTYPE html>
<html>
    <head>
Beispiel #20
0
 */
session_start();
$projectRoot = $_SERVER['DOCUMENT_ROOT'] . '/Cubbyhole';
require_once $projectRoot . '/controller/functions.php';
require_once $projectRoot . '/required.php';
$cryptinstall = $projectRoot . '/controller/crypt/cryptographp.fct.php';
include $cryptinstall;
$OK = false;
if (isset($_POST['changePassword'])) {
    $email = $_POST['email'];
    $oldPass = $_POST['oldPassword'];
    $newPass = $_POST['newPassword'];
    $newPassConfirm = $_POST['newPasswordConfirmation'];
    if (!empty($email)) {
        if (chk_crypt($_POST['code'])) {
            $userPdoManager = new UserPdoManager();
            $result = $userPdoManager->changePassword($email, $oldPass, $newPass, $newPassConfirm);
            //http://www.php.net/manual/en/function.array-key-exists.php
            if (!array_key_exists('error', $result)) {
                $OK = true;
                $_SESSION['validMessageChange'] = $OK;
                //reste sur la page
                header('Location:/Cubbyhole/view/change.php');
                die;
            } else {
                $_SESSION['errorMessageChange'] = $result['error'];
                header('Location:/Cubbyhole/view/change.php');
                die;
            }
        } else {
            $errorCaptcha = 'Error, invalid captcha';