Project

General

Profile

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