/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2010-2012, Tomasz Sowa * All rights reserved. * */ #ifndef headerfile_winix_core_system #define headerfile_winix_core_system #include #include "dirs.h" #include "mounts.h" #include "db/db.h" #include "request.h" #include "config.h" #include "crypt.h" #include "users.h" #include "groups.h" #include "rebus.h" #include "loadavg.h" #include "synchro.h" #include "image.h" #include "threadmanager.h" #include "notify/notify.h" class Functions; // 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; // notifications (by emails) Notify notify; // images (resizing, generating thumbnails) Image image; // the time when the winix starts time_t system_start; // cryptography and hashes Crypt crypt; // thread management ThreadManager thread_manager; void SetCur(Cur * pcur); void SetConfig(Config * pconfig); void SetDb(Db * pdb); void SetSynchro(Synchro * psynchro); void SetFunctions(Functions * pfunctions); void Init(); void AddParams(const ParamTab & param_tab, std::wstring & str, bool clear_str = true); void PutUrlProto(bool can_use_ssl, std::wstring & str, bool clear_str = true); void RedirectTo(const Item & item, const wchar_t * postfix = 0); void RedirectTo(long item_id, const wchar_t * postfix = 0); void RedirectTo(const wchar_t * url); void RedirectTo(const std::wstring & url); void RedirectWithFunctionAndParamsTo(const wchar_t * url); void RedirectWithFunctionAndParamsTo(const std::wstring & url); 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 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 HasReadExecAccessToPath(const std::vector & dir_tab); bool DirsHaveReadExecPerm(); void CheckAccessToItems(std::vector & item_tab); void CheckWriteAccessToItems(std::vector & item_tab); /* this method checks the sticky bit and write permissions it returns true if we can remove/rename an item for the given child_item_user_id user id */ bool CanRemoveRenameChild(const Item & dir, long child_item_user_id); int NewFilePrivileges(); int NewDirPrivileges(); bool CanUseHtml(long user_id); bool CanUseBBCode(long user_id); bool CanUseRaw(long user_id); bool IsMemberOfGroup(long user_id, const wchar_t * group_name); // 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); bool MakePath(const Item & item, std::wstring & path, bool clear_path = true); Error AddFile(Item & item, int notify_code = 0, bool call_plugins = true); Error EditFile(Item & item, bool with_url = true, int notify_code = 0, bool call_plugins = true); // 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); int FollowLink(const std::vector & current_dir_tab, const std::wstring & link_to, std::vector & out_dir_tab, Item & out_item); int FollowAllLinks(const std::vector & current_dir_tab, const std::wstring & link_to, std::vector & 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 & out_dir_tab, Item & out_item, bool follow_dir_default = false, bool stop_on_link_redirect = false, bool check_access = true); // using cur->request->dir_tab and cur->request->item bool FollowAllLinks(const std::wstring & link_to, bool follow_dir_default = false, bool stop_on_link_redirect = false, bool check_access = true); bool AddCommonFileToVar(const wchar_t * file_path, const wchar_t * url, bool overwrite_existing = true); private: Cur * cur; Db * db; Config * config; Synchro * synchro; Functions * functions; Item item_temp; std::wstring link_to_temp, name_temp; std::wstring file_content, file_name; Item file_content_item; // for FollowAllLinks std::vector temp_follow_dir_tab; std::vector root_follow_dir_tab; Item temp_follow_item; bool HasAccess(const Item & item, int mask); int NewPrivileges(int creation_mask); bool CreateNewFileSimpleFs(Item & item); bool CreateNewFileHashFs(Item & item); bool FollowAllLinksDirFound(std::vector & out_dir_tab, bool follow_dir_default, bool stop_on_link_redirect, bool check_access); bool FollowAllLinksFileOrSymlinkFound(std::vector & out_dir_tab, Item & out_item, bool stop_on_link_redirect, bool check_access); }; #endif