2010-08-10 18:12:50 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "download.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Fun
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Download::Download()
|
|
|
|
{
|
2010-11-21 01:19:17 +01:00
|
|
|
fun.url = L"download";
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Download::MakeGet()
|
|
|
|
{
|
|
|
|
// !! moze wywalic to no_item i wszedzie w takich miejscach dac poprostu permission_denied?
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !cur->request->is_item )
|
2010-08-10 18:12:50 +02:00
|
|
|
{
|
|
|
|
log << log1 << "Content: download function requires an item" << logend;
|
2011-01-23 15:15:30 +01:00
|
|
|
cur->request->status = WINIX_ERR_NO_ITEM;
|
2010-08-10 18:12:50 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
if( !system->HasReadAccess(cur->request->item) ||
|
|
|
|
cur->request->item.file_type == WINIX_ITEM_FILETYPE_NONE ||
|
|
|
|
cur->request->item.file_path.empty() )
|
2010-08-10 18:12:50 +02:00
|
|
|
{
|
2011-01-23 15:15:30 +01:00
|
|
|
cur->request->status = WINIX_ERR_PERMISSION_DENIED;
|
2010-08-10 18:12:50 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
cur->request->send_as_attachment = cur->request->IsParam(L"attachment");
|
2010-12-10 22:07:01 +01:00
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
if( cur->request->item.has_thumb && cur->request->IsParam(L"thumb") )
|
|
|
|
system->MakeFilePath(cur->request->item, cur->request->x_sendfile, true);
|
2010-12-10 22:07:01 +01:00
|
|
|
else
|
2011-01-23 15:15:30 +01:00
|
|
|
system->MakeFilePath(cur->request->item, cur->request->x_sendfile);
|
2010-08-10 18:12:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|