From a6d68fef556d352a2dc5dc90200e2052aa41b9a5 Mon Sep 17 00:00:00 2001 From: Afterster Date: Sun, 5 Apr 2015 21:00:38 +0200 Subject: [PATCH] Fix channel htaccess installation --- channel/{.htaccess => .htaccess.dist} | 2 +- install.php | 6 ++++++ lib/class/channel.class.php | 13 +++++++++++++ lib/class/live_stream.class.php | 12 ++++++++++++ lib/class/update.class.php | 17 +++++++++++++++++ lib/debug.lib.php | 6 ++++++ templates/show_install_config.inc.php | 15 +++++++++++++++ 7 files changed, 70 insertions(+), 1 deletion(-) rename channel/{.htaccess => .htaccess.dist} (62%) diff --git a/channel/.htaccess b/channel/.htaccess.dist similarity index 62% rename from channel/.htaccess rename to channel/.htaccess.dist index 0eb7988d..e60d35cd 100644 --- a/channel/.htaccess +++ b/channel/.htaccess.dist @@ -2,5 +2,5 @@ RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d 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] \ No newline at end of file diff --git a/install.php b/install.php index ff5b7352..686c1b7f 100644 --- a/install.php +++ b/install.php @@ -37,6 +37,7 @@ define('INSTALL', 1); $htaccess_play_file = AmpConfig::get('prefix') . '/play/.htaccess'; $htaccess_rest_file = AmpConfig::get('prefix') . '/rest/.htaccess'; +$htaccess_channel_file = AmpConfig::get('prefix') . '/channel/.htaccess'; // Clean up incoming variables $web_path = scrub_in($_REQUEST['web_path']); @@ -142,12 +143,17 @@ switch ($_REQUEST['action']) { if (!$skip) { $write = (isset($_POST['write'])); $download = (isset($_POST['download'])); + $download_htaccess_channel = (isset($_POST['download_htaccess_channel'])); $download_htaccess_rest = (isset($_POST['download_htaccess_rest'])); $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_play = (isset($_POST['write_htaccess_play'])); $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) { $created_config = $created_config && install_rewrite_rules($htaccess_rest_file, $_POST['web_path'], $download_htaccess_rest); } diff --git a/lib/class/channel.class.php b/lib/class/channel.class.php index a4682bff..15875d2c 100644 --- a/lib/class/channel.class.php +++ b/lib/class/channel.class.php @@ -37,6 +37,7 @@ class Channel extends database_object implements media, library_item public $loop; public $bitrate; public $name; + public $description; public $tags; public $f_tags; @@ -232,6 +233,18 @@ class Channel extends database_object implements media, library_item 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() { $object = null; diff --git a/lib/class/live_stream.class.php b/lib/class/live_stream.class.php index cdbfeefe..d095bb28 100644 --- a/lib/class/live_stream.class.php +++ b/lib/class/live_stream.class.php @@ -156,6 +156,18 @@ class Live_Stream extends database_object implements media, library_item 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 * This is a static function that takes a key'd array for input diff --git a/lib/class/update.class.php b/lib/class/update.class.php index ce549f04..cba4abd1 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -2552,6 +2552,7 @@ class Update $htaccess_play_file = AmpConfig::get('prefix') . '/play/.htaccess'; $htaccess_rest_file = AmpConfig::get('prefix') . '/rest/.htaccess'; + $htaccess_channel_file = AmpConfig::get('prefix') . '/channel/.htaccess'; $ret = true; 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 ' . $htaccess_channel_file . '.dist to ' . $htaccess_channel_file . '.'); + $ret = false; + } + } + return $ret; } diff --git a/lib/debug.lib.php b/lib/debug.lib.php index 8a222bd1..d76af278 100644 --- a/lib/debug.lib.php +++ b/lib/debug.lib.php @@ -263,6 +263,12 @@ function check_config_writable() || (!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() { return ((file_exists(AmpConfig::get('prefix') . '/rest/.htaccess') && is_writable(AmpConfig::get('prefix') . '/rest/.htaccess')) diff --git a/templates/show_install_config.inc.php b/templates/show_install_config.inc.php index 1a131671..0f489aff 100644 --- a/templates/show_install_config.inc.php +++ b/templates/show_install_config.inc.php @@ -183,6 +183,21 @@ require $prefix . '/templates/install_header.inc.php';
">
+
 
 
+
+ +
+
+ + +
+
+
+
+
+