Project

General

Profile

Download (6.22 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    edit.php
5
    Copyright (C) 2004, 2005 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
require("guiconfig.inc");
31

    
32
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
	$loadmsg = "Loaded text from " . $_POST['savetopath'];
38
	if(stristr($_POST['savetopath'], ".php") == true)
39
		$language = "php";
40
	else if(stristr($_POST['savetopath'], ".inc") == true)
41
		$language = "php";		
42
	else if(stristr($_POST['savetopath'], ".sh") == true)
43
		$language = "core";
44
	else if(stristr($_POST['savetopath'], ".xml") == true)
45
		$language = "xml";
46
} else if (($_POST['submit'] == "Save")) {
47
	conf_mount_rw();
48
	$content = ereg_replace("\r","",$_POST['code']) ;
49
	$fd = fopen($_POST['savetopath'], "w");
50
	fwrite($fd, $content);
51
	fclose($fd);
52
	$edit_area="";
53
	$savemsg = "Saved text to " . $_POST['savetopath'];
54
	conf_mount_ro();
55
} else if (($_POST['submit'] == "Load") && !file_exists($_POST['savetopath'])) {
56
	$savemsg = "File not found " . $_POST['savetopath'];
57
	$content = "";
58
	$_POST['savetopath'] = "";
59
}
60

    
61
if($_POST['highlight'] <> "") {
62
	if($_POST['highlight'] == "yes" or
63
	  $_POST['highlight'] == "enabled") {
64
		$highlight = "yes";
65
	} else {
66
		$highlight = "no";
67
	}
68
} else {
69
	$highlight = "no";
70
}
71

    
72
if($_POST['rows'] <> "")
73
	$rows = $_POST['rows'];
74
else
75
	$rows = 30;
76

    
77
if($_POST['cols'] <> "")
78
	$cols = $_POST['cols'];
79
else
80
	$cols = 66;
81
?>
82
<?php
83

    
84
/*
85
	Exec+ v1.02-000 - Copyright 2001-2003, All rights reserved
86
	Created by technologEase (http://www.technologEase.com).
87
	(modified for m0n0wall by Manuel Kasper <mk@neon1.net>)
88
        (modified for pfSense Edit/Save file by Scott Ullrich, Copyright 2004, 2005)
89
*/
90

    
91
// Function: is Blank
92
// Returns true or false depending on blankness of argument.
93

    
94
function isBlank( $arg ) { return ereg( "^\s*$", $arg ); }
95

    
96
// Function: Puts
97
// Put string, Ruby-style.
98

    
99
function puts( $arg ) { echo "$arg\n"; }
100

    
101
// "Constants".
102

    
103
$Version    = '';
104
$ScriptName = $HTTP_SERVER_VARS['SCRIPT_NAME'];
105

    
106
// Get year.
107

    
108
$arrDT   = localtime();
109
$intYear = $arrDT[5] + 1900;
110

    
111
$pgtitle = "Diagnostics: Edit File";
112

    
113
include("head.inc");
114

    
115
?>
116

    
117
<?php include("fbegin.inc"); ?>
118

    
119
<script language="Javascript">
120
function sf() { document.forms[0].savetopath.focus(); }
121
</script>
122
<body onLoad="sf();">
123
<p><span class="pgtitle"><?=$pgtitle?></span>
124
<?php if ($savemsg) print_info_box($savemsg); ?>
125
<?php if ($loadmsg) echo "<p><b><div style=\"background:#eeeeee\" id=\"shapeme\">&nbsp;&nbsp;&nbsp;{$loadmsg}</div><br>"; ?>
126
<form action="edit.php" method="POST">
127

    
128
<div id="shapeme">
129
<table width="100%" cellpadding='9' cellspacing='9' bgcolor='#eeeeee'>
130
 <tr>
131
  <td>
132
	<center>
133
	Save/Load from path: <input size="42" id="savetopath" name="savetopath" value="<?php echo $_POST['savetopath']; ?>">
134
	<input name="submit" type="submit"  class="button" id="Load" value="Load"> <input name="submit" type="submit"  class="button" id="Save" value="Save">
135
	<hr noshade>
136
	<?php if($_POST['highlight'] == "no"): ?>
137
	   Rows: <input size="3" name="rows" value="<? echo $rows; ?>"> 
138
	   Cols: <input size="3" name="cols" value="<? echo $cols; ?>">
139
	<?php endif; ?>
140
	 | 
141
	Highlighting: <input name="highlight" type="radio" value="yes"
142
	<?php if($highlight == "yes") echo " checked"; ?>>Enabled
143
	<input name="highlight" type="radio" value="no"<?php if($highlight == "no") echo " checked"; ?>>Disabled
144
  </td>
145
 </tr>
146
</table>
147
</div>
148

    
149
<br>
150

    
151
  <table width='100%'>
152
    <tr>
153
      <td valign="top" class="label">
154
	<div style="background:#eeeeee" id="textareaitem">
155
	&nbsp;<br>&nbsp;
156
	<center>
157
	<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>
158
	&nbsp;
159
	</div>
160
        <p>
161
    </td>
162
    </tr>
163
  </table>
164
<?php include("fend.inc"); ?>
165
</form>
166
</body>
167
</html>
168

    
169
<script language="Javascript">
170
sf();
171
</script>
172

    
173
</div>
174
<script language="javascript" src="/code-syntax-highlighter/shCore.js"></script>
175
<script language="javascript" src="/code-syntax-highlighter/shBrushCSharp.js"></script>
176
<script language="javascript" src="/code-syntax-highlighter/shBrushPhp.js"></script>
177
<script language="javascript" src="/code-syntax-highlighter/shBrushJScript.js"></script>
178
<script language="javascript" src="/code-syntax-highlighter/shBrushVb.js"></script>
179
<script language="javascript" src="/code-syntax-highlighter/shBrushSql.js"></script>
180
<script language="javascript" src="/code-syntax-highlighter/shBrushXml.js"></script>
181
<script language="javascript" src="/code-syntax-highlighter/shBrushDelphi.js"></script>
182
<script language="javascript" src="/code-syntax-highlighter/shBrushPython.js"></script>
183

    
184
<?php if($_POST['highlight'] == "yes") {
185
	echo "<script language=\"javascript\">\n";
186
	echo "dp.SyntaxHighlighter.HighlightAll('code', true, true);\n";
187
	echo "</script>\n";
188
}
189
?>
190

    
191
<script type="text/javascript">
192
NiftyCheck();
193
Rounded("div#shapeme","all","#FFF","#eeeeee","smooth");
194
Rounded("div#textareaitem","all","#FFF","#eeeeee","smooth");
195
</script>
(29-29/159)