Browse Source

Upload files to 'classes'

Stortebeker 6 years ago
parent
commit
ca9f3fa700
5 changed files with 405 additions and 385 deletions
  1. 287
    278
      classes/comments.class.php
  2. 54
    50
      classes/commentsview.class.php
  3. 0
    0
      classes/config.template
  4. 29
    24
      classes/cookie.class.php
  5. 35
    33
      classes/crypto.class.php

+ 287
- 278
classes/comments.class.php View File

@@ -1,21 +1,23 @@
1
-<?
2
-class Comments {
3
-  /*
4
-   * For all functions:
5
-   * $Page = 'artist', 'collages', 'requests' or 'torrents'
6
-   * $PageID = ArtistID, CollageID, RequestID or GroupID, respectively
7
-   */
8
-
9
-  /**
10
-   * Post a comment on an artist, request or torrent page.
11
-   * @param string $Page
12
-   * @param int $PageID
13
-   * @param string $Body
14
-   * @return int ID of the new comment
15
-   */
16
-  public static function post($Page, $PageID, $Body) {
17
-    $QueryID = G::$DB->get_query_id();
18
-    G::$DB->query("
1
+<?php
2
+class Comments
3
+{
4
+    /*
5
+     * For all functions:
6
+     * $Page = 'artist', 'collages', 'requests' or 'torrents'
7
+     * $PageID = ArtistID, CollageID, RequestID or GroupID, respectively
8
+     */
9
+
10
+    /**
11
+     * Post a comment on an artist, request or torrent page.
12
+     * @param string $Page
13
+     * @param int $PageID
14
+     * @param string $Body
15
+     * @return int ID of the new comment
16
+     */
17
+    public static function post($Page, $PageID, $Body)
18
+    {
19
+        $QueryID = G::$DB->get_query_id();
20
+        G::$DB->query("
19 21
       SELECT
20 22
         CEIL(
21 23
           (
@@ -25,36 +27,37 @@ class Comments {
25 27
               AND PageID = $PageID
26 28
           ) / " . TORRENT_COMMENTS_PER_PAGE . "
27 29
         ) AS Pages");
28
-    list($Pages) = G::$DB->next_record();
30
+        list($Pages) = G::$DB->next_record();
29 31
 
30
-    G::$DB->query("
32
+        G::$DB->query("
31 33
       INSERT INTO comments (Page, PageID, AuthorID, AddedTime, Body)
32 34
       VALUES ('$Page', $PageID, " . G::$LoggedUser['ID'] . ", NOW(), '" . db_string($Body) . "')");
33
-    $PostID = G::$DB->inserted_id();
35
+        $PostID = G::$DB->inserted_id();
34 36
 
35
-    $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
36
-    G::$Cache->delete_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID);
37
-    G::$Cache->delete_value($Page.'_comments_'.$PageID);
37
+        $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
38
+        G::$Cache->delete_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID);
39
+        G::$Cache->delete_value($Page.'_comments_'.$PageID);
38 40
 
39
-    Subscriptions::flush_subscriptions($Page, $PageID);
40
-    Subscriptions::quote_notify($Body, $PostID, $Page, $PageID);
41
+        Subscriptions::flush_subscriptions($Page, $PageID);
42
+        Subscriptions::quote_notify($Body, $PostID, $Page, $PageID);
41 43
 
42
-    G::$DB->set_query_id($QueryID);
44
+        G::$DB->set_query_id($QueryID);
43 45
 
44
-    return $PostID;
45
-  }
46
+        return $PostID;
47
+    }
46 48
 
47
-  /**
48
-   * Edit a comment
49
-   * @param int $PostID
50
-   * @param string $NewBody
51
-   * @param bool $SendPM If true, send a PM to the author of the comment informing him about the edit
52
-   * @todo move permission check out of here/remove hardcoded error(404)
53
-   */
54
-  public static function edit($PostID, $NewBody, $SendPM = false) {
55
-    $QueryID = G::$DB->get_query_id();
49
+    /**
50
+     * Edit a comment
51
+     * @param int $PostID
52
+     * @param string $NewBody
53
+     * @param bool $SendPM If true, send a PM to the author of the comment informing him about the edit
54
+     * @todo move permission check out of here/remove hardcoded error(404)
55
+     */
56
+    public static function edit($PostID, $NewBody, $SendPM = false)
57
+    {
58
+        $QueryID = G::$DB->get_query_id();
56 59
 
57
-    G::$DB->query("
60
+        G::$DB->query("
58 61
       SELECT
59 62
         Body,
60 63
         AuthorID,
@@ -63,25 +66,25 @@ class Comments {
63 66
         AddedTime
64 67
       FROM comments
65 68
       WHERE ID = $PostID");
66
-    if (!G::$DB->has_results()) {
67
-      return false;
68
-    }
69
-    list($OldBody, $AuthorID, $Page, $PageID, $AddedTime) = G::$DB->next_record();
69
+        if (!G::$DB->has_results()) {
70
+            return false;
71
+        }
72
+        list($OldBody, $AuthorID, $Page, $PageID, $AddedTime) = G::$DB->next_record();
70 73
 
71
-    if (G::$LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
72
-      return false;
73
-    }
74
+        if (G::$LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
75
+            return false;
76
+        }
74 77
 
75
-    G::$DB->query("
78
+        G::$DB->query("
76 79
       SELECT CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
77 80
       FROM comments
78 81
       WHERE Page = '$Page'
79 82
         AND PageID = $PageID
80 83
         AND ID <= $PostID");
81
-    list($CommPage) = G::$DB->next_record();
84
+        list($CommPage) = G::$DB->next_record();
82 85
 
83
-    // Perform the update
84
-    G::$DB->query("
86
+        // Perform the update
87
+        G::$DB->query("
85 88
       UPDATE comments
86 89
       SET
87 90
         Body = '" . db_string($NewBody) . "',
@@ -89,49 +92,50 @@ class Comments {
89 92
         EditedTime = NOW()
90 93
       WHERE ID = $PostID");
91 94
 
92
-    // Update the cache
93
-    $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
94
-    G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $CatalogueID);
95
+        // Update the cache
96
+        $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
97
+        G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $CatalogueID);
95 98
 
96
-    if ($Page == 'collages') {
97
-      // On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
98
-      G::$Cache->delete_value('collage_' . $PageID);
99
-    }
99
+        if ($Page == 'collages') {
100
+            // On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
101
+            G::$Cache->delete_value('collage_' . $PageID);
102
+        }
100 103
 
101
-    G::$DB->query("
104
+        G::$DB->query("
102 105
       INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
103 106
       VALUES ('$Page', $PostID, " . G::$LoggedUser['ID'] . ", NOW(), '" . db_string($OldBody) . "')");
104 107
 
105
-    G::$DB->set_query_id($QueryID);
108
+        G::$DB->set_query_id($QueryID);
106 109
 
107
-    if ($SendPM && G::$LoggedUser['ID'] != $AuthorID) {
108
-      // Send a PM to the user to notify them of the edit
109
-      $PMSubject = "Your comment #$PostID has been edited";
110
-      $PMurl = site_url()."comments.php?action=jump&postid=$PostID";
111
-      $ProfLink = '[url='.site_url().'user.php?id='.G::$LoggedUser['ID'].']'.G::$LoggedUser['Username'].'[/url]';
112
-      $PMBody = "One of your comments has been edited by $ProfLink: [url]{$PMurl}[/url]";
113
-      Misc::send_pm($AuthorID, 0, $PMSubject, $PMBody);
114
-    }
110
+        if ($SendPM && G::$LoggedUser['ID'] != $AuthorID) {
111
+            // Send a PM to the user to notify them of the edit
112
+            $PMSubject = "Your comment #$PostID has been edited";
113
+            $PMurl = site_url()."comments.php?action=jump&postid=$PostID";
114
+            $ProfLink = '[url='.site_url().'user.php?id='.G::$LoggedUser['ID'].']'.G::$LoggedUser['Username'].'[/url]';
115
+            $PMBody = "One of your comments has been edited by $ProfLink: [url]{$PMurl}[/url]";
116
+            Misc::send_pm($AuthorID, 0, $PMSubject, $PMBody);
117
+        }
115 118
 
116
-    return true; // TODO: this should reflect whether or not the update was actually successful, e.g. by checking G::$DB->affected_rows after the UPDATE query
117
-  }
118
-
119
-  /**
120
-   * Delete a comment
121
-   * @param int $PostID
122
-   */
123
-  public static function delete($PostID) {
124
-    $QueryID = G::$DB->get_query_id();
125
-    // Get page, pageid
126
-    G::$DB->query("SELECT Page, PageID FROM comments WHERE ID = $PostID");
127
-    if (!G::$DB->has_results()) {
128
-      // no such comment?
129
-      G::$DB->set_query_id($QueryID);
130
-      return false;
119
+        return true; // TODO: this should reflect whether or not the update was actually successful, e.g. by checking G::$DB->affected_rows after the UPDATE query
131 120
     }
132
-    list ($Page, $PageID) = G::$DB->next_record();
133
-    // get number of pages
134
-    G::$DB->query("
121
+
122
+    /**
123
+     * Delete a comment
124
+     * @param int $PostID
125
+     */
126
+    public static function delete($PostID)
127
+    {
128
+        $QueryID = G::$DB->get_query_id();
129
+        // Get page, pageid
130
+        G::$DB->query("SELECT Page, PageID FROM comments WHERE ID = $PostID");
131
+        if (!G::$DB->has_results()) {
132
+            // no such comment?
133
+            G::$DB->set_query_id($QueryID);
134
+            return false;
135
+        }
136
+        list($Page, $PageID) = G::$DB->next_record();
137
+        // get number of pages
138
+        G::$DB->query("
135 139
       SELECT
136 140
         CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
137 141
         CEIL(SUM(IF(ID <= $PostID, 1, 0)) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
@@ -139,148 +143,151 @@ class Comments {
139 143
       WHERE Page = '$Page'
140 144
         AND PageID = $PageID
141 145
       GROUP BY PageID");
142
-    if (!G::$DB->has_results()) {
143
-      // the comment $PostID was probably not posted on $Page
144
-      G::$DB->set_query_id($QueryID);
145
-      return false;
146
-    }
147
-    list($CommPages, $CommPage) = G::$DB->next_record();
146
+        if (!G::$DB->has_results()) {
147
+            // the comment $PostID was probably not posted on $Page
148
+            G::$DB->set_query_id($QueryID);
149
+            return false;
150
+        }
151
+        list($CommPages, $CommPage) = G::$DB->next_record();
148 152
 
149
-    // $CommPages = number of pages in the thread
150
-    // $CommPage = which page the post is on
151
-    // These are set for cache clearing.
153
+        // $CommPages = number of pages in the thread
154
+        // $CommPage = which page the post is on
155
+        // These are set for cache clearing.
152 156
 
153
-    G::$DB->query("
157
+        G::$DB->query("
154 158
       DELETE FROM comments
155 159
       WHERE ID = $PostID");
156
-    G::$DB->query("
160
+        G::$DB->query("
157 161
       DELETE FROM comments_edits
158 162
       WHERE Page = '$Page'
159 163
         AND PostID = $PostID");
160 164
 
161
-    G::$DB->query("
165
+        G::$DB->query("
162 166
       DELETE FROM users_notify_quoted
163 167
       WHERE Page = '$Page'
164 168
         AND PostID = $PostID");
165 169
 
166
-    Subscriptions::flush_subscriptions($Page, $PageID);
167
-    Subscriptions::flush_quote_notifications($Page, $PageID);
170
+        Subscriptions::flush_subscriptions($Page, $PageID);
171
+        Subscriptions::flush_quote_notifications($Page, $PageID);
168 172
 
169
-    //We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
170
-    $ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
171
-    $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
172
-    for ($i = $ThisCatalogue; $i <= $LastCatalogue; ++$i) {
173
-      G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
174
-    }
173
+        //We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
174
+        $ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
175
+        $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
176
+        for ($i = $ThisCatalogue; $i <= $LastCatalogue; ++$i) {
177
+            G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
178
+        }
175 179
 
176
-    G::$Cache->delete_value($Page . '_comments_' . $PageID);
180
+        G::$Cache->delete_value($Page . '_comments_' . $PageID);
177 181
 
178
-    if ($Page == 'collages') {
179
-      // On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
180
-      G::$Cache->delete_value("collage_$PageID");
182
+        if ($Page == 'collages') {
183
+            // On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
184
+            G::$Cache->delete_value("collage_$PageID");
185
+        }
186
+
187
+        G::$DB->set_query_id($QueryID);
188
+
189
+        return true;
181 190
     }
182 191
 
183
-    G::$DB->set_query_id($QueryID);
184
-
185
-    return true;
186
-  }
187
-
188
-  /**
189
-   * Get the URL to a comment, already knowing the Page and PostID
190
-   * @param string $Page
191
-   * @param int $PageID
192
-   * @param int $PostID
193
-   * @return string|bool The URL to the comment or false on error
194
-   */
195
-  public static function get_url($Page, $PageID, $PostID = null) {
196
-    $Post = (!empty($PostID) ? "&postid=$PostID#post$PostID" : '');
197
-    switch ($Page) {
198
-      case 'artist':
199
-        return "artist.php?id=$PageID$Post";
200
-      case 'collages':
201
-        return "collages.php?action=comments&collageid=$PageID$Post";
202
-      case 'requests':
203
-        return "requests.php?action=view&id=$PageID$Post";
204
-      case 'torrents':
205
-        return "torrents.php?id=$PageID$Post";
206
-      default:
207
-        return false;
192
+    /**
193
+     * Get the URL to a comment, already knowing the Page and PostID
194
+     * @param string $Page
195
+     * @param int $PageID
196
+     * @param int $PostID
197
+     * @return string|bool The URL to the comment or false on error
198
+     */
199
+    public static function get_url($Page, $PageID, $PostID = null)
200
+    {
201
+        $Post = (!empty($PostID) ? "&postid=$PostID#post$PostID" : '');
202
+        switch ($Page) {
203
+            case 'artist':
204
+                return "artist.php?id=$PageID$Post";
205
+            case 'collages':
206
+                return "collages.php?action=comments&collageid=$PageID$Post";
207
+            case 'requests':
208
+                return "requests.php?action=view&id=$PageID$Post";
209
+            case 'torrents':
210
+                return "torrents.php?id=$PageID$Post";
211
+            default:
212
+                return false;
213
+        }
208 214
     }
209
-  }
210 215
 
211
-  /**
212
-   * Get the URL to a comment
213
-   * @param int $PostID
214
-   * @return string|bool The URL to the comment or false on error
215
-   */
216
-  public static function get_url_query($PostID) {
217
-    $QueryID = G::$DB->get_query_id();
216
+    /**
217
+     * Get the URL to a comment
218
+     * @param int $PostID
219
+     * @return string|bool The URL to the comment or false on error
220
+     */
221
+    public static function get_url_query($PostID)
222
+    {
223
+        $QueryID = G::$DB->get_query_id();
218 224
 
219
-    G::$DB->query("
225
+        G::$DB->query("
220 226
       SELECT Page, PageID
221 227
       FROM comments
222 228
       WHERE ID = $PostID");
223
-    if (!G::$DB->has_results()) {
224
-      error(404);
229
+        if (!G::$DB->has_results()) {
230
+            error(404);
231
+        }
232
+        list($Page, $PageID) = G::$DB->next_record();
233
+
234
+        G::$DB->set_query_id($QueryID);
235
+
236
+        return self::get_url($Page, $PageID, $PostID);
225 237
     }
226
-    list($Page, $PageID) = G::$DB->next_record();
227
-
228
-    G::$DB->set_query_id($QueryID);
229
-
230
-    return self::get_url($Page, $PageID, $PostID);
231
-  }
232
-
233
-  /**
234
-   * Load a page's comments. This takes care of `postid` and (indirectly) `page` parameters passed in $_GET.
235
-   * Quote notifications and last read are also handled here, unless $HandleSubscriptions = false is passed.
236
-   * @param string $Page
237
-   * @param int $PageID
238
-   * @param bool $HandleSubscriptions Whether or not to handle subscriptions (last read & quote notifications)
239
-   * @return array ($NumComments, $Page, $Thread, $LastRead)
240
-   *     $NumComments: the total number of comments on this artist/request/torrent group
241
-   *     $Page: the page we're currently on
242
-   *     $Thread: an array of all posts on this page
243
-   *     $LastRead: ID of the last comment read by the current user in this thread;
244
-   *                will be false if $HandleSubscriptions == false or if there are no comments on this page
245
-   */
246
-  public static function load($Page, $PageID, $HandleSubscriptions = true) {
247
-    $QueryID = G::$DB->get_query_id();
248
-
249
-    // Get the total number of comments
250
-    $NumComments = G::$Cache->get_value($Page."_comments_$PageID");
251
-    if ($NumComments === false) {
252
-      G::$DB->query("
238
+
239
+    /**
240
+     * Load a page's comments. This takes care of `postid` and (indirectly) `page` parameters passed in $_GET.
241
+     * Quote notifications and last read are also handled here, unless $HandleSubscriptions = false is passed.
242
+     * @param string $Page
243
+     * @param int $PageID
244
+     * @param bool $HandleSubscriptions Whether or not to handle subscriptions (last read & quote notifications)
245
+     * @return array ($NumComments, $Page, $Thread, $LastRead)
246
+     *     $NumComments: the total number of comments on this artist/request/torrent group
247
+     *     $Page: the page we're currently on
248
+     *     $Thread: an array of all posts on this page
249
+     *     $LastRead: ID of the last comment read by the current user in this thread;
250
+     *                will be false if $HandleSubscriptions == false or if there are no comments on this page
251
+     */
252
+    public static function load($Page, $PageID, $HandleSubscriptions = true)
253
+    {
254
+        $QueryID = G::$DB->get_query_id();
255
+
256
+        // Get the total number of comments
257
+        $NumComments = G::$Cache->get_value($Page."_comments_$PageID");
258
+        if ($NumComments === false) {
259
+            G::$DB->query("
253 260
         SELECT COUNT(ID)
254 261
         FROM comments
255 262
         WHERE Page = '$Page'
256 263
           AND PageID = $PageID");
257
-      list($NumComments) = G::$DB->next_record();
258
-      G::$Cache->cache_value($Page."_comments_$PageID", $NumComments, 0);
259
-    }
260
-
261
-    // If a postid was passed, we need to determine which page that comment is on.
262
-    // Format::page_limit handles a potential $_GET['page']
263
-    if (isset($_GET['postid']) && is_number($_GET['postid']) && $NumComments > TORRENT_COMMENTS_PER_PAGE) {
264
-      G::$DB->query("
264
+            list($NumComments) = G::$DB->next_record();
265
+            G::$Cache->cache_value($Page."_comments_$PageID", $NumComments, 0);
266
+        }
267
+
268
+        // If a postid was passed, we need to determine which page that comment is on.
269
+        // Format::page_limit handles a potential $_GET['page']
270
+        if (isset($_GET['postid']) && is_number($_GET['postid']) && $NumComments > TORRENT_COMMENTS_PER_PAGE) {
271
+            G::$DB->query("
265 272
         SELECT COUNT(ID)
266 273
         FROM comments
267 274
         WHERE Page = '$Page'
268 275
           AND PageID = $PageID
269 276
           AND ID <= $_GET[postid]");
270
-      list($PostNum) = G::$DB->next_record();
271
-      list($CommPage, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
272
-    } else {
273
-      list($CommPage, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $NumComments);
274
-    }
275
-
276
-    // Get the cache catalogue
277
-    $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
278
-
279
-    // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
280
-    $Catalogue = G::$Cache->get_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID);
281
-    if ($Catalogue === false) {
282
-      $CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
283
-      G::$DB->query("
277
+            list($PostNum) = G::$DB->next_record();
278
+            list($CommPage, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
279
+        } else {
280
+            list($CommPage, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $NumComments);
281
+        }
282
+
283
+        // Get the cache catalogue
284
+        $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
285
+
286
+        // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
287
+        $Catalogue = G::$Cache->get_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID);
288
+        if ($Catalogue === false) {
289
+            $CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
290
+            G::$DB->query("
284 291
         SELECT
285 292
           c.ID,
286 293
           c.AuthorID,
@@ -295,20 +302,20 @@ class Comments {
295 302
           AND c.PageID = $PageID
296 303
         ORDER BY c.ID
297 304
         LIMIT $CatalogueLimit");
298
-      $Catalogue = G::$DB->to_array(false, MYSQLI_ASSOC);
299
-      G::$Cache->cache_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
300
-    }
301
-
302
-    //This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
303
-    $Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
304
-
305
-    if ($HandleSubscriptions && count($Thread) > 0) {
306
-      // quote notifications
307
-      $LastPost = end($Thread);
308
-      $LastPost = $LastPost['ID'];
309
-      $FirstPost = reset($Thread);
310
-      $FirstPost = $FirstPost['ID'];
311
-      G::$DB->query("
305
+            $Catalogue = G::$DB->to_array(false, MYSQLI_ASSOC);
306
+            G::$Cache->cache_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
307
+        }
308
+
309
+        //This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
310
+        $Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
311
+
312
+        if ($HandleSubscriptions && count($Thread) > 0) {
313
+            // quote notifications
314
+            $LastPost = end($Thread);
315
+            $LastPost = $LastPost['ID'];
316
+            $FirstPost = reset($Thread);
317
+            $FirstPost = $FirstPost['ID'];
318
+            G::$DB->query("
312 319
         UPDATE users_notify_quoted
313 320
         SET UnRead = false
314 321
         WHERE UserID = " . G::$LoggedUser['ID'] . "
@@ -316,126 +323,128 @@ class Comments {
316 323
           AND PageID = $PageID
317 324
           AND PostID >= $FirstPost
318 325
           AND PostID <= $LastPost");
319
-      if (G::$DB->affected_rows()) {
320
-        G::$Cache->delete_value('notify_quoted_' . G::$LoggedUser['ID']);
321
-      }
326
+            if (G::$DB->affected_rows()) {
327
+                G::$Cache->delete_value('notify_quoted_' . G::$LoggedUser['ID']);
328
+            }
322 329
 
323
-      // last read
324
-      G::$DB->query("
330
+            // last read
331
+            G::$DB->query("
325 332
         SELECT PostID
326 333
         FROM users_comments_last_read
327 334
         WHERE UserID = " . G::$LoggedUser['ID'] . "
328 335
           AND Page = '$Page'
329 336
           AND PageID = $PageID");
330
-      list($LastRead) = G::$DB->next_record();
331
-      if ($LastRead < $LastPost) {
332
-        G::$DB->query("
337
+            list($LastRead) = G::$DB->next_record();
338
+            if ($LastRead < $LastPost) {
339
+                G::$DB->query("
333 340
           INSERT INTO users_comments_last_read
334 341
             (UserID, Page, PageID, PostID)
335 342
           VALUES
336 343
             (" . G::$LoggedUser['ID'] . ", '$Page', $PageID, $LastPost)
337 344
           ON DUPLICATE KEY UPDATE
338 345
             PostID = $LastPost");
339
-        G::$Cache->delete_value('subscriptions_user_new_' . G::$LoggedUser['ID']);
340
-      }
341
-    } else {
342
-      $LastRead = false;
343
-    }
346
+                G::$Cache->delete_value('subscriptions_user_new_' . G::$LoggedUser['ID']);
347
+            }
348
+        } else {
349
+            $LastRead = false;
350
+        }
344 351
 
345
-    G::$DB->set_query_id($QueryID);
352
+        G::$DB->set_query_id($QueryID);
346 353
 
347
-    return array($NumComments, $CommPage, $Thread, $LastRead);
348
-  }
354
+        return array($NumComments, $CommPage, $Thread, $LastRead);
355
+    }
349 356
 
350
-  /**
351
-   * Merges all comments from $Page/$PageID into $Page/$TargetPageID. This also takes care of quote notifications, subscriptions and cache.
352
-   * @param type $Page
353
-   * @param type $PageID
354
-   * @param type $TargetPageID
355
-   */
356
-  public static function merge($Page, $PageID, $TargetPageID) {
357
-    $QueryID = G::$DB->get_query_id();
357
+    /**
358
+     * Merges all comments from $Page/$PageID into $Page/$TargetPageID. This also takes care of quote notifications, subscriptions and cache.
359
+     * @param type $Page
360
+     * @param type $PageID
361
+     * @param type $TargetPageID
362
+     */
363
+    public static function merge($Page, $PageID, $TargetPageID)
364
+    {
365
+        $QueryID = G::$DB->get_query_id();
358 366
 
359
-    G::$DB->query("
367
+        G::$DB->query("
360 368
       UPDATE comments
361 369
       SET PageID = $TargetPageID
362 370
       WHERE Page = '$Page'
363 371
         AND PageID = $PageID");
364 372
 
365
-    // quote notifications
366
-    G::$DB->query("
373
+        // quote notifications
374
+        G::$DB->query("
367 375
       UPDATE users_notify_quoted
368 376
       SET PageID = $TargetPageID
369 377
       WHERE Page = '$Page'
370 378
         AND PageID = $PageID");
371 379
 
372
-    // comment subscriptions
373
-    Subscriptions::move_subscriptions($Page, $PageID, $TargetPageID);
380
+        // comment subscriptions
381
+        Subscriptions::move_subscriptions($Page, $PageID, $TargetPageID);
374 382
 
375
-    // cache (we need to clear all comment catalogues)
376
-    G::$DB->query("
383
+        // cache (we need to clear all comment catalogues)
384
+        G::$DB->query("
377 385
       SELECT
378 386
         CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages
379 387
       FROM comments
380 388
       WHERE Page = '$Page'
381 389
         AND PageID = $TargetPageID
382 390
       GROUP BY PageID");
383
-    list($CommPages) = G::$DB->next_record();
384
-    $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
385
-    for ($i = 0; $i <= $LastCatalogue; ++$i) {
386
-      G::$Cache->delete_value($Page . "_comments_$TargetPageID" . "_catalogue_$i");
391
+        list($CommPages) = G::$DB->next_record();
392
+        $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
393
+        for ($i = 0; $i <= $LastCatalogue; ++$i) {
394
+            G::$Cache->delete_value($Page . "_comments_$TargetPageID" . "_catalogue_$i");
395
+        }
396
+        G::$Cache->delete_value($Page."_comments_$TargetPageID");
397
+        G::$DB->set_query_id($QueryID);
387 398
     }
388
-    G::$Cache->delete_value($Page."_comments_$TargetPageID");
389
-    G::$DB->set_query_id($QueryID);
390
-  }
391
-
392
-  /**
393
-   * Delete all comments on $Page/$PageID (deals with quote notifications and subscriptions as well)
394
-   * @param string $Page
395
-   * @param int $PageID
396
-   * @return boolean
397
-   */
398
-  public static function delete_page($Page, $PageID) {
399
-    $QueryID = G::$DB->get_query_id();
400
-
401
-    // get number of pages
402
-    G::$DB->query("
399
+
400
+    /**
401
+     * Delete all comments on $Page/$PageID (deals with quote notifications and subscriptions as well)
402
+     * @param string $Page
403
+     * @param int $PageID
404
+     * @return boolean
405
+     */
406
+    public static function delete_page($Page, $PageID)
407
+    {
408
+        $QueryID = G::$DB->get_query_id();
409
+
410
+        // get number of pages
411
+        G::$DB->query("
403 412
       SELECT
404 413
         CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages
405 414
       FROM comments
406 415
       WHERE Page = '$Page'
407 416
         AND PageID = $PageID
408 417
       GROUP BY PageID");
409
-    if (!G::$DB->has_results()) {
410
-      return false;
411
-    }
412
-    list($CommPages) = G::$DB->next_record();
418
+        if (!G::$DB->has_results()) {
419
+            return false;
420
+        }
421
+        list($CommPages) = G::$DB->next_record();
413 422
 
414
-    // Delete comments
415
-    G::$DB->query("
423
+        // Delete comments
424
+        G::$DB->query("
416 425
       DELETE FROM comments
417 426
       WHERE Page = '$Page'
418 427
         AND PageID = $PageID");
419 428
 
420
-    // Delete quote notifications
421
-    Subscriptions::flush_quote_notifications($Page, $PageID);
422
-    G::$DB->query("
429
+        // Delete quote notifications
430
+        Subscriptions::flush_quote_notifications($Page, $PageID);
431
+        G::$DB->query("
423 432
       DELETE FROM users_notify_quoted
424 433
       WHERE Page = '$Page'
425 434
         AND PageID = $PageID");
426 435
 
427
-    // Deal with subscriptions
428
-    Subscriptions::move_subscriptions($Page, $PageID, null);
436
+        // Deal with subscriptions
437
+        Subscriptions::move_subscriptions($Page, $PageID, null);
429 438
 
430
-    // Clear cache
431
-    $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
432
-    for ($i = 0; $i <= $LastCatalogue; ++$i) {
433
-      G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
434
-    }
435
-    G::$Cache->delete_value($Page.'_comments_'.$PageID);
439
+        // Clear cache
440
+        $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
441
+        for ($i = 0; $i <= $LastCatalogue; ++$i) {
442
+            G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
443
+        }
444
+        G::$Cache->delete_value($Page.'_comments_'.$PageID);
436 445
 
437
-    G::$DB->set_query_id($QueryID);
446
+        G::$DB->set_query_id($QueryID);
438 447
 
439
-    return true;
440
-  }
448
+        return true;
449
+    }
441 450
 }

+ 54
- 50
classes/commentsview.class.php View File

@@ -1,95 +1,99 @@
1
-<?
2
-class CommentsView {
3
-  /**
4
-   * Render a thread of comments
5
-   * @param array $Thread An array as returned by Comments::load
6
-   * @param int $LastRead PostID of the last read post
7
-   * @param string $Baselink Link to the site these comments are on
8
-   */
9
-  public static function render_comments($Thread, $LastRead, $Baselink) {
10
-    foreach ($Thread as $Post) {
11
-      list($PostID, $AuthorID, $AddedTime, $CommentBody, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
12
-      self::render_comment($AuthorID, $PostID, $CommentBody, $AddedTime, $EditedUserID, $EditedTime, $Baselink . "&amp;postid=$PostID#post$PostID", ($PostID > $LastRead));
1
+<?php
2
+class CommentsView
3
+{
4
+    /**
5
+     * Render a thread of comments
6
+     * @param array $Thread An array as returned by Comments::load
7
+     * @param int $LastRead PostID of the last read post
8
+     * @param string $Baselink Link to the site these comments are on
9
+     */
10
+    public static function render_comments($Thread, $LastRead, $Baselink)
11
+    {
12
+        foreach ($Thread as $Post) {
13
+            list($PostID, $AuthorID, $AddedTime, $CommentBody, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
14
+            self::render_comment($AuthorID, $PostID, $CommentBody, $AddedTime, $EditedUserID, $EditedTime, $Baselink . "&amp;postid=$PostID#post$PostID", ($PostID > $LastRead));
15
+        }
13 16
     }
14
-  }
15 17
 
16
-  /**
17
-   * Render one comment
18
-   * @param int $AuthorID
19
-   * @param int $PostID
20
-   * @param string $Body
21
-   * @param string $AddedTime
22
-   * @param int $EditedUserID
23
-   * @param string $EditedTime
24
-   * @param string $Link The link to the post elsewhere on the site
25
-   * @param string $Header The header used in the post
26
-   * @param bool $Tools Whether or not to show [Edit], [Report] etc.
27
-   * @todo Find a better way to pass the page (artist, collages, requests, torrents) to this function than extracting it from $Link
28
-   */
29
-  static function render_comment($AuthorID, $PostID, $Body, $AddedTime, $EditedUserID, $EditedTime, $Link, $Unread = false, $Header = '', $Tools = true) {
30
-    $UserInfo = Users::user_info($AuthorID);
31
-    $Header = Users::format_username($AuthorID, true, true, true, true, true) . time_diff($AddedTime) . $Header;
32
-?>
18
+    /**
19
+     * Render one comment
20
+     * @param int $AuthorID
21
+     * @param int $PostID
22
+     * @param string $Body
23
+     * @param string $AddedTime
24
+     * @param int $EditedUserID
25
+     * @param string $EditedTime
26
+     * @param string $Link The link to the post elsewhere on the site
27
+     * @param string $Header The header used in the post
28
+     * @param bool $Tools Whether or not to show [Edit], [Report] etc.
29
+     * @todo Find a better way to pass the page (artist, collages, requests, torrents) to this function than extracting it from $Link
30
+     */
31
+    public static function render_comment($AuthorID, $PostID, $Body, $AddedTime, $EditedUserID, $EditedTime, $Link, $Unread = false, $Header = '', $Tools = true)
32
+    {
33
+        $UserInfo = Users::user_info($AuthorID);
34
+        $Header = Users::format_username($AuthorID, true, true, true, true, true) . time_diff($AddedTime) . $Header; ?>
33 35
     <table class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '') . ($Unread ? ' forum_unread' : '')?>" id="post<?=$PostID?>">
34 36
       <colgroup>
35
-<?    if (Users::has_avatars_enabled()) { ?>
37
+        <?php    if (Users::has_avatars_enabled()) { ?>
36 38
         <col class="col_avatar" />
37
-<?    } ?>
39
+        <?php    } ?>
38 40
         <col class="col_post_body" />
39 41
       </colgroup>
40 42
       <tr class="colhead_dark">
41 43
         <td colspan="<?=(Users::has_avatars_enabled() ? 2 : 1)?>">
42 44
           <div class="float_left"><a class="post_id" href="<?=$Link?>">#<?=$PostID?></a>
43 45
             <?=$Header?>
44
-<?    if ($Tools) { ?>
46
+        <?php    if ($Tools) { ?>
45 47
             - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$UserInfo['Username']?>', true);" class="brackets">Quote</a>
46
-<?      if ($AuthorID == G::$LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?>
48
+            <?php      if ($AuthorID == G::$LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?>
47 49
             - <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>','');" class="brackets">Edit</a>
48
-<?      }
49
-      if (check_perms('site_moderate_forums')) { ?>
50
+            <?php      }
51
+            if (check_perms('site_moderate_forums')) { ?>
50 52
             - <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');" class="brackets">Delete</a>
51
-<?      } ?>
53
+            <?php      } ?>
52 54
           </div>
53 55
           <div id="bar<?=$PostID?>" class="float_right">
54 56
             <a href="reports.php?action=report&amp;type=comment&amp;id=<?=$PostID?>" class="brackets">Report</a>
55
-<?
56
-      if (check_perms('users_warn') && $AuthorID != G::$LoggedUser['ID'] && G::$LoggedUser['Class'] >= $UserInfo['Class']) {
57
-?>
57
+            <?php
58
+            if (check_perms('users_warn') && $AuthorID != G::$LoggedUser['ID'] && G::$LoggedUser['Class'] >= $UserInfo['Class']) {
59
+                ?>
58 60
             <form class="manage_form hidden" name="user" id="warn<?=$PostID?>" action="comments.php" method="post">
59 61
               <input type="hidden" name="action" value="warn" />
60 62
               <input type="hidden" name="postid" value="<?=$PostID?>" />
61 63
             </form>
62 64
             - <a href="#" onclick="$('#warn<?=$PostID?>').raw().submit(); return false;" class="brackets">Warn</a>
63
-<?      } ?>
65
+                <?php
66
+            } ?>
64 67
             &nbsp;
65 68
             <a href="#">&uarr;</a>
66
-<?    } ?>
69
+        <?php    } ?>
67 70
           </div>
68 71
         </td>
69 72
       </tr>
70 73
       <tr>
71
-<?    if (Users::has_avatars_enabled()) { ?>
74
+        <?php    if (Users::has_avatars_enabled()) { ?>
72 75
         <td class="avatar" valign="top">
73
-        <?=Users::show_avatar($UserInfo['Avatar'], $AuthorID, $UserInfo['Username'], G::$LoggedUser['DisableAvatars'])?>
76
+            <?=Users::show_avatar($UserInfo['Avatar'], $AuthorID, $UserInfo['Username'], G::$LoggedUser['DisableAvatars'])?>
74 77
         </td>
75
-<?    } ?>
78
+        <?php    } ?>
76 79
         <td class="body" valign="top">
77 80
           <div id="content<?=$PostID?>">
78 81
             <?=Text::full_format($Body)?>
79
-<?    if ($EditedUserID) { ?>
82
+        <?php    if ($EditedUserID) { ?>
80 83
             <br />
81 84
             <br />
82 85
             <div class="last_edited">
83
-<?      if (check_perms('site_admin_forums')) { ?>
86
+            <?php      if (check_perms('site_admin_forums')) { ?>
84 87
               <a href="#content<?=$PostID?>" onclick="LoadEdit('<?=substr($Link, 0, strcspn($Link, '.'))?>', <?=$PostID?>, 1); return false;">&laquo;</a>
85
-<?      } ?>
88
+            <?php      } ?>
86 89
               Last edited by
87 90
               <?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime, 2, true, true)?>
88
-<?    } ?>
91
+        <?php    } ?>
89 92
             </div>
90 93
           </div>
91 94
         </td>
92 95
       </tr>
93 96
     </table>
94
-<?  }
97
+        <?php
98
+    }
95 99
 }

+ 0
- 0
classes/config.template View File


+ 29
- 24
classes/cookie.class.php View File

@@ -1,4 +1,4 @@
1
-<?
1
+<?php
2 2
 /*************************************************************************|
3 3
 |--------------- Cookie class --------------------------------------------|
4 4
 |*************************************************************************|
@@ -19,30 +19,35 @@ interface COOKIE_INTERFACE {
19 19
 }
20 20
 */
21 21
 
22
-class COOKIE /*implements COOKIE_INTERFACE*/ {
23
-  const LIMIT_ACCESS = true; //If true, blocks JS cookie API access by default (can be overridden case by case)
24
-  const PREFIX = ''; //In some cases you may desire to prefix your cookies
22
+class COOKIE /*implements COOKIE_INTERFACE*/
23
+{
24
+    const LIMIT_ACCESS = true; //If true, blocks JS cookie API access by default (can be overridden case by case)
25
+    const PREFIX = ''; //In some cases you may desire to prefix your cookies
26
+
27
+    public function get($Key)
28
+    {
29
+        if (!isset($_COOKIE[self::PREFIX.$Key])) {
30
+            return false;
31
+        }
32
+        return $_COOKIE[self::PREFIX.$Key];
33
+    }
34
+
35
+    //Pass the 4th optional param as false to allow JS access to the cookie
36
+    public function set($Key, $Value, $Seconds = 86400, $LimitAccess = self::LIMIT_ACCESS)
37
+    {
38
+        setcookie(self::PREFIX.$Key, $Value, time() + $Seconds, '/', SITE_DOMAIN, $_SERVER['SERVER_PORT'] === '443', $LimitAccess, false);
39
+    }
25 40
 
26
-  public function get($Key) {
27
-    if (!isset($_COOKIE[SELF::PREFIX.$Key])) {
28
-      return false;
41
+    public function del($Key)
42
+    {
43
+        setcookie(self::PREFIX.$Key, '', time() - 24 * 3600); //3600 vs 1 second to account for potential clock desyncs
29 44
     }
30
-    return $_COOKIE[SELF::PREFIX.$Key];
31
-  }
32
-
33
-  //Pass the 4th optional param as false to allow JS access to the cookie
34
-  public function set($Key, $Value, $Seconds = 86400, $LimitAccess = SELF::LIMIT_ACCESS) {
35
-    setcookie(SELF::PREFIX.$Key, $Value, time() + $Seconds, '/', SITE_DOMAIN, $_SERVER['SERVER_PORT'] === '443', $LimitAccess, false);
36
-  }
37
-
38
-  public function del($Key) {
39
-    setcookie(SELF::PREFIX.$Key, '', time() - 24 * 3600); //3600 vs 1 second to account for potential clock desyncs
40
-  }
41
-
42
-  public function flush() {
43
-    $Cookies = array_keys($_COOKIE);
44
-    foreach ($Cookies as $Cookie) {
45
-      $this->del($Cookie);
45
+
46
+    public function flush()
47
+    {
48
+        $Cookies = array_keys($_COOKIE);
49
+        foreach ($Cookies as $Cookie) {
50
+            $this->del($Cookie);
51
+        }
46 52
     }
47
-  }
48 53
 }

+ 35
- 33
classes/crypto.class.php View File

@@ -1,37 +1,39 @@
1
-<?
2
-class Crypto {
3
-  /**
4
-   * Encrypts input text for use in database
5
-   *
6
-   * @param string $plaintext
7
-   * @return encrypted string or false if DB key not accessible
8
-   */
9
-  public static function encrypt($plaintext) {
10
-    if (apcu_exists('DBKEY')) {
11
-      $iv_size = openssl_cipher_iv_length('AES-128-CBC');
12
-      $iv = openssl_random_pseudo_bytes($iv_size);
13
-      $ret = base64_encode($iv.openssl_encrypt($plaintext, 'AES-128-CBC', apcu_fetch('DBKEY'), OPENSSL_RAW_DATA, $iv));
14
-      return $ret;
15
-    } else {
16
-      return false;
1
+<?php
2
+class Crypto
3
+{
4
+    /**
5
+     * Encrypts input text for use in database
6
+     *
7
+     * @param string $plaintext
8
+     * @return encrypted string or false if DB key not accessible
9
+     */
10
+    public static function encrypt($plaintext)
11
+    {
12
+        if (apcu_exists('DBKEY')) {
13
+            $iv_size = openssl_cipher_iv_length('AES-128-CBC');
14
+            $iv = openssl_random_pseudo_bytes($iv_size);
15
+            $ret = base64_encode($iv.openssl_encrypt($plaintext, 'AES-128-CBC', apcu_fetch('DBKEY'), OPENSSL_RAW_DATA, $iv));
16
+            return $ret;
17
+        } else {
18
+            return false;
19
+        }
17 20
     }
18
-  }
19 21
 
20
-  /**
21
-   * Decrypts input text from database
22
-   *
23
-   * @param string $ciphertext
24
-   * @return decrypted string string or false if DB key not accessible
25
-   */
26
-  public static function decrypt($ciphertext) {
27
-    if (apcu_exists('DBKEY')) {
28
-      $iv_size = openssl_cipher_iv_length('AES-128-CBC');
29
-      $iv = substr(base64_decode($ciphertext), 0, $iv_size);
30
-      $ciphertext = substr(base64_decode($ciphertext), $iv_size);
31
-      return openssl_decrypt($ciphertext, 'AES-128-CBC', apcu_fetch('DBKEY'), OPENSSL_RAW_DATA, $iv);
32
-    } else {
33
-      return false;
22
+    /**
23
+     * Decrypts input text from database
24
+     *
25
+     * @param string $ciphertext
26
+     * @return decrypted string string or false if DB key not accessible
27
+     */
28
+    public static function decrypt($ciphertext)
29
+    {
30
+        if (apcu_exists('DBKEY')) {
31
+            $iv_size = openssl_cipher_iv_length('AES-128-CBC');
32
+            $iv = substr(base64_decode($ciphertext), 0, $iv_size);
33
+            $ciphertext = substr(base64_decode($ciphertext), $iv_size);
34
+            return openssl_decrypt($ciphertext, 'AES-128-CBC', apcu_fetch('DBKEY'), OPENSSL_RAW_DATA, $iv);
35
+        } else {
36
+            return false;
37
+        }
34 38
     }
35
-  }
36 39
 }
37
-?>

Loading…
Cancel
Save