Browse Source

API: Fix torrent group errors

spaghetti 8 years ago
parent
commit
5d3aa1059b
2 changed files with 12 additions and 20 deletions
  1. 5
    9
      sections/ajax/torrent.php
  2. 7
    11
      sections/ajax/torrentgroup.php

+ 5
- 9
sections/ajax/torrent.php View File

1
 <?
1
 <?
2
 require(SERVER_ROOT.'/sections/torrents/functions.php');
2
 require(SERVER_ROOT.'/sections/torrents/functions.php');
3
 
3
 
4
-// What do these two variables even do?
5
-$GroupAllowed = array('WikiBody', 'WikiImage', 'ID', 'Name', 'Year', 'CatalogueNumber', 'ReleaseType', 'CategoryID', 'Time');
6
-$TorrentAllowed = array('ID', 'Media', 'Format', 'Encoding', 'FileCount', 'Size', 'Seeders', 'Leechers', 'Snatched', 'FreeTorrent', 'Time', 'Description', 'FileList', 'FilePath', 'UserID', 'Username');
7
-
8
 $TorrentID = (int)$_GET['id'];
4
 $TorrentID = (int)$_GET['id'];
9
 $TorrentHash = (string)$_GET['hash'];
5
 $TorrentHash = (string)$_GET['hash'];
10
 
6
 
51
 
47
 
52
 $TagList = explode('|', $TorrentDetails['GROUP_CONCAT(DISTINCT tags.Name SEPARATOR \'|\')']);
48
 $TagList = explode('|', $TorrentDetails['GROUP_CONCAT(DISTINCT tags.Name SEPARATOR \'|\')']);
53
 
49
 
54
-$JsonTorrentDetails = array(
50
+$JsonTorrentDetails = [
55
   'wikiBody'        => Text::full_format($TorrentDetails['WikiBody']),
51
   'wikiBody'        => Text::full_format($TorrentDetails['WikiBody']),
56
   'wikiImage'       => $TorrentDetails['WikiImage'],
52
   'wikiImage'       => $TorrentDetails['WikiImage'],
57
   'id'              => (int)$TorrentDetails['ID'],
53
   'id'              => (int)$TorrentDetails['ID'],
67
   'time'            => $TorrentDetails['Time'],
63
   'time'            => $TorrentDetails['Time'],
68
   'isBookmarked'    => Bookmarks::has_bookmarked('torrent', $GroupID),
64
   'isBookmarked'    => Bookmarks::has_bookmarked('torrent', $GroupID),
69
   'tags'            => $TagList
65
   'tags'            => $TagList
70
-);
66
+];
71
 
67
 
72
 $Torrent = $TorrentList[$TorrentID];
68
 $Torrent = $TorrentList[$TorrentID];
73
 
69
 
82
 unset($File);
78
 unset($File);
83
 $FileList = implode('|||', $FileList);
79
 $FileList = implode('|||', $FileList);
84
 $Userinfo = Users::user_info($Torrent['UserID']);
80
 $Userinfo = Users::user_info($Torrent['UserID']);
85
-$JsonTorrentList[] = array(
81
+$JsonTorrentList[] = [
86
   'id'          => (int)$Torrent['ID'],
82
   'id'          => (int)$Torrent['ID'],
87
   'infoHash'    => $Torrent['InfoHash'],
83
   'infoHash'    => $Torrent['InfoHash'],
88
   'media'       => $Torrent['Media'],
84
   'media'       => $Torrent['Media'],
109
   'filePath'    => $Torrent['FilePath'],
105
   'filePath'    => $Torrent['FilePath'],
110
   'userId'      => (int)$Torrent['UserID'],
106
   'userId'      => (int)$Torrent['UserID'],
111
   'username'    => $Userinfo['Username']
107
   'username'    => $Userinfo['Username']
112
-);
108
+];
113
 
109
 
114
-json_die("success", array('group' => $JsonTorrentDetails, 'torrent' => array_pop($JsonTorrentList)));
110
+json_die("success", ['group' => $JsonTorrentDetails, 'torrent' => array_pop($JsonTorrentList)]);

+ 7
- 11
sections/ajax/torrentgroup.php View File

2
 
2
 
3
 require(SERVER_ROOT.'/sections/torrents/functions.php');
3
 require(SERVER_ROOT.'/sections/torrents/functions.php');
4
 
4
 
5
-// Seriously what the hell do these do
6
-$GroupAllowed = array('WikiBody', 'WikiImage', 'ID', 'Name', 'Year', 'RecordLabel', 'CatalogueNumber', 'ReleaseType', 'CategoryID', 'Time', 'VanityHouse');
7
-$TorrentAllowed = array('ID', 'Media', 'Format', 'Encoding', 'Remastered', 'RemasterYear', 'RemasterTitle', 'RemasterRecordLabel', 'RemasterCatalogueNumber', 'Scene', 'HasLog', 'HasCue', 'LogScore', 'FileCount', 'Size', 'Seeders', 'Leechers', 'Snatched', 'FreeTorrent', 'Time', 'Description', 'FileList', 'FilePath', 'UserID', 'Username');
8
-
9
 $GroupID = (int)$_GET['id'];
5
 $GroupID = (int)$_GET['id'];
10
 $TorrentHash = (string)$_GET['hash'];
6
 $TorrentHash = (string)$_GET['hash'];
11
 
7
 
36
 
32
 
37
 list($TorrentDetails, $TorrentList) = $TorrentCache;
33
 list($TorrentDetails, $TorrentList) = $TorrentCache;
38
 
34
 
39
-$Artiss = pullmediainfo(Artists::get_artist($GroupID));
35
+$Artists = pullmediainfo(Artists::get_artist($GroupID));
40
 
36
 
41
 if ($TorrentDetails['CategoryID'] == 0) {
37
 if ($TorrentDetails['CategoryID'] == 0) {
42
   $CategoryName = 'Unknown';
38
   $CategoryName = 'Unknown';
46
 
42
 
47
 $TagList = explode('|', $TorrentDetails['GROUP_CONCAT(DISTINCT tags.Name SEPARATOR \'|\')']);
43
 $TagList = explode('|', $TorrentDetails['GROUP_CONCAT(DISTINCT tags.Name SEPARATOR \'|\')']);
48
 
44
 
49
-$JsonTorrentDetails = array(
45
+$JsonTorrentDetails = [
50
   'wikiBody'        => Text::full_format($TorrentDetails['WikiBody']),
46
   'wikiBody'        => Text::full_format($TorrentDetails['WikiBody']),
51
   'wikiImage'       => $TorrentDetails['WikiImage'],
47
   'wikiImage'       => $TorrentDetails['WikiImage'],
52
   'id'              => (int)$TorrentDetails['ID'],
48
   'id'              => (int)$TorrentDetails['ID'],
62
   'time'            => $TorrentDetails['Time'],
58
   'time'            => $TorrentDetails['Time'],
63
   'isBookmarked'    => Bookmarks::has_bookmarked('torrent', $GroupID),
59
   'isBookmarked'    => Bookmarks::has_bookmarked('torrent', $GroupID),
64
   'tags'            => $TagList
60
   'tags'            => $TagList
65
-);
61
+];
66
 
62
 
67
 $JsonTorrentList = [];
63
 $JsonTorrentList = [];
68
 foreach ($TorrentList as $Torrent) {
64
 foreach ($TorrentList as $Torrent) {
76
   $Userinfo = Users::user_info($Torrent['UserID']);
72
   $Userinfo = Users::user_info($Torrent['UserID']);
77
   $Reports = Torrents::get_reports($Torrent['ID']);
73
   $Reports = Torrents::get_reports($Torrent['ID']);
78
   $Torrent['Reported'] = count($Reports) > 0;
74
   $Torrent['Reported'] = count($Reports) > 0;
79
-  $JsonTorrentList[] = array(
75
+  $JsonTorrentList[] = [
80
     'id'          => (int)$Torrent['ID'],
76
     'id'          => (int)$Torrent['ID'],
81
     'infoHash'    => $Torrent['InfoHash'],
77
     'infoHash'    => $Torrent['InfoHash'],
82
     'media'       => $Torrent['Media'],
78
     'media'       => $Torrent['Media'],
85
     'resolution'  => $Torrent['Resolution'],
81
     'resolution'  => $Torrent['Resolution'],
86
     'audioFormat' => $Torrent['AudioFormat'],
82
     'audioFormat' => $Torrent['AudioFormat'],
87
     'subbing'     => $Torrent['Subbing'],
83
     'subbing'     => $Torrent['Subbing'],
88
-    'subber'      => $Torrent['Subber']
84
+    'subber'      => $Torrent['Subber'],
89
     'language'    => $Torrent['Language'],
85
     'language'    => $Torrent['Language'],
90
     'censored'    => (bool)$Torrent['Censored'],
86
     'censored'    => (bool)$Torrent['Censored'],
91
     'archive'     => $Torrent['Archive'],
87
     'archive'     => $Torrent['Archive'],
103
     'filePath'    => $Torrent['FilePath'],
99
     'filePath'    => $Torrent['FilePath'],
104
     'userId'      => (int)$Torrent['UserID'],
100
     'userId'      => (int)$Torrent['UserID'],
105
     'username'    => $Userinfo['Username']
101
     'username'    => $Userinfo['Username']
106
-  );
102
+  ];
107
 }
103
 }
108
 
104
 
109
-json_die("success", array('group' => $JsonTorrentDetails, 'torrents' => $JsonTorrentList));
105
+json_die("success", ['group' => $JsonTorrentDetails, 'torrents' => $JsonTorrentList]);

Loading…
Cancel
Save