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.11 1996/12/02 14:43:02 per Exp $"; + string cvs_version = "$Id: mainconfig.pike,v 1.12 1996/12/02 16:31:31 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 TABLEP(x, y) (id->supports->tables ? x : y)
Roxen.git/server/base_server/mainconfig.pike:131:   int expert_mode;         void create()   {    build_root(root);    init_ip_list();    call_out(init_ip_list, 0);   }    - inline string shutdown_restart(string save, int compact) + #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>") +  + inline string shutdown_restart(string save, int compact,void|object o)   { - #define CBR (compact?"":"<br clear=right>\n") +  array res = ({});    -  return -  ("<a href=/(shutdown)/Configurations/?"+(bar++)+">" -  "<img src=/image/shutdown.gif alt=Kill hspace=0 border=0 align=right>" -  "</a>") -  + CBR -  + ("<a href=/(restart)/Configurations/?"+(bar++)+">" -  "<img src=/image/restart.gif alt=Restart hspace=0 border=0 align=right>" -  "</a>") -  + CBR -  + (save? -  ("<a href=/(save)"+ save +"?"+(bar++)+ ">" -  "<img src=/image/save.gif alt=Save hspace=0 border=0 align=right>" -  "</a>"):""); +  +  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*"";   }      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>"
Roxen.git/server/base_server/mainconfig.pike:876:   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 button_font = module_font;      mapping auto_image(string in, object id)   {    string key, value;    mapping r;    mixed e;    sscanf(in, "%s/%s", key, value);    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],    roxen->allmodules[value][2],    module_font)    ->togif(64), "image/gif");    })    perror("While drawing auto-image: \n"+describe_backtrace(e)+"\n"); -  cache_set("module_images", key, r); +  cache_set("module_images", value, r);    return r; -  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; +     }   }    -  +    mapping configuration_parse(object id)   { -  string res; +  array (string) res=({}); +  string tmp;    // Is it an image? -  if(sscanf(id->not_query, "/image/%s", res)) -  return file_image(res) || (["data":"No such image"]); +  if(sscanf(id->not_query, "/image/%s", tmp)) +  return file_image(tmp) || (["data":"No such image"]);       object o;    int i;       id->since = 0; // We do not want 'get-if-modified-since' to work here.          // Permisson denied by address?    if(id->remoteaddr)    if(strlen(roxen->QUERY(ConfigurationIPpattern)) &&
Roxen.git/server/base_server/mainconfig.pike:936:    else if(!conf_auth_ok(id->auth))    return http_auth_failed("Roxen server maintenance"); // Denied    } else {    id->prestate = aggregate_multiset(@indices(id->prestate)    &({"fold","unfold"}));       if(sizeof(id->variables)) // This is not 100% neccesary, really.    id->variables = ([ ]);    }    -  if(sscanf(id->not_query, "/auto/%s", res)) -  return auto_image(res,id) || (["data":"No such image"]); +  if(sscanf(id->not_query, "/auto/%s", tmp)) +  return auto_image(tmp,id) || (["data":"No such image"]);       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
Roxen.git/server/base_server/mainconfig.pike:1062:    mv("configurations/"+o->data->name,    "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": -  res = default_head("Roxen Configuration")+ "<hr noshade>"; +  PUSH(default_head("Roxen Configuration")); +  PUSH("<hr noshade>");       switch(o->type)    {    case NODE_CONFIGURATION: -  res += ("<font size=+2>Do you really want to delete the configuration " -  + o->data->name + ", all its modules and their copies?" +  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:    case NODE_MODULE: -  res += ("<font size=+2>Do you really want to delete the module " -  + o->data->name + ", and its copies?" -  "\n\n<p></font>"); +  PUSH("<font size=+2>Do you really want to delete the module "+ +  o->data->name + ", and its copies?\n\n<p></font>");    break;       case NODE_MODULE_COPY_VARIABLES:       case NODE_MODULE_COPY: -  res += ("<font size=+2>Do you really want to delete this copy " +  PUSH("<font size=+2>Do you really want to delete this copy "    " of the module "+ o->up->data->name + "?\n\n<p></font>"); -  +     break;       case NODE_CONFIGURATIONS:    return stores("You don't want to do that...\n");    } -  res += ("<font size=+2><i>This action cannot be undone.\n\n<p></font>" -  + TABLEP("<table>", "") +"<tr><td><form action="+ +  PUSH("<font size=+2><i>This action cannot be undone.\n\n<p></font>"+ +  TABLEP("<table>", "") +"<tr><td><form action="+    o->path(1)+">"    "<input type=submit value=\"No, I do not want to delete it\"> " -  "</form></td><td><form action=/(really_delete)"+o->path(1) -  + "><input type=submit value=\"Go ahead\"></form></td></tr> " +  "</form></td><td><form action=/(really_delete)"+o->path(1)+ +  "><input type=submit value=\"Go ahead\"></form></td></tr> "    "</table>");    -  return stores(res); +  return stores(res*"");    break;       /* When this has been called, the node will be * _very_ deleted    * The amount of work needed to delete a node does vary    * depending on the node, since there is no 'zap' function in    * the nodes at the moment. I will probably move this code into    * function-pointers in the nodes.    */       case "really_delete":
Roxen.git/server/base_server/mainconfig.pike:1284:    if(equal(o->original, tmp))    o->change(-1);    else if(!o->changed)    o->change(1);    }    break;    }    return std_redirect(o, id);    }    -  res = (default_head("Roxen server configuration", -  root->changed?o->path(1):0) -  + "\n" + display_tabular_header( o ) + "\n<br>\n" -  + "<dl>\n"); +  PUSH(default_head("Roxen server configuration", root->changed?o->path(1):0)); +  PUSH("\n"+display_tabular_header( o )+"\n<br>\n"); +  PUSH("<dl>\n");       if(o->up != root && o->up) -  res += ("<a href=\""+ o->up->path(1)+"?"+(bar++)+"\">" +  PUSH("<a href=\""+ o->up->path(1)+"?"+(bar++)+"\">"    "<img src=/image/up.gif alt='[Up]' align=left hspace=0 border=0></a> ");       if(i=o->folded) o->folded=0; -  res += o->describe(1) ; +  PUSH(o->describe(1));    o->folded=i;    -  res += "</dl>\n\n<p>"; +  PUSH("</dl>\n\n<p>"); + // PUSH("<nobr><img height=15 src=/auto/button/ width=100% align=right>"); +  PUSH("<table width=100%><tr><td bgcolor=#7f7755>"); +  PUSH("<img src=/auto/button/>");    -  if(nunfolded(o)) -  res += ("<a href=\"/(foldall)"+o->path(1)+"?"+(bar++)+"\">" -  "<img src=/image/foldall.gif align=left hspace=0 border=0" -  " height=19 alt=\"Close all\">" -  "</a>"); -  +     if(o->type == NODE_CONFIGURATIONS) -  res += ("<a href=/(newconfig)/Configurations?"+(bar++)+">" -  "<img src=/image/newconf.gif align=left hspace=0 border=0" -  " height=19 alt=\"Add virtual server\">" -  "</a>"); +  BUTTON(newconfig, "New virtual server", left);       if(o->type == NODE_CONFIGURATION) -  res += ("<a href=\"/(newmodule)"+o->path(1)+"?"+(bar++)+"\">" -  "<img src=/image/newmod.gif align=left hspace=0 border=0" -  " height=19 alt=\"Add a module\">" -  "</a>"); +  BUTTON(newmodule, "New module", left);       if(o->type == NODE_MODULE)    { -  res += ("<a href=\"/(delete)"+o->path(1)+"?"+(bar++)+"\">" -  "<img src=/image/delmodcop.gif align=left hspace=0 border=0" -  " height=19 alt=\"Remove this module and it's copies\">" -  "</a>"); +  BUTTON(delete, "Delete module and copies", left);    if(o->data->copies) -  { -  res += ("<a href=\"/(newmodulecopy)"+o->path(1)+"?"+(bar++)+"\">" -  "<img src=/image/newmod.gif align=left hspace=0 border=0" -  " height=19 alt=\"Add a new copy\">" -  "</a>"); +  BUTTON(newmodulecopy, "New module copy", left);    } -  } +        i=0;    if(o->type == NODE_MODULE_MASTER_COPY || o->type == NODE_MODULE_COPY    || o->type == NODE_MODULE_COPY_VARIABLES)    { -  res += ("<a href=\"/(delete)"+o->path(1)+"?"+(bar++)+"\">" -  "<img src=/image/delmod.gif align=left hspace=0 border=0" -  " height=19 alt=\"Remove this module\">" -  "</a>") -  + ("<a href=\"/(refresh)"+o->path(1)+"?"+(bar++)+"\">" -  "<img src=/image/refresh.gif align=left hspace=0 border=0" -  " height=19 alt=\"Refresh\">" -  "</a>"); -  i++; +  BUTTON(delete, "Delete module", left); +  BUTTON(refresh, "Reload module", left);    }       if(o->type == NODE_CONFIGURATION) -  { -  res += ("<a href=\"/(delete)"+o->path(1)+"?"+(bar++)+"\">" -  "<img src=/image/delconf.gif align=left hspace=0 border=0" -  " height=19 alt=\"Remove this configuration\">" -  "</a>"); -  i++; -  } +  BUTTON(delete,"Remove virtual server", left);    -  +  if(nunfolded(o)) +  BUTTON(foldall, "Close all",left);    if(o->changed) -  { -  res += ("<a href=\"/(unfoldmodified)"+o->path(1)+"?"+(bar++)+"\">" -  "<img src=/image/unmod.gif align=right hspace=0 border=0" -  " height=19 alt=\"Open all modified\">" -  "</a>"); -  } +  BUTTON(unfoldmodified, "Open all modified", left);    -  if(i) -  res += ("<img src=/image/right.gif align=left height=19" -  " hspace=0 border=0 alt=\"\">"); -  -  res += "<hr noshade>"; -  return stores(res+"<p align=right><a href=$docurl>"+ -  roxen->real_version +"</a></body>"); +  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*"");   }