Browse Source

Start systematically going through DB schema

pjc 5 years ago
parent
commit
2c05983307

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

3
 class Torrents
3
 class Torrents
4
 {
4
 {
5
     const FILELIST_DELIM = 0xF7; // Hex for ÷ Must be the same as phrase_boundary in sphinx.conf!
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
    * Function to get data and torrents for an array of GroupIDs. Order of keys doesn't matter
10
    * Function to get data and torrents for an array of GroupIDs. Order of keys doesn't matter
181
     public static function array_group(array &$Group)
181
     public static function array_group(array &$Group)
182
     {
182
     {
183
         return array(
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
             G::$Cache->delete_value("torrent_download_$TorrentID");
771
             G::$Cache->delete_value("torrent_download_$TorrentID");
772
             Misc::write_log((G::$LoggedUser['Username']??'System')." marked torrent $TorrentID freeleech type $FreeLeechType");
772
             Misc::write_log((G::$LoggedUser['Username']??'System')." marked torrent $TorrentID freeleech type $FreeLeechType");
773
             Torrents::write_group_log($GroupID, $TorrentID, (G::$LoggedUser['ID']??0), "marked as freeleech type $FreeLeechType", 0);
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
                 send_irc('PRIVMSG '.BOT_ANNOUNCE_CHAN.' FREELEECH - '.site_url()."torrents.php?id=$GroupID / ".site_url()."torrents.php?action=download&id=$TorrentID");
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
         {
38
         {
39
             return (is_array($Ann)) ? array_map('add_passkey', $Ann) : $Ann."/".G::$LoggedUser['torrent_pass']."/announce";
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
         #$this->AnnounceList = (sizeof(ANNOUNCE_URLS) == 1 && sizeof(ANNOUNCE_URLS[0]) == 1) ? [] : array_map('add_passkey', ANNOUNCE_URLS);
43
         #$this->AnnounceList = (sizeof(ANNOUNCE_URLS) == 1 && sizeof(ANNOUNCE_URLS[0]) == 1) ? [] : array_map('add_passkey', ANNOUNCE_URLS);
43
         $this->Zip = new Zip(Misc::file_string($Title));
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
   <div class="box pad donation_info">
52
   <div class="box pad donation_info">
53
     <p>
53
     <p>
54
       <?= SITE_NAME ?> accepts donations on a tactful array of platforms.
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
       <a href="https://www.boslab.org/donate" target="_blank">Boston Open Science Laboratory (BosLab)</a>,
56
       <a href="https://www.boslab.org/donate" target="_blank">Boston Open Science Laboratory (BosLab)</a>,
57
       a registered 501c3.
57
       a registered 501c3.
58
       Please use the memo field on BosLab's PayPal form to credit your <?= SITE_NAME ?> account.
58
       Please use the memo field on BosLab's PayPal form to credit your <?= SITE_NAME ?> account.
83
       </ul>
83
       </ul>
84
 
84
 
85
     <p>
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
       I can generate unique cryptocurrency addresses for donations in Bitcoin, Litecoin, Curecoin, and Namecoin.
88
       I can generate unique cryptocurrency addresses for donations in Bitcoin, Litecoin, Curecoin, and Namecoin.
89
       Please use <a href="https://pgp.mit.edu/pks/lookup?op=get&search=0x760EBED7CFE266D7" target="_blank">GPG key 760EBED7CFE266D7</a> if you desire.
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
     </p>
90
     </p>

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

188
     return (is_array($ann)) ? array_map("add_passkey", $ann) : $ann."/".$TorrentPass."/announce";
188
     return (is_array($ann)) ? array_map("add_passkey", $ann) : $ann."/".$TorrentPass."/announce";
189
 }
189
 }
190
 $UserAnnounceURL = ANNOUNCE_URLS[0][0]."/".$TorrentPass."/announce";
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
 #$UserAnnounceList = (sizeof(ANNOUNCE_URLS) == 1 && sizeof(ANNOUNCE_URLS[0]) == 1) ? [] : array_map("add_passkey", ANNOUNCE_URLS);
193
 #$UserAnnounceList = (sizeof(ANNOUNCE_URLS) == 1 && sizeof(ANNOUNCE_URLS[0]) == 1) ? [] : array_map("add_passkey", ANNOUNCE_URLS);
193
 
194
 
194
 echo TorrentsDL::get_file($Contents, $UserAnnounceURL, $UserAnnounceList);
195
 echo TorrentsDL::get_file($Contents, $UserAnnounceURL, $UserAnnounceList);

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

1
-<?
1
+<?php
2
+
2
 if (!check_perms('site_torrents_notify')) {
3
 if (!check_perms('site_torrents_notify')) {
3
-  error(403);
4
+    error(403);
4
 }
5
 }
5
 authorize();
6
 authorize();
6
 
7
 
14
 $HasFilter = false;
15
 $HasFilter = false;
15
 
16
 
16
 if ($_POST['formid'] && is_number($_POST['formid'])) {
17
 if ($_POST['formid'] && is_number($_POST['formid'])) {
17
-  $FormID = $_POST['formid'];
18
+    $FormID = $_POST['formid'];
18
 }
19
 }
19
 
20
 
20
 if ($_POST['artists'.$FormID]) {
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
 if ($_POST['excludeva'.$FormID]) {
35
 if ($_POST['excludeva'.$FormID]) {
35
-  $ExcludeVA = '1';
36
-  $HasFilter = true;
36
+    $ExcludeVA = '1';
37
+    $HasFilter = true;
37
 } else {
38
 } else {
38
-  $ExcludeVA = '0';
39
+    $ExcludeVA = '0';
39
 }
40
 }
40
 
41
 
41
 if ($_POST['newgroupsonly'.$FormID]) {
42
 if ($_POST['newgroupsonly'.$FormID]) {
42
-  $NewGroupsOnly = '1';
43
-  $HasFilter = true;
43
+    $NewGroupsOnly = '1';
44
+    $HasFilter = true;
44
 } else {
45
 } else {
45
-  $NewGroupsOnly = '0';
46
+    $NewGroupsOnly = '0';
46
 }
47
 }
47
 
48
 
48
 if ($_POST['tags'.$FormID]) {
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
 if ($_POST['nottags'.$FormID]) {
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
 if ($_POST['categories'.$FormID]) {
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
 if ($_POST['media'.$FormID]) {
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
 if ($_POST['users'.$FormID]) {
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
     SELECT ID, Paranoia
91
     SELECT ID, Paranoia
91
     FROM users_main
92
     FROM users_main
92
     WHERE Username IN ('" . implode("', '", $EscapedUsernames) . "')
93
     WHERE Username IN ('" . implode("', '", $EscapedUsernames) . "')
93
       AND ID != $LoggedUser[ID]");
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
 if (!$HasFilter) {
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
 } elseif (!$_POST['label'.$FormID] && !$_POST['id'.$FormID]) {
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
 if ($Err) {
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
 $ArtistList = str_replace('||', '|', $ArtistList);
116
 $ArtistList = str_replace('||', '|', $ArtistList);
118
 $Users = str_replace('||', '|', $Users);
119
 $Users = str_replace('||', '|', $Users);
119
 
120
 
120
 if ($_POST['id'.$FormID] && is_number($_POST['id'.$FormID])) {
121
 if ($_POST['id'.$FormID] && is_number($_POST['id'.$FormID])) {
121
-  $DB->query("
122
+    $DB->query("
122
     UPDATE users_notify_filters
123
     UPDATE users_notify_filters
123
     SET
124
     SET
124
       Artists='$ArtistList',
125
       Artists='$ArtistList',
132
     WHERE ID='".$_POST['id'.$FormID]."'
133
     WHERE ID='".$_POST['id'.$FormID]."'
133
       AND UserID='$LoggedUser[ID]'");
134
       AND UserID='$LoggedUser[ID]'");
134
 } else {
135
 } else {
135
-  $DB->query("
136
+    $DB->query("
136
     INSERT INTO users_notify_filters
137
     INSERT INTO users_notify_filters
137
       (UserID, Label, Artists, ExcludeVA, NewGroupsOnly, Tags, NotTags, Categories, Media, Users)
138
       (UserID, Label, Artists, ExcludeVA, NewGroupsOnly, Tags, NotTags, Categories, Media, Users)
138
     VALUES
139
     VALUES
140
 }
141
 }
141
 
142
 
142
 $Cache->delete_value('notify_filters_'.$LoggedUser['ID']);
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
 header('Location: user.php?action=notify');
147
 header('Location: user.php?action=notify');
147
-?>

Loading…
Cancel
Save