예제 #1
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';
 }
예제 #2
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 '';
 }
예제 #3
0
파일: Add.php 프로젝트: sinfocol/gwf3
 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);
 }