public static function mainSearch($user_id, $tracker, $user)
 {
     $user = iconv("utf-8", "windows-1251", $user);
     $page = tfileSearch::getSearchPage($user);
     if (preg_match_all('/<td class=\\"f\\">\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t(.*)\\n\\t\\t\\t\\t<\\/td>/', $page, $section)) {
         for ($i = 0; $i < count($section[1]); $i++) {
             preg_match_all('/<a href=\\"viewforum\\.php\\?f=\\d{1,9}\\">(.*)<\\/a>/U', $section[1][$i], $sections);
             $sectionStr = '';
             for ($x = 0; $x < count($sections[1]); $x++) {
                 $sectionStr .= $sections[1][$x] . ', ';
             }
             $sectionStr = substr($sectionStr, 0, -2);
             $sectionArr[] = $sectionStr;
         }
     }
     preg_match_all('/<a href=\\"viewtopic\\.php\\?t=(\\d{1,9})\\">(.*)<\\/a>/U', $page, $threme);
     if (!empty($threme)) {
         for ($i = 0; $i < count($threme[1]); $i++) {
             Database::addThremeToBuffer($user_id, $sectionArr[$i], $threme[1][$i], $threme[2][$i], $tracker);
         }
     }
     $toDownload = Database::takeToDownload($tracker);
     if (count($toDownload) > 0) {
         for ($i = 0; $i < count($toDownload); $i++) {
             //получаем страницу для парсинга
             $page = tfile::getContent($toDownload[$i]['threme_id']);
             //сохраняем торрент в файл
             $torrent_id = tfile::findId($page);
             if (is_string($torrent_id)) {
                 if (Database::getSetting('download')) {
                     $torrent = tfile::getTorrent($torrent_id);
                     $client = ClientAdapterFactory::getStorage('file');
                     $client->store($torrent, $toDownload[$i]['id'], $tracker, $toDownload[$i]['threme'], $toDownload[$i]['threme_id'], time());
                 }
                 //обновляем время регистрации торрента в базе
                 Database::setDownloaded($toDownload[$i]['id']);
                 //отправляем уведомлении о новом торренте
                 $message = $toDownload[$i]['threme'] . ' добавлена для скачивания.';
                 $date = date('d M Y H:i');
                 Notification::sendNotification('notification', $date, $tracker, $message);
             } else {
                 //устанавливаем варнинг
                 if (tfile::$warning == NULL) {
                     tfile::$warning = TRUE;
                     Errors::setWarnings($tracker, 'not_available');
                 }
                 //останавливаем процесс выполнения, т.к. не может работать без кук
                 tfile::$exucution = FALSE;
             }
         }
     }
 }
 public static function mainSearch($user_id, $tracker, $user)
 {
     $cookie = Database::getCookie($tracker);
     if (nnmclub::checkCookie($cookie)) {
         nnmclub::$sess_cookie = $cookie;
         //запускам процесс выполнения
         nnmclub::$exucution = TRUE;
     } else {
         nnmclub::getCookie($tracker);
     }
     if (nnmclub::$exucution) {
         $user = iconv("utf-8", "windows-1251", $user);
         $page = nnmclubSearch::getSearchPage($user, nnmclub::$sess_cookie);
         preg_match_all('/<a class=\\"gen\\" href=\\"tracker\\.php\\?f=\\d{3,9}\\">(.*)<\\/a>/', $page, $section);
         preg_match_all('/<a class=\\"(genmed|leechmed|seedmed) (topicpremod|topictitle)\\" href=\\"viewtopic\\.php\\?t=(\\d{3,9})\\"><b>(.*)<\\/b><\\/a>/', $page, $threme);
         for ($i = 0; $i < count($threme[1]); $i++) {
             Database::addThremeToBuffer($user_id, $section[1][$i], $threme[3][$i], $threme[4][$i], $tracker);
         }
         $toDownload = Database::takeToDownload($tracker);
         if (count($toDownload) > 0) {
             for ($i = 0; $i < count($toDownload); $i++) {
                 nnmclub::$page = nnmclub::getContent($toDownload[$i]['threme_id'], nnmclub::$sess_cookie);
                 if (!empty(nnmclub::$page)) {
                     //находим имя торрента для скачивания
                     if (preg_match("/download\\.php\\?id=(\\d{2,8})/", nnmclub::$page, $link)) {
                         //сохраняем торрент в файл
                         $torrent_id = $link[1];
                         if (Database::getSetting('download')) {
                             $torrent = nnmclub::getTorrent($torrent_id, nnmclub::$sess_cookie);
                             $client = ClientAdapterFactory::getStorage('file');
                             $client->store($torrent, $toDownload[$i]['threme_id'], $tracker, $toDownload[$i]['threme'], $torrent_id, time());
                         }
                         //обновляем время регистрации торрента в базе
                         Database::setDownloaded($toDownload[$i]['id']);
                         //отправляем уведомлении о новом торренте
                         $message = $toDownload[$i]['threme'] . ' добавлена для скачивания.';
                         $date = date('d M Y H:i');
                         Notification::sendNotification('notification', $date, $tracker, $message);
                     }
                 }
             }
         }
     }
 }
 public static function mainSearch($user_id, $tracker, $user)
 {
     $cookie = Database::getCookie($tracker);
     if (rutracker::checkCookie($cookie)) {
         rutracker::$sess_cookie = $cookie;
         //запускам процесс выполнения
         rutracker::$exucution = TRUE;
     } else {
         rutracker::getCookie($tracker);
     }
     if (rutracker::$exucution) {
         $user = iconv("utf-8", "windows-1251", $user);
         $page = rutrackerSearch::getSearchPage($user, rutracker::$sess_cookie);
         preg_match_all('/<a class=\\"gen f\\" href=\\"tracker\\.php\\?f=\\d{1,9}\\">(.*)<\\/a>/', $page, $section);
         preg_match_all('/<a data-topic_id=\\"\\d{3,9}\\" class=\\"med tLink hl-tags bold\\" href=\\"\\.\\/viewtopic.php\\?t=(\\d{3,9})\\">(.*)<\\/a>/', $page, $threme);
         for ($i = 0; $i < count($threme[1]); $i++) {
             Database::addThremeToBuffer($user_id, $section[1][$i], $threme[1][$i], $threme[2][$i], $tracker);
         }
         $toDownload = Database::takeToDownload($tracker);
         if (count($toDownload) > 0) {
             for ($i = 0; $i < count($toDownload); $i++) {
                 if (Database::getSetting('download')) {
                     //сохраняем торрент в файл
                     $torrent = rutracker::getTorrent($toDownload[$i]['threme_id'], rutracker::$sess_cookie);
                     $client = ClientAdapterFactory::getStorage('file');
                     $client->store($torrent, $id, $tracker, $name, $id, time());
                 }
                 //обновляем время регистрации торрента в базе
                 Database::setDownloaded($toDownload[$i]['id']);
                 //отправляем уведомлении о новом торренте
                 $message = $toDownload[$i]['threme'] . ' добавлена для скачивания.';
                 $date = date('d M Y H:i');
                 Notification::sendNotification('notification', $date, $tracker, $message);
             }
         }
     }
 }