예제 #1
0
#$pdo = Db::singleton();
$mysiteURL = $app->option('site.url');
//      Conditions      --------------------------------------------------------------------------------------------
$app->condition('signed_in', function () use($app) {
    $app->redirect($app->getBaseUri() . '/login', !$app->store('user'));
});
//      Login   --------------------------------------------------------------------------------------------
$app->get('/login', function () use($app) {
    $app->render('login', array(), 'layout');
});
$app->post('/login', function () use($app) {
    $sql = "SELECT * FROM `user` WHERE `email`='{$_POST['user']}' AND `password`='{$_POST['pass']}'";
    $pdo = Db::singleton();
    $res = $pdo->query($sql);
    $user = $res->fetch();
    if (isset($user['ID'])) {
        $app->store('user', $user['ID']);
        $app->redirect($app->getBaseUri() . '/home');
    } else {
        $app->redirect($app->getBaseUri() . '/login');
    }
});
$app->get('/signup', function () use($app) {
    $app->render('register', array(), 'layout');
});
$app->post('/signup', function () use($app) {
    $client = new Services_Twilio($app->option('twilio.accountsid'), $app->option('twilio.authtoken'));
    extract($_POST);
    $timestamp = strtotime($timestamp);
    $subaccount = $client->accounts->create(array("FriendlyName" => $email));
    $sid = $subaccount->sid;
    $token = $subaccount->auth_token;
예제 #2
0
#$pdo = Db::singleton();
$mysiteURL = $app->option('site.url');
//      Conditions      --------------------------------------------------------------------------------------------
$app->condition('signed_in', function () use($app) {
    $app->redirect($app->getBaseUri() . '/login', !$app->store('user'));
});
//      Login   --------------------------------------------------------------------------------------------
$app->get('/login', function () use($app) {
    $app->render('login', array(), 'layout');
});
$app->post('/login', function () use($app) {
    $sql = "SELECT * FROM `user` WHERE `email`='{$_POST['user']}' AND `password`='{$_POST['pass']}'";
    $pdo = Db::singleton();
    $res = $pdo->query($sql);
    $user = $res->fetch();
    if (isset($user['ID'])) {
        $app->store('user', $user['ID']);
        $app->redirect($app->getBaseUri() . '/home');
    } else {
        $app->redirect($app->getBaseUri() . '/login');
    }
});
$app->get('/signup', function () use($app) {
    $app->render('register', array(), 'layout');
});
$app->post('/signup', function () use($app) {
    $client = new Services_Twilio($app->option('twilio.accountsid'), $app->option('twilio.authtoken'));
    extract($_POST);
    $timestamp = strtotime($timestamp);
    $subaccount = $client->accounts->create(array("FriendlyName" => $email));
    $sid = $subaccount->sid;
    $token = $subaccount->auth_token;