This repository has been archived by the owner on Nov 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
163 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: Rhilip | ||
* Date: 2019/3/10 | ||
* Time: 17:25 | ||
*/ | ||
|
||
namespace apps\middleware; | ||
|
||
|
||
class AuthByPasskeyMiddleware | ||
{ | ||
public function handle($callable, \Closure $next) | ||
{ | ||
|
||
// Check User | ||
if (app()->request->get('passkey') === null) { | ||
return 'missing passkey'; | ||
} | ||
|
||
app()->user->loadUserFromPasskey(); | ||
if (app()->user->isAnonymous()) { | ||
return 'passkey not exist'; | ||
} | ||
|
||
// 执行下一个中间件 | ||
return $next(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* @link http://www.bittorrent.org/beps/bep_0036.html | ||
* | ||
* Created by PhpStorm. | ||
* User: Rhilip | ||
* Date: 2019/3/10 | ||
* Time: 17:24 | ||
* | ||
* @var array $torrents | ||
* @var \apps\models\Torrent $torrent | ||
*/ | ||
|
||
$url = (app()->request->isSecure() ? 'https://' : 'http://') . app()->config->get('base.site_url'); | ||
$site_name = app()->config->get('base.site_name'); | ||
$site_email = app()->config->get('base.site_email'); | ||
$yearfounded = 2019; // FIXME get it from dynamic config | ||
$copyright = "Copyright (c) " . $site_name . " " . (date("Y") != $yearfounded ? $yearfounded . "-" : "") . date("Y") . ", all rights reserved"; | ||
?> | ||
<?= '<?xml version="1.0" encoding="utf-8"?>' ?> | ||
|
||
<rss version="2.0"> | ||
<channel> | ||
<title><?= addslashes($site_name . ' Torrents') ?></title> | ||
<link><?= $url ?></link> | ||
<description><![CDATA[<?= addslashes('Latest torrents from ' . $site_name ) ?>]]></description> | ||
<language>en</language> | ||
<copyright><?= $copyright ?></copyright> | ||
<managingEditor><?= $site_email . "(" . $site_name . " Admin)" ?></managingEditor> | ||
<webMaster><?= $site_email . "(" . $site_name . " Webmaster)" ?></webMaster> | ||
<pubDate><?= date('r') ?></pubDate> | ||
<generator><?= app()->config->get('base.site_generator') ?> RSS Generator</generator> | ||
<docs><![CDATA[http://www.rssboard.org/rss-specification]]></docs> | ||
<ttl>120</ttl> | ||
<image> | ||
<url><![CDATA[<?= $url . '/favicon.ico' ?>]]></url> | ||
<title><?= addslashes($site_name . 'Torrents') ?></title> | ||
<link><![CDATA[<?= $url ?><]]></link> | ||
<width>100</width> | ||
<height>100</height> | ||
<description><?= addslashes($site_name . ' Torrents') ?></description> | ||
</image> | ||
<?php foreach ($torrents as $torrent): ?> | ||
<item> | ||
<title><![CDATA[<?= $torrent->getTitle() ?>]]></title> | ||
<link><?= $url.'/torrents/details?id=' . $torrent->getId() ?></link> | ||
<description><?= $torrent->getDescr() ?></description> | ||
<author><?= ($torrent->getUplver() == 'yes' ? 'Anonymous' : $torrent->getOwner()->getUsername()) . '@' . $site_name ?></author> | ||
<category domain="<?= $url . '/torrents?cat='.$torrent->getCategoryId()?>">Movie</category> | ||
<comments><![CDATA[<?= $url. '/torrents/details?id=' . $torrent->getId() . '&cmtpage=0#startcomments' ?>]]></comments> | ||
<enclosure url="<?= $url . '/torrents/download?id=' . $torrent->getId() . ('') ?>" length="<?= $torrent->getTorrentSize() ?>" type="application/x-bittorrent" /> | ||
<guid isPermaLink="false"><?= $torrent->getInfoHash() ?></guid> | ||
<pubDate><?= date('r',strtotime($torrent->getAddedAt())) ?></pubDate> | ||
</item> | ||
<?php endforeach; ?> | ||
</channel> | ||
</rss> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* | ||
* Common function to render torrent page | ||
* | ||
* Created by PhpStorm. | ||
* User: Rhilip | ||
* Date: 2019/3/11 | ||
* Time: 16:09 | ||
* | ||
*/ | ||
|
||
/** | ||
* @param \apps\models\Torrent $torrent | ||
* @return string | ||
*/ | ||
function get_torrent_uploader(\apps\models\Torrent $torrent) | ||
{ | ||
if ($torrent->getUplver() == 'yes' and app()->user->getClass(true) < app()->config->get('authority.see_anonymous_uploader')) { | ||
return '<i>Anonymous</i>'; | ||
} else { | ||
return "<a class=\"text-default\" href=\"/user/panel?id={$torrent->getOwnerId()}\" data-toggle=\"tooltip\" title=\"User\">{$torrent->getOwner()->getUsername()}</a>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters