added: created directory 'content' which has Content:: files

added:   created directory 'templates' which has Templates:: and TemplatesFunctions:: files
changed: content.cpp split into many files (directory 'content')
changed: templates.cpp split into many files (directory 'templates')
added:   full permissions
changed: building of the program (GNU make is used now)
         Makefile and Makefile.dep added into directories
added:   a parser 'FunctionParser'
         is used to parse the GET string
         it recognizes directories, items, functions, functions parameters
added:   other classes: Function, Functions 
added:   function: ls, privileges
changed: function 'id' to 'node'
changed: version: to 0.2.0
added/changed: a lot of work have been done


git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@469 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2008-12-30 01:05:03 +00:00
parent fac60a197b
commit 3e328932fc
62 changed files with 3457 additions and 1617 deletions

View File

@@ -13,13 +13,18 @@
Request::Request() : char_empty(0)
{
id = 0;
Clear();
}
void Request::Clear()
{
// warning: don't clear in, out, err, env
// warning: don't clear: in, out, err, env
// id is never 0
if( ++id == 0 )
++id;
get_table.clear();
post_table.clear();
@@ -40,15 +45,22 @@ void Request::Clear()
session = 0;
result = err404; // tutaj moze cos lepszego, cos w stylu 'not implemented'
result = err404; // !! tutaj moze cos lepszego, cos w stylu 'not implemented'
dir = -1;
cur_dir_table.clear();
// dir = -1;
// cur_dir_table.clear();
item_table.clear();
dir_table.clear();
// dir_table2.clear();
item.Clear();
str.clear();
dir_table.clear();
is_item = false;
pfunction = 0;
param_table.clear();
status = Error::ok;
}
@@ -113,14 +125,29 @@ std::string & Request::PostVar(const char * var)
p = post_table.find(var);
if( p == post_table.end() )
throw Error(Error::no_cookie);
{
throw Error(Error::no_postvar);
}
return p->second;
}
/*
bool Request::PostVar(const char * var, std::string & result)
{
PostTable::iterator p;
p = post_table.find(var);
if( p == post_table.end() )
return false;
result = p->second;
return true;
}
*/
@@ -197,13 +224,12 @@ void Request::ReadEnvVariables()
// we store that values because FCGX_GetParam has O(n) complexity
// with this variables (env_*) we have O(1)
env_request_method = SetEnvVar("REQUEST_METHOD");
env_request_uri = SetEnvVar("REQUEST_URI");
env_http_cookie = SetEnvVar("HTTP_COOKIE");
env_remote_addr = SetEnvVar("REMOTE_ADDR");
env_http_host = SetEnvVar("HTTP_HOST");
log << log1 << "IP: " << env_remote_addr << logend;
env_request_method = SetEnvVar("REQUEST_METHOD");
env_request_uri = SetEnvVar("REQUEST_URI");
env_http_cookie = SetEnvVar("HTTP_COOKIE");
env_remote_addr = SetEnvVar("REMOTE_ADDR");
env_http_host = SetEnvVar("HTTP_HOST");
env_http_user_agent = SetEnvVar("HTTP_USER_AGENT");
}
@@ -222,7 +248,7 @@ void Request::CheckMethod()
void Request::ReadParameters()
{
// some parameters (get) we have always
// !!some parameters (get) we have always
// if( method == get )
{
GetParser get_parser(env_request_uri, get_table);
@@ -240,10 +266,30 @@ void Request::ReadParameters()
}
void Request::StandardLog()
{
time_t t = std::time(0);
std::tm * loct = std::localtime(&t);
char buffer[70];
sprintf(buffer, "%d.%02d.%02d %02d:%02d:%02d ", int(loct->tm_year + 1900),
int(loct->tm_mon + 1),
int(loct->tm_mday),
int(loct->tm_hour),
int(loct->tm_min),
int(loct->tm_sec));
log << log1 << buffer << env_remote_addr << ' ' << env_request_method << ' ' << env_request_uri << ' ' << env_http_user_agent << logend;
}
// reading everything
void Request::Read()
{
ReadEnvVariables();
ReadEnvVariables();
StandardLog();
CheckMethod();
ReadParameters();
}
@@ -257,7 +303,7 @@ void Request::SendAll()
FCGX_PutS("Status: 301 Moved Permanently\r\n", out);
FCGX_FPrintF(out, "Location: %s\r\n", str.c_str());
log << log2 << "Redirect into: " << str << logend;
log << log2 << "Redirect to: " << str << logend;
}
else
{
@@ -288,6 +334,21 @@ void Request::SendAll()
bool Request::IsParam(const char * s)
{
std::vector<std::string*>::iterator i;
for(i=param_table.begin() ; i!=param_table.end() ; ++i)
{
if( **i == s )
return true;
}
return false;
}
bool Request::CanChangeUser(const Item & item, long new_user_id)
{
if( !session )