mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-03 09:49:30 +02:00
Fix channel htaccess installation
This commit is contained in:
parent
b04208b5c3
commit
a6d68fef55
7 changed files with 70 additions and 1 deletions
|
@ -2,5 +2,5 @@
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RewriteCond %{REQUEST_FILENAME} !-d
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
RewriteCond %{REQUEST_FILENAME} !-s
|
RewriteCond %{REQUEST_FILENAME} !-s
|
||||||
RewriteRule ^([0-9]+)/(.*)$ index.php?channel=$1&target=$2 [PT,L,QSA]
|
RewriteRule ^([0-9]+)/(.*)$ /channel/index.php?channel=$1&target=$2 [PT,L,QSA]
|
||||||
</IfModule>
|
</IfModule>
|
|
@ -37,6 +37,7 @@ define('INSTALL', 1);
|
||||||
|
|
||||||
$htaccess_play_file = AmpConfig::get('prefix') . '/play/.htaccess';
|
$htaccess_play_file = AmpConfig::get('prefix') . '/play/.htaccess';
|
||||||
$htaccess_rest_file = AmpConfig::get('prefix') . '/rest/.htaccess';
|
$htaccess_rest_file = AmpConfig::get('prefix') . '/rest/.htaccess';
|
||||||
|
$htaccess_channel_file = AmpConfig::get('prefix') . '/channel/.htaccess';
|
||||||
|
|
||||||
// Clean up incoming variables
|
// Clean up incoming variables
|
||||||
$web_path = scrub_in($_REQUEST['web_path']);
|
$web_path = scrub_in($_REQUEST['web_path']);
|
||||||
|
@ -142,12 +143,17 @@ switch ($_REQUEST['action']) {
|
||||||
if (!$skip) {
|
if (!$skip) {
|
||||||
$write = (isset($_POST['write']));
|
$write = (isset($_POST['write']));
|
||||||
$download = (isset($_POST['download']));
|
$download = (isset($_POST['download']));
|
||||||
|
$download_htaccess_channel = (isset($_POST['download_htaccess_channel']));
|
||||||
$download_htaccess_rest = (isset($_POST['download_htaccess_rest']));
|
$download_htaccess_rest = (isset($_POST['download_htaccess_rest']));
|
||||||
$download_htaccess_play = (isset($_POST['download_htaccess_play']));
|
$download_htaccess_play = (isset($_POST['download_htaccess_play']));
|
||||||
|
$write_htaccess_channel = (isset($_POST['write_htaccess_channel']));
|
||||||
$write_htaccess_rest = (isset($_POST['write_htaccess_rest']));
|
$write_htaccess_rest = (isset($_POST['write_htaccess_rest']));
|
||||||
$write_htaccess_play = (isset($_POST['write_htaccess_play']));
|
$write_htaccess_play = (isset($_POST['write_htaccess_play']));
|
||||||
|
|
||||||
$created_config = true;
|
$created_config = true;
|
||||||
|
if ($write_htaccess_channel || $download_htaccess_channel || $all) {
|
||||||
|
$created_config = $created_config && install_rewrite_rules($htaccess_channel_file, $_POST['web_path'], $download_htaccess_channel);
|
||||||
|
}
|
||||||
if ($write_htaccess_rest || $download_htaccess_rest || $all) {
|
if ($write_htaccess_rest || $download_htaccess_rest || $all) {
|
||||||
$created_config = $created_config && install_rewrite_rules($htaccess_rest_file, $_POST['web_path'], $download_htaccess_rest);
|
$created_config = $created_config && install_rewrite_rules($htaccess_rest_file, $_POST['web_path'], $download_htaccess_rest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ class Channel extends database_object implements media, library_item
|
||||||
public $loop;
|
public $loop;
|
||||||
public $bitrate;
|
public $bitrate;
|
||||||
public $name;
|
public $name;
|
||||||
|
public $description;
|
||||||
|
|
||||||
public $tags;
|
public $tags;
|
||||||
public $f_tags;
|
public $f_tags;
|
||||||
|
@ -232,6 +233,18 @@ class Channel extends database_object implements media, library_item
|
||||||
return 'default';
|
return 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_description()
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function display_art($thumb = 2)
|
||||||
|
{
|
||||||
|
if (Art::has_db($this->id, 'channel')) {
|
||||||
|
Art::display('channel', $this->id, $this->get_fullname(), $thumb, $this->link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function get_target_object()
|
public function get_target_object()
|
||||||
{
|
{
|
||||||
$object = null;
|
$object = null;
|
||||||
|
|
|
@ -156,6 +156,18 @@ class Live_Stream extends database_object implements media, library_item
|
||||||
return 'default';
|
return 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_description()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function display_art($thumb = 2)
|
||||||
|
{
|
||||||
|
if (Art::has_db($this->id, 'live_stream')) {
|
||||||
|
Art::display('live_stream', $this->id, $this->get_fullname(), $thumb, $this->link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update
|
* update
|
||||||
* This is a static function that takes a key'd array for input
|
* This is a static function that takes a key'd array for input
|
||||||
|
|
|
@ -2552,6 +2552,7 @@ class Update
|
||||||
|
|
||||||
$htaccess_play_file = AmpConfig::get('prefix') . '/play/.htaccess';
|
$htaccess_play_file = AmpConfig::get('prefix') . '/play/.htaccess';
|
||||||
$htaccess_rest_file = AmpConfig::get('prefix') . '/rest/.htaccess';
|
$htaccess_rest_file = AmpConfig::get('prefix') . '/rest/.htaccess';
|
||||||
|
$htaccess_channel_file = AmpConfig::get('prefix') . '/channel/.htaccess';
|
||||||
|
|
||||||
$ret = true;
|
$ret = true;
|
||||||
if (!is_readable($htaccess_play_file)) {
|
if (!is_readable($htaccess_play_file)) {
|
||||||
|
@ -2586,6 +2587,22 @@ class Update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_readable($htaccess_channel_file)) {
|
||||||
|
$created = false;
|
||||||
|
if (check_htaccess_channel_writable()) {
|
||||||
|
if (!install_rewrite_rules($htaccess_channel_file, AmpConfig::get('raw_web_path'), false)) {
|
||||||
|
Error::add('general', T_('File copy error.'));
|
||||||
|
} else {
|
||||||
|
$created = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$created) {
|
||||||
|
Error::add('general', T_('Cannot copy default .htaccess file.') . ' Please copy <b>' . $htaccess_channel_file . '.dist</b> to <b>' . $htaccess_channel_file . '</b>.');
|
||||||
|
$ret = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,12 @@ function check_config_writable()
|
||||||
|| (!file_exists(AmpConfig::get('prefix') . '/config/ampache.cfg.php') && is_writeable(AmpConfig::get('prefix') . '/config/')));
|
|| (!file_exists(AmpConfig::get('prefix') . '/config/ampache.cfg.php') && is_writeable(AmpConfig::get('prefix') . '/config/')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function check_htaccess_channel_writable()
|
||||||
|
{
|
||||||
|
return ((file_exists(AmpConfig::get('prefix') . '/channel/.htaccess') && is_writable(AmpConfig::get('prefix') . '/channel/.htaccess'))
|
||||||
|
|| (!file_exists(AmpConfig::get('prefix') . '/channel/.htaccess') && is_writeable(AmpConfig::get('prefix') . '/channel/')));
|
||||||
|
}
|
||||||
|
|
||||||
function check_htaccess_rest_writable()
|
function check_htaccess_rest_writable()
|
||||||
{
|
{
|
||||||
return ((file_exists(AmpConfig::get('prefix') . '/rest/.htaccess') && is_writable(AmpConfig::get('prefix') . '/rest/.htaccess'))
|
return ((file_exists(AmpConfig::get('prefix') . '/rest/.htaccess') && is_writable(AmpConfig::get('prefix') . '/rest/.htaccess'))
|
||||||
|
|
|
@ -183,6 +183,21 @@ require $prefix . '/templates/install_header.inc.php';
|
||||||
<div id="collapseConfigFiles" class="panel-collapse collapse <?php if(isset($created_config) && !$created_config) echo "in"; ?>">
|
<div id="collapseConfigFiles" class="panel-collapse collapse <?php if(isset($created_config) && !$created_config) echo "in"; ?>">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<?php if (install_check_server_apache()) { ?>
|
<?php if (install_check_server_apache()) { ?>
|
||||||
|
<div class="col-sm-4"> </div><div class="col-sm-8"> </div>
|
||||||
|
<div class="col-sm-4 control-label">
|
||||||
|
<?php echo T_('channel/.htaccess action'); ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<button type="submit" class="btn btn-warning" name="download_htaccess_channel"><?php echo T_('Download'); ?></button>
|
||||||
|
<button type="submit" class="btn btn-warning" name="write_htaccess_channel" <?php if (!check_htaccess_channel_writable()) { echo "disabled "; } ?>>
|
||||||
|
<?php echo T_('Write'); ?>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-4 control-label"><?php echo T_('channel/.htaccess exists?'); ?></div>
|
||||||
|
<div class="col-sm-8"><?php echo debug_result(is_readable($htaccess_channel_file)); ?></div>
|
||||||
|
<div class="col-sm-4 control-label"><?php echo T_('channel/.htaccess configured?'); ?></div>
|
||||||
|
<div class="col-sm-8"><?php echo debug_result(install_check_rewrite_rules($htaccess_channel_file, $web_path_guess)); ?></div>
|
||||||
|
|
||||||
<div class="col-sm-4"> </div><div class="col-sm-8"> </div>
|
<div class="col-sm-4"> </div><div class="col-sm-8"> </div>
|
||||||
<div class="col-sm-4 control-label">
|
<div class="col-sm-4 control-label">
|
||||||
<?php echo T_('rest/.htaccess action'); ?>
|
<?php echo T_('rest/.htaccess action'); ?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue