/* * 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. * */ #ifndef headerfilecmslucorerequest #define headerfilecmslucorerequest #include #include #include #include #include "requesttypes.h" #include "session.h" #include "item.h" #include "error.h" #include "function.h" #include "thread.h" #include "compress.h" #include "acceptencodingparser.h" struct Request { // request id // is incremented for each request and is never 0 // (from -1 will be incremented twice) // it's used for some optimalization e.g. in templates size_t id; FCGX_Stream * in, * out, * err; FCGX_ParamArray env; // defined as 'char **' enum Method { get, post, none } method; // headers, page and debug // notify (for mailing) std::ostringstream headers, page, debug, notify; GetTable get_table; PostTable post_table; CookieTable cookie_table; // environment variables // they are not null -- when the server doesn't have such a variable // it will be pointing into 'char_empty' which is default '\0' const char * env_request_method; const char * env_request_uri; const char * env_http_cookie; const char * env_remote_addr; const char * env_http_host; const char * env_http_user_agent; const char * env_http_accept_encoding; // true if the browser is Microsoft Internet Explorer bool browser_msie; // current session // is set after calling session_manager.SetSession() Session * session; // current directory std::vector dir_table; bool is_item; // this item is used for many purposes such as editing, adding an item etc. Item item; // null if there is no a function Function * pfunction; // !! moze nazwac to poprostu param? std::vector param_table; Error status; // last notify int notify_code; // items in the current directory // maybe without contents? std::vector item_table; // current thread (if exists) bool is_thread; Thread thread; std::vector thread_tab; // if not empty means an address for redirecting to std::string redirect_to; // for debugging void PrintGetTable(); void PrintEnv(); void PrintIn(); Request(); void Clear(); void Init(); bool IsParam(const char * s); void SetCookie(const char * name, const char * value, tm * expires = 0); void SetCookie(const char * name, long value, tm * expires = 0); bool IsPostVar(const char * var); std::string * PostVar(const char * var); // it can return null when there is no such a post variable bool PostVar(const char * var, std::string & result); void ReadEnvVariables(); void CheckMethod(); void ReadParameters(); void Read(); void SendAll(); void SendNotify(); 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 CanCreateThread(bool check_root = false); bool CanRemove(const Item & item); bool CanUseEmacs(const Item & item, bool check_root = false); bool CanUseMkdir(const Item & item, bool check_root = false); bool CanUseHtml(long user_id); bool CanUseBBCode(long user_id); private: void SendSessionCookie(); void CheckIE(); // used to set some env_* variables into it, when the server didn't set that variable // it contains '\0' const char char_empty; const char * SetEnvVar(const char * var); void StandardLog(); Compress compress; AcceptEncodingParser accept_encoding_parser; }; extern Request request; #endif