Browse Source

Start systematically going through DB schema

pjc 5 years ago
parent
commit
2c05983307

+ 20
- 20
classes/torrents.class.php View File

@@ -3,8 +3,8 @@
3 3
 class Torrents
4 4
 {
5 5
     const FILELIST_DELIM = 0xF7; // Hex for ÷ Must be the same as phrase_boundary in sphinx.conf!
6
-  const SNATCHED_UPDATE_INTERVAL = 3600; // How often we want to update users' snatch lists
7
-  const SNATCHED_UPDATE_AFTERDL = 300; // How long after a torrent download we want to update a user's snatch lists
6
+    const SNATCHED_UPDATE_INTERVAL = 3600; // How often we want to update users' snatch lists
7
+    const SNATCHED_UPDATE_AFTERDL = 300; // How long after a torrent download we want to update a user's snatch lists
8 8
 
9 9
   /**
10 10
    * Function to get data and torrents for an array of GroupIDs. Order of keys doesn't matter
@@ -181,23 +181,23 @@ class Torrents
181 181
     public static function array_group(array &$Group)
182 182
     {
183 183
         return array(
184
-      'GroupID' => $Group['ID'],
185
-      'GroupName' => $Group['Name'],
186
-      'GroupNameRJ' => $Group['NameRJ'],
187
-      'GroupNameJP' => $Group['NameJP'],
188
-      'GroupYear' => $Group['Year'],
189
-      'GroupCategoryID' => $Group['CategoryID'],
190
-      'GroupCatalogueNumber' => $Group['CatalogueNumber'],
191
-      'GroupPages' => $Group['Pages'],
192
-      'GroupDLSiteID' => ($Group['DLSiteID'] ?? ''),
193
-      'GroupStudio' => $Group['Studio'],
194
-      'GroupSeries' => $Group['Series'],
195
-      'GroupFlags' => ($Group['Flags'] ?? ''),
196
-      'TagList' => $Group['TagList'],
197
-      'WikiImage' => $Group['WikiImage'],
198
-      'Torrents' => $Group['Torrents'],
199
-      'Artists' => $Group['Artists']
200
-    );
184
+          'GroupID' => $Group['ID'],
185
+          'GroupName' => $Group['Name'],
186
+          'GroupNameRJ' => $Group['NameRJ'],
187
+          'GroupNameJP' => $Group['NameJP'],
188
+          'GroupYear' => $Group['Year'],
189
+          'GroupCategoryID' => $Group['CategoryID'],
190
+          'GroupCatalogueNumber' => $Group['CatalogueNumber'],
191
+          'GroupPages' => $Group['Pages'],
192
+          'GroupDLSiteID' => ($Group['DLSiteID'] ?? ''),
193
+          'GroupStudio' => $Group['Studio'],
194
+          'GroupSeries' => $Group['Series'],
195
+          'GroupFlags' => ($Group['Flags'] ?? ''),
196
+          'TagList' => $Group['TagList'],
197
+          'WikiImage' => $Group['WikiImage'],
198
+          'Torrents' => $Group['Torrents'],
199
+          'Artists' => $Group['Artists']
200
+        );
201 201
     }
202 202
 
203 203
     /**
@@ -771,7 +771,7 @@ class Torrents
771 771
             G::$Cache->delete_value("torrent_download_$TorrentID");
772 772
             Misc::write_log((G::$LoggedUser['Username']??'System')." marked torrent $TorrentID freeleech type $FreeLeechType");
773 773
             Torrents::write_group_log($GroupID, $TorrentID, (G::$LoggedUser['ID']??0), "marked as freeleech type $FreeLeechType", 0);
774
-            if ($Announce && ($FreeLeechType == 1 || $FreeLeechType == 3)) {
774
+            if ($Announce && ($FreeLeechType === 1 || $FreeLeechType === 3)) {
775 775
                 send_irc('PRIVMSG '.BOT_ANNOUNCE_CHAN.' FREELEECH - '.site_url()."torrents.php?id=$GroupID / ".site_url()."torrents.php?action=download&id=$TorrentID");
776 776
             }
777 777
         }

+ 2
- 1
classes/torrentsdl.class.php View File

@@ -38,7 +38,8 @@ class TorrentsDL
38 38
         {
39 39
             return (is_array($Ann)) ? array_map('add_passkey', $Ann) : $Ann."/".G::$LoggedUser['torrent_pass']."/announce";
40 40
         }
41
-        $this->AnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array(array_map('add_passkey', ANNOUNCE_URLS[0]), ANNOUNCE_URLS[1]);
41
+        $this->AnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array_map('add_passkey', ANNOUNCE_URLS[0]);
42
+        #$this->AnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array(array_map('add_passkey', ANNOUNCE_URLS[0]), ANNOUNCE_URLS[1]);
42 43
         #$this->AnnounceList = (sizeof(ANNOUNCE_URLS) == 1 && sizeof(ANNOUNCE_URLS[0]) == 1) ? [] : array_map('add_passkey', ANNOUNCE_URLS);
43 44
         $this->Zip = new Zip(Misc::file_string($Title));
44 45
     }

+ 264
- 170
gazelle.sql
File diff suppressed because it is too large
View File


+ 3
- 3
sections/donate/donate.php View File

@@ -52,7 +52,7 @@ View::show_header('Donate');
52 52
   <div class="box pad donation_info">
53 53
     <p>
54 54
       <?= SITE_NAME ?> accepts donations on a tactful array of platforms.
55
-      We also accept tax-deductible donations on behalf of the
55
+      We also accept <strong>tax-deductible donations</strong> on behalf of the
56 56
       <a href="https://www.boslab.org/donate" target="_blank">Boston Open Science Laboratory (BosLab)</a>,
57 57
       a registered 501c3.
58 58
       Please use the memo field on BosLab's PayPal form to credit your <?= SITE_NAME ?> account.
@@ -83,8 +83,8 @@ View::show_header('Donate');
83 83
       </ul>
84 84
 
85 85
     <p>
86
-      I also accept private donations of cash and cash equivalents, including Bitcoin and other cryptocurrencies.
87
-      Besides gift transactions sent to my personal PayPal account, I'll also accept USPS money orders in the mail.
86
+      I also accept private donations of cash and cash equivalents, including <strong>Bitcoin</strong> and other cryptocurrencies.
87
+      Besides gift transactions sent to my personal <strong>PayPal</strong> account, I'll also accept <strong>USPS money orders</strong> in the mail.
88 88
       I can generate unique cryptocurrency addresses for donations in Bitcoin, Litecoin, Curecoin, and Namecoin.
89 89
       Please use <a href="https://pgp.mit.edu/pks/lookup?op=get&search=0x760EBED7CFE266D7" target="_blank">GPG key 760EBED7CFE266D7</a> if you desire.
90 90
     </p>

+ 2
- 1
sections/torrents/download.php View File

@@ -188,7 +188,8 @@ function add_passkey($ann)
188 188
     return (is_array($ann)) ? array_map("add_passkey", $ann) : $ann."/".$TorrentPass."/announce";
189 189
 }
190 190
 $UserAnnounceURL = ANNOUNCE_URLS[0][0]."/".$TorrentPass."/announce";
191
-$UserAnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array(array_map('add_passkey', ANNOUNCE_URLS[0]), ANNOUNCE_URLS[1]);
191
+$UserAnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array_map('add_passkey', ANNOUNCE_URLS[0]);
192
+#$UserAnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array(array_map('add_passkey', ANNOUNCE_URLS[0]), ANNOUNCE_URLS[1]);
192 193
 #$UserAnnounceList = (sizeof(ANNOUNCE_URLS) == 1 && sizeof(ANNOUNCE_URLS[0]) == 1) ? [] : array_map("add_passkey", ANNOUNCE_URLS);
193 194
 
194 195
 echo TorrentsDL::get_file($Contents, $UserAnnounceURL, $UserAnnounceList);

+ 63
- 63
sections/user/notify_handle.php View File

@@ -1,6 +1,7 @@
1
-<?
1
+<?php
2
+
2 3
 if (!check_perms('site_torrents_notify')) {
3
-  error(403);
4
+    error(403);
4 5
 }
5 6
 authorize();
6 7
 
@@ -14,102 +15,102 @@ $Users = '';
14 15
 $HasFilter = false;
15 16
 
16 17
 if ($_POST['formid'] && is_number($_POST['formid'])) {
17
-  $FormID = $_POST['formid'];
18
+    $FormID = $_POST['formid'];
18 19
 }
19 20
 
20 21
 if ($_POST['artists'.$FormID]) {
21
-  $Artists = explode(',', $_POST['artists'.$FormID]);
22
-  $ParsedArtists = [];
23
-  foreach ($Artists as $Artist) {
24
-    if (trim($Artist) != '') {
25
-      $ParsedArtists[] = db_string(trim($Artist));
22
+    $Artists = explode(',', $_POST['artists'.$FormID]);
23
+    $ParsedArtists = [];
24
+    foreach ($Artists as $Artist) {
25
+        if (trim($Artist) !== '') {
26
+            $ParsedArtists[] = db_string(trim($Artist));
27
+        }
28
+    }
29
+    if (count($ParsedArtists) > 0) {
30
+        $ArtistList = '|'.implode('|', $ParsedArtists).'|';
31
+        $HasFilter = true;
26 32
     }
27
-  }
28
-  if (count($ParsedArtists) > 0) {
29
-    $ArtistList = '|'.implode('|', $ParsedArtists).'|';
30
-    $HasFilter = true;
31
-  }
32 33
 }
33 34
 
34 35
 if ($_POST['excludeva'.$FormID]) {
35
-  $ExcludeVA = '1';
36
-  $HasFilter = true;
36
+    $ExcludeVA = '1';
37
+    $HasFilter = true;
37 38
 } else {
38
-  $ExcludeVA = '0';
39
+    $ExcludeVA = '0';
39 40
 }
40 41
 
41 42
 if ($_POST['newgroupsonly'.$FormID]) {
42
-  $NewGroupsOnly = '1';
43
-  $HasFilter = true;
43
+    $NewGroupsOnly = '1';
44
+    $HasFilter = true;
44 45
 } else {
45
-  $NewGroupsOnly = '0';
46
+    $NewGroupsOnly = '0';
46 47
 }
47 48
 
48 49
 if ($_POST['tags'.$FormID]) {
49
-  $TagList = '|';
50
-  $Tags = explode(',', $_POST['tags'.$FormID]);
51
-  foreach ($Tags as $Tag) {
52
-    $TagList.=db_string(trim($Tag)).'|';
53
-  }
54
-  $HasFilter = true;
50
+    $TagList = '|';
51
+    $Tags = explode(',', $_POST['tags'.$FormID]);
52
+    foreach ($Tags as $Tag) {
53
+        $TagList.=db_string(trim($Tag)).'|';
54
+    }
55
+    $HasFilter = true;
55 56
 }
56 57
 
57 58
 if ($_POST['nottags'.$FormID]) {
58
-  $NotTagList = '|';
59
-  $Tags = explode(',', $_POST['nottags'.$FormID]);
60
-  foreach ($Tags as $Tag) {
61
-    $NotTagList.=db_string(trim($Tag)).'|';
62
-  }
63
-  $HasFilter = true;
59
+    $NotTagList = '|';
60
+    $Tags = explode(',', $_POST['nottags'.$FormID]);
61
+    foreach ($Tags as $Tag) {
62
+        $NotTagList.=db_string(trim($Tag)).'|';
63
+    }
64
+    $HasFilter = true;
64 65
 }
65 66
 
66 67
 if ($_POST['categories'.$FormID]) {
67
-  $CategoryList = '|';
68
-  foreach ($_POST['categories'.$FormID] as $Category) {
69
-    $CategoryList.=db_string(trim($Category)).'|';
70
-  }
71
-  $HasFilter = true;
68
+    $CategoryList = '|';
69
+    foreach ($_POST['categories'.$FormID] as $Category) {
70
+        $CategoryList.=db_string(trim($Category)).'|';
71
+    }
72
+    $HasFilter = true;
72 73
 }
73 74
 
74 75
 if ($_POST['media'.$FormID]) {
75
-  $MediaList = '|';
76
-  foreach ($_POST['media'.$FormID] as $Medium) {
77
-    $MediaList.=db_string(trim($Medium)).'|';
78
-  }
79
-  $HasFilter = true;
76
+    $MediaList = '|';
77
+    foreach ($_POST['media'.$FormID] as $Medium) {
78
+        $MediaList.=db_string(trim($Medium)).'|';
79
+    }
80
+    $HasFilter = true;
80 81
 }
81 82
 
82 83
 if ($_POST['users'.$FormID]) {
83
-  $Usernames = explode(',', $_POST['users'.$FormID]);
84
-  $EscapedUsernames = [];
85
-  foreach ($Usernames as $Username) {
86
-    $EscapedUsernames[] = db_string(trim($Username));;
87
-  }
84
+    $Usernames = explode(',', $_POST['users'.$FormID]);
85
+    $EscapedUsernames = [];
86
+    foreach ($Usernames as $Username) {
87
+        $EscapedUsernames[] = db_string(trim($Username));
88
+    }
88 89
 
89
-  $DB->query("
90
+    $DB->query("
90 91
     SELECT ID, Paranoia
91 92
     FROM users_main
92 93
     WHERE Username IN ('" . implode("', '", $EscapedUsernames) . "')
93 94
       AND ID != $LoggedUser[ID]");
94
-  while (list($UserID, $Paranoia) = $DB->next_record()) {
95
-    $Paranoia = unserialize($Paranoia);
96
-    if (!in_array('notifications', $Paranoia)) {
97
-      $Users .= '|' . $UserID . '|';
98
-      $HasFilter = true;
95
+    while (list($UserID, $Paranoia) = $DB->next_record()) {
96
+        $Paranoia = unserialize($Paranoia);
97
+        if (!in_array('notifications', $Paranoia)) {
98
+            $Users .= '|' . $UserID . '|';
99
+            $HasFilter = true;
100
+        }
99 101
     }
100
-  }
101 102
 }
102 103
 
103 104
 if (!$HasFilter) {
104
-  $Err = 'You must add at least one criterion to filter by';
105
+    $Err = 'You must add at least one criterion to filter by';
105 106
 } elseif (!$_POST['label'.$FormID] && !$_POST['id'.$FormID]) {
106
-  $Err = 'You must add a label for the filter set';
107
+    $Err = 'You must add a label for the filter set';
107 108
 }
108 109
 
109 110
 if ($Err) {
110
-  error($Err);
111
-  header('Location: user.php?action=notify');
112
-  die();
111
+    error($Err);
112
+    header('Location: user.php?action=notify');
113
+    die();
113 114
 }
114 115
 
115 116
 $ArtistList = str_replace('||', '|', $ArtistList);
@@ -118,7 +119,7 @@ $NotTagList = str_replace('||', '|', $NotTagList);
118 119
 $Users = str_replace('||', '|', $Users);
119 120
 
120 121
 if ($_POST['id'.$FormID] && is_number($_POST['id'.$FormID])) {
121
-  $DB->query("
122
+    $DB->query("
122 123
     UPDATE users_notify_filters
123 124
     SET
124 125
       Artists='$ArtistList',
@@ -132,7 +133,7 @@ if ($_POST['id'.$FormID] && is_number($_POST['id'.$FormID])) {
132 133
     WHERE ID='".$_POST['id'.$FormID]."'
133 134
       AND UserID='$LoggedUser[ID]'");
134 135
 } else {
135
-  $DB->query("
136
+    $DB->query("
136 137
     INSERT INTO users_notify_filters
137 138
       (UserID, Label, Artists, ExcludeVA, NewGroupsOnly, Tags, NotTags, Categories, Media, Users)
138 139
     VALUES
@@ -140,8 +141,7 @@ if ($_POST['id'.$FormID] && is_number($_POST['id'.$FormID])) {
140 141
 }
141 142
 
142 143
 $Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
143
-if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) !== false && $Notify['ID'] == $_POST['id'.$FormID]) {
144
-  $Cache->delete_value('notify_artists_'.$LoggedUser['ID']);
144
+if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) !== false && $Notify['ID'] === $_POST['id'.$FormID]) {
145
+    $Cache->delete_value('notify_artists_'.$LoggedUser['ID']);
145 146
 }
146 147
 header('Location: user.php?action=notify');
147
-?>

Loading…
Cancel
Save