Exemplo n.º 1
0
 function approve($id)
 {
     if ($_POST) {
         $rs = new Download($id);
         $rs->from_array($_POST);
         $rs->save();
     }
 }
Exemplo n.º 2
0
 /**
  * Process partial/complete file download
  * @param array $args - array containing session id as an element with a key es_id 
  */
 public static function serve($args)
 {
     $session = new Db\Session();
     $session->load(@$args['es_id']);
     self::preDispatchGuest();
     $filename = $session->getGenesisUrl() ? $session->getGenesisUrl() : '';
     $download = new Download($session->getOwner(), $filename);
     $download->sendResponse();
 }
Exemplo n.º 3
0
 function download($id)
 {
     $rs = new Download($id);
     $rs->counter();
     $this->load->helper('download');
     $data = file_get_contents(urldecode($rs->files));
     $name = basename($rs->files);
     force_download($name, $data);
 }
Exemplo n.º 4
0
 public function save($runValidation = true, $attributes = NULL)
 {
     $a = parent::save($runValidation, $attributes);
     if ($this->public && $this->hash == '') {
         $download = new Download();
         $download->file_id = $this->id;
         $download->company_id = Yii::app()->user->Company;
         $this->hash = $download->id = md5(mt_rand());
         $download->save();
     }
     return $a;
 }
 /**
  * Process partial/complete file download
  * @param array $args - array containing session id as an element with a key es_id 
  */
 public static function serve($args)
 {
     $session = new Db_Session();
     $sessionData = $session->load(@$args['es_id'])->getData();
     $file = new File(@$sessionData['file_id']);
     if (!$file->isPublicShare()) {
         self::preDispatch(false);
     } else {
         self::preDispatchGuest(false);
     }
     $filename = isset($sessionData['genesis_url']) ? $sessionData['genesis_url'] : '';
     $download = new Download($sessionData['owner'], $filename);
     $download->sendResponse();
 }
Exemplo n.º 6
0
 public function __construct()
 {
     // 		$this->product	 = '';
     // 		$this->id		 = '';
     // 		$this->cpid		 = '';
     // 		$this->author	 = '';
     // 		$this->cyid		 = '';
     // 		$this->meid		 = '';
     parent::__construct();
     $this->name = '';
     $this->userid = '';
     $this->order = '';
     $this->count = 1;
     $this->transid = '';
     $this->appid = '';
     $this->waresid = '';
     $this->feetype = 0;
     $this->money = 0;
     $this->result = 0;
     $this->transtype = 0;
     $this->transtime = '';
     $this->status = 0;
     $this->ruleid = '';
     $this->score = 0;
     $this->isscore = 0;
     $this->channel = 'yx';
 }
 /**
  * Display customer profile
  *
  * @param $profile
  * @return Response
  */
 public function show($profile)
 {
     $p = User::where('profile_url', '=', $profile)->where('approved', '=', '0')->first();
     $page = Page::where('title', '=', 'faq-customer')->first();
     $follow = Follow::where('user', $p->id)->where('hub', '=', 0)->get();
     $follow_hub = Follow::where('user', $p->id)->where('artist', '=', 0)->get();
     $wall = new \Illuminate\Database\Eloquent\Collection();
     $events = new \Illuminate\Database\Eloquent\Collection();
     $comments = Comment::where('user', '=', $p->id)->orderBy('created_at', 'desc')->get();
     $hidden = unserialize(Cookie::get('hide'));
     //dd( Cookie::get('hide') );
     if (count($follow) > 0) {
         foreach ($follow as $f) {
             $s = Song::where('artist', '=', $f->artist)->where('completed', '=', '1')->get();
             $e = ArtistEvent::where('artist', '=', $f->artist)->where('date', '>', \Carbon\Carbon::now())->get();
             $wall = $wall->merge($s);
             $events = $events->merge($e);
         }
     }
     if (count($follow_hub) > 0) {
         foreach ($follow_hub as $h) {
             $hub = Hub::where('id', '=', $h->hub)->first();
             if (!is_null($hub)) {
                 $artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get();
                 $artists_list = [];
                 $songs = [];
                 $events = [];
                 foreach ($artists as $a) {
                     $artists_list[] = $a->id;
                 }
                 if (count($artists_list) > 0) {
                     $songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get();
                     $events = ArtistEvent::whereIn('artist', $artists_list)->get();
                 }
                 $news = News::where('hub', '=', $hub->id)->take(3)->get();
                 $wall = $wall->merge($songs);
                 $events = $events->merge($events);
             }
         }
     }
     $purchased = Purchase::where('customer', '=', $p->id)->get();
     foreach ($purchased as $pp) {
         $song_purchased = Song::withTrashed()->where('id', '=', $pp->song)->get();
         $download = Download::where('customer', '=', $p->id)->where('song', '=', $pp->song)->first();
         $song_purchased[0]->purchased = true;
         if (isset($download)) {
             $song_purchased[0]->link = $download->url;
         }
         $wall = $wall->merge($song_purchased);
     }
     $wall->sortByDesc('created_at');
     if (!isset($news)) {
         $news = null;
     }
     return View::make('customer.profile-new', ['profile' => $p, 'wall' => $wall, 'page' => $page, 'events' => $events, 'comments' => $comments, 'hidden' => $hidden, 'news' => $news]);
 }
Exemplo n.º 8
0
 public function add_download($username)
 {
     if (Auth::user() && Auth::user()->role == 'administrator') {
         $user = User::where('username', '=', $username)->first();
         $downloads = Download::lists('dname', 'did');
         // $download = UserUpload::where('fid', '=', $any)->first();
         $adds = Add::where('did_id', '=', Download::lists('did'));
         return View::make('users.add_download')->with('user', $user)->with('downloads', $downloads)->with('adds', $adds);
     }
     return Redirect::to('login');
 }
Exemplo n.º 9
0
 public function action_index()
 {
     $path = Download::decode_path($this->request->param('path'));
     if (!file_exists($path)) {
         if (IS_BACKEND) {
             throw new HTTP_Exception_404('File :file not found', array(':file' => $path));
         } else {
             Model_Page_Front::not_found('File :file not found', array(':file' => $path));
         }
     }
     $this->responses->send_file($path);
 }
Exemplo n.º 10
0
 /**
  * Liefert unter zu Hilfenahme der Methode getContent() den Inhalt des Downloadbereiches in HTML
  * @see getTableRows()
  * @param object $template eine Referenz auf das Template
  * @return string den Download-Bereich als HTML-Repräsentation
  */
 function getContent(&$template)
 {
     $files = array("posemuckel-client-win32-0.4.exe" => "DOWNLOAD_CLIENT_WININST", "posemuckel-client-bin-win32-0.4.zip" => "DOWNLOAD_CLIENT_WIN", "posemuckel-client-bin-linux-0.4.tgz" => "DOWNLOAD_CLIENT_LIN", "posemuckel-sources-0.4.zip" => "DOWNLOAD_SOURCE");
     $filename = $_SESSION['translate']->it('FILE');
     $filesize = $_SESSION['translate']->it('FILE_SIZE');
     $filedate = $_SESSION['translate']->it('FILE_DATE');
     $filedesc = $_SESSION['translate']->it('FILE_DESCRIPTION');
     $html = "<table width=\"100%\">\n\t";
     $html .= "<tr>\n\t";
     $html .= "<th>{$filename}</th><th>{$filedesc}</th><th>{$filesize}</th><th>{$filedate}</th>\n\t";
     $html .= "</tr>\n\t";
     $html .= Download::getTableRows($files);
     $html .= "</table>\n\t";
     return $html;
 }
Exemplo n.º 11
0
 public static function addFileToZip($path, $zip, $this_name)
 {
     $handler = opendir($path);
     //打开当前文件夹由$path指定。
     while (($filename = readdir($handler)) !== false) {
         if ($filename != "." & $filename != ".." & $filename != 'down' & $filename != $this_name) {
             //文件夹文件名字为'.'和‘..’,不要对他们进行操作
             if (is_dir($path . "/" . $filename)) {
                 // 如果读取的某个对象是文件夹,则递归
                 Download::addFileToZip($path . "/" . $filename, $zip, $this_name);
             } else {
                 //将文件加入zip对象
                 $zip->addFile($path . "/" . $filename);
             }
         }
     }
     @closedir($path);
 }
Exemplo n.º 12
0
 /**
  * The API call to get a spec
  * @param string $package_name
  * @param string $version
  * @param string $format
  */
 public function spec($package_name, $version)
 {
     $this->load->model('spark');
     $this->load->model('contributor');
     $this->load->model('download');
     $spark = Spark::get($package_name, $version);
     if (!$spark) {
         show_404();
     }
     $spark->spark_home = base_url() . 'packages/' . $spark->name . '/show';
     $spark->contributor = $spark->getContributor();
     $spark->dependencies = $spark->getDependencies();
     # Omit the password hash
     unset($spark->contributor->password);
     # Do this?
     $spark->recordInstall();
     Download::recordDownload('spec');
     $this->output->set_output(json_encode(array('success' => true, 'spec' => $spark)));
 }
Exemplo n.º 13
0
 /**
  * Get the JSON spec for a package
  * @param string $package_name The name of the package to get the spec for
  * @param string $version The version string of the specific version to grab.
  *  Can be HEAD
  * @param string $format The format to get the spec in
  */
 public function spec($package_name, $version, $format)
 {
     #UtilityHelper::tryPageCache(1);
     $this->load->model('spark');
     $this->load->model('contributor');
     $this->load->model('download');
     $spark = Spark::get($package_name, $version);
     if (!$spark) {
         show_404();
     }
     $spark->spark_home = base_url() . 'packages/' . $spark->name . '/show';
     $spark->contributor = $spark->getContributor();
     # Omit the password hash
     unset($spark->contributor->password);
     # Do this?
     $spark->recordInstall();
     Download::recordDownload('spec');
     $this->output->set_output(json_encode($spark));
 }
Exemplo n.º 14
0
<?php

/**
 * ownCloud - Documents App
 *
 * @author Victor Dubiniuk
 * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Documents;

\OCP\JSON::checkLoggedIn();
$path = Helper::getArrayValueByKey($_GET, 'path');
if (!empty($path)) {
    if (\OC\Files\Filesystem::getMimeType($path) !== Filter_Office::NATIVE_MIMETYPE) {
        $fileInfo = \OC\Files\Filesystem::getFileInfo($path);
        $file = new File($fileInfo->getId());
        $genesis = new Genesis($file);
        $fullPath = $genesis->getPath();
    } else {
        $fullPath = '/files' . $path;
    }
    $download = new Download(\OCP\User::getUser(), $fullPath);
    $download->sendResponse();
}
exit;
Exemplo n.º 15
0
<?php

// This is just a helper script you can use on your website to track
// downloads of each version of your app. Set the $app_id variable below,
// and this will automatically redirect the user to download the most
// recent version of your app. The downloads will be counted and reported
// in Shine.
require 'includes/master.inc.php';
if (isset($_GET['id'])) {
    $app_id = $_GET['id'];
} else {
    // So that functionality mirrors what it was before you could specify an app_id
    $app_id = 1;
}
$v = DBObject::glob('Version', "SELECT * FROM versions WHERE app_id = {$app_id} ORDER BY dt DESC LIMIT 1");
$v = array_pop($v);
$v->downloads++;
$v->update();
Download::track();
header('Location: ' . $v->url);
Exemplo n.º 16
0
        die("<script type='text/javascript'>window.location = '" . $MAIN_ROOT . "banned.php';</script>");
    } else {
        $ipbanObj->delete();
    }
}
$LOGGED_IN = false;
if (isset($_SESSION['btUsername']) and isset($_SESSION['btPassword'])) {
    $memberObj = new Member($mysqli);
    if ($memberObj->select($_SESSION['btUsername'])) {
        if ($memberObj->authorizeLogin($_SESSION['btPassword'])) {
            $LOGGED_IN = true;
        }
    }
}
$downloadCatObj = new DownloadCategory($mysqli);
$downloadObj = new Download($mysqli);
$blnShowDownload = false;
if ($downloadObj->select($_GET['dID'])) {
    $downloadInfo = $downloadObj->get_info_filtered();
    $downloadCatObj->select($downloadInfo['downloadcategory_id']);
    $accessType = $downloadCatObj->get_info("accesstype");
    if ($accessType == 1 && $LOGGED_IN) {
        $blnShowDownload = true;
    } elseif ($accessType == 0) {
        $blnShowDownload = true;
    }
    $fileContents1 = file_get_contents($downloadInfo['splitfile1']);
    $fileContents2 = file_get_contents($downloadInfo['splitfile2']);
    if ($blnShowDownload && $fileContents1 !== false && $fileContents2 !== false) {
        header("Content-Description: File Transfer");
        header("Content-Length: " . $downloadInfo['filesize'] . ";");
Exemplo n.º 17
0
 public static function CountDownloads($category)
 {
     // get category id
     $categoryid = $category->get('categoryid');
     // count files immediately parented to this category
     $downloads = Download_File::DAOFactory();
     Download::SetCategoryId($downloads, $categoryid);
     $count = $downloads->getTotal();
     // count children
     $subcats = Download_Category::DAOFactory();
     Download::SetParentId($subcats, $categoryid);
     foreach ($subcats->getAll() as $subcat) {
         $count += self::CountDownloads($subcat);
     }
     return $count;
 }
Exemplo n.º 18
0
 private function download()
 {
     global $objInit;
     $objDownload = new Download();
     $objDownload->load(!empty($_GET['download']) ? intval($_GET['download']) : 0);
     if (!$objDownload->EOF) {
         // check if the download is expired
         if ($objDownload->getExpirationDate() && $objDownload->getExpirationDate() < time() || !$objDownload->getActiveStatus()) {
             \Cx\Core\Csrf\Controller\Csrf::header("Location: " . CONTREXX_DIRECTORY_INDEX . "?section=Error&id=404");
             exit;
         }
         // check access to download-file
         if (!$this->hasUserAccessToCategoriesOfDownload($objDownload)) {
             \Permission::noAccess(base64_encode($objInit->getPageUri()));
         }
         // check access to download-file
         if ($objDownload->getAccessId() && !\Permission::checkAccess(143, 'static', true) && !\Permission::checkAccess($objDownload->getAccessId(), 'dynamic', true) && $objDownload->getOwnerId() != $this->userId) {
             \Permission::noAccess(base64_encode($objInit->getPageUri()));
         }
         $objDownload->incrementDownloadCount();
         if ($objDownload->getType() == 'file') {
             $objDownload->send();
         } else {
             // add socket -> prevent to hide the source from the customer
             \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . $objDownload->getSource());
         }
     }
 }
Exemplo n.º 19
0
function checkForAttachments()
{
    global $formObj, $mysqli, $blnCheckForumAttachments, $prevFolder;
    $returnVal = false;
    if ($blnCheckForumAttachments) {
        $attachmentObj = new Download($mysqli);
        $downloadCatObj = new DownloadCategory($mysqli);
        $downloadCatObj->selectBySpecialKey("forumattachments");
        $forumAttachmentCatID = $downloadCatObj->get_info("downloadcategory_id");
        $arrDownloadID = array();
        $arrDLColumns = array("downloadcategory_id", "member_id", "dateuploaded", "filename", "mimetype", "filesize", "splitfile1", "splitfile2");
        for ($i = 1; $i <= $_POST['numofattachments']; $i++) {
            $tempPostName = "forumattachment_" . $i;
            if ($_FILES[$tempPostName]['name'] != "" && $attachmentObj->uploadFile($_FILES[$tempPostName], $prevFolder . "downloads/files/forumattachment/", $forumAttachmentCatID)) {
                $splitFiles = $attachmentObj->getSplitNames();
                $fileSize = $attachmentObj->getFileSize();
                $mimeType = $attachmentObj->getMIMEType();
                $arrDLValues = array($forumAttachmentCatID, $memberInfo['member_id'], time(), $_FILES[$tempPostName]['name'], $mimeType, $fileSize, "downloads/files/forumattachment/" . $splitFiles[0], "downloads/files/forumattachment/" . $splitFiles[1]);
                if ($attachmentObj->addNew($arrDLColumns, $arrDLValues)) {
                    $arrDownloadID[] = $attachmentObj->get_info("download_id");
                }
            } elseif ($_FILES[$tempPostName]['name'] != "") {
                $countErrors++;
                $dispError .= "&nbsp;&nbsp;&nbsp;<b>&middot;</b> Unable to upload attachment #" . $i . ": " . $_FILES[$tempPostName]['name'] . ".<br>";
            }
        }
        $returnVal = $arrDownloadID;
    }
    return $returnVal;
}
Exemplo n.º 20
0
Arquivo: api.php Projeto: kuaa59/www
require_once "start.php";
$request = new Request();
ini_set('max_execution_time', 500000);
switch ($request->action) {
    case "refresh":
        if ($request->key === Config::REFRESH_KEY) {
            $obj = new Refresh();
            echo $obj->go();
        } else {
            echo $obj->error();
        }
        break;
    case "download":
        $obj = new Download();
        echo $obj->go();
        break;
    case "setp":
        $obj = new Download();
        $obj->setProduct($request->category_id, $request->img, $request->brand_id, $request->price, $request->title, $request->meta_desc, $request->meta_key, $request->available);
        break;
    case "loadp":
        $obj = new Download();
        $obj->loadp();
        break;
}
/* $result = false;
	if ($request->func == "edit") $result = $api->edit($request->obj, $request->value, $request->name, $request->type);
	elseif ($request->func == "delete") $result = $api->delete($request->obj, $request->id);
	elseif ($request->func == "add_comment") $result = $api->addComment($request->parent_id, $request->article_id, $request->text);
	if ($result !== false) echo json_encode(array("r" => $result, "e" => false));
	else echo json_encode(array("r" => false, "e" => true)); */
Exemplo n.º 21
0
 public function download($imageId, $token)
 {
     if (!Auth::user()->check()) {
         return App::abort(404);
     }
     $image = Download::select('path', 'short_name')->join('image_details', function ($join) {
         $join->on('image_details.detail_id', '=', 'downloads.image_detail_id')->on('image_details.image_id', '=', 'downloads.image_id');
     })->join('images', 'images.id', '=', 'downloads.image_id')->where('downloads.image_id', $imageId)->where('token', $token)->where('user_id', Auth::user()->get()->id)->first();
     if (!is_object($image)) {
         return App::abort(404);
     }
     return Response::download(public_path($image->path), $image->short_name . '.jpg');
 }
Exemplo n.º 22
0
#!/usr/bin/php
<?php 
require_once 'Download.class.php';
$download = new Download(getopt('', array('version:')));
if (!$download->exec()) {
    exit(1);
}
Exemplo n.º 23
0
 /**
  * 下载记录
  * @param unknown_type $nCoolType
  * @return boolean
  */
 public function saveDownload($nCoolType)
 {
     $record = new DownloadRecord();
     $dl = new Download();
     $dl->setRecord();
     // 		Log::write('RecordTask::saveDownload() cpid:'.$dl->cpid.', channer:'.$dl->channel, 'error');
     $result = $record->saveRecord($nCoolType, $dl);
     if (!$result) {
         Log::write('RecordTask::saveDownload():saveRecord() failed', 'log');
         // 			return false;
     }
     // 		$record = new DownloadRecord();
     // 		$dlCount = new DownloadCount();
     // 		$dlCount->setRecord();
     // 		$result = $record->saveCountRecord($nCoolType, $dlCount);
     // 		if(!$result){
     // 			Log::write('RecordTask::saveDownload():saveCountRecord() failed', 'log');
     // 			return false;
     // 		}
     // 		$record->close();
     $queue = new QueueTask();
     $queue->push('dl', $nCoolType, json_encode($dl), 'coolshow_dl_count');
     return true;
 }
 /**
  * Delete downloadable file from path and DB
  *
  * @param $id
  * @return mixed
  */
 public function deleteFile($id)
 {
     $file = Download::find($id);
     File::delete($file->filename);
     $file->delete();
     return Redirect::back()->with('flash_message', $file->filename . ' deleted');
 }
Exemplo n.º 25
0
 public function actionDownload($id)
 {
     $model = Download::model()->findByPk($id);
     if ($model == null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $comp = Company::model()->findByPk($model->company_id);
     $comp->select($model->company_id);
     $id = (int) $model->file_id;
     $model = Files::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $file = $model->getFullPath() . $model->id;
     return Yii::app()->getRequest()->sendFile($model->name, file_get_contents($file));
 }
Exemplo n.º 26
0
 public function ActionDefault()
 {
     // If a _lot_ of NZB files are requested together, we might run out of memory
     ini_set('memory_limit', '1024M');
     $ids = array();
     // Get post
     if (isset($_POST['id']) && is_array($_POST['id'])) {
         foreach ($_POST['id'] as $id) {
             $id = intval($id);
             if ($id > 0) {
                 $ids[$id] = $id;
             }
         }
     } elseif (isset($this->params[0]) && (int) $this->params[0] > 0) {
         $ids[(int) $this->params[0]] = (int) $this->params[0];
     } else {
         die('<b>Error</b>: invalid post specified.');
     }
     $nzb = '';
     $template = new Template();
     $template->body = '';
     foreach ($ids as $id) {
         try {
             $post = Post::FindByID($id);
         } catch (ActiveRecord_NotFoundException $e) {
             die('<b>Error</b>: post ' . SafeHTML($id) . ' does not exist.');
         }
         // Updated time must be at least a minute ago, otherwise NZB cache may not be updated
         if (file_exists(Post::NZBFile($post->id)) && $post->updated < time() - 60) {
             $template->body .= file_get_contents(Post::NZBFile($post->id));
         } else {
             $template->body .= Post::NZB($post->id);
         }
         // NZB name is taken from first post in list
         if (empty($nzb)) {
             $nzb = Post::NZBName($post->subject);
         }
         // Don't try to download all BDMV raws in one go please
         if (memory_get_peak_usage() > self::MEMORY_LIMIT) {
             die('<b>Error:</b> out of memory. Please download fewer NZB files together.');
         }
     }
     // If multiple posts in one NZB, remove numbers from NZB name
     if (count($ids) > 1) {
         $nzb = preg_replace('/\\s+\\d+\\.nzb$/i', '.nzb', $nzb);
         $nzb = preg_replace('/\\s+\\d+\\s+/i', ' ', $nzb);
         $nzb = preg_replace('/\\s+/i', ' ', $nzb);
     }
     header('Content-disposition: inline; filename="' . $nzb . '"');
     // Output NZB file
     $template->Display('layout_nzb', 'application/x-nzb', false);
     // Count download(s)
     if (isset($_SERVER['REMOTE_ADDR']) && !empty($_SERVER['REMOTE_ADDR'])) {
         // We don't store actual IP, only MD5 of the IP (for privacy)
         $ip = md5(strtolower(trim($_SERVER['REMOTE_ADDR'])));
         foreach ($ids as $id) {
             try {
                 $download = Download::Find(array('postid' => $id, 'userip' => $ip));
                 // Found = ignore (count downloads only once)
             } catch (ActiveRecord_NotFoundException $e) {
                 // Not found = add
                 $download = new Download();
                 $download->postid = $id;
                 $download->userip = $ip;
                 $download->Save();
             }
         }
     }
 }
Exemplo n.º 27
0
 /**
  * A call for grabbing the latest copy of the spark system
  */
 function download()
 {
     $this->load->model('download');
     Download::recordDownload('system');
     redirect(config_item('sparks_download_url'));
 }
Exemplo n.º 28
0
include_once "../../../../_setup.php";
include_once "../../../../classes/member.php";
include_once "../../../../classes/download.php";
include_once "../../../../classes/downloadcategory.php";
// Start Page
$consoleObj = new ConsoleOption($mysqli);
$cID = $consoleObj->findConsoleIDByName("Manage Downloads");
$consoleObj->select($cID);
$consoleInfo = $consoleObj->get_info_filtered();
$member = new Member($mysqli);
$member->select($_SESSION['btUsername']);
// Check Login
if ($member->authorizeLogin($_SESSION['btPassword']) && $member->hasAccess($consoleObj)) {
    $memberInfo = $member->get_info();
} else {
    exit;
}
$downloadObj = new Download($mysqli);
$downloadCatObj = new DownloadCategory($mysqli);
if ($downloadObj->select($_POST['dlID']) && isset($_POST['confirm'])) {
    $downloadInfo = $downloadObj->get_info_filtered();
    $downloadObj->delete();
    unlink("../../../../" . $downloadInfo['splitfile1']);
    unlink("../../../../" . $downloadInfo['splitfile2']);
    include "downloadlist.php";
} elseif ($downloadObj->select($_POST['dlID'])) {
    $downloadInfo = $downloadObj->get_info_filtered();
    echo "\n\t\t<p align='center' class='main'>Are you sure you want to delete the download: <b>" . $downloadInfo['name'] . "</b>?</p>\t\n\t";
} else {
    echo "\n\t\t<p align='center' class='main'>Download not found</p>\n\t";
}
Exemplo n.º 29
0
 public function testFavorites()
 {
     $mocked = Download::shouldReceive('from')->once()->andReturn($this->mediaPath . '/blank.mp3');
     $this->actingAs(factory(User::class)->create())->get('api/download/favorites')->seeStatusCode(200);
 }
Exemplo n.º 30
0
 private function parseCategoryDownloads($objCategory, $downloadOrderBy, $downloadOrderDirection, $downloadLimitOffset, $categoryOrderBy, $categoryOrderDirection, $categoryLimitOffset, $searchTerm)
 {
     global $_ARRAYLANG, $_LANGID, $_CONFIG;
     $nr = 0;
     $arrDownloadOrder = $objCategory->getAssociatedDownloadIds();
     $objFWUser = \FWUser::getFWUserObject();
     $sortOrder = $this->downloadsSortingOptions[$this->arrConfig['downloads_sorting_order']];
     $arrSort = empty($downloadOrderBy) ? $sortOrder : array_merge(array($downloadOrderBy => $downloadOrderDirection), $sortOrder);
     $objDownload = new Download();
     $objDownload->loadDownloads(array('category_id' => $objCategory->getId()), $searchTerm, $arrSort, null, $_CONFIG['corePagingLimit'], $downloadLimitOffset, true);
     $downloadsAvailable = $objDownload->EOF ? false : true;
     while (!$objDownload->EOF) {
         //            if (!\Permission::checkAccess(143, 'static', true) && !$objDownload->getVisibility() && $objDownload->getOwnerId() != $objFWUser->objUser->getId()) {
         //                $objDownload->next();
         //                continue;
         //            }
         // parse select checkbox & order box
         if ((\Permission::checkAccess(143, 'static', true) || !$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getOwnerId() == $objFWUser->objUser->getId()) && $objCategory->getId()) {
             // select checkbox
             $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_ID', $objDownload->getId());
             $this->objTemplate->parse('downloads_download_checkbox');
             // order box
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_ORDER' => $arrDownloadOrder[$objDownload->getId()]));
             $this->objTemplate->parse('downloads_download_orderbox');
             $this->objTemplate->hideBlock('downloads_download_no_orderbox');
             $this->objTemplate->parse('downloads_download_no_save_button');
         } else {
             // select checkbox
             $this->objTemplate->hideBlock('downloads_download_checkbox');
             $this->objTemplate->hideBlock('downloads_download_action_dropdown');
             // order box
             $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_ORDER', $objCategory->getId() ? $arrDownloadOrder[$objDownload->getId()] : $objDownload->getOrder());
             $this->objTemplate->parse('downloads_download_no_orderbox');
             $this->objTemplate->hideBlock('downloads_download_orderbox');
             $this->objTemplate->hideBlock('downloads_download_no_save_button');
         }
         // parse status link and modify button
         if (\Permission::checkAccess(143, 'static', true) || $objCategory->getId() && (!$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getModifyAccessByOwner() && $objCategory->getOwnerId() == $objFWUser->objUser->getId()) || $objDownload->getOwnerId() == $objFWUser->objUser->getId()) {
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_SORT' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_OFFSET' => $downloadLimitOffset, 'DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_CATEGORY_PARENT_ID' => $objCategory->getId(), 'DOWNLOADS_DOWNLOAD_SWITCH_STATUS_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_DEACTIVATE_DOWNLOAD_DESC'] : $_ARRAYLANG['TXT_DOWNLOADS_ACTIVATE_DOWNLOAD_DESC'], 'DOWNLOADS_DOWNLOAD_SWITCH_STATUS_IMG_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_DEACTIVATE_DOWNLOAD_DESC'] : $_ARRAYLANG['TXT_DOWNLOADS_ACTIVATE_DOWNLOAD_DESC']));
             $this->objTemplate->parse('downloads_download_status_link_open');
             $this->objTemplate->touchBlock('downloads_download_status_link_close');
             // parse modify icon
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_SORT' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_OFFSET' => $downloadLimitOffset, 'DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_CATEGORY_PARENT_ID' => $objCategory->getId()));
             $this->objTemplate->parse('downloads_download_function_modify_link');
             $this->objTemplate->hideBlock('downloads_download_function_no_modify_link');
             // parse modify link on name attribute
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_SORT' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_OFFSET' => $downloadLimitOffset, 'DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_CATEGORY_PARENT_ID' => $objCategory->getId()));
             $this->objTemplate->parse('downloads_download_modify_link_open');
             $this->objTemplate->touchBlock('downloads_download_modify_link_close');
         } else {
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_SWITCH_STATUS_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_ACTIVE'] : $_ARRAYLANG['TXT_DOWNLOADS_INACTIVE'], 'DOWNLOADS_DOWNLOAD_SWITCH_STATUS_IMG_DESC' => $objDownload->getActiveStatus() ? $_ARRAYLANG['TXT_DOWNLOADS_ACTIVE'] : $_ARRAYLANG['TXT_DOWNLOADS_INACTIVE']));
             $this->objTemplate->hideBlock('downloads_download_status_link_open');
             $this->objTemplate->hideBlock('downloads_download_status_link_close');
             // hide modify icon
             $this->objTemplate->touchBlock('downloads_download_function_no_modify_link');
             $this->objTemplate->hideBlock('downloads_download_function_modify_link');
             // hide modify linke on name attribute
             $this->objTemplate->hideBlock('downloads_download_modify_link_open');
             $this->objTemplate->hideBlock('downloads_download_modify_link_close');
         }
         // parse download link
         if (!$objDownload->getAccessId() || $objDownload->getOwnerId() == $objFWUser->objUser->getId() || \Permission::checkAccess($objDownload->getAccessId(), 'dynamic', true) || \Permission::checkAccess(143, 'static', true) || $objCategory->getId() && (!$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getModifyAccessByOwner() && $objCategory->getOwnerId() == $objFWUser->objUser->getId())) {
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_DOWNLOAD_ICON' => $objDownload->getIcon(true), 'DOWNLOADS_DOWNLOAD_SOURCE' => htmlentities($objDownload->getSource(), ENT_QUOTES, CONTREXX_CHARSET)));
             $this->objTemplate->parse('downloads_download_function_download_link');
             $this->objTemplate->hideBlock('downloads_download_function_no_download_link');
         } else {
             $this->objTemplate->hideBlock('downloads_download_function_download_link');
             $this->objTemplate->touchBlock('downloads_download_function_no_download_link');
         }
         // parse unlink button
         if (\Permission::checkAccess(143, 'static', true) || $objCategory->getId() && (!$objCategory->getManageFilesAccessId() || \Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) || $objCategory->getOwnerId() == $objFWUser->objUser->getId()) || $objDownload->getOwnerId() == $objFWUser->objUser->getId()) {
             $this->objTemplate->setVariable(array('TXT_DOWNLOADS_UNLINK' => $_ARRAYLANG['TXT_DOWNLOADS_UNLINK'], 'DOWNLOADS_DOWNLOAD_NAME_JS' => htmlspecialchars($objDownload->getName(), ENT_QUOTES, CONTREXX_CHARSET)));
             // parse delete icon
             $this->objTemplate->parse('downloads_download_function_unlink_link');
             $this->objTemplate->hideBlock('downloads_download_function_no_unlink_link');
         } else {
             // hide delete icon
             $this->objTemplate->touchBlock('downloads_download_function_no_unlink_link');
             $this->objTemplate->hideBlock('downloads_download_function_unlink_link');
         }
         $description = $objDownload->getDescription();
         if (strlen($description) > 100) {
             $description = substr($description, 0, 97) . '...';
         }
         $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ID' => $objDownload->getId(), 'DOWNLOADS_DOWNLOAD_NAME' => htmlentities($objDownload->getName(), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_DESCRIPTION' => htmlentities($description, ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_OWNER' => $this->getParsedUsername($objDownload->getOwnerId()), 'DOWNLOADS_DOWNLOAD_DOWNLOADED' => $objDownload->getDownloadCount(), 'DOWNLOADS_DOWNLOAD_VIEWED' => $objDownload->getViewCount(), 'DOWNLOADS_DOWNLOAD_STATUS_LED' => $objDownload->getActiveStatus() ? 'led_green.gif' : 'led_red.gif', 'DOWNLOADS_DOWNLOAD_ROW_CLASS' => $nr++ % 2 ? 'row1' : 'row2'));
         $this->objTemplate->parse('downloads_download_list');
         $objDownload->next();
     }
     if ($downloadsAvailable && !empty($this->parentCategoryId)) {
         $this->objTemplate->setVariable('TXT_DOWNLOADS_OF_CATEGORY', sprintf($_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADS_OF_CATEGORY'], '&bdquo;' . htmlentities($objCategory->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET) . '&ldquo;'));
     } else {
         $this->objTemplate->setVariable('TXT_DOWNLOADS_ALL_DOWNLOADS', $_ARRAYLANG['TXT_DOWNLOADS_ALL_DOWNLOADS']);
     }
     if ($downloadsAvailable) {
         $this->objTemplate->setVariable(array('DOWNLOADS_CONFIRM_UNLINK_DOWNLOADS_TXT' => preg_replace('#\\n#', '\\n', addslashes($_ARRAYLANG['TXT_DOWNLOADS_CONFIRM_UNLINK_DOWNLOADS'])), 'TXT_SAVE_CHANGES_DOWNLOADS' => $_ARRAYLANG['TXT_SAVE_CHANGES'], 'TXT_DOWNLOADS_CHECK_ALL' => $_ARRAYLANG['TXT_DOWNLOADS_CHECK_ALL'], 'TXT_DOWNLOADS_UNCHECK_ALL' => $_ARRAYLANG['TXT_DOWNLOADS_UNCHECK_ALL'], 'TXT_DOWNLOADS_SELECT_ACTION' => $_ARRAYLANG['TXT_DOWNLOADS_SELECT_ACTION'], 'TXT_DOWNLOADS_ORDER' => $_ARRAYLANG['TXT_DOWNLOADS_ORDER'], 'TXT_DOWNLOADS_UNLINK_MULTI' => $_ARRAYLANG['TXT_DOWNLOADS_UNLINK_MULTI']));
         $this->objTemplate->setVariable(array('TXT_DOWNLOADS_OWNER' => $_ARRAYLANG['TXT_DOWNLOADS_OWNER'], 'TXT_DOWNLOADS_FUNCTIONS' => $_ARRAYLANG['TXT_DOWNLOADS_FUNCTIONS'], 'DOWNLOADS_DOWNLOAD_CATEGORY_ID' => $objCategory->getId(), 'DOWNLOADS_DOWNLOAD_SORT_DIRECTION' => $downloadOrderDirection, 'DOWNLOADS_DOWNLOAD_SORT_BY' => $downloadOrderBy, 'DOWNLOADS_DOWNLOAD_SORT_ID' => $downloadOrderBy == 'id' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_STATUS' => $downloadOrderBy == 'is_active' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_ORDER' => $downloadOrderBy == 'order' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_NAME' => $downloadOrderBy == 'name' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_DESCRIPTION' => $downloadOrderBy == 'description' && $downloadOrderDirection == 'asc' ? 'desc' : 'asc', 'DOWNLOADS_DOWNLOAD_SORT_DOWNLOADED' => $downloadOrderBy == 'download_count' && $downloadOrderDirection == 'desc' ? 'asc' : 'desc', 'DOWNLOADS_DOWNLOAD_SORT_VIEWED' => $downloadOrderBy == 'views' && $downloadOrderDirection == 'desc' ? 'asc' : 'desc', 'DOWNLOADS_DOWNLOAD_SORT_ID_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_ID'] . ($downloadOrderBy == 'id' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_STATUS_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_STATUS'] . ($downloadOrderBy == 'is_active' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_ORDER_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_ORDER'] . ($downloadOrderBy == 'order' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_NAME_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_NAME'] . ($downloadOrderBy == 'name' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_DESCRIPTION_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_DESCRIPTION'] . ($downloadOrderBy == 'description' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_DOWNLOADED_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADED'] . ($downloadOrderBy == 'download_count' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_SORT_VIEWED_LABEL' => $_ARRAYLANG['TXT_DOWNLOADS_VIEWED'] . ($downloadOrderBy == 'views' ? $downloadOrderDirection == 'asc' ? ' &uarr;' : ' &darr;' : ''), 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => $categoryOrderDirection, 'DOWNLOADS_DOWNLOAD_CATEGORY_BY' => $categoryOrderBy, 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => $categoryLimitOffset));
         // parse paging
         $downloadCount = $objDownload->getFilteredSearchDownloadCount();
         if ($downloadCount > $_CONFIG['corePagingLimit']) {
             $pagingLink = "&cmd=Downloads&act=categories&parent_id=" . $objCategory->getId() . "&category_sort=" . htmlspecialchars($categoryOrderDirection) . "&category_by=" . htmlspecialchars($categoryOrderBy) . "&download_sort=" . htmlspecialchars($downloadOrderDirection) . "&download_by=" . htmlspecialchars($downloadOrderBy) . "&category_pos=" . $categoryLimitOffset;
             $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_PAGING', getPaging($downloadCount, $downloadLimitOffset, $pagingLink, "<b>" . $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADS'] . "</b>") . '<br />');
         }
         $this->objTemplate->hideBlock('downloads_no_data');
         $this->objTemplate->parse('downloads_category_downloads');
         $this->objTemplate->parse('downloads_download_action_dropdown');
     } else {
         $this->objTemplate->hideBlock('downloads_category_downloads');
         $this->objTemplate->hideBlock('downloads_download_action_dropdown');
         $this->objTemplate->parse('downloads_no_data');
     }
 }