79 lines
1.6 KiB
C++
Executable File
79 lines
1.6 KiB
C++
Executable File
/*
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2008-2009, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include "content.h"
|
|
#include "../core/request.h"
|
|
#include "../core/data.h"
|
|
#include <cstdio>
|
|
|
|
|
|
void Content::FunUpload()
|
|
{
|
|
if( request.is_item || !request.CanUseUpload(*request.dir_table.back()) )
|
|
{
|
|
request.status = Error::permision_denied;
|
|
return;
|
|
}
|
|
|
|
|
|
if( data.mounts.CurrentMountType() != Mount::cms )
|
|
{
|
|
request.status = Error::permision_denied;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
void Content::PostFunUpload()
|
|
{
|
|
if( request.is_item || !request.CanUseUpload(*request.dir_table.back()) )
|
|
{
|
|
request.status = Error::permision_denied;
|
|
return;
|
|
}
|
|
|
|
if( data.mounts.CurrentMountType() != Mount::cms )
|
|
{
|
|
request.status = Error::permision_denied;
|
|
return;
|
|
}
|
|
|
|
if( request.post_file_table.empty() )
|
|
{
|
|
request.status = Error::permision_denied;
|
|
return;
|
|
}
|
|
|
|
// !! tutaj w zaleznosci od rozszerzenia dobrac odpowiedni static_auth
|
|
request.item.static_auth = Item::static_other;
|
|
|
|
PostFunEmacs();
|
|
|
|
|
|
if( request.session->done_status == Error::ok )
|
|
{
|
|
std::string path;
|
|
|
|
if( request.MakeDirsOnFS(path) )
|
|
{
|
|
path += '/';
|
|
path += request.item.url;
|
|
const std::string & tmp_filename = request.post_file_table.begin()->second.tmp_filename;
|
|
|
|
if( rename(tmp_filename.c_str(), path.c_str()) < 0 )
|
|
{
|
|
// !! skasowac takze plik z bazy danych
|
|
log << log1 << "Content: can't move the tmp file from: " << tmp_filename;
|
|
log << log1 << ", to: " << path << logend;
|
|
request.status = Error::permision_denied;
|
|
}
|
|
}
|
|
}
|
|
}
|