Example #1
0
if (isset($_POST['id']) && isset($_POST['method']) && isset($_SESSION['shop'])) {
    require_once 'config.php';
    require_once 'functions.php';
    if ($_POST['method'] == "insert") {
        $data = array('id' => $_POST['id'], 'shop' => $_SESSION['shop']);
        $response = insertCollection($data);
        if ($response['status']) {
            echo 1;
        } else {
            echo 0;
        }
    } else {
        if ($_POST['method'] == 'delete') {
            if (isset($_POST['shop']) && $_POST['shop'] == $_SESSION['shop']) {
                $data = array('id' => $_POST['id'], 'shop' => $_SESSION['shop'], 'type' => $_POST['type']);
                $response = deleteCollection($data);
                if ($response['status']) {
                    echo 1;
                } else {
                    echo 0;
                }
            }
        }
    }
}
/* if(isset($_POST['method']) && $_POST['method'] == 'installPixels' && isset($_SESSION['shop'])){
	require_once('config.php');
	require_once('functions.php');
	require_once("shopify.php");
	
	$response = checkShopExists($_SESSION['shop']);
Example #2
0
<?php 
mb_internal_encoding('UTF-8');
$pageTitle = 'Въвеждане на нова колекция';
include 'header.php';
if (isset($_GET['delete_collection'])) {
    $collectionId = $_GET['delete_collection'];
    if (deleteCollection($db, $collectionId) === false) {
        echo "Грешка при изтриване на колекция.";
    } else {
        echo "Успешно изтриване на колекцията.";
    }
}
if ($_POST) {
    $collectionName = $db->real_escape_string(trim($_POST['collectionName']));
    $newCollectionId = insertCollectionByName($db, $collectionName);
    if ($newCollectionId === false) {
        echo 'Грешка при въвеждане на колекция!';
    }
}
?>
<p>Въвеждане на нова колекция:</p>
<form method="POST">
    <div>Име на нова колекция:
	     <input type="text" name="collectionName" />
	     <input type="submit" value="Въведи" />
	</div>
</form>
<p></p>
<table border = "1">
	<tr>
		<th>Колекции</th>
Example #3
0
if (null === $id) {
    // Collection
    switch ($method) {
        case 'GET':
            echo readCollection($data);
            break;
        case 'POST':
            $payload = getPayload();
            $id = uniqid();
            $data = createItem($data, $id);
            $data = updateItem($data, $id, $payload);
            saveData($data);
            echo readItem($data, $id);
            break;
        case 'DELETE':
            $data = deleteCollection($data);
            saveData($data);
            break;
        case 'OPTIONS':
            header('Access-Control-Allow-Methods: GET,POST,DELETE,OPTIONS');
            break;
        default:
            throw new InvalidArgumentException('Unsupported HTTP verb: ' . $method);
    }
} else {
    // Item
    if (!array_key_exists($id, $data)) {
        throw new InvalidArgumentException('Unknown item: ' . $id);
    }
    switch ($method) {
        case 'GET':