Exemplo n.º 1
0
 private function onDelete(GWF_Download $dl)
 {
     if (false === $dl->getVotes()->onDelete()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $dl->delete()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_deleted');
 }
Exemplo n.º 2
0
 public static function checkUser(Module_Download $module, GWF_Download $dl, $user)
 {
     if ($user === false) {
         return false;
     }
     $id = $dl->getID();
     $uid = $user->getID();
     $now = GWF_Time::getDate(GWF_Date::LEN_SECOND);
     return self::table(__CLASS__)->selectVar('1', "dlt_dlid={$id} AND dlt_uid={$uid} AND (dlt_expires='' OR dlt_expires>'{$now}')") === '1';
 }
Exemplo n.º 3
0
 private function templateList($user)
 {
     $dl = GDO::table('GWF_Download');
     $permquery = GWF_Download::getPermissionQueryList($user);
     $ipp = $this->module->cfgIPP();
     $nItems = $dl->countRows($permquery);
     $nPages = GWF_PageMenu::getPagecount($ipp, $nItems);
     $page = Common::clamp(intval(Common::getGet('page', 1)), 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $by = Common::getGet('by', 'dl_id');
     $dir = Common::getGet('dir', 'ASC');
     $orderby = $dl->getMultiOrderby($by, $dir);
     $tVars = array('href_add' => $this->module->hrefAdd(), 'may_upload' => $this->module->mayUpload($user), 'sort_url' => GWF_WEB_ROOT . 'downloads/by/%BY%/%DIR%/page-1', 'downloads' => $dl->selectObjects('*', $permquery, $orderby, $ipp, $from), 'page_menu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . sprintf('downloads/by/%s/%s/page-%%PAGE%%', urlencode($by), urlencode($dir))));
     return $this->module->templatePHP('list.php', $tVars);
 }
Exemplo n.º 4
0
 public static function hook(GWF_User $user, GWF_Download $dl)
 {
     $dlid = $dl->getID();
     if ($dlid > 2) {
         return true;
     }
     $demo = $dlid == 2;
     if (false === ($row = BAIM_MC::generate($user, $demo))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $mime = $dl->getVar('dl_mime');
     $path = $dl->getDownloadPath();
     $temp_path = GWF_PATH . 'extra/temp/baim/' . $user->getVar('user_id') . '_' . $row->getToken();
     if (!Common::isFile($path)) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', htmlspecialchars($path));
     }
     if (Common::isFile($temp_path)) {
         if (false === unlink($temp_path)) {
             return GWF_HTML::err('ERR_WRITE_FILE', array($temp_path));
         }
     }
     if ($mime === 'application/zip') {
         if (false === copy($path, $temp_path)) {
             return GWF_HTML::err('ERR_WRITE_FILE', array($temp_path));
         }
         $have_zip = true;
     } else {
         $have_zip = false;
     }
     $zip = new GWF_ZipArchive();
     if (false === $zip->open($temp_path, GWF_ZipArchive::CREATE)) {
         return GWF_HTML::err('ERR_WRITE_FILE', array($temp_path));
     }
     if ($have_zip === false) {
         $filename = $dl->getVar('dl_filename');
         $zip->addFile($path, $filename);
         $dl->setCustomDownloadName($filename . '.zip');
     }
     if (false === $zip->addFromString('B.AiM/key.dat', self::getIniContent($row))) {
         return GWF_HTML::error('BAIM', 'The download slot is not a zip archive!');
     }
     $zip->addFromString('B.AiM/readme.txt', self::getReadmeContent($row));
     $zip->addFromString('B.AiM/release_notes.txt', self::getReleaseNotes($row));
     $zip->close();
     $dl->setCustomDownloadPath($temp_path);
     return '';
 }
Exemplo n.º 5
0
 public function mayDownload($user, GWF_Download $download)
 {
     if ($user === false) {
         # Guest
         if (!$download->isEnabled()) {
             return $this->error('err_disabled');
         }
         if ($download->isAdult()) {
             return $this->error('err_adult');
         }
         if (!$download->isOptionEnabled(GWF_Download::GUEST_DOWNLOAD)) {
             return $this->error('err_guest');
         }
         if (!$this->cfgAnonDown()) {
             return $this->error('err_guest');
         }
         return false;
     } else {
         $user instanceof GWF_User;
         # Admin
         if ($user->isAdmin()) {
             return false;
         }
         if (!$download->isEnabled()) {
             return $this->error('err_disabled');
         }
         if ($download->isAdult() && !$user->wantsAdult()) {
             return $this->error('err_adult');
         }
         # Level
         if ($download->getVar('dl_level') > $user->getVar('user_level')) {
             return $this->error('err_level', $download->getVar('dl_level'));
         }
         # Group
         $gid = $download->getVar('dl_gid');
         if (false === ($group = GWF_Group::getByID($gid))) {
         } elseif ($gid > 0 && !$user->isInGroupID($download->getVar('dl_gid'))) {
             return $this->error('err_group', $group->display('group_name'));
         }
         return false;
     }
 }
Exemplo n.º 6
0
 private function sendModMailB(GWF_Download $dl, GWF_User $uploader, GWF_User $staff)
 {
     if ('' === ($rec = $staff->getValidMail())) {
         return;
     }
     $mail = new GWF_Mail();
     $mail->setSender(GWF_BOT_EMAIL);
     $mail->setReceiver($rec);
     $mail->setSubject($this->module->langUser($staff, 'mod_mail_subj'));
     $token = $dl->getHashcode();
     $dlid = $dl->getID();
     $url1 = "index.php?mo=Download&me=Moderate&token={$token}&dlid={$dlid}&action=download";
     $url2 = "index.php?mo=Download&me=Moderate&token={$token}&dlid={$dlid}&action=allow";
     $url3 = "index.php?mo=Download&me=Moderate&token={$token}&dlid={$dlid}&action=delete";
     $args = array($staff->displayUsername(), $uploader->displayUsername(), $dl->display('dl_filename'), $dl->display('dl_realname'), $dl->display('dl_mime'), $dl->getFilesize(), $dl->display('dl_descr'), Common::getAbsoluteURL($url1, true), Common::getAbsoluteURL($url2, true), Common::getAbsoluteURL($url3, true));
     $mail->setBody($this->module->langUser($staff, 'mod_mail_body', $args));
     $mail->sendToUser($staff);
 }
Exemplo n.º 7
0
 private function onOrder(GWF_Download $dl)
 {
     // Check for Payment, as it`s not a required dependency.
     if (false === ($mod_pay = GWF_Module::getModule('Payment'))) {
         return GWF_HTML::err('ERR_MODULE_MISSING', array('Payment'));
     }
     $user = GWF_User::getStaticOrGuest();
     $paysite = Common::getPost('paysite', 'xx');
     $dl->setVar('your_token', GWF_DownloadToken::generateToken());
     return Module_Payment::displayOrder2S($this->module, $dl, $user, $paysite);
 }