Browse Source

Remove .txt torrent download option

ISPs can't see filenames through TLS. This option is useless in a
codebase that forces HTTPS, and only confuses users.
spaghetti 8 years ago
parent
commit
69c165ee75

+ 3
- 7
classes/torrentsdl.class.php View File

86
   public function add_file(&$TorrentData, $Info, $FolderName = '') {
86
   public function add_file(&$TorrentData, $Info, $FolderName = '') {
87
     $FolderName = Misc::file_string($FolderName);
87
     $FolderName = Misc::file_string($FolderName);
88
     $MaxPathLength = $FolderName ? (self::MaxPathLength - strlen($FolderName) - 1) : self::MaxPathLength;
88
     $MaxPathLength = $FolderName ? (self::MaxPathLength - strlen($FolderName) - 1) : self::MaxPathLength;
89
-    $FileName = self::construct_file_name($Info['Artist'], $Info['Name'], $Info['Year'], $Info['Media'], $Info['Format'], $Info['Encoding'], $Info['TorrentID'], false, $MaxPathLength);
89
+    $FileName = self::construct_file_name($Info['Artist'], $Info['Name'], $Info['Year'], $Info['Media'], $Info['Format'], $Info['Encoding'], $Info['TorrentID'], $MaxPathLength);
90
     $this->Size += $Info['Size'];
90
     $this->Size += $Info['Size'];
91
     $this->NumAdded++;
91
     $this->NumAdded++;
92
     $this->Zip->add_file(self::get_file($TorrentData, $this->AnnounceURL, $this->AnnounceList), ($FolderName ? "$FolderName/" : "") . $FileName);
92
     $this->Zip->add_file(self::get_file($TorrentData, $this->AnnounceURL, $this->AnnounceList), ($FolderName ? "$FolderName/" : "") . $FileName);
176
    *
176
    *
177
    * @params most input variables are self-explanatory
177
    * @params most input variables are self-explanatory
178
    * @param int $TorrentID if given, append "-TorrentID" to torrent name
178
    * @param int $TorrentID if given, append "-TorrentID" to torrent name
179
-   * @param bool $Txt whether to use .txt or .torrent as file extension
180
    * @param int $MaxLength maximum file name length
179
    * @param int $MaxLength maximum file name length
181
    * @return file name with at most $MaxLength characters
180
    * @return file name with at most $MaxLength characters
182
    */
181
    */
183
-  public static function construct_file_name($Artist, $Album, $Year, $Media, $Format, $Encoding, $TorrentID = false, $Txt = false, $MaxLength = self::MaxPathLength) {
184
-    $MaxLength -= ($Txt ? 4 : 8);
182
+  public static function construct_file_name($Artist, $Album, $Year, $Media, $Format, $Encoding, $TorrentID = false, $MaxLength = self::MaxPathLength) {
183
+    $MaxLength -= 8; // ".torrent"
185
     if ($TorrentID !== false) {
184
     if ($TorrentID !== false) {
186
       $MaxLength -= (strlen($TorrentID) + 1);
185
       $MaxLength -= (strlen($TorrentID) + 1);
187
     }
186
     }
216
     if ($TorrentID !== false) {
215
     if ($TorrentID !== false) {
217
       $TorrentName .= "-$TorrentID";
216
       $TorrentName .= "-$TorrentID";
218
     }
217
     }
219
-    if ($Txt) {
220
-      return "$TorrentName.txt";
221
-    }
222
     return "$TorrentName.torrent";
218
     return "$TorrentName.torrent";
223
   }
219
   }
224
 
220
 

+ 31
- 35
classes/users.class.php View File

18
       $Classes = G::$DB->to_array('ID');
18
       $Classes = G::$DB->to_array('ID');
19
       $ClassLevels = G::$DB->to_array('Level');
19
       $ClassLevels = G::$DB->to_array('Level');
20
       G::$DB->set_query_id($QueryID);
20
       G::$DB->set_query_id($QueryID);
21
-      G::$Cache->cache_value('classes', array($Classes, $ClassLevels), 0);
21
+      G::$Cache->cache_value('classes', [$Classes, $ClassLevels], 0);
22
     }
22
     }
23
     $Debug->set_flag('Loaded permissions');
23
     $Debug->set_flag('Loaded permissions');
24
 
24
 
25
-    return array($Classes, $ClassLevels);
25
+    return [$Classes, $ClassLevels];
26
   }
26
   }
27
 
27
 
28
 
28
 
77
         GROUP BY m.ID");
77
         GROUP BY m.ID");
78
 
78
 
79
       if (!G::$DB->has_results()) { // Deleted user, maybe?
79
       if (!G::$DB->has_results()) { // Deleted user, maybe?
80
-        $UserInfo = array(
81
-            'ID' => $UserID,
82
-            'Username' => '',
83
-            'PermissionID' => 0,
84
-            'Paranoia' => array(),
85
-            'Artist' => false,
86
-            'Donor' => false,
87
-            'Warned' => NULL,
88
-            'Avatar' => '',
89
-            'Enabled' => 0,
90
-            'Title' => '',
91
-            'CatchupTime' => 0,
92
-            'Visible' => '1',
93
-            'Levels' => '',
94
-            'Class' => 0);
80
+        $UserInfo = [
81
+          'ID'           => $UserID,
82
+          'Username'     => '',
83
+          'PermissionID' => 0,
84
+          'Paranoia'     => [],
85
+          'Artist'       => false,
86
+          'Donor'        => false,
87
+          'Warned'       => NULL,
88
+          'Avatar'       => '',
89
+          'Enabled'      => 0,
90
+          'Title'        => '',
91
+          'CatchupTime'  => 0,
92
+          'Visible'      => '1',
93
+          'Levels'       => '',
94
+          'Class'        => 0
95
+        ];
95
       } else {
96
       } else {
96
-        $UserInfo = G::$DB->next_record(MYSQLI_ASSOC, array('Paranoia', 'Title'));
97
+        $UserInfo = G::$DB->next_record(MYSQLI_ASSOC, ['Paranoia', 'Title']);
97
         $UserInfo['CatchupTime'] = strtotime($UserInfo['CatchupTime']);
98
         $UserInfo['CatchupTime'] = strtotime($UserInfo['CatchupTime']);
98
         if (!is_array($UserInfo['Paranoia'])) {
99
         if (!is_array($UserInfo['Paranoia'])) {
99
           $UserInfo['Paranoia'] = json_decode($UserInfo['Paranoia'], true);
100
           $UserInfo['Paranoia'] = json_decode($UserInfo['Paranoia'], true);
100
         }
101
         }
101
         if (!$UserInfo['Paranoia']) {
102
         if (!$UserInfo['Paranoia']) {
102
-          $UserInfo['Paranoia'] = array();
103
+          $UserInfo['Paranoia'] = [];
103
         }
104
         }
104
         $UserInfo['Class'] = $Classes[$UserInfo['PermissionID']]['Level'];
105
         $UserInfo['Class'] = $Classes[$UserInfo['PermissionID']]['Level'];
105
       }
106
       }
111
       if (!empty($UserInfo['Levels'])) {
112
       if (!empty($UserInfo['Levels'])) {
112
         $UserInfo['ExtraClasses'] = array_fill_keys(explode(',', $UserInfo['Levels']), 1);
113
         $UserInfo['ExtraClasses'] = array_fill_keys(explode(',', $UserInfo['Levels']), 1);
113
       } else {
114
       } else {
114
-        $UserInfo['ExtraClasses'] = array();
115
+        $UserInfo['ExtraClasses'] = [];
115
       }
116
       }
116
       unset($UserInfo['Levels']);
117
       unset($UserInfo['Levels']);
117
       $EffectiveClass = $UserInfo['Class'];
118
       $EffectiveClass = $UserInfo['Class'];
169
           i.DisableForums,
170
           i.DisableForums,
170
           i.DisableTagging,
171
           i.DisableTagging,
171
           i.SiteOptions,
172
           i.SiteOptions,
172
-          i.DownloadAlt,
173
           i.LastReadNews,
173
           i.LastReadNews,
174
           i.LastReadBlog,
174
           i.LastReadBlog,
175
           i.RestrictedForums,
175
           i.RestrictedForums,
181
         FROM users_main AS m
181
         FROM users_main AS m
182
           INNER JOIN users_info AS i ON i.UserID = m.ID
182
           INNER JOIN users_info AS i ON i.UserID = m.ID
183
         WHERE m.ID = '$UserID'");
183
         WHERE m.ID = '$UserID'");
184
-      $HeavyInfo = G::$DB->next_record(MYSQLI_ASSOC, array('CustomPermissions', 'SiteOptions'));
184
+      $HeavyInfo = G::$DB->next_record(MYSQLI_ASSOC, ['CustomPermissions', 'SiteOptions']);
185
 
185
 
186
+      $HeavyInfo['CustomPermissions'] = [];
186
       if (!empty($HeavyInfo['CustomPermissions'])) {
187
       if (!empty($HeavyInfo['CustomPermissions'])) {
187
         $HeavyInfo['CustomPermissions'] = json_decode($HeavyInfo['CustomPermissions'], true);
188
         $HeavyInfo['CustomPermissions'] = json_decode($HeavyInfo['CustomPermissions'], true);
188
-      } else {
189
-        $HeavyInfo['CustomPermissions'] = array();
190
       }
189
       }
191
 
190
 
191
+      $RestrictedForums = [];
192
       if (!empty($HeavyInfo['RestrictedForums'])) {
192
       if (!empty($HeavyInfo['RestrictedForums'])) {
193
         $RestrictedForums = array_map('trim', explode(',', $HeavyInfo['RestrictedForums']));
193
         $RestrictedForums = array_map('trim', explode(',', $HeavyInfo['RestrictedForums']));
194
-      } else {
195
-        $RestrictedForums = array();
196
       }
194
       }
197
       unset($HeavyInfo['RestrictedForums']);
195
       unset($HeavyInfo['RestrictedForums']);
196
+
197
+      $PermittedForums = [];
198
       if (!empty($HeavyInfo['PermittedForums'])) {
198
       if (!empty($HeavyInfo['PermittedForums'])) {
199
         $PermittedForums = array_map('trim', explode(',', $HeavyInfo['PermittedForums']));
199
         $PermittedForums = array_map('trim', explode(',', $HeavyInfo['PermittedForums']));
200
-      } else {
201
-        $PermittedForums = array();
202
       }
200
       }
203
       unset($HeavyInfo['PermittedForums']);
201
       unset($HeavyInfo['PermittedForums']);
204
 
202
 
219
         $PermittedForums = array_merge($PermittedForums, array_map('trim', explode(',', $Perms['PermittedForums'])));
217
         $PermittedForums = array_merge($PermittedForums, array_map('trim', explode(',', $Perms['PermittedForums'])));
220
       }
218
       }
221
 
219
 
220
+      $HeavyInfo['CustomForums'] = null;
222
       if (!empty($PermittedForums) || !empty($RestrictedForums)) {
221
       if (!empty($PermittedForums) || !empty($RestrictedForums)) {
223
-        $HeavyInfo['CustomForums'] = array();
222
+        $HeavyInfo['CustomForums'] = [];
224
         foreach ($RestrictedForums as $ForumID) {
223
         foreach ($RestrictedForums as $ForumID) {
225
           $HeavyInfo['CustomForums'][$ForumID] = 0;
224
           $HeavyInfo['CustomForums'][$ForumID] = 0;
226
         }
225
         }
227
         foreach ($PermittedForums as $ForumID) {
226
         foreach ($PermittedForums as $ForumID) {
228
           $HeavyInfo['CustomForums'][$ForumID] = 1;
227
           $HeavyInfo['CustomForums'][$ForumID] = 1;
229
         }
228
         }
230
-      } else {
231
-        $HeavyInfo['CustomForums'] = null;
232
       }
229
       }
233
       if (isset($HeavyInfo['CustomForums'][''])) {
230
       if (isset($HeavyInfo['CustomForums'][''])) {
234
         unset($HeavyInfo['CustomForums']['']);
231
         unset($HeavyInfo['CustomForums']['']);
491
       $GroupIDs = G::$DB->collect('GroupID');
488
       $GroupIDs = G::$DB->collect('GroupID');
492
       $BookmarkData = G::$DB->to_array('GroupID', MYSQLI_ASSOC);
489
       $BookmarkData = G::$DB->to_array('GroupID', MYSQLI_ASSOC);
493
       G::$DB->set_query_id($QueryID);
490
       G::$DB->set_query_id($QueryID);
494
-      G::$Cache->cache_value("bookmarks_group_ids_$UserID",
495
-        array($GroupIDs, $BookmarkData), 3600);
491
+      G::$Cache->cache_value("bookmarks_group_ids_$UserID", [$GroupIDs, $BookmarkData], 3600);
496
     }
492
     }
497
 
493
 
498
     $TorrentList = Torrents::get_groups($GroupIDs);
494
     $TorrentList = Torrents::get_groups($GroupIDs);
499
 
495
 
500
-    return array($GroupIDs, $BookmarkData, $TorrentList);
496
+    return [$GroupIDs, $BookmarkData, $TorrentList];
501
   }
497
   }
502
 
498
 
503
   /**
499
   /**
669
    */
665
    */
670
   public static function auth_location($UserID, $Username, $ASN, $Email) {
666
   public static function auth_location($UserID, $Username, $ASN, $Email) {
671
     $AuthKey = Users::make_secret();
667
     $AuthKey = Users::make_secret();
672
-    G::$Cache->cache_value('new_location_'.$AuthKey, array('UserID'=>$UserID, 'ASN'=>$ASN), 3600*2);
668
+    G::$Cache->cache_value('new_location_'.$AuthKey, ['UserID'=>$UserID, 'ASN'=>$ASN], 3600*2);
673
     require(SERVER_ROOT . '/classes/templates.class.php');
669
     require(SERVER_ROOT . '/classes/templates.class.php');
674
     $TPL = NEW TEMPLATE;
670
     $TPL = NEW TEMPLATE;
675
     $TPL->open(SERVER_ROOT . '/templates/new_location.tpl');
671
     $TPL->open(SERVER_ROOT . '/templates/new_location.tpl');

+ 0
- 1
gazelle.sql View File

1457
   `ViewAvatars` enum('0','1') NOT NULL DEFAULT '1',
1457
   `ViewAvatars` enum('0','1') NOT NULL DEFAULT '1',
1458
   `Donor` enum('0','1') NOT NULL DEFAULT '0',
1458
   `Donor` enum('0','1') NOT NULL DEFAULT '0',
1459
   `Artist` enum('0','1') NOT NULL DEFAULT '0',
1459
   `Artist` enum('0','1') NOT NULL DEFAULT '0',
1460
-  `DownloadAlt` enum('0','1') NOT NULL DEFAULT '0',
1461
   `Warned` datetime,
1460
   `Warned` datetime,
1462
   `SupportFor` varchar(255),
1461
   `SupportFor` varchar(255),
1463
   `TorrentGrouping` enum('0','1','2') NOT NULL COMMENT '0=Open,1=Closed,2=Off',
1462
   `TorrentGrouping` enum('0','1','2') NOT NULL COMMENT '0=Open,1=Closed,2=Off',

+ 5
- 10
sections/torrents/download.php View File

2
 if (!isset($_REQUEST['authkey']) || !isset($_REQUEST['torrent_pass'])) {
2
 if (!isset($_REQUEST['authkey']) || !isset($_REQUEST['torrent_pass'])) {
3
   enforce_login();
3
   enforce_login();
4
   $TorrentPass = $LoggedUser['torrent_pass'];
4
   $TorrentPass = $LoggedUser['torrent_pass'];
5
-  $DownloadAlt = $LoggedUser['DownloadAlt'];
6
-  $UserID     = $LoggedUser['ID'];
5
+  $UserID    = $LoggedUser['ID'];
7
   $AuthKey   = $LoggedUser['AuthKey'];
6
   $AuthKey   = $LoggedUser['AuthKey'];
8
 } else {
7
 } else {
9
   if (strpos($_REQUEST['torrent_pass'], '_') !== false) {
8
   if (strpos($_REQUEST['torrent_pass'], '_') !== false) {
13
   $UserInfo = $Cache->get_value('user_'.$_REQUEST['torrent_pass']);
12
   $UserInfo = $Cache->get_value('user_'.$_REQUEST['torrent_pass']);
14
   if (!is_array($UserInfo)) {
13
   if (!is_array($UserInfo)) {
15
     $DB->query("
14
     $DB->query("
16
-      SELECT ID, DownloadAlt, la.UserID
15
+      SELECT ID, la.UserID
17
       FROM users_main AS m
16
       FROM users_main AS m
18
         INNER JOIN users_info AS i ON i.UserID = m.ID
17
         INNER JOIN users_info AS i ON i.UserID = m.ID
19
         LEFT JOIN locked_accounts AS la ON la.UserID = m.ID
18
         LEFT JOIN locked_accounts AS la ON la.UserID = m.ID
23
     $Cache->cache_value('user_'.$_REQUEST['torrent_pass'], $UserInfo, 3600);
22
     $Cache->cache_value('user_'.$_REQUEST['torrent_pass'], $UserInfo, 3600);
24
   }
23
   }
25
   $UserInfo = array($UserInfo);
24
   $UserInfo = array($UserInfo);
26
-  list($UserID, $DownloadAlt, $Locked) = array_shift($UserInfo);
25
+  list($UserID, $Locked) = array_shift($UserInfo);
27
   if (!$UserID) {
26
   if (!$UserID) {
28
     error(0);
27
     error(0);
29
   }
28
   }
179
 
178
 
180
 Torrents::set_snatch_update_time($UserID, Torrents::SNATCHED_UPDATE_AFTERDL);
179
 Torrents::set_snatch_update_time($UserID, Torrents::SNATCHED_UPDATE_AFTERDL);
181
 $Contents = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
180
 $Contents = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
182
-$FileName = TorrentsDL::construct_file_name($Info['PlainArtists'], $Name, $Year, $Media, $Format, $Encoding, $TorrentID, $DownloadAlt);
181
+$FileName = TorrentsDL::construct_file_name($Info['PlainArtists'], $Name, $Year, $Media, $Format, $Encoding, $TorrentID);
183
 
182
 
184
-if ($DownloadAlt) {
185
-  header('Content-Type: text/plain; charset=utf-8');
186
-} elseif (!$DownloadAlt || $Failed) {
187
-  header('Content-Type: application/x-bittorrent; charset=utf-8');
188
-}
183
+header('Content-Type: application/x-bittorrent; charset=utf-8');
189
 header('Content-disposition: attachment; filename="'.$FileName.'"');
184
 header('Content-disposition: attachment; filename="'.$FileName.'"');
190
 
185
 
191
 function add_passkey($ann) {
186
 function add_passkey($ann) {

+ 1
- 9
sections/user/edit.php View File

18
     i.StyleURL,
18
     i.StyleURL,
19
     i.SiteOptions,
19
     i.SiteOptions,
20
     i.UnseededAlerts,
20
     i.UnseededAlerts,
21
-    i.DownloadAlt,
22
     p.Level AS Class,
21
     p.Level AS Class,
23
     i.InfoTitle
22
     i.InfoTitle
24
   FROM users_main AS m
23
   FROM users_main AS m
25
     JOIN users_info AS i ON i.UserID = m.ID
24
     JOIN users_info AS i ON i.UserID = m.ID
26
     LEFT JOIN permissions AS p ON p.ID = m.PermissionID
25
     LEFT JOIN permissions AS p ON p.ID = m.PermissionID
27
   WHERE m.ID = '".db_string($UserID)."'");
26
   WHERE m.ID = '".db_string($UserID)."'");
28
-list($Username, $TwoFactor, $Email, $IRCKey, $Paranoia, $Info, $Avatar, $StyleID, $StyleURL, $SiteOptions, $UnseededAlerts, $DownloadAlt, $Class, $InfoTitle) = $DB->next_record(MYSQLI_NUM, array(4, 9));
27
+list($Username, $TwoFactor, $Email, $IRCKey, $Paranoia, $Info, $Avatar, $StyleID, $StyleURL, $SiteOptions, $UnseededAlerts, $Class, $InfoTitle) = $DB->next_record(MYSQLI_NUM, array(4, 9));
29
 
28
 
30
 $TwoFA = new TwoFactorAuth();
29
 $TwoFA = new TwoFactorAuth();
31
 
30
 
324
           <label for="novotelinks">Disable voting links</label>
323
           <label for="novotelinks">Disable voting links</label>
325
         </td>
324
         </td>
326
       </tr>
325
       </tr>
327
-      <tr id="tor_dltext_tr">
328
-        <td class="label tooltip" title="Some ISPs block the downloading of torrent files. Enable this option if you wish to download torrent files with a &quot;.txt&quot; file extension."><strong>Text file downloads</strong></td>
329
-        <td>
330
-          <input type="checkbox" name="downloadalt" id="downloadalt"<?=$DownloadAlt ? ' checked="checked"' : ''?> />
331
-          <label for="downloadalt">Enable downloading torrent files as text files</label>
332
-        </td>
333
-      </tr>
334
       <tr id="tor_hidequestionable_tr">
326
       <tr id="tor_hidequestionable_tr">
335
         <td class="label tooltip" title="Prevent torrents with these tags from showing up on the torrent search page"><strong>Content Filtering</strong></td>
327
         <td class="label tooltip" title="Prevent torrents with these tags from showing up on the torrent search page"><strong>Content Filtering</strong></td>
336
         <td>
328
         <td>

+ 28
- 36
sections/user/take_edit.php View File

20
 }
20
 }
21
 
21
 
22
 $Val->SetFields('stylesheet', 1, "number", "You forgot to select a stylesheet.");
22
 $Val->SetFields('stylesheet', 1, "number", "You forgot to select a stylesheet.");
23
-$Val->SetFields('styleurl', 0, "regex", "You did not enter a valid stylesheet URL.", array('regex' => '/^'.CSS_REGEX.'$/i'));
23
+$Val->SetFields('styleurl', 0, "regex", "You did not enter a valid stylesheet URL.", ['regex' => '/^'.CSS_REGEX.'$/i']);
24
 // The next two are commented out because the drop-down menus were replaced with a check box and radio buttons
24
 // The next two are commented out because the drop-down menus were replaced with a check box and radio buttons
25
 //$Val->SetFields('disablegrouping', 0, "number", "You forgot to select your torrent grouping option.");
25
 //$Val->SetFields('disablegrouping', 0, "number", "You forgot to select your torrent grouping option.");
26
 //$Val->SetFields('torrentgrouping', 0, "number", "You forgot to select your torrent grouping option.");
26
 //$Val->SetFields('torrentgrouping', 0, "number", "You forgot to select your torrent grouping option.");
27
-$Val->SetFields('postsperpage', 1, "number", "You forgot to select your posts per page option.", array('inarray' => array(25, 50, 100)));
28
-//$Val->SetFields('hidecollage', 1, "number", "You forgot to select your collage option.", array('minlength' => 0, 'maxlength' => 1));
27
+$Val->SetFields('postsperpage', 1, "number", "You forgot to select your posts per page option.", ['inarray' => [25, 50, 100]]);
28
+//$Val->SetFields('hidecollage', 1, "number", "You forgot to select your collage option.", ['minlength' => 0, 'maxlength' => 1]);
29
 $Val->SetFields('collagecovers', 1, "number", "You forgot to select your collage option.");
29
 $Val->SetFields('collagecovers', 1, "number", "You forgot to select your collage option.");
30
-$Val->SetFields('avatar', 0, "regex", "You did not enter a valid avatar URL.", array('regex' => "/^".IMAGE_REGEX."$/i"));
30
+$Val->SetFields('avatar', 0, "regex", "You did not enter a valid avatar URL.", ['regex' => "/^".IMAGE_REGEX."$/i"]);
31
 $Val->SetFields('email', 1, "email", "You did not enter a valid email address.");
31
 $Val->SetFields('email', 1, "email", "You did not enter a valid email address.");
32
-$Val->SetFields('twofa', 0, "regex", "You did not enter a valid 2FA verification code.", array('regex' => '/^[0-9]{6}$/'));
33
-$Val->SetFields('irckey', 0, "string", "You did not enter a valid IRC key. An IRC key must be between 6 and 32 characters long.", array('minlength' => 6, 'maxlength' => 32));
34
-$Val->SetFields('new_pass_1', 0, "regex", "You did not enter a valid password. A valid password is 6 characters or longer.", array('regex' => '/(?=^.{6,}$).*$/'));
35
-$Val->SetFields('new_pass_2', 1, "compare", "Your passwords do not match.", array('comparefield' => 'new_pass_1'));
32
+$Val->SetFields('twofa', 0, "regex", "You did not enter a valid 2FA verification code.", ['regex' => '/^[0-9]{6}$/']);
33
+$Val->SetFields('irckey', 0, "string", "You did not enter a valid IRC key. An IRC key must be between 6 and 32 characters long.", ['minlength' => 6, 'maxlength' => 32]);
34
+$Val->SetFields('new_pass_1', 0, "regex", "You did not enter a valid password. A valid password is 6 characters or longer.", ['regex' => '/(?=^.{6,}$).*$/']);
35
+$Val->SetFields('new_pass_2', 1, "compare", "Your passwords do not match.", ['comparefield' => 'new_pass_1']);
36
 if (check_perms('site_advanced_search')) {
36
 if (check_perms('site_advanced_search')) {
37
-  $Val->SetFields('searchtype', 1, "number", "You forgot to select your default search preference.", array('minlength' => 0, 'maxlength' => 1));
37
+  $Val->SetFields('searchtype', 1, "number", "You forgot to select your default search preference.", ['minlength' => 0, 'maxlength' => 1]);
38
 }
38
 }
39
 
39
 
40
 $Err = $Val->ValidateForm($_POST);
40
 $Err = $Val->ValidateForm($_POST);
75
 
75
 
76
 // if showing exactly 2 of stats, show all 3 of stats
76
 // if showing exactly 2 of stats, show all 3 of stats
77
 $StatsShown = 0;
77
 $StatsShown = 0;
78
-$Stats = array('downloaded', 'uploaded', 'ratio');
78
+$Stats = ['downloaded', 'uploaded', 'ratio'];
79
 foreach ($Stats as $S) {
79
 foreach ($Stats as $S) {
80
   if (isset($_POST["p_$S"])) {
80
   if (isset($_POST["p_$S"])) {
81
     $StatsShown++;
81
     $StatsShown++;
88
   }
88
   }
89
 }
89
 }
90
 
90
 
91
-$Paranoia = array();
92
-$Checkboxes = array('downloaded', 'uploaded', 'ratio', 'lastseen', 'requiredratio', 'invitedcount', 'artistsadded', 'notifications');
91
+$Paranoia = [];
92
+$Checkboxes = ['downloaded', 'uploaded', 'ratio', 'lastseen', 'requiredratio', 'invitedcount', 'artistsadded', 'notifications'];
93
 foreach ($Checkboxes as $C) {
93
 foreach ($Checkboxes as $C) {
94
   if (!isset($_POST["p_$C"])) {
94
   if (!isset($_POST["p_$C"])) {
95
     $Paranoia[] = $C;
95
     $Paranoia[] = $C;
96
   }
96
   }
97
 }
97
 }
98
 
98
 
99
-$SimpleSelects = array('torrentcomments', 'collages', 'collagecontribs', 'uploads', 'uniquegroups', 'perfectflacs', 'seeding', 'leeching', 'snatched');
99
+$SimpleSelects = ['torrentcomments', 'collages', 'collagecontribs', 'uploads', 'uniquegroups', 'perfectflacs', 'seeding', 'leeching', 'snatched'];
100
 foreach ($SimpleSelects as $S) {
100
 foreach ($SimpleSelects as $S) {
101
   if (!isset($_POST["p_$S".'_c']) && !isset($_POST["p_$S".'_l'])) {
101
   if (!isset($_POST["p_$S".'_c']) && !isset($_POST["p_$S".'_l'])) {
102
     // Very paranoid - don't show count or list
102
     // Very paranoid - don't show count or list
107
   }
107
   }
108
 }
108
 }
109
 
109
 
110
-$Bounties = array('requestsfilled', 'requestsvoted');
110
+$Bounties = ['requestsfilled', 'requestsvoted'];
111
 foreach ($Bounties as $B) {
111
 foreach ($Bounties as $B) {
112
   if (isset($_POST["p_$B".'_list'])) {
112
   if (isset($_POST["p_$B".'_list'])) {
113
     $_POST["p_$B".'_count'] = 'on';
113
     $_POST["p_$B".'_count'] = 'on';
292
     $Options['SortHide'][$E[0]] = $E[1];
292
     $Options['SortHide'][$E[0]] = $E[1];
293
   }
293
   }
294
 } else {
294
 } else {
295
-  $Options['SortHide'] = array();
295
+  $Options['SortHide'] = [];
296
 }
296
 }
297
 
297
 
298
 if (check_perms('site_advanced_search')) {
298
 if (check_perms('site_advanced_search')) {
306
 unset($Options['ShowQueryList']);
306
 unset($Options['ShowQueryList']);
307
 unset($Options['ShowCacheList']);
307
 unset($Options['ShowCacheList']);
308
 
308
 
309
-$DownloadAlt = isset($_POST['downloadalt']) ? 1 : 0;
310
 $UnseededAlerts = isset($_POST['unseededalerts']) ? 1 : 0;
309
 $UnseededAlerts = isset($_POST['unseededalerts']) ? 1 : 0;
311
 
310
 
312
 Donations::update_rewards($UserID);
311
 Donations::update_rewards($UserID);
316
 if (!empty($_POST['badges'])) {
315
 if (!empty($_POST['badges'])) {
317
   $BadgeIDs = array_slice($_POST['badges'], 0, 5);
316
   $BadgeIDs = array_slice($_POST['badges'], 0, 5);
318
 } else {
317
 } else {
319
-  $BadgeIDs = array();
318
+  $BadgeIDs = [];
320
 }
319
 }
321
 
320
 
322
 $BadgesChanged = false;
321
 $BadgesChanged = false;
323
-$NewBadges = array();
322
+$NewBadges = [];
324
 if ($Cache->get_value('user_badges_'.$UserID)) {
323
 if ($Cache->get_value('user_badges_'.$UserID)) {
325
   $Badges = $Cache->get_value('user_badges_'.$UserID);
324
   $Badges = $Cache->get_value('user_badges_'.$UserID);
326
   foreach ($Badges as $Badge) {
325
   foreach ($Badges as $Badge) {
334
       $Displayed = false;
333
       $Displayed = false;
335
       $BadgesChanged = true;
334
       $BadgesChanged = true;
336
     }
335
     }
337
-    $NewBadges[] = array('BadgeID' => $Badge['BadgeID'], 'Displayed' => $Displayed?'1':'0');
336
+    $NewBadges[] = ['BadgeID' => $Badge['BadgeID'], 'Displayed' => $Displayed?'1':'0'];
338
 
337
 
339
   }
338
   }
340
 } else {
339
 } else {
345
 }
344
 }
346
 // End Badge settings
345
 // End Badge settings
347
 
346
 
348
-// Information on how the user likes to download torrents is stored in cache
349
-if ($DownloadAlt != $LoggedUser['DownloadAlt']) {
350
-  $Cache->delete_value('user_'.$LoggedUser['torrent_pass']);
351
-}
352
-
353
 $Cache->begin_transaction("user_info_$UserID");
347
 $Cache->begin_transaction("user_info_$UserID");
354
-$Cache->update_row(false, array(
355
-    'Avatar' => display_str($_POST['avatar']),
356
-    'Paranoia' => $Paranoia
357
-));
348
+$Cache->update_row(false, [
349
+  'Avatar' => display_str($_POST['avatar']),
350
+  'Paranoia' => $Paranoia
351
+]);
358
 $Cache->commit_transaction(0);
352
 $Cache->commit_transaction(0);
359
 
353
 
360
 $Cache->begin_transaction("user_info_heavy_$UserID");
354
 $Cache->begin_transaction("user_info_heavy_$UserID");
361
-$Cache->update_row(false, array(
362
-    'StyleID' => $_POST['stylesheet'],
363
-    'StyleURL' => display_str($_POST['styleurl']),
364
-    'DownloadAlt' => $DownloadAlt
365
-    ));
355
+$Cache->update_row(false, [
356
+  'StyleID' => $_POST['stylesheet'],
357
+  'StyleURL' => display_str($_POST['styleurl'])
358
+]);
366
 $Cache->update_row(false, $Options);
359
 $Cache->update_row(false, $Options);
367
 $Cache->commit_transaction(0);
360
 $Cache->commit_transaction(0);
368
 
361
 
378
     i.NotifyOnQuote = '".db_string($Options['NotifyOnQuote'])."',
371
     i.NotifyOnQuote = '".db_string($Options['NotifyOnQuote'])."',
379
     i.Info = '".db_string($_POST['info'])."',
372
     i.Info = '".db_string($_POST['info'])."',
380
     i.InfoTitle = '".db_string($_POST['profile_title'])."',
373
     i.InfoTitle = '".db_string($_POST['profile_title'])."',
381
-    i.DownloadAlt = '$DownloadAlt',
382
     i.UnseededAlerts = '$UnseededAlerts',
374
     i.UnseededAlerts = '$UnseededAlerts',
383
     m.Email = '".DBCrypt::encrypt($_POST['email'])."',
375
     m.Email = '".DBCrypt::encrypt($_POST['email'])."',
384
     m.IRCKey = '".db_string($_POST['irckey'])."',
376
     m.IRCKey = '".db_string($_POST['irckey'])."',
408
     VALUES
400
     VALUES
409
       ('$UserID', '$OldPassKey', '$NewPassKey', '$ChangerIP', '".sqltime()."')");
401
       ('$UserID', '$OldPassKey', '$NewPassKey', '$ChangerIP', '".sqltime()."')");
410
   $Cache->begin_transaction("user_info_heavy_$UserID");
402
   $Cache->begin_transaction("user_info_heavy_$UserID");
411
-  $Cache->update_row(false, array('torrent_pass' => $NewPassKey));
403
+  $Cache->update_row(false, ['torrent_pass' => $NewPassKey]);
412
   $Cache->commit_transaction(0);
404
   $Cache->commit_transaction(0);
413
   $Cache->delete_value("user_$OldPassKey");
405
   $Cache->delete_value("user_$OldPassKey");
414
 
406
 
415
-  Tracker::update_tracker('change_passkey', array('oldpasskey' => $OldPassKey, 'newpasskey' => $NewPassKey));
407
+  Tracker::update_tracker('change_passkey', ['oldpasskey' => $OldPassKey, 'newpasskey' => $NewPassKey]);
416
 }
408
 }
417
 
409
 
418
 $SQL .= "WHERE m.ID = '".db_string($UserID)."'";
410
 $SQL .= "WHERE m.ID = '".db_string($UserID)."'";

Loading…
Cancel
Save