Roxen.git / server / base_server / mainconfig.pike

version» Context lines:

Roxen.git/server/base_server/mainconfig.pike:1:   inherit "config/builders"; - string cvs_version = "$Id: mainconfig.pike,v 1.18 1996/12/04 07:38:23 per Exp $"; + string cvs_version = "$Id: mainconfig.pike,v 1.19 1996/12/04 09:40:03 per Exp $";   inherit "roxenlib";   inherit "config/draw_things";      #include <confignode.h>   #include <module.h>      #define dR "00"   #define dG "20"   #define dB "50"      #define bdR "00"   #define bdG "50"   #define bdB "90"         #define BODY "<body bgcolor=#002050 text=#ffffff link=#ffffaa vlink=#ffffaa alink=#f0e0f0>"      #define TABLEP(x, y) (id->supports->tables ? x : y) -  + #define PUSH(X) do{res+=({(X)});}while(0)      int bar=time(1);    - program Node = class { + class Node {    inherit "struct/node";       mixed original;    int changed;       int bar=previous_object()->bar;    function saver = lambda(object o) { if(o->changed) o->change(-o->changed); };       string|array error;       void change(int i)    {    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 align=baseline src=/auto/unfold" -  +(changed?"2":"")+" alt="+(changed?"*-":"--")+">" -  "</a> "+s); +  return ("<a name=\""+name+"\">\n" +  "<a href=\"/(unfold)" + name + "?"+(bar++)+ +  "\">\n<img border=0 align=baseline src=/auto/unfold" +  +(changed?"2":"")+" alt=\""+(changed?"*-":"--")+"\">" +  "</a>\n "+s+"\n");    else -  return ("<a name=\""+name+"\">" -  "<a href=\"/(fold)/" + name + "?"+(bar++)+ -  "\"><img border=0 src=/auto/fold"+(changed?"2":"") +  return ("<a name=\""+name+"\">\n" +  "<a href=\"/(fold)" + name + "?"+(bar++)+ +  "\">\n<img border=0 src=/auto/fold"+(changed?"2":"")    +" alt="+(changed?"**":"\"\\/\"")+">" -  "</a> "+s); +  "</a>\n "+s+"\n");    }       string describe(int i)    { -  string res=""; +  array (string) res=({""});    object node,prevnode;    mixed tmp;       if(describer)    tmp = describer(this_object());   #ifdef NODE_DEBUG    else    perror("No describer in node "+path(1)+"\n");   #endif    if(arrayp(tmp) && sizeof(tmp)) -  res += tmp[0] + "<dt>" + (!i?show_me(tmp[1]):tmp[1]) + "\n\n"; +  PUSH(tmp[0] + (!i?"<dt>"+show_me(tmp[1]):tmp[1]) + "\n");    else if(stringp(tmp) && strlen(tmp)) -  res += "<dt>" + (i?tmp:show_me(tmp)) + "\n\n"; +  PUSH((i?tmp:"<dt>"+show_me(tmp)) + "\n");    else if(!tmp)    return "";    -  if(!i && strlen(res)) -  res += "<dd>"; -  else if(strlen(res)) -  res += "<p>"; -  +     if(!folded)    {    int sdl = 0; /* Add slash-dl to the end.. */    -  if(!i && strlen(res)) -  { -  sdl = 1; -  res += "<dl>\n\n"; -  } +  PUSH("<dl><dd>\n");    node = down;    while(node)    {    if(!objectp(node)) // ERROR! Destructed node in tree!    {    if(objectp(prevnode))    prevnode->next=0;    node=0;    break;    }    prevnode = node;    node = node->next; -  res += prevnode->describe(); +  PUSH(prevnode->describe()); + // PUSH("<br>");    } -  if(sdl) -  res += "</dl>\n\n"; +  PUSH("</dl>\n\n");    } -  return res; +  return res*"";    }          object config()    {    object node;    node=this_object();    while(node)    if(node->type == NODE_CONFIGURATION)    return node->data;
Roxen.git/server/base_server/mainconfig.pike:126:    node=down;       // depth-first save.    while(node)    {    if(node->changed) node->save();    node=node->next;    }    if(saver) saver(this_object());    } - }; + }      object root=Node();   int expert_mode;         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) do{PUSH("<a href=\"/(ACTION)"+(o?o->path(1):"/")+"?"+(bar++)+"\"><img border=0 hspacing=0 vspacing=0 src=/auto/button/"+(lm?"lm/":"")+replace(TEXT," ","%20")+" alt=\""+TEXT+"\""+(("ALIGN"-" ")=="left"?"":" align="+("ALIGN"-" "))+"></a>");lm=0;}while(0) + #define BUTTON(ACTION,TEXT,ALIGN) do{PUSH("<a href=\"/(ACTION)"+(o?o->path(1):"/")+"?"+(bar++)+"\"><img border=0 hspacing=0 vspacing=0 src=/auto/button/"+(lm?"lm/":"")+replace(TEXT," ","%20")+" alt=\""+(lm?"/ ":" ")+TEXT+" /\""+(("ALIGN"-" ")=="left"?"":" align="+("ALIGN"-" "))+"></a>");lm=0;}while(0)      inline string shutdown_restart(string save, int compact,void|object o)   {    return /*"<br clear=all>"*/"";   }      string default_head(string h, string|void save)   { -  return ("<title>"+h+"</title>"+ BODY); +  return ("<head><title>"+h+"</title></head>\n"+ BODY+"\n");   }      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:423:    object o;    foreach(roxen->configurations, o)    res += "<option>Copy of '"+o->name+"'";    return res;   }      string new_configuration_form()   {    return replace(default_head("")+read_bytes("etc/newconfig.html"), ({"$COPIES","$configurl"}),    ({configuration_list(),CONFIG_URL})) + -  "\n\n<hr noshade><p align=right><a href=http://www.roxen.com/>"+ -  roxen->real_version +"</a></body>"; +  "\n\n</body>";   }      mapping module_nomore(string name, int type, object conf)   {    mapping module;    object o;   // perror("Module: "+name+"\n");    if((module = conf->modules[name])    && (!module->copies && module->enabled))    return module;
Roxen.git/server/base_server/mainconfig.pike:814:   }               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>"); +  PUSH("<a href=\""+links[i]+"\"><img alt=\"/"+nodes[i][1..strlen(nodes[i])-2]+"\\_\" 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("<a href=\""+links[i]+"\"><b><img alt=\"/"+nodes[i][1..strlen(nodes[i])-2]+"\\_\" src=/auto/selected/"+replace(nodes[i]," ","%20")+" border=0></b></a>");    PUSH("<br>");    return res*"";   }      mapping (string:string) selected_nodes =   ([    "Configurations":"/Configurations",    "Globals":"/Globals",    "Status":"/Status",    "Errors":"/Errors",
Roxen.git/server/base_server/mainconfig.pike:932:    break;    }    i->map_closest(i->select_colors(64)+({trans}));    if(i) r = http_string_answer(i->togif(@trans),"image/gif");    i=0;    cache_set("config_images", in, r);    return r;   }       + string remove_font(string t, mapping m, string c) + { +  return "<b>"+c+"</b>"; + } +  +    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"]);       object o;    int i;
Roxen.git/server/base_server/mainconfig.pike:1316:    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=/auto/back alt='[Up]' align=left hspace=0 border=0></a> "); +  "<img src=/auto/back alt='[Up]' align=left hspace=0 border=0></a>\n");       if(i=o->folded) o->folded=0; -  PUSH(o->describe(1)); +  string tmp = o->describe(1); +  if(!id->supports->font) +  tmp = parse_html(tmp, ([]),(["font":remove_font, ])); +  PUSH(tmp);    o->folded=i;    -  PUSH("</dl>"); - // PUSH("<nobr><img height=15 src=/auto/button/ width=100% align=right>"); -  PUSH("<br clear=all>"); - // PUSH("<table width=100%><tr><td bgcolor=#"+bdR+bdG+bdB+">"); +  PUSH("<br clear=all>\n");       int lm=1;       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)
Roxen.git/server/base_server/mainconfig.pike:1370:    BUTTON(foldall, "Close all",left);    if(o->changed)    BUTTON(unfoldmodified, "Open modified", left);       if((o->changed||root->changed))    BUTTON(save, "Save", left);    BUTTON(restart, "Restart", left);    BUTTON(shutdown,"Shutdown", left);       -  PUSH("<img border=0 hspacing=0 vspacing=0 src=/auto/button/rm/%20>"); -  +  PUSH("<img border=0 alt=\"\" hspacing=0 vspacing=0 src=/auto/button/rm/%20>");    PUSH("</nobr><br clear=all>"); - // PUSH("</td></tr></table>"); -  PUSH("<p align=right><a href=$docurl>"+roxen->real_version +"</a></body>"); + // PUSH("<a href=$docurl>"+roxen->real_version +"</a>" +  PUSH("</body>\n");    return stores(res*"");   }