Project

General

Profile

Download (3.1 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
if (($_POST['submit'] == "Load") && file_exists($_POST['savetopath'])) {
4
	$fd = fopen($_POST['savetopath'], "r");
5
	$content = fread($fd, filesize($_POST['savetopath']));
6
	fclose($fd);
7
	$edit_area="";
8
	$ulmsg = "Loaded text from " . $_POST['savetopath'];
9
} else if (($_POST['submit'] == "Save")) {
10
	$content = ereg_replace("\r","",$_POST['content']) ;
11
	$fd = fopen($_POST['savetopath'], "w");
12
	fwrite($fd, $content);
13
	fclose($fd);
14
	$edit_area="";
15
	$ulmsg = "Saved text to " . $_POST['savetopath'];
16
} else if (($_POST['submit'] == "Load") && !file_exists($_POST['savetopath'])) {
17
	$ulmsg = "File not found " . $_POST['savetopath'];
18
	$content = "";
19
	$_POST['savetopath'] = "";
20
}
21

    
22
if($_POST['rows'] <> "")
23
	$rows = $_POST['rows'];
24
else
25
	$rows = 40;
26

    
27
if($_POST['cols'] <> "")
28
	$cols = $_POST['cols'];
29
else
30
	$cols = 80;
31
?>
32
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
33
<html>
34
<head>
35
<?php
36

    
37
/*
38
	Exec+ v1.02-000 - Copyright 2001-2003, All rights reserved
39
	Created by technologEase (http://www.technologEase.com).
40
	(modified for m0n0wall by Manuel Kasper <mk@neon1.net>)
41
        (modified for pfSense Edit/Save file by Scott Ullrich, Copyright 2004)
42
*/
43

    
44
// Function: is Blank
45
// Returns true or false depending on blankness of argument.
46

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

    
49
// Function: Puts
50
// Put string, Ruby-style.
51

    
52
function puts( $arg ) { echo "$arg\n"; }
53

    
54
// "Constants".
55

    
56
$Version    = '';
57
$ScriptName = $HTTP_SERVER_VARS['SCRIPT_NAME'];
58
$Title      = 'pfSense: edit file';
59

    
60
// Get year.
61

    
62
$arrDT   = localtime();
63
$intYear = $arrDT[5] + 1900;
64

    
65
?>
66
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
67
<title><?=$Title ?></title>
68
<link href="gui.css" rel="stylesheet" type="text/css">
69
<style>
70
<!--
71

    
72
input {
73
   font-family: courier new, courier;
74
   font-weight: normal;
75
   font-size: 9pt;
76
}
77

    
78
pre {
79
   border: 2px solid #435370;
80
   background: #F0F0F0;
81
   padding: 1em;
82
   font-family: courier new, courier;
83
   white-space: pre;
84
   line-height: 10pt;
85
   font-size: 10pt;
86
}
87

    
88
.label {
89
   font-family: tahoma, verdana, arial, helvetica;
90
   font-size: 11px;
91
   font-weight: bold;
92
}
93

    
94
.button {
95
   font-family: tahoma, verdana, arial, helvetica;
96
   font-weight: bold;
97
   font-size: 11px;
98
}
99

    
100
-->
101
</style>
102
</head>
103
<body>
104
<p><span class="pgtitle"><?=$Title ?></span>
105
<?php if ($ulmsg) echo "<p><strong>" . $ulmsg . "</strong></p>\n"; ?>
106

    
107
<form action="<?=$ScriptName ?>" method="POST">
108
  <table>
109
    <tr>
110
      <td>
111
        Save/Load from path: <input name="savetopath" value="<?php echo $_POST['savetopath']; ?>">
112
	Rows: <input size="3" name="rows" value="<? echo $rows; ?>">
113
	Cols: <input size="3" name="cols" value="<? echo $cols; ?>">
114
        <input name="submit" type="submit"  class="button" id="Load" value="Load">
115
	<br><hr noshade width=100%>
116
        </td>
117
    </tr>
118
    <tr>
119
      <td valign="top" class="label">
120
	<textarea rows="<?php echo $rows; ?>" cols="<?php echo $cols; ?>" name="content"><?php echo $content; ?></textarea><br>
121
        <p>
122
	<center><input name="submit" type="submit"  class="button" id="Save" value="Save"></center></td>
123
    </tr>
124
  </table>
125
</form>
126
</body>
127
</html>
128

    
(14-14/90)