public static function setWarnings($tracker, $warning) { $date = date('Y-m-d H:i:s'); Database::setWarnings($date, $tracker, $warning); $countErrors = Database::getWarningsCount($tracker); if ($countErrors == 1) { Notification::sendNotification('warning', $date, $tracker, $message); } }
public static function findWarning() { $trackersArray = Database::getTrackersList(); foreach ($trackersArray as $tracker) { $warningsCount = Database::getWarningsCount($tracker); if ($warningsCount == 1) { $warningsArray = Database::getWarnings($tracker); Notification::sendNotification('warning', $warningsArray['time'], $tracker, $warningsArray['reason']); } } }
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); } } } }
public static function main($id, $tracker, $name, $torrent_id, $timestamp) { $cookie = Database::getCookie($tracker); if (rutracker::checkCookie($cookie)) { rutracker::$sess_cookie = $cookie; //запускам процесс выполнения rutracker::$exucution = TRUE; } else { rutracker::getCookie($tracker); } if (rutracker::$exucution) { //получаем страницу для парсинга $page = rutracker::getContent($torrent_id, rutracker::$sess_cookie); if (!empty($page)) { //ищем на странице дату регистрации торрента if (preg_match("/<span title=\"Когда зарегистрирован\">\\[ (.+) \\]<\\/span>/", $page, $array)) { //проверяем удалось ли получить дату со страницы if (isset($array[1])) { //если дата не равна ничему if (!empty($array[1])) { //сбрасываем варнинг Database::clearWarnings($tracker); //приводим дату к общему виду $date = rutracker::dateStringToNum($array[1]); $date_str = $array[1]; //если даты не совпадают, перекачиваем торрент if ($date != $timestamp) { if (Database::getSetting('download')) { //сохраняем торрент в файл $torrent = rutracker::getTorrent($torrent_id, rutracker::$sess_cookie); $client = ClientAdapterFactory::getStorage('file'); $client->store($torrent, $id, $tracker, $name, $torrent_id, $timestamp); } //обновляем время регистрации торрента в базе Database::setNewDate($id, $date); //отправляем уведомлении о новом торренте $message = $name . ' обновлён.'; Notification::sendNotification('notification', rutracker::dateNumToString($date_str), $tracker, $message); } } else { //устанавливаем варнинг if (rutracker::$warning == NULL) { rutracker::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук rutracker::$exucution = FALSE; } } else { //устанавливаем варнинг if (rutracker::$warning == NULL) { rutracker::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук rutracker::$exucution = FALSE; } } else { //устанавливаем варнинг if (rutracker::$warning == NULL) { rutracker::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук rutracker::$exucution = FALSE; } } else { //устанавливаем варнинг if (rutracker::$warning == NULL) { rutracker::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук rutracker::$exucution = FALSE; } } }
public static function main($id, $tracker, $name, $hd, $ep, $timestamp) { //проверяем небыло ли до этого уже ошибок if (empty(lostfilm::$exucution) || lostfilm::$exucution) { //проверяем получена ли уже кука if (empty(lostfilm::$sess_cookie)) { $cookie = Database::getCookie($tracker); if (lostfilm::checkCookie($cookie)) { lostfilm::$sess_cookie = $cookie; //запускам процесс выполнения lostfilm::$exucution = TRUE; } else { lostfilm::getCookie($tracker); } } //проверяем получена ли уже RSS лента if (!lostfilm::$log_page) { if (lostfilm::$exucution) { //получаем страницу lostfilm::$page = lostfilm::getContent(); lostfilm::$page = str_replace('<?xml version="1.0" encoding="windows-1251" ?>', '<?xml version="1.0" encoding="utf-8"?>', lostfilm::$page); if (!empty(lostfilm::$page)) { //читаем xml lostfilm::$xml_page = @simplexml_load_string(lostfilm::$page); //если XML пришёл с ошибками - останавливаем выполнение, иначе - ставим флажок, что получаем страницу if (!lostfilm::$xml_page) { //устанавливаем варнинг if (lostfilm::$warning == NULL) { lostfilm::$warning = TRUE; Errors::setWarnings($tracker, 'rss_parse_false'); } //останавливаем выполнение цепочки lostfilm::$exucution = FALSE; } else { lostfilm::$log_page = TRUE; } } else { //устанавливаем варнинг if (lostfilm::$warning == NULL) { lostfilm::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем выполнение цепочки lostfilm::$exucution = FALSE; } } } //если выполнение цепочки не остановлено if (lostfilm::$exucution) { if (!empty(lostfilm::$xml_page)) { //сбрасываем варнинг Database::clearWarnings($tracker); $nodes = array(); foreach (lostfilm::$xml_page->channel->item as $item) { array_unshift($nodes, $item); } foreach ($nodes as $item) { $serial = lostfilm::analysis($name, $hd, $item); if (!empty($serial)) { $episode = substr($serial['episode'], 4, 2); $season = substr($serial['episode'], 1, 2); if (!empty($ep)) { if ($season == substr($ep, 1, 2) && $episode > substr($ep, 4, 2)) { $download = TRUE; } elseif ($season > substr($ep, 1, 2) && $episode < substr($ep, 4, 2)) { $download = TRUE; } else { $download = FALSE; } } elseif ($ep == NULL) { $download = TRUE; } else { $download = FALSE; } if ($download) { if ($hd == 1) { $amp = 'HD'; } elseif ($hd == 2) { $amp = 'MP4'; } else { $amp = NULL; } if (Database::getSetting('download')) { $torrent = lostfilm::getTorrent($serial['link'], lostfilm::$sess_cookie); $file = '[lostfilm.tv]_' . $name . '_' . $serial['episode'] . '_' . $amp . '.torrent'; //сохраняем торрент в файл $client = ClientAdapterFactory::getStorage('file'); $client->store($torrent, $id, $tracker, $name, $id, $timestamp, array('filename' => $file)); } //обновляем время регистрации торрента в базе Database::setNewDate($id, $serial['date']); //обновляем сведения о последнем эпизоде Database::setNewEpisode($id, $serial['episode']); $episode = substr($episode, 0, 1) == 0 ? substr($episode, 1, 1) : $episode; $season = substr($season, 0, 1) == 0 ? substr($season, 1, 1) : $season; //отправляем уведомлении о новом торренте $message = $name . ' ' . $amp . ' обновлён до ' . $episode . ' серии, ' . $season . ' сезона.'; Notification::sendNotification('notification', lostfilm::dateNumToString($serial['date']), $tracker, $message); } } } } } } }
/** * Check user login * @param username string Username * @param password string Password * @return bool **/ public function checkLogin($username, $password) { $this->debug->append("STA " . __METHOD__, 4); $this->debug->append("Checking login for {$username} with password {$password}", 2); if (empty($username) || empty($password)) { $this->setErrorMessage("Invalid username or password."); return false; } if (!filter_var($username, FILTER_VALIDATE_EMAIL)) { $this->debug->append("Not an e-mail address, rejecting login", 2); $this->setErrorMessage("Please login with your e-mail address"); return false; } else { $this->debug->append("Username is an e-mail: {$username}", 2); if (!($username = $this->getUserNameByEmail($username))) { $this->setErrorMessage("Invalid username or password."); return false; } } if ($this->isLocked($this->getUserId($username))) { $this->setErrorMessage('Account locked. Please Check your Email for instructions to unlock.'); return false; } if ($this->checkUserPassword($username, $password)) { $uid = $this->getUserId($username); $lastLoginTime = $this->getLastLogin($uid); $this->updateLoginTimestamp($uid); $getIPAddress = $this->getUserIp($uid); if ($getIPAddress !== $_SERVER['REMOTE_ADDR']) { $this->log->log("warn", "{$username} has logged in with a different IP, saved is [{$getIPAddress}]"); } $setIPAddress = $this->setUserIp($uid, $_SERVER['REMOTE_ADDR']); $this->createSession($username, $getIPAddress, $lastLoginTime); if ($setIPAddress) { // send a notification if success_login is active $uid = $this->getUserId($username); $notifs = new Notification(); $notifs->setDebug($this->debug); $notifs->setMysql($this->mysqli); $notifs->setSmarty($this->smarty); $notifs->setConfig($this->config); $notifs->setSetting($this->setting); $notifs->setErrorCodes($this->aErrorCodes); $ndata = $notifs->getNotificationSettings($uid); if (@$ndata['success_login'] == 1) { // seems to be active, let's send it $aDataN['username'] = $username; $aDataN['email'] = $this->getUserEmail($username); $aDataN['subject'] = 'Successful login notification'; $aDataN['LOGINIP'] = $this->getCurrentIP(); $aDataN['LOGINUSER'] = $username; $aDataN['LOGINTIME'] = date('m/d/y H:i:s'); $notifs->sendNotification($uid, 'success_login', $aDataN); } return true; } } $this->setErrorMessage("Invalid username or password"); $this->log->log('error', "Authentication failed for {$username}"); if ($id = $this->getUserId($username)) { $this->incUserFailed($id); // Check if this account should be locked if (isset($this->config['maxfailed']['login']) && $this->getUserFailed($id) >= $this->config['maxfailed']['login']) { $this->setLocked($id, 1); $this->log->log("warn", "{$username} locked due to failed logins, saved is [" . $this->getUserIp($this->getUserId($username)) . "]"); if ($token = $this->token->createToken('account_unlock', $id)) { $aData['token'] = $token; $aData['username'] = $username; $aData['email'] = $this->getUserEmail($username); $aData['subject'] = 'Account auto-locked'; $this->mail->sendMail('notifications/locked', $aData); } } } return false; }
public static function main($id, $tracker, $name, $torrent_id, $timestamp) { $cookie = Database::getCookie($tracker); if (anidub::checkCookie($cookie)) { anidub::$sess_cookie = $cookie; //запускам процесс выполнения anidub::$exucution = TRUE; } else { anidub::getCookie($tracker); } if (anidub::$exucution) { //получаем страницу для парсинга $page = anidub::getContent($torrent_id, anidub::$sess_cookie); if (!empty($page)) { //ищем на странице дату регистрации торрента if (preg_match("/<td width=\"\" class=\"heading\" valign=\"top\" align=\"right\">Добавлен<\\/td><td valign=\"top\" align=\"left\">(.*)<\\/td>/", $page, $array)) { //проверяем удалось ли получить дату со страницы if (isset($array[1])) { //если дата не равна ничему if (!empty($array[1])) { //сбрасываем варнинг Database::clearWarnings($tracker); //приводим дату к общему виду $date = $array[1]; $date_str = anidub::dateNumToString($array[1]); //если даты не совпадают, перекачиваем торрент if ($date != $timestamp) { preg_match('/<a href=\\"download\\.php\\?id=(\\d{2,6})&name=(.*)\\">/U', $page, $array); $torrent_id = $array[1]; $torrent_id_name = $array[2]; if (Database::getSetting('download')) { //сохраняем торрент в файл $torrent = anidub::getTorrent($torrent_id, $torrent_id_name, anidub::$sess_cookie); $client = ClientAdapterFactory::getStorage('file'); $client->store($torrent, $id, $tracker, $name, $torrent_id, $timestamp); } //обновляем время регистрации торрента в базе Database::setNewDate($id, $date); //отправляем уведомлении о новом торренте $message = $name . ' обновлён.'; Notification::sendNotification('notification', $date_str, $tracker, $message); } } else { //устанавливаем варнинг if (anidub::$warning == NULL) { anidub::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук anidub::$exucution = FALSE; } } else { //устанавливаем варнинг if (anidub::$warning == NULL) { anidub::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук anidub::$exucution = FALSE; } } else { //устанавливаем варнинг if (anidub::$warning == NULL) { anidub::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук anidub::$exucution = FALSE; } } else { //устанавливаем варнинг if (anidub::$warning == NULL) { anidub::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук anidub::$exucution = FALSE; } } }
public static function work($array, $id, $tracker, $name, $torrent_id, $timestamp) { //проверяем удалось ли получить дату со страницы if (isset($array[1])) { //если дата не равна ничему if (!empty($array[1])) { //сбрасываем варнинг Database::clearWarnings($tracker); //приводим дату к общему виду $date = kinozal::dateStringToNum($array[1]); $date_str = $array[1]; //если даты не совпадают, перекачиваем торрент if ($date != $timestamp) { if (Database::getSetting('download')) { //сохраняем торрент в файл $torrent = kinozal::getTorrent($torrent_id, kinozal::$sess_cookie); if (preg_match('/<a href=\'\\/pay_mode\\.php\\#tcounter\' class=sbab>/', $torrent)) { //устанавливаем варнинг if (kinozal::$warning == NULL) { kinozal::$warning = TRUE; Errors::setWarnings($tracker, 'max_torrent'); } //останавливаем процесс выполнения kinozal::$exucution = FALSE; } else { $client = ClientAdapterFactory::getStorage('file'); $client->store($torrent, $id, $tracker, $name, $torrent_id, $timestamp); //обновляем время регистрации торрента в базе Database::setNewDate($id, $date); //отправляем уведомлении о новом торренте $message = $name . ' обновлён.'; Notification::sendNotification('notification', $date_str, $tracker, $message); } } else { //обновляем время регистрации торрента в базе Database::setNewDate($id, $date); //отправляем уведомлении о новом торренте $message = $name . ' обновлён.'; Notification::sendNotification('notification', $date_str, $tracker, $message); } } } else { //устанавливаем варнинг if (kinozal::$warning == NULL) { kinozal::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук kinozal::$exucution = FALSE; } } else { //устанавливаем варнинг if (kinozal::$warning == NULL) { kinozal::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук kinozal::$exucution = FALSE; } }
public static function main($id, $tracker, $name, $torrent_id, $timestamp) { $cookie = Database::getCookie($tracker); if (nnmclub::checkCookie($cookie)) { nnmclub::$sess_cookie = $cookie; //запускам процесс выполнения nnmclub::$exucution = TRUE; } else { nnmclub::getCookie($tracker); } if (nnmclub::$exucution) { nnmclub::$page = nnmclub::getContent($torrent_id, nnmclub::$sess_cookie); if (!empty(nnmclub::$page)) { //ищем на странице дату регистрации торрента if (preg_match("/<td class=\"genmed\"> (\\d{2}\\s\\D{6}\\s\\d{4}\\s\\d{2}:\\d{2}:\\d{2})<\\/td>/", nnmclub::$page, $array)) { //проверяем удалось ли получить дату со страницы if (isset($array[1])) { //если дата не равна ничему if (!empty($array[1])) { //находим имя торрента для скачивания if (preg_match("/download\\.php\\?id=(\\d{6,8})/", nnmclub::$page, $link)) { //сбрасываем варнинг Database::clearWarnings($tracker); //приводим дату к общему виду $date = nnmclub::dateStringToNum($array[1]); $date_str = $array[1]; //если даты не совпадают, перекачиваем торрент if ($date != $timestamp) { //сохраняем торрент в файл $torrent_id = $link[1]; if (Database::getSetting('download')) { $torrent = nnmclub::getTorrent($torrent_id, nnmclub::$sess_cookie); $client = ClientAdapterFactory::getStorage('file'); $client->store($torrent, $id, $tracker, $name, $torrent_id, $timestamp); } //обновляем время регистрации торрента в базе Database::setNewDate($id, $date); //отправляем уведомлении о новом торренте $message = $name . ' обновлён.'; Notification::sendNotification('notification', nnmclub::dateNumToString($date_str), $tracker, $message); } } else { //устанавливаем варнинг if (nnmclub::$warning == NULL) { nnmclub::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук nnmclub::$exucution = FALSE; } } else { //устанавливаем варнинг if (nnmclub::$warning == NULL) { nnmclub::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук nnmclub::$exucution = FALSE; } } else { //устанавливаем варнинг if (nnmclub::$warning == NULL) { nnmclub::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук nnmclub::$exucution = FALSE; } } else { //устанавливаем варнинг if (nnmclub::$warning == NULL) { nnmclub::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук nnmclub::$exucution = FALSE; } } else { //устанавливаем варнинг if (nnmclub::$warning == NULL) { nnmclub::$warning = TRUE; Errors::setWarnings($tracker, 'not_available'); } //останавливаем процесс выполнения, т.к. не может работать без кук nnmclub::$exucution = FALSE; } } }