diff --git a/fuel/app/classes/controller/admin.php b/fuel/app/classes/controller/admin.php index 9501665..12f2496 100755 --- a/fuel/app/classes/controller/admin.php +++ b/fuel/app/classes/controller/admin.php @@ -1,12 +1,11 @@ template->MenuLibraries = $this->template->MenuServer ? $this->template->MenuServer->getLibraries() : null; - $watching_movies = Model_User_Watching::find_by([ + $watching_movies = Model_User_History::find_by([ ['user_id', '=', $this->_user->id], ['is_ended', '=', 0] ]); diff --git a/fuel/app/classes/controller/index.php b/fuel/app/classes/controller/index.php index d16441b..3c3d89d 100644 --- a/fuel/app/classes/controller/index.php +++ b/fuel/app/classes/controller/index.php @@ -8,7 +8,13 @@ class Controller_Index extends Controller { public function before() { + $lock = Config::load('lock', true); + + if(!$lock) + Response::redirect('/install'); + $user = Session::get('user'); + if(!$user) Response::redirect('/login'); else diff --git a/fuel/app/classes/controller/login.php b/fuel/app/classes/controller/login.php index 6b50e59..dbd43b2 100755 --- a/fuel/app/classes/controller/login.php +++ b/fuel/app/classes/controller/login.php @@ -15,14 +15,15 @@ class Controller_Login extends Controller { parent::before(); - $user = Session::get('user'); $lock = Config::load('lock', true); - if($user) - Response::redirect('/home'); - if(!$lock) Response::redirect('/install'); + + $user = Session::get('user'); + + if($user) + Response::redirect('/home'); } public function action_index() diff --git a/fuel/app/classes/controller/register.php b/fuel/app/classes/controller/register.php index 4fef9a6..4645f4f 100755 --- a/fuel/app/classes/controller/register.php +++ b/fuel/app/classes/controller/register.php @@ -12,6 +12,12 @@ class Controller_Register extends Controller public function before() { parent::before(); + + $lock = Config::load('lock', true); + + if(!$lock) + Response::redirect('/install'); + $user = Session::get('user'); if($user) diff --git a/fuel/app/classes/controller/rest/install.php b/fuel/app/classes/controller/rest/install.php index 241a6c5..94f10a6 100755 --- a/fuel/app/classes/controller/rest/install.php +++ b/fuel/app/classes/controller/rest/install.php @@ -311,10 +311,10 @@ class Controller_Rest_Install extends Controller_Rest * CREATE TABLE USER'S WATCHING */ DBUtil::create_table( - 'user_watching', + 'user_history', array( 'id' => array('constraint' => 36, 'type' => 'varchar'), - 'user_id' => array('constraint' => 11, 'type' => 'int'), + 'user_id' => array('constraint' => 36, 'type' => 'varchar'), 'movie_id' => array('constraint' => 36, 'type' => 'varchar'), 'watching_time' => array('constraint' => 11, 'type' => 'int'), 'ended_time' => array('constraint' => 11, 'type' => 'int', 'default' => 0), @@ -437,8 +437,8 @@ class Controller_Rest_Install extends Controller_Rest 'on_update' => 'NO ACTION', 'on_delete' => 'NO ACTION', )); - /*DBUtil::add_foreign_key('user_watching', array( - 'constraint' => 'constraintUserUserWatching', + DBUtil::add_foreign_key('user_history', array( + 'constraint' => 'constraintUserUserHistory', 'key' => 'user_id', 'reference' => array( 'table' => 'user', @@ -446,9 +446,9 @@ class Controller_Rest_Install extends Controller_Rest ), 'on_update' => 'NO ACTION', 'on_delete' => 'NO ACTION', - ));*/ - DBUtil::add_foreign_key('user_watching', array( - 'constraint' => 'constraintMovieWatching', + )); + DBUtil::add_foreign_key('user_history', array( + 'constraint' => 'constraintMovieHistory', 'key' => 'movie_id', 'reference' => array( 'table' => 'movie', @@ -514,18 +514,18 @@ class Controller_Rest_Install extends Controller_Rest return $this->response(['error' => false, 'message' => $logs]); } catch (FuelException $e) { try { - DBUtil::drop_table('user_watching'); - DBUtil::drop_table('user_permission'); + DBUtil::drop_table('user_history'); + DBUtil::drop_table('user_permission'); DBUtil::drop_table('user_settings'); DBUtil::drop_table('library_permission'); DBUtil::drop_table('movie'); DBUtil::drop_table('season'); DBUtil::drop_table('tvshow'); DBUtil::drop_table('library'); - DBUtil::drop_table('server'); - DBUtil::drop_table('configurations'); + DBUtil::drop_table('server'); + DBUtil::drop_table('configurations'); DBUtil::drop_table('user'); - DBUtil::drop_table('permission'); + DBUtil::drop_table('permission'); DBUtil::drop_table('library'); return $this->response(array('error' => true, 'message' => $e->getMessage()), 400); diff --git a/fuel/app/classes/controller/rest/movie.php b/fuel/app/classes/controller/rest/movie.php index ce9a02b..9d38cdc 100644 --- a/fuel/app/classes/controller/rest/movie.php +++ b/fuel/app/classes/controller/rest/movie.php @@ -8,9 +8,9 @@ use Fuel\Core\Session; use Fuel\Core\View; use Fuel\Core\FuelException; -class Controller_Rest_Movie extends Controller_Rest_Index +class Controller_Rest_Movie extends Controller_Rest { - public function get_stream(): object + public function get_stream() { try { @@ -30,10 +30,10 @@ class Controller_Rest_Movie extends Controller_Rest_Index throw new FuelException('You dont have the permission to watch in this library!'); } - $user_settings = Model_Setting::find_one_by('user_id', Session::get('user')->id); + $user_settings = Model_User_Settings::find_one_by('user_id', Session::get('user')->id); if ($movie->type !== 'movie') { - $episodes = $movie->getSeason()?->getEpisodes(); + $episodes = $movie->getSeason()->getEpisodes(); } else { $episodes = [$movie]; @@ -60,10 +60,10 @@ class Controller_Rest_Movie extends Controller_Rest_Index $timeplay = Input::post('timeplay'); $isFinish = Input::post('isFinish'); - $watching = Model_User_Watching::find_one_by([ + $watching = Model_User_History::find_one_by([ ['movie_id', '=', $movie_id], ['user_id', '=', $user->id] - ]) ?: new Model_User_Watching(); + ]) ?: new Model_User_History(); $watching->set([ 'user_id' => $user->id, diff --git a/fuel/app/classes/controller/rest/player.php b/fuel/app/classes/controller/rest/player.php index 1ba28d2..7a1d4bc 100644 --- a/fuel/app/classes/controller/rest/player.php +++ b/fuel/app/classes/controller/rest/player.php @@ -24,10 +24,10 @@ class Controller_Rest_Player extends Controller_Rest if (!$movie) throw new FuelException('No movie found'); - $user_watching = Model_User_Watching::find_one_by([ + $user_watching = Model_User_History::find_one_by([ ['movie_id', '=', $movie_id], ['movie_id', '=', $user->id] - ]) ?: new Model_User_Watching(); + ]) ?: new Model_User_History(); return $this->response(['error' => false, 'message' => 'OK!'], 200); } catch (Exception $exception) { diff --git a/fuel/app/classes/controller/security.php b/fuel/app/classes/controller/security.php new file mode 100644 index 0000000..c68a307 --- /dev/null +++ b/fuel/app/classes/controller/security.php @@ -0,0 +1,26 @@ +id); + $settings = Model_User_Settings::find_one_by('user_id', Session::get('user')->id); $is_submit = Input::post('submit'); if(isset($is_submit)) { - $settings = !empty($settings) ? $settings : new Model_Setting(); + $settings = !empty($settings) ? $settings : new Model_User_Settings(); $settings->set([ 'user_id' => $this->_user->id, 'language' => Input::post('language'), diff --git a/fuel/app/classes/model/user/watching.php b/fuel/app/classes/model/user/history.php similarity index 81% rename from fuel/app/classes/model/user/watching.php rename to fuel/app/classes/model/user/history.php index 9ce02b1..1a85fe6 100644 --- a/fuel/app/classes/model/user/watching.php +++ b/fuel/app/classes/model/user/history.php @@ -2,9 +2,9 @@ -class Model_User_Watching extends Model_Overwrite +class Model_User_History extends Model_Overwrite { - protected static $_table_name = 'user_watching'; + protected static $_table_name = 'user_history'; protected static $_primary_key = 'id'; protected static $_properties = array( 'id', diff --git a/fuel/app/classes/model/setting.php b/fuel/app/classes/model/user/settings.php similarity index 75% rename from fuel/app/classes/model/setting.php rename to fuel/app/classes/model/user/settings.php index 8e32e36..c6ef544 100644 --- a/fuel/app/classes/model/setting.php +++ b/fuel/app/classes/model/user/settings.php @@ -1,8 +1,8 @@ 'required', diff --git a/fuel/app/views/libraries/list.php b/fuel/app/views/libraries/list.php index 76a60f1..4e7f5b8 100644 --- a/fuel/app/views/libraries/list.php +++ b/fuel/app/views/libraries/list.php @@ -253,50 +253,34 @@ let number = 1; - $('.PosterCardImg-imageContainer-1Ar4M[data-movie-id]').each(function (index, element) { + $('.PosterCardImg-imageContainer-1Ar4M[data-movie-id]:not(.hasBackground)').each(function (index, element) { let movie_id = $(element).data('movie-id'); - let position = element.getBoundingClientRect(); - let movie = document.querySelector('[data-movie-id="' + movie_id + '"] > div'); - if( position.top > 0 && position.top <= (window.innerHeight || document.documentElement.clientHeight) && !movie.classList.contains('hasBackground') ) { - movie.classList.add('hasBackground'); - /** IF USING CLOUDFLARE TOO MANY REQUEST **/ - setTimeout(function () { - $('[data-movie-id="' + movie_id + '"] > div') - .css('opacity', 0) - .css('background-image', 'url("/cover/movie?movie_id=' + movie_id + '&width=' + 175 + '&height=' + 263 + '")') - .animate({opacity: 1}, 500); - }, 50 +( 50 * number)); - number++; - } else if( ( position.top < 0 || position.top > (window.innerHeight || document.documentElement.clientHeight) ) && movie.classList.contains('hasBackground') ) { - $('[data-movie-id="' + movie_id + '"] > div').css('background-image', '') - .removeClass('hasBackground') - .animate({opacity: 0}, 500); - } + this.classList.add('hasBackground'); + /** IF USING CLOUDFLARE TOO MANY REQUEST **/ + setTimeout(function () { + $('[data-movie-id="' + movie_id + '"] > div') + .css('opacity', 0) + .css('background-image', 'url("/cover/movie?movie_id=' + movie_id + '&width=' + 175 + '&height=' + 263 + '")') + .animate({opacity: 1}, 500); + }, 50 +( 50 * number)); + number++; }); - $('.PosterCardImg-imageContainer-1Ar4M[data-tvshow-id]').each(function (index, element) { + $('.PosterCardImg-imageContainer-1Ar4M[data-tvshow-id]:not(.hasBackground)').each(function (index, element) { let tvshow_id = $(element).data('tvshow-id'); - let position = element.getBoundingClientRect(); - let tvshow = document.querySelector('[data-tvshow-id="' + tvshow_id + '"] > div'); - if( position.top > 0 && position.top <= (window.innerHeight || document.documentElement.clientHeight) && !tvshow.classList.contains('hasBackground') ) { - tvshow.classList.add('hasBackground'); - /** IF USING CLOUDFLARE TOO MANY REQUEST **/ - setTimeout(function () { - $('[data-tvshow-id="' + tvshow_id + '"] > div') - .css('opacity', 0) - .css('background-image', 'url("/cover/tvshow?tvshow_id=' + tvshow_id + '&width=' + 175 + '&height=' + 263 + '")') - .animate({opacity: 1}, 500); - }, 50 +( 50 * number)); - number++; - } else if( ( position.top < 0 || position.top > (window.innerHeight || document.documentElement.clientHeight) ) && tvshow.classList.contains('hasBackground') ) { - $('[data-tvshow-id="' + tvshow_id + '"] > div').css('background-image', '') - .removeClass('hasBackground') - .animate({opacity: 0}, 500); - } + this.classList.add('hasBackground'); + /** IF USING CLOUDFLARE TOO MANY REQUEST **/ + setTimeout(function () { + $('[data-tvshow-id="' + tvshow_id + '"] > div') + .css('opacity', 0) + .css('background-image', 'url("/cover/tvshow?tvshow_id=' + tvshow_id + '&width=' + 175 + '&height=' + 263 + '")') + .animate({opacity: 1}, 500); + }, 50 +( 50 * number)); + number++; }); }); diff --git a/fuel/app/views/movie/list.php b/fuel/app/views/movie/list.php index 5cc17c6..fb8aa00 100644 --- a/fuel/app/views/movie/list.php +++ b/fuel/app/views/movie/list.php @@ -337,24 +337,16 @@ $('.PosterCardImg-imageContainer-1Ar4M[data-movie-id]:not(.hasBackground)').each(function (index, element) { let movie_id = $(element).data('movie-id'); - let position = element.getBoundingClientRect(); - let movie = document.querySelector('[data-movie-id="' + movie_id + '"] > div'); - //if( position.top > 0 && position.top <= (window.innerHeight || document.documentElement.clientHeight) && !movie.classList.contains('hasBackground') ) { - this.classList.add('hasBackground'); - // IF USING CLOUDFLARE TOO MANY REQUEST - setTimeout(function () { - $('[data-movie-id="' + movie_id + '"] > div') - .css('opacity', 0) - .css('background-image', 'url("/cover/movie?movie_id=' + movie_id + '&width=' + 175 + '&height=' + 263 + '")') - .animate({opacity: 1}, 500); - }, 100 +( 50 * number)); - number++; - /*} else if( ( position.top < 0 || position.top > (window.innerHeight || document.documentElement.clientHeight) ) && movie.classList.contains('hasBackground') ) { - $('[data-movie-id="' + movie_id + '"] > div').css('background-image', '') - .removeClass('hasBackground') - .animate({opacity: 0}, 500); - }*/ + this.classList.add('hasBackground'); + // IF USING CLOUDFLARE TOO MANY REQUEST + setTimeout(function () { + $('[data-movie-id="' + movie_id + '"] > div') + .css('opacity', 0) + .css('background-image', 'url("/cover/movie?movie_id=' + movie_id + '&width=' + 175 + '&height=' + 263 + '")') + .animate({opacity: 1}, 500); + }, 100 +( 50 * number)); + number++; }); });