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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
#ifndef headerfile_winix_core_system
|
|
|
|
#define headerfile_winix_core_system
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-12-02 03:36:49 +01:00
|
|
|
#include <ctime>
|
2010-08-10 18:12:50 +02:00
|
|
|
#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-12-02 02:02:02 +01:00
|
|
|
#include "synchro.h"
|
2010-12-11 23:55:48 +01:00
|
|
|
#include "thumb.h"
|
2010-12-02 03:36:49 +01:00
|
|
|
#include "notify/notify.h"
|
2010-08-10 18:12:50 +02:00
|
|
|
|
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;
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
// notifications (by emails)
|
|
|
|
Notify notify;
|
|
|
|
|
2010-12-11 23:55:48 +01:00
|
|
|
// thumbnails (special thread)
|
|
|
|
Thumb thumb;
|
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
// the time when the winix starts
|
|
|
|
time_t system_start;
|
|
|
|
|
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
void SetCur(Cur * pcur);
|
2010-08-10 18:12:50 +02:00
|
|
|
void SetConfig(Config * pconfig);
|
|
|
|
void SetDb(Db * pdb);
|
2010-12-02 02:02:02 +01:00
|
|
|
void SetSynchro(Synchro * psynchro);
|
2010-08-10 18:12:50 +02:00
|
|
|
void Init();
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
void AddParams(const ParamTab & param_tab, std::wstring & str, bool clear_str = true);
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
void RedirectTo(const Item & item, const wchar_t * postfix = 0);
|
|
|
|
void RedirectTo(long item_id, const wchar_t * postfix = 0);
|
2011-01-05 22:24:11 +01:00
|
|
|
void RedirectTo(const std::wstring & url);
|
|
|
|
void RedirectWithFunctionAndParamsTo(const std::wstring & url);
|
2010-08-10 18:12:50 +02:00
|
|
|
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);
|
2011-01-05 22:24:11 +01:00
|
|
|
bool HasReadExecAccessToPath(const std::vector<Item*> & dir_tab);
|
2010-08-10 18:12:50 +02:00
|
|
|
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);
|
|
|
|
|
2010-11-21 01:19:17 +01:00
|
|
|
bool IsMemberOfGroup(long user_id, const wchar_t * group_name);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-12-10 22:07:01 +01:00
|
|
|
// creating item.file_path and item.file_fs (the mountpoint where the item is located)
|
|
|
|
bool CreateNewFile(Item & item);
|
|
|
|
bool MakeFilePath(const Item & item, std::wstring & path, bool thumb = false, bool create_dir = false, int chmod = 0755);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
bool MakePath(const Item & item, std::wstring & path, bool clear_path = true);
|
|
|
|
|
2010-12-02 02:02:02 +01:00
|
|
|
Error AddFile(Item & item, int notify_code = 0);
|
|
|
|
Error EditFile(Item & item, bool with_url = true, int notify_code = 0);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2010-10-24 01:12:47 +02:00
|
|
|
// converting GMT time to local time (different for each user)
|
|
|
|
time_t LocalTime(time_t gmt_time);
|
|
|
|
tm LocalTime(const tm * ptm);
|
|
|
|
tm LocalTime(const tm & ptm);
|
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
int FollowLink(const std::vector<Item*> & current_dir_tab, const std::wstring & link_to,
|
|
|
|
std::vector<Item*> & out_dir_tab, Item & out_item);
|
|
|
|
|
|
|
|
int FollowAllLinks(const std::vector<Item*> & current_dir_tab, const std::wstring & link_to,
|
|
|
|
std::vector<Item*> & out_dir_tab, Item & out_item,
|
|
|
|
bool follow_dir_default = false, bool stop_on_link_redirect = false, bool check_access = true);
|
|
|
|
|
|
|
|
// starting from root dir
|
|
|
|
int FollowAllLinks(const std::wstring & link_to,
|
|
|
|
std::vector<Item*> & out_dir_tab, Item & out_item,
|
|
|
|
bool follow_dir_default = false, bool stop_on_link_redirect = false, bool check_access = true);
|
2010-10-24 01:12:47 +02:00
|
|
|
|
2011-01-23 15:15:30 +01:00
|
|
|
// using cur->request->dir_tab and cur->request->item
|
2011-01-05 22:24:11 +01:00
|
|
|
bool FollowAllLinks(const std::wstring & link_to,
|
|
|
|
bool follow_dir_default = false, bool stop_on_link_redirect = false, bool check_access = true);
|
2010-10-24 01:12:47 +02:00
|
|
|
|
2010-08-10 18:12:50 +02:00
|
|
|
private:
|
2011-01-23 15:15:30 +01:00
|
|
|
|
|
|
|
Cur * cur;
|
|
|
|
Db * db;
|
|
|
|
Config * config;
|
|
|
|
Synchro * synchro;
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
Item item_temp;
|
|
|
|
std::wstring link_to_temp, name_temp;
|
|
|
|
|
|
|
|
// for FollowAllLinks
|
|
|
|
std::vector<Item*> temp_follow_dir_tab;
|
|
|
|
std::vector<Item*> root_follow_dir_tab;
|
|
|
|
Item temp_follow_item;
|
|
|
|
|
2010-12-10 22:07:01 +01:00
|
|
|
bool CreateNewFileSimpleFs(Item & item);
|
|
|
|
bool CreateNewFileHashFs(Item & item);
|
2010-08-10 18:12:50 +02:00
|
|
|
|
2011-01-05 22:24:11 +01:00
|
|
|
bool FollowAllLinksDirFound(std::vector<Item*> & out_dir_tab,
|
|
|
|
bool follow_dir_default, bool stop_on_link_redirect, bool check_access);
|
|
|
|
|
|
|
|
bool FollowAllLinksFileOrSymlinkFound(std::vector<Item*> & out_dir_tab, Item & out_item,
|
|
|
|
bool stop_on_link_redirect, bool check_access);
|
2010-08-10 18:12:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|