This repository was archived by the owner on Sep 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
97 lines (90 loc) · 2.79 KB
/
index.php
File metadata and controls
97 lines (90 loc) · 2.79 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
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
88
89
90
91
92
93
94
95
96
97
<?php
/**
* SMUtility
*
* @package Core
*/
/**
* Shorthand for DIRECTORY_SEPARATOR
* @package Core
*/
define('DS', DIRECTORY_SEPARATOR);
/**
* Location of the root of the script
* @package Core
*/
define('ROOT', '.' . DS);
require_once ROOT . 'display.php';
require_once ROOT . 'functions.php';
$systemMeta = array(
'ID' => 'core',
'name' => 'SMUtility',
'version' => '1.1',
'author' => 'AfroSoft'
);
/* first check for info command. If found, load meta from script */
if (isset($_GET['info']) && isset($_GET['script']) && !empty($_GET['script'])) {
if ($_GET['script'] == 'core') {
$meta = $systemMeta;
$context = false;
} else {
try {
$meta = Load::meta($_GET['script']);
} catch (Exception $e) {
HTML::display('Error', HTML::grid(HTML::box($e->getMessage())));
exit();
}
$context = true;
}
ksort($meta);
$content = "";
foreach ($meta as $key => $value) {
$content .= "<dt>{$key}</dt><dd>{$value}</dd>";
}
if ($context == true) {
HTML::display($meta['name'] . ' Info', HTML::grid(HTML::box(HTML::wrap('dl', $content))), $meta);
} else {
HTML::display($meta['name'] . ' Info', HTML::grid(HTML::box(HTML::wrap('dl', $content))));
}
exit();
}
/* second check if a plugin has been specified, if so, load it and run the current view */
if (isset($_GET['script']) && !empty($_GET['script'])) {
try {
$obj = Load::plugin($_GET['script']);
$meta = Load::meta($_GET['script']);
} catch (Exception $e) {
HTML::display('Error', HTML::grid(HTML::box($e->getMessage())));
exit();
}
if (isset($_GET['do'])) {
$pluginValues = array();
foreach ($_POST as $key => $value) {
if (strpos($key, $meta['ID']) !== false) {
$pluginValues[str_replace($meta['ID'] . '_', "", $key)] = $value;
}
}
try {
$content = HTML::generateResult($obj, $pluginValues);
} catch (Exception $e) {
HTML::display('Error', HTML::grid(HTML::box($e->getMessage())), $meta);
exit();
}
} else {
$content = HTML::generateForm($obj, $meta['ID']);
}
HTML::display($meta['name'], $content, $meta);
exit();
}
/* nothing matched so display index */
$content = "";
foreach (scandir(ROOT . 'plugins') as $item) {
try {
$meta = Load::meta($item);
$content .= '<li><a href="?script=' . $meta['ID'] . '">' . $meta['name'] . '</a> - <a href="?info&script=' . $meta['ID'] . '">Info</a></li>';
} catch (Exception $e) {
// An exception signifies that the directory is not a plugin.
// We skip that directory
}
}
HTML::display('Script List', HTML::grid(HTML::box(HTML::wrap('ul', $content))));