function pageController()
{
    $data = [];
    //$data['counter'] = isset($_GET["counter"]) ? $_GET["counter"] : 0;
    $data['counter'] = inputHas('counter') ? escape(inputGet('counter')) : 0;
    return $data;
}
Beispiel #2
0
function pageController()
{
    if (inputHas('counter')) {
        $counter = inputGet('counter');
    } else {
        $counter = 0;
    }
    return array('counter' => $counter);
}
function click()
{
    $hitsValue = Input::get('hits');
    if (inputGet('action') == 'hit') {
        $hitsValue++;
    } else {
        $hitsValue = 0;
    }
    return $hitsValue;
}
 /**
  * POST /comments
  * @param PostsInterface $postsInterface
  * @param CommentsTransformer $commentsTransformer
  * @return mixed
  */
 public function store(PostsInterface $postsInterface, CommentsTransformer $commentsTransformer)
 {
     validate(['post_id' => 'required|integer', 'content' => 'required']);
     $user = user();
     $post = $postsInterface->findPostWithException(inputGet('post_id'));
     $parentId = inputGet('parent_id');
     if ($parentId) {
         $parent = $this->commentsInterface->findCommentWithException($parentId);
     } else {
         $parent = null;
     }
     $comment = $this->commentsInterface->createComment($user, $post, inputGet('content'), $parent);
     return respondWithItem($comment, $commentsTransformer);
 }
Beispiel #5
0
function pageController()
{
    $name = "";
    $password = "";
    $javascript = "";
    if (!empty($_POST)) {
        $name = inputHas('name') ? inputGet('name') : "";
        $password = inputHas('password') ? inputGet('password') : "";
        $javascript = '';
        if (Auth::attempt($name, $password)) {
            header('Location: /ads.index.php');
            die;
        } else {
            if ($name != "" || $password != "") {
                $javascript = 'alert("Incorrect input.")';
            }
        }
    }
    return array('name' => $name, 'password' => $password, 'javascript' => $javascript);
}
function pageController()
{
    $data = array();
    session_start();
    if (Auth::check()) {
        header("Location: authorized.php");
    }
    $username = Input::has('username') ? escape(Input::get('username')) : '';
    $password = Input::has('password') ? Input::get(inputGet('password')) : '';
    $errorMessage = "";
    if ($username == '' && $password == '') {
    } elseif (Auth::attempt($username, $password)) {
        header("Location: authorized.php");
        exit;
    } else {
        $errorMessage = "Login Failed. Please try again.";
    }
    $data['errorMessage'] = $errorMessage;
    return $data;
}
Beispiel #7
0
 /**
  * 用户动态
  * GET /posts/user_timeline
  * @param PostsInterface $postInterface
  * @return mixed
  */
 public function getUserTimeline(PostsInterface $postInterface)
 {
     $maxId = maxId();
     $sinceId = sinceId();
     $pageSize = pageSize();
     $userId = inputGet('user_id');
     // if null
     if ($userId) {
         $data = $postInterface->getUserPosts($userId, $sinceId, $maxId, $pageSize);
         return respondWithCollection($data, new PostsTransformer());
     }
     $user = user();
     if (is_null($user)) {
         errorUnauthorized();
     }
     $data = $postInterface->getMyPosts($user->id, $sinceId, $maxId, $pageSize);
     return respondWithCollection($data, new MyPostsTransformer());
 }
function pageController()
{
    $counter = inputGet('counter');
    $choice = inputGet('choice');
    return array('counter' => $counter, 'choice' => $choice);
}
function escape($input)
{
    if (inputGet($key)) {
        return htmlspecialchars(strip_tags($_REQUEST($key)));
    }
}
Beispiel #10
0
//SlimBoilerplate\Layout\LayoutView::setDefaultDescription('Slim PHP boilerplate');
// ########################################
// ############### ROUTES #################
// REST API
// Very simple Rest server for the "account" sql table
$restAccounts = new \SlimBoilerplate\Rest\RestServer('account');
$restAccounts->createRoutes($app);
// HTML
$app->get('/', function () use($app) {
    $app->render('home.php');
})->name('home');
$app->get('/error', function () use($app) {
    $app->render('error.php');
})->name('error');
$app->get('/pay', function () use($app) {
    $data = inputGet('success') ? array('success' => inputGet('success')) : array();
    $app->render('pay.php', $data);
});
$app->get('/success', function () use($app) {
    $model = new Model();
    $data = [];
    $payment = current($model->read('payments', 'id', (int) base64_decode($_GET['order'])));
    $data['payment'] = $payment;
    $app->render('success.php', $data);
});
$app->get('/basket', function () use($app) {
    $app->render('basket.php');
});
$app->get('/pizza', function () use($app) {
    $app->render('pizza.php');
});
// var_dump($_POST);
require_once '../Auth.php';
require_once '../Input.php';
$message = '';
// Creating a session
session_start();
// get the current session id
$sessionId = session_id();
$username = '';
// Creating logged_in_user if not created already.
if (isset($_SESSION['LOGGED_IN_USER'])) {
    header('Location: authorized.php');
    die;
}
$username = inputGet('username');
$password = inputGet('password');
// Verifying userename and password.
if ($username == 'guest' && $password == 'password') {
    $_SESSION['LOGGED_IN_USER'] = $username;
    header('Location: authorized.php');
    // Good message.
    die;
} else {
    // Bad message
    $message = "Please input a valid username and password";
}
?>

<!DOCTYPE html>
<html>
<head>
Beispiel #12
0
 /**
  * 第三方登录
  * POST /auth/third_party
  * @param AuthTransformer $authTransformer
  * @return mixed
  */
 public function postThirdParty(AuthTransformer $authTransformer)
 {
     validate(['open_id' => 'required', 'platform' => 'required|in:qq,weixin,weibo', 'platform_info' => 'required']);
     $user = $this->userInterface->findOrCreateWithPlatform(inputGet('platform'), inputGet('open_id'), inputGet('platform_info'));
     return respondWithItem($user, $authTransformer);
 }
<?php

session_start();
$sessionId = session_id();
require_once 'classes.php';
require_once 'classes2.php';
require_once 'functions.php';
//order form has hidden orderNumber
//that submits with the form.
if (inputHas('orderNumber')) {
    $customer = new Customer();
    $order->orderNumber = inputGet('orderNumber');
    $order->customer = inputGet('customer_name');
    $order = new Order();
    $order->deliveryAddress = inputGet('delivery_address');
    $order->orderNumber = inputGet('order_number');
    $order->customer = $customer;
}
if (inputHas('delivered')) {
    $order->deliver();
}
?>
<!DOCTYPE html>
<html>
<head>
	<title>Stuff</title>
</head>
<body>
	<?php 
if ($order->delivered) {
    ?>
<?php

// Procedural Code
require_once 'customer_flower.php';
require_once 'order.php';
require_once 'functions.php';
// order form has hidden orderNumber
// that submits with the form
if (inputHas('orderNumber')) {
    // $_POST['flowers'] = ['petunia', 'daisy'];
    $customer = new Customer();
    $customer->name = inputGet('customer_name');
    $address = inputGet('delivery_address');
    $order = new Order($address);
    // $order-> = deliveryAddress = inputGet('delivery_address');
    $order->customer = $customer;
}
if (inputHas('delivered')) {
    $order->deliver();
}
?>

<!DOCTYPE html>
<html>
<head>
  <title></title>
</head>
<body>
  <?php 
if ($order->delivered) {
    ?>
    } else {
        return false;
    }
}
function inputGet($key)
{
    if (isset($_REQUEST[$key])) {
        return $_REQUEST[$key];
    } else {
        return null;
    }
}
function escape($input)
{
    return strip_tags(htmlspecialchars($input));
}
?>
<html>
<head>
    <title></title>
</head>
<body>
    <? if(inputHas('date')): ?>
        <h1>DATE is in the $_REQUEST and its value is <?php 
echo inputGet('date');
?>
</h1>
    <? endif; ?>
</body>
</html>
Beispiel #16
0
<?php

require_once 'functions.php';
require_once '../../Auth.php';
require_once '../../Input.php';
session_start();
$message = '';
$username = '';
if (Auth::check()) {
    header("Location: authorized.php");
    die;
}
if (Input::get('username') && Input::get('password')) {
    $log = new Log();
    if (Auth::attempt(inputGet('username'), inputGet('password')) == true) {
        $log->info('User ' . $username . ' logged in.');
        header("Location: authorized.php");
        die;
    }
    $log->error('User ' . $username . ' failed to log in!');
}
?>

<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" href="../css/bootstrap.css">
	<link rel="stylesheet" href="../css/login.css">
    <title>POST Example</title>
</head>
<body>
Beispiel #17
0
<?php

include_once "\\phpGroupProject\\Core\\input.php";
echo '$_GET is empty <br / >';
var_dump(inputGet('page', 'int', 0));
echo "<br > -------------------- <br / >";
$GET = ["page" => 1];
echo 'has page in $_GET array and its int <br/ >';
echo inputGet('page', 'int', 0);
echo "<br> ------------------ <br / >";
$GET = ["page" => 'str'];
echo 'has page in $_GET array and its int <br/ >';
var_dump(inputGet('page', 'int', 0));
echo "<br> ------------------ <br / >";
$GET = ["selection" => 'home'];
echo 'has page in $_GET array and its int <br/ >';
var_dump(inputGet('selection', 'str', 404));
echo "<br> ------------------ <br / >";
$GET = ["selection" => '1000'];
echo 'has page in $_GET array and its int <br/ >';
var_dump(inputGet('selection', 'str', 404));
echo "<br> ------------------ <br / >";
?>

<?php

session_start();
//always at the top!
require_once 'functions.php';
$username = inputHas('username') ? inputGet('username') : '';
$password = inputHas('password') ? inputGet('password') : '';
$realUsername = "******";
$realPassword = "******";
//first tells me that they are logged in already and don't need to be here
if (isset($_SESSION['LOGGED_IN_USER']) && $_SESSION['LOGGED_IN_USER'] != '') {
    header('Location: /authorized.php');
    die;
} else {
    if ($username == $realUsername && $password == $realPassword) {
        //create a session key, save the value as username
        $_SESSION['LOGGED_IN_USER'] = $username;
        header('Location: /authorized.php');
        die;
    } else {
        if ($username != "" || $password != "") {
            echo "WRONG!";
        }
    }
}
?>
<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" type="text/css" href="sessions.css">
</head>
<?php

require_once 'Order.php';
require_once 'Customer.php';
require_once 'functions.php';
if (inputHas('oderNumber')) {
    $customer = new Customer();
    $customer->name = inputGet('customer_name');
    $customer->orderNumber = inputGet('orderNumber');
    $order = new Order();
    $oder->orderNumber = inputGet('oderNumber');
}
Beispiel #20
0
<?php

require_once 'Customer_Flower.php';
require_once 'Order.php';
require_once '/php/functions.php';
// order form has hidden orderNumber
// that submits with the form
if (inputHas('orderNumber')) {
    $customer = new Customer();
    $customer->name = inputGet('customerName');
    $customer->orderNumber - inptGet('orderNumber');
    $customer = new Order();
    $order->orderNumber = inputGet('orderNumber');
    $order->deliveryAddress = inputGet('deliveryAddress');
    $order->customer = $customer;
}
if (inputHas('delivered')) {
    $order->deliver();
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Flower/Order/Customer Objects</title>
</head>
<body>
	<?php 
if ($order->delivered) {
    ?>