Fix migration, add planel config, only enable/disable registration

master
root 2 years ago
parent 677de21bf3
commit 2cacf35072

@ -21,7 +21,17 @@
- [x] List last Movies
- [x] List last TvShow
- [ ] Search
- [x] By Name
- [x] By Movie Name
- [x] By TvShows Name
- [x] By Episode Name
- [ ] Panel Configuration
- [x] Enable/Disabled registration
- [ ] Force user to use token on registration
- [ ] Enable/Disable Queue to limit connection
- [ ] Enable/Disable Guest account with limited permissions
- [ ] Enable/Disable Achievements
- [ ] Allow user to add his self Plex Server
- [ ] Enable/Disable Sub-accounts
- [ ] Movies
- [x] Title
- [x] Description
@ -51,7 +61,7 @@
- [X] Add server
- [X] Edit server
- [X] Disable Server
- [X] Delete server
- [ ] Delete server
- [ ] Check state and latence (cron)
- [ ] Management Libraries
- [x] List libraries
@ -66,12 +76,13 @@
- [ ] Netflix [OTHER]
- [ ] Cache
- [ ] Cache Libraries [OTHER]
- [x] Cache Media MetaData [OTHER]
- [x] Cache Media MetaData
- [ ] Cache SQL request [OTHER]
- [ ] Migrate Cache to redis for performance
- [ ] Streaming
- [ ] Implement Video Player that stay when we change of page [OTHER]
- [ ] Management PlexServer
- [ ] Stream directly from PlexServer or use the site like a web-proxy [OTHER]
- [x] Management PlexServer
- [x] Stream directly from PlexServer or use the site like a web-proxy
- [ ] Management User
- [ ] Add sub-account [OTHER]
- [ ] Edit sub-account [OTHER]
@ -79,7 +90,7 @@
- [ ] List of session [OTHER]
- [ ] Ban IP [OTHER]
- [ ] Delete Account [OTHER]
- [ ] Limit acces to ip [OTHER]
- [ ] Limit access by ip [OTHER]
- [ ] Management Permission
- [ ] Limit Quality [OTHER]
- [ ] Limit number streaming [OTHER]

@ -47,17 +47,4 @@ class Controller_Admin extends Controller_Security
$this->template->body = $body;
}
public function action_users()
{
$this->template->js_bottom = ['plex_alert.js'];
$body = View::forge('admin/users');
$users = Model_User::find_all();
$body->set('users', $users);
$this->template->body = $body;
}
}

@ -17,19 +17,4 @@ class Controller_Admin_Libraries extends Controller_Admin
$this->template->body = $body;
}
public function action_permissions()
{
$body = View::forge('admin/libraries/permissions');
$library_id = $this->param('library_id');
$permissions = Model_Permission::find_all();
$body->set('permissions', $permissions);
$body->set('user', Session::get('user'));
$this->template->body = $body;
}
}

@ -0,0 +1,21 @@
<?php
use Fuel\Core\Lang;
use Fuel\Core\Session;
use Fuel\Core\View;
class Controller_Admin_Users extends Controller_Admin
{
public function action_index()
{
$this->template->js_bottom = ['plex_alert.js'];
$body = View::forge('admin/users');
$users = Model_User::find_all();
$body->set('users', $users);
$this->template->body = $body;
}
}

@ -30,10 +30,15 @@ class Controller_Login extends Controller
{
$view = View::forge('login/index');
$start_js = Asset::js('jquery.min.js');
$panel = Config::load('panel', true);
$view->set('registration', (bool)$panel['registration']);
try {
$config = Config::load('db', true);
if (Input::method() === 'POST') {
$config = Config::load('db', true);
$login = Input::post('email');
$password = Input::post('password');

@ -18,6 +18,11 @@ class Controller_Register extends Controller
if(!$lock)
Response::redirect('/install');
$panel = Config::load('panel', true);
if(!$panel['registration'])
Response::redirect('/login');
$user = Session::get('user');
if($user)
@ -45,7 +50,7 @@ class Controller_Register extends Controller
if (Input::post('password') !== Input::post('confirm_password'))
throw new FuelException('Your password are not identical');
if(Model_User::EmailAlreadyUse(Input::post('email')))
if(Model_User::EmailAlreadyUsed(Input::post('email')))
throw new FuelException('Email already use!');
$config = Config::load('db', true);

@ -19,6 +19,7 @@
if(!$user)
Response::redirect('/login');
}
public function action_index()
{
// DO NOTHING

@ -37,7 +37,7 @@ class Controller_Settings_Libraries extends Controller_Settings
$permissions = Model_Permission::find_by('disable', 0);
$library_permissions = Model_Library_Permission::find_by('library_id', $library_id);
$library_permissions = Model_Library_Permission::find_by('library_id', $library_id) ?: [];
$temp = [];

@ -20,7 +20,7 @@ class Model_User extends Model_Overwrite
'disable',
);
public static function EmailAlreadyUse($email)
public static function EmailAlreadyUsed($email)
{
$result = self::find(function ($query) use ($email){
return $query

@ -6,19 +6,18 @@ return array(
array(
'default' =>
array(
0 => '001_create_configurations',
1 => '002_create_library',
2 => '003_create_library_permission',
3 => '004_create_movie',
4 => '005_create_permission',
5 => '006_create_season',
6 => '007_create_server',
7 => '008_create_tvshow',
8 => '009_create_user',
0 => '001_create_library',
1 => '002_create_library_permission',
2 => '003_create_movie',
3 => '004_create_permission',
4 => '005_create_season',
5 => '006_create_server',
6 => '007_create_tvshow',
7 => '008_create_user',
8 => '009_create_user_download',
9 => '010_create_user_history',
10 => '011_create_user_permission',
11 => '012_create_user_settings',
12 => '013_create_user_download',
),
),
'module' =>

@ -0,0 +1,25 @@
<?php
return [
// Enable/Disabled the registration page
'registration' => true,
// Force use to have an invite code when register
'invitation' => false,
// Limit the number of user connected to server
'queue' => false,
'max_connected' => 0, // need queue true
// Alow anyone to use guest account with retricted permissions
// No download and no watching
'guest' => false,
// Enable/Disabled the achievements
'achievements' => false,
// Allow anyone to add plex server
'add_server' => true,
// Allow user to create sub-account
'sub_accounts' => true,
];

@ -13,5 +13,6 @@ return array(
'movie/:movie_id/video/\:/transcode/:transcode/session/:session/:index/:base' => 'movie/stream',
'movie/:movie_id/download' => 'movie/download',
'movie/:movie_id' => 'movie/index',
'settings/libraries/premissions/:library_id' => 'settings/libraries/permissions'
'settings/libraries/premissions/:library_id' => 'settings/libraries/permissions',
'admin/users/premissions/:user_id' => 'admin/users/permissions'
);

@ -0,0 +1,30 @@
<?php
namespace Fuel\Migrations;
class Create_library
{
public function up()
{
\DBUtil::create_table('library', array(
'id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'server_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'plex_key' => array('type' => 'int', 'null' => false, 'constraint' => 11),
'name' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'type' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'updatedAt' => array('type' => 'int', 'null' => false, 'constraint' => 11),
'createdAt' => array('type' => 'int', 'null' => false, 'constraint' => 11),
'scannedAt' => array('type' => 'int', 'null' => false, 'constraint' => 11),
'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
), array('id'));
\DB::query('CREATE INDEX constraintServerLibrary ON ' . \DB::table_prefix('library') . '(`server_id`)')->execute();
}
public function down()
{
\DB::query('DROP INDEX constraintServerLibrary ON ' . \DB::table_prefix('library'))->execute();
\DBUtil::drop_table('library');
}
}

@ -0,0 +1,28 @@
<?php
namespace Fuel\Migrations;
class Create_library_permission
{
public function up()
{
\DBUtil::create_table('library_permission', array(
'id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'permission_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'library_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'value' => array('type' => 'varchar', 'null' => true, 'constraint' => 36),
'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
), array('id'));
\DB::query('CREATE INDEX constraintPermissionLibrariesPermission ON ' . \DB::table_prefix('library_permission') . '(`permission_id`)')->execute();
\DB::query('CREATE INDEX constraintLibraryLibrariesPermission ON ' . \DB::table_prefix('library_permission') . '(`library_id`)')->execute();
}
public function down()
{
\DB::query('DROP INDEX constraintPermissionLibrariesPermission ON ' . \DB::table_prefix('library_permission'))->execute();
\DB::query('DROP INDEX constraintLibraryLibrariesPermission ON ' . \DB::table_prefix('library_permission'))->execute();
\DBUtil::drop_table('library_permission');
}
}

@ -0,0 +1,44 @@
<?php
namespace Fuel\Migrations;
class Create_movie
{
public function up()
{
\DBUtil::create_table('movie', array(
'id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'library_id' => array('type' => 'varchar', 'null' => true, 'constraint' => 36),
'season_id' => array('type' => 'varchar', 'null' => true, 'constraint' => 36),
'plex_key' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'type' => array('type' => 'varchar', 'null' => false, 'constraint' => 20),
'number' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'studio' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'title' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'originalTitle' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'summary' => array('type' => 'text', 'null' => true),
'rating' => array('type' => 'varchar', 'null' => true, 'constraint' => 4),
'year' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'thumb' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'art' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'duration' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'originallyAvailableAt' => array('type' => 'varchar', 'null' => true, 'constraint' => 11),
'addedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
), array('id'));
\DB::query('CREATE INDEX constraintMovieLibrary ON ' . \DB::table_prefix('movie') . '(`library_id`)')->execute();
\DB::query('CREATE INDEX constraintMovieSeason ON ' . \DB::table_prefix('movie') . '(`season_id`)')->execute();
\DB::query('CREATE INDEX searchTitle ON ' . \DB::table_prefix('movie') . '(`title` DESC)')->execute();
}
public function down()
{
\DB::query('DROP INDEX constraintMovieLibrary ON ' . \DB::table_prefix('movie'))->execute();
\DB::query('DROP INDEX constraintMovieSeason ON ' . \DB::table_prefix('movie'))->execute();
\DB::query('DROP INDEX searchTitle ON ' . \DB::table_prefix('movie'))->execute();
\DBUtil::drop_table('movie');
}
}

@ -0,0 +1,21 @@
<?php
namespace Fuel\Migrations;
class Create_permission
{
public function up()
{
\DBUtil::create_table('permission', array(
'id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'name' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'parameters' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
), array('id'));
}
public function down()
{
\DBUtil::drop_table('permission');
}
}

@ -0,0 +1,32 @@
<?php
namespace Fuel\Migrations;
class Create_season
{
public function up()
{
\DBUtil::create_table('season', array(
'id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'tv_show_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'plex_key' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'number' => array('type' => 'int', 'null' => false, 'constraint' => 11),
'title' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'thumb' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'art' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'leafCount' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'addedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
), array('id'));
\DB::query('CREATE INDEX constraintSeasonTvShow ON ' . \DB::table_prefix('season') . '(`tv_show_id`)')->execute();
}
public function down()
{
\DB::query('DROP INDEX constraintSeasonTvShow ON ' . \DB::table_prefix('season'))->execute();
\DBUtil::drop_table('season');
}
}

@ -0,0 +1,35 @@
<?php
namespace Fuel\Migrations;
class Create_server
{
public function up()
{
\DBUtil::create_table('server', array(
'id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'user_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'https' => array('type' => 'int', 'null' => false, 'constraint' => 1),
'url' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'port' => array('type' => 'int', 'null' => true, 'constraint' => 2),
'token' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'lastcheck' => array('type' => 'int', 'null' => false, 'constraint' => 11),
'name' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'plateforme' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'platformVersion' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'version' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'online' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
), array('id'));
\DB::query('CREATE INDEX constraintServerUser ON ' . \DB::table_prefix('server') . '(`user_id`)')->execute();
}
public function down()
{
\DB::query('DROP INDEX constraintServerUser ON ' . \DB::table_prefix('server'))->execute();
\DBUtil::drop_table('server');
}
}

@ -0,0 +1,41 @@
<?php
namespace Fuel\Migrations;
class Create_tvshow
{
public function up()
{
\DBUtil::create_table('tvshow', array(
'id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'library_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'plex_key' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'studio' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'title' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'contentRating' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'summary' => array('type' => 'text', 'null' => true),
'rating' => array('type' => 'varchar', 'null' => true, 'constraint' => 4),
'year' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'thumb' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'art' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'banner' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'theme' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'originallyAvailableAt' => array('type' => 'varchar', 'null' => true, 'constraint' => 255),
'leafCount' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'addedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11),
'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
), array('id'));
\DB::query('CREATE INDEX constraintTvShowLibrary ON ' . \DB::table_prefix('tvshow') . '(`library_id`)')->execute();
\DB::query('CREATE INDEX searchTitle ON ' . \DB::table_prefix('tvshow') . '(`title` DESC)')->execute();
}
public function down()
{
\DB::query('DROP INDEX constraintTvShowLibrary ON ' . \DB::table_prefix('tvshow'))->execute();
\DB::query('DROP INDEX searchTitle ON ' . \DB::table_prefix('tvshow'))->execute();
\DBUtil::drop_table('tvshow');
}
}

@ -0,0 +1,29 @@
<?php
namespace Fuel\Migrations;
class Create_user
{
public function up()
{
\DBUtil::create_table('user', array(
'id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'username' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'email' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'password' => array('type' => 'varchar', 'null' => false, 'constraint' => 255),
'admin' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
'lastlogin' => array('type' => 'int', 'null' => false, 'constraint' => 11),
'parent_id' => array('type' => 'varchar', 'null' => true, 'constraint' => 36),
'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
), array('id'));
\DB::query('CREATE INDEX constraintUserUser ON ' . \DB::table_prefix('user') . '(`parent_id`)')->execute();
}
public function down()
{
\DB::query('DROP INDEX constraintUserUser ON ' . \DB::table_prefix('user'))->execute();
\DBUtil::drop_table('user');
}
}

@ -0,0 +1,27 @@
<?php
namespace Fuel\Migrations;
class Create_user_download
{
public function up()
{
\DBUtil::create_table('user_download', array(
'id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'user_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'movie_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36),
'date' => array('type' => 'int', 'null' => false, 'constraint' => 11),
), array('id'));
\DB::query('CREATE INDEX constraintDownloadUser ON ' . \DB::table_prefix('user_download') . '(`user_id`)')->execute();
\DB::query('CREATE INDEX constraintDownloadMovie ON ' . \DB::table_prefix('user_download') . '(`movie_id`)')->execute();
}
public function down()
{
\DB::query('DROP INDEX constraintDownloadUser ON ' . \DB::table_prefix('user_download'))->execute();
\DB::query('DROP INDEX constraintDownloadMovie ON ' . \DB::table_prefix('user_download'))->execute();
\DBUtil::drop_table('user_download');
}
}

@ -13,7 +13,7 @@ class Create_user_history
'watching_time' => array('type' => 'int', 'null' => false, 'constraint' => 11),
'ended_time' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 11),
'is_ended' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
'date' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1),
'date' => array('type' => 'int', 'null' => false, 'constraint' => 11),
), array('id'));
\DB::query('CREATE INDEX constraintUserUserHistory ON ' . \DB::table_prefix('user_history') . '(`user_id`)')->execute();

@ -9,7 +9,7 @@
<li class="card-tile-list-item card-3-col-item">
<div class="card card-device <?php echo $user->disable ? 'disabled' : ''; ?>">
<div class="card-actions">
<a href="/settings/users/premissions/<?php echo $user->id; ?>">
<a href="/admin/users/premissions/<?php echo $user->id; ?>">
<button class="permissions-user-btn card-action-btn" data-library-id="<?php echo $user->id; ?>"
data-toggle="tooltip" data-original-title="Permissions">
<i class="glyphicon unlock"></i>

@ -78,7 +78,9 @@
<span class="qxG01S">Sign in</span>
</button>
</form>
<?php if($registration) : ?>
<span class="_3kVXYV _3TSWy2">Need an account? <a href="/register" role="link" class=" _2n0yJn _1vcAGA ">Create an account!</a></span>
<?php endif; ?>
</div>
</div>
</div>

Loading…
Cancel
Save