예제 #1
0
$dsn = $dbmethod . $dbname;
$pdo = new PDO($dsn, $dbuser, $dbpass);
$db = new NotORM($pdo);
// Home Route
$app->get('/', function () use($app) {
    $app->response->setStatus(200);
    $app->render('../templates/homepage.html');
});
// Register a user
$app->post('/register', function () use($app, $db) {
    $app->response()->header('Content-Type', 'application/json');
    $name = $app->request()->post('name');
    $email = $app->request()->post('email');
    $password = $app->request()->post('password');
    $passwordEncryption = md5($password);
    if ($email === $db->users()->where('email', $email)->fetch('email')) {
        echo json_encode(['message' => 'That email address is already in use. Please use another email address']);
    } else {
        $user = ['name' => "{$name}", 'email' => "{$email}", 'password' => "{$passwordEncryption}"];
        $result = $db->users->insert($user);
        $users = array();
        foreach ($db->users() as $user) {
            $users[] = array('id' => $user['id'], 'name' => $user['name'], 'email' => $user['email']);
        }
        echo json_encode($users, JSON_FORCE_OBJECT);
    }
});
// Login a user
$app->post('/login', function () use($app, $db) {
    $email = $app->request->post('email');
    $password = $app->request->post('password');
예제 #2
0
파일: slim.php 프로젝트: ssolanki/website1
$app = new \Slim\Slim();
/**********************************  USER LOGIN SIGNUP CHECKING ******************************/
$authenticate = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['user'])) {
            $app->redirect('/login.html');
        }
    };
};
session_start();
$app->post("/auth/process", function () use($app, $db) {
    $array = (array) json_decode($app->request()->getBody());
    //    print_r($array);
    $email = $array['email'];
    $pwd = md5($array['pwd']);
    $user = $db->users()->where('user_email', $email)->where('user_password', $pwd);
    $count = count($user);
    if ($count == 1) {
        $_SESSION['user'] = $email;
        $data = array("loginStatus" => "success", 'userEmail' => $email);
    } else {
        $data = array("loginStatus" => "login failure");
    }
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($data);
});
$app->post("/register", function () use($app, $db) {
    $data = array();
    $array = (array) json_decode($app->request()->getBody());
    $user = $db->users()->where('user_email', $array['email']);
    $count = count($user);
예제 #3
0
파일: index.php 프로젝트: ypan92/iconmerce
require 'plugins/NotORM.php';
$app = new \Slim\Slim();
$dbhost = 'iconmercedb.cxcch2tzx4mi.us-west-1.rds.amazonaws.com';
$dbuser = '******';
$dbpass = '******';
$dbname = 'icondb';
$dbmethod = 'mysql:dbname=';
$dsn = $dbmethod . $dbname;
$pdo = new PDO("mysql:host={$dbhost};port=8889;dbname={$dbname}", $dbuser, $dbpass);
$db = new NotORM($pdo);
$app->get('/', function () {
    echo 'ICONMERCE - RESTful Services';
});
$app->get('/users', function () use($app, $db) {
    $users = array();
    foreach ($db->users() as $user) {
        $users[] = array('user_id' => $user['user_id'], 'username' => $user['username'], 'password' => $user['password'], 'email' => $user['email']);
    }
    $app->response()->header("Content-Type", "application/json");
    echo json_encode($users, JSON_FORCE_OBJECT);
});
$app->get("/transactions", function () use($app, $db) {
    $app->response()->header("Content-Type", "application/json");
    $transactions = array();
    $trans = $db->transactions()->order("date");
    foreach ($trans as $trans) {
        $transactions[] = array('transactionId' => $trans['transactionId'], 'userId' => $trans['userId'], 'isDeposit' => $trans['isDeposit'], 'amount' => $trans['amount'], 'date' => $trans['date'], 'category' => $trans['category']);
    }
    echo json_encode($transactions, JSON_FORCE_OBJECT);
});
$app->get("/transMonth/:month/:year", function ($month, $year) use($app, $db) {
예제 #4
0
/* CONFIG */
$dbhost = 'localhost';
$dbuser = '******';
$dbpass = '';
$dbname = 'slim';
$dbmethod = 'mysql:dbname=';
$dsn = $dbmethod . $dbname;
$pdo = new PDO($dsn, $dbuser, $dbpass);
$db = new NotORM($pdo);
/* ROUTES */
$app->get('/', function () {
    echo 'Home';
});
$app->get('/users', function () use($app, $db) {
    $users = array();
    foreach ($db->users() as $user) {
        $users[] = array('id' => $user['id'], 'username' => $user['username'], 'email' => $user['email']);
    }
    $app->response()->header("Content-Type", "application/json");
    echo json_encode($users, JSON_FORCE_OBJECT);
});
$app->get('/users/:id', function ($id) use($app, $db) {
    $app->response()->header("Content-Type", "application/json");
    $user = $db->users()->where('id', $id);
    if ($data = $user->fetch()) {
        echo json_encode(array('id' => $data['id'], 'username' => $data['username'], 'email' => $data['email']));
    } else {
        echo json_encode(array('status' => false, 'message' => "User ID {$id} does not exist"));
    }
});
$app->post('/user', function () use($app, $db) {
예제 #5
0
</body></html>
            ';
// $postdata = file_get_contents("php://input");
// $request = json_decode($postdata);
// @$email = $request->email;
// echo $email;
$app->post("/shiningfloor/email_verification/:email", function ($email = null) use($app, $db) {
    // $request = $app->request();
    // var_dump($body);
    // $email_id = $app->request()->post('email');
    //echo $email;
    global $email_html_code1, $email_html_code2;
    $email_fromr = "*****@*****.**";
    $email_subjectr = "Follow link to change password";
    $email_tor = $email;
    $user = $db->users()->where('email', $email);
    $data;
    $count = count($user);
    if ($count == 1) {
        $pwd_update_time = $user->fetch()['pwd_update_time'];
        $send_url = 'http://ankitsilaich.in/shiningfloor-master/main_site/change_pwd.php?';
        $send_url .= 'email=' . $email . '&token=' . md5($email . md5($pwd_update_time));
        //echo $send_url;
        $headers3 = 'From:' . 'Shining Floor' . " " . '<' . '*****@*****.**' . '>' . "\r\n";
        $headers3 .= 'Reply-To: ' . $email_fromr . "\r\n";
        $headers3 .= "MIME-Version: 1.0\r\n";
        $headers3 .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        $body = $email_html_code1 . $send_url . $email_html_code2;
        //     // echo $body;
        $headersr = 'From: ' . $email_fromr . "\r\n" . 'Reply-To: ' . $email_fromr . "\r\n" . 'X-Mailer: PHP/' . phpversion();
        mail($email_tor, $email_subjectr, $body, $headers3);
예제 #6
0
// $pdo = new PDO('mysql:dbname=shiningfloor;host=localhost', 'shiningfloor', 'Shiningfloor');
$db = new NotORM($pdo);
global $db;
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
require_once 'seller.php';
require_once 'admin.php';
/*************************************  EMAIL VERIFICATION ***********************************/
include 'email_content.php';
$app->post("/shiningfloor/email_verification/:email", function ($email = null) use($app, $db) {
    global $email_html_code1, $email_html_code2;
    $email_fromr = "*****@*****.**";
    $email_subjectr = "Follow link to change password";
    $email_tor = $email;
    $user = $db->users()->where('email', $email);
    $data;
    $count = count($user);
    if ($count == 1) {
        $pwd_update_time = $user->fetch()['pwd_update_time'];
        $send_url = 'http://ankitsilaich.in/shiningfloor-master/main_site/change_pwd.php?';
        $send_url .= 'email=' . $email . '&token=' . md5($email . md5($pwd_update_time));
        //echo $send_url;
        $headers3 = 'From:' . 'Shining Floor' . " " . '<' . '*****@*****.**' . '>' . "\r\n";
        $headers3 .= 'Reply-To: ' . $email_fromr . "\r\n";
        $headers3 .= "MIME-Version: 1.0\r\n";
        $headers3 .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        $body = $email_html_code1 . $send_url . $email_html_code2;
        //     // echo $body;
        $headersr = 'From: ' . $email_fromr . "\r\n" . 'Reply-To: ' . $email_fromr . "\r\n" . 'X-Mailer: PHP/' . phpversion();
        mail($email_tor, $email_subjectr, $body, $headers3);
예제 #7
0
파일: slim.php 프로젝트: Tourepedia/v1.1
$app = new \Slim\Slim();
/**********************************  USER LOGIN SIGNUP CHECKING ******************************/
$authenticate = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['user'])) {
            $app->redirect('/login.html');
        }
    };
};
session_start();
$app->post("/auth/process", function () use($app, $db) {
    $array = (array) json_decode($app->request()->getBody());
    //    print_r($array);
    $email = $array['email'];
    $pwd = md5($array['pwd']);
    $user = $db->users()->where('user_email', $email)->where('user_password', $pwd);
    $count = count($user);
    if ($count == 1) {
        $_SESSION['user'] = $email;
        $data = array("loginStatus" => "success", 'userEmail' => $email);
    } else {
        $data = array("loginStatus" => "login failure");
    }
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($data);
});
$app->post("/register", function () use($app, $db) {
    $data = array();
    $array = (array) json_decode($app->request()->getBody());
    $user = $db->users()->where('user_email', $array['email']);
    $count = count($user);