addon.build0000644000000000000000000000001114423720134014037 0ustar adminadministrators20230501 addon.json0000644000000000000000000000462714423717742013745 0ustar adminadministrators{ "author": "Rapideo.pl", "website": "https://www.rapideo.pl", "name": "Rapideo.pl", "addon": "rapideo.pl.php", "class": "rapideopl", "hosts": [ "filefactory.com", "turbobit.net", "turb.to", "turbobyte.net", "turb.cc", "turbo.to", "turb.pw", "redtube.com", "tube8.com", "4shared.com", "mediafire.com", "hitfile.net", "hitf.to", "hil.to", "hitf.cc", "fastshare.cz", "fastshare.pl", "zippyshare.com", "1fichier.com", "tusfiles.net", "uptobox.com", "youporn.com", "pornhub.com", "pornhubpremium.com", "clicknupload.com", "clicknupload.me", "clicknupload.link", "alfafile.net", "katfile.com", "icerbox.com", "filenext.com", "isra.cloud", "isrbx.net", "israbox-music.com", "wrzucajpliki.pl", "megaup.net", "dropapk.to", "drop.download", "anonfiles.com", "ddownload.com", "ddl.to", "bayfiles.com", "mixdrop.co", "vidoza.net", "dailyuploads.net", "wplik.com", "uploadrar.com", "fastclick.to", "upstore.net", "gigapeta.com", "downloadly.net", "downloadly.ir", "uloz.to", "ulozto.sk", "ulozto.net", "zachowajto.pl", "soundcloud.com", "rapidgator.net", "rg.to", "nitroflare.com", "nitro.download", "uploadgig.com", "1dl.net", "fikper.com", "easybytez.com", "wupfile.com", "dailymotion.com", "sendspace.com", "highload.to", "embedo.co", "upstream.to", "webshare.cz", "filerice.com", "copycase.com", "egofiles.net", "hotlink.cc", "hot4share.com", "wrzucaj.pl", "sharewith.click", "uploadcloud.pro", "syncs.online" ], "domain": "rapideo.pl", "version": 231, "interface": [ "ISearch", "IVerify", "IDownload" ], "qpkg_dependencies": { "DownloadStation": "5.0.1" }, "description": { "ENG": "Official Rapideo addon for QNAP Download Station", "POL": "Oficjalna wtyczka serwisu Rapideo dla QNAP Download Station." } }rapideo.pl.php0000644000000000000000000004732514423720061014521 0ustar adminadministratorsajax = new Ajax(); $this->url = $url; $this->username = $username; $this->password = $password; $timezone = ini_get('date.timezone'); if(empty($timezone)) { date_default_timezone_set('Europe/Warsaw'); } } private function api_request($endpoint = "", $method = 'GET' , $data = array(), $conv_json = false) { if($conv_json) { $json_data = json_encode($data, JSON_PRETTY_PRINT); unset($data); $data = array($json_data); } $request = array( 'body'=>true, 'url' => $this->api_url. '/' . $endpoint, 'params' => $data, 'header'=>array('User-Agent: QNAP') ); if(strtolower($method) == 'post') $request['post'] = true; try { $this->ajax->request($request, function($request_headers , $header, $cookie, $body, $url) { $this->response = $body; }); if($this->response) { $response = json_decode($this->response , true); if(!empty($response['error']) && !empty($response['error'])) { $this->save_log($response['message'] , $response['error']); $this->reset_authtoken(); } } } catch(Exception $e) { $this->save_log($e->getMessage()); $this->send_log($e->getMessage()); } return array('response'=>$response); } /* * Search() * @param {string} $keyword * @param {integer} $limit * @param {string} $category * @return {array} SearchLink array */ public function Search($keyword, $limit, $category) { if(preg_match('/console\:\:/i' , $keyword)) { return $this->Console($keyword); } $found = array(); $search = $this->api_request($this->search_endpoint , 'post', array('authtoken'=>$this->load_authtoken(), 'keyword'=>$keyword, 'display' => $limit ,'mode'=>'qnap' ,'device'=>'qnap', 'version'=>$this->_version)); if(!empty($search['response']['search']['search_result'])) { foreach($search['response']['search']['search_result'] as $result) { try { $slink = new SearchLink(); $slink->src = ucfirst($result['hosting']); $slink->link = $this->api_url. '/' . $this->search_endpoint; $slink->name = $result['filename_long']; $slink->size = (int)$result['filesize_bytes']; $slink->enclosure_url = rawurldecode($result['url_encoded']); if(isset($result['movie']) && !empty($result['movie'])) { $slink->category = 'video'; } else { $slink->category = 'other'; } $slink->seeds = (int)$result['best']; $slink->peers = (int)$result['best']; $found[] = $slink; }catch(Exception $e) { $this->save_log($e->getMessage()); $this->send_log($e->getMessage()); } } } return $found; } /* * Verify() * @return {boolean} */ public function Verify() { global $argv; if(!empty($argv[1]) && preg_match('/console\:\:/i' , $argv[1]) && !preg_match('/account/i' , $argv[1])) return true; if(!empty($this->load_authtoken())) return true; if(empty($this->username) || empty($this->password)) { $this->save_log('Wprowadź nazwę użytkownika i hasło w ustawieniach wtyczki' , true); return false; } $return = $this->api_request( $this->login_endpoint , 'POST', array( 'login' => $this->username , 'password'=>$this->password, 'device'=>'qnap', 'version'=>$this->_version ) ); if(!empty($return['response']['logged']) && !empty($return['response']['authtoken'])) { $this->save_log('Zalogowano w serwisie'); $this->save_authtoken($return['response']['authtoken']); return true; } $this->reset_authtoken(); return false; } /* * GetDownloadLink() * @return {mixed} DownloadLink object or DownloadLink array */ public function GetDownloadLink() { $check_file = $this->api_request($this->check_file_endpoint, 'post', array('authtoken'=>$this->load_authtoken(), 'url'=>$this->url, 'device'=>'qnap', 'version'=>$this->_version)); if(!empty($check_file['response']['file']['filename']) && !empty($check_file['response']['file']['filesize']) && !empty($check_file['response']['file']['hash'])) { $get_download_url = $this->api_request($this->download_file_endpoint, 'post' , array('authtoken'=>$this->load_authtoken(), 'hash'=>$check_file['response']['file']['hash'] , 'mode'=>'qnap', 'device'=>'qnap', 'version'=>$this->_version)); if(!empty($get_download_url['response']['file']['url'])) { $this->save_log('Rozpoczynam pobieranie pliku ' . $check_file['response']['file']['filename_full']); if(function_exists('mb_pathinfo')) { $path_info = mb_pathinfo($get_download_url['response']['file']['url']); } else { $path_info = pathinfo($get_download_url['response']['file']['url']); } //return new DownloadLink($get_download_url['response']['file']['url']); $dlink = new DownloadLink(); try { $dlink->url = $get_download_url['response']['file']['url']; $dlink->filename = $path_info["basename"]; $dlink->base_name = $path_info["filename"]; $dlink->ext_name = ".". $path_info["extension"]; $this->save_log('Tworze obiekt pobierania'); return $dlink; } catch(Exception $e) { $this->save_log($e->getMessage()); } } else { $this->save_log($get_download_url['response']['file']['message'] , $get_download_url['response']['file']['error']); $this->send_log($get_download_url); } } else { $this->save_log($check_file['response']['file']['message'], $check_file['response']['file']['error']); $this->send_log($check_file); } } private function save_log($message = "" , $error = null) { if(is_array($message)) return; if(!is_writable($this->_tmp_path)) return; $date = new DateTime(); try { clearstatcache(); if(file_exists($this->log_file) && filesize($this->log_file) > (1*1024*1024)) { unlink($this->log_file); } $log['message'] = $message; if(!empty($error)) $log['message_type'] = 'error'; else $log['message_type'] = 'notice'; $log['logtime'] = $date; $handle = @fopen($this->log_file , 'a'); @fwrite($handle, json_encode($log)); @fwrite($handle, "\r\n\r\n"); @fclose($handle); } catch(Exception $e) { $fp = @fopen($this->log_file , 'a'); @fwrite($fp, json_encode(array('message'=>$e->getMessage() , 'logtime'=>$date))); @fwrite($fp, "\r\n\r\n"); @fclose($fp); } } private function send_log($log = "") { $this->api_request($this->log_endpoint , 'post', array('log'=>$log, 'authtoken'=>$this->load_authtoken() , 'device'=>'qnap' , 'version'=>$this->_version) , true); } /* * RefreshDownloadLink() * @param {DownloadLink} $dlink * @return {DownloadLink} DownloadLink object */ public function RefreshDownloadLink($dlink) { return $dlink; } private function reset_authtoken() { if(file_exists($this->authtoken_file)) { unlink($this->authtoken_file); } return true; } private function load_authtoken() { if(!file_exists($this->authtoken_file)) return; if(filesize($this->authtoken_file) == 0) return; $handle = @fopen($this->authtoken_file , 'r'); $authtoken = @fread($handle, filesize($this->authtoken_file)); @fclose($handle); if(!empty($authtoken)) return $authtoken; } private function save_authtoken( $authtoken = "") { if(!is_writable($this->_tmp_path)) return; $handle = @fopen($this->authtoken_file , 'w'); @fwrite($handle, $authtoken); @fclose($handle); } private function Logs() { if(!is_writable($this->_tmp_path)) return false; $date = new DateTime(); if(!file_exists($this->log_file)) { try { $slink = new SearchLink(); $slink->src = 'Log'; $slink->name = 'Brak logów'; $slink->size = 0; $slink->category = 'log'; $slink->time = $date; $slink->seeds = 0; $slink->peers = 0; $found[] = $slink; } catch(Exception $e) { } return $found; } $found = array(); $handle = @fopen($this->log_file, 'r'); $readlogs = @fread($handle, filesize($this->log_file)); @fclose($handle); $logs = explode("\r\n\r\n", $readlogs); foreach($logs as $log) { if(empty($log)) continue; try { $decode_log = json_decode($log, true); if(isset($decode_log['message_type']) && $decode_log['message_type'] == 'error') { $message = "Błąd: " . $decode_log['message']; } else { $message = $decode_log['message']; } $logtime = new DateTime($decode_log['logtime']['date']); $slink = new SearchLink(); $slink->src = 'Log'; $slink->name = $message; $slink->enclosure_url = $message; $slink->time = $logtime; $slink->size = 0; $slink->category = 'log'; $slink->seeds = 0; $slink->peers = 0; $found[] = $slink; } catch(Exception $e) { $this->save_log($e->getMessage()); } } return $found; } private function LogsClear() { if(file_exists($this->log_file)) { unlink($this->log_file); } return $this->Logs(); } private function ConsoleMenu() { $commands = array(); $options = array( 'console::help'=> 'Pomoc', 'console::account'=> 'Informacja o koncie', 'console::logs'=> 'Wyświetl logi', 'console::logs_clear'=> 'Skasuj logi', 'console::hosters'=> 'Obsługiwane serwisy hostingowe', 'console::version'=> 'Wersja wtyczki', 'console::update'=> 'Aktualizacja wtyczki' ); foreach($options as $command => $value) { $commands[] = $this->displayConsole($command .' - ' . $value)[0]; } return $commands; } private function Console( $option = "") { switch($option) { case "console::help": return $this->ConsoleMenu(); break; case "console::account": return $this->accountInfo(); break; case "console::logs": return $this->Logs(); break; case "console::logs_clear" : return $this->LogsClear(); break; case "console::hosters": return $this->displayHosters(); break; case "console::version" : $current_version = $this->CheckVersion(); return $this->displayConsole('Wersja wtyczki: ' . $current_version); break; case "console::update" : return $this->Update(); break; case "console::check" : return $this->CheckAddon(); break; default: return $this->displayConsole('Nieprawidłowa opcja konsoli'); break; } } private function CheckAddon() { $checks = array(); if(is_writable($this->_tmp_path)) { $checks[] = $this->displayConsole('Folder tymczasowy posiada uprawnienia zapisu')[0]; if(file_exists($this->log_file)) { $checks[] = $this->displayConsole('Plik logów prawidłowy')[0]; } if(file_exists($this->authtoken_file)) { $checks[] = $this->displayConsole('Plik autoryzacji prawidłowy')[0]; } } else { $checks[] = $this->displayConsole('Folder tymczasowy nie posiada uprawnień zapisu')[0]; } return $checks; } private function CheckVersion() { if(file_exists('addon.json')) { $addon_json = json_decode(file_get_contents('addon.json') , true); return $addon_json['version']; } } private function GetHosters() { if(file_exists('addon.json')) { $addon_json = json_decode(file_get_contents('addon.json') , true); return $addon_json['hosts']; } } private function displayHosters() { $hosters = array(); $gethosters = $this->GetHosters(); foreach($gethosters as $hoster) { $hosters[] = $this->displayConsole($hoster)[0]; } return $hosters; } private function displayConsole($title = "") { $console = new SearchLink(); $console->src = 'Console'; $console->category = 'Console'; $console->name = $title; return array($console); } private function Update() { if(!is_writable($this->_tmp_path)) { return $this->displayConsole('Folder tymczasowy nie posiada uprawnień zapisu - nie można wykonać aktualizacji'); } $this->ds_addon = str_replace(array("rapideo.pl", "addons") , array("", ""), dirname(__dir__))."/ds-addon"; if(file_exists($this->ds_addon)) { $current_version = (int)$this->CheckVersion(); $fetch_update = $this->api_request($this->update_endpoint , 'post' , array('device'=>'qnap','version'=>$this->_version)); $remote_version = isset($fetch_update['response']['version']) ? (int)$fetch_update['response']['version'] : 0; $remote_url = isset($fetch_update['response']['url']) ? $fetch_update['response']['url'] : ''; $remote_size = isset($fetch_update['response']['size']) ? $fetch_update['response']['size'] : 0; if(empty($current_version) || empty($remote_version) || empty($remote_url)) { return $this->displayConsole('Nie udało się sprawdzić aktualizacji - ' . $remote_version); } if(is_numeric($current_version) && is_numeric($remote_version)) { if($current_version == $remote_version) { return $this->displayConsole('Brak dostępnej aktualizacji (wersja wtyczki: ' . $current_version.', wersja aktualna: ' . $remote_version.')'); } else if($remote_version > $current_version) { try { $update = file_get_contents($remote_url); file_put_contents($this->update_path, $update); } catch(Exception $e) { return $this->displayConsole('Nie udało się pobrać aktualizacji'); } if(file_exists($this->update_path) && filesize($this->update_path) == $remote_size) { exec($this->ds_addon . ' -i ' . $this->update_path . ' 1' , $result); unlink($this->update_path); return $this->displayConsole('Wtyczka została zaktualizowana'); } else { return $this->displayConsole('Aktualizacja nie powiodła się'); } } } } else { return $this->displayConsole('Aplikacja aktualizacji nie istnieje - nie można wykonać aktualizacji'); } } private function accountInfo() { $account = array(); $accountInfo = $this->api_request($this->account_endpoint , 'post' , array('authtoken'=>$this->load_authtoken(), 'device'=>'qnap' , 'version'=>$this->_version)); if(!empty($accountInfo['response']['account'])) { $login = isset($accountInfo['response']['account']['login']) ? $accountInfo['response']['account']['login'] : ''; $email = isset($accountInfo['response']['account']['email']) ? $accountInfo['response']['account']['email'] : ''; $transfer_left_gb = isset($accountInfo['response']['account']['transfer_left_gb']) ? $accountInfo['response']['account']['transfer_left_gb'] : 0; $premium_active = isset($accountInfo['response']['account']['premium_active']) ? $accountInfo['response']['account']['premium_active'] : 0; $premium_expire_date = isset($accountInfo['response']['account']['premium_expire_date']) ? $accountInfo['response']['account']['premium_expire_date'] : ''; $premium_left_gb = isset($accountInfo['response']['account']['premium_left_gb']) ? $accountInfo['response']['account']['premium_left_gb'] : 0; $account[] = $this->displayConsole('Login: ' . $login)[0]; $account[] = $this->displayConsole('E-mail: ' . $email)[0]; if(!empty($premium_active)) { $account[] = $this->displayConsole('Ważność konta Premium: ' . $premium_expire_date)[0]; $account[] = $this->displayConsole('Transfer konta Premium: ' . $premium_left_gb . ' GB')[0]; $account[] = $this->displayConsole('Transfer dodatkowy: ' . $transfer_left_gb . ' GB')[0]; } else { $account[] = $this->displayConsole('Transfer standardowy: ' . $transfer_left_gb . ' GB')[0]; } return $account; } } } ?>addon.key0000666000000000000000000000042014423672405013547 0ustar adminadministrators-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0OI2Rw0GP6p+rBhz9DZw8Z1B0 hVn2u4qtq5ECDEUJQI5tuszl38ngNss2d90ScGIcgcigPJpDQpEl6PeyycKgclu7 sQG5n3+Kji/mcOUBgv4G+ajvM1XI/6/a5lIvBLPrS7iIW23bgZj5MxaSQG+PnNYr G7wtVcnep9UHK8AdMQIDAQAB -----END PUBLIC KEY----- V8rXn8['Ћ/CTp#'OX*R26 D%O\R&u]VړM N#yUT~2buKb%}#}