added: to mount points: file systems

we have two file systems now:
       - simplefs - the files stored on the hard drive have the same structure as in the database (dir1/dir2/file)
       - hashfs - files are stored in special directories
extented: the mountparser can read file system 
added: function download
       this is a default function for items which have static content
  


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@588 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-02-18 23:30:22 +00:00
parent 87747fab06
commit 16e51cd4e5
34 changed files with 487 additions and 157 deletions

View File

@@ -11,7 +11,10 @@ cat.o: ../core/error.h ../core/log.h ../core/user.h ../core/rebus.h
cat.o: ../core/function.h ../core/thread.h ../core/compress.h
cat.o: ../core/acceptencodingparser.h ../core/acceptbaseparser.h
cat.o: ../core/htmlfilter.h ../core/postmultiparser.h ../core/ticket.h
cat.o: ../core/error.h
cat.o: ../core/error.h ../core/data.h ../core/dirs.h ../core/dircontainer.h
cat.o: ../core/users.h ../core/ugcontainer.h ../core/groups.h ../core/group.h
cat.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
cat.o: ../core/mount.h ../core/loadavg.h
content.o: content.h ../core/item.h ../templates/templates.h
content.o: ../templates/patterncacher.h ../templates/misc.h
content.o: ../templates/localefilter.h ../core/locale.h
@@ -81,6 +84,22 @@ default.o: ../core/ugcontainer.h ../core/data.h ../core/dirs.h
default.o: ../core/users.h ../core/groups.h ../core/functions.h
default.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
default.o: ../core/loadavg.h
download.o: content.h ../core/item.h ../templates/templates.h
download.o: ../templates/patterncacher.h ../templates/misc.h
download.o: ../templates/localefilter.h ../core/locale.h
download.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
download.o: ../core/httpsimpleparser.h ../core/log.h ../core/thread.h
download.o: ../core/ticket.h ../core/done.h ../core/request.h
download.o: ../core/requesttypes.h ../core/session.h ../core/done.h
download.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h
download.o: ../core/rebus.h ../core/function.h ../core/thread.h
download.o: ../core/compress.h ../core/acceptencodingparser.h
download.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
download.o: ../core/postmultiparser.h ../core/ticket.h ../core/data.h
download.o: ../core/dirs.h ../core/dircontainer.h ../core/users.h
download.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h
download.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
download.o: ../core/mount.h ../core/loadavg.h
editticket.o: content.h ../core/item.h ../templates/templates.h
editticket.o: ../templates/patterncacher.h ../templates/misc.h
editticket.o: ../templates/localefilter.h ../core/locale.h

View File

@@ -1 +1 @@
o = cat.o content.o createthread.o createticket.o default.o editticket.o emacs.o last.o login.o logout.o ls.o misc_item.o misc_specialfile.o mkdir.o node.o priv.o reload.o rm.o run.o thread.o ticket.o upload.o who.o
o = cat.o content.o createthread.o createticket.o default.o download.o editticket.o emacs.o last.o login.o logout.o ls.o misc_item.o misc_specialfile.o mkdir.o node.o priv.o reload.o rm.o run.o thread.o ticket.o upload.o who.o

View File

@@ -10,6 +10,7 @@
#include "content.h"
#include "../core/request.h"
#include "../core/error.h"
#include "../core/data.h"
@@ -18,7 +19,7 @@ void Content::FunCat()
{
if( !request.is_item )
{
log << log1 << "Content: Cat function requires an item" << logend;
log << log1 << "Content: cat function requires an item" << logend;
request.status = Error::no_item;
return;
}
@@ -29,6 +30,8 @@ void Content::FunCat()
request.status = Error::permission_denied;
return;
}
request.send_as_attachment = request.IsParam("attachment");
}

View File

@@ -46,6 +46,9 @@ return true;
void Content::SetDefaultFunctionForFile()
{
if( request.item.static_auth != Item::static_none )
request.pfunction = data.functions.GetFunction(FUN_DOWNLOAD);
else
if( request.HasReadExecAccess(request.item) )
request.pfunction = data.functions.GetFunction(FUN_RUN);
else
@@ -223,6 +226,9 @@ void Content::MakeStandardFunction()
else
if( request.pfunction->code == FUN_CHOWN )
FunPriv();
else
if( request.pfunction->code == FUN_DOWNLOAD )
FunDownload();
else
request.status = Error::permission_denied;
@@ -309,7 +315,13 @@ void Content::MakePage()
{
bool sent = false;
if( request.is_item && request.item.content_type == Item::ct_raw && request.status == Error::ok && request.pfunction )
if( !request.redirect_to.empty() ||
!request.x_sendfile.empty() )
return;
if( request.is_item && request.item.static_auth == Item::static_none &&
request.item.content_type == Item::ct_raw && request.status == Error::ok && request.pfunction )
{
if( request.pfunction->code == FUN_CAT )
{

View File

@@ -29,6 +29,8 @@ class Content
std::string temp;
void FunDownload();
void CheckSpecialFile();
void PrepareUrl(Item & item);
@@ -53,6 +55,8 @@ class Content
void FunEmacs();
void AddPathToStaticAuth(std::string & path);
void FunCKEditor();
bool FunRmCheckAccess();
@@ -141,7 +145,7 @@ class Content
void UploadSingle();
bool FunUploadCheckAbuse();
void PostFunUpload();
std::string tmp_path, tmp_path2;
std::string tmp_path;
bool FunCreateTicketCheckAccess();
void FunCreateTicket();

48
content/download.cpp Executable file
View File

@@ -0,0 +1,48 @@
/*
* 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"
void Content::FunDownload()
{
// !! moze wywalic to no_item i wszedzie w takich miejscach dac poprostu permission_denied?
if( !request.is_item )
{
log << log1 << "Content: pv function requires an item" << logend;
request.status = Error::no_item;
return;
}
if( !request.HasReadAccess(request.item) ||
request.item.static_auth == Item::static_none ||
data.static_simplefs_dir.empty() )
{
request.status = Error::permission_denied;
return;
}
request.send_as_attachment = request.IsParam("attachment");
if( !request.MakePath(request.x_sendfile) )
{
request.status = Error::permission_denied;
return;
}
}

View File

@@ -27,12 +27,6 @@ bool Content::FunUploadCheckAccess()
return false;
}
// !! in the future the 'upload' can be used everywhere
if( data.mounts.pmount->type != Mount::cms )
{
request.status = Error::permission_denied;
return false;
}
return true;
}
@@ -41,10 +35,7 @@ return true;
bool Content::UploadCreatePath(std::string & path)
{
path.clear();
request.MakePath(path);
if( !request.MakeDirsOnFS() )
if( !request.MakePath(path, true) )
{
request.status = Error::permission_denied;
return false;
@@ -116,11 +107,6 @@ void Content::UploadMulti()
request.item.privileges = 0644; // !! tymczasowo
SetUser(request.item);
if( !UploadCreatePath(tmp_path) )
return;
tmp_path2 = tmp_path; // remember the path
PostFileTable::iterator i = request.post_file_table.begin();
for( ; i != request.post_file_table.end() ; ++i)
@@ -134,14 +120,11 @@ void Content::UploadMulti()
PrepareUrl(request.item);
PostFunEmacsAdd(); // always adding a new item
if( request.session->done_status == Error::ok )
{
tmp_path += '/';
tmp_path += request.item.url; // item.url could have been changed
if( !UploadCreatePath(tmp_path) )
return;
if( request.session->done_status == Error::ok )
UploadSaveFile(i->second.tmp_filename, tmp_path);
tmp_path = tmp_path2; // restoring the oryginal path
}
}
RedirectToLastDir();
@@ -180,16 +163,19 @@ void Content::UploadSingle()
if( !UploadCreatePath(tmp_path) )
return;
tmp_path += '/';
tmp_path += request.item.url; // item.url could have been changed
UploadSaveFile(tmp_filename, tmp_path);
}
if( request.session->done_status == Error::ok )
RedirectTo(request.item);
{
if( !request.IsParam("ckeditor_upload") )
RedirectTo(request.item);
}
}
// !! dodac usuwanie plikow statycznych przez rm
void Content::PostFunUpload()
{