Browse Source

Add OPS's prepared_query() SQL method

biotorrents 4 years ago
parent
commit
72cb2e0792

+ 5
- 16
classes/autoload.php View File

@@ -11,8 +11,10 @@ declare(strict_types=1);
11 11
  * @see https://www.php.net/manual/en/language.oop5.autoload.php
12 12
  */
13 13
 spl_autoload_register(function ($ClassName) {
14
-    $FilePath = SERVER_ROOT . '/classes/' . strtolower($ClassName) . '.class.php';
15
-    #$FilePath = $_SERVER['DOCUMENT_ROOT'] . '/classes/' . strtolower($ClassName) . '.class.php';
14
+  $ENV = ENV::go();
15
+
16
+  $classname = strtolower($ClassName);
17
+    $FilePath = "$ENV->SERVER_ROOT/classes/$classname.class.php";
16 18
 
17 19
     if (!file_exists($FilePath)) {
18 20
         // todo: Rename the following classes to conform with the code guidelines
@@ -43,24 +45,11 @@ spl_autoload_register(function ($ClassName) {
43 45
           $FileName = 'env.class';
44 46
           break;
45 47
 
46
-        case 'Parsedown':
47
-          $FileName = 'vendor/Parsedown';
48
-          break;
49
-
50
-        case 'ParsedownExtra':
51
-          $FileName = 'vendor/ParsedownExtra';
52
-          break;
53
-
54
-        case 'TwitterAPIExchange':
55
-          $FileName = 'vendor/TwitterAPIExchange';
56
-          break;
57
-
58 48
         default:
59 49
           error("Couldn't import class $ClassName");
60 50
     }
61 51
 
62
-        $FilePath = SERVER_ROOT . "/classes/$FileName.php";
63
-        #$FilePath = $_SERVER['DOCUMENT_ROOT'] . "/classes/$FileName.php";
52
+        $FilePath = "$ENV->SERVER_ROOT/classes/$FileName.php";
64 53
     }
65 54
 
66 55
     require_once $FilePath;

+ 34
- 8
classes/mysql.class.php View File

@@ -111,10 +111,6 @@ set_query_id($ResultSet)
111 111
 -------------------------------------------------------------------------------------
112 112
 *///---------------------------------------------------------------------------------
113 113
 
114
-if (!extension_loaded('mysqli')) {
115
-    error('Mysqli Extension not loaded.');
116
-}
117
-
118 114
 
119 115
 /**
120 116
  * db_string
@@ -285,9 +281,27 @@ class DB_MYSQL
285 281
 
286 282
 
287 283
     /**
288
-     * prepare_query
284
+     * Prepare and execute a prepared query returning the result set.
285
+     *
286
+     * Utility function that wraps DB_MYSQL::prepare and DB_MYSQL::execute
287
+     * as most times, the query is going to be one-off and this will save
288
+     * on keystrokes. If you do plan to be executing a prepared query
289
+     * multiple times with different bound parameters, you'll want to call
290
+     * the two functions separately instead of this function.
291
+     *
292
+     * @param $Query
293
+     * @param mixed ...$Parameters
294
+     * @return bool|mysqli_result
295
+     */
296
+    public function prepared_query($Query, ...$Parameters) {
297
+        $this->prepare($Query);
298
+        return $this->execute(...$Parameters);
299
+    }
300
+
301
+    /**
302
+     * prepare
289 303
      */
290
-    public function prepare_query($Query, &...$BindVars)
304
+    public function prepare($Query, &...$BindVars)
291 305
     {
292 306
         $this->connect();
293 307
         $this->StatementID = mysqli_prepare($this->LinkID, $Query);
@@ -306,11 +320,17 @@ class DB_MYSQL
306 320
         return $this->StatementID;
307 321
     }
308 322
 
323
+    # Compatibility function for the old name
324
+    public function prepare_query($Query, &...$BindVars)
325
+    {
326
+        return $this->prepare($Query, $BindVars);
327
+    }
328
+
309 329
 
310 330
     /**
311
-     * exec_prepared_query
331
+     * execute
312 332
      */
313
-    public function exec_prepared_query()
333
+    public function execute()
314 334
     {
315 335
         $QueryStartTime = microtime(true);
316 336
         mysqli_stmt_execute($this->StatementID);
@@ -320,6 +340,12 @@ class DB_MYSQL
320 340
         $this->Time += $QueryRunTime;
321 341
     }
322 342
 
343
+    # Compatibility function for the old name
344
+    public function exec_prepared_query()
345
+    {
346
+        return $this->execute();
347
+    }
348
+
323 349
 
324 350
     /**
325 351
      * Runs a raw query assuming pre-sanitized input. However, attempting to self sanitize (such

+ 5
- 0
classes/security.class.php View File

@@ -64,6 +64,11 @@ class Security
64 64
             error('memcached extension php-memcache not loaded.');
65 65
         }
66 66
 
67
+        # mysqli
68
+        if (!extension_loaded('mysqli')) {
69
+            error('mysqli extension php-mysql not loaded.');
70
+        }
71
+        
67 72
         # blake3
68 73
         if ($ENV->FEATURE_BIOPHP && !extension_loaded('blake3')) {
69 74
             error('Please install and enable the php-blake3 extension.');

+ 1
- 1
classes/twig.class.php View File

@@ -68,7 +68,7 @@ class Twig
68 68
                 'auto_reload' => true,
69 69
                 'autoescape' => 'name',
70 70
                 'cache' => "$ENV->WEB_ROOT/cache/twig",
71
-                #'debug' => DEBUG_MODE,
71
+                'debug' => $ENV->DEV,
72 72
                 'strict_variables' => true,
73 73
         ]
74 74
         );

+ 1
- 1
design/views/generic/reply/staffpm.php View File

@@ -32,7 +32,7 @@ $TextPrev = new TEXTAREA_PREVIEW(
32 32
 
33 33
     <input type="button" value="Preview"
34 34
       class="hidden button_preview_<?=$TextPrev->getID()?>" />
35
-    <input type="submit" value="Send message" />
35
+    <input type="submit" class="button-primary" value="Send message" />
36 36
     <input type="button" value="Hide" data-toggle-target="#compose" />
37 37
   </form>
38 38
 </div>

+ 4
- 4
sections/better/better.php View File

@@ -24,7 +24,7 @@ View::show_header('Better');
24 24
 </h3>
25 25
 
26 26
 <div class="box pad">
27
-  <table>
27
+  <table class="better_list">
28 28
     <tr class="colhead">
29 29
       <td style="width: 150px;">Method</td>
30 30
       <td style="width: 400px;">Additional Information</td>
@@ -42,11 +42,11 @@ View::show_header('Better');
42 42
 
43 43
     <tr class="row">
44 44
       <td class="nobr">
45
-        <a href="better.php?method=literature&filter=all">Publications</a>
45
+        <a href="better.php?method=literature&filter=all">DOI numbers</a>
46 46
       </td>
47 47
 
48 48
       <td class="nobr">
49
-        When a torrent group doesn't have a publication
49
+        Torrent groups without citations, for enhanced metadata support
50 50
       </td>
51 51
     </tr>
52 52
 
@@ -55,7 +55,7 @@ View::show_header('Better');
55 55
         <a href="better.php?method=covers&filter=all">Pictures</a>
56 56
       </td>
57 57
       <td class="nobr">
58
-        When a torrent group doesn't have a picture
58
+        Torrent groups without pictures, for at-a-glance context
59 59
       </td>
60 60
     </tr>
61 61
 

+ 1
- 1
sections/better/index.php View File

@@ -1,7 +1,7 @@
1 1
 <?php
2 2
 declare(strict_types=1);
3 3
 
4
-enforce_login();
4
+#enforce_login();
5 5
 
6 6
 if (isset($_GET['method'])) {
7 7
     switch ($_GET['method']) {

+ 5
- 5
sections/better/literature.php View File

@@ -12,7 +12,7 @@ $Join = $All
12 12
 
13 13
 View::show_header('Torrent groups with no publications');
14 14
 
15
-$DB->query("
15
+$DB->prepared_query("
16 16
 SELECT SQL_CALC_FOUND_ROWS
17 17
   tg.`id`
18 18
 FROM
@@ -38,21 +38,21 @@ $Results = Torrents::get_groups(array_keys($Groups)); ?>
38 38
 <div class="header">
39 39
   <?php if ($All) { ?>
40 40
   <h2>
41
-    All groups with no publications
41
+    All groups with no DOI numbers
42 42
   </h2>
43 43
 
44 44
   <?php } else { ?>
45 45
   <h2>
46
-    Torrent groups with no publications that you have snatched
46
+    Torrent groups with no DOI numbers that you have snatched
47 47
   </h2>
48 48
   <?php } ?>
49 49
 
50 50
   <div class="linkbox">
51 51
     <a href="better.php" class="brackets">Back to better.php list</a>
52 52
     <?php if ($All) { ?>
53
-    <a href="better.php?method=screenshots" class="brackets">Show only those you have snatched</a>
53
+    <a href="better.php?method=literature" class="brackets">Show only those you have snatched</a>
54 54
     <?php } else { ?>
55
-    <a href="better.php?method=screenshots&amp;filter=all" class="brackets">Show all</a>
55
+    <a href="better.php?method=literature&amp;filter=all" class="brackets">Show all</a>
56 56
     <?php } ?>
57 57
   </div>
58 58
 </div>

+ 15
- 13
sections/bookmarks/torrents.php View File

@@ -66,18 +66,19 @@ foreach ($GroupIDs as $GroupID) {
66 66
         }
67 67
     }
68 68
 
69
-    $TorrentTags = new Tags($TagList);
70
-    $DisplayName = Artists::display_artists($Artists);
71
-    $GroupName = empty($GroupName) ? (empty($GroupTitle2) ? $GroupNameJP : $GroupTitle2) : $GroupName;
69
+    $TorrentTags = new Tags($tag_list);
70
+    $DisplayName = '';
71
+    #$DisplayName = Artists::display_artists($Artists);
72
+    $GroupName = empty($title) ? (empty($subject) ? $object : $subject) : $title;
72 73
     
73 74
     $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" ';
74 75
     if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
75
-        $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
76
+        $DisplayName .= 'data-cover="'.ImageTools::process($picture, 'thumb').'" ';
76 77
     }
77 78
 
78 79
     $DisplayName .= ' class="tooltip" title="View torrent group" dir="ltr">'.$GroupName.'</a>';
79
-    if ($GroupYear > 0) {
80
-        $DisplayName = "$DisplayName [$GroupYear]";
80
+    if ($year > 0) {
81
+        $DisplayName = "$DisplayName [$year]";
81 82
     }
82 83
     $SnatchedGroupClass = $GroupFlags['IsSnatched'] ? ' snatched_group' : '';
83 84
 
@@ -159,11 +160,12 @@ foreach ($GroupIDs as $GroupID) {
159 160
         $TorrentID = key($Torrents);
160 161
         $Torrent = current($Torrents);
161 162
 
162
-        $DisplayName = Artists::display_artists(Artists::get_artist($GroupID));
163
+        $DisplayName = '';
164
+        #$DisplayName = Artists::display_artists(Artists::get_artist($GroupID));
163 165
         $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" ';
164 166
 
165 167
         if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
166
-            $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
168
+            $DisplayName .= 'data-cover="'.ImageTools::process($picture, 'thumb').'" ';
167 169
         }
168 170
 
169 171
         $DisplayName .=' class="tooltip" title="View torrent group" dir="ltr">'.$GroupName.'</a>';
@@ -241,8 +243,8 @@ foreach ($GroupIDs as $GroupID) {
241 243
     #$DisplayName .= Artists::display_artists($Artists, false);
242 244
     $DisplayName .= $GroupName;
243 245
 
244
-    if ($GroupYear > 0) {
245
-        $DisplayName = "$DisplayName [$GroupYear]";
246
+    if ($year > 0) {
247
+        $DisplayName = "$DisplayName [$year]";
246 248
     }
247 249
 
248 250
     $Tags = display_str($TorrentTags->format());
@@ -252,12 +254,12 @@ foreach ($GroupIDs as $GroupID) {
252 254
   <a href="torrents.php?id=<?=$GroupID?>"
253 255
     class="bookmark_<?=$GroupID?>">
254 256
 
255
-    <?php if (!$WikiImage) {
256
-        $WikiImage = STATIC_SERVER.'common/noartwork/music.png';
257
+    <?php if (!$picture) {
258
+        $picture = STATIC_SERVER.'common/noartwork/music.png';
257 259
     } ?>
258 260
 
259 261
     <img class="tooltip"
260
-      src="<?=ImageTools::process($WikiImage, 'thumb')?>"
262
+      src="<?=ImageTools::process($picture, 'thumb')?>"
261 263
       alt="<?=$DisplayName?>"
262 264
       title="<?=$DisplayName?>"
263 265
       data-title-plain="<?=$DisplayName?>" width="100%" />

+ 2
- 2
sections/collages/edit.php View File

@@ -44,7 +44,7 @@ if (!empty($Err)) {
44 44
         value="<?=$LoggedUser['AuthKey']?>" />
45 45
       <input type="hidden" name="collageid"
46 46
         value="<?=$CollageID?>" />
47
-      <table id="edit_collage" class="layout">
47
+      <table id="edit_collage" class="layout collage_edit">
48 48
         <?php if (check_perms('site_collages_delete') || ($CategoryID == 0 && $UserID == $LoggedUser['ID'] && check_perms('site_collages_renamepersonal'))) { ?>
49 49
         <tr>
50 50
           <td class="label">Name</td>
@@ -117,7 +117,7 @@ if (check_perms('site_collages_delete')) { ?>
117 117
 
118 118
         <?php } ?>
119 119
         <tr>
120
-          <td colspan="2" class="center"><input type="submit" value="Edit" /></td>
120
+          <td colspan="2" class="center"><input type="submit" class="button-primary" value="Edit" /></td>
121 121
         </tr>
122 122
       </table>
123 123
     </form>

+ 1
- 1
sections/collages/new.php View File

@@ -136,7 +136,7 @@ new TEXTAREA_PREVIEW(
136 136
 
137 137
         <tr>
138 138
           <td colspan="2" class="center">
139
-            <input type="submit" value="Create" />
139
+            <input type="submit" class="button-primary" value="Create" />
140 140
           </td>
141 141
         </tr>
142 142
       </table>

+ 7
- 2
sections/inbox/inbox.php View File

@@ -122,7 +122,7 @@ echo $Pages;
122 122
     <input type="hidden" name="action" value="masschange" />
123 123
     <input type="hidden" name="auth"
124 124
       value="<?=$LoggedUser['AuthKey']?>" />
125
-    <input type="submit" name="read" value="Mark as read" />
125
+    <input type="submit" name="read" class="button-primary" value="Mark as read" />
126 126
     <input type="submit" name="unread" value="Mark as unread" />
127 127
     <input type="submit" name="delete" value="Delete message(s)" />
128 128
 
@@ -181,12 +181,17 @@ echo $Pages;
181 181
       }
182 182
   } ?>
183 183
     </table>
184
-    <input type="submit" name="read" value="Mark as read" />
184
+    <?php
185
+    $MsgLimit = ($LoggedUser['PostsPerPage']) ? $LoggedUser['PostsPerPage'] : MESSAGES_PER_PAGE;
186
+    if ($Count > $MsgLimit) { ?>
187
+    <input type="submit" name="read" class="button-primary" value="Mark as read" />
185 188
     <input type="submit" name="unread" value="Mark as unread" />
186 189
     <input type="submit" name="delete" value="Delete message(s)" />
190
+    <?php } ?>
187 191
   </form>
188 192
   <?php } ?>
189 193
 </div>
194
+
190 195
 <div class="linkbox">
191 196
   <?= $Pages ?>
192 197
 </div>

+ 2
- 2
sections/requests/new_edit.php View File

@@ -444,13 +444,13 @@ View::show_header(
444 444
         <!-- Submit -->
445 445
         <tr>
446 446
           <td colspan="2" class="center">
447
-            <input type="submit" id="button" value="Create" disabled="disabled" />
447
+            <input type="submit" id="button" class="button-primary" value="Create" disabled="disabled" />
448 448
           </td>
449 449
         </tr>
450 450
         <?php } else { ?>
451 451
         <tr>
452 452
           <td colspan="2" class="center">
453
-            <input type="submit" id="button" value="Edit" />
453
+            <input type="submit" id="button" class="button-primary" value="Edit" />
454 454
           </td>
455 455
         </tr>
456 456
         <?php } ?>

+ 2
- 2
sections/requests/request.php View File

@@ -361,7 +361,7 @@ $encoded_artist = urlencode($encoded_artist);
361 361
                   <li><strong>Ratio:</strong> <span id="new_ratio"><?= Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded']) ?></span>
362 362
                   </li>
363 363
                 </ul>
364
-                <input type="button" id="button" value="Vote!" disabled="disabled" onclick="Vote();" />
364
+                <input type="button" id="button" value="Vote!" class="button-primary" disabled="disabled" onclick="Vote();" />
365 365
               </form>
366 366
             </td>
367 367
           </tr>
@@ -413,7 +413,7 @@ $encoded_artist = urlencode($encoded_artist);
413 413
                 </div>
414 414
                 <?php } ?>
415 415
                 <div class="submit_div">
416
-                  <input type="submit" value="Fill" />
416
+                  <input type="submit" class="button-primary" value="Fill" />
417 417
                 </div>
418 418
               </form>
419 419
             </td>

+ 1
- 1
sections/requests/requests.php View File

@@ -443,7 +443,7 @@ View::show_header($Title, 'requests');
443 443
             <table class="layout">
444 444
                 <tr>
445 445
                     <td colspan="2" class="center">
446
-                        <input type="submit" value="Search" />
446
+                        <input type="submit" class="button-primary" value="Search" />
447 447
                     </td>
448 448
                 </tr>
449 449
             </table>

+ 1
- 1
sections/top10/torrents.php View File

@@ -92,7 +92,7 @@ if (check_perms('site_advanced_top10')) {
92 92
                 </tr>
93 93
                 <tr>
94 94
                     <td colspan="2" class="center">
95
-                        <input type="submit" value="Search" />
95
+                        <input type="submit" class="button-primary" value="Search" />
96 96
                     </td>
97 97
                 </tr>
98 98
             </table>

+ 1
- 1
sections/torrents/details.php View File

@@ -851,7 +851,7 @@ if (count($Collages) > 0) {
851 851
     <div class="box">
852 852
       <table class="collage_table" id="collages">
853 853
         <tr class="colhead">
854
-          <td width="75%"><a href="#">&uarr;</a>&nbsp;This content is in <?=number_format(count($Collages))?> collection<?=((count($Collages) > 1) ? 's' : '')?><?=$SeeAll?>
854
+          <td width="85%"><a href="#">&uarr;</a>&nbsp;This content is in <?=number_format(count($Collages))?> collection<?=((count($Collages) > 1) ? 's' : '')?><?=$SeeAll?>
855 855
           </td>
856 856
           <td># torrents</td>
857 857
         </tr>

+ 78
- 78
sections/torrents/user.php View File

@@ -50,43 +50,43 @@ if (!empty($_GET['way']) && array_key_exists($_GET['way'], $Ways)) {
50 50
 $SearchWhere = [];
51 51
 if (!empty($_GET['format'])) {
52 52
     if (in_array($_GET['format'], $Formats)) {
53
-        $SearchWhere[] = "t.Format = '".db_string($_GET['format'])."'";
53
+        $SearchWhere[] = "t.`Format` = '".db_string($_GET['format'])."'";
54 54
     }
55 55
 }
56 56
 
57 57
 # Get release specifics
58 58
 if (isset($_GET['container'])
59 59
  && in_array($_GET['container'], $ENV-flatten($ENV->META->Formats))) {
60
-    $SearchWhere[] = "t.Container = '".db_string($_GET['container'])."'";
60
+    $SearchWhere[] = "t.`Container` = '".db_string($_GET['container'])."'";
61 61
 }
62 62
 
63 63
 if (isset($_GET['bitrate'])
64 64
  && in_array($_GET['bitrate'], $Bitrates)) {
65
-    $SearchWhere[] = "t.Encoding = '".db_string($_GET['bitrate'])."'";
65
+    $SearchWhere[] = "t.`Encoding` = '".db_string($_GET['bitrate'])."'";
66 66
 }
67 67
 
68 68
 if (isset($_GET['media'])
69 69
  && in_array($_GET['media'], $ENV-flatten($ENV->META->Platforms))) {
70
-    $SearchWhere[] = "t.Media = '".db_string($_GET['media'])."'";
70
+    $SearchWhere[] = "t.`Media` = '".db_string($_GET['media'])."'";
71 71
 }
72 72
 
73 73
 if (isset($_GET['codec'])
74 74
  && in_array($_GET['codec'], $ENV->META->Licenses)) {
75
-    $SearchWhere[] = "t.Codec = '".db_string($_GET['codec'])."'";
75
+    $SearchWhere[] = "t.`Codec` = '".db_string($_GET['codec'])."'";
76 76
 }
77 77
 
78 78
 if (isset($_GET['version'])) {
79
-    $SearchWhere[] = "t.Version = '".db_string($_GET['version'])."'";
79
+    $SearchWhere[] = "t.`Version` = '".db_string($_GET['version'])."'";
80 80
 }
81 81
 
82 82
 if (isset($_GET['resolution'])
83 83
  && in_array($_GET['resolution'], $ENV->flatten($ENV->META->Scopes))) {
84
-    $SearchWhere[] = "t.Resolution = '".db_string($_GET['resolution'])."'";
84
+    $SearchWhere[] = "t.`Resolution` = '".db_string($_GET['resolution'])."'";
85 85
 }
86 86
 
87 87
 if (isset($_GET['censored'])
88 88
  && in_array($_GET['censored'], array(1, 0))) {
89
-    $SearchWhere[] = "t.Censored = '".db_string($_GET['censored'])."'";
89
+    $SearchWhere[] = "t.`Censored` = '".db_string($_GET['censored'])."'";
90 90
 }
91 91
 
92 92
 if (!empty($_GET['categories'])) {
@@ -95,7 +95,7 @@ if (!empty($_GET['categories'])) {
95 95
         if (!is_number($Cat)) {
96 96
             error(0);
97 97
         }
98
-        $Cats[] = "tg.CategoryID = '".db_string($Cat)."'";
98
+        $Cats[] = "tg.`category_id` = '".db_string($Cat)."'";
99 99
     }
100 100
     $SearchWhere[] = '('.implode(' OR ', $Cats).')';
101 101
 }
@@ -120,9 +120,9 @@ if (!empty($_GET['tags'])) {
120 120
             if (empty($Tag)) {
121 121
                 continue;
122 122
             }
123
-            $TagList[] = "tg.TagList NOT RLIKE '[[:<:]]".db_string($Tag)."(:[^ ]+)?[[:>:]]'";
123
+            $TagList[] = "tg.`tag_list` NOT RLIKE '[[:<:]]".db_string($Tag)."(:[^ ]+)?[[:>:]]'";
124 124
         } else {
125
-            $TagList[] = "tg.TagList RLIKE '[[:<:]]".db_string($Tag)."(:[^ ]+)?[[:>:]]'";
125
+            $TagList[] = "tg.`tag_list` RLIKE '[[:<:]]".db_string($Tag)."(:[^ ]+)?[[:>:]]'";
126 126
         }
127 127
     }
128 128
 
@@ -151,74 +151,74 @@ switch ($_GET['type']) {
151 151
     if (!check_paranoia('snatched', $User['Paranoia'], $UserClass, $UserID)) {
152 152
         error(403);
153 153
     }
154
-    $Time = 'xs.tstamp';
155
-    $UserField = 'xs.uid';
154
+    $Time = 'xs.`tstamp`';
155
+    $UserField = 'xs.`uid`';
156 156
     $ExtraWhere = '';
157 157
     $From = "
158
-      xbt_snatched AS xs
159
-        JOIN torrents AS t ON t.ID = xs.fid";
158
+      `xbt_snatched` AS xs
159
+        JOIN `torrents` AS t ON t.`ID` = xs.`fid`";
160 160
     break;
161 161
 
162 162
   case 'seeding':
163 163
     if (!check_paranoia('seeding', $User['Paranoia'], $UserClass, $UserID)) {
164 164
         error(403);
165 165
     }
166
-    $Time = '(xfu.mtime - xfu.timespent)';
167
-    $UserField = 'xfu.uid';
166
+    $Time = '(xfu.`mtime` - xfu.`timespent`)';
167
+    $UserField = 'xfu.`uid`';
168 168
     $ExtraWhere = '
169
-      AND xfu.active = 1
170
-      AND xfu.Remaining = 0';
169
+      AND xfu.`active` = 1
170
+      AND xfu.`Remaining` = 0';
171 171
     $From = "
172
-      xbt_files_users AS xfu
173
-        JOIN torrents AS t ON t.ID = xfu.fid";
172
+      `xbt_files_users` AS xfu
173
+        JOIN `torrents` AS t ON t.`ID` = xfu.`fid`";
174 174
     break;
175 175
 
176 176
   case 'contest':
177
-    $Time = 'unix_timestamp(t.Time)';
178
-    $UserField = 't.UserID';
177
+    $Time = 'unix_timestamp(t.`Time`)';
178
+    $UserField = 't.`UserID`';
179 179
     $ExtraWhere = "
180
-      AND t.ID IN (
181
-        SELECT TorrentID
182
-        FROM library_contest
183
-        WHERE UserID = $UserID
180
+      AND t.`ID` IN (
181
+        SELECT `TorrentID`
182
+        FROM `library_contest`
183
+        WHERE `UserID` = $UserID
184 184
       )";
185
-    $From = 'torrents AS t';
185
+    $From = '`torrents` AS t';
186 186
     break;
187 187
 
188 188
   case 'leeching':
189 189
     if (!check_paranoia('leeching', $User['Paranoia'], $UserClass, $UserID)) {
190 190
         error(403);
191 191
     }
192
-    $Time = '(xfu.mtime - xfu.timespent)';
193
-    $UserField = 'xfu.uid';
192
+    $Time = '(xfu.`mtime` - xfu.`timespent`)';
193
+    $UserField = 'xfu.`uid`';
194 194
     $ExtraWhere = '
195
-      AND xfu.active = 1
196
-      AND xfu.Remaining > 0';
195
+      AND xfu.`active` = 1
196
+      AND xfu.`Remaining` > 0';
197 197
     $From = "
198
-      xbt_files_users AS xfu
199
-        JOIN torrents AS t ON t.ID = xfu.fid";
198
+      `xbt_files_users` AS xfu
199
+        JOIN `torrents` AS t ON t.`ID` = xfu.`fid`";
200 200
     break;
201 201
 
202 202
   case 'uploaded':
203 203
     if ((empty($_GET['filter']) || $_GET['filter'] !== 'perfectflac') && !check_paranoia('uploads', $User['Paranoia'], $UserClass, $UserID)) {
204 204
         error(403);
205 205
     }
206
-    $Time = 'unix_timestamp(t.Time)';
207
-    $UserField = 't.UserID';
206
+    $Time = 'unix_timestamp(t.`Time`)';
207
+    $UserField = 't.`UserID`';
208 208
     $ExtraWhere = '';
209
-    $From = "torrents AS t";
209
+    $From = "`torrents` AS t";
210 210
     break;
211 211
 
212 212
   case 'downloaded':
213 213
     if (!check_perms('site_view_torrent_snatchlist')) {
214 214
         error(403);
215 215
     }
216
-    $Time = 'unix_timestamp(ud.Time)';
217
-    $UserField = 'ud.UserID';
216
+    $Time = 'unix_timestamp(ud.`Time`)';
217
+    $UserField = 'ud.`UserID`';
218 218
     $ExtraWhere = '';
219 219
     $From = "
220
-      users_downloads AS ud
221
-        JOIN torrents AS t ON t.ID = ud.TorrentID";
220
+      `users_downloads` AS ud
221
+        JOIN `torrents` AS t ON t.`ID` = ud.`TorrentID`";
222 222
     break;
223 223
     
224 224
   default:
@@ -226,7 +226,7 @@ switch ($_GET['type']) {
226 226
 }
227 227
 
228 228
 if (empty($GroupBy)) {
229
-    $GroupBy = 't.ID';
229
+    $GroupBy = 't.`ID`';
230 230
 }
231 231
 
232 232
 if ((empty($_GET['search'])
@@ -234,13 +234,13 @@ if ((empty($_GET['search'])
234 234
     $SQL = "
235 235
       SELECT
236 236
         SQL_CALC_FOUND_ROWS
237
-        t.GroupID,
238
-        t.ID AS TorrentID,
237
+        t.`GroupID`,
238
+        t.`ID` AS TorrentID,
239 239
         $Time AS Time,
240
-        COALESCE(NULLIF(tg.Name, ''), NULLIF(tg.Title2, ''), tg.NameJP) AS Name,
241
-        tg.CategoryID
240
+        COALESCE(NULLIF(tg.`title`, ''), NULLIF(tg. subject, ''), tg.`object`) AS Name,
241
+        tg.`category_id`
242 242
       FROM $From
243
-        JOIN torrents_group AS tg ON tg.ID = t.GroupID
243
+        JOIN `torrents_group` AS tg ON tg.`id` = t.`GroupID`
244 244
       WHERE $UserField = '$UserID'
245 245
         $ExtraWhere
246 246
         $SearchWhere
@@ -249,38 +249,38 @@ if ((empty($_GET['search'])
249 249
       LIMIT $Limit";
250 250
 } else {
251 251
     $DB->query("
252
-      CREATE TEMPORARY TABLE temp_sections_torrents_user (
253
-        GroupID int(10) unsigned not null,
254
-        TorrentID int(10) unsigned not null,
255
-        Time int(12) unsigned not null,
256
-        CategoryID int(3) unsigned,
257
-        Seeders int(6) unsigned,
258
-        Leechers int(6) unsigned,
259
-        Snatched int(10) unsigned,
260
-        Name mediumtext,
261
-        Size bigint(12) unsigned,
262
-      PRIMARY KEY (TorrentID)) CHARSET=utf8");
252
+      CREATE TEMPORARY TABLE `temp_sections_torrents_user` (
253
+        `GroupID` int(10) unsigned not null,
254
+        `TorrentID` int(10) unsigned not null,
255
+        `Time` int(12) unsigned not null,
256
+        `CategoryID` int(3) unsigned,
257
+        `Seeders` int(6) unsigned,
258
+        `Leechers` int(6) unsigned,
259
+        `Snatched` int(10) unsigned,
260
+        `Name` mediumtext,
261
+        `Size` bigint(12) unsigned,
262
+      PRIMARY KEY (`TorrentID`)) CHARSET=utf8");
263 263
 
264 264
     $DB->query("
265
-      INSERT IGNORE INTO temp_sections_torrents_user
265
+      INSERT IGNORE INTO `temp_sections_torrents_user`
266 266
       SELECT
267
-        t.GroupID,
268
-        t.ID AS TorrentID,
267
+        t.`GroupID`,
268
+        t.`ID` AS TorrentID,
269 269
         $Time AS Time,
270
-        tg.CategoryID,
271
-        t.Seeders,
272
-        t.Leechers,
273
-        t.Snatched,
274
-        CONCAT_WS(' ', GROUP_CONCAT(ag.Name SEPARATOR ' '), ' ', COALESCE(NULLIF(tg.Name,''), NULLIF(tg.Title2,''), tg.NameJP), ' ', tg.Year, ' ') AS Name,
275
-        t.Size
270
+        tg.`category_id`,
271
+        t.`Seeders`,
272
+        t.`Leechers`,
273
+        t.`Snatched`,
274
+        CONCAT_WS(' ', GROUP_CONCAT(ag.`Name` SEPARATOR ' '), ' ', COALESCE(NULLIF(tg.`title`,''), NULLIF(tg.`subject`,''), tg.`object`), ' ', tg.`year`, ' ') AS Name,
275
+        t.`Size`
276 276
       FROM $From
277
-        JOIN torrents_group AS tg ON tg.ID = t.GroupID
278
-        LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID
279
-        LEFT JOIN artists_group AS ag ON ag.ArtistID = ta.ArtistID
277
+        JOIN `torrents_group` AS tg ON tg.`id` = t.`GroupID`
278
+        LEFT JOIN `torrents_artists` AS ta ON ta.`GroupID` = tg.`id`
279
+        LEFT JOIN `artists_group` AS ag ON ag.`ArtistID` = ta.`ArtistID`
280 280
       WHERE $UserField = '$UserID'
281 281
         $ExtraWhere
282 282
         $SearchWhere
283
-      GROUP BY TorrentID, Time");
283
+      GROUP BY `TorrentID`, `Time`");
284 284
 
285 285
     if (!empty($_GET['search']) && trim($_GET['search']) !== '') {
286 286
         $Words = array_unique(explode(' ', db_string($_GET['search'])));
@@ -289,15 +289,15 @@ if ((empty($_GET['search'])
289 289
     $SQL = "
290 290
       SELECT
291 291
         SQL_CALC_FOUND_ROWS
292
-        GroupID,
293
-        TorrentID,
294
-        Time,
295
-        CategoryID
296
-      FROM temp_sections_torrents_user";
292
+        `GroupID`,
293
+        `TorrentID`,
294
+        `Time`,
295
+        `CategoryID`
296
+      FROM `temp_sections_torrents_user`";
297 297
 
298 298
     if (!empty($Words)) {
299 299
         $SQL .= "
300
-          WHERE Name LIKE '%".implode("%' AND Name LIKE '%", $Words)."%'";
300
+          WHERE `Name` LIKE '%".implode("%' AND `Name` LIKE '%", $Words)."%'";
301 301
     }
302 302
 
303 303
     $SQL .= "
@@ -470,7 +470,7 @@ foreach ($Categories as $CatKey => $CatName) {
470 470
           <?= number_format($TorrentCount) ?>
471 471
           Results
472 472
         </span>
473
-        <input type="submit" value="Search" />
473
+        <input type="submit" class="button-primary" value="Search" />
474 474
       </div>
475 475
     </form>
476 476
   </div>

+ 21
- 17
sections/user/notify_edit.php View File

@@ -4,6 +4,7 @@
4 4
 if (!check_perms('site_torrents_notify')) {
5 5
     error(403);
6 6
 }
7
+
7 8
 View::show_header(
8 9
     'Manage notifications',
9 10
     'vendor/jquery.validate.min,form_validate'
@@ -21,22 +22,23 @@ View::show_header(
21 22
   <?php
22 23
 $DB->query("
23 24
   SELECT
24
-    ID,
25
-    Label,
26
-    Artists,
27
-    NewGroupsOnly,
28
-    Tags,
29
-    NotTags,
30
-    ReleaseTypes,
31
-    Categories,
32
-    Formats,
33
-    Encodings,
34
-    Media,
35
-    FromYear,
36
-    ToYear,
37
-    Users
38
-  FROM users_notify_filters
39
-  WHERE UserID=$LoggedUser[ID]");
25
+    `ID`,
26
+    `Label`,
27
+    `Artists`,
28
+    `NewGroupsOnly`,
29
+    `Tags`,
30
+    `NotTags`,
31
+    `ReleaseTypes`,
32
+    `Categories`,
33
+    `Formats`,
34
+    `Encodings`,
35
+    `Media`,
36
+    `FromYear`,
37
+    `ToYear`,
38
+    `Users`
39
+  FROM `users_notify_filters`
40
+  WHERE `UserID` = $LoggedUser[ID]
41
+");
40 42
 
41 43
 $NumFilters = $DB->record_count();
42 44
 
@@ -82,9 +84,11 @@ foreach ($Notifications as $N) { // $N stands for Notifications
82 84
     if ($N['FromYear'] === 0) {
83 85
         $N['FromYear'] = '';
84 86
     }
87
+
85 88
     if ($N['ToYear'] === 0) {
86 89
         $N['ToYear'] = '';
87 90
     }
91
+
88 92
     if ($NewFilter && $NumFilters > 0) {
89 93
         ?>
90 94
   <br><br>
@@ -207,7 +211,7 @@ foreach ($Notifications as $N) { // $N stands for Notifications
207 211
 
208 212
       <tr>
209 213
         <td colspan="2" class="center">
210
-          <input type="submit"
214
+          <input type="submit" class="button-primary"
211 215
             value="<?=($NewFilter ? 'Create' : 'Update')?>">
212 216
         </td>
213 217
       </tr>

+ 1
- 1
sections/wiki/wiki_browse.php View File

@@ -68,7 +68,7 @@ while (list($ID, $Title, $Date, $UserID) = $DB->next_record()) { ?>
68 68
       <input type="hidden" name="action" value="search" />
69 69
       <input type="hidden" name="nojump" value="1" />
70 70
       <input type="search" name="search" size="80" />
71
-      <input value="Search" type="submit" class="hidden" />
71
+      <input value="Search" type="submit" class="hidden button-primary" />
72 72
     </form>
73 73
     <br />
74 74
 

+ 25
- 16
static/styles/bookish/scss/colors.scss View File

@@ -29,17 +29,6 @@ $shadow: 2px 2px 10px -2px slategray;
29 29
  * Common elements
30 30
  */
31 31
 
32
-/* Alternating tables */
33
-/*
34
-#request_table .request:nth-of-type(even) {
35
-    background: white;
36
-}
37
-
38
-#request_table .request:nth-of-type(odd) {
39
-    background: whitesmoke;
40
-}
41
-*/
42
-
43 32
 /**
44 33
  * RGB color intensity border
45 34
  * For semi-transparent elements,
@@ -68,32 +57,52 @@ input[type="file"] {
68 57
  * Needs one unified error display
69 58
  * (torrent form, API keys use their own)
70 59
  */
60
+@mixin alertbar($bg) {
61
+    background: change-color($bg, $alpha: 0.25);
62
+    /* box-shadow: $shadow; */
63
+    text-align: center;
64
+    color: black;
65
+    font-weight: bold;
66
+    /* font-size: 0.95rem; */
67
+    width: 33%;
68
+    margin: 2em auto;
69
+    padding: 1rem;
70
+    border-radius: 4px;
71
+    border: 1px solid $bg;
72
+}
73
+
74
+/*
71 75
 @mixin alertbar($bg) {
72 76
     background: $bg;
73 77
     box-shadow: $shadow;
74 78
     text-align: center;
75 79
     color: black;
76 80
     font-weight: bold;
77
-    /* font-size: 0.95rem; */
81
+    /* font-size: 0.95rem; * /
78 82
     width: 33%;
79 83
     margin: 2em auto;
80 84
     padding: 1rem;
81 85
 }
86
+*/
82 87
 
83 88
 .alertbar {
84
-    @include alertbar($lb100);
89
+    @include alertbar(gold);
90
+    /* @include alertbar($lb100); */
85 91
 
86 92
     .warning {
87
-        background: #ffe0b2;
93
+        background: orange;
94
+        /* background: #ffe0b2; */
88 95
     }
89 96
 
90 97
     .error {
91
-        background: #ffcdd2;
98
+        background: red;
99
+        /* background: #ffcdd2; */
92 100
     }
93 101
 }
94 102
 
95 103
 .token_error {
96
-    @include alertbar(#ffcdd2);
104
+    @include alertbar(pink);
105
+    /* @include alertbar(#ffcdd2); */
97 106
 }
98 107
 
99 108
 .modbar a {

+ 0
- 5
static/styles/bookish/scss/layout.scss View File

@@ -308,8 +308,3 @@ ul .invitetree {
308 308
     }
309 309
     */
310 310
 }
311
-
312
-/* User and torrent stats */
313
-.chart {
314
-    max-height: 30rem;
315
-}

+ 5
- 0
static/styles/global/scss/layout.scss View File

@@ -207,3 +207,8 @@ img {
207 207
         height: 2rem;
208 208
     }
209 209
 }
210
+
211
+/* User and torrent stats */
212
+.chart {
213
+    max-height: 30rem;
214
+}

+ 8
- 3
static/styles/global/scss/skeleton-fixes.scss View File

@@ -85,7 +85,8 @@ table.torrent_search,
85 85
 /* request search */ table.torrent_requests,
86 86
 /* forum list */ table.forum_index,
87 87
 /* upload form */ table.torrent_form,
88
-/* new request? */ table.request_form,
88
+/* requests? */ table.request_form,
89
+/* new request */ form#request_form,
89 90
 /* forum thread */ table.new_thread,
90 91
 /* toolbox */ table.admin_tools,
91 92
 /* BP */ table.store_table,
@@ -94,6 +95,7 @@ table.torrent_search,
94 95
 /* login */ table.login_form,
95 96
 /* requests? */form.create_form,
96 97
 /* top10 */ form.search_form,
98
+/* edit collage */ table.collage_edit,
97 99
 /* start user management */
98 100
 table#user_info_box,
99 101
 table#warn_user_box,
@@ -102,8 +104,11 @@ table#user_privs_box,
102 104
 table#session_box,
103 105
 table#donation_box,
104 106
 table#donor_points_box,
105
-table#submit_box
106
-/* end user management */ {
107
+table#submit_box,
108
+/* end user management */
109
+/* notif filters */ form[name="notification"],
110
+/* wiki search */ table.wiki_browse,
111
+/* better.php */ table.better_list {
107 112
     th,
108 113
     td {
109 114
         border-bottom: 0 !important;

+ 53
- 0
templates/wiki/browse.html View File

@@ -0,0 +1,53 @@
1
+<section class="wiki_search">
2
+  <p>Search the wiki for user created tutorials and information.</p>
3
+
4
+  <form class="search_form" name="wiki" action="wiki.php" method="get">
5
+    <input type="hidden" name="action" value="search" />
6
+    <input type="hidden" name="nojump" value="1" />
7
+    <input type="search" name="search" size="80" />
8
+    <input value="Search" type="submit" class="hidden button-primary" />
9
+  </form>
10
+  <br />
11
+
12
+  <p>
13
+    Additionally, you can manually browse through the articles by their first letter.
14
+  </p>
15
+  
16
+  <span>
17
+    {% for letter in 'a'..'z' %}
18
+    <a href="wiki.php?action=browse&amp;letter={{ letter }}"
19
+      >{{ letter|upper }}</a
20
+    >&nbsp;&nbsp; {% endfor %}
21
+    <a href="wiki.php?action=browse&amp;letter=1">All</a>&nbsp;&nbsp;
22
+  </span>
23
+</section>
24
+
25
+<section class="wiki_results">
26
+  <div class="header">
27
+    <h2>{{ title }}</h2>
28
+  </div>
29
+  <div class="linkbox">
30
+    <a href="wiki.php?action=create" class="brackets">Create</a>
31
+  </div>
32
+
33
+
34
+  <table width="100%" style="margin-bottom: 10px">
35
+    <tr class="colhead">
36
+      <td>Article</td>
37
+      <td>Last updated on</td>
38
+      <td>Last edited by</td>
39
+    </tr>
40
+    {% for article in articles %}
41
+    <tr>
42
+      <td>
43
+        <a href="wiki.php?action=article&amp;id={{ article.ID }}"
44
+          >{{ article.Title }}</a
45
+        >
46
+      </td>
47
+      <td>{{ article.Date }}</td>
48
+      <td>{{ article.Author|user_url }}</td>
49
+    </tr>
50
+    {% endfor %}
51
+  </table>
52
+
53
+</section>

+ 0
- 49
templates/wiki/browse.twig View File

@@ -1,49 +0,0 @@
1
-{% macro letter_box(show_search = true) %}
2
-    <div class="box pad center">
3
-        {% if show_search %}
4
-        <p>Search the wiki for user created tutorials and information.</p>
5
-        <form class="search_form" name="wiki" action="wiki.php" method="get">
6
-            <input type="hidden" name="action" value="search" />
7
-            <input type="hidden" name="nojump" value="1" />
8
-            <input type="search" name="search" size="80" />
9
-            <input value="Search" type="submit" class="hidden" />
10
-        </form>
11
-        <br />
12
-        <p>Additionally, you can manually browse through the articles by their first letter.</p>
13
-        {% endif %}
14
-        <span>
15
-            {% for letter in 'a'..'z' %}
16
-            <a href="wiki.php?action=browse&amp;letter={{ letter }}">{{ letter|upper }}</a>&nbsp;&nbsp;
17
-            {% endfor %}
18
-            <a href="wiki.php?action=browse&amp;letter=1">All</a>&nbsp;&nbsp;
19
-        </span>
20
-    </div>
21
-{% endmacro %}
22
-
23
-<div class="thin">
24
-    <div class="header">
25
-        <h2>{{ title }}</h2>
26
-    </div>
27
-    <div class="linkbox">
28
-        <a href="wiki.php?action=create" class="brackets">Create</a>
29
-    </div>
30
-
31
-    {{ _self.letter_box() }}
32
-
33
-    <table width="100%" style="margin-bottom: 10px;">
34
-        <tr class="colhead">
35
-            <td>Article</td>
36
-            <td>Last updated on</td>
37
-            <td>Last edited by</td>
38
-        </tr>
39
-        {% for article in articles %}
40
-        <tr>
41
-            <td><a href="wiki.php?action=article&amp;id={{ article.ID }}">{{ article.Title }}</a></td>
42
-            <td>{{ article.Date }}</td>
43
-            <td>{{ article.Author|user_url }}</td>
44
-        </tr>
45
-        {% endfor %}
46
-    </table>
47
-
48
-    {{ _self.letter_box(false) }}
49
-</div>

Loading…
Cancel
Save