ff3ddf2000-03-20Per Hedbor #include <config_interface.h>
1c783c2000-07-15Andreas Lange #include <roxen.h>
ea0a982000-07-17Andreas Lange 
23414a2000-07-21Andreas Lange //<locale-token project="roxen_config">LOCALE</locale-token> #define LOCALE(X,Y) _DEF_LOCALE("roxen_config",X,Y)
1c783c2000-07-15Andreas Lange 
ff3ddf2000-03-20Per Hedbor 
62a1a62001-08-10Per Hedbor void get_dead( string cfg, int del ) { };
ea0a982000-07-17Andreas Lange string|mapping parse( RequestID id )
ff3ddf2000-03-20Per Hedbor { if( !config_perm( "Create Site" ) )
23414a2000-07-21Andreas Lange  return LOCALE(226, "Permission denied");
ff3ddf2000-03-20Per Hedbor 
7f431f2014-02-24Henrik Grubbström (Grubba)  if (!id->variables->site) return Roxen.http_redirect( "/sites/", id );
ff3ddf2000-03-20Per Hedbor  Configuration cf = roxen->find_configuration( id->variables->site );
62a1a62001-08-10Per Hedbor  if( !cf ) return "No such configuration: "+id->variables->site;
ff3ddf2000-03-20Per Hedbor 
2136682000-09-17Per Hedbor  if( !id->variables["really.x"] ) {
62a1a62001-08-10Per Hedbor  string res =
ea69952001-01-29Per Hedbor  "<use file='/template' />\n"
e3702b2000-09-18Andreas Lange  "<tmpl title=' "+ LOCALE(249,"Drop old site") +"'>" "<topmenu base='&cf.num-dotdots;' selected='sites'/>\n" "<content><cv-split>" "<subtablist width='100%'>" "<st-tabs></st-tabs>"
62a1a62001-08-10Per Hedbor  "<st-page><b><font size=+1>"+
644a732000-09-19Per Hedbor  sprintf((string)(LOCALE(235,"Are you sure you want to disable the site %s?")+"\n"),
62a1a62001-08-10Per Hedbor  (cf->query_name()||""))+ "</font></b><br />"; // 1: Find databases that will be "dead" when this site is gone. mapping q = DBManager.get_permission_map( ); array dead = ({}); foreach( sort( indices( q ) ), string db ) { int ok; foreach( indices(q[db]), string c ) foreach( (roxen->configurations-({cf}))->name, string c ) { if( q[db][c] != DBManager.NONE ) { ok=1; break; } } if( !ok ) dead += ({ db }); }
c517152001-09-03Per Hedbor  // Never ever drop these. dead -= ({ "roxen", "mysql", "local", "replicate" });
66aa4b2001-09-02Per Hedbor 
62a1a62001-08-10Per Hedbor  res += "<b>"+
9fa11d2001-08-24Martin Nilsson  LOCALE(468,"This site listens to the following ports:")+"</b><br />\n";
62a1a62001-08-10Per Hedbor  res += "<ul>\n"; foreach( cf->query( "URLs" ), string url )
21182a2001-10-05Per Hedbor  { url = (url/"#")[0];
62a1a62001-08-10Per Hedbor #if constant(gethostname) res += "<li> "+replace(url,"*",gethostname())+"\n"; #else res += "<li> "+url+"\n"; #endif
21182a2001-10-05Per Hedbor  }
62a1a62001-08-10Per Hedbor  res += "</ul\n>"; if( sizeof( dead ) ) {
9fa11d2001-08-24Martin Nilsson  res += "<b>"+LOCALE(469,"Databases that will no longer be used")+
62a1a62001-08-10Per Hedbor  "</b><br />"; res += "<blockquote>"; if( sizeof( dead ) == 1 )
9fa11d2001-08-24Martin Nilsson  res += LOCALE(470,"If you do not want to delete this database, "
62a1a62001-08-10Per Hedbor  "uncheck the checkmark in front of it");
9909172011-01-20Martin Stjernholm  else { res += "<p>" + LOCALE(471,"If you do not want to delete one or more of these " "databases, uncheck the checkmark in front of the ones" " you want to keep.") + #"</p> <script type='text/javascript'> var check_all_toggle = 0; function checkAll() { var checkboxes = document.getElementById ('checkbox_list').
f1e5ef2012-01-23Jonas Wallden  getElementsByTagName ('INPUT');
9909172011-01-20Martin Stjernholm  for (var i = 0; i < checkboxes.length; i++) {
f1e5ef2012-01-23Jonas Wallden  checkboxes[i].checked = check_all_toggle;
9909172011-01-20Martin Stjernholm  } check_all_toggle = !check_all_toggle; } </script> <p><a id='check_all_button' onClick='checkAll()'><gbutton>" +
f1e5ef2012-01-23Jonas Wallden  LOCALE(1065, "Uncheck/Check All") +
9909172011-01-20Martin Stjernholm  "</gbutton></a></p>\n"; } res += "<ul id='checkbox_list'>";
62a1a62001-08-10Per Hedbor  int n; foreach( dead, string d ) {
3a7aa42005-04-12Anders Johansson  res += "<li style='list-style-image: none; list-style-type: none'>" "<input name='del_db_"+d+"' id='del_db_"+d+"' type=checkbox checked=checked />" "<label for='del_db_"+d+"'>"+d+"</label></li>\n";
62a1a62001-08-10Per Hedbor  }
3a7aa42005-04-12Anders Johansson  res += "</ul>";
62a1a62001-08-10Per Hedbor  res += "</blockquote>"; } // 2: Tables res += ("<input type=hidden name=site value='"+ Roxen.html_encode_string(id->variables->site)+"' />"); res += "<table width='100%'><tr width='100%'>"
e3702b2000-09-18Andreas Lange  "<td align='left'><submit-gbutton2 name='really'> "+ LOCALE(249,"Drop old site") + " </submit-gbutton2></td><td align='right'>"
028f2d2002-04-18Anders Johansson  "<cf-cancel href='./'/></td></tr></table>";
62a1a62001-08-10Per Hedbor  return res +
e3702b2000-09-18Andreas Lange  "</st-page></subtablist></td></tr></table>" "</cv-split></content></tmpl>";
2136682000-09-17Per Hedbor  }
ff3ddf2000-03-20Per Hedbor 
2136682000-09-17Per Hedbor 
e3702b2000-09-18Andreas Lange  report_notice(LOCALE(255, "Disabling old configuration %s")+"\n", cf->name);
62a1a62001-08-10Per Hedbor  foreach( glob("del_db_*", indices(id->variables)), string d ) { d = d[7..]; DBManager.drop_db( d ); }
2e48a82000-05-25Martin Stjernholm  string cfname = roxen.configuration_dir + "/" + cf->name; mv (cfname, cfname + "~");
be6d3c2000-03-24Per Hedbor  roxen->remove_configuration( cf->name );
ff3ddf2000-03-20Per Hedbor  cf->stop(); destruct( cf );
62a1a62001-08-10Per Hedbor 
9909172011-01-20Martin Stjernholm  return Roxen.http_redirect( "/sites/", id );
ff3ddf2000-03-20Per Hedbor }