Roxen.git
/
server
/
base_server
/
mainconfig.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/base_server/mainconfig.pike:1:
inherit "config/builders";
-
string cvs_version = "$Id: mainconfig.pike,v 1.
12
1996/12/
02
16
:
31
:
31
per Exp $";
+
string cvs_version = "$Id: mainconfig.pike,v 1.
13
1996/12/
03
00
:
51
:
46
per Exp $";
inherit "roxenlib"; inherit "config/draw_things"; #include <confignode.h> #include <module.h>
-
#define
BODY
(roxen->variables->BG[VAR_VALUE]?
"
<body background=/image/background.jpg bgcolor=
#
f0e0a0
text=#000000
link=#0000f0 vlink=#0000f0 alink=#00f000>
"
:
"
<body>")
-
//
#define
BODY
"
<body bgcolor=#ffeeaa text=#000000 link=#0000f0 vlink=#0000f0 alink=#00f000>
"
+
#define
dR
"
00"
+
#
define
dG
"
20
"
+
#define
dB
"
ff
"
-
+
#define bdR "00"
+
#define bdG "30"
+
#define bdB "70"
+
+
+
#define BODY "<body bgcolor=#002050 text=#ffffff link=#ffffaa vlink=#ffffaa alink=#f0e0f0>"
+
#define TABLEP(x, y) (id->supports->tables ? x : y) int bar=time(1); program Node = class { inherit "struct/node"; mixed original; int changed;
Roxen.git/server/base_server/mainconfig.pike:29:
changed += i; if(up) up->change(i); } private string show_me(string s) { string name=path(1); if(folded) return ("<a name=\""+name+"\">" "<a href=\"/(unfold)/" + name + "?"+(bar++)+
-
"\"><img border=0 src=/
image
/unfold"
-
+(changed?"2":"")+"
.gif
alt="+(changed?"*-":"--")+">"
+
"\"><img border=0
align=baseline
src=/
auto
/unfold"
+
+(changed?"2":"")+" alt="+(changed?"*-":"--")+">"
"</a> "+s); else return ("<a name=\""+name+"\">" "<a href=\"/(fold)/" + name + "?"+(bar++)+
-
"\"><img border=0 src=/
image
/fold"+(changed?"2":"")
-
+"
.gif
align=top
alt="+(changed?"**":"\"\\/\"")+">"
+
"\"><img border=0 src=/
auto
/fold"+(changed?"2":"")
+
+" alt="+(changed?"**":"\"\\/\"")+">"
"</a> "+s); } string describe(int i) { string res=""; object node,prevnode; mixed tmp; if(describer)
Roxen.git/server/base_server/mainconfig.pike:132:
void create() { build_root(root); init_ip_list(); call_out(init_ip_list, 0); } #define PUSH(X) do{res+=({(X)});}while(0)
-
#define BUTTON(ACTION,TEXT,ALIGN) PUSH("<a href=\"/(ACTION)"+(o?o->path(1):"")+"?"+(bar++)+"\"><img border=0 hspacing=0 vspacing=0 src=/auto/button/"+replace(TEXT," ","%20")+" alt=\""+TEXT+"\""+(("ALIGN"-" ")=="left"?"":" align="+("ALIGN"-" "))+"></a>")
+
#define BUTTON(ACTION,TEXT,ALIGN) PUSH("<a href=\"/(ACTION)"+(o?o->path(1):"
/
")+"?"+(bar++)+"\"><img border=0 hspacing=0 vspacing=0 src=/auto/button/"+replace(TEXT," ","%20")+" alt=\""+TEXT+"\""+(("ALIGN"-" ")=="left"?"":" align="+("ALIGN"-" "))+"></a>")
inline string shutdown_restart(string save, int compact,void|object o) {
-
array
res = ({});
-
-
-
PUSH(
"<br clear=all>
<table width=100%><tr><td bgcolor=#7f7755>
"
);
-
-
if(save)
-
BUTTON(save, "Save current configuration", left);
-
BUTTON(restart, "Restart Roxen", left);
-
BUTTON(shutdown,"Shutdown Roxen", left);
-
PUSH("<img src=
/
auto/button/%20>
"
);
-
PUSH(
"
</table>")
;
-
return res*"";
+
return
/*
"<br clear=all>"
*
/"";
} string default_head(string h, string|void save) {
-
return ("<title>"+h+"</title>"
-
+ BODY
-
+ (roxen->variables->BS[VAR_VALUE]?
-
("<h2 align=center>"+shutdown_restart(save, 1
)
+h+"</h2>"):
-
("<h1 align=center><img align=left alt=\""
-
+h+"\" src=/image/roxen.gif></h1>"
-
+shutdown_restart(save, 0)))
-
+ "<br clear=all>")
;
+
return ("<title>"+h+"</title>"+ BODY);
} object find_node(string l) { array tmp = l/"/"-({""}); object o; if(!sizeof(tmp)) return root; for(o=root; sizeof(tmp) && (o=o->descend(tmp[0],1)); tmp=tmp[1..1000]); if(!o) return 0; roxen->current_configuration = o->config();
Roxen.git/server/base_server/mainconfig.pike:770:
roxen->QUERY(ConfigurationUser) = id->variables->user; n2 = node->descend("Configuration interface", 1)->descend("Password", 1); n2->data[VAR_VALUE]=roxen->QUERY(ConfigurationPassword); n2->change(1); n2 = node->descend("Configuration interface", 1)->descend("User", 1); n2->data[VAR_VALUE] = roxen->QUERY(ConfigurationUser); n2->change(1);
-
-
if(strlen(id->variables->pattern))
-
{
-
node = node->descend("Configuration interface", 1)->descend("IP-Pattern", 1);
-
node->folded=0;
-
node->data[VAR_VALUE] = id->variables->pattern;
-
node->change(1);
-
}
+
root->save(); return std_redirect(root, id); } } res = default_head("Welcome to Roxen Challenger") + "<hr noshade>"; res += read_bytes("etc/welcome.html"); if(error && strlen(error)) res += "\n<p><b>"+error+"</b>";
Roxen.git/server/base_server/mainconfig.pike:819:
return node->data; if(node->type == NODE_MODULE_MASTER_COPY) return node->data->master; node = node->up; } return roxen; } string extract_almost_top(object node) {
-
for(;node->up!=root;node=node->up);
+
if(!node) return "";
+
for(;node
&& (node
->up!=root
)
;node=node->up);
+
if(!node) return "";
return node->path(1); }
-
+
+
+
+
string tablist(array(string) nodes, array(string) links, int selected)
+
{
+
array res = ({});
+
for(int i=0; i<sizeof(nodes); i++)
+
if(i!=selected)
+
PUSH("<a href=\""+links[i]+"\"><img alt=\""+nodes[i]+" \" src=/auto/unselected/"+replace(nodes[i]," ","%20")+" border=0></a>");
+
else
+
PUSH("<a href=\""+links[i]+"\"><img alt=\""+nodes[i]+" \" src=/auto/selected/"+replace(nodes[i]," ","%20")+" border=0></a>");
+
PUSH("<br>");
+
return res*"";
+
}
+
mapping (string:string) selected_nodes = ([ "Configurations":"/Configurations", "Globals":"/Globals", "Status":"/Status", "Errors":"/Errors", ]);
-
array
tabs = ({
-
({
"Configurations",
read_bytes("etc/tablists/1.html") }),
-
({
"Globals",
read_bytes("etc/tablists/2.html") }),
-
({
"Status",
read_bytes("etc/tablists/3.html") }),
-
({
"Errors",
read_bytes("etc/tablists/4.html") }),
+
constant
tabs = ({
+
"Configurations",
+
"Globals",
+
"Status",
+
"Errors",
});
-
+
constant tab_names = ({
+
"Virtual servers",
+
"Global variables",
+
"Status info",
+
"Error log",
+
});
string display_tabular_header(object node) { string p, s;
-
int i;
+
-
s = extract_almost_top(node)
;
-
s
-
=
"/";
-
string sel = root->descend(s, 1)->path(1)+"?"+(bar++);
+
s = extract_almost_top(node)
-
"/";
selected_nodes[s] = node->path(1);
-
for(i=0;i<sizeof(tabs);i++)
-
if(s
=
=tabs[i][0])
-
return replace
(
tabs[i][1],
-
(
{
"@servers", "@globals", "@status", "@debug" }),
-
({
-
(i==0?sel:
selected_nodes[
"Configurations"
]+"?"
+bar++
),
-
(i==1?sel:
selected_nodes[
"Globals"
]+"?"
+bar++
),
-
(i==2?sel:
selected_nodes[
"Status"
]+"?"
+bar++
),
-
(i==3?sel:
selected_nodes[
"Errors"
]+"?"
+bar++
),
-
})
)
;
-
return (
""
);
+
array
links
= ({
+
selected_nodes[
tabs[0
]
]
+"?"
+(bar++
),
+
selected_nodes[
tabs[1
]
]
+"?"
+(bar++
),
+
selected_nodes[
tabs[2
]
]
+"?"
+(bar++
),
+
selected_nodes[
tabs[3
]
]
+"?"
+(bar++
),
+
});
+
return
tablist
(
tab_names, links, search(tabs,s
)
)
;
} // Return the number of unfolded nodes on the level directly below the passed // node. int nunfolded(object o) { int i; if(o = o->down) do { i+=!o->folded; } while(o=o->next); return i; }
-
object module_font = Font()->load("fonts/32/
urw
_
itc_avant_garde-demi-r
");
+
object module_font = Font()->load("fonts/32/
configuration
_
font
");
object button_font = module_font; mapping auto_image(string in, object id) { string key, value;
-
+
array trans = ({ (int)("0x"+dR),(int)("0x"+dG),(int)("0x"+dB) });
mapping r; mixed e;
-
sscanf(in, "%s/%s", key, value);
+
object i;
+
+
if(!id->pragma["no-cache"] && (r=cache_lookup("config_images", in)))
+
return r;
+
if(!
sscanf(in, "%s/%s", key, value)
)
+
key=in
;
+
switch(key) { case "module":
-
if(!id->pragma["no-cache"]
&& (r
=
cache_lookup("module_images",
value)))
-
return r;
-
if(e=catch {
-
r = http_string_answer(
draw_module_header(roxen->allmodules[value][0],
+
i
= draw_module_header(roxen->allmodules[value][0],
roxen->allmodules[value][2],
-
module_font)
-
->togif(64), "image/gif")
;
-
})
-
perror("While drawing auto-image: \n"+describe_backtrace(e)+"\n")
;
-
cache_set("module_images", value, r);
-
return r;
+
module_font);
+
break
;
case "button":
-
if(!id->pragma["no-cache"] && (r
=
cache_lookup("config_button_image", value)))
-
return r;
-
if(e=catch {
-
r = http_string_answer(
draw_config_button(value,button_font)
->togif(32),
-
"image/gif")
;
-
})
-
perror("While drawing auto-image: \n"+describe_backtrace(e)+"\n")
;
-
cache_set("config_button_image", value, r);
-
return r;
+
i
=draw_config_button(value,button_font);
+
break
;
-
+
case "fold":
+
case "fold2":
+
i = draw_fold((int)reverse(key));
+
break;
+
+
case "unfold":
+
case "unfold2":
+
i = draw_unfold((int)reverse(key));
+
break;
+
+
case "back":
+
i = draw_back((int)reverse(key));
+
break;
+
+
case "selected":
+
i=draw_selected_button(value,button_font);
+
break;
+
+
case "unselected":
+
i=draw_unselected_button(value,button_font);
+
break;
}
-
+
if(i) r = http_string_answer(i->togif(128,@trans),"image/gif");
+
i=0;
+
cache_set("config_images", in, r);
+
return r;
} mapping configuration_parse(object id) { array (string) res=({}); string tmp; // Is it an image? if(sscanf(id->not_query, "/image/%s", tmp)) return file_image(tmp) || (["data":"No such image"]);
Roxen.git/server/base_server/mainconfig.pike:963:
o = find_node(id->not_query); // Find the requested node (from the filename) if(!o) // Bad node, perhaps an old bookmark or something. { id->referer = ({ }); return std_redirect(0, id); } else if(o == root) { // The URL is http://config-url/, not one of the top nodes, but // _above_ them. This is supposed to be some nice introductory // text about the configuration interface...
-
return
stores
(
replace
(
read
_bytes("etc/config.html"),"
rand()
"
,
-
(string
)
time()))
;
+
return
http_string_answer
(
default_head
(
"")+display
_
tabular_header(root)+read_
bytes("etc/config.html"),"
text/html
");
} if(sizeof(id->prestate)) { switch(indices(id->prestate)[0]) { // It is possible to mark variables as 'VAR_EXPERT', this // will make it impossible to configure them whithout the // 'expert' mode. It can be useful. case "expert": expert_mode = 1; break;
Roxen.git/server/base_server/mainconfig.pike:1077:
"configurations/"+id->variables->name); o->data->name=id->variables->name; } break; /* This only asks "do you really want to...", it does not delete * the node */ case "delete": PUSH(default_head("Roxen Configuration"));
-
PUSH("<hr noshade>");
+
//
PUSH("<hr noshade>");
switch(o->type) { case NODE_CONFIGURATION: PUSH("<font size=+2>Do you really want to delete the configuration "+ o->data->name + ", all its modules and their copies?" "\n\n<p></font>"); break; case NODE_MODULE_MASTER_COPY:
Roxen.git/server/base_server/mainconfig.pike:1299:
else if(!o->changed) o->change(1); } break; } return std_redirect(o, id); } PUSH(default_head("Roxen server configuration", root->changed?o->path(1):0)); PUSH("\n"+display_tabular_header( o )+"\n<br>\n");
+
// PUSH("<img src=/image/roxen-rotated.gif alt=\"\" align=right>");
+
PUSH("<dl>\n"); if(o->up != root && o->up) PUSH("<a href=\""+ o->up->path(1)+"?"+(bar++)+"\">"
-
"<img src=/
image
/
up.gif
alt='[Up]' align=left hspace=0 border=0></a> ");
+
"<img src=/
auto
/
back
alt='[Up]' align=left hspace=0 border=0></a> ");
if(i=o->folded) o->folded=0; PUSH(o->describe(1)); o->folded=i;
-
PUSH("</dl>
\n\n<p>
");
+
PUSH("</dl>");
// PUSH("<nobr><img height=15 src=/auto/button/ width=100% align=right>");
-
PUSH("<table width=100%><tr><td bgcolor=#
7f7755
>");
+
PUSH("<
br clear=all>");
+
PUSH("<
table width=100%><tr><td bgcolor=#
"+bdR+bdG+bdB+"
>");
PUSH("<img src=/auto/button/>"); if(o->type == NODE_CONFIGURATIONS) BUTTON(newconfig, "New virtual server", left); if(o->type == NODE_CONFIGURATION) BUTTON(newmodule, "New module", left); if(o->type == NODE_MODULE) {
-
BUTTON(delete, "Delete
module and copies
", left);
+
BUTTON(delete, "Delete", left);
if(o->data->copies)
-
BUTTON(newmodulecopy, "
New
module
copy
", left);
+
BUTTON(newmodulecopy, "
Copy
module", left);
} i=0; if(o->type == NODE_MODULE_MASTER_COPY || o->type == NODE_MODULE_COPY || o->type == NODE_MODULE_COPY_VARIABLES) {
-
BUTTON(delete, "Delete
module
", left);
-
BUTTON(refresh, "Reload
module
", left);
+
BUTTON(delete, "Delete", left);
+
BUTTON(refresh, "Reload", left);
} if(o->type == NODE_CONFIGURATION) BUTTON(delete,"Remove virtual server", left); if(nunfolded(o)) BUTTON(foldall, "Close all",left); if(o->changed) BUTTON(unfoldmodified, "Open all modified", left);
-
+
if((o->changed||root->changed))
+
BUTTON(save, "Save changes", left);
+
BUTTON(restart, "Restart", left);
+
BUTTON(shutdown,"Shutdown", left);
+
+
PUSH("<img src=/auto/button/%20>"); PUSH("</nobr><br clear=all>"); PUSH("</td></tr></table>"); PUSH("<p align=right><a href=$docurl>"+roxen->real_version +"</a></body>"); return stores(res*""); }