-
Notifications
You must be signed in to change notification settings - Fork 0
/
library.php
87 lines (77 loc) · 1.89 KB
/
library.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
87
<?php
function print_ord($conn, $ord) {
$query = "SELECT * FROM menspec WHERE oid='$ord[oid]'";
$result = $conn->query($query);
if (!$result) err($query);
echo<<<_END
<li>$ord[person]</li>
<li>id $ord[oid] for $ord[whn]</li>
<li>with: $result->num_rows ingredients!
_END;
for ($j = 0; $j < $result->num_rows; $j++) {
$result->data_seek($j);
$row = $result->fetch_array(MYSQL_ASSOC);
echo pid_to_item($row[pid]);
}
echo "</li>";
}
function pid_to_item($conn, $pid) {
$query = "SELECT * FROM menuniv WHERE pid='$pid'";
$result = $conn->query($query);
if(!$result) mysql_ferror($query);
var_dump($result->data_seek('0'));
$row = $result->fetch_array(MYSQL_ASSOC);
return $row[name];
}
function is_user($conn, $user) {
$query = "SELECT * FROM people WHERE name='$user'";
$result = $conn->query($query);
if ($result->num_rows > 0){
return TRUE;
} else {
return FALSE;
}
}
function is_admin($name) {
return in_array("Tommy", "Pat");
}
function msqli_ferror($conn)
{
$msg = mysqli_error($conn);
echo <<<_END
Unfortunatly something has gone wrong with the requested task.
The error was:
<p>$msg</p>
Feel free to try again, or email our <a href="mailto:[email protected]">support staff</a>. Have a nice day!
_END;
}
function get_post($conn, $var)
{
return $conn->real_escape_string($_POST[$var]);
}
function is_email($string)
{
return true;
}
function is_prop_type($string)
{
$is = false;
$prop_types = array("substrate", "protein", "dessert", "side", "snack", "fruit", "drink", "vegetable", "condiment", "cheese");
foreach($prop_types as $prop) {
if($string == $prop) $is = true;
}
}
function type_list()
{
$output = "";
$prop_types = get_types();
foreach($prop_types as $type){
$output = $output . $type . " ";
}
return $output;
}
function get_types()
{
return array("substrate", "protein", "dessert", "side", "snack", "fruit", "drink", "vegetable", "condiment", "cheese");
}
?>