2008-12-10 05:42:49 +01:00
|
|
|
/*
|
2010-02-28 01:08:10 +01:00
|
|
|
* This file is a part of Winix
|
2008-12-10 05:42:49 +01:00
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
2010-02-28 22:33:06 +01:00
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
2008-12-10 05:42:49 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
#ifndef headerfilecmslucorerequest
|
|
|
|
#define headerfilecmslucorerequest
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
#include <fcgiapp.h>
|
|
|
|
#include <sstream>
|
|
|
|
#include <vector>
|
2008-12-30 02:05:03 +01:00
|
|
|
#include <iomanip>
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
#include "requesttypes.h"
|
|
|
|
#include "session.h"
|
|
|
|
#include "item.h"
|
|
|
|
#include "error.h"
|
2008-12-30 02:05:03 +01:00
|
|
|
#include "function.h"
|
2009-04-21 01:49:28 +02:00
|
|
|
#include "thread.h"
|
2009-09-22 01:05:05 +02:00
|
|
|
#include "compress.h"
|
2009-10-08 19:59:10 +02:00
|
|
|
#include "acceptencodingparser.h"
|
2009-12-09 01:42:40 +01:00
|
|
|
#include "htmlfilter.h"
|
2010-01-06 20:17:53 +01:00
|
|
|
#include "postmultiparser.h"
|
2010-01-25 05:52:17 +01:00
|
|
|
#include "ticket.h"
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2009-04-21 22:50:55 +02:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
struct Request
|
|
|
|
{
|
2008-12-30 02:05:03 +01:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
FCGX_Stream * in, * out, * err;
|
|
|
|
FCGX_ParamArray env; // defined as 'char **'
|
|
|
|
|
|
|
|
|
|
|
|
enum Method { get, post, none } method;
|
2009-12-30 21:46:12 +01:00
|
|
|
enum Role { responder, authorizer } role;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
// headers, page and debug
|
2009-10-01 00:31:20 +02:00
|
|
|
// notify (for mailing)
|
|
|
|
std::ostringstream headers, page, debug, notify;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
|
2010-01-06 20:17:53 +01:00
|
|
|
GetTable get_table;
|
|
|
|
PostTable post_table;
|
|
|
|
PostFileTable post_file_table;
|
|
|
|
CookieTable cookie_table;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2008-12-12 04:11:29 +01:00
|
|
|
// environment variables
|
2009-11-17 02:04:01 +01:00
|
|
|
// they are not null -- when the server doesn't have such a variable
|
|
|
|
// it will be pointing into 'char_empty' which is default '\0'
|
2008-12-10 05:42:49 +01:00
|
|
|
const char * env_request_method;
|
|
|
|
const char * env_request_uri;
|
|
|
|
const char * env_http_cookie;
|
2008-12-11 03:46:16 +01:00
|
|
|
const char * env_remote_addr;
|
2008-12-12 04:11:29 +01:00
|
|
|
const char * env_http_host;
|
2008-12-30 02:05:03 +01:00
|
|
|
const char * env_http_user_agent;
|
2009-10-08 19:59:10 +02:00
|
|
|
const char * env_http_accept_encoding;
|
2009-12-30 21:46:12 +01:00
|
|
|
const char * env_fcgi_role;
|
2010-01-06 20:17:53 +01:00
|
|
|
const char * env_content_type;
|
2009-10-08 19:59:10 +02:00
|
|
|
|
|
|
|
// true if the browser is Microsoft Internet Explorer
|
|
|
|
bool browser_msie;
|
|
|
|
|
2009-12-19 20:46:15 +01:00
|
|
|
// true if the browser is Konqueror
|
|
|
|
bool browser_konqueror;
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
// current session
|
|
|
|
// is set after calling session_manager.SetSession()
|
|
|
|
Session * session;
|
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
// current directory
|
|
|
|
std::vector<Item*> dir_table;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
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<std::string*> param_table;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
Error status;
|
|
|
|
|
2009-10-01 00:31:20 +02:00
|
|
|
// last notify
|
|
|
|
int notify_code;
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
// items in the current directory
|
|
|
|
// maybe without contents?
|
|
|
|
std::vector<Item> item_table;
|
|
|
|
|
2009-04-21 01:49:28 +02:00
|
|
|
// current thread (if exists)
|
2009-06-05 22:29:06 +02:00
|
|
|
bool is_thread;
|
2009-04-21 01:49:28 +02:00
|
|
|
Thread thread;
|
2009-06-05 22:29:06 +02:00
|
|
|
std::vector<Thread> thread_tab;
|
|
|
|
|
2010-01-25 05:52:17 +01:00
|
|
|
// current ticket (if exists)
|
|
|
|
bool is_ticket;
|
|
|
|
Ticket ticket;
|
|
|
|
std::vector<Ticket> ticket_tab;
|
|
|
|
|
2009-11-17 02:04:01 +01:00
|
|
|
// if not empty means an address for redirecting to
|
|
|
|
std::string redirect_to;
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2010-02-19 00:30:22 +01:00
|
|
|
// send header X-LIGHTTPD-send-file with path to a file
|
|
|
|
std::string x_sendfile;
|
|
|
|
|
|
|
|
// send as attachment (causing header: content-disposition: attachment)
|
|
|
|
bool send_as_attachment;
|
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
// for debugging
|
|
|
|
void PrintGetTable();
|
|
|
|
void PrintEnv();
|
|
|
|
void PrintIn();
|
|
|
|
|
|
|
|
Request();
|
2010-01-06 20:17:53 +01:00
|
|
|
void ClearPostFileTmp();
|
2008-12-10 05:42:49 +01:00
|
|
|
void Clear();
|
|
|
|
|
2009-09-22 01:05:05 +02:00
|
|
|
void Init();
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2008-12-30 02:05:03 +01:00
|
|
|
bool IsParam(const char * s);
|
|
|
|
|
2009-11-21 00:09:52 +01:00
|
|
|
void SetCookie(const char * name, const char * value, tm * expires = 0);
|
|
|
|
void SetCookie(const char * name, long value, tm * expires = 0);
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
bool IsPostVar(const char * var);
|
2009-11-17 02:04:01 +01:00
|
|
|
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);
|
2009-12-09 01:42:40 +01:00
|
|
|
bool AllPostVarEmpty(); // returning true if all post vars are empty
|
2008-12-10 05:42:49 +01:00
|
|
|
|
|
|
|
void ReadEnvVariables();
|
|
|
|
void CheckMethod();
|
|
|
|
void ReadParameters();
|
|
|
|
void Read();
|
|
|
|
void SendAll();
|
2009-10-01 00:31:20 +02:00
|
|
|
void SendNotify();
|
2008-12-10 05:42:49 +01:00
|
|
|
|
2008-12-21 22:17:09 +01:00
|
|
|
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);
|
2008-12-22 17:03:03 +01:00
|
|
|
bool HasReadExecAccess(const Item & item);
|
2010-02-16 19:34:41 +01:00
|
|
|
bool HasReadExecAccessForRoot(const Item & item);
|
2010-03-15 02:47:26 +01:00
|
|
|
bool HasReadExecAccessToPath(long dir_id);
|
2009-01-26 21:49:28 +01:00
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
bool CanCreateThread(bool check_root = false);
|
2010-01-25 05:52:17 +01:00
|
|
|
bool CanCreateTicket(bool check_root = false);
|
|
|
|
bool CanEditTicket();
|
2009-06-05 22:29:06 +02:00
|
|
|
bool CanRemove(const Item & item);
|
|
|
|
bool CanUseEmacs(const Item & item, bool check_root = false);
|
|
|
|
bool CanUseMkdir(const Item & item, bool check_root = false);
|
2010-01-06 20:17:53 +01:00
|
|
|
bool CanUseUpload(const Item & item, bool check_root = false);
|
|
|
|
|
2009-06-05 22:29:06 +02:00
|
|
|
bool CanUseHtml(long user_id);
|
|
|
|
bool CanUseBBCode(long user_id);
|
2010-01-11 15:47:52 +01:00
|
|
|
bool CanUseRaw(long user_id);
|
|
|
|
|
2010-03-15 02:47:26 +01:00
|
|
|
bool MakePathSimpleFs(std::string & path, long dir_id, bool create_dir = false);
|
2010-02-19 00:30:22 +01:00
|
|
|
bool MakePathHashFs(std::string & path, long id, bool create_dir = false);
|
2010-03-15 02:47:26 +01:00
|
|
|
bool MakePath(const Item & item, std::string & path, bool create_dir = false);
|
|
|
|
bool MakePath(Item & item, bool create_dir = false);
|
2010-01-06 20:17:53 +01:00
|
|
|
|
2008-12-12 04:11:29 +01:00
|
|
|
private:
|
2009-10-08 19:59:10 +02:00
|
|
|
|
2009-12-30 21:46:12 +01:00
|
|
|
enum Header
|
|
|
|
{
|
|
|
|
h_200,
|
|
|
|
h_404,
|
|
|
|
h_403
|
|
|
|
};
|
|
|
|
|
2010-01-11 15:47:52 +01:00
|
|
|
bool CanUse(long user_id, const char * group_name);
|
|
|
|
|
2009-11-21 00:09:52 +01:00
|
|
|
void SendSessionCookie();
|
2009-10-08 19:59:10 +02:00
|
|
|
void CheckIE();
|
2009-12-19 20:46:15 +01:00
|
|
|
void CheckKonqueror();
|
2009-10-08 19:59:10 +02:00
|
|
|
|
2009-12-30 21:46:12 +01:00
|
|
|
void SendHeaders(bool compressing, Header header);
|
2009-12-09 01:42:40 +01:00
|
|
|
void AddDebugInfo();
|
2010-01-11 15:47:52 +01:00
|
|
|
void SendPage(bool compressing, const std::string & source_ref);
|
2009-12-09 01:42:40 +01:00
|
|
|
|
2008-12-12 04:11:29 +01:00
|
|
|
// used to set some env_* variables into it, when the server didn't set that variable
|
|
|
|
// it contains '\0'
|
|
|
|
const char char_empty;
|
2009-11-17 00:36:38 +01:00
|
|
|
|
2010-01-06 20:17:53 +01:00
|
|
|
|
|
|
|
PostMultiParser post_multi_parser;
|
|
|
|
|
2008-12-12 04:11:29 +01:00
|
|
|
const char * SetEnvVar(const char * var);
|
2008-12-30 02:05:03 +01:00
|
|
|
void StandardLog();
|
|
|
|
|
2009-09-22 01:05:05 +02:00
|
|
|
Compress compress;
|
2009-10-08 19:59:10 +02:00
|
|
|
AcceptEncodingParser accept_encoding_parser;
|
2009-12-09 01:42:40 +01:00
|
|
|
HTMLFilter html_filter;
|
|
|
|
|
2010-01-06 20:17:53 +01:00
|
|
|
|
2009-12-09 01:42:40 +01:00
|
|
|
// html after filtering
|
|
|
|
std::string clean_html;
|
2009-12-30 21:46:12 +01:00
|
|
|
|
2008-12-10 05:42:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern Request request;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|