Beispiel #1
0
function login()
{
    if (!is_post_parameter_complete(array('username', 'password'))) {
        echo 'Nice try :P';
        die;
    }
    IncludeModel('user');
    $user = IsUsernamePasswordMatch($_POST['username'], $_POST['password']);
    if ($user != null) {
        $_SESSION['user'] = $user;
        echo 'success';
    } else {
        echo 'Username and password do not match <br>';
    }
}
Beispiel #2
0
<?php

IncludeModel('items');
global $itemDetails;
function initialize_item()
{
    global $itemDetails;
    if (!is_get_parameter_complete(array('iditem'))) {
        Redirect('store.php');
    }
    $itemDetails = SelectItem($_GET['iditem']);
    if ($itemDetails == null) {
        Error('Item not found');
    }
}
Beispiel #3
0
<?php

IncludeModel('user');
function initialize_edit_user()
{
    if (!is_logged_in()) {
        Redirect('index.php');
    }
    AddJs('user_form_libraries.js');
    AddJs('user_script.js');
}
function edit_user()
{
    if (!is_logged_in() || !is_post_parameter_complete(array('salutation', 'gender', 'firstname', 'lastname', 'birthyear', 'birthmonth', 'birthday', 'password', 'aboutme'))) {
        Redirect('../edit_user.php');
    }
    $userDetails['salutation'] = $_POST['salutation'];
    $userDetails['firstname'] = $_POST['firstname'];
    $userDetails['lastname'] = $_POST['lastname'];
    $userDetails['gender'] = $_POST['gender'];
    $userDetails['birthdate'] = "{$_POST['birthyear']}-{$_POST['birthmonth']}-{$_POST['birthday']}";
    $userDetails['username'] = $_SESSION['user']['username'];
    $userDetails['password'] = $_POST['password'];
    $userDetails['aboutme'] = $_POST['aboutme'];
    if (is_admin()) {
        if (is_post_parameter_complete(array('accesslevel'))) {
            $userDetails['accesslevel'] = $_POST['accesslevel'];
        } else {
            Redirect('../edit_user.php');
        }
    } else {
Beispiel #4
0
<?php

use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\Payment;
use PayPal\Api\PaymentExecution;
IncludeLibrary('paypal');
IncludeModel('donations');
global $donatePack;
function initialize_donate()
{
    if (!is_logged_in()) {
        Error('Invalid Access');
    }
    $GLOBALS['donatePack'] = GetDonationsPack();
}
function test()
{
    global $apiContext;
    // IncludeConfig('paypal/bootstrap.php');
    $payer = new Payer();
    $payer->setPaymentMethod("paypal");
    $item1 = new Item();
    $item1->setName('Ground Coffee 40 oz')->setCurrency('USD')->setQuantity(1)->setPrice(7.5);
    $item2 = new Item();
    $item2->setName('Granola bars')->setCurrency('USD')->setQuantity(5)->setPrice(2);
    $itemList = new ItemList();
    $itemList->setItems(array($item1, $item2));
    $details = new Details();
    $details->setShipping(1.2)->setTax(1.3)->setSubtotal(17.5);
    $amount = new Amount();
Beispiel #5
0
<?php

IncludeModel('posts');
function initialize_create_post()
{
    if (!is_logged_in()) {
        Error("Access Forbidden");
    }
    AddJs('create_post.js');
}
function create_post()
{
    if (!is_logged_in() || !is_post_parameter_complete(array('post-message'))) {
        Error('Forbidden Access');
    }
    if (AddPost($_SESSION['user']['username'], $_POST['post-message'])) {
        echo 'success';
        die;
    } else {
        echo 'Message was not posted successfully.';
        die;
    }
}
Beispiel #6
0
<?php

IncludeModel('forms');
function AddItem($item)
{
    try {
        $conn = openConnection();
        $stmt = $conn->prepare('INSERT INTO items values(null, :name, :description, :image, :price, :category)');
        BindFormParameters($stmt, $item);
        $stmt->execute();
    } catch (PDOException $e) {
        return false;
    }
    return true;
}
function SelectItem($iditem)
{
    $result = null;
    try {
        $conn = openConnection();
        $stmt = $conn->prepare('SELECT * FROM items WHERE iditem = :iditem');
        $stmt->bindParam(':iditem', $iditem);
        $stmt->execute();
        if ($stmt->rowCount() > 0) {
            $result = $stmt->fetchAll()[0];
        }
    } catch (PDOException $e) {
        // echo 'selectAllUsers() Error: ' . $e->getMessage();
    }
    return $result;
}