forked from TDR-1000/KeyAuth-Source-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.php
More file actions
42 lines (33 loc) · 1.04 KB
/
button.php
File metadata and controls
42 lines (33 loc) · 1.04 KB
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
<?php
namespace misc\button;
use misc\etc;
use misc\cache;
use misc\mysql;
function addButton($text, $value, $secret = null)
{
$text = etc\sanitize($text);
$value = etc\sanitize($value);
$query = mysql\query("INSERT INTO `buttons` (`text`, `value`, `app`) VALUES (?, ?, ?)",[$text, $value, $secret ?? $_SESSION['app']]);
if ($query->affected_rows > 0) {
if ($_SESSION['role'] == "seller" || !is_null($secret)) {
cache\purge('KeyAuthButtons:' . ($secret ?? $_SESSION['app']));
}
return 'success';
} else {
return 'failure';
}
}
function deleteButton($value, $secret = null)
{
$value = etc\sanitize($value);
$query = mysql\query("DELETE FROM `buttons` WHERE `value` = ? AND `app` = ?",[$value, $secret ?? $_SESSION['app']]);
if ($query->affected_rows > 0) {
if ($_SESSION['role'] == "seller" || !is_null($secret)) {
cache\purge('KeyAuthButtons:' . ($secret ?? $_SESSION['app']));
}
return 'success';
} else {
return 'failure';
}
}
?>