Browse Source

Remove torrent group voting and similar artists

These features only have any value if users actually use them, and
experience has shown that nowhere near enough users use them to make
them worthwhile.
spaghetti 4 years ago
parent
commit
9f7885546a

+ 0
- 385
classes/artists_similar.class.php View File

@@ -1,385 +0,0 @@
1
-<?
2
-class ARTIST {
3
-  var $ID = 0;
4
-  var $Name = 0;
5
-  var $NameLength = 0;
6
-  var $SimilarID = 0;
7
-  var $Displayed = false;
8
-  var $x = 0;
9
-  var $y = 0;
10
-  var $Similar = [];
11
-
12
-  function ARTIST($ID = '', $Name = '') {
13
-    $this->ID = $ID;
14
-    $this->NameLength = mb_strlen($Name, 'utf8');
15
-    $this->Name = display_str($Name);
16
-  }
17
-}
18
-
19
-class ARTISTS_SIMILAR extends ARTIST{
20
-  var $Artists = [];
21
-  var $TotalScore = 0;
22
-
23
-  var $xValues = array(WIDTH=>1);
24
-  var $yValues = array(HEIGHT=>1);
25
-
26
-  var $LargestDecimal = 0;
27
-  var $LowestDecimal = 1;
28
-
29
-
30
-
31
-  function dump_data() {
32
-    return serialize(array(time(), $this->Name, $this->x, $this->y, serialize($this->Artists), serialize($this->Similar)));
33
-  }
34
-
35
-  function load_data($Data) {
36
-    list($LastUpdated, $this->Name, $this->x, $this->y, $this->Artists, $this->Similar) = unserialize($Data);
37
-    $this->Artists = unserialize($this->Artists);
38
-    $this->Similar = unserialize($this->Similar);
39
-  }
40
-
41
-  function set_up() {
42
-    $QueryID = G::$DB->get_query_id();
43
-
44
-    $this->x = ceil(WIDTH / 2);
45
-    $this->y = ceil(HEIGHT / 2);
46
-
47
-    $this->xValues[$this->x] = $this->ID;
48
-    $this->yValues[$this->y] = $this->ID;
49
-
50
-
51
-    // Get artists that are directly similar to the artist
52
-    $ArtistIDs = [];
53
-    G::$DB->query("
54
-      SELECT
55
-        s2.ArtistID,
56
-        ag.Name,
57
-        ass.Score
58
-      FROM artists_similar AS s1
59
-        JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID AND s1.ArtistID!=s2.ArtistID
60
-        JOIN artists_similar_scores AS ass ON ass.SimilarID=s1.SimilarID
61
-        JOIN artists_group AS ag ON ag.ArtistID=s2.ArtistID
62
-      WHERE s1.ArtistID=".$this->ID."
63
-      ORDER BY ass.Score DESC
64
-      LIMIT 14");
65
-
66
-    if (!G::$DB->has_results()) {
67
-      return;
68
-    }
69
-
70
-    // Build into array. Each artist is its own object in $this->Artists
71
-    while (list($ArtistID, $Name, $Score) = G::$DB->next_record(MYSQLI_NUM, false)) {
72
-      if ($Score < 0) {
73
-        continue;
74
-      }
75
-      $this->Artists[$ArtistID] = new ARTIST($ArtistID, $Name);
76
-      $this->Similar[$ArtistID] = array('ID' => $ArtistID, 'Score' => $Score);
77
-      $this->TotalScore += $Score;
78
-      $ArtistIDs[] = $ArtistID;
79
-    }
80
-
81
-    // Get similarities between artists on the map
82
-    G::$DB->query("
83
-      SELECT
84
-        s1.ArtistID,
85
-        s2.ArtistID
86
-      FROM artists_similar AS s1
87
-        JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID AND s1.ArtistID!=s2.ArtistID
88
-        JOIN artists_similar_scores AS ass ON ass.SimilarID=s1.SimilarID
89
-        JOIN artists_group AS a ON a.ArtistID=s2.ArtistID
90
-      WHERE s1.ArtistID IN(".implode(',', $ArtistIDs).')
91
-        AND s2.ArtistID IN('.implode(',', $ArtistIDs).')');
92
-
93
-    // Build into array
94
-    while (list($Artist1ID, $Artist2ID) = G::$DB->next_record()) {
95
-      $this->Artists[$Artist1ID]->Similar[$Artist2ID] = array('ID'=>$Artist2ID);
96
-    }
97
-
98
-    // Calculate decimal point scores between artists
99
-    foreach ($this->Similar as $SimilarArtist) {
100
-      list($ArtistID, $Similar) = array_values($SimilarArtist);
101
-      $this->Similar[$ArtistID]['Decimal'] =  $this->similarity($Similar['Score'], $this->TotalScore);
102
-
103
-      if ($this->Similar[$ArtistID]['Decimal'] < $this->LowestDecimal) {
104
-        $this->LowestDecimal = $this->Similar[$ArtistID]['Decimal'];
105
-      }
106
-      if ($this->Similar[$ArtistID]['Decimal'] > $this->LargestDecimal) {
107
-        $this->LargestDecimal = $this->Similar[$ArtistID]['Decimal'];
108
-      }
109
-    }
110
-    reset($this->Artists);
111
-
112
-    G::$DB->set_query_id($QueryID);
113
-  }
114
-
115
-  function set_positions() {
116
-    $xValues = []; // Possible x values
117
-    $Root = ceil(WIDTH / 4); // Half-way into half of the image
118
-    $Offset = 4; // Distance from the root (a quarter of the way into the image) to the x value
119
-
120
-    // The number of artists placed in the top or the bottom
121
-    $NumTop = 0;
122
-    $NumBottom = 0;
123
-
124
-    // The number of artists placed in the left or the right
125
-    $NumLeft = 0;
126
-    $NumRight = 0;
127
-
128
-    $Multiplier = 0;
129
-
130
-    // Build up an impressive list of possible x values
131
-    // We later iterate through these, and pick out the ones we want
132
-
133
-    // These x values are all below WIDTH/2 (all on the left)
134
-    // The script later chooses which side to put them on
135
-
136
-    // We create more very low x values because they're more likely to be skipped
137
-    for ($i = 0; $i <= count($this->Artists) * 4; $i++) {
138
-      if ($Offset >= ((WIDTH / 4))) {
139
-        $Offset = $Offset % (WIDTH / 4);
140
-      }
141
-      $Plus = $Root + $Offset; // Point on the right of the root
142
-      $Minus = abs($Root - $Offset); // Point on the left of the root
143
-
144
-      $xValues[$Plus] = $Plus;
145
-
146
-      $xValues[$Minus] = $Minus;
147
-
148
-      // Throw in an extra x value closer to the edge, because they're more likely to be skipped
149
-
150
-      if ($Minus > 30) {
151
-      //  $xValues[$Minus - 30] = $Minus - 30;
152
-      }
153
-
154
-      $Offset = $Offset + rand(5, 20); // Increase offset, and go again
155
-    }
156
-
157
-    foreach ($this->Artists as $Artist) {
158
-      $ArtistID = $Artist->ID;
159
-      if ($Artist->Displayed == true) {
160
-        continue;
161
-      }
162
-      $this->Similar[$ArtistID]['Decimal'] = $this->Similar[$ArtistID]['Decimal'] * (1 / ($this->LargestDecimal)) - 0.1;
163
-      // Calculate the distance away from the center, based on similarity
164
-      $IdealDistance =  $this->calculate_distance($this->Similar[$ArtistID]['Decimal'], $this->x, $this->y);
165
-
166
-      $this->Similar[$ArtistID]['Distance'] = $IdealDistance;
167
-
168
-      // 1 = left, 2 = right
169
-      $Horizontal = 0;
170
-      $Vertical = 0;
171
-
172
-      // See if any similar artists have been placed yet. If so, place artist in that half
173
-      // (provided that there are enough in the other half to visually balance out)
174
-      reset($Artist->Similar);
175
-      foreach ($Artist->Similar as $SimilarArtist) {
176
-        list($Artist2ID) = array_values($SimilarArtist);
177
-        if ($this->Artists[$Artist2ID]) {
178
-          if ($this->Artists[$Artist2ID]->x > (WIDTH / 2) && ($NumRight-$NumLeft) < 1) {
179
-            $Horizontal = 2;
180
-          } elseif ($NumLeft - $NumRight < 1) {
181
-            $Horizontal = 1;
182
-          }
183
-          break;
184
-        }
185
-      }
186
-
187
-      shuffle($xValues);
188
-
189
-      while ($xValue = array_shift($xValues)) {
190
-        if (abs($this->x - $xValue) <= $IdealDistance) {
191
-          if (hypot(abs($this->x - $xValue), ($this->y - 50)) > $IdealDistance
192
-            || ceil(sqrt(pow($IdealDistance, 2) - pow($this->x - $xValue, 2))) > (HEIGHT / 2)) {
193
-            $xValue = $this->x - ceil(sqrt(pow($IdealDistance, 2) - pow($IdealDistance * 0.1 * rand(5,9), 2)));
194
-            //echo "Had to change x value for ".$Artist->Name." to ".$xValue."\n";
195
-          }
196
-          // Found a match (Is close enough to the center to satisfy $IdealDistance),
197
-          // Now it's time to choose which half to put it on
198
-          if (!$Horizontal) {
199
-            // No similar artists displayed
200
-            $Horizontal = ($NumLeft < $NumRight) ? 1 : 2;
201
-          }
202
-          if ($Horizontal == 2) {
203
-            $xValue = WIDTH - $xValue;
204
-            $NumRight++;
205
-          } else {
206
-            $NumLeft++;
207
-          }
208
-
209
-          $Artist->x = $xValue;
210
-          $this->xValues[$xValue] = $ArtistID;
211
-          unset($xValues[$xValue]);
212
-
213
-          break;
214
-        }
215
-      }
216
-      if (!$xValue) { // Uh-oh, we were unable to choose an x value.
217
-        $xValue = ceil(sqrt(pow($IdealDistance, 2) / 2));
218
-        $xValue = (WIDTH / 2) - $xValue;
219
-        $Artist->x = $xValue;
220
-        $this->xValues[$xValue] = $ArtistID;
221
-        unset($xValues[$xValue]);
222
-      }
223
-
224
-
225
-      // Pythagoras. $yValue is the vertical distance from the center to the y value
226
-      $yValue = sqrt(pow($IdealDistance, 2) - pow(abs($this->x - $Artist->x), 2));
227
-
228
-
229
-      // Now we pick if it should go on the top or bottom
230
-
231
-      if ($NumTop > $NumBottom) { // Send it to the bottom half
232
-        $yValue = (HEIGHT / 2) + $yValue;
233
-        $NumBottom++;
234
-      } else {
235
-        $yValue=(HEIGHT / 2) - $yValue;
236
-        $NumTop++;
237
-      }
238
-
239
-      $yValue = ceil($yValue);
240
-
241
-      // $yValue is now a proper y coordinate
242
-      // Now time to do some spacing out
243
-
244
-      if ($yValue < 10) {
245
-        $yValue += (10 + abs($yValue)) + rand(10,20);
246
-      }
247
-
248
-      if ($yValue > (HEIGHT - 10)) {
249
-        $yValue -= ((HEIGHT / 2) - rand(10,20));
250
-      }
251
-
252
-      $i = 1;
253
-      while ($Conflict = $this->scan_array_range($this->yValues, abs($yValue - 13), $yValue + 13)) {
254
-        if ($i > 10) {
255
-          break;
256
-        }
257
-        if (!$this->scan_array_range($this->yValues, abs($yValue - 5), $yValue - 20)) {
258
-          $yValue -= 20;
259
-        }
260
-
261
-        $yValue = $Conflict + rand(10, 20);
262
-        if ($yValue > HEIGHT - 10) {
263
-          $yValue -= ceil(HEIGHT / 2.5);
264
-        } elseif ($yValue < 10) {
265
-          $yValue += ceil(HEIGHT / 2.5);
266
-        }
267
-        $i++;
268
-      }
269
-
270
-      $Artist->y = $yValue;
271
-      $this->yValues[$yValue] = $ArtistID;
272
-    }
273
-    reset($this->Artists);
274
-    reset($this->xValues);
275
-    reset($this->yValues);
276
-
277
-  }
278
-
279
-  // Calculate the ideal distance from the center point ($Rootx, $Rooty) to the artist's point on the board
280
-  // Pythagoras as fun!
281
-  function calculate_distance($SimilarityCoefficient, $Rootx, $Rooty) {
282
-    $MaxWidth = WIDTH - $Rootx;
283
-    $MaxHeight = HEIGHT - $Rooty;
284
-    $x = $MaxWidth - ($SimilarityCoefficient * $MaxWidth * 0.01); // Possible x value
285
-    $y = $MaxHeight - ($SimilarityCoefficient * $MaxHeight); // Possible y value
286
-    $Hypot = hypot($Rootx - $x, $Rooty - $y);
287
-    return $MaxWidth - $Hypot;
288
-
289
-  }
290
-
291
-  function similarity($Score, $TotalArtistScore) {
292
-    return (pow(($Score / ($TotalArtistScore + 1)), (1 / 1)));
293
-  }
294
-
295
-  function scan_array_range($Array, $Start, $Finish) {
296
-    if ($Start < 0) {
297
-      die($Start);
298
-    }
299
-    for ($i = $Start; $i <= $Finish; $i++) {
300
-      if (isset($Array[$i])) {
301
-        return $i;
302
-      }
303
-    }
304
-    return false;
305
-  }
306
-
307
-  function write_artists() {
308
-?>
309
-    <div style="position: absolute; bottom: <?=($this->y - 10)?>px; left: <?=($this->x - $this->NameLength * 4)?>px; font-size: 13pt; white-space: nowrap;" class="similar_artist_header">
310
-      <?=($this->Name)?>
311
-    </div>
312
-<?
313
-    foreach ($this->Artists as $Artist) {
314
-      if ($Artist->ID == $this->ID) {
315
-        continue;
316
-      }
317
-      $xPosition = $Artist->x - $Artist->NameLength * 4;
318
-      if ($xPosition < 0) {
319
-        $xPosition = 3;
320
-        $Artist->x = $xPosition;
321
-
322
-      }
323
-      $Decimal = $this->Similar[$Artist->ID]['Decimal'];
324
-
325
-      if ($Decimal < 0.2) {
326
-        $FontSize = 8;
327
-      } elseif ($Decimal < 0.3) {
328
-        $FontSize = 9;
329
-      } elseif ($Decimal < 0.4) {
330
-        $FontSize = 10;
331
-      } else {
332
-        $FontSize = 12;
333
-      }
334
-?>
335
-    <div style="position: absolute; top: <?=($Artist->y - 5)?>px; left: <?=$xPosition?>px; font-size: <?=$FontSize?>pt; white-space: nowrap;">
336
-      <a href="artist.php?id=<?=($Artist->ID)?>" class="similar_artist"><?=($Artist->Name)?></a>
337
-    </div>
338
-<?
339
-    }
340
-    reset($this->Artists);
341
-  }
342
-
343
-  function background_image() {
344
-    global $Img;
345
-    reset($this->Similar);
346
-    foreach ($this->Similar as $SimilarArtist) {
347
-      list($ArtistID, $Val) = array_values($SimilarArtist);
348
-      $Artist = $this->Artists[$ArtistID];
349
-      $Decimal = $this->Similar[$ArtistID]['Decimal'];
350
-      $Width = ceil($Decimal * 4) + 1;
351
-
352
-      $Img->line($this->x, $this->y, $Artist->x, $Artist->y, $Img->color(199, 218, 255), $Width);
353
-
354
-      unset($Artist->Similar[$this->ID]);
355
-      reset($Artist->Similar);
356
-      foreach ($Artist->Similar as $SimilarArtist2) {
357
-        list($Artist2ID) = array_values($SimilarArtist2);
358
-        if ($this->Artists[$Artist2ID]) {
359
-          $Artist2 = $this->Artists[$Artist2ID];
360
-          $Img->line($Artist->x, $Artist->y, $Artist2->x, $Artist2->y, $Img->color(173, 201, 255));
361
-          unset($Artist2->Similar[$ArtistID]);
362
-        }
363
-      }
364
-      reset($this->xValues);
365
-    }
366
-    $Img->make_png(SERVER_ROOT.'/static/similar/'.$this->ID.'.png');
367
-  }
368
-
369
-  function dump() {
370
-    echo "Similarities:\n";
371
-    foreach ($this->Artists as $Artist) {
372
-      echo $Artist->ID;
373
-      echo ' - ';
374
-      echo $Artist->Name;
375
-      echo "\n";
376
-      echo 'x - ' . $Artist->x . "\n";
377
-      echo 'y - ' . $Artist->y . "\n";
378
-      print_r($this->Similar[$Artist->ID]);
379
-      //print_r($Artist->Similar);
380
-      echo "\n\n---\n\n";
381
-    }
382
-
383
-  }
384
-}
385
-?>

+ 2
- 3
classes/cache.class.php View File

@@ -40,18 +40,17 @@ class CACHE extends Memcache {
40 40
   protected $InTransaction = false;
41 41
   public $Time = 0;
42 42
   private $Servers = [];
43
-  private $PersistentKeys = array(
43
+  private $PersistentKeys = [
44 44
     'ajax_requests_*',
45 45
     'query_lock_*',
46 46
     'stats_*',
47 47
     'top10tor_*',
48
-    'top10votes_*',
49 48
     'users_snatched_*',
50 49
 
51 50
     // Cache-based features
52 51
     'global_notification',
53 52
     'notifications_one_reads_*',
54
-  );
53
+  ];
55 54
   private $ClearedKeys = [];
56 55
 
57 56
   public $CanClear = false;

+ 0
- 2
classes/permissions_form.php View File

@@ -15,7 +15,6 @@ $PermissionsArray = array(
15 15
   'site_advanced_search' => 'Advanced search access.',
16 16
   'site_top10' => 'Top 10 access.',
17 17
   'site_advanced_top10' => 'Advanced Top 10 access.',
18
-  'site_album_votes' => 'Voting for favorite torrents.',
19 18
   'site_torrents_notify' => 'Notifications access.',
20 19
   'site_collages_create' => 'Collage create access.',
21 20
   'site_collages_manage' => 'Collage manage access.',
@@ -138,7 +137,6 @@ function permissions_form() {
138 137
           display_perm('site_collages_personal','Can have a personal collage.');
139 138
           display_perm('site_collages_renamepersonal','Can rename own personal collages.');
140 139
           display_perm('site_advanced_top10','Can access advanced top 10.');
141
-          display_perm('site_album_votes', 'Can vote for favorite torrents.');
142 140
           display_perm('site_make_bookmarks','Can make bookmarks.');
143 141
           display_perm('site_edit_wiki','Can edit wiki pages.');
144 142
           display_perm('site_can_invite_always', 'Can invite users even when invites are closed.');

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

@@ -1,5 +0,0 @@
1
-<?
2
-
3
-class Top10 {
4
-
5
-}

+ 0
- 1
classes/top10view.class.php View File

@@ -8,7 +8,6 @@ class Top10View {
8 8
       <a href="top10.php?type=torrents" class="brackets"><?=self::get_selected_link("Torrents", $Selected == "torrents")?></a>
9 9
       <a href="top10.php?type=users" class="brackets"><?=self::get_selected_link("Users", $Selected == "users")?></a>
10 10
       <a href="top10.php?type=tags" class="brackets"><?=self::get_selected_link("Tags", $Selected == "tags")?></a>
11
-      <a href="top10.php?type=votes" class="brackets"><?=self::get_selected_link("Favorites", $Selected == "votes")?></a>
12 11
       <a href="top10.php?type=donors" class="brackets"><?=self::get_selected_link("Donors", $Selected == "donors")?></a>
13 12
     </div>
14 13
 <?

+ 0
- 11
classes/torrents.class.php View File

@@ -500,17 +500,6 @@ class Torrents {
500 500
           )
501 501
       WHERE ID = '$GroupID'");
502 502
 
503
-    // Fetch album vote score
504
-    G::$DB->query("
505
-      SELECT Score
506
-      FROM torrents_votes
507
-      WHERE GroupID = $GroupID");
508
-    if (G::$DB->has_results()) {
509
-      list($VoteScore) = G::$DB->next_record();
510
-    } else {
511
-      $VoteScore = 0;
512
-    }
513
-
514 503
     // Fetch album artists
515 504
     G::$DB->query("
516 505
       SELECT GROUP_CONCAT(ag.Name separator ' ')

+ 0
- 314
classes/votes.class.php View File

@@ -1,314 +0,0 @@
1
-<?
2
-class Votes {
3
-  /**
4
-   * Confidence level for binomial scoring
5
-   */
6
-  //const Z_VAL = 1.645211440143815; // p-value .95
7
-  const Z_VAL = 1.281728756502709; // p-value .90
8
-
9
-  /**
10
-   * Generate voting links for torrent pages, etc.
11
-   * @param $GroupID
12
-   * @param $Vote The pre-existing vote, if it exists 'Up'|'Down'
13
-   */
14
-  public static function vote_link($GroupID, $Vote = '') {
15
-    if (!G::$LoggedUser['NoVoteLinks'] && check_perms('site_album_votes')) { ?>
16
-      <span class="votespan brackets" style="white-space: nowrap;">
17
-        Vote:
18
-        <a href="#" onclick="UpVoteGroup(<?=$GroupID?>, '<?=G::$LoggedUser['AuthKey']?>'); return false;" class="tooltip small_upvote vote_link_<?=$GroupID?><?=(!empty($Vote) ? ' hidden' : '')?>" style="font-weight: bolder;" title="Upvote">&and;</a>
19
-        <span class="tooltip voted_type small_upvoted voted_up_<?=$GroupID?><?=(($Vote == 'Down' || empty($Vote)) ? ' hidden' : '')?>" style="font-weight: bolder;" title="Upvoted">&and;</span>
20
-        <a href="#" onclick="DownVoteGroup(<?=$GroupID?>, '<?=G::$LoggedUser['AuthKey']?>'); return false;" class="tooltip small_downvote vote_link_<?=$GroupID?><?=(!empty($Vote) ? ' hidden' : '')?>" style="font-weight: bolder;" title="Downvote">&or;</a>
21
-        <span class="tooltip voted_type small_downvoted voted_down_<?=$GroupID?><?=(($Vote == 'Up' || empty($Vote)) ? ' hidden' : '')?>" style="font-weight: bolder;" title="Downvoted">&or;</span>
22
-        <a href="#" onclick="UnvoteGroup(<?=$GroupID?>, '<?=G::$LoggedUser['AuthKey']?>'); return false;" class="tooltip small_clearvote vote_clear_<?=$GroupID?><?=(empty($Vote) ? ' hidden' : '')?>" title="Clear your vote">x</a>
23
-      </span>
24
-<?    }
25
-  }
26
-
27
-  /**
28
-   * Returns an array with User Vote data: GroupID and vote type
29
-   * @param string|int $UserID
30
-   * @return array GroupID=>(GroupID, 'Up'|'Down')
31
-   */
32
-  public static function get_user_votes($UserID) {
33
-    if ((int)$UserID == 0) {
34
-      return [];
35
-    }
36
-
37
-    $UserVotes = G::$Cache->get_value("voted_albums_$UserID");
38
-    if ($UserVotes === false) {
39
-      $QueryID = G::$DB->get_query_id();
40
-      G::$DB->query("
41
-        SELECT GroupID, Type
42
-        FROM users_votes
43
-        WHERE UserID = $UserID");
44
-      $UserVotes = G::$DB->to_array('GroupID', MYSQLI_ASSOC, false);
45
-      G::$DB->set_query_id($QueryID);
46
-      G::$Cache->cache_value("voted_albums_$UserID", $UserVotes);
47
-    }
48
-    return $UserVotes;
49
-  }
50
-
51
-  /**
52
-   * Returns an array with torrent group vote data
53
-   * @param string|int $GroupID
54
-   * @return array (Upvotes, Total Votes)
55
-   */
56
-  public static function get_group_votes($GroupID) {
57
-    if (!is_number($GroupID)) {
58
-      return array('Ups' => 0, 'Total' => 0);
59
-    }
60
-    $GroupVotes = G::$Cache->get_value("votes_$GroupID");
61
-    if ($GroupVotes === false) {
62
-      $QueryID = G::$DB->get_query_id();
63
-      G::$DB->query("
64
-        SELECT Ups AS Ups, Total AS Total
65
-        FROM torrents_votes
66
-        WHERE GroupID = $GroupID");
67
-      if (!G::$DB->has_results()) {
68
-        $GroupVotes = array('Ups' => 0, 'Total' => 0);
69
-      } else {
70
-        $GroupVotes = G::$DB->next_record(MYSQLI_ASSOC, false);
71
-      }
72
-      G::$DB->set_query_id($QueryID);
73
-      G::$Cache->cache_value("votes_$GroupID", $GroupVotes, 259200); // 3 days
74
-    }
75
-    return $GroupVotes;
76
-  }
77
-
78
-  /**
79
-   * Computes the inverse normal CDF of a p-value
80
-   * @param float $GroupID
81
-   * @return float Inverse Normal CDF
82
-   */
83
-  private function inverse_ncdf($p) {
84
-  /***************************************************************************
85
-   *                                inverse_ncdf.php
86
-   *                            -------------------
87
-   *   begin                : Friday, January 16, 2004
88
-   *   copyright            : (C) 2004 Michael Nickerson
89
-   *   email                : nickersonm@yahoo.com
90
-   *
91
-   ***************************************************************************/
92
-
93
-    //Inverse ncdf approximation by Peter John Acklam, implementation adapted to
94
-    //PHP by Michael Nickerson, using Dr. Thomas Ziegler's C implementation as
95
-    //a guide.  http://home.online.no/~pjacklam/notes/invnorm/index.html
96
-    //I have not checked the accuracy of this implementation. Be aware that PHP
97
-    //will truncate the coeficcients to 14 digits.
98
-
99
-    //You have permission to use and distribute this function freely for
100
-    //whatever purpose you want, but please show common courtesy and give credit
101
-    //where credit is due.
102
-
103
-    //Input paramater is $p - probability - where 0 < p < 1.
104
-
105
-    //Coefficients in rational approximations
106
-    $a = array(1 => -3.969683028665376e+01, 2 => 2.209460984245205e+02,
107
-           3 => -2.759285104469687e+02, 4 => 1.383577518672690e+02,
108
-           5 => -3.066479806614716e+01, 6 => 2.506628277459239e+00);
109
-
110
-    $b = array(1 => -5.447609879822406e+01, 2 => 1.615858368580409e+02,
111
-           3 => -1.556989798598866e+02, 4 => 6.680131188771972e+01,
112
-           5 => -1.328068155288572e+01);
113
-
114
-    $c = array(1 => -7.784894002430293e-03, 2 => -3.223964580411365e-01,
115
-           3 => -2.400758277161838e+00, 4 => -2.549732539343734e+00,
116
-           5 => 4.374664141464968e+00,  6 => 2.938163982698783e+00);
117
-
118
-    $d = array(1 => 7.784695709041462e-03, 2 => 3.224671290700398e-01,
119
-           3 => 2.445134137142996e+00, 4 => 3.754408661907416e+00);
120
-
121
-    //Define break-points.
122
-    $p_low  = 0.02425;                   //Use lower region approx. below this
123
-    $p_high = 1 - $p_low;                //Use upper region approx. above this
124
-
125
-    //Define/list variables (doesn't really need a definition)
126
-    //$p (probability), $sigma (std. deviation), and $mu (mean) are user inputs
127
-    $q = null; $x = null; $y = null; $r = null;
128
-
129
-    //Rational approximation for lower region.
130
-    if (0 < $p && $p < $p_low) {
131
-      $q = sqrt(-2 * log($p));
132
-      $x = ((((($c[1] * $q + $c[2]) * $q + $c[3]) * $q + $c[4]) * $q + $c[5]) *
133
-           $q + $c[6]) / (((($d[1] * $q + $d[2]) * $q + $d[3]) * $q + $d[4]) *
134
-           $q + 1);
135
-    }
136
-
137
-    //Rational approximation for central region.
138
-    elseif ($p_low <= $p && $p <= $p_high) {
139
-      $q = $p - 0.5;
140
-      $r = $q * $q;
141
-      $x = ((((($a[1] * $r + $a[2]) * $r + $a[3]) * $r + $a[4]) * $r + $a[5]) *
142
-           $r + $a[6]) * $q / ((((($b[1] * $r + $b[2]) * $r + $b[3]) * $r +
143
-           $b[4]) * $r + $b[5]) * $r + 1);
144
-    }
145
-
146
-    //Rational approximation for upper region.
147
-    elseif ($p_high < $p && $p < 1) {
148
-      $q = sqrt(-2 * log(1 - $p));
149
-      $x = -((((($c[1] * $q + $c[2]) * $q + $c[3]) * $q + $c[4]) * $q +
150
-           $c[5]) * $q + $c[6]) / (((($d[1] * $q + $d[2]) * $q + $d[3]) *
151
-           $q + $d[4]) * $q + 1);
152
-    }
153
-
154
-    //If 0 < p < 1, return a null value
155
-    else {
156
-      $x = null;
157
-    }
158
-
159
-    return $x;
160
-    //END inverse ncdf implementation.
161
-  }
162
-
163
-  /**
164
-   * Implementation of the algorithm described at http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
165
-   * @param int $Ups Number of upvotes
166
-   * @param int $Total Number of total votes
167
-   * @return float Ranking score
168
-   */
169
-  public static function binomial_score($Ups, $Total) {
170
-    if (($Total <= 0) || ($Ups < 0)) {
171
-      return 0;
172
-    }
173
-    $phat = $Ups / $Total;
174
-    $Numerator = ($phat + self::Z_VAL * self::Z_VAL / (2 * $Total) - self::Z_VAL * sqrt(($phat * (1 - $phat) + self::Z_VAL * self::Z_VAL / (4 * $Total)) / $Total));
175
-    $Denominator = (1 + self::Z_VAL * self::Z_VAL / $Total);
176
-    return ($Numerator / $Denominator);
177
-  }
178
-
179
-  /**
180
-   * Gets where this album ranks overall, for its year, and for its decade.  This is really just a wrapper.
181
-   * @param int $GroupID GroupID of the album
182
-   * @param int $Year Year it was released
183
-   * @return array ('overall'=><overall rank>, 'year'=><rank for its year>, 'decade'=><rank for its decade>)
184
-   */
185
-  public static function get_ranking($GroupID, $Year) {
186
-    $GroupID = (int)$GroupID;
187
-    $Year = (int)$Year;
188
-    if ($GroupID <= 0 || $Year <= 0) {
189
-      return false;
190
-    }
191
-
192
-    return array(
193
-        'overall' => Votes::get_rank_all($GroupID),
194
-        'year'    => Votes::get_rank_year($GroupID, $Year),
195
-        'decade'  => Votes::get_rank_decade($GroupID, $Year));
196
-  }
197
-
198
-  /**
199
-   * Gets where this album ranks overall.
200
-   * @param int $GroupID GroupID of the album
201
-   * @return int Rank
202
-   */
203
-  public static function get_rank_all($GroupID) {
204
-    $GroupID = (int)$GroupID;
205
-    if ($GroupID <= 0) {
206
-      return false;
207
-    }
208
-
209
-    $Rankings = G::$Cache->get_value('voting_ranks_overall');
210
-    if ($Rankings === false) {
211
-      $QueryID = G::$DB->get_query_id();
212
-      G::$DB->query('
213
-        SELECT GroupID, Score
214
-        FROM torrents_votes
215
-        ORDER BY Score DESC
216
-        LIMIT 100');
217
-      $Rankings = self::calc_ranks(G::$DB->to_pair(0, 1, false));
218
-      G::$DB->set_query_id($QueryID);
219
-      G::$Cache->cache_value('voting_ranks_overall', $Rankings, 259200); // 3 days
220
-    }
221
-
222
-    return ($Rankings[$GroupID] ?? false);
223
-  }
224
-
225
-  /**
226
-   * Gets where this album ranks in its year.
227
-   * @param int $GroupID GroupID of the album
228
-   * @param int $Year Year it was released
229
-   * @return int Rank for its year
230
-   */
231
-  public static function get_rank_year($GroupID, $Year) {
232
-    $GroupID = (int)$GroupID;
233
-    $Year = (int)$Year;
234
-    if ($GroupID <= 0 || $Year <= 0) {
235
-      return false;
236
-    }
237
-
238
-    $Rankings = G::$Cache->get_value("voting_ranks_year_$Year");
239
-    if ($Rankings === false) {
240
-      $QueryID = G::$DB->get_query_id();
241
-      G::$DB->query("
242
-        SELECT GroupID, Score
243
-        FROM torrents_votes  AS v
244
-          JOIN torrents_group AS g ON g.ID = v.GroupID
245
-        WHERE g.Year = $Year
246
-        ORDER BY Score DESC
247
-        LIMIT 100");
248
-      $Rankings = self::calc_ranks(G::$DB->to_pair(0, 1, false));
249
-      G::$DB->set_query_id($QueryID);
250
-      G::$Cache->cache_value("voting_ranks_year_$Year", $Rankings, 259200); // 3 days
251
-    }
252
-
253
-    return ($Rankings[$GroupID] ?? false);
254
-  }
255
-
256
-  /**
257
-   * Gets where this album ranks in its decade.
258
-   * @param int $GroupID GroupID of the album
259
-   * @param int $Year Year it was released
260
-   * @return int Rank for its year
261
-   */
262
-  public static function get_rank_decade($GroupID, $Year) {
263
-    $GroupID = (int)$GroupID;
264
-    $Year = (int)$Year;
265
-    if ($GroupID <= 0 || $Year <= 0) {
266
-      return false;
267
-    }
268
-
269
-    // First year of the decade
270
-    $Year = $Year - ($Year % 10);
271
-
272
-    $Rankings = G::$Cache->get_value("voting_ranks_decade_$Year");
273
-    if ($Rankings === false) {
274
-      $QueryID = G::$DB->get_query_id();
275
-      G::$DB->query("
276
-        SELECT GroupID, Score
277
-        FROM torrents_votes  AS v
278
-          JOIN torrents_group AS g ON g.ID = v.GroupID
279
-        WHERE g.Year BETWEEN $Year AND " . ($Year + 9) . "
280
-            AND g.CategoryID = 1
281
-        ORDER BY Score DESC
282
-        LIMIT 100");
283
-      $Rankings = self::calc_ranks(G::$DB->to_pair(0, 1, false));
284
-      G::$DB->set_query_id($QueryID);
285
-      G::$Cache->cache_value("voting_ranks_decade_$Year", $Rankings, 259200); // 3 days
286
-    }
287
-
288
-    return ($Rankings[$GroupID] ?? false);
289
-  }
290
-
291
-  /**
292
-   * Turn vote scores into vote ranks. This basically only sorts out tied ranks
293
-   *
294
-   * @param array $GroupScores array (<GroupID> => <Score>) ordered by Score
295
-   * @return array (<GroupID> => <Rank>)
296
-   */
297
-  public static function calc_ranks($GroupScores) {
298
-    $Rankings = [];
299
-    $PrevScore = $PrevRank = false;
300
-    $Rank = 1;
301
-    foreach ($GroupScores as $GroupID => $Score) {
302
-      if ($Score === $PrevScore) {
303
-        $Rankings[$GroupID] = $PrevRank;
304
-      } else {
305
-        $Rankings[$GroupID] = $Rank;
306
-        $PrevRank = $Rank;
307
-        $PrevScore = $Score;
308
-      }
309
-      $Rank++;
310
-    }
311
-    return $Rankings;
312
-  }
313
-}
314
-?>

+ 0
- 46
gazelle.sql View File

@@ -53,28 +53,6 @@ CREATE TABLE `artists_group` (
53 53
   KEY `RevisionID` (`RevisionID`)
54 54
 ) ENGINE=InnoDB CHARSET=utf8;
55 55
 
56
-CREATE TABLE `artists_similar` (
57
-  `ArtistID` int(10) NOT NULL DEFAULT '0',
58
-  `SimilarID` int(12) NOT NULL DEFAULT '0',
59
-  PRIMARY KEY (`ArtistID`,`SimilarID`),
60
-  KEY `ArtistID` (`ArtistID`),
61
-  KEY `SimilarID` (`SimilarID`)
62
-) ENGINE=InnoDB CHARSET=utf8;
63
-
64
-CREATE TABLE `artists_similar_scores` (
65
-  `SimilarID` int(12) NOT NULL AUTO_INCREMENT,
66
-  `Score` int(10) NOT NULL DEFAULT '0',
67
-  PRIMARY KEY (`SimilarID`),
68
-  KEY `Score` (`Score`)
69
-) ENGINE=InnoDB CHARSET=utf8;
70
-
71
-CREATE TABLE `artists_similar_votes` (
72
-  `SimilarID` int(12) NOT NULL,
73
-  `UserID` int(10) NOT NULL,
74
-  `Way` enum('up','down') NOT NULL DEFAULT 'up',
75
-  PRIMARY KEY (`SimilarID`,`UserID`,`Way`)
76
-) ENGINE=InnoDB CHARSET=utf8;
77
-
78 56
 CREATE TABLE `artists_tags` (
79 57
   `TagID` int(10) NOT NULL DEFAULT '0',
80 58
   `ArtistID` int(10) NOT NULL DEFAULT '0',
@@ -1275,16 +1253,6 @@ CREATE TABLE `torrents_tags_votes` (
1275 1253
   PRIMARY KEY (`GroupID`,`TagID`,`UserID`,`Way`)
1276 1254
 ) ENGINE=InnoDB CHARSET=utf8;
1277 1255
 
1278
-CREATE TABLE `torrents_votes` (
1279
-  `GroupID` int(10) NOT NULL,
1280
-  `Ups` int(10) unsigned NOT NULL DEFAULT '0',
1281
-  `Total` int(10) unsigned NOT NULL DEFAULT '0',
1282
-  `Score` float NOT NULL DEFAULT '0',
1283
-  PRIMARY KEY (`GroupID`),
1284
-  KEY `Score` (`Score`),
1285
-  CONSTRAINT `torrents_votes_ibfk_1` FOREIGN KEY (`GroupID`) REFERENCES `torrents_group` (`ID`) ON DELETE CASCADE
1286
-) ENGINE=InnoDB CHARSET=utf8;
1287
-
1288 1256
 CREATE TABLE `user_questions` (
1289 1257
   `ID` int(10) NOT NULL AUTO_INCREMENT,
1290 1258
   `Question` mediumtext,
@@ -1691,20 +1659,6 @@ CREATE TABLE `users_torrent_history_temp` (
1691 1659
   PRIMARY KEY (`UserID`)
1692 1660
 ) ENGINE=InnoDB CHARSET=utf8;
1693 1661
 
1694
-CREATE TABLE `users_votes` (
1695
-  `UserID` int(10) unsigned NOT NULL,
1696
-  `GroupID` int(10) NOT NULL,
1697
-  `Type` enum('Up','Down') DEFAULT NULL,
1698
-  `Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
1699
-  PRIMARY KEY (`UserID`,`GroupID`),
1700
-  KEY `GroupID` (`GroupID`),
1701
-  KEY `Type` (`Type`),
1702
-  KEY `Time` (`Time`),
1703
-  KEY `Vote` (`Type`,`GroupID`,`UserID`),
1704
-  CONSTRAINT `users_votes_ibfk_1` FOREIGN KEY (`GroupID`) REFERENCES `torrents_group` (`ID`) ON DELETE CASCADE,
1705
-  CONSTRAINT `users_votes_ibfk_2` FOREIGN KEY (`UserID`) REFERENCES `users_main` (`ID`) ON DELETE CASCADE
1706
-) ENGINE=InnoDB CHARSET=utf8;
1707
-
1708 1662
 CREATE TABLE `users_warnings_forums` (
1709 1663
   `UserID` int(10) unsigned NOT NULL,
1710 1664
   `Comment` text,

+ 2
- 42
sections/ajax/artist.php View File

@@ -42,8 +42,7 @@ if (!empty($_GET['revisionid'])) { // if they're viewing an old revision
42 42
   $RevisionID = false;
43 43
 }
44 44
 if ($Data) {
45
-//  list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, , , $VanityHouseArtist)) = each($Data);
46
-  list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, , )) = each($Data);
45
+  list($K, list($Name, $Image, $Body)) = each($Data);
47 46
 } else {
48 47
   if ($RevisionID) {
49 48
   /*
@@ -290,44 +289,6 @@ foreach ($GroupIDs as $GroupID) {
290 289
   );
291 290
 }
292 291
 
293
-$JsonSimilar = [];
294
-if (empty($SimilarArray)) {
295
-  $DB->query("
296
-    SELECT
297
-      s2.ArtistID,
298
-      a.Name,
299
-      ass.Score,
300
-      ass.SimilarID
301
-    FROM artists_similar AS s1
302
-      JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID AND s1.ArtistID != s2.ArtistID
303
-      JOIN artists_similar_scores AS ass ON ass.SimilarID = s1.SimilarID
304
-      JOIN artists_group AS a ON a.ArtistID = s2.ArtistID
305
-    WHERE s1.ArtistID = '$ArtistID'
306
-    ORDER BY ass.Score DESC
307
-    LIMIT 30
308
-  ");
309
-  $SimilarArray = $DB->to_array();
310
-  foreach ($SimilarArray as $Similar) {
311
-    $JsonSimilar[] = array(
312
-      'artistId' => (int)$Similar['ArtistID'],
313
-      'name' => $Similar['Name'],
314
-      'score' => (int)$Similar['Score'],
315
-      'similarId' => (int)$Similar['SimilarID']
316
-    );
317
-  }
318
-  $NumSimilar = count($SimilarArray);
319
-} else {
320
-  //If data already exists, use it
321
-  foreach ($SimilarArray as $Similar) {
322
-    $JsonSimilar[] = array(
323
-      'artistId' => (int)$Similar['ArtistID'],
324
-      'name' => $Similar['Name'],
325
-      'score' => (int)$Similar['Score'],
326
-      'similarId' => (int)$Similar['SimilarID']
327
-    );
328
-  }
329
-}
330
-
331 292
 $JsonRequests = [];
332 293
 foreach ($Requests as $RequestID => $Request) {
333 294
   $JsonRequests[] = array(
@@ -369,7 +330,7 @@ if ($RevisionID) {
369 330
   $Key = "artist_$ArtistID";
370 331
 }
371 332
 
372
-$Data = array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, [], [], $VanityHouseArtist));
333
+$Data = array(array($Name, $Image, $Body));
373 334
 
374 335
 $Cache->cache_value($Key, $Data, 3600);
375 336
 
@@ -382,7 +343,6 @@ json_die("success", array(
382 343
   'body' => Text::full_format($Body),
383 344
   'vanityHouse' => $VanityHouseArtist == 1,
384 345
   'tags' => array_values($Tags),
385
-  'similarArtists' => $JsonSimilar,
386 346
   'statistics' => array(
387 347
     'numGroups' => $NumGroups,
388 348
     'numTorrents' => $NumTorrents,

+ 0
- 42
sections/ajax/similar_artists.php View File

@@ -1,42 +0,0 @@
1
-<?php
2
-
3
-if (empty($_GET['id']) || !is_number($_GET['id']) || empty($_GET['limit']) || !is_number($_GET['limit'])) {
4
-  print
5
-    json_encode(
6
-      array(
7
-        'status' => 'failure'
8
-      )
9
-    );
10
-  die();
11
-}
12
-
13
-$artist_id = $_GET["id"];
14
-$artist_limit = $_GET["limit"];
15
-
16
-$DB->query("
17
-    SELECT
18
-      s2.ArtistID,
19
-      ag.Name,
20
-      ass.Score
21
-    FROM artists_similar AS s1
22
-      JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID AND s1.ArtistID != s2.ArtistID
23
-      JOIN artists_similar_scores AS ass ON ass.SimilarID = s1.SimilarID
24
-      JOIN artists_group AS ag ON ag.ArtistID = s2.ArtistID
25
-    WHERE s1.ArtistID = $artist_id
26
-    ORDER BY ass.Score DESC
27
-    LIMIT $artist_limit");
28
-
29
-
30
-    while (list($ArtistID, $Name, $Score) = $DB->next_record(MYSQLI_NUM, false)) {
31
-      if ($Score < 0) {
32
-        continue;
33
-      }
34
-      $results[] = array(
35
-          'id' => (int)$ArtistID,
36
-          'name' => $Name,
37
-          'score' => (int)$Score);
38
-    }
39
-
40
-print json_encode($results);
41
-exit();
42
-?>

+ 0
- 214
sections/ajax/takevote.php View File

@@ -1,214 +0,0 @@
1
-<?
2
-authorize();
3
-
4
-$GroupID = $_REQUEST['groupid'];
5
-if (!is_number($GroupID)) {
6
-  echo 'Invalid Group';
7
-  die();
8
-}
9
-
10
-// What groups has this guy voted?
11
-$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
12
-
13
-// What are the votes for this group?
14
-$GroupVotes = Votes::get_group_votes($GroupID);
15
-
16
-$UserID = $LoggedUser['ID'];
17
-if ($_REQUEST['do'] == 'vote') {
18
-  if (isset($UserVotes[$GroupID]) || !check_perms('site_album_votes')) {
19
-    echo 'noaction';
20
-    die();
21
-  }
22
-  if ($_REQUEST['vote'] != 'up' && $_REQUEST['vote'] != 'down') {
23
-    echo 'badvote';
24
-    die();
25
-  }
26
-  $Type = ($_REQUEST['vote'] == 'up') ? 'Up' : 'Down';
27
-
28
-  // Update the two votes tables if needed
29
-  $DB->query("
30
-    INSERT IGNORE INTO users_votes (UserID, GroupID, Type)
31
-    VALUES ($UserID, $GroupID, '$Type')");
32
-  if ($DB->affected_rows() == 0) {
33
-    echo 'noaction';
34
-    die();
35
-  }
36
-
37
-  // Update the group's cache key
38
-  $GroupVotes['Total'] += 1;
39
-  if ($Type == 'Up') {
40
-    $GroupVotes['Ups'] += 1;
41
-  }
42
-  $Cache->cache_value("votes_$GroupID", $GroupVotes);
43
-
44
-  // If the group has no votes yet, we need an insert, otherwise an update
45
-  // so we can cut corners and use the magic of INSERT...ON DUPLICATE KEY UPDATE...
46
-  // to accomplish both in one query
47
-  $DB->query("
48
-    INSERT INTO torrents_votes
49
-      (GroupID, Total, Ups, Score)
50
-    VALUES
51
-      ($GroupID, 1, ".($Type == 'Up' ? 1 : 0).", 0)
52
-    ON DUPLICATE KEY UPDATE
53
-      Total = Total + 1,
54
-      Score = IFNULL(binomial_ci(Ups".($Type == 'Up' ? '+1' : '').", Total), 0)".
55
-        ($Type == 'Up' ? ', Ups = Ups + 1' : ''));
56
-
57
-  $UserVotes[$GroupID] = array('GroupID' => $GroupID, 'Type' => $Type);
58
-
59
-  // Update this guy's cache key
60
-  $Cache->cache_value('voted_albums_'.$LoggedUser['ID'], $UserVotes);
61
-
62
-  // Update the paired cache keys for "people who liked"
63
-  // First update this album's paired votes. If this keys is magically not set,
64
-  // our life just got a bit easier. We're only tracking paired votes on upvotes.
65
-  if ($Type == 'Up') {
66
-    $VotePairs = $Cache->get_value("vote_pairs_$GroupID", true);
67
-    if ($VotePairs !== false) {
68
-      foreach ($UserVotes as $Vote) {
69
-        if ($Vote['GroupID'] == $GroupID) {
70
-          continue;
71
-        }
72
-        // Go through each of his other votes, incrementing the
73
-        // corresponding keys in this groups vote_pairs array
74
-        if (isset($VotePairs[$Vote['GroupID']])) {
75
-          $VotePairs[$Vote['GroupID']]['Total'] += 1;
76
-          if ($Vote['Type'] == 'Up') {
77
-            $VotePairs[$Vote['GroupID']]['Ups'] += 1;
78
-          }
79
-        } else {
80
-          $VotePairs[$Vote['GroupID']] = array(
81
-                'GroupID' => $Vote['GroupID'],
82
-                'Total' => 1,
83
-                'Ups' => ($Type == 'Up') ? 1 : 0);
84
-        }
85
-      }
86
-    }
87
-    $Cache->cache_value("vote_pairs_$GroupID", $VotePairs, 21600);
88
-  }
89
-
90
-  // Now do the paired votes keys for all of this guy's other votes
91
-  foreach ($UserVotes as $VGID => $Vote) {
92
-    if ($Vote['Type'] != 'Up') {
93
-      // We're only track paired votes on upvotes
94
-      continue;
95
-    }
96
-    if ($VGID == $GroupID) {
97
-      continue;
98
-    }
99
-    // Again, if the cache key is not set, move along
100
-    $VotePairs = $Cache->get_value("vote_pairs_$VGID", true);
101
-    if ($VotePairs !== false) {
102
-      // Go through all of the other albums paired to this one, and update
103
-      // this group's entry in their vote_pairs keys
104
-      if (isset($VotePairs[$GroupID])) {
105
-        $VotePairs[$GroupID]['Total']++;
106
-        if ($Type == 'Up') {
107
-          $VotePairs[$GroupID]['Ups']++;
108
-        }
109
-      } else {
110
-        $VotePairs[$GroupID] = array(
111
-              'GroupID' => $GroupID,
112
-              'Total' => 1,
113
-              'Ups' => ($Type == 'Up') ? 1 : 0);
114
-      }
115
-      $Cache->cache_value("vote_pairs_$VGID", $VotePairs, 21600);
116
-    }
117
-  }
118
-
119
-  echo 'success';
120
-} elseif ($_REQUEST['do'] == 'unvote') {
121
-  if (!isset($UserVotes[$GroupID])) {
122
-    echo 'noaction';
123
-    die();
124
-  }
125
-  $Type = $UserVotes[$GroupID]['Type'];
126
-
127
-  $DB->query("
128
-    DELETE FROM users_votes
129
-    WHERE UserID = $UserID
130
-      AND GroupID = $GroupID");
131
-
132
-  // Update personal cache key
133
-  unset($UserVotes[$GroupID]);
134
-  $Cache->cache_value('voted_albums_'.$LoggedUser['ID'], $UserVotes);
135
-
136
-  // Update the group's cache key
137
-  $GroupVotes['Total'] -= 1;
138
-  if ($Type == 'Up') {
139
-    $GroupVotes['Ups'] -= 1;
140
-  }
141
-  $Cache->cache_value("votes_$GroupID", $GroupVotes);
142
-
143
-  $DB->query('
144
-    UPDATE torrents_votes
145
-    SET
146
-      Total = GREATEST(0, Total - 1),
147
-      Score = IFNULL(binomial_ci(GREATEST(0, Ups'.($Type == 'Up' ? '-1' : '').'), GREATEST(0, Total)), 0)'.
148
-      ($Type == 'Up' ? ', Ups = GREATEST(0, Ups - 1)' : '')."
149
-    WHERE GroupID=$GroupID");
150
-  // Update paired cache keys
151
-  // First update this album's paired votes. If this keys is magically not set,
152
-  // our life just got a bit easier. We're only tracking paired votes on upvotes.
153
-  if ($Type == 'Up') {
154
-    $VotePairs = $Cache->get_value("vote_pairs_$GroupID", true);
155
-    if ($VotePairs !== false) {
156
-      foreach ($UserVotes as $Vote) {
157
-        if (isset($VotePairs[$Vote['GroupID']])) {
158
-          if ($VotePairs[$Vote['GroupID']]['Total'] == 0) {
159
-            // Something is screwy
160
-            $Cache->delete_value("vote_pairs_$GroupID");
161
-            continue;
162
-          }
163
-          $VotePairs[$Vote['GroupID']]['Total'] -= 1;
164
-          if ($Vote['Type'] == 'Up') {
165
-            $VotePairs[$Vote['GroupID']]['Ups'] -= 1;
166
-          }
167
-        } else {
168
-          // Something is screwy, kill the key and move on
169
-          $Cache->delete_value("vote_pairs_$GroupID");
170
-          break;
171
-        }
172
-      }
173
-    }
174
-    $Cache->cache_value("vote_pairs_$GroupID", $VotePairs, 21600);
175
-  }
176
-
177
-  // Now do the paired votes keys for all of this guy's other votes
178
-  foreach ($UserVotes as $VGID => $Vote) {
179
-    if ($Vote['Type'] != 'Up') {
180
-      // We're only track paired votes on upvotes
181
-      continue;
182
-    }
183
-    if ($VGID == $GroupID) {
184
-      continue;
185
-    }
186
-    // Again, if the cache key is not set, move along
187
-    $VotePairs = $Cache->get_value("vote_pairs_$VGID", true);
188
-    if ($VotePairs !== false) {
189
-      if (isset($VotePairs[$GroupID])) {
190
-        if ($VotePairs[$GroupID]['Total'] == 0) {
191
-          // Something is screwy
192
-          $Cache->delete_value("vote_pairs_$VGID");
193
-          continue;
194
-        }
195
-        $VotePairs[$GroupID]['Total'] -= 1;
196
-        if ($Type == 'Up') {
197
-          $VotePairs[$GroupID]['Ups'] -= 1;
198
-        }
199
-        $Cache->cache_value("vote_pairs_$VGID", $VotePairs, 21600);
200
-      } else {
201
-        // Something is screwy, kill the key and move on
202
-        $Cache->delete_value("vote_pairs_$VGID");
203
-      }
204
-    }
205
-  }
206
-
207
-  // Let the script know what happened
208
-  if ($Type == 'Up') {
209
-    echo 'success-up';
210
-  } else {
211
-    echo 'success-down';
212
-  }
213
-}
214
-?>

+ 0
- 70
sections/artist/add_similar.php View File

@@ -1,70 +0,0 @@
1
-<?
2
-authorize();
3
-
4
-$UserID = $LoggedUser['ID'];
5
-$Artist1ID = db_string($_POST['artistid']);
6
-$Artist2Name = db_string($_POST['artistname']);
7
-
8
-if (!is_number($Artist1ID)) {
9
-  error(0);
10
-}
11
-
12
-if (empty($Artist2Name)) {
13
-  error('Blank artist name.');
14
-}
15
-
16
-$DB->query("
17
-  SELECT ArtistID
18
-  FROM artists_group
19
-  WHERE Name LIKE '$Artist2Name'");
20
-list($Artist2ID) = $DB->next_record();
21
-
22
-if (!empty($Artist2ID)) { // artist was found in the database
23
-
24
-  // Let's see if there's already a similar artists field for these two
25
-  $DB->query("
26
-    SELECT s1.SimilarID
27
-    FROM artists_similar AS s1
28
-      JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID
29
-    WHERE s1.ArtistID = '$Artist1ID'
30
-      AND s2.ArtistID = '$Artist2ID'");
31
-  list($SimilarID) = $DB->next_record();
32
-
33
-  if ($SimilarID) { // The similar artists field already exists, just update the score
34
-    $DB->query("
35
-      UPDATE artists_similar_scores
36
-      SET Score = Score + 200
37
-      WHERE SimilarID = '$SimilarID'");
38
-  } else { // No, it doesn't exist - create it
39
-    $DB->query("
40
-      INSERT INTO artists_similar_scores (Score)
41
-      VALUES ('200')");
42
-    $SimilarID = $DB->inserted_id();
43
-    $DB->query("
44
-      INSERT INTO artists_similar (ArtistID, SimilarID)
45
-      VALUES ('$Artist1ID', '$SimilarID')");
46
-    $DB->query("
47
-      INSERT INTO artists_similar (ArtistID, SimilarID)
48
-      VALUES ('$Artist2ID', '$SimilarID')");
49
-  }
50
-
51
-  $DB->query("
52
-    SELECT SimilarID
53
-    FROM artists_similar_votes
54
-    WHERE SimilarID = '$SimilarID'
55
-      AND UserID = '$UserID'
56
-      AND Way = 'up'");
57
-  if (!$DB->has_results()) {
58
-    $DB->query("
59
-      INSERT INTO artists_similar_votes (SimilarID, UserID, way)
60
-      VALUES ('$SimilarID', '$UserID', 'up')");
61
-  }
62
-
63
-  $Cache->delete_value("artist_$Artist1ID"); // Delete artist cache
64
-  $Cache->delete_value("artist_$Artist2ID"); // Delete artist cache
65
-  $Cache->delete_value("similar_positions_$Artist1ID"); // Delete artist's similar map cache
66
-  $Cache->delete_value("similar_positions_$Artist2ID"); // Delete artist's similar map cache
67
-}
68
-
69
-header('Location: '.$_SERVER['HTTP_REFERER']);
70
-?>

+ 4
- 182
sections/artist/artist.php View File

@@ -6,17 +6,11 @@ function compare($X, $Y) {
6 6
   return($Y['count'] - $X['count']);
7 7
 }
8 8
 
9
-// Similar Artist Map
10
-include(SERVER_ROOT.'/classes/artists_similar.class.php');
11
-
12
-$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
13
-
14 9
 $ArtistID = $_GET['id'];
15 10
 if (!is_number($ArtistID)) {
16 11
   error(0);
17 12
 }
18 13
 
19
-
20 14
 if (!empty($_GET['revisionid'])) { // if they're viewing an old revision
21 15
   $RevisionID = $_GET['revisionid'];
22 16
   if (!is_number($RevisionID)) {
@@ -29,8 +23,7 @@ if (!empty($_GET['revisionid'])) { // if they're viewing an old revision
29 23
 }
30 24
 
31 25
 if ($Data) {
32
-  #list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray, , , $VanityHouseArtist)) = each($Data);
33
-  list($K, list($Name, $Image, $Body, $NumSimilar, $SimilarArray)) = each($Data);
26
+  list($K, list($Name, $Image, $Body)) = each($Data);
34 27
 } else {
35 28
   if ($RevisionID) {
36 29
     $sql = "
@@ -262,10 +255,7 @@ foreach ($TorrentList as $Group) {
262 255
             <span class="add_bookmark float_right">
263 256
               <a style="float: right;" href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
264 257
             </span>
265
-<?  }
266
-    $VoteType = isset($UserVotes[$GroupID]['Type']) ? $UserVotes[$GroupID]['Type'] : '';
267
-    Votes::vote_link($GroupID, $VoteType);
268
-?>
258
+<?  } ?>
269 259
             <div class="tags"><?=$TorrentTags->format('torrents.php?taglist=', $Name)?></div>
270 260
           </div>
271 261
         </td>
@@ -411,7 +401,7 @@ $TorrentDisplayList = ob_get_clean();
411 401
 // Comments (must be loaded before View::show_header so that subscriptions and quote notifications are handled properly)
412 402
 list($NumComments, $Page, $Thread, $LastRead) = Comments::load('artist', $ArtistID);
413 403
 
414
-View::show_header($Name, 'browse,requests,bbcode,comments,voting,recommend,subscriptions');
404
+View::show_header($Name, 'browse,requests,bbcode,comments,recommend,subscriptions');
415 405
 ?>
416 406
 <div class="thin">
417 407
   <div class="header">
@@ -572,75 +562,6 @@ foreach ($ZIPOptions as $Option) {
572 562
         <li>Number of snatches: <?=number_format($NumSnatches)?></li>
573 563
       </ul>
574 564
     </div>
575
-<?
576
-
577
-
578
-if (empty($SimilarArray)) {
579
-  $DB->query("
580
-    SELECT
581
-      s2.ArtistID,
582
-      a.Name,
583
-      ass.Score,
584
-      ass.SimilarID
585
-    FROM artists_similar AS s1
586
-      JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID AND s1.ArtistID != s2.ArtistID
587
-      JOIN artists_similar_scores AS ass ON ass.SimilarID = s1.SimilarID
588
-      JOIN artists_group AS a ON a.ArtistID = s2.ArtistID
589
-    WHERE s1.ArtistID = '$ArtistID'
590
-    ORDER BY ass.Score DESC
591
-    LIMIT 30
592
-  ");
593
-  $SimilarArray = $DB->to_array();
594
-  $NumSimilar = count($SimilarArray);
595
-}
596
-?>
597
-    <div class="box box_artists">
598
-      <div class="head"><strong>Similar</strong></div>
599
-      <ul class="stats nobullet">
600
-<?  if ($NumSimilar == 0) { ?>
601
-        <li><span style="font-style: italic;">None found</span></li>
602
-<?
603
-  }
604
-  $First = true;
605
-  foreach ($SimilarArray as $SimilarArtist) {
606
-    list($Artist2ID, $Artist2Name, $Score, $SimilarID) = $SimilarArtist;
607
-    $Score = $Score / 100;
608
-    if ($First) {
609
-      $Max = $Score + 1;
610
-      $First = false;
611
-    }
612
-
613
-    $FontSize = (ceil(((($Score - 2) / $Max - 2) * 4))) + 8;
614
-
615
-?>
616
-        <li>
617
-          <span class="tooltip" title="<?=$Score?>"><a href="artist.php?id=<?=$Artist2ID?>" style="float: left; display: block;"><?=$Artist2Name?></a></span>
618
-          <div style="float: right; display: block; letter-spacing: -1px;">
619
-            <a href="artist.php?action=vote_similar&amp;artistid=<?=$ArtistID?>&amp;similarid=<?=$SimilarID?>&amp;way=up" class="tooltip brackets vote_artist_up" title="Vote up this similar artist. Use this when you feel that the two artists are quite similar.">&and;</a>
620
-            <a href="artist.php?action=vote_similar&amp;artistid=<?=$ArtistID?>&amp;similarid=<?=$SimilarID?>&amp;way=down" class="tooltip brackets vote_artist_down" title="Vote down this similar artist. Use this when you feel that the two artists are not all that similar.">&or;</a>
621
-<?    if (check_perms('site_delete_tag')) { ?>
622
-            <span class="remove remove_artist"><a href="artist.php?action=delete_similar&amp;similarid=<?=$SimilarID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="tooltip brackets" title="Remove this similar artist">X</a></span>
623
-<?    } ?>
624
-          </div>
625
-          <br style="clear: both;" />
626
-        </li>
627
-<?    } ?>
628
-      </ul>
629
-    </div>
630
-    <div class="box box_addartists box_addartists_similar">
631
-      <div class="head"><strong>Add similar</strong></div>
632
-      <ul class="nobullet">
633
-        <li>
634
-          <form class="add_form" name="similar_artists" action="artist.php" method="post">
635
-            <input type="hidden" name="action" value="add_similar" />
636
-            <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
637
-            <input type="hidden" name="artistid" value="<?=$ArtistID?>" />
638
-            <input type="text" autocomplete="off" id="artistsimilar" name="artistname" size="20"<? Users::has_autocomplete_enabled('other'); ?> />
639
-            <input type="submit" value="+" />
640
-          </form>
641
-        </li>
642
-      </ul>
643
-    </div>
644 565
   </div>
645 566
   <div class="main_column">
646 567
     <div id="artist_information" class="box">
@@ -780,105 +701,6 @@ if ($NumRequests > 0) {
780 701
 <?
781 702
 }
782 703
 
783
-// Similar Artist Map
784
-
785
-if ($NumSimilar > 0) {
786
-  if ($SimilarData = $Cache->get_value("similar_positions_$ArtistID")) {
787
-    $Similar = new ARTISTS_SIMILAR($ArtistID, $Name);
788
-    $Similar->load_data($SimilarData);
789
-    if (!(current($Similar->Artists)->NameLength)) {
790
-      unset($Similar);
791
-    }
792
-  }
793
-  if (empty($Similar) || empty($Similar->Artists)) {
794
-    include(SERVER_ROOT.'/classes/image.class.php');
795
-    $Img = new IMAGE;
796
-    $Img->create(WIDTH, HEIGHT);
797
-    $Img->color(255, 255, 255, 127);
798
-
799
-    $Similar = new ARTISTS_SIMILAR($ArtistID, $Name);
800
-    $Similar->set_up();
801
-    $Similar->set_positions();
802
-    $Similar->background_image();
803
-
804
-    $SimilarData = $Similar->dump_data();
805
-
806
-    $Cache->cache_value("similar_positions_$ArtistID", $SimilarData, 3600 * 24);
807
-  }
808
-?>
809
-    <div id="similar_artist_map" class="box">
810
-      <div id="flipper_head" class="head">
811
-        <a href="#">&uarr;</a>&nbsp;
812
-        <strong id="flipper_title">Similar Map</strong>
813
-        <a id="flip_to" class="brackets" href="#" onclick="flipView(); return false;">Switch to cloud</a>
814
-      </div>
815
-      <div id="flip_view_1" style="display: block; width: <?=(WIDTH)?>px; height: <?=(HEIGHT)?>px; position: relative; background-image: url(static/similar/<?=($ArtistID)?>.png?t=<?=(time())?>);">
816
-<?
817
-  $Similar->write_artists();
818
-?>
819
-      </div>
820
-      <div id="flip_view_2" style="display: none; width: <?=WIDTH?>px; height: <?=HEIGHT?>px;">
821
-        <canvas width="<?=WIDTH?>px" height="<?=(HEIGHT - 20)?>px" id="similarArtistsCanvas"></canvas>
822
-        <div id="artistTags" style="display: none;">
823
-          <ul><li></li></ul>
824
-        </div>
825
-        <strong style="margin-left: 10px;"><a id="currentArtist" href="#null">Loading...</a></strong>
826
-      </div>
827
-    </div>
828
-
829
-<script type="text/javascript">//<![CDATA[
830
-var cloudLoaded = false;
831
-
832
-function flipView() {
833
-  var state = document.getElementById('flip_view_1').style.display == 'block';
834
-
835
-  if (state) {
836
-    document.getElementById('flip_view_1').style.display = 'none';
837
-    document.getElementById('flip_view_2').style.display = 'block';
838
-    document.getElementById('flipper_title').innerHTML = 'Similar Cloud';
839
-    document.getElementById('flip_to').innerHTML = 'Switch to map';
840
-
841
-    if (!cloudLoaded) {
842
-      require("static/functions/tagcanvas.js", function () {
843
-        require("static/functions/artist_cloud.js", function () {
844
-        });
845
-      });
846
-      cloudLoaded = true;
847
-    }
848
-  }
849
-  else {
850
-    document.getElementById('flip_view_1').style.display = 'block';
851
-    document.getElementById('flip_view_2').style.display = 'none';
852
-    document.getElementById('flipper_title').innerHTML = 'Similar Map';
853
-    document.getElementById('flip_to').innerHTML = 'Switch to cloud';
854
-  }
855
-}
856
-
857
-//TODO move this to global, perhaps it will be used elsewhere in the future
858
-//http://stackoverflow.com/questions/7293344/load-javascript-dynamically
859
-function require(file, callback) {
860
-  var script = document.getElementsByTagName('script')[0],
861
-  newjs = document.createElement('script');
862
-
863
-  // IE
864
-  newjs.onreadystatechange = function () {
865
-    if (newjs.readyState === 'loaded' || newjs.readyState === 'complete') {
866
-      newjs.onreadystatechange = null;
867
-      callback();
868
-    }
869
-  };
870
-  // others
871
-  newjs.onload = function () {
872
-    callback();
873
-  };
874
-  newjs.src = file;
875
-  script.parentNode.insertBefore(newjs, script);
876
-}
877
-//]]>
878
-</script>
879
-
880
-<? }
881
-
882 704
 // --- Comments ---
883 705
 $Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9, '#comments');
884 706
 
@@ -919,7 +741,7 @@ if ($RevisionID) {
919 741
   $Key = "artist_$ArtistID";
920 742
 }
921 743
 
922
-$Data = array(array($Name, $Image, $Body, $NumSimilar, $SimilarArray, [], [], $VanityHouseArtist));
744
+$Data = array(array($Name, $Image, $Body));
923 745
 
924 746
 $Cache->cache_value($Key, $Data, 3600);
925 747
 ?>

+ 0
- 32
sections/artist/delete_similar.php View File

@@ -1,32 +0,0 @@
1
-<?php
2
-authorize();
3
-$SimilarID = db_string($_GET['similarid']);
4
-
5
-if (!is_number($SimilarID) || !$SimilarID) {
6
-  error(404);
7
-}
8
-if (!check_perms('site_delete_tag')) {
9
-  error(403);
10
-}
11
-$DB->query("
12
-  SELECT ArtistID
13
-  FROM artists_similar
14
-  WHERE SimilarID = '$SimilarID'");
15
-$ArtistIDs = $DB->to_array();
16
-$DB->query("
17
-  DELETE FROM artists_similar
18
-  WHERE SimilarID = '$SimilarID'");
19
-$DB->query("
20
-  DELETE FROM artists_similar_scores
21
-  WHERE SimilarID = '$SimilarID'");
22
-$DB->query("
23
-  DELETE FROM artists_similar_votes
24
-  WHERE SimilarID = '$SimilarID'");
25
-
26
-foreach ($ArtistIDs as $ArtistID) {
27
-  list($ArtistID) = $ArtistID;
28
-  $Cache->delete_value("artist_$ArtistID"); // Delete artist cache
29
-  $Cache->delete_value("similar_positions_$ArtistID");
30
-}
31
-header('Location: '.$_SERVER['HTTP_REFERER']);
32
-?>

+ 0
- 38
sections/artist/vote_similar.php View File

@@ -1,38 +0,0 @@
1
-<?
2
-$UserID = $LoggedUser['ID'];
3
-$SimilarID = db_string($_GET['similarid']);
4
-$ArtistID = db_string($_GET['artistid']);
5
-$Way = db_string($_GET['way']);
6
-
7
-if (!is_number($SimilarID) || !is_number($ArtistID)) {
8
-  error(404);
9
-}
10
-if (!in_array($Way, array('up', 'down'))) {
11
-  error(404);
12
-}
13
-
14
-$DB->query("
15
-  SELECT SimilarID
16
-  FROM artists_similar_votes
17
-  WHERE SimilarID='$SimilarID'
18
-    AND UserID='$UserID'
19
-    AND Way='$Way'");
20
-if (!$DB->has_results()) {
21
-  if ($Way == 'down') {
22
-    $Score = 'Score-100';
23
-  } elseif ($Way == 'up') {
24
-    $Score = 'Score+100';
25
-  } else { // Nothing is impossible!
26
-    $Score = 'Score';
27
-  }
28
-  $DB->query("
29
-    UPDATE artists_similar_scores
30
-    SET Score=$Score
31
-    WHERE SimilarID='$SimilarID'");
32
-  $DB->query("
33
-    INSERT INTO artists_similar_votes (SimilarID, UserID, Way)
34
-    VALUES ('$SimilarID', '$UserID', '$Way')");
35
-  $Cache->delete_value('artist_'.$ArtistID); // Delete artist cache
36
-}
37
-header('Location: '.$_SERVER['HTTP_REFERER']);
38
-?>

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

@@ -82,7 +82,7 @@ for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
82 82
   $CollagePages[] = $CollagePage;
83 83
 }
84 84
 
85
-View::show_header($Name, 'browse,collage,bbcode,voting,recommend');
85
+View::show_header($Name, 'browse,collage,bbcode,recommend');
86 86
 
87 87
 ?>
88 88
 <div class="thin">

+ 1
- 5
sections/collages/torrent_collage.php View File

@@ -18,7 +18,6 @@ $GroupIDs = $DB->collect('GroupID');
18 18
 $Contributors = $DB->to_pair('GroupID', 'UserID', false);
19 19
 if (count($GroupIDs) > 0) {
20 20
   $TorrentList = Torrents::get_groups($GroupIDs);
21
-  $UserVotes = Votes::get_user_votes($LoggedUser['ID']);
22 21
 } else {
23 22
   $TorrentList = [];
24 23
 }
@@ -89,7 +88,6 @@ foreach ($GroupIDs as $GroupID) {
89 88
     $DisplayName .= " [$GroupDLSiteID]";
90 89
   }
91 90
   $SnatchedGroupClass = ($GroupFlags['IsSnatched'] ? ' snatched_group' : '');
92
-  $UserVote = isset($UserVotes[$GroupID]) ? $UserVotes[$GroupID]['Type'] : '';
93 91
   // Start an output buffer, so we can store this output in $TorrentTable
94 92
   ob_start();
95 93
 
@@ -118,7 +116,6 @@ foreach ($GroupIDs as $GroupID) {
118 116
           </span>
119 117
 <?
120 118
     }
121
-    Votes::vote_link($GroupID, $UserVote);
122 119
 ?>
123 120
           <div class="tags"><?=$TorrentTags->format()?></div>
124 121
         </td>
@@ -216,7 +213,6 @@ foreach ($GroupIDs as $GroupID) {
216 213
             | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a>
217 214
           </span>
218 215
           <strong><?=$DisplayName?></strong>
219
-<?    Votes::vote_link($GroupID, $UserVote); ?>
220 216
           <div class="tags"><?=$TorrentTags->format()?></div>
221 217
         </td>
222 218
         <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
@@ -283,7 +279,7 @@ for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
283 279
   $CollagePages[] = $CollagePage;
284 280
 }
285 281
 
286
-View::show_header($Name, 'browse,collage,bbcode,voting,recommend,wall');
282
+View::show_header($Name, 'browse,collage,bbcode,recommend,wall');
287 283
 ?>
288 284
 <div class="thin">
289 285
   <div class="header">

+ 0
- 18
sections/schedule/daily/delete_dead_torrents.php View File

@@ -64,22 +64,4 @@ if (count($LogEntries) > 0) {
64 64
     VALUES $Values");
65 65
   echo "\nDeleted $i torrents for inactivity\n";
66 66
 }
67
-
68
-$DB->query("
69
-  SELECT SimilarID
70
-  FROM artists_similar_scores
71
-  WHERE Score <= 0");
72
-$SimilarIDs = implode(',', $DB->collect('SimilarID'));
73
-
74
-if ($SimilarIDs) {
75
-  $DB->query("
76
-    DELETE FROM artists_similar
77
-    WHERE SimilarID IN($SimilarIDs)");
78
-  $DB->query("
79
-    DELETE FROM artists_similar_scores
80
-    WHERE SimilarID IN($SimilarIDs)");
81
-  $DB->query("
82
-    DELETE FROM artists_similar_votes
83
-    WHERE SimilarID IN($SimilarIDs)");
84
-}
85 67
 ?>

+ 0
- 3
sections/top10/index.php View File

@@ -26,9 +26,6 @@ if (empty($_GET['type']) || $_GET['type'] == 'torrents') {
26 26
     case 'history':
27 27
       include(SERVER_ROOT.'/sections/top10/history.php');
28 28
       break;
29
-    case 'votes':
30
-      include(SERVER_ROOT.'/sections/top10/votes.php');
31
-      break;
32 29
     case 'donors':
33 30
       include(SERVER_ROOT.'/sections/top10/donors.php');
34 31
       break;

+ 0
- 354
sections/top10/votes.php View File

@@ -1,354 +0,0 @@
1
-<?
2
-// We need these to do our rankification
3
-include(SERVER_ROOT.'/sections/torrents/ranking_funcs.php');
4
-
5
-
6
-$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
7
-
8
-if (!empty($_GET['advanced']) && check_perms('site_advanced_top10')) {
9
-  $Details = 'all';
10
-  $Limit = 25;
11
-
12
-  if (!empty($_GET['tags'])) {
13
-    $TagsAny = isset($_GET['anyall']) && $_GET['anyall'] === 'any';
14
-    $Tags = explode(',', str_replace('.', '_', trim($_GET['tags'])));
15
-    foreach ($Tags as $Tag) {
16
-      $Tag = preg_replace('/[^a-z0-9_]/', '', $Tag);
17
-      if ($Tag != '') {
18
-        $TagWhere[] = "g.TagList REGEXP '[[:<:]]".db_string($Tag)."[[:>:]]'";
19
-      }
20
-    }
21
-    $Operator = $TagsAny ? ' OR ' : ' AND ';
22
-    $Where[] = '('.implode($Operator, $TagWhere).')';
23
-  }
24
-  $Year1 = (int)$_GET['year1'];
25
-  $Year2 = (int)$_GET['year2'];
26
-  if ($Year1 > 0 && $Year2 <= 0) {
27
-    $Where[] = "g.Year = $Year1";
28
-  } elseif ($Year1 > 0 && $Year2 > 0) {
29
-    $Where[] = "g.Year BETWEEN $Year1 AND $Year2";
30
-  } elseif ($Year2 > 0 && $Year1 <= 0) {
31
-    $Where[] = "g.Year <= $Year2";
32
-  }
33
-} else {
34
-  $Details = 'all';
35
-  // defaults to 10 (duh)
36
-  $Limit = isset($_GET['limit']) ? intval($_GET['limit']) : 25;
37
-  $Limit = in_array($Limit, array(25, 100, 250)) ? $Limit : 25;
38
-}
39
-$Filtered = !empty($Where);
40
-
41
-if (!empty($Where)) {
42
-  $Where = implode(' AND ', $Where);
43
-}
44
-$WhereSum = (empty($Where)) ? '' : md5($Where);
45
-
46
-// Unlike the other top 10s, this query just gets some raw stats
47
-// We'll need to do some fancy-pants stuff to translate it into
48
-// BPCI scores before getting the torrent data
49
-$Query = '
50
-  SELECT v.GroupID, v.Ups, v.Total, v.Score
51
-  FROM torrents_votes AS v';
52
-if (!empty($Where)) {
53
-  $Query .= "
54
-    JOIN torrents_group AS g ON g.ID = v.GroupID
55
-  WHERE $Where AND ";
56
-} else {
57
-  $Query .= '
58
-  WHERE ';
59
-}
60
-$Query .= "
61
-    Score > 0
62
-  ORDER BY Score DESC
63
-  LIMIT $Limit";
64
-
65
-$TopVotes = $Cache->get_value('top10votes_'.$Limit.$WhereSum);
66
-if ($TopVotes === false) {
67
-  if ($Cache->get_query_lock('top10votes')) {
68
-    $DB->query($Query);
69
-
70
-    $Results = $DB->to_array('GroupID', MYSQLI_ASSOC, false);
71
-    $Ranks = Votes::calc_ranks($DB->to_pair('GroupID', 'Score', false));
72
-
73
-    $Groups = Torrents::get_groups(array_keys($Results));
74
-
75
-    $TopVotes = [];
76
-    foreach ($Results as $GroupID => $Votes) {
77
-      $TopVotes[$GroupID] = $Groups[$GroupID];
78
-      $TopVotes[$GroupID]['Ups'] = $Votes['Ups'];
79
-      $TopVotes[$GroupID]['Total'] = $Votes['Total'];
80
-      $TopVotes[$GroupID]['Score'] = $Votes['Score'];
81
-      $TopVotes[$GroupID]['Rank'] = $Ranks[$GroupID];
82
-    }
83
-
84
-    $Cache->cache_value('top10votes_'.$Limit.$WhereSum, $TopVotes, 60 * 30);
85
-    $Cache->clear_query_lock('top10votes');
86
-  } else {
87
-    $TopVotes = false;
88
-  }
89
-}
90
-View::show_header("Top $Limit Voted Groups",'browse,voting');
91
-?>
92
-<div class="thin">
93
-  <div class="header">
94
-    <h2>Top <?=$Limit?> Voted Groups</h2>
95
-    <? Top10View::render_linkbox("votes"); ?>
96
-  </div>
97
-<?
98
-
99
-if (check_perms('site_advanced_top10')) { ?>
100
-  <form class="search_form" name="votes" action="" method="get">
101
-    <input type="hidden" name="advanced" value="1" />
102
-    <input type="hidden" name="type" value="votes" />
103
-    <table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
104
-      <tr id="tagfilter">
105
-        <td class="label">Tags (comma-separated):</td>
106
-        <td class="ft_taglist">
107
-          <input type="text" name="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>" />&nbsp;
108
-          <input type="radio" id="rdoAll" name="anyall" value="all"<?=(!isset($TagsAny) ? ' checked="checked"' : '')?> /><label for="rdoAll"> All</label>&nbsp;&nbsp;
109
-          <input type="radio" id="rdoAny" name="anyall" value="any"<?=(isset($TagsAny) ? ' checked="checked"' : '')?> /><label for="rdoAny"> Any</label>
110
-        </td>
111
-      </tr>
112
-      <tr id="yearfilter">
113
-        <td class="label">Year:</td>
114
-        <td class="ft_year">
115
-          <input type="text" name="year1" size="4" value="<? if (!empty($_GET['year1'])) { echo display_str($_GET['year1']);} ?>" />
116
-          to
117
-          <input type="text" name="year2" size="4" value="<? if (!empty($_GET['year2'])) { echo display_str($_GET['year2']);} ?>" />
118
-        </td>
119
-      </tr>
120
-      <tr>
121
-        <td colspan="2" class="center">
122
-          <input type="submit" value="Filter torrents" />
123
-        </td>
124
-      </tr>
125
-    </table>
126
-  </form>
127
-<?
128
-}
129
-
130
-$Bookmarks = Bookmarks::all_bookmarks('torrent');
131
-?>
132
-  <h3>Top <?=$Limit?>
133
-<?
134
-if (empty($_GET['advanced'])) { ?>
135
-    <small class="top10_quantity_links">
136
-<?
137
-  switch ($Limit) {
138
-    case 100: ?>
139
-      - <a href="top10.php?type=votes" class="brackets">Top 25</a>
140
-      - <span class="brackets">Top 100</span>
141
-      - <a href="top10.php?type=votes&amp;limit=250" class="brackets">Top 250</a>
142
-<?      break;
143
-    case 250: ?>
144
-      - <a href="top10.php?type=votes" class="brackets">Top 25</a>
145
-      - <a href="top10.php?type=votes&amp;limit=100" class="brackets">Top 100</a>
146
-      - <span class="brackets">Top 250</span>
147
-<?      break;
148
-    default: ?>
149
-      - <span class="brackets">Top 25</span>
150
-      - <a href="top10.php?type=votes&amp;limit=100" class="brackets">Top 100</a>
151
-      - <a href="top10.php?type=votes&amp;limit=250" class="brackets">Top 250</a>
152
-<?  } ?>
153
-    </small>
154
-<?
155
-} ?>
156
-  </h3>
157
-<?
158
-
159
-$TorrentTable = '';
160
-foreach ($TopVotes as $GroupID => $Group) {
161
-  extract(Torrents::array_group($Group));
162
-  $UpVotes = $Group['Ups'];
163
-  $TotalVotes = $Group['Total'];
164
-  $Score = $Group['Score'];
165
-  $DownVotes = $TotalVotes - $UpVotes;
166
-
167
-  $IsBookmarked = in_array($GroupID, $Bookmarks);
168
-  $UserVote = isset($UserVotes[$GroupID]) ? $UserVotes[$GroupID]['Type'] : '';
169
-
170
-  $TorrentTags = new Tags($TagList);
171
-  $DisplayName = "$Group[Rank] - ";
172
-
173
-  $DisplayName .= Artists::display_artists($Artists);
174
-
175
-  $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" dir="ltr"';
176
-  if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
177
-    $DisplayName .= ' onmouseover="getCover(event)" data-cover="'.ImageTools::process($WikiImage, true).'" onmouseleave="ungetCover(event)"';
178
-  }
179
-  $DisplayName .= '>'.$GroupName.'</a>';
180
-  if ($GroupYear > 0) {
181
-    $DisplayName = $DisplayName. " [$GroupYear]";
182
-  }
183
-  // Start an output buffer, so we can store this output in $TorrentTable
184
-  ob_start();
185
-
186
-  if (count($Torrents) > 1 || $GroupCategoryID == 1) {
187
-    // Grouped torrents
188
-    $GroupSnatched = false;
189
-    foreach ($Torrents as &$Torrent) {
190
-      if (($Torrent['IsSnatched'] = Torrents::has_snatched($Torrent['ID'])) && !$GroupSnatched) {
191
-        $GroupSnatched = true;
192
-      }
193
-    }
194
-    unset($Torrent);
195
-    $SnatchedGroupClass = $GroupSnatched ? ' snatched_group' : '';
196
-?>
197
-        <tr class="group<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
198
-          <td class="center">
199
-            <div id="showimg_<?=$GroupID?>" class="show_torrents">
200
-              <a class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event);" title="Toggle this group (Hold &quot;Shift&quot; to toggle all groups)"></a>
201
-            </div>
202
-          </td>
203
-          <td class="center cats_col">
204
-            <div title="<?=Format::pretty_category($GroupCategoryID)?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>"></div>
205
-          </td>
206
-          <td class="big_info">
207
-            <div class="group_info clear">
208
-
209
-              <strong><?=$DisplayName?></strong> <!--<?Votes::vote_link($GroupID, $UserVote);?>-->
210
-<?    if ($IsBookmarked) { ?>
211
-              <span class="remove_bookmark float_right">
212
-                <a href="#" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
213
-              </span>
214
-<?    } else { ?>
215
-              <span class="add_bookmark float_right">
216
-                <a href="#" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
217
-              </span>
218
-<?    } ?>
219
-              <div class="tags"><?=$TorrentTags->format()?></div>
220
-
221
-            </div>
222
-          </td>
223
-          <td colspan="4" class="votes_info_td">
224
-            <span style="white-space: nowrap;">
225
-              <span class="favoritecount_small tooltip" title="<?=$UpVotes . ($UpVotes == 1 ? ' upvote' : ' upvotes')?>"><span id="upvotes"><?=number_format($UpVotes)?></span> <span class="vote_album_up">&and;</span></span>
226
-              &nbsp; &nbsp;
227
-              <span class="favoritecount_small tooltip" title="<?=$DownVotes . ($DownVotes == 1 ? ' downvote' : ' downvotes')?>"><span id="downvotes"><?=number_format($DownVotes)?></span> <span class="vote_album_down">&or;</span></span>
228
-              &nbsp;
229
-              <span style="float: right;"><span class="favoritecount_small" id="totalvotes"><?=number_format($TotalVotes)?></span> Total</span>
230
-            </span>
231
-            <br />
232
-            <span style="white-space: nowrap;">
233
-              <span class="tooltip_interactive" title="&lt;span style=&quot;font-weight: bold;&quot;&gt;Score: <?=number_format($Score * 100, 4)?>&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is the lower bound of the binomial confidence interval &lt;a href=&quot;wiki.php?action=article&amp;id=1037&quot;&gt;described here&lt;/a&gt;, multiplied by 100." data-title-plain="Score: <?=number_format($Score * 100, 4)?>. This is the lower bound of the binomial confidence interval described in the Favorite Album Votes wiki article, multiplied by 100.">Score: <span class="favoritecount_small"><?=number_format($Score * 100, 1)?></span></span>
234
-              &nbsp; | &nbsp;
235
-              <span class="favoritecount_small"><?=number_format($UpVotes / $TotalVotes * 100, 1)?>%</span> positive
236
-            </span>
237
-          </td>
238
-        </tr>
239
-<?
240
-    foreach ($Torrents as $TorrentID => $Torrent) {
241
-      //Get report info, use the cache if available, if not, add to it.
242
-      $Reported = false;
243
-      $Reports = Torrents::get_reports($TorrentID);
244
-      if (count($Reports) > 0) {
245
-        $Reported = true;
246
-      }
247
-      $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
248
-?>
249
-    <tr class="group_torrent torrent_row groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass?> hidden">
250
-      <td colspan="3">
251
-        <span>
252
-          [ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
253
-<?      if (Torrents::can_use_token($Torrent)) { ?>
254
-          | <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
255
-<?      } ?>
256
-          | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
257
-        </span>
258
-        &nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?><? if ($Reported) { ?> / <strong class="torrent_label tl_reported">Reported</strong><? } ?></a>
259
-      </td>
260
-      <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
261
-      <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
262
-      <td class="number_column<?=($Torrent['Seeders'] == 0) ? ' r00' : '' ?>"><?=number_format($Torrent['Seeders'])?></td>
263
-      <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
264
-    </tr>
265
-<?
266
-    }
267
-  } else { //if (count($Torrents) > 1 || $GroupCategoryID == 1)
268
-    // Viewing a type that does not require grouping
269
-
270
-    list($TorrentID, $Torrent) = each($Torrents);
271
-    $Torrent['IsSnatched'] = Torrents::has_snatched($TorrentID);
272
-
273
-    $DisplayName = $Group['Rank'] .' - <a href="torrents.php?id='.$GroupID.'" dir="ltr"';
274
-    if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
275
-      $DisplayName .= ' onmouseover="getCover(event)" data-cover="'.ImageTools::process($WikiImage, true).'" onmouseleave="ungetCover(event)"';
276
-    }
277
-    $DisplayName .= '>'.$GroupName.'</a>';
278
-    if ($Torrent['IsSnatched']) {
279
-      $DisplayName .= ' ' . Format::torrent_label('Snatched!');
280
-    }
281
-    if ($Torrent['FreeTorrent'] == '1') {
282
-      $DisplayName .= ' ' . Format::torrent_label('Freeleech!');
283
-    } elseif ($Torrent['FreeTorrent'] == '2') {
284
-      $DisplayName .= ' ' . Format::torrent_label('Neutral leech!');
285
-    } elseif (Torrents::has_token($TorrentID)) {
286
-      $DisplayName .= ' ' . Format::torrent_label('Personal freeleech!');
287
-    }
288
-    $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
289
-?>
290
-    <tr class="torrent torrent_row<?=$SnatchedTorrentClass . $SnatchedGroupClass?>" id="group_<?=$GroupID?>">
291
-      <td></td>
292
-      <td class="center cats_col">
293
-        <div title="<?=Format::pretty_category($GroupCategoryID)?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>">
294
-        </div>
295
-      </td>
296
-      <td class="big_info">
297
-        <div class="group_info clear">
298
-          <span>
299
-            [ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
300
-<?    if (Torrents::can_use_token($Torrent)) { ?>
301
-            | <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
302
-<?    } ?>
303
-            | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a>
304
-<?    if ($IsBookmarked) { ?>
305
-            | <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="remove_bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
306
-<?    } else { ?>
307
-            | <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="add_bookmark" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
308
-<?    } ?>
309
-            ]
310
-          </span>
311
-          <strong><?=$DisplayName?></strong> <!--<?Votes::vote_link($GroupID, $UserVote);?>-->
312
-          <div class="tags"><?=$TorrentTags->format()?></div>
313
-        </div>
314
-      </td>
315
-      <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
316
-      <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
317
-      <td class="number_column<?=($Torrent['Seeders'] == 0) ? ' r00' : '' ?>"><?=number_format($Torrent['Seeders'])?></td>
318
-      <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
319
-    </tr>
320
-<?
321
-  } //if (count($Torrents) > 1 || $GroupCategoryID == 1)
322
-  $TorrentTable .= ob_get_clean();
323
-}
324
-?>
325
-<table class="torrent_table grouping cats box" id="discog_table">
326
-  <tr class="colhead_dark">
327
-    <td><!-- expand/collapse --></td>
328
-    <td class="cats_col"><!-- category --></td>
329
-    <td width="70%">Torrents</td>
330
-    <td>Size</td>
331
-    <td class="sign snatches"><svg width="15" height="15" fill="white" class="tooltip" alt="Snatches" title="Snatches" viewBox="3 0 88 98"><path d="M20 20 A43 43,0,1,0,77 23 L90 10 L55 10 L55 45 L68 32 A30.27 30.27,0,1,1,28 29"></path></svg></td>
332
-    <td class="sign seeders"><svg width="11" height="15" fill="white" class="tooltip" alt="Seeders" title="Seeders"><polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon></svg></td>
333
-    <td class="sign leechers"><svg width="11" height="15" fill="white" class="tooltip" alt="Leechers" title="Leechers"><polygon points="0,8 5.5,15 11,8 8,8 8,0 3,0 3,8"></polygon></svg></td>
334
-  </tr>
335
-<?
336
-if ($TopVotes === false) { ?>
337
-  <tr>
338
-    <td colspan="7" class="center">Server is busy processing another top list request. Please try again in a minute.</td>
339
-  </tr>
340
-<?
341
-} elseif (count($TopVotes) === 0) { ?>
342
-  <tr>
343
-    <td colspan="7" class="center">No torrents were found that meet your criteria.</td>
344
-  </tr>
345
-<?
346
-} else {
347
-  echo $TorrentTable;
348
-}
349
-?>
350
-</table>
351
-</div>
352
-<?
353
-View::show_footer();
354
-?>

+ 0
- 4
sections/torrents/details.php View File

@@ -297,8 +297,6 @@ if ($Categories[$GroupCategoryID - 1] != 'Other') {
297 297
 <?
298 298
     }
299 299
   }
300
-include(SERVER_ROOT.'/sections/torrents/vote_ranks.php');
301
-include(SERVER_ROOT.'/sections/torrents/vote.php');
302 300
 ?>
303 301
     <div class="box box_tags">
304 302
       <div class="head">
@@ -777,8 +775,6 @@ if (count($PersonalCollages) > 0) {
777 775
     </table>
778 776
 <?
779 777
 }
780
-// Matched Votes
781
-include(SERVER_ROOT.'/sections/torrents/voter_picks.php');
782 778
 ?>
783 779
     <div class="box torrent_description">
784 780
       <div class="head"><a href="#">&uarr;</a>&nbsp;<strong><?=(!empty($ReleaseType) ? $ReleaseTypes[$ReleaseType].' info' : 'Info' )?></strong></div>

+ 0
- 1
sections/torrents/editgroupid.php View File

@@ -85,7 +85,6 @@ if (empty($_POST['confirm'])) {
85 85
     WHERE GroupID = '$OldGroupID'");
86 86
   list($TorrentsInGroup) = $DB->next_record();
87 87
   if ($TorrentsInGroup == 0) {
88
-    // TODO: votes etc!
89 88
     $DB->query("
90 89
       UPDATE comments
91 90
       SET PageID = '$GroupID'

+ 0
- 48
sections/torrents/merge.php View File

@@ -70,54 +70,6 @@ if (empty($_POST['confirm'])) {
70 70
 } else {
71 71
   authorize();
72 72
 
73
-  // Votes ninjutsu. This is so annoyingly complicated.
74
-  // 1. Get a list of everybody who voted on the old group and clear their cache keys
75
-  $DB->query("
76
-    SELECT UserID
77
-    FROM users_votes
78
-    WHERE GroupID = '$GroupID'");
79
-  while (list($UserID) = $DB->next_record()) {
80
-    $Cache->delete_value("voted_albums_$UserID");
81
-  }
82
-  // 2. Update the existing votes where possible, clear out the duplicates left by key
83
-  // conflicts, and update the torrents_votes table
84
-  $DB->query("
85
-    UPDATE IGNORE users_votes
86
-    SET GroupID = '$NewGroupID'
87
-    WHERE GroupID = '$GroupID'");
88
-  $DB->query("
89
-    DELETE FROM users_votes
90
-    WHERE GroupID = '$GroupID'");
91
-  $DB->query("
92
-    INSERT INTO torrents_votes (GroupID, Ups, Total, Score)
93
-      SELECT $NewGroupID, UpVotes, TotalVotes, VoteScore
94
-      FROM (
95
-        SELECT
96
-          IFNULL(SUM(IF(Type = 'Up', 1, 0)), 0) As UpVotes,
97
-          COUNT(1) AS TotalVotes,
98
-          binomial_ci(IFNULL(SUM(IF(Type = 'Up', 1, 0)), 0), COUNT(1)) AS VoteScore
99
-        FROM users_votes
100
-        WHERE GroupID = $NewGroupID
101
-        GROUP BY GroupID
102
-      ) AS a
103
-    ON DUPLICATE KEY UPDATE
104
-      Ups = a.UpVotes,
105
-      Total = a.TotalVotes,
106
-      Score = a.VoteScore;");
107
-  // 3. Clear the votes_pairs keys!
108
-  $DB->query("
109
-    SELECT v2.GroupID
110
-    FROM users_votes AS v1
111
-      INNER JOIN users_votes AS v2 USING (UserID)
112
-    WHERE (v1.Type = 'Up' OR v2.Type = 'Up')
113
-      AND (v1.GroupID IN($GroupID, $NewGroupID))
114
-      AND (v2.GroupID NOT IN($GroupID, $NewGroupID));");
115
-  while (list($CacheGroupID) = $DB->next_record()) {
116
-    $Cache->delete_value("vote_pairs_$CacheGroupID");
117
-  }
118
-  // 4. Clear the new groups vote keys
119
-  $Cache->delete_value("votes_$NewGroupID");
120
-
121 73
   $DB->query("
122 74
     UPDATE torrents
123 75
     SET GroupID = '$NewGroupID'

+ 0
- 93
sections/torrents/ranking_funcs.php View File

@@ -1,93 +0,0 @@
1
-<?php
2
-function inverse_ncdf($p) {
3
-/***************************************************************************
4
- *                                inverse_ncdf.php
5
- *                            -------------------
6
- *   begin                : Friday, January 16, 2004
7
- *   copyright            : (C) 2004 Michael Nickerson
8
- *   email                : nickersonm@yahoo.com
9
- *
10
- ***************************************************************************/
11
-
12
-  //Inverse ncdf approximation by Peter John Acklam, implementation adapted to
13
-  //PHP by Michael Nickerson, using Dr. Thomas Ziegler's C implementation as
14
-  //a guide.  http://home.online.no/~pjacklam/notes/invnorm/index.html
15
-  //I have not checked the accuracy of this implementation.  Be aware that PHP
16
-  //will truncate the coeficcients to 14 digits.
17
-
18
-  //You have permission to use and distribute this function freely for
19
-  //whatever purpose you want, but please show common courtesy and give credit
20
-  //where credit is due.
21
-
22
-  //Input paramater is $p - probability - where 0 < p < 1.
23
-
24
-  //Coefficients in rational approximations
25
-  $a = array(1 => -3.969683028665376e+01, 2 => 2.209460984245205e+02,
26
-         3 => -2.759285104469687e+02, 4 => 1.383577518672690e+02,
27
-         5 => -3.066479806614716e+01, 6 => 2.506628277459239e+00);
28
-
29
-  $b = array(1 => -5.447609879822406e+01, 2 => 1.615858368580409e+02,
30
-         3 => -1.556989798598866e+02, 4 => 6.680131188771972e+01,
31
-         5 => -1.328068155288572e+01);
32
-
33
-  $c = array(1 => -7.784894002430293e-03, 2 => -3.223964580411365e-01,
34
-         3 => -2.400758277161838e+00, 4 => -2.549732539343734e+00,
35
-         5 => 4.374664141464968e+00,  6 => 2.938163982698783e+00);
36
-
37
-  $d = array(1 => 7.784695709041462e-03, 2 => 3.224671290700398e-01,
38
-         3 => 2.445134137142996e+00, 4 => 3.754408661907416e+00);
39
-
40
-  //Define break-points.
41
-  $p_low  = 0.02425;                   //Use lower region approx. below this
42
-  $p_high = 1 - $p_low;                 //Use upper region approx. above this
43
-
44
-  //Define/list variables (doesn't really need a definition)
45
-  //$p (probability), $sigma (std. deviation), and $mu (mean) are user inputs
46
-  $q = null; $x = null; $y = null; $r = null;
47
-
48
-  //Rational approximation for lower region.
49
-  if (0 < $p && $p < $p_low) {
50
-    $q = sqrt(-2 * log($p));
51
-    $x = ((((($c[1] * $q + $c[2]) * $q + $c[3]) * $q + $c[4]) * $q + $c[5]) *
52
-            $q + $c[6]) / (((($d[1] * $q + $d[2]) * $q + $d[3]) * $q + $d[4]) *
53
-          $q + 1);
54
-  }
55
-
56
-  //Rational approximation for central region.
57
-  elseif ($p_low <= $p && $p <= $p_high) {
58
-    $q = $p - 0.5;
59
-    $r = $q * $q;
60
-    $x = ((((($a[1] * $r + $a[2]) * $r + $a[3]) * $r + $a[4]) * $r + $a[5]) *
61
-            $r + $a[6]) * $q / ((((($b[1] * $r + $b[2]) * $r + $b[3]) * $r +
62
-          $b[4]) * $r + $b[5]) * $r + 1);
63
-  }
64
-
65
-  //Rational approximation for upper region.
66
-  elseif ($p_high < $p && $p < 1) {
67
-    $q = sqrt(-2 * log(1 - $p));
68
-    $x = -((((($c[1] * $q + $c[2]) * $q + $c[3]) * $q + $c[4]) * $q +
69
-            $c[5]) * $q + $c[6]) / (((($d[1] * $q + $d[2]) * $q + $d[3]) *
70
-          $q + $d[4]) * $q + 1);
71
-  }
72
-
73
-  //If 0 < p < 1, return a null value
74
-  else {
75
-    $x = null;
76
-  }
77
-
78
-  return $x;
79
-  //END inverse ncdf implementation.
80
-}
81
-
82
-// Confidence level for binomial scoring.  Just compute this once.
83
-define('Z_VAL', inverse_ncdf(1 - (1 - 0.95) / 2));
84
-
85
-// Implementation of the algorithm described at http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
86
-function binomial_score($Ups, $Total) {
87
-  if (($Total <= 0) || ($Ups < 0)) {
88
-    return 0;
89
-  }
90
-  $phat = $Ups/$Total;
91
-  return ($phat + Z_VAL * Z_VAL / (2 * $Total) - Z_VAL * sqrt(($phat * (1 - $phat) + Z_VAL * Z_VAL / (4 * $Total)) / $Total)) / (1 + Z_VAL * Z_VAL / $Total);
92
-}
93
-?>

+ 0
- 1
sections/torrents/takechangecategory.php View File

@@ -96,7 +96,6 @@ $DB->query("
96 96
   FROM torrents
97 97
   WHERE GroupID = '$OldGroupID'");
98 98
 if (!$DB->has_results()) {
99
-  // TODO: votes etc.
100 99
   $DB->query("
101 100
     UPDATE comments
102 101
     SET PageID = '$GroupID'

+ 1
- 3
sections/torrents/user.php View File

@@ -3,7 +3,6 @@
3 3
 
4 4
 $Orders = array('Time', 'Name', 'Seeders', 'Leechers', 'Snatched', 'Size');
5 5
 $Ways = array('DESC' => 'Descending', 'ASC' => 'Ascending');
6
-$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
7 6
 
8 7
 // The "order by x" links on columns headers
9 8
 function header_link($SortKey, $DefaultWay = 'DESC') {
@@ -328,7 +327,7 @@ $Results = Torrents::get_groups($GroupIDs);
328 327
 $Action = display_str($_GET['type']);
329 328
 $User = Users::user_info($UserID);
330 329
 
331
-View::show_header($User['Username']."'s $Action torrents",'voting,browse');
330
+View::show_header($User['Username']."'s $Action torrents", 'browse');
332 331
 
333 332
 $Pages = Format::get_pages($Page, $TorrentCount, TORRENTS_PER_PAGE);
334 333
 
@@ -545,7 +544,6 @@ foreach ($Categories as $CatKey => $CatName) {
545 544
             | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
546 545
           </span>
547 546
           <? echo "$DisplayName\n"; ?>
548
-<?          Votes::vote_link($GroupID, isset($UserVotes[$GroupID]) ? $UserVotes[$GroupID]['Type'] : ''); ?>
549 547
           <div class="tags"><?=$TorrentTags->format('torrents.php?type='.$Action.'&amp;userid='.$UserID.'&amp;tags=')?></div>
550 548
         </div>
551 549
       </td>

+ 0
- 36
sections/torrents/vote.php View File

@@ -1,36 +0,0 @@
1
-<?
2
-  $UserVotes = Votes::get_user_votes($LoggedUser['ID']);
3
-  $GroupVotes = Votes::get_group_votes($GroupID);
4
-
5
-  $TotalVotes = $GroupVotes['Total'];
6
-  $UpVotes  = $GroupVotes['Ups'];
7
-  $DownVotes  = $TotalVotes - $UpVotes;
8
-
9
-  $Voted = isset($UserVotes[$GroupID]) ? $UserVotes[$GroupID]['Type'] : false;
10
-  $Score = Votes::binomial_score($UpVotes, $TotalVotes);
11
-?>
12
-<div class="box" id="votes">
13
-  <div class="head"><strong>Group Votes</strong></div>
14
-  <div class="album_votes body">
15
-    <span class="favoritecount tooltip" title="<?=$UpVotes . ($UpVotes == 1 ? ' upvote' : ' upvotes')?>"><span id="upvotes"><?=number_format($UpVotes)?></span> <span class="vote_album_up">&and;</span></span>
16
-    &nbsp; &nbsp;
17
-    <span class="favoritecount tooltip" title="<?=$DownVotes . ($DownVotes == 1 ? ' downvote' : ' downvotes')?>"><span id="downvotes"><?=number_format($DownVotes)?></span> <span class="vote_album_down">&or;</span></span>
18
-    &nbsp; &nbsp;
19
-    <span class="favoritecount" id="totalvotes"><?=number_format($TotalVotes)?></span> Total
20
-    <br /><br />
21
-    <span class="tooltip_interactive" title="&lt;span style=&quot;font-weight: bold;&quot;&gt;Score: <?=number_format($Score * 100, 4)?>&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is the lower bound of the binomial confidence interval &lt;a href=&quot;wiki.php?action=article&amp;id=1037&quot;&gt;described here&lt;/a&gt;, multiplied by 100." data-title-plain="Score: <?=number_format($Score * 100, 4)?>. This is the lower bound of the binomial confidence interval described in the Favorite Album Votes wiki article, multiplied by 100.">Score: <span class="favoritecount"><?=number_format($Score * 100, 1)?></span></span>
22
-    &nbsp; | &nbsp;
23
-    <span class="favoritecount"><?=number_format(($TotalVotes == 0) ? 0 : ($UpVotes / $TotalVotes) * 100, 1)?>%</span> positive
24
-    <br /><br />
25
-    <span id="upvoted"<?=(($Voted != 'Up') ? ' class="hidden"' : '')?>>You have upvoted.<br /><br /></span>
26
-    <span id="downvoted"<?=(($Voted != 'Down') ? ' class="hidden"' : '')?>>You have downvoted.<br /><br /></span>
27
-<?  if (check_perms('site_album_votes')) { ?>
28
-    <span<?=($Voted ? ' class="hidden"' : '')?> id="vote_message"><a href="#" class="brackets upvote" onclick="UpVoteGroup(<?=$GroupID?>, '<?=$LoggedUser['AuthKey']?>'); return false;">Upvote</a> - <a href="#" class="brackets downvote" onclick="DownVoteGroup(<?=$GroupID?>, '<?=$LoggedUser['AuthKey']?>'); return false;">Downvote</a></span>
29
-<?  } ?>
30
-    <span<?=($Voted ? '' : ' class="hidden"')?> id="unvote_message">
31
-      Changed your mind?
32
-      <br />
33
-      <a href="#" onclick="UnvoteGroup(<?=$GroupID?>, '<?=$LoggedUser['AuthKey']?>'); return false;" class="brackets">Clear your vote</a>
34
-    </span>
35
-  </div>
36
-</div>

+ 0
- 39
sections/torrents/vote_ranks.php View File

@@ -1,39 +0,0 @@
1
-<?
2
-// Show the "This album is number x overall", etc. box for the "Music" category only
3
-if ($GroupCategoryID == 1) {
4
-  $Rankings = Votes::get_ranking($GroupID, $GroupYear);
5
-  $LIs = '';
6
-  // Display information for the return categories of get_ranking()
7
-  $GroupDecade = $GroupYear - ($GroupYear % 10);
8
-  $names = array('overall'=>'<a href="top10.php?type=votes">overall</a>',
9
-        'decade'=>check_perms('site_advanced_top10') ? 'for the <a href="top10.php?advanced=1&amp;type=votes&amp;year1='.$GroupDecade.'&amp;year2='.($GroupDecade+9).'">'.$GroupDecade.'s</a>' : 'for the '.$GroupDecade.'s',
10
-        'year'=>check_perms('site_advanced_top10') ? 'for <a href="top10.php?advanced=1&amp;type=votes&amp;year1='.$GroupYear.'&amp;year2=">'.$GroupYear.'</a>' : "for $GroupYear");
11
-
12
-  foreach ($names as $key => $text) {
13
-    if ($Rank = $Rankings[$key]) {
14
-      if ($Rank <= 10) {
15
-        $Class = 'vr_top_10';
16
-      } elseif ($Rank <= 25) {
17
-        $Class = 'vr_top_25';
18
-      } elseif ($Rank <= 50) {
19
-        $Class = 'vr_top_50';
20
-      }
21
-
22
-      $LIs .= "<li id=\"vote_rank_$key\" class=\"$Class\">No. $Rank $text</li>";
23
-    }
24
-  }
25
-
26
-  if ($LIs != '') {
27
-?>
28
-    <div class="box" id="votes_ranks">
29
-      <div class="head"><strong><?=SITE_NAME?> Favorites</strong></div>
30
-      <div class="vote_charts body">
31
-        <ul class="stats nobullet" id="vote_rankings">
32
-          <?=$LIs?>
33
-        </ul>
34
-      </div>
35
-    </div>
36
-<?
37
-  }
38
-}
39
-?>

+ 0
- 64
sections/torrents/voter_picks.php View File

@@ -1,64 +0,0 @@
1
-<?
2
-//global $Cache, $DB;
3
-include(SERVER_ROOT.'/sections/torrents/ranking_funcs.php');
4
-
5
-$Top10 = $Cache->get_value('similar_albums_'.$GroupID);
6
-if ($Top10 === false || isset($Top10[$GroupID])) {
7
-
8
-  $VotePairs = $Cache->get_value('vote_pairs_'.$GroupID, true);
9
-  if ($VotePairs === false || isset($VotePairs[$GroupID])) {
10
-    $DB->query("
11
-      SELECT v.GroupID, SUM(IF(v.Type='Up',1,0)) AS Ups, COUNT(1) AS Total
12
-      FROM (  SELECT UserID
13
-          FROM users_votes
14
-          WHERE GroupID = '$GroupID'
15
-            AND Type='Up'
16
-        ) AS a
17
-        JOIN users_votes AS v USING (UserID)
18
-      WHERE v.GroupID != '$GroupID'
19
-      GROUP BY v.GroupID
20
-      HAVING Ups > 0");
21
-    $VotePairs = $DB->to_array('GroupID', MYSQLI_ASSOC, false);
22
-    $Cache->cache_value('vote_pairs_'.$GroupID, $VotePairs, 21600);
23
-  }
24
-
25
-  $GroupScores = [];
26
-  foreach ($VotePairs as $RatingGroup) {
27
-    // Cutting out the junk should speed the sort significantly
28
-    $Score = binomial_score($RatingGroup['Ups'], $RatingGroup['Total']);
29
-    if ($Score > 0.3) {
30
-      $GroupScores[$RatingGroup['GroupID']] = $Score;
31
-    }
32
-  }
33
-
34
-  arsort($GroupScores);
35
-  $Top10 = array_slice($GroupScores, 0, 10, true);
36
-  $Cache->cache_value('similar_albums_'.$GroupID, $Top10, 0.5 * 3600);
37
-}
38
-if (count($Top10) > 0) {
39
-?>
40
-    <table class="box vote_matches_table" id="vote_matches">
41
-      <tr class="colhead">
42
-        <td><a href="#">&uarr;</a>&nbsp;People who like this also liked... <a data-toggle-target=".votes_rows" class="brackets" style="float: right;">Toggle</a></td>
43
-      </tr>
44
-<?
45
-  $Top10Groups = array_keys($Top10);
46
-
47
-  $Groups = Torrents::get_groups($Top10Groups, true, true, false);
48
-  $i = 0;
49
-  foreach ($Top10Groups as $MatchGroupID) {
50
-    if (!isset($Groups[$MatchGroupID])) {
51
-      continue;
52
-    }
53
-    $MatchGroup = $Groups[$MatchGroupID];
54
-    $i++;
55
-    $Str = Artists::display_artists($MatchGroup['ExtendedArtists']).'<a href="torrents.php?id='.$MatchGroupID.'">'.$MatchGroup['Name'].'</a>';
56
-?>
57
-      <tr class="votes_rows hidden row">
58
-        <td><span class="like_ranks"><?=$i?>.</span> <?=$Str?></td>
59
-      </tr>
60
-<?  } ?>
61
-    </table>
62
-<?
63
-}
64
-?>

+ 0
- 7
sections/user/edit.php View File

@@ -323,13 +323,6 @@ echo $Val->GenerateJS('userform');
323 323
           </select>
324 324
         </td>
325 325
       </tr>
326
-      <tr id="tor_voting_tr">
327
-        <td class="label tooltip" title="This option allows you to enable or disable &quot;up&quot; and &quot;down&quot; voting links on artist pages, collections, and snatched lists."><strong>Voting links</strong></td>
328
-        <td>
329
-          <input type="checkbox" name="novotelinks" id="novotelinks"<?=!empty($SiteOptions['NoVoteLinks']) ? ' checked="checked"' : ''?> />
330
-          <label for="novotelinks">Disable voting links</label>
331
-        </td>
332
-      </tr>
333 326
       <tr id="tor_hidequestionable_tr">
334 327
         <td class="label tooltip" title="Prevent torrents with these tags from showing up on the torrent search page"><strong>Content Filtering</strong></td>
335 328
         <td>

+ 0
- 1
sections/user/take_edit.php View File

@@ -273,7 +273,6 @@ $Options['ListUnreadPMsFirst']  = (!empty($_POST['list_unread_pms_first']) ? 1 :
273 273
 $Options['ShowSnatched']        = (!empty($_POST['showsnatched']) ? 1 : 0);
274 274
 $Options['ShowMagnets']         = (!empty($_POST['showmagnets']) ? 1 : 0);
275 275
 $Options['DisableAutoSave']     = (!empty($_POST['disableautosave']) ? 1 : 0);
276
-$Options['NoVoteLinks']         = (!empty($_POST['novotelinks']) ? 1 : 0);
277 276
 $Options['CoverArt']            = (int)!empty($_POST['coverart']);
278 277
 $Options['ShowExtraCovers']     = (int)!empty($_POST['show_extra_covers']);
279 278
 $Options['HideLolicon']         = (int)!empty($_POST['hide_lolicon']);

+ 0
- 104
static/functions/artist_cloud.js View File

@@ -1,104 +0,0 @@
1
-(function() {
2
-
3
-var LIMIT = 10;
4
-var artistId, artistName;
5
-var artistTags;
6
-$(document).ready(function() {
7
-  initArtistCloud();
8
-});
9
-function initArtistCloud() {
10
-  $("#currentArtist").text();
11
-
12
-  artistTags = $("#artistTags").find('ul');
13
-  artistName = $("#content").find("h2:first").text();
14
-  artistId = window.location.search.split("?id=")[1];
15
-  addArtistMain(artistName);
16
-  loadArtists();
17
-}
18
-
19
-
20
-function loadArtists() {
21
-  $.getJSON('ajax.php?action=similar_artists&id='+artistId+'&limit='+LIMIT, function(data) {
22
-    var first = true;
23
-    var ratio;
24
-    $.each(data, function(key, val) {
25
-      if (first) {
26
-        ratio = val['score'] / 300;
27
-        first = false;
28
-      }
29
-      var score = val['score'] / ratio;
30
-      score = score <= 150 ? 150 : score;
31
-      addArtist(val['id'], val['name'], score);
32
-    });
33
-
34
-  createCloud();
35
-  });
36
-
37
-}
38
-
39
-function addArtist(id, name, score) {
40
-  var item = $('<li><a style="color:#007DC6;" data-weight="' + score + '">' + name + '</a></li>');
41
-
42
-  $(item).click(function(e) {
43
-    e.preventDefault();
44
-    reinit(id, name);
45
-  });
46