Browse Source

Collected edits, web seeds, and RSS feeds

pjc 5 years ago
parent
commit
9a057055d2

+ 24
- 0
_packages/web-seeds/classes/bencodetorrent.class.php View File

1
+<?php
2
+
3
+class BencodeTorrent extends BencodeDecode
4
+{
5
+    # ...
6
+
7
+    /**
8
+     * Add list of web seeds to a torrent
9
+     */
10
+    public static function add_web_seeds($Data, $Urls)
11
+    {
12
+        $r = 'd8:url-listl';
13
+        for ($i = 0; $i < count($Urls); $i++) {
14
+            $r .= 'l';
15
+            for ($j = 0; $j < count($Urls[$i]); $j++) {
16
+                $r .= strlen($Urls[$i][$j]).':'.$Urls[$i][$j];
17
+            }
18
+            $r .= 'e';
19
+        }
20
+        return $r.'e'.substr($Data, 1);
21
+    }
22
+}
23
+
24
+# EOF

+ 16
- 0
classes/bencodetorrent.class.php View File

168
         }
168
         }
169
         return $r.'e'.substr($Data, 1);
169
         return $r.'e'.substr($Data, 1);
170
     }
170
     }
171
+
172
+    /**
173
+     * Add list of web seeds to a torrent
174
+     */
175
+    public static function add_web_seeds($Data, $Urls)
176
+    {
177
+        $r = 'd8:url-listl';
178
+        for ($i = 0; $i < count($Urls); $i++) {
179
+            $r .= 'l';
180
+            for ($j = 0; $j < count($Urls[$i]); $j++) {
181
+                $r .= strlen($Urls[$i][$j]).':'.$Urls[$i][$j];
182
+            }
183
+            $r .= 'e';
184
+        }
185
+        return $r.'e'.substr($Data, 1);
186
+    }
171
 }
187
 }

+ 69
- 62
classes/feed.class.php View File

1
-<?
2
-class Feed {
3
-  function open_feed() {
4
-    header("Content-type: application/xml; charset=UTF-8");
5
-    echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n","<rss xmlns:dc=\"http://purl.org/dc/elements/1.1/\" version=\"2.0\">\n\t<channel>\n";
6
-  }
7
-
8
-  function close_feed() {
9
-    echo "\t</channel>\n</rss>";
10
-  }
11
-
12
-  function channel($Title, $Description, $Section = '') {
13
-    $Site = site_url();
14
-    echo "\t\t<title>$Title :: ". SITE_NAME. "</title>\n";
15
-    echo "\t\t<link>$Site$Section</link>\n";
16
-    echo "\t\t<description>$Description</description>\n";
17
-    echo "\t\t<language>en-us</language>\n";
18
-    echo "\t\t<lastBuildDate>". date('r'). "</lastBuildDate>\n";
19
-    echo "\t\t<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
20
-    echo "\t\t<generator>Gazelle Feed Class</generator>\n\n";
21
-  }
1
+<?php
2
+class Feed
3
+{
4
+    public function open_feed()
5
+    {
6
+        header("Content-type: application/xml; charset=UTF-8");
7
+        echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n","<rss xmlns:dc=\"http://purl.org/dc/elements/1.1/\" version=\"2.0\">\n\t<channel>\n";
8
+    }
22
 
9
 
23
-  function item($Title, $Description, $Page, $Creator, $Comments = '', $Category = '', $Date = '') { //Escape with CDATA, otherwise the feed breaks.
24
-    if ($Date == '') {
25
-      $Date = date('r');
26
-    } else {
27
-      $Date = date('r', strtotime($Date));
10
+    public function close_feed()
11
+    {
12
+        echo "\t</channel>\n</rss>";
28
     }
13
     }
29
-    $Site = site_url();
30
-    $Item = "\t\t<item>\n";
31
-    $Item .= "\t\t\t<title><![CDATA[$Title]]></title>\n";
32
-    $Item .= "\t\t\t<description><![CDATA[$Description]]></description>\n";
33
-    $Item .= "\t\t\t<pubDate>$Date</pubDate>\n";
34
-    $Item .= "\t\t\t<link>$Site$Page</link>\n";
35
-    $Item .= "\t\t\t<guid>$Site$Page</guid>\n";
36
-    if ($Comments != '') {
37
-      $Item .= "\t\t\t<comments>$Site$Comments</comments>\n";
14
+
15
+    public function channel($Title, $Description, $Section = '')
16
+    {
17
+        $Site = site_url();
18
+        echo "\t\t<title>$Title :: ". SITE_NAME. "</title>\n";
19
+        echo "\t\t<link>$Site$Section</link>\n";
20
+        echo "\t\t<description>$Description</description>\n";
21
+        echo "\t\t<language>en-us</language>\n";
22
+        echo "\t\t<lastBuildDate>". date('r'). "</lastBuildDate>\n";
23
+        echo "\t\t<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
24
+        echo "\t\t<generator>Gazelle Feed Class</generator>\n\n";
38
     }
25
     }
39
-    if ($Category != '') {
40
-      $Item .= "\t\t\t<category><![CDATA[$Category]]></category>\n";
26
+
27
+    public function item($Title, $Description, $Page, $Creator, $Comments = '', $Category = '', $Date = '')
28
+    { // Escape with CDATA, otherwise the feed breaks.
29
+        if ($Date === '') {
30
+            $Date = date('r');
31
+        } else {
32
+            $Date = date('r', strtotime($Date));
33
+        }
34
+        $Site = site_url();
35
+        $Item = "\t\t<item>\n";
36
+        $Item .= "\t\t\t<title><![CDATA[$Title]]></title>\n";
37
+        $Item .= "\t\t\t<description><![CDATA[$Description]]></description>\n";
38
+        $Item .= "\t\t\t<pubDate>$Date</pubDate>\n";
39
+        $Item .= "\t\t\t<link>$Site$Page</link>\n";
40
+        $Item .= "\t\t\t<guid>$Site$Page</guid>\n";
41
+        if ($Comments !== '') {
42
+            $Item .= "\t\t\t<comments>$Site$Comments</comments>\n";
43
+        }
44
+        if ($Category !== '') {
45
+            $Item .= "\t\t\t<category><![CDATA[$Category]]></category>\n";
46
+        }
47
+        $Item .= "\t\t\t<dc:creator>$Creator</dc:creator>\n\t\t</item>\n";
48
+        return $Item;
41
     }
49
     }
42
-    $Item .= "\t\t\t<dc:creator>$Creator</dc:creator>\n\t\t</item>\n";
43
-    return $Item;
44
-  }
45
 
50
 
46
-  function retrieve($CacheKey, $AuthKey, $PassKey) {
47
-    global $Cache;
48
-    $Entries = $Cache->get_value($CacheKey);
49
-    if (!$Entries) {
50
-      $Entries = [];
51
-    } else {
52
-      foreach ($Entries as $Item) {
53
-        echo str_replace(array('[[PASSKEY]]', '[[AUTHKEY]]'), array(display_str($PassKey), display_str($AuthKey)), $Item);
54
-      }
51
+    public function retrieve($CacheKey, $AuthKey, $PassKey)
52
+    {
53
+        global $Cache;
54
+        $Entries = $Cache->get_value($CacheKey);
55
+        if (!$Entries) {
56
+            $Entries = [];
57
+        } else {
58
+            foreach ($Entries as $Item) {
59
+                echo str_replace(array('[[PASSKEY]]', '[[AUTHKEY]]'), array(display_str($PassKey), display_str($AuthKey)), $Item);
60
+            }
61
+        }
55
     }
62
     }
56
-  }
57
 
63
 
58
-  function populate($CacheKey, $Item) {
59
-    global $Cache;
60
-    $Entries = $Cache->get_value($CacheKey, true);
61
-    if (!$Entries) {
62
-      $Entries = [];
63
-    } else {
64
-      if (count($Entries) >= 50) {
65
-        array_pop($Entries);
66
-      }
64
+    public function populate($CacheKey, $Item)
65
+    {
66
+        global $Cache;
67
+        $Entries = $Cache->get_value($CacheKey, true);
68
+        if (!$Entries) {
69
+            $Entries = [];
70
+        } else {
71
+            if (count($Entries) >= 50) {
72
+                array_pop($Entries);
73
+            }
74
+        }
75
+        array_unshift($Entries, $Item);
76
+        $Cache->cache_value($CacheKey, $Entries, 0); // inf cache
67
     }
77
     }
68
-    array_unshift($Entries, $Item);
69
-    $Cache->cache_value($CacheKey, $Entries, 0); //inf cache
70
-  }
71
 }
78
 }

+ 171
- 152
classes/irc.class.php View File

1
-<?
2
-class IRC_DB extends DB_MYSQL {
3
-  function halt($Msg) {
4
-    global $Bot;
5
-    $Bot->send_to($Bot->get_channel(), 'The database is currently unavailable; try again later.');
6
-  }
1
+<?php
2
+class IRC_DB extends DB_MYSQL
3
+{
4
+    public function halt($Msg)
5
+    {
6
+        global $Bot;
7
+        $Bot->send_to($Bot->get_channel(), 'The database is currently unavailable; try again later.');
8
+    }
7
 }
9
 }
8
 
10
 
9
-abstract class IRC_BOT {
10
-  abstract protected function connect_events();
11
-  abstract protected function channel_events();
12
-  abstract protected function query_events();
13
-  abstract protected function irc_events();
14
-  abstract protected function listener_events();
15
-
16
-  protected $Debug = false;
17
-  protected $Socket = false;
18
-  protected $Data = false;
19
-  protected $Whois = false;
20
-  protected $Identified = [];
21
-  protected $Channels = [];
22
-  protected $Messages = [];
23
-  protected $LastChan = false;
24
-  protected $ListenSocket = false;
25
-  protected $Listened = false;
26
-  protected $Connecting = false;
27
-  protected $State = 1; // Drone is live
11
+abstract class IRC_BOT
12
+{
13
+    abstract protected function connect_events();
14
+    abstract protected function channel_events();
15
+    abstract protected function query_events();
16
+    abstract protected function irc_events();
17
+    abstract protected function listener_events();
18
+
19
+    protected $Debug = false;
20
+    protected $Socket = false;
21
+    protected $Data = false;
22
+    protected $Whois = false;
23
+    protected $Identified = [];
24
+    protected $Channels = [];
25
+    protected $Messages = [];
26
+    protected $LastChan = false;
27
+    protected $ListenSocket = false;
28
+    protected $Listened = false;
29
+    protected $Connecting = false;
30
+    protected $State = 1; // Drone is live
28
   public $Restart = 0; // Die by default
31
   public $Restart = 0; // Die by default
29
 
32
 
30
-  public function __construct() {
31
-    if (isset($_SERVER['HOME']) && is_dir($_SERVER['HOME']) && getcwd() != $_SERVER['HOME']) {
32
-      chdir($_SERVER['HOME']);
33
-    }
34
-    ob_end_clean();
35
-    restore_error_handler(); //Avoid PHP error logging
36
-    set_time_limit(0);
37
-  }
38
-
39
-  public function connect() {
40
-    $this->connect_irc();
41
-    $this->connect_listener();
42
-    $this->post_connect();
33
+  public function __construct()
34
+  {
35
+      if (isset($_SERVER['HOME']) && is_dir($_SERVER['HOME']) && getcwd() !== $_SERVER['HOME']) {
36
+          chdir($_SERVER['HOME']);
37
+      }
38
+      ob_end_clean();
39
+      restore_error_handler(); // Avoid PHP error logging
40
+      set_time_limit(0);
43
   }
41
   }
44
 
42
 
45
-  private function connect_irc($Reconnect = false) {
46
-    $this->Connecting = true;
47
-    //Open a socket to the IRC server
48
-    if (defined('BOT_PORT_SSL')) {
49
-      $IrcAddress = 'tls://' . BOT_SERVER . ':' . BOT_PORT_SSL;
50
-    } else {
51
-      $IrcAddress = 'tcp://' . BOT_SERVER . ':' . BOT_PORT;
43
+    public function connect()
44
+    {
45
+        $this->connect_irc();
46
+        $this->connect_listener();
47
+        $this->post_connect();
52
     }
48
     }
53
-    while (!$this->Socket = stream_socket_client($IrcAddress, $ErrNr, $ErrStr)) {
54
-      sleep(15);
55
-    }
56
-    stream_set_blocking($this->Socket, 0);
57
-    $this->Connecting = false;
58
-    if ($Reconnect) {
59
-      $this->post_connect();
60
-    }
61
-  }
62
 
49
 
63
-  private function connect_listener() {
64
-    //create a socket to listen on
65
-    $ListenAddress = 'tcp://' . SOCKET_LISTEN_ADDRESS . ':' . SOCKET_LISTEN_PORT;
66
-    if (!$this->ListenSocket = stream_socket_server($ListenAddress, $ErrNr, $ErrStr)) {
67
-      die("Cannot create listen socket: $ErrStr");
50
+    private function connect_irc($Reconnect = false)
51
+    {
52
+        $this->Connecting = true;
53
+        // Open a socket to the IRC server
54
+        if (defined('BOT_PORT_SSL')) {
55
+            $IrcAddress = 'tls://' . BOT_SERVER . ':' . BOT_PORT_SSL;
56
+        } else {
57
+            $IrcAddress = 'tcp://' . BOT_SERVER . ':' . BOT_PORT;
58
+        }
59
+        while (!$this->Socket = stream_socket_client($IrcAddress, $ErrNr, $ErrStr)) {
60
+            sleep(15);
61
+        }
62
+        stream_set_blocking($this->Socket, 0);
63
+        $this->Connecting = false;
64
+        if ($Reconnect) {
65
+            $this->post_connect();
66
+        }
68
     }
67
     }
69
-    stream_set_blocking($this->ListenSocket, false);
70
-  }
71
-
72
-  private function post_connect() {
73
-    fwrite($this->Socket, "NICK ".BOT_NICK."Init\n");
74
-    fwrite($this->Socket, "USER ".BOT_NICK." * * :IRC Bot\n");
75
-    $this->listen();
76
-  }
77
 
68
 
78
-  public function disconnect() {
79
-    fclose($this->ListenSocket);
80
-    $this->State = 0; //Drones dead
81
-  }
69
+    private function connect_listener()
70
+    {
71
+        // Create a socket to listen on
72
+        $ListenAddress = 'tcp://' . SOCKET_LISTEN_ADDRESS . ':' . SOCKET_LISTEN_PORT;
73
+        if (!$this->ListenSocket = stream_socket_server($ListenAddress, $ErrNr, $ErrStr)) {
74
+            die("Cannot create listen socket: $ErrStr");
75
+        }
76
+        stream_set_blocking($this->ListenSocket, false);
77
+    }
82
 
78
 
83
-  public function get_channel() {
84
-    preg_match('/.+ PRIVMSG ([^:]+) :.+/', $this->Data, $Channel);
85
-    if (preg_match('/#.+/', $Channel[1])) {
86
-      return $Channel[1];
87
-    } else {
88
-      return false;
79
+    private function post_connect()
80
+    {
81
+        fwrite($this->Socket, "NICK ".BOT_NICK."Init\n");
82
+        fwrite($this->Socket, "USER ".BOT_NICK." * * :IRC Bot\n");
83
+        $this->listen();
89
     }
84
     }
90
-  }
91
 
85
 
92
-  public function get_nick() {
93
-    preg_match('/:([^!:]+)!.+@[^\s]+ PRIVMSG [^:]+ :.+/', $this->Data, $Nick);
94
-    return $Nick[1];
95
-  }
86
+    public function disconnect()
87
+    {
88
+        fclose($this->ListenSocket);
89
+        $this->State = 0; // Drone's dead
90
+    }
96
 
91
 
97
-  protected function get_message() {
98
-    preg_match('/:.+ PRIVMSG [^:]+ :(.+)/', $this->Data, $Msg);
99
-    return trim($Msg[1]);
100
-  }
92
+    public function get_channel()
93
+    {
94
+        preg_match('/.+ PRIVMSG ([^:]+) :.+/', $this->Data, $Channel);
95
+        if (preg_match('/#.+/', $Channel[1])) {
96
+            return $Channel[1];
97
+        } else {
98
+            return false;
99
+        }
100
+    }
101
 
101
 
102
-  protected function get_irc_host() {
103
-    preg_match('/:[^!:]+!.+@([^\s]+) PRIVMSG [^:]+ :.+/', $this->Data, $Host);
104
-    return trim($Host[1]);
105
-  }
102
+    public function get_nick()
103
+    {
104
+        preg_match('/:([^!:]+)!.+@[^\s]+ PRIVMSG [^:]+ :.+/', $this->Data, $Nick);
105
+        return $Nick[1];
106
+    }
106
 
107
 
107
-  protected function get_word($Select = 1) {
108
-    preg_match('/:.+ PRIVMSG [^:]+ :(.+)/', $this->Data, $Word);
109
-    $Word = split(' ', $Word[1]);
110
-    return trim($Word[$Select]);
111
-  }
108
+    protected function get_message()
109
+    {
110
+        preg_match('/:.+ PRIVMSG [^:]+ :(.+)/', $this->Data, $Msg);
111
+        return trim($Msg[1]);
112
+    }
112
 
113
 
113
-  protected function get_action() {
114
-    preg_match('/:.+ PRIVMSG [^:]+ :!(\S+)/', $this->Data, $Action);
115
-    return strtoupper($Action[1]);
116
-  }
114
+    protected function get_irc_host()
115
+    {
116
+        preg_match('/:[^!:]+!.+@([^\s]+) PRIVMSG [^:]+ :.+/', $this->Data, $Host);
117
+        return trim($Host[1]);
118
+    }
117
 
119
 
118
-  protected function send_raw($Text) {
119
-    if (!feof($this->Socket)) {
120
-      fwrite($this->Socket, "$Text\n");
121
-    } elseif (!$this->Connecting) {
122
-      $this->Connecting = true;
123
-      sleep(120);
124
-      $this->connect_irc(true);
120
+    protected function get_word($Select = 1)
121
+    {
122
+        preg_match('/:.+ PRIVMSG [^:]+ :(.+)/', $this->Data, $Word);
123
+        $Word = split(' ', $Word[1]);
124
+        return trim($Word[$Select]);
125
     }
125
     }
126
-  }
127
 
126
 
128
-  public function send_to($Channel, $Text) {
129
-    // split the message up into <= 460 character strings and send each individually
130
-    // this is used to prevent messages from getting truncated
131
-    $Text = wordwrap($Text, 460, "\n", true);
132
-    $TextArray = explode("\n", $Text);
133
-    foreach ($TextArray as $Text) {
134
-      $this->send_raw("PRIVMSG $Channel :$Text");
127
+    protected function get_action()
128
+    {
129
+        preg_match('/:.+ PRIVMSG [^:]+ :!(\S+)/', $this->Data, $Action);
130
+        return strtoupper($Action[1]);
135
     }
131
     }
136
-  }
137
 
132
 
138
-  protected function whois($Nick) {
139
-    $this->Whois = $Nick;
140
-    $this->send_raw("WHOIS $Nick");
141
-  }
133
+    protected function send_raw($Text)
134
+    {
135
+        if (!feof($this->Socket)) {
136
+            fwrite($this->Socket, "$Text\n");
137
+        } elseif (!$this->Connecting) {
138
+            $this->Connecting = true;
139
+            sleep(120);
140
+            $this->connect_irc(true);
141
+        }
142
+    }
142
 
143
 
143
-  /*
144
-  This function uses blacklisted_ip, which is no longer in RC2.
145
-  You can probably find it in old RC1 code kicking aronud if you need it.
146
-  protected function ip_check($IP, $Gline = false, $Channel = BOT_REPORT_CHAN) {
147
-    if (blacklisted_ip($IP)) {
148
-      $this->send_to($Channel, 'TOR IP Detected: '.$IP);
149
-      if ($Gline) {
150
-        $this->send_raw('GLINE *@'.$IP.' 90d :DNSBL Proxy');
151
-      }
144
+    public function send_to($Channel, $Text)
145
+    {
146
+        // Split the message up into <= 460 character strings and send each individually
147
+        // This is used to prevent messages from getting truncated
148
+        $Text = wordwrap($Text, 460, "\n", true);
149
+        $TextArray = explode("\n", $Text);
150
+        foreach ($TextArray as $Text) {
151
+            $this->send_raw("PRIVMSG $Channel :$Text");
152
+        }
152
     }
153
     }
153
-    if (Tools::site_ban_ip($IP)) {
154
-      $this->send_to($Channel, 'Site IP Ban Detected: '.$IP);
155
-      if ($Gline) {
156
-        $this->send_raw('GLINE *@'.$IP.' 90d :IP Ban');
157
-      }
154
+
155
+    protected function whois($Nick)
156
+    {
157
+        $this->Whois = $Nick;
158
+        $this->send_raw("WHOIS $Nick");
158
     }
159
     }
159
-  }*/
160
 
160
 
161
-  protected function listen() {
162
-    G::$Cache->InternalCache = false;
163
-    stream_set_timeout($this->Socket, 10000000000);
164
-    while ($this->State == 1) {
165
-      $NullSock = null;
166
-      $Sockets = array($this->Socket, $this->ListenSocket);
167
-      if (stream_select($Sockets, $NullSock, $NullSock, null) === false) {
168
-        die();
161
+    /*
162
+    This function uses blacklisted_ip, which is no longer in RC2.
163
+    You can probably find it in old RC1 code kicking aronud if you need it.
164
+    protected function ip_check($IP, $Gline = false, $Channel = BOT_REPORT_CHAN) {
165
+      if (blacklisted_ip($IP)) {
166
+        $this->send_to($Channel, 'TOR IP Detected: '.$IP);
167
+        if ($Gline) {
168
+          $this->send_raw('GLINE *@'.$IP.' 90d :DNSBL Proxy');
169
+        }
169
       }
170
       }
170
-      foreach ($Sockets as $Socket) {
171
-        if ($Socket === $this->Socket) {
172
-          $this->irc_events();
173
-        } else {
174
-          $this->Listened = stream_socket_accept($Socket);
175
-          $this->listener_events();
171
+      if (Tools::site_ban_ip($IP)) {
172
+        $this->send_to($Channel, 'Site IP Ban Detected: '.$IP);
173
+        if ($Gline) {
174
+          $this->send_raw('GLINE *@'.$IP.' 90d :IP Ban');
176
         }
175
         }
177
       }
176
       }
178
-      G::$DB->LinkID = false;
179
-      G::$DB->Queries = [];
180
     }
177
     }
181
-  }
178
+    */
179
+
180
+    protected function listen()
181
+    {
182
+        G::$Cache->InternalCache = false;
183
+        stream_set_timeout($this->Socket, 10000000000);
184
+        while ($this->State === 1) {
185
+            $NullSock = null;
186
+            $Sockets = array($this->Socket, $this->ListenSocket);
187
+            if (stream_select($Sockets, $NullSock, $NullSock, null) === false) {
188
+                die();
189
+            }
190
+            foreach ($Sockets as $Socket) {
191
+                if ($Socket === $this->Socket) {
192
+                    $this->irc_events();
193
+                } else {
194
+                    $this->Listened = stream_socket_accept($Socket);
195
+                    $this->listener_events();
196
+                }
197
+            }
198
+            G::$DB->LinkID = false;
199
+            G::$DB->Queries = [];
200
+        }
201
+    }
182
 }
202
 }
183
-?>

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

40
             return (is_array($Ann)) ? array_map('add_passkey', $Ann) : $Ann.'/'.G::$LoggedUser['torrent_pass'].'/announce';
40
             return (is_array($Ann)) ? array_map('add_passkey', $Ann) : $Ann.'/'.G::$LoggedUser['torrent_pass'].'/announce';
41
         }
41
         }
42
 
42
 
43
-        $this->AnnounceList = array(array_map('add_passkey', ANNOUNCE_URLS[0]), ANNOUNCE_URLS[1]);
43
+        $this->AnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array(array_map('add_passkey', ANNOUNCE_URLS[0]), ANNOUNCE_URLS[1]);
44
         #$this->AnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array_map('add_passkey', ANNOUNCE_URLS);
44
         #$this->AnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array_map('add_passkey', ANNOUNCE_URLS);
45
         $this->Zip = new Zip(Misc::file_string($Title));
45
         $this->Zip = new Zip(Misc::file_string($Title));
46
     }
46
     }
238
      * @param mixed $TorrentData bencoded torrent without announce URL (new format) or TORRENT object (old format)
238
      * @param mixed $TorrentData bencoded torrent without announce URL (new format) or TORRENT object (old format)
239
      * @return bencoded string
239
      * @return bencoded string
240
      */
240
      */
241
-    public static function get_file(&$TorrentData, $AnnounceURL, $AnnounceList = [])
241
+    public static function get_file(&$TorrentData, $AnnounceURL, $AnnounceList = [], $WebSeeds = [])
242
     {
242
     {
243
         if (Misc::is_new_torrent($TorrentData)) {
243
         if (Misc::is_new_torrent($TorrentData)) {
244
             $Bencode = BencodeTorrent::add_announce_url($TorrentData, $AnnounceURL);
244
             $Bencode = BencodeTorrent::add_announce_url($TorrentData, $AnnounceURL);
245
             if (!empty($AnnounceList)) {
245
             if (!empty($AnnounceList)) {
246
                 $Bencode = BencodeTorrent::add_announce_list($Bencode, $AnnounceList);
246
                 $Bencode = BencodeTorrent::add_announce_list($Bencode, $AnnounceList);
247
             }
247
             }
248
+            /* todo: Support web seeds
249
+            if (!empty($WebSeeds)) {
250
+                $Bencode = BencodeTorrent::add_web_seeds($Bencode, $WebSeeds);
251
+            }
252
+            */
248
             return $Bencode;
253
             return $Bencode;
249
         }
254
         }
250
         $Tor = new TORRENT(unserialize(base64_decode($TorrentData)), true);
255
         $Tor = new TORRENT(unserialize(base64_decode($TorrentData)), true);

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

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

static/common/bioicons/protein.png → static/common/bioicons/proteins.png View File


+ 6
- 6
static/styles/beluga/style.css View File

18
   padding: 0
18
   padding: 0
19
 }
19
 }
20
 
20
 
21
-.cats_dna, .cats_rna, .cats_protein, .cats_imaging, .cats_extras {
21
+.cats_dna, .cats_rna, .cats_proteins, .cats_imaging, .cats_extras {
22
   /* width: 36px!important; */
22
   /* width: 36px!important; */
23
   height: 36px!important;
23
   height: 36px!important;
24
   line-height: 36px;
24
   line-height: 36px;
25
 }
25
 }
26
-.group .cats_dna:after, .group .cats_rna:after, .group .cats_protein:after,
26
+.group .cats_dna:after, .group .cats_rna:after, .group .cats_proteins:after,
27
 .group .cats_imaging:after, .group .cats_extras:after {
27
 .group .cats_imaging:after, .group .cats_extras:after {
28
   color: black!important;
28
   color: black!important;
29
 }
29
 }
47
 .group .cats_rna { background-color: #1D818E; }
47
 .group .cats_rna { background-color: #1D818E; }
48
 
48
 
49
 /* Protein */
49
 /* Protein */
50
-.cats_protein:after {
50
+.cats_proteins:after {
51
   content: "PROT";
51
   content: "PROT";
52
   color: #88C796;
52
   color: #88C796;
53
   font-size: 18px;
53
   font-size: 18px;
54
   letter-spacing: -2px;
54
   letter-spacing: -2px;
55
 }
55
 }
56
-.group .cats_protein { background-color: #88C796; }
56
+.group .cats_proteins { background-color: #88C796; }
57
 
57
 
58
 /* Imaging */
58
 /* Imaging */
59
 .cats_imaging:after {
59
 .cats_imaging:after {
2128
 body.style_pink .cats_rna:after { color: #4f3063; }
2128
 body.style_pink .cats_rna:after { color: #4f3063; }
2129
 body.style_pink .group .cats_rna { background-color: #4f3063; }
2129
 body.style_pink .group .cats_rna { background-color: #4f3063; }
2130
 
2130
 
2131
-body.style_pink .cats_protein:after { color: #9f5c9c; }
2132
-body.style_pink .group .cats_protein { background-color: #9f5c9c; }
2131
+body.style_pink .cats_proteins:after { color: #9f5c9c; }
2132
+body.style_pink .group .cats_proteins { background-color: #9f5c9c; }
2133
 
2133
 
2134
 body.style_pink .cats_imaging:after { color: #c871b9; }
2134
 body.style_pink .cats_imaging:after { color: #c871b9; }
2135
 body.style_pink .group .cats_imaging { background-color: #c871b9; }
2135
 body.style_pink .group .cats_imaging { background-color: #c871b9; }

+ 1
- 1
static/styles/oppai.2020-01-14/style.css View File

7
 /* We're going to opt for the category icon method for now, tags_* is also available */
7
 /* We're going to opt for the category icon method for now, tags_* is also available */
8
 .cats_dna { width: 36px; height: 36px; background: url('/static/common/bioicons/dna.png') no-repeat center center; }
8
 .cats_dna { width: 36px; height: 36px; background: url('/static/common/bioicons/dna.png') no-repeat center center; }
9
 .cats_rna { width: 36px; height: 36px; background: url('/static/common/bioicons/rna.png') no-repeat center center; }
9
 .cats_rna { width: 36px; height: 36px; background: url('/static/common/bioicons/rna.png') no-repeat center center; }
10
-.cats_protein { width: 36px; height: 36px; background: url('/static/common/bioicons/protein.png') no-repeat center center; }
10
+.cats_proteins { width: 36px; height: 36px; background: url('/static/common/bioicons/proteins.png') no-repeat center center; }
11
 .cats_imaging { width: 36px; height: 36px; background: url('/static/common/bioicons/imaging.png') no-repeat center center; }
11
 .cats_imaging { width: 36px; height: 36px; background: url('/static/common/bioicons/imaging.png') no-repeat center center; }
12
 .cats_other { width: 36px; height: 36px; background: url('/static/common/bioicons/other.png') no-repeat center center; }
12
 .cats_other { width: 36px; height: 36px; background: url('/static/common/bioicons/other.png') no-repeat center center; }
13
 
13
 

+ 1
- 1
static/styles/oppai/style.css View File

7
 /* We're going to opt for the category icon method for now, tags_* is also available */
7
 /* We're going to opt for the category icon method for now, tags_* is also available */
8
 .cats_dna { width: 36px; height: 36px; background: url('/static/common/bioicons/dna.png') no-repeat center center; }
8
 .cats_dna { width: 36px; height: 36px; background: url('/static/common/bioicons/dna.png') no-repeat center center; }
9
 .cats_rna { width: 36px; height: 36px; background: url('/static/common/bioicons/rna.png') no-repeat center center; }
9
 .cats_rna { width: 36px; height: 36px; background: url('/static/common/bioicons/rna.png') no-repeat center center; }
10
-.cats_protein { width: 36px; height: 36px; background: url('/static/common/bioicons/protein.png') no-repeat center center; }
10
+.cats_proteins { width: 36px; height: 36px; background: url('/static/common/bioicons/proteins.png') no-repeat center center; }
11
 .cats_imaging { width: 36px; height: 36px; background: url('/static/common/bioicons/imaging.png') no-repeat center center; }
11
 .cats_imaging { width: 36px; height: 36px; background: url('/static/common/bioicons/imaging.png') no-repeat center center; }
12
 .cats_extras { width: 36px; height: 36px; background: url('/static/common/bioicons/extras.png') no-repeat center center; }
12
 .cats_extras { width: 36px; height: 36px; background: url('/static/common/bioicons/extras.png') no-repeat center center; }
13
 
13
 

Loading…
Cancel
Save