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.49 1997/08/12 09:04:33 per Exp $"; + string cvs_version = "$Id: mainconfig.pike,v 1.50 1997/08/12 09:06:19 neotron Exp $";   inherit "roxenlib";   inherit "config/draw_things";      import Array;   import Stdio;   string status_row(object node);   string display_tabular_header(object node);      /* Work-around for Simulate.perror */   #define perror roxen_perror
Roxen.git/server/base_server/mainconfig.pike:22:   #define bdG "50"   #define bdB "90"         #define BODY "<body "+(roxen->QUERY(BG)?"--background=/image/background.gif ":"")+"bgcolor=#"+dR+dG+dB+" text=black link=0x000044 vlink=0x000044 alink=red>"      #define TABLEP(x, y) (id->supports->tables ? x : y)   #define PUSH(X) do{res+=({(X)});}while(0)      int bar=time(1); + multiset changed_port_servers;      class Node {    inherit "struct/node";       import Simulate;       mixed original;    int changed, moredocs;       int bar=time();
Roxen.git/server/base_server/mainconfig.pike:126:    {    object node;    node=down;       // depth-first save.    while(node)    {    if(node->changed) node->save();    node=node->next;    } +  if(changed && type == NODE_MODULE_COPY_VARIABLE && +  data[VAR_TYPE] == TYPE_PORTS) { +  roxen->configuration_interface_obj->changed_port_servers[config()] = 1; +  // A port was changed in the current server... +  }    if(saver) saver(this_object());    }   }      object root=Node();   int expert_mode, more_mode;         void create()   {
Roxen.git/server/base_server/mainconfig.pike:171:   }      mapping file_image(string img)   {    object o;    o=open("roxen-images/"+img, "r");    if (!o) return 0;    return ([ "file":o, "type":"image/" + ((img[-1]=='f')?"gif":"jpeg"), ]);   }    - #define CONFIG_URL roxen->config_url() -  - mapping save_it(object id, object o) - { -  id->referer = ({ CONFIG_URL + o->path(1) }); -  root->save(); -  roxen->update_supports_from_roxen_com(); -  roxen->initiate_configuration_port( 0 ); - } -  +    mapping stores( string s )   {    return    ([    "data":replace(s, "$docurl", roxen->docurl),    "type":"text/html",    "extra_heads":    ([    "Title":"Roxen Challenger maintenance",   // "Expires":http_date(time(1)+2),   // "Pragma":"no-cache",    "Last-Modified":http_date(time(1)),    ])    ]);   }    -  + #define CONFIG_URL roxen->config_url() +  + mapping verify_changed_ports(object id, object o) + { +  string res = default_head("Roxen Config: Setting Server URL") + +  ("<h1>Set the correct server URL</h1>" +  "As you have changed the open ports in one or more servers " +  "you might have to adjust the default server URL(s). Check the " +  "correct URL(s) below and modify it as needed." +  "<form action=\"/(modify_server_url)"+o->path(1)+"\">"); +  foreach(indices(changed_port_servers), object server) +  { +  perror("Server %s, URL %s, Ports %O\n", server->name, +  server->query("MyWorldLocation"), +  server->query("Ports")); +  +  string def = server->query("MyWorldLocation"); +  +  res += sprintf("<h3>Select server URL for for %s: </h3>\n" +  "<pre>", server->name); +  +  foreach(server->query("Ports"), array port) { +  string prt; +  if(port[1] == "tetris") +  continue; +  switch(port[1][0..2]) +  { +  case "ssl": +  prt = "https://"; +  break; +  +  default: +  prt = port[1]+"://"; +  } +  if(port[2] && port[2]!="ANY") +  prt += port[2]; +  else +  prt += (gethostname()/".")[0] + "." + server->query("Domain"); +  prt += ":"+port[0]+"/"; +  if(prt != def) +  res += sprintf(" <input type=radio name=\"%s\" value=\"%s\"> %s\n", +  server->name, prt, prt); +  +  } +  res += sprintf(" <input type=radio checked value=own name=\"%s\"> " +  "<input size=70 name=\"%s->own\" " +  "value=\"%s\">\n</pre><p>", +  server->name, server->name, def); +  } +  return stores(res+"<input type=submit value=\"Continue...\"></form>"); + } +  + mapping save_it(object id, object o) + { +  changed_port_servers = (<>); +  id->referer = ({ CONFIG_URL + o->path(1) }); +  root->save(); +  roxen->update_supports_from_roxen_com(); +  roxen->initiate_configuration_port( 0 ); +  if(sizeof(changed_port_servers)) +  return verify_changed_ports(id, o); + } +  +    object find_module(string name, object in)   {    mapping mod;    object o;    string s;    int i;    name = lower_case(name);    if(!sscanf(name, "%s#%d", name, i))    {   #ifdef MODULE_DEBUG
Roxen.git/server/base_server/mainconfig.pike:1400:          // Create a new configuration. All the work is done in another    // function.. This _should_ be the case with some of the other    // actions too.    case "newconfig":    id->referer = ({ CONFIG_URL + o->path(1) });    return new_configuration(id);       +  // When a port has been changed the admin are prompted to +  // change the server URL. This is where we come when we are +  // done. +  +  case "modify_server_url": +  id->referer = ({ CONFIG_URL + o->path(1) }); +  +  string srv, url; +  object thenode; +  foreach(indices(id->variables), string var) +  { +  if(sscanf(var, "%s->own", srv)) { +  url = id->variables[srv] == "own" ? +  id->variables[var] : id->variables[srv]; +  thenode = find_node("/Configurations/"+srv+ +  "/Global/Server URL"); +  if(thenode) { +  thenode->data[VAR_VALUE] = url; +  thenode->change(1); +  thenode->up->save(); +  } +  } +  } +  break;    // Save changes done to the node 'o'. Currently 'o' is the root    // node most of the time, thus saving _everything_.    case "save": -  if(save_it(id, o)) -  return 0; +  mapping cf; +  if(cf = save_it(id, o)) +  return cf;    break;          // Set the password and username, the first time, or when    // the action 'changepass' is requested.    case "initial":    case "changepass":    return initial_configuration(id);