Torrent::announce PHP Method

announce() public method

Getter and setter of torrent announce url / list If the argument is a string, announce url is added to announce list (or set as announce if announce is not set) If the argument is an array/object, set announce url (with first url) and list (if array has more than one url), tiered list supported If the argument is false announce url & list are unset
public announce ( $announce = null ) : string | array | null
return string | array | null announce url / list or null if not set
    public function announce($announce = null)
    {
        if (is_null($announce)) {
            return !isset($this->{'announce-list'}) ? isset($this->announce) ? $this->announce : null : $this->{'announce-list'};
        }
        $this->touch();
        if (is_string($announce) && isset($this->announce)) {
            return $this->{'announce-list'} = self::announce_list(isset($this->{'announce-list'}) ? $this->{'announce-list'} : $this->announce, $announce);
        }
        unset($this->{'announce-list'});
        if (is_array($announce) || is_object($announce)) {
            if (($this->announce = self::first_announce($announce)) && count($announce) > 1) {
                return $this->{'announce-list'} = self::announce_list($announce);
            } else {
                return $this->announce;
            }
        }
        if (!isset($this->announce) && $announce) {
            return $this->announce = (string) $announce;
        }
        unset($this->announce);
    }

Usage Example

Beispiel #1
0
             $trackersCount = $trackersCount + 1;
         } else {
             if (count($trackers) > 0) {
                 $announce_list[] = $trackers;
                 $trackers = array();
             }
         }
     }
 }
 if (count($trackers) > 0) {
     $announce_list[] = $trackers;
 }
 $torrent = new Torrent($tname);
 $torrent->clear_announce();
 if (count($announce_list) > 0) {
     $torrent->announce($announce_list[0][0]);
     if ($trackersCount > 1) {
         $torrent->announce_list($announce_list);
     }
 }
 if (isset($request['comment'])) {
     $comment = trim($request['comment']);
     if (strlen($comment)) {
         $torrent->comment($comment);
     }
 }
 if ($request['private']) {
     $torrent->is_private(true);
 }
 $fname = rTask::formatPath($taskNo) . "/result.torrent";
 $torrent->save($fname);
All Usage Examples Of Torrent::announce