1 |
5b237745
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
a7f908db
|
Scott Ullrich
|
/*
|
4 |
|
|
edit.php
|
5 |
b49448ac
|
Scott Ullrich
|
Copyright (C) 2004, 2005 Scott Ullrich
|
6 |
a7f908db
|
Scott Ullrich
|
All rights reserved.
|
7 |
|
|
|
8 |
|
|
Redistribution and use in source and binary forms, with or without
|
9 |
|
|
modification, are permitted provided that the following conditions are met:
|
10 |
|
|
|
11 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
12 |
|
|
this list of conditions and the following disclaimer.
|
13 |
|
|
|
14 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
15 |
|
|
notice, this list of conditions and the following disclaimer in the
|
16 |
|
|
documentation and/or other materials provided with the distribution.
|
17 |
|
|
|
18 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
28 |
|
|
*/
|
29 |
|
|
|
30 |
859329c8
|
Scott Ullrich
|
require("guiconfig.inc");
|
31 |
|
|
|
32 |
ad6eae25
|
Scott Ullrich
|
if (($_GET['submit'] == "Load") && file_exists($_GET['savetopath'])) {
|
33 |
|
|
$fd = fopen($_GET['savetopath'], "r");
|
34 |
a2bb4586
|
Scott Ullrich
|
if ((filesize($_GET['savetopath']) != 0)) { $content = fread($fd, filesize($_GET['savetopath'])); } else { $content = ""; }
|
35 |
ad6eae25
|
Scott Ullrich
|
fclose($fd);
|
36 |
|
|
$edit_area="";
|
37 |
|
|
$loadmsg = gettext("Loaded text from")." " . $_GET['savetopath'];
|
38 |
|
|
if(stristr($_GET['savetopath'], ".php") == true)
|
39 |
|
|
$language = "php";
|
40 |
|
|
else if(stristr($_GET['savetopath'], ".inc") == true)
|
41 |
|
|
$language = "php";
|
42 |
|
|
else if(stristr($_GET['savetopath'], ".sh") == true)
|
43 |
|
|
$language = "core";
|
44 |
|
|
else if(stristr($_GET['savetopath'], ".xml") == true)
|
45 |
|
|
$language = "xml";
|
46 |
|
|
|
47 |
|
|
$savetopath = $_GET['savetopath'];
|
48 |
|
|
}
|
49 |
|
|
|
50 |
5b237745
|
Scott Ullrich
|
if (($_POST['submit'] == "Load") && file_exists($_POST['savetopath'])) {
|
51 |
|
|
$fd = fopen($_POST['savetopath'], "r");
|
52 |
a2bb4586
|
Scott Ullrich
|
if ((filesize($_POST['savetopath']) != "0")) { $content = fread($fd, filesize($_POST['savetopath'])); } else { $content = ""; }
|
53 |
5b237745
|
Scott Ullrich
|
fclose($fd);
|
54 |
|
|
$edit_area="";
|
55 |
7c35be3e
|
Scott Ullrich
|
$loadmsg = "Loaded text from " . $_POST['savetopath'];
|
56 |
207c6304
|
Scott Ullrich
|
if(stristr($_POST['savetopath'], ".php") == true)
|
57 |
2e8eada0
|
Scott Ullrich
|
$language = "php";
|
58 |
f14e4c2a
|
Scott Ullrich
|
else if(stristr($_POST['savetopath'], ".inc") == true)
|
59 |
5cfb93bc
|
Scott Ullrich
|
$language = "php";
|
60 |
207c6304
|
Scott Ullrich
|
else if(stristr($_POST['savetopath'], ".sh") == true)
|
61 |
f14e4c2a
|
Scott Ullrich
|
$language = "core";
|
62 |
207c6304
|
Scott Ullrich
|
else if(stristr($_POST['savetopath'], ".xml") == true)
|
63 |
2e8eada0
|
Scott Ullrich
|
$language = "xml";
|
64 |
ad6eae25
|
Scott Ullrich
|
$savetopath = $_POST['savetopath'];
|
65 |
5b237745
|
Scott Ullrich
|
} else if (($_POST['submit'] == "Save")) {
|
66 |
c52087ad
|
Scott Ullrich
|
conf_mount_rw();
|
67 |
5124d619
|
Scott Ullrich
|
$content = ereg_replace("\r","",$_POST['code']) ;
|
68 |
5b237745
|
Scott Ullrich
|
$fd = fopen($_POST['savetopath'], "w");
|
69 |
|
|
fwrite($fd, $content);
|
70 |
|
|
fclose($fd);
|
71 |
|
|
$edit_area="";
|
72 |
e613545f
|
Scott Ullrich
|
$savemsg = "Saved text to " . $_POST['savetopath'];
|
73 |
5cfb93bc
|
Scott Ullrich
|
if($_POST['savetopath'] == "/cf/conf/config.xml")
|
74 |
|
|
unlink_if_exists("/tmp/config.cache");
|
75 |
c52087ad
|
Scott Ullrich
|
conf_mount_ro();
|
76 |
ad6eae25
|
Scott Ullrich
|
$savetopath = $_POST['savetopath'];
|
77 |
5b237745
|
Scott Ullrich
|
} else if (($_POST['submit'] == "Load") && !file_exists($_POST['savetopath'])) {
|
78 |
c52087ad
|
Scott Ullrich
|
$savemsg = "File not found " . $_POST['savetopath'];
|
79 |
5b237745
|
Scott Ullrich
|
$content = "";
|
80 |
|
|
$_POST['savetopath'] = "";
|
81 |
|
|
}
|
82 |
|
|
|
83 |
5124d619
|
Scott Ullrich
|
if($_POST['highlight'] <> "") {
|
84 |
bd19c08a
|
Scott Ullrich
|
if($_POST['highlight'] == "yes" or
|
85 |
|
|
$_POST['highlight'] == "enabled") {
|
86 |
5124d619
|
Scott Ullrich
|
$highlight = "yes";
|
87 |
|
|
} else {
|
88 |
|
|
$highlight = "no";
|
89 |
|
|
}
|
90 |
|
|
} else {
|
91 |
|
|
$highlight = "no";
|
92 |
|
|
}
|
93 |
|
|
|
94 |
5b237745
|
Scott Ullrich
|
if($_POST['rows'] <> "")
|
95 |
|
|
$rows = $_POST['rows'];
|
96 |
|
|
else
|
97 |
5124d619
|
Scott Ullrich
|
$rows = 30;
|
98 |
5b237745
|
Scott Ullrich
|
|
99 |
|
|
if($_POST['cols'] <> "")
|
100 |
|
|
$cols = $_POST['cols'];
|
101 |
|
|
else
|
102 |
ee6d9b34
|
Scott Ullrich
|
$cols = 66;
|
103 |
5b237745
|
Scott Ullrich
|
?>
|
104 |
|
|
<?php
|
105 |
|
|
|
106 |
|
|
/*
|
107 |
|
|
Exec+ v1.02-000 - Copyright 2001-2003, All rights reserved
|
108 |
|
|
Created by technologEase (http://www.technologEase.com).
|
109 |
|
|
(modified for m0n0wall by Manuel Kasper <mk@neon1.net>)
|
110 |
36d0358b
|
Scott Ullrich
|
(modified for {$g['product_name']} Edit/Save file by Scott Ullrich, Copyright 2004, 2005)
|
111 |
5b237745
|
Scott Ullrich
|
*/
|
112 |
|
|
|
113 |
|
|
// Function: is Blank
|
114 |
|
|
// Returns true or false depending on blankness of argument.
|
115 |
|
|
|
116 |
|
|
function isBlank( $arg ) { return ereg( "^\s*$", $arg ); }
|
117 |
|
|
|
118 |
|
|
// Function: Puts
|
119 |
|
|
// Put string, Ruby-style.
|
120 |
|
|
|
121 |
|
|
function puts( $arg ) { echo "$arg\n"; }
|
122 |
|
|
|
123 |
|
|
// "Constants".
|
124 |
|
|
|
125 |
|
|
$Version = '';
|
126 |
|
|
$ScriptName = $HTTP_SERVER_VARS['SCRIPT_NAME'];
|
127 |
|
|
|
128 |
|
|
// Get year.
|
129 |
|
|
|
130 |
|
|
$arrDT = localtime();
|
131 |
|
|
$intYear = $arrDT[5] + 1900;
|
132 |
|
|
|
133 |
d88c6a9f
|
Scott Ullrich
|
$pgtitle = array("Diagnostics","Edit File");
|
134 |
5b237745
|
Scott Ullrich
|
|
135 |
48581bb7
|
Scott Ullrich
|
include("head.inc");
|
136 |
|
|
|
137 |
f9c14a6f
|
Scott Ullrich
|
?>
|
138 |
2e8eada0
|
Scott Ullrich
|
|
139 |
5124d619
|
Scott Ullrich
|
<?php include("fbegin.inc"); ?>
|
140 |
2e8eada0
|
Scott Ullrich
|
|
141 |
be4b8e72
|
Scott Ullrich
|
<script language="Javascript">
|
142 |
|
|
function sf() { document.forms[0].savetopath.focus(); }
|
143 |
|
|
</script>
|
144 |
|
|
<body onLoad="sf();">
|
145 |
e613545f
|
Scott Ullrich
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
146 |
8a1ec45d
|
Scott Ullrich
|
<?php if ($loadmsg) echo "<p><b><div style=\"background:#eeeeee\" id=\"shapeme\"> {$loadmsg}</div><br>"; ?>
|
147 |
767067da
|
Scott Ullrich
|
<form action="edit.php" method="POST">
|
148 |
5124d619
|
Scott Ullrich
|
|
149 |
|
|
<div id="shapeme">
|
150 |
|
|
<table width="100%" cellpadding='9' cellspacing='9' bgcolor='#eeeeee'>
|
151 |
|
|
<tr>
|
152 |
|
|
<td>
|
153 |
|
|
<center>
|
154 |
b5c78501
|
Seth Mos
|
Save/Load from path: <input size="42" id="savetopath" class="formfld unknown" name="savetopath" value="<?php echo $savetopath; ?>">
|
155 |
6e558e52
|
Scott Ullrich
|
<input name="submit" type="submit" class="button" id="Load" value="Load"> <input name="submit" type="submit" class="button" id="Save" value="Save">
|
156 |
bd19c08a
|
Scott Ullrich
|
<hr noshade>
|
157 |
5124d619
|
Scott Ullrich
|
<?php if($_POST['highlight'] == "no"): ?>
|
158 |
5cfb93bc
|
Scott Ullrich
|
Rows: <input size="3" name="rows" value="<? echo $rows; ?>">
|
159 |
5124d619
|
Scott Ullrich
|
Cols: <input size="3" name="cols" value="<? echo $cols; ?>">
|
160 |
0831bc86
|
Scott Ullrich
|
<?php endif; ?>
|
161 |
5124d619
|
Scott Ullrich
|
</td>
|
162 |
|
|
</tr>
|
163 |
|
|
</table>
|
164 |
|
|
</div>
|
165 |
|
|
|
166 |
ab541dbb
|
Scott Ullrich
|
<br>
|
167 |
|
|
|
168 |
5124d619
|
Scott Ullrich
|
<table width='100%'>
|
169 |
5b237745
|
Scott Ullrich
|
<tr>
|
170 |
|
|
<td valign="top" class="label">
|
171 |
b16def07
|
Scott Ullrich
|
<div style="background:#eeeeee" id="textareaitem">
|
172 |
|
|
<br>
|
173 |
8e0e58ff
|
Scott Ullrich
|
<center>
|
174 |
|
|
<textarea style="width:98%" name="code" language="<?php echo $language; ?>" rows="<?php echo $rows; ?>" cols="<?php echo $cols; ?>" name="content"><?php echo htmlentities($content); ?></textarea><br>
|
175 |
b16def07
|
Scott Ullrich
|
|
176 |
|
|
</div>
|
177 |
5b237745
|
Scott Ullrich
|
<p>
|
178 |
476ef195
|
Scott Ullrich
|
</td>
|
179 |
5b237745
|
Scott Ullrich
|
</tr>
|
180 |
|
|
</table>
|
181 |
2900e518
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
182 |
5b237745
|
Scott Ullrich
|
</form>
|
183 |
|
|
</body>
|
184 |
|
|
</html>
|
185 |
|
|
|
186 |
be4b8e72
|
Scott Ullrich
|
<script language="Javascript">
|
187 |
|
|
sf();
|
188 |
5124d619
|
Scott Ullrich
|
</script>
|
189 |
|
|
|
190 |
|
|
</div>
|
191 |
|
|
<script language="javascript" src="/code-syntax-highlighter/shCore.js"></script>
|
192 |
|
|
<script language="javascript" src="/code-syntax-highlighter/shBrushCSharp.js"></script>
|
193 |
|
|
<script language="javascript" src="/code-syntax-highlighter/shBrushPhp.js"></script>
|
194 |
|
|
<script language="javascript" src="/code-syntax-highlighter/shBrushJScript.js"></script>
|
195 |
|
|
<script language="javascript" src="/code-syntax-highlighter/shBrushVb.js"></script>
|
196 |
|
|
<script language="javascript" src="/code-syntax-highlighter/shBrushSql.js"></script>
|
197 |
|
|
<script language="javascript" src="/code-syntax-highlighter/shBrushXml.js"></script>
|
198 |
|
|
<script language="javascript" src="/code-syntax-highlighter/shBrushDelphi.js"></script>
|
199 |
|
|
<script language="javascript" src="/code-syntax-highlighter/shBrushPython.js"></script>
|
200 |
|
|
|
201 |
|
|
<?php if($_POST['highlight'] == "yes") {
|
202 |
|
|
echo "<script language=\"javascript\">\n";
|
203 |
|
|
echo "dp.SyntaxHighlighter.HighlightAll('code', true, true);\n";
|
204 |
f0df1e49
|
Bill Marquette
|
echo "</script>\n";
|
205 |
5124d619
|
Scott Ullrich
|
}
|
206 |
|
|
?>
|
207 |
|
|
|
208 |
|
|
<script type="text/javascript">
|
209 |
|
|
NiftyCheck();
|
210 |
|
|
Rounded("div#shapeme","all","#FFF","#eeeeee","smooth");
|
211 |
b16def07
|
Scott Ullrich
|
Rounded("div#textareaitem","all","#FFF","#eeeeee","smooth");
|
212 |
5124d619
|
Scott Ullrich
|
</script>
|