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