24c6c1 | 2000-02-20 | Martin Nilsson | |
|
e6f83d | 2000-03-06 | Peter Bortas | |
|
199d03 | 1999-09-05 | Francesco Chemolli | |
|
a0fbcc | 2000-04-05 | Martin Stjernholm | | constant cvs_version = "$Id: configuration.pike,v 1.297 2000/04/05 17:52:50 mast Exp $";
|
4d1683 | 1999-11-17 | Per Hedbor | | constant is_configuration = 1;
|
b1fca0 | 1996-11-12 | Per Hedbor | | #include <module.h>
|
14179b | 1997-01-29 | Per Hedbor | | #include <roxen.h>
|
c5e096 | 1999-10-04 | Per Hedbor | | #include <request_trace.h>
|
8afc81 | 1998-02-04 | Per Hedbor | |
|
cf0f68 | 2000-02-08 | Per Hedbor | | inherit "basic_defvar";
|
c5e096 | 1999-10-04 | Per Hedbor | | mapping enabled_modules = ([]);
|
4d1683 | 1999-11-17 | Per Hedbor | | mapping(string:array(int)) error_log=([]);
|
8afc81 | 1998-02-04 | Per Hedbor | |
#ifdef PROFILE
mapping profile_map = ([]);
#endif
|
c7a5f0 | 1999-02-16 | Per Hedbor | | #define CATCH(P,X) do{mixed e;if(e=catch{X;})report_error("While "+P+"\n"+describe_backtrace(e));}while(0)
|
18be21 | 1998-05-07 | Henrik Grubbström (Grubba) | |
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | |
|
b87aa7 | 1998-10-15 | Henrik Grubbström (Grubba) | | #define LOCALE LOW_LOCALE->base_server
|
18be21 | 1998-05-07 | Henrik Grubbström (Grubba) | |
|
199d03 | 1999-09-05 | Francesco Chemolli | | #ifdef THROTTLING_DEBUG
#undef THROTTLING_DEBUG
|
10c7e1 | 1999-12-28 | Martin Nilsson | | #define THROTTLING_DEBUG(X) werror("Throttling: "+X+"\n")
|
199d03 | 1999-09-05 | Francesco Chemolli | | #else
#define THROTTLING_DEBUG(X)
#endif
|
10c7e1 | 1999-12-28 | Martin Nilsson | | #ifdef REQUEST_DEBUG
# define REQUEST_WERR(X) werror("CONFIG: "+X+"\n")
#else
# define REQUEST_WERR(X)
#endif
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
dfe036 | 2000-03-19 | Martin Nilsson | |
|
3b1783 | 1998-11-22 | Per Hedbor | | #include "rxml.pike";
|
14179b | 1997-01-29 | Per Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | object throttler;
function store = roxen->store;
function retrieve = roxen->retrieve;
function remove = roxen->remove;
RoxenModule types_module;
RoxenModule auth_module;
RoxenModule dir_module;
function types_fun;
function auth_fun;
|
b1fca0 | 1996-11-12 | Per Hedbor | |
string name;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | mapping variables = ([]);
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
1d7d6d | 2000-02-16 | Per Hedbor | | int inited;
|
c7a5f0 | 1999-02-16 | Per Hedbor | |
|
65c6d2 | 2000-03-10 | Martin Nilsson | | int config_id;
int get_config_id() {
if(config_id) return config_id;
for(int i=sizeof(roxen->configurations); i;)
if(roxen->configurations[--i]->name==name) return config_id=i;
}
|
c7a5f0 | 1999-02-16 | Per Hedbor | | string get_doc_for( string region, string variable )
{
|
e351dd | 1999-11-29 | Per Hedbor | | RoxenModule module;
|
c7a5f0 | 1999-02-16 | Per Hedbor | | if(variable[0] == '_')
return 0;
if((int)reverse(region))
return 0;
if(module = find_module( region ))
{
if(module->variables[variable])
return module->variables[variable][VAR_NAME]+
"\n"+module->variables[ variable ][ VAR_DOC_STR ];
}
if(variables[ variable ])
return variables[variable][VAR_NAME]+
"\n"+variables[ variable ][ VAR_DOC_STR ];
}
|
c85684 | 1998-01-21 | Henrik Grubbström (Grubba) | | int defvar(string var, mixed value, string name, int type,
string|void doc_str, mixed|void misc,
int|function|void not_in_config)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
cf0f68 | 2000-02-08 | Per Hedbor | | ::defvar( var, value, name, type, doc_str, misc );
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
cf0f68 | 2000-02-08 | Per Hedbor | | type &= (VAR_EXPERT | VAR_MORE | VAR_INITIAL | VAR_DEVELOPER);
|
c5e096 | 1999-10-04 | Per Hedbor | | if (functionp(not_in_config))
if (type)
|
cf0f68 | 2000-02-08 | Per Hedbor | | variables[ var ][ VAR_CONFIGURABLE ] =
roxen->ConfigurableWrapper(type, not_in_config)->check;
|
c5e096 | 1999-10-04 | Per Hedbor | | else
|
7acb8e | 1998-07-07 | Henrik Grubbström (Grubba) | | variables[var][ VAR_CONFIGURABLE ] = not_in_config;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | else if (type)
|
7acb8e | 1998-07-07 | Henrik Grubbström (Grubba) | | variables[var][ VAR_CONFIGURABLE ] = type;
|
c5e096 | 1999-10-04 | Per Hedbor | | else if(intp(not_in_config))
|
7acb8e | 1998-07-07 | Henrik Grubbström (Grubba) | | variables[var][ VAR_CONFIGURABLE ] = !not_in_config;
|
df6cd1 | 1998-10-13 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | int definvisvar(string var, mixed value, int type)
{
return defvar(var, value, "", type, "", 0, 1);
}
|
e351dd | 1999-11-29 | Per Hedbor | | string query_internal_location(RoxenModule|void mod)
|
5839c3 | 1999-01-22 | Marcus Comstedt | | {
|
c5e096 | 1999-10-04 | Per Hedbor | | return QUERY(InternalLoc)+(mod?replace(otomod[mod]||"", "#", "!")+"/":"");
|
5839c3 | 1999-01-22 | Marcus Comstedt | | }
|
b1fca0 | 1996-11-12 | Per Hedbor | |
string query_name()
{
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(strlen(QUERY(name)))
|
c5e096 | 1999-10-04 | Per Hedbor | | return QUERY(name);
|
b1fca0 | 1996-11-12 | Per Hedbor | | return name;
}
string comment()
{
return QUERY(comment);
}
|
10c7e1 | 1999-12-28 | Martin Nilsson | | class Priority
|
27b0e1 | 1996-11-26 | Per Hedbor | | {
|
ec9150 | 1999-11-23 | Per Hedbor | | string _sprintf()
{
return "Priority()";
}
|
e351dd | 1999-11-29 | Per Hedbor | | array (RoxenModule) url_modules = ({ });
array (RoxenModule) logger_modules = ({ });
array (RoxenModule) location_modules = ({ });
array (RoxenModule) filter_modules = ({ });
array (RoxenModule) last_modules = ({ });
array (RoxenModule) first_modules = ({ });
mapping (string:array(RoxenModule)) file_extension_modules = ([ ]);
mapping (RoxenModule:multiset(string)) provider_modules = ([ ]);
|
38dca8 | 1996-12-10 | Per Hedbor | |
void stop()
{
|
a8f1b3 | 2000-01-31 | Per Hedbor | | foreach(url_modules, RoxenModule m)
|
c7a5f0 | 1999-02-16 | Per Hedbor | | CATCH("stopping url modules",m->stop && m->stop());
|
a8f1b3 | 2000-01-31 | Per Hedbor | | foreach(logger_modules, RoxenModule m)
|
c7a5f0 | 1999-02-16 | Per Hedbor | | CATCH("stopping logging modules",m->stop && m->stop());
|
a8f1b3 | 2000-01-31 | Per Hedbor | | foreach(filter_modules, RoxenModule m)
|
c7a5f0 | 1999-02-16 | Per Hedbor | | CATCH("stopping filter modules",m->stop && m->stop());
|
a8f1b3 | 2000-01-31 | Per Hedbor | | foreach(location_modules, RoxenModule m)
|
c7a5f0 | 1999-02-16 | Per Hedbor | | CATCH("stopping location modules",m->stop && m->stop());
|
a8f1b3 | 2000-01-31 | Per Hedbor | | foreach(last_modules, RoxenModule m)
|
c7a5f0 | 1999-02-16 | Per Hedbor | | CATCH("stopping last modules",m->stop && m->stop());
|
a8f1b3 | 2000-01-31 | Per Hedbor | | foreach(first_modules, RoxenModule m)
|
c7a5f0 | 1999-02-16 | Per Hedbor | | CATCH("stopping first modules",m->stop && m->stop());
|
10c7e1 | 1999-12-28 | Martin Nilsson | | foreach(indices(provider_modules), RoxenModule m)
|
c7a5f0 | 1999-02-16 | Per Hedbor | | CATCH("stopping provider modules",m->stop && m->stop());
|
38dca8 | 1996-12-10 | Per Hedbor | | }
}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | array (Priority) allocate_pris()
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
c5e096 | 1999-10-04 | Per Hedbor | | return allocate(10, Priority)();
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
27b0e1 | 1996-11-26 | Per Hedbor | |
int requests;
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | |
mapping(string:mixed) extra_statistics = ([]);
|
dc54c4 | 1997-08-28 | Henrik Grubbström (Grubba) | | mapping(string:mixed) misc = ([]);
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
48315a | 1999-11-23 | Per Hedbor | | int sent;
int hsent;
int received;
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
f406ba | 1999-11-27 | Per Hedbor | | function(string:int) log_function;
|
b1fca0 | 1996-11-12 | Per Hedbor | |
private mapping (string:string) log_format = ([]);
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | private array (Priority) pri = allocate_pris();
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
f56958 | 1999-11-23 | Per Hedbor | |
public mapping modules = ([]);
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | public mapping (RoxenModule:string) otomod = ([]);
|
b1fca0 | 1996-11-12 | Per Hedbor | |
private array (function) url_module_cache, last_module_cache;
private array (function) logger_module_cache, first_module_cache;
private array (function) filter_module_cache;
private array (array (string|function)) location_module_cache;
private mapping (string:array (function)) file_extension_module_cache=([]);
|
e351dd | 1999-11-29 | Per Hedbor | | private mapping (string:array (RoxenModule)) provider_module_cache=([]);
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
38dca8 | 1996-12-10 | Per Hedbor | |
void stop()
{
|
c7a5f0 | 1999-02-16 | Per Hedbor | | CATCH("stopping type modules",
types_module && types_module->stop && types_module->stop());
CATCH("stopping auth module",
auth_module && auth_module->stop && auth_module->stop());
CATCH("stopping directory module",
dir_module && dir_module->stop && dir_module->stop());
|
10c7e1 | 1999-12-28 | Martin Nilsson | | for(int i=0; i<10; i++)
|
c7a5f0 | 1999-02-16 | Per Hedbor | | CATCH("stopping priority group",
|
5b0ec7 | 2000-04-03 | Henrik Grubbström (Grubba) | | (pri[i] && pri[i]->stop && pri[i]->stop()));
|
f86c19 | 2000-04-03 | Henrik Grubbström (Grubba) | | CATCH("stopping the logger",
log_function && lambda(mixed m){
destruct(m);
}(function_object(log_function)));
|
e62d48 | 2000-02-29 | David Hedbor | | foreach( registered_urls, string url )
roxen->unregister_url(url);
|
38dca8 | 1996-12-10 | Per Hedbor | | }
|
41b77c | 1999-07-15 | David Hedbor | | public string type_from_filename( string file, int|void to, string|void myext )
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
f28c11 | 2000-03-06 | Martin Nilsson | | array(string)|string tmp;
|
14179b | 1997-01-29 | Per Hedbor | | if(!types_fun)
return to?({ "application/octet-stream", 0 }):"application/octet-stream";
|
dfe036 | 2000-03-19 | Martin Nilsson | | string ext=myext || Roxen.extension(file);
|
41b77c | 1999-07-15 | David Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | if(tmp = types_fun(ext))
{
mixed tmp2,nx;
if(tmp[0] == "strip")
{
tmp2=file/".";
if(sizeof(tmp2) > 2)
nx=tmp2[-2];
if(nx && (tmp2=types_fun(nx)))
tmp[0] = tmp2[0];
|
9be5aa | 1998-07-03 | Henrik Grubbström (Grubba) | | else if(tmp2=types_fun("default"))
tmp[0] = tmp2[0];
|
14179b | 1997-01-29 | Per Hedbor | | else
|
9be5aa | 1998-07-03 | Henrik Grubbström (Grubba) | | tmp[0]="application/octet-stream";
|
14179b | 1997-01-29 | Per Hedbor | | }
|
9be5aa | 1998-07-03 | Henrik Grubbström (Grubba) | | } else if(!(tmp = types_fun("default"))) {
tmp = ({ "application/octet-stream", 0 });
|
14179b | 1997-01-29 | Per Hedbor | | }
|
9be5aa | 1998-07-03 | Henrik Grubbström (Grubba) | | return to?tmp:tmp[0];
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
ae32d0 | 1998-03-23 | David Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | array (RoxenModule) get_providers(string provides)
|
ae32d0 | 1998-03-23 | David Hedbor | | {
|
d8b772 | 1998-05-28 | Henrik Grubbström (Grubba) | |
|
9336a8 | 1998-07-09 | Henrik Grubbström (Grubba) | |
|
ae32d0 | 1998-03-23 | David Hedbor | | if(!provider_module_cache[provides])
|
10c7e1 | 1999-12-28 | Martin Nilsson | | {
|
ae32d0 | 1998-03-23 | David Hedbor | | int i;
provider_module_cache[provides] = ({ });
for(i = 9; i >= 0; i--)
{
|
10c7e1 | 1999-12-28 | Martin Nilsson | | foreach(indices(pri[i]->provider_modules), RoxenModule d)
if(pri[i]->provider_modules[ d ][ provides ])
|
ae32d0 | 1998-03-23 | David Hedbor | | provider_module_cache[provides] += ({ d });
}
}
return provider_module_cache[provides];
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
ae32d0 | 1998-03-23 | David Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | RoxenModule get_provider(string provides)
|
ae32d0 | 1998-03-23 | David Hedbor | | {
|
e351dd | 1999-11-29 | Per Hedbor | | array (RoxenModule) prov = get_providers(provides);
|
ae32d0 | 1998-03-23 | David Hedbor | | if(sizeof(prov))
return prov[0];
return 0;
}
|
bdb8da | 1998-09-02 | Johan Schön | | array(mixed) map_providers(string provides, string fun, mixed ... args)
|
ae32d0 | 1998-03-23 | David Hedbor | | {
|
e351dd | 1999-11-29 | Per Hedbor | | array (RoxenModule) prov = get_providers(provides);
|
ae32d0 | 1998-03-23 | David Hedbor | | array error;
|
bdb8da | 1998-09-02 | Johan Schön | | array a=({ });
mixed m;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | foreach(prov, RoxenModule mod)
|
9bb813 | 1998-09-12 | Per Hedbor | | {
|
ae32d0 | 1998-03-23 | David Hedbor | | if(!objectp(mod))
continue;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(functionp(mod[fun]))
|
bdb8da | 1998-09-02 | Johan Schön | | error = catch(m=mod[fun](@args));
|
24fbd4 | 1999-04-21 | David Hedbor | | if(arrayp(error)) {
error[0] = "Error in map_providers(): "+error[0];
|
10c7e1 | 1999-12-28 | Martin Nilsson | | report_debug(describe_backtrace(error));
|
24fbd4 | 1999-04-21 | David Hedbor | | }
|
bdb8da | 1998-09-02 | Johan Schön | | else
|
9bb813 | 1998-09-12 | Per Hedbor | | a += ({ m });
|
18be21 | 1998-05-07 | Henrik Grubbström (Grubba) | | error = 0;
|
ae32d0 | 1998-03-23 | David Hedbor | | }
|
9bb813 | 1998-09-12 | Per Hedbor | | return a;
|
ae32d0 | 1998-03-23 | David Hedbor | | }
mixed call_provider(string provides, string fun, mixed ... args)
{
|
10c7e1 | 1999-12-28 | Martin Nilsson | | foreach(get_providers(provides), RoxenModule mod)
|
e351dd | 1999-11-29 | Per Hedbor | | {
|
d8b772 | 1998-05-28 | Henrik Grubbström (Grubba) | | function f;
if(objectp(mod) && functionp(f = mod[fun])) {
mixed error;
if (arrayp(error = catch {
mixed ret;
if (ret = f(@args)) {
|
c5e096 | 1999-10-04 | Per Hedbor | | return ret;
|
d8b772 | 1998-05-28 | Henrik Grubbström (Grubba) | | }
})) {
|
24fbd4 | 1999-04-21 | David Hedbor | | error[0] = "Error in call_provider(): "+error[0];
throw(error);
|
d8b772 | 1998-05-28 | Henrik Grubbström (Grubba) | | }
}
|
ae32d0 | 1998-03-23 | David Hedbor | | }
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | array (function) file_extension_modules(string ext, RequestID id)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
if(!file_extension_module_cache[ext])
|
10c7e1 | 1999-12-28 | Martin Nilsson | | {
|
b1fca0 | 1996-11-12 | Per Hedbor | | int i;
file_extension_module_cache[ext] = ({ });
for(i=9; i>=0; i--)
{
|
e351dd | 1999-11-29 | Per Hedbor | | array(RoxenModule) d;
RoxenModule p;
|
b1fca0 | 1996-11-12 | Per Hedbor | | if(d = pri[i]->file_extension_modules[ext])
foreach(d, p)
file_extension_module_cache[ext] += ({ p->handle_file_extension });
}
}
return file_extension_module_cache[ext];
}
|
e351dd | 1999-11-29 | Per Hedbor | | array (function) url_modules(RequestID id)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
if(!url_module_cache)
{
int i;
url_module_cache=({ });
for(i=9; i>=0; i--)
{
|
e351dd | 1999-11-29 | Per Hedbor | | array(RoxenModule) d;
RoxenModule p;
|
b1fca0 | 1996-11-12 | Per Hedbor | | if(d=pri[i]->url_modules)
foreach(d, p)
url_module_cache += ({ p->remap_url });
}
}
return url_module_cache;
}
|
4f4bc1 | 1998-02-04 | Per Hedbor | | mapping api_module_cache = ([]);
|
e351dd | 1999-11-29 | Per Hedbor | | mapping api_functions(void|RequestID id)
|
4f4bc1 | 1998-02-04 | Per Hedbor | | {
return copy_value(api_module_cache);
}
|
e351dd | 1999-11-29 | Per Hedbor | | array (function) logger_modules(RequestID id)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
if(!logger_module_cache)
{
int i;
logger_module_cache=({ });
for(i=9; i>=0; i--)
{
|
e351dd | 1999-11-29 | Per Hedbor | | array(RoxenModule) d;
RoxenModule p;
|
b1fca0 | 1996-11-12 | Per Hedbor | | if(d=pri[i]->logger_modules)
foreach(d, p)
if(p->log)
logger_module_cache += ({ p->log });
}
}
return logger_module_cache;
}
|
e351dd | 1999-11-29 | Per Hedbor | | array (function) last_modules(RequestID id)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
if(!last_module_cache)
{
int i;
last_module_cache=({ });
for(i=9; i>=0; i--)
{
|
e351dd | 1999-11-29 | Per Hedbor | | array(RoxenModule) d;
RoxenModule p;
|
b1fca0 | 1996-11-12 | Per Hedbor | | if(d=pri[i]->last_modules)
foreach(d, p)
if(p->last_resort)
last_module_cache += ({ p->last_resort });
}
}
return last_module_cache;
}
|
ca44e5 | 1998-07-02 | Henrik Grubbström (Grubba) | | #ifdef __NT__
|
e351dd | 1999-11-29 | Per Hedbor | | static mixed strip_fork_information(RequestID id)
|
ca44e5 | 1998-07-02 | Henrik Grubbström (Grubba) | | {
array a = id->not_query/"::";
id->not_query = a[0];
id->misc->fork_information = a[1..];
|
c5e096 | 1999-10-04 | Per Hedbor | | return 0;
|
ca44e5 | 1998-07-02 | Henrik Grubbström (Grubba) | | }
#endif /* __NT__ */
|
e351dd | 1999-11-29 | Per Hedbor | | array (function) first_modules(RequestID id)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
if(!first_module_cache)
{
int i;
|
ca44e5 | 1998-07-02 | Henrik Grubbström (Grubba) | | first_module_cache=({
#ifdef __NT__
strip_fork_information,
#endif /* __NT__ */
});
|
b1fca0 | 1996-11-12 | Per Hedbor | | for(i=9; i>=0; i--)
{
|
e351dd | 1999-11-29 | Per Hedbor | | array(RoxenModule) d; RoxenModule p;
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | if(d=pri[i]->first_modules) {
foreach(d, p) {
if(p->first_try) {
|
b1fca0 | 1996-11-12 | Per Hedbor | | first_module_cache += ({ p->first_try });
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | }
}
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
}
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
|
b1fca0 | 1996-11-12 | Per Hedbor | | return first_module_cache;
}
|
e351dd | 1999-11-29 | Per Hedbor | | array location_modules(RequestID id)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
if(!location_module_cache)
{
int i;
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | array new_location_module_cache=({ });
|
b1fca0 | 1996-11-12 | Per Hedbor | | for(i=9; i>=0; i--)
{
|
10c7e1 | 1999-12-28 | Martin Nilsson | | array(RoxenModule) d;
|
e351dd | 1999-11-29 | Per Hedbor | | RoxenModule p;
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | if(d=pri[i]->location_modules) {
array level_find_files = ({});
array level_locations = ({});
foreach(d, p) {
string location;
if(p->find_file && (location = p->query_location())) {
level_find_files += ({ p->find_file });
level_locations += ({ location });
}
}
sort(level_locations, level_find_files);
int j;
for (j = sizeof(level_locations); j--;) {
new_location_module_cache += ({ ({ level_locations[j],
level_find_files[j] }) });
}
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | location_module_cache = new_location_module_cache;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
return location_module_cache;
}
|
e351dd | 1999-11-29 | Per Hedbor | | array filter_modules(RequestID id)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
if(!filter_module_cache)
{
int i;
filter_module_cache=({ });
for(i=9; i>=0; i--)
{
|
10c7e1 | 1999-12-28 | Martin Nilsson | | array(RoxenModule) d;
|
e351dd | 1999-11-29 | Per Hedbor | | RoxenModule p;
|
b1fca0 | 1996-11-12 | Per Hedbor | | if(d=pri[i]->filter_modules)
foreach(d, p)
if(p->filter)
filter_module_cache+=({ p->filter });
}
}
return filter_module_cache;
}
|
3bb38c | 2000-01-20 | Martin Bähr | | static string cached_hostname = gethostname();
|
1c7823 | 2000-03-13 | Per Hedbor | | class LogFile
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
1c7823 | 2000-03-13 | Per Hedbor | | Stdio.File fd;
int opened;
string fname;
void do_open()
{
|
5b0ec7 | 2000-04-03 | Henrik Grubbström (Grubba) | | mixed parent;
if (catch { parent = function_object(object_program(this_object())); } ||
!parent) {
remove_call_out(do_open);
remove_call_out(do_close);
destruct();
return;
}
|
651361 | 2000-03-14 | Per Hedbor | | string ff = fname;
mapping m = localtime(time());
m->year += 1900;
m->mon++;
if(m->mon < 10) m->mon = "0"+m->mon;
if(m->mday < 10) m->mday = "0"+m->mday;
if(m->hour < 10) m->hour = "0"+m->hour;
ff = replace(fname,({"%d","%m","%y","%h", "%H" }),
({ (string)m->mday, (string)(m->mon),
(string)(m->year),(string)m->hour,
cached_hostname,
}));
mkdirhier( ff );
fd = open( ff, "wac" );
if(!fd)
{
remove_call_out( do_open );
call_out( do_open, 120 );
report_error("Failed to open logfile "+fname+" "
#if constant(strerror)
"(" + strerror(errno()) + ")"
#endif
"\n");
return;
}
|
1c7823 | 2000-03-13 | Per Hedbor | | opened = 1;
|
651361 | 2000-03-14 | Per Hedbor | | remove_call_out( do_open );
call_out( do_open, 1800 );
|
1c7823 | 2000-03-13 | Per Hedbor | | }
void do_close()
{
destruct( fd );
opened = 0;
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
651361 | 2000-03-14 | Per Hedbor | | int write( string what )
|
1c7823 | 2000-03-13 | Per Hedbor | | {
|
651361 | 2000-03-14 | Per Hedbor | | if( !opened ) do_open();
if( !opened ) return 0;
|
1c7823 | 2000-03-13 | Per Hedbor | | remove_call_out( do_close );
call_out( do_close, 10.0 );
|
651361 | 2000-03-14 | Per Hedbor | | return fd->write( what );
|
1c7823 | 2000-03-13 | Per Hedbor | | }
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
1c7823 | 2000-03-13 | Per Hedbor | | static void create( string f )
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
651361 | 2000-03-14 | Per Hedbor | | fname = f;
|
1c7823 | 2000-03-13 | Per Hedbor | | opened = 0;
}
}
void init_log_file()
{
if(log_function)
{
destruct(function_object(log_function));
log_function = 0;
}
if(query("Log"))
{
string logfile = query("LogFile");
|
f7d981 | 1997-09-12 | Per Hedbor | | if(strlen(logfile))
|
1c7823 | 2000-03-13 | Per Hedbor | | log_function = LogFile( logfile )->write;
}
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | |
private inline string fix_logging(string s)
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
14179b | 1997-01-29 | Per Hedbor | | string pre, post, c;
sscanf(s, "%*[\t ]", s);
s = replace(s, ({"\\t", "\\n", "\\r" }), ({"\t", "\n", "\r" }));
|
62eac8 | 1997-10-03 | Henrik Grubbström (Grubba) | |
|
1c7823 | 2000-03-13 | Per Hedbor | | s = String.trim_whites( s );
|
14179b | 1997-01-29 | Per Hedbor | | while(sscanf(s, "%s$char(%d)%s", pre, c, post)==3)
s=sprintf("%s%c%s", pre, c, post);
while(sscanf(s, "%s$wchar(%d)%s", pre, c, post)==3)
s=sprintf("%s%2c%s", pre, c, post);
while(sscanf(s, "%s$int(%d)%s", pre, c, post)==3)
s=sprintf("%s%4c%s", pre, c, post);
if(!sscanf(s, "%s$^%s", pre, post))
s+="\n";
else
s=pre+post;
return s;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | private void parse_log_formats()
{
string b;
array foo=query("LogFormat")/"\n";
foreach(foo, b)
if(strlen(b) && b[0] != '#' && sizeof(b/":")>1)
|
62eac8 | 1997-10-03 | Henrik Grubbström (Grubba) | | log_format[(b/":")[0]] = fix_logging((b/":")[1..]*":");
|
14179b | 1997-01-29 | Per Hedbor | | }
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | |
private void write_to_log( string host, string rest, string oh, function fun )
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
14179b | 1997-01-29 | Per Hedbor | | int s;
if(!host) host=oh;
if(!stringp(host))
host = "error:no_host";
|
71c7b1 | 1998-03-02 | Henrik Grubbström (Grubba) | | else
host = (host/" ")[0];
|
14179b | 1997-01-29 | Per Hedbor | | if(fun) fun(replace(rest, "$host", host));
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | |
nomask private inline string host_ip_to_int(string s)
{
int a, b, c, d;
sscanf(s, "%d.%d.%d.%d", a, b, c, d);
return sprintf("%c%c%c%c",a, b, c, d);
}
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | nomask private inline string unsigned_to_bin(int a)
{
return sprintf("%4c", a);
}
nomask private inline string unsigned_short_to_bin(int a)
{
return sprintf("%2c", a);
}
nomask private inline string extract_user(string from)
{
array tmp;
if (!from || sizeof(tmp = from/":")<2)
return "-";
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | return tmp[0];
}
|
f406ba | 1999-11-27 | Per Hedbor | | public void log(mapping file, RequestID request_id)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
e5bad2 | 1998-02-10 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | string a;
string form;
function f;
foreach(logger_modules(request_id), f)
if(f(request_id,file))return;
|
097690 | 1998-11-26 | Henrik Grubbström (Grubba) | | if(!log_function || !request_id) return;
|
14179b | 1997-01-29 | Per Hedbor | |
|
dfe036 | 2000-03-19 | Martin Nilsson | | if(QUERY(NoLog) && Roxen._match(request_id->remoteaddr, QUERY(NoLog)))
|
14179b | 1997-01-29 | Per Hedbor | | return;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | if(!(form=log_format[(string)file->error]))
form = log_format["*"];
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | if(!form) return;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
form=replace(form,
({
|
14179b | 1997-01-29 | Per Hedbor | | "$ip_number", "$bin-ip_number", "$cern_date",
|
dfb4ec | 1999-05-20 | Francesco Chemolli | | "$bin-date", "$method", "$resource", "$full_resource", "$protocol",
|
14179b | 1997-01-29 | Per Hedbor | | "$response", "$bin-response", "$length", "$bin-length",
"$referer", "$user_agent", "$user", "$user_id",
|
d9624c | 1998-04-03 | Henrik Grubbström (Grubba) | | "$request-time"
|
10c7e1 | 1999-12-28 | Martin Nilsson | | }),
|
f406ba | 1999-11-27 | Per Hedbor | | ({
|
14179b | 1997-01-29 | Per Hedbor | | (string)request_id->remoteaddr,
|
71c7b1 | 1998-03-02 | Henrik Grubbström (Grubba) | | host_ip_to_int(request_id->remoteaddr),
|
dfe036 | 2000-03-19 | Martin Nilsson | | Roxen.cern_http_date(time(1)),
|
71c7b1 | 1998-03-02 | Henrik Grubbström (Grubba) | | unsigned_to_bin(time(1)),
(string)request_id->method,
|
dfe036 | 2000-03-19 | Martin Nilsson | | Roxen.http_encode_string((string)request_id->not_query),
Roxen.http_encode_string((string)request_id->raw_url),
|
71c7b1 | 1998-03-02 | Henrik Grubbström (Grubba) | | (string)request_id->prot,
(string)(file->error||200),
unsigned_short_to_bin(file->error||200),
(string)(file->len>=0?file->len:"?"),
unsigned_to_bin(file->len),
(string)
(sizeof(request_id->referer||({}))?request_id->referer[0]:"-"),
|
dfe036 | 2000-03-19 | Martin Nilsson | | Roxen.http_encode_string(sizeof(request_id->client||({}))?request_id->client*" ":"-"),
|
71c7b1 | 1998-03-02 | Henrik Grubbström (Grubba) | | extract_user(request_id->realauth),
|
f406ba | 1999-11-27 | Per Hedbor | | request_id->cookies->RoxenUserID||"0",
|
d9624c | 1998-04-03 | Henrik Grubbström (Grubba) | | (string)(time(1)-request_id->time)
|
71c7b1 | 1998-03-02 | Henrik Grubbström (Grubba) | | }));
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | if(search(form, "host") != -1)
roxen->ip_to_host(request_id->remoteaddr, write_to_log, form,
request_id->remoteaddr, log_function);
else
log_function(form);
|
e5bad2 | 1998-02-10 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | }
public string status()
|
b1fca0 | 1996-11-12 | Per Hedbor | | {
|
14179b | 1997-01-29 | Per Hedbor | | float tmp;
|
b1fca0 | 1996-11-12 | Per Hedbor | | string res="";
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | float dt = (float)(time(1) - roxen->start_time + 1);
|
14179b | 1997-01-29 | Per Hedbor | |
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res = "<table>";
|
10c7e1 | 1999-12-28 | Martin Nilsson | | res += LOCALE->config_status(((float)sent/(1024.0*1024.0)),
|
8f5abe | 1999-12-11 | Per Hedbor | | (((float)sent)/(1024.0*1024.0)/dt) * 8192.0,
|
10c7e1 | 1999-12-28 | Martin Nilsson | | ((float)hsent)/(1024.0*1024.0),
|
8f5abe | 1999-12-11 | Per Hedbor | | requests,
|
10c7e1 | 1999-12-28 | Martin Nilsson | | (((float)requests * 60.0)/dt),
|
8f5abe | 1999-12-11 | Per Hedbor | | ((float)received)/(1024.0*1024.0));
|
dc54c4 | 1997-08-28 | Henrik Grubbström (Grubba) | |
if (!zero_type(misc->ftp_users)) {
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res += LOCALE->ftp_status(misc->ftp_users,
(((float)misc->ftp_users*(float)60.0)/dt),
misc->ftp_users_now);
|
dc54c4 | 1997-08-28 | Henrik Grubbström (Grubba) | | }
|
926d1a | 1997-08-31 | Henrik Grubbström (Grubba) | | res += "</table><p>\n\n";
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if ((extra_statistics->ftp) && (extra_statistics->ftp->commands)) {
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | |
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res += LOCALE->ftp_statistics() + "<br>\n"
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | "<ul><table>\n";
foreach(sort(indices(extra_statistics->ftp->commands)), string cmd) {
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res += LOCALE->ftp_stat_line(upper_case(cmd),
extra_statistics->ftp->commands[cmd]);
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | }
res += "</table></ul>\n";
}
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | return res;
|
14179b | 1997-01-29 | Per Hedbor | | }
|
e351dd | 1999-11-29 | Per Hedbor | | public array(string) userinfo(string u, RequestID|void id)
|
14179b | 1997-01-29 | Per Hedbor | | {
if(auth_module) return auth_module->userinfo(u);
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | else report_warning(sprintf("userinfo(): %s\n"
"%s\n",
LOCALE->no_auth_module(),
describe_backtrace(backtrace())));
|
14179b | 1997-01-29 | Per Hedbor | | }
|
e351dd | 1999-11-29 | Per Hedbor | | public array(string) userlist(RequestID|void id)
|
14179b | 1997-01-29 | Per Hedbor | | {
if(auth_module) return auth_module->userlist();
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | else report_warning(sprintf("userlist(): %s\n"
"%s\n",
LOCALE->no_auth_module(),
describe_backtrace(backtrace())));
|
14179b | 1997-01-29 | Per Hedbor | | }
|
e351dd | 1999-11-29 | Per Hedbor | | public array(string) user_from_uid(int u, RequestID|void id)
|
14179b | 1997-01-29 | Per Hedbor | | {
if(auth_module)
return auth_module->user_from_uid(u);
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | else report_warning(sprintf("user_from_uid(): %s\n"
"%s\n",
LOCALE->no_auth_module(),
describe_backtrace(backtrace())));
|
14179b | 1997-01-29 | Per Hedbor | | }
|
e351dd | 1999-11-29 | Per Hedbor | | public string last_modified_by(Stdio.File file, RequestID id)
|
6103bc | 1999-10-09 | Henrik Grubbström (Grubba) | | {
|
9f9fc3 | 2000-02-17 | Per Hedbor | | array(int) s;
|
6103bc | 1999-10-09 | Henrik Grubbström (Grubba) | | int uid;
|
9f9fc3 | 2000-02-17 | Per Hedbor | | array u;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
6103bc | 1999-10-09 | Henrik Grubbström (Grubba) | | if(objectp(file)) s=file->stat();
if(!s || sizeof(s)<5) return "A. Nonymous";
uid=s[5];
u=user_from_uid(uid, id);
if(u) return u[0];
return "A. Nonymous";
}
|
14179b | 1997-01-29 | Per Hedbor | |
private mapping internal_gopher_image(string from)
{
sscanf(from, "%s.gif", from);
sscanf(from, "%s.jpg", from);
from -= ".";
|
1c7823 | 2000-03-13 | Per Hedbor | | Stdio.File f = lopen("roxen-images/dir/"+from+".gif","r");
if (f)
{
|
06026c | 1999-10-19 | Henrik Grubbström (Grubba) | | return (["file":f, "type":"image/gif"]);
} else {
return 0;
}
|
14179b | 1997-01-29 | Per Hedbor | | }
private static int nest = 0;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
private mapping misc_cache=([]);
|
e351dd | 1999-11-29 | Per Hedbor | | int|mapping check_security(function a, RequestID id, void|int slevel)
|
14179b | 1997-01-29 | Per Hedbor | | {
array level;
array seclevels;
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | int ip_ok = 0;
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | int auth_ok = 0;
|
193535 | 1997-04-28 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | | if(!(seclevels = misc_cache[ a ]))
|
3b1783 | 1998-11-22 | Per Hedbor | | if(function_object(a)->query_seclevels)
misc_cache[ a ] = seclevels = ({
function_object(a)->query_seclevels(),
function_object(a)->query("_seclvl"),
function_object(a)->query("_sec_group")
});
else
misc_cache[ a ] = seclevels = ({({}),0,"foo" });
|
14179b | 1997-01-29 | Per Hedbor | |
if(slevel && (seclevels[1] > slevel))
return 1;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | if(!sizeof(seclevels[0]))
return 0;
|
18be21 | 1998-05-07 | Henrik Grubbström (Grubba) | | mixed err;
err = catch {
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | foreach(seclevels[0], level) {
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | switch(level[0]) {
case MOD_ALLOW:
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | if(level[1](id->remoteaddr)) {
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | ip_ok = ~0;
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | } else {
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | ip_ok |= 1;
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | }
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | break;
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | case MOD_DENY:
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | |
|
a75a32 | 1997-05-14 | Henrik Grubbström (Grubba) | | if(level[1](id->remoteaddr))
|
dfe036 | 2000-03-19 | Martin Nilsson | | return Roxen.http_low_answer(403, "<h2>Access forbidden</h2>");
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | break;
|
14179b | 1997-01-29 | Per Hedbor | |
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | case MOD_USER:
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | if(id->auth && id->auth[0] && level[1](id->auth[1])) {
auth_ok = ~0;
} else {
auth_ok |= 1;
}
break;
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
cc6d7c | 1997-07-22 | Henrik Grubbström (Grubba) | | case MOD_PROXY_USER:
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | if (ip_ok != 1) {
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(id->misc->proxyauth && id->misc->proxyauth[0] &&
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | level[1](id->misc->proxyauth[1])) return 0;
|
dfe036 | 2000-03-19 | Martin Nilsson | | return Roxen.http_proxy_auth_required(seclevels[2]);
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | } else {
|
c5e096 | 1999-10-04 | Per Hedbor | | return 1;
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | }
|
7be80e | 1998-06-29 | Henrik Grubbström (Grubba) | | break;
case MOD_ACCEPT:
if(level[1](id->remoteaddr)) {
|
c5e096 | 1999-10-04 | Per Hedbor | | return 0;
|
7be80e | 1998-06-29 | Henrik Grubbström (Grubba) | | } else {
ip_ok |= 1;
}
break;
case MOD_ACCEPT_USER:
if(id->auth && id->auth[0] && level[1](id->auth[1])) {
|
c5e096 | 1999-10-04 | Per Hedbor | | return 0;
|
7be80e | 1998-06-29 | Henrik Grubbström (Grubba) | | } else {
if (id->auth) {
auth_ok |= 1;
} else {
|
dfe036 | 2000-03-19 | Martin Nilsson | | return Roxen.http_auth_required(seclevels[2]);
|
7be80e | 1998-06-29 | Henrik Grubbström (Grubba) | | }
}
break;
|
14179b | 1997-01-29 | Per Hedbor | | }
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | }
|
14179b | 1997-01-29 | Per Hedbor | | };
|
18be21 | 1998-05-07 | Henrik Grubbström (Grubba) | |
if (err) {
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | report_error(LOCALE->module_security_error(describe_backtrace(err)));
|
c5e096 | 1999-10-04 | Per Hedbor | | return 1;
|
18be21 | 1998-05-07 | Henrik Grubbström (Grubba) | | }
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | if (ip_ok == 1) {
|
c5e096 | 1999-10-04 | Per Hedbor | | return 1;
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | } else {
if (auth_ok == 1) {
|
dfe036 | 2000-03-19 | Martin Nilsson | | return Roxen.http_auth_required(seclevels[2]);
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | } else {
|
c5e096 | 1999-10-04 | Per Hedbor | | return 0;
|
12a9c5 | 1997-08-11 | Henrik Grubbström (Grubba) | | }
|
2028af | 1997-07-07 | Henrik Grubbström (Grubba) | | }
|
14179b | 1997-01-29 | Per Hedbor | | }
#endif
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | void invalidate_cache()
|
14179b | 1997-01-29 | Per Hedbor | | {
last_module_cache = 0;
filter_module_cache = 0;
first_module_cache = 0;
url_module_cache = 0;
location_module_cache = 0;
logger_module_cache = 0;
file_extension_module_cache = ([]);
|
ae32d0 | 1998-03-23 | David Hedbor | | provider_module_cache = ([]);
|
14179b | 1997-01-29 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
if(misc_cache)
misc_cache = ([ ]);
#endif
}
|
ec058c | 1998-07-04 | Henrik Grubbström (Grubba) | |
void clear_memory_caches()
{
invalidate_cache();
|
10c7e1 | 1999-12-28 | Martin Nilsson | | foreach(indices(otomod), RoxenModule m)
if (m && m->clear_memory_caches)
if (mixed err = catch( m->clear_memory_caches() ))
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | report_error(LOCALE->
clear_memory_cache_error(otomod[m],
describe_backtrace(err)));
|
ec058c | 1998-07-04 | Henrik Grubbström (Grubba) | | }
|
fc9433 | 1997-10-25 | Per Hedbor | | string draw_saturation_bar(int hue,int brightness, int where)
{
|
e351dd | 1999-11-29 | Per Hedbor | | Image.Image bar=Image.Image(30,256);
|
fc9433 | 1997-10-25 | Per Hedbor | |
for(int i=0;i<128;i++)
{
int j = i*2;
bar->line(0,j,29,j,@hsv_to_rgb(hue,255-j,brightness));
bar->line(0,j+1,29,j+1,@hsv_to_rgb(hue,255-j,brightness));
}
where = 255-where;
bar->line(0,where,29,where, 255,255,255);
|
4c6df9 | 1999-11-25 | Jonas Wallden | | return Image.GIF.encode(bar);
|
fc9433 | 1997-10-25 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | |
|
a6ef1f | 2000-03-28 | Johan Sundström | |
|
14179b | 1997-01-29 | Per Hedbor | | private mapping internal_roxen_image(string from)
{
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
2b658c | 2000-02-07 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | sscanf(from, "%s.gif", from);
sscanf(from, "%s.jpg", from);
|
2b658c | 2000-02-07 | Per Hedbor | | sscanf(from, "%s.xcf", from);
sscanf(from, "%s.png", from);
|
fc9433 | 1997-10-25 | Per Hedbor | |
|
1c7823 | 2000-03-13 | Per Hedbor | |
|
fc9433 | 1997-10-25 | Per Hedbor | | int hue,bright,w;
if(sscanf(from, "%*s:%d,%d,%d", hue, bright,w)==4)
|
dfe036 | 2000-03-19 | Martin Nilsson | | return Roxen.http_string_answer(draw_saturation_bar(hue,bright,w),"image/gif");
|
fc9433 | 1997-10-25 | Per Hedbor | |
|
2b658c | 2000-02-07 | Per Hedbor | | Stdio.File f;
|
1c7823 | 2000-03-13 | Per Hedbor | | if(f = lopen("roxen-images/"+from+".gif", "r"))
|
06026c | 1999-10-19 | Henrik Grubbström (Grubba) | | return (["file":f, "type":"image/gif"]);
|
1c7823 | 2000-03-13 | Per Hedbor | | if(f = lopen("roxen-images/"+from+".jpg", "r"))
|
06026c | 1999-10-19 | Henrik Grubbström (Grubba) | | return (["file":f, "type":"image/jpeg"]);
|
1c7823 | 2000-03-13 | Per Hedbor | | if(f = lopen("roxen-images/"+from+".png", "r"))
|
2b658c | 2000-02-07 | Per Hedbor | | return (["file":f, "type":"image/png"]);
|
1c7823 | 2000-03-13 | Per Hedbor | | if(f = lopen("roxen-images/"+from+".xcf", "r"))
|
2b658c | 2000-02-07 | Per Hedbor | | return (["file":f, "type":"image/x-gimp-image"]);
return 0;
|
14179b | 1997-01-29 | Per Hedbor | | }
mapping (mixed:function|int) locks = ([]);
#ifdef THREADS
|
e5bad2 | 1998-02-10 | Per Hedbor | |
|
e6aff0 | 1997-05-25 | Henrik Grubbström (Grubba) | |
|
55a89e | 1997-09-14 | Per Hedbor | | mapping locked = ([]), thread_safe = ([]);
|
e351dd | 1999-11-29 | Per Hedbor | | mixed _lock(object|function f)
|
14179b | 1997-01-29 | Per Hedbor | | {
object key;
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | function|int l;
|
55a89e | 1997-09-14 | Per Hedbor | |
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | if (functionp(f)) {
f = function_object(f);
}
|
55a89e | 1997-09-14 | Per Hedbor | | if (l = locks[f])
{
if (l != -1)
{
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | |
|
beb1f2 | 1998-05-23 | Mattias Wingstedt | | catch{
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
55a89e | 1997-09-14 | Per Hedbor | | locked[f]++;
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | key = l();
|
beb1f2 | 1998-05-23 | Mattias Wingstedt | | };
|
55a89e | 1997-09-14 | Per Hedbor | | } else
thread_safe[f]++;
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | } else if (f->thread_safe) {
locks[f]=-1;
|
55a89e | 1997-09-14 | Per Hedbor | | thread_safe[f]++;
|
14179b | 1997-01-29 | Per Hedbor | | } else {
|
55a89e | 1997-09-14 | Per Hedbor | | if (!locks[f])
{
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | |
|
e5bad2 | 1998-02-10 | Per Hedbor | | l = Thread.Mutex()->lock;
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | if (!locks[f]) {
locks[f]=l;
}
|
14179b | 1997-01-29 | Per Hedbor | | }
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
55a89e | 1997-09-14 | Per Hedbor | | locked[f]++;
|
1fab6f | 1997-09-03 | Henrik Grubbström (Grubba) | | key = l();
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | return key;
|
b1fca0 | 1996-11-12 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | #define LOCK(X) key=_lock(X)
|
d7b087 | 1997-08-31 | Per Hedbor | | #define UNLOCK() do{key=0;}while(0)
|
14179b | 1997-01-29 | Per Hedbor | | #else
#define LOCK(X)
|
c95bd5 | 1998-01-30 | Henrik Grubbström (Grubba) | | #define UNLOCK()
|
14179b | 1997-01-29 | Per Hedbor | | #endif
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | string examine_return_mapping(mapping m)
{
string res;
if (m->extra_heads)
m->extra_heads=mkmapping(Array.map(indices(m->extra_heads),
lower_case),
values(m->extra_heads));
else
m->extra_heads=([]);
switch (m->error||200)
{
case 302:
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if (m->extra_heads &&
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | (m->extra_heads->location))
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res = LOCALE->returned_redirect_to(m->extra_heads->location);
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | else
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res = LOCALE->returned_redirect_no_location();
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | break;
case 401:
if (m->extra_heads["www-authenticate"])
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res = LOCALE->
returned_authenticate(m->extra_heads["www-authenticate"]);
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | else
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res = LOCALE->returned_auth_failed();
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | break;
case 200:
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res = LOCALE->returned_ok();
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | break;
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | default:
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res = LOCALE->returned_error(m->error);
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | }
if (!zero_type(m->len))
if (m->len<0)
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res += LOCALE->returned_no_data();
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | else
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res += LOCALE->returned_bytes(m->len);
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | else if (stringp(m->data))
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res += LOCALE->returned_bytes(strlen(m->data));
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | | else if (objectp(m->file))
if (catch {
array a=m->file->stat();
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | res += LOCALE->returned_bytes(a[1]-m->file->tell());
})
res += LOCALE->returned_unknown_bytes();
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | |
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | if (m->data) res += LOCALE->returned_static_data();
|
7b8078 | 1999-02-15 | Marcus Comstedt | | else if (m->file) res += LOCALE->returned_open_file();
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | |
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | if (stringp(m->extra_heads["http-content-type"]) ||
stringp(m->type)) {
res += LOCALE->returned_type(m->type);
}
|
a1334f | 1998-02-20 | Mirar (Pontus Hagland) | |
res+="<br>";
return res;
}
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | mapping|int low_get_file(RequestID id, int|void no_magic)
|
14179b | 1997-01-29 | Per Hedbor | | {
#ifdef MODULE_LEVEL_SECURITY
int slevel;
#endif
#ifdef THREADS
object key;
#endif
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->request_for(id->not_query), 0);
|
14179b | 1997-01-29 | Per Hedbor | |
string file=id->not_query;
string loc;
function funp;
mixed tmp, tmp2;
mapping|object fid;
if(!no_magic)
{
|
41b77c | 1999-07-15 | David Hedbor | | #ifndef NO_INTERNAL_HACK
string type;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
41b77c | 1999-07-15 | David Hedbor | |
if(sizeof(file) > 17 && (file[0] == '/') &&
sscanf(file, "%*s/internal-%s-%[^/]", type, loc) == 3)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
41b77c | 1999-07-15 | David Hedbor | | switch(type) {
case "gopher":
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->magic_internal_gopher());
|
14179b | 1997-01-29 | Per Hedbor | | return internal_gopher_image(loc);
|
41b77c | 1999-07-15 | David Hedbor | |
case "spinner": case "roxen":
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->magic_internal_roxen());
|
14179b | 1997-01-29 | Per Hedbor | | return internal_roxen_image(loc);
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | }
#endif
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | if(id->prestate->diract && dir_module)
{
LOCK(dir_module);
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->directory_module(), dir_module);
|
14179b | 1997-01-29 | Per Hedbor | | tmp = dir_module->parse_directory(id);
UNLOCK();
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(mappingp(tmp))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("");
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returning_data());
|
41d0f9 | 1998-02-20 | Per Hedbor | | return tmp;
}
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | }
|
5839c3 | 1999-01-22 | Marcus Comstedt | |
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(!search(file, QUERY(InternalLoc)))
|
5839c3 | 1999-01-22 | Marcus Comstedt | | {
TRACE_ENTER(LOCALE->magic_internal_module_location(), 0);
|
e351dd | 1999-11-29 | Per Hedbor | | RoxenModule module;
|
5839c3 | 1999-01-22 | Marcus Comstedt | | string name, rest;
function find_internal;
if(2==sscanf(file[strlen(QUERY(InternalLoc))..], "%s/%s", name, rest) &&
(module = find_module(replace(name, "!", "#"))) &&
(find_internal = module->find_internal))
{
#ifdef MODULE_LEVEL_SECURITY
if(tmp2 = check_security(find_internal, id, slevel))
if(intp(tmp2))
{
TRACE_LEAVE(LOCALE->module_access_denied());
find_internal = 0;
} else {
TRACE_LEAVE("");
TRACE_LEAVE(LOCALE->request_denied());
return tmp2;
}
#endif
|
41b77c | 1999-07-15 | David Hedbor | | if(find_internal)
|
5839c3 | 1999-01-22 | Marcus Comstedt | | {
|
8f46d9 | 1999-01-22 | Marcus Comstedt | | TRACE_ENTER(LOCALE->calling_find_internal(), find_internal);
|
5839c3 | 1999-01-22 | Marcus Comstedt | | LOCK(find_internal);
fid=find_internal( rest, id );
UNLOCK();
TRACE_LEAVE(LOCALE->find_internal_returned(fid));
if(fid)
{
if(mappingp(fid))
{
TRACE_LEAVE("");
TRACE_LEAVE(examine_return_mapping(fid));
return fid;
}
else
{
#ifdef MODULE_LEVEL_SECURITY
int oslevel = slevel;
slevel = misc_cache[ find_internal ][1];
id->misc->seclevel = slevel;
#endif
if(objectp(fid))
TRACE_LEAVE(LOCALE->returned_fd()
#ifdef MODULE_LEVEL_SECURITY
+(slevel != oslevel?
LOCALE->seclevel_is_now(slevel):"")
#endif
+".");
else
TRACE_LEAVE(LOCALE->returned_directory_indicator()
#ifdef MODULE_LEVEL_SECURITY
+(oslevel != slevel?
LOCALE->seclevel_is_now(slevel):"")
#endif
);
}
} else
TRACE_LEAVE("");
} else
TRACE_LEAVE("");
} else
TRACE_LEAVE("");
}
|
14179b | 1997-01-29 | Per Hedbor | | }
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
5839c3 | 1999-01-22 | Marcus Comstedt | | if(!fid)
{
|
14179b | 1997-01-29 | Per Hedbor | | #ifdef URL_MODULES
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
|
5839c3 | 1999-01-22 | Marcus Comstedt | | foreach(url_modules(id), funp)
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
|
5839c3 | 1999-01-22 | Marcus Comstedt | | LOCK(funp);
TRACE_ENTER(LOCALE->url_module(), funp);
tmp=funp( id, file );
UNLOCK();
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
if(mappingp(tmp))
|
5839c3 | 1999-01-22 | Marcus Comstedt | | {
TRACE_LEAVE("");
TRACE_LEAVE(LOCALE->returning_data());
return tmp;
}
if(objectp( tmp ))
{
array err;
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
5839c3 | 1999-01-22 | Marcus Comstedt | | nest ++;
err = catch {
if( nest < 20 )
tmp = (id->conf || this_object())->low_get_file( tmp, no_magic );
else
{
TRACE_LEAVE(LOCALE->too_deep_recursion());
error("Too deep recursion in roxen::get_file() while mapping "
+file+".\n");
}
};
nest = 0;
if(err) throw(err);
TRACE_LEAVE("");
TRACE_LEAVE(LOCALE->returning_data());
return tmp;
}
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("");
}
|
14179b | 1997-01-29 | Per Hedbor | | #endif
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
5839c3 | 1999-01-22 | Marcus Comstedt | | foreach(location_modules(id), tmp)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
5839c3 | 1999-01-22 | Marcus Comstedt | | loc = tmp[0];
|
41b77c | 1999-07-15 | David Hedbor | | if(!search(file, loc))
|
5839c3 | 1999-01-22 | Marcus Comstedt | | {
TRACE_ENTER(LOCALE->location_module(loc), tmp[1]);
|
df8d71 | 1998-02-27 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
|
5839c3 | 1999-01-22 | Marcus Comstedt | | if(tmp2 = check_security(tmp[1], id, slevel))
if(intp(tmp2))
{
TRACE_LEAVE(LOCALE->module_access_denied());
continue;
} else {
TRACE_LEAVE("");
TRACE_LEAVE(LOCALE->request_denied());
return tmp2;
}
|
14179b | 1997-01-29 | Per Hedbor | | #endif
|
5839c3 | 1999-01-22 | Marcus Comstedt | | TRACE_ENTER(LOCALE->calling_find_file(), 0);
LOCK(tmp[1]);
fid=tmp[1]( file[ strlen(loc) .. ] + id->extra_extension, id);
UNLOCK();
|
b8b107 | 2000-03-24 | Per Hedbor | |
TRACE_LEAVE("");
|
5839c3 | 1999-01-22 | Marcus Comstedt | | if(fid)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
5839c3 | 1999-01-22 | Marcus Comstedt | | id->virtfile = loc;
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
5839c3 | 1999-01-22 | Marcus Comstedt | | if(mappingp(fid))
{
TRACE_LEAVE("");
TRACE_LEAVE(examine_return_mapping(fid));
return fid;
}
else
{
|
14179b | 1997-01-29 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
|
5839c3 | 1999-01-22 | Marcus Comstedt | | int oslevel = slevel;
slevel = misc_cache[ tmp[1] ][1];
id->misc->seclevel = slevel;
|
14179b | 1997-01-29 | Per Hedbor | | #endif
|
5839c3 | 1999-01-22 | Marcus Comstedt | | if(objectp(fid))
TRACE_LEAVE(LOCALE->returned_fd()
|
41d0f9 | 1998-02-20 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
|
5839c3 | 1999-01-22 | Marcus Comstedt | | +(slevel != oslevel?
LOCALE->seclevel_is_now(slevel):"")
|
41d0f9 | 1998-02-20 | Per Hedbor | | #endif
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
5839c3 | 1999-01-22 | Marcus Comstedt | | +".");
else
TRACE_LEAVE(LOCALE->returned_directory_indicator()
|
41d0f9 | 1998-02-20 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
|
5839c3 | 1999-01-22 | Marcus Comstedt | | +(oslevel != slevel?
LOCALE->seclevel_is_now(slevel):"")
|
41d0f9 | 1998-02-20 | Per Hedbor | | #endif
|
5839c3 | 1999-01-22 | Marcus Comstedt | | );
break;
}
} else
TRACE_LEAVE("");
|
41b77c | 1999-07-15 | David Hedbor | | } else if(strlen(loc)-1==strlen(file) && file+"/" == loc) {
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
5839c3 | 1999-01-22 | Marcus Comstedt | |
|
41b77c | 1999-07-15 | David Hedbor | | TRACE_ENTER(LOCALE->automatic_redirect_to_location(), tmp[1]);
TRACE_LEAVE(LOCALE->returning_data());
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
41b77c | 1999-07-15 | David Hedbor | |
|
dfe036 | 2000-03-19 | Martin Nilsson | | string new_query = Roxen.http_encode_string(id->not_query) + "/" +
|
41b77c | 1999-07-15 | David Hedbor | | (id->query?("?"+id->query):"");
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
dfe036 | 2000-03-19 | Martin Nilsson | | return Roxen.http_redirect(new_query, id);
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | }
}
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | if(fid == -1)
{
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(no_magic)
{
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->no_magic());
|
41d0f9 | 1998-02-20 | Per Hedbor | | return -1;
}
|
14179b | 1997-01-29 | Per Hedbor | | if(dir_module)
{
LOCK(dir_module);
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->directory_module(), dir_module);
|
14179b | 1997-01-29 | Per Hedbor | | fid = dir_module->parse_directory(id);
UNLOCK();
}
else
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->no_directory_module());
|
14179b | 1997-01-29 | Per Hedbor | | return 0;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(mappingp(fid))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returning_data());
|
41d0f9 | 1998-02-20 | Per Hedbor | | return (mapping)fid;
}
|
14179b | 1997-01-29 | Per Hedbor | | }
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | |
|
41b77c | 1999-07-15 | David Hedbor | | if(objectp(fid) &&
|
dfe036 | 2000-03-19 | Martin Nilsson | | (tmp = file_extension_modules(loc = Roxen.extension(id->not_query, id), id))) {
|
14179b | 1997-01-29 | Per Hedbor | | foreach(tmp, funp)
{
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->extension_module(loc), funp);
|
14179b | 1997-01-29 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
if(tmp=check_security(funp, id, slevel))
if(intp(tmp))
{
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->module_access_denied());
|
14179b | 1997-01-29 | Per Hedbor | | continue;
}
else
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("");
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->permission_denied());
|
14179b | 1997-01-29 | Per Hedbor | | return tmp;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | #endif
LOCK(funp);
tmp=funp(fid, loc, id);
UNLOCK();
if(tmp)
{
if(!objectp(tmp))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("");
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returning_data());
|
14179b | 1997-01-29 | Per Hedbor | | return tmp;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | if(fid)
|
41b77c | 1999-07-15 | David Hedbor | | destruct(fid);
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returned_new_open_file());
|
14179b | 1997-01-29 | Per Hedbor | | fid = tmp;
break;
|
41d0f9 | 1998-02-20 | Per Hedbor | | } else
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | }
|
41b77c | 1999-07-15 | David Hedbor | | }
|
14179b | 1997-01-29 | Per Hedbor | | if(objectp(fid))
{
|
41b77c | 1999-07-15 | David Hedbor | | if(stringp(id->extension)) {
|
14179b | 1997-01-29 | Per Hedbor | | id->not_query += id->extension;
|
dfe036 | 2000-03-19 | Martin Nilsson | | loc = Roxen.extension(id->not_query, id);
|
41b77c | 1999-07-15 | David Hedbor | | }
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->content_type_module(), types_module);
|
41b77c | 1999-07-15 | David Hedbor | | tmp=type_from_filename(id->not_query, 1, loc);
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(tmp?LOCALE->returned_mime_type(tmp[0],tmp[1]):
LOCALE->missing_type());
|
14179b | 1997-01-29 | Per Hedbor | | if(tmp)
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | return ([ "file":fid, "type":tmp[0], "encoding":tmp[1] ]);
|
10c7e1 | 1999-12-28 | Martin Nilsson | | }
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | return ([ "file":fid, ]);
}
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(!fid)
|
c7a5f0 | 1999-02-16 | Per Hedbor | | {
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returned_not_found());
|
c7a5f0 | 1999-02-16 | Per Hedbor | | }
|
41d0f9 | 1998-02-20 | Per Hedbor | | else
|
b46164 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returning_data());
|
14179b | 1997-01-29 | Per Hedbor | | return fid;
}
|
c7a5f0 | 1999-02-16 | Per Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | mixed handle_request( RequestID id )
|
c7a5f0 | 1999-02-16 | Per Hedbor | | {
function funp;
mixed file;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | REQUEST_WERR("handle_request()");
|
c7a5f0 | 1999-02-16 | Per Hedbor | | foreach(first_modules(id), funp)
{
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(file = funp( id ))
|
c7a5f0 | 1999-02-16 | Per Hedbor | | break;
|
cfda38 | 1999-03-28 | Henrik Grubbström (Grubba) | | if(id->conf != this_object()) {
|
10c7e1 | 1999-12-28 | Martin Nilsson | | REQUEST_WERR("handle_request(): Redirected (2)");
|
c7a5f0 | 1999-02-16 | Per Hedbor | | return id->conf->handle_request(id);
|
cfda38 | 1999-03-28 | Henrik Grubbström (Grubba) | | }
|
c7a5f0 | 1999-02-16 | Per Hedbor | | }
|
fd8b15 | 1999-05-19 | David Hedbor | | if(!mappingp(file) && !mappingp(file = get_file(id)))
|
c7a5f0 | 1999-02-16 | Per Hedbor | | {
mixed ret;
foreach(last_modules(id), funp) if(ret = funp(id)) break;
|
cfda38 | 1999-03-28 | Henrik Grubbström (Grubba) | | if (ret == 1) {
|
10c7e1 | 1999-12-28 | Martin Nilsson | | REQUEST_WERR("handle_request(): Recurse");
|
c7a5f0 | 1999-02-16 | Per Hedbor | | return handle_request(id);
|
cfda38 | 1999-03-28 | Henrik Grubbström (Grubba) | | }
|
c7a5f0 | 1999-02-16 | Per Hedbor | | file = ret;
}
|
10c7e1 | 1999-12-28 | Martin Nilsson | | REQUEST_WERR("handle_request(): Done");
|
c7a5f0 | 1999-02-16 | Per Hedbor | | return file;
}
|
576c11 | 2000-03-07 | Martin Stjernholm | | mixed get_file(RequestID id, int|void no_magic, int|void internal_get)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
576c11 | 2000-03-07 | Martin Stjernholm | | int orig_internal_get = id->misc->internal_get;
id->misc->internal_get = internal_get;
|
14179b | 1997-01-29 | Per Hedbor | | mixed res, res2;
function tmp;
res = low_get_file(id, no_magic);
foreach(filter_modules(id), tmp)
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->filter_module(), tmp);
|
14179b | 1997-01-29 | Per Hedbor | | if(res2=tmp(res,id))
{
if(res && res->file && (res2->file != res->file))
destruct(res->file);
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->rewrote_result());
|
14179b | 1997-01-29 | Per Hedbor | | res=res2;
|
41d0f9 | 1998-02-20 | Per Hedbor | | } else
TRACE_LEAVE("");
}
|
576c11 | 2000-03-07 | Martin Stjernholm | |
id->misc->internal_get = orig_internal_get;
|
14179b | 1997-01-29 | Per Hedbor | | return res;
}
|
b6a904 | 2000-03-17 | Martin Nilsson | | public array(string) find_dir(string file, RequestID id)
|
14179b | 1997-01-29 | Per Hedbor | | {
string loc;
|
b6a904 | 2000-03-17 | Martin Nilsson | | array dir = ({ });
array|mapping|object tmp;
|
29a807 | 1998-08-21 | David Hedbor | | array | mapping d;
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->list_directory(file), 0);
|
c7a5f0 | 1999-02-16 | Per Hedbor | |
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
193535 | 1997-04-28 | Henrik Grubbström (Grubba) | | if(file[0] != '/')
file = "/" + file;
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | #ifdef URL_MODULES
|
fc0e5d | 1997-08-26 | Henrik Grubbström (Grubba) | | #ifdef THREADS
object key;
#endif
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
foreach(url_modules(id), function funp)
{
string of = id->not_query;
id->not_query = file;
LOCK(funp);
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->url_module(), funp);
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | tmp=funp( id, file );
UNLOCK();
if(mappingp( tmp ))
{
id->not_query=of;
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returned_no_thanks());
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | return 0;
}
if(objectp( tmp ))
{
array err;
nest ++;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->recursing());
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | file = id->not_query;
err = catch {
if( nest < 20 )
tmp = (id->conf || this_object())->find_dir( file, id );
else
error("Too deep recursion in roxen::find_dir() while mapping "
+file+".\n");
};
nest = 0;
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | if(err)
throw(err);
return tmp;
}
id->not_query=of;
}
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | #endif /* URL_MODULES */
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | | foreach(location_modules(id), tmp)
{
loc = tmp[0];
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | if(!search(file, loc)) {
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->location_module(loc), tmp[1]);
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | #ifdef MODULE_LEVEL_SECURITY
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(check_security(tmp[1], id)) {
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->permission_denied());
|
41d0f9 | 1998-02-20 | Per Hedbor | | continue;
}
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | #endif
|
8dbe2d | 1997-05-26 | Henrik Grubbström (Grubba) | | if(d=function_object(tmp[1])->find_dir(file[strlen(loc)..], id))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
|
29a807 | 1998-08-21 | David Hedbor | | if(mappingp(d))
{
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(d->files) {
|
29a807 | 1998-08-21 | David Hedbor | | dir |= d->files;
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->got_exclusive_dir());
TRACE_LEAVE(LOCALE->returning_file_list(sizeof(dir)));
|
29a807 | 1998-08-21 | David Hedbor | | return dir;
} else
TRACE_LEAVE("");
} else {
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->got_files());
|
29a807 | 1998-08-21 | David Hedbor | | dir |= d;
}
|
41d0f9 | 1998-02-20 | Per Hedbor | | } else
TRACE_LEAVE("");
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | } else if((search(loc, file)==0) && (loc[strlen(file)-1]=='/') &&
(loc[0]==loc[-1]) && (loc[-1]=='/') &&
|
6c67c8 | 1998-02-28 | Johan Schön | | (function_object(tmp[1])->stat_file(".", id))) {
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | |
24fa08 | 1998-02-28 | Henrik Grubbström (Grubba) | | * and stat_file(".") returns non-zero.
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | */
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->location_module(loc), tmp[1]);
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | loc=loc[strlen(file)..];
sscanf(loc, "%s/", loc);
dir += ({ loc });
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->added_module_mountpoint());
|
14179b | 1997-01-29 | Per Hedbor | | }
}
if(sizeof(dir))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
|
cfda38 | 1999-03-28 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returning_file_list(sizeof(dir)));
|
14179b | 1997-01-29 | Per Hedbor | | return dir;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | }
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returning_no_dir());
|
14179b | 1997-01-29 | Per Hedbor | | }
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | public array(int) stat_file(string file, RequestID id)
|
14179b | 1997-01-29 | Per Hedbor | | {
string loc;
array s, tmp;
|
c5e096 | 1999-10-04 | Per Hedbor | | #ifdef THREADS
object key;
#endif
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->stat_file(file), 0);
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | file=replace(file, "//", "/");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | |
#ifdef URL_MODULES
foreach(url_modules(id), function funp)
{
string of = id->not_query;
id->not_query = file;
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->url_module(), funp);
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | LOCK(funp);
tmp=funp( id, file );
UNLOCK();
if(mappingp( tmp )) {
id->not_query = of;
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("");
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returned_no_thanks());
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | return 0;
}
if(objectp( tmp ))
{
file = id->not_query;
array err;
nest ++;
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->recursing());
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | err = catch {
if( nest < 20 )
tmp = (id->conf || this_object())->stat_file( file, id );
else
error("Too deep recursion in roxen::stat_file() while mapping "
+file+".\n");
};
nest = 0;
if(err)
throw(err);
|
8fd51f | 1998-03-01 | Per Hedbor | | TRACE_LEAVE("");
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returning_data());
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | return tmp;
}
|
8fd51f | 1998-03-01 | Per Hedbor | | TRACE_LEAVE("");
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | id->not_query = of;
}
#endif
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | |
foreach(location_modules(id), tmp)
{
loc = tmp[0];
if((file == loc) || ((file+"/")==loc))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->location_module(loc), tmp[1]);
TRACE_LEAVE(LOCALE->exact_match());
|
41d0f9 | 1998-02-20 | Per Hedbor | | TRACE_LEAVE("");
|
223fd1 | 2000-01-27 | Johan Sundström | | return ({ 0775, -3, 0, 0, 0, 0, 0 });
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(!search(file, loc))
|
14179b | 1997-01-29 | Per Hedbor | | {
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->location_module(loc), tmp[1]);
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | #ifdef MODULE_LEVEL_SECURITY
|
41d0f9 | 1998-02-20 | Per Hedbor | | if(check_security(tmp[1], id)) {
|
8fd51f | 1998-03-01 | Per Hedbor | | TRACE_LEAVE("");
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->permission_denied());
|
41d0f9 | 1998-02-20 | Per Hedbor | | continue;
}
|
a78a59 | 1997-04-28 | Henrik Grubbström (Grubba) | | #endif
|
14179b | 1997-01-29 | Per Hedbor | | if(s=function_object(tmp[1])->stat_file(file[strlen(loc)..], id))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
TRACE_LEAVE("");
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->stat_ok());
|
14179b | 1997-01-29 | Per Hedbor | | return s;
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
TRACE_LEAVE("");
|
14179b | 1997-01-29 | Per Hedbor | | }
}
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returned_not_found());
|
14179b | 1997-01-29 | Per Hedbor | | }
|
e8790b | 1998-02-19 | Per Hedbor | | class StringFile
{
string data;
int offset;
|
ec9150 | 1999-11-23 | Per Hedbor | | string _sprintf()
{
return "StringFile("+strlen(data)+","+offset+")";
}
|
e8790b | 1998-02-19 | Per Hedbor | | string read(int nbytes)
{
|
6d9398 | 1998-11-30 | Per Hedbor | | if(!nbytes)
{
offset = strlen(data);
return data;
}
|
41d0f9 | 1998-02-20 | Per Hedbor | | string d = data[offset..offset+nbytes-1];
|
e8790b | 1998-02-19 | Per Hedbor | | offset += strlen(d);
return d;
}
void write(mixed ... args)
{
|
3bb38c | 2000-01-20 | Martin Bähr | | throw( ({ "File not open for write\n", backtrace() }) );
|
e8790b | 1998-02-19 | Per Hedbor | | }
void seek(int to)
{
offset = to;
}
void create(string d)
{
data = d;
}
|
41d0f9 | 1998-02-20 | Per Hedbor | |
|
e8790b | 1998-02-19 | Per Hedbor | | }
|
e351dd | 1999-11-29 | Per Hedbor | | public array open_file(string fname, string mode, RequestID id)
|
e8790b | 1998-02-19 | Per Hedbor | | {
object oc = id->conf;
string oq = id->not_query;
function funp;
|
3a4b9a | 1999-12-27 | Martin Nilsson | | mapping|int(0..1) file;
|
cd7ea4 | 1998-12-14 | Peter Bortas | |
id->not_query = fname;
|
c7a5f0 | 1999-02-16 | Per Hedbor | |
|
e8790b | 1998-02-19 | Per Hedbor | | foreach(oc->first_modules(), funp)
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(file = funp( id ))
|
e8790b | 1998-02-19 | Per Hedbor | | break;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | else if(id->conf != oc)
|
e8790b | 1998-02-19 | Per Hedbor | | {
return open_file(fname, mode,id);
}
fname = id->not_query;
if(search(mode, "R")!=-1)
{
string f;
mode -= "R";
if(f = real_file(fname, id))
|
41d0f9 | 1998-02-20 | Per Hedbor | | {
|
9bb813 | 1998-09-12 | Per Hedbor | |
|
e8790b | 1998-02-19 | Per Hedbor | | return ({ open(f, mode), ([]) });
|
41d0f9 | 1998-02-20 | Per Hedbor | | }
|
238083 | 1998-02-22 | Per Hedbor | |
|
e8790b | 1998-02-19 | Per Hedbor | | }
if(mode=="r")
{
if(!file)
{
file = oc->get_file( id );
|
f920ce | 1998-10-02 | Henrik Grubbström (Grubba) | | if(!file) {
|
41d0f9 | 1998-02-20 | Per Hedbor | | foreach(oc->last_modules(), funp) if(file = funp( id ))
|
e8790b | 1998-02-19 | Per Hedbor | | break;
|
f920ce | 1998-10-02 | Henrik Grubbström (Grubba) | | if (file == 1) {
return open_file(id->not_query, mode, id);
}
}
|
e8790b | 1998-02-19 | Per Hedbor | | }
if(!mappingp(file))
{
if(id->misc->error_code)
|
dfe036 | 2000-03-19 | Martin Nilsson | | file = Roxen.http_low_answer(id->misc->error_code, "Failed" );
|
238083 | 1998-02-22 | Per Hedbor | | else if(id->method!="GET"&&id->method != "HEAD"&&id->method!="POST")
|
dfe036 | 2000-03-19 | Martin Nilsson | | file = Roxen.http_low_answer(501, "Not implemented.");
|
576c11 | 2000-03-07 | Martin Stjernholm | | else {
|
dfe036 | 2000-03-19 | Martin Nilsson | | file = Roxen.http_low_answer(404,
|
52e082 | 2000-03-07 | Henrik Grubbström (Grubba) | | parse_rxml(
|
576c11 | 2000-03-07 | Martin Stjernholm | | #ifdef OLD_RXML_COMPAT
|
52e082 | 2000-03-07 | Henrik Grubbström (Grubba) | | replace(query("ZNoSuchFile"),
({ "$File", "$Me" }),
({ "&page.virtfile;",
|
ee8057 | 2000-03-08 | Martin Nilsson | | "&roxen.server;"
|
52e082 | 2000-03-07 | Henrik Grubbström (Grubba) | | })),
|
576c11 | 2000-03-07 | Martin Stjernholm | | #else
|
52e082 | 2000-03-07 | Henrik Grubbström (Grubba) | | query("ZNoSuchFile"),
|
576c11 | 2000-03-07 | Martin Stjernholm | | #endif
|
52e082 | 2000-03-07 | Henrik Grubbström (Grubba) | | id));
|
576c11 | 2000-03-07 | Martin Stjernholm | | }
|
e8790b | 1998-02-19 | Per Hedbor | |
id->not_query = oq;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
e8790b | 1998-02-19 | Per Hedbor | | return ({ 0, file });
}
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if( file->data )
|
e8790b | 1998-02-19 | Per Hedbor | | {
file->file = StringFile(file->data);
m_delete(file, "data");
|
10c7e1 | 1999-12-28 | Martin Nilsson | | }
|
e8790b | 1998-02-19 | Per Hedbor | | id->not_query = oq;
return ({ file->file, file });
}
id->not_query = oq;
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | return ({ 0, (["error":501, "data":"Not implemented"]) });
|
e8790b | 1998-02-19 | Per Hedbor | | }
|
e351dd | 1999-11-29 | Per Hedbor | | public mapping(string:array(mixed)) find_dir_stat(string file, RequestID id)
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | {
string loc;
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | mapping(string:array(mixed)) dir = ([]);
mixed d, tmp;
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | |
|
c7a5f0 | 1999-02-16 | Per Hedbor | |
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | file=replace(file, "//", "/");
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | if(file[0] != '/')
file = "/" + file;
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | |
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->find_dir_stat(file), 0);
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | |
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | #ifdef URL_MODULES
#ifdef THREADS
object key;
#endif
foreach(url_modules(id), function funp)
{
string of = id->not_query;
id->not_query = file;
LOCK(funp);
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->url_module(), funp);
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | tmp=funp( id, file );
UNLOCK();
if(mappingp( tmp ))
{
id->not_query=of;
|
3510fb | 1997-11-09 | Henrik Grubbström (Grubba) | | #ifdef MODULE_DEBUG
|
10c7e1 | 1999-12-28 | Martin Nilsson | | werror("conf->find_dir_stat(\"%s\"): url_module returned mapping:%O\n",
file, tmp);
|
3510fb | 1997-11-09 | Henrik Grubbström (Grubba) | | #endif /* MODULE_DEBUG */
|
07014c | 1999-05-24 | Per Hedbor | | TRACE_LEAVE(LOCALE->returned_mapping()+sprintf("%O", tmp));
TRACE_LEAVE("");
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | return 0;
}
if(objectp( tmp ))
{
array err;
nest ++;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | file = id->not_query;
err = catch {
if( nest < 20 )
tmp = (id->conf || this_object())->find_dir_stat( file, id );
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | | else {
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->too_deep_recursion());
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | error("Too deep recursion in roxen::find_dir_stat() while mapping "
+file+".\n");
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | | }
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | };
nest = 0;
if(err)
throw(err);
|
3510fb | 1997-11-09 | Henrik Grubbström (Grubba) | | #ifdef MODULE_DEBUG
|
10c7e1 | 1999-12-28 | Martin Nilsson | | werror("conf->find_dir_stat(\"%s\"): url_module returned object:\n",
file);
|
3510fb | 1997-11-09 | Henrik Grubbström (Grubba) | | #endif /* MODULE_DEBUG */
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_LEAVE(LOCALE->returned_object());
TRACE_LEAVE(LOCALE->returning_it());
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | | return tmp;
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | }
id->not_query=of;
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | | TRACE_LEAVE("");
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | }
#endif /* URL_MODULES */
foreach(location_modules(id), tmp)
{
loc = tmp[0];
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | |
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->location_module(loc), 0);
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | |
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | if(!search(file, loc))
{
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | |
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | #ifdef MODULE_LEVEL_SECURITY
if(check_security(tmp[1], id)) continue;
#endif
|
e351dd | 1999-11-29 | Per Hedbor | | RoxenModule c = function_object(tmp[1]);
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | string f = file[strlen(loc)..];
if (c->find_dir_stat) {
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->has_find_dir_stat(), 0);
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | if (d = c->find_dir_stat(f, id)) {
|
07014c | 1999-05-24 | Per Hedbor | | TRACE_ENTER(LOCALE->returned_mapping()+sprintf("%O", d),c);
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | dir = d | dir;
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | | TRACE_LEAVE("");
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | }
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | | TRACE_LEAVE("");
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | } else if(d = c->find_dir(f, id)) {
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->returned_array(), 0);
|
10c7e1 | 1999-12-28 | Martin Nilsson | | dir = mkmapping(d, Array.map(d, lambda(string fn)
|
e351dd | 1999-11-29 | Per Hedbor | | {
return c->stat_file(f + fn, id);
})) | dir;
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | | TRACE_LEAVE("");
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | }
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | } else if(search(loc, file)==0 && loc[strlen(file)-1]=='/' &&
(loc[0]==loc[-1]) && loc[-1]=='/' &&
|
8935ad | 1998-03-30 | Johan Schön | | (function_object(tmp[1])->stat_file(".", id))) {
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | |
8935ad | 1998-03-30 | Johan Schön | | * and stat_file(".") returns non-zero.
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | */
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | TRACE_ENTER(LOCALE->file_on_mountpoint_path(file, loc), 0);
|
a47671 | 1997-10-20 | Henrik Grubbström (Grubba) | | loc=loc[strlen(file)..];
sscanf(loc, "%s/", loc);
if (!dir[loc]) {
dir[loc] = ({ 0775, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | }
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | | TRACE_LEAVE("");
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | }
|
ae60b6 | 1998-05-23 | Henrik Grubbström (Grubba) | | TRACE_LEAVE("");
|
a86c6c | 1997-09-22 | Henrik Grubbström (Grubba) | | }
if(sizeof(dir))
return dir;
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
e351dd | 1999-11-29 | Per Hedbor | | public array access(string file, RequestID id)
|
14179b | 1997-01-29 | Per Hedbor | | {
string loc;
array s, tmp;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | file=replace(file, "//", "/");
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | |
foreach(location_modules(id), tmp)
{
loc = tmp[0];
|
477042 | 1999-11-22 | Henrik Grubbström (Grubba) | | if((file+"/")==loc) {
#ifdef MODULE_LEVEL_SECURITY
if(check_security(tmp[1], id)) continue;
#endif
if(s=function_object(tmp[1])->access("", id))
return s;
} else if(!search(file, loc)) {
|
14179b | 1997-01-29 | Per Hedbor | | #ifdef MODULE_LEVEL_SECURITY
if(check_security(tmp[1], id)) continue;
#endif
if(s=function_object(tmp[1])->access(file[strlen(loc)..], id))
return s;
}
}
|
477042 | 1999-11-22 | Henrik Grubbström (Grubba) | | return 0;
|
14179b | 1997-01-29 | Per Hedbor | | }
|
e351dd | 1999-11-29 | Per Hedbor | | public string real_file(string file, RequestID id)
|
14179b | 1997-01-29 | Per Hedbor | | {
string loc;
string s;
array tmp;
file=replace(file, "//", "/");
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | if(!id) error("No id passed to real_file");
foreach(location_modules(id), tmp)
{
loc = tmp[0];
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(!search(file, loc))
|
14179b | 1997-01-29 | Per Hedbor | | {
#ifdef MODULE_LEVEL_SECURITY
if(check_security(tmp[1], id)) continue;
#endif
|
c5e096 | 1999-10-04 | Per Hedbor | | if(s=function_object(tmp[1])->real_file(file[strlen(loc)..], id))
|
14179b | 1997-01-29 | Per Hedbor | | return s;
}
}
}
|
646f72 | 2000-03-07 | Martin Stjernholm | |
|
10c7e1 | 1999-12-28 | Martin Nilsson | | int|string try_get_file(string s, RequestID id,
|
646f72 | 2000-03-07 | Martin Stjernholm | | int|void status, int|void nocache,
int|void not_internal)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
646f72 | 2000-03-07 | Martin Stjernholm | | string res, q, cache_key;
|
e351dd | 1999-11-29 | Per Hedbor | | RequestID fake_id;
|
14179b | 1997-01-29 | Per Hedbor | | mapping m;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(!objectp(id))
|
14179b | 1997-01-29 | Per Hedbor | | error("No ID passed to 'try_get_file'\n");
|
e351dd | 1999-11-29 | Per Hedbor | |
if ( !id->misc )
id->misc = ([]);
if ( !id->misc->common )
id->misc->common = ([]);
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
e351dd | 1999-11-29 | Per Hedbor | | fake_id = id->clone_me();
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
e351dd | 1999-11-29 | Per Hedbor | | fake_id->misc->common = id->misc->common;
|
646da2 | 2000-03-20 | Martin Stjernholm | | s = Roxen.fix_relative (s, id);
|
646f72 | 2000-03-07 | Martin Stjernholm | | if(!id->pragma["no-cache"] && !nocache && (!id->auth || !id->auth[0])) {
cache_key =
s + "\0" +
id->request_headers->cookie + "\0" +
id->request_headers["user-agent"];
|
db02e5 | 2000-03-20 | Martin Nilsson | | if(res = cache_lookup("file:"+name, cache_key))
|
14179b | 1997-01-29 | Per Hedbor | | return res;
|
646f72 | 2000-03-07 | Martin Stjernholm | | }
|
14179b | 1997-01-29 | Per Hedbor | |
|
4e0a53 | 2000-03-20 | Martin Stjernholm | | if (fake_id->scan_for_query)
s = fake_id->scan_for_query (s);
|
14179b | 1997-01-29 | Per Hedbor | | fake_id->raw_url=s;
fake_id->not_query=s;
|
c927a0 | 2000-03-18 | Martin Stjernholm | | if(!(m = get_file(fake_id,0,!not_internal))) {
|
4cd5e8 | 2000-03-20 | Martin Stjernholm | |
m_delete (fake_id->misc, "path_info");
|
e1e86d | 2000-03-20 | Martin Stjernholm | | array a = open_file( s, "r", fake_id );
if(a && a[0]) {
m = a[1];
m->file = a[0];
}
else {
destruct (fake_id);
return 0;
}
|
c927a0 | 2000-03-18 | Martin Stjernholm | | }
destruct (fake_id);
|
889d03 | 1999-10-04 | Per Hedbor | |
|
3bb38c | 2000-01-20 | Martin Bähr | | if (!mappingp(m) && !objectp(m)) {
report_error("try_get_file(%O, %O, %O, %O): m = %O is not a mapping.\n",
s, id, status, nocache, m);
return 0;
}
|
3510fb | 1997-11-09 | Henrik Grubbström (Grubba) | | if (!(< 0, 200, 201, 202, 203 >)[m->error]) return 0;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
3510fb | 1997-11-09 | Henrik Grubbström (Grubba) | | if(status) return 1;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(m->data)
|
a22f6f | 1999-05-12 | Per Hedbor | | res = m->data;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | else
|
a22f6f | 1999-05-12 | Per Hedbor | | res="";
|
14179b | 1997-01-29 | Per Hedbor | | m->data = 0;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | if(m->file)
{
|
3a4d7e | 1997-09-03 | Per Hedbor | | res += m->file->read();
|
14179b | 1997-01-29 | Per Hedbor | | destruct(m->file);
m->file = 0;
}
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | if(m->raw)
{
res -= "\r";
if(!sscanf(res, "%*s\n\n%s", res))
sscanf(res, "%*s\n%s", res);
}
|
646f72 | 2000-03-07 | Martin Stjernholm | | if (cache_key)
|
db02e5 | 2000-03-20 | Martin Nilsson | | cache_set("file:"+name, cache_key, res);
|
14179b | 1997-01-29 | Per Hedbor | | return res;
}
|
e351dd | 1999-11-29 | Per Hedbor | | int(0..1) is_file(string what, RequestID id)
|
14179b | 1997-01-29 | Per Hedbor | | {
return !!stat_file(what, id);
}
|
c5e096 | 1999-10-04 | Per Hedbor | | array registered_urls = ({});
|
14179b | 1997-01-29 | Per Hedbor | | void start(int num)
{
|
c5e096 | 1999-10-04 | Per Hedbor | |
foreach( query( "URLs" )-registered_urls, string url )
{
registered_urls += ({ url });
roxenp()->register_url( url, this_object() );
|
14179b | 1997-01-29 | Per Hedbor | | }
|
c5e096 | 1999-10-04 | Per Hedbor | | foreach( registered_urls-query("URLs"), string url )
{
registered_urls -= ({ url });
roxenp()->unregister_url( url );
|
14179b | 1997-01-29 | Per Hedbor | | }
}
|
e7e603 | 1999-11-05 | Per Hedbor | | void save_me()
{
save_one( 0 );
}
|
c45e3f | 2000-02-16 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | void save(int|void all)
{
if(all)
{
|
3f628a | 1999-12-09 | Martin Stjernholm | | store("spider#0", variables, 0, this_object());
|
14179b | 1997-01-29 | Per Hedbor | | start(2);
}
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
3f628a | 1999-12-09 | Martin Stjernholm | | foreach(indices(modules), string modname)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
3f628a | 1999-12-09 | Martin Stjernholm | | foreach(indices(modules[modname]->copies), int i)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
3f628a | 1999-12-09 | Martin Stjernholm | | store(modname+"#"+i, modules[modname]->copies[i]->query(), 0, this_object());
modules[modname]->copies[i]->start(2, this_object());
|
14179b | 1997-01-29 | Per Hedbor | | }
}
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | invalidate_cache();
|
14179b | 1997-01-29 | Per Hedbor | | }
|
e351dd | 1999-11-29 | Per Hedbor | | int save_one( RoxenModule o )
|
14179b | 1997-01-29 | Per Hedbor | | {
mapping mod;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(!o)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
c5e096 | 1999-10-04 | Per Hedbor | | store("spider#0", variables, 0, this_object());
|
14179b | 1997-01-29 | Per Hedbor | | start(2);
return 1;
}
|
2c13a8 | 1999-11-10 | Per Hedbor | | string q = otomod[ o ];
if( !q )
error("Invalid module");
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
2c13a8 | 1999-11-10 | Per Hedbor | | store(q, o->query(), 0, this_object());
invalidate_cache();
o->start(2, this_object());
invalidate_cache();
return 1;
|
14179b | 1997-01-29 | Per Hedbor | | }
|
2f7920 | 2000-03-27 | Per Hedbor | | RoxenModule reload_module( string modname )
|
596425 | 1999-11-19 | Per Hedbor | | {
|
e351dd | 1999-11-29 | Per Hedbor | | RoxenModule old_module = find_module( modname );
|
2f7920 | 2000-03-27 | Per Hedbor | | ModuleInfo mi = roxen->find_module( (modname/"#")[0] );
if( !old_module ) return 0;
|
f56958 | 1999-11-23 | Per Hedbor | |
|
2f7920 | 2000-03-27 | Per Hedbor | | save_one( old_module );
|
1f5652 | 1999-11-23 | Per Hedbor | |
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | master()->refresh_inherit( object_program( old_module ) );
|
2f7920 | 2000-03-27 | Per Hedbor | | master()->refresh( object_program( old_module ), 1 );
catch( disable_module( modname, 1 ) );
|
f56958 | 1999-11-23 | Per Hedbor | |
|
2f7920 | 2000-03-27 | Per Hedbor | | RoxenModule nm;
if( catch( nm = enable_module( modname ) ) || (nm == 0) )
enable_module( modname, (nm=old_module), mi );
|
f56958 | 1999-11-23 | Per Hedbor | |
|
2f7920 | 2000-03-27 | Per Hedbor | | return nm;
|
596425 | 1999-11-19 | Per Hedbor | | }
|
7e446c | 1999-11-24 | Per Hedbor | | class ModuleCopies
{
mapping copies = ([]);
|
0b7d2b | 1999-12-22 | Per Hedbor | | mixed `[](mixed q )
{
return copies[q];
}
mixed `[]=(mixed q,mixed w )
{
return copies[q]=w;
}
mixed _indices()
{
return(indices(copies));
}
mixed _values()
{
return(values(copies));
}
|
7e446c | 1999-11-24 | Per Hedbor | | string _sprintf( ) { return "ModuleCopies()"; }
}
|
beba57 | 2000-03-20 | Martin Stjernholm | | #ifdef THREADS
Thread.Mutex enable_modules_mutex = Thread.Mutex();
#define MODULE_LOCK \
Thread.MutexKey enable_modules_lock = enable_modules_mutex->lock (2)
#else
#define MODULE_LOCK
#endif
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | static int enable_module_batch_msgs;
|
2f7920 | 2000-03-27 | Per Hedbor | | RoxenModule enable_module( string modname, RoxenModule|void me,
ModuleInfo|void moduleinfo )
|
14179b | 1997-01-29 | Per Hedbor | | {
|
beba57 | 2000-03-20 | Martin Stjernholm | | MODULE_LOCK;
|
c5e096 | 1999-10-04 | Per Hedbor | | int id;
|
e351dd | 1999-11-29 | Per Hedbor | | ModuleCopies module;
|
c5e096 | 1999-10-04 | Per Hedbor | | int pr;
mixed err;
int module_type;
|
e7e603 | 1999-11-05 | Per Hedbor | | if( sscanf(modname, "%s#%d", modname, id ) != 2 )
|
2f7920 | 2000-03-27 | Per Hedbor | | while( modules[ modname ] && modules[ modname ][ id ] )
|
4f43eb | 1999-11-05 | Per Hedbor | | id++;
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
7f0008 | 1998-03-20 | Per Hedbor | | int start_time = gethrtime();
|
2f7920 | 2000-03-27 | Per Hedbor | | mixed err;
|
25171c | 1999-11-06 | Per Hedbor | |
|
2f7920 | 2000-03-27 | Per Hedbor | | if( !moduleinfo )
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | {
|
2f7920 | 2000-03-27 | Per Hedbor | | moduleinfo = roxen->find_module( modname );
if (!moduleinfo)
{
report_warning("Failed to load %s. The module probably "
"doesn't exist in the module path.\n", modname);
return 0;
}
|
c5e096 | 1999-10-04 | Per Hedbor | | }
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | string descr = moduleinfo->get_name() + (id ? " copy " + (id + 1) : "");
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | #ifdef MODULE_DEBUG
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | if (enable_module_batch_msgs)
report_debug(" %-43s... \b", descr );
|
c5e096 | 1999-10-04 | Per Hedbor | | else
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | report_debug("Enabling " + descr + "\n");
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | #endif
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
0b7d2b | 1999-12-22 | Per Hedbor | | module = modules[ modname ];
|
c5e096 | 1999-10-04 | Per Hedbor | |
if(!module)
|
7e446c | 1999-11-24 | Per Hedbor | | modules[ modname ] = module = ModuleCopies();
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
f56958 | 1999-11-23 | Per Hedbor | | if( !me )
|
c5e096 | 1999-10-04 | Per Hedbor | | {
|
f56958 | 1999-11-23 | Per Hedbor | | if(err = catch(me = moduleinfo->instance(this_object())))
{
|
c45b2a | 1999-12-09 | Martin Stjernholm | | #ifdef MODULE_DEBUG
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | if (enable_module_batch_msgs) report_debug("\bERROR\n");
|
086406 | 1999-12-28 | Martin Stjernholm | | if (err != "")
|
c45b2a | 1999-12-09 | Martin Stjernholm | | #endif
|
086406 | 1999-12-28 | Martin Stjernholm | | report_error(LOCALE->
error_initializing_module_copy(moduleinfo->get_name(),
err != "" &&
describe_backtrace(err)));
|
0b7d2b | 1999-12-22 | Per Hedbor | | return module[id];
|
f56958 | 1999-11-23 | Per Hedbor | | }
|
c5e096 | 1999-10-04 | Per Hedbor | | }
|
0b7d2b | 1999-12-22 | Per Hedbor | | if(module[id] && module[id] != me)
|
c5e096 | 1999-10-04 | Per Hedbor | | {
|
c45e3f | 2000-02-16 | Per Hedbor | | if( module[id]->stop )
module[id]->stop();
|
f56958 | 1999-11-23 | Per Hedbor | |
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | }
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | me->set_configuration( this_object() );
module_type = moduleinfo->type;
if (module_type & (MODULE_LOCATION|MODULE_EXTENSION|
MODULE_CONFIG|MODULE_FILE_EXTENSION|MODULE_LOGGER|
MODULE_URL|MODULE_LAST|MODULE_PROVIDER|
MODULE_FILTER|MODULE_PARSER|MODULE_FIRST))
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | {
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type != MODULE_CONFIG)
|
3b1783 | 1998-11-22 | Per Hedbor | | {
|
477042 | 1999-11-22 | Henrik Grubbström (Grubba) | | if (err = catch {
me->defvar("_priority", 5, "Priority", TYPE_INT_LIST,
"The priority of the module. 9 is highest and 0 is lowest."
" Modules with the same priority can be assumed to be "
|
10c7e1 | 1999-12-28 | Martin Nilsson | | "called in random order",
|
477042 | 1999-11-22 | Henrik Grubbström (Grubba) | | ({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}));
|
e6f83d | 2000-03-06 | Peter Bortas | | me->deflocaledoc("deutsch", "_priority", "Priorität",
"Modul Priorität. 9 höchste, 0 niedrigste."
" Module mit gleicher Priorität werden in "
"zufälliger Reihenfolge aufgerufen.");
|
477042 | 1999-11-22 | Henrik Grubbström (Grubba) | | me->deflocaledoc("svenska", "_priority", "Prioritet",
"Modulens prioritet, 9 är högst och 0 är"
" lägst. Moduler med samma prioritet anropas i "
"mer eller mindre slumpmässig ordning.");
}) {
throw(err);
}
|
3b1783 | 1998-11-22 | Per Hedbor | | }
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type != MODULE_LOGGER && module_type != MODULE_PROVIDER)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | {
|
c5e096 | 1999-10-04 | Per Hedbor | | if(!(module_type & MODULE_PROXY))
|
14179b | 1997-01-29 | Per Hedbor | | {
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | me->defvar("_sec_group", "user", "Security: Realm", TYPE_STRING,
"The realm to use when requesting password from the "
"client. Usually used as an informative message to the "
"user.");
|
df6cd1 | 1998-10-13 | Per Hedbor | |
|
e6f83d | 2000-03-06 | Peter Bortas | | me->deflocaledoc("deutsch", "_sec_group", "Sicherheit: Bereich",
"Bereichsname, der benutzt werden soll, "
"wenn vom Webbrowser ein Passwort angefordert "
"werden soll. Wird üblicherweise als informativer "
"Hinweis für den Benutzer verwendet.");
|
df6cd1 | 1998-10-13 | Per Hedbor | | me->deflocaledoc("svenska", "_sec_group", "Säkerhet: Grupp",
"Gruppnamnet som används när klienten bes"
" ange lösenord. I de flesta klienter visas den "
" här informationen för användaren i"
|
3b1783 | 1998-11-22 | Per Hedbor | | " lösenordsdialogen.");
|
df6cd1 | 1998-10-13 | Per Hedbor | |
|
10c7e1 | 1999-12-28 | Martin Nilsson | | me->defvar("_seclvl", 0, "Security: Security level", TYPE_INT,
|
3bf345 | 1998-10-01 | Peter Bortas | | "The modules security level is used to determine if a "
" request should be handled by the module."
"\n<p><h2>Security level vs Trust level</h2>"
" Each module has a configurable <i>security level</i>."
" Each request has an assigned trust level. Higher"
" <i>trust levels</i> grants access to modules with higher"
" <i>security levels</i>."
"\n<p><h2>Definitions</h2><ul>"
" <li>A requests initial Trust level is infinitely high."
" <li> A request will only be handled by a module if its"
" <i>trust level</i> is higher or equal to the"
" <i>security level</i> of the module."
" <li> Each time the request is handled by a module the"
" <i>trust level</i> of the module will be set to the"
" lower of its <i>trust level</i> and the modules"
" <i>security level</i>."
" </ul>"
"\n<p><h2>Example</h2>"
" Modules:<ul>"
" <li> User filesystem, <i>security level</i> 1"
" <li> Filesystem module, <i>security level</i> 3"
" <li> CGI module, <i>security level</i> 2"
" </ul>"
"\n<p>A request handled by \"User filesystem\" is assigned"
" a <i>trust level</i> of one after the <i>security"
" level</i> of that module. That request can then not be"
" handled by the \"CGI module\" since that module has a"
" higher <i>security level</i> than the requests trust"
" level."
"\n<p>On the other hand, a request handled by the the"
" \"Filsystem module\" could later be handled by the"
" \"CGI module\".");
|
e6f83d | 2000-03-06 | Peter Bortas | |
me->deflocaledoc("deutsch", "_seclvl", "Sicherheit: Sicherheitsebene",
"Die Sicherheitsebene des Moduls wird verwendet, "
"wenn ein Request vom Modul behandelt werden soll."
"\n<p><h2>Sicherheitsebene vs Vertrauensebene</h2> "
"Jedes Modul hat eine konfigurierbare "
"<i>Sicherheitsebene</i>."
"Jeder Request hat eine zugewiesene Vertrauensebene. "
"Höhere <i>Vertrauensebeben</i> erlauben Zugriff zu "
"Modulen mir höherer <i>Sicherheitsebene</i>."
"\n<p><h2>Definitionen</h2><ul>"
" <li>Die ursprüngliche Vertrauensebene eines Requests "
" ist unendlich hoch."
" <li> Ein Request wird nur von einem Modul behandelt, wenn"
" seine <i>Vertrauensebene</i> mindestens so hoch ist,"
" wie die <i>Sicherheitsebene</i> des Moduls."
" <li> Jedes Mal wenn ein Request von einem Modul "
" behandelt wird, wird die <i>Vertrauensebene</i>"
" des Requests auf den jeweils niedrigeren Wert"
" von der <i>Vertrauensebene</i> des Requests und der"
" <i>Sicherheitsebene</i> des Moduls, gesetzt."
" </ul>"
"\n<p><h2>Beispiel</h2>"
" Module:<ul>"
" <li> User filesystem, <i>Sicherheitsebene</i> 1"
" <li> Filesystem module, <i>Sicherheitsebene</i> 3"
" <li> CGI module, <i>Sicherheitsebene</i> 2"
" </ul>"
"\n<p>Ein Request der vom \"User filesystem\" behandelt "
"wird bekommt eine <i>Vertrauensebene</i> die der "
"<i>Sicherheitsebene</i> des Moduls entspricht. "
"Der Request kann dann nicht mehr vom \"CGI module\" "
"behandelt werden, da dieses eine höhere "
"<i>Sicherheitsebene</i> hat als die Vertrauensebene "
"des Requests."
"\n<p>Ein Request der vom \"Filsystem module\" behandelt "
"wurde kann andererseits später vom \"CGI module\" "
"behandelt werden.");
|
df6cd1 | 1998-10-13 | Per Hedbor | | me->deflocaledoc("svenska", "_seclvl", "Säkerhet: Säkerhetsnivå",
"Modulens säkerhetsnivå används för att avgöra om "
" en specifik request ska få hanteras av modulen. "
"\n<p><h2>Säkerhetsnivå och pålitlighetsnivå</h2>"
" Varje modul har en konfigurerbar "
"<i>säkerhtesnivå</i>. "
"Varje request har en <i>pålitlighetsnivå</i>.<p>"
"Högre <i>pålitlighetsnivåer</i> ger "
" requesten tillgång till moduler med högre "
"<i>säkerhetsnivå</i>. <p>\n"
"\n<p><h2>Defenitioner</h2><ul>"
" <li>En requests initialpålitlighetsnivå är "
" oändligt hög."
" <li> En request hanteras bara av moduler om "
"dess <i>pålitlighetsnivå</i> är högre eller "
" lika hög som modulens <i>säkerhetsnivå</i>"
" <li> Varje gång en request hanteras av en"
" modul så sätts dess <i>pålitlighetsnivå</i> "
"till modulens <i>säkerhetsnivå</i> om "
" modulen har en <i>säkerhetsnivå</i> som är "
"skiljd from noll. "
" </ul>"
"\n<p><h2>Ett exempel</h2>"
" Moduler:<ul>"
" <li> Användarfilsystem, <i>säkerhetsnivå</i> 1"
" <li> Filesystem, <i>säkerhetsnivå</i> 3"
" <li> CGI modul, <i>säkerhetsnivå</i> 2"
" </ul>"
"\n<p>En request hanterad av "
" <i>Användarfilsystemet</i> får ett "
"som <i>pålitlighetsnivå</i>. Den här"
" requesten kan därför inte skickas vidare "
"till <i>CGI modulen</i> eftersom den har"
" en <i>säkerhetsnivå</i> som är högre än"
" requestens <i>pålitlighetsnivå</i>.<p>"
" Å andra sidan så kan en request som "
" hanteras av <i>Filsystem</i> modulen "
" skickas vidare till <i>CGI modulen</i>.");
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | me->defvar("_seclevels", "", "Security: Patterns", TYPE_TEXT_FIELD,
"This is the 'security level=value' list.<br>"
"Each security level can be any or more from this list:"
"<hr noshade>"
"allow ip=<i>IP</i>/<i>bits</i><br>"
"allow ip=<i>IP</i>:<i>mask</i><br>"
"allow ip=<i>pattern</i><br>"
"allow user=<i>username</i>,...<br>"
"deny ip=<i>IP</i>/<i>bits</i><br>"
"deny ip=<i>IP</i>:<i>mask</i><br>"
"deny ip=<i>pattern</i><br>"
"<hr noshade>"
"In patterns: * matches one or more characters, "
"and ? matches one character.<p>"
"In username: 'any' stands for any valid account "
"(from .htaccess"
|
002628 | 1999-06-07 | Martin Stjernholm | | " or an auth module. The default (used when _no_ "
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | "entries are present) is 'allow ip=*', allowing"
" everyone to access the module");
|
df6cd1 | 1998-10-13 | Per Hedbor | |
|
e6f83d | 2000-03-06 | Peter Bortas | | me->deflocaledoc("deutsch", "_seclevels",
"Sicherheit: Muster",
"Dies ist die Liste der Sicherheitsmuster.<p>"
"Jede Sicherheitsebene kann aus einem oder mehr "
"der folgenden Einträgen bestehen: "
"<hr noshade>"
"allow ip=<i>IP-Adresse</i>/<i>Bits</i><br>"
"allow ip=<i>IP-Adresse</i>:<i>Netzmaske</i><br>"
"allow ip=<i>Muster</i><br>"
"allow user=<i>Benutzername</i>,...<br>"
"deny ip=<i>IP-Adresse</i>/<i>Bits</i><br>"
"deny ip=<i>IP-nummer</i>:<i>Netzmaske</i><br>"
"deny ip=<i>Muster</i><br>"
"<hr noshade>"
"Bei den Mustern trifft '*' auf ein oder "
"mehrere Zeichen zu, '?' auf genau ein "
"Zeichen.<p> "
"Bei den Benutzernamen steht 'any' für jeden "
"gültigen Benutzernamen "
"(aus einer .htaccess-Datei oder jedem anderen "
"Auth-Modul) Der Standard-Wert (wenn keine Eingaben "
"gemacht wurden), ist 'allow ip=*', d.h. jeder "
"darf auf das Modul zugreifen.");
|
10c7e1 | 1999-12-28 | Martin Nilsson | | me->deflocaledoc("svenska", "_seclevels",
|
df6cd1 | 1998-10-13 | Per Hedbor | | "Säkerhet: Behörighetsregler",
"Det här är en lista av behörighetsregler.<p>"
"Varje behörighetsregler måste följa någon av de "
" här mönstren: "
"<hr noshade>"
"allow ip=<i>IP-nummer</i>/<i>antal nätmaskbittar</i><br>"
"allow ip=<i>IP-nummer</i>:<i>nätmask</i><br>"
"allow ip=<i>globmönster</i><br>"
"allow user=<i>användarnamn</i>,...<br>"
"deny ip=<i>IP-nummer</i>/<i>antal nätmaskbittar</i><br>"
"deny ip=<i>IP-nummer</i>:<i>nätmask</i><br>"
"deny ip=<i>globmönster</i><br>"
"<hr noshade>"
"I globmänster betyer '*' ett eller flera "
"godtyckliga tecken, och '?' betyder exekt "
"ett godtyckligt tecken.<p> "
"Användnamnet 'any' kan användas för att ange "
"att vilken giltig användare som helst ska "
" kunna få använda modulen.");
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | } else {
me->definvisvar("_seclvl", -10, TYPE_INT);
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | me->defvar("_sec_group", "user", "Proxy Security: Realm", TYPE_STRING,
"The realm to use when requesting password from the "
"client. Usually used as an informative message to the "
"user.");
|
e6f83d | 2000-03-06 | Peter Bortas | |
me->deflocaledoc("deutsch", "_sec_group", "Sicherheit: Bereich",
"Bereichsname, der benutzt werden soll, "
"wenn vom Webbrowser ein Passwort angefordert "
"werden soll. Wird üblicherweise als informativer "
"Hinweis für den Benutzer verwendet.");
|
df6cd1 | 1998-10-13 | Per Hedbor | | me->deflocaledoc("svenska", "_sec_group", "Säkerhet: Grupp",
"Gruppnamnet som används när klienten bes"
" ange lösenord. I de flesta klienter visas den "
" här informationen för användaren i"
"lösenordsdialogen.");
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | me->defvar("_seclevels", "", "Proxy security: Patterns",
TYPE_TEXT_FIELD,
"This is the 'security level=value' list.<br>"
"Each security level can be any or more from "
"this list:<br>"
"<hr noshade>"
"allow ip=pattern<br>"
"allow user=username,...<br>"
"deny ip=pattern<br>"
"<hr noshade>"
"In patterns: * is on or more characters, ? is one "
" character.<p>"
"In username: 'any' stands for any valid account"
" (from .htaccess"
|
002628 | 1999-06-07 | Martin Stjernholm | | " or an auth module. The default is 'deny ip=*'");
|
df6cd1 | 1998-10-13 | Per Hedbor | |
|
e6f83d | 2000-03-06 | Peter Bortas | |
me->deflocaledoc("deutsch", "_seclevels",
"Sicherheit: Muster",
"Dies ist die Liste der Sicherheitsmuster.<p>"
"Jede Sicherheitsebene kann aus einem oder mehr "
"der folgenden Einträgen bestehen: "
"<hr noshade>"
"allow ip=<i>IP-Adresse</i>/<i>Bits</i><br>"
"allow ip=<i>IP-Adresse</i>:<i>Netzmaske</i><br>"
"allow ip=<i>Muster</i><br>"
"allow user=<i>Benutzername</i>,...<br>"
"deny ip=<i>IP-Adresse</i>/<i>Bits</i><br>"
"deny ip=<i>IP-nummer</i>:<i>Netzmaske</i><br>"
"deny ip=<i>Muster</i><br>"
"<hr noshade>"
"Bei den Mustern trifft '*' auf ein oder "
"mehrere Zeichen zu, '?' auf genau ein "
"Zeichen.<p> "
"Bei den Benutzernamen steht 'any' für jeden "
"gültigen Benutzernamen "
"(aus einer .htaccess-Datei oder jedem anderen "
"Auth-Modul) Der Standard-Wert (wenn keine Eingaben "
"gemacht wurden), ist 'allow ip=*', d.h. jeder "
"darf auf das Modul zugreifen.");
|
10c7e1 | 1999-12-28 | Martin Nilsson | | me->deflocaledoc("svenska", "_seclevels",
|
df6cd1 | 1998-10-13 | Per Hedbor | | "Säkerhet: Behörighetsregler",
"Det här är en lista av behörighetsregler.<p>"
"Varje behörighetsregler måste följa någon av de "
" här mönstren: "
"<hr noshade>"
"allow ip=<i>IP-nummer</i>/<i>antal nätmaskbittar</i><br>"
"allow ip=<i>IP-nummer</i>:<i>nätmask</i><br>"
"allow ip=<i>globmönster</i><br>"
"allow user=<i>användarnamn</i>,...<br>"
"deny ip=<i>IP-nummer</i>/<i>antal nätmaskbittar</i><br>"
"deny ip=<i>IP-nummer</i>:<i>nätmask</i><br>"
"deny ip=<i>globmönster</i><br>"
"<hr noshade>"
"I globmänster betyer '*' ett eller flera "
"godtyckliga tecken, och '?' betyder exekt "
"ett godtyckligt tecken.<p> "
"Användnamnet 'any' kan användas för att ange "
"att vilken giltig användare som helst ska "
" kunna få använda modulen.");
|
14179b | 1997-01-29 | Per Hedbor | | }
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | }
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | } else {
me->defvar("_priority", 0, "", TYPE_INT, "", 0, 1);
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | me->defvar("_comment", "", " Comment", TYPE_TEXT_FIELD|VAR_MORE,
"An optional comment. This has no effect on the module, it "
"is only a text field for comments that the administrator "
"might have (why the module are here, etc.)");
|
14179b | 1997-01-29 | Per Hedbor | |
|
e6f83d | 2000-03-06 | Peter Bortas | | me->deflocaledoc("deutsch", "_comment",
"Kommentar",
"Ein Kommentar, der keinen technischen Einfluss "
"auf das Modul hat, sondern lediglich ein Textfeld "
"für Kommentare seitens des Administrators ist.");
|
10c7e1 | 1999-12-28 | Martin Nilsson | | me->deflocaledoc("svenska", "_comment",
|
df6cd1 | 1998-10-13 | Per Hedbor | | "Kommentar",
"En kommentar. Den här kommentaren påverkar inte "
" funktionaliteten hos modulen på något sätt, den "
" syns bara i konfigurationsinterfacet.");
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | me->defvar("_name", "", " Module name", TYPE_STRING|VAR_MORE,
|
a0fbcc | 2000-04-05 | Martin Stjernholm | | "An optional name. You can set it to something to remind you what "
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | "the module really does.");
|
14179b | 1997-01-29 | Per Hedbor | |
|
e6f83d | 2000-03-06 | Peter Bortas | | me->deflocaledoc("deutsch", "_name", "Modul-Name",
"Modul-Name. Hier kann ein beliebiger Wert eingetragen "
"werden, um die Funktionsweise des Moduls zu beschreiben.");
|
df6cd1 | 1998-10-13 | Per Hedbor | | me->deflocaledoc("svenska", "_name", "Namn",
"Modulens namn. Om den här variablen är satt så "
"används dess värde istället för modulens riktiga namn "
"i konfigurationsinterfacet.");
|
a0fbcc | 2000-04-05 | Martin Stjernholm | | mapping(string:mixed) stored_vars = retrieve(modname + "#" + id, this_object());
int has_stored_vars = sizeof (stored_vars);
me->setvars(stored_vars);
|
33e635 | 1998-02-28 | Martin Stjernholm | |
|
0b7d2b | 1999-12-22 | Per Hedbor | | module[ id ] = me;
|
37c1b3 | 1999-10-12 | Per Hedbor | | otomod[ me ] = modname+"#"+id;
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | mixed err;
|
c5e096 | 1999-10-04 | Per Hedbor | | if((me->start) && (err = catch( me->start(0, this_object()) ) ) )
{
#ifdef MODULE_DEBUG
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | if (enable_module_batch_msgs) report_debug("\bERROR\n");
|
c5e096 | 1999-10-04 | Per Hedbor | | #endif
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | report_error(LOCALE->
|
c5e096 | 1999-10-04 | Per Hedbor | | error_initializing_module_copy(moduleinfo->get_name(),
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | describe_backtrace(err)));
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | |
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | |
m_delete(otomod, me);
|
0b7d2b | 1999-12-22 | Per Hedbor | | m_delete(module->copies, id);
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | destruct(me);
return 0;
}
|
5ffa54 | 2000-02-16 | Per Hedbor | | if( inited && me->ready_to_receive_requests )
|
c2fdff | 2000-03-21 | Martin Stjernholm | | if( mixed q = catch( me->ready_to_receive_requests( this_object() ) ) ) {
#ifdef MODULE_DEBUG
if (enable_module_batch_msgs) report_debug("\bERROR\n");
#endif
report_error( "While calling ready_to_receive_requests:\n"+
describe_backtrace( q ) );
}
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if (err = catch(pr = me->query("_priority")))
|
c5e096 | 1999-10-04 | Per Hedbor | | {
|
c45b2a | 1999-12-09 | Martin Stjernholm | | #ifdef MODULE_DEBUG
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | if (enable_module_batch_msgs) report_debug("\bERROR\n");
|
c45b2a | 1999-12-09 | Martin Stjernholm | | #endif
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | report_error(LOCALE->
|
c5e096 | 1999-10-04 | Per Hedbor | | error_initializing_module_copy(moduleinfo->get_name(),
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | describe_backtrace(err)));
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | pr = 3;
}
api_module_cache |= me->api_functions();
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(module_type & MODULE_EXTENSION)
|
c5e096 | 1999-10-04 | Per Hedbor | | {
report_error( moduleinfo->get_name()+
" is an MODULE_EXTENSION, that type is no "
"longer available.\nPlease notify the modules writer.\n"
"Suitable replacement types include MODULE_FIRST and "
" MODULE_LAST\n");
}
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type & MODULE_FILE_EXTENSION)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | if (err = catch {
array arr = me->query_file_extensions();
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if (arrayp(arr))
|
c5e096 | 1999-10-04 | Per Hedbor | | {
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | string foo;
foreach( me->query_file_extensions(), foo )
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(pri[pr]->file_extension_modules[foo] )
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | pri[pr]->file_extension_modules[foo]+=({me});
else
pri[pr]->file_extension_modules[foo]=({me});
}
|
c45b2a | 1999-12-09 | Martin Stjernholm | | }) {
#ifdef MODULE_DEBUG
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | if (enable_module_batch_msgs) report_debug("\bERROR\n");
|
c45b2a | 1999-12-09 | Martin Stjernholm | | #endif
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | report_error(LOCALE->
|
c5e096 | 1999-10-04 | Per Hedbor | | error_initializing_module_copy(moduleinfo->get_name(),
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | describe_backtrace(err)));
|
c45b2a | 1999-12-09 | Martin Stjernholm | | }
|
14179b | 1997-01-29 | Per Hedbor | |
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(module_type & MODULE_PROVIDER)
if (err = catch
|
c5e096 | 1999-10-04 | Per Hedbor | | {
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | mixed provs = me->query_provides();
if(stringp(provs))
provs = (< provs >);
if(arrayp(provs))
provs = mkmultiset(provs);
if (multisetp(provs)) {
pri[pr]->provider_modules [ me ] = provs;
|
3bbda8 | 1997-06-11 | Henrik Grubbström (Grubba) | | }
|
c45b2a | 1999-12-09 | Martin Stjernholm | | }) {
#ifdef MODULE_DEBUG
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | if (enable_module_batch_msgs) report_debug("\bERROR\n");
|
c45b2a | 1999-12-09 | Martin Stjernholm | | #endif
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | report_error(LOCALE->
|
c5e096 | 1999-10-04 | Per Hedbor | | error_initializing_module_copy(moduleinfo->get_name(),
describe_backtrace(err)));
|
c45b2a | 1999-12-09 | Martin Stjernholm | | }
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type & MODULE_TYPES)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | {
types_module = me;
types_fun = me->type_from_extension;
}
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type & MODULE_PARSER)
add_parse_module( me );
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | |
if(module_type & MODULE_AUTH)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | {
auth_module = me;
auth_fun = me->auth;
}
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type & MODULE_DIRECTORIES)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | dir_module = me;
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type & MODULE_LOCATION)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | pri[pr]->location_modules += ({ me });
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type & MODULE_LOGGER)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | pri[pr]->logger_modules += ({ me });
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type & MODULE_URL)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | pri[pr]->url_modules += ({ me });
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type & MODULE_LAST)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | pri[pr]->last_modules += ({ me });
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(module_type & MODULE_FILTER)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | pri[pr]->filter_modules += ({ me });
|
14179b | 1997-01-29 | Per Hedbor | |
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(module_type & MODULE_FIRST)
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | pri[pr]->first_modules += ({ me });
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(!enabled_modules[ modname+"#"+id ])
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | {
enabled_modules[modname+"#"+id] = 1;
|
c5e096 | 1999-10-04 | Per Hedbor | | store( "EnabledModules", enabled_modules, 1, this_object());
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | }
|
a0fbcc | 2000-04-05 | Martin Stjernholm | | if (!has_stored_vars)
store (modname + "#" + id, me->query(), 0, this_object());
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | invalidate_cache();
|
c45b2a | 1999-12-09 | Martin Stjernholm | | #ifdef MODULE_DEBUG
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | if (enable_module_batch_msgs)
report_debug("\bOK %6.1fms\n", (gethrtime()-start_time)/1000.0);
|
c45b2a | 1999-12-09 | Martin Stjernholm | | #endif
|
c45e3f | 2000-02-16 | Per Hedbor | | if( me->no_delayed_load )
set( "no_delayed_load", 1 );
|
ad683e | 1998-05-09 | Henrik Grubbström (Grubba) | | return me;
|
14179b | 1997-01-29 | Per Hedbor | | }
|
a6ef1f | 2000-03-28 | Johan Sundström | |
|
199d03 | 1999-09-05 | Francesco Chemolli | | string check_variable(string name, mixed value)
|
14179b | 1997-01-29 | Per Hedbor | | {
switch(name)
{
case "MyWorldLocation":
if(strlen(value)<7 || value[-1] != '/' ||
!(sscanf(value,"%*s://%*s/")==2))
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | return LOCALE->url_format();
|
4f4bc1 | 1998-02-04 | Per Hedbor | | return 0;
|
199d03 | 1999-09-05 | Francesco Chemolli | | case "throttle":
if (value) {
THROTTLING_DEBUG("configuration: Starting throttler up");
throttler=.throttler();
throttler->throttle(query("throttle_fill_rate"),
query("throttle_bucket_depth"),
query("throttle_min_grant"),
query("throttle_max_grant"));
} else {
THROTTLING_DEBUG("configuration: Stopping throttler");
destruct(throttler);
throttler=0;
}
return 0;
case "throttle_fill_rate":
case "throttle_bucket_depth":
case "throttle_min_grant":
case "throttle_max_grant":
THROTTLING_DEBUG("configuration: setting throttling parameter: "+
name+"="+value);
throttler->throttle(query("throttle_fill_rate"),
query("throttle_bucket_depth"),
query("throttle_min_grant"),
query("throttle_max_grant"));
return 0;
|
14179b | 1997-01-29 | Per Hedbor | | }
}
|
2f7920 | 2000-03-27 | Per Hedbor | | int disable_module( string modname, int|void nodest )
|
14179b | 1997-01-29 | Per Hedbor | | {
|
beba57 | 2000-03-20 | Martin Stjernholm | | MODULE_LOCK;
|
e351dd | 1999-11-29 | Per Hedbor | | RoxenModule me;
|
c5e096 | 1999-10-04 | Per Hedbor | | int id, pr;
|
14179b | 1997-01-29 | Per Hedbor | | sscanf(modname, "%s#%d", modname, id );
|
e351dd | 1999-11-29 | Per Hedbor | | ModuleInfo moduleinfo = roxen->find_module( modname );
|
c5e096 | 1999-10-04 | Per Hedbor | | mapping module = modules[ modname ];
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | string descr = moduleinfo->get_name() + (id ? " copy " + (id + 1) : "");
|
14179b | 1997-01-29 | Per Hedbor | |
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if(!module)
|
14179b | 1997-01-29 | Per Hedbor | | {
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | | report_error(LOCALE->disable_nonexistant_module(modname));
|
14179b | 1997-01-29 | Per Hedbor | | return 0;
}
|
0b7d2b | 1999-12-22 | Per Hedbor | | me = module[id];
|
c5e096 | 1999-10-04 | Per Hedbor | | m_delete(module->copies, id);
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(!sizeof(module->copies))
m_delete( modules, modname );
|
14179b | 1997-01-29 | Per Hedbor | |
|
8cc31b | 1997-10-12 | Henrik Grubbström (Grubba) | | invalidate_cache();
|
14179b | 1997-01-29 | Per Hedbor | |
if(!me)
{
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | report_error(LOCALE->disable_module_failed(descr));
|
14179b | 1997-01-29 | Per Hedbor | | return 0;
}
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | if(me->stop)
if (mixed err = catch (me->stop()))
report_error (LOCALE->error_disabling_module (descr, describe_backtrace (err)));
|
14179b | 1997-01-29 | Per Hedbor | |
#ifdef MODULE_DEBUG
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | report_debug("Disabling "+descr+"\n");
|
14179b | 1997-01-29 | Per Hedbor | | #endif
|
c5e096 | 1999-10-04 | Per Hedbor | | if(moduleinfo->type & MODULE_FILE_EXTENSION)
|
14179b | 1997-01-29 | Per Hedbor | | {
string foo;
|
d54d06 | 1999-06-10 | Martin Stjernholm | | for(pr=0; pr<10; pr++)
foreach( indices (pri[pr]->file_extension_modules), foo )
pri[pr]->file_extension_modules[foo]-=({me});
|
14179b | 1997-01-29 | Per Hedbor | | }
|
c5e096 | 1999-10-04 | Per Hedbor | | if(moduleinfo->type & MODULE_PROVIDER) {
|
ae32d0 | 1998-03-23 | David Hedbor | | for(pr=0; pr<10; pr++)
m_delete(pri[pr]->provider_modules, me);
}
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if(moduleinfo->type & MODULE_TYPES)
|
14179b | 1997-01-29 | Per Hedbor | | {
types_module = 0;
types_fun = 0;
}
|
c5e096 | 1999-10-04 | Per Hedbor | | if(moduleinfo->type & MODULE_PARSER)
|
b796b5 | 1998-11-18 | Per Hedbor | | remove_parse_module( me );
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if( moduleinfo->type & MODULE_AUTH )
|
14179b | 1997-01-29 | Per Hedbor | | {
auth_module = 0;
auth_fun = 0;
}
|
c5e096 | 1999-10-04 | Per Hedbor | | if( moduleinfo->type & MODULE_DIRECTORIES )
|
14179b | 1997-01-29 | Per Hedbor | | dir_module = 0;
|
c5e096 | 1999-10-04 | Per Hedbor | | if( moduleinfo->type & MODULE_LOCATION )
|
14179b | 1997-01-29 | Per Hedbor | | for(pr=0; pr<10; pr++)
pri[pr]->location_modules -= ({ me });
|
c5e096 | 1999-10-04 | Per Hedbor | | if( moduleinfo->type & MODULE_URL )
|
14179b | 1997-01-29 | Per Hedbor | | for(pr=0; pr<10; pr++)
pri[pr]->url_modules -= ({ me });
|
c5e096 | 1999-10-04 | Per Hedbor | | if( moduleinfo->type & MODULE_LAST )
|
14179b | 1997-01-29 | Per Hedbor | | for(pr=0; pr<10; pr++)
pri[pr]->last_modules -= ({ me });
|
c5e096 | 1999-10-04 | Per Hedbor | | if( moduleinfo->type & MODULE_FILTER )
|
14179b | 1997-01-29 | Per Hedbor | | for(pr=0; pr<10; pr++)
pri[pr]->filter_modules -= ({ me });
|
c5e096 | 1999-10-04 | Per Hedbor | | if( moduleinfo->type & MODULE_FIRST ) {
|
14179b | 1997-01-29 | Per Hedbor | | for(pr=0; pr<10; pr++)
pri[pr]->first_modules -= ({ me });
|
f12890 | 1997-08-15 | Henrik Grubbström (Grubba) | | }
|
14179b | 1997-01-29 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | if( moduleinfo->type & MODULE_LOGGER )
|
14179b | 1997-01-29 | Per Hedbor | | for(pr=0; pr<10; pr++)
pri[pr]->logger_modules -= ({ me });
|
c5e096 | 1999-10-04 | Per Hedbor | | if( enabled_modules[modname+"#"+id] )
|
14179b | 1997-01-29 | Per Hedbor | | {
m_delete( enabled_modules, modname + "#" + id );
|
c5e096 | 1999-10-04 | Per Hedbor | | store( "EnabledModules",enabled_modules, 1, this_object());
|
14179b | 1997-01-29 | Per Hedbor | | }
|
2f7920 | 2000-03-27 | Per Hedbor | | if(!nodest)
destruct(me);
|
14179b | 1997-01-29 | Per Hedbor | | return 1;
}
|
e351dd | 1999-11-29 | Per Hedbor | | RoxenModule|string find_module(string name)
|
14179b | 1997-01-29 | Per Hedbor | | {
int id;
sscanf(name, "%s#%d", name, id);
if(modules[name])
|
c5e096 | 1999-10-04 | Per Hedbor | | return modules[name]->copies[id];
|
14179b | 1997-01-29 | Per Hedbor | | return 0;
}
|
f5a274 | 1999-10-18 | Per Hedbor | | multiset forcibly_added = (<>);
int add_modules( array(string) mods, int|void now )
|
14179b | 1997-01-29 | Per Hedbor | | {
|
ba18d7 | 1999-11-27 | Per Hedbor | | #ifdef MODULE_DEBUG
|
c5e096 | 1999-10-04 | Per Hedbor | | int wr;
|
ba18d7 | 1999-11-27 | Per Hedbor | | #endif
|
c5e096 | 1999-10-04 | Per Hedbor | | foreach (mods, string mod)
|
8f061b | 1999-11-19 | Per Hedbor | | {
sscanf( mod, "%s#", mod );
|
10c7e1 | 1999-12-28 | Martin Nilsson | | if( ((now && !modules[ mod ]) ||
|
0ce25d | 1999-11-15 | Per Hedbor | | !enabled_modules[ mod+"#0" ] )
&& !forcibly_added[ mod+"#0" ])
|
14179b | 1997-01-29 | Per Hedbor | | {
|
ba18d7 | 1999-11-27 | Per Hedbor | | #ifdef MODULE_DEBUG
|
c5e096 | 1999-10-04 | Per Hedbor | | if( !wr++ )
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | if (enable_module_batch_msgs)
report_debug("\b[ adding req module" + (sizeof (mods) > 1 ? "s" : "") + "\n");
else
report_debug("Adding required module" + (sizeof (mods) > 1 ? "s" : "") + "\n");
|
14179b | 1997-01-29 | Per Hedbor | | #endif
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | forcibly_added[ mod+"#0" ] = 1;
enable_module( mod+"#0" );
|
14179b | 1997-01-29 | Per Hedbor | | }
|
8f061b | 1999-11-19 | Per Hedbor | | }
|
ba18d7 | 1999-11-27 | Per Hedbor | | #ifdef MODULE_DEBUG
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | if( wr && enable_module_batch_msgs )
|
ed8d26 | 1999-12-30 | Martin Stjernholm | | report_debug("] \b");
|
c79b26 | 1998-02-05 | Johan Schön | | #endif
|
14179b | 1997-01-29 | Per Hedbor | | }
|
279a0c | 1997-11-26 | Henrik Grubbström (Grubba) | |
|
14179b | 1997-01-29 | Per Hedbor | |
|
279a0c | 1997-11-26 | Henrik Grubbström (Grubba) | | mapping(string:string) sql_urls = ([]);
|
ed9313 | 1998-07-09 | Johan Schön | | mapping sql_cache = ([]);
|
e351dd | 1999-11-29 | Per Hedbor | | Sql.sql sql_cache_get(string what)
|
ed9313 | 1998-07-09 | Johan Schön | | {
#ifdef THREADS
if(sql_cache[what] && sql_cache[what][this_thread()])
return sql_cache[what][this_thread()];
if(!sql_cache[what])
sql_cache[what] = ([ this_thread():Sql.sql( what ) ]);
else
sql_cache[what][ this_thread() ] = Sql.sql( what );
return sql_cache[what][ this_thread() ];
#else /* !THREADS */
if(!sql_cache[what])
sql_cache[what] = Sql.sql( what );
return sql_cache[what];
#endif
}
|
e351dd | 1999-11-29 | Per Hedbor | | Sql.sql sql_connect(string db)
|
279a0c | 1997-11-26 | Henrik Grubbström (Grubba) | | {
|
c5e096 | 1999-10-04 | Per Hedbor | | if (sql_urls[db])
return sql_cache_get(sql_urls[db]);
else
return sql_cache_get(db);
|
279a0c | 1997-11-26 | Henrik Grubbström (Grubba) | | }
|
14179b | 1997-01-29 | Per Hedbor | |
|
1e5ee8 | 1997-08-21 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | private string get_my_url()
{
string s;
|
c79b26 | 1998-02-05 | Johan Schön | | #if efun(gethostname)
|
14179b | 1997-01-29 | Per Hedbor | | s = (gethostname()/".")[0] + "." + query("Domain");
s -= "\n";
|
c79b26 | 1998-02-05 | Johan Schön | | #else
s = "localhost";
#endif
|
14179b | 1997-01-29 | Per Hedbor | | return "http://" + s + "/";
}
|
5ffa54 | 2000-02-16 | Per Hedbor | | array after_init_hooks = ({});
mixed add_init_hook( mixed what )
{
if( inited )
call_out( what, 0, this_object() );
else
after_init_hooks |= ({ what });
}
|
0f28da | 1997-08-13 | Per Hedbor | | void enable_all_modules()
|
14179b | 1997-01-29 | Per Hedbor | | {
|
beba57 | 2000-03-20 | Martin Stjernholm | | MODULE_LOCK;
|
c45e3f | 2000-02-16 | Per Hedbor | | int q = query( "no_delayed_load" );
set( "no_delayed_load", 0 );
low_init( );
if( q != query( "no_delayed_load" ) )
save_one( 0 );
|
5ffa54 | 2000-02-16 | Per Hedbor | | }
|
c45e3f | 2000-02-16 | Per Hedbor | | void low_init()
|
5ffa54 | 2000-02-16 | Per Hedbor | | {
if( inited )
return;
|
8516a7 | 1999-12-22 | Per Hedbor | |
|
24c06c | 2000-02-16 | Per Hedbor | | int start_time = gethrtime();
report_debug("\nEnabling all modules for "+query_name()+"... \n");
|
1d7d6d | 2000-02-16 | Per Hedbor | | add_parse_module( (object)this_object() );
enabled_modules = retrieve("EnabledModules", this_object());
|
695801 | 1999-12-28 | Martin Stjernholm | | object ec = roxenloader.LowErrorContainer();
roxenloader.push_compile_error_handler( ec );
|
c5e096 | 1999-10-04 | Per Hedbor | | array modules_to_process = indices( enabled_modules );
|
14179b | 1997-01-29 | Per Hedbor | | string tmp_string;
|
44f243 | 1999-06-07 | Martin Stjernholm | |
parse_log_formats();
init_log_file();
|
0f28da | 1997-08-13 | Per Hedbor | |
if(search(modules_to_process, "userdb#0")>-1)
modules_to_process = (({"userdb#0"})+(modules_to_process-({"userdb#0"})));
array err;
|
f5a274 | 1999-10-18 | Per Hedbor | | forcibly_added = (<>);
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | enable_module_batch_msgs = 1;
|
0f28da | 1997-08-13 | Per Hedbor | | foreach( modules_to_process, tmp_string )
|
f5a274 | 1999-10-18 | Per Hedbor | | {
|
695801 | 1999-12-28 | Martin Stjernholm | | if( !forcibly_added[ tmp_string ] )
|
f5a274 | 1999-10-18 | Per Hedbor | | if(err = catch( enable_module( tmp_string )))
|
10c7e1 | 1999-12-28 | Martin Nilsson | | report_error(LOCALE->enable_module_failed(tmp_string,
|
f5a274 | 1999-10-18 | Per Hedbor | | describe_backtrace(err)));
}
|
9a1d47 | 2000-01-12 | Martin Stjernholm | | enable_module_batch_msgs = 0;
|
695801 | 1999-12-28 | Martin Stjernholm | | roxenloader.pop_compile_error_handler();
if( strlen( ec->get() ) )
report_error( "While enabling modules in "+name+":\n"+ec->get() );
|
17d6d1 | 2000-03-30 | Per Hedbor | | if( strlen( ec->get_warnings() ) )
report_warning( "While enabling modules in "+name+":\n"+ec->get_warnings());
|
5ffa54 | 2000-02-16 | Per Hedbor | | foreach( ({this_object()})+indices( otomod ), object mod )
if( mod->ready_to_receive_requests )
if( mixed q = catch( mod->ready_to_receive_requests( this_object() ) ) )
|
c2fdff | 2000-03-21 | Martin Stjernholm | | report_error( "While calling ready_to_receive_requests in "+
|
5ffa54 | 2000-02-16 | Per Hedbor | | otomod[mod]+":\n"+
describe_backtrace( q ) );
foreach( after_init_hooks, function q )
if( mixed w = catch( q ) )
|
c2fdff | 2000-03-21 | Martin Stjernholm | | report_error( "While calling after_init_hook %O:\n%s",
|
5ffa54 | 2000-02-16 | Per Hedbor | | q, describe_backtrace( w ) );
after_init_hooks = ({});
inited = 1;
|
10c7e1 | 1999-12-28 | Martin Nilsson | | report_notice("All modules for %s enabled in %3.1f seconds\n\n",
|
07c992 | 1999-11-23 | Per Hedbor | | query_name(),(gethrtime()-start_time)/1000000.0);
|
0f28da | 1997-08-13 | Per Hedbor | | }
void create(string config)
{
|
14179b | 1997-01-29 | Per Hedbor | | name=config;
|
001ae7 | 1998-10-11 | Henrik Grubbström (Grubba) | |
|
9b9f70 | 1997-08-12 | Per Hedbor | | defvar("comment", "", "Virtual server comment",
TYPE_TEXT_FIELD|VAR_MORE,
|
a6ef1f | 2000-03-28 | Johan Sundström | | "This text will be visible in the administration interface, it "
|
14179b | 1997-01-29 | Per Hedbor | | " can be quite useful to use as a memory helper.");
|
b796b5 | 1998-11-18 | Per Hedbor | |
|
e6f83d | 2000-03-06 | Peter Bortas | | deflocaledoc("deutsch", "comment", "Kommentar",
"Ein Kommentar, der im Konfigurations-Interface "
"sichtbar ist und als Dokumentation nützlich ist.");
|
b796b5 | 1998-11-18 | Per Hedbor | | deflocaledoc("svenska", "comment", "Kommentar",
"En kommentar som syns i konfigurationsinterfacet");
|
9b9f70 | 1997-08-12 | Per Hedbor | | defvar("name", "", "Virtual server name",
TYPE_STRING|VAR_MORE,
|
14179b | 1997-01-29 | Per Hedbor | | "This is the name that will be used in the configuration "
"interface. If this is left empty, the actual name of the "
"virtual server will be used");
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
e6f83d | 2000-03-06 | Peter Bortas | | deflocaledoc("deutsch", "name", "Servername",
#"Dies ist der Name, der im Konfigurations-Interface für den
virtuellen Server benutzt wird. Wird dieses Feld leer gelassen,
wird der eigentliche Name des virtuellen Servers benutzt.");
|
b796b5 | 1998-11-18 | Per Hedbor | | deflocaledoc("svenska", "name", "Serverns namn",
#"Det här är namnet som kommer att synas i
konfigurationsgränssnittet. Om du lämnar det här fältet tomt kommer
serverns ursprungliga namn (det du skrev in när du skapade servern)
att användas.");
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
defvar("LogFormat",
|
14179b | 1997-01-29 | Per Hedbor | | "404: $host $referer - [$cern_date] \"$method $resource $protocol\" 404 -\n"
|
2d4d4f | 1997-08-01 | Fredrik Noring | | "500: $host $referer ERROR [$cern_date] \"$method $resource $protocol\" 500 -\n"
|
14179b | 1997-01-29 | Per Hedbor | | "*: $host - - [$cern_date] \"$method $resource $protocol\" $response $length"
,
|
10c7e1 | 1999-12-28 | Martin Nilsson | | "Logging: Format",
|
9b9f70 | 1997-08-12 | Per Hedbor | | TYPE_TEXT_FIELD|VAR_MORE,
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | | "What format to use for logging. The syntax is:\n"
"<pre>"
"response-code or *: Log format for that response acode\n\n"
"Log format is normal characters, or one or more of the "
"variables below:\n"
"\n"
"\\n \\t \\r -- As in C, newline, tab and linefeed\n"
"$char(int) -- Insert the (1 byte) character specified by the integer.\n"
"$wchar(int) -- Insert the (2 byte) word specified by the integer.\n"
"$int(int) -- Insert the (4 byte) word specified by the integer.\n"
"$^ -- Supress newline at the end of the logentry\n"
"$host -- The remote host name, or ip number.\n"
"$ip_number -- The remote ip number.\n"
"$bin-ip_number -- The remote host id as a binary integer number.\n"
"\n"
"$cern_date -- Cern Common Log file format date.\n"
"$bin-date -- Time, but as an 32 bit iteger in network byteorder\n"
"\n"
"$method -- Request method\n"
"$resource -- Resource identifier\n"
|
dfb4ec | 1999-05-20 | Francesco Chemolli | | "$full_resource -- Full requested resource, including any query fields\n"
|
14179b | 1997-01-29 | Per Hedbor | | "$protocol -- The protocol used (normally HTTP/1.0)\n"
"$response -- The response code sent\n"
"$bin-response -- The response code sent as a binary short number\n"
"$length -- The length of the data section of the reply\n"
"$bin-length -- Same, but as an 32 bit iteger in network byteorder\n"
|
0bf5a1 | 1998-04-03 | Henrik Grubbström (Grubba) | | "$request-time -- The time the request took (seconds)\n"
|
14179b | 1997-01-29 | Per Hedbor | | "$referer -- the header 'referer' from the request, or '-'.\n"
"$user_agent -- the header 'User-Agent' from the request, or '-'.\n\n"
"$user -- the name of the auth user used, if any\n"
"$user_id -- A unique user ID, if cookies are supported,\n"
" by the client, otherwise '0'\n"
|
c5e096 | 1999-10-04 | Per Hedbor | | "</pre>", 0, lambda(){ return !query("Log");});
|
e6f83d | 2000-03-06 | Peter Bortas | |
deflocaledoc("deutsch", "LogFormat", "Logging: Loggingformat",
#"Welches Format soll für die Logfiles benutzt werden.
<pre>
Antwort-Code oder *: Loggingformat für diesen Antwort-Code (z.B 404)
Das Loggingformat ist normaler Text, in den folgende
Variabeln eingesetzt werden können.
\\n \\t \\r -- Newline, Tab oder Linefeed-Zeichen (wie in C)
$char(int) -- Fügt das 8Bit-Zeichen ein, das dem Integerwert entspricht.
$wchar(int) -- Fügt das 16Bit-Zeichen ein, das dem Integerwert entspricht.
$int(int) -- Fügt das 32Bit-Word ein, das dem Integerwert entspricht.
$^ -- Unterdrückt das Newline-Zeichen am Ende des Eintrages.
$host -- Hostname oder IP-Adresse des Webbrowsers.
$ip_number -- IP-Adresse des Webbrowsers.
$bin-ip_number -- IP-Adresse des Webbrowsers in 32Bit-Dezimaldarstellung.
$cern_date -- Uhrzeit und Datum im CERN-Format.
$bin-date -- Zeit als 32Bit-Integer-Darstellung (Sekunden seit 1.1.1970).
$method -- Anfrage-Methode (GET, POST, usw.)
$resource -- Angeforderte Datei.
$protocol -- Verwendetes Protokoll (normalerweise HTTP/1.0 oder HTTP/1.1)
$response -- Der verschichte Antwort-Code
$bin-response -- Der verschickte Antwort-Code in 32Bit-Dezimaldarstellung
$length -- Die Größe der verschickten Daten
$bin-length -- Die Größe der verschickten Daten in 32Bit-Dezimaldarstellung
$request-time -- Verstrichene Zeit in Sekunden, die die Anfrage benötigt hat
$referer -- Die 'referer'-Information aus der Anfrage, oder '-'
$user_agent -- Die 'user-agent'-Information aus der Anfrage, oder '-'
$user -- Der Name des angemeldeten Benutzers, sofern vorhanden
$user_id -- Die eindeutige Benutzerkennung, sofern Cookies vom
Browser unterstützt wurden, ansonsten '0'.
</pre>");
|
b796b5 | 1998-11-18 | Per Hedbor | | deflocaledoc("svenska", "LogFormat", "Loggning: Loggningsformat",
#"Vilket format som ska användas för att logga
<pre>
|
10c7e1 | 1999-12-28 | Martin Nilsson | | svarskod eller *: Loggformat för svarskoden (eller alla koder som inte
|
b796b5 | 1998-11-18 | Per Hedbor | | har något annat format specifierat om du använder '*')
loggformatet är normala tecken, och en eller flera av koderna nedan.
\\n \\t \\r -- Precis som i C, ny rad, tab och carriage return
$char(int) -- Stoppa in det tecken vars teckenkod är det angivna nummret.
|
10c7e1 | 1999-12-28 | Martin Nilsson | | $wchar(int) -- Stoppa in det tvåocktetstecken vars teckenkod är det
|
b796b5 | 1998-11-18 | Per Hedbor | | angivna nummret.
|
10c7e1 | 1999-12-28 | Martin Nilsson | | $int(int) -- Stoppa in det fyraocktetstecken vars teckenkod är det
|
b796b5 | 1998-11-18 | Per Hedbor | | angivna nummret.
$^ -- Stoppa <b>inte</b> in en vagnretur på slutet av
varje loggrad
$host -- DNS namnet för datorn som gjorde förfrågan
$ip_number -- IP-nummret för datorn som gjorde förfrågan
$bin-ip_number -- IP-nummret för datorn som gjorde förfrågan som
|
10c7e1 | 1999-12-28 | Martin Nilsson | | binärdata i nätverksoktettordning
|
b796b5 | 1998-11-18 | Per Hedbor | |
$cern_date -- Ett datum som det ska vara enligt Cern Common Log
|
10c7e1 | 1999-12-28 | Martin Nilsson | | file specifikationen
|
b796b5 | 1998-11-18 | Per Hedbor | | $bin-date -- Tiden för requesten som sekunder sedan 1970, binärt
i nätverksoktettordning.
$method -- Förfrågningsmetoden (GET, POST etc)
$resource -- Resursidentifieraren (filnamnet)
$protocol -- Protokollet som användes för att fråga efter filen
$response -- Den skickade svarskoden
$bin-response -- Den skickade svarskoden som ett binärt ord (2
oktetter) i nätverksoktettordning
$length -- Längden av datan som skickades som svar till klienten
$bin-length -- Samma sak, men som ett 4 oktetters ord i
|
10c7e1 | 1999-12-28 | Martin Nilsson | | nätverksoktettordning.
|
b796b5 | 1998-11-18 | Per Hedbor | | $request-time -- Tiden som requeten tog i sekunder
$referer -- Headern 'referer' från förfrågan eller '-'.
$user_agent -- Headern 'User-Agent' från förfrågan eller '-'.
$user -- Den autentifierade användarens namn, eller '-'
|
10c7e1 | 1999-12-28 | Martin Nilsson | | $user_id -- Ett unikt användarid. Tas från kakan RoxenUserID, du
|
b796b5 | 1998-11-18 | Per Hedbor | | måste slå på kaksättningsfunktionaliteten i de
globala inställningarna. '0' används för de
förfrågningar som inte har kakan.
</pre>");
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
14179b | 1997-01-29 | Per Hedbor | | defvar("Log", 1, "Logging: Enabled", TYPE_FLAG, "Log requests");
|
b796b5 | 1998-11-18 | Per Hedbor | | deflocaledoc("svenska", "Log", "Loggning: På",
"Ska roxen logga alla förfrågningar till en logfil?");
|
dfe036 | 2000-03-19 | Martin Nilsson | | defvar("LogFile", "$LOGDIR/"+Roxen.short_name(name)+"/Log",
|
14179b | 1997-01-29 | Per Hedbor | |
"Logging: Log file", TYPE_FILE, "The log file. "
|
f7d981 | 1997-09-12 | Per Hedbor | | ""
"A file name. May be relative to "+getcwd()+"."
" Some substitutions will be done:"
"<pre>"
|
b796b5 | 1998-11-18 | Per Hedbor | | "%y Year (e.g. '1997')\n"
"%m Month (e.g. '08')\n"
"%d Date (e.g. '10' for the tenth)\n"
|
3bb38c | 2000-01-20 | Martin Bähr | | "%h Hour (e.g. '00')\n"
"%H Hostname\n"
"</pre>"
|
c5e096 | 1999-10-04 | Per Hedbor | | ,0, lambda(){ return !query("Log");});
|
e6f83d | 2000-03-06 | Peter Bortas | | deflocaledoc("deutsch", "LogFile",
"Logging: Logdatei",
"Ein Dateiname. Kann relativ zu "+getcwd()+" sein."
"Einige Ersetzungen werden vorgenommen:"
#"<pre>
%y Jahr (z.B. '1997')
%m Monat (z.B. '08')
%d Tag (z.B. '10' für den 10. des Monats)
%h Stunden (z.B. '00')
</pre>");
|
10c7e1 | 1999-12-28 | Martin Nilsson | | deflocaledoc("svenska", "LogFile",
|
3b1783 | 1998-11-22 | Per Hedbor | | "Loggning: Loggfil",
|
b796b5 | 1998-11-18 | Per Hedbor | | "Filen som roxen loggar i. Filnamnet kan vara relativt "
+getcwd()+
#". Du kan använda några kontrollkoder för att få flera loggfiler och
automatisk loggrotation:
<pre>
%y År (t.ex. '1997')
%m Månad (t.ex. '08')
%d Datum (t.ex. '10')
%h Timme (t.ex. '00')
</pre>");
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
defvar("NoLog", ({ }),
|
9b9f70 | 1997-08-12 | Per Hedbor | | "Logging: No Logging for", TYPE_STRING_LIST|VAR_MORE,
|
14179b | 1997-01-29 | Per Hedbor | | "Don't log requests from hosts with an IP number which matches any "
"of the patterns in this list. This also affects the access counter "
|
c5e096 | 1999-10-04 | Per Hedbor | | "log.\n",0, lambda(){ return !query("Log");});
|
e6f83d | 2000-03-06 | Peter Bortas | |
deflocaledoc("deutsch", "NoLog",
"Logging: Kein Log für",
#"Für die folgenden IP-Adressen werden keine Log-Einträge vorgenommen.
Dies hat auch Einfluss auf den Access-Counter.");
|
10c7e1 | 1999-12-28 | Martin Nilsson | | deflocaledoc("svenska", "NoLog",
|
3b1783 | 1998-11-22 | Per Hedbor | | "Loggning: Logga inte för",
|
b796b5 | 1998-11-18 | Per Hedbor | | #"Logga inte några förfrågningar vars IP-nummer matchar
något av de mönster som står i den här listan. Den här variabeln
påverkar även <accessed> RXML-styrkoden.");
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
b653f5 | 1999-05-18 | Martin Stjernholm | | defvar("Domain", roxen->get_domain(), "Domain", TYPE_STRING,
|
b796b5 | 1998-11-18 | Per Hedbor | | "The domainname of the server. The domainname is used "
" to generate default URLs, and to gererate email addresses");
|
e6f83d | 2000-03-06 | Peter Bortas | |
deflocaledoc( "deutsch", "Domain",
"DNS-Domain",
#"Der Domainname des Servers, der für die Generierung der
Standard-URLs und Email-Adressen verwendet wird");
|
10c7e1 | 1999-12-28 | Martin Nilsson | | deflocaledoc( "svenska", "Domain",
|
b796b5 | 1998-11-18 | Per Hedbor | | "DNS Domän",
#"Serverns domännamn. Det av en del RXML styrkoder för att generara
epostadresser, samt för att generera skönskvärdet för serverurl variablen.");
|
a8f1b3 | 2000-01-31 | Per Hedbor | |
|
14179b | 1997-01-29 | Per Hedbor | |
|
18f5fa | 2000-03-26 | Martin Nilsson | | defvar("MyWorldLocation", "http://"+gethostname()+"/", "Server URL", TYPE_STRING,
|
c5e096 | 1999-10-04 | Per Hedbor | | "This is the main server URL, where your start page is located.");
|
e6f83d | 2000-03-06 | Peter Bortas | |
deflocaledoc( "deutsch", "MyWorldLocation",
"Server-URL",
"Dies ist die URL des Haupt-Servers, auf dem die Startseite "
"abgelegt ist.");
|
b796b5 | 1998-11-18 | Per Hedbor | | deflocaledoc( "svenska", "MyWorldLocation",
"Serverns URL",
|
10c7e1 | 1999-12-28 | Martin Nilsson | | #"Det här är huvudURLen till din startsida. Den används av många
|
b796b5 | 1998-11-18 | Per Hedbor | | moduler för att bygga upp absoluta URLer från en relativ URL.");
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
f406ba | 1999-11-27 | Per Hedbor | | defvar("URLs", ({"http://*:80/"}), "URLs", TYPE_STRING_LIST|VAR_INITIAL,
|
038798 | 2000-02-28 | Per Hedbor | | "Bind to these URLs. You can use '*' and '?' to perform globbing "
"(using any of these will default to binding to all IP-numbers on "
"your machine). The possible protocols are http, fhttp (a faster "
"version of the normal HTTP protocol, but not 100% compatible with "
"all modules) https, ftp, ftps, gopher and tetris.");
|
c5e096 | 1999-10-04 | Per Hedbor | |
|
199d03 | 1999-09-05 | Francesco Chemolli | | defvar("InternalLoc", "/_internal/",
|
10c7e1 | 1999-12-28 | Martin Nilsson | | "Internal module resource mountpoint",
|
f406ba | 1999-11-27 | Per Hedbor | | TYPE_LOCATION|VAR_MORE|VAR_DEVELOPER,
|
5839c3 | 1999-01-22 | Marcus Comstedt | | "Some modules may want to create links to internal resources. "
"This setting configures an internally handled location that can "
"be used for such purposes. Simply select a location that you are "
"not likely to use for regular resources.");
|
f406ba | 1999-11-27 | Per Hedbor | |
|
e6f83d | 2000-03-06 | Peter Bortas | | deflocaledoc("deutsch", "InternalLoc",
"Interner Modulressourcen-Mountpoint",
#"Einige Module erzeugen Links auf interne Ressourcen. Diese Einstellung
bestimmt eine intern verwandte Position im virtuellen Dateisystem, um
solche Zwecke zu erfüllen. Es sollte ein Wert benutzt werden, der nicht
durch andere Ressourcen benutzt wird.");
|
10c7e1 | 1999-12-28 | Martin Nilsson | | deflocaledoc("svenska", "InternalLoc",
|
5839c3 | 1999-01-22 | Marcus Comstedt | | "Intern modulresursmountpoint",
#"Somliga moduler kan vilja skapa länkar till interna resurser.
Denna inställning konfigurerar en internt hanterad location som kan användas
för sådana ändamål. Välj bara en location som du förmodligen inte kommer
behöva för vanliga resurser.");
|
199d03 | 1999-09-05 | Francesco Chemolli | |
defvar("throttle",0,
|
4d1683 | 1999-11-17 | Per Hedbor | | "Bandwidth Throttling: Server: Enabled",TYPE_FLAG,
|
10c7e1 | 1999-12-28 | Martin Nilsson | | #"If set, per-server bandwidth throttling will be enabled.
It will allow you to limit the total available bandwidth for
|
199d03 | 1999-09-05 | Francesco Chemolli | | this Virtual Server.<BR>Bandwidth is assigned using a Token Bucket.
The principle under which it works is: for each byte we send we use a token.
Tokens are added to a repository at a constant rate. When there's not enough,
we can't transmit. When there's too many, they \"spill\" and are lost.");
|
e6f83d | 2000-03-06 | Peter Bortas | | deflocaledoc( "deutsch", "throttle",
"Bandbreitenbegrenzung: Server: Aktiviert",
#"Wenn gesetzt, wird pro Server eine Bandbreitenbegrenzung aktiviert.
Dadurch kann man die zur Verfügung stehende Bandbreite für diesen
virtuellen Server begrenzen.<br>");
|
4d1683 | 1999-11-17 | Per Hedbor | | deflocaledoc( "svenska", "throttle", "Bandviddsbegränsning: Servernivå: På",
|
10c7e1 | 1999-12-28 | Martin Nilsson | | #"Om den här variablen är på så kommer bandvisddsbegränsning
|
4d1683 | 1999-11-17 | Per Hedbor | | på servernivå att ske. Det gör det möjligt för dig att begränsa den totala
bandvidden som den här virtuella servern använder.
<p>
|
10c7e1 | 1999-12-28 | Martin Nilsson | | Bandvidden räknas ut genom att använda en poletthink. Principen som den
|
4d1683 | 1999-11-17 | Per Hedbor | | arbetar efter är: För varje byte som sänds så används en polett, poletter
stoppas i hinken i en konstant hastighet. När det inte finns några poletter
så avstännar dataskickande tills en polett blir tillgänglig. När det är för
många poletter i hinken så kommer de nya som kommer in att \"ramla ut\".");
|
199d03 | 1999-09-05 | Francesco Chemolli | | defvar("throttle_fill_rate",102400,
|
4d1683 | 1999-11-17 | Per Hedbor | | "Bandwidth Throttling: Server: Average available bandwidth",
|
199d03 | 1999-09-05 | Francesco Chemolli | | TYPE_INT,
|
10c7e1 | 1999-12-28 | Martin Nilsson | | #"This is the average bandwidth available to this Virtual Server in
|
199d03 | 1999-09-05 | Francesco Chemolli | | bytes/sec (the bucket \"fill rate\").",
0,arent_we_throttling_server);
|
e6f83d | 2000-03-06 | Peter Bortas | | deflocaledoc( "deutsch", "throttle_fill_rate",
"Bandbreitenbegrenzung: Server: "
"Durchschnittliche Bandbreite",
"Dies ist die durchschnittliche Bandbreite, die "
"für diesen virtuellen Server zur Verfügung steht. "
"(in Bytes/Sekunde).");
|
4d1683 | 1999-11-17 | Per Hedbor | | deflocaledoc( "svenska", "throttle_fill_rate",
"Bandviddsbegränsning: Servernivå:"
" Genomsnittlig tillgänglig bandvidd",
"Det här är den genomsnittliga bandvidden som är tillgänglig "
"för servern (hastigheten med vilken hinken fylls)");
|
199d03 | 1999-09-05 | Francesco Chemolli | | defvar("throttle_bucket_depth",1024000,
|
4d1683 | 1999-11-17 | Per Hedbor | | "Bandwidth Throttling: Server: Bucket Depth", TYPE_INT,
|
199d03 | 1999-09-05 | Francesco Chemolli | | #"This is the maximum depth of the bucket. After a long enough period
of inactivity, a request will get this many unthrottled bytes of data, before
throttling kicks back in.<br>Set equal to the Fill Rate in order not to allow
any data bursts. This value determines the length of the time over which the
bandwidth is averaged",0,arent_we_throttling_server);
|
4d1683 | 1999-11-17 | Per Hedbor | |
|
e6f83d | 2000-03-06 | Peter Bortas | |
|
4d1683 | 1999-11-17 | Per Hedbor | | deflocaledoc( "svenska", "throttle_bucket_depth",
"Bandviddsbegränsning: Servernivå:"
" Hinkstorlek",
"Det här är det maximala antalet poletter som får plats "
"i hinken. Om det här värdet är lika stort som den "
"genomsnittliga tillgängliga bandvidden så tillåts inga "
"tillfälliga datapulser när servern har varit inaktiv ett tag"
" utan data skickas alltid med max den bandvidden");
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
199d03 | 1999-09-05 | Francesco Chemolli | | defvar("throttle_min_grant",1300,
|
4d1683 | 1999-11-17 | Per Hedbor | | "Bandwidth Throttling: Server: Minimum Grant", TYPE_INT,
|
199d03 | 1999-09-05 | Francesco Chemolli | | #"When the bandwidth availability is below this value, connections will
be delayed rather than granted minimal amounts of bandwidth. The purpose
is to avoid sending too small packets (which would increase the IP overhead)",
0,arent_we_throttling_server);
|
e6f83d | 2000-03-06 | Peter Bortas | |
|
4d1683 | 1999-11-17 | Per Hedbor | | deflocaledoc( "svenska", "throttle_min_grant",
"Bandviddsbegränsning: Servernivå:"
" Minimalt antal bytes",
|
10c7e1 | 1999-12-28 | Martin Nilsson | | #"När det tillgängliga antalet poletter (alltså bytes) är mindre än det här
|
4d1683 | 1999-11-17 | Per Hedbor | | värdet så fördröjs förbindelser, alternativet är att skicka små paket, vilket
öker overheaden som kommer till från IP och TCP paketheadrar." );
|
199d03 | 1999-09-05 | Francesco Chemolli | | defvar("throttle_max_grant",14900,
|
4d1683 | 1999-11-17 | Per Hedbor | | "Bandwidth Throttling: Server: Maximum Grant", TYPE_INT,
|
199d03 | 1999-09-05 | Francesco Chemolli | | #"This is the maximum number of bytes assigned in a single request
to a connection. Keeping this number low will share bandwidth more evenly
among the pending connections, but keeping it too low will increase IP
overhead and (marginally) CPU usage. You'll want to set it just a tiny
bit lower than any integer multiple of your network's MTU (typically 1500
for ethernet)",0,arent_we_throttling_server);
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
e6f83d | 2000-03-06 | Peter Bortas | |
|
4d1683 | 1999-11-17 | Per Hedbor | | deflocaledoc( "svenska", "throttle_max_grant",
"Bandviddsbegränsning: Servernivå:"
" Maximalt antal bytes",
#"Det här är det maximala antalet bytes som en förbindelse kan få.
Om det här värdet är lågt så fördelas bandvidden mer jämnt mellan olika
förbindelser, men om det är för lågt så ökar overeden från IP och TCP.
<p>
Sätt det till ett värde som är aningens lägre än en jämn multipel av
ditt nätverks MTU (normala ethernetförbindelser har en MTU på 1500)
" );
|
199d03 | 1999-09-05 | Francesco Chemolli | |
defvar("req_throttle", 0,
|
4d1683 | 1999-11-17 | Per Hedbor | | "Bandwidth Throttling: Request: Enabled", TYPE_FLAG,
|
199d03 | 1999-09-05 | Francesco Chemolli | | #"If set, per-request bandwidth throttling will be enabled."
);
|
4d1683 | 1999-11-17 | Per Hedbor | |
|
e6f83d | 2000-03-06 | Peter Bortas | |
|
4d1683 | 1999-11-17 | Per Hedbor | | deflocaledoc( "svenska", "req_throttle",
"Bandviddsbegränsning: Förbindelsenivå: På",
"Om på så begränsas bandvidden individuellt på förbindelser"
);
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
199d03 | 1999-09-05 | Francesco Chemolli | | defvar("req_throttle_min", 1024,
|
4d1683 | 1999-11-17 | Per Hedbor | | "Bandwidth Throttling: Request: Minimum guarranteed bandwidth",
|
199d03 | 1999-09-05 | Francesco Chemolli | | TYPE_INT,
#"The maximum bandwidth each connection (in bytes/sec) can use is determined
|
10c7e1 | 1999-12-28 | Martin Nilsson | | combining a number of modules. But doing so can lead to too small
|
199d03 | 1999-09-05 | Francesco Chemolli | | or even negative bandwidths for particularly unlucky requests. This variable
guarantees a minimum bandwidth for each request",
0,arent_we_throttling_request);
|
10c7e1 | 1999-12-28 | Martin Nilsson | |
|
e6f83d | 2000-03-06 | Peter Bortas | |
|
4d1683 | 1999-11-17 | Per Hedbor | | deflocaledoc( "svenska", "req_throttle_min",
"Bandviddsbegränsning: Förbindelsenivå: Minimal bandvidd",
|
10c7e1 | 1999-12-28 | Martin Nilsson | | #"Den maximala bandvidden som varje förbindelse får bestäms av en kombination
|
4d1683 | 1999-11-17 | Per Hedbor | | av de bandviddsbegränsningsmoduler som är adderade i servern. Men ibland
|
10c7e1 | 1999-12-28 | Martin Nilsson | | så blir det framräknade värdet väldigt lågt, och en del riktigt otursamma
|
4d1683 | 1999-11-17 | Per Hedbor | | förbindelser kan råka hamna på 0 eller mindre bytes per sekund. <p>Den
här variablen garanterar en vis minimal bandvidd för alla requests"
);
|
199d03 | 1999-09-05 | Francesco Chemolli | | defvar("req_throttle_depth_mult", 60.0,
|
4d1683 | 1999-11-17 | Per Hedbor | | "Bandwidth Throttling: Request: Bucket Depth Multiplier",
|
199d03 | 1999-09-05 | Francesco Chemolli | | TYPE_FLOAT,
|
10c7e1 | 1999-12-28 | Martin Nilsson | | #"The average bandwidth available for each request will be determined by
|
199d03 | 1999-09-05 | Francesco Chemolli | | the modules combination. The bucket depth will be determined multiplying
the rate by this factor.",
0,arent_we_throttling_request);
|
e6f83d | 2000-03-06 | Peter Bortas | |
|
4d1683 | 1999-11-17 | Per Hedbor | | deflocaledoc( "svenska", "req_throttle_depth_mult",
"Bandviddsbegränsning: Förbindelsenivå: Hinkstorlek",
|
10c7e1 | 1999-12-28 | Martin Nilsson | | #"Den genomsnittliga bandvidden som varje förbindelse bestäms av
|
4d1683 | 1999-11-17 | Per Hedbor | | de adderade bandvidsbegränsningsmodulerna. Hinkstorleken bestäms genom att
multiplicera detta värde med den här faktorn.");
|
94d475 | 2000-04-05 | Martin Nilsson | | defvar("ZNoSuchFile", #"
<html><head>
<title>404 - Page not found</title>
</head>
<body alink=\"#000000\" bgcolor=\"#ffffff\" bottommargin=\"0\" leftmargin=\"0\" link=\"#ce5c00\" marginheight=\"2\" marginwidth=\"0\" rightmargin=\"0\" text=\"#333333\" topmargin=\"2\" vlink=\"#ce5c00\">
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td><img src=\"/internal-roxen-page-not-found\" border=\"0\" alt=\"Page not found\" hspace=\"2\" /></td>
<td> </td>
<td align=\"right\"><b>&roxen.version;</b></td>
</tr>
<tr>
<td width=\"100%\" height=\"21\" colspan=\"3\" background=\"/internal-roxen-tile\"><img src=\"/internal-roxen-unit\" alt=\"\" /></td>
</tr>
</table>
<font face=\"lucida,helvetica,arial\">
<h2> Unable to retrieve &page.virtfile;.</h2>
<br /><br />
<blockquote>
If you feel that this is a configuration error,
please contact the administrators or the author
of the
<if referrer>
<a href=\"&client.referrer;\">referring</a>
</if><else>
referring
</else>
page.
</blockquote>
</font>
</body>
",
|
a7e39f | 2000-02-04 | Per Hedbor | | "Messages: No such file",TYPE_TEXT_FIELD,
"What to return when there is no resource or file available "
"at a certain location.");
|
e6f83d | 2000-03-06 | Peter Bortas | | deflocaledoc("deutsch", "ZNoSuchFile",
"Mitteilungen: Datei nicht gefunden",
#"Dieser Text wird angezeigt, wenn eine nicht verfügbare Datei
aufgerufen wird. '$File' wird ersetzt durch den Dateinamen,
'$Me' durch die Server-URL");
|
a7e39f | 2000-02-04 | Per Hedbor | | deflocaledoc("svenska", "ZNoSuchFile",
"Meddelanden: Filen finns inte",
#"Det här meddelandet returneras om en användare frågar efter en
resurs som inte finns. '$File' byts ut mot den efterfrågade
resursen, och '$Me' med serverns URL");
|
c45e3f | 2000-02-16 | Per Hedbor | | definvisvar( "no_delayed_load", 0, TYPE_FLAG );
|
a7e39f | 2000-02-04 | Per Hedbor | |
|
c5e096 | 1999-10-04 | Per Hedbor | | setvars(retrieve("spider#0", this_object()));
|
199d03 | 1999-09-05 | Francesco Chemolli | |
|
07c992 | 1999-11-23 | Per Hedbor | | if (query("throttle"))
|
c5e096 | 1999-10-04 | Per Hedbor | | {
|
199d03 | 1999-09-05 | Francesco Chemolli | | throttler=.throttler();
throttler->throttle(query("throttle_fill_rate"),
query("throttle_bucket_depth"),
query("throttle_min_grant"),
query("throttle_max_grant"));
}
}
int arent_we_throttling_server () {
return !query("throttle");
}
int arent_we_throttling_request() {
return !query("req_throttle");
|
14179b | 1997-01-29 | Per Hedbor | | }
|
b6fb05 | 1999-11-02 | Per Hedbor | |
string _sprintf( )
{
return "Configuration("+name+")";
}
|