Menu

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

Download this file

177 lines (156 with data), 8.7 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#!/usr/local/bin/php
<?php
/*
services_daap.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) 2006-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");
require("services.inc");
$pgtitle = array(gettext("Services"), gettext("iTunes/DAAP"));
if (!is_array($config['daap']))
$config['daap'] = array();
$pconfig['enable'] = isset($config['daap']['enable']);
$pconfig['servername'] = $config['daap']['servername'];
$pconfig['port'] = $config['daap']['port'];
$pconfig['dbdir'] = $config['daap']['dbdir'];
$pconfig['content'] = $config['daap']['content'];
$pconfig['rescaninterval'] = $config['daap']['rescaninterval'];
$pconfig['alwaysscan'] = isset($config['daap']['alwaysscan']);
$pconfig['scantype'] = $config['daap']['scantype'];
$pconfig['admin_pw'] = $config['daap']['admin_pw'];
// Set default values.
if (!$pconfig['servername']) $pconfig['servername'] = $config['system']['hostname'];
if (!$pconfig['port']) $pconfig['port'] = "3689";
if (!$pconfig['rescaninterval']) $pconfig['rescaninterval'] = "0";
if (!$pconfig['alwaysscan']) $pconfig['alwaysscan'] = false;
if (!$pconfig['scantype']) $pconfig['scantype'] = "0";
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
// Input validation.
if ($_POST['enable']) {
$reqdfields = explode(" ", "servername port dbdir content admin_pw");
$reqdfieldsn = array(gettext("Server name"), gettext("Port"), gettext("Database directory"), gettext("Content"), gettext("Password"));
$reqdfieldst = explode(" ", "string port string array password");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
$reqdfields = array_merge($reqdfields, array("rescaninterval"));
$reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Rescan interval")));
$reqdfieldst = array_merge($reqdfieldst, array("numeric"));
do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, &$input_errors);
// Check if port is already used.
if (services_is_port_used($_POST['port'], "daap"))
$input_errors[] = sprintf(gettext("Port %ld is already used by another service."), $_POST['port']);
}
if (!$input_errors) {
$config['daap']['enable'] = $_POST['enable'] ? true : false;
$config['daap']['servername'] = $_POST['servername'];
$config['daap']['port'] = $_POST['port'];
$config['daap']['dbdir'] = $_POST['dbdir'];
$config['daap']['content'] = $_POST['content'];
$config['daap']['rescaninterval'] = $_POST['rescaninterval'];
$config['daap']['alwaysscan'] = $_POST['alwaysscan'] ? true : false;
$config['daap']['scantype'] = $_POST['scantype'];
$config['daap']['admin_pw'] = $_POST['admin_pw'];
write_config();
$retval = 0;
if (!file_exists($d_sysrebootreqd_path)) {
config_lock();
$retval |= rc_update_service("mt-daapd");
$retval |= rc_update_service("mdnsresponder");
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.servername.disabled = endis;
document.iform.port.disabled = endis;
document.iform.dbdir.disabled = endis;
document.iform.dbdirbrowsebtn.disabled = endis;
document.iform.content.disabled = endis;
document.iform.contentaddbtn.disabled = endis;
document.iform.contentchangebtn.disabled = endis;
document.iform.contentdeletebtn.disabled = endis;
document.iform.contentdata.disabled = endis;
document.iform.contentbrowsebtn.disabled = endis;
document.iform.rescaninterval.disabled = endis;
document.iform.alwaysscan.disabled = endis;
document.iform.scantype.disabled = endis;
document.iform.admin_pw.disabled = endis;
}
//-->
</script>
<form action="services_daap.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="tabcont">
<?php if ($input_errors) print_input_errors($input_errors);?>
<?php if ($savemsg) print_info_box($savemsg);?>
<?php if (!isset($config['system']['zeroconf'])) print_error_box(sprintf(gettext("You have to activate <a href='%s'>Zeroconf/Bonjour</a> to advertise this service to clients."), "system_advanced.php"));?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<?php html_titleline_checkbox("enable", gettext("Digital Audio Access Protocol"), $pconfig['enable'] ? true : false, gettext("Enable"), "enable_change(false)");?>
<?php html_inputbox("servername", gettext("Server name"), $pconfig['servername'], gettext("This is both the name of the server as advertised via Zeroconf/Bonjour/Rendezvous, and the name of the database exported via DAAP."), true, 20);?>
<?php html_inputbox("port", gettext("Port"), $pconfig['port'], gettext("Port to listen on. Default iTunes port is 3689."), true, 5);?>
<?php html_filechooser("dbdir", gettext("Database directory"), $pconfig['dbdir'], gettext("Location where the content database file will be stored."), $g['media_path'], true, 60);?>
<?php html_folderbox("content", gettext("Content"), $pconfig['content'], gettext("Location of the files to share."), $g['media_path'], true);?>
<?php html_inputbox("rescaninterval", gettext("Rescan interval"), $pconfig['rescaninterval'], gettext("Scan file system every N seconds to see if any files have been added or removed. Set to 0 to disable background scanning. If background rescanning is disabled, a scan can still be forced from the status page of the administrative web interface."), false, 5);?>
<?php html_checkbox("alwaysscan", gettext("Always scan"), $pconfig['alwaysscan'] ? true : false, "", gettext("Whether scans should be skipped if there are no users connected. This allows the drive to spin down when no users are connected."), false);?>
<?php html_combobox("scantype", gettext("Scan type"), $pconfig['scantype'], array("0" => gettext("Normal"), "1" => gettext("Aggressive"), "2" => gettext("Painfully aggressive")), "", false);?>
<?php html_separator();?>
<?php html_titleline(gettext("Administrative WebGUI"));?>
<?php html_passwordbox("admin_pw", gettext("Password"), $pconfig['admin_pw'], sprintf("%s %s", gettext("Password for the administrative pages."), gettext("Default user name is 'admin'.")), true, 20);?>
<?php
$if = get_ifname($config['interfaces']['lan']['if']);
$ipaddr = get_ipaddr($if);
$url = htmlspecialchars("http://{$ipaddr}:{$pconfig['port']}");
$text = "<a href='{$url}' target='_blank'>{$url}</a>";
?>
<?php html_text("url", gettext("URL"), $text);?>
</table>
<div id="submit">
<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save and Restart");?>" onclick="onsubmit_content(); enable_change(true)" />
</div>
<div id="remarks">
<?php html_remark("note", gettext("Note"), sprintf(gettext("You have to activate <a href='%s'>Zeroconf/Bonjour</a> to advertise this service to clients."), "system_advanced.php"));?>
</div>
</td>
</tr>
</table>
<?php include("formend.inc");?>
</form>
<script type="text/javascript">
<!--
enable_change(false);
//-->
</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.