Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
refactor(SiteConfig): change namespace authority.route_ to route.
Browse files Browse the repository at this point in the history
Signed-off-by: Rhilip <rhilipruan@gmail.com>
  • Loading branch information
Rhilip committed Jun 15, 2019
1 parent 7fa7069 commit 037ca71
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions apps/middleware/AuthByCookiesMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public function handle($callable, \Closure $next)
* if this config key is not exist , the default class 1 will be used to compare.
*
* Example of `Route - Controller - Config Key` Map:
* /admin -> AdminController::actionIndex -> authority.route_admin_index
* /admin/service -> AdminController::actionService -> authority.route_admin_service
* /admin -> AdminController::actionIndex -> route.admin_index
* /admin/service -> AdminController::actionService -> route.admin_service
*/
$route = strtolower(str_replace(['apps\\controllers\\', 'Controller'], ['', ''], $controllerName)) .
"_" . strtolower(str_replace('action', '', $action));
$required_class = app()->config->get('authority.route_' . $route, false) ?: 1;
$required_class = app()->config->get('route.' . $route, false) ?: 1;
if (app()->user->getClass(true) < $required_class) {
return app()->response->setStatusCode(403);
}
Expand Down
4 changes: 4 additions & 0 deletions apps/public/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ body{background-color:#f6f6f6}

.nowrap {white-space: nowrap;}

.required:after{position: static}

/*-----------------------------------------------------------------------------------*/
/* 2. Layout of Header, Navigation & Menus
/*-----------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -86,6 +88,8 @@ body{background-color:#f6f6f6}
/* Common */
.torrent-title-block{margin-bottom: 15px}
.torrent-title{}
.name-left{width:95%;}
#torrents_table td[data-item] {vertical-align: middle;}

/* '/torrent/upload' */
#torrent_upload_table > tbody > tr > td:first-child{vertical-align:middle;text-align:right}
Expand Down
1 change: 1 addition & 0 deletions apps/views/auth/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
onpaste="return false;" data-match="#password"
>
</div>
<div class="help-block with-errors"></div>
</div>

<?php if ($register_type == 'invite') : ?>
Expand Down
3 changes: 1 addition & 2 deletions apps/views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @var League\Plates\Template\Template $this
* @var array $news
*/

$can_manage_news = app()->user->isPrivilege('manage_news');
?>

<?= $this->layout('layout/base') ?>
Expand All @@ -18,6 +16,7 @@

<?php $this->start('container') ?>
<div class="panel" id="news_panel">
<?php $can_manage_news = app()->user->isPrivilege('manage_news'); ?>
<div class="panel-heading">Recent News - <small>[<a href="/news" target="_blank">All</a>]</small>
<?= $can_manage_news ? '<small>[<a href="/news/new">New</a>]</small>' : '' ?>
</div>
Expand Down
6 changes: 3 additions & 3 deletions apps/views/torrent/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<table id="torrent_upload_table" class="table table-bordered table-striped">
<tbody>
<tr>
<td class="nowrap"><label for="title">Title<span class="text-red">*</span></label></td>
<td class="nowrap"><label for="title" class="required">Title</td>
<td><input id="title" name="title" class="form-control" type="text"
placeholder="The main title of Your upload torrent"
required="required">
Expand All @@ -35,7 +35,7 @@
<small>You should obey our upload rules. **LINK**</small></td> <!-- FIXME link url -->
</tr>
<tr>
<td class="nowrap"><label for="file">Torrent File<span class="text-red">*</span></label></td>
<td class="nowrap"><label for="file" class="required">Torrent File</label></td>
<td>
<input id="torrent_file" name="file" class="form-control" type="file"
accept=".torrent" required="required"
Expand All @@ -44,7 +44,7 @@
<span id="torrent_file_name"></span>
</tr>
<tr>
<td class="nowrap"><label for="descr">Description<span class="text-red">*</span></label></td>
<td class="nowrap"><label for="descr" class="required">Description</label></td>
<td>
<textarea id="descr" name="descr" class="form-control" style="width: 99%"
cols="100" rows="10" required="required"></textarea>
Expand Down
8 changes: 4 additions & 4 deletions migration/ridpt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jun 07, 2019 at 11:15 AM
-- Generation Time: Jun 15, 2019 at 07:53 PM
-- Server version: 8.0.16
-- PHP Version: 7.3.6

Expand Down Expand Up @@ -196,7 +196,7 @@ CREATE TABLE IF NOT EXISTS `invite` (
`invite_type` enum('temporarily','permanent') NOT NULL DEFAULT 'temporarily',
`create_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`expire_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`used` tinyint(1) NOT NULL DEFAULT '0',
`used` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0 - wait to use ; 1 - used ; -1 - expired; -2 - recycled',
PRIMARY KEY (`id`),
UNIQUE KEY `hash` (`hash`),
UNIQUE KEY `username` (`username`),
Expand Down Expand Up @@ -364,8 +364,6 @@ INSERT INTO `site_config` (`name`, `value`) VALUES
('authority.manage_news', '80'),
('authority.pass_invite_interval_check', '60'),
('authority.pass_tracker_upspeed_check', '60'),
('authority.route_admin_index', '60'),
('authority.route_admin_service', '90'),
('authority.see_anonymous_uploader', '40'),
('authority.see_banned_torrent', '40'),
('authority.see_extend_debug_log', '90'),
Expand Down Expand Up @@ -427,6 +425,8 @@ INSERT INTO `site_config` (`name`, `value`) VALUES
('register.user_default_status', 'pending'),
('register.user_default_uploaded', '0'),
('register.user_default_uploadpos', '1'),
('route.admin_index', '60'),
('route.admin_service', '90'),
('security.max_login_attempts', '10'),
('torrent.max_file_size', '3145728'),
('torrent.max_nfo_size', '65535'),
Expand Down

0 comments on commit 037ca71

Please sign in to comment.