This commit is contained in:
xiaomlove
2021-06-08 10:42:39 +08:00
parent 557c9d3b30
commit 6361f96d62
15 changed files with 109 additions and 39 deletions

View File

@@ -40,6 +40,7 @@
"laravel/sanctum": "^2.10", "laravel/sanctum": "^2.10",
"laravel/tinker": "^2.5", "laravel/tinker": "^2.5",
"nao-pon/flysystem-google-drive": "^1.1", "nao-pon/flysystem-google-drive": "^1.1",
"orangehill/iseed": "^3.0",
"swiftmailer/swiftmailer": "^6.2" "swiftmailer/swiftmailer": "^6.2"
}, },
"require-dev": { "require-dev": {

71
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d86d139cb95257a0d64eb0af9cf6f453", "content-hash": "87d34a5b9914da908347ed77069167ea",
"packages": [ "packages": [
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
@@ -3084,6 +3084,75 @@
], ],
"time": "2020-11-07T02:01:34+00:00" "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", "name": "paragonie/constant_time_encoding",
"version": "v2.4.0", "version": "v2.4.0",

View File

@@ -5,6 +5,6 @@ $connectionMysql = $config['mysql'];
$connectionMysql['driver'] = 'mysql'; $connectionMysql['driver'] = 'mysql';
$connectionMysql['charset'] = 'utf8mb4'; $connectionMysql['charset'] = 'utf8mb4';
$connectionMysql['collation'] = 'utf8mb4_unicode_ci'; $connectionMysql['collation'] = 'utf8mb4_unicode_ci';
\Nexus\Database\DB::bootEloquent($connectionMysql); \Nexus\Database\NexusDB::bootEloquent($connectionMysql);

View File

@@ -1769,7 +1769,7 @@ function getExportedValue($input,$t = null) {
function dbconn($autoclean = false, $doLogin = true) function dbconn($autoclean = false, $doLogin = true)
{ {
global $useCronTriggerCleanUp; global $useCronTriggerCleanUp;
\Nexus\Database\DB::getInstance()->autoConnect(); \Nexus\Database\NexusDB::getInstance()->autoConnect();
if ($doLogin) { if ($doLogin) {
userlogin(); userlogin();
} }

View File

@@ -5,7 +5,7 @@ if(!defined('IN_TRACKER'))
function dbconn_announce() { function dbconn_announce() {
\Nexus\Database\DB::getInstance()->autoConnect(); \Nexus\Database\NexusDB::getInstance()->autoConnect();
} }
function hash_where_arr($name, $hash_arr) { function hash_where_arr($name, $hash_arr) {

View File

@@ -521,7 +521,7 @@ function fail(...$args)
function last_query($all = false) function last_query($all = false)
{ {
if (IN_NEXUS) { 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 { } else {
$queries = \Illuminate\Support\Facades\DB::connection(config('database.default'))->getQueryLog(); $queries = \Illuminate\Support\Facades\DB::connection(config('database.default'))->getQueryLog();
} }

View File

@@ -3,7 +3,7 @@
namespace Nexus\Client; namespace Nexus\Client;
use Nexus\Core\Management; use Nexus\Core\Management;
use Nexus\Database\DB; use Nexus\Database\NexusDB;
class Client extends Management class Client extends Management
{ {
@@ -460,4 +460,4 @@ JS;
} }

View File

@@ -4,7 +4,7 @@ namespace Nexus\Database;
use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Database\Capsule\Manager as Capsule;
class DB class NexusDB
{ {
private $driver; private $driver;

View File

@@ -1,67 +1,67 @@
<?php <?php
use Nexus\Database\DB; use Nexus\Database\NexusDB;
function mysql_connect($host, $username, $password, $database, $port) function mysql_connect($host, $username, $password, $database, $port)
{ {
return DB::getInstance()->connect($host, $username, $password, $database, $port); return NexusDB::getInstance()->connect($host, $username, $password, $database, $port);
} }
function mysql_errno() function mysql_errno()
{ {
return DB::getInstance()->errno(); return NexusDB::getInstance()->errno();
} }
function mysql_error() function mysql_error()
{ {
return DB::getInstance()->error(); return NexusDB::getInstance()->error();
} }
function mysql_query(string $sql) function mysql_query(string $sql)
{ {
return DB::getInstance()->query($sql); return NexusDB::getInstance()->query($sql);
} }
function mysql_select_db($database) function mysql_select_db($database)
{ {
return DB::getInstance()->select_db($database); return NexusDB::getInstance()->select_db($database);
} }
function mysql_num_rows($result) function mysql_num_rows($result)
{ {
return DB::getInstance()->numRows($result); return NexusDB::getInstance()->numRows($result);
} }
function mysql_fetch_array($result, $type = null) function mysql_fetch_array($result, $type = null)
{ {
return DB::getInstance()->fetchArray($result, $type); return NexusDB::getInstance()->fetchArray($result, $type);
} }
function mysql_fetch_assoc($result) function mysql_fetch_assoc($result)
{ {
return DB::getInstance()->fetchAssoc($result); return NexusDB::getInstance()->fetchAssoc($result);
} }
function mysql_fetch_row($result) function mysql_fetch_row($result)
{ {
return DB::getInstance()->fetchRow($result); return NexusDB::getInstance()->fetchRow($result);
} }
function mysql_affected_rows() function mysql_affected_rows()
{ {
return DB::getInstance()->affectedRows(); return NexusDB::getInstance()->affectedRows();
} }
function mysql_real_escape_string($string) function mysql_real_escape_string($string)
{ {
return DB::getInstance()->escapeString($string); return NexusDB::getInstance()->escapeString($string);
} }
function mysql_insert_id() function mysql_insert_id()
{ {
return DB::getInstance()->lastInsertId(); return NexusDB::getInstance()->lastInsertId();
} }
function mysql_free_result($result) function mysql_free_result($result)
{ {
return DB::getInstance()->freeResult($result); return NexusDB::getInstance()->freeResult($result);
} }

View File

@@ -2,7 +2,7 @@
namespace Nexus\Field; namespace Nexus\Field;
use Nexus\Database\DB; use Nexus\Database\NexusDB;
class Field class Field
{ {
@@ -207,10 +207,10 @@ HEAD;
$attributes['updated_at'] = $now; $attributes['updated_at'] = $now;
$table = 'torrents_custom_fields'; $table = 'torrents_custom_fields';
if (!empty($data['id'])) { if (!empty($data['id'])) {
$result = DB::update($table, $attributes, "id = " . sqlesc($data['id'])); $result = NexusDB::update($table, $attributes, "id = " . sqlesc($data['id']));
} else { } else {
$attributes['created_at'] = $now; $attributes['created_at'] = $now;
$result = DB::insert($table, $attributes); $result = NexusDB::insert($table, $attributes);
} }
return $result; return $result;
} }
@@ -255,7 +255,7 @@ HEAD;
public function renderOnUploadPage($torrentId = 0) public function renderOnUploadPage($torrentId = 0)
{ {
global $browsecatmode; global $browsecatmode;
$searchBox = DB::getOne('searchbox', "id = $browsecatmode"); $searchBox = NexusDB::getOne('searchbox', "id = $browsecatmode");
if (empty($searchBox)) { if (empty($searchBox)) {
throw new \RuntimeException("Invalid search box: $browsecatmode"); throw new \RuntimeException("Invalid search box: $browsecatmode");
} }

View File

@@ -3,7 +3,7 @@
namespace Nexus\Install; namespace Nexus\Install;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Nexus\Database\DB; use Nexus\Database\NexusDB;
class Install class Install
{ {
@@ -389,7 +389,7 @@ class Install
'added' => date('Y-m-d H:i:s'), 'added' => date('Y-m-d H:i:s'),
]; ];
$this->doLog("[CREATE ADMINISTRATOR] " . json_encode($insert)); $this->doLog("[CREATE ADMINISTRATOR] " . json_encode($insert));
return DB::insert('users', $insert); return NexusDB::insert('users', $insert);
} }
public function createEnvFile($data) public function createEnvFile($data)

View File

@@ -6,7 +6,7 @@ use App\Models\Category;
use App\Models\Icon; use App\Models\Icon;
use App\Models\Setting; use App\Models\Setting;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Nexus\Database\DB; use Nexus\Database\NexusDB;
class Update extends Install class Update extends Install
{ {
@@ -63,11 +63,11 @@ class Update extends Install
'url' => $url, 'url' => $url,
'info' => 'Manage custom fields', '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"); $this->doLog("[ADD CUSTOM FIELD MENU] insert: " . json_encode($insert) . " to table: $table, id: $id");
} }
//since beta8 //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]'); $this->doLog('[INIT CATEGORY ICON_ID]');
$icon = Icon::query()->orderBy('id', 'asc')->first(); $icon = Icon::query()->orderBy('id', 'asc')->first();
if ($icon) { if ($icon) {
@@ -75,7 +75,7 @@ class Update extends Install
} }
} }
//fix base url, since beta8 //fix base url, since beta8
if (WITH_LARAVEL && DB::schema()->hasTable('settings')) { if (WITH_LARAVEL && NexusDB::schema()->hasTable('settings')) {
$settingBasic = get_setting('basic'); $settingBasic = get_setting('basic');
if (isset($settingBasic['BASEURL']) && Str::startsWith($settingBasic['BASEURL'], 'localhost')) { if (isset($settingBasic['BASEURL']) && Str::startsWith($settingBasic['BASEURL'], 'localhost')) {
$this->doLog('[RESET CONFIG basic.BASEURL]'); $this->doLog('[RESET CONFIG basic.BASEURL]');
@@ -89,7 +89,7 @@ class Update extends Install
//torrent support sticky second level //torrent support sticky second level
if (WITH_LARAVEL) { 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)); $this->doLog("[TORRENT POS_STATE], column info: " . json_encode($columnInfo));
if ($columnInfo['DATA_TYPE'] == 'enum') { if ($columnInfo['DATA_TYPE'] == 'enum') {
$sql = "alter table torrents modify `pos_state` varchar(32) NOT NULL DEFAULT 'normal'"; $sql = "alter table torrents modify `pos_state` varchar(32) NOT NULL DEFAULT 'normal'";

View File

@@ -2,7 +2,7 @@
namespace Nexus\Torrent; namespace Nexus\Torrent;
use Nexus\Database\DB; use Nexus\Database\NexusDB;
class Torrent class Torrent
{ {
@@ -19,7 +19,7 @@ class Torrent
$torrentIdStr = implode(',', $torrentIdArr); $torrentIdStr = implode(',', $torrentIdArr);
//seeding or leeching, from peers //seeding or leeching, from peers
$whereStr = sprintf("userid = %s and torrent in (%s)", sqlesc($uid), $torrentIdStr); $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'); $peerList = array_column($peerList,'to_go', 'torrent');
//download progress, from snatched //download progress, from snatched
$sql = sprintf( $sql = sprintf(
@@ -64,4 +64,4 @@ class Torrent
); );
return $result; return $result;
} }
} }

View File

@@ -193,7 +193,7 @@ sql_query("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id") or
* @since v1.6 * @since v1.6
*/ */
if (!empty($_POST['custom_fields'])) { 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'); $now = date('Y-m-d H:i:s');
foreach ($_POST['custom_fields'] as $customField => $customValue) { foreach ($_POST['custom_fields'] as $customField => $customValue) {
foreach ((array)$customValue as $value) { foreach ((array)$customValue as $value) {
@@ -204,7 +204,7 @@ if (!empty($_POST['custom_fields'])) {
'created_at' => $now, 'created_at' => $now,
'updated_at' => $now, 'updated_at' => $now,
]; ];
\Nexus\Database\DB::insert('torrents_custom_field_values', $customData); \Nexus\Database\NexusDB::insert('torrents_custom_field_values', $customData);
} }
} }
} }

View File

@@ -369,7 +369,7 @@ if (!empty($_POST['custom_fields'])) {
'created_at' => $now, 'created_at' => $now,
'updated_at' => $now, 'updated_at' => $now,
]; ];
\Nexus\Database\DB::insert('torrents_custom_field_values', $customData); \Nexus\Database\NexusDB::insert('torrents_custom_field_values', $customData);
} }
} }
} }