announce_list() protected static method

Build announce list
protected static announce_list ( $announce, $merge = [] ) : array
return array announce list (array of arrays)
                 $trackers = array();
             }
         }
     }
 }
 if (count($trackers) > 0) {
     $announce_list[] = $trackers;
 }
 $path_edit = trim($request['path_edit']);
 $piece_size = $request['piece_size'];
 $callback_log = create_function('$msg', '$fp=fopen("php://stdout","w"); fputs($fp, $msg."\\n"); fclose($fp);');
 $callback_err = create_function('$msg', '$fp=fopen("php://stderr","w"); fputs($fp, $msg."\\n"); fclose($fp);');
 if (count($announce_list) > 0) {
     $torrent = new Torrent($path_edit, $announce_list[0][0], $piece_size, $callback_log, $callback_err);
     if ($trackersCount > 1) {
         $torrent->announce_list($announce_list);
     }
 } else {
     $torrent = new Torrent($path_edit, array(), $piece_size, $callback_log, $callback_err);
 }
 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);
Beispiel #2
0
 if ($req->success()) {
     $isStart = $req->val[1] != 0;
     if ((count($trks->list) || count($trks->todelete)) && !($req->val[5] && $trks->dontAddPrivate) && $req->val[6] != $hash . ".meta") {
         $fname = $req->val[0] . $hash . ".torrent";
         if (empty($req->val[0]) || !is_readable($fname)) {
             if (strlen($req->val[2]) && is_readable($req->val[2])) {
                 $fname = $req->val[2];
             } else {
                 $fname = null;
             }
         }
         if ($fname) {
             $torrent = new Torrent($fname);
             if (!$torrent->errors()) {
                 $needToProcessed = true;
                 $lst = $torrent->announce_list();
                 if (!$lst) {
                     if (count($trks->list)) {
                         if ($torrent->announce()) {
                             $torrent->announce_list($trks->addToBegin ? array_merge($trks->list, array(array($torrent->announce()))) : array_merge(array(array($torrent->announce())), $trks->list));
                         } else {
                             $torrent->announce($trks->list[0][0]);
                             $torrent->announce_list($trks->list);
                         }
                     } else {
                         $needToProcessed = false;
                     }
                 } else {
                     $addition = $trks->list;
                     foreach ($lst as $group) {
                         foreach ($group as $tracker) {