parent
07bdc95fcb
commit
f6716ed53b
@ -0,0 +1,12 @@
|
|||||||
|
language: php
|
||||||
|
php:
|
||||||
|
- 5.3
|
||||||
|
- 5.4
|
||||||
|
- 5.5
|
||||||
|
- 7.0
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- curl -s http://getcomposer.org/installer | php
|
||||||
|
- php composer.phar install --dev
|
||||||
|
|
||||||
|
script: php oil test
|
@ -1,42 +1,48 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Fuel\Core\Controller;
|
use Fuel\Core\Controller;
|
||||||
use Fuel\Core\FuelException;
|
use Fuel\Core\FuelException;
|
||||||
use Fuel\Core\View;
|
use Fuel\Core\Response;
|
||||||
use Fuel\Core\Asset;
|
use Fuel\Core\View;
|
||||||
|
use Fuel\Core\Asset;
|
||||||
class Controller_Install extends Controller
|
|
||||||
{
|
class Controller_Install extends Controller
|
||||||
public function action_index()
|
{
|
||||||
{
|
public function action_index()
|
||||||
$view = View::forge('install/index');
|
{
|
||||||
|
$lock = Config::load('lock', true);
|
||||||
$js = Asset::js('plex_alert.js');
|
|
||||||
|
if($lock)
|
||||||
$view->set_safe('end_js', $js);
|
Response::redirect('/login');
|
||||||
|
|
||||||
$config_db = Config::load('db', true);
|
$view = View::forge('install/index');
|
||||||
$config_db = $config_db['default'];
|
|
||||||
|
$js = Asset::js('plex_alert.js');
|
||||||
$view->set('db_host', $config_db['connection']['hostname']);
|
|
||||||
$view->set('db_port', $config_db['connection']['port']);
|
$view->set_safe('end_js', $js);
|
||||||
$view->set('db_database', $config_db['connection']['database']);
|
|
||||||
$view->set('db_prefix', $config_db['table_prefix']);
|
$config_db = Config::load('db', true);
|
||||||
$view->set('db_username', $config_db['connection']['username']);
|
$config_db = $config_db['default'];
|
||||||
$view->set('db_password', $config_db['connection']['password']);
|
|
||||||
|
$view->set('db_host', $config_db['connection']['hostname']);
|
||||||
try {
|
$view->set('db_port', $config_db['connection']['port']);
|
||||||
$config_plex = Model_Server::find()[0];
|
$view->set('db_database', $config_db['connection']['database']);
|
||||||
|
$view->set('db_prefix', $config_db['table_prefix']);
|
||||||
if($config_plex) {
|
$view->set('db_username', $config_db['connection']['username']);
|
||||||
$view->set('plex_url', $config_plex->url);
|
$view->set('db_password', $config_db['connection']['password']);
|
||||||
$view->set('plex_port', $config_plex->port);
|
|
||||||
$view->set('plex_token', $config_plex->token);
|
try {
|
||||||
}
|
$config_plex = Model_Server::find()[0];
|
||||||
}catch (FuelException $e){
|
|
||||||
//@TODO
|
if($config_plex) {
|
||||||
}
|
$view->set('plex_url', $config_plex->url);
|
||||||
|
$view->set('plex_port', $config_plex->port);
|
||||||
return $view;
|
$view->set('plex_token', $config_plex->token);
|
||||||
}
|
}
|
||||||
|
}catch (FuelException $e){
|
||||||
|
//@TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,463 +1,465 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Fuel\Core\Config;
|
use Fuel\Core\Config;
|
||||||
use Fuel\Core\Controller_Rest;
|
use Fuel\Core\Controller_Rest;
|
||||||
use Fuel\Core\DB;
|
use Fuel\Core\DB;
|
||||||
use Fuel\Core\DBUtil;
|
use Fuel\Core\DBUtil;
|
||||||
use Fuel\Core\FuelException;
|
use Fuel\Core\FuelException;
|
||||||
use Fuel\Core\Input;
|
use Fuel\Core\Input;
|
||||||
use Fuel\Core\Request;
|
use Fuel\Core\Request;
|
||||||
use Fuel\Core\Str;
|
use Fuel\Core\Str;
|
||||||
|
|
||||||
class Controller_Rest_Install extends Controller_Rest
|
class Controller_Rest_Install extends Controller_Rest
|
||||||
{
|
{
|
||||||
public function post_require()
|
public function post_require()
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
$version = version_compare(PHP_VERSION, 5.6, '>=');
|
$version = version_compare(PHP_VERSION, 5.6, '>=');
|
||||||
$result['version'] = $version ? true : false;
|
$result['version'] = $version ? true : false;
|
||||||
|
|
||||||
$result['mysql'] = extension_loaded('mysql') ? true : false;
|
$result['mysql'] = extension_loaded('mysql') ? true : false;
|
||||||
$result['mysqli'] = extension_loaded('mysqli') ? true : false;
|
$result['mysqli'] = extension_loaded('mysqli') ? true : false;
|
||||||
$result['pdo_mysql'] = extension_loaded('pdo_mysql') ? true : false;
|
$result['pdo_mysql'] = extension_loaded('pdo_mysql') ? true : false;
|
||||||
$result['simplexml'] = extension_loaded('SimpleXML') ? true : false;
|
$result['simplexml'] = extension_loaded('SimpleXML') ? true : false;
|
||||||
$result['curl'] = function_exists('curl_version') ? true : false;
|
$result['curl'] = function_exists('curl_version') ? true : false;
|
||||||
$result['config'] = is_writable('../fuel/app/config/') ? true : false;
|
$result['config'] = is_writable('../fuel/app/config/') ? true : false;
|
||||||
|
|
||||||
return $this->response($result);
|
return $this->response($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post_config()
|
public function post_config()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$host = Input::post('host');
|
$host = Input::post('host');
|
||||||
$port = Input::post('port');
|
$port = Input::post('port');
|
||||||
$dbname = Input::post('database');
|
$dbname = Input::post('database');
|
||||||
$username = Input::post('username');
|
$username = Input::post('username');
|
||||||
$password = Input::post('password');
|
$password = Input::post('password');
|
||||||
|
|
||||||
$boolean = Config::load('db', true);
|
$boolean = Config::load('db', true);
|
||||||
|
|
||||||
if(!$boolean)
|
if(!$boolean)
|
||||||
throw new FuelException('Config db.php not work!');
|
throw new FuelException('Config db.php not work!');
|
||||||
|
|
||||||
$config = array(
|
$config = array(
|
||||||
'active' => 'default',
|
'active' => 'default',
|
||||||
'default' => array(
|
'default' => array(
|
||||||
'type' => 'pdo',
|
'type' => 'pdo',
|
||||||
'connection' => array(
|
'connection' => array(
|
||||||
'dsn' => 'mysql:host=' . $host . ($port ? ';port=' . $port : '') . ';dbname=' . $dbname,
|
'dsn' => 'mysql:host=' . $host . ($port ? ';port=' . $port : '') . ';dbname=' . $dbname,
|
||||||
'hostname' => $host,
|
'hostname' => $host,
|
||||||
'port' => $port,
|
'port' => $port,
|
||||||
'database' => $dbname,
|
'database' => $dbname,
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
),
|
),
|
||||||
'table_prefix' => 'plex_',
|
'table_prefix' => 'plex_',
|
||||||
'charset' => 'utf8',
|
'charset' => 'utf8',
|
||||||
'enable_cache' => true,
|
'enable_cache' => true,
|
||||||
'hash' => Str::random('alnum', 32)
|
'hash' => Str::random('alnum', 32)
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Config::save('db', $config);
|
Config::save('db', $config);
|
||||||
|
|
||||||
return $this->response(array('error' => false));
|
return $this->response(array('error' => false));
|
||||||
}catch (FuelException $e) {
|
}catch (FuelException $e) {
|
||||||
return $this->response(array('error' => true, 'message' => $e->getMessage()), 400);
|
return $this->response(array('error' => true, 'message' => $e->getMessage()), 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post_tables()
|
public function post_tables()
|
||||||
{
|
{
|
||||||
|
|
||||||
Config::load('db', true);
|
Config::load('db', true);
|
||||||
|
|
||||||
$logs = '';
|
$logs = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::start_transaction();
|
DB::start_transaction();
|
||||||
|
|
||||||
$logs .= 'Creation table user'."\r\n";
|
$logs .= 'Creation table user'."\r\n";
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE USER
|
* CREATE TABLE USER
|
||||||
*/
|
*/
|
||||||
DBUtil::create_table(
|
DBUtil::create_table(
|
||||||
'user',
|
'user',
|
||||||
array(
|
array(
|
||||||
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'username' => array('constraint' => 255, 'type' => 'varchar'),
|
'username' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'email' => array('constraint' => 255, 'type' => 'varchar'),
|
'email' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'password' => array('constraint' => 255, 'type' => 'varchar'),
|
'password' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'admin' => array('constraint' => 1, 'type' => 'int', 'default' => 0),
|
'admin' => array('constraint' => 1, 'type' => 'int', 'default' => 0),
|
||||||
'lastlogin' => array('constraint' => 11, 'type' => 'int'),
|
'lastlogin' => array('constraint' => 11, 'type' => 'int'),
|
||||||
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
||||||
),
|
),
|
||||||
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
||||||
);
|
);
|
||||||
|
|
||||||
$logs .= 'Table user create!'."\r\n";
|
$logs .= 'Table user create!'."\r\n";
|
||||||
|
|
||||||
$logs .= 'Creation table server'."\r\n";
|
$logs .= 'Creation table server'."\r\n";
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE SERVER
|
* CREATE TABLE SERVER
|
||||||
*/
|
*/
|
||||||
DBUtil::create_table(
|
DBUtil::create_table(
|
||||||
'server',
|
'server',
|
||||||
array(
|
array(
|
||||||
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'user_id' => array('constraint' => 36, 'type' => 'varchar'),
|
'user_id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'url' => array('constraint' => 255, 'type' => 'varchar'),
|
'url' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'port' => array('constraint' => 2, 'type' => 'int', 'null' => true),
|
'port' => array('constraint' => 2, 'type' => 'int', 'null' => true),
|
||||||
'token' => array('constraint' => 255, 'type' => 'varchar'),
|
'token' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'lastcheck' => array('constraint' => 11, 'type' => 'int'),
|
'lastcheck' => array('constraint' => 11, 'type' => 'int'),
|
||||||
'name' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'name' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'plateforme' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'plateforme' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'platformVersion' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'platformVersion' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'updatedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'updatedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'version' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'version' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'online' => array('constraint' => 1, 'type' => 'int', 'default' => 0),
|
'online' => array('constraint' => 1, 'type' => 'int', 'default' => 0),
|
||||||
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
||||||
),
|
),
|
||||||
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
||||||
);
|
);
|
||||||
$logs .= 'Server table create!'."\r\n";
|
$logs .= 'Server table create!'."\r\n";
|
||||||
|
|
||||||
$logs .= 'Creation table library'."\r\n";
|
$logs .= 'Creation table library'."\r\n";
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE LIBRARY
|
* CREATE TABLE LIBRARY
|
||||||
*/
|
*/
|
||||||
DBUtil::create_table(
|
DBUtil::create_table(
|
||||||
'library',
|
'library',
|
||||||
array(
|
array(
|
||||||
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'server_id' => array('constraint' => 36, 'type' => 'varchar'),
|
'server_id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'plex_key' => array('constraint' => 11, 'type' => 'int'),
|
'plex_key' => array('constraint' => 11, 'type' => 'int'),
|
||||||
'name' => array('constraint' => 255, 'type' => 'varchar'),
|
'name' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'type' => array('constraint' => 255, 'type' => 'varchar'),
|
'type' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'updatedAt' => array('constraint' => 11, 'type' => 'int'),
|
'updatedAt' => array('constraint' => 11, 'type' => 'int'),
|
||||||
'createdAt' => array('constraint' => 11, 'type' => 'int'),
|
'createdAt' => array('constraint' => 11, 'type' => 'int'),
|
||||||
'scannedAt' => array('constraint' => 11, 'type' => 'int'),
|
'scannedAt' => array('constraint' => 11, 'type' => 'int'),
|
||||||
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
||||||
),
|
),
|
||||||
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
||||||
);
|
);
|
||||||
$logs .= 'Library table create!'."\r\n";
|
$logs .= 'Library table create!'."\r\n";
|
||||||
|
|
||||||
$logs .= 'Creation table tv_show'."\r\n";
|
$logs .= 'Creation table tv_show'."\r\n";
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE LIBRARY
|
* CREATE TABLE LIBRARY
|
||||||
*/
|
*/
|
||||||
DBUtil::create_table(
|
DBUtil::create_table(
|
||||||
'tvshow',
|
'tvshow',
|
||||||
array(
|
array(
|
||||||
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'library_id' => array('constraint' => 36, 'type' => 'varchar'),
|
'library_id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'plex_key' => array('constraint' => 255, 'type' => 'varchar'),
|
'plex_key' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'studio' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'studio' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'title' => array('constraint' => 255, 'type' => 'varchar'),
|
'title' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'contentRating' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'contentRating' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'summary' => array('type' => 'text', 'null' => true),
|
'summary' => array('type' => 'text', 'null' => true),
|
||||||
'rating' => array('constraint' => 3, 'type' => 'varchar', 'null' => true),
|
'rating' => array('constraint' => 3, 'type' => 'varchar', 'null' => true),
|
||||||
'year' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'year' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'thumb' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'thumb' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'art' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'art' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'banner' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'banner' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'theme' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'theme' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'originallyAvailableAt' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'originallyAvailableAt' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'leafCount' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'leafCount' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'addedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'addedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'updatedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'updatedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
||||||
),
|
),
|
||||||
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
||||||
);
|
);
|
||||||
$logs .= 'Library table create!'."\r\n";
|
$logs .= 'Library table create!'."\r\n";
|
||||||
|
|
||||||
$logs .= 'Creation table season'."\r\n";
|
$logs .= 'Creation table season'."\r\n";
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE SEASON
|
* CREATE TABLE SEASON
|
||||||
*/
|
*/
|
||||||
DBUtil::create_table(
|
DBUtil::create_table(
|
||||||
'season',
|
'season',
|
||||||
array(
|
array(
|
||||||
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'tv_show_id' => array('constraint' => 36, 'type' => 'varchar'),
|
'tv_show_id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'plex_key' => array('constraint' => 36, 'type' => 'varchar'),
|
'plex_key' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'number' => array('constraint' => 11, 'type' => 'int'),
|
'number' => array('constraint' => 11, 'type' => 'int'),
|
||||||
'title' => array('constraint' => 255, 'type' => 'varchar'),
|
'title' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'thumb' => array('constraint' => 255, 'type' => 'varchar'),
|
'thumb' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'art' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'art' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'leafCount' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'leafCount' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'addedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'addedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'updatedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'updatedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
||||||
),
|
),
|
||||||
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
||||||
);
|
);
|
||||||
$logs .= 'Season table create!'."\r\n";
|
$logs .= 'Season table create!'."\r\n";
|
||||||
|
|
||||||
$logs .= 'Creation table movie'."\r\n";
|
$logs .= 'Creation table movie'."\r\n";
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE SEASON
|
* CREATE TABLE SEASON
|
||||||
*/
|
*/
|
||||||
DBUtil::create_table(
|
DBUtil::create_table(
|
||||||
'movie',
|
'movie',
|
||||||
array(
|
array(
|
||||||
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'library_id' => array('constraint' => 36, 'type' => 'varchar', 'null' => true),
|
'library_id' => array('constraint' => 36, 'type' => 'varchar', 'null' => true),
|
||||||
'season_id' => array('constraint' => 36, 'type' => 'varchar', 'null' => true),
|
'season_id' => array('constraint' => 36, 'type' => 'varchar', 'null' => true),
|
||||||
'plex_key' => array('constraint' => 36, 'type' => 'varchar'),
|
'plex_key' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'type' => array('constraint' => 5, 'type' => 'varchar'),
|
'type' => array('constraint' => 5, 'type' => 'varchar'),
|
||||||
'number' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'number' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'studio' => array('constraint' => 36, 'type' => 'varchar', 'null' => true),
|
'studio' => array('constraint' => 36, 'type' => 'varchar', 'null' => true),
|
||||||
'title' => array('constraint' => 255, 'type' => 'varchar'),
|
'title' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'originalTitle' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'originalTitle' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'summary' => array('type' => 'text', 'null' => true),
|
'summary' => array('type' => 'text', 'null' => true),
|
||||||
'rating' => array('constraint' => 3, 'type' => 'varchar', 'null' => true),
|
'rating' => array('constraint' => 3, 'type' => 'varchar', 'null' => true),
|
||||||
'year' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'year' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'thumb' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'thumb' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'art' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
'art' => array('constraint' => 255, 'type' => 'varchar', 'null' => true),
|
||||||
'duration' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'duration' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'originallyAvailableAt' => array('constraint' => 11, 'type' => 'varchar', 'null' => true),
|
'originallyAvailableAt' => array('constraint' => 11, 'type' => 'varchar', 'null' => true),
|
||||||
'addedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'addedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'updatedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
'updatedAt' => array('constraint' => 11, 'type' => 'int', 'null' => true),
|
||||||
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
||||||
),
|
),
|
||||||
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
||||||
);
|
);
|
||||||
$logs .= 'Movie table create!'."\r\n";
|
$logs .= 'Movie table create!'."\r\n";
|
||||||
|
|
||||||
$logs .= 'Creation table configuration'."\r\n";
|
$logs .= 'Creation table configuration'."\r\n";
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE CONFIGURATION
|
* CREATE TABLE CONFIGURATION
|
||||||
*/
|
*/
|
||||||
DBUtil::create_table(
|
DBUtil::create_table(
|
||||||
'configurations',
|
'configurations',
|
||||||
array(
|
array(
|
||||||
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'name' => array('constraint' => 255, 'type' => 'varchar'),
|
'name' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'data' => array('constraint' => 255, 'type' => 'varchar')
|
'data' => array('constraint' => 255, 'type' => 'varchar')
|
||||||
),
|
),
|
||||||
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
||||||
);
|
);
|
||||||
$logs .= 'Configuration table create!'."\r\n";
|
$logs .= 'Configuration table create!'."\r\n";
|
||||||
|
|
||||||
$logs .= 'Creation table permission'."\r\n";
|
$logs .= 'Creation table permission'."\r\n";
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE PERMISSION
|
* CREATE TABLE PERMISSION
|
||||||
*/
|
*/
|
||||||
DBUtil::create_table(
|
DBUtil::create_table(
|
||||||
'permission',
|
'permission',
|
||||||
array(
|
array(
|
||||||
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'name' => array('constraint' => 255, 'type' => 'varchar'),
|
'name' => array('constraint' => 255, 'type' => 'varchar'),
|
||||||
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
||||||
),
|
),
|
||||||
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
||||||
);
|
);
|
||||||
$logs .= 'Permission table create!'."\r\n";
|
$logs .= 'Permission table create!'."\r\n";
|
||||||
|
|
||||||
$logs .= 'Creation table user permission'."\r\n";
|
$logs .= 'Creation table user permission'."\r\n";
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE USER'S PERMISSION
|
* CREATE TABLE USER'S PERMISSION
|
||||||
*/
|
*/
|
||||||
DBUtil::create_table(
|
DBUtil::create_table(
|
||||||
'user_permission',
|
'user_permission',
|
||||||
array(
|
array(
|
||||||
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'permission_id' => array('constraint' => 36, 'type' => 'varchar'),
|
'permission_id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'user_id' => array('constraint' => 36, 'type' => 'varchar'),
|
'user_id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'library_id' => array('constraint' => 36, 'type' => 'varchar'),
|
'library_id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
||||||
),
|
),
|
||||||
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
||||||
);
|
);
|
||||||
$logs .= 'User Permission table create!'."\r\n";
|
$logs .= 'User Permission table create!'."\r\n";
|
||||||
|
|
||||||
$logs .= 'Creation table user watching'."\r\n";
|
$logs .= 'Creation table user watching'."\r\n";
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE USER'S WATCHING
|
* CREATE TABLE USER'S WATCHING
|
||||||
*/
|
*/
|
||||||
DBUtil::create_table(
|
DBUtil::create_table(
|
||||||
'user_watching',
|
'user_watching',
|
||||||
array(
|
array(
|
||||||
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
'id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'file_id' => array('constraint' => 11, 'type' => 'int'),
|
'file_id' => array('constraint' => 11, 'type' => 'int'),
|
||||||
'user_id' => array('constraint' => 36, 'type' => 'varchar'),
|
'user_id' => array('constraint' => 36, 'type' => 'varchar'),
|
||||||
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
'disable' => array('constraint' => 1, 'type' => 'int', 'default' => 0)
|
||||||
),
|
),
|
||||||
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
|
||||||
);
|
);
|
||||||
$logs .= 'User Watching table create!'."\r\n";
|
$logs .= 'User Watching table create!'."\r\n";
|
||||||
|
|
||||||
$logs .= 'Create Foreign key'."\r\n";
|
$logs .= 'Create Foreign key'."\r\n";
|
||||||
/**
|
/**
|
||||||
* FOREIGN KEY
|
* FOREIGN KEY
|
||||||
*/
|
*/
|
||||||
DBUtil::add_foreign_key('tvshow', array(
|
DBUtil::add_foreign_key('tvshow', array(
|
||||||
'constraint' => 'constraintTvShowLibrary',
|
'constraint' => 'constraintTvShowLibrary',
|
||||||
'key' => 'library_id',
|
'key' => 'library_id',
|
||||||
'reference' => array(
|
'reference' => array(
|
||||||
'table' => 'library',
|
'table' => 'library',
|
||||||
'column' => 'id',
|
'column' => 'id',
|
||||||
),
|
),
|
||||||
'on_update' => 'NO ACTION',
|
'on_update' => 'NO ACTION',
|
||||||
'on_delete' => 'NO ACTION',
|
'on_delete' => 'NO ACTION',
|
||||||
));
|
));
|
||||||
DBUtil::add_foreign_key('season', array(
|
DBUtil::add_foreign_key('season', array(
|
||||||
'constraint' => 'constraintSeasonTvShow',
|
'constraint' => 'constraintSeasonTvShow',
|
||||||
'key' => 'tv_show_id',
|
'key' => 'tv_show_id',
|
||||||
'reference' => array(
|
'reference' => array(
|
||||||
'table' => 'tvshow',
|
'table' => 'tvshow',
|
||||||
'column' => 'id',
|
'column' => 'id',
|
||||||
),
|
),
|
||||||
'on_update' => 'NO ACTION',
|
'on_update' => 'NO ACTION',
|
||||||
'on_delete' => 'NO ACTION',
|
'on_delete' => 'NO ACTION',
|
||||||
));
|
));
|
||||||
DBUtil::add_foreign_key('movie', array(
|
DBUtil::add_foreign_key('movie', array(
|
||||||
'constraint' => 'constraintMovieLibrary',
|
'constraint' => 'constraintMovieLibrary',
|
||||||
'key' => 'library_id',
|
'key' => 'library_id',
|
||||||
'reference' => array(
|
'reference' => array(
|
||||||
'table' => 'library',
|
'table' => 'library',
|
||||||
'column' => 'id',
|
'column' => 'id',
|
||||||
),
|
),
|
||||||
'on_update' => 'NO ACTION',
|
'on_update' => 'NO ACTION',
|
||||||
'on_delete' => 'NO ACTION',
|
'on_delete' => 'NO ACTION',
|
||||||
));
|
));
|
||||||
DBUtil::add_foreign_key('movie', array(
|
DBUtil::add_foreign_key('movie', array(
|
||||||
'constraint' => 'constraintMovieSeason',
|
'constraint' => 'constraintMovieSeason',
|
||||||
'key' => 'season_id',
|
'key' => 'season_id',
|
||||||
'reference' => array(
|
'reference' => array(
|
||||||
'table' => 'season',
|
'table' => 'season',
|
||||||
'column' => 'id',
|
'column' => 'id',
|
||||||
),
|
),
|
||||||
'on_update' => 'NO ACTION',
|
'on_update' => 'NO ACTION',
|
||||||
'on_delete' => 'NO ACTION',
|
'on_delete' => 'NO ACTION',
|
||||||
));
|
));
|
||||||
DBUtil::add_foreign_key('user_permission', array(
|
DBUtil::add_foreign_key('user_permission', array(
|
||||||
'constraint' => 'constraintLibraryPermission',
|
'constraint' => 'constraintLibraryPermission',
|
||||||
'key' => 'library_id',
|
'key' => 'library_id',
|
||||||
'reference' => array(
|
'reference' => array(
|
||||||
'table' => 'library',
|
'table' => 'library',
|
||||||
'column' => 'id',
|
'column' => 'id',
|
||||||
),
|
),
|
||||||
'on_update' => 'NO ACTION',
|
'on_update' => 'NO ACTION',
|
||||||
'on_delete' => 'NO ACTION',
|
'on_delete' => 'NO ACTION',
|
||||||
));
|
));
|
||||||
DBUtil::add_foreign_key('user_watching', array(
|
DBUtil::add_foreign_key('user_watching', array(
|
||||||
'constraint' => 'constraintUserWatching',
|
'constraint' => 'constraintUserWatching',
|
||||||
'key' => 'user_id',
|
'key' => 'user_id',
|
||||||
'reference' => array(
|
'reference' => array(
|
||||||
'table' => 'user',
|
'table' => 'user',
|
||||||
'column' => 'id',
|
'column' => 'id',
|
||||||
),
|
),
|
||||||
'on_update' => 'NO ACTION',
|
'on_update' => 'NO ACTION',
|
||||||
'on_delete' => 'NO ACTION',
|
'on_delete' => 'NO ACTION',
|
||||||
));
|
));
|
||||||
DBUtil::add_foreign_key('library', array(
|
DBUtil::add_foreign_key('library', array(
|
||||||
'constraint' => 'constraintServerLibrary',
|
'constraint' => 'constraintServerLibrary',
|
||||||
'key' => 'server_id',
|
'key' => 'server_id',
|
||||||
'reference' => array(
|
'reference' => array(
|
||||||
'table' => 'server',
|
'table' => 'server',
|
||||||
'column' => 'id',
|
'column' => 'id',
|
||||||
),
|
),
|
||||||
'on_update' => 'NO ACTION',
|
'on_update' => 'NO ACTION',
|
||||||
'on_delete' => 'NO ACTION',
|
'on_delete' => 'NO ACTION',
|
||||||
));
|
));
|
||||||
DBUtil::add_foreign_key('server', array(
|
DBUtil::add_foreign_key('server', array(
|
||||||
'constraint' => 'constraintServerUser',
|
'constraint' => 'constraintServerUser',
|
||||||
'key' => 'user_id',
|
'key' => 'user_id',
|
||||||
'reference' => array(
|
'reference' => array(
|
||||||
'table' => 'user',
|
'table' => 'user',
|
||||||
'column' => 'id',
|
'column' => 'id',
|
||||||
),
|
),
|
||||||
'on_update' => 'NO ACTION',
|
'on_update' => 'NO ACTION',
|
||||||
'on_delete' => 'NO ACTION',
|
'on_delete' => 'NO ACTION',
|
||||||
));
|
));
|
||||||
|
|
||||||
$logs .= 'Foreign key create!'."\r\n";
|
$logs .= 'Foreign key create!'."\r\n";
|
||||||
|
|
||||||
DB::commit_transaction();
|
DB::commit_transaction();
|
||||||
|
|
||||||
$logs .= 'All Tables and Foreign Key successfully!'."\r\n";
|
$logs .= 'All Tables and Foreign Key successfully!'."\r\n";
|
||||||
|
|
||||||
return $this->response(array('error' => false, 'message' => $logs));
|
return $this->response(array('error' => false, 'message' => $logs));
|
||||||
}catch (FuelException $e) {
|
}catch (FuelException $e) {
|
||||||
DBUtil::drop_table('user_watching');
|
DBUtil::drop_table('user_watching');
|
||||||
DBUtil::drop_table('user_permission');
|
DBUtil::drop_table('user_permission');
|
||||||
DBUtil::drop_table('permission');
|
DBUtil::drop_table('permission');
|
||||||
DBUtil::drop_table('library');
|
DBUtil::drop_table('library');
|
||||||
DBUtil::drop_table('server');
|
DBUtil::drop_table('server');
|
||||||
DBUtil::drop_table('configurations');
|
DBUtil::drop_table('configurations');
|
||||||
DBUtil::drop_table('user');
|
DBUtil::drop_table('user');
|
||||||
DB::rollback_transaction();
|
DB::rollback_transaction();
|
||||||
return $this->response(array('error' => true, 'message' => $e->getMessage()), 400);
|
return $this->response(array('error' => true, 'message' => $e->getMessage()), 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function post_plex()
|
public function post_admin()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$url = Input::post('url');
|
$config = Config::load('db', true);
|
||||||
|
|
||||||
//@TODO CHECK AND REMOVE HTTP AND HTTPS
|
$email = Input::post('email');
|
||||||
|
$username = Input::post('username');
|
||||||
$port = Input::post('port');
|
$password = Input::post('password');
|
||||||
$token = Input::post('token');
|
$Cpassword = Input::post('cpassword');
|
||||||
|
|
||||||
$curl = Request::forge('http://' . $url . ($port ? ':' . $port : '') . '/?X-Plex-Token=' . $token, 'curl');
|
if($password !== $Cpassword)
|
||||||
$result = $curl->execute();
|
throw new FuelException('Password match error!');
|
||||||
|
|
||||||
if(!$result)
|
$user = Model_User::forge(array(
|
||||||
throw new FuelException('Can not connect to your server!');
|
'username' => $username,
|
||||||
|
'email' => $email,
|
||||||
$server = Model_Server::forge();
|
'password' => hash('sha512', $config['default']['hash'] . $password),
|
||||||
$server->set([
|
'admin' => 1,
|
||||||
'url' => $url,
|
'lastlogin' => time()
|
||||||
'port' => $port,
|
));
|
||||||
'token' => $token,
|
|
||||||
'lastcheck' => time()
|
if(!$user->validates()) {
|
||||||
]);
|
throw new FuelException($user->validation()->show_errors());
|
||||||
$server->save();
|
}
|
||||||
|
|
||||||
return $this->response(array('error' => false));
|
$user->save();
|
||||||
} catch (FuelException $e) {
|
|
||||||
return $this->response(array('error' => true, 'message' => $e->getMessage()), 400);
|
return $this->response(array('error' => false));
|
||||||
}
|
} catch (Exception $e) {
|
||||||
}
|
return $this->response(array('error' => true, 'message' => $e->getMessage()), 404);
|
||||||
|
}
|
||||||
public function post_admin()
|
}
|
||||||
{
|
|
||||||
try {
|
public function post_plex()
|
||||||
$config = Config::load('db', true);
|
{
|
||||||
|
try {
|
||||||
$email = Input::post('email');
|
$url = Input::post('url');
|
||||||
$username = Input::post('username');
|
|
||||||
$password = Input::post('password');
|
//@TODO CHECK AND REMOVE HTTP AND HTTPS
|
||||||
$Cpassword = Input::post('cpassword');
|
|
||||||
|
$port = Input::post('port');
|
||||||
if($password !== $Cpassword)
|
$token = Input::post('token');
|
||||||
throw new FuelException('Password match error!');
|
|
||||||
|
$curl = Request::forge('http://' . $url . ($port ? ':' . $port : '') . '/?X-Plex-Token=' . $token, 'curl');
|
||||||
$user = Model_User::forge(array(
|
$result = $curl->execute();
|
||||||
'username' => $username,
|
|
||||||
'email' => $email,
|
if(!$result)
|
||||||
'password' => hash('sha512', $config['default']['hash'] . $password),
|
throw new FuelException('Can not connect to your server!');
|
||||||
'admin' => 1,
|
|
||||||
'lastlogin' => time()
|
$server = Model_Server::forge();
|
||||||
));
|
$server->set([
|
||||||
|
'url' => $url,
|
||||||
if(!$user->validates()) {
|
'port' => $port,
|
||||||
throw new FuelException($user->validation()->show_errors());
|
'token' => $token,
|
||||||
}
|
'lastcheck' => time()
|
||||||
|
]);
|
||||||
$user->save();
|
$server->save();
|
||||||
|
|
||||||
return $this->response(array('error' => false));
|
Config::save('lock', array('FUCK OFF!'));
|
||||||
} catch (Exception $e) {
|
|
||||||
return $this->response(array('error' => true, 'message' => $e->getMessage()), 404);
|
return $this->response(array('error' => false));
|
||||||
}
|
} catch (FuelException $e) {
|
||||||
}
|
return $this->response(array('error' => true, 'message' => $e->getMessage()), 400);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
return array('FUCK OFF!');
|
||||||
|
|
@ -0,0 +1,58 @@
|
|||||||
|
<div class="settings-container">
|
||||||
|
<div class="filter-bar">
|
||||||
|
<button class="toggle-advanced-btn btn btn-sm Button-primary-2LQVw pull-left add-libraries"
|
||||||
|
data-placement="top" data-toggle="tooltip" data-original-title="Add library"><i class="glyphicon circle-plus"></i></button>
|
||||||
|
<button class="toggle-advanced-btn btn btn-sm btn-default pull-right refresh">Refresh Libraries <i class="glyphicon refresh"></i></button>
|
||||||
|
</div>
|
||||||
|
<div class="devices-container row">
|
||||||
|
<div class="device-list-container col-sm-12 col-md-12">
|
||||||
|
<ul class="list card-tile-list">
|
||||||
|
<?php if($libraries) : ?>
|
||||||
|
<?php foreach ($libraries as $library) : ?>
|
||||||
|
<li class="card-tile-list-item card-3-col-item">
|
||||||
|
<div class="card card-device">
|
||||||
|
<div class="card-actions">
|
||||||
|
<button class="edit-device-btn card-action-btn btn-info"
|
||||||
|
data-placement="top" data-toggle="tooltip" data-original-title="Refresh">
|
||||||
|
<i class="glyphicon refresh"></i>
|
||||||
|
</button>
|
||||||
|
<button class="edit-device-btn card-action-btn"
|
||||||
|
data-placement="top" data-toggle="tooltip" data-original-title="Edit">
|
||||||
|
<i class="glyphicon pencil"></i>
|
||||||
|
</button>
|
||||||
|
<button class="edit-device-btn card-action-btn btn-danger"
|
||||||
|
data-placement="top" data-toggle="tooltip" data-original-title="Disable">
|
||||||
|
<i class="glyphicon ban"></i>
|
||||||
|
</button>
|
||||||
|
<button class="remove-libraries-btn card-action-btn btn-danger"
|
||||||
|
data-placement="top" data-toggle="tooltip" data-original-title="Delete">
|
||||||
|
<i class="glyphicon remove-2"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<h4 class="name"><?php echo $library->name; ?> <span class="glyphicon ok-2 text-success"></span></h4>
|
||||||
|
<div class="card-details">
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="last-seen text-muted"><i class="plex-icon-watch-later-560"></i> <?php echo $library->getLastUpdate(); ?></div>
|
||||||
|
<span class="sync-info hidden">
|
||||||
|
<span class="glyphicon circle-arrow-down sync-icon"></span>
|
||||||
|
<span class="sync-count">123</span> / <span class="sync-size">456</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span class="version text-muted"><?php echo $library->type; ?></span>
|
||||||
|
<div class="device-info-container">
|
||||||
|
<div class="product"><?php echo $library->getServer()->name; ?></div>
|
||||||
|
<div class="device text-muted"></div>
|
||||||
|
<div class="platform-info text-muted">
|
||||||
|
<span class="platform">Linux</span>
|
||||||
|
<span class="platform-version">Debian 8</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
Reference in new issue