2010-08-10 18:12:50 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef headerfilecmslucorefs
|
|
|
|
#define headerfilecmslucorefs
|
|
|
|
|
|
|
|
|
|
|
|
#include "dirs.h"
|
|
|
|
#include "mounts.h"
|
2010-09-18 02:51:12 +02:00
|
|
|
#include "db/db.h"
|
2010-08-10 18:12:50 +02:00
|
|
|
#include "request.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "users.h"
|
|
|
|
#include "groups.h"
|
|
|
|
#include "rebus.h"
|
|
|
|
#include "loadavg.h"
|
|
|
|
|
|
|
|
|
2010-08-12 21:10:12 +02:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
// file system
|
|
|
|
class System
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// contains current directories tree
|
|
|
|
Dirs dirs;
|
|
|
|
|
|
|
|
// mount points
|
|
|
|
Mounts mounts;
|
|
|
|
|
|
|
|
// users
|
|
|
|
Users users;
|
|
|
|
|
|
|
|
// groups
|
|
|
|
Groups groups;
|
|
|
|
|
|
|
|
// rebus (captcha)
|
|
|
|
Rebus rebus;
|
|
|
|
|
|
|
|
// load averages
|
|
|
|
LoadAvg load_avg;
|
|
|
|
|
|
|
|
// the time when the winix starts
|
|
|
|
time_t system_start;
|
|
|
|
|
|
|
|
|
|
|
|
void SetRequest(Request * prequest);
|
|
|
|
void SetConfig(Config * pconfig);
|
|
|
|
void SetDb(Db * pdb);
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
void RedirectTo(const Item & item, const char * postfix = 0);
|
|
|
|
void RedirectTo(long item_id, const char * postfix = 0);
|
|
|
|
void RedirectToLastDir();
|
|
|
|
void RedirectToLastItem(); // redirect to an item if exists or to the last directory
|
|
|
|
|
|
|
|
bool CanChangeUser(const Item & item, long new_user_id);
|
|
|
|
bool CanChangeGroup(const Item & item, long new_group_id);
|
|
|
|
bool CanChangePrivileges(const Item & item, int new_priv);
|
|
|
|
bool HasAccess(const Item & item, int mask);
|
|
|
|
bool HasReadAccess(const Item & item);
|
|
|
|
bool HasWriteAccess(const Item & item);
|
|
|
|
bool HasReadWriteAccess(const Item & item);
|
|
|
|
bool HasReadExecAccess(const Item & item);
|
|
|
|
bool HasReadExecAccessToPath(long dir_id);
|
|
|
|
bool DirsHaveReadExecPerm();
|
2010-08-10 22:43:38 +02:00
|
|
|
void CheckAccessToItems(std::vector<Item> & item_tab);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
|
|
|
bool CanUseHtml(long user_id);
|
|
|
|
bool CanUseBBCode(long user_id);
|
|
|
|
bool CanUseRaw(long user_id);
|
|
|
|
|
|
|
|
bool IsMemberOfGroup(long user_id, const char * group_name);
|
|
|
|
|
|
|
|
bool MakePath(const Item & item, std::string & path, bool create_dir);
|
|
|
|
bool MakePath(Item & item, bool create_dir); // output path is: item.auth_path
|
|
|
|
|
|
|
|
Error AddFile(Item & item);
|
|
|
|
Error EditFile(Item & item, bool with_url = true);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Request * request;
|
|
|
|
Config * config;
|
|
|
|
Db * db;
|
|
|
|
|
|
|
|
std::string path;
|
|
|
|
bool MakePathSimpleFs(std::string & path, long dir_id, bool create_dir);
|
|
|
|
bool MakePathHashFs(std::string & path, long id, bool create_dir);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|