forked from asxzy/Program-O
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_edit.php
More file actions
75 lines (67 loc) · 1.83 KB
/
config_edit.php
File metadata and controls
75 lines (67 loc) · 1.83 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
<?php
$e_all = defined('E_DEPRECATED') ? E_ALL & ~E_DEPRECATED : E_ALL;
error_reporting($e_all);
ini_set('display_errors', 1);
$thisFile = __FILE__;
/** @noinspection PhpIncludeInspection */
require_once('../config/global_config.php');
$all_vars = get_defined_vars();
$contents = file_get_contents('../config/config.template.php');
$contents = str_replace('<?php', '', $contents);
$contents = str_replace('?>', '', $contents);
$search = '~\[(\w+?)\]~';
$contents = preg_replace_callback($search, 'make_input', $contents);
/**
* Function make_input
*
* @param $matches
* @return string
*/
function make_input($matches)
{
global $all_vars;
$my_var = (in_array($matches[1], array_keys($all_vars))) ? $all_vars[$matches[1]] : '';
$replace = '<input name="' . $matches[1] . '" value="' . $my_var . '" />';
return $replace;
}
?>
<!doctype html>
<html>
<head>
<title>Program O Global Config File Editor</title>
<style type="text/css">
h3 {
text-align: center;
}
#config_div {
width: 95%;
max-height: 500px;
min-height: 250px;
height: 80%;
overflow: auto;
}
#save_btn {
text-align: center;
}
</style>
</head>
<body>
<h3>Program O Config File Editor</h3>
<p>
Use this (somewhat unconventional) form to edit your chatbot's confituration
file directly. Only the settings that you <strong>should</strong> need to change are
available here. If you need to change other settings, then you'll need to
make those changes in a text editor.
</p>
<form name="config" action="config_edit.php">
<hr/>
<div id="config_div">
<pre>
<?php echo $contents ?>
</pre>
</div>
<hr/>
<div id="save_btn"><input type="submit" name="save" value="Save"/></div>
</form>
</body>
</html>