added: function adduser

changed: errors (removed enum, there are macros now)
added: error messages to locales (winix_err_NN)
removed: templates: err_abuse.html err_others.html


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@593 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2010-02-28 00:08:10 +00:00
parent 3702efc5be
commit 71a63cc70e
160 changed files with 912 additions and 607 deletions

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008, Tomasz Sowa

View File

@ -1,5 +1,21 @@
# DO NOT DELETE
adduser.o: content.h ../core/item.h ../templates/templates.h
adduser.o: ../templates/patterncacher.h ../templates/misc.h
adduser.o: ../templates/localefilter.h ../core/locale.h
adduser.o: ../confparser/confparser.h ../templates/ckeditorgetparser.h
adduser.o: ../core/httpsimpleparser.h ../core/log.h ../core/thread.h
adduser.o: ../core/ticket.h ../core/done.h ../core/request.h
adduser.o: ../core/requesttypes.h ../core/session.h ../core/done.h
adduser.o: ../core/item.h ../core/error.h ../core/log.h ../core/user.h
adduser.o: ../core/rebus.h ../core/function.h ../core/thread.h
adduser.o: ../core/compress.h ../core/acceptencodingparser.h
adduser.o: ../core/acceptbaseparser.h ../core/htmlfilter.h
adduser.o: ../core/postmultiparser.h ../core/ticket.h ../core/data.h
adduser.o: ../core/dirs.h ../core/dircontainer.h ../core/users.h
adduser.o: ../core/ugcontainer.h ../core/groups.h ../core/group.h
adduser.o: ../core/functions.h ../core/lastcontainer.h ../core/mounts.h
adduser.o: ../core/mount.h ../core/loadavg.h ../core/db.h
cat.o: content.h ../core/item.h ../templates/templates.h
cat.o: ../templates/patterncacher.h ../templates/misc.h
cat.o: ../templates/localefilter.h ../core/locale.h

View File

@ -1 +1 @@
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
o = adduser.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

111
content/adduser.cpp Executable file
View File

@ -0,0 +1,111 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* All rights reserved.
*
*/
#include "content.h"
#include "../core/request.h"
#include "../core/data.h"
#include "../core/db.h"
bool Content::CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass)
{
if( !login || !pass || !conf_pass )
{
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
if( login->empty() )
{
request.status = WINIX_ERR_LOGIN_EMPTY;
return false;
}
if( *pass != *conf_pass )
{
request.status = WINIX_ERR_PASSWORDS_DIFFERENT;
return false;
}
if( pass->size() < 5 )
{
request.status = WINIX_ERR_PASSWORD_TOO_SHORT;
return false;
}
if( data.users.IsUser(*login) )
{
request.status = WINIX_ERR_USER_EXISTS;
return false;
}
return true;
}
void Content::PostFunAddUser()
{
User user;
std::string * login = request.PostVar("login");
std::string * pass = request.PostVar("password");
std::string * conf_pass = request.PostVar("confirmpassword");
std::string * email = request.PostVar("email");
if( !CheckAddUserVars(login, pass, conf_pass) )
return;
user.name = *login;
if( email )
user.email = *email;
request.status = db.AddUser(user, *pass);
if( request.status == WINIX_ERR_OK )
{
if( data.users.AddUser(user) )
{
if( !request.session->puser )
LoginUser(user.id, false);
log << log2 << "Content: added a new user: " << user.name << logend;
}
else
{
log << log1 << "Content: I can't add to data.users: " << user.name
<< " but the user was added to the db correctly" << logend;
}
if( request.is_item )
RedirectTo(request.item);
else
RedirectToLastDir();
}
}
void Content::FunAddUser()
{
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -20,14 +20,14 @@ void Content::FunCat()
if( !request.is_item )
{
log << log1 << "Content: cat function requires an item" << logend;
request.status = Error::no_item;
request.status = WINIX_ERR_NO_ITEM;
return;
}
if( !request.HasReadAccess(request.item) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -125,7 +125,7 @@ void Content::MakeStandardFunction()
if( request.pfunction )
{
request.status = Error::no_item;
request.status = WINIX_ERR_NO_ITEM;
log << log1 << "Content: in authorizer mode only 'cat' funtion is available and must "
"be default (not in the url)" << logend;
return;
@ -142,7 +142,7 @@ void Content::MakeStandardFunction()
if( !request.pfunction )
{
request.status = Error::no_function;
request.status = WINIX_ERR_NO_FUNCTION;
log << log1 << "Content: no function (neither cat nor ls)" << logend;
return;
}
@ -230,7 +230,10 @@ void Content::MakeStandardFunction()
if( request.pfunction->code == FUN_DOWNLOAD )
FunDownload();
else
request.status = Error::permission_denied;
if( request.pfunction->code == FUN_ADDUSER )
FunAddUser();
else
request.status = WINIX_ERR_PERMISSION_DENIED;
}
@ -242,7 +245,7 @@ void Content::MakePost()
{
if( request.role == Request::authorizer )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}
@ -251,7 +254,7 @@ void Content::MakePost()
if( !request.pfunction )
{
request.status = Error::no_function;
request.status = WINIX_ERR_NO_FUNCTION;
log << log1 << "Content: MakePost: no function" << logend;
return;
}
@ -304,6 +307,10 @@ void Content::MakePost()
PostFunEmacs();
break;
case FUN_ADDUSER:
PostFunAddUser();
break;
default:
log << log1 << "Content: unknown post function" << logend;
break;
@ -321,7 +328,7 @@ bool sent = false;
if( request.is_item && request.item.auth == Item::auth_none &&
request.item.content_type == Item::ct_raw && request.status == Error::ok && request.pfunction )
request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK && request.pfunction )
{
if( request.pfunction->code == FUN_CAT )
{
@ -353,18 +360,18 @@ void Content::Make()
}
// request.status can be changed by function_parser
if( request.status == Error::ok )
if( request.status == WINIX_ERR_OK )
{
if( DirsHaveReadExecPerm() )
{
if( request.method == Request::post )
MakePost();
if( request.redirect_to.empty() && request.status == Error::ok )
if( request.redirect_to.empty() && request.status == WINIX_ERR_OK )
MakeStandardFunction();
}
else
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
}
if( request.session->spam_score > 0 )
@ -467,13 +474,13 @@ void Content::ReadAdditionalInfo()
if( data.mounts.pmount->type == Mount::thread )
{
if( db.GetThreadByDirId(request.dir_table.back()->id, request.thread) == Error::ok )
if( db.GetThreadByDirId(request.dir_table.back()->id, request.thread) == WINIX_ERR_OK )
request.is_thread = true;
}
else
if( data.mounts.pmount->type == Mount::ticket )
{
if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) == Error::ok )
if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) == WINIX_ERR_OK )
{
request.is_ticket = true;

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -36,6 +36,10 @@ class Content
void PrepareUrl(Item & item);
bool CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass);
void PostFunAddUser();
void FunAddUser();
void SetDefaultFunctionForFile();
void SetDefaultFunctionForDir();
void SetDefaultFunction();
@ -87,6 +91,7 @@ class Content
void CheckAccessToItems();
void LoginUser(long user_id, bool remember_me);
void FunLogin();
void PostFunLogin();

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -21,7 +21,7 @@ bool Content::FunCreateThreadCheckAccess()
{
if( !request.CanCreateThread() )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
@ -35,9 +35,9 @@ bool Content::FunCreateThreadCheckAbuse()
{
if( !CheckRebus() )
{
request.status = Error::incorrect_rebus;
request.status = WINIX_ERR_INCORRECT_REBUS;
request.session->done = Done::added_thread;
request.session->done_status = Error::incorrect_rebus;
request.session->done_status = WINIX_ERR_INCORRECT_REBUS;
return false;
}
@ -46,9 +46,9 @@ bool Content::FunCreateThreadCheckAbuse()
if( request.session->spam_score > 0 )
{
request.status = Error::spam;
request.status = WINIX_ERR_SPAM;
request.session->done = Done::added_thread;
request.session->done_status = Error::spam;
request.session->done_status = WINIX_ERR_SPAM;
log << log1 << "Content: ignoring due to suspected spamming" << logend;
return false;
@ -80,7 +80,7 @@ void Content::AddThread()
void Content::PostFunCreateThreadLogAndRedirect()
{
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
request.session->done = Done::added_thread;
@ -113,7 +113,7 @@ void Content::PostFunCreateThread()
Mkdir(request.item, true);
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
ReadItemContentWithType(request.item);
request.item.type = Item::file;
@ -121,7 +121,7 @@ void Content::PostFunCreateThread()
request.item.parent_id = request.dir_table.back()->id;
PostFunEmacsAdd();
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
AddThread();
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -22,7 +22,7 @@ bool Content::FunCreateTicketCheckAccess()
{
if( !request.CanCreateTicket() )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
@ -36,9 +36,9 @@ bool Content::FunCreateTicketCheckAbuse(const Done & done)
{
if( !CheckRebus() )
{
request.status = Error::incorrect_rebus;
request.status = WINIX_ERR_INCORRECT_REBUS;
request.session->done = done;
request.session->done_status = Error::incorrect_rebus;
request.session->done_status = WINIX_ERR_INCORRECT_REBUS;
return false;
}
@ -47,9 +47,9 @@ bool Content::FunCreateTicketCheckAbuse(const Done & done)
if( request.session->spam_score > 0 )
{
request.status = Error::spam;
request.status = WINIX_ERR_SPAM;
request.session->done = done;
request.session->done_status = Error::spam;
request.session->done_status = WINIX_ERR_SPAM;
log << log1 << "Content: ignoring due to suspected spamming" << logend;
return false;
@ -168,7 +168,7 @@ void Content::AddTicket()
void Content::PostFunCreateTicketLogAndRedirect()
{
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
request.session->done = Done::added_ticket;
@ -201,7 +201,7 @@ void Content::PostFunCreateTicket()
Mkdir(request.item, true);
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
ReadItemContentWithType(request.item);
request.item.type = Item::file;
@ -209,7 +209,7 @@ void Content::PostFunCreateTicket()
request.item.parent_id = request.dir_table.back()->id;
PostFunEmacsAdd();
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
AddTicket();
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -33,7 +33,7 @@ long defaultid = -1;
pdir = data.dirs.GetDir(dir);
if( !pdir )
throw Error(Error::incorrect_dir);
throw Error(WINIX_ERR_INCORRECT_DIR);
if( file.empty() )
{
@ -49,7 +49,7 @@ long defaultid = -1;
defaultid = db.GetFileId(pdir->id, file);
if( defaultid == -1 )
throw Error(Error::no_item);
throw Error(WINIX_ERR_NO_ITEM);
}
else
{
@ -72,7 +72,7 @@ void Content::PostFunDefault()
if( !request.HasWriteAccess(*request.dir_table.back()) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}
@ -82,7 +82,7 @@ void Content::PostFunDefault()
long defaultid = PostFunDefaultParsePath();
request.session->done_status = db.EditDefaultItem(request.dir_table.back()->id, defaultid);
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
request.dir_table.back()->default_item = defaultid;
}
catch(const Error & e)
@ -91,7 +91,7 @@ void Content::PostFunDefault()
}
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
RedirectTo(*request.dir_table.back());
else
log << log1 << "Content: PostFunDefaultItem: Error: " << request.session->done_status << logend;
@ -104,7 +104,7 @@ void Content::FunDefault()
{
if( !request.HasWriteAccess(*request.dir_table.back()) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -21,7 +21,7 @@ void Content::FunDownload()
if( !request.is_item )
{
log << log1 << "Content: pv function requires an item" << logend;
request.status = Error::no_item;
request.status = WINIX_ERR_NO_ITEM;
return;
}
@ -30,7 +30,7 @@ void Content::FunDownload()
request.item.auth == Item::auth_none ||
data.auth_simplefs_dir.empty() )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}
@ -38,7 +38,7 @@ void Content::FunDownload()
if( !request.MakePath(request.x_sendfile) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -20,7 +20,7 @@ bool Content::FunEditTicketCheckAccess()
{
if( !request.CanEditTicket() )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
@ -31,7 +31,7 @@ return true;
void Content::EditTicketCheckFirstItem()
{
if( request.session->done_status != Error::ok )
if( request.session->done_status != WINIX_ERR_OK )
return;
@ -49,7 +49,7 @@ void Content::EditTicketCheckFirstItem()
request.session->done_status = db.AddItem(item);
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
log << log2 << "Content: added the first item with content for the ticket, item.id: " << item.id << logend;
request.ticket.item_id = item.id;
@ -61,7 +61,7 @@ void Content::EditTicketCheckFirstItem()
void Content::EditTicketModTicket()
{
if( request.session->done_status != Error::ok )
if( request.session->done_status != WINIX_ERR_OK )
return;
Ticket ticket;
@ -81,7 +81,7 @@ void Content::EditTicketModTicket()
void Content::EditTicketModDir()
{
if( request.session->done_status != Error::ok )
if( request.session->done_status != WINIX_ERR_OK )
return;
// we don't modify the url
@ -99,7 +99,7 @@ void Content::EditTicketModDir()
void Content::EditTicketModFirstItem()
{
if( request.session->done_status != Error::ok )
if( request.session->done_status != WINIX_ERR_OK )
return;
// modyfing the first item (the one with content)
@ -119,7 +119,7 @@ void Content::EditTicketModFirstItem()
void Content::PostFunEditTicketLogAndRedirect()
{
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
request.session->done = Done::edited_ticket;
@ -149,9 +149,9 @@ void Content::PostFunEditTicket()
return;
}
if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) != Error::ok )
if( db.GetTicketByDirId(request.dir_table.back()->id, request.ticket) != WINIX_ERR_OK )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -24,14 +24,14 @@ bool Content::FunEmacsCheckAccess()
// adding a new item
if( !request.CanUseEmacs(*request.dir_table.back()) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
}
else // editing an existing item
if( !request.CanUseEmacs(request.item) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
@ -44,7 +44,7 @@ void Content::PostFunEmacsAdd()
request.session->done = Done::added_item;
request.session->done_status = db.AddItem(request.item);
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
log << log2 << "Content: added a new item" << logend;
request.notify_code |= WINIX_NOTIFY_ITEM_ADD;
@ -59,7 +59,7 @@ void Content::PostFunEmacsEdit(bool with_url)
request.session->done = Done::edited_item;
request.session->done_status = db.EditItemById(request.item, with_url);
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
TemplatesFunctions::pattern_cacher.UpdatePattern(request.item);
log << log2 << "Content: modified an item" << logend;
@ -73,9 +73,9 @@ bool Content::PostEmacsCheckAbuse(bool adding)
{
if( !CheckRebus() )
{
request.status = Error::incorrect_rebus;
request.status = WINIX_ERR_INCORRECT_REBUS;
request.session->done = (adding)? Done::added_item : Done::edited_item;
request.session->done_status = Error::incorrect_rebus;
request.session->done_status = WINIX_ERR_INCORRECT_REBUS;
return false;
}
@ -85,9 +85,9 @@ bool Content::PostEmacsCheckAbuse(bool adding)
if( request.session->spam_score > 0 )
{
request.status = Error::spam;
request.status = WINIX_ERR_SPAM;
request.session->done = (adding)? Done::added_item : Done::edited_item;
request.session->done_status = Error::spam;
request.session->done_status = WINIX_ERR_SPAM;
log << log1 << "Content: ignoring due to suspected spamming" << logend;
return false;
@ -128,7 +128,7 @@ void Content::PostFunEmacs()
bool adding = !request.is_item;
bool edit_with_url = ReadItem(request.item, Item::file);
request.session->done_status = Error::ok;
request.session->done_status = WINIX_ERR_OK;
if( !PostEmacsCheckAbuse(adding) )
return;
@ -146,7 +146,7 @@ void Content::PostFunEmacs()
}
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
PostFunEmacsModifyMountPoint(adding);
CheckSpecialFile();

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -18,6 +18,26 @@
void Content::LoginUser(long user_id, bool remember_me)
{
request.session->puser = data.users.GetUser(user_id);
request.session->spam_score = 0;
if( !request.session->puser )
{
log << log1 << "Content: user id: " << user_id << " is not in data.users" << logend;
return;
}
request.session->remember_me = remember_me;
data.last.UserLogin(user_id, request.session->puser->name, inet_addr(request.env_remote_addr), request.session->id);
data.how_many_logged += 1;
log << log2 << "User " << request.session->puser->name << " (id: " << user_id << ") logged" << logend;
}
void Content::PostFunLogin()
{
@ -29,24 +49,7 @@ void Content::PostFunLogin()
long user_id;
if( login && pass && db.CheckUser(*login, *pass, user_id) )
{
request.session->puser = data.users.GetUser(user_id);
request.session->spam_score = 0;
if( !request.session->puser )
{
log << log1 << "Content: user: " << login << " is in the database but is not in data.users" << logend;
return;
}
if( remem )
request.session->remember_me = true;
data.last.UserLogin(user_id, *login, inet_addr(request.env_remote_addr), request.session->id);
data.how_many_logged += 1;
log << log2 << "User " << login << " (id: " << user_id << ") logged" << logend;
}
LoginUser(user_id, remem != 0);
// !! moze zglosic komunikat o nie poprawnym logowaniu
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -21,7 +21,7 @@ bool Content::FunMkdirCheckAccess()
{
if( request.is_item || !request.CanUseMkdir(*request.dir_table.back()) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
@ -34,7 +34,7 @@ void Content::Mkdir(Item & item, bool add_to_dir_table)
{
request.session->done_status = db.AddItem(item);
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
Item * pdir = data.dirs.AddDir(item);
@ -56,7 +56,7 @@ void Content::PostFunMkdir(bool add_to_dir_table, int privileges)
Mkdir(request.item, add_to_dir_table);
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
request.notify_code |= WINIX_NOTIFY_DIR_ADD;
RedirectTo(request.item);

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
@ -27,7 +27,7 @@ bool Content::PrivCheckAccess()
if( !request.session->puser || (request.is_item && request.IsParam("r")) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -22,7 +22,7 @@ void Content::FunReloadTemplates()
notify.ReadTemplates(); // make sure that ReadTemplates() is using some kind of locking
request.session->done = Done::reloaded_templates;
request.session->done_status = Error::ok;
request.session->done_status = WINIX_ERR_OK;
}
@ -35,7 +35,7 @@ void Content::FunReload()
if( !request.session->puser || !request.session->puser->super_user )
{
log << log1 << "Content: Only an admin has access to reload function" << logend;
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -21,14 +21,14 @@ bool Content::FunRmCheckAccess()
{
if( !request.CanRemove(*request.dir_table.back()) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
}
else
if( !request.CanRemove(request.item) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
@ -64,7 +64,7 @@ void Content::FunRmDirRecursive()
request.session->done = Done::deleted_dir;
request.session->done_status = Error::ok;
request.session->done_status = WINIX_ERR_OK;
request.session->done_timer = 2;
// redirect to the last valid directory
@ -75,7 +75,7 @@ void Content::FunRmDirRecursive()
void Content::FunRmDir()
{
if( request.param_table.empty() )
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
else
if( request.IsParam("confirm") )
return;
@ -83,7 +83,7 @@ void Content::FunRmDir()
if( request.IsParam("r") )
FunRmDirRecursive();
else
request.status = Error::unknown_param;
request.status = WINIX_ERR_UNKNOWN_PARAM;
}
@ -100,7 +100,7 @@ void Content::FunRm()
{
if( db.DelItem( request.item ) )
{
request.session->done_status = Error::ok;
request.session->done_status = WINIX_ERR_OK;
log << log2 << "Content: deleted item: subject: " << request.item.subject << ", id: " << request.item.id << logend;
TemplatesFunctions::pattern_cacher.DeletePattern(request.item);
@ -113,7 +113,7 @@ void Content::FunRm()
}
else
{
request.session->done_status = Error::no_item;
request.session->done_status = WINIX_ERR_NO_ITEM;
}
request.session->done = Done::deleted_item;
@ -125,7 +125,7 @@ void Content::FunRm()
{
if( !request.IsParam("confirm") )
//request.result = Request::err404;
request.status = Error::unknown_param;
request.status = WINIX_ERR_UNKNOWN_PARAM;
}
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -19,13 +19,13 @@ void Content::FunRun()
if( !request.is_item )
{
log << log1 << "Content: Run function requires an item" << logend;
request.status = Error::no_item;
request.status = WINIX_ERR_NO_ITEM;
return;
}
if( !request.HasReadExecAccess(request.item) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -35,7 +35,7 @@ void Content::FunThread()
{
if( request.is_item )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -29,7 +29,7 @@ void Content::TicketDeleteFirst()
if( !request.HasReadAccess(request.item_table[i]) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
}
request.item_table.erase(request.item_table.begin() + i);
@ -46,7 +46,7 @@ void Content::FunTicket()
{
if( request.is_item || data.mounts.pmount->type != Mount::ticket )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -23,7 +23,7 @@ bool Content::FunUploadCheckAccess()
{
if( request.is_item || !request.CanUseUpload(*request.dir_table.back()) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
@ -37,7 +37,7 @@ bool Content::UploadCreatePath(std::string & path)
{
if( !request.MakePath(path, true) )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return false;
}
@ -62,7 +62,7 @@ void Content::UploadSaveFile(const std::string & tmp_filename, const std::string
log.SystemErr(err);
log << logend;
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
}
}
@ -72,9 +72,9 @@ bool Content::FunUploadCheckAbuse()
{
if( !CheckRebus() )
{
request.status = Error::incorrect_rebus;
request.status = WINIX_ERR_INCORRECT_REBUS;
request.session->done = Done::added_thread;
request.session->done_status = Error::incorrect_rebus;
request.session->done_status = WINIX_ERR_INCORRECT_REBUS;
return false;
}
@ -83,9 +83,9 @@ bool Content::FunUploadCheckAbuse()
if( request.session->spam_score > 0 )
{
request.status = Error::spam;
request.status = WINIX_ERR_SPAM;
request.session->done = Done::added_thread;
request.session->done_status = Error::spam;
request.session->done_status = WINIX_ERR_SPAM;
log << log1 << "Content: ignoring due to suspected spamming" << logend;
return false;
@ -123,7 +123,7 @@ void Content::UploadMulti()
if( !UploadCreatePath(tmp_path) )
return;
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
UploadSaveFile(i->second.tmp_filename, tmp_path);
}
@ -156,7 +156,7 @@ void Content::UploadSingle()
PostFunEmacsAdd(); // always adding a new item
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
const std::string & tmp_filename = request.post_file_table.begin()->second.tmp_filename;
@ -167,7 +167,7 @@ void Content::UploadSingle()
}
if( request.session->done_status == Error::ok )
if( request.session->done_status == WINIX_ERR_OK )
{
if( !request.IsParam("ckeditor_upload") )
RedirectTo(request.item);
@ -184,7 +184,7 @@ void Content::PostFunUpload()
if( request.post_file_table.empty() )
{
request.status = Error::permission_denied;
request.status = WINIX_ERR_PERMISSION_DENIED;
return;
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -24,7 +24,6 @@ dirs.o: request.h requesttypes.h session.h done.h compress.h
dirs.o: acceptencodingparser.h acceptbaseparser.h htmlfilter.h
dirs.o: postmultiparser.h
done.o: done.h
error.o: error.h log.h
function.o: function.h item.h
functioncodeparser.o: functioncodeparser.h item.h function.h log.h
functionparser.o: functionparser.h requesttypes.h log.h item.h error.h data.h

View File

@ -1 +1 @@
o = acceptbaseparser.o compress.o config.o data.o db.o db_itemcolumns.o dircontainer.o dirs.o done.o error.o function.o functioncodeparser.o functionparser.o functions.o groups.o htmlfilter.o httpsimpleparser.o lastcontainer.o loadavg.o locale.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o postmultiparser.o rebus.o request.o requestcontroller.o session.o sessioncontainer.o sessionmanager.o sessionparser.o users.o
o = acceptbaseparser.o compress.o config.o data.o db.o db_itemcolumns.o dircontainer.o dirs.o done.o function.o functioncodeparser.o functionparser.o functions.o groups.o htmlfilter.o httpsimpleparser.o lastcontainer.o loadavg.o locale.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o postmultiparser.o rebus.o request.o requestcontroller.o session.o sessioncontainer.o sessionmanager.o sessionparser.o users.o

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -108,7 +108,7 @@ bool was_connection = true;
else
{
log << log1 << "Db: Connection to db server cannot be established" << logend;
throw Error(Error::db_fatal_error_during_connecting);
throw Error(WINIX_ERR_DB_FATAL_ERROR_DURING_CONNECTING);
}
}
@ -157,7 +157,7 @@ PGresult * Db::AssertQuery(const std::string & q)
log << log1 << "Db: Problem with query: \"" << q << '\"' << logend;
log << log1 << "Db: " << PQerrorMessage(pg_conn) << logend;
throw Error(Error::db_incorrect_query);
throw Error(WINIX_ERR_DB_INCORRECT_QUERY);
}
return r;
@ -171,7 +171,7 @@ void Db::AssertResultStatus(PGresult * r, ExecStatusType t)
{
log << "Db: Incorrect result status: " << PQerrorMessage(pg_conn) << logend;
throw Error(Error::db_incorrent_result_status);
throw Error(WINIX_ERR_DB_INCORRENT_RESULT_STATUS);
}
}
@ -185,7 +185,7 @@ int Db::AssertColumn(PGresult * r, const char * column_name)
{
log << log1 << "Db: there is no column: " << column_name << logend;
throw Error(Error::db_no_column);
throw Error(WINIX_ERR_DB_NO_COLUMN);
}
return c;
@ -200,7 +200,7 @@ const char * Db::AssertValue(PGresult * r, int row, int col)
{
log << log1 << "Db: there is no such an item in the result, row:" << row << ", col:" << col << logend;
throw Error(Error::no_item);
throw Error(WINIX_ERR_NO_ITEM);
}
return res;
@ -234,12 +234,12 @@ bool Db::CheckUser(std::string & login, std::string & password, long & user_id)
int rows = PQntuples(r);
if( rows == 0 )
throw Error(Error::db_incorrect_login);
throw Error(WINIX_ERR_DB_INCORRECT_LOGIN);
if( rows > 1 )
{
log << log1 << "Db: there is more than one user: " << login << " (with the same password)" << logend;
throw Error(Error::db_more_than_one_login);
throw Error(WINIX_ERR_DB_MORE_THAN_ONE_LOGIN);
}
int cuser_id = AssertColumn(r, "id");
@ -262,6 +262,40 @@ return user_ok;
Error Db::AddUser(User & user, const std::string & password)
{
PGresult * r = 0;
Error status = WINIX_ERR_OK;
try
{
AssertConnection();
std::ostringstream query;
query << "insert into core.user (login, password, super_user, email, cms_notify, thread_notify) values (";
query << '\'' << Escape(user.name) << "', ";
query << '\'' << Escape(password) << "', ";
query << '\'' << static_cast<int>(user.super_user) << "', ";
query << '\'' << Escape(user.email) << "', ";
query << '\'' << user.cms_notify << "', ";
query << '\'' << user.thread_notify << "');";
r = AssertQuery(query.str());
AssertResultStatus(r, PGRES_COMMAND_OK);
user.id = AssertCurrval("core.user_id_seq");
}
catch(const Error & e)
{
status = e;
}
ClearResult(r);
return status;
}
@ -401,7 +435,7 @@ long Db::AssertCurrval(const char * table)
if( PQntuples(r) != 1 )
{
log << log1 << "Db: error (currval) for table: " << table << ", " << PQerrorMessage(pg_conn) << logend;
throw Error(Error::db_err_currval);
throw Error(WINIX_ERR_DB_ERR_CURRVAL);
}
long res = strtol( AssertValue(r, 0, 0), 0, 10 );
@ -413,7 +447,7 @@ return res;
Error Db::AddItemIntoItem(Item & item)
{
PGresult * r = 0;
Error result = Error::ok;
Error result = WINIX_ERR_OK;
bool url_without_id = false;
try
@ -468,7 +502,7 @@ return result;
Error Db::AddItemIntoContent(Item & item)
{
PGresult * r = 0;
Error result = Error::ok;
Error result = WINIX_ERR_OK;
try
{
@ -499,14 +533,14 @@ return result;
Error Db::AddItem(Item & item)
{
Error result = Error::ok;
Error result = WINIX_ERR_OK;
if( item.type == Item::file )
result = AddItemIntoContent(item);
else
item.content_id = -1;
if( result == Error::ok )
if( result == WINIX_ERR_OK )
result = AddItemIntoItem(item);
return result;
@ -519,7 +553,7 @@ return result;
Error Db::EditItemInItem(Item & item, bool with_url)
{
PGresult * r = 0;
Error result = Error::ok;
Error result = WINIX_ERR_OK;
bool url_without_id = false;
try
@ -578,7 +612,7 @@ return result;
Error Db::EditItemInContent(Item & item)
{
PGresult * r = 0;
Error result = Error::ok;
Error result = WINIX_ERR_OK;
try
{
@ -607,7 +641,7 @@ return result;
Error Db::EditItemGetId(Item & item)
{
PGresult * r = 0;
Error result = Error::ok;
Error result = WINIX_ERR_OK;
try
{
@ -620,7 +654,7 @@ Error Db::EditItemGetId(Item & item)
AssertResultStatus(r, PGRES_TUPLES_OK);
if( PQntuples(r) != 1 || PQnfields(r) != 2 )
throw Error(Error::no_item);
throw Error(WINIX_ERR_NO_ITEM);
// we cannot use AssertColumn() with a name because both columns are called 'id'
item.id = atol( AssertValue(r, 0, 0) );
@ -640,7 +674,7 @@ return result;
Error Db::EditItemGetContentId(Item & item)
{
PGresult * r = 0;
Error result = Error::ok;
Error result = WINIX_ERR_OK;
try
{
@ -654,7 +688,7 @@ Error Db::EditItemGetContentId(Item & item)
AssertResultStatus(r, PGRES_TUPLES_OK);
if( PQntuples(r) != 1 || PQnfields(r) != 1 )
throw Error(Error::no_item);
throw Error(WINIX_ERR_NO_ITEM);
item.content_id = atol( AssertValue(r, 0, 0) );
}
@ -673,19 +707,19 @@ return result;
// !! moze nazwa poprostu EditItem (nie trzeba tego ById) ? (sprawdzic czy nie koliduje z inna nazwa)
Error Db::EditItemById(Item & item, bool with_url)
{
Error result = Error::ok;
Error result = WINIX_ERR_OK;
// !! dla katalogow nie testowane jeszcze
if( item.type == Item::file )
result = EditItemGetContentId(item);
if( result == Error::ok )
if( result == WINIX_ERR_OK )
{
if( item.type == Item::file )
result = EditItemInContent(item);
if( result == Error::ok )
if( result == WINIX_ERR_OK )
result = EditItemInItem(item, with_url);
}
@ -700,11 +734,11 @@ Error Db::EditItemByUrl(Item & item, bool with_url)
{
Error result = EditItemGetId(item);
if( result == Error::ok )
if( result == WINIX_ERR_OK )
{
result = EditItemInContent(item);
if( result == Error::ok )
if( result == WINIX_ERR_OK )
result = EditItemInItem(item, with_url);
}
@ -716,7 +750,7 @@ return result;
Error Db::EditDefaultItem(long id, long new_default_item)
{
PGresult * r = 0;
Error result = Error::ok;
Error result = WINIX_ERR_OK;
try
{
@ -735,7 +769,7 @@ Error Db::EditDefaultItem(long id, long new_default_item)
if( rows == 0 )
{
result = Error::no_item;
result = WINIX_ERR_NO_ITEM;
log << log1 << "Db: EditDefaultItem: no such item, id: " << id << logend;
}
}
@ -914,7 +948,7 @@ void Db::GetItem(std::vector<Item> & item_table, long id)
Error Db::GetItem(long parent_id, const std::string & url, Item & item)
{
PGresult * r = 0;
Error result = Error::ok;
Error result = WINIX_ERR_OK;
try
{
@ -930,7 +964,7 @@ Error Db::GetItem(long parent_id, const std::string & url, Item & item)
int rows = PQntuples(r);
if( rows == 0 )
throw Error(Error::no_item);
throw Error(WINIX_ERR_NO_ITEM);
ItemColumns col;
col.SetColumns(r);
@ -950,7 +984,7 @@ return result;
Error Db::GetItemById(long item_id, Item & item)
{
PGresult * r = 0;
Error result = Error::ok;
Error result = WINIX_ERR_OK;
try
{
@ -965,7 +999,7 @@ Error Db::GetItemById(long item_id, Item & item)
int rows = PQntuples(r);
if( rows == 0 )
throw Error(Error::no_item);
throw Error(WINIX_ERR_NO_ITEM);
ItemColumns col;
col.SetColumns(r);
@ -1074,7 +1108,7 @@ return result;
Error Db::EditPrivById(Item & item, long id)
{
PGresult * r = 0;
Error result = Error::ok;
Error result = WINIX_ERR_OK;
try
{
@ -1106,7 +1140,7 @@ return result;
Error Db::DelDirById(long id)
{
Error result = Error::ok;
Error result = WINIX_ERR_OK;
PGresult * r = 0;
const char * crows;
@ -1224,7 +1258,7 @@ void Db::DelItemDelContent(const Item & item)
Error Db::DelItemCountContents(const Item & item, long & contents)
{
Error result = Error::ok;
Error result = WINIX_ERR_OK;
PGresult * r = 0;
try
@ -1259,7 +1293,7 @@ long contents;
Error result = DelItemCountContents(item, contents);
if( result == Error::ok && contents == 1 )
if( result == WINIX_ERR_OK && contents == 1 )
DelItemDelContent(item);
return DelItemDelItem(item);
@ -1331,7 +1365,7 @@ void Db::GetUsers(UGContainer<User> & user_table)
User u;
long last_id = -1;
UGContainer<User>::Iterator iter;
UGContainer<User>::Iterator iter = user_table.End();
for(int i = 0 ; i<rows ; ++i)
{
@ -1348,12 +1382,16 @@ void Db::GetUsers(UGContainer<User> & user_table)
log << log1 << "Db: get user: id:" << u.id << ", name:" << u.name << ", super_user:" << u.super_user << logend;
iter = user_table.PushBack( u );
if( iter == user_table.End() )
log << log1 << "Db: can't add a user: " << u.name << logend;
last_id = u.id;
}
long group_id = atol( AssertValue(r, i, cgroup_id) );
if( !PQgetisnull(r, i, cgroup_id) && group_id!=-1 && !user_table.Empty() )
if( !PQgetisnull(r, i, cgroup_id) && group_id!=-1 && iter!=user_table.End() )
{
iter->groups.push_back(group_id);
log << log3 << "Db: user:" << iter->name << " is a member of group_id:" << group_id << logend;
@ -1485,7 +1523,7 @@ return buffer;
Error Db::GetThreadByDirId(long dir_id, Thread & thread)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1506,7 +1544,7 @@ Error Db::GetThreadByDirId(long dir_id, Thread & thread)
log << log1 << "Db: there is more than one thread with dir_id: " << dir_id << logend;
else
if( rows == 0 )
throw Error(Error::no_thread);
throw Error(WINIX_ERR_NO_THREAD);
int cid = AssertColumn(r, "id");
int cparent_id = AssertColumn(r, "parent_id");
@ -1542,7 +1580,7 @@ return status;
Error Db::GetThreads(long parent_id, std::vector<Thread> & thread_tab)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1604,7 +1642,7 @@ return status;
Error Db::AddThread(Thread & thread)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1638,7 +1676,7 @@ return status;
Error Db::EditThreadAddItem(long dir_id, long item_id)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1664,7 +1702,7 @@ return status;
Error Db::EditThreadRemoveItem(long dir_id)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1703,7 +1741,7 @@ return status;
Error Db::RemoveThread(long dir_id)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1737,7 +1775,7 @@ return status;
Error Db::GetTicketByDirId(long dir_id, Ticket & ticket)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1758,7 +1796,7 @@ Error Db::GetTicketByDirId(long dir_id, Ticket & ticket)
log << log1 << "Db: there is more than one ticket with dir_id: " << dir_id << logend;
else
if( rows == 0 )
throw Error(Error::no_ticket);
throw Error(WINIX_ERR_NO_TICKET);
TicketColumns tc;
@ -1782,7 +1820,7 @@ return status;
Error Db::GetTickets(long parent_id, std::vector<Ticket> & ticket_tab)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1856,7 +1894,7 @@ return is_ticket;
Error Db::AddTicket(Ticket & ticket)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1892,7 +1930,7 @@ return status;
Error Db::EditTicketById(Ticket & ticket)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1927,7 +1965,7 @@ return status;
Error Db::EditTicketRemoveItem(long item_id)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{
@ -1954,7 +1992,7 @@ return status;
Error Db::RemoveTicket(long dir_id)
{
PGresult * r = 0;
Error status = Error::ok;
Error status = WINIX_ERR_OK;
try
{

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -44,6 +44,8 @@ public:
void Init(const std::string & database, const std::string & user, const std::string & pass);
bool CheckUser(std::string & login, std::string & password, long & user_id);
Error AddUser(User & user, const std::string & password);
Error AddItem(Item & item);
Error EditItemById(Item & item, bool with_url = true);
Error EditItemByUrl(Item & item, bool with_url = true);

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -52,7 +52,7 @@ void Dirs::CheckRootDir()
// !! upewnic sie ze baza nie zmieni url (gdyby wczesniej juz byl w bazie pusty url)
// !! zrobic jakis wyjatek do wprowadzania roota?
if( db.AddItem(root) == Error::ok )
if( db.AddItem(root) == WINIX_ERR_OK )
{
dir_table.PushBack(root);
}
@ -298,7 +298,7 @@ void Dirs::DeleteDir(long id)
DeleteDir(p->second->id);
}
if( db.DelDirById(id) == Error::ok )
if( db.DelDirById(id) == WINIX_ERR_OK )
dir_table.DelById(id);
db.RemoveThread(id);

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,94 +0,0 @@
/*
* 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 "error.h"
Error::Error()
{
code = unknown;
}
Error::Error(Code c) : code(c)
{
}
Error::Error(int i)
{
code = static_cast<Code>(i);
}
Error::Error(const Error & e)
{
code = e.code;
}
Error::operator int() const
{
return static_cast<int>(code);
}
Error & Error::operator=(Code c)
{
code = c;
return *this;
}
Error & Error::operator=(const Error & e)
{
code = e.code;
return *this;
}
bool Error::operator==(Code c) const
{
return code == c;
}
bool Error::operator!=(Code c) const
{
return code != c;
}
bool Error::operator==(const Error & e) const
{
return code == e.code;
}
bool Error::operator!=(const Error & e) const
{
return code != e.code;
}
std::ostream & operator<<(std::ostream & out, const Error & e)
{
out << static_cast<int>(e.code);
return out;
}
Log & operator<<(Log & out, const Error & e)
{
out << static_cast<int>(e.code);
return out;
}

View File

@ -1,8 +1,8 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
* Copyright (c) 2008-2010, Tomasz Sowa
* All rights reserved.
*
*/
@ -13,84 +13,61 @@
#include <iostream>
#include "log.h"
#define WINIX_ERR_OK 0
//#define WINIX_ERR_INCORRECT_PATH 1
//#define WINIX_ERR_NO_POSTVAR 2
#define WINIX_ERR_INCORRECT_DIR 3
#define WINIX_ERR_CANT_CHANGE_USER 4
#define WINIX_ERR_CANT_CHANGE_GROUP 5
#define WINIX_ERR_CANT_CHANGE_PRIVILEGES 6
#define WINIX_ERR_PERMISSION_DENIED 7
#define WINIX_ERR_NO_ROOT_DIR 8
#define WINIX_ERR_NO_FUNCTION 9
#define WINIX_ERR_NO_ITEM 10
#define WINIX_ERR_UNKNOWN_PARAM 11
#define WINIX_ERR_MOUNT_UNKNOWN 12
#define WINIX_ERR_UNKNOWN_FILESYSTEM 13
#define WINIX_ERR_NO_MOUNTPOINT 14
//#define WINIX_ERR_MOUNT_NO_PARAM 15
#define WINIX_ERR_NO_THREAD 16
#define WINIX_ERR_EMPTY 17
#define WINIX_ERR_SPAM 18
#define WINIX_ERR_INCORRECT_REBUS 19
class Error
{
#define WINIX_ERR_NO_BOUNDARY 20
#define WINIX_ERR_BROKEN_INPUT 21
#define WINIX_ERR_INPUT_TOO_LARGE 22
#define WINIX_ERR_CANT_CREATE_FILE 23
public:
#define WINIX_ERR_NO_TICKET 24
enum Code
{
ok = 0,
incorrect_path,
db_fatal_error_during_connecting,
db_incorrect_query,
db_incorrent_result_status,
db_no_column,
db_incorrect_login,
db_more_than_one_login,
db_err_currval,
no_postvar,
incorrect_dir,
cant_change_user,
cant_change_group,
cant_change_privileges,
permission_denied,
no_root_dir,
no_function,
no_item,
unknown_param,
mount_unknown,
unknown_filesystem,
no_mountpoint,
mount_no_param,
no_thread,
empty,
spam,
incorrect_rebus,
no_boundary,
broken_input,
input_too_large,
cant_create_file,
no_ticket,
unknown = 1000
};
Error();
Error(Code c);
Error(int i);
Error(const Error & e);
Error & operator=(Code c);
Error & operator=(const Error & e);
operator int() const;
bool operator==(Code c) const;
bool operator!=(Code c) const;
bool operator==(const Error & e) const;
bool operator!=(const Error & e) const;
friend std::ostream & operator<<(std::ostream & out, const Error & e);
friend Log & operator<<(Log & out, const Error & e);
#define WINIX_ERR_PASSWORDS_DIFFERENT 25
#define WINIX_ERR_PASSWORD_TOO_SHORT 26
#define WINIX_ERR_USER_EXISTS 27
#define WINIX_ERR_LOGIN_EMPTY 28
private:
#define WINIX_ERR_DB_FATAL_ERROR_DURING_CONNECTING 100
#define WINIX_ERR_DB_INCORRECT_QUERY 101
#define WINIX_ERR_DB_INCORRENT_RESULT_STATUS 102
#define WINIX_ERR_DB_NO_COLUMN 103
#define WINIX_ERR_DB_INCORRECT_LOGIN 104
#define WINIX_ERR_DB_MORE_THAN_ONE_LOGIN 105
#define WINIX_ERR_DB_ERR_CURRVAL 106
Code code;
};
//#define WINIX_ERR_UNKNOWN 1000
typedef int Error;

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -42,7 +42,7 @@
#define FUN_CHOWN 26
#define FUN_CKEDITOR 27
#define FUN_DOWNLOAD 28
#define FUN_ADDUSER 29

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -34,7 +34,7 @@ void FunctionParser::ParseDirectories()
if( !pdir )
{
// there is no the root dir
request.status = Error::no_root_dir;
request.status = WINIX_ERR_NO_ROOT_DIR;
return;
}
@ -78,12 +78,12 @@ void FunctionParser::ParseItem()
request.status = db.GetItem(parent_id, url, request.item);
if( request.status == Error::ok )
if( request.status == WINIX_ERR_OK )
{
if( request.role == Request::authorizer && request.item.auth == Item::auth_none )
{
log << log1 << "FP: item.url: " << url << " exists but has not a static content (authorizer role)" << logend;
request.status = Error::no_item;
request.status = WINIX_ERR_NO_ITEM;
return;
}
@ -138,7 +138,7 @@ void FunctionParser::ParseParams()
void FunctionParser::Parse()
{
request.status = Error::ok;
request.status = WINIX_ERR_OK;
get_index = 0;
get_table_len = request.get_table.size();
request.pfunction = 0;
@ -146,7 +146,7 @@ void FunctionParser::Parse()
ParseDirectories();
if( request.status != Error::ok )
if( request.status != WINIX_ERR_OK )
return;
ParseFunction();
@ -155,14 +155,14 @@ void FunctionParser::Parse()
{
ParseItem();
if( request.status != Error::ok )
if( request.status != WINIX_ERR_OK )
return;
ParseFunction();
if( !request.pfunction && get_index != get_table_len )
{
request.status = Error::no_function;
request.status = WINIX_ERR_NO_FUNCTION;
log << log3 << "FP: Parse: unknown function: \"" << request.get_table[get_index] << "\"" << logend;
return;
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -143,6 +143,9 @@ void Functions::ReadFunctions()
f.item.url = "download";
table.insert( std::make_pair(f.item.url, f) );
f.code = FUN_ADDUSER;
f.item.url = "adduser";
table.insert( std::make_pair(f.item.url, f) );
// functions which need more privileges

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
@ -111,22 +111,69 @@ void Locale::SetLangDef(Lang lang)
}
bool Locale::IsKey(const std::string & key) const
{
return IsKey(key, current_lang);
}
bool Locale::IsKey(const std::string & key, Lang lang) const
{
if( static_cast<size_t>(lang) >= loc_tab.size() )
{
// ops, something wrong
return false;
}
// looking in the lang language
ConfParser::Table::const_iterator i = loc_tab[lang].find(key);
if( i != loc_tab[lang].end() )
return true;
if( lang == default_lang )
return false;
if( static_cast<size_t>(default_lang) >= loc_tab.size() )
{
// ops, something wrong
return false;
}
// looking in a default language
i = loc_tab[default_lang].find(key);
if( i != loc_tab[default_lang].end() )
return true;
// there is no such a key
return false;
}
const std::string & Locale::Get(const std::string & key) const
{
if( static_cast<size_t>(current_lang) >= loc_tab.size() )
return Get(key, current_lang);
}
const std::string & Locale::Get(const std::string & key, Lang lang) const
{
if( static_cast<size_t>(lang) >= loc_tab.size() )
{
// ops, something wrong
return empty;
}
// looking in the current_lang
ConfParser::Table::const_iterator i = loc_tab[current_lang].find(key);
// looking in the lang language
ConfParser::Table::const_iterator i = loc_tab[lang].find(key);
if( i != loc_tab[current_lang].end() )
if( i != loc_tab[lang].end() )
return i->second;
if( current_lang == default_lang )
if( lang == default_lang )
return empty;

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
@ -32,7 +32,11 @@ public:
void Read(const char * dir, const char * dir_def = 0);
void Read(const std::string & dir, const std::string & dir_def);
bool IsKey(const std::string & key) const;
bool IsKey(const std::string & key, Lang lang) const;
const std::string & Get(const std::string & key) const;
const std::string & Get(const std::string & key, Lang lang) const;
// default is english
void SetLang(Lang lang);

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
@ -196,7 +196,7 @@ void MountParser::ReadMountType()
if( temp.empty() )
{
// an empty line (some white characters only)
err = Error::empty;
err = WINIX_ERR_EMPTY;
}
else
if( temp == "cms" )
@ -218,7 +218,7 @@ void MountParser::ReadMountType()
}
else
{
err = Error::mount_unknown;
err = WINIX_ERR_MOUNT_UNKNOWN;
log << log1 << "MP: unknown mount type: " << temp << logend;
}
}
@ -238,7 +238,7 @@ void MountParser::ReadMountPoint()
}
else
{
err = Error::no_mountpoint;
err = WINIX_ERR_NO_MOUNTPOINT;
log << log1 << "MP: there is no such a mount point: " << temp << logend;
}
}
@ -262,7 +262,7 @@ void MountParser::ReadFs()
}
else
{
err = Error::unknown_filesystem;
err = WINIX_ERR_UNKNOWN_FILESYSTEM;
log << log1 << "MP: unknown filesystem: " << temp << logend;
}
}
@ -315,23 +315,23 @@ void MountParser::ReadRow(std::map<long, Mount> & output)
{
ReadMountType();
if( err == Error::empty )
if( err == WINIX_ERR_EMPTY )
{
err = Error::ok;
err = WINIX_ERR_OK;
SkipLine();
return;
}
if( err == Error::ok )
if( err == WINIX_ERR_OK )
ReadMountPoint();
if( err == Error::ok )
if( err == WINIX_ERR_OK )
ReadFs();
if( err == Error::ok )
if( err == WINIX_ERR_OK )
ReadMountParams();
if( err == Error::ok )
if( err == WINIX_ERR_OK )
{
std::pair<std::map<long, Mount>::iterator, bool> res = output.insert( std::make_pair(mount.dir_id, mount) );
@ -348,10 +348,10 @@ void MountParser::ReadRow(std::map<long, Mount> & output)
Error MountParser::Parse(const std::string & input, std::map<long, Mount> & output)
{
pinput = input.c_str();
err = Error::ok;
err = WINIX_ERR_OK;
output.clear();
while( *pinput && err == Error::ok )
while( *pinput && err == WINIX_ERR_OK )
ReadRow(output);
return err;

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2009, Tomasz Sowa
@ -29,7 +29,7 @@ Error Mounts::ReadMounts(const std::string & mounts)
MountParser mp;
Error err = mp.Parse(mounts, mount_tab);
if( err != Error::ok )
if( err != WINIX_ERR_OK )
{
log << log1 << "M: some problems with mountpoints (mountpoints table will be empty)" << logend;
mount_tab.clear();
@ -52,19 +52,19 @@ Error Mounts::ReadMounts()
if( !etc )
{
log << log1 << "M: there is no /etc directory" << logend;
return Error::no_item;
return WINIX_ERR_NO_ITEM;
}
Item fstab;
Error err = db.GetItem(etc->id, file, fstab);
if( err == Error::no_item )
if( err == WINIX_ERR_NO_ITEM )
{
log << log1 << "M: there is no /etc/fstab file" << logend;
return err;
}
if( err != Error::ok )
if( err != WINIX_ERR_OK )
{
log << log1 << "M: cannot read /etc/fstab" << logend;
return err;

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -106,7 +106,7 @@ void PostMultiParser::ReadHeaderName()
if( last != ':' && last != '=' )
{
err = Error::broken_input;
err = WINIX_ERR_BROKEN_INPUT;
return;
}
@ -137,7 +137,7 @@ bool was_apost = false;
{
if( last != '"' )
{
err = Error::broken_input;
err = WINIX_ERR_BROKEN_INPUT;
return;
}
@ -148,7 +148,7 @@ bool was_apost = false;
if( last != ';' && last != 10 )
{
err = Error::broken_input;
err = WINIX_ERR_BROKEN_INPUT;
return;
}
@ -163,12 +163,12 @@ void PostMultiParser::ReadPartHeader()
ReadHeaderName();
if( err != Error::ok )
if( err != WINIX_ERR_OK )
return;
ReadHeaderValue();
if( err != Error::ok )
if( err != WINIX_ERR_OK )
return;
log << "PMP: " << header_name << ": " << header_value << logend;
@ -265,7 +265,7 @@ bool has_boundary = false;
if( data.post_file_max != 0 && content_len > (size_t)data.post_file_max )
{
err = Error::input_too_large;
err = WINIX_ERR_INPUT_TOO_LARGE;
log << log1 << "PMP: content greater than " << data.post_file_max << " (skipping)" << logend;
return;
}
@ -319,7 +319,7 @@ bool has_boundary = false;
if( data.post_file_max != 0 && content_len > (size_t)data.post_file_max )
{
err = Error::input_too_large;
err = WINIX_ERR_INPUT_TOO_LARGE;
log << log1 << "PMP: content greater than " << data.post_file_max << " (skipping)" << logend;
return;
}
@ -345,7 +345,7 @@ void PostMultiParser::AddNormalPostVar()
{
if( post_table->size() >= WINIX_POSTTABLE_MAXSIZE )
{
err = Error::input_too_large;
err = WINIX_ERR_INPUT_TOO_LARGE;
log << log1 << "PMP: more than " << WINIX_POSTTABLE_MAXSIZE << " post variables (skipping)" << logend;
return;
}
@ -366,7 +366,7 @@ void PostMultiParser::AddFilePostVar()
{
if( post_file_table->size() >= WINIX_POSTTABLE_MAXSIZE )
{
err = Error::input_too_large;
err = WINIX_ERR_INPUT_TOO_LARGE;
log << log1 << "PMP: more than " << WINIX_POSTTABLE_MAXSIZE << " post file variables (skipping)" << logend;
return;
}
@ -411,7 +411,7 @@ void PostMultiParser::CheckBoundaryEnd()
if( last != '-' )
{
err = Error::broken_input;
err = WINIX_ERR_BROKEN_INPUT;
return;
}
@ -436,7 +436,7 @@ char buf[100];
if( data.auth_tmp_dir.empty() )
{
log << log1 << "PMP: auth_tmp_dir is not set in the config" << logend;
err = Error::cant_create_file;
err = WINIX_ERR_CANT_CREATE_FILE;
return;
}
@ -449,7 +449,7 @@ char buf[100];
if( !tmp_file )
{
log << log1 << "PMP: can't create a temporary file: " << tmp_filename << logend;
err = Error::cant_create_file;
err = WINIX_ERR_CANT_CREATE_FILE;
return;
}
@ -465,13 +465,13 @@ void PostMultiParser::ReadPart()
while( IsHeader() )
ReadPartHeader();
if( err != Error::ok )
if( err != WINIX_ERR_OK )
return;
if( !filename.empty() )
CreateTmpFile();
if( err != Error::ok )
if( err != WINIX_ERR_OK )
return;
if( !filename.empty() )
@ -479,13 +479,13 @@ void PostMultiParser::ReadPart()
else
ReadContent();
if( err == Error::ok )
if( err == WINIX_ERR_OK )
{
AddPostVar();
CheckBoundaryEnd();
}
if( err != Error::ok && !filename.empty() )
if( err != WINIX_ERR_OK && !filename.empty() )
{
log << log1 << "PMP: deleting the tmp file: " << tmp_filename << logend;
unlink(tmp_filename.c_str());
@ -527,7 +527,7 @@ Error PostMultiParser::Parse(FCGX_Stream * in_, PostTable & post_table_, PostFil
{
in = in_;
last = 0;
err = Error::ok;
err = WINIX_ERR_OK;
line_end_dos = false;
in_buffer_ind = WINIX_POSTMULTI_INPUT_BUFFER;
in_buffer_len = WINIX_POSTMULTI_INPUT_BUFFER;
@ -539,17 +539,17 @@ Error PostMultiParser::Parse(FCGX_Stream * in_, PostTable & post_table_, PostFil
ReadBoundary();
if( boundary.empty() )
return Error::no_boundary;
return WINIX_ERR_NO_BOUNDARY;
while( last!=-1 && err == Error::ok )
while( last!=-1 && err == WINIX_ERR_OK )
ReadPart();
if( err != Error::ok )
if( err != WINIX_ERR_OK )
{
post_table->clear();
post_file_table->clear();
if( err != Error::input_too_large && err != Error::cant_create_file )
if( err != WINIX_ERR_INPUT_TOO_LARGE && err != WINIX_ERR_CANT_CREATE_FILE )
log << log1 << "PMP: syntax error" << logend;
}

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa
@ -90,7 +90,7 @@ void Request::Clear()
pfunction = 0;
param_table.clear();
status = Error::ok;
status = WINIX_ERR_OK;
is_thread = false;
thread.Clear();
@ -477,7 +477,7 @@ void Request::SendPage(bool compressing, const std::string & source_ref)
{
const std::string * source = &source_ref;
bool raw = request.is_item && request.item.content_type == Item::ct_raw && request.status == Error::ok &&
bool raw = request.is_item && request.item.content_type == Item::ct_raw && request.status == WINIX_ERR_OK &&
request.pfunction && (request.pfunction->code == FUN_CAT || request.pfunction->code == FUN_RUN);
if( data.html_filter && !raw )
@ -506,10 +506,10 @@ bool compressing = data.compression && role == responder && redirect_to.empty()
accept_encoding_parser.AcceptDeflate() && source.size() >= 512;
if( status == Error::no_item || status == Error::no_function || status == Error::unknown_param )
if( status == WINIX_ERR_NO_ITEM || status == WINIX_ERR_NO_FUNCTION || status == WINIX_ERR_UNKNOWN_PARAM )
header = h_404;
if( status == Error::permission_denied || status == Error::cant_change_user || status == Error::cant_change_group )
if( status == WINIX_ERR_PERMISSION_DENIED || status == WINIX_ERR_CANT_CHANGE_USER || status == WINIX_ERR_CANT_CHANGE_GROUP )
header = h_403;
SendSessionCookie();

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa

View File

@ -1,5 +1,5 @@
/*
* This file is a part of CMSLU -- Content Management System like Unix
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2009, Tomasz Sowa

Some files were not shown because too many files have changed in this diff Show More