1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
/* 
 * $Id$ 
 */ 
 
#include <config_interface.h> 
#include <roxen.h> 
 
//<locale-token project="admin_tasks"> LOCALE </locale-token> 
#define LOCALE(X,Y)  _DEF_LOCALE("admin_tasks",X,Y) 
 
constant action = "maintenance"; 
 
LocaleString name= LOCALE(34, "Restart or shutdown")+"..."; 
constant doc = ""; 
 
 
mixed parse( RequestID id ) 
{ 
  string pid = (string) getpid(); 
   
  string res = "<font size='+1'><b>" + 
    LOCALE(34, "Restart or shutdown") + "</b></font>" 
    "<p />"; 
   
  //  Verify pid for possibly repeated request (browser restart etc) 
  string what = id->variables->what; 
  string ignore_msg = ""; 
  if (string form_pid = id->variables->pid) 
    if (form_pid != pid) { 
      ignore_msg = 
        "<br />" 
        "<p><font color='&usr.warncolor;'>" + 
        LOCALE(406, "Repeated action request ignored &ndash; " 
               "server process ID is different.") + 
        "</font></p>"; 
      what = 0; 
    } 
 
  switch (what) { 
  case "restart": 
     if( config_perm( "Restart" ) ) 
     { 
       roxen->restart(0.5, UNDEFINED, -1); 
       return res + 
"<input type=hidden name=action value=restart.pike>" 
"<font color='&usr.warncolor;'><h1>"+LOCALE(197,"Restart")+"</h1></font>"+ 
 LOCALE(233, "Roxen will restart automatically.")+ 
"\n\n<p><i>"+ 
LOCALE(234, "You might see the old process for a while in the process table " 
       "when doing 'ps' or running 'top'. This is normal. Roxen waits for a " 
       "while for all connections to finish, the process will go away after " 
       "at most 15 minutes.")+ "</i></p>"; 
     } 
     return res + LOCALE(226,"Permission denied"); 
 
   case "shutdown": 
     if( config_perm( "Shutdown" ) ) 
     { 
       roxen->shutdown(0.5, -1); 
       return res + 
"<font color='&usr.warncolor;'><h1>"+LOCALE(198,"Shutdown")+"</h1></font>"+ 
LOCALE(235,"Roxen will <b>not</b> restart automatically.")+ 
"\n\n<p><i>"+ 
LOCALE(234, "You might see the old process for a while in the process table " 
       "when doing 'ps' or running 'top'. This is normal. Roxen waits for a " 
       "while for all connections to finish, the process will go away after " 
       "at most 15 minutes.")+ "</i></p>"; 
     } 
     return res + LOCALE(226,"Permission denied"); 
 
  default: 
    return Roxen.http_string_answer(res + 
#"<blockquote><br /> 
 
 <cf-perm perm='Restart'> 
   <gbutton href='?what=restart&amp;action=restart.pike&amp;class=maintenance&amp;pid=" + pid + #"&amp;&usr.set-wiz-id;' 
            width=250 icon_src=&usr.err-2;> "+ 
       LOCALE(197,"Restart")+#" </gbutton> 
 </cf-perm> 
 
<cf-perm not perm='Restart'> 
  <gbutton dim width=250 icon_src=&usr.err-2;> "+ 
       LOCALE(197,"Restart")+#" </gbutton> 
</cf-perm> 
 
<br/><br/> 
 
<cf-perm perm='Shutdown'> 
  <gbutton href='?what=shutdown&amp;action=restart.pike&amp;class=maintenance&amp;pid=" + pid + #"&amp;&usr.set-wiz-id;' 
           width=250  icon_src=&usr.err-3;> "+ 
       LOCALE(198,"Shutdown")+#" </gbutton> 
</cf-perm> 
 
<cf-perm not perm='Shutdown'> 
  <gbutton dim width=250 icon_src=&usr.err-3;> "+ 
       LOCALE(198,"Shutdown")+#" </gbutton> 
</cf-perm>" + ignore_msg + #" 
 
</blockquote> 
 
<br/> 
 
<p><cf-cancel href='?class=&form.class;&amp;&usr.set-wiz-id;'/></p>" ); 
     } 
}