winix/content/content.h

296 lines
6.3 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucontentcontent
#define headerfilecmslucontentcontent
#include <cstdlib>
#include <fcgiapp.h>
#include <ctime>
#include "../core/item.h"
#include "../templates/templates.h"
#include "../core/thread.h"
#include "../core/ticket.h"
#include "../core/db.h"
class Content
{
Templates templates;
std::string temp;
void FunDownload();
void CheckSpecialFile();
void PrepareUrl(Item & item);
bool CheckAddUserVars(const std::string * login, const std::string * pass, const std::string * conf_pass);
void PostFunAddUser();
void FunAddUser();
/*
mv
*/
bool MoveIsTheSameFile(const Item & item);
void MoveAuth(Item & item);
void MoveFile(Item & item, bool redirect = true);
void MoveDir(Item & item, bool redirect = true);
void MoveAuthPrepareQuery();
void MoveAuthContentOfDir(const Item & item);
bool MoveParseDir(long & dir_id, std::string & dir, std::string & file);
bool MoveCheckAccessFromToDir();
bool MoveCheckAccessFrom();
bool MoveCheckAccessTo(long dir_id);
bool MoveCheckMountPoints(long dir_id);
void MoveContentOfDir();
void PostFunMv();
void FunMv();
std::string mv_dir;
std::string mv_file;
std::string mv_new_path;
long mv_dir_id;
std::vector<Item> mv_auth;
Db::ItemQuery mv_auth_iq;
/*
cp
*/
bool CpCheckAccessFrom();
void CpAuth(Item & item);
void CpSetNewAttributes(Item & item);
void CpItem(Item & item, long dst_dir_id);
void CpFilesInDir(const Item & dir, long dst_dir_id);
void CpContentOfDir(const Item & item, long dst_dir_id);
long CpDir(const Item & item, long dst_dir_id);
void CpItemCheck(Item & item, bool redirect = true);
void CpContentOfDirCheck(const Item & item, bool redirect = true);
void CpDirCheck(const Item & item, bool redirect = true);
void PostFunCp();
void FunCp();
void CpPrepare();
Item cp_temp;
Db::ItemQuery cp_iq;
bool cp_remove_defaults;
bool cp_preserve_attr;
long cp_new_user;
long cp_new_group;
void SetDefaultFunctionForFile();
void SetDefaultFunctionForDir();
void SetDefaultFunction();
bool DirsHaveReadExecPerm();
/*
calling functions (standard, post)
*/
typedef void (Content::*Fun)();
struct FunItem
{
int code;
Fun fun;
};
void FunNothing();
void CallFunction();
void MakeStandardFunction();
void CallPostFunction();
void MakePost();
void SetUser(Item & item);
bool CheckRebus();
void FunCat();
void FunLogout();
void FunLs();
void FunEmacs();
void AddPathToAuth(std::string & path);
void FunCKEditor();
void FunUname();
bool SubjectCheckAccess();
void EditDirSubject();
void EditFileSubject();
void PostFunSubject();
void FunSubject();
/*
rm
*/
bool RemoveCheckAccess();
void RemoveAllDirs();
void RemoveAllDirs(long dir_id);
void RemoveDir();
void RemoveAuthPrepareQuery();
void RemoveAuth(Item & item);
void RemoveFile();
void FunRm();
Db::ItemQuery rm_auth_iq;
void FunNode();
void FunMkdir();
void FunDefault();
void FunRun();
void PostFunRun();
void FunWho();
void FunLast();
void FunReloadTemplates();
void FunReload();
static bool FunThreadSort(const Thread & t1, const Thread & t2);
void FunThread();
void FunCreateThread();
bool FunUploadCheckAccess();
void FunUpload();
bool ReadItemUrlSubject(Item & item, Item::Type item_type);
bool ReadItem(Item & item, Item::Type item_type);
void CheckAccessToItems();
void LoginUser(long user_id, bool remember_me);
void FunLogin();
void PostFunLogin();
void ReadItemContentWithType(Item & item);
bool FunEmacsCheckAccess();
void PostFunEmacsAdd(Item & item);
void PostFunEmacsEdit(bool with_url);
bool PostEmacsCheckAbuse(bool adding);
void PostFunEmacsModifyMountPoint(bool adding);
void PostFunEmacs();
bool FunMkdirCheckAccess();
void PostFunMkdir(bool add_to_dir_table, int privileges);
void PostFunMkdir();
void Mkdir(Item & item, bool add_to_dir_table);
long PostFunDefaultParsePath();
void PostFunDefault();
/*
function: priv, chmod, chown
*/
bool PrivCheckAccess();
void PrivLogStart(const char * what, long user, long group, int priv);
void PrivLog(const char * what, long id, const std::string & url);
bool ChangeOwner(Item & item, long user_id, long group_id);
bool ChangePrivileges(Item & item, int privileges);
void ChangePriv(Item & item, long user_id, long group_id, int privileges);
void PostFunPriv();
void PrivFilesInDir(long parent_id);
void PrivDir(long parent_id);
bool ReadPriv(const char * user_in, const char * group_in, const char * priv_in, long & user_id, long & group_id, int & priv);
void PrivDir();
void PrivOneItem();
void FunPriv();
long user_id_file, group_id_file, user_id_dir, group_id_dir;
int priv_file, priv_dir;
bool subdirectories;
bool change_owner, change_priv;
bool FunCreateThreadCheckAccess();
bool FunCreateThreadCheckAbuse();
void ReadThread(Thread & thread);
void AddThread();
void PostFunCreateThreadLogAndRedirect();
void PostFunCreateThread();
bool UploadCreatePath();
void UploadSaveFile(const std::string & tmp_filename, const std::string & destination);
void UploadMulti();
void UploadSingle();
bool FunUploadCheckAbuse();
void PostFunUpload();
bool FunCreateTicketCheckAccess();
void FunCreateTicket();
bool FunCreateTicketCheckAbuse();
void PostFunCreateTicketLogAndRedirect();
void PostFunCreateTicket();
void FunTicket();
void TicketDeleteFirst();
bool FunEditTicketCheckAccess();
void PostFunEditTicketLogAndRedirect();
void EditTicketCheckFirstItem();
void EditTicketModTicket();
void EditTicketModDir();
void EditTicketModFirstItem();
void PostFunEditTicket();
void FunEditTicket();
void AddTicket();
void ReadTicket(Ticket & ticket);
void ReadTicketType(Ticket & ticket);
void ReadTicketStatus(Ticket & ticket);
void ReadTicketPriority(Ticket & ticket);
void ReadTicketCategory(Ticket & ticket);
void ReadTicketExpected(Ticket & ticket);
void ReadTicketProgress(Ticket & ticket);
void RedirectTo(const Item & item, const char * postfix = 0);
void RedirectTo(long item_id, const char * postfix = 0);
void RedirectToLastDir();
void CheckGetPostTimes(time_t difference = 10);
// bool CreateFile(const std::string & path, const std::string & content);
void MakePage();
public:
bool Init();
void ReadAdditionalInfo();
void Make();
};
#endif