changed organization of static files
removed: item.auth item.auth_path added: item.file_path, item.file_fs, item.file_type now the path to a static file is a relative path added: thumbnails (not finished yet) fixed: db didn't correctly return the number of deleted items /DelItem() method/ git-svn-id: svn://ttmath.org/publicrep/winix/trunk@696 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -79,24 +79,26 @@ return res == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Cp::CpAuth(Item & item)
|
||||
void Cp::CpStaticFile(Item & item)
|
||||
{
|
||||
if( !system->MakePath(item, mv_new_path, true) )
|
||||
bool res1 = system->MakeFilePath(item, old_path);
|
||||
bool res2 = system->CreateNewFile(item);
|
||||
bool res3 = system->MakeFilePath(item, mv_new_path, false, true, config->upload_dirs_chmod);
|
||||
|
||||
if( !res1 || !res2 || !res3 )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
if( CopyFile(item.auth_path, mv_new_path) )
|
||||
if( CopyFile(old_path, mv_new_path) )
|
||||
{
|
||||
log << log1 << "Content: copied static file from: " << item.auth_path << ", to: " << mv_new_path << logend;
|
||||
item.auth_path = mv_new_path;
|
||||
request->status = db->EditAuthById(item, item.id);
|
||||
log << log1 << "Cp: copied static file from: " << old_path << ", to: " << mv_new_path << logend;
|
||||
request->status = db->EditFileById(item, item.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Content: can't copy a file from: " << item.auth_path << ", to: " << mv_new_path << logend;
|
||||
log << log1 << "Cp: can't copy a file from: " << old_path << ", to: " << mv_new_path << logend;
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
}
|
||||
@@ -124,8 +126,8 @@ void Cp::CpItem(Item & item, long dst_dir_id)
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
if( item.auth != Item::auth_none )
|
||||
CpAuth(item);
|
||||
if( item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
CpStaticFile(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -38,12 +38,13 @@ private:
|
||||
std::wstring mv_dir;
|
||||
std::wstring mv_file;
|
||||
std::wstring mv_new_path;
|
||||
std::wstring old_path;
|
||||
long mv_dir_id;
|
||||
|
||||
bool CpCheckAccessFrom();
|
||||
bool CheckAccessTo(long dir_id);
|
||||
bool ParseDir(long & dir_id, std::wstring & dir, std::wstring & file);
|
||||
void CpAuth(Item & item);
|
||||
void CpStaticFile(Item & item);
|
||||
void CpSetNewAttributes(Item & item);
|
||||
void CpItem(Item & item, long dst_dir_id);
|
||||
void CpPrepare();
|
||||
|
@@ -80,10 +80,18 @@ void Default::MakePost()
|
||||
try
|
||||
{
|
||||
long defaultid = PostFunDefaultParsePath();
|
||||
request->status = db->EditDefaultItem(request->dir_tab.back()->id, defaultid);
|
||||
|
||||
if( defaultid != request->dir_tab.back()->id )
|
||||
{
|
||||
request->status = db->EditDefaultItem(request->dir_tab.back()->id, defaultid);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
request->dir_tab.back()->default_item = defaultid;
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
request->dir_tab.back()->default_item = defaultid;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << "Default: skipping the same directory" << logend;
|
||||
}
|
||||
}
|
||||
catch(const Error & e)
|
||||
{
|
||||
|
@@ -32,16 +32,20 @@ void Download::MakeGet()
|
||||
}
|
||||
|
||||
|
||||
if( !system->HasReadAccess(request->item) ||
|
||||
request->item.auth == Item::auth_none ||
|
||||
request->item.auth_path.empty() )
|
||||
if( !system->HasReadAccess(request->item) ||
|
||||
request->item.file_type == WINIX_ITEM_FILETYPE_NONE ||
|
||||
request->item.file_path.empty() )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
request->send_as_attachment = request->IsParam(L"attachment");
|
||||
request->x_sendfile = request->item.auth_path;
|
||||
|
||||
if( request->item.file_type == WINIX_ITEM_FILETYPE_IMAGE && config->create_thumb && request->IsParam(L"thumb") )
|
||||
system->MakeFilePath(request->item, request->x_sendfile, true);
|
||||
else
|
||||
system->MakeFilePath(request->item, request->x_sendfile);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -81,7 +81,7 @@ void FunctionParser::ParseItem()
|
||||
{
|
||||
request->last_item = &request->item;
|
||||
|
||||
if( request->role == Request::authorizer && request->item.auth == Item::auth_none )
|
||||
if( request->role == Request::authorizer && request->item.file_type == WINIX_ITEM_FILETYPE_NONE )
|
||||
{
|
||||
log << log1 << "FP: item.url: " << url << " exists but has not a static content (authorizer role)" << logend;
|
||||
request->status = WINIX_ERR_NO_ITEM;
|
||||
|
@@ -232,7 +232,7 @@ void Functions::Parse()
|
||||
|
||||
void Functions::SetDefaultFunctionForFile()
|
||||
{
|
||||
if( request->item.auth != Item::auth_none )
|
||||
if( request->item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
request->function = &fun_download;
|
||||
else
|
||||
if( system->HasReadExecAccess(request->item) )
|
||||
|
@@ -71,7 +71,7 @@ void FunThread::MakeGet()
|
||||
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
iq.WhereType(Item::file);
|
||||
iq.WhereAuth(Item::auth_none);
|
||||
iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE);
|
||||
|
||||
db->GetItems(request->item_tab, iq);
|
||||
db->GetThreads(request->dir_tab.back()->id, thread_tab);
|
||||
|
@@ -34,7 +34,7 @@ void Ls::MakeGet()
|
||||
|
||||
if( request->IsParam(L"ckeditor_browse") )
|
||||
{
|
||||
iq.WhereAuth(Item::auth_image);
|
||||
iq.WhereFileType(WINIX_ITEM_FILETYPE_IMAGE);
|
||||
db->GetItems(request->item_tab, iq);
|
||||
}
|
||||
else
|
||||
|
@@ -146,28 +146,26 @@ return res == 0;
|
||||
|
||||
|
||||
|
||||
void Mv::MoveAuth(Item & item)
|
||||
void Mv::MoveStaticFile(Item & item)
|
||||
{
|
||||
if( !system->MakePath(item, mv_new_path, true) )
|
||||
bool res1 = system->MakeFilePath(item, old_path);
|
||||
bool res2 = system->CreateNewFile(item);
|
||||
bool res3 = system->MakeFilePath(item, mv_new_path, false, true, config->upload_dirs_chmod);
|
||||
|
||||
if( !res1 || !res2 || !res3 )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return;
|
||||
}
|
||||
|
||||
if( RenameFile(item.auth_path, mv_new_path) )
|
||||
if( RenameFile(old_path, mv_new_path) )
|
||||
{
|
||||
log << log1 << "Mv: moved static file from: " << item.auth_path << ", to: " << mv_new_path << logend;
|
||||
item.auth_path = mv_new_path;
|
||||
request->status = db->EditAuthById(item, item.id);
|
||||
log << log1 << "Mv: moved static file from: " << old_path << ", to: " << mv_new_path << logend;
|
||||
request->status = db->EditFileById(item, item.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
int err = errno;
|
||||
|
||||
log << log1 << "Mv: can't move a file from: " << item.auth_path << ", to: " << mv_new_path << ", ";
|
||||
log.SystemErr(err);
|
||||
log << logend;
|
||||
|
||||
log << log1 << "Mv: can't move a file from: " << old_path << ", to: " << mv_new_path << logend;
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
}
|
||||
@@ -210,8 +208,8 @@ void Mv::MoveFile(Item & item, bool redirect)
|
||||
{
|
||||
log << log2 << "Mv: the file was moved to: " << mv_dir << item.url << logend;
|
||||
|
||||
if( item.auth != Item::auth_none )
|
||||
MoveAuth(item);
|
||||
if( item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
MoveStaticFile(item);
|
||||
|
||||
if( redirect )
|
||||
system->RedirectTo(item);
|
||||
@@ -227,7 +225,7 @@ DbItemQuery iq;
|
||||
iq.sel_parent_id = true;
|
||||
iq.sel_type = true;
|
||||
iq.sel_url = true;
|
||||
iq.sel_auth = true;
|
||||
iq.sel_file = true;
|
||||
iq.WhereParentId(request->dir_tab.back()->id);
|
||||
|
||||
db->GetItems(request->item_tab, iq);
|
||||
@@ -252,10 +250,10 @@ void Mv::MoveAuthPrepareQuery()
|
||||
mv_auth_iq.sel_parent_id = true;
|
||||
mv_auth_iq.sel_type = true;
|
||||
mv_auth_iq.sel_url = true;
|
||||
mv_auth_iq.sel_auth = true;
|
||||
mv_auth_iq.sel_file = true;
|
||||
|
||||
mv_auth_iq.WhereType(Item::file);
|
||||
mv_auth_iq.WhereAuth(Item::auth_none, false);
|
||||
mv_auth_iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +272,7 @@ void Mv::MoveAuthContentOfDir(const Item & item)
|
||||
db->GetItems(mv_auth, mv_auth_iq);
|
||||
|
||||
for(size_t i=0 ; i<mv_auth.size() ; ++i)
|
||||
MoveAuth(mv_auth[i]);
|
||||
MoveStaticFile(mv_auth[i]);
|
||||
|
||||
mv_auth.clear();
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ private:
|
||||
std::wstring mv_dir;
|
||||
std::wstring mv_file;
|
||||
std::wstring mv_new_path;
|
||||
std::wstring old_path;
|
||||
long mv_dir_id;
|
||||
std::vector<Item> mv_auth;
|
||||
DbItemQuery mv_auth_iq;
|
||||
@@ -40,7 +41,7 @@ private:
|
||||
bool MoveCheckAccessTo(long dir_id);
|
||||
bool MoveCheckMountPoints(long dir_id);
|
||||
bool MoveParseDir(long & dir_id, std::wstring & dir, std::wstring & file);
|
||||
void MoveAuth(Item & item);
|
||||
void MoveStaticFile(Item & item);
|
||||
bool MoveIsTheSameFile(const Item & item);
|
||||
void MoveFile(Item & item, bool redirect = true);
|
||||
void MoveContentOfDir();
|
||||
|
@@ -78,10 +78,10 @@ void Rm::RemoveAuthPrepareQuery()
|
||||
|
||||
rm_auth_iq.sel_parent_id = true;
|
||||
rm_auth_iq.sel_type = true;
|
||||
rm_auth_iq.sel_auth = true;
|
||||
rm_auth_iq.sel_file = true;
|
||||
|
||||
rm_auth_iq.WhereType(Item::file);
|
||||
rm_auth_iq.WhereAuth(Item::auth_none, false);
|
||||
rm_auth_iq.WhereFileType(WINIX_ITEM_FILETYPE_NONE, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,15 +104,12 @@ void Rm::RemoveAllDirs(long dir_id)
|
||||
db->GetItems(request->item_tab, rm_auth_iq);
|
||||
|
||||
for(size_t i=0 ; i<request->item_tab.size() ; ++i)
|
||||
RemoveAuth(request->item_tab[i]);
|
||||
RemoveStaticFile(request->item_tab[i]);
|
||||
|
||||
if( db->DelDirById(dir_id) == WINIX_ERR_OK )
|
||||
{
|
||||
system->dirs.DelDir(dir_id);
|
||||
|
||||
db->RemoveThread(dir_id);
|
||||
// !! tticket
|
||||
// db->RemoveTicket(dir_id);
|
||||
|
||||
plugin.Call(WINIX_DIR_REMOVED, dir_id);
|
||||
}
|
||||
@@ -160,29 +157,27 @@ void Rm::RemoveDir()
|
||||
|
||||
|
||||
|
||||
void Rm::RemoveAuth(Item & item)
|
||||
void Rm::RemoveStaticFile(Item & item)
|
||||
{
|
||||
if( item.auth_path.empty() )
|
||||
if( item.file_path.empty() )
|
||||
{
|
||||
log << log1 << "Content: can't remove a static file: auth_path is empty" << logend;
|
||||
log << log1 << "Rm: can't remove a static file: file_path is empty" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( ::RemoveFile(item.auth_path) )
|
||||
if( !system->MakeFilePath(item, path) )
|
||||
return;
|
||||
|
||||
if( ::RemoveFile(path) )
|
||||
{
|
||||
log << log1 << "Content: removed static file: " << item.auth_path << logend;
|
||||
item.auth_path.clear();
|
||||
item.auth = Item::auth_none;
|
||||
log << log1 << "Rm: removed static file: " << path << logend;
|
||||
item.file_path.clear();
|
||||
item.file_type = WINIX_ITEM_FILETYPE_NONE;
|
||||
// we don't store it to db (will be removed or is removed already)
|
||||
}
|
||||
else
|
||||
{
|
||||
int err = errno;
|
||||
|
||||
log << log1 << "Content: can't remove a file: " << item.auth_path;
|
||||
log.SystemErr(err);
|
||||
log << logend;
|
||||
|
||||
log << log1 << "Rm: can't remove a file: " << path << logend;
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
}
|
||||
@@ -198,26 +193,19 @@ void Rm::RemoveFile()
|
||||
request->status = WINIX_ERR_UNKNOWN_PARAM;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( db->DelItem( request->item ) )
|
||||
{
|
||||
log << log2 << "Content: deleted item: subject: " << request->item.subject << ", id: " << request->item.id << logend;
|
||||
log << log2 << "Rm: deleted item: subject: " << request->item.subject << ", id: " << request->item.id << logend;
|
||||
TemplatesFunctions::pattern_cacher.DeletePattern(request->item);
|
||||
|
||||
plugin.Call(WINIX_FILE_REMOVED, request->item.id);
|
||||
|
||||
if( system->mounts.pmount->type == system->mounts.MountTypeThread() )
|
||||
db->EditThreadRemoveItem(request->item.parent_id);
|
||||
/*
|
||||
!! tticket
|
||||
else
|
||||
if( system->mounts.pmount->type == system->mounts.MountTypeTicket() )
|
||||
db->EditTicketRemoveItem(request->item.id);
|
||||
*/
|
||||
|
||||
if( request->item.auth != Item::auth_none )
|
||||
RemoveAuth(request->item);
|
||||
if( request->item.file_type != WINIX_ITEM_FILETYPE_NONE )
|
||||
RemoveStaticFile(request->item);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -29,13 +29,14 @@ public:
|
||||
private:
|
||||
|
||||
DbItemQuery rm_auth_iq;
|
||||
std::wstring path;
|
||||
|
||||
bool HasAccess(const Item & item);
|
||||
void RemoveAuthPrepareQuery();
|
||||
void RemoveAllDirs(long dir_id);
|
||||
void RemoveAllDirs();
|
||||
void RemoveDir();
|
||||
void RemoveAuth(Item & item);
|
||||
void RemoveStaticFile(Item & item);
|
||||
void RemoveFile();
|
||||
|
||||
};
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "wand/MagickWand.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cstdio>
|
||||
@@ -14,6 +15,7 @@
|
||||
#include "upload.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions/functions.h"
|
||||
#include "utf8.h"
|
||||
|
||||
|
||||
|
||||
@@ -38,21 +40,9 @@ bool Upload::HasAccess(const Item & item)
|
||||
if( !system->mounts.pmount )
|
||||
return false;
|
||||
|
||||
if( system->mounts.pmount->fs == system->mounts.MountFsSimplefs() && config->auth_simplefs_dir.empty() )
|
||||
if( config->upload_dir.empty() )
|
||||
{
|
||||
log << log1 << "Request: can't use upload function, auth_simplefs_dir must be set in the config file" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( system->mounts.pmount->fs == system->mounts.MountFsHashfs() && config->auth_hashfs_dir.empty() )
|
||||
{
|
||||
log << log1 << "Request: can't use upload function, auth_hashfs_dir must be set in the config file" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( config->auth_tmp_dir.empty() )
|
||||
{
|
||||
log << log1 << "Request: can't use upload function, auth_tmp_dir must be set in the config file" << logend;
|
||||
log << log1 << "Request: can't use upload function, upload_dir must be set in the config file" << logend;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -77,40 +67,78 @@ return true;
|
||||
|
||||
|
||||
|
||||
bool Upload::UploadCreatePath()
|
||||
void Upload::CreateThumbnail(const Item & item)
|
||||
{
|
||||
if( !system->MakePath(request->item, true) )
|
||||
if( !system->MakeFilePath(item, path) ||
|
||||
!system->MakeFilePath(item, path_thumb, true, true, config->upload_dirs_chmod) )
|
||||
return;
|
||||
|
||||
Ezc::WideToUTF8(path, patha);
|
||||
Ezc::WideToUTF8(path_thumb, path_thumba);
|
||||
|
||||
MagickWand * wand = NewMagickWand();
|
||||
|
||||
if( MagickReadImage(wand, patha.c_str()) )
|
||||
{
|
||||
//log <<log1 << "images: " << MagickGetNumberImages(wand) << logend << logsavenow;
|
||||
//MagickResizeImage(wand, config->images_thumb_cx, config->images_thumb_cy, CubicFilter, 0.25);
|
||||
//MagickScaleImage(wand, 100, 100);
|
||||
MagickThumbnailImage(wand, config->thumb_cx, config->thumb_cy);
|
||||
|
||||
if( MagickWriteImage(wand, path_thumba.c_str()) )
|
||||
log << log3 << "Upload: created a thumbnail: " << path_thumba << logend;
|
||||
}
|
||||
|
||||
DestroyMagickWand(wand);
|
||||
}
|
||||
|
||||
|
||||
bool Upload::UploadSaveStaticFile(const Item & item, const std::wstring & tmp_filename)
|
||||
{
|
||||
if( !system->MakeFilePath(item, path, false, true, config->upload_dirs_chmod) )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Upload::UploadSaveFile(const std::wstring & tmp_filename, const std::wstring & destination)
|
||||
{
|
||||
if( RenameFile(tmp_filename, destination) )
|
||||
if( RenameFile(tmp_filename, path) )
|
||||
{
|
||||
log << log1 << "Content: uploaded a new file: " << destination << logend;
|
||||
log << log1 << "Upload: uploaded a new file: " << path << logend;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int err = errno;
|
||||
|
||||
// !! skasowac takze plik z bazy danych?
|
||||
log << log1 << "Content: can't move the tmp file from: " << tmp_filename << ", to: " << destination << ", ";
|
||||
log.SystemErr(err);
|
||||
log << logend;
|
||||
|
||||
log << log1 << "Upload: can't move the tmp file from: " << tmp_filename << ", to: " << path << logend;
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
||||
{
|
||||
// we should add the file beforehand to get the proper item.id
|
||||
request->status = system->AddFile(item);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
if( system->CreateNewFile(item) )
|
||||
{
|
||||
if( UploadSaveStaticFile(item, tmp_filename) )
|
||||
{
|
||||
request->status = db->EditFileById(item, item.id);
|
||||
|
||||
if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE && config->create_thumb )
|
||||
CreateThumbnail(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
db->DelItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Upload::FunUploadCheckAbuse()
|
||||
{
|
||||
@@ -136,7 +164,6 @@ return true;
|
||||
|
||||
|
||||
|
||||
|
||||
void Upload::UploadMulti()
|
||||
{
|
||||
request->item.Clear(); // clearing and setting date
|
||||
@@ -151,21 +178,12 @@ void Upload::UploadMulti()
|
||||
{
|
||||
const wchar_t * file_name = i->second.filename.c_str();
|
||||
|
||||
request->item.subject = file_name;
|
||||
request->item.url = file_name;
|
||||
request->item.auth = SelectFileType(file_name);
|
||||
request->item.subject = file_name;
|
||||
request->item.url = file_name;
|
||||
request->item.file_type = SelectFileType(file_name);
|
||||
|
||||
functions->PrepareUrl(request->item);
|
||||
request->status = system->AddFile(request->item);
|
||||
|
||||
if( !UploadCreatePath() )
|
||||
return;
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
UploadSaveFile(i->second.tmp_filename, request->item.auth_path);
|
||||
request->status = db->EditAuthById(request->item, request->item.id);
|
||||
}
|
||||
UploadFile(request->item, i->second.tmp_filename);
|
||||
}
|
||||
|
||||
system->RedirectToLastDir();
|
||||
@@ -177,14 +195,14 @@ void Upload::UploadSingle()
|
||||
const std::wstring & new_subject = request->PostVar(L"subject");
|
||||
const std::wstring & new_url = request->PostVar(L"url");
|
||||
bool has_subject = !new_subject.empty();
|
||||
bool has_url = !new_url.empty(); //(new_url && (*new_url)[0] != 0 );
|
||||
bool has_url = !new_url.empty();
|
||||
|
||||
functions->ReadItem(request->item, Item::file); // ReadItem() changes the url if it is empty
|
||||
functions->SetUser(request->item);
|
||||
request->item.privileges = 0644; // !! tymczasowo
|
||||
|
||||
const wchar_t * file_name = request->post_file_tab.begin()->second.filename.c_str();
|
||||
request->item.auth = SelectFileType(file_name);
|
||||
request->item.file_type = SelectFileType(file_name);
|
||||
|
||||
if( !has_subject )
|
||||
request->item.subject = file_name;
|
||||
@@ -194,19 +212,8 @@ void Upload::UploadSingle()
|
||||
request->item.url = file_name;
|
||||
functions->PrepareUrl(request->item);
|
||||
}
|
||||
|
||||
request->status = system->AddFile(request->item);
|
||||
|
||||
// url can be changed by PostFunEmacsAdd()
|
||||
if( !UploadCreatePath() )
|
||||
return;
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
{
|
||||
const std::wstring & tmp_filename = request->post_file_tab.begin()->second.tmp_filename;
|
||||
UploadSaveFile(tmp_filename, request->item.auth_path);
|
||||
request->status = db->EditAuthById(request->item, request->item.id);
|
||||
}
|
||||
UploadFile(request->item, request->post_file_tab.begin()->second.tmp_filename);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
system->RedirectTo(request->item, L"/cat");
|
||||
|
@@ -28,10 +28,14 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
std::wstring path, path_thumb;
|
||||
std::string patha, path_thumba;
|
||||
|
||||
bool HasAccess(const Item & item);
|
||||
bool UploadCreatePath();
|
||||
void UploadSaveFile(const std::wstring & tmp_filename, const std::wstring & destination);
|
||||
void CreateThumbnail(const Item & item);
|
||||
bool UploadSaveStaticFile(const Item & item, const std::wstring & tmp_filename);
|
||||
bool FunUploadCheckAbuse();
|
||||
void UploadFile(Item & item, const std::wstring & tmp_filename);
|
||||
void UploadMulti();
|
||||
void UploadSingle();
|
||||
};
|
||||
|
Reference in New Issue
Block a user