pjc 5 years ago
parent
commit
b9f44e087b

+ 3
- 1
classes/bencodetorrent.class.php View File

1
 <?php
1
 <?php
2
 
2
 
3
+# todo: Replace this with https://github.com/OPSnet/bencode-torrent
4
+
3
 /**
5
 /**
4
  * Torrent class that contains some convenient functions related to torrent meta data
6
  * Torrent class that contains some convenient functions related to torrent meta data
5
  */
7
  */
34
             if (isset($InfoDict['path.utf-8']['files'][0])) {
36
             if (isset($InfoDict['path.utf-8']['files'][0])) {
35
                 $this->PathKey = 'path.utf-8';
37
                 $this->PathKey = 'path.utf-8';
36
             }
38
             }
37
-            
39
+
38
             foreach ($InfoDict['files'] as $File) {
40
             foreach ($InfoDict['files'] as $File) {
39
                 $TmpPath = [];
41
                 $TmpPath = [];
40
                 foreach ($File[$this->PathKey] as $SubPath) {
42
                 foreach ($File[$this->PathKey] as $SubPath) {

+ 111
- 91
classes/commentsview.class.php View File

1
-<?
2
-class CommentsView {
3
-  /**
4
-   * Render a thread of comments
5
-   * @param array $Thread An array as returned by Comments::load
6
-   * @param int $LastRead PostID of the last read post
7
-   * @param string $Baselink Link to the site these comments are on
8
-   */
9
-  public static function render_comments($Thread, $LastRead, $Baselink) {
10
-    foreach ($Thread as $Post) {
11
-      list($PostID, $AuthorID, $AddedTime, $CommentBody, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
12
-      self::render_comment($AuthorID, $PostID, $CommentBody, $AddedTime, $EditedUserID, $EditedTime, $Baselink . "&amp;postid=$PostID#post$PostID", ($PostID > $LastRead));
1
+<?php
2
+
3
+class CommentsView
4
+{
5
+    /**
6
+     * Render a thread of comments
7
+     * @param array $Thread An array as returned by Comments::load
8
+     * @param int $LastRead PostID of the last read post
9
+     * @param string $Baselink Link to the site these comments are on
10
+     */
11
+    public static function render_comments($Thread, $LastRead, $Baselink)
12
+    {
13
+        foreach ($Thread as $Post) {
14
+            list($PostID, $AuthorID, $AddedTime, $CommentBody, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
15
+            self::render_comment($AuthorID, $PostID, $CommentBody, $AddedTime, $EditedUserID, $EditedTime, $Baselink . "&amp;postid=$PostID#post$PostID", ($PostID > $LastRead));
16
+        }
13
     }
17
     }
14
-  }
15
 
18
 
16
-  /**
17
-   * Render one comment
18
-   * @param int $AuthorID
19
-   * @param int $PostID
20
-   * @param string $Body
21
-   * @param string $AddedTime
22
-   * @param int $EditedUserID
23
-   * @param string $EditedTime
24
-   * @param string $Link The link to the post elsewhere on the site
25
-   * @param string $Header The header used in the post
26
-   * @param bool $Tools Whether or not to show [Edit], [Report] etc.
27
-   * 
28
-   * todo: Find a better way to pass the page (artist, collages, requests, torrents) to this function than extracting it from $Link
29
-   */
30
-  static function render_comment($AuthorID, $PostID, $Body, $AddedTime, $EditedUserID, $EditedTime, $Link, $Unread = false, $Header = '', $Tools = true) {
31
-    $UserInfo = Users::user_info($AuthorID);
32
-    $Header = Users::format_username($AuthorID, true, true, true, true, true) . time_diff($AddedTime) . $Header;
33
-?>
34
-    <table class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '') . ($Unread ? ' forum_unread' : '')?>" id="post<?=$PostID?>">
35
-      <colgroup>
36
-<?    if (Users::has_avatars_enabled()) { ?>
37
-        <col class="col_avatar" />
38
-<?    } ?>
39
-        <col class="col_post_body" />
40
-      </colgroup>
41
-      <tr class="colhead_dark">
42
-        <td colspan="<?=(Users::has_avatars_enabled() ? 2 : 1)?>">
43
-          <div class="float_left"><a class="post_id" href="<?=$Link?>">#<?=$PostID?></a>
44
-            <?=$Header?>
45
-<?    if ($Tools) { ?>
46
-            - <a href="#quickpost" onclick="Quote('<?=$PostID?>','<?=$UserInfo['Username']?>', true);" class="brackets">Quote</a>
47
-<?      if ($AuthorID == G::$LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?>
48
-            - <a href="#post<?=$PostID?>" onclick="Edit_Form('<?=$PostID?>','');" class="brackets">Edit</a>
49
-<?      }
19
+    /**
20
+     * Render one comment
21
+     * @param int $AuthorID
22
+     * @param int $PostID
23
+     * @param string $Body
24
+     * @param string $AddedTime
25
+     * @param int $EditedUserID
26
+     * @param string $EditedTime
27
+     * @param string $Link The link to the post elsewhere on the site
28
+     * @param string $Header The header used in the post
29
+     * @param bool $Tools Whether or not to show [Edit], [Report] etc.
30
+     *
31
+     * todo: Find a better way to pass the page (artist, collages, requests, torrents) to this function than extracting it from $Link
32
+     */
33
+    public static function render_comment($AuthorID, $PostID, $Body, $AddedTime, $EditedUserID, $EditedTime, $Link, $Unread = false, $Header = '', $Tools = true)
34
+    {
35
+        $UserInfo = Users::user_info($AuthorID);
36
+        $Header = Users::format_username($AuthorID, true, true, true, true, true) . time_diff($AddedTime) . $Header; ?>
37
+<table
38
+  class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '') . ($Unread ? ' forum_unread' : '')?>"
39
+  id="post<?=$PostID?>">
40
+  <colgroup>
41
+    <?php if (Users::has_avatars_enabled()) { ?>
42
+    <col class="col_avatar" />
43
+    <?php } ?>
44
+    <col class="col_post_body" />
45
+  </colgroup>
46
+  <tr class="colhead_dark">
47
+    <td colspan="<?=(Users::has_avatars_enabled() ? 2 : 1)?>">
48
+      <div class="float_left"><a class="post_id"
49
+          href="<?=$Link?>">#<?=$PostID?></a>
50
+        <?=$Header?>
51
+        <?php if ($Tools) { ?>
52
+        - <a href="#quickpost"
53
+          onclick="Quote('<?=$PostID?>','<?=$UserInfo['Username']?>', true);"
54
+          class="brackets">Quote</a>
55
+        <?php if ($AuthorID == G::$LoggedUser['ID'] || check_perms('site_moderate_forums')) { ?>
56
+        - <a href="#post<?=$PostID?>"
57
+          onclick="Edit_Form('<?=$PostID?>','');"
58
+          class="brackets">Edit</a>
59
+        <?php }
50
       if (check_perms('site_moderate_forums')) { ?>
60
       if (check_perms('site_moderate_forums')) { ?>
51
-            - <a href="#post<?=$PostID?>" onclick="Delete('<?=$PostID?>');" class="brackets">Delete</a>
52
-<?      } ?>
53
-          </div>
54
-          <div id="bar<?=$PostID?>" class="float_right">
55
-            <a href="reports.php?action=report&amp;type=comment&amp;id=<?=$PostID?>" class="brackets">Report</a>
56
-<?
61
+        - <a href="#post<?=$PostID?>"
62
+          onclick="Delete('<?=$PostID?>');"
63
+          class="brackets">Delete</a>
64
+        <?php } ?>
65
+      </div>
66
+      <div id="bar<?=$PostID?>" class="float_right">
67
+        <a href="reports.php?action=report&amp;type=comment&amp;id=<?=$PostID?>"
68
+          class="brackets">Report</a>
69
+        <?php
57
       if (check_perms('users_warn') && $AuthorID != G::$LoggedUser['ID'] && G::$LoggedUser['Class'] >= $UserInfo['Class']) {
70
       if (check_perms('users_warn') && $AuthorID != G::$LoggedUser['ID'] && G::$LoggedUser['Class'] >= $UserInfo['Class']) {
58
-?>
59
-            <form class="manage_form hidden" name="user" id="warn<?=$PostID?>" action="comments.php" method="post">
60
-              <input type="hidden" name="action" value="warn" />
61
-              <input type="hidden" name="postid" value="<?=$PostID?>" />
62
-            </form>
63
-            - <a href="#" onclick="$('#warn<?=$PostID?>').raw().submit(); return false;" class="brackets">Warn</a>
64
-<?      } ?>
65
-            &nbsp;
66
-            <a href="#">&uarr;</a>
67
-<?    } ?>
68
-          </div>
69
-        </td>
70
-      </tr>
71
-      <tr>
72
-<?    if (Users::has_avatars_enabled()) { ?>
73
-        <td class="avatar" valign="top">
74
-        <?=Users::show_avatar($UserInfo['Avatar'], $AuthorID, $UserInfo['Username'], G::$LoggedUser['DisableAvatars'])?>
75
-        </td>
76
-<?    } ?>
77
-        <td class="body" valign="top">
78
-          <div id="content<?=$PostID?>">
79
-            <?=Text::full_format($Body)?>
80
-<?    if ($EditedUserID) { ?>
81
-            <br />
82
-            <br />
83
-            <div class="last_edited">
84
-<?      if (check_perms('site_admin_forums')) { ?>
85
-              <a href="#content<?=$PostID?>" onclick="LoadEdit('<?=substr($Link, 0, strcspn($Link, '.'))?>', <?=$PostID?>, 1); return false;">&laquo;</a>
86
-<?      } ?>
87
-              Last edited by
88
-              <?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime, 2, true, true)?>
89
-<?    } ?>
90
-            </div>
91
-          </div>
92
-        </td>
93
-      </tr>
94
-    </table>
95
-<?  }
71
+          ?>
72
+        <form class="manage_form hidden" name="user"
73
+          id="warn<?=$PostID?>" action="comments.php" method="post">
74
+          <input type="hidden" name="action" value="warn" />
75
+          <input type="hidden" name="postid" value="<?=$PostID?>" />
76
+        </form>
77
+        - <a href="#"
78
+          onclick="$('#warn<?=$PostID?>').raw().submit(); return false;"
79
+          class="brackets">Warn</a>
80
+        <?php
81
+      } ?>
82
+        &nbsp;
83
+        <a href="#">&uarr;</a>
84
+        <?php } ?>
85
+      </div>
86
+    </td>
87
+  </tr>
88
+  <tr>
89
+    <?php if (Users::has_avatars_enabled()) { ?>
90
+    <td class="avatar" valign="top">
91
+      <?=Users::show_avatar($UserInfo['Avatar'], $AuthorID, $UserInfo['Username'], G::$LoggedUser['DisableAvatars'])?>
92
+    </td>
93
+    <?php } ?>
94
+    <td class="body" valign="top">
95
+      <div id="content<?=$PostID?>">
96
+        <?=Text::full_format($Body)?>
97
+        <?php if ($EditedUserID) { ?>
98
+        <br />
99
+        <br />
100
+        <div class="last_edited">
101
+          <?php if (check_perms('site_admin_forums')) { ?>
102
+          <a href="#content<?=$PostID?>"
103
+            onclick="LoadEdit('<?=substr($Link, 0, strcspn($Link, '.'))?>', <?=$PostID?>, 1); return false;">&laquo;</a>
104
+          <?php } ?>
105
+          Last edited by
106
+          <?=Users::format_username($EditedUserID, false, false, false) ?>
107
+          <?=time_diff($EditedTime, 2, true, true)?>
108
+          <?php } ?>
109
+        </div>
110
+      </div>
111
+    </td>
112
+  </tr>
113
+</table>
114
+<?php
115
+    }
96
 }
116
 }

+ 215
- 202
classes/donationsview.class.php View File

1
-<?
1
+<?php
2
 
2
 
3
-class DonationsView {
4
-  public static function render_mod_donations($UserID) {
5
-?>
6
-    <table class="layout box" id="donation_box">
7
-      <tr class="colhead">
8
-        <td colspan="2">
9
-          Donor System (add points)
10
-        </td>
11
-      </tr>
12
-      <tr>
13
-        <td class="label">Value:</td>
14
-        <td>
15
-          <input type="text" name="donation_value" onkeypress="return isNumberKey(event);" />
16
-          <select name="donation_currency">
17
-            <option value="EUR">EUR</option>
18
-            <option value="USD">USD</option>
19
-            <option value="BTC">BTC</option>
20
-          </select>
21
-        </td>
22
-      </tr>
23
-      <tr>
24
-        <td class="label">Reason:</td>
25
-        <td><input type="text" class="wide_input_text" name="donation_reason" /></td>
26
-      </tr>
27
-      <tr>
28
-        <td align="right" colspan="2">
29
-          <input type="submit" name="donor_points_submit" value="Add donor points" />
30
-        </td>
31
-      </tr>
32
-    </table>
3
+class DonationsView
4
+{
5
+    public static function render_mod_donations($UserID)
6
+    {
7
+        ?>
8
+<table class="layout box" id="donation_box">
9
+  <tr class="colhead">
10
+    <td colspan="2">
11
+      Donor System (add points)
12
+    </td>
13
+  </tr>
14
+  <tr>
15
+    <td class="label">Value:</td>
16
+    <td>
17
+      <input type="text" name="donation_value" onkeypress="return isNumberKey(event);" />
18
+      <select name="donation_currency">
19
+        <option value="EUR">EUR</option>
20
+        <option value="USD">USD</option>
21
+        <option value="BTC">BTC</option>
22
+      </select>
23
+    </td>
24
+  </tr>
25
+  <tr>
26
+    <td class="label">Reason:</td>
27
+    <td><input type="text" class="wide_input_text" name="donation_reason" /></td>
28
+  </tr>
29
+  <tr>
30
+    <td align="right" colspan="2">
31
+      <input type="submit" name="donor_points_submit" value="Add donor points" />
32
+    </td>
33
+  </tr>
34
+</table>
33
 
35
 
34
-    <table class="layout box" id="donor_points_box">
35
-      <tr class="colhead">
36
-        <td colspan="3" class="tooltip" title='Use this tool only when manually correcting values. If crediting donations normally, use the "Donor System (add points)" tool'>
37
-          Donor System (modify values)
38
-        </td>
39
-      </tr>
40
-      <tr>
41
-        <td class="label tooltip" title="Active points determine a user's Donor Rank and do expire.">Active points:</td>
42
-        <td><input type="text" name="donor_rank" onkeypress="return isNumberKey(event);" value="<?=Donations::get_rank($UserID)?>" /></td>
43
-      </tr>
44
-      <tr>
45
-        <td class="label tooltip" title="Total points represent a user's overall total and never expire. Total points determines a user's Special Rank and Donor Leaderboard placement.">Total points:</td>
46
-        <td><input type="text" name="total_donor_rank" onkeypress="return isNumberKey(event);" value="<?=Donations::get_total_rank($UserID)?>" /></td>
47
-      </tr>
48
-      <tr>
49
-        <td class="label">Reason:</td>
50
-        <td><input type="text" class="wide_input_text" name="reason" /></td>
51
-      </tr>
52
-      <tr>
53
-        <td align="right" colspan="2">
54
-          <input type="submit" name="donor_values_submit" value="Change point values" />
55
-        </td>
56
-      </tr>
57
-    </table>
58
-<?
59
-  }
36
+<table class="layout box" id="donor_points_box">
37
+  <tr class="colhead">
38
+    <td colspan="3" class="tooltip"
39
+      title='Use this tool only when manually correcting values. If crediting donations normally, use the "Donor System (add points)" tool'>
40
+      Donor System (modify values)
41
+    </td>
42
+  </tr>
43
+  <tr>
44
+    <td class="label tooltip" title="Active points determine a user's Donor Rank and do expire.">Active points:</td>
45
+    <td><input type="text" name="donor_rank" onkeypress="return isNumberKey(event);"
46
+        value="<?=Donations::get_rank($UserID)?>" /></td>
47
+  </tr>
48
+  <tr>
49
+    <td class="label tooltip"
50
+      title="Total points represent a user's overall total and never expire. Total points determines a user's Special Rank and Donor Leaderboard placement.">
51
+      Total points:</td>
52
+    <td><input type="text" name="total_donor_rank" onkeypress="return isNumberKey(event);"
53
+        value="<?=Donations::get_total_rank($UserID)?>" /></td>
54
+  </tr>
55
+  <tr>
56
+    <td class="label">Reason:</td>
57
+    <td><input type="text" class="wide_input_text" name="reason" /></td>
58
+  </tr>
59
+  <tr>
60
+    <td align="right" colspan="2">
61
+      <input type="submit" name="donor_values_submit" value="Change point values" />
62
+    </td>
63
+  </tr>
64
+</table>
65
+<?php
66
+    }
60
 
67
 
61
-  public static function render_donor_stats($UserID) {
62
-    $OwnProfile = G::$LoggedUser['ID'] == $UserID;
63
-    if (check_perms("users_mod") || $OwnProfile || Donations::is_visible($UserID)) {
64
-?>
65
-      <div class="box box_info box_userinfo_donor_stats">
66
-        <div class="head colhead_dark">Donor Statistics</div>
67
-        <ul class="stats nobullet">
68
-<?
68
+    public static function render_donor_stats($UserID)
69
+    {
70
+        $OwnProfile = G::$LoggedUser['ID'] === $UserID;
71
+        if (check_perms("users_mod") || $OwnProfile || Donations::is_visible($UserID)) {
72
+            ?>
73
+<div class="box box_info box_userinfo_donor_stats">
74
+  <div class="head colhead_dark">Donor Statistics</div>
75
+  <ul class="stats nobullet">
76
+    <?php
69
       if (Donations::is_donor($UserID)) {
77
       if (Donations::is_donor($UserID)) {
70
-        if (check_perms('users_mod') || $OwnProfile) {
71
-?>
72
-          <li>
73
-            Total donor points: <?=Donations::get_total_rank($UserID)?>
74
-          </li>
75
-<?        } ?>
76
-          <li>
77
-            Current donor rank: <?=self::render_rank(Donations::get_rank($UserID), Donations::get_special_rank($UserID), true)?>
78
-          </li>
79
-          <li>
80
-            Leaderboard position: <?=Donations::get_leaderboard_position($UserID)?>
81
-          </li>
82
-          <li>
83
-            Last donated: <?=time_diff(Donations::get_donation_time($UserID))?>
84
-          </li>
85
-          <li>
86
-            Rank expires: <?=(Donations::get_rank_expiration($UserID))?>
87
-          </li>
88
-<?      } else { ?>
89
-          <li>
90
-            This user hasn't donated.
91
-          </li>
92
-<?      } ?>
93
-        </ul>
94
-      </div>
95
-<?
78
+          if (check_perms('users_mod') || $OwnProfile) {
79
+              ?>
80
+    <li>
81
+      Total donor points: <?=Donations::get_total_rank($UserID)?>
82
+    </li>
83
+    <?php
84
+          } ?>
85
+    <li>
86
+      Current donor rank: <?=self::render_rank(Donations::get_rank($UserID), Donations::get_special_rank($UserID), true)?>
87
+    </li>
88
+    <li>
89
+      Leaderboard position: <?=Donations::get_leaderboard_position($UserID)?>
90
+    </li>
91
+    <li>
92
+      Last donated: <?=time_diff(Donations::get_donation_time($UserID))?>
93
+    </li>
94
+    <li>
95
+      Rank expires: <?=(Donations::get_rank_expiration($UserID))?>
96
+    </li>
97
+    <?php
98
+      } else { ?>
99
+    <li>
100
+      This user hasn't donated.
101
+    </li>
102
+    <?php      } ?>
103
+  </ul>
104
+</div>
105
+<?php
106
+        }
96
     }
107
     }
97
-  }
98
 
108
 
99
-  public static function render_profile_rewards($EnabledRewards, $ProfileRewards) {
100
-    for ($i = 1; $i <= 4; $i++) {
101
-      if ($EnabledRewards['HasProfileInfo' . $i] && $ProfileRewards['ProfileInfo' . $i]) {
102
-?>
103
-      <div class="box">
104
-        <div class="head">
105
-          <span><?=!empty($ProfileRewards['ProfileInfoTitle' . $i]) ? display_str($ProfileRewards['ProfileInfoTitle' . $i]) : "Extra Profile " . ($i + 1)?></span>
106
-          <span class="float_right"><a data-toggle-target="#profilediv_<?=$i?>" data-toggle-replace="Show" class="brackets">Hide</a></span>
107
-        </div>
108
-        <div class="pad profileinfo" id="profilediv_<?=$i?>">
109
-<?          echo Text::full_format($ProfileRewards['ProfileInfo' . $i]); ?>
110
-        </div>
111
-      </div>
112
-<?
113
-      }
109
+    public static function render_profile_rewards($EnabledRewards, $ProfileRewards)
110
+    {
111
+        for ($i = 1; $i <= 4; $i++) {
112
+            if ($EnabledRewards['HasProfileInfo' . $i] && $ProfileRewards['ProfileInfo' . $i]) {
113
+                ?>
114
+<div class="box">
115
+  <div class="head">
116
+    <span><?=!empty($ProfileRewards['ProfileInfoTitle' . $i]) ? display_str($ProfileRewards['ProfileInfoTitle' . $i]) : "Extra Profile " . ($i + 1)?></span>
117
+    <span class="float_right"><a
118
+        data-toggle-target="#profilediv_<?=$i?>"
119
+        data-toggle-replace="Show" class="brackets">Hide</a></span>
120
+  </div>
121
+  <div class="pad profileinfo" id="profilediv_<?=$i?>">
122
+    <?php          echo Text::full_format($ProfileRewards['ProfileInfo' . $i]); ?>
123
+  </div>
124
+</div>
125
+<?php
126
+            }
127
+        }
114
     }
128
     }
115
-  }
116
 
129
 
117
-  public static function render_donation_history($DonationHistory) {
118
-    if (empty($DonationHistory)) {
119
-      return;
120
-    }
121
-?>
122
-    <div class="box box2" id="donation_history_box">
123
-      <div class="head">
124
-        Donation History <a data-toggle-target="#donation_history" class="brackets" style="float_right">Toggle</a>
125
-      </div>
126
-      <div class="hidden" id="donation_history">
127
-        <table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
128
-          <tbody>
129
-          <tr class="colhead_dark">
130
-            <td>
131
-              <strong>Source</strong>
132
-            </td>
133
-            <td>
134
-              <strong>Date</strong>
135
-            </td>
136
-            <td>
137
-              <strong>Amount (EUR)</strong>
138
-            </td>
139
-            <td>
140
-              <strong>Added Points</strong>
141
-            </td>
142
-            <td>
143
-              <strong>Total Points</strong>
144
-            </td>
145
-            <td>
146
-              <strong>Email</strong>
147
-            </td>
148
-            <td style="width: 30%;">
149
-              <strong>Reason</strong>
150
-            </td>
151
-          </tr>
152
-<?    foreach ($DonationHistory as $Donation) { ?>
153
-          <tr class="row">
154
-            <td>
155
-              <?=display_str($Donation['Source'])?> (<?=Users::format_username($Donation['AddedBy'])?>)
156
-            </td>
157
-            <td>
158
-              <?=$Donation['Time']?>
159
-            </td>
160
-            <td>
161
-              <?=$Donation['Amount']?>
162
-            </td>
163
-            <td>
164
-              <?=$Donation['Rank']?>
165
-            </td>
166
-            <td>
167
-              <?=$Donation['TotalRank']?>
168
-            </td>
169
-            <td>
170
-              <?=display_str($Donation['Email'])?>
171
-            </td>
172
-            <td>
173
-              <?=display_str($Donation['Reason'])?>
174
-            </td>
175
-          </tr>
176
-<?
130
+    public static function render_donation_history($DonationHistory)
131
+    {
132
+        if (empty($DonationHistory)) {
133
+            return;
134
+        } ?>
135
+<div class="box box2" id="donation_history_box">
136
+  <div class="head">
137
+    Donation History <a data-toggle-target="#donation_history" class="brackets" style="float_right">Toggle</a>
138
+  </div>
139
+  <div class="hidden" id="donation_history">
140
+    <table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
141
+      <tbody>
142
+        <tr class="colhead_dark">
143
+          <td>
144
+            <strong>Source</strong>
145
+          </td>
146
+          <td>
147
+            <strong>Date</strong>
148
+          </td>
149
+          <td>
150
+            <strong>Amount (EUR)</strong>
151
+          </td>
152
+          <td>
153
+            <strong>Added Points</strong>
154
+          </td>
155
+          <td>
156
+            <strong>Total Points</strong>
157
+          </td>
158
+          <td>
159
+            <strong>Email</strong>
160
+          </td>
161
+          <td style="width: 30%;">
162
+            <strong>Reason</strong>
163
+          </td>
164
+        </tr>
165
+        <?php    foreach ($DonationHistory as $Donation) { ?>
166
+        <tr class="row">
167
+          <td>
168
+            <?=display_str($Donation['Source'])?>
169
+            (<?=Users::format_username($Donation['AddedBy'])?>)
170
+          </td>
171
+          <td>
172
+            <?=$Donation['Time']?>
173
+          </td>
174
+          <td>
175
+            <?=$Donation['Amount']?>
176
+          </td>
177
+          <td>
178
+            <?=$Donation['Rank']?>
179
+          </td>
180
+          <td>
181
+            <?=$Donation['TotalRank']?>
182
+          </td>
183
+          <td>
184
+            <?=display_str($Donation['Email'])?>
185
+          </td>
186
+          <td>
187
+            <?=display_str($Donation['Reason'])?>
188
+          </td>
189
+        </tr>
190
+        <?php
191
+    } ?>
192
+      </tbody>
193
+    </table>
194
+  </div>
195
+</div>
196
+<?php
177
     }
197
     }
178
-?>
179
-          </tbody>
180
-        </table>
181
-      </div>
182
-    </div>
183
-<?
184
-  }
185
 
198
 
186
-  public static function render_rank($Rank, $SpecialRank, $ShowOverflow = false) {
187
-    if ($SpecialRank == 3) {
188
-      $Display = '∞ [Diamond]';
189
-    } else {
190
-      $CurrentRank = $Rank >= MAX_RANK ? MAX_RANK : $Rank;
191
-      $Overflow = $Rank - $CurrentRank;
192
-      $Display = $CurrentRank;
193
-      if ($Display == 5 || $Display == 6) {
194
-        $Display--;
195
-      }
196
-      if ($ShowOverflow && $Overflow) {
197
-        $Display .= " (+$Overflow)";
198
-      }
199
-      if ($Rank >= 6) {
200
-        $Display .= ' [Gold]';
201
-      } elseif ($Rank >= 4) {
202
-        $Display .= ' [Silver]';
203
-      } elseif ($Rank >= 3) {
204
-        $Display .= ' [Bronze]';
205
-      } elseif ($Rank >= 2) {
206
-        $Display .= ' [Copper]';
207
-      } elseif ($Rank >= 1) {
208
-        $Display .= ' [Red]';
209
-      }
199
+    public static function render_rank($Rank, $SpecialRank, $ShowOverflow = false)
200
+    {
201
+        if ($SpecialRank === 3) {
202
+            $Display = '∞ [Diamond]';
203
+        } else {
204
+            $CurrentRank = $Rank >= MAX_RANK ? MAX_RANK : $Rank;
205
+            $Overflow = $Rank - $CurrentRank;
206
+            $Display = $CurrentRank;
207
+            if ($Display === 5 || $Display === 6) {
208
+                $Display--;
209
+            }
210
+            if ($ShowOverflow && $Overflow) {
211
+                $Display .= " (+$Overflow)";
212
+            }
213
+            if ($Rank >= 6) {
214
+                $Display .= ' [Gold]';
215
+            } elseif ($Rank >= 4) {
216
+                $Display .= ' [Silver]';
217
+            } elseif ($Rank >= 3) {
218
+                $Display .= ' [Bronze]';
219
+            } elseif ($Rank >= 2) {
220
+                $Display .= ' [Copper]';
221
+            } elseif ($Rank >= 1) {
222
+                $Display .= ' [Red]';
223
+            }
224
+        }
225
+        echo $Display;
210
     }
226
     }
211
-    echo $Display;
212
-  }
213
-
214
 }
227
 }

+ 77
- 45
classes/format.class.php View File

2
 
2
 
3
 class Format
3
 class Format
4
 {
4
 {
5
-
6
-  /**
7
-   * Torrent Labels
8
-   * Map a common display string to a CSS class
9
-   * Indexes are lower case
10
-   * Note the "tl_" prefix for "torrent label"
11
-   *
12
-   * There are five basic types:
13
-   * * tl_free (leech status)
14
-   * * tl_snatched
15
-   * * tl_reported
16
-   * * tl_approved
17
-   * * tl_notice (default)
18
-   *
19
-   * @var array Strings
20
-   */
5
+    /**
6
+     * Torrent Labels
7
+     * Map a common display string to a CSS class
8
+     * Indexes are lower case
9
+     * Note the "tl_" prefix for "torrent label"
10
+     *
11
+     * There are five basic types:
12
+     * * tl_free (leech status)
13
+     * * tl_snatched
14
+     * * tl_reported
15
+     * * tl_approved
16
+     * * tl_notice (default)
17
+     *
18
+     * @var array Strings
19
+     */
21
     private static $TorrentLabels = array(
20
     private static $TorrentLabels = array(
22
-    'default'  => 'tl_notice',
23
-    'snatched' => 'tl_snatched',
24
-    'seeding'  => 'tl_seeding',
25
-    'leeching' => 'tl_leeching',
21
+        'default'  => 'tl_notice',
22
+        'snatched' => 'tl_snatched',
23
+        'seeding'  => 'tl_seeding',
24
+        'leeching' => 'tl_leeching',
26
 
25
 
27
-    'freeleech'          => 'tl_free',
28
-    'neutral leech'      => 'tl_free tl_neutral',
29
-    'personal freeleech' => 'tl_free tl_personal',
26
+        'freeleech'          => 'tl_free',
27
+        'neutral leech'      => 'tl_free tl_neutral',
28
+        'personal freeleech' => 'tl_free tl_personal',
30
 
29
 
31
-    'reported'       => 'tl_reported',
32
-    'bad tags'       => 'tl_reported tl_bad_tags',
33
-    'bad folders'    => 'tl_reported tl_bad_folders',
34
-    'bad file names' => 'tl_reported tl_bad_file_names',
30
+        'reported'       => 'tl_reported',
31
+        'bad tags'       => 'tl_reported tl_bad_tags',
32
+        'bad folders'    => 'tl_reported tl_bad_folders',
33
+        'bad file names' => 'tl_reported tl_bad_file_names',
35
 
34
 
36
-    'uncensored' => 'tl_notice'
37
-  );
35
+        'uncensored' => 'tl_notice'
36
+    );
38
 
37
 
39
     /**
38
     /**
40
      * Shorten a string
39
      * Shorten a string
82
         if ($Ratio < 0.1) {
81
         if ($Ratio < 0.1) {
83
             return 'r00';
82
             return 'r00';
84
         }
83
         }
84
+
85
         if ($Ratio < 0.2) {
85
         if ($Ratio < 0.2) {
86
             return 'r01';
86
             return 'r01';
87
         }
87
         }
88
+
88
         if ($Ratio < 0.3) {
89
         if ($Ratio < 0.3) {
89
             return 'r02';
90
             return 'r02';
90
         }
91
         }
92
+
91
         if ($Ratio < 0.4) {
93
         if ($Ratio < 0.4) {
92
             return 'r03';
94
             return 'r03';
93
         }
95
         }
96
+
94
         if ($Ratio < 0.5) {
97
         if ($Ratio < 0.5) {
95
             return 'r04';
98
             return 'r04';
96
         }
99
         }
100
+
97
         if ($Ratio < 0.6) {
101
         if ($Ratio < 0.6) {
98
             return 'r05';
102
             return 'r05';
99
         }
103
         }
104
+
100
         if ($Ratio < 0.7) {
105
         if ($Ratio < 0.7) {
101
             return 'r06';
106
             return 'r06';
102
         }
107
         }
108
+
103
         if ($Ratio < 0.8) {
109
         if ($Ratio < 0.8) {
104
             return 'r07';
110
             return 'r07';
105
         }
111
         }
112
+
106
         if ($Ratio < 0.9) {
113
         if ($Ratio < 0.9) {
107
             return 'r08';
114
             return 'r08';
108
         }
115
         }
116
+
109
         if ($Ratio < 1) {
117
         if ($Ratio < 1) {
110
             return 'r09';
118
             return 'r09';
111
         }
119
         }
120
+
112
         if ($Ratio < 2) {
121
         if ($Ratio < 2) {
113
             return 'r10';
122
             return 'r10';
114
         }
123
         }
124
+
115
         if ($Ratio < 5) {
125
         if ($Ratio < 5) {
116
             return 'r20';
126
             return 'r20';
117
         }
127
         }
133
         if ($Ratio === false) {
143
         if ($Ratio === false) {
134
             return '&ndash;';
144
             return '&ndash;';
135
         }
145
         }
146
+
136
         if ($Ratio === '∞') {
147
         if ($Ratio === '∞') {
137
             return '<span class="tooltip r99" title="Infinite">∞</span>';
148
             return '<span class="tooltip r99" title="Infinite">∞</span>';
138
         }
149
         }
150
+
139
         if ($Color) {
151
         if ($Color) {
140
             $Ratio = sprintf(
152
             $Ratio = sprintf(
141
                 '<span class="tooltip %s" title="%s">%s</span>',
153
                 '<span class="tooltip %s" title="%s">%s</span>',
144
                 $Ratio
156
                 $Ratio
145
             );
157
             );
146
         }
158
         }
147
-
148
         return $Ratio;
159
         return $Ratio;
149
     }
160
     }
150
 
161
 
160
         if ($Divisor === 0 && $Dividend === 0) {
171
         if ($Divisor === 0 && $Dividend === 0) {
161
             return false;
172
             return false;
162
         }
173
         }
174
+
163
         if ($Divisor === 0) {
175
         if ($Divisor === 0) {
164
             return '∞';
176
             return '∞';
165
         }
177
         }
180
             $Separator = $Escape ? '&amp;' : '&';
192
             $Separator = $Escape ? '&amp;' : '&';
181
             $QueryItems = null;
193
             $QueryItems = null;
182
             parse_str($_SERVER['QUERY_STRING'], $QueryItems);
194
             parse_str($_SERVER['QUERY_STRING'], $QueryItems);
195
+
183
             foreach ($Exclude as $Key) {
196
             foreach ($Exclude as $Key) {
184
                 unset($QueryItems[$Key]);
197
                 unset($QueryItems[$Key]);
185
             }
198
             }
199
+
186
             if ($Sort) {
200
             if ($Sort) {
187
                 ksort($QueryItems);
201
                 ksort($QueryItems);
188
             }
202
             }
217
                 error(0);
231
                 error(0);
218
             }
232
             }
219
             $Page = $_GET['page'];
233
             $Page = $_GET['page'];
234
+
220
             if ($Page <= 0) {
235
             if ($Page <= 0) {
221
                 $Page = 1;
236
                 $Page = 1;
222
             }
237
             }
262
         $Location = "$Document.php";
277
         $Location = "$Document.php";
263
         $StartPage = ceil($StartPage);
278
         $StartPage = ceil($StartPage);
264
         $TotalPages = 0;
279
         $TotalPages = 0;
280
+
265
         if ($TotalRecords > 0) {
281
         if ($TotalRecords > 0) {
266
             $StartPage = min($StartPage, ceil($TotalRecords / $ItemsPerPage));
282
             $StartPage = min($StartPage, ceil($TotalRecords / $ItemsPerPage));
267
 
283
 
305
                     if ($i !== $StartPage) {
321
                     if ($i !== $StartPage) {
306
                         $Pages .= "<a href=\"$Location?page=$i$QueryString$Anchor\">";
322
                         $Pages .= "<a href=\"$Location?page=$i$QueryString$Anchor\">";
307
                     }
323
                     }
324
+
308
                     $Pages .= '<strong>';
325
                     $Pages .= '<strong>';
309
                     if ($i * $ItemsPerPage > $TotalRecords) {
326
                     if ($i * $ItemsPerPage > $TotalRecords) {
310
                         $Pages .= ((($i - 1) * $ItemsPerPage) + 1)."-$TotalRecords";
327
                         $Pages .= ((($i - 1) * $ItemsPerPage) + 1)."-$TotalRecords";
316
                     if ($i !== $StartPage) {
333
                     if ($i !== $StartPage) {
317
                         $Pages .= '</a>';
334
                         $Pages .= '</a>';
318
                     }
335
                     }
336
+
319
                     if ($i < $StopPage) {
337
                     if ($i < $StopPage) {
320
                         $Pages .= ' | ';
338
                         $Pages .= ' | ';
321
                     }
339
                     }
329
                 $Pages .= "<a href=\"$Location?page=$TotalPages$QueryString$Anchor\"><strong> Last »</strong></a>";
347
                 $Pages .= "<a href=\"$Location?page=$TotalPages$QueryString$Anchor\"><strong> Last »</strong></a>";
330
             }
348
             }
331
         }
349
         }
350
+
332
         if ($TotalPages > 1) {
351
         if ($TotalPages > 1) {
333
             return $Pages;
352
             return $Pages;
334
         }
353
         }
347
     {
366
     {
348
         $Units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB');
367
         $Units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB');
349
         $Size = (double)$Size;
368
         $Size = (double)$Size;
369
+
350
         for ($Steps = 0; abs($Size) >= 1024 && $Steps < count($Units); $Size /= 1024, $Steps++) {
370
         for ($Steps = 0; abs($Size) >= 1024 && $Steps < count($Units); $Size /= 1024, $Steps++) {
351
         }
371
         }
372
+
352
         if (func_num_args() === 1 && $Steps >= 4) {
373
         if (func_num_args() === 1 && $Steps >= 4) {
353
             $Levels++;
374
             $Levels++;
354
         }
375
         }
369
             $Number = $Number / 1000;
390
             $Number = $Number / 1000;
370
         }
391
         }
371
         switch ($Steps) {
392
         switch ($Steps) {
372
-      case 0: return round($Number); break;
373
-      case 1: return round($Number, 2).'k'; break;
374
-      case 2: return round($Number, 2).'M'; break;
375
-      case 3: return round($Number, 2).'G'; break;
376
-      case 4: return round($Number, 2).'T'; break;
377
-      case 5: return round($Number, 2).'P'; break;
378
-      default:
379
-        return round($Number, 2).'E + '.$Steps * 3;
380
-    }
393
+          case 0: return round($Number); break;
394
+          case 1: return round($Number, 2).'k'; break;
395
+          case 2: return round($Number, 2).'M'; break;
396
+          case 3: return round($Number, 2).'G'; break;
397
+          case 4: return round($Number, 2).'T'; break;
398
+          case 5: return round($Number, 2).'P'; break;
399
+          default:
400
+            return round($Number, 2).'E + '.$Steps * 3;
401
+        }
381
     }
402
     }
382
 
403
 
383
     /**
404
     /**
393
         if (empty($Unit)) {
414
         if (empty($Unit)) {
394
             return $Value ? round($Value) : 0;
415
             return $Value ? round($Value) : 0;
395
         }
416
         }
417
+
396
         switch (strtolower($Unit[0])) {
418
         switch (strtolower($Unit[0])) {
397
-      case 'k': return round($Value * 1024);
398
-      case 'm': return round($Value * 1048576);
399
-      case 'g': return round($Value * 1073741824);
400
-      case 't': return round($Value * 1099511627776);
401
-      default: return 0;
402
-    }
419
+          case 'k': return round($Value * 1024);
420
+          case 'm': return round($Value * 1048576);
421
+          case 'g': return round($Value * 1073741824);
422
+          case 't': return round($Value * 1099511627776);
423
+          default: return 0;
424
+        }
403
     }
425
     }
404
 
426
 
405
     /**
427
     /**
447
         if (empty($Array)) {
469
         if (empty($Array)) {
448
             $Array = $_GET;
470
             $Array = $_GET;
449
         }
471
         }
472
+
450
         if (isset($Array[$Name]) && $Array[$Name] !== '') {
473
         if (isset($Array[$Name]) && $Array[$Name] !== '') {
451
             if ($Array[$Name] === $Value) {
474
             if ($Array[$Name] === $Value) {
452
                 echo " $Attribute=\"$Attribute\"";
475
                 echo " $Attribute=\"$Attribute\"";
473
         if ($UserIDKey && isset($_REQUEST[$UserIDKey]) && G::$LoggedUser['ID'] != $_REQUEST[$UserIDKey]) {
496
         if ($UserIDKey && isset($_REQUEST[$UserIDKey]) && G::$LoggedUser['ID'] != $_REQUEST[$UserIDKey]) {
474
             return '';
497
             return '';
475
         }
498
         }
499
+
476
         $Pass = true;
500
         $Pass = true;
477
         if (!is_array($Tests)) {
501
         if (!is_array($Tests)) {
478
             // Scalars are nice and easy
502
             // Scalars are nice and easy
489
             // Loop to the end of the array or until we find a matching test
513
             // Loop to the end of the array or until we find a matching test
490
             foreach ($Tests as $Test) {
514
             foreach ($Tests as $Test) {
491
                 $Pass = true;
515
                 $Pass = true;
516
+
492
                 // If $Pass remains true after this test, it's a match
517
                 // If $Pass remains true after this test, it's a match
493
                 foreach ($Test as $Type => $Part) {
518
                 foreach ($Test as $Type => $Part) {
494
                     if (!isset($Target[$Type]) || $Target[$Type] !== $Part) {
519
                     if (!isset($Target[$Type]) || $Target[$Type] !== $Part) {
496
                         break;
521
                         break;
497
                     }
522
                     }
498
                 }
523
                 }
524
+
499
                 if ($Pass) {
525
                 if ($Pass) {
500
                     break;
526
                     break;
501
                 }
527
                 }
502
             }
528
             }
503
         }
529
         }
530
+
504
         if (!$Pass) {
531
         if (!$Pass) {
505
             return '';
532
             return '';
506
         }
533
         }
534
+
507
         if ($AddAttribute) {
535
         if ($AddAttribute) {
508
             return " class=\"$ClassName\"";
536
             return " class=\"$ClassName\"";
509
         }
537
         }
522
             if (self::is_utf8($Str)) {
550
             if (self::is_utf8($Str)) {
523
                 $Encoding = 'UTF-8';
551
                 $Encoding = 'UTF-8';
524
             }
552
             }
553
+
525
             if (empty($Encoding)) {
554
             if (empty($Encoding)) {
526
                 $Encoding = mb_detect_encoding($Str, 'UTF-8, ISO-8859-1');
555
                 $Encoding = mb_detect_encoding($Str, 'UTF-8, ISO-8859-1');
527
             }
556
             }
557
+
528
             if (empty($Encoding)) {
558
             if (empty($Encoding)) {
529
                 $Encoding = 'ISO-8859-1';
559
                 $Encoding = 'ISO-8859-1';
530
             }
560
             }
561
+
531
             if ($Encoding === 'UTF-8') {
562
             if ($Encoding === 'UTF-8') {
532
                 return $Str;
563
                 return $Str;
533
             } else {
564
             } else {
592
         if (empty($Class)) {
623
         if (empty($Class)) {
593
             $Class = self::find_torrent_label_class($Text);
624
             $Class = self::find_torrent_label_class($Text);
594
         }
625
         }
626
+        
595
         return sprintf(
627
         return sprintf(
596
             '<strong class="torrent_label tooltip %1$s" title="%2$s" style="white-space: nowrap;">%2$s</strong>',
628
             '<strong class="torrent_label tooltip %1$s" title="%2$s" style="white-space: nowrap;">%2$s</strong>',
597
             display_str($Class),
629
             display_str($Class),

+ 11
- 7
classes/image.class.php View File

15
     {
15
     {
16
         $this->Image = imagecreate($Width, $Height);
16
         $this->Image = imagecreate($Width, $Height);
17
         $this->Font = SERVER_ROOT.'/classes/fonts/VERDANA.TTF';
17
         $this->Font = SERVER_ROOT.'/classes/fonts/VERDANA.TTF';
18
+
18
         if (function_exists('imageantialias')) {
19
         if (function_exists('imageantialias')) {
19
             imageantialias($this->Image, true);
20
             imageantialias($this->Image, true);
20
         }
21
         }
27
 
28
 
28
     public function line($x1, $y1, $x2, $y2, $Color, $Thickness = 1)
29
     public function line($x1, $y1, $x2, $y2, $Color, $Thickness = 1)
29
     {
30
     {
30
-        if ($Thickness == 1) {
31
+        if ($Thickness === 1) {
31
             return imageline($this->Image, $x1, $y1, $x2, $y2, $Color);
32
             return imageline($this->Image, $x1, $y1, $x2, $y2, $Color);
32
         }
33
         }
33
         $t = $Thickness / 2 - 0.5;
34
         $t = $Thickness / 2 - 0.5;
34
-        if ($x1 == $x2 || $y1 == $y2) {
35
+
36
+        if ($x1 === $x2 || $y1 === $y2) {
35
             return imagefilledrectangle($this->Image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color);
37
             return imagefilledrectangle($this->Image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color);
36
         }
38
         }
37
         $k = ($y2 - $y1) / ($x2 - $x1); //y = kx + q
39
         $k = ($y2 - $y1) / ($x2 - $x1); //y = kx + q
38
         $a = $t / sqrt(1 + pow($k, 2));
40
         $a = $t / sqrt(1 + pow($k, 2));
41
+
39
         $Points = array(
42
         $Points = array(
40
-      round($x1 - (1 + $k) * $a), round($y1 + (1 - $k) * $a),
41
-      round($x1 - (1 - $k) * $a), round($y1 - (1 + $k) * $a),
42
-      round($x2 + (1 + $k) * $a), round($y2 - (1 - $k) * $a),
43
-      round($x2 + (1 - $k) * $a), round($y2 + (1 + $k) * $a),
44
-    );
43
+            round($x1 - (1 + $k) * $a), round($y1 + (1 - $k) * $a),
44
+            round($x1 - (1 - $k) * $a), round($y1 - (1 + $k) * $a),
45
+            round($x2 + (1 + $k) * $a), round($y2 - (1 - $k) * $a),
46
+            round($x2 + (1 - $k) * $a), round($y2 + (1 + $k) * $a),
47
+        );
48
+
45
         imagefilledpolygon($this->Image, $Points, 4, $Color);
49
         imagefilledpolygon($this->Image, $Points, 4, $Color);
46
         return imagepolygon($this->Image, $Points, 4, $Color);
50
         return imagepolygon($this->Image, $Points, 4, $Color);
47
     }
51
     }

+ 10
- 0
classes/irc.class.php View File

1
 <?php
1
 <?php
2
+
2
 class IRC_DB extends DB_MYSQL
3
 class IRC_DB extends DB_MYSQL
3
 {
4
 {
4
     public function halt($Msg)
5
     public function halt($Msg)
35
       if (isset($_SERVER['HOME']) && is_dir($_SERVER['HOME']) && getcwd() !== $_SERVER['HOME']) {
36
       if (isset($_SERVER['HOME']) && is_dir($_SERVER['HOME']) && getcwd() !== $_SERVER['HOME']) {
36
           chdir($_SERVER['HOME']);
37
           chdir($_SERVER['HOME']);
37
       }
38
       }
39
+
38
       ob_end_clean();
40
       ob_end_clean();
39
       restore_error_handler(); // Avoid PHP error logging
41
       restore_error_handler(); // Avoid PHP error logging
40
       set_time_limit(0);
42
       set_time_limit(0);
56
         } else {
58
         } else {
57
             $IrcAddress = 'tcp://' . BOT_SERVER . ':' . BOT_PORT;
59
             $IrcAddress = 'tcp://' . BOT_SERVER . ':' . BOT_PORT;
58
         }
60
         }
61
+
59
         while (!$this->Socket = stream_socket_client($IrcAddress, $ErrNr, $ErrStr)) {
62
         while (!$this->Socket = stream_socket_client($IrcAddress, $ErrNr, $ErrStr)) {
60
             sleep(15);
63
             sleep(15);
61
         }
64
         }
65
+
62
         stream_set_blocking($this->Socket, 0);
66
         stream_set_blocking($this->Socket, 0);
63
         $this->Connecting = false;
67
         $this->Connecting = false;
68
+
64
         if ($Reconnect) {
69
         if ($Reconnect) {
65
             $this->post_connect();
70
             $this->post_connect();
66
         }
71
         }
147
         // This is used to prevent messages from getting truncated
152
         // This is used to prevent messages from getting truncated
148
         $Text = wordwrap($Text, 460, "\n", true);
153
         $Text = wordwrap($Text, 460, "\n", true);
149
         $TextArray = explode("\n", $Text);
154
         $TextArray = explode("\n", $Text);
155
+
150
         foreach ($TextArray as $Text) {
156
         foreach ($TextArray as $Text) {
151
             $this->send_raw("PRIVMSG $Channel :$Text");
157
             $this->send_raw("PRIVMSG $Channel :$Text");
152
         }
158
         }
181
     {
187
     {
182
         G::$Cache->InternalCache = false;
188
         G::$Cache->InternalCache = false;
183
         stream_set_timeout($this->Socket, 10000000000);
189
         stream_set_timeout($this->Socket, 10000000000);
190
+
184
         while ($this->State === 1) {
191
         while ($this->State === 1) {
185
             $NullSock = null;
192
             $NullSock = null;
186
             $Sockets = array($this->Socket, $this->ListenSocket);
193
             $Sockets = array($this->Socket, $this->ListenSocket);
194
+
187
             if (stream_select($Sockets, $NullSock, $NullSock, null) === false) {
195
             if (stream_select($Sockets, $NullSock, $NullSock, null) === false) {
188
                 die();
196
                 die();
189
             }
197
             }
198
+
190
             foreach ($Sockets as $Socket) {
199
             foreach ($Sockets as $Socket) {
191
                 if ($Socket === $this->Socket) {
200
                 if ($Socket === $this->Socket) {
192
                     $this->irc_events();
201
                     $this->irc_events();
195
                     $this->listener_events();
204
                     $this->listener_events();
196
                 }
205
                 }
197
             }
206
             }
207
+            
198
             G::$DB->LinkID = false;
208
             G::$DB->LinkID = false;
199
             G::$DB->Queries = [];
209
             G::$DB->Queries = [];
200
         }
210
         }

+ 7
- 7
classes/lockedaccounts.class.php View File

1
-<?
1
+<?php
2
 
2
 
3
 /**
3
 /**
4
  * Class to manage locked accounts
4
  * Class to manage locked accounts
17
      */
17
      */
18
     public static function lock_account($UserID, $Type, $Message, $Reason, $LockedByUserID)
18
     public static function lock_account($UserID, $Type, $Message, $Reason, $LockedByUserID)
19
     {
19
     {
20
-
21
-        if ($LockedByUserID == 0) {
20
+        if ($LockedByUserID === 0) {
22
             $Username = "System";
21
             $Username = "System";
23
         } else {
22
         } else {
24
             G::$DB->query("SELECT Username FROM users_main WHERE ID = '" . $LockedByUserID . "'");
23
             G::$DB->query("SELECT Username FROM users_main WHERE ID = '" . $LockedByUserID . "'");
26
         }
25
         }
27
 
26
 
28
         G::$DB->query("
27
         G::$DB->query("
29
-                INSERT INTO locked_accounts (UserID, Type)
30
-                VALUES ('" . $UserID . "', " . $Type . ")");
28
+        INSERT INTO locked_accounts (UserID, Type)
29
+          VALUES ('" . $UserID . "', " . $Type . ")");
30
+          
31
         Tools::update_user_notes($UserID, sqltime() . " - " . db_string($Message) . " by $Username\nReason: " . db_string($Reason) . "\n\n");
31
         Tools::update_user_notes($UserID, sqltime() . " - " . db_string($Message) . " by $Username\nReason: " . db_string($Reason) . "\n\n");
32
         G::$Cache->delete_value('user_info_' . $UserID);
32
         G::$Cache->delete_value('user_info_' . $UserID);
33
     }
33
     }
43
      */
43
      */
44
     public static function unlock_account($UserID, $Type, $Message, $Reason, $UnlockedByUserID)
44
     public static function unlock_account($UserID, $Type, $Message, $Reason, $UnlockedByUserID)
45
     {
45
     {
46
-        if ($UnlockedByUserID == 0) {
46
+        if ($UnlockedByUserID === 0) {
47
             $Username = "System";
47
             $Username = "System";
48
         } else {
48
         } else {
49
             G::$DB->query("SELECT Username FROM users_main WHERE ID = '" . $UnlockedByUserID . "'");
49
             G::$DB->query("SELECT Username FROM users_main WHERE ID = '" . $UnlockedByUserID . "'");
52
 
52
 
53
         G::$DB->query("DELETE FROM locked_accounts WHERE UserID = '$UserID' AND Type = '". $Type ."'");
53
         G::$DB->query("DELETE FROM locked_accounts WHERE UserID = '$UserID' AND Type = '". $Type ."'");
54
 
54
 
55
-        if (G::$DB->affected_rows() == 1) {
55
+        if (G::$DB->affected_rows() === 1) {
56
             G::$Cache->delete_value("user_info_" . $UserID);
56
             G::$Cache->delete_value("user_info_" . $UserID);
57
             Tools::update_user_notes($UserID, sqltime() . " - " . db_string($Message) . " by $Username\nReason: " . db_string($Reason) . "\n\n");
57
             Tools::update_user_notes($UserID, sqltime() . " - " . db_string($Message) . " by $Username\nReason: " . db_string($Reason) . "\n\n");
58
         }
58
         }

+ 45
- 40
classes/mass_user_torrents_editor.class.php View File

13
  *
13
  *
14
  * It could also be used for other types like collages.
14
  * It could also be used for other types like collages.
15
  */
15
  */
16
-abstract class MASS_USER_TORRENTS_EDITOR {
17
-  /**
18
-   * The affected DB table
19
-   * @var string $Table
20
-   */
21
-  protected $Table;
16
+abstract class MASS_USER_TORRENTS_EDITOR
17
+{
18
+    /**
19
+     * The affected DB table
20
+     * @var string $Table
21
+     */
22
+    protected $Table;
22
 
23
 
23
-  /**
24
-   * Set the Table
25
-   * @param string $Table
26
-   */
27
-  final public function set_table($Table) {
28
-    $this->Table = db_string($Table);
29
-  }
24
+    /**
25
+     * Set the Table
26
+     * @param string $Table
27
+     */
28
+    final public function set_table($Table)
29
+    {
30
+        $this->Table = db_string($Table);
31
+    }
30
 
32
 
31
-  /**
32
-   * Get the Table
33
-   * @return string $Table
34
-   */
35
-  final public function get_table() {
36
-    return $this->Table;
37
-  }
33
+    /**
34
+     * Get the Table
35
+     * @return string $Table
36
+     */
37
+    final public function get_table()
38
+    {
39
+        return $this->Table;
40
+    }
38
 
41
 
39
-  /**
40
-   * The extending class must provide a method to send a query and clear the cache
41
-   */
42
-  abstract protected function query_and_clear_cache($sql);
42
+    /**
43
+     * The extending class must provide a method to send a query and clear the cache
44
+     */
45
+    abstract protected function query_and_clear_cache($sql);
43
 
46
 
44
-  /**
45
-   * A method to insert many rows into a single table
46
-   * Not required in subsequent classes
47
-   */
48
-  public function mass_add() {}
47
+    /**
48
+     * A method to insert many rows into a single table
49
+     * Not required in subsequent classes
50
+     */
51
+    public function mass_add()
52
+    {
53
+    }
49
 
54
 
50
-  /**
51
-   * A method to remove many rows from a table
52
-   * The extending class must have a mass_remove method
53
-   */
54
-  abstract public function mass_remove();
55
+    /**
56
+     * A method to remove many rows from a table
57
+     * The extending class must have a mass_remove method
58
+     */
59
+    abstract public function mass_remove();
55
 
60
 
56
-  /**
57
-   * A method to update many rows in a table
58
-   * The extending class must have a mass_update method
59
-   */
60
-  abstract public function mass_update();
61
-}
61
+    /**
62
+     * A method to update many rows in a table
63
+     * The extending class must have a mass_update method
64
+     */
65
+    abstract public function mass_update();
66
+}

+ 3
- 0
classes/sphinxqlresult.class.php View File

57
         while ($Row = $this->fetch_array()) {
57
         while ($Row = $this->fetch_array()) {
58
             $Return[] = $Row[$Key];
58
             $Return[] = $Row[$Key];
59
         }
59
         }
60
+
60
         $this->data_seek(0);
61
         $this->data_seek(0);
61
         return $Return;
62
         return $Return;
62
     }
63
     }
78
                 $Return[] = $Row;
79
                 $Return[] = $Row;
79
             }
80
             }
80
         }
81
         }
82
+
81
         $this->data_seek(0);
83
         $this->data_seek(0);
82
         return $Return;
84
         return $Return;
83
     }
85
     }
95
         while ($Row = $this->fetch_array()) {
97
         while ($Row = $this->fetch_array()) {
96
             $Return[$Row[$Key1]] = $Row[$Key2];
98
             $Return[$Row[$Key1]] = $Row[$Key2];
97
         }
99
         }
100
+        
98
         $this->data_seek(0);
101
         $this->data_seek(0);
99
         return $Return;
102
         return $Return;
100
     }
103
     }

+ 282
- 262
classes/subscriptions.class.php View File

1
-<?
2
-class Subscriptions {
3
-  /**
4
-   * Parse a post/comment body for quotes and notify all quoted users that have quote notifications enabled.
5
-   * @param string $Body
6
-   * @param int $PostID
7
-   * @param string $Page
8
-   * @param int $PageID
9
-   */
10
-  public static function quote_notify($Body, $PostID, $Page, $PageID) {
11
-    $QueryID = G::$DB->get_query_id();
12
-    /*
13
-     * Explanation of the parameters PageID and Page: Page contains where
14
-     * this quote comes from and can be forums, artist, collages, requests
15
-     * or torrents. The PageID contains the additional value that is
16
-     * necessary for the users_notify_quoted table. The PageIDs for the
17
-     * different Page are: forums: TopicID artist: ArtistID collages:
18
-     * CollageID requests: RequestID torrents: GroupID
1
+<?php
2
+
3
+class Subscriptions
4
+{
5
+    /**
6
+     * Parse a post/comment body for quotes and notify all quoted users that have quote notifications enabled.
7
+     * @param string $Body
8
+     * @param int $PostID
9
+     * @param string $Page
10
+     * @param int $PageID
19
      */
11
      */
20
-    $Matches = [];
21
-    preg_match_all('/\[quote(?:=(.*)(?:\|.*)?)?]|\[\/quote]/iU', $Body, $Matches, PREG_SET_ORDER);
12
+    public static function quote_notify($Body, $PostID, $Page, $PageID)
13
+    {
14
+        $QueryID = G::$DB->get_query_id();
15
+        /*
16
+         * Explanation of the parameters PageID and Page: Page contains where
17
+         * this quote comes from and can be forums, artist, collages, requests
18
+         * or torrents. The PageID contains the additional value that is
19
+         * necessary for the users_notify_quoted table. The PageIDs for the
20
+         * different Page are: forums: TopicID artist: ArtistID collages:
21
+         * CollageID requests: RequestID torrents: GroupID
22
+         */
23
+        $Matches = [];
24
+        preg_match_all('/\[quote(?:=(.*)(?:\|.*)?)?]|\[\/quote]/iU', $Body, $Matches, PREG_SET_ORDER);
22
 
25
 
23
-    if (count($Matches)) {
24
-      $Usernames = [];
25
-      $Level = 0;
26
-      foreach ($Matches as $M) {
27
-        if ($M[0] != '[/quote]') {
28
-          if ($Level == 0 && isset($M[1]) && strlen($M[1]) > 0 && preg_match(USERNAME_REGEX, $M[1])) {
29
-            $Usernames[] = preg_replace('/(^[.,]*)|([.,]*$)/', '', $M[1]); // wut?
30
-          }
31
-          ++$Level;
32
-        } else {
33
-          --$Level;
26
+        if (count($Matches)) {
27
+            $Usernames = [];
28
+            $Level = 0;
29
+            foreach ($Matches as $M) {
30
+                if ($M[0] != '[/quote]') {
31
+                    if ($Level == 0 && isset($M[1]) && strlen($M[1]) > 0 && preg_match(USERNAME_REGEX, $M[1])) {
32
+                        $Usernames[] = preg_replace('/(^[.,]*)|([.,]*$)/', '', $M[1]); // wut?
33
+                    }
34
+                    ++$Level;
35
+                } else {
36
+                    --$Level;
37
+                }
38
+            }
34
         }
39
         }
35
-      }
36
-    }
37
-    // remove any dupes in the array (the fast way)
38
-    $Usernames = array_flip(array_flip($Usernames));
40
+        // remove any dupes in the array (the fast way)
41
+        $Usernames = array_flip(array_flip($Usernames));
39
 
42
 
40
-    G::$DB->query("
43
+        G::$DB->query("
41
       SELECT m.ID
44
       SELECT m.ID
42
       FROM users_main AS m
45
       FROM users_main AS m
43
         LEFT JOIN users_info AS i ON i.UserID = m.ID
46
         LEFT JOIN users_info AS i ON i.UserID = m.ID
45
         AND i.NotifyOnQuote = '1'
48
         AND i.NotifyOnQuote = '1'
46
         AND i.UserID != " . G::$LoggedUser['ID']);
49
         AND i.UserID != " . G::$LoggedUser['ID']);
47
 
50
 
48
-    $Results = G::$DB->to_array();
49
-    foreach ($Results as $Result) {
50
-      $UserID = db_string($Result['ID']);
51
-      $QuoterID = db_string(G::$LoggedUser['ID']);
52
-      $Page = db_string($Page);
53
-      $PageID = db_string($PageID);
54
-      $PostID = db_string($PostID);
51
+        $Results = G::$DB->to_array();
52
+        foreach ($Results as $Result) {
53
+            $UserID = db_string($Result['ID']);
54
+            $QuoterID = db_string(G::$LoggedUser['ID']);
55
+            $Page = db_string($Page);
56
+            $PageID = db_string($PageID);
57
+            $PostID = db_string($PostID);
55
 
58
 
56
-      G::$DB->query("
59
+            G::$DB->query(
60
+          "
57
         INSERT IGNORE INTO users_notify_quoted
61
         INSERT IGNORE INTO users_notify_quoted
58
           (UserID, QuoterID, Page, PageID, PostID, Date)
62
           (UserID, QuoterID, Page, PageID, PostID, Date)
59
         VALUES
63
         VALUES
60
           (    ?,               ?,               ?,      ?,       ?,   NOW())",
64
           (    ?,               ?,               ?,      ?,       ?,   NOW())",
61
-          $Result['ID'], G::$LoggedUser['ID'], $Page, $PageID, $PostID);
62
-      G::$Cache->delete_value("notify_quoted_$UserID");
63
-      if ($Page == 'forums') {
64
-        $URL = site_url() . "forums.php?action=viewthread&postid=$PostID";
65
-      } else {
66
-        $URL = site_url() . "comments.php?action=jump&postid=$PostID";
67
-      }
65
+          $Result['ID'],
66
+          G::$LoggedUser['ID'],
67
+          $Page,
68
+          $PageID,
69
+          $PostID
70
+      );
71
+            G::$Cache->delete_value("notify_quoted_$UserID");
72
+            if ($Page == 'forums') {
73
+                $URL = site_url() . "forums.php?action=viewthread&postid=$PostID";
74
+            } else {
75
+                $URL = site_url() . "comments.php?action=jump&postid=$PostID";
76
+            }
77
+        }
78
+        G::$DB->set_query_id($QueryID);
68
     }
79
     }
69
-    G::$DB->set_query_id($QueryID);
70
-  }
71
 
80
 
72
-  /**
73
-   * (Un)subscribe from a forum thread.
74
-   * If UserID == 0, G::$LoggedUser[ID] is used
75
-   * @param int $TopicID
76
-   * @param int $UserID
77
-   */
78
-  public static function subscribe($TopicID, $UserID = 0) {
79
-    if ($UserID == 0) {
80
-      $UserID = G::$LoggedUser['ID'];
81
-    }
82
-    $QueryID = G::$DB->get_query_id();
83
-    $UserSubscriptions = self::get_subscriptions();
84
-    $Key = self::has_subscribed($TopicID);
85
-    if ($Key !== false) {
86
-      G::$DB->query('
81
+    /**
82
+     * (Un)subscribe from a forum thread.
83
+     * If UserID == 0, G::$LoggedUser[ID] is used
84
+     * @param int $TopicID
85
+     * @param int $UserID
86
+     */
87
+    public static function subscribe($TopicID, $UserID = 0)
88
+    {
89
+        if ($UserID == 0) {
90
+            $UserID = G::$LoggedUser['ID'];
91
+        }
92
+        $QueryID = G::$DB->get_query_id();
93
+        $UserSubscriptions = self::get_subscriptions();
94
+        $Key = self::has_subscribed($TopicID);
95
+        if ($Key !== false) {
96
+            G::$DB->query('
87
         DELETE FROM users_subscriptions
97
         DELETE FROM users_subscriptions
88
         WHERE UserID = ' . db_string($UserID) . '
98
         WHERE UserID = ' . db_string($UserID) . '
89
           AND TopicID = ' . db_string($TopicID));
99
           AND TopicID = ' . db_string($TopicID));
90
-      unset($UserSubscriptions[$Key]);
91
-    } else {
92
-      G::$DB->query("
100
+            unset($UserSubscriptions[$Key]);
101
+        } else {
102
+            G::$DB->query("
93
         INSERT IGNORE INTO users_subscriptions (UserID, TopicID)
103
         INSERT IGNORE INTO users_subscriptions (UserID, TopicID)
94
         VALUES ($UserID, " . db_string($TopicID) . ")");
104
         VALUES ($UserID, " . db_string($TopicID) . ")");
95
-      array_push($UserSubscriptions, $TopicID);
105
+            array_push($UserSubscriptions, $TopicID);
106
+        }
107
+        G::$Cache->replace_value("subscriptions_user_$UserID", $UserSubscriptions, 0);
108
+        G::$Cache->delete_value("subscriptions_user_new_$UserID");
109
+        G::$DB->set_query_id($QueryID);
96
     }
110
     }
97
-    G::$Cache->replace_value("subscriptions_user_$UserID", $UserSubscriptions, 0);
98
-    G::$Cache->delete_value("subscriptions_user_new_$UserID");
99
-    G::$DB->set_query_id($QueryID);
100
-  }
101
 
111
 
102
-  /**
103
-   * (Un)subscribe from comments.
104
-   * If UserID == 0, G::$LoggedUser[ID] is used
105
-   * @param string $Page 'artist', 'collages', 'requests' or 'torrents'
106
-   * @param int $PageID ArtistID, CollageID, RequestID or GroupID
107
-   * @param int $UserID
108
-   */
109
-  public static function subscribe_comments($Page, $PageID, $UserID = 0) {
110
-    if ($UserID == 0) {
111
-      $UserID = G::$LoggedUser['ID'];
112
-    }
113
-    $QueryID = G::$DB->get_query_id();
114
-    $UserCommentSubscriptions = self::get_comment_subscriptions();
115
-    $Key = self::has_subscribed_comments($Page, $PageID);
116
-    if ($Key !== false) {
117
-      G::$DB->query("
112
+    /**
113
+     * (Un)subscribe from comments.
114
+     * If UserID == 0, G::$LoggedUser[ID] is used
115
+     * @param string $Page 'artist', 'collages', 'requests' or 'torrents'
116
+     * @param int $PageID ArtistID, CollageID, RequestID or GroupID
117
+     * @param int $UserID
118
+     */
119
+    public static function subscribe_comments($Page, $PageID, $UserID = 0)
120
+    {
121
+        if ($UserID == 0) {
122
+            $UserID = G::$LoggedUser['ID'];
123
+        }
124
+        $QueryID = G::$DB->get_query_id();
125
+        $UserCommentSubscriptions = self::get_comment_subscriptions();
126
+        $Key = self::has_subscribed_comments($Page, $PageID);
127
+        if ($Key !== false) {
128
+            G::$DB->query("
118
         DELETE FROM users_subscriptions_comments
129
         DELETE FROM users_subscriptions_comments
119
         WHERE UserID = " . db_string($UserID) . "
130
         WHERE UserID = " . db_string($UserID) . "
120
           AND Page = '" . db_string($Page) . "'
131
           AND Page = '" . db_string($Page) . "'
121
           AND PageID = " . db_string($PageID));
132
           AND PageID = " . db_string($PageID));
122
-      unset($UserCommentSubscriptions[$Key]);
123
-    } else {
124
-      G::$DB->query("
133
+            unset($UserCommentSubscriptions[$Key]);
134
+        } else {
135
+            G::$DB->query("
125
         INSERT IGNORE INTO users_subscriptions_comments
136
         INSERT IGNORE INTO users_subscriptions_comments
126
           (UserID, Page, PageID)
137
           (UserID, Page, PageID)
127
         VALUES
138
         VALUES
128
           ($UserID, '" . db_string($Page) . "', " . db_string($PageID) . ")");
139
           ($UserID, '" . db_string($Page) . "', " . db_string($PageID) . ")");
129
-      array_push($UserCommentSubscriptions, array($Page, $PageID));
140
+            array_push($UserCommentSubscriptions, array($Page, $PageID));
141
+        }
142
+        G::$Cache->replace_value("subscriptions_comments_user_$UserID", $UserCommentSubscriptions, 0);
143
+        G::$Cache->delete_value("subscriptions_comments_user_new_$UserID");
144
+        G::$DB->set_query_id($QueryID);
130
     }
145
     }
131
-    G::$Cache->replace_value("subscriptions_comments_user_$UserID", $UserCommentSubscriptions, 0);
132
-    G::$Cache->delete_value("subscriptions_comments_user_new_$UserID");
133
-    G::$DB->set_query_id($QueryID);
134
-  }
135
 
146
 
136
-  /**
137
-   * Read $UserID's subscriptions. If the cache key isn't set, it gets filled.
138
-   * If UserID == 0, G::$LoggedUser[ID] is used
139
-   * @param int $UserID
140
-   * @return array Array of TopicIDs
141
-   */
142
-  public static function get_subscriptions($UserID = 0) {
143
-    if ($UserID == 0) {
144
-      $UserID = G::$LoggedUser['ID'];
145
-    }
146
-    $QueryID = G::$DB->get_query_id();
147
-    $UserSubscriptions = G::$Cache->get_value("subscriptions_user_$UserID");
148
-    if ($UserSubscriptions === false) {
149
-      G::$DB->query('
147
+    /**
148
+     * Read $UserID's subscriptions. If the cache key isn't set, it gets filled.
149
+     * If UserID == 0, G::$LoggedUser[ID] is used
150
+     * @param int $UserID
151
+     * @return array Array of TopicIDs
152
+     */
153
+    public static function get_subscriptions($UserID = 0)
154
+    {
155
+        if ($UserID == 0) {
156
+            $UserID = G::$LoggedUser['ID'];
157
+        }
158
+        $QueryID = G::$DB->get_query_id();
159
+        $UserSubscriptions = G::$Cache->get_value("subscriptions_user_$UserID");
160
+        if ($UserSubscriptions === false) {
161
+            G::$DB->query('
150
         SELECT TopicID
162
         SELECT TopicID
151
         FROM users_subscriptions
163
         FROM users_subscriptions
152
         WHERE UserID = ' . db_string($UserID));
164
         WHERE UserID = ' . db_string($UserID));
153
-      $UserSubscriptions = G::$DB->collect(0);
154
-      G::$Cache->cache_value("subscriptions_user_$UserID", $UserSubscriptions, 0);
165
+            $UserSubscriptions = G::$DB->collect(0);
166
+            G::$Cache->cache_value("subscriptions_user_$UserID", $UserSubscriptions, 0);
167
+        }
168
+        G::$DB->set_query_id($QueryID);
169
+        return $UserSubscriptions;
155
     }
170
     }
156
-    G::$DB->set_query_id($QueryID);
157
-    return $UserSubscriptions;
158
-  }
159
 
171
 
160
-  /**
161
-   * Same as self::get_subscriptions, but for comment subscriptions
162
-   * @param int $UserID
163
-   * @return array Array of ($Page, $PageID)
164
-   */
165
-  public static function get_comment_subscriptions($UserID = 0) {
166
-    if ($UserID == 0) {
167
-      $UserID = G::$LoggedUser['ID'];
168
-    }
169
-    $QueryID = G::$DB->get_query_id();
170
-    $UserCommentSubscriptions = G::$Cache->get_value("subscriptions_comments_user_$UserID");
171
-    if ($UserCommentSubscriptions === false) {
172
-      G::$DB->query('
172
+    /**
173
+     * Same as self::get_subscriptions, but for comment subscriptions
174
+     * @param int $UserID
175
+     * @return array Array of ($Page, $PageID)
176
+     */
177
+    public static function get_comment_subscriptions($UserID = 0)
178
+    {
179
+        if ($UserID == 0) {
180
+            $UserID = G::$LoggedUser['ID'];
181
+        }
182
+        $QueryID = G::$DB->get_query_id();
183
+        $UserCommentSubscriptions = G::$Cache->get_value("subscriptions_comments_user_$UserID");
184
+        if ($UserCommentSubscriptions === false) {
185
+            G::$DB->query('
173
         SELECT Page, PageID
186
         SELECT Page, PageID
174
         FROM users_subscriptions_comments
187
         FROM users_subscriptions_comments
175
         WHERE UserID = ' . db_string($UserID));
188
         WHERE UserID = ' . db_string($UserID));
176
-      $UserCommentSubscriptions = G::$DB->to_array(false, MYSQLI_NUM);
177
-      G::$Cache->cache_value("subscriptions_comments_user_$UserID", $UserCommentSubscriptions, 0);
189
+            $UserCommentSubscriptions = G::$DB->to_array(false, MYSQLI_NUM);
190
+            G::$Cache->cache_value("subscriptions_comments_user_$UserID", $UserCommentSubscriptions, 0);
191
+        }
192
+        G::$DB->set_query_id($QueryID);
193
+        return $UserCommentSubscriptions;
178
     }
194
     }
179
-    G::$DB->set_query_id($QueryID);
180
-    return $UserCommentSubscriptions;
181
-  }
182
 
195
 
183
-  /**
184
-   * Returns whether or not the current user has new subscriptions. This handles both forum and comment subscriptions.
185
-   * @return int Number of unread subscribed threads/comments
186
-   */
187
-  public static function has_new_subscriptions() {
188
-    $QueryID = G::$DB->get_query_id();
196
+    /**
197
+     * Returns whether or not the current user has new subscriptions. This handles both forum and comment subscriptions.
198
+     * @return int Number of unread subscribed threads/comments
199
+     */
200
+    public static function has_new_subscriptions()
201
+    {
202
+        $QueryID = G::$DB->get_query_id();
189
 
203
 
190
-    $NewSubscriptions = G::$Cache->get_value('subscriptions_user_new_' . G::$LoggedUser['ID']);
191
-    if ($NewSubscriptions === false) {
192
-      // forum subscriptions
193
-      G::$DB->query("
204
+        $NewSubscriptions = G::$Cache->get_value('subscriptions_user_new_' . G::$LoggedUser['ID']);
205
+        if ($NewSubscriptions === false) {
206
+            // forum subscriptions
207
+            G::$DB->query("
194
           SELECT COUNT(1)
208
           SELECT COUNT(1)
195
           FROM users_subscriptions AS s
209
           FROM users_subscriptions AS s
196
             LEFT JOIN forums_last_read_topics AS l ON l.UserID = s.UserID AND l.TopicID = s.TopicID
210
             LEFT JOIN forums_last_read_topics AS l ON l.UserID = s.UserID AND l.TopicID = s.TopicID
199
           WHERE " . Forums::user_forums_sql() . "
213
           WHERE " . Forums::user_forums_sql() . "
200
             AND IF(t.IsLocked = '1' AND t.IsSticky = '0'" . ", t.LastPostID, IF(l.PostID IS NULL, 0, l.PostID)) < t.LastPostID
214
             AND IF(t.IsLocked = '1' AND t.IsSticky = '0'" . ", t.LastPostID, IF(l.PostID IS NULL, 0, l.PostID)) < t.LastPostID
201
             AND s.UserID = " . G::$LoggedUser['ID']);
215
             AND s.UserID = " . G::$LoggedUser['ID']);
202
-      list($NewForumSubscriptions) = G::$DB->next_record();
216
+            list($NewForumSubscriptions) = G::$DB->next_record();
203
 
217
 
204
-      // comment subscriptions
205
-      G::$DB->query("
218
+            // comment subscriptions
219
+            G::$DB->query("
206
           SELECT COUNT(1)
220
           SELECT COUNT(1)
207
           FROM users_subscriptions_comments AS s
221
           FROM users_subscriptions_comments AS s
208
             LEFT JOIN users_comments_last_read AS lr ON lr.UserID = s.UserID AND lr.Page = s.Page AND lr.PageID = s.PageID
222
             LEFT JOIN users_comments_last_read AS lr ON lr.UserID = s.UserID AND lr.Page = s.Page AND lr.PageID = s.PageID
211
           WHERE s.UserID = " . G::$LoggedUser['ID'] . "
225
           WHERE s.UserID = " . G::$LoggedUser['ID'] . "
212
             AND (s.Page != 'collages' OR co.Deleted = '0')
226
             AND (s.Page != 'collages' OR co.Deleted = '0')
213
             AND IF(lr.PostID IS NULL, 0, lr.PostID) < c.ID");
227
             AND IF(lr.PostID IS NULL, 0, lr.PostID) < c.ID");
214
-      list($NewCommentSubscriptions) = G::$DB->next_record();
228
+            list($NewCommentSubscriptions) = G::$DB->next_record();
215
 
229
 
216
-      $NewSubscriptions = $NewForumSubscriptions + $NewCommentSubscriptions;
217
-      G::$Cache->cache_value('subscriptions_user_new_' . G::$LoggedUser['ID'], $NewSubscriptions, 0);
230
+            $NewSubscriptions = $NewForumSubscriptions + $NewCommentSubscriptions;
231
+            G::$Cache->cache_value('subscriptions_user_new_' . G::$LoggedUser['ID'], $NewSubscriptions, 0);
232
+        }
233
+        G::$DB->set_query_id($QueryID);
234
+        return (int)$NewSubscriptions;
218
     }
235
     }
219
-    G::$DB->set_query_id($QueryID);
220
-    return (int)$NewSubscriptions;
221
-  }
222
 
236
 
223
-  /**
224
-   * Returns whether or not the current user has new quote notifications.
225
-   * @return int Number of unread quote notifications
226
-   */
227
-  public static function has_new_quote_notifications() {
228
-    $QuoteNotificationsCount = G::$Cache->get_value('notify_quoted_' . G::$LoggedUser['ID']);
229
-    if ($QuoteNotificationsCount === false) {
230
-      $sql = "
237
+    /**
238
+     * Returns whether or not the current user has new quote notifications.
239
+     * @return int Number of unread quote notifications
240
+     */
241
+    public static function has_new_quote_notifications()
242
+    {
243
+        $QuoteNotificationsCount = G::$Cache->get_value('notify_quoted_' . G::$LoggedUser['ID']);
244
+        if ($QuoteNotificationsCount === false) {
245
+            $sql = "
231
         SELECT COUNT(1)
246
         SELECT COUNT(1)
232
         FROM users_notify_quoted AS q
247
         FROM users_notify_quoted AS q
233
           LEFT JOIN forums_topics AS t ON t.ID = q.PageID
248
           LEFT JOIN forums_topics AS t ON t.ID = q.PageID
237
           AND q.UnRead
252
           AND q.UnRead
238
           AND (q.Page != 'forums' OR " . Forums::user_forums_sql() . ")
253
           AND (q.Page != 'forums' OR " . Forums::user_forums_sql() . ")
239
           AND (q.Page != 'collages' OR c.Deleted = '0')";
254
           AND (q.Page != 'collages' OR c.Deleted = '0')";
240
-      $QueryID = G::$DB->get_query_id();
241
-      G::$DB->query($sql);
242
-      list($QuoteNotificationsCount) = G::$DB->next_record();
243
-      G::$DB->set_query_id($QueryID);
244
-      G::$Cache->cache_value('notify_quoted_' . G::$LoggedUser['ID'], $QuoteNotificationsCount, 0);
255
+            $QueryID = G::$DB->get_query_id();
256
+            G::$DB->query($sql);
257
+            list($QuoteNotificationsCount) = G::$DB->next_record();
258
+            G::$DB->set_query_id($QueryID);
259
+            G::$Cache->cache_value('notify_quoted_' . G::$LoggedUser['ID'], $QuoteNotificationsCount, 0);
260
+        }
261
+        return (int)$QuoteNotificationsCount;
245
     }
262
     }
246
-    return (int)$QuoteNotificationsCount;
247
-  }
248
 
263
 
249
-  /**
250
-   * Returns the key which holds this $TopicID in the subscription array.
251
-   * Use type-aware comparison operators with this! (ie. if (self::has_subscribed($TopicID) !== false) { ... })
252
-   * @param int $TopicID
253
-   * @return bool|int
254
-   */
255
-  public static function has_subscribed($TopicID) {
256
-    $UserSubscriptions = self::get_subscriptions();
257
-    return array_search($TopicID, $UserSubscriptions);
258
-  }
264
+    /**
265
+     * Returns the key which holds this $TopicID in the subscription array.
266
+     * Use type-aware comparison operators with this! (ie. if (self::has_subscribed($TopicID) !== false) { ... })
267
+     * @param int $TopicID
268
+     * @return bool|int
269
+     */
270
+    public static function has_subscribed($TopicID)
271
+    {
272
+        $UserSubscriptions = self::get_subscriptions();
273
+        return array_search($TopicID, $UserSubscriptions);
274
+    }
259
 
275
 
260
-  /**
261
-   * Same as has_subscribed, but for comment subscriptions.
262
-   * @param string $Page 'artist', 'collages', 'requests' or 'torrents'
263
-   * @param int $PageID
264
-   * @return bool|int
265
-   */
266
-  public static function has_subscribed_comments($Page, $PageID) {
267
-    $UserCommentSubscriptions = self::get_comment_subscriptions();
268
-    return array_search(array($Page, $PageID), $UserCommentSubscriptions);
269
-  }
276
+    /**
277
+     * Same as has_subscribed, but for comment subscriptions.
278
+     * @param string $Page 'artist', 'collages', 'requests' or 'torrents'
279
+     * @param int $PageID
280
+     * @return bool|int
281
+     */
282
+    public static function has_subscribed_comments($Page, $PageID)
283
+    {
284
+        $UserCommentSubscriptions = self::get_comment_subscriptions();
285
+        return array_search(array($Page, $PageID), $UserCommentSubscriptions);
286
+    }
270
 
287
 
271
-  /**
272
-   * Clear the subscription cache for all subscribers of a forum thread or artist/collage/request/torrent comments.
273
-   * @param type $Page 'forums', 'artist', 'collages', 'requests' or 'torrents'
274
-   * @param type $PageID TopicID, ArtistID, CollageID, RequestID or GroupID, respectively
275
-   */
276
-  public static function flush_subscriptions($Page, $PageID) {
277
-    $QueryID = G::$DB->get_query_id();
278
-    if ($Page == 'forums') {
279
-      G::$DB->query("
288
+    /**
289
+     * Clear the subscription cache for all subscribers of a forum thread or artist/collage/request/torrent comments.
290
+     * @param type $Page 'forums', 'artist', 'collages', 'requests' or 'torrents'
291
+     * @param type $PageID TopicID, ArtistID, CollageID, RequestID or GroupID, respectively
292
+     */
293
+    public static function flush_subscriptions($Page, $PageID)
294
+    {
295
+        $QueryID = G::$DB->get_query_id();
296
+        if ($Page == 'forums') {
297
+            G::$DB->query("
280
         SELECT UserID
298
         SELECT UserID
281
         FROM users_subscriptions
299
         FROM users_subscriptions
282
         WHERE TopicID = '$PageID'");
300
         WHERE TopicID = '$PageID'");
283
-    } else {
284
-      G::$DB->query("
301
+        } else {
302
+            G::$DB->query("
285
         SELECT UserID
303
         SELECT UserID
286
         FROM users_subscriptions_comments
304
         FROM users_subscriptions_comments
287
         WHERE Page = '$Page'
305
         WHERE Page = '$Page'
288
           AND PageID = '$PageID'");
306
           AND PageID = '$PageID'");
307
+        }
308
+        $Subscribers = G::$DB->collect('UserID');
309
+        foreach ($Subscribers as $Subscriber) {
310
+            G::$Cache->delete_value("subscriptions_user_new_$Subscriber");
311
+        }
312
+        G::$DB->set_query_id($QueryID);
289
     }
313
     }
290
-    $Subscribers = G::$DB->collect('UserID');
291
-    foreach ($Subscribers as $Subscriber) {
292
-      G::$Cache->delete_value("subscriptions_user_new_$Subscriber");
293
-    }
294
-    G::$DB->set_query_id($QueryID);
295
-  }
296
 
314
 
297
-  /**
298
-   * Move all $Page subscriptions from $OldPageID to $NewPageID (for example when merging torrent groups).
299
-   * Passing $NewPageID = null will delete the subscriptions.
300
-   * @param string $Page 'forums', 'artist', 'collages', 'requests' or 'torrents'
301
-   * @param int $OldPageID TopicID, ArtistID, CollageID, RequestID or GroupID, respectively
302
-   * @param int|null $NewPageID As $OldPageID, or null to delete the subscriptions
303
-   */
304
-  public static function move_subscriptions($Page, $OldPageID, $NewPageID) {
305
-    self::flush_subscriptions($Page, $OldPageID);
306
-    $QueryID = G::$DB->get_query_id();
307
-    if ($Page == 'forums') {
308
-      if ($NewPageID !== null) {
309
-        G::$DB->query("
315
+    /**
316
+     * Move all $Page subscriptions from $OldPageID to $NewPageID (for example when merging torrent groups).
317
+     * Passing $NewPageID = null will delete the subscriptions.
318
+     * @param string $Page 'forums', 'artist', 'collages', 'requests' or 'torrents'
319
+     * @param int $OldPageID TopicID, ArtistID, CollageID, RequestID or GroupID, respectively
320
+     * @param int|null $NewPageID As $OldPageID, or null to delete the subscriptions
321
+     */
322
+    public static function move_subscriptions($Page, $OldPageID, $NewPageID)
323
+    {
324
+        self::flush_subscriptions($Page, $OldPageID);
325
+        $QueryID = G::$DB->get_query_id();
326
+        if ($Page == 'forums') {
327
+            if ($NewPageID !== null) {
328
+                G::$DB->query("
310
           UPDATE IGNORE users_subscriptions
329
           UPDATE IGNORE users_subscriptions
311
           SET TopicID = '$NewPageID'
330
           SET TopicID = '$NewPageID'
312
           WHERE TopicID = '$OldPageID'");
331
           WHERE TopicID = '$OldPageID'");
313
-        // explanation see below
314
-        G::$DB->query("
332
+                // explanation see below
333
+                G::$DB->query("
315
           UPDATE IGNORE forums_last_read_topics
334
           UPDATE IGNORE forums_last_read_topics
316
           SET TopicID = $NewPageID
335
           SET TopicID = $NewPageID
317
           WHERE TopicID = $OldPageID");
336
           WHERE TopicID = $OldPageID");
318
-        G::$DB->query("
337
+                G::$DB->query("
319
           SELECT UserID, MIN(PostID)
338
           SELECT UserID, MIN(PostID)
320
           FROM forums_last_read_topics
339
           FROM forums_last_read_topics
321
           WHERE TopicID IN ($OldPageID, $NewPageID)
340
           WHERE TopicID IN ($OldPageID, $NewPageID)
322
           GROUP BY UserID
341
           GROUP BY UserID
323
           HAVING COUNT(1) = 2");
342
           HAVING COUNT(1) = 2");
324
-        $Results = G::$DB->to_array(false, MYSQLI_NUM);
325
-        foreach ($Results as $Result) {
326
-          G::$DB->query("
343
+                $Results = G::$DB->to_array(false, MYSQLI_NUM);
344
+                foreach ($Results as $Result) {
345
+                    G::$DB->query("
327
             UPDATE forums_last_read_topics
346
             UPDATE forums_last_read_topics
328
             SET PostID = $Result[1]
347
             SET PostID = $Result[1]
329
             WHERE TopicID = $NewPageID
348
             WHERE TopicID = $NewPageID
330
               AND UserID = $Result[0]");
349
               AND UserID = $Result[0]");
331
-        }
332
-      }
333
-      G::$DB->query("
350
+                }
351
+            }
352
+            G::$DB->query("
334
         DELETE FROM users_subscriptions
353
         DELETE FROM users_subscriptions
335
         WHERE TopicID = '$OldPageID'");
354
         WHERE TopicID = '$OldPageID'");
336
-      G::$DB->query("
355
+            G::$DB->query("
337
         DELETE FROM forums_last_read_topics
356
         DELETE FROM forums_last_read_topics
338
         WHERE TopicID = $OldPageID");
357
         WHERE TopicID = $OldPageID");
339
-    } else {
340
-      if ($NewPageID !== null) {
341
-        G::$DB->query("
358
+        } else {
359
+            if ($NewPageID !== null) {
360
+                G::$DB->query("
342
           UPDATE IGNORE users_subscriptions_comments
361
           UPDATE IGNORE users_subscriptions_comments
343
           SET PageID = '$NewPageID'
362
           SET PageID = '$NewPageID'
344
           WHERE Page = '$Page'
363
           WHERE Page = '$Page'
345
             AND PageID = '$OldPageID'");
364
             AND PageID = '$OldPageID'");
346
-        // last read handling
347
-        // 1) update all rows that have no key collisions (i.e. users that haven't previously read both pages or if there are only comments on one page)
348
-        G::$DB->query("
365
+                // last read handling
366
+                // 1) update all rows that have no key collisions (i.e. users that haven't previously read both pages or if there are only comments on one page)
367
+                G::$DB->query("
349
           UPDATE IGNORE users_comments_last_read
368
           UPDATE IGNORE users_comments_last_read
350
           SET PageID = '$NewPageID'
369
           SET PageID = '$NewPageID'
351
           WHERE Page = '$Page'
370
           WHERE Page = '$Page'
352
             AND PageID = $OldPageID");
371
             AND PageID = $OldPageID");
353
-        // 2) get all last read records with key collisions (i.e. there are records for one user for both PageIDs)
354
-        G::$DB->query("
372
+                // 2) get all last read records with key collisions (i.e. there are records for one user for both PageIDs)
373
+                G::$DB->query("
355
           SELECT UserID, MIN(PostID)
374
           SELECT UserID, MIN(PostID)
356
           FROM users_comments_last_read
375
           FROM users_comments_last_read
357
           WHERE Page = '$Page'
376
           WHERE Page = '$Page'
358
             AND PageID IN ($OldPageID, $NewPageID)
377
             AND PageID IN ($OldPageID, $NewPageID)
359
           GROUP BY UserID
378
           GROUP BY UserID
360
           HAVING COUNT(1) = 2");
379
           HAVING COUNT(1) = 2");
361
-        $Results = G::$DB->to_array(false, MYSQLI_NUM);
362
-        // 3) update rows for those people found in 2) to the earlier post
363
-        foreach ($Results as $Result) {
364
-          G::$DB->query("
380
+                $Results = G::$DB->to_array(false, MYSQLI_NUM);
381
+                // 3) update rows for those people found in 2) to the earlier post
382
+                foreach ($Results as $Result) {
383
+                    G::$DB->query("
365
             UPDATE users_comments_last_read
384
             UPDATE users_comments_last_read
366
             SET PostID = $Result[1]
385
             SET PostID = $Result[1]
367
             WHERE Page = '$Page'
386
             WHERE Page = '$Page'
368
               AND PageID = $NewPageID
387
               AND PageID = $NewPageID
369
               AND UserID = $Result[0]");
388
               AND UserID = $Result[0]");
370
-        }
371
-      }
372
-      G::$DB->query("
389
+                }
390
+            }
391
+            G::$DB->query("
373
         DELETE FROM users_subscriptions_comments
392
         DELETE FROM users_subscriptions_comments
374
         WHERE Page = '$Page'
393
         WHERE Page = '$Page'
375
           AND PageID = '$OldPageID'");
394
           AND PageID = '$OldPageID'");
376
-      G::$DB->query("
395
+            G::$DB->query("
377
         DELETE FROM users_comments_last_read
396
         DELETE FROM users_comments_last_read
378
         WHERE Page = '$Page'
397
         WHERE Page = '$Page'
379
           AND PageID = '$OldPageID'");
398
           AND PageID = '$OldPageID'");
399
+        }
400
+        G::$DB->set_query_id($QueryID);
380
     }
401
     }
381
-    G::$DB->set_query_id($QueryID);
382
-  }
383
 
402
 
384
-  /**
385
-   * Clear the quote notification cache for all subscribers of a forum thread or artist/collage/request/torrent comments.
386
-   * @param string $Page 'forums', 'artist', 'collages', 'requests' or 'torrents'
387
-   * @param int $PageID TopicID, ArtistID, CollageID, RequestID or GroupID, respectively
388
-   */
389
-  public static function flush_quote_notifications($Page, $PageID) {
390
-    $QueryID = G::$DB->get_query_id();
391
-    G::$DB->query("
403
+    /**
404
+     * Clear the quote notification cache for all subscribers of a forum thread or artist/collage/request/torrent comments.
405
+     * @param string $Page 'forums', 'artist', 'collages', 'requests' or 'torrents'
406
+     * @param int $PageID TopicID, ArtistID, CollageID, RequestID or GroupID, respectively
407
+     */
408
+    public static function flush_quote_notifications($Page, $PageID)
409
+    {
410
+        $QueryID = G::$DB->get_query_id();
411
+        G::$DB->query("
392
       SELECT UserID
412
       SELECT UserID
393
       FROM users_notify_quoted
413
       FROM users_notify_quoted
394
       WHERE Page = '$Page'
414
       WHERE Page = '$Page'
395
         AND PageID = $PageID");
415
         AND PageID = $PageID");
396
-    $Subscribers = G::$DB->collect('UserID');
397
-    foreach ($Subscribers as $Subscriber) {
398
-      G::$Cache->delete_value("notify_quoted_$Subscriber");
416
+        $Subscribers = G::$DB->collect('UserID');
417
+        foreach ($Subscribers as $Subscriber) {
418
+            G::$Cache->delete_value("notify_quoted_$Subscriber");
419
+        }
420
+        G::$DB->set_query_id($QueryID);
399
     }
421
     }
400
-    G::$DB->set_query_id($QueryID);
401
-  }
402
 }
422
 }

+ 20
- 18
classes/textarea_preview.class.php View File

43
         if (self::$Textareas === 0) {
43
         if (self::$Textareas === 0) {
44
             return;
44
             return;
45
         }
45
         }
46
+
46
         if (self::$Exectuted === false && $all) {
47
         if (self::$Exectuted === false && $all) {
47
             View::parse('generic/textarea/script.phtml');
48
             View::parse('generic/textarea/script.phtml');
48
         }
49
         }
70
             }
71
             }
71
             $script[] = sprintf('[%s]', $a);
72
             $script[] = sprintf('[%s]', $a);
72
         }
73
         }
74
+
73
         if (!empty($script)) {
75
         if (!empty($script)) {
74
             View::parse('generic/textarea/script_factory.phtml', array('script' => join(', ', $script)));
76
             View::parse('generic/textarea/script_factory.phtml', array('script' => join(', ', $script)));
75
         }
77
         }
155
      * It's important to have the right IDs as they make the JS function properly.
157
      * It's important to have the right IDs as they make the JS function properly.
156
      */
158
      */
157
     public function __construct(
159
     public function __construct(
158
-      $Name,
159
-      $ID = '',
160
-      $Value = '',
161
-      $Cols = 50,
162
-      $Rows = 10,
163
-      $Preview = true,
164
-      $Buttons = true,
165
-      $Buffer = false,
166
-      array $ExtraAttributes = []
167
-  ) {
160
+        $Name,
161
+        $ID = '',
162
+        $Value = '',
163
+        $Cols = 50,
164
+        $Rows = 10,
165
+        $Preview = true,
166
+        $Buttons = true,
167
+        $Buffer = false,
168
+        array $ExtraAttributes = []
169
+    ) {
168
         $this->id = parent::$Textareas;
170
         $this->id = parent::$Textareas;
169
         parent::$Textareas += 1;
171
         parent::$Textareas += 1;
170
         array_push(parent::$_ID, $ID);
172
         array_push(parent::$_ID, $ID);
184
         }
186
         }
185
 
187
 
186
         $this->buffer = View::parse('generic/textarea/textarea.phtml', array(
188
         $this->buffer = View::parse('generic/textarea/textarea.phtml', array(
187
-      'ID' => $ID,
188
-      'NID' => $this->id,
189
-      'Name' => &$Name,
190
-      'Value' => &$Value,
191
-      'Cols' => &$Cols,
192
-      'Rows' => &$Rows,
193
-      'Attributes' => &$Attributes
194
-    ), $Buffer);
189
+            'ID' => $ID,
190
+            'NID' => $this->id,
191
+            'Name' => &$Name,
192
+            'Value' => &$Value,
193
+            'Cols' => &$Cols,
194
+            'Rows' => &$Rows,
195
+            'Attributes' => &$Attributes
196
+        ), $Buffer);
195
 
197
 
196
         if ($Buttons === true) {
198
         if ($Buttons === true) {
197
             $this->buttons();
199
             $this->buttons();

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

5
     public static function render_linkbox($Selected)
5
     public static function render_linkbox($Selected)
6
     {
6
     {
7
         ?>
7
         ?>
8
-
9
 <div class="linkbox">
8
 <div class="linkbox">
10
   <a href="top10.php?type=torrents" class="brackets"><?=self::get_selected_link("Torrents", $Selected === "torrents")?></a>
9
   <a href="top10.php?type=torrents" class="brackets"><?=self::get_selected_link("Torrents", $Selected === "torrents")?></a>
11
   <a href="top10.php?type=users" class="brackets"><?=self::get_selected_link("Users", $Selected === "users")?></a>
10
   <a href="top10.php?type=users" class="brackets"><?=self::get_selected_link("Users", $Selected === "users")?></a>
14
   <a href="top10.php?type=donors" class="brackets"><?=self::get_selected_link("Donors", $Selected === "donors")?></a>
13
   <a href="top10.php?type=donors" class="brackets"><?=self::get_selected_link("Donors", $Selected === "donors")?></a>
15
   <?php } ?>
14
   <?php } ?>
16
 </div>
15
 </div>
17
-
18
 <?php
16
 <?php
19
     }
17
     }
20
 
18
 
45
     {
43
     {
46
         if (!empty($Image)) {
44
         if (!empty($Image)) {
47
             $Name = display_str($Name); ?>
45
             $Name = display_str($Name); ?>
48
-
49
 <li>
46
 <li>
50
   <a
47
   <a
51
     href="<?=$Url?><?=$Name?>">
48
     href="<?=$Url?><?=$Name?>">

+ 224
- 212
classes/torrent_32bit.class.php View File

1
-<?
1
+<?php
2
+
3
+# todo: Replace this with https://github.com/OPSnet/bencode-torrent
4
+
2
 /*******************************************************************************
5
 /*******************************************************************************
3
 |~~~~ Gazelle bencode parser                                               ~~~~|
6
 |~~~~ Gazelle bencode parser                                               ~~~~|
4
 --------------------------------------------------------------------------------
7
 --------------------------------------------------------------------------------
72
 discovered that floats aren't accurate enough to use. :(
75
 discovered that floats aren't accurate enough to use. :(
73
 
76
 
74
 *******************************************************************************/
77
 *******************************************************************************/
75
-class BENCODE2 {
76
-  var $Val; // Decoded array
77
-  var $Pos = 1; // Pointer that indicates our position in the string
78
-  var $Str = ''; // Torrent string
79
-
80
-  function __construct($Val, $IsParsed = false) {
81
-    if (!$IsParsed) {
82
-      $this->Str = $Val;
83
-      $this->dec();
84
-    } else {
85
-      $this->Val = $Val;
86
-    }
87
-  }
88
-
89
-  // Decode an element based on the type
90
-  function decode($Type, $Key) {
91
-    if (ctype_digit($Type)) { // Element is a string
92
-      // Get length of string
93
-      $StrLen = $Type;
94
-      while ($this->Str[$this->Pos + 1] != ':') {
95
-        $this->Pos++;
96
-        $StrLen.=$this->Str[$this->Pos];
78
+class BENCODE2
79
+{
80
+    public $Val; // Decoded array
81
+  public $Pos = 1; // Pointer that indicates our position in the string
82
+  public $Str = ''; // Torrent string
83
+
84
+  public function __construct($Val, $IsParsed = false)
85
+  {
86
+      if (!$IsParsed) {
87
+          $this->Str = $Val;
88
+          $this->dec();
89
+      } else {
90
+          $this->Val = $Val;
97
       }
91
       }
98
-      $this->Val[$Key] = substr($this->Str, $this->Pos + 2, $StrLen);
99
-
100
-      $this->Pos += $StrLen;
101
-      $this->Pos += 2;
102
-
103
-    } elseif ($Type == 'i') { // Element is an int
104
-      $this->Pos++;
105
-
106
-      // Find end of integer (first occurance of 'e' after position)
107
-      $End = strpos($this->Str, 'e', $this->Pos);
108
-
109
-      // Get the integer, and mark it as an int (on our version 64 bit box, we cast it to an int)
110
-      $this->Val[$Key] = '[*INT*]'.substr($this->Str, $this->Pos, $End-$this->Pos);
111
-      $this->Pos = $End + 1;
112
-
113
-    } elseif ($Type == 'l') { // Element is a list
114
-      $this->Val[$Key] = new BENCODE_LIST(substr($this->Str, $this->Pos));
115
-      $this->Pos += $this->Val[$Key]->Pos;
116
-
117
-    } elseif ($Type == 'd') { // Element is a dictionary
118
-      $this->Val[$Key] = new BENCODE_DICT(substr($this->Str, $this->Pos));
119
-      $this->Pos += $this->Val[$Key]->Pos;
120
-      // Sort by key to respect spec
121
-      ksort($this->Val[$Key]->Val);
92
+  }
122
 
93
 
123
-    } else {
124
-      die('Invalid torrent file');
94
+    // Decode an element based on the type
95
+    public function decode($Type, $Key)
96
+    {
97
+        if (ctype_digit($Type)) { // Element is a string
98
+            // Get length of string
99
+            $StrLen = $Type;
100
+            while ($this->Str[$this->Pos + 1] != ':') {
101
+                $this->Pos++;
102
+                $StrLen.=$this->Str[$this->Pos];
103
+            }
104
+            $this->Val[$Key] = substr($this->Str, $this->Pos + 2, $StrLen);
105
+
106
+            $this->Pos += $StrLen;
107
+            $this->Pos += 2;
108
+        } elseif ($Type == 'i') { // Element is an int
109
+            $this->Pos++;
110
+
111
+            // Find end of integer (first occurance of 'e' after position)
112
+            $End = strpos($this->Str, 'e', $this->Pos);
113
+
114
+            // Get the integer, and mark it as an int (on our version 64 bit box, we cast it to an int)
115
+            $this->Val[$Key] = '[*INT*]'.substr($this->Str, $this->Pos, $End-$this->Pos);
116
+            $this->Pos = $End + 1;
117
+        } elseif ($Type == 'l') { // Element is a list
118
+            $this->Val[$Key] = new BENCODE_LIST(substr($this->Str, $this->Pos));
119
+            $this->Pos += $this->Val[$Key]->Pos;
120
+        } elseif ($Type == 'd') { // Element is a dictionary
121
+            $this->Val[$Key] = new BENCODE_DICT(substr($this->Str, $this->Pos));
122
+            $this->Pos += $this->Val[$Key]->Pos;
123
+            // Sort by key to respect spec
124
+            ksort($this->Val[$Key]->Val);
125
+        } else {
126
+            die('Invalid torrent file');
127
+        }
125
     }
128
     }
126
-  }
127
 
129
 
128
-  function encode($Val) {
129
-    if (is_string($Val)) {
130
-      if (substr($Val, 0, 7) == '[*INT*]') {
131
-        return 'i'.substr($Val,7).'e';
132
-      } else {
133
-        return strlen($Val).':'.$Val;
134
-      }
135
-    } elseif (is_object($Val)) {
136
-      return $Val->enc();
137
-    } else {
138
-      return 'fail';
130
+    public function encode($Val)
131
+    {
132
+        if (is_string($Val)) {
133
+            if (substr($Val, 0, 7) == '[*INT*]') {
134
+                return 'i'.substr($Val, 7).'e';
135
+            } else {
136
+                return strlen($Val).':'.$Val;
137
+            }
138
+        } elseif (is_object($Val)) {
139
+            return $Val->enc();
140
+        } else {
141
+            return 'fail';
142
+        }
139
     }
143
     }
140
-  }
141
 }
144
 }
142
 
145
 
143
-class BENCODE_LIST extends BENCODE2 {
144
-  function enc() {
145
-    $Str = 'l';
146
-    foreach ($this->Val as $Value) {
147
-      $Str.=$this->encode($Value);
146
+class BENCODE_LIST extends BENCODE2
147
+{
148
+    public function enc()
149
+    {
150
+        $Str = 'l';
151
+        foreach ($this->Val as $Value) {
152
+            $Str.=$this->encode($Value);
153
+        }
154
+        return $Str.'e';
148
     }
155
     }
149
-    return $Str.'e';
150
-  }
151
 
156
 
152
-  // Decode a list
153
-  function dec() {
154
-    $Key = 0; // Array index
155
-    $Length = strlen($this->Str);
156
-    while ($this->Pos<$Length) {
157
-      $Type = $this->Str[$this->Pos];
158
-      // $Type now indicates what type of element we're dealing with
159
-      // It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
160
-
161
-      if ($Type == 'e') { // End of list
162
-        $this->Pos += 1;
163
-        unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
164
-        return;
165
-      }
166
-
167
-      // Decode the bencoded element.
168
-      // This function changes $this->Pos and $this->Val, so you don't have to.
169
-      $this->decode($Type, $Key);
170
-      ++ $Key;
157
+    // Decode a list
158
+    public function dec()
159
+    {
160
+        $Key = 0; // Array index
161
+        $Length = strlen($this->Str);
162
+        while ($this->Pos<$Length) {
163
+            $Type = $this->Str[$this->Pos];
164
+            // $Type now indicates what type of element we're dealing with
165
+            // It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
166
+
167
+            if ($Type == 'e') { // End of list
168
+                $this->Pos += 1;
169
+                unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
170
+                return;
171
+            }
172
+
173
+            // Decode the bencoded element.
174
+            // This function changes $this->Pos and $this->Val, so you don't have to.
175
+            $this->decode($Type, $Key);
176
+            ++ $Key;
177
+        }
178
+        return true;
171
     }
179
     }
172
-    return true;
173
-  }
174
 }
180
 }
175
 
181
 
176
-class BENCODE_DICT extends BENCODE2 {
177
-  function enc() {
178
-    $Str = 'd';
179
-    foreach ($this->Val as $Key => $Value) {
180
-      $Str.=strlen($Key).':'.$Key.$this->encode($Value);
182
+class BENCODE_DICT extends BENCODE2
183
+{
184
+    public function enc()
185
+    {
186
+        $Str = 'd';
187
+        foreach ($this->Val as $Key => $Value) {
188
+            $Str.=strlen($Key).':'.$Key.$this->encode($Value);
189
+        }
190
+        return $Str.'e';
181
     }
191
     }
182
-    return $Str.'e';
183
-  }
184
-
185
-  // Decode a dictionary
186
-  function dec() {
187
-    $Length = strlen($this->Str);
188
-    while ($this->Pos < $Length) {
189
-
190
-      if ($this->Str[$this->Pos] == 'e') { // End of dictionary
191
-        $this->Pos += 1;
192
-        unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
193
-        return;
194
-      }
195
-
196
-      // Get the dictionary key
197
-      // Length of the key, in bytes
198
-      $KeyLen = $this->Str[$this->Pos];
199
-
200
-      // Allow for multi-digit lengths
201
-      while ($this->Str[$this->Pos + 1] != ':' && $this->Pos + 1 < $Length) {
202
-        $this->Pos++;
203
-        $KeyLen.=$this->Str[$this->Pos];
204
-      }
205
-      // $this->Pos is now on the last letter of the key length
206
-      // Adding 2 brings it past that character and the ':' to the beginning of the string
207
-      $this->Pos+=2;
208
-
209
-      // Get the name of the key
210
-      $Key = substr($this->Str, $this->Pos, $KeyLen);
211
-
212
-      // Move the position past the key to the beginning of the element
213
-      $this->Pos += $KeyLen;
214
-      $Type = $this->Str[$this->Pos];
215
-      // $Type now indicates what type of element we're dealing with
216
-      // It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
217
-
218
-      // Decode the bencoded element.
219
-      // This function changes $this->Pos and $this->Val, so you don't have to.
220
-      $this->decode($Type, $Key);
221
-
222
 
192
 
193
+    // Decode a dictionary
194
+    public function dec()
195
+    {
196
+        $Length = strlen($this->Str);
197
+        while ($this->Pos < $Length) {
198
+            if ($this->Str[$this->Pos] == 'e') { // End of dictionary
199
+                $this->Pos += 1;
200
+                unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
201
+                return;
202
+            }
203
+
204
+            // Get the dictionary key
205
+            // Length of the key, in bytes
206
+            $KeyLen = $this->Str[$this->Pos];
207
+
208
+            // Allow for multi-digit lengths
209
+            while ($this->Str[$this->Pos + 1] != ':' && $this->Pos + 1 < $Length) {
210
+                $this->Pos++;
211
+                $KeyLen.=$this->Str[$this->Pos];
212
+            }
213
+            // $this->Pos is now on the last letter of the key length
214
+            // Adding 2 brings it past that character and the ':' to the beginning of the string
215
+            $this->Pos+=2;
216
+
217
+            // Get the name of the key
218
+            $Key = substr($this->Str, $this->Pos, $KeyLen);
219
+
220
+            // Move the position past the key to the beginning of the element
221
+            $this->Pos += $KeyLen;
222
+            $Type = $this->Str[$this->Pos];
223
+            // $Type now indicates what type of element we're dealing with
224
+            // It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
225
+
226
+            // Decode the bencoded element.
227
+            // This function changes $this->Pos and $this->Val, so you don't have to.
228
+            $this->decode($Type, $Key);
229
+        }
230
+        return true;
223
     }
231
     }
224
-    return true;
225
-  }
226
 }
232
 }
227
 
233
 
228
 
234
 
229
-class TORRENT extends BENCODE_DICT {
230
-  function dump() {
231
-    // Convenience function used for testing and figuring out how we store the data
232
-    print_r($this->Val);
233
-  }
234
-
235
-  function dump_data() {
236
-    // Function which serializes $this->Val for storage
237
-    return base64_encode(serialize($this->Val));
238
-  }
235
+class TORRENT extends BENCODE_DICT
236
+{
237
+    public function dump()
238
+    {
239
+        // Convenience function used for testing and figuring out how we store the data
240
+        print_r($this->Val);
241
+    }
239
 
242
 
240
-  function set_announce_url($Announce) {
241
-    $this->Val['announce'] = $Announce;
242
-    ksort($this->Val);
243
-  }
243
+    public function dump_data()
244
+    {
245
+        // Function which serializes $this->Val for storage
246
+        return base64_encode(serialize($this->Val));
247
+    }
244
 
248
 
245
-  // Returns an array of:
246
-  //  * the files in the torrent
247
-  //  * the total size of files described therein
248
-  function file_list() {
249
-    $FileList = [];
250
-    if (!isset($this->Val['info']->Val['files'])) { // Single file mode
251
-      $TotalSize = substr($this->Val['info']->Val['length'],7);
252
-      $FileList[] = array($TotalSize, $this->get_name());
253
-    } else { // Multiple file mode
254
-      $FileNames = [];
255
-      $FileSizes = [];
256
-      $TotalSize = 0;
257
-      $Files = $this->Val['info']->Val['files']->Val;
258
-      if (isset($Files[0]->Val['path.utf-8'])) {
259
-        $PathKey = 'path.utf-8';
260
-      } else {
261
-        $PathKey = 'path';
262
-      }
263
-      foreach ($Files as $File) {
264
-        $FileSize = substr($File->Val['length'], 7);
265
-        $TotalSize += $FileSize;
249
+    public function set_announce_url($Announce)
250
+    {
251
+        $this->Val['announce'] = $Announce;
252
+        ksort($this->Val);
253
+    }
266
 
254
 
267
-        $FileName = ltrim(implode('/', $File->Val[$PathKey]->Val), '/');
268
-        $FileSizes[] = $FileSize;
269
-        $FileNames[] = $FileName;
270
-      }
271
-      natcasesort($FileNames);
272
-      foreach ($FileNames as $Index => $FileName) {
273
-        $FileList[] = array($FileSizes[$Index], $FileName);
274
-      }
255
+    // Returns an array of:
256
+    //  * the files in the torrent
257
+    //  * the total size of files described therein
258
+    public function file_list()
259
+    {
260
+        $FileList = [];
261
+        if (!isset($this->Val['info']->Val['files'])) { // Single file mode
262
+            $TotalSize = substr($this->Val['info']->Val['length'], 7);
263
+            $FileList[] = array($TotalSize, $this->get_name());
264
+        } else { // Multiple file mode
265
+            $FileNames = [];
266
+            $FileSizes = [];
267
+            $TotalSize = 0;
268
+            $Files = $this->Val['info']->Val['files']->Val;
269
+            if (isset($Files[0]->Val['path.utf-8'])) {
270
+                $PathKey = 'path.utf-8';
271
+            } else {
272
+                $PathKey = 'path';
273
+            }
274
+            foreach ($Files as $File) {
275
+                $FileSize = substr($File->Val['length'], 7);
276
+                $TotalSize += $FileSize;
277
+
278
+                $FileName = ltrim(implode('/', $File->Val[$PathKey]->Val), '/');
279
+                $FileSizes[] = $FileSize;
280
+                $FileNames[] = $FileName;
281
+            }
282
+            natcasesort($FileNames);
283
+            foreach ($FileNames as $Index => $FileName) {
284
+                $FileList[] = array($FileSizes[$Index], $FileName);
285
+            }
286
+        }
287
+        return array($TotalSize, $FileList);
275
     }
288
     }
276
-    return array($TotalSize, $FileList);
277
-  }
278
 
289
 
279
-  function get_name() {
280
-    if (isset($this->Val['info']->Val['name.utf-8'])) {
281
-      return $this->Val['info']->Val['name.utf-8'];
282
-    } else {
283
-      return $this->Val['info']->Val['name'];
290
+    public function get_name()
291
+    {
292
+        if (isset($this->Val['info']->Val['name.utf-8'])) {
293
+            return $this->Val['info']->Val['name.utf-8'];
294
+        } else {
295
+            return $this->Val['info']->Val['name'];
296
+        }
284
     }
297
     }
285
-  }
286
 
298
 
287
-  function make_private() {
288
-    //----- The following properties do not affect the infohash:
299
+    public function make_private()
300
+    {
301
+        //----- The following properties do not affect the infohash:
289
 
302
 
290
-    // anounce-list is an unofficial extension to the protocol
291
-    // that allows for multiple trackers per torrent
292
-    unset($this->Val['announce-list']);
303
+        // anounce-list is an unofficial extension to the protocol
304
+        // that allows for multiple trackers per torrent
305
+        unset($this->Val['announce-list']);
293
 
306
 
294
-    // Bitcomet & Azureus cache peers in here
295
-    unset($this->Val['nodes']);
307
+        // Bitcomet & Azureus cache peers in here
308
+        unset($this->Val['nodes']);
296
 
309
 
297
-    // Azureus stores the dht_backup_enable flag here
298
-    unset($this->Val['azureus_properties']);
310
+        // Azureus stores the dht_backup_enable flag here
311
+        unset($this->Val['azureus_properties']);
299
 
312
 
300
-    // Remove web-seeds
301
-    unset($this->Val['url-list']);
313
+        // Remove web-seeds
314
+        unset($this->Val['url-list']);
302
 
315
 
303
-    // Remove libtorrent resume info
304
-    unset($this->Val['libtorrent_resume']);
316
+        // Remove libtorrent resume info
317
+        unset($this->Val['libtorrent_resume']);
305
 
318
 
306
-    //----- End properties that do not affect the infohash
319
+        //----- End properties that do not affect the infohash
307
 
320
 
308
-    if (!empty($this->Val['info']->Val['private']) && $this->Val['info']->Val['private'] == '[*INT*]1') {
309
-      return true;
310
-    } else {
311
-      // Torrent is not private!
312
-      // add private tracker flag and sort info dictionary
313
-      $this->Val['info']->Val['private'] = '[*INT*]1';
314
-      ksort($this->Val['info']->Val);
315
-      return false;
321
+        if (!empty($this->Val['info']->Val['private']) && $this->Val['info']->Val['private'] == '[*INT*]1') {
322
+            return true;
323
+        } else {
324
+            // Torrent is not private!
325
+            // add private tracker flag and sort info dictionary
326
+            $this->Val['info']->Val['private'] = '[*INT*]1';
327
+            ksort($this->Val['info']->Val);
328
+            return false;
329
+        }
316
     }
330
     }
317
-  }
318
 }
331
 }
319
-?>

+ 14
- 11
classes/useragent.class.php View File

3
 class UserAgent
3
 class UserAgent
4
 {
4
 {
5
     private static $Browsers = array(
5
     private static $Browsers = array(
6
-    //Less popular
6
+    // Less popular
7
     'Shiira'     => 'Shiira',
7
     'Shiira'     => 'Shiira',
8
     'Songbird'   => 'Songbird',
8
     'Songbird'   => 'Songbird',
9
     'SeaMonkey'  => 'SeaMonkey',
9
     'SeaMonkey'  => 'SeaMonkey',
18
     'libcurl'    => 'cURL',
18
     'libcurl'    => 'cURL',
19
     'midori'     => 'Midori',
19
     'midori'     => 'Midori',
20
     'Blackberry' => 'BlackBerry Browser',
20
     'Blackberry' => 'BlackBerry Browser',
21
-    //Big names
21
+    // Big names
22
     'Firefox' => 'Firefox',
22
     'Firefox' => 'Firefox',
23
     'OPR'     => 'Opera Blink', # Opera 15+ (the version running Blink)
23
     'OPR'     => 'Opera Blink', # Opera 15+ (the version running Blink)
24
     'Opera'   => 'Opera',
24
     'Opera'   => 'Opera',
25
     'Chrome'  => 'Chrome',
25
     'Chrome'  => 'Chrome',
26
     'Safari'  => 'Safari',
26
     'Safari'  => 'Safari',
27
-    //Put Chrome Frame above IE
27
+    // Put Chrome Frame above IE
28
     'chromeframe' => 'Chrome Frame',
28
     'chromeframe' => 'Chrome Frame',
29
     'x-clock'     => 'Chrome Frame',
29
     'x-clock'     => 'Chrome Frame',
30
     'MSIE'        => 'Internet Explorer',
30
     'MSIE'        => 'Internet Explorer',
31
     'Trident'     => 'Internet Explorer',
31
     'Trident'     => 'Internet Explorer',
32
-    //Firefox versions
32
+    // Firefox versions
33
     'Shiretoko'    => 'Firefox (Experimental)',
33
     'Shiretoko'    => 'Firefox (Experimental)',
34
     'Minefield'    => 'Firefox (Experimental)',
34
     'Minefield'    => 'Firefox (Experimental)',
35
     'GranParadiso' => 'Firefox (Experimental)',
35
     'GranParadiso' => 'Firefox (Experimental)',
36
     'Namoroka'     => 'Firefox (Experimental)',
36
     'Namoroka'     => 'Firefox (Experimental)',
37
     'AppleWebKit'  => 'WebKit',
37
     'AppleWebKit'  => 'WebKit',
38
     'Mozilla'      => 'Mozilla'
38
     'Mozilla'      => 'Mozilla'
39
-    //Weird shit
39
+    // Weird shit
40
     /*
40
     /*
41
     'WWW-Mechanize' => 'Perl',
41
     'WWW-Mechanize' => 'Perl',
42
     'Wget'          => 'Wget',
42
     'Wget'          => 'Wget',
48
   );
48
   );
49
 
49
 
50
     private static $OperatingSystems = array(
50
     private static $OperatingSystems = array(
51
-    //Mobile
51
+    // Mobile
52
     'SymbianOS'    => 'Symbian',
52
     'SymbianOS'    => 'Symbian',
53
     'blackberry'   => 'BlackBerry',
53
     'blackberry'   => 'BlackBerry',
54
     'iphone'       => 'iPhone',
54
     'iphone'       => 'iPhone',
58
     'mot-razr'     => 'Motorola Razr',
58
     'mot-razr'     => 'Motorola Razr',
59
   //'tablet PC'    => 'Windows RT',
59
   //'tablet PC'    => 'Windows RT',
60
   //'ARM; Trident' => 'Windows RT',
60
   //'ARM; Trident' => 'Windows RT',
61
-    //Windows
61
+    // Windows
62
     'Windows NT 10.0' => 'Windows 10',
62
     'Windows NT 10.0' => 'Windows 10',
63
     'Windows NT 6.4'  => 'Windows 10',
63
     'Windows NT 6.4'  => 'Windows 10',
64
     'Windows NT 6.3'  => 'Windows 8.1',
64
     'Windows NT 6.3'  => 'Windows 8.1',
88
     'win16'           => 'Windows 3.1',
88
     'win16'           => 'Windows 3.1',
89
   //'windows'         => 'Windows',
89
   //'windows'         => 'Windows',
90
     'cros'            => 'Chrome OS',
90
     'cros'            => 'Chrome OS',
91
-    //OS X
91
+    // OS X
92
     'os x'      => 'Mac OS X',
92
     'os x'      => 'Mac OS X',
93
     'macintosh' => 'Mac OS X',
93
     'macintosh' => 'Mac OS X',
94
     'darwin'    => 'Mac OS X',
94
     'darwin'    => 'Mac OS X',
95
-    //Less popular
95
+    // Less popular
96
     'ubuntu'  => 'Ubuntu',
96
     'ubuntu'  => 'Ubuntu',
97
     'debian'  => 'Debian',
97
     'debian'  => 'Debian',
98
     'fedora'  => 'Fedora',
98
     'fedora'  => 'Fedora',
105
     'unix'    => 'Unix',
105
     'unix'    => 'Unix',
106
     'Sun OS'  => 'Sun',
106
     'Sun OS'  => 'Sun',
107
     'Sun'     => 'Sun',
107
     'Sun'     => 'Sun',
108
-    //Weird shit
108
+    // Weird shit
109
     /*
109
     /*
110
     'WWW-Mechanize' => 'Perl',
110
     'WWW-Mechanize' => 'Perl',
111
     'Wget'          => 'Wget',
111
     'Wget'          => 'Wget',
114
     'Java'          => 'Java',
114
     'Java'          => 'Java',
115
     'RSS'           => 'RSS Downloader',
115
     'RSS'           => 'RSS Downloader',
116
     */
116
     */
117
-    //Catch-all
117
+    // Catch-all
118
     'win' => 'Windows',
118
     'win' => 'Windows',
119
     'mac' => 'Mac OS X'
119
     'mac' => 'Mac OS X'
120
   );
120
   );
124
         if (empty($UserAgentString)) {
124
         if (empty($UserAgentString)) {
125
             return 'Hidden';
125
             return 'Hidden';
126
         }
126
         }
127
+
127
         foreach (self::$OperatingSystems as $String => $OperatingSystem) {
128
         foreach (self::$OperatingSystems as $String => $OperatingSystem) {
128
             if (stripos($UserAgentString, $String) !== false) {
129
             if (stripos($UserAgentString, $String) !== false) {
129
                 return $OperatingSystem;
130
                 return $OperatingSystem;
150
         if (empty($UserAgentString)) {
151
         if (empty($UserAgentString)) {
151
             return 'Hidden';
152
             return 'Hidden';
152
         }
153
         }
154
+
153
         $Return = 'Unknown';
155
         $Return = 'Unknown';
154
         foreach (self::$Browsers as $String => $Browser) {
156
         foreach (self::$Browsers as $String => $Browser) {
155
             if (strpos($UserAgentString, $String) !== false) {
157
             if (strpos($UserAgentString, $String) !== false) {
157
                 break;
159
                 break;
158
             }
160
             }
159
         }
161
         }
162
+        
160
         if (self::mobile($UserAgentString)) {
163
         if (self::mobile($UserAgentString)) {
161
             $Return .= ' Mobile';
164
             $Return .= ' Mobile';
162
         }
165
         }

Loading…
Cancel
Save