-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_recipe.php
executable file
·86 lines (72 loc) · 2.28 KB
/
query_recipe.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
if (!isset($_SESSION['ing']))
{
$_SESSION['ing'] = array();
}
if (!isset($_SESSION['amt']))
{
$_SESSION['amt'] = array();
}
if (!isset($_SESSION['rec']))
{
$_SESSION['rec'] = array();
}
if (!isset($_SESSION['title']))
{
$_SESSION['title'] = "My New Recipe";
}
if (!isset($_SESSION['steps']))
{
$_SESSION['steps'] = array();
}
if (isset($_GET['rem']) && gettype($_GET['rem']) == "array")
{
$_SESSION['ing'] = array_diff($_SESSION['ing'], $_GET['rem']);
}
else if (isset($_GET['rem']))
{
$_SESSION['ing'] = array_diff($_SESSION['ing'], array($_GET['rem']));
}
if (isset($_GET['add']) && gettype($_GET['add']) == "array")
{
$_SESSION['ing'] = array_merge($_SESSION['ing'], $_GET['add']);
sort($_SESSION['ing']);
$_SESSION['ing'] = array_unique($_SESSION['ing']);
}
else if (isset($_GET['add']))
{
array_push($_SESSION['ing'], $_GET['add']);
sort($_SESSION['ing']);
$_SESSION['ing'] = array_unique($_SESSION['ing']);
}
if (isset($_GET['add-rec']) && gettype($_GET['add-rec']) == "array")
{
$_SESSION['rec'] = array_merge($_SESSION['rec'], $_GET['add-rec']);
sort($_SESSION['rec']);
$_SESSION['rec'] = array_unique($_SESSION['rec']);
}
else if (isset($_GET['add-rec']))
{
array_push($_SESSION['rec'], $_GET['add-rec']);
sort($_SESSION['rec']);
$_SESSION['rec'] = array_unique($_SESSION['rec']);
}
if (isset($_GET['rem-rec']) && gettype($_GET['rem-rec']) == "array")
{
$_SESSION['rec'] = array_diff($_SESSION['rec'], $_GET['rem-rec']);
}
else if (isset($_GET['rem-rec']))
{
$_SESSION['rec'] = array_diff($_SESSION['rec'], array($_GET['rem-rec']));
}
foreach ($_SESSION['ing'] as $value)
{
if (!isset($_SESSION['amt'][$value]))
$_SESSION['amt'][$value] = "some";
printf("<li class=\"ingredient\"><textarea class=\"dyn-textarea amount\" id=\"%d\" name=\"%d\">%s</textarea><div class=\"name\" onclick=\"recipe.remove(%d)\">%s</div></li>", $value, $value, $_SESSION['amt'][$value], $value, exec("/var/bin/recipes/get_name " . escapeshellarg($value)));
}
printf("<li><form id=\"add-ingredient-form\"><textarea class=\"dyn-textarea\" id=\"add-ingredient\" autocomplete=\"off\">add ingredient</textarea><ul id=\"suggestions\"></ul></form></li>");
?>