Skip to content

Instantly share code, notes, and snippets.

View elmarputz's full-sized avatar

Elmar Putz elmarputz

  • Studio Mitte Digital Media GmbH
  • Linz, Austria
View GitHub Profile
@elmarputz
elmarputz / ShoppingCart.php
Created December 16, 2016 09:28
ShoppingCart.php
<?php
//as soon as shopping cart is referenced the session context is created
SessionContext::create();
/**
* ShoppingCart
*
*
* @package
<?php
//as soon as shopping cart is referenced the session context is created
SessionContext::create();
/**
* ShoppingCart
*
*
* @package
@elmarputz
elmarputz / success.php
Created December 16, 2016 09:32
success.php
<?php
$orderId = isset($_REQUEST['orderId']) ? $_REQUEST['orderId'] : null;
require_once('views/partials/header.php');
?>
<div class="page-header">
<h2>Success!</h2>
</div>
/**
* place query
*
* note: using prepared statements
* see the filtering in bindValue()
*
* @return mixed
*/
private static function query($connection, $query, $parameters = array()) {
$statement = $connection->prepare($query);
@elmarputz
elmarputz / header.php
Created March 4, 2017 07:53
bookshop header
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>SCM4 Book Shop</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
@elmarputz
elmarputz / BaseObject.php
Last active March 4, 2017 09:20
BaseObject
<?php
namespace Bookshop;
/**
* BaseObject
*
* handles magic functions
*/
class BaseObject {
/**
* @param string $type 'categories', 'books', 'users'
* @return array
*/
private static function getMockData(string $type) : array {
$data = array();
switch ($type) {
case 'categories' :
$data = array(1 => new Category(1, "Mobile & Wireless Computing1"),
<?php
namespace App\Routing\Filter;
use Cake\Event\Event;
use Cake\Routing\DispatcherFilter;
class RESTFilter extends DispatcherFilter
{
public function beforeDispatch(Event $event)
{
//zu Beginn
/* needed to prevent CORS errors, when cakephp throws an exception */
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Methods: *');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Request-Method: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization');
...
//am Ende
<!DOCTYPE html>
<html ng-app='bookstore'>
<head>
<meta charset="utf-8">
<title>Bookstore of Hannes</title>
</head>
<body>
<header>
<h1>Bookstore</h1>