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

Commit

Permalink
fix(User): Fix all user class info become cur_user
Browse files Browse the repository at this point in the history
1. Fix all user class info become cur_user
2. Fix `PHP Notice:  Array to string conversion in /data/wwwroot/ridp.top/application/Controllers/TrackerController.php on line 166`
3. Fix app()->request->server->get('query_string') can't get $_SERVER['QUERY_STRING'], use app()->request->getQueryString() instead.
4. Use magic function __toString() to get string format info of `app()->request->headers`
  • Loading branch information
Rhilip committed Jan 23, 2020
1 parent dd001d2 commit 77c7345
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- **phpstorm:** Add `.phpstorm.meat.php` for config() function (407bb66)

### Feat
- **Requests:** Make Request Component extends from `Symfony\Component\HttpFoundation\Request` (9cd715b)
- **Torrent:** Per-add torrent edit (f06b342)
- **i18n:** Use symfony/translation and JSON format for locale (02cc251)
- **layout:** Add anti-robots html meta tag (9c21e73)
Expand Down
10 changes: 4 additions & 6 deletions application/Controllers/TrackerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ public function actionIndex()

protected function logException(\Exception $exception, $userInfo = null, $torrentInfo = null)
{
$req_info = app()->request->server->get('query_string') . "\n\n";
foreach (app()->request->headers->all() as $key => $value) {
$req_info .= "$key : $value \n";
}
$req_info = app()->request->getQueryString() . "\n\n";
$req_info .= (string) app()->request->headers;

app()->pdo->createCommand('INSERT INTO `agent_deny_log`(`tid`, `uid`, `user_agent`, `peer_id`, `req_info`,`create_at`, `msg`)
VALUES (:tid,:uid,:ua,:peer_id,:req_info,CURRENT_TIMESTAMP,:msg)
Expand Down Expand Up @@ -472,7 +470,7 @@ private function getTorrentInfoByHash($hash, bool $scrape = false)
*/
private function checkScrapeFields(&$info_hash_array)
{
preg_match_all('/info_hash=([^&]*)/i', urldecode(app()->request->server->get('query_string')), $info_hash_match);
preg_match_all('/info_hash=([^&]*)/i', urldecode(app()->request->getQueryString()), $info_hash_match);

$info_hash_array = $info_hash_match[1];
if (count($info_hash_array) < 1) {
Expand Down Expand Up @@ -701,7 +699,7 @@ private function getTorrentInfo($queries, $userInfo, &$torrentInfo)
*/
private function lockAnnounceDuration()
{
$identity = md5(urldecode(app()->request->server->get('query_string')));
$identity = md5(urldecode(app()->request->getQueryString()));
if (false == $check = app()->redis->zScore(Constant::trackerAnnounceLockZset, $identity)) { // this identity is not lock
app()->redis->zAdd(Constant::trackerAnnounceLockZset, time() + 60, $identity);
}
Expand Down
6 changes: 2 additions & 4 deletions application/Entity/User/AbstractUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ class AbstractUser extends BaseObject implements AbstractUserInterface

protected function getCacheNameSpace(): string
{
if (is_null($this->info_cache_key)) {
$this->info_cache_key = Constant::userContent($this->id);
}

return $this->info_cache_key;
}

/** @noinspection PhpMissingParentConstructorInspection */
public function __construct($id = 0)
{
$this->id = $id;
$this->info_cache_key = Constant::userContent($this->id);
$self = app()->redis->hGetAll($this->info_cache_key);
if (empty($self) || !isset($self['id'])) {
if (app()->redis->zScore(Constant::invalidUserIdZset, $id) === false) {
Expand Down

0 comments on commit 77c7345

Please sign in to comment.