예제 #1
0
 protected function action()
 {
     if ($this->isValidReferer()) {
         $mc_links = Utils_MegaCrypter::encryptLinkList(Utils_MiscTools::extractLinks(Utils_CryptTools::decryptMegaDownloaderLinks($this->request->getPostVar('links'))), ['tiny_url' => $this->request->getPostVar('tiny_url'), 'pass' => $this->request->getPostVar('pass'), 'extra_info' => $this->request->getPostVar('extra_info'), 'hide_name' => $this->request->getPostVar('hide_name'), 'expire' => $this->request->getPostVar('expire'), 'no_expire_token' => $this->request->getPostVar('no_expire_token'), 'referer' => $this->request->getPostVar('referer'), 'email' => $this->request->getPostVar('email')], $this->request->getPostVar('app_finfo'));
         if (!empty($mc_links)) {
             $this->setViewData(['links' => Utils_MiscTools::rimplode("\r\n", $mc_links), 'cols' => min([Utils_MiscTools::getMaxStringLength($mc_links), self::CRYPT_TEXTAREA_COLS]), 'tot_links' => Utils_MiscTools::rCount($mc_links)]);
         } else {
             throw new Exception(__METHOD__ . ' No links could be crypted!');
         }
     } else {
         throw new Exception_InvalidRefererException(function (Controller_DefaultController $controller) {
             $controller->redirect('/');
         });
     }
 }
예제 #2
0
 private function _actionCrypt($post_data)
 {
     if (is_array($post_data->links) && !empty($post_data->links)) {
         if (!self::MAX_LINKS_LIST || count($post_data->links) <= self::MAX_LINKS_LIST) {
             $options = [];
             $opts = ['tiny_url', 'pass', 'extra_info', 'hide_name', 'expire', 'no_expire_token', 'referer', 'email'];
             foreach ($opts as $opt) {
                 if (isset($post_data->{$opt})) {
                     $options[$opt] = $post_data->{$opt};
                 }
             }
             $data = ['links' => Utils_MegaCrypter::encryptLinkList(Utils_CryptTools::decryptMegaDownloaderLinks($post_data->links), $options, $post_data->app_finfo)];
         } else {
             throw new Exception_MegaCrypterAPIException(self::ETOOMUCHLINKS);
         }
     } else {
         throw new Exception_MegaCrypterAPIException(self::ENOLINKS);
     }
     return $data;
 }