Exemple #1
0
/**
 * Modification du profil utilisateur
 * @global type $tpl
 */
function index_profile()
{
    global $tpl, $srcdir, $pdo;
    $mdl = new Modele('users');
    $mdl->fetch($_SESSION['user']['user_id']);
    if (isset($_POST['edit'])) {
        $tpl->assign('hsuccess', $mdl->modFrom($_POST));
    }
    if (isset($_POST['editpass'])) {
        if ($_POST['pwd1'] == '' || $_POST['oldpass'] != md5($_SESSION['user']['user_pass'] . $_SESSION['random'])) {
            $tpl->assign('hsuccess', false);
        } else {
            $tpl->assign('hsuccess', $mdl->modFrom(array('user_pass' => $_POST['pwd1']), false));
        }
    }
    $mdt = new Modele('mandate');
    if ($mdt->find('`mandate_start` < now() and `mandate_end` > now()')) {
        while ($line = $mdt->next()) {
            $tpl->append('mandate', $line);
        }
    }
    $mdtu = $pdo->prepare('SELECT * FROM user_mandate LEFT JOIN mandate ON um_mandate = mandate_id WHERE um_user = ? ORDER BY `mandate_end` DESC');
    $mdtu->bindValue(1, $_SESSION['user']['user_id']);
    $mdtu->execute();
    while ($line = $mdtu->fetch()) {
        $tpl->append('usr_mandate', $line);
    }
    $_SESSION['random'] = md5(uniqid('epicenote'));
    $tpl->assign('random', $_SESSION['random']);
    $tpl->assign('isMember', hasAcl(ACL_USER));
    $tpl->assign('form', $mdl->edit());
    $mdl = new Modele('card');
    $mdl->find(array('card_user' => $_SESSION['user']['user_id']));
    $l = $mdl->next();
    if (!$l) {
        $tpl->assign('cards', false);
    }
    while ($l) {
        $o = new Modele('card');
        $o->fetch($mdl->card_id);
        $tpl->append('cards', $o);
        $l = $mdl->next();
    }
    //GoogleAuthentificator
    require_once $srcdir . '/libs/GoogleAuthenticator/GoogleAuthenticator.php';
    $api = new GoogleAuthenticator();
    $_SESSION['user']['GoogleAuthenticator'] = $api->generateSecret();
    $tpl->assign('GoogleAuth', $api);
    //FIN GoogleAuthentificator
    display();
}
Exemple #2
0
 public function generateSecret()
 {
     $g = new GoogleAuthenticator();
     $secret = $g->generateSecret();
     $this->data['secret'] = $secret;
     return $secret;
 }
Exemple #3
0
<?php

include_once "lib/GoogleAuthenticator.php";
$secret = 'XVQ2UIGO75XRUKJO';
$time = floor(time() / 30);
$code = "846474";
$g = new GoogleAuthenticator();
print "Current Code is: ";
print $g->getCode($secret);
print "\n";
print "Check if {$code} is valid: ";
if ($g->checkCode($secret, $code)) {
    print "YES \n";
} else {
    print "NO \n";
}
$secret = $g->generateSecret();
print "Get a new Secret: {$secret} \n";
print "The QR Code for this secret (to scan with the Google Authenticator App: \n";
print $g->getURL('chregu', 'example.org', $secret);
print "\n";
 /**
  * Generate 16 digit secret key
  */
 private function getSecretKey()
 {
     $g = new GoogleAuthenticator();
     return $g->generateSecret();
 }