Browse Source

Remove testing and staff blog stuff

biotorrents 1 month ago
parent
commit
ff836e7897

+ 0
- 170
classes/testing.class.php View File

@@ -1,170 +0,0 @@
1
-<?php
2
-#declare(strict_types=1);
3
-
4
-class Testing
5
-{
6
-    private static $ClassDirectories = array("classes");
7
-    private static $Classes = [];
8
-
9
-    /**
10
-     * Initialize the testasble classes into a map keyed by class name
11
-     */
12
-    public static function init()
13
-    {
14
-        self::load_classes();
15
-    }
16
-
17
-    /**
18
-     * Gets the class
19
-     */
20
-    public static function get_classes()
21
-    {
22
-        return self::$Classes;
23
-    }
24
-
25
-    /**
26
-     * Loads all the classes within given directories
27
-     */
28
-    private static function load_classes()
29
-    {
30
-        foreach (self::$ClassDirectories as $Directory) {
31
-            $Directory = SERVER_ROOT . "/" . $Directory . "/";
32
-            foreach (glob($Directory . "*.php") as $FileName) {
33
-                self::get_class_name($FileName);
34
-            }
35
-        }
36
-    }
37
-
38
-    /**
39
-     * Gets the class and adds into the map
40
-     */
41
-    private static function get_class_name($FileName)
42
-    {
43
-        $Tokens = token_get_all(file_get_contents($FileName));
44
-        $IsTestable = false;
45
-        $IsClass = false;
46
-
47
-        foreach ($Tokens as $Token) {
48
-            if (is_array($Token)) {
49
-                if (!$IsTestable && $Token[0] == T_DOC_COMMENT && strpos($Token[1], "@TestClass")) {
50
-                    $IsTestable = true;
51
-                }
52
-
53
-                if ($IsTestable && $Token[0] == T_CLASS) {
54
-                    $IsClass = true;
55
-                } elseif ($IsClass && $Token[0] == T_STRING) {
56
-                    $ReflectionClass = new ReflectionClass($Token[1]);
57
-
58
-                    if (count(self::get_testable_methods($ReflectionClass))) {
59
-                        self::$Classes[$Token[1]] = new ReflectionClass($Token[1]);
60
-                    }
61
-
62
-                    $IsTestable = false;
63
-                    $IsClass = false;
64
-                }
65
-            }
66
-        }
67
-    }
68
-
69
-    /**
70
-     * Checks if class exists in the map
71
-     */
72
-    public static function has_class($Class)
73
-    {
74
-        return array_key_exists($Class, self::$Classes);
75
-    }
76
-
77
-    /**
78
-     * Checks if class has a given testable methood
79
-     */
80
-    public static function has_testable_method($Class, $Method)
81
-    {
82
-        $TestableMethods = self::get_testable_methods($Class);
83
-        foreach ($TestableMethods as $TestMethod) {
84
-            if ($TestMethod->getName() === $Method) {
85
-                return true;
86
-            }
87
-        }
88
-        return false;
89
-    }
90
-
91
-    /**
92
-     * Get testable methods in a class, a testable method has a @Test
93
-     */
94
-    public static function get_testable_methods($Class)
95
-    {
96
-        if (is_string($Class)) {
97
-            $ReflectionClass = self::$Classes[$Class];
98
-        } else {
99
-            $ReflectionClass = $Class;
100
-        }
101
-
102
-        $ReflectionMethods = $ReflectionClass->getMethods();
103
-        $TestableMethods = [];
104
-
105
-        foreach ($ReflectionMethods as $Method) {
106
-            if ($Method->isPublic() && $Method->isStatic() && strpos($Method->getDocComment(), "@Test")) {
107
-                $TestableMethods[] = $Method;
108
-            }
109
-        }
110
-        return $TestableMethods;
111
-    }
112
-
113
-
114
-    /**
115
-     * Get the class comment
116
-     */
117
-    public static function get_class_comment($Class)
118
-    {
119
-        $ReflectionClass = self::$Classes[$Class];
120
-        return trim(str_replace(array("@TestClass", "*", "/"), "", $ReflectionClass->getDocComment()));
121
-    }
122
-
123
-    /**
124
-     * Get the undocumented methods in a class
125
-     */
126
-    public static function get_undocumented_methods($Class)
127
-    {
128
-        $ReflectionClass = self::$Classes[$Class];
129
-        $Methods = [];
130
-
131
-        foreach ($ReflectionClass->getMethods() as $Method) {
132
-            if (!$Method->getDocComment()) {
133
-                $Methods[] = $Method;
134
-            }
135
-        }
136
-        return $Methods;
137
-    }
138
-
139
-    /**
140
-     * Get the documented methods
141
-     */
142
-    public static function get_documented_methods($Class)
143
-    {
144
-        $ReflectionClass = self::$Classes[$Class];
145
-        $Methods = [];
146
-
147
-        foreach ($ReflectionClass->getMethods() as $Method) {
148
-            if ($Method->getDocComment()) {
149
-                $Methods[] = $Method;
150
-            }
151
-        }
152
-        return $Methods;
153
-    }
154
-
155
-    /**
156
-     * Get all methods in a class
157
-     */
158
-    public static function get_methods($Class)
159
-    {
160
-        return self::$Classes[$Class]->getMethods();
161
-    }
162
-
163
-    /**
164
-     * Get a method  comment
165
-     */
166
-    public static function get_method_comment($Method)
167
-    {
168
-        return trim(str_replace(array("*", "/"), "", $Method->getDocComment()));
169
-    }
170
-}

+ 0
- 183
classes/testingview.class.php View File

@@ -1,183 +0,0 @@
1
-<?php
2
-#declare(strict_types=1);
3
-
4
-class TestingView
5
-{
6
-    /**
7
-     * Render the linkbox
8
-     */
9
-    public static function render_linkbox($Page) { ?>
10
-<div class="linkbox">
11
-  <?php if ($Page != "classes") { ?>
12
-  <a href="testing.php" class="brackets">Classes</a>
13
-  <?php }
14
-      if ($Page != "comments") { ?>
15
-  <a href="testing.php?action=comments" class="brackets">Comments</a>
16
-  <?php } ?>
17
-</div>
18
-<?php }
19
-
20
-    /**
21
-     * Render a list of classes
22
-     */
23
-    public static function render_classes($Classes) { ?>
24
-<table>
25
-  <tr class="colhead">
26
-    <td>
27
-      Class
28
-    </td>
29
-    <td>
30
-      Testable functions
31
-    </td>
32
-  </tr>
33
-  <?php foreach ($Classes as $Key => $Value) {
34
-        $Doc = Testing::get_class_comment($Key);
35
-        $Methods = count(Testing::get_testable_methods($Key)); ?>
36
-  <tr>
37
-    <td>
38
-      <a href="testing.php?action=class&amp;name=<?=$Key?>"
39
-        class="tooltip" title="<?=$Doc?>"><?=$Key?></a>
40
-    </td>
41
-    <td>
42
-      <?=$Methods?>
43
-    </td>
44
-  </tr>
45
-  <?php
46
-    } ?>
47
-</table>
48
-<?php }
49
-
50
-    /**
51
-     * Render functions in a class
52
-     */
53
-    public static function render_functions($Methods)
54
-    {
55
-        foreach ($Methods as $Index => $Method) {
56
-            $ClassName = $Method->getDeclaringClass()->getName();
57
-            $MethodName = $Method->getName(); ?>
58
-<div class="box">
59
-  <div class="head">
60
-    <span><?=self::render_method_definition($Method)?></span>
61
-    <span class="float_right">
62
-      <a data-toggle-target="#method_params_<?=$Index?>"
63
-        class="brackets">Params</a>
64
-      <a href="#" class="brackets run" data-gazelle-id="<?=$Index?>"
65
-        data-gazelle-class="<?=$ClassName?>"
66
-        data-gazelle-method="<?=$MethodName?>">Run</a>
67
-    </span>
68
-  </div>
69
-  <div class="pad hidden" id="method_params_<?=$Index?>">
70
-    <?self::render_method_params($Method); ?>
71
-  </div>
72
-  <div class="pad hidden" id="method_results_<?=$Index?>">
73
-  </div>
74
-</div>
75
-<?php
76
-        }
77
-    }
78
-
79
-    /**
80
-     * Render method parameters
81
-     */
82
-    private static function render_method_params($Method) { ?>
83
-<table>
84
-  <?php foreach ($Method->getParameters() as $Parameter) {
85
-        $DefaultValue = $Parameter->isDefaultValueAvailable() ? $Parameter->getDefaultValue() : ""; ?>
86
-  <tr>
87
-    <td class="label">
88
-      <?=$Parameter->getName()?>
89
-    </td>
90
-    <td>
91
-      <input type="text" name="<?=$Parameter->getName()?>"
92
-        value="<?=$DefaultValue?>" />
93
-    </td>
94
-  </tr>
95
-  <?php
96
-    } ?>
97
-</table>
98
-<?php }
99
-
100
-    /**
101
-     * Render the method definition
102
-     */
103
-    private static function render_method_definition($Method)
104
-    {
105
-        $Title = "<span class='tooltip' title='" . Testing::get_method_comment($Method) . "'>" . $Method->getName() . "</span> (";
106
-        foreach ($Method->getParameters() as $Parameter) {
107
-            $Color = "red";
108
-            if ($Parameter->isDefaultValueAvailable()) {
109
-                $Color = "green";
110
-            }
111
-            $Title .= "<span style='color: $Color'>";
112
-            $Title .= "$" . $Parameter->getName();
113
-            if ($Parameter->isDefaultValueAvailable()) {
114
-                $Title .= " = " . $Parameter->getDefaultValue();
115
-            }
116
-            $Title .= "</span>";
117
-            $Title .= ", ";
118
-        }
119
-        $Title = rtrim($Title, ", ");
120
-        $Title .= ")";
121
-        return $Title;
122
-    }
123
-
124
-    /**
125
-     * Renders class documentation stats
126
-     */
127
-    public static function render_missing_documentation($Classes) { ?>
128
-<table>
129
-  <tr class="colhead">
130
-    <td>
131
-      Class
132
-    </td>
133
-    <td>
134
-      Class documented
135
-    </td>
136
-    <td>
137
-      Undocumented functions
138
-    </td>
139
-    <td>
140
-      Documented functions
141
-    </td>
142
-  </tr>
143
-  <?php foreach ($Classes as $Key => $Value) {
144
-        $ClassComment = Testing::get_class_comment($Key); ?>
145
-  <tr>
146
-    <td>
147
-      <?=$Key?>
148
-    </td>
149
-    <td>
150
-      <?=!empty($ClassComment) ? "Yes" : "No"?>
151
-    <td>
152
-      <?=count(Testing::get_undocumented_methods($Key))?>
153
-    </td>
154
-    <td>
155
-      <?=count(Testing::get_documented_methods($Key))?>
156
-    </td>
157
-  </tr>
158
-  <?php
159
-    } ?>
160
-</table>
161
-<?php }
162
-
163
-    /**
164
-     * Pretty print any data
165
-     */
166
-    public static function render_results($Data)
167
-    {
168
-        $Results = '<pre><ul style="list-style-type: none">';
169
-        if (is_array($Data)) {
170
-            foreach ($Data as $Key => $Value) {
171
-                if (is_array($Value)) {
172
-                    $Results .= '<li>' . $Key . ' => ' . self::render_results($Value) . '</li>';
173
-                } else {
174
-                    $Results .= '<li>' . $Key . ' => ' . $Value . '</li>';
175
-                }
176
-            }
177
-        } else {
178
-            $Results .= '<li>' . $Data . '</li>';
179
-        }
180
-        $Results .= '</ul></pre>';
181
-        echo $Results;
182
-    }
183
-}

+ 0
- 31
gazelle.sql View File

@@ -793,20 +793,6 @@ CREATE TABLE `shop_freeleeches` (
793 793
   KEY `ExpiryTime` (`ExpiryTime`)
794 794
 ) ENGINE=InnoDB CHARSET=utf8mb4;
795 795
 
796
-CREATE TABLE `site_history` (
797
-  `ID` int NOT NULL AUTO_INCREMENT,
798
-  `Title` varchar(255) DEFAULT NULL,
799
-  `Url` varchar(255) NOT NULL DEFAULT '',
800
-  `Category` tinyint DEFAULT NULL,
801
-  `SubCategory` tinyint DEFAULT NULL,
802
-  `Tags` mediumtext,
803
-  `AddedBy` int DEFAULT NULL,
804
-  `Date` datetime DEFAULT NULL,
805
-  `Body` mediumtext,
806
-  PRIMARY KEY (`ID`)
807
-) ENGINE=InnoDB CHARSET=utf8mb4;
808
-
809 796
 -- 2020-03-09
810 797
 CREATE TABLE `slaves` (
811 798
   `UserID` int NOT NULL DEFAULT '0',
@@ -961,26 +947,6 @@ CREATE TABLE `sphinx_tg` (
961 947
   PRIMARY KEY (`id`)
962 948
 ) ENGINE=InnoDB CHARSET=utf8mb4;
963 949
 
964
-CREATE TABLE `staff_blog` (
965
-  `ID` int unsigned NOT NULL AUTO_INCREMENT,
966
-  `UserID` int unsigned NOT NULL,
967
-  `Title` varchar(255) NOT NULL,
968
-  `Body` text,
969
-  `Time` datetime,
970
-  PRIMARY KEY (`ID`),
971
-  KEY `UserID` (`UserID`),
972
-  KEY `Time` (`Time`)
973
-) ENGINE=InnoDB CHARSET=utf8mb4;
974
-
975
-CREATE TABLE `staff_blog_visits` (
976
-  `UserID` int unsigned NOT NULL,
977
-  `Time` datetime,
978
-  UNIQUE KEY `UserID` (`UserID`),
979
-  CONSTRAINT `staff_blog_visits_ibfk_1` FOREIGN KEY (`UserID`) REFERENCES `users_main` (`ID`) ON DELETE CASCADE
980
-) ENGINE=InnoDB CHARSET=utf8mb4;
981
-
982 950
 -- 2020-03-09
983 951
 CREATE TABLE `staff_pm_conversations` (
984 952
   `ID` int NOT NULL AUTO_INCREMENT,

+ 0
- 300
sections/api/index.php View File

@@ -1,300 +0,0 @@
1
-<?php
2
-declare(strict_types = 1);
3
-
4
-/**
5
- * AJAX Switch Center
6
- *
7
- * This page acts as an AJAX "switch" - it's called by scripts, and it includes the required pages.
8
- * The required page is determined by $_GET['action'].
9
- */
10
-
11
-# $_POST login cookie
12
-if (!isset($FullToken)) {
13
-    enforce_login();
14
-}
15
-
16
-
17
-/**
18
- * These users aren't rate limited.
19
- * This array should contain user IDs.
20
- */
21
-
22
-# Get people with Donor permissions
23
-$Donors = $DB->query("
24
-SELECT
25
-  `ID`
26
-FROM
27
-  `users_main`
28
-WHERE
29
-  `PermissionID` = 20
30
-");
31
-
32
-# Add Donors to $UserExceptions or define manually
33
-if ($DB->record_count()) {
34
-    $UserExceptions = array_unique($DB->collect('ID'));
35
-} else {
36
-    $UserExceptions = array(
37
-      # 1, 2, 3, etc.
38
-    );
39
-}
40
-
41
-# System and admin fix
42
-array_push($UserExceptions, 0, 1);
43
-
44
-
45
-/**
46
- * AJAX_LIMIT = array($x, $y) = $x requests every $y seconds,
47
- * e.g., array(5, 10) = 5 requests every 10 seconds.
48
- */
49
-$AJAX_LIMIT = array(1, 6);
50
-$UserID = $LoggedUser['ID'];
51
-
52
-# Set proper headers for JSON output
53
-# https://github.com/OPSnet/Gazelle/blob/master/sections/ajax/index.php
54
-if (!empty($_SERVER['CONTENT_TYPE']) && substr($_SERVER['CONTENT_TYPE'], 0, 16) === 'application/json') {
55
-    $_POST = json_decode(file_get_contents('php://input'), true);
56
-}
57
-header('Content-Type: application/json; charset=utf-8');
58
-
59
-#  Enforce rate limiting everywhere
60
-if (!in_array($UserID, $UserExceptions) && isset($_GET['action'])) {
61
-    if (!$UserRequests = $Cache->get_value("ajax_requests_$UserID")) {
62
-        $UserRequests = 0;
63
-        $Cache->cache_value("ajax_requests_$UserID", '0', $AJAX_LIMIT[1]);
64
-    }
65
-
66
-    if ($UserRequests > $AJAX_LIMIT[0]) {
67
-        json_die('failure', 'rate limit exceeded');
68
-    } else {
69
-        $Cache->increment_value("ajax_requests_$UserID");
70
-    }
71
-}
72
-
73
-
74
-/**
75
- * Actions
76
- */
77
-
78
-switch ($_GET['action']) {
79
-
80
-  /**
81
-   * Torrents
82
-   */
83
-
84
-  case 'torrent':
85
-    require 'torrents/torrent.php';
86
-    break;
87
-
88
-  case 'group':
89
-    require 'torrents/group.php';
90
-    break;
91
-
92
-  // So the album art script can function without breaking the rate limit
93
-  case 'torrentgroupalbumart':
94
-    require SERVER_ROOT.'/sections/ajax/torrentgroupalbumart.php';
95
-    break;
96
-
97
-  case 'browse':
98
-    require SERVER_ROOT.'/sections/ajax/browse.php';
99
-    break;
100
-  
101
-   case 'tcomments':
102
-    require SERVER_ROOT.'/sections/ajax/tcomments.php';
103
-    break;
104
-
105
-
106
-  /**
107
-   * Features
108
-   */
109
-
110
-  case 'collage':
111
-    require SERVER_ROOT.'/sections/ajax/collage.php';
112
-    break;
113
-  
114
-  case 'artist':
115
-    require SERVER_ROOT.'/sections/ajax/artist.php';
116
-    break;
117
-
118
-  case 'request':
119
-    require SERVER_ROOT.'/sections/ajax/request.php';
120
-    break;
121
-
122
-  case 'requests':
123
-    require SERVER_ROOT.'/sections/ajax/requests.php';
124
-    break;
125
-
126
-  case 'top10':
127
-    require SERVER_ROOT.'/sections/ajax/top10/index.php';
128
-    break;
129
-
130
-
131
-  /**
132
-   * Users
133
-   */
134
-
135
-  case 'user':
136
-    require SERVER_ROOT.'/sections/ajax/user.php';
137
-    break;
138
-
139
-  case 'usersearch':
140
-    require SERVER_ROOT.'/sections/ajax/usersearch.php';
141
-    break;
142
-  
143
-  case 'community_stats':
144
-    require SERVER_ROOT.'/sections/ajax/community_stats.php';
145
-    break;
146
-
147
-  case 'user_recents':
148
-    require SERVER_ROOT.'/sections/ajax/user_recents.php';
149
-    break;
150
-
151
-  case 'userhistory':
152
-    require SERVER_ROOT.'/sections/ajax/userhistory/index.php';
153
-    break;
154
-
155
-
156
-  /**
157
-   * Account
158
-   */
159
-
160
-  case 'inbox':
161
-    require SERVER_ROOT.'/sections/ajax/inbox/index.php';
162
-    break;
163
-
164
-  case 'bookmarks':
165
-    require SERVER_ROOT.'/sections/ajax/bookmarks/index.php';
166
-    break;
167
-
168
-  case 'notifications':
169
-    require SERVER_ROOT.'/sections/ajax/notifications.php';
170
-    break;
171
-
172
-  case 'get_user_notifications':
173
-    require SERVER_ROOT.'/sections/ajax/get_user_notifications.php';
174
-    break;
175
-
176
-  case 'clear_user_notification':
177
-    require SERVER_ROOT.'/sections/ajax/clear_user_notification.php';
178
-    break;
179
-
180
-
181
-  /**
182
-   * Forums
183
-   */
184
-
185
-  case 'forum':
186
-    require SERVER_ROOT.'/sections/ajax/forum/index.php';
187
-    break;
188
-
189
-
190
-  case 'subscriptions':
191
-    require SERVER_ROOT.'/sections/ajax/subscriptions.php';
192
-    break;
193
-
194
-  case 'raw_bbcode':
195
-    require SERVER_ROOT.'/sections/ajax/raw_bbcode.php';
196
-    break;
197
-
198
-
199
-  /**
200
-   * Meta
201
-   */
202
-
203
-  case 'index':
204
-    require SERVER_ROOT.'/sections/ajax/info.php';
205
-    break;
206
-
207
-  case 'manifest':
208
-    require SERVER_ROOT.'/manifest.php';
209
-    json_die('success', manifest());
210
-    break;
211
-
212
-  case 'stats':
213
-    require SERVER_ROOT.'/sections/ajax/stats.php';
214
-    break;
215
-
216
-  case 'loadavg':
217
-    require SERVER_ROOT.'/sections/ajax/loadavg.php';
218
-    break;
219
-
220
-  case 'announcements':
221
-    require SERVER_ROOT.'/sections/ajax/announcements.php';
222
-    break;
223
-
224
-  case 'wiki':
225
-    require SERVER_ROOT.'/sections/ajax/wiki.php';
226
-    break;
227
-  
228
-  case 'ontology':
229
-    require SERVER_ROOT.'/sections/ajax/ontology.php';
230
-    break;
231
-  
232
-
233
-  /**
234
-   * Under construction
235
-   */
236
-
237
-  case 'preview':
238
-    require 'preview.php';
239
-    break;
240
-
241
-  case 'better':
242
-    require SERVER_ROOT.'/sections/ajax/better/index.php';
243
-    break;
244
-
245
-  case 'get_friends':
246
-    require SERVER_ROOT.'/sections/ajax/get_friends.php';
247
-    break;
248
-
249
-  case 'news_ajax':
250
-    require SERVER_ROOT.'/sections/ajax/news_ajax.php';
251
-    break;
252
-
253
-  case 'send_recommendation':
254
-    require SERVER_ROOT.'/sections/ajax/send_recommendation.php';
255
-    break;
256
-
257
-  /*
258
-  case 'similar_artists':
259
-    require SERVER_ROOT.'/sections/ajax/similar_artists.php';
260
-    break;
261
-  */
262
-
263
-  /*
264
-  case 'votefavorite':
265
-    require SERVER_ROOT.'/sections/ajax/takevote.php';
266
-    break;
267
-  */
268
-
269
-  /*
270
-  case 'torrent_info':
271
-    require 'torrent_info.php';
272
-    break;
273
-  */
274
-
275
-  /*
276
-  case 'checkprivate':
277
-    include 'checkprivate.php';
278
-    break;
279
-  */
280
-
281
-  case 'autofill':
282
-    /*
283
-    if ($_GET['cat'] === 'anime') {
284
-        require SERVER_ROOT.'/sections/ajax/autofill/anime.php';
285
-    }
286
-
287
-    if ($_GET['cat'] === 'jav') {
288
-        require SERVER_ROOT.'/sections/ajax/autofill/jav.php';
289
-    }
290
-
291
-    if ($_GET['cat'] === 'manga') {
292
-        require SERVER_ROOT.'/sections/ajax/autofill/manga.php';
293
-    }
294
-    */
295
-    break;
296
-
297
-  default:
298
-    // If they're screwing around with the query string
299
-    json_die('failure');
300
-}

+ 0
- 101
sections/api/torrents/group.php View File

@@ -1,101 +0,0 @@
1
-<?php
2
-#declare(strict_types=1);
3
-
4
-require SERVER_ROOT.'/sections/torrents/functions.php';
5
-
6
-$GroupID = (int) $_GET['id'];
7
-$TorrentHash = (string) $_GET['hash'];
8
-
9
-if ($GroupID && $TorrentHash) {
10
-    json_die('failure', 'bad parameters');
11
-}
12
-
13
-if ($TorrentHash) {
14
-    if (!is_valid_torrenthash($TorrentHash)) {
15
-        json_die('failure', 'bad hash parameter');
16
-    } else {
17
-        $GroupID = (int) torrenthash_to_groupid($TorrentHash);
18
-        if (!$GroupID) {
19
-            json_die('failure', 'bad hash parameter');
20
-        }
21
-    }
22
-}
23
-
24
-if ($GroupID <= 0) {
25
-    json_die('failure', 'bad id parameter');
26
-}
27
-
28
-$TorrentCache = get_group_info($GroupID, true, 0, true, true);
29
-if (!$TorrentCache) {
30
-    json_die('failure', 'bad id parameter');
31
-}
32
-
33
-list($TorrentDetails, $TorrentList) = $TorrentCache;
34
-$Artists = Artists::get_artist($GroupID);
35
-
36
-if ($TorrentDetails['CategoryID'] === 0) {
37
-    $CategoryName = 'Unknown';
38
-} else {
39
-    $CategoryName = $Categories[$TorrentDetails['CategoryID'] - 1];
40
-}
41
-
42
-$TagList = explode('|', $TorrentDetails['GROUP_CONCAT(DISTINCT tags.Name SEPARATOR \'|\')']);
43
-
44
-$JsonTorrentDetails = [
45
-  'description'  => Text::full_format($TorrentDetails['WikiBody']),
46
-  'picture'      => $TorrentDetails['WikiImage'],
47
-  'id'           => (int) $TorrentDetails['ID'],
48
-  'name'         => $TorrentDetails['Name'],
49
-  'organism'     => $TorrentDetails['Title2'],
50
-  'strain'       => $TorrentDetails['NameJP'],
51
-  'authors'      => $Artists,
52
-  'year'         => (int) $TorrentDetails['Year'],
53
-  'accession'    => $TorrentDetails['CatalogueNumber'],
54
-  'categoryId'   => (int) $TorrentDetails['CategoryID'],
55
-  'categoryName' => $CategoryName,
56
-  'time'         => $TorrentDetails['Time'],
57
-  'isBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID),
58
-  'tags'         => $TagList
59
-];
60
-
61
-$JsonTorrentList = [];
62
-foreach ($TorrentList as $Torrent) {
63
-    // Convert file list back to the old format
64
-    $FileList = explode("\n", $Torrent['FileList']);
65
-    foreach ($FileList as &$File) {
66
-        $File = Torrents::filelist_old_format($File);
67
-    }
68
-
69
-    unset($File);
70
-    $FileList = implode('|||', $FileList);
71
-    $Userinfo = Users::user_info($Torrent['UserID']);
72
-
73
-    $Reports = Torrents::get_reports($Torrent['ID']);
74
-    $Torrent['Reported'] = count($Reports) > 0;
75
-
76
-    $JsonTorrentList[] = [
77
-      'id'          => (int) $Torrent['ID'],
78
-      'infoHash'    => $Torrent['InfoHash'],
79
-      'platform'    => $Torrent['Media'],
80
-      'format'      => $Torrent['Container'],
81
-      'license'     => $Torrent['Codec'],
82
-      'scope'       => $Torrent['Resolution'],
83
-      'annotated'   => (bool) $Torrent['Censored'],
84
-      'archive'     => $Torrent['Archive'],
85
-      'fileCount'   => (int) $Torrent['FileCount'],
86
-      'size'        => (int) $Torrent['Size'],
87
-      'seeders'     => (int) $Torrent['Seeders'],
88
-      'leechers'    => (int) $Torrent['Leechers'],
89
-      'snatched'    => (int) $Torrent['Snatched'],
90
-      'freeTorrent' => ($Torrent['FreeTorrent'] == 1),
91
-      'reported'    => (bool) $Torrent['Reported'],
92
-      'time'        => $Torrent['Time'],
93
-      'description' => $Torrent['Description'],
94
-      'fileList'    => $FileList,
95
-      'filePath'    => $Torrent['FilePath'],
96
-      'userId'      => (int) ($Torrent['Anonymous'] ? 0 : $Torrent['UserID']),
97
-      'username'    => ($Torrent['Anonymous'] ? 'Anonymous' : $Userinfo['Username'])
98
-    ];
99
-}
100
-
101
-json_die('success', ['group' => $JsonTorrentDetails, 'torrents' => $JsonTorrentList]);

+ 0
- 105
sections/api/torrents/torrent.php View File

@@ -1,105 +0,0 @@
1
-<?php
2
-#declare(strict_types=1);
3
-
4
-require SERVER_ROOT.'/sections/torrents/functions.php';
5
-
6
-$TorrentID = (int) $_GET['id'];
7
-$TorrentHash = (string) $_GET['hash'];
8
-
9
-if ($TorrentID && $TorrentHash) {
10
-    json_die('failure', 'bad parameters');
11
-}
12
-
13
-if ($TorrentHash) {
14
-    if (!is_valid_torrenthash($TorrentHash)) {
15
-        json_die('failure', 'bad hash parameter');
16
-    } else {
17
-        $TorrentID = (int) torrenthash_to_torrentid($TorrentHash);
18
-        if (!$TorrentID) {
19
-            json_die('failure', 'bad hash parameter');
20
-        }
21
-    }
22
-}
23
-
24
-if ($TorrentID <= 0) {
25
-    json_die('failure', 'bad id parameter');
26
-}
27
-
28
-$TorrentCache = get_torrent_info($TorrentID, true, 0, true, true);
29
-if (!$TorrentCache) {
30
-    json_die('failure', 'bad id parameter');
31
-}
32
-
33
-list($TorrentDetails, $TorrentList) = $TorrentCache;
34
-if (!isset($TorrentList[$TorrentID])) {
35
-    json_die('failure', 'bad id parameter');
36
-}
37
-
38
-$GroupID = $TorrentDetails['ID'];
39
-$Artists = Artists::get_artist($GroupID);
40
-
41
-if ($TorrentDetails['CategoryID'] === 0) {
42
-    $CategoryName = 'Unknown';
43
-} else {
44
-    $CategoryName = $Categories[$TorrentDetails['CategoryID'] - 1];
45
-}
46
-
47
-$TagList = explode('|', $TorrentDetails['GROUP_CONCAT(DISTINCT tags.Name SEPARATOR \'|\')']);
48
-
49
-$JsonTorrentDetails = [
50
-  'description'  => Text::full_format($TorrentDetails['WikiBody']),
51
-  'picture'      => $TorrentDetails['WikiImage'],
52
-  'id'           => (int) $TorrentDetails['ID'],
53
-  'name'         => $TorrentDetails['Name'],
54
-  'organism'     => $TorrentDetails['Title2'],
55
-  'strain'       => $TorrentDetails['NameJP'],
56
-  'authors'      => $Artists,
57
-  'year'         => (int) $TorrentDetails['Year'],
58
-  'accession'    => $TorrentDetails['CatalogueNumber'],
59
-  'categoryId'   => (int) $TorrentDetails['CategoryID'],
60
-  'categoryName' => $CategoryName,
61
-  'time'         => $TorrentDetails['Time'],
62
-  'isBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID),
63
-  'tags'         => $TagList
64
-];
65
-
66
-$Torrent = $TorrentList[$TorrentID];
67
-
68
-$Reports = Torrents::get_reports($TorrentID);
69
-$Torrent['Reported'] = (count($Reports) > 0);
70
-
71
-// Convert file list back to the old format
72
-$FileList = explode("\n", $Torrent['FileList']);
73
-foreach ($FileList as &$File) {
74
-    $File = Torrents::filelist_old_format($File);
75
-}
76
-
77
-unset($File);
78
-$FileList = implode('|||', $FileList);
79
-$Userinfo = Users::user_info($Torrent['UserID']);
80
-
81
-$JsonTorrentList[] = [
82
-  'id'          => (int) $Torrent['ID'],
83
-  'infoHash'    => $Torrent['InfoHash'],
84
-  'platform'    => $Torrent['Media'],
85
-  'format'      => $Torrent['Container'],
86
-  'license'     => $Torrent['Codec'],
87
-  'scope'       => $Torrent['Resolution'],
88
-  'annotated'   => (bool) $Torrent['Censored'],
89
-  'archive'     => $Torrent['Archive'],
90
-  'fileCount'   => (int) $Torrent['FileCount'],
91
-  'size'        => (int) $Torrent['Size'],
92
-  'seeders'     => (int) $Torrent['Seeders'],
93
-  'leechers'    => (int) $Torrent['Leechers'],
94
-  'snatched'    => (int) $Torrent['Snatched'],
95
-  'freeTorrent' => ($Torrent['FreeTorrent'] == 1),
96
-  'reported'    => (bool) $Torrent['Reported'],
97
-  'time'        => $Torrent['Time'],
98
-  'description' => $Torrent['Description'],
99
-  'fileList'    => $FileList,
100
-  'filePath'    => $Torrent['FilePath'],
101
-  'userId'      => (int) ($Torrent['Anonymous'] ? 0 : $Torrent['UserID']),
102
-  'username'    => ($Torrent['Anonymous'] ? 'Anonymous' : $Userinfo['Username'])
103
-];
104
-
105
-json_die('success', ['group' => $JsonTorrentDetails, 'torrent' => array_pop($JsonTorrentList)]);

+ 0
- 156
sections/staffblog/index.php View File

@@ -1,156 +0,0 @@
1
-<?
2
-enforce_login();
3
-
4
-if (!check_perms('users_mod')) {
5
-  error(403);
6
-}
7
-
8
-$DB->query("
9
-  INSERT INTO staff_blog_visits
10
-    (UserID, Time)
11
-  VALUES
12
-    (".$LoggedUser['ID'].", NOW())
13
-  ON DUPLICATE KEY UPDATE
14
-    Time = NOW()");
15
-$Cache->delete_value('staff_blog_read_'.$LoggedUser['ID']);
16
-
17
-// WHY
18
-//define('ANNOUNCEMENT_FORUM_ID', 19);
19
-
20
-if (check_perms('admin_manage_blog')) {
21
-  if (!empty($_REQUEST['action'])) {
22
-    switch ($_REQUEST['action']) {
23
-      case 'takeeditblog':
24
-        authorize();
25
-        if (empty($_POST['title'])) {
26
-          error("Please enter a title.");
27
-        }
28
-        if (is_number($_POST['blogid'])) {
29
-          $DB->query("
30
-            UPDATE staff_blog
31
-            SET Title = '".db_string($_POST['title'])."', Body = '".db_string($_POST['body'])."'
32
-            WHERE ID = '".db_string($_POST['blogid'])."'");
33
-          $Cache->delete_value('staff_blog');
34
-          $Cache->delete_value('staff_feed_blog');
35
-        }
36
-        header('Location: staffblog.php');
37
-        break;
38
-      case 'editblog':
39
-        if (is_number($_GET['id'])) {
40
-          $BlogID = $_GET['id'];
41
-          $DB->query("
42
-            SELECT Title, Body
43
-            FROM staff_blog
44
-            WHERE ID = $BlogID");
45
-          list($Title, $Body, $ThreadID) = $DB->next_record();
46
-        }
47
-        break;
48
-      case 'deleteblog':
49
-        if (is_number($_GET['id'])) {
50
-          authorize();
51
-          $DB->query("
52
-            DELETE FROM staff_blog
53
-            WHERE ID = '".db_string($_GET['id'])."'");
54
-          $Cache->delete_value('staff_blog');
55
-          $Cache->delete_value('staff_feed_blog');
56
-        }
57
-        header('Location: staffblog.php');
58
-        break;
59
-
60
-      case 'takenewblog':
61
-        authorize();
62
-        if (empty($_POST['title'])) {
63
-          error("Please enter a title.");
64
-        }
65
-        $Title = db_string($_POST['title']);
66
-        $Body = db_string($_POST['body']);
67
-
68
-        $DB->query("
69
-          INSERT INTO staff_blog
70
-            (UserID, Title, Body, Time)
71
-          VALUES
72
-            ('$LoggedUser[ID]', '".db_string($_POST['title'])."', '".db_string($_POST['body'])."', NOW())");
73
-        $Cache->delete_value('staff_blog');
74
-        $Cache->delete_value('staff_blog_latest_time');
75
-
76
-        send_irc(STAFF_CHAN, "New staff blog: ".$_POST['title']." - https://".SITE_DOMAIN."/staffblog.php#blog".$DB->inserted_id());
77
-
78
-        header('Location: staffblog.php');
79
-        break;
80
-    }
81
-  }
82
-  View::show_header('Staff Blog','bbcode');
83
-  ?>
84
-    <div class="box">
85
-      <div class="head">
86
-        <?=((empty($_GET['action'])) ? 'Create a staff blog post' : 'Edit staff blog post')?>
87
-        <span class="float_right">
88
-          <a data-toggle-target="#postform" data-toggle-replace="<?=(($_REQUEST['action'] != 'editblog') ? 'Hide' : 'Show')?>" class="brackets"><?=(($_REQUEST['action'] != 'editblog') ? 'Show' : 'Hide')?></a>
89
-        </span>
90
-      </div>
91
-      <form class="<?=((empty($_GET['action'])) ? 'create_form' : 'edit_form')?>" name="blog_post" action="staffblog.php" method="post">
92
-        <div id="postform" class="pad<?=($_REQUEST['action'] != 'editblog') ? ' hidden' : '' ?>">
93
-          <input type="hidden" name="action" value="<?=((empty($_GET['action'])) ? 'takenewblog' : 'takeeditblog')?>" />
94
-          <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
95
-<?php if (!empty($_GET['action']) && $_GET['action'] == 'editblog') { ?>
96
-          <input type="hidden" name="blogid" value="<?=$BlogID; ?>" />
97
-<?php } ?>
98
-          <div>
99
-            <h3>Title</h3>
100
-            <input type="text" name="title" size="95"<? if (!empty($Title)) { echo ' value="'.display_str($Title).'"'; } ?> />
101
-          </div>
102
-          <div>
103
-            <h3>Body</h3>
104
-            <textarea name="body" cols="95" rows="15"><? if (!empty($Body)) { echo display_str($Body); } ?></textarea> <br />
105
-          </div>
106
-          <div class="submit_div center">
107
-            <input type="submit" value="<?=((!isset($_GET['action'])) ? 'Create blog post' : 'Edit blog post') ?>" />
108
-          </div>
109
-        </div>
110
-      </form>
111
-    </div>
112
-<?
113
-} else {
114
-  View::show_header('Staff Blog','bbcode');
115
-}
116
-?>
117
-<div>
118
-<?
119
-if (($Blog = $Cache->get_value('staff_blog')) === false) {
120
-  $DB->query("
121
-    SELECT
122
-      b.ID,
123
-      um.Username,
124
-      b.Title,
125
-      b.Body,
126
-      b.Time
127
-    FROM staff_blog AS b
128
-      LEFT JOIN users_main AS um ON b.UserID = um.ID
129
-    ORDER BY Time DESC");
130
-  $Blog = $DB->to_array(false, MYSQLI_NUM);
131
-  $Cache->cache_value('staff_blog', $Blog, 1209600);
132
-}
133
-
134
-foreach ($Blog as $BlogItem) {
135
-  list($BlogID, $Author, $Title, $Body, $BlogTime) = $BlogItem;
136
-  $BlogTime = strtotime($BlogTime);
137
-?>
138
-      <div id="blog<?=$BlogID?>" class="box blog_post">
139
-        <div class="head">
140
-          <strong><?=$Title?></strong> - posted <?=time_diff($BlogTime);?> by <?=$Author?>
141
-<?php if (check_perms('admin_manage_blog')) { ?>
142
-          - <a href="staffblog.php?action=editblog&amp;id=<?=$BlogID?>" class="brackets">Edit</a>
143
-          <a href="staffblog.php?action=deleteblog&amp;id=<?=$BlogID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" onclick="return confirm('Do you want to delete this?');" class="brackets">Delete</a>
144
-<?php } ?>
145
-        </div>
146
-        <div class="pad">
147
-          <?=Text::full_format($Body)?>
148
-        </div>
149
-      </div>
150
-<?
151
-}
152
-?>
153
-</div>
154
-<?
155
-View::show_footer();
156
-?>

+ 0
- 43
sections/store/become_admin.php View File

@@ -1,43 +0,0 @@
1
-<?php
2
-#declare(strict_types=1);
3
-
4
-$Purchase = "Admin status";
5
-$UserID = $LoggedUser['ID'];
6
-
7
-$DB->query("
8
-  SELECT BonusPoints
9
-  FROM users_main
10
-  WHERE ID = $UserID");
11
-  
12
-if ($DB->has_results()) {
13
-    list($Points) = $DB->next_record();
14
-
15
-    if ($Points >= 4294967296) {
16
-        $DB->query("
17
-          UPDATE users_main
18
-          SET BonusPoints  = BonusPoints - 4294967296,
19
-            PermissionID = 15
20
-          WHERE ID = $UserID");
21
-        $Worked = true;
22
-    } else {
23
-        $Worked = false;
24
-        $ErrMessage = "Not enough points";
25
-    }
26
-}
27
-
28
-View::show_header('Store'); ?>
29
-<div>
30
-  <h2>Purchase
31
-    <?= $Worked?"Successful":"Failed"?>
32
-  </h2>
33
-  <div class="box">
34
-    <p>
35
-      <?= $Worked?("You purchased ".$Purchase):("Error: ".$ErrMessage)?>
36
-    </p>
37
-    <p>
38
-      <a href="/store.php">Back to Store</a>
39
-    </p>
40
-  </div>
41
-</div>
42
-<?php
43
-View::show_footer();

+ 0
- 18
sections/testing/ajax_run_method.php View File

@@ -1,18 +0,0 @@
1
-<?
2
-authorize();
3
-if (!check_perms('users_mod')) {
4
-  error(404);
5
-}
6
-
7
-$Class = $_POST['class'];
8
-$Method = $_POST['method'];
9
-$Params = json_decode($_POST['params'], true);
10
-
11
-if (!empty($Class) && !empty($Method) && Testing::has_testable_method($Class, $Method)) {
12
-  if (count($Params)) {
13
-    $Results = call_user_func_array(array($Class, $Method), array_values($Params));
14
-  } else {
15
-    $Results = call_user_func(array($Class, $Method));
16
-  }
17
-  TestingView::render_results($Results);
18
-}

+ 0
- 26
sections/testing/class.php View File

@@ -1,26 +0,0 @@
1
-<?
2
-if (!check_perms('users_mod')) {
3
-  error(404);
4
-}
5
-
6
-$Class = $_GET['name'];
7
-if (!empty($Class) && !Testing::has_class($Class)) {
8
-  error("Missing class");
9
-}
10
-
11
-View::show_header("Tests", "testing");
12
-
13
-?>
14
-<div class="header">
15
-  <h2><?=$Class?></h2>
16
-  <?=TestingView::render_linkbox("class"); ?>
17
-</div>
18
-
19
-<div>
20
-  <?=TestingView::render_functions(Testing::get_testable_methods($Class));?>
21
-</div>
22
-
23
-<?
24
-View::show_footer();
25
-
26
-

+ 0
- 21
sections/testing/classes.php View File

@@ -1,21 +0,0 @@
1
-<?
2
-if (!check_perms('users_mod')) {
3
-  error(404);
4
-}
5
-
6
-View::show_header("Tests");
7
-
8
-?>
9
-<div class="header">
10
-  <h2>Tests</h2>
11
-  <? TestingView::render_linkbox("classes"); ?>
12
-</div>
13
-
14
-<div>
15
-  <? TestingView::render_classes(Testing::get_classes());?>
16
-</div>
17
-
18
-<?
19
-View::show_footer();
20
-
21
-

+ 0
- 23
sections/testing/comments.php View File

@@ -1,23 +0,0 @@
1
-<?php
2
-#declare(strict_types=1);
3
-
4
-if (!check_perms('users_mod')) {
5
-  error(404);
6
-}
7
-
8
-View::show_header("Tests");
9
-
10
-?>
11
-
12
-<div class="header">
13
-  <h2>Documentation</h2>
14
-  <? TestingView::render_linkbox("comments"); ?>
15
-</div>
16
-
17
-<div>
18
-  <? TestingView::render_missing_documentation(Testing::get_classes());?>
19
-</div>
20
-
21
-<?
22
-View::show_footer();
23
-

+ 0
- 26
sections/testing/index.php View File

@@ -1,26 +0,0 @@
1
-<?
2
-enforce_login();
3
-if (!check_perms('users_mod')) {
4
-  error(404);
5
-} else {
6
-  Testing::init();
7
-
8
-  if (!empty($_REQUEST['action'])) {
9
-    switch ($_REQUEST['action']) {
10
-      case 'class':
11
-        include(SERVER_ROOT.'/sections/testing/class.php');
12
-        break;
13
-      case 'ajax_run_method':
14
-        include(SERVER_ROOT.'/sections/testing/ajax_run_method.php');
15
-        break;
16
-      case 'comments':
17
-        include(SERVER_ROOT.'/sections/testing/comments.php');
18
-        break;
19
-      default:
20
-        include(SERVER_ROOT.'/sections/testing/classes.php');
21
-        break;
22
-    }
23
-  } else {
24
-    include(SERVER_ROOT.'/sections/testing/classes.php');
25
-  }
26
-}

+ 0
- 5
staffblog.php View File

@@ -1,5 +0,0 @@
1
-<?php
2
-declare(strict_types=1);
3
-
4
-define('ERROR_EXCEPTION', true);
5
-require_once 'classes/script_start.php';

+ 0
- 4
testing.php View File

@@ -1,4 +0,0 @@
1
-<?php
2
-declare(strict_types=1);
3
-
4
-require_once 'classes/script_start.php';

Loading…
Cancel
Save