added some development tools
[windows-sources.git] / developer / Samples / Bot / admin / config_edit.php
blob2de79c4cdd1307fc9f5f41e50398990bbd8e592a
1 <?php
2 $e_all = defined('E_DEPRECATED') ? E_ALL & ~E_DEPRECATED : E_ALL;
3 error_reporting($e_all);
4 ini_set('display_errors', 1);
5 $thisFile = __FILE__;
6 require_once('../config/global_config.php');
7 $all_vars = get_defined_vars();
8 $contents = file_get_contents('../config/config.template.php');
9 $contents = str_replace('<?php', '', $contents);
10 $contents = str_replace('?>', '', $contents);
11 $search = '~\[(\w+?)\]~';
12 $contents = preg_replace_callback($search, 'make_input', $contents);
15 /**
16 * Function make_input
18 * * @param $matches
19 * @return string
21 function make_input($matches)
23 global $all_vars;
24 $my_var = (in_array($matches[1], array_keys($all_vars))) ? $all_vars[$matches[1]] : '';
25 $replace = '<input name="' . $matches[1] . '" value="' . $my_var . '" />';
26 return $replace;
29 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
30 <html xmlns="http://www.w3.org/1999/xhtml">
31 <head>
32 <title>Program O Global Config File Editor</title>
33 <style type="text/css">
34 h3 {
35 text-align: center;
37 #config_div {
38 width: 95%;
39 max-height: 500px;
40 min-height: 250px;
41 height: 80%;
42 overflow: auto;
44 #save_btn {
45 text-align: center;
47 </style>
48 </head>
49 <body>
50 <h3>Program O Config File Editor</h3>
51 <p>
52 Use this (somewhat unconventional) form to edit your chatbot's confituration
53 file directly. Only the settings that you <strong>should</strong> need to change are
54 available here. If you need to change other settings, then you'll need to
55 make those changes in a text editor.
56 </p>
57 <form name="config" action="config_edit.php">
58 <hr />
59 <div id="config_div">
60 <pre>
61 <?php echo $contents ?>
62 </pre>
63 </div>
64 <hr />
65 <div id="save_btn"><input type="submit" name="save" value="Save" /></div>
66 </form>
67 </body>
68 </html>