summaryrefslogtreecommitdiffstats
path: root/usr/local/www/edit.php
blob: 694f40b97250ebd349cb3499a3e40d9eda488e23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/local/bin/php
<?php
if (($_POST['submit'] == "Load") && file_exists($_POST['savetopath'])) {
	$fd = fopen($_POST['savetopath'], "r");
	$content = fread($fd, filesize($_POST['savetopath']));
	fclose($fd);
	$edit_area="";
	$ulmsg = "Loaded text from " . $_POST['savetopath'];
} else if (($_POST['submit'] == "Save")) {
	$content = ereg_replace("\r","",$_POST['content']) ;
	$fd = fopen($_POST['savetopath'], "w");
	fwrite($fd, $content);
	fclose($fd);
	$edit_area="";
	$ulmsg = "Saved text to " . $_POST['savetopath'];
} else if (($_POST['submit'] == "Load") && !file_exists($_POST['savetopath'])) {
	$ulmsg = "File not found " . $_POST['savetopath'];
	$content = "";
	$_POST['savetopath'] = "";
}

if($_POST['rows'] <> "")
	$rows = $_POST['rows'];
else
	$rows = 40;

if($_POST['cols'] <> "")
	$cols = $_POST['cols'];
else
	$cols = 80;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<?php

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

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

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

// Function: Puts
// Put string, Ruby-style.

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

// "Constants".

$Version    = '';
$ScriptName = $HTTP_SERVER_VARS['SCRIPT_NAME'];
$Title      = 'pfSense: edit file';

// Get year.

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

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

input {
   font-family: courier new, courier;
   font-weight: normal;
   font-size: 9pt;
}

pre {
   border: 2px solid #435370;
   background: #F0F0F0;
   padding: 1em;
   font-family: courier new, courier;
   white-space: pre;
   line-height: 10pt;
   font-size: 10pt;
}

.label {
   font-family: tahoma, verdana, arial, helvetica;
   font-size: 11px;
   font-weight: bold;
}

.button {
   font-family: tahoma, verdana, arial, helvetica;
   font-weight: bold;
   font-size: 11px;
}

-->
</style>
</head>
<body>
<p><span class="pgtitle"><?=$Title ?></span>
<?php if ($ulmsg) echo "<p><strong>" . $ulmsg . "</strong></p>\n"; ?>

<form action="<?=$ScriptName ?>" method="POST">
  <table>
    <tr>
      <td>
        Save/Load from path: <input name="savetopath" value="<?php echo $_POST['savetopath']; ?>">
	Rows: <input size="3" name="rows" value="<? echo $rows; ?>">
	Cols: <input size="3" name="cols" value="<? echo $cols; ?>">
        <input name="submit" type="submit"  class="button" id="Load" value="Load">
	<br><hr noshade width=100%>
        </td>
    </tr>
    <tr>
      <td valign="top" class="label">
	<textarea rows="<?php echo $rows; ?>" cols="<?php echo $cols; ?>" name="content"><?php echo $content; ?></textarea><br>
        <p>
	<center><input name="submit" type="submit"  class="button" id="Save" value="Save"></center></td>
    </tr>
  </table>
</form>
</body>
</html>

OpenPOWER on IntegriCloud