-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathitemsAdmin.php
72 lines (63 loc) · 1.47 KB
/
itemsAdmin.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
<html>
<head>
<meta charset="utf-8">
<title>Админский файл - items</title>
</head>
<body>
<?php
require_once("db.php");
$query = mysqli_query($bd, "SELECT * FROM names WHERE nkey='name' LIMIT 1");
$result = mysqli_fetch_assoc($query);
mysqli_free_result($query);
$name = $result["value"];
echo "<style>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
color: #ffffff;
font-size: 180%;
}
textarea {
width: 100%;
height: 100%;
}
</style>";
//The string template for itemsAdmin with placeholders
$str = "<?php
require_once('api/Simpla.php');
class %class% extends Simpla {
function fetch() {
if (\$this->request->method('post')) {
\$ids = \$this->request->post('check');
if (is_array(\$ids)) {
switch(\$this->request->post('action')) {
case 'delete':
foreach(\$ids as \$id) {
\$this->%api%->delete_%name%(\$id);
}
break;
}
}
}
\$%name%s = \$this->%api%->get_%name%s();
\$this->design->assign('%name%s', \$%name%s);
return \$this->body = \$this->design->fetch('%name%s.tpl');
}
}";
//Inserting variables into a template
$str = str_replace("<", "<", $str);
$str = str_replace(">", ">", $str);
$str = str_replace("%class%", ucfirst($name)."sAdmin", $str);
$str = str_replace("%name%", $name, $str);
$str = str_replace("%api%", $name."s", $str);
echo "<textarea>";
echo $str;
echo "</textarea>";
?>
</body>
</html>