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 |
74285e13
|
Scott Ullrich
|
conf_mount_rw();
|
34 |
|
|
|
35 |
5b237745
|
Scott Ullrich
|
if (($_POST['submit'] == "Load") && file_exists($_POST['savetopath'])) {
|
36 |
|
|
$fd = fopen($_POST['savetopath'], "r");
|
37 |
|
|
$content = fread($fd, filesize($_POST['savetopath']));
|
38 |
|
|
fclose($fd);
|
39 |
|
|
$edit_area="";
|
40 |
|
|
$ulmsg = "Loaded text from " . $_POST['savetopath'];
|
41 |
|
|
} else if (($_POST['submit'] == "Save")) {
|
42 |
|
|
$content = ereg_replace("\r","",$_POST['content']) ;
|
43 |
|
|
$fd = fopen($_POST['savetopath'], "w");
|
44 |
|
|
fwrite($fd, $content);
|
45 |
|
|
fclose($fd);
|
46 |
|
|
$edit_area="";
|
47 |
|
|
$ulmsg = "Saved text to " . $_POST['savetopath'];
|
48 |
|
|
} else if (($_POST['submit'] == "Load") && !file_exists($_POST['savetopath'])) {
|
49 |
|
|
$ulmsg = "File not found " . $_POST['savetopath'];
|
50 |
|
|
$content = "";
|
51 |
|
|
$_POST['savetopath'] = "";
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
if($_POST['rows'] <> "")
|
55 |
|
|
$rows = $_POST['rows'];
|
56 |
|
|
else
|
57 |
|
|
$rows = 40;
|
58 |
|
|
|
59 |
|
|
if($_POST['cols'] <> "")
|
60 |
|
|
$cols = $_POST['cols'];
|
61 |
|
|
else
|
62 |
|
|
$cols = 80;
|
63 |
|
|
?>
|
64 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
65 |
|
|
<html>
|
66 |
|
|
<head>
|
67 |
|
|
<?php
|
68 |
|
|
|
69 |
|
|
/*
|
70 |
|
|
Exec+ v1.02-000 - Copyright 2001-2003, All rights reserved
|
71 |
|
|
Created by technologEase (http://www.technologEase.com).
|
72 |
|
|
(modified for m0n0wall by Manuel Kasper <mk@neon1.net>)
|
73 |
b49448ac
|
Scott Ullrich
|
(modified for pfSense Edit/Save file by Scott Ullrich, Copyright 2004, 2005)
|
74 |
5b237745
|
Scott Ullrich
|
*/
|
75 |
|
|
|
76 |
859329c8
|
Scott Ullrich
|
include("fbegin.inc");
|
77 |
|
|
|
78 |
5b237745
|
Scott Ullrich
|
// Function: is Blank
|
79 |
|
|
// Returns true or false depending on blankness of argument.
|
80 |
|
|
|
81 |
|
|
function isBlank( $arg ) { return ereg( "^\s*$", $arg ); }
|
82 |
|
|
|
83 |
|
|
// Function: Puts
|
84 |
|
|
// Put string, Ruby-style.
|
85 |
|
|
|
86 |
|
|
function puts( $arg ) { echo "$arg\n"; }
|
87 |
|
|
|
88 |
|
|
// "Constants".
|
89 |
|
|
|
90 |
|
|
$Version = '';
|
91 |
|
|
$ScriptName = $HTTP_SERVER_VARS['SCRIPT_NAME'];
|
92 |
859329c8
|
Scott Ullrich
|
$Title = gentitle("edit file");
|
93 |
5b237745
|
Scott Ullrich
|
|
94 |
|
|
// Get year.
|
95 |
|
|
|
96 |
|
|
$arrDT = localtime();
|
97 |
|
|
$intYear = $arrDT[5] + 1900;
|
98 |
|
|
|
99 |
|
|
?>
|
100 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
101 |
|
|
<title><?=$Title ?></title>
|
102 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
103 |
|
|
<style>
|
104 |
|
|
<!--
|
105 |
|
|
|
106 |
|
|
input {
|
107 |
|
|
font-family: courier new, courier;
|
108 |
|
|
font-weight: normal;
|
109 |
|
|
font-size: 9pt;
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
pre {
|
113 |
|
|
border: 2px solid #435370;
|
114 |
|
|
background: #F0F0F0;
|
115 |
|
|
padding: 1em;
|
116 |
|
|
font-family: courier new, courier;
|
117 |
|
|
white-space: pre;
|
118 |
|
|
line-height: 10pt;
|
119 |
|
|
font-size: 10pt;
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
.label {
|
123 |
|
|
font-family: tahoma, verdana, arial, helvetica;
|
124 |
|
|
font-size: 11px;
|
125 |
|
|
font-weight: bold;
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
.button {
|
129 |
|
|
font-family: tahoma, verdana, arial, helvetica;
|
130 |
|
|
font-weight: bold;
|
131 |
|
|
font-size: 11px;
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
-->
|
135 |
|
|
</style>
|
136 |
|
|
</head>
|
137 |
be4b8e72
|
Scott Ullrich
|
<script language="Javascript">
|
138 |
|
|
function sf() { document.forms[0].savetopath.focus(); }
|
139 |
|
|
</script>
|
140 |
|
|
<body onLoad="sf();">
|
141 |
5b237745
|
Scott Ullrich
|
<p><span class="pgtitle"><?=$Title ?></span>
|
142 |
|
|
<?php if ($ulmsg) echo "<p><strong>" . $ulmsg . "</strong></p>\n"; ?>
|
143 |
|
|
|
144 |
767067da
|
Scott Ullrich
|
<form action="edit.php" method="POST">
|
145 |
5b237745
|
Scott Ullrich
|
<table>
|
146 |
|
|
<tr>
|
147 |
2f87ff69
|
Bill Marquette
|
<td nowrap>
|
148 |
be4b8e72
|
Scott Ullrich
|
Save/Load from path: <input size="42" id="savetopath" name="savetopath" value="<?php echo $_POST['savetopath']; ?>"> |
|
149 |
accca15f
|
Scott Ullrich
|
Rows: <input size="3" name="rows" value="<? echo $rows; ?>"> |
|
150 |
|
|
Cols: <input size="3" name="cols" value="<? echo $cols; ?>"> |
|
151 |
476ef195
|
Scott Ullrich
|
<input name="submit" type="submit" class="button" id="Load" value="Load"> | <input name="submit" type="submit" class="button" id="Save" value="Save">
|
152 |
5b237745
|
Scott Ullrich
|
<br><hr noshade width=100%>
|
153 |
|
|
</td>
|
154 |
|
|
</tr>
|
155 |
|
|
<tr>
|
156 |
|
|
<td valign="top" class="label">
|
157 |
|
|
<textarea rows="<?php echo $rows; ?>" cols="<?php echo $cols; ?>" name="content"><?php echo $content; ?></textarea><br>
|
158 |
|
|
<p>
|
159 |
476ef195
|
Scott Ullrich
|
</td>
|
160 |
5b237745
|
Scott Ullrich
|
</tr>
|
161 |
|
|
</table>
|
162 |
2900e518
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
163 |
5b237745
|
Scott Ullrich
|
</form>
|
164 |
|
|
</body>
|
165 |
|
|
</html>
|
166 |
|
|
|
167 |
be4b8e72
|
Scott Ullrich
|
|
168 |
|
|
<script language="Javascript">
|
169 |
|
|
sf();
|
170 |
b46bfcf5
|
Bill Marquette
|
</script>
|
171 |
74285e13
|
Scott Ullrich
|
|
172 |
|
|
<?php
|
173 |
|
|
|
174 |
|
|
conf_mount_ro();
|
175 |
|
|
|
176 |
2f87ff69
|
Bill Marquette
|
?>
|