mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
tag add more customized options + NexusDB::rememter()
This commit is contained in:
@@ -7,10 +7,30 @@
|
|||||||
<el-input v-model="formData.name" placeholder=""></el-input>
|
<el-input v-model="formData.name" placeholder=""></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="Color" prop="color">
|
<el-form-item label="Background color" prop="color">
|
||||||
<el-input v-model="formData.color" placeholder=""></el-input>
|
<el-input v-model="formData.color" placeholder=""></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="Font color" prop="font_color">
|
||||||
|
<el-input v-model="formData.font_color" placeholder=""></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="Font size" prop="font_size">
|
||||||
|
<el-input v-model="formData.font_size" placeholder=""></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="Padding" prop="padding">
|
||||||
|
<el-input v-model="formData.padding" placeholder=""></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="Margin" prop="margin">
|
||||||
|
<el-input v-model="formData.margin" placeholder=""></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="Border radius" prop="border_radius">
|
||||||
|
<el-input v-model="formData.border_radius" placeholder=""></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="Priority" prop="priority">
|
<el-form-item label="Priority" prop="priority">
|
||||||
<el-input v-model="formData.priority" placeholder="The higher the value, the higher the ranking"></el-input>
|
<el-input v-model="formData.priority" placeholder="The higher the value, the higher the ranking"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -47,7 +67,12 @@ export default {
|
|||||||
formData: {
|
formData: {
|
||||||
color: '',
|
color: '',
|
||||||
name: '',
|
name: '',
|
||||||
priority: ''
|
priority: '',
|
||||||
|
font_color: '#ffffff',
|
||||||
|
font_size: '12px',
|
||||||
|
margin: 0,
|
||||||
|
padding: 0,
|
||||||
|
border_radius: 0,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
color: [
|
color: [
|
||||||
@@ -64,6 +89,11 @@ export default {
|
|||||||
state.formData.name = res.data.name
|
state.formData.name = res.data.name
|
||||||
state.formData.color = res.data.color
|
state.formData.color = res.data.color
|
||||||
state.formData.priority = res.data.priority
|
state.formData.priority = res.data.priority
|
||||||
|
state.formData.font_color = res.data.font_color
|
||||||
|
state.formData.font_size = res.data.font_size
|
||||||
|
state.formData.margin = res.data.margin
|
||||||
|
state.formData.padding = res.data.padding
|
||||||
|
state.formData.border_radius = res.data.border_radius
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,37 @@
|
|||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="color"
|
prop="color"
|
||||||
label="Color"
|
label="Background color"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column
|
||||||
|
prop="font_color"
|
||||||
|
label="Font color"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column
|
||||||
|
prop="font_size"
|
||||||
|
label="Font size"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column
|
||||||
|
prop="margin"
|
||||||
|
label="Margin"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column
|
||||||
|
prop="padding"
|
||||||
|
label="Padding"
|
||||||
|
>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column
|
||||||
|
prop="border_radius"
|
||||||
|
label="Border radius"
|
||||||
>
|
>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
@@ -48,12 +78,6 @@
|
|||||||
label="Updated at"
|
label="Updated at"
|
||||||
></el-table-column>
|
></el-table-column>
|
||||||
|
|
||||||
<el-table-column
|
|
||||||
prop="created_at"
|
|
||||||
label="Created at"
|
|
||||||
></el-table-column>
|
|
||||||
|
|
||||||
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
label="Action"
|
label="Action"
|
||||||
width="120"
|
width="120"
|
||||||
|
|||||||
@@ -46,10 +46,7 @@ class TagController extends Controller
|
|||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate($this->getRules());
|
$request->validate($this->getRules());
|
||||||
$data = $request->all();
|
$data = array_filter($request->all());
|
||||||
if (isset($data['priority'])) {
|
|
||||||
$data['priority'] = intval($data['priority']);
|
|
||||||
}
|
|
||||||
$result = $this->repository->store($data);
|
$result = $this->repository->store($data);
|
||||||
$resource = new TagResource($result);
|
$resource = new TagResource($result);
|
||||||
return $this->success($resource);
|
return $this->success($resource);
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ class TagResource extends JsonResource
|
|||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'color' => $this->color,
|
'color' => $this->color,
|
||||||
|
'font_color' => $this->font_color,
|
||||||
|
'font_size' => $this->font_size,
|
||||||
|
'padding' => $this->padding,
|
||||||
|
'margin' => $this->margin,
|
||||||
|
'border_radius' => $this->border_radius,
|
||||||
'priority' => $this->priority,
|
'priority' => $this->priority,
|
||||||
'created_at' => format_datetime($this->created_at),
|
'created_at' => format_datetime($this->created_at),
|
||||||
'updated_at' => format_datetime($this->updated_at),
|
'updated_at' => format_datetime($this->updated_at),
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Nexus\Database\NexusDB;
|
||||||
|
|
||||||
class Setting extends NexusModel
|
class Setting extends NexusModel
|
||||||
{
|
{
|
||||||
@@ -10,9 +12,9 @@ class Setting extends NexusModel
|
|||||||
|
|
||||||
public static function get($name = null)
|
public static function get($name = null)
|
||||||
{
|
{
|
||||||
static $settings;
|
$settings = NexusDB::remember("nexus_settings_in_laravel", 10, function () {
|
||||||
if (is_null($settings)) {
|
|
||||||
$rows = self::query()->get(['name', 'value']);
|
$rows = self::query()->get(['name', 'value']);
|
||||||
|
$result = [];
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$value = $row->value;
|
$value = $row->value;
|
||||||
if (!is_null($value)) {
|
if (!is_null($value)) {
|
||||||
@@ -21,9 +23,10 @@ class Setting extends NexusModel
|
|||||||
$value = $arr;
|
$value = $arr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Arr::set($settings, $row->name, $value);
|
Arr::set($result, $row->name, $value);
|
||||||
}
|
}
|
||||||
}
|
return $result;
|
||||||
|
});
|
||||||
if (is_null($name)) {
|
if (is_null($name)) {
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class Tag extends NexusModel
|
|||||||
public $timestamps = true;
|
public $timestamps = true;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id', 'name', 'color', 'priority', 'created_at', 'updated_at'
|
'id', 'name', 'color', 'priority', 'created_at', 'updated_at', 'font_size', 'font_color', 'padding', 'margin', 'border_radius'
|
||||||
];
|
];
|
||||||
|
|
||||||
const DEFAULTS = [
|
const DEFAULTS = [
|
||||||
|
|||||||
@@ -67,7 +67,10 @@ class TagRepository extends BaseRepository
|
|||||||
foreach ($renderIdArr as $tagId) {
|
foreach ($renderIdArr as $tagId) {
|
||||||
$value = $tagKeyById->get($tagId);
|
$value = $tagKeyById->get($tagId);
|
||||||
if ($value) {
|
if ($value) {
|
||||||
$item = "<span style=\"background-color:{$value->color};color:white;border-radius:15%\">{$value->name}</span> ";
|
$item = sprintf(
|
||||||
|
"<span style=\"background-color:%s;color:%s;border-radius:%s;font-size:%s;margin:%s;padding:%s\">%s</span>",
|
||||||
|
$value->color, $value->font_color, $value->border_radius, $value->font_size, $value->margin, $value->padding, $value->name
|
||||||
|
);
|
||||||
if ($withFilterLink) {
|
if ($withFilterLink) {
|
||||||
$html .= sprintf('<a href="torrents.php?tag_id=%s">%s</a>', $tagId, $item);
|
$html .= sprintf('<a href="torrents.php?tag_id=%s">%s</a>', $tagId, $item);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -661,8 +661,17 @@ class TrackerRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Torrent $torrent
|
||||||
|
* @param $queries
|
||||||
|
*/
|
||||||
private function updateTorrent(Torrent $torrent, $queries)
|
private function updateTorrent(Torrent $torrent, $queries)
|
||||||
{
|
{
|
||||||
|
if (empty($queries['event'])) {
|
||||||
|
do_log("no event, return", 'debug');
|
||||||
|
return;
|
||||||
|
}
|
||||||
$torrent->seeders = Peer::query()
|
$torrent->seeders = Peer::query()
|
||||||
->where('torrent', $torrent->id)
|
->where('torrent', $torrent->id)
|
||||||
->where('to_go', '=',0)
|
->where('to_go', '=',0)
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddMarginPaddingToTagsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('tags', function (Blueprint $table) {
|
||||||
|
$table->string('padding')->default(0);
|
||||||
|
$table->string('margin')->default('0 4px 0 0');
|
||||||
|
$table->string('border_radius')->default(0);
|
||||||
|
$table->string('font_size')->default('12px');
|
||||||
|
$table->string('font_color')->default('#ffffff');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('tags', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['padding', 'margin', 'font_size', 'font_color', 'border_radius']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ if (!file_exists($rootpath . '.env')) {
|
|||||||
require $rootpath . 'nexus/Database/helpers.php';
|
require $rootpath . 'nexus/Database/helpers.php';
|
||||||
require $rootpath . 'classes/class_cache_redis.php';
|
require $rootpath . 'classes/class_cache_redis.php';
|
||||||
require $rootpath . 'include/eloquent.php';
|
require $rootpath . 'include/eloquent.php';
|
||||||
require $rootpath . 'include/config.php';
|
|
||||||
|
|
||||||
ini_set('date.timezone', nexus_config('nexus.timezone'));
|
ini_set('date.timezone', nexus_config('nexus.timezone'));
|
||||||
ini_set('error_reporting', E_ALL);
|
ini_set('error_reporting', E_ALL);
|
||||||
@@ -24,6 +23,8 @@ if (!in_array(nexus()->getScript(), ['announce', 'scrape'])) {
|
|||||||
}
|
}
|
||||||
$Cache = new class_cache_redis(); //Load the caching class
|
$Cache = new class_cache_redis(); //Load the caching class
|
||||||
$Cache->setLanguageFolderArray(get_langfolder_list());
|
$Cache->setLanguageFolderArray(get_langfolder_list());
|
||||||
|
require $rootpath . 'include/config.php';
|
||||||
|
|
||||||
define('TIMENOW', time());
|
define('TIMENOW', time());
|
||||||
$USERUPDATESET = array();
|
$USERUPDATESET = array();
|
||||||
$query_name=array();
|
$query_name=array();
|
||||||
|
|||||||
@@ -282,19 +282,23 @@ function get_setting($name = null)
|
|||||||
{
|
{
|
||||||
static $settings;
|
static $settings;
|
||||||
if (is_null($settings)) {
|
if (is_null($settings)) {
|
||||||
//get all settings from database
|
$settings = \Nexus\Database\NexusDB::remember("nexus_settings_in_nexus" . __METHOD__, 10, function () {
|
||||||
$sql = "select name, value from settings";
|
//get all settings from database
|
||||||
$result = sql_query($sql);
|
$sql = "select name, value from settings";
|
||||||
while ($row = mysql_fetch_assoc($result)) {
|
$result = sql_query($sql);
|
||||||
$value = $row['value'];
|
$final = [];
|
||||||
if (!is_null($value)) {
|
while ($row = mysql_fetch_assoc($result)) {
|
||||||
$arr = json_decode($value, true);
|
$value = $row['value'];
|
||||||
if (is_array($arr)) {
|
if (!is_null($value)) {
|
||||||
$value = $arr;
|
$arr = json_decode($value, true);
|
||||||
|
if (is_array($arr)) {
|
||||||
|
$value = $arr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
arr_set($final, $row['name'], $value);
|
||||||
}
|
}
|
||||||
arr_set($settings, $row['name'], $value);
|
return $final;
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
if (is_null($name)) {
|
if (is_null($name)) {
|
||||||
return $settings;
|
return $settings;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Nexus\Database;
|
|||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||||
use Illuminate\Database\Query\Expression;
|
use Illuminate\Database\Query\Expression;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class NexusDB
|
class NexusDB
|
||||||
@@ -267,6 +268,24 @@ class NexusDB
|
|||||||
return DB::transaction($callback, $attempts);
|
return DB::transaction($callback, $attempts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function remember($key, $ttl, \Closure $callback)
|
||||||
|
{
|
||||||
|
if (IN_NEXUS) {
|
||||||
|
global $Cache;
|
||||||
|
$result = $Cache->get_value($key);
|
||||||
|
if ($result === false) {
|
||||||
|
do_log("cache miss, get from database.");
|
||||||
|
$result = $callback();
|
||||||
|
$Cache->cache_value($key, $result, $ttl);
|
||||||
|
} else {
|
||||||
|
do_log("cache hit.");
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
} else {
|
||||||
|
return Cache::remember($key, $ttl, $callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function getMysqlColumnInfo($table, $column)
|
public static function getMysqlColumnInfo($table, $column)
|
||||||
{
|
{
|
||||||
static $driver;
|
static $driver;
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ else{
|
|||||||
if ($newnumpeers > $rsize)
|
if ($newnumpeers > $rsize)
|
||||||
$limit = " ORDER BY RAND() LIMIT $rsize";
|
$limit = " ORDER BY RAND() LIMIT $rsize";
|
||||||
else $limit = "";
|
else $limit = "";
|
||||||
$announce_wait = 30;
|
$announce_wait = \App\Repositories\TrackerRepository::MIN_ANNOUNCE_WAIT_SECOND;
|
||||||
|
|
||||||
$fields = "seeder, peer_id, ip, port, uploaded, downloaded, (".TIMENOW." - UNIX_TIMESTAMP(last_action)) AS announcetime, UNIX_TIMESTAMP(prev_action) AS prevts";
|
$fields = "seeder, peer_id, ip, port, uploaded, downloaded, (".TIMENOW." - UNIX_TIMESTAMP(last_action)) AS announcetime, UNIX_TIMESTAMP(prev_action) AS prevts";
|
||||||
//$peerlistsql = "SELECT ".$fields." FROM peers WHERE torrent = ".$torrentid." AND connectable = 'yes' ".$only_leech_query.$limit;
|
//$peerlistsql = "SELECT ".$fields." FROM peers WHERE torrent = ".$torrentid." AND connectable = 'yes' ".$only_leech_query.$limit;
|
||||||
@@ -199,7 +199,7 @@ $params = $_GET;
|
|||||||
unset($params['key']);
|
unset($params['key']);
|
||||||
$lockKey = md5(http_build_query($params));
|
$lockKey = md5(http_build_query($params));
|
||||||
$redis = $Cache->getRedis();
|
$redis = $Cache->getRedis();
|
||||||
if (!$redis->set($lockKey, TIMENOW, ['nx', 'ex' => $announce_wait])) {
|
if (!$redis->set($lockKey, TIMENOW, ['nx', 'ex' => 5])) {
|
||||||
do_log('ReAnnounce');
|
do_log('ReAnnounce');
|
||||||
benc_resp($rep_dict);
|
benc_resp($rep_dict);
|
||||||
exit();
|
exit();
|
||||||
|
|||||||
Reference in New Issue
Block a user