Menu

[r8045]: / legacy / www / services_tftp.php  Maximize  Restore  History

Download this file

157 lines (136 with data), 7.4 kB

  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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/local/bin/php
<?php
/*
services_tftp.php
Modified for XHTML by Daisuke Aoyama (aoyama@peach.ne.jp)
Copyright (C) 2010 Daisuke Aoyama <aoyama@peach.ne.jp>.
All rights reserved.
Copyright (C) 2008-2010 Volker Theile (votdev@gmx.de)
All rights reserved.
part of FreeNAS (http://www.freenas.org)
Copyright (C) 2005-2010 Olivier Cochard <olivier@freenas.org>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
require("auth.inc");
require("guiconfig.inc");
$pgtitle = array(gettext("Services"), gettext("TFTP"));
if (!is_array($config['tftpd']))
$config['tftpd'] = array();
$pconfig['enable'] = isset($config['tftpd']['enable']);
$pconfig['dir'] = $config['tftpd']['dir'];
$pconfig['allowfilecreation'] = isset($config['tftpd']['allowfilecreation']);
$pconfig['port'] = $config['tftpd']['port'];
$pconfig['username'] = $config['tftpd']['username'];
$pconfig['umask'] = $config['tftpd']['umask'];
$pconfig['timeout'] = $config['tftpd']['timeout'];
$pconfig['maxblocksize'] = $config['tftpd']['maxblocksize'];
$pconfig['extraoptions'] = $config['tftpd']['extraoptions'];
// Set defaults
if (empty($pconfig['username']))
$pconfig['username'] = "nobody";
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
// Input validation.
if ($_POST['enable']) {
$reqdfields = explode(" ", "dir");
$reqdfieldsn = array(gettext("Directory"));
$reqdfieldst = explode(" ", "string");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
$reqdfields = array_merge($reqdfields, explode(" ", "port umask timeout maxblocksize"));
$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Port"), gettext("umask"), gettext("Timeout"), gettext("Max. block size")));
$reqdfieldst = array_merge($reqdfieldst, explode(" ", "port numeric numeric numeric"));
do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, &$input_errors);
}
if ($_POST['maxblocksize'] && ((512 > $_POST['maxblocksize']) || (65464 < $_POST['maxblocksize']))) {
$input_errors[] = sprintf(gettext("Invalid max. block size! It must be in the range from %d to %d."), 512, 65464);
}
if (!$input_errors) {
$config['tftpd']['enable'] = $_POST['enable'] ? true : false;
$config['tftpd']['dir'] = $_POST['dir'];
$config['tftpd']['allowfilecreation'] = $_POST['allowfilecreation'] ? true : false;
$config['tftpd']['port'] = $_POST['port'];
$config['tftpd']['username'] = $_POST['username'];
$config['tftpd']['umask'] = $_POST['umask'];
$config['tftpd']['timeout'] = $_POST['timeout'];
$config['tftpd']['maxblocksize'] = $_POST['maxblocksize'];
$config['tftpd']['extraoptions'] = $_POST['extraoptions'];
write_config();
$retval = 0;
if (!file_exists($d_sysrebootreqd_path)) {
config_lock();
$retval |= rc_update_service("tftpd");
config_unlock();
}
$savemsg = get_std_save_message($retval);
}
}
?>
<?php include("fbegin.inc");?>
<script type="text/javascript">
<!--
function enable_change(enable_change) {
var endis = !(document.iform.enable.checked || enable_change);
document.iform.dir.disabled = endis;
document.iform.dirbrowsebtn.disabled = endis;
document.iform.allowfilecreation.disabled = endis;
document.iform.port.disabled = endis;
document.iform.username.disabled = endis;
document.iform.umask.disabled = endis;
document.iform.timeout.disabled = endis;
document.iform.maxblocksize.disabled = endis;
document.iform.extraoptions.disabled = endis;
}
//-->
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="tabcont">
<form action="services_tftp.php" method="post" name="iform" id="iform">
<?php if ($input_errors) print_input_errors($input_errors);?>
<?php if ($savemsg) print_info_box($savemsg);?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<?php html_titleline_checkbox("enable", gettext("Trivial File Transfer Protocol"), $pconfig['enable'] ? true : false, gettext("Enable"), "enable_change(false)");?>
<?php html_filechooser("dir", gettext("Directory"), $pconfig['dir'], gettext("The directory containing the files you want to publish. The remote host does not need to pass along the directory as part of the transfer."), $g['media_path'], true, 60);?>
<?php html_checkbox("allowfilecreation", gettext("Allow new files"), $pconfig['allowfilecreation'] ? true : false, gettext("Allow new files to be created."), gettext("By default, only already existing files can be uploaded."), false);?>
<?php html_separator();?>
<?php html_titleline(gettext("Advanced settings"));?>
<?php html_inputbox("port", gettext("Port"), $pconfig['port'], gettext("The port to listen to. The default is to listen to the tftp port specified in /etc/services."), false, 5);?>
<?php $a_user = array(); foreach (system_get_user_list() as $userk => $userv) { $a_user[$userk] = htmlspecialchars($userk); }?>
<?php html_combobox("username", gettext("Username"), $pconfig['username'], $a_user, gettext("Specifies the username which the service will run as."), false);?>
<?php html_inputbox("umask", gettext("umask"), $pconfig['umask'], gettext("Sets the umask for newly created files to the specified value. The default is zero (anyone can read or write)."), false, 4);?>
<?php html_inputbox("timeout", gettext("Timeout"), $pconfig['timeout'], gettext("Determine the default timeout, in microseconds, before the first packet is retransmitted. The default is 1000000 (1 second)."), false, 10);?>
<?php html_inputbox("maxblocksize", gettext("Max. block size"), $pconfig['maxblocksize'], gettext("Specifies the maximum permitted block size. The permitted range for this parameter is from 512 to 65464."), false, 5);?>
<?php html_inputbox("extraoptions", gettext("Extra options"), $pconfig['extraoptions'], gettext("Extra options (usually empty)."), false, 40);?>
</table>
<div id="submit">
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save and Restart");?>" onclick="enable_change(true)" />
</div>
<?php include("formend.inc");?>
</form>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
enable_change();
//-->
</script>
<?php include("fend.inc");?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.