home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / admin / httpd.cgi < prev    next >
Encoding:
Text File  |  2004-06-03  |  16.1 KB  |  250 lines

  1. #!perl/bin/perl.exe
  2.  
  3. print "Content-type: text/html\n\n";
  4.  
  5. require "../inc/config.inc.cgi";
  6. require "../lang/$lang/conf.cgi";
  7.  
  8. $FORM{'act'} = '';
  9.  
  10. &parseform();
  11.  
  12. if ($FORM{'act'}eq'-- Ok --'){
  13. print "<link rel=stylesheet href=../css/style.css><title>$httpdtitle</title>";
  14. &action;
  15. }else{
  16. &entry;
  17. }
  18. exit;
  19.  
  20.  
  21. sub parseform() {
  22. if($ENV{'REQUEST_METHOD'} eq 'GET'){
  23. $buffer=$ENV{'QUERY_STRING'};
  24. }elsif($ENV{'REQUEST_METHOD'} eq 'POST'){
  25. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});}
  26. @pairs = split(/&/, $buffer);
  27. foreach $pair (@pairs) {
  28. ($name, $value) = split(/=/, $pair);
  29. $value =~ tr/+/ /;
  30. $value =~s/%([a-fA-F0-9][a-fA-F0-9])/pack("c",hex($1))/eg;
  31. $FORM{$name} = $value;}
  32. }
  33.  
  34.  
  35. sub entry {
  36.  
  37. open (CONF,"< $httpdconf") or print "<b>$httpdconf</b> $cant_be_op<br>";
  38. @data=<CONF>;
  39. foreach $d (@data){
  40. if ($d =~ m~ServerName (.*)~g) {$servername = $1;}
  41. if ($d =~ m~Listen (.*)~g) {$listen = $1;}
  42. if ($d =~ m~ServerAdmin (.*)~g) {$serveradmin = $1;}
  43. if ($d =~ m~LogLevel (.*)~g) {$loglevel = $1;}
  44. if ($d =~ m~ServerTokens (.*)~g) {$servertokens = $1;}
  45. if ($d =~ m~ServerSignature (.*)~g) {$serversignature = $1;}
  46. if ($d =~ m~DirectoryIndex (.*)~g) {$directoryindex = $1;}
  47. if ($d =~ m~ThreadsPerChild (.*)~g) {$threadsperchild = $1;}
  48. if ($d =~ m~HostnameLookups (.*)~g) {$hostnamelookups = $1;}
  49. if ($d =~ m~IndexOptions (.*)~g) {$indexoptions = $1;}
  50.  
  51. if ($d =~ m/^Include conf\/mods\/php_handler.conf/) {$php = "checked";}
  52. if ($d =~ m/^Include conf\/mods\/perl.conf/) {$perl = "checked";}
  53. if ($d =~ m/^Include conf\/mods\/python.conf/) {$python = "checked";}
  54. if ($d =~ m/^Include conf\/mods\/php_cgi.conf/) {$phpcgi = "checked";}
  55. if ($d =~ m/^Include conf\/mods\/asp.conf/) {$asp = "checked";}
  56. if ($d =~ m/^LoadModule ssl_module modules\/mod_ssl.so/) {$ssl = "checked";}
  57. if ($d =~ m/^LoadModule status_module modules\/mod_status.so/) {$status = "checked";}
  58. if ($d =~ m/^LoadModule security_module modules\/mod_security.dll/) {$security = "checked";}
  59. if ($d =~ m/^Include conf\/mods\/proxy.conf/) {$proxy = "checked";}
  60. if ($d =~ m/^Include conf\/mods\/mod_gzip.conf/) {$gzip = "checked";}
  61. if ($d =~ m/^LoadModule rewrite_module modules\/mod_rewrite.so/) {$rewrite = "checked";}
  62.  
  63. }
  64. close (CONF) or die "$died_wc $httpdconf $with_error( $! )";
  65.  
  66.  
  67. print "<link rel=stylesheet href=../css/style.css>
  68. <title>$httpdtitle</title><body class=\"bodymain\"><center>
  69. <p class=manipheadtitle>$httpdtitle: $httpdcnf</p>
  70. <span class=tdinfored>$infohead</span><br>";
  71.  
  72. print "<form name=form1 action=$ENV{SCRIPT_NAME} method=post><br>
  73. <table width=\"75%\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" class=\"maniptab\" bgcolor=\"#F5F5F5\">
  74. <tr><td colspan=\"3\"><span class=\"manipactiv\">$srvmod_extens</span></td></tr>
  75. <tr>
  76. <td class=\"manipcheckbox\"><input type=checkbox name=php value=on $php></input>$act_php</td>
  77. <td class=\"manipcheckbox\"><input type=checkbox name=perl value=on $perl></input>$act_perl</td>
  78. <td class=\"manipcheckbox\"><input type=checkbox name=python value=on $python></input>$act_python</td></tr>
  79. <tr>
  80. <td class=\"manipcheckbox\"><input type=checkbox name=phpcgi value=on $phpcgi></input>$act_phpcgi</td>
  81. <td class=\"manipcheckbox\"><input type=checkbox name=asp value=on $asp></input>$act_asp</td>
  82. <td class=\"manipcheckbox\"><input type=checkbox name=ssl value=on $ssl></input>$act_ssl</td></tr>
  83. <tr><td colspan=\"3\"><span class=\"manipactiv\">$srvmod_mods</span></td></tr>
  84. <tr>
  85. <td class=\"manipcheckbox\"><input type=checkbox name=status value=on $status></input>$act_modstatus</td>
  86. <td class=\"manipcheckbox\"><input type=checkbox name=proxy value=on $proxy></input>$act_modproxy</td>
  87. <td class=\"manipcheckbox\"><input type=checkbox name=security value=on $security></input>$act_modsecurity</td></tr>
  88. <tr>
  89. <td class=\"manipcheckbox\"><input type=checkbox name=gzip value=on $gzip></input>$act_modgzip</td>
  90. <td class=\"manipcheckbox\"><input type=checkbox name=rewrite value=on $rewrite></input>$act_modrewrite</td>
  91. <td class=\"manipcheckbox\"> </td></tr>
  92. </table>
  93.  
  94. <table width=\"75%\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" class=\"maniptab\">
  95. <tr>
  96. <td class=\"tdinfored\">$php_mod_or_cgi</td>
  97. </tr>
  98. </table><br><br>
  99.  
  100. <table width=\"75%\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" class=\"maniptab\">
  101. <tr><td class=\"maniptitle\"><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> $sr_name<br><span class=\"maniptext\">$descr_sr</span></td></tr>
  102. <tr><td><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=servername value=$servername></input></td></tr>
  103. <tr><td class=\"maniptitle\"><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> $lst_to<br><span class=\"maniptext\">$descr_lst</span></td></tr>
  104. <tr><td><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=listen value=$listen></input></td></tr>
  105. <tr><td class=\"maniptitle\"><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> $sr_adm<br><span class=\"maniptext\">$descr_sr_adm</span></td></tr>
  106. <tr><td><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=serveradmin value=$serveradmin></input></td></tr>
  107. <tr><td class=\"maniptitle\"><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> $logl<br><span class=\"maniptext\">$descr_logl</span></td></tr>
  108. <tr><td><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=loglevel value=$loglevel></input></td></tr>
  109. <tr><td class=\"maniptitle\"><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> $sr_tok<br><span class=\"maniptext\">$descr_sr_tok</span></td></tr>
  110. <tr><td><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=servertokens value=$servertokens></input></td></tr>
  111. <tr><td class=\"maniptitle\"><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> $sr_sig<br><span class=\"maniptext\">$descr_sr_sig</span></td></tr>
  112. <tr><td><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=serversignature value=$serversignature></input></td></tr>
  113. <tr><td class=\"maniptitle\"><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> $sr_docind<br><span class=\"maniptext\">$descr_docind</span></td></tr>
  114. <tr><td><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=directoryindex value=\"$directoryindex\"></input></td></tr>
  115. <tr><td class=\"maniptitle\"><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> $sr_tpc<br><span class=\"maniptext\">$descr_sr_tpc</span></td></tr>
  116. <tr><td><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=threadsperchild value=$threadsperchild></input></td></tr>
  117. <tr><td class=\"maniptitle\"><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> $sr_hnl<br><span class=\"maniptext\">$descr_sr_hnl</span></td></tr>
  118. <tr><td><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=hostnamelookups value=$hostnamelookups></input></td></tr>
  119. <tr><td class=\"maniptitle\"><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> $sr_indopt<br><span class=\"maniptext\">$descr_sr_indopt</span></td></tr>
  120. <tr><td><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=indexoptions value=\"$indexoptions\"></input></td></tr>
  121. </table>
  122. <br><br><input class=submit type=submit name=act value=\"-- Ok --\"></input></form>";
  123. }
  124.  
  125.  
  126. sub action {
  127.  
  128. open (CONF,"< $httpdconf") or print "$error <b>$httpdconf</b> $cant_be_op<br>";
  129. @data=<CONF>;
  130. foreach $d (@data){
  131. if ($d =~ m~ServerName (.*)~g) {$servername = $1;}
  132. if ($d =~ m~Listen (.*)~g) {$listen = $1;}
  133. if ($d =~ m~ServerAdmin (.*)~g) {$serveradmin = $1;}
  134. if ($d =~ m~LogLevel (.*)~g) {$loglevel = $1;}
  135. if ($d =~ m~ServerTokens (.*)~g) {$servertokens = $1;}
  136. if ($d =~ m~ServerSignature (.*)~g) {$serversignature = $1;}
  137. if ($d =~ m~DirectoryIndex (.*)~g) {$directoryindex = $1;}
  138. if ($d =~ m~ThreadsPerChild (.*)~g) {$threadsperchild = $1;}
  139. if ($d =~ m~HostnameLookups (.*)~g) {$hostnamelookups = $1;}
  140. if ($d =~ m~IndexOptions (.*)~g) {$indexoptions = $1;}
  141. print CONF $d;
  142. }
  143. close (CONF) or die "$died_wc $httpdconf $with_error( $! )";
  144.  
  145. $servername1 = $FORM{'servername'};
  146. $listen1 = $FORM{'listen'};
  147. $serveradmin1 = $FORM{'serveradmin'};
  148. $loglevel1 = $FORM{'loglevel'};
  149. $servertokens1 = $FORM{'servertokens'};
  150. $serversignature1 = $FORM{'serversignature'};
  151. $directoryindex1 = $FORM{'directoryindex'};
  152. $threadsperchild1 = $FORM{'threadsperchild'};
  153. $hostnamelookups1 = $FORM{'hostnamelookups'};
  154. $indexoptions1 = $FORM{'indexoptions'};
  155.  
  156. if ($FORM{'php'} eq "on"){$php="on";}else{$php="off"}
  157. if ($FORM{'perl'} eq "on"){$perl="on";}else{$perl="off"}
  158. if ($FORM{'python'} eq "on"){$python="on";}else{$python="off"}
  159. if ($FORM{'phpcgi'} eq "on"){$phpcgi="on";}else{$phpcgi="off"}
  160. if ($FORM{'asp'} eq "on"){$asp="on";}else{$asp="off"}
  161. if ($FORM{'ssl'} eq "on"){$ssl="on";}else{$ssl="off"}
  162. if ($FORM{'status'} eq "on"){$status="on";}else{$status="off"}
  163. if ($FORM{'proxy'} eq "on"){$proxy="on";}else{$proxy="off"}
  164. if ($FORM{'security'} eq "on"){$security="on";}else{$security="off"}
  165. if ($FORM{'gzip'} eq "on"){$gzip="on";}else{$gzip="off"}
  166. if ($FORM{'rewrite'} eq "on"){$rewrite="on";}else{$rewrite="off"}
  167.  
  168. open (CONF,"+< $httpdconf") or print "<b>$httpdconf</b> $cant_be_op<br>";
  169. @data=<CONF>;
  170. truncate (CONF,0) or die "$died_wt $httpdconf $with_error( $! )";
  171. close (CONF) or die "$died_wc $httpdconf $with_error( $! )";
  172. open (CONF,"+< $httpdconf") or print "<b>$httpdconf</b> $cant_be_op<br>";
  173.  
  174. foreach $d (@data){
  175. $d =~ s~ServerName $servername~ServerName $servername1~g;
  176. $d =~ s~Listen $listen~Listen $listen1~g;
  177. $d =~ s~ServerAdmin $serveradmin~ServerAdmin $serveradmin1~g;
  178. $d =~ s~LogLevel $loglevel~LogLevel $loglevel1~g;
  179. $d =~ s~ServerTokens $servertokens~ServerTokens $servertokens1~g;
  180. $d =~ s~ServerSignature $serversignature~ServerSignature $serversignature1~g;
  181. $d =~ s~DirectoryIndex $directoryindex~DirectoryIndex $directoryindex1~g;
  182. $d =~ s~ThreadsPerChild $threadsperchild~ThreadsPerChild $threadsperchild1~g;
  183. $d =~ s~HostnameLookups $hostnamelookups~HostnameLookups $hostnamelookups1~g;
  184. $d =~ s~IndexOptions $indexoptions~IndexOptions $indexoptions1~g;
  185.  
  186. if ($php eq "on"){$d =~ s/^#Include conf\/mods\/php_handler.conf/Include conf\/mods\/php_handler.conf/g;}
  187. if ($php eq "off"){$d =~ s/^Include conf\/mods\/php_handler.conf/#Include conf\/mods\/php_handler.conf/g;}
  188. if ($perl eq "on"){$d =~ s/^#Include conf\/mods\/perl.conf/Include conf\/mods\/perl.conf/g;}
  189. if ($perl eq "off"){$d =~ s/^Include conf\/mods\/perl.conf/#Include conf\/mods\/perl.conf/g;}
  190. if ($python eq "on"){$d =~ s/^#Include conf\/mods\/python.conf/Include conf\/mods\/python.conf/g;}
  191. if ($python eq "off"){$d =~ s/^Include conf\/mods\/python.conf/#Include conf\/mods\/python.conf/g;}
  192. if ($phpcgi eq "on"){$d =~ s/^#Include conf\/mods\/php_cgi.conf/Include conf\/mods\/php_cgi.conf/g;}
  193. if ($phpcgi eq "off"){$d =~ s/^Include conf\/mods\/php_cgi.conf/#Include conf\/mods\/php_cgi.conf/g;}
  194. if ($ssl eq "on"){$d =~ s/^#LoadModule ssl_module/LoadModule ssl_module/g;}
  195. if ($ssl eq "off"){$d =~ s/^LoadModule ssl_module/#LoadModule ssl_module/g;}
  196. if ($asp eq "on"){$d =~ s/^#Include conf\/mods\/asp.conf/Include conf\/mods\/asp.conf/g;}
  197. if ($asp eq "off"){$d =~ s/^Include conf\/mods\/asp.conf/#Include conf\/mods\/asp.conf/g;}
  198. if ($status eq "on"){$d =~ s/^#LoadModule status_module/LoadModule status_module/g;}
  199. if ($status eq "off"){$d =~ s/^LoadModule status_module/#LoadModule status_module/g;}
  200. if ($security eq "on"){$d =~ s/^#LoadModule security_module/LoadModule security_module/g;}
  201. if ($security eq "off"){$d =~ s/^LoadModule security_module/#LoadModule security_module/g;}
  202. if ($proxy eq "on"){$d =~ s/^#Include conf\/mods\/proxy.conf/Include conf\/mods\/proxy.conf/g;}
  203. if ($proxy eq "off"){$d =~ s/^Include conf\/mods\/proxy.conf/#Include conf\/mods\/proxy.conf/g;}
  204. if ($gzip eq "on"){$d =~ s/^#Include conf\/mods\/mod_gzip.conf/Include conf\/mods\/mod_gzip.conf/g;}
  205. if ($gzip eq "off"){$d =~ s/^Include conf\/mods\/mod_gzip.conf/#Include conf\/mods\/mod_gzip.conf/g;}
  206. if ($rewrite eq "on"){$d =~ s/^#LoadModule rewrite_module/LoadModule rewrite_module/g;}
  207. if ($rewrite eq "off"){$d =~ s/^LoadModule rewrite_module/#LoadModule rewrite_module/g;}
  208.   
  209.     print CONF $d;
  210. }
  211. close (CONF) or die "$died_wc $httpdconf $with_error( $! )";
  212.  
  213. print "<center><p class=manipheadtitle>$after_restart</p><br>";
  214. print "<table width=\"75%\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" class=\"maniptab\" bgcolor=\"#F5F5F5\">
  215. <tr><td colspan=\"3\" class=\"manipactiv\">$srvmod_extens</td></tr>
  216. <tr><td class=\"maniptitle\">$php_act <span class=\"maniptitlered\">$php</span></td>
  217. <td class=\"maniptitle\">$perl_act <span class=\"maniptitlered\">$perl</span></td>
  218. <td class=\"maniptitle\">$python_act <span class=\"maniptitlered\">$python</span></td></tr>
  219. <tr><td class=\"maniptitle\">$phpcgi_act <span class=\"maniptitlered\">$phpcgi</span></td>
  220. <td class=\"maniptitle\">$asp_act <span class=\"maniptitlered\">$asp</span></td>
  221. <td class=\"maniptitle\">$ssl_act <span class=\"maniptitlered\">$ssl</span></td></tr>
  222. <tr><td colspan=\"3\" class=\"manipactiv\">$srvmod_mods</td></tr>
  223. <tr><td class=\"maniptitle\">$mod_status_act <span class=\"maniptitlered\">$status</span></td>
  224. <td class=\"maniptitle\">$mod_proxy_act <span class=\"maniptitlered\">$proxy</span></td>
  225. <td class=\"maniptitle\">$mod_security_act <span class=\"maniptitlered\">$security</span></td></tr>
  226. <tr><td class=\"maniptitle\">$mod_gzip_act <span class=\"maniptitlered\">$gzip</span></td>
  227. <td class=\"maniptitle\">$mod_rewrite_act <span class=\"maniptitlered\">$rewrite</span></td>
  228. <td class=\"maniptitle\"> </td></tr>
  229. </table><br>";
  230.  
  231. print "<table width=\"75%\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" class=\"maniptab\">
  232. <tr><td class=\"tdinfo\">$sol_srpo<br><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=servername value=$servername1></input></td></tr>
  233. <tr><td class=\"tdinfo\">$sol_lst<br><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=listen value=$listen1></input></td></tr>
  234. <tr><td class=\"tdinfo\">$sol_sradm<br><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=serveradmin value=$serveradmin1></input></td></tr>
  235. <tr><td class=\"tdinfo\">$sol_logl<br><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=loglevel value=$loglevel1></input></td></tr>
  236. <tr><td class=\"tdinfo\">$sol_srtok<br><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=servertokens value=$servertokens1></input></td></tr>
  237. <tr><td class=\"tdinfo\">$sol_srsig<br><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=serversignature value=$serversignature1></input></td></tr>
  238. <tr><td class=\"tdinfo\">$sol_docind<br><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=directoryindex value=\"$directoryindex1\"></input></td></tr>
  239. <tr><td class=\"tdinfo\">$sol_tpc<br><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=threadsperchild value=$threadsperchild1></input></td></tr>
  240. <tr><td class=\"tdinfo\">$sol_hnl<br><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=hostnamelookups value=$hostnamelookups1></input></td></tr>
  241. <tr><td class=\"tdinfo\">$sol_indopt<br><input class=\"manipinput\" type=text size=\"75\" maxlength=\"100\" name=indexoptions value=\"$indexoptions1\"></input></td></tr>
  242. </table><br>";
  243.  
  244. print "<table width=\"75%\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" class=\"maniptab\" bgcolor=\"#F5F5F5\">";
  245. print "<tr><td class=\"maniptext\"><div align=\"justify\"><b>$httpdcnf</b> $was_edt_succ $if_srn_edt</div></td></tr>";
  246. print "<tr><td><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> <a href=httpd.ssl.cgi target=_self>$man_sslcnf</a></td></tr>";
  247. print "<tr><td><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> <a href=manipulation.php target=_self>$click_stst</a></td></tr>";
  248. print "<tr><td><img src=\"../gfx/fwd.png\" width=\"12\" height=\"11\" border=\"0\" alt=\"\"> <a href=javascript:history.go(-1)>$back</a></td></tr></table>";
  249. }
  250. exit;