added: parser for multipart forms, files: postmultiparser.h postmultiparser.cpp

added: function: upload




git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@543 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-01-06 19:17:53 +00:00
parent 60fccea703
commit 81faca041a
22 changed files with 1016 additions and 132 deletions

78
content/upload.cpp Executable file
View File

@@ -0,0 +1,78 @@
/*
* 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;
}
}
}
}