1<?php
2/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
3/**
4 *
5 * LICENSE: GNU Affero General Public License, version 3 (AGPL-3.0-or-later)
6 * Copyright 2001 - 2020 Ampache.org
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 *
21 */
22
23// Try to guess the web path
24use Ampache\Module\System\AmpError;
25use Ampache\Module\System\Core;
26
27$web_path_guess = $_REQUEST['web_path'];
28if (empty($web_path_guess)) {
29    $web_path_guess = get_web_path();
30}
31$db_user        = scrub_out($_REQUEST['db_user']);
32$local_username = scrub_out($_REQUEST['db_username']);
33if (!$db_user) {
34    $local_username = scrub_out($_REQUEST['local_username']);
35}
36$local_pass = scrub_out($_REQUEST['db_password']);
37if (empty($local_pass)) {
38    $local_pass = scrub_out($_REQUEST['local_pass']);
39}
40
41require __DIR__ . '/install_header.inc.php'; ?>
42        <div class="jumbotron" style="margin-top: 70px">
43            <h1><?php echo T_('Install Progress'); ?></h1>
44            <div class="progress">
45                <div class="progress-bar progress-bar-warning"
46                    role="progressbar"
47                    aria-valuenow="60"
48                    aria-valuemin="0"
49                    aria-valuemax="100"
50                    style="width: 66%">
51                    66%
52                </div>
53            </div>
54            <p><?php echo T_('Step 1 - Create the Ampache database'); ?></p>
55                <p><strong><?php echo T_('Step 2 - Create configuration files (ampache.cfg.php ...)'); ?></strong></p>
56                <dl>
57                    <dd><?php printf(T_('This step takes the basic config values and generates the config file. If your config/ directory is writable, you can select "write" to have Ampache write the config file directly to the correct location. If you select "download" it will prompt you to download the config file, and you can then manually place the config file in %s.'), realpath(__DIR__ . '/../../config')); ?></dd>
58                </dl>
59            <ul class="list-unstyled">
60                <li><?php echo T_('Step 3 - Set up the initial account'); ?></li>
61            </ul>
62            </div>
63            <?php echo AmpError::display('general'); ?>
64<form method="post" action="<?php echo $web_path . "/install.php?action=create_config"; ?>" enctype="multipart/form-data" autocomplete="off">
65            <h2><?php echo T_('Generate Configuration File'); ?></h2>
66            <h3><?php echo T_('Various'); ?></h3>
67<div class="form-group">
68    <label for="web_path" class="col-sm-4 control-label"><?php echo T_('Web Path'); ?></label>
69    <div class="col-sm-8">
70        <input type="text" class="form-control" id="web_path" name="web_path" value="<?php echo scrub_out($web_path_guess); ?>">
71    </div>
72</div>
73            <h3><?php echo T_('Database Connection'); ?></h3>
74            <?php echo AmpError::display('config'); ?>
75<div class="form-group">
76    <label for="local_db" class="col-sm-4 control-label"><?php echo T_('Database Name'); ?></label>
77    <div class="col-sm-8">
78        <input type="text" class="form-control" id="local_db" name="local_db" value="<?php echo scrub_out($_REQUEST['local_db']); ?>">
79    </div>
80</div>
81<div class="form-group">
82    <label for="local_host" class="col-sm-4 control-label"><?php echo T_('MySQL Hostname'); ?></label>
83    <div class="col-sm-8">
84        <input type="text" class="form-control" id="local_host" name="local_host" value="<?php echo scrub_out($_REQUEST['local_host']); ?>">
85    </div>
86</div>
87<div class="form-group">
88    <label for="local_port" class="col-sm-4 control-label"><?php echo T_('MySQL Port (optional)'); ?></label>
89    <div class="col-sm-8">
90        <input type="text" class="form-control" id="local_port" name="local_port" value="<?php echo scrub_out($_REQUEST['local_port']);?>"/>
91    </div>
92</div>
93<div class="form-group">
94    <label for="local_username" class="col-sm-4 control-label"><?php echo T_('MySQL Username'); ?></label>
95    <div class="col-sm-8">
96        <input type="text" class="form-control" id="local_username" name="local_username" value="<?php echo $local_username; ?>"/>
97    </div>
98</div>
99<div class="form-group">
100    <label for="local_pass" class="col-sm-4 control-label"><?php echo T_('MySQL Password'); ?></label>
101    <div class="col-sm-8">
102        <input type="password" class="form-control" id="local_pass" name="local_pass" value="<?php echo $local_pass; ?>" placeholder="<?php echo T_("Password") . '(' . T_("required") . ')'; ?>">
103    </div>
104</div>
105
106<input type="hidden" name="htmllang" value="<?php echo $htmllang; ?>" />
107<input type="hidden" name="charset" value="<?php echo $charset; ?>" />
108
109<p>&nbsp;</p>
110<h3><?php echo T_('Installation Type'); ?></h3>
111<div><?php echo T_('Optimize Ampache for your use case. The installer will enable/disable features automatically.'); ?></div>
112<br />
113<div class="form-group">
114    <div class="radio">
115      <label><input type="radio" name="usecase" value="default" <?php if (!isset($_REQUEST['usecase']) || $_REQUEST['usecase'] == 'default') {
116    echo 'checked';
117} ?>><?php echo T_('Default'); ?> &mdash; <?php echo T_('Ampache is configured for personal use with the best features.'); ?></label>
118    </div>
119    <div class="radio">
120      <label><input type="radio" name="usecase" value="minimalist" <?php if (isset($_REQUEST['usecase']) && $_REQUEST['usecase'] == 'minimalist') {
121    echo 'checked';
122} ?>><?php echo T_('Minimalist'); ?> &mdash; <?php echo T_('Only essential features are enabled to simply stream your music from the Web Interface.'); ?></label>
123    </div>
124    <div class="radio">
125      <label><input type="radio" name="usecase" value="community" <?php if (isset($_REQUEST['usecase']) && $_REQUEST['usecase'] == 'community') {
126    echo 'checked';
127} ?>><?php echo T_('Community'); ?> &mdash; <?php echo T_('Recommended settings when using Ampache as a frontend for a music community.'); ?></label>
128    </div>
129</div>
130
131<p>&nbsp;</p>
132<h3><?php echo T_('Allow Transcoding'); ?></h3>
133<div>
134    <?php echo T_('Transcoding allows you to convert music from one encoding to another. Ampache supports on the fly transcoding of any file type based on user, player, IP address or available bandwidth. In order to transcode, Ampache takes advantage of existing binary applications such as ffmpeg. In order for transcoding to work you must first install the supporting applications and ensure that they are executable by the web server.'); ?>
135    <br />
136    <?php echo T_('This section applies the default transcoding configuration according to the application you want to use. You may need to customize settings once setup has ended.'); ?> <a href="https://github.com/ampache/ampache/wiki/Transcoding" target="_blank"><?php echo T_('See wiki page'); ?>.</a>
137</div>
138<br />
139<div class="form-group">
140    <label for="transcode_template" class="col-sm-4 control-label"><?php echo T_('Template Configuration'); ?></label>
141    <div class="col-sm-8">
142        <select class="form-control" id="transcode_template" name="transcode_template">
143        <option value=""><?php echo T_('None'); ?></option>
144        <?php
145            $modes = $this->installationHelper->install_get_transcode_modes();
146            foreach ($modes as $mode) { ?>
147            <option value="<?php echo $mode; ?>" <?php if (Core::get_request('transcode_template') == $mode) {
148                echo 'selected';
149            } ?>><?php echo $mode; ?></option>
150        <?php
151            } ?>
152        </select>
153        <?php
154        if (count($modes) == 0) { ?>
155        <label><?php echo T_('No default transcoding application found. You may need to install a popular application (FFmpeg, avconv ...) or customize transcoding settings manually after installation.'); ?></label>
156        <?php
157        } ?>
158    </div>
159</div>
160
161<p>&nbsp;</p>
162<h3><?php echo T_('Players'); ?></h3>
163<div><?php echo T_('Ampache is more than only a web interface. Several backends are implemented to ensure you can stream your media to any player.'); ?></div>
164<div><?php echo T_('Select each backend to enable. Depending on the backend, you may need to perform additional configuration.'); ?> <a href="https://github.com/ampache/ampache/wiki/API" target="_blank"><?php echo T_('See wiki page'); ?>.</a></div>
165<br />
166<div class="form-group">
167    <div class="checkbox-inline disabled">
168        <label><input type="checkbox" value="1" checked disabled>Web Interface</label>
169    </div>
170    <div class="checkbox-inline disabled">
171        <label><input type="checkbox" value="1" checked disabled>Ampache API</label>
172    </div>
173    <div class="checkbox-inline">
174        <label><input type="checkbox" name="backends[]" value="subsonic" <?php if (!isset($_REQUEST['backends']) || in_array('subsonic', $_REQUEST['backends'])) {
175            echo 'checked';
176        } ?>>Subsonic</label>
177    </div>
178    <div class="checkbox-inline">
179        <label><input type="checkbox" name="backends[]" value="upnp" <?php if (isset($_REQUEST['backends']) && in_array('upnp', $_REQUEST['backends'])) {
180            echo 'checked';
181        } ?>>UPnP</label>
182    </div>
183    <div class="checkbox-inline">
184        <label><input type="checkbox" name="backends[]" value="daap" <?php if (isset($_REQUEST['backends']) && in_array('daap', $_REQUEST['backends'])) {
185            echo 'checked';
186        } ?>>DAAP (iTunes)</label>
187    </div>
188    <div class="checkbox-inline">
189        <label><input type="checkbox" name="backends[]" value="webdav" <?php if (isset($_REQUEST['backends']) && in_array('webdav', $_REQUEST['backends'])) {
190            echo 'checked';
191        } ?>>WebDAV</label>
192    </div>
193</div>
194
195<br /><br />
196<div class="panel-group" id="accordion">
197    <div id="config_files" class="panel panel-default">
198        <div class="panel-heading">
199            <h3 class="panel-title"><a data-toggle="collapse" data-target="#collapseConfigFiles" href="#collapseConfigFiles"><?php echo T_('File Insight'); ?></a></h3>
200        </div>
201        <div id="collapseConfigFiles" class="panel-collapse collapse <?php if (isset($created_config) && !$created_config) {
202            echo "in";
203        } ?>">
204            <div class="panel-body">
205                <?php if ($this->installationHelper->install_check_server_apache()) { ?>
206                    <div class="col-sm-4">&nbsp;</div><div class="col-sm-8">&nbsp;</div>
207                    <div class="col-sm-4 control-label">
208                        <?php echo T_('channel/.htaccess action'); ?>
209                    </div>
210                    <div class="col-sm-8">
211                        <button type="submit" class="btn btn-warning" name="download_htaccess_channel"><?php echo T_('Download'); ?></button>
212                        <button type="submit" class="btn btn-warning" name="write_htaccess_channel" <?php if (!check_htaccess_channel_writable()) {
213            echo "disabled ";
214        } ?>>
215                            <?php echo T_('Write'); ?>
216                        </button>
217                    </div>
218                    <div class="col-sm-4 control-label"><?php echo T_('channel/.htaccess exists?'); ?></div>
219                    <div class="col-sm-8"><?php echo debug_result(is_readable($htaccess_channel_file)); ?></div>
220                    <div class="col-sm-4 control-label"><?php echo T_('channel/.htaccess configured?'); ?></div>
221                    <div class="col-sm-8"><?php echo debug_result($this->installationHelper->install_check_rewrite_rules($htaccess_channel_file, $web_path_guess)); ?></div>
222
223                    <div class="col-sm-4">&nbsp;</div><div class="col-sm-8">&nbsp;</div>
224                    <div class="col-sm-4 control-label">
225                        <?php echo T_('rest/.htaccess action'); ?>
226                    </div>
227                    <div class="col-sm-8">
228                        <button type="submit" class="btn btn-warning" name="download_htaccess_rest"><?php echo T_('Download'); ?></button>
229                        <button type="submit" class="btn btn-warning" name="write_htaccess_rest" <?php if (!check_htaccess_rest_writable()) {
230            echo "disabled ";
231        } ?>>
232                            <?php echo T_('Write'); ?>
233                        </button>
234                    </div>
235                    <div class="col-sm-4 control-label"><?php echo T_('rest/.htaccess exists?'); ?></div>
236                    <div class="col-sm-8"><?php echo debug_result(is_readable($htaccess_rest_file)); ?></div>
237                    <div class="col-sm-4 control-label"><?php echo T_('rest/.htaccess configured?'); ?></div>
238                    <div class="col-sm-8"><?php echo debug_result($this->installationHelper->install_check_rewrite_rules($htaccess_rest_file, $web_path_guess)); ?></div>
239
240                    <div class="col-sm-4">&nbsp;</div><div class="col-sm-8">&nbsp;</div>
241                    <div class="col-sm-4 control-label">
242                        <?php echo T_('play/.htaccess action'); ?>
243                    </div>
244                    <div class="col-sm-8">
245                        <button type="submit" class="btn btn-warning" name="download_htaccess_play"><?php echo T_('Download'); ?></button>
246                        <button type="submit" class="btn btn-warning" name="write_htaccess_play" <?php if (!check_htaccess_play_writable()) {
247            echo "disabled ";
248        } ?>>
249                            <?php echo T_('Write'); ?>
250                        </button>
251                    </div>
252                    <div class="col-sm-4 control-label"><?php echo T_('play/.htaccess exists?'); ?></div>
253                    <div class="col-sm-8"><?php echo debug_result(is_readable($htaccess_play_file)); ?></div>
254                    <div class="col-sm-4 control-label"><?php echo T_('play/.htaccess configured?'); ?></div>
255                    <div class="col-sm-8"><?php echo debug_result($this->installationHelper->install_check_rewrite_rules($htaccess_play_file, $web_path_guess)); ?></div>
256                <?php
257        } ?>
258
259                <div class="col-sm-4">&nbsp;</div><div class="col-sm-8">&nbsp;</div>
260                <div class="col-sm-4">
261                    <?php echo T_('config/ampache.cfg.php action'); ?>
262                </div>
263                <div class="col-sm-8">
264                    <button type="submit" class="btn btn-warning" name="download"><?php echo T_('Download'); ?></button>
265                    <button type="submit" class="btn btn-warning" name="write" <?php if (!check_config_writable()) {
266            echo T_('Disabled');
267        } ?>>
268                        <?php echo T_('Write'); ?>
269                    </button>
270                </div>
271                <div class="col-sm-4 control-label"><?php echo T_('config/ampache.cfg.php exists?'); ?></div>
272                <div class="col-sm-8"><?php echo debug_result(is_readable($configfile)); ?></div>
273                <div class="col-sm-4 control-label"><?php echo T_('config/ampache.cfg.php configured?'); ?></div>
274                <div class="col-sm-8"><?php $results = @parse_ini_file($configfile); echo debug_result(check_config_values($results)); ?></div>
275                <div class="col-sm-4">&nbsp;</div><div class="col-sm-8">&nbsp;</div>
276
277                <div class="col-sm-4"></div>
278                <?php $check_url = $web_path . "/install.php?action=show_create_config&htmllang=$htmllang&charset=$charset&local_db=" . $_REQUEST['local_db'] . "&local_host=" . $_REQUEST['local_host']; ?>
279                <div class="col-sm-8">
280                    <a href="<?php echo $check_url; ?>">[<?php echo T_('Recheck Config'); ?>]</a>
281                </div>
282            </div>
283        </div>
284    </div>
285</div>
286
287<div class="col-sm-4">
288    <button type="submit" class="btn btn-warning" name="skip_config"><?php echo T_('Skip'); ?></button>
289</div>
290<div class="col-sm-8">
291    <button type="submit" class="btn btn-warning" name="create_all"><?php echo T_('Create Config'); ?></button>
292</div>
293</form>
294
295<?php require __DIR__ . '/install_footer.inc.php'; ?>
296