|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ownCloud - Music app |
|
5
|
|
|
* |
|
6
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
7
|
|
|
* later. See the COPYING file. |
|
8
|
|
|
* |
|
9
|
|
|
* @author Morris Jobke <[email protected]> |
|
10
|
|
|
* @author Pauli Järvinen <[email protected]> |
|
11
|
|
|
* @copyright Morris Jobke 2013, 2014 |
|
12
|
|
|
* @copyright Pauli Järvinen 2020 |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace OCA\Music\Db; |
|
16
|
|
|
|
|
17
|
|
|
use OCP\AppFramework\Db\Mapper; |
|
|
|
|
|
|
18
|
|
|
use OCP\IDBConnection; |
|
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
class AmpacheSessionMapper extends Mapper { |
|
21
|
|
|
public function __construct(IDBConnection $db) { |
|
22
|
|
|
parent::__construct($db, 'music_ampache_sessions', '\OCA\Music\Db\AmpacheSession'); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param string $token |
|
27
|
|
|
* @return string|false |
|
28
|
|
|
*/ |
|
29
|
|
|
public function findByToken($token) { |
|
30
|
|
|
$sql = 'SELECT `user_id` |
|
31
|
|
|
FROM `*PREFIX*music_ampache_sessions` |
|
32
|
|
|
WHERE `token` = ? AND `expiry` > ?'; |
|
33
|
|
|
$params = [$token, \time()]; |
|
34
|
|
|
|
|
35
|
|
|
$result = $this->execute($sql, $params); |
|
36
|
|
|
|
|
37
|
|
|
$row = $result->fetch(); |
|
38
|
|
|
return \is_array($row) ? $row['user_id'] : false; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param string $token |
|
43
|
|
|
* @param integer $expiry |
|
44
|
|
|
*/ |
|
45
|
|
|
public function extend($token, $expiry) { |
|
46
|
|
|
$sql = 'UPDATE `*PREFIX*music_ampache_sessions` |
|
47
|
|
|
SET `expiry` = ? |
|
48
|
|
|
WHERE `token` = ?'; |
|
49
|
|
|
|
|
50
|
|
|
$params = [$expiry, $token]; |
|
51
|
|
|
$this->execute($sql, $params); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function cleanUp() { |
|
55
|
|
|
$sql = 'DELETE FROM `*PREFIX*music_ampache_sessions` |
|
56
|
|
|
WHERE `expiry` < ?'; |
|
57
|
|
|
$params = [\time()]; |
|
58
|
|
|
$this->execute($sql, $params); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param string $token |
|
63
|
|
|
* @return integer|false |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getExpiryTime($token) { |
|
66
|
|
|
$sql = 'SELECT `expiry` |
|
67
|
|
|
FROM `*PREFIX*music_ampache_sessions` |
|
68
|
|
|
WHERE `token` = ?'; |
|
69
|
|
|
$params = [$token]; |
|
70
|
|
|
|
|
71
|
|
|
$result = $this->execute($sql, $params); |
|
72
|
|
|
|
|
73
|
|
|
$row = $result->fetch(); |
|
74
|
|
|
return \is_array($row) ? (int)$row['expiry'] : false; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths