diff --git a/composer.json b/composer.json index c822df2e..a7a38947 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ "laravel/sanctum": "^2.10", "laravel/tinker": "^2.5", "nao-pon/flysystem-google-drive": "^1.1", + "orangehill/iseed": "^3.0", "swiftmailer/swiftmailer": "^6.2" }, "require-dev": { diff --git a/composer.lock b/composer.lock index aa47b69b..f43bae28 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d86d139cb95257a0d64eb0af9cf6f453", + "content-hash": "87d34a5b9914da908347ed77069167ea", "packages": [ { "name": "asm89/stack-cors", @@ -3084,6 +3084,75 @@ ], "time": "2020-11-07T02:01:34+00:00" }, + { + "name": "orangehill/iseed", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/orangehill/iseed.git", + "reference": "874f77a20d49aa4c6c5fec2daf0daa070514e013" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/orangehill/iseed/zipball/874f77a20d49aa4c6c5fec2daf0daa070514e013", + "reference": "874f77a20d49aa4c6c5fec2daf0daa070514e013", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0", + "php": "^7.2|^8.0" + }, + "require-dev": { + "illuminate/filesystem": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0", + "laravel/framework": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0", + "mockery/mockery": "^1.0.0", + "phpunit/phpunit": "^8.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Orangehill\\Iseed\\IseedServiceProvider" + ] + } + }, + "autoload": { + "psr-0": { + "Orangehill\\Iseed": "src/" + }, + "classmap": [ + "src/Orangehill/Iseed/Exceptions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Tihomir Opacic", + "email": "tihomir.opacic@orangehilldev.com" + } + ], + "description": "Generate a new Laravel database seed file based on data from the existing database table.", + "keywords": [ + "artisan", + "generators", + "laravel", + "seed" + ], + "support": { + "issues": "https://github.com/orangehill/iseed/issues", + "source": "https://github.com/orangehill/iseed/tree/v3.0.1" + }, + "time": "2021-01-14T15:34:12+00:00" + }, { "name": "paragonie/constant_time_encoding", "version": "v2.4.0", diff --git a/include/eloquent.php b/include/eloquent.php index 05a5342c..dbe4cc60 100644 --- a/include/eloquent.php +++ b/include/eloquent.php @@ -5,6 +5,6 @@ $connectionMysql = $config['mysql']; $connectionMysql['driver'] = 'mysql'; $connectionMysql['charset'] = 'utf8mb4'; $connectionMysql['collation'] = 'utf8mb4_unicode_ci'; -\Nexus\Database\DB::bootEloquent($connectionMysql); +\Nexus\Database\NexusDB::bootEloquent($connectionMysql); diff --git a/include/functions.php b/include/functions.php index 3357ef26..aad8b560 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1769,7 +1769,7 @@ function getExportedValue($input,$t = null) { function dbconn($autoclean = false, $doLogin = true) { global $useCronTriggerCleanUp; - \Nexus\Database\DB::getInstance()->autoConnect(); + \Nexus\Database\NexusDB::getInstance()->autoConnect(); if ($doLogin) { userlogin(); } diff --git a/include/functions_announce.php b/include/functions_announce.php index 724f4324..d9eb0770 100644 --- a/include/functions_announce.php +++ b/include/functions_announce.php @@ -5,7 +5,7 @@ if(!defined('IN_TRACKER')) function dbconn_announce() { - \Nexus\Database\DB::getInstance()->autoConnect(); + \Nexus\Database\NexusDB::getInstance()->autoConnect(); } function hash_where_arr($name, $hash_arr) { diff --git a/include/globalfunctions.php b/include/globalfunctions.php index c5967d00..81ebc0b5 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -521,7 +521,7 @@ function fail(...$args) function last_query($all = false) { if (IN_NEXUS) { - $queries = \Illuminate\Database\Capsule\Manager::connection(\Nexus\Database\DB::ELOQUENT_CONNECTION_NAME)->getQueryLog(); + $queries = \Illuminate\Database\Capsule\Manager::connection(\Nexus\Database\NexusDB::ELOQUENT_CONNECTION_NAME)->getQueryLog(); } else { $queries = \Illuminate\Support\Facades\DB::connection(config('database.default'))->getQueryLog(); } diff --git a/nexus/Client/Client.php b/nexus/Client/Client.php index 242b2440..09cc3952 100644 --- a/nexus/Client/Client.php +++ b/nexus/Client/Client.php @@ -3,7 +3,7 @@ namespace Nexus\Client; use Nexus\Core\Management; -use Nexus\Database\DB; +use Nexus\Database\NexusDB; class Client extends Management { @@ -460,4 +460,4 @@ JS; -} \ No newline at end of file +} diff --git a/nexus/Database/DB.php b/nexus/Database/NexusDB.php similarity index 99% rename from nexus/Database/DB.php rename to nexus/Database/NexusDB.php index 69c96a63..21e8adc0 100644 --- a/nexus/Database/DB.php +++ b/nexus/Database/NexusDB.php @@ -4,7 +4,7 @@ namespace Nexus\Database; use Illuminate\Database\Capsule\Manager as Capsule; -class DB +class NexusDB { private $driver; diff --git a/nexus/Database/helpers.php b/nexus/Database/helpers.php index 7705283e..51f33e7c 100644 --- a/nexus/Database/helpers.php +++ b/nexus/Database/helpers.php @@ -1,67 +1,67 @@ connect($host, $username, $password, $database, $port); + return NexusDB::getInstance()->connect($host, $username, $password, $database, $port); } function mysql_errno() { - return DB::getInstance()->errno(); + return NexusDB::getInstance()->errno(); } function mysql_error() { - return DB::getInstance()->error(); + return NexusDB::getInstance()->error(); } function mysql_query(string $sql) { - return DB::getInstance()->query($sql); + return NexusDB::getInstance()->query($sql); } function mysql_select_db($database) { - return DB::getInstance()->select_db($database); + return NexusDB::getInstance()->select_db($database); } function mysql_num_rows($result) { - return DB::getInstance()->numRows($result); + return NexusDB::getInstance()->numRows($result); } function mysql_fetch_array($result, $type = null) { - return DB::getInstance()->fetchArray($result, $type); + return NexusDB::getInstance()->fetchArray($result, $type); } function mysql_fetch_assoc($result) { - return DB::getInstance()->fetchAssoc($result); + return NexusDB::getInstance()->fetchAssoc($result); } function mysql_fetch_row($result) { - return DB::getInstance()->fetchRow($result); + return NexusDB::getInstance()->fetchRow($result); } function mysql_affected_rows() { - return DB::getInstance()->affectedRows(); + return NexusDB::getInstance()->affectedRows(); } function mysql_real_escape_string($string) { - return DB::getInstance()->escapeString($string); + return NexusDB::getInstance()->escapeString($string); } function mysql_insert_id() { - return DB::getInstance()->lastInsertId(); + return NexusDB::getInstance()->lastInsertId(); } function mysql_free_result($result) { - return DB::getInstance()->freeResult($result); + return NexusDB::getInstance()->freeResult($result); } diff --git a/nexus/Field/Field.php b/nexus/Field/Field.php index f5a9d07f..8637d0e0 100644 --- a/nexus/Field/Field.php +++ b/nexus/Field/Field.php @@ -2,7 +2,7 @@ namespace Nexus\Field; -use Nexus\Database\DB; +use Nexus\Database\NexusDB; class Field { @@ -207,10 +207,10 @@ HEAD; $attributes['updated_at'] = $now; $table = 'torrents_custom_fields'; if (!empty($data['id'])) { - $result = DB::update($table, $attributes, "id = " . sqlesc($data['id'])); + $result = NexusDB::update($table, $attributes, "id = " . sqlesc($data['id'])); } else { $attributes['created_at'] = $now; - $result = DB::insert($table, $attributes); + $result = NexusDB::insert($table, $attributes); } return $result; } @@ -255,7 +255,7 @@ HEAD; public function renderOnUploadPage($torrentId = 0) { global $browsecatmode; - $searchBox = DB::getOne('searchbox', "id = $browsecatmode"); + $searchBox = NexusDB::getOne('searchbox', "id = $browsecatmode"); if (empty($searchBox)) { throw new \RuntimeException("Invalid search box: $browsecatmode"); } diff --git a/nexus/Install/Install.php b/nexus/Install/Install.php index 54fe3bb4..088272e5 100644 --- a/nexus/Install/Install.php +++ b/nexus/Install/Install.php @@ -3,7 +3,7 @@ namespace Nexus\Install; use Illuminate\Support\Str; -use Nexus\Database\DB; +use Nexus\Database\NexusDB; class Install { @@ -389,7 +389,7 @@ class Install 'added' => date('Y-m-d H:i:s'), ]; $this->doLog("[CREATE ADMINISTRATOR] " . json_encode($insert)); - return DB::insert('users', $insert); + return NexusDB::insert('users', $insert); } public function createEnvFile($data) diff --git a/nexus/Install/Update.php b/nexus/Install/Update.php index 16fba8d9..b1ae6ea9 100644 --- a/nexus/Install/Update.php +++ b/nexus/Install/Update.php @@ -6,7 +6,7 @@ use App\Models\Category; use App\Models\Icon; use App\Models\Setting; use Illuminate\Support\Str; -use Nexus\Database\DB; +use Nexus\Database\NexusDB; class Update extends Install { @@ -63,11 +63,11 @@ class Update extends Install 'url' => $url, 'info' => 'Manage custom fields', ]; - $id = DB::insert($table, $insert); + $id = NexusDB::insert($table, $insert); $this->doLog("[ADD CUSTOM FIELD MENU] insert: " . json_encode($insert) . " to table: $table, id: $id"); } //since beta8 - if (WITH_LARAVEL && DB::schema()->hasColumn('categories', 'icon_id')) { + if (WITH_LARAVEL && NexusDB::schema()->hasColumn('categories', 'icon_id')) { $this->doLog('[INIT CATEGORY ICON_ID]'); $icon = Icon::query()->orderBy('id', 'asc')->first(); if ($icon) { @@ -75,7 +75,7 @@ class Update extends Install } } //fix base url, since beta8 - if (WITH_LARAVEL && DB::schema()->hasTable('settings')) { + if (WITH_LARAVEL && NexusDB::schema()->hasTable('settings')) { $settingBasic = get_setting('basic'); if (isset($settingBasic['BASEURL']) && Str::startsWith($settingBasic['BASEURL'], 'localhost')) { $this->doLog('[RESET CONFIG basic.BASEURL]'); @@ -89,7 +89,7 @@ class Update extends Install //torrent support sticky second level if (WITH_LARAVEL) { - $columnInfo = DB::getMysqlColumnInfo('torrents', 'pos_state'); + $columnInfo = NexusDB::getMysqlColumnInfo('torrents', 'pos_state'); $this->doLog("[TORRENT POS_STATE], column info: " . json_encode($columnInfo)); if ($columnInfo['DATA_TYPE'] == 'enum') { $sql = "alter table torrents modify `pos_state` varchar(32) NOT NULL DEFAULT 'normal'"; diff --git a/nexus/Torrent/Torrent.php b/nexus/Torrent/Torrent.php index 9fdfd219..d23afd5b 100644 --- a/nexus/Torrent/Torrent.php +++ b/nexus/Torrent/Torrent.php @@ -2,7 +2,7 @@ namespace Nexus\Torrent; -use Nexus\Database\DB; +use Nexus\Database\NexusDB; class Torrent { @@ -19,7 +19,7 @@ class Torrent $torrentIdStr = implode(',', $torrentIdArr); //seeding or leeching, from peers $whereStr = sprintf("userid = %s and torrent in (%s)", sqlesc($uid), $torrentIdStr); - $peerList = DB::getAll('peers', $whereStr, 'torrent, to_go'); + $peerList = NexusDB::getAll('peers', $whereStr, 'torrent, to_go'); $peerList = array_column($peerList,'to_go', 'torrent'); //download progress, from snatched $sql = sprintf( @@ -64,4 +64,4 @@ class Torrent ); return $result; } -} \ No newline at end of file +} diff --git a/public/takeedit.php b/public/takeedit.php index 07ddee35..4d8013d1 100644 --- a/public/takeedit.php +++ b/public/takeedit.php @@ -193,7 +193,7 @@ sql_query("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id") or * @since v1.6 */ if (!empty($_POST['custom_fields'])) { - \Nexus\Database\DB::delete('torrents_custom_field_values', "torrent_id = $id"); + \Nexus\Database\NexusDB::delete('torrents_custom_field_values', "torrent_id = $id"); $now = date('Y-m-d H:i:s'); foreach ($_POST['custom_fields'] as $customField => $customValue) { foreach ((array)$customValue as $value) { @@ -204,7 +204,7 @@ if (!empty($_POST['custom_fields'])) { 'created_at' => $now, 'updated_at' => $now, ]; - \Nexus\Database\DB::insert('torrents_custom_field_values', $customData); + \Nexus\Database\NexusDB::insert('torrents_custom_field_values', $customData); } } } diff --git a/public/takeupload.php b/public/takeupload.php index 3d91f28a..1f8cdb48 100644 --- a/public/takeupload.php +++ b/public/takeupload.php @@ -369,7 +369,7 @@ if (!empty($_POST['custom_fields'])) { 'created_at' => $now, 'updated_at' => $now, ]; - \Nexus\Database\DB::insert('torrents_custom_field_values', $customData); + \Nexus\Database\NexusDB::insert('torrents_custom_field_values', $customData); } } }