From c831615b7a5f534538a0b405aac394415c77cfae Mon Sep 17 00:00:00 2001 From: redray <redray@ispconfig3> Date: Thu, 18 Dec 2008 08:03:34 -0500 Subject: [PATCH] changed some stuff around the default indexes (new look for de and en). --- server/conf/index/standard_index.html_cz | 99 + server/conf/index/standard_index.html_pl | 1 server/conf/index/user_standard_index.html_fr | 3 server/conf/index/standard_index.html_es | 97 + server/conf/index/user_standard_index.html_hu | 1 server/conf/index/standard_index.html_hu | 1 server/plugins-available/apache2_plugin.inc.php | 1865 +++++++++++++++++++++++++++++-------------- server/conf/index/standard_index.html_fr | 3 server/conf/index/user_standard_index.html_cz | 38 server/conf/index/standard_index.html_de | 96 + server/conf/index/robots.txt | 2 server/conf/index/user_standard_index.html_pl | 1 server/conf/index/favicon.ico | 0 server/conf/index/standard_index.html_nl | 1 server/conf/index/user_standard_index.html_nl | 1 server/conf/index/user_standard_index.html_de | 96 + interface/web/themes/default/images/favicon.ico | 0 interface/web/themes/default/templates/main.tpl.htm | 1 server/conf/index/user_standard_index.html_en | 97 + server/conf/index/user_standard_index.html_gr | 1 server/conf/index/user_standard_index.html_it | 1 server/conf/index/user_standard_index.html_es | 7 server/conf/index/standard_index.html_se | 1 server/conf/index/.htaccess | 0 server/conf/index/standard_index.html_en | 101 + server/conf/index/user_standard_index.html_se | 1 server/conf/index/standard_index.html_gr | 1 server/conf/index/standard_index.html_it | 1 server/conf/index/standard_index.html_sr | 1 server/conf/index/user_standard_index.html_sr | 1 30 files changed, 1,667 insertions(+), 852 deletions(-) diff --git a/interface/web/themes/default/images/favicon.ico b/interface/web/themes/default/images/favicon.ico new file mode 100644 index 0000000..da6257c --- /dev/null +++ b/interface/web/themes/default/images/favicon.ico Binary files differ diff --git a/interface/web/themes/default/templates/main.tpl.htm b/interface/web/themes/default/templates/main.tpl.htm index c40e36a..37c8fad 100644 --- a/interface/web/themes/default/templates/main.tpl.htm +++ b/interface/web/themes/default/templates/main.tpl.htm @@ -8,6 +8,7 @@ <!--[if lte IE 7]> <link href="themes/default/css/patches/central.css" rel="stylesheet" type="text/css" /> <![endif]--> + <link rel="shortcut icon" href="/themes/default/images/favicon.ico" /> <script type="text/javascript" src="js/yui/yahoo/yahoo-min.js"></script> <script type="text/javascript" src="js/yui/connection/connection-min.js"></script> <script type="text/javascript" src="js/scrigo.js.php"></script> diff --git a/server/conf/index/.htaccess b/server/conf/index/.htaccess new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/server/conf/index/.htaccess diff --git a/server/conf/index/favicon.ico b/server/conf/index/favicon.ico new file mode 100644 index 0000000..da6257c --- /dev/null +++ b/server/conf/index/favicon.ico Binary files differ diff --git a/server/conf/index/robots.txt b/server/conf/index/robots.txt new file mode 100644 index 0000000..4354fd9 --- /dev/null +++ b/server/conf/index/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: /stats/ diff --git a/server/conf/index/standard_index.html_cz b/server/conf/index/standard_index.html_cz index e572107..da148a0 100644 --- a/server/conf/index/standard_index.html_cz +++ b/server/conf/index/standard_index.html_cz @@ -1,39 +1,60 @@ -<HTML> -<HEAD> -<TITLE>Vitejte!</TITLE> -</HEAD> -<BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> -<CENTER> -<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"> - <TR> - <TD BGCOLOR="#025CCA" ALIGN="CENTER"> - <HR SIZE="1" COLOR="#FFFFFF"> - <TABLE> - <TR> - <TD><FONT SIZE="3" COLOR="#FFFFFF" FACE="Helvetica, Arial"><B>Vitejte na - <!--ADRESSE//--> - Vasem webu! - <!--ADRESSE//--> - </B></FONT></TD> - </TR> - </TABLE> - <HR SIZE="1" COLOR="#FFFFFF"> - </TD> - </TR> - <TR> - <TD BGCOLOR="#FFFFFF"> - <BR><BR><CENTER> - <FONT COLOR="#000000" SIZE="2" FACE="Helvetica, Arial">Toto je standardni stranka Vaseho webu. Muzete ji bez obav vymazat nebo nahradit jinym souborem. Toto je soubor index.html v adresari <B>web</B>. - <P>Pokud mate jakekoliv dotazy prosim kontaktuje administratora serveru.</FONT> </CENTER> - <BR> - - <HR SIZE="1" WIDTH="90%"> - <CENTER> -<FONT SIZE="1" COLOR="#000000" FACE="Verdana, Arial">powered by <A HREF="http://www.ispconfig.org">ISPConfig</A> on <a href="http://www.zserver.cz">Zserver s.r.o.</a></FONT> - </CENTER> - </TD> - </TR> -</TABLE> -</CENTER> -</BODY> -</HTML> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Vitejte!</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <link rel="shortcut icon" href="/favicon.ico" /> + <style type="text/css"><!-- + body { + color: #444444; + background-color: #EEEEEE; + font-family: 'Trebuchet MS', sans-serif; + font-size: 80%; + } + h1 {} + h2 { font-size: 1.2em; } + #page{ + background-color: #FFFFFF; + width: 60%; + margin: 0 auto; + padding: 6px 12px; + } + #header{ + color: #FFFFFF; + background-color: #6A6A6A; + padding: 6px ; + text-align: center; + } + #content { + padding: 4px 0 24px 0; + } + #footer { + color:#6A6A6A; + background: #f9f9f9; + padding: 10px 20px; + border-top: 5px #efefef solid; + font-size: 0.8em; + text-align: center; + } + #footer a { + color: #6A6A6A; + } + --></style> +</head> +<body> + <div id="page"> + <div id="header"> + <h1>Vitejte na <!--ADRESSE//-->Vasem webu!<!--ADRESSE//--></h1> + </div> + <div id="content"> + <h2>Toto je standardni stranka Vaseho webu.</h2> + <p>Muzete ji bez obav vymazat nebo nahradit jinym souborem. Toto je soubor <b>index.html</b> v adresari <b>web</b>.</p> + <pPokud mate jakekoliv dotazy prosim kontaktuje administratora serveru.</p> + </div> + <div id="footer"> + <p>powered by <a href="http://www.ispconfig.org">ISPConfig</a></p> + </div> + </div> +</body> +</html> diff --git a/server/conf/index/standard_index.html_de b/server/conf/index/standard_index.html_de index 67f7a93..5604685 100644 --- a/server/conf/index/standard_index.html_de +++ b/server/conf/index/standard_index.html_de @@ -1,36 +1,60 @@ -<HTML> -<HEAD> -<TITLE>Herzlich Willkommen!</TITLE> -</HEAD> -<BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> -<CENTER> -<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"> - <TR> - <TD BGCOLOR="#025CCA" ALIGN="CENTER"> - <HR SIZE="1" COLOR="#FFFFFF"> - <TABLE> - <TR> - <TD><FONT SIZE="3" COLOR="#FFFFFF" FACE="Helvetica, Arial"><B>Herzlich Willkommen auf <!--ADRESSE//-->Ihrer Website!<!--ADRESSE//--></B></FONT></TD> - </TR> - </TABLE> - <HR SIZE="1" COLOR="#FFFFFF"> - </TD> - </TR> - <TR> - <TD BGCOLOR="#FFFFFF"> - <BR><BR> - <CENTER> - <FONT COLOR="#000000" SIZE="2" FACE="Helvetica, Arial">Dies ist die Standard-Index-Seite Ihres Webs. Sie können sie problemlos löschen oder durch eine andere Seite ersetzen. Es handelt sich hierbei um die Datei index.html im Verzeichnis <B>web</B>. - <P>Bei Fragen oder Problemen wenden Sie sich bitte an den Server-Administrator.</FONT> - </CENTER> - <BR> - <HR SIZE="1" WIDTH="90%"> - <CENTER> -<FONT SIZE="1" COLOR="#000000" FACE="Verdana, Arial">powered by <A HREF="http://www.ispconfig.org">ISPConfig</A></FONT> - </CENTER> - </TD> - </TR> -</TABLE> -</CENTER> -</BODY> -</HTML> \ No newline at end of file +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Herzlich Willkommen!</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <link rel="shortcut icon" href="/favicon.ico" /> + <style type="text/css"><!-- + body { + color: #444444; + background-color: #EEEEEE; + font-family: 'Trebuchet MS', sans-serif; + font-size: 80%; + } + h1 {} + h2 { font-size: 1.2em; } + #page{ + background-color: #FFFFFF; + width: 60%; + margin: 0 auto; + padding: 6px 12px; + } + #header{ + color: #FFFFFF; + background-color: #6A6A6A; + padding: 6px ; + text-align: center; + } + #content { + padding: 4px 0 24px 0; + } + #footer { + color:#6A6A6A; + background: #f9f9f9; + padding: 10px 20px; + border-top: 5px #efefef solid; + font-size: 0.8em; + text-align: center; + } + #footer a { + color: #6A6A6A; + } + --></style> +</head> +<body> + <div id="page"> + <div id="header"> + <h1>Herzlich Willkommen auf <!--ADRESSE//-->Ihrer Website!<!--ADRESSE//--></h1> + </div> + <div id="content"> + <h2>Dies ist die Standard-Index-Seite Ihres Webs.</h2> + <p>Sie können sie problemlos löschen oder durch eine andere Seite ersetzen. Es handelt sich hierbei um die Datei <b>index.html</b> im Verzeichnis <b>web</b>.</p> + <p>Bei Fragen oder Problemen wenden Sie sich bitte an den Server-Administrator.</p> + </div> + <div id="footer"> + <p>powered by <a href="http://www.ispconfig.org">ISPConfig</a></p> + </div> + </div> +</body> +</html> diff --git a/server/conf/index/standard_index.html_en b/server/conf/index/standard_index.html_en index e2e281f..69b6d57 100644 --- a/server/conf/index/standard_index.html_en +++ b/server/conf/index/standard_index.html_en @@ -1,41 +1,60 @@ -<HTML> -<HEAD> -<TITLE>Welcome!</TITLE> -</HEAD> -<BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> -<CENTER> -<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"> - <TR> - <TD BGCOLOR="#025CCA" ALIGN="CENTER"> - <HR SIZE="1" COLOR="#FFFFFF"> - <TABLE> - <TR> - <TD><FONT SIZE="3" COLOR="#FFFFFF" FACE="Helvetica, Arial"><B>Welcome - to - <!--ADRESSE//--> - your website! - <!--ADRESSE//--> - </B></FONT></TD> - </TR> - </TABLE> - <HR SIZE="1" COLOR="#FFFFFF"> - </TD> - </TR> - <TR> - <TD BGCOLOR="#FFFFFF"> - <BR><BR><CENTER> - <FONT COLOR="#000000" SIZE="2" FACE="Helvetica, Arial">This is the standard index of your website. You can easily delete it or replace it with another file. This is the index.html file - in the <B>web</B> directory. - <P>For questions or problems please contact the server administrator.</FONT> </CENTER> - <BR> - - <HR SIZE="1" WIDTH="90%"> - <CENTER> -<FONT SIZE="1" COLOR="#000000" FACE="Verdana, Arial">powered by <A HREF="http://www.ispconfig.org">ISPConfig</A></FONT> - </CENTER> - </TD> - </TR> -</TABLE> -</CENTER> -</BODY> -</HTML> \ No newline at end of file +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Welcome!</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <link rel="shortcut icon" href="/favicon.ico" /> + <style type="text/css"><!-- + body { + color: #444444; + background-color: #EEEEEE; + font-family: 'Trebuchet MS', sans-serif; + font-size: 80%; + } + h1 {} + h2 { font-size: 1.2em; } + #page{ + background-color: #FFFFFF; + width: 60%; + margin: 0 auto; + padding: 6px 12px; + } + #header{ + color: #FFFFFF; + background-color: #6A6A6A; + padding: 6px ; + text-align: center; + } + #content { + padding: 4px 0 24px 0; + } + #footer { + color:#6A6A6A; + background: #f9f9f9; + padding: 10px 20px; + border-top: 5px #efefef solid; + font-size: 0.8em; + text-align: center; + } + #footer a { + color: #6A6A6A; + } + --></style> +</head> +<body> + <div id="page"> + <div id="header"> + <h1>Welcome to <!--ADRESSE//-->your website!<!--ADRESSE//--></h1> + </div> + <div id="content"> + <h2>This is the default index page of your website.</h2> + <p>This file may be deleted or overwritten without any difficulty. This is produced by the file <b>index.html</b> in the <b>web</b> directory.</p> + <p>For questions or problems please contact the server administrator.</p> + </div> + <div id="footer"> + <p>powered by <a href="http://www.ispconfig.org">ISPConfig</a></p> + </div> + </div> +</body> +</html> diff --git a/server/conf/index/standard_index.html_es b/server/conf/index/standard_index.html_es index ca0811c..ef23e7f 100644 --- a/server/conf/index/standard_index.html_es +++ b/server/conf/index/standard_index.html_es @@ -1,37 +1,60 @@ -<HTML> -<HEAD> -<TITLE>Bienvenido!</TITLE> -</HEAD> -<BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> -<CENTER> -<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"> - <TR> - <TD BGCOLOR="#025CCA" ALIGN="CENTER"> - <HR SIZE="1" COLOR="#FFFFFF"> - <TABLE> - <TR> - <TD><FONT SIZE="3" COLOR="#FFFFFF" FACE="Helvetica, Arial"><B>Bienvenido a su sitio web!</B></FONT></TD> - </TR> - </TABLE> - <HR SIZE="1" COLOR="#FFFFFF"> - </TD> - </TR> - <TR> - <TD BGCOLOR="#FFFFFF"> - <BR><BR> - <center> - <FONT COLOR="#000000" SIZE="2" FACE="Helvetica, Arial">Esta es la página principal del sitio. - Puede cambiarla por otra simplemente reemplazando este archivo. - <P>Si tiene dudas o problemas, porfavor contacte al administrador del sistema.</FONT> - <BR> - </center> - <HR SIZE="1" WIDTH="90%"> - <CENTER> -<FONT SIZE="1" COLOR="#000000" FACE="Verdana, Arial">powered by <A HREF="http://www.ispconfig.org">ISPConfig</A></FONT> - </CENTER> - </TD> - </TR> -</TABLE> -</CENTER> -</BODY> -</HTML> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Bienvenido!</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <link rel="shortcut icon" href="/favicon.ico" /> + <style type="text/css"><!-- + body { + color: #444444; + background-color: #EEEEEE; + font-family: 'Trebuchet MS', sans-serif; + font-size: 80%; + } + h1 {} + h2 { font-size: 1.2em; } + #page{ + background-color: #FFFFFF; + width: 60%; + margin: 0 auto; + padding: 6px 12px; + } + #header{ + color: #FFFFFF; + background-color: #6A6A6A; + padding: 6px ; + text-align: center; + } + #content { + padding: 4px 0 24px 0; + } + #footer { + color:#6A6A6A; + background: #f9f9f9; + padding: 10px 20px; + border-top: 5px #efefef solid; + font-size: 0.8em; + text-align: center; + } + #footer a { + color: #6A6A6A; + } + --></style> +</head> +<body> + <div id="page"> + <div id="header"> + <h1>Bienvenido a <!--ADRESSE//-->su sitio web!<!--ADRESSE//--></h1> + </div> + <div id="content"> + <h2>Esta es la página principal del sitio.</h2> + <p>Puede cambiarla por otra simplemente reemplazando este archivo. This is produced by the file <b>index.html</b> in the <b>web</b> directory.</p> + <p>Si tiene dudas o problemas, porfavor contacte al administrador del sistema.</p> + </div> + <div id="footer"> + <p>powered by <a href="http://www.ispconfig.org">ISPConfig</a></p> + </div> + </div> +</body> +</html> diff --git a/server/conf/index/standard_index.html_fr b/server/conf/index/standard_index.html_fr index 35fb141..46bb03c 100644 --- a/server/conf/index/standard_index.html_fr +++ b/server/conf/index/standard_index.html_fr @@ -1,7 +1,8 @@ <html> <head> <title>Bienvenue!</title> -</head> +<link rel="shortcut icon" href="/favicon.ico" /> +</HEAD> <body BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <center> <table BORDER="0" WIDTH="100%" CELLSPACING="0"> diff --git a/server/conf/index/standard_index.html_gr b/server/conf/index/standard_index.html_gr index 4bc23f3..74e6161 100644 --- a/server/conf/index/standard_index.html_gr +++ b/server/conf/index/standard_index.html_gr @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>����� ������!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/standard_index.html_hu b/server/conf/index/standard_index.html_hu index 83e5ae8..9d50335 100644 --- a/server/conf/index/standard_index.html_hu +++ b/server/conf/index/standard_index.html_hu @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>�dv�z�lj�k!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/standard_index.html_it b/server/conf/index/standard_index.html_it index 736c90b..229a439 100644 --- a/server/conf/index/standard_index.html_it +++ b/server/conf/index/standard_index.html_it @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>Benvenuti!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/standard_index.html_nl b/server/conf/index/standard_index.html_nl index 028845c..5959d8c 100644 --- a/server/conf/index/standard_index.html_nl +++ b/server/conf/index/standard_index.html_nl @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>Welkom!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/standard_index.html_pl b/server/conf/index/standard_index.html_pl index e2e281f..e28d456 100644 --- a/server/conf/index/standard_index.html_pl +++ b/server/conf/index/standard_index.html_pl @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>Welcome!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/standard_index.html_se b/server/conf/index/standard_index.html_se index 1129f8a..a32fbe0 100644 --- a/server/conf/index/standard_index.html_se +++ b/server/conf/index/standard_index.html_se @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>V�lkommen!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/standard_index.html_sr b/server/conf/index/standard_index.html_sr index c3825a9..1d2f2e7 100644 --- a/server/conf/index/standard_index.html_sr +++ b/server/conf/index/standard_index.html_sr @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>Dobrodo�li!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/user_standard_index.html_cz b/server/conf/index/user_standard_index.html_cz new file mode 100644 index 0000000..33b0190 --- /dev/null +++ b/server/conf/index/user_standard_index.html_cz @@ -0,0 +1,38 @@ +<HTML> +<HEAD> +<TITLE>Herzlich Willkommen!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> +</HEAD> +<BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> +<CENTER> +<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"> + <TR> + <TD BGCOLOR="#025CCA" ALIGN="CENTER"> + <HR SIZE="1" COLOR="#FFFFFF"> + <TABLE> + <TR> + <TD><FONT SIZE="3" COLOR="#FFFFFF" FACE="Helvetica, Arial"><B>Vasem webu!</B></FONT></TD> + </TR> + </TABLE> + <HR SIZE="1" COLOR="#FFFFFF"> + </TD> + </TR> + <TR> + <TD BGCOLOR="#FFFFFF"> + <BR><BR> + <CENTER> + <FONT COLOR="#000000" SIZE="2" FACE="Helvetica, Arial"> + Toto je standardni stranka Vaseho webu. Muzete ji bez obav vymazat nebo nahradit jinym souborem. Toto je soubor index.html v adresari <B>web</B>. + <P>Pokud mate jakekoliv dotazy prosim kontaktuje administratora serveru.</FONT> + </CENTER> + <BR> + <HR SIZE="1" WIDTH="90%"> + <CENTER> + <FONT SIZE="1" COLOR="#000000" FACE="Verdana, Arial">powered by <A HREF="http://www.ispconfig.org">ISPConfig</A></FONT> + </CENTER> + </TD> + </TR> +</TABLE> +</CENTER> +</BODY> +</HTML> \ No newline at end of file diff --git a/server/conf/index/user_standard_index.html_de b/server/conf/index/user_standard_index.html_de index 0d31366..8fa55c5 100644 --- a/server/conf/index/user_standard_index.html_de +++ b/server/conf/index/user_standard_index.html_de @@ -1,36 +1,60 @@ -<HTML> -<HEAD> -<TITLE>Herzlich Willkommen!</TITLE> -</HEAD> -<BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> -<CENTER> -<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"> - <TR> - <TD BGCOLOR="#025CCA" ALIGN="CENTER"> - <HR SIZE="1" COLOR="#FFFFFF"> - <TABLE> - <TR> - <TD><FONT SIZE="3" COLOR="#FFFFFF" FACE="Helvetica, Arial"><B>Herzlich Willkommen auf Ihrer Website!</B></FONT></TD> - </TR> - </TABLE> - <HR SIZE="1" COLOR="#FFFFFF"> - </TD> - </TR> - <TR> - <TD BGCOLOR="#FFFFFF"> - <BR><BR> - <CENTER> - <FONT COLOR="#000000" SIZE="2" FACE="Helvetica, Arial">Dies ist die Standard-Index-Seite von User <b>{USER_USERNAME}</b>. Sie können sie problemlos löschen oder durch eine andere Seite ersetzen. Es handelt sich hierbei um die Datei index.html im Verzeichnis <B>user/{USER_USERNAME}/web</B>. - <P>Bei Fragen oder Problemen wenden Sie sich bitte an den Server-Administrator.</FONT> - </CENTER> - <BR> - <HR SIZE="1" WIDTH="90%"> - <CENTER> -<FONT SIZE="1" COLOR="#000000" FACE="Verdana, Arial">powered by <A HREF="http://www.ispconfig.org">ISPConfig</A></FONT> - </CENTER> - </TD> - </TR> -</TABLE> -</CENTER> -</BODY> -</HTML> \ No newline at end of file +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Herzlich Willkommen!</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <link rel="shortcut icon" href="/favicon.ico" /> + <style type="text/css"><!-- + body { + color: #444444; + background-color: #EEEEEE; + font-family: 'Trebuchet MS', sans-serif; + font-size: 80%; + } + h1 {} + h2 { font-size: 1.2em; } + #page{ + background-color: #FFFFFF; + width: 60%; + margin: 0 auto; + padding: 6px 12px; + } + #header{ + color: #FFFFFF; + background-color: #6A6A6A; + padding: 6px ; + text-align: center; + } + #content { + padding: 4px 0 24px 0; + } + #footer { + color:#6A6A6A; + background: #f9f9f9; + padding: 10px 20px; + border-top: 5px #efefef solid; + font-size: 0.8em; + text-align: center; + } + #footer a { + color: #6A6A6A; + } + --></style> +</head> +<body> + <div id="page"> + <div id="header"> + <h1>Herzlich Willkommen auf <!--ADRESSE//-->Ihrer Website!<!--ADRESSE//--></h1> + </div> + <div id="content"> + <h2>Dies ist die Standard-Index-Seite von User <b>{USER_USERNAME}</b>.</h2> + <p>Sie können sie problemlos löschen oder durch eine andere Seite ersetzen. Es handelt sich hierbei um die Datei <b>index.html</b> im Verzeichnis <b>user/{USER_USERNAME}/web</b>.</p> + <p>Bei Fragen oder Problemen wenden Sie sich bitte an den Server-Administrator.</p> + </div> + <div id="footer"> + <p>powered by <a href="http://www.ispconfig.org">ISPConfig</a></p> + </div> + </div> +</body> +</html> diff --git a/server/conf/index/user_standard_index.html_en b/server/conf/index/user_standard_index.html_en index f5df92d..ac3367a 100644 --- a/server/conf/index/user_standard_index.html_en +++ b/server/conf/index/user_standard_index.html_en @@ -1,37 +1,60 @@ -<HTML> -<HEAD> -<TITLE>Welcome!</TITLE> -</HEAD> -<BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> -<CENTER> -<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0"> - <TR> - <TD BGCOLOR="#025CCA" ALIGN="CENTER"> - <HR SIZE="1" COLOR="#FFFFFF"> - <TABLE> - <TR> - <TD><FONT SIZE="3" COLOR="#FFFFFF" FACE="Helvetica, Arial"><B>Welcome to your website!</B></FONT></TD> - </TR> - </TABLE> - <HR SIZE="1" COLOR="#FFFFFF"> - </TD> - </TR> - <TR> - <TD BGCOLOR="#FFFFFF"> - <BR><BR> - <CENTER> - <FONT COLOR="#000000" SIZE="2" FACE="Helvetica, Arial">This is the default index page for user <b>{USER_USERNAME}</b>. - This file may be deleted or overwritten without any difficulty. This is produced by the file index.html in the directory <B>user/{USER_USERNAME}/web</B>. - <P>For questions or problems please contact the server administrator.</FONT> - </CENTER> - <BR> - <HR SIZE="1" WIDTH="90%"> - <CENTER> -<FONT SIZE="1" COLOR="#000000" FACE="Verdana, Arial">powered by <A HREF="http://www.ispconfig.org">ISPConfig</A></FONT> - </CENTER> - </TD> - </TR> -</TABLE> -</CENTER> -</BODY> -</HTML> \ No newline at end of file +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Welcome!</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <link rel="shortcut icon" href="/favicon.ico" /> + <style type="text/css"><!-- + body { + color: #444444; + background-color: #EEEEEE; + font-family: 'Trebuchet MS', sans-serif; + font-size: 80%; + } + h1 {} + h2 { font-size: 1.2em; } + #page{ + background-color: #FFFFFF; + width: 60%; + margin: 0 auto; + padding: 6px 12px; + } + #header{ + color: #FFFFFF; + background-color: #6A6A6A; + padding: 6px ; + text-align: center; + } + #content { + padding: 4px 0 24px 0; + } + #footer { + color:#6A6A6A; + background: #f9f9f9; + padding: 10px 20px; + border-top: 5px #efefef solid; + font-size: 0.8em; + text-align: center; + } + #footer a { + color: #6A6A6A; + } + --></style> +</head> +<body> + <div id="page"> + <div id="header"> + <h1>Welcome to <!--ADRESSE//-->your website!<!--ADRESSE//--></h1> + </div> + <div id="content"> + <h2>This is the default index page for user <b>{USER_USERNAME}</b>.</h2> + <p>This file may be deleted or overwritten without any difficulty. This is produced by the file <b>index.html</b> in the <b>user/{USER_USERNAME}/web</b> directory.</p> + <p>For questions or problems please contact the server administrator.</p> + </div> + <div id="footer"> + <p>powered by <a href="http://www.ispconfig.org">ISPConfig</a></p> + </div> + </div> +</body> +</html> diff --git a/server/conf/index/user_standard_index.html_es b/server/conf/index/user_standard_index.html_es index 849f04b..a8c2658 100644 --- a/server/conf/index/user_standard_index.html_es +++ b/server/conf/index/user_standard_index.html_es @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>Bienvenido!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> @@ -18,11 +19,11 @@ </TR> <TR> <TD BGCOLOR="#FFFFFF"> - <BR><BR> + <BR><BR> <center> <FONT COLOR="#000000" SIZE="2" FACE="Helvetica, Arial">Esta es la página indice de la cuenta <b>{USER_USERNAME}</b>. Este archivo puede ser removido o sobreescrito. <P>El archivo 'index.html' se encuentra localicado en el directorio '<B>user/{USER_USERNAME}/web</B>'. - <P>Si tiene dudas, porfavor contacte al administrador del sistema.</FONT> + <P>Si tiene dudas, porfavor contacte al administrador del sistema.</FONT> </center> <BR> <HR SIZE="1" WIDTH="90%"> @@ -34,4 +35,4 @@ </TABLE> </CENTER> </BODY> -</HTML> +</HTML> diff --git a/server/conf/index/user_standard_index.html_fr b/server/conf/index/user_standard_index.html_fr index 45c835f..fa00669 100644 --- a/server/conf/index/user_standard_index.html_fr +++ b/server/conf/index/user_standard_index.html_fr @@ -1,7 +1,8 @@ <html> <head> <title>Bienvenue!</title> -</head> +<link rel="shortcut icon" href="/favicon.ico" /> +</HEAD> <body BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <center> <table BORDER="0" WIDTH="100%" CELLSPACING="0"> diff --git a/server/conf/index/user_standard_index.html_gr b/server/conf/index/user_standard_index.html_gr index 90e9a62..645773c 100644 --- a/server/conf/index/user_standard_index.html_gr +++ b/server/conf/index/user_standard_index.html_gr @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>����� ������</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/user_standard_index.html_hu b/server/conf/index/user_standard_index.html_hu index cdce8a7..e6b81f0 100644 --- a/server/conf/index/user_standard_index.html_hu +++ b/server/conf/index/user_standard_index.html_hu @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>Welcome!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/user_standard_index.html_it b/server/conf/index/user_standard_index.html_it index 5d94682..b294d99 100644 --- a/server/conf/index/user_standard_index.html_it +++ b/server/conf/index/user_standard_index.html_it @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>Benvenuti!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/user_standard_index.html_nl b/server/conf/index/user_standard_index.html_nl index 94697f3..b3990a3 100644 --- a/server/conf/index/user_standard_index.html_nl +++ b/server/conf/index/user_standard_index.html_nl @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>Welkom!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/user_standard_index.html_pl b/server/conf/index/user_standard_index.html_pl index f5df92d..f1417e3 100644 --- a/server/conf/index/user_standard_index.html_pl +++ b/server/conf/index/user_standard_index.html_pl @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>Welcome!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/user_standard_index.html_se b/server/conf/index/user_standard_index.html_se index f83b03f..b38fb07 100644 --- a/server/conf/index/user_standard_index.html_se +++ b/server/conf/index/user_standard_index.html_se @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>V�lkommen!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/conf/index/user_standard_index.html_sr b/server/conf/index/user_standard_index.html_sr index 6d2293f..2abb7db 100644 --- a/server/conf/index/user_standard_index.html_sr +++ b/server/conf/index/user_standard_index.html_sr @@ -1,6 +1,7 @@ <HTML> <HEAD> <TITLE>Dobrodo�li!</TITLE> +<link rel="shortcut icon" href="/favicon.ico" /> </HEAD> <BODY BGCOLOR="#FFFFFF" leftMargin=0 topMargin=0 rightMargin=0 marginheight="0" marginwidth="0"> <CENTER> diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index da6d877..7f8628a 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -1,622 +1,1245 @@ -<?php - -/* -Copyright (c) 2007, Till Brehm, projektfarm Gmbh -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of ISPConfig nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -class apache2_plugin { - - var $plugin_name = 'apache2_plugin'; - var $class_name = 'apache2_plugin'; - - // private variables - var $action = ''; - - //* This function is called during ispconfig installation to determine - // if a symlink shall be created for this plugin. - function onInstall() { - global $conf; - - if($conf['services']['web'] == true) { - return true; - } else { - return false; - } - - } - - - /* - This function is called when the plugin is loaded - */ - - function onLoad() { - global $app; - - /* - Register for the events - */ - - - - $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'ssl'); - $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'ssl'); - $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'ssl'); - - $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert'); - $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update'); - $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'delete'); - - $app->plugins->registerEvent('server_ip_insert',$this->plugin_name,'server_ip'); - $app->plugins->registerEvent('server_ip_update',$this->plugin_name,'server_ip'); - $app->plugins->registerEvent('server_ip_delete',$this->plugin_name,'server_ip'); - - } - - // Handle the creation of SSL certificates - function ssl($event_name,$data) { - global $app, $conf; - - if(!is_dir($data["new"]["document_root"]."/ssl")) exec("mkdir -p ".$data["new"]["document_root"]."/ssl"); - $ssl_dir = $data["new"]["document_root"]."/ssl"; - $domain = $data["new"]["domain"]; - $key_file = $ssl_dir.'/'.$domain.".key.org"; - $key_file2 = $ssl_dir.'/'.$domain.".key"; - $csr_file = $ssl_dir.'/'.$domain.".csr"; - $crt_file = $ssl_dir.'/'.$domain.".crt"; - - //* Create a SSL Certificate - if($data["new"]["ssl_action"] == 'create') { - $rand_file = $ssl_dir."/random_file"; - $rand_data = md5(uniqid(microtime(),1)); - for($i=0; $i<1000; $i++){ - $rand_data .= md5(uniqid(microtime(),1)); - $rand_data .= md5(uniqid(microtime(),1)); - $rand_data .= md5(uniqid(microtime(),1)); - $rand_data .= md5(uniqid(microtime(),1)); - } - file_put_contents($rand_file, $rand_data); - - $ssl_password = substr(md5(uniqid(microtime(),1)), 0, 15); - - $ssl_cnf = " RANDFILE = $rand_file - - [ req ] - default_bits = 1024 - default_keyfile = keyfile.pem - distinguished_name = req_distinguished_name - attributes = req_attributes - prompt = no - output_password = $ssl_password - - [ req_distinguished_name ] - C = ".$data['new']['ssl_country']." - ST = ".$data['new']['ssl_state']." - L = ".$data['new']['ssl_locality']." - O = ".$data['new']['ssl_organisation']." - OU = ".$data['new']['ssl_organisation_unit']." - CN = $domain - emailAddress = webmaster@".$data['new']['domain']." - - [ req_attributes ] - challengePassword = A challenge password"; - - $ssl_cnf_file = $ssl_dir."/openssl.conf"; - file_put_contents($ssl_cnf_file,$ssl_cnf); - - $rand_file = escapeshellcmd($rand_file); - $key_file = escapeshellcmd($key_file); - $key_file2 = escapeshellcmd($key_file2); - $ssl_days = 3650; - $csr_file = escapeshellcmd($csr_file); - $config_file = escapeshellcmd($ssl_cnf_file); - $crt_file = escapeshellcmd($crt_file); - - if(is_file($ssl_cnf_file)){ - exec("openssl genrsa -des3 -rand $rand_file -passout pass:$ssl_password -out $key_file 1024 && openssl req -new -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -out $csr_file -days $ssl_days -config $config_file && openssl req -x509 -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -in $csr_file -out $crt_file -days $ssl_days -config $config_file && openssl rsa -passin pass:$ssl_password -in $key_file -out $key_file2"); - $app->log("Creating SSL Cert for: $domain",LOGLEVEL_DEBUG); - } - - exec("chmod 400 $key_file2"); - @unlink($config_file); - @unlink($rand_file); - $ssl_request = file_get_contents($csr_file); - $ssl_cert = file_get_contents($crt_file); - $app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data["new"]["domain"]."'"); - $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); - } - - //* Save a SSL certificate to disk - if($data["new"]["ssl_action"] == 'save') { - $ssl_dir = $data["new"]["document_root"]."/ssl"; - $domain = $data["new"]["domain"]; - $csr_file = $ssl_dir.'/'.$domain.".csr"; - $crt_file = $ssl_dir.'/'.$domain.".crt"; - $bundle_file = $ssl_dir.'/'.$domain.".bundle"; - file_put_contents($csr_file,$data["new"]["ssl_request"]); - file_put_contents($crt_file,$data["new"]["ssl_cert"]); - if(trim($data["new"]["ssl_bundle"]) != '') file_put_contents($bundle_file,$data["new"]["ssl_bundle"]); - $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); - $app->log("Saving SSL Cert for: $domain",LOGLEVEL_DEBUG); - } - - //* Delete a SSL certificate - if($data["new"]["ssl_action"] == 'del') { - $ssl_dir = $data["new"]["document_root"]."/ssl"; - $domain = $data["new"]["domain"]; - $csr_file = $ssl_dir.'/'.$domain.".csr"; - $crt_file = $ssl_dir.'/'.$domain.".crt"; - $bundle_file = $ssl_dir.'/'.$domain.".bundle"; - unlink($csr_file); - unlink($crt_file); - unlink($bundle_file); - $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); - $app->log("Deleting SSL Cert for: $domain",LOGLEVEL_DEBUG); - } - - - } - - - function insert($event_name,$data) { - global $app, $conf; - - $this->action = 'insert'; - // just run the update function - $this->update($event_name,$data); - - - } - - - function update($event_name,$data) { - global $app, $conf; - - if($this->action != 'insert') $this->action = 'update'; - - if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) { - - $old_parent_domain_id = intval($data["old"]["parent_domain_id"]); - $new_parent_domain_id = intval($data["new"]["parent_domain_id"]); - - // If the parent_domain_id has been chenged, we will have to update the old site as well. - if($data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) { - $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'"); - $data["new"] = $tmp; - $data["old"] = $tmp; - $this->action = 'update'; - $this->update($event_name,$data); - } - - // This is not a vhost, so we need to update the parent record instead. - $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'"); - $data["new"] = $tmp; - $data["old"] = $tmp; - $this->action = 'update'; - } - - - // load the server configuration options - $app->uses("getconf"); - $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); - - if($data["new"]["document_root"] == '') { - $app->log("document_root not set",LOGLEVEL_WARN); - return 0; - } - if($data["new"]["system_user"] == 'root' or $data["new"]["system_group"] == 'root') { - $app->log("Websites can not be owned by the root user or group.",LOGLEVEL_WARN); - return 0; - } - - //print_r($data); - - // Check if the directories are there and create them if nescessary. - if(!is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web"); - if(!is_dir($data["new"]["document_root"]."/web/error") and $data["new"]["errordocs"]) exec("mkdir -p ".$data["new"]["document_root"]."/web/error"); - //if(!is_dir($data["new"]["document_root"]."/log")) exec("mkdir -p ".$data["new"]["document_root"]."/log"); - if(!is_dir($data["new"]["document_root"]."/ssl")) exec("mkdir -p ".$data["new"]["document_root"]."/ssl"); - if(!is_dir($data["new"]["document_root"]."/cgi-bin")) exec("mkdir -p ".$data["new"]["document_root"]."/cgi-bin"); - if(!is_dir($data["new"]["document_root"]."/tmp")) exec("mkdir -p ".$data["new"]["document_root"]."/tmp"); - - // Remove the symlink for the site, if site is renamed - if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { - if(is_dir('/var/log/ispconfig/httpd/'.$data["old"]["domain"])) exec('rm -rf /var/log/ispconfig/httpd/'.$data["old"]["domain"]); - if(is_link($data["old"]["document_root"]."/log")) unlink($data["old"]["document_root"]."/log"); - } - - // Create the symlink for the logfiles - if(!is_dir('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data["new"]["domain"]); - if(!is_link($data["new"]["document_root"]."/log")) { - exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log"); - $app->log("Creating Symlink: ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log",LOGLEVEL_DEBUG); - } - /* - // Create the symlink for the logfiles - // This does not work as vlogger can not log trogh symlinks. - if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { - if(is_dir($data["old"]["document_root"]."/log")) exec('rm -rf '.$data["old"]["document_root"]."/log"); - if(is_link('/var/log/ispconfig/httpd/'.$data["old"]["domain"])) unlink('/var/log/ispconfig/httpd/'.$data["old"]["domain"]); - } - - // Create the symlink for the logfiles - if(!is_dir($data["new"]["document_root"]."/log")) exec('mkdir -p '.$data["new"]["document_root"]."/log"); - if(!is_link('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) { - exec("ln -s ".$data["new"]["document_root"]."/log /var/log/ispconfig/httpd/".$data["new"]["domain"]); - $app->log("Creating Symlink: ln -s ".$data["new"]["document_root"]."/log /var/log/ispconfig/httpd/".$data["new"]["domain"],LOGLEVEL_DEBUG); - } - */ - - // Get the client ID - $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["new"]["sys_groupid"])); - $client_id = intval($client["client_id"]); - unset($client); - - // Remove old symlinks, if site is renamed - if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { - $tmp_symlinks_array = explode(':',$web_config["website_symlinks"]); - if(is_array($tmp_symlinks_array)) { - foreach($tmp_symlinks_array as $tmp_symlink) { - $tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink); - $tmp_symlink = str_replace("[website_domain]",$data["old"]["domain"],$tmp_symlink); - // Remove trailing slash - if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); - // create the symlinks, if not exist - if(!is_link($tmp_symlink)) { - exec("rm -f ".escapeshellcmd($tmp_symlink)); - $app->log("Removed Symlink: rm -f ".$tmp_symlink,LOGLEVEL_DEBUG); - } - } - } - } - - // Create the symlinks for the sites - $tmp_symlinks_array = explode(':',$web_config["website_symlinks"]); - if(is_array($tmp_symlinks_array)) { - foreach($tmp_symlinks_array as $tmp_symlink) { - $tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink); - $tmp_symlink = str_replace("[website_domain]",$data["new"]["domain"],$tmp_symlink); - // Remove trailing slash - if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); - //* Remove symlink if target folder has been changed. - if($data["old"]["document_root"] != '' && $data["old"]["document_root"] != $data["new"]["document_root"] && is_link($tmp_symlink)) { - unlink($tmp_symlink); - } - // create the symlinks, if not exist - if(!is_link($tmp_symlink)) { - exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink)); - $app->log("Creating Symlink: ln -s ".$data["new"]["document_root"]."/ ".$tmp_symlink,LOGLEVEL_DEBUG); - } - } - } - - - if($this->action == 'insert' && $data["new"]["type"] == 'vhost') { - // Copy the error pages - if($data["new"]["errordocs"]){ - $error_page_path = escapeshellcmd($data["new"]["document_root"])."/web/error/"; - if (file_exists("/usr/local/ispconfig/server/conf-custom/error/".substr(escapeshellcmd($conf["language"]),0,2))){ - exec("cp /usr/local/ispconfig/server/conf-custom/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path); - } - else { - if (file_exists("/usr/local/ispconfig/server/conf-custom/error/fileNotFound.html")){ - exec("cp /usr/local/ispconfig/server/conf-custom/error/*.html ".$error_page_path); - } - else { - exec("cp /usr/local/ispconfig/server/conf/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path); - } - } - exec("chmod -R +r ".$error_page_path); - } - - // copy the standard index page - if (file_exists("/usr/local/ispconfig/server/conf-custom/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2))){ - exec("cp /usr/local/ispconfig/server/conf-custom/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2)." ".escapeshellcmd($data["new"]["document_root"])."/web/index.html"); - } - else { - if (file_exists("/usr/local/ispconfig/server/conf-custom/index/standard_index.html")){ - exec("cp /usr/local/ispconfig/server/conf-custom/index/standard_index.html ".escapeshellcmd($data["new"]["document_root"])."/web/index.html"); - } - else { - exec("cp /usr/local/ispconfig/server/conf/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2)." ".escapeshellcmd($data["new"]["document_root"])."/web/index.html"); - } - } - exec("chmod +r ".escapeshellcmd($data["new"]["document_root"])."/web/index.html"); - } - - // Create group and user, if not exist - $app->uses("system"); - - $groupname = escapeshellcmd($data["new"]["system_group"]); - if($data["new"]["system_group"] != '' && !$app->system->is_group($data["new"]["system_group"])) { - exec("groupadd $groupname"); - $app->log("Adding the group: $groupname",LOGLEVEL_DEBUG); - } - - $username = escapeshellcmd($data["new"]["system_user"]); - if($data["new"]["system_user"] != '' && !$app->system->is_user($data["new"]["system_user"])) { - exec("useradd -d ".escapeshellcmd($data["new"]["document_root"])." -g $groupname $username -s /bin/false"); - $app->log("Adding the user: $username",LOGLEVEL_DEBUG); - } - - // Set the quota for the user - if($username != '' && $app->system->is_user($username)) { - if($data["new"]["hd_quota"] > 0){ - $blocks_soft = $data["new"]["hd_quota"] * 1024; - $blocks_hard = $blocks_soft + 1024; - } else { - $blocks_soft = $blocks_hard = 0; - } - exec("setquota -u $username $blocks_soft $blocks_hard 0 0 -a &> /dev/null"); - exec("setquota -T -u $username 604800 604800 -a &> /dev/null"); - } - - - - // Chown and chmod the directories - exec("chown -R $username:$groupname ".escapeshellcmd($data["new"]["document_root"])); - - // make temp direcory writable for the apache user and the website user - exec("chmod 777 ".escapeshellcmd($data["new"]["document_root"]."/tmp")); - - - // Create the vhost config file - $app->load('tpl'); - - $tpl = new tpl(); - $tpl->newTemplate("vhost.conf.master"); - - $vhost_data = $data["new"]; - $vhost_data["web_document_root"] = $data["new"]["document_root"]."/web"; - $vhost_data["web_document_root_www"] = "/var/www/".$data["new"]["domain"]."/web"; - - // Check if a SSL cert exists - $ssl_dir = $data["new"]["document_root"]."/ssl"; - $domain = $data["new"]["domain"]; - $key_file = $ssl_dir.'/'.$domain.".key"; - $crt_file = $ssl_dir.'/'.$domain.".crt"; - $bundle_file = $ssl_dir.'/'.$domain.".bundle"; - - if($data["new"]["ssl"] == 'y' && @is_file($crt_file) && @is_file($key_file)) { - $vhost_data["ssl_enabled"] = 1; - $app->log("Enable SSL for: $domain",LOGLEVEL_DEBUG); - } else { - $vhost_data["ssl_enabled"] = 0; - $app->log("Disable SSL for: $domain",LOGLEVEL_DEBUG); - } - - if(@is_file($bundle_file)) $vhost_data['has_bundle_cert'] = 1; - - //$vhost_data["document_root"] = $data["new"]["document_root"]."/web"; - $tpl->setVar($vhost_data); - - // Rewrite rules - $rewrite_rules = array(); - if($data["new"]["redirect_type"] != '') { - $rewrite_rules[] = array( 'rewrite_domain' => $data["new"]["domain"], - 'rewrite_type' => $data["new"]["redirect_type"], - 'rewrite_target' => $data["new"]["redirect_path"]); - } - - // get alias domains (co-domains and subdomains) - $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]." AND active = 'y'"); - switch($data["new"]["subdomain"]) { - case 'www': - $server_alias .= 'www.'.$data["new"]["domain"].' '; - break; - case '*': - $server_alias .= '*.'.$data["new"]["domain"].' '; - break; - } - if(is_array($aliases)) { - foreach($aliases as $alias) { - switch($alias["subdomain"]) { - case 'www': - $server_alias .= 'www.'.$alias["domain"].' '.$alias["domain"].' '; - break; - case '*': - $server_alias .= '*.'.$alias["domain"].' '.$alias["domain"].' '; - break; - default: - $server_alias .= $alias["domain"].' '; - break; - } - $app->log("Add server alias: $alias[domain]",LOGLEVEL_DEBUG); - // Rewriting - if($alias["redirect_type"] != '') { - $rewrite_rules[] = array( 'rewrite_domain' => $alias["domain"], - 'rewrite_type' => $alias["redirect_type"], - 'rewrite_target' => $alias["redirect_path"]); - } - } - } - $tpl->setVar('alias',trim($server_alias)); - if(count($rewrite_rules) > 0) { - $tpl->setVar('rewrite_enabled',1); - } else { - $tpl->setVar('rewrite_enabled',0); - } - $tpl->setLoop('redirects',$rewrite_rules); - - /** - * install fast-cgi starter script and add script aliasd config - * first we create the script directory if not already created, then copy over the starter script - * settings are copied over from the server ini config for now - * TODO: Create form for fastcgi configs per site. - */ - - if ($data["new"]["php"] == "fast-cgi") - { - $fastcgi_config = $app->getconf->get_server_config($conf["server_id"], 'fastcgi'); - - $fastcgi_starter_path = str_replace("[system_user]",$data["new"]["system_user"],$fastcgi_config["fastcgi_starter_path"]); - $fastcgi_starter_path = str_replace("[client_id]",$client_id,$fastcgi_starter_path); - - if (!is_dir($fastcgi_starter_path)) - { - exec("mkdir -p ".escapeshellcmd($fastcgi_starter_path)); - exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." ".escapeshellcmd($fastcgi_starter_path)); - - - $app->log("Creating fastcgi starter script directory: $fastcgi_starter_path",LOGLEVEL_DEBUG); - } - - $fcgi_tpl = new tpl(); - $fcgi_tpl->newTemplate("php-fcgi-starter.master"); - - $fcgi_tpl->setVar('php_ini_path',$fastcgi_config["fastcgi_phpini_path"]); - $fcgi_tpl->setVar('document_root',$data["new"]["document_root"]); - $fcgi_tpl->setVar('php_fcgi_children',$fastcgi_config["fastcgi_children"]); - $fcgi_tpl->setVar('php_fcgi_max_requests',$fastcgi_config["fastcgi_max_requests"]); - $fcgi_tpl->setVar('php_fcgi_bin',$fastcgi_config["fastcgi_bin"]); - - $fcgi_starter_script = escapeshellcmd($fastcgi_starter_path.$fastcgi_config["fastcgi_starter_script"]); - file_put_contents($fcgi_starter_script,$fcgi_tpl->grab()); - unset($fcgi_tpl); - - $app->log("Creating fastcgi starter script: $fcgi_starter_script",LOGLEVEL_DEBUG); - - - exec("chmod 755 $fcgi_starter_script"); - exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." $fcgi_starter_script"); - - $tpl->setVar('fastcgi_alias',$fastcgi_config["fastcgi_alias"]); - $tpl->setVar('fastcgi_starter_path',$fastcgi_starter_path); - $tpl->setVar('fastcgi_starter_script',$fastcgi_config["fastcgi_starter_script"]); - - } - - $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["new"]["domain"].'.vhost'); - file_put_contents($vhost_file,$tpl->grab()); - $app->log("Writing the vhost file: $vhost_file",LOGLEVEL_DEBUG); - unset($tpl); - - // Set the symlink to enable the vhost - $vhost_symlink = escapeshellcmd($web_config["vhost_conf_enabled_dir"].'/'.$data["new"]["domain"].'.vhost'); - if($data["new"]["active"] == 'y' && !is_link($vhost_symlink)) { - symlink($vhost_file,$vhost_symlink); - $app->log("Creating the symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); - } - - // Remove the symlink, if site is inactive - if($data["new"]["active"] == 'n' && is_link($vhost_symlink)) { - unlink($vhost_symlink); - $app->log("Removing symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); - } - - // remove old symlink and vhost file, if domain name of the site has changed - if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { - $vhost_symlink = escapeshellcmd($web_config["vhost_conf_enabled_dir"].'/'.$data["old"]["domain"].'.vhost'); - unlink($vhost_symlink); - $app->log("Removing symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); - $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["old"]["domain"].'.vhost'); - unlink($vhost_file); - $app->log("Removing File $vhost_file",LOGLEVEL_DEBUG); - } - - // request a httpd reload when all records have been processed - $app->services->restartServiceDelayed('httpd','reload'); - - } - - function delete($event_name,$data) { - global $app, $conf; - - // load the server configuration options - $app->uses("getconf"); - $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); - - // Deleting the vhost file, symlink and the data directory - $vhost_symlink = escapeshellcmd($web_config["vhost_conf_enabled_dir"].'/'.$data["old"]["domain"].'.vhost'); - unlink($vhost_symlink); - $app->log("Removing symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); - - $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["old"]["domain"].'.vhost'); - unlink($vhost_file); - $app->log("Removing vhost file: $vhost_file",LOGLEVEL_DEBUG); - - $docroot = escapeshellcmd($data["old"]["document_root"]); - if($docroot != '' && !stristr($docroot,'..')) exec("rm -rf $docroot"); - - - //remove the php fastgi starter script if available - if ($data["old"]["php"] == "fast-cgi") - { - $fastcgi_starter_path = str_replace("[system_user]",$data["old"]["system_user"],$web_config["fastcgi_starter_path"]); - if (is_dir($fastcgi_starter_path)) - { - exec("rm -rf $fastcgi_starter_path"); - } - } - - $app->log("Removing website: $docroot",LOGLEVEL_DEBUG); - - // Delete the symlinks for the sites - $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["old"]["sys_groupid"])); - $client_id = intval($client["client_id"]); - unset($client); - $tmp_symlinks_array = explode(':',$web_config["website_symlinks"]); - if(is_array($tmp_symlinks_array)) { - foreach($tmp_symlinks_array as $tmp_symlink) { - $tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink); - $tmp_symlink = str_replace("[website_domain]",$data["old"]["domain"],$tmp_symlink); - // Remove trailing slash - if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); - // create the symlinks, if not exist - if(is_link($tmp_symlink)) { - unlink($tmp_symlink); - $app->log("Removing symlink: ".$tmp_symlink,LOGLEVEL_DEBUG); - } - } - } - // end removing symlinks - - // Delete the log file directory - $vhost_logfile_dir = escapeshellcmd('/var/log/ispconfig/httpd/'.$data["old"]["domain"]); - if($data["old"]["domain"] != '' && !stristr($vhost_logfile_dir,'..')) exec("rm -rf $vhost_logfile_dir"); - $app->log("Removing website logfile directory: $vhost_logfile_dir",LOGLEVEL_DEBUG); - - //delete the web user - $command = 'userdel'; - $command .= ' '.$data["old"]["system_user"]; - exec($command); - } - - //* This function is called when a IP on the server is inserted, updated or deleted - function server_ip($event_name,$data) { - global $app, $conf; - - // Here we write the name virtualhost directives - // NameVirtualHost IP:80 - // NameVirtualHost IP:443 - - } - - -} // end class - +<<<<<<< .mine +<?php + +/* +Copyright (c) 2007, Till Brehm, projektfarm Gmbh +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +class apache2_plugin { + + var $plugin_name = 'apache2_plugin'; + var $class_name = 'apache2_plugin'; + + // private variables + var $action = ''; + + //* This function is called during ispconfig installation to determine + // if a symlink shall be created for this plugin. + function onInstall() { + global $conf; + + if($conf['services']['web'] == true) { + return true; + } else { + return false; + } + + } + + + /* + This function is called when the plugin is loaded + */ + + function onLoad() { + global $app; + + /* + Register for the events + */ + + + + $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'ssl'); + $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'ssl'); + $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'ssl'); + + $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert'); + $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update'); + $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'delete'); + + $app->plugins->registerEvent('server_ip_insert',$this->plugin_name,'server_ip'); + $app->plugins->registerEvent('server_ip_update',$this->plugin_name,'server_ip'); + $app->plugins->registerEvent('server_ip_delete',$this->plugin_name,'server_ip'); + + } + + // Handle the creation of SSL certificates + function ssl($event_name,$data) { + global $app, $conf; + + if(!is_dir($data["new"]["document_root"]."/ssl")) exec("mkdir -p ".$data["new"]["document_root"]."/ssl"); + $ssl_dir = $data["new"]["document_root"]."/ssl"; + $domain = $data["new"]["domain"]; + $key_file = $ssl_dir.'/'.$domain.".key.org"; + $key_file2 = $ssl_dir.'/'.$domain.".key"; + $csr_file = $ssl_dir.'/'.$domain.".csr"; + $crt_file = $ssl_dir.'/'.$domain.".crt"; + + //* Create a SSL Certificate + if($data["new"]["ssl_action"] == 'create') { + $rand_file = $ssl_dir."/random_file"; + $rand_data = md5(uniqid(microtime(),1)); + for($i=0; $i<1000; $i++){ + $rand_data .= md5(uniqid(microtime(),1)); + $rand_data .= md5(uniqid(microtime(),1)); + $rand_data .= md5(uniqid(microtime(),1)); + $rand_data .= md5(uniqid(microtime(),1)); + } + file_put_contents($rand_file, $rand_data); + + $ssl_password = substr(md5(uniqid(microtime(),1)), 0, 15); + + $ssl_cnf = " RANDFILE = $rand_file + + [ req ] + default_bits = 1024 + default_keyfile = keyfile.pem + distinguished_name = req_distinguished_name + attributes = req_attributes + prompt = no + output_password = $ssl_password + + [ req_distinguished_name ] + C = ".$data['new']['ssl_country']." + ST = ".$data['new']['ssl_state']." + L = ".$data['new']['ssl_locality']." + O = ".$data['new']['ssl_organisation']." + OU = ".$data['new']['ssl_organisation_unit']." + CN = $domain + emailAddress = webmaster@".$data['new']['domain']." + + [ req_attributes ] + challengePassword = A challenge password"; + + $ssl_cnf_file = $ssl_dir."/openssl.conf"; + file_put_contents($ssl_cnf_file,$ssl_cnf); + + $rand_file = escapeshellcmd($rand_file); + $key_file = escapeshellcmd($key_file); + $key_file2 = escapeshellcmd($key_file2); + $ssl_days = 3650; + $csr_file = escapeshellcmd($csr_file); + $config_file = escapeshellcmd($ssl_cnf_file); + $crt_file = escapeshellcmd($crt_file); + + if(is_file($ssl_cnf_file)){ + exec("openssl genrsa -des3 -rand $rand_file -passout pass:$ssl_password -out $key_file 1024 && openssl req -new -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -out $csr_file -days $ssl_days -config $config_file && openssl req -x509 -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -in $csr_file -out $crt_file -days $ssl_days -config $config_file && openssl rsa -passin pass:$ssl_password -in $key_file -out $key_file2"); + $app->log("Creating SSL Cert for: $domain",LOGLEVEL_DEBUG); + } + + exec("chmod 400 $key_file2"); + @unlink($config_file); + @unlink($rand_file); + $ssl_request = file_get_contents($csr_file); + $ssl_cert = file_get_contents($crt_file); + $app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data["new"]["domain"]."'"); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); + } + + //* Save a SSL certificate to disk + if($data["new"]["ssl_action"] == 'save') { + $ssl_dir = $data["new"]["document_root"]."/ssl"; + $domain = $data["new"]["domain"]; + $csr_file = $ssl_dir.'/'.$domain.".csr"; + $crt_file = $ssl_dir.'/'.$domain.".crt"; + $bundle_file = $ssl_dir.'/'.$domain.".bundle"; + file_put_contents($csr_file,$data["new"]["ssl_request"]); + file_put_contents($crt_file,$data["new"]["ssl_cert"]); + if(trim($data["new"]["ssl_bundle"]) != '') file_put_contents($bundle_file,$data["new"]["ssl_bundle"]); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); + $app->log("Saving SSL Cert for: $domain",LOGLEVEL_DEBUG); + } + + //* Delete a SSL certificate + if($data["new"]["ssl_action"] == 'del') { + $ssl_dir = $data["new"]["document_root"]."/ssl"; + $domain = $data["new"]["domain"]; + $csr_file = $ssl_dir.'/'.$domain.".csr"; + $crt_file = $ssl_dir.'/'.$domain.".crt"; + $bundle_file = $ssl_dir.'/'.$domain.".bundle"; + unlink($csr_file); + unlink($crt_file); + unlink($bundle_file); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); + $app->log("Deleting SSL Cert for: $domain",LOGLEVEL_DEBUG); + } + + + } + + + function insert($event_name,$data) { + global $app, $conf; + + $this->action = 'insert'; + // just run the update function + $this->update($event_name,$data); + + + } + + + function update($event_name,$data) { + global $app, $conf; + + if($this->action != 'insert') $this->action = 'update'; + + if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) { + + $old_parent_domain_id = intval($data["old"]["parent_domain_id"]); + $new_parent_domain_id = intval($data["new"]["parent_domain_id"]); + + // If the parent_domain_id has been chenged, we will have to update the old site as well. + if($data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) { + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'"); + $data["new"] = $tmp; + $data["old"] = $tmp; + $this->action = 'update'; + $this->update($event_name,$data); + } + + // This is not a vhost, so we need to update the parent record instead. + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'"); + $data["new"] = $tmp; + $data["old"] = $tmp; + $this->action = 'update'; + } + + + // load the server configuration options + $app->uses("getconf"); + $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); + + if($data["new"]["document_root"] == '') { + $app->log("document_root not set",LOGLEVEL_WARN); + return 0; + } + if($data["new"]["system_user"] == 'root' or $data["new"]["system_group"] == 'root') { + $app->log("Websites can not be owned by the root user or group.",LOGLEVEL_WARN); + return 0; + } + + //print_r($data); + + // Check if the directories are there and create them if nescessary. + if(!is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web"); + if(!is_dir($data["new"]["document_root"]."/web/error") and $data["new"]["errordocs"]) exec("mkdir -p ".$data["new"]["document_root"]."/web/error"); + //if(!is_dir($data["new"]["document_root"]."/log")) exec("mkdir -p ".$data["new"]["document_root"]."/log"); + if(!is_dir($data["new"]["document_root"]."/ssl")) exec("mkdir -p ".$data["new"]["document_root"]."/ssl"); + if(!is_dir($data["new"]["document_root"]."/cgi-bin")) exec("mkdir -p ".$data["new"]["document_root"]."/cgi-bin"); + if(!is_dir($data["new"]["document_root"]."/tmp")) exec("mkdir -p ".$data["new"]["document_root"]."/tmp"); + + // Remove the symlink for the site, if site is renamed + if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { + if(is_dir('/var/log/ispconfig/httpd/'.$data["old"]["domain"])) exec('rm -rf /var/log/ispconfig/httpd/'.$data["old"]["domain"]); + if(is_link($data["old"]["document_root"]."/log")) unlink($data["old"]["document_root"]."/log"); + } + + // Create the symlink for the logfiles + if(!is_dir('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data["new"]["domain"]); + if(!is_link($data["new"]["document_root"]."/log")) { + exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log"); + $app->log("Creating Symlink: ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log",LOGLEVEL_DEBUG); + } + /* + // Create the symlink for the logfiles + // This does not work as vlogger can not log trogh symlinks. + if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { + if(is_dir($data["old"]["document_root"]."/log")) exec('rm -rf '.$data["old"]["document_root"]."/log"); + if(is_link('/var/log/ispconfig/httpd/'.$data["old"]["domain"])) unlink('/var/log/ispconfig/httpd/'.$data["old"]["domain"]); + } + + // Create the symlink for the logfiles + if(!is_dir($data["new"]["document_root"]."/log")) exec('mkdir -p '.$data["new"]["document_root"]."/log"); + if(!is_link('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) { + exec("ln -s ".$data["new"]["document_root"]."/log /var/log/ispconfig/httpd/".$data["new"]["domain"]); + $app->log("Creating Symlink: ln -s ".$data["new"]["document_root"]."/log /var/log/ispconfig/httpd/".$data["new"]["domain"],LOGLEVEL_DEBUG); + } + */ + + // Get the client ID + $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["new"]["sys_groupid"])); + $client_id = intval($client["client_id"]); + unset($client); + + // Remove old symlinks, if site is renamed + if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { + $tmp_symlinks_array = explode(':',$web_config["website_symlinks"]); + if(is_array($tmp_symlinks_array)) { + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink); + $tmp_symlink = str_replace("[website_domain]",$data["old"]["domain"],$tmp_symlink); + // Remove trailing slash + if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); + // create the symlinks, if not exist + if(!is_link($tmp_symlink)) { + exec("rm -f ".escapeshellcmd($tmp_symlink)); + $app->log("Removed Symlink: rm -f ".$tmp_symlink,LOGLEVEL_DEBUG); + } + } + } + } + + // Create the symlinks for the sites + $tmp_symlinks_array = explode(':',$web_config["website_symlinks"]); + if(is_array($tmp_symlinks_array)) { + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink); + $tmp_symlink = str_replace("[website_domain]",$data["new"]["domain"],$tmp_symlink); + // Remove trailing slash + if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); + // create the symlinks, if not exist + if(!is_link($tmp_symlink)) { + exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink)); + $app->log("Creating Symlink: ln -s ".$data["new"]["document_root"]."/ ".$tmp_symlink,LOGLEVEL_DEBUG); + } + } + } + + + if($this->action == 'insert' && $data["new"]["type"] == 'vhost') { + // Copy the error pages + if($data["new"]["errordocs"]){ + $error_page_path = escapeshellcmd($data["new"]["document_root"])."/web/error/"; + if (file_exists("/usr/local/ispconfig/server/conf-custom/error/".substr(escapeshellcmd($conf["language"]),0,2))){ + exec("cp /usr/local/ispconfig/server/conf-custom/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path); + } + else { + if (file_exists("/usr/local/ispconfig/server/conf-custom/error/fileNotFound.html")){ + exec("cp /usr/local/ispconfig/server/conf-custom/error/*.html ".$error_page_path); + } + else { + exec("cp /usr/local/ispconfig/server/conf/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path); + } + } + exec("chmod -R +r ".$error_page_path); + } + + // copy the standard index page + if (file_exists("/usr/local/ispconfig/server/conf-custom/index/".substr(escapeshellcmd($conf["language"]),0,2)."/index.html")){ + exec("cp /usr/local/ispconfig/server/conf-custom/index/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".escapeshellcmd($data["new"]["document_root"])."/web/"); + } + else { + if (file_exists("/usr/local/ispconfig/server/conf-custom/index/default/index.html")){ + exec("cp /usr/local/ispconfig/server/conf-custom/index/default/* ".escapeshellcmd($data["new"]["document_root"])."/web/"); + } + else { + exec("cp /usr/local/ispconfig/server/conf/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2)." ".escapeshellcmd($data["new"]["document_root"])."/web/index.html"); + exec("cp /usr/local/ispconfig/server/conf/index/favicon.ico ".escapeshellcmd($data["new"]["document_root"])."/web/"); + exec("cp /usr/local/ispconfig/server/conf/index/robots.txt ".escapeshellcmd($data["new"]["document_root"])."/web/"); + exec("cp /usr/local/ispconfig/server/conf/index/.htaccess ".escapeshellcmd($data["new"]["document_root"])."/web/"); + } + } + exec("chmod +r ".escapeshellcmd($data["new"]["document_root"])."/web"); + } + + // Create group and user, if not exist + $app->uses("system"); + + $groupname = escapeshellcmd($data["new"]["system_group"]); + if($data["new"]["system_group"] != '' && !$app->system->is_group($data["new"]["system_group"])) { + exec("groupadd $groupname"); + $app->log("Adding the group: $groupname",LOGLEVEL_DEBUG); + } + + $username = escapeshellcmd($data["new"]["system_user"]); + if($data["new"]["system_user"] != '' && !$app->system->is_user($data["new"]["system_user"])) { + exec("useradd -d ".escapeshellcmd($data["new"]["document_root"])." -g $groupname $username -s /bin/false"); + $app->log("Adding the user: $username",LOGLEVEL_DEBUG); + } + + // Set the quota for the user + if($username != '' && $app->system->is_user($username)) { + if($data["new"]["hd_quota"] > 0){ + $blocks_soft = $data["new"]["hd_quota"] * 1024; + $blocks_hard = $blocks_soft + 1024; + } else { + $blocks_soft = $blocks_hard = 0; + } + exec("setquota -u $username $blocks_soft $blocks_hard 0 0 -a &> /dev/null"); + exec("setquota -T -u $username 604800 604800 -a &> /dev/null"); + } + + + + // Chown and chmod the directories + exec("chown -R $username:$groupname ".escapeshellcmd($data["new"]["document_root"])); + + // make temp direcory writable for the apache user and the website user + exec("chmod 777 ".escapeshellcmd($data["new"]["document_root"]."/tmp")); + + + // Create the vhost config file + $app->load('tpl'); + + $tpl = new tpl(); + $tpl->newTemplate("vhost.conf.master"); + + $vhost_data = $data["new"]; + $vhost_data["web_document_root"] = $data["new"]["document_root"]."/web"; + $vhost_data["web_document_root_www"] = "/var/www/".$data["new"]["domain"]."/web"; + + // Check if a SSL cert exists + $ssl_dir = $data["new"]["document_root"]."/ssl"; + $domain = $data["new"]["domain"]; + $key_file = $ssl_dir.'/'.$domain.".key"; + $crt_file = $ssl_dir.'/'.$domain.".crt"; + $bundle_file = $ssl_dir.'/'.$domain.".bundle"; + + if($data["new"]["ssl"] == 'y' && @is_file($crt_file) && @is_file($key_file)) { + $vhost_data["ssl_enabled"] = 1; + $app->log("Enable SSL for: $domain",LOGLEVEL_DEBUG); + } else { + $vhost_data["ssl_enabled"] = 0; + $app->log("Disable SSL for: $domain",LOGLEVEL_DEBUG); + } + + if(@is_file($bundle_file)) $vhost_data['has_bundle_cert'] = 1; + + //$vhost_data["document_root"] = $data["new"]["document_root"]."/web"; + $tpl->setVar($vhost_data); + + // Rewrite rules + $rewrite_rules = array(); + if($data["new"]["redirect_type"] != '') { + $rewrite_rules[] = array( 'rewrite_domain' => $data["new"]["domain"], + 'rewrite_type' => $data["new"]["redirect_type"], + 'rewrite_target' => $data["new"]["redirect_path"]); + } + + // get alias domains (co-domains and subdomains) + $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]." AND active = 'y'"); + switch($data["new"]["subdomain"]) { + case 'www': + $server_alias .= 'www.'.$data["new"]["domain"].' '; + break; + case '*': + $server_alias .= '*.'.$data["new"]["domain"].' '; + break; + } + if(is_array($aliases)) { + foreach($aliases as $alias) { + switch($alias["subdomain"]) { + case 'www': + $server_alias .= 'www.'.$alias["domain"].' '.$alias["domain"].' '; + break; + case '*': + $server_alias .= '*.'.$alias["domain"].' '.$alias["domain"].' '; + break; + default: + $server_alias .= $alias["domain"].' '; + break; + } + $app->log("Add server alias: $alias[domain]",LOGLEVEL_DEBUG); + // Rewriting + if($alias["redirect_type"] != '') { + $rewrite_rules[] = array( 'rewrite_domain' => $alias["domain"], + 'rewrite_type' => $alias["redirect_type"], + 'rewrite_target' => $alias["redirect_path"]); + } + } + } + $tpl->setVar('alias',trim($server_alias)); + if(count($rewrite_rules) > 0) { + $tpl->setVar('rewrite_enabled',1); + } else { + $tpl->setVar('rewrite_enabled',0); + } + $tpl->setLoop('redirects',$rewrite_rules); + + /** + * install fast-cgi starter script and add script aliasd config + * first we create the script directory if not already created, then copy over the starter script + * settings are copied over from the server ini config for now + * TODO: Create form for fastcgi configs per site. + */ + + if ($data["new"]["php"] == "fast-cgi") + { + $fastcgi_config = $app->getconf->get_server_config($conf["server_id"], 'fastcgi'); + + $fastcgi_starter_path = str_replace("[system_user]",$data["new"]["system_user"],$fastcgi_config["fastcgi_starter_path"]); + $fastcgi_starter_path = str_replace("[client_id]",$client_id,$fastcgi_starter_path); + + if (!is_dir($fastcgi_starter_path)) + { + exec("mkdir -p ".escapeshellcmd($fastcgi_starter_path)); + exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." ".escapeshellcmd($fastcgi_starter_path)); + + + $app->log("Creating fastcgi starter script directory: $fastcgi_starter_path",LOGLEVEL_DEBUG); + } + + $fcgi_tpl = new tpl(); + $fcgi_tpl->newTemplate("php-fcgi-starter.master"); + + $fcgi_tpl->setVar('php_ini_path',$fastcgi_config["fastcgi_phpini_path"]); + $fcgi_tpl->setVar('document_root',$data["new"]["document_root"]); + $fcgi_tpl->setVar('php_fcgi_children',$fastcgi_config["fastcgi_children"]); + $fcgi_tpl->setVar('php_fcgi_max_requests',$fastcgi_config["fastcgi_max_requests"]); + $fcgi_tpl->setVar('php_fcgi_bin',$fastcgi_config["fastcgi_bin"]); + + $fcgi_starter_script = escapeshellcmd($fastcgi_starter_path.$fastcgi_config["fastcgi_starter_script"]); + file_put_contents($fcgi_starter_script,$fcgi_tpl->grab()); + unset($fcgi_tpl); + + $app->log("Creating fastcgi starter script: $fcgi_starter_script",LOGLEVEL_DEBUG); + + + exec("chmod 755 $fcgi_starter_script"); + exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." $fcgi_starter_script"); + + $tpl->setVar('fastcgi_alias',$fastcgi_config["fastcgi_alias"]); + $tpl->setVar('fastcgi_starter_path',$fastcgi_starter_path); + $tpl->setVar('fastcgi_starter_script',$fastcgi_config["fastcgi_starter_script"]); + + } + + $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["new"]["domain"].'.vhost'); + file_put_contents($vhost_file,$tpl->grab()); + $app->log("Writing the vhost file: $vhost_file",LOGLEVEL_DEBUG); + unset($tpl); + + // Set the symlink to enable the vhost + $vhost_symlink = escapeshellcmd($web_config["vhost_conf_enabled_dir"].'/'.$data["new"]["domain"].'.vhost'); + if($data["new"]["active"] == 'y' && !is_link($vhost_symlink)) { + symlink($vhost_file,$vhost_symlink); + $app->log("Creating the symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); + } + + // Remove the symlink, if site is inactive + if($data["new"]["active"] == 'n' && is_link($vhost_symlink)) { + unlink($vhost_symlink); + $app->log("Removing symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); + } + + // remove old symlink and vhost file, if domain name of the site has changed + if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { + $vhost_symlink = escapeshellcmd($web_config["vhost_conf_enabled_dir"].'/'.$data["old"]["domain"].'.vhost'); + unlink($vhost_symlink); + $app->log("Removing symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); + $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["old"]["domain"].'.vhost'); + unlink($vhost_file); + $app->log("Removing File $vhost_file",LOGLEVEL_DEBUG); + } + + // request a httpd reload when all records have been processed + $app->services->restartServiceDelayed('httpd','reload'); + + } + + function delete($event_name,$data) { + global $app, $conf; + + // load the server configuration options + $app->uses("getconf"); + $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); + + // Deleting the vhost file, symlink and the data directory + $vhost_symlink = escapeshellcmd($web_config["vhost_conf_enabled_dir"].'/'.$data["old"]["domain"].'.vhost'); + unlink($vhost_symlink); + $app->log("Removing symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); + + $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["old"]["domain"].'.vhost'); + unlink($vhost_file); + $app->log("Removing vhost file: $vhost_file",LOGLEVEL_DEBUG); + + $docroot = escapeshellcmd($data["old"]["document_root"]); + if($docroot != '' && !stristr($docroot,'..')) exec("rm -rf $docroot"); + + + //remove the php fastgi starter script if available + if ($data["old"]["php"] == "fast-cgi") + { + $fastcgi_starter_path = str_replace("[system_user]",$data["old"]["system_user"],$web_config["fastcgi_starter_path"]); + if (is_dir($fastcgi_starter_path)) + { + exec("rm -rf $fastcgi_starter_path"); + } + } + + $app->log("Removing website: $docroot",LOGLEVEL_DEBUG); + + // Delete the symlinks for the sites + $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["old"]["sys_groupid"])); + $client_id = intval($client["client_id"]); + unset($client); + $tmp_symlinks_array = explode(':',$web_config["website_symlinks"]); + if(is_array($tmp_symlinks_array)) { + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink); + $tmp_symlink = str_replace("[website_domain]",$data["old"]["domain"],$tmp_symlink); + // Remove trailing slash + if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); + // create the symlinks, if not exist + if(is_link($tmp_symlink)) { + unlink($tmp_symlink); + $app->log("Removing symlink: ".$tmp_symlink,LOGLEVEL_DEBUG); + } + } + } + // end removing symlinks + + // Delete the log file directory + $vhost_logfile_dir = escapeshellcmd('/var/log/ispconfig/httpd/'.$data["old"]["domain"]); + if($data["old"]["domain"] != '' && !stristr($vhost_logfile_dir,'..')) exec("rm -rf $vhost_logfile_dir"); + $app->log("Removing website logfile directory: $vhost_logfile_dir",LOGLEVEL_DEBUG); + + //delete the web user + $command = 'userdel'; + $command .= ' '.$data["old"]["system_user"]; + exec($command); + } + + //* This function is called when a IP on the server is inserted, updated or deleted + function server_ip($event_name,$data) { + global $app, $conf; + + // Here we write the name virtualhost directives + // NameVirtualHost IP:80 + // NameVirtualHost IP:443 + + } + + +} // end class + +======= +<?php + +/* +Copyright (c) 2007, Till Brehm, projektfarm Gmbh +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +class apache2_plugin { + + var $plugin_name = 'apache2_plugin'; + var $class_name = 'apache2_plugin'; + + // private variables + var $action = ''; + + //* This function is called during ispconfig installation to determine + // if a symlink shall be created for this plugin. + function onInstall() { + global $conf; + + if($conf['services']['web'] == true) { + return true; + } else { + return false; + } + + } + + + /* + This function is called when the plugin is loaded + */ + + function onLoad() { + global $app; + + /* + Register for the events + */ + + + + $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'ssl'); + $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'ssl'); + $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'ssl'); + + $app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert'); + $app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update'); + $app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'delete'); + + $app->plugins->registerEvent('server_ip_insert',$this->plugin_name,'server_ip'); + $app->plugins->registerEvent('server_ip_update',$this->plugin_name,'server_ip'); + $app->plugins->registerEvent('server_ip_delete',$this->plugin_name,'server_ip'); + + } + + // Handle the creation of SSL certificates + function ssl($event_name,$data) { + global $app, $conf; + + if(!is_dir($data["new"]["document_root"]."/ssl")) exec("mkdir -p ".$data["new"]["document_root"]."/ssl"); + $ssl_dir = $data["new"]["document_root"]."/ssl"; + $domain = $data["new"]["domain"]; + $key_file = $ssl_dir.'/'.$domain.".key.org"; + $key_file2 = $ssl_dir.'/'.$domain.".key"; + $csr_file = $ssl_dir.'/'.$domain.".csr"; + $crt_file = $ssl_dir.'/'.$domain.".crt"; + + //* Create a SSL Certificate + if($data["new"]["ssl_action"] == 'create') { + $rand_file = $ssl_dir."/random_file"; + $rand_data = md5(uniqid(microtime(),1)); + for($i=0; $i<1000; $i++){ + $rand_data .= md5(uniqid(microtime(),1)); + $rand_data .= md5(uniqid(microtime(),1)); + $rand_data .= md5(uniqid(microtime(),1)); + $rand_data .= md5(uniqid(microtime(),1)); + } + file_put_contents($rand_file, $rand_data); + + $ssl_password = substr(md5(uniqid(microtime(),1)), 0, 15); + + $ssl_cnf = " RANDFILE = $rand_file + + [ req ] + default_bits = 1024 + default_keyfile = keyfile.pem + distinguished_name = req_distinguished_name + attributes = req_attributes + prompt = no + output_password = $ssl_password + + [ req_distinguished_name ] + C = ".$data['new']['ssl_country']." + ST = ".$data['new']['ssl_state']." + L = ".$data['new']['ssl_locality']." + O = ".$data['new']['ssl_organisation']." + OU = ".$data['new']['ssl_organisation_unit']." + CN = $domain + emailAddress = webmaster@".$data['new']['domain']." + + [ req_attributes ] + challengePassword = A challenge password"; + + $ssl_cnf_file = $ssl_dir."/openssl.conf"; + file_put_contents($ssl_cnf_file,$ssl_cnf); + + $rand_file = escapeshellcmd($rand_file); + $key_file = escapeshellcmd($key_file); + $key_file2 = escapeshellcmd($key_file2); + $ssl_days = 3650; + $csr_file = escapeshellcmd($csr_file); + $config_file = escapeshellcmd($ssl_cnf_file); + $crt_file = escapeshellcmd($crt_file); + + if(is_file($ssl_cnf_file)){ + exec("openssl genrsa -des3 -rand $rand_file -passout pass:$ssl_password -out $key_file 1024 && openssl req -new -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -out $csr_file -days $ssl_days -config $config_file && openssl req -x509 -passin pass:$ssl_password -passout pass:$ssl_password -key $key_file -in $csr_file -out $crt_file -days $ssl_days -config $config_file && openssl rsa -passin pass:$ssl_password -in $key_file -out $key_file2"); + $app->log("Creating SSL Cert for: $domain",LOGLEVEL_DEBUG); + } + + exec("chmod 400 $key_file2"); + @unlink($config_file); + @unlink($rand_file); + $ssl_request = file_get_contents($csr_file); + $ssl_cert = file_get_contents($crt_file); + $app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert' WHERE domain = '".$data["new"]["domain"]."'"); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); + } + + //* Save a SSL certificate to disk + if($data["new"]["ssl_action"] == 'save') { + $ssl_dir = $data["new"]["document_root"]."/ssl"; + $domain = $data["new"]["domain"]; + $csr_file = $ssl_dir.'/'.$domain.".csr"; + $crt_file = $ssl_dir.'/'.$domain.".crt"; + $bundle_file = $ssl_dir.'/'.$domain.".bundle"; + file_put_contents($csr_file,$data["new"]["ssl_request"]); + file_put_contents($crt_file,$data["new"]["ssl_cert"]); + if(trim($data["new"]["ssl_bundle"]) != '') file_put_contents($bundle_file,$data["new"]["ssl_bundle"]); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); + $app->log("Saving SSL Cert for: $domain",LOGLEVEL_DEBUG); + } + + //* Delete a SSL certificate + if($data["new"]["ssl_action"] == 'del') { + $ssl_dir = $data["new"]["document_root"]."/ssl"; + $domain = $data["new"]["domain"]; + $csr_file = $ssl_dir.'/'.$domain.".csr"; + $crt_file = $ssl_dir.'/'.$domain.".crt"; + $bundle_file = $ssl_dir.'/'.$domain.".bundle"; + unlink($csr_file); + unlink($crt_file); + unlink($bundle_file); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data["new"]["domain"]."'"); + $app->log("Deleting SSL Cert for: $domain",LOGLEVEL_DEBUG); + } + + + } + + + function insert($event_name,$data) { + global $app, $conf; + + $this->action = 'insert'; + // just run the update function + $this->update($event_name,$data); + + + } + + + function update($event_name,$data) { + global $app, $conf; + + if($this->action != 'insert') $this->action = 'update'; + + if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) { + + $old_parent_domain_id = intval($data["old"]["parent_domain_id"]); + $new_parent_domain_id = intval($data["new"]["parent_domain_id"]); + + // If the parent_domain_id has been chenged, we will have to update the old site as well. + if($data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) { + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'"); + $data["new"] = $tmp; + $data["old"] = $tmp; + $this->action = 'update'; + $this->update($event_name,$data); + } + + // This is not a vhost, so we need to update the parent record instead. + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'"); + $data["new"] = $tmp; + $data["old"] = $tmp; + $this->action = 'update'; + } + + + // load the server configuration options + $app->uses("getconf"); + $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); + + if($data["new"]["document_root"] == '') { + $app->log("document_root not set",LOGLEVEL_WARN); + return 0; + } + if($data["new"]["system_user"] == 'root' or $data["new"]["system_group"] == 'root') { + $app->log("Websites can not be owned by the root user or group.",LOGLEVEL_WARN); + return 0; + } + + //print_r($data); + + // Check if the directories are there and create them if nescessary. + if(!is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web"); + if(!is_dir($data["new"]["document_root"]."/web/error") and $data["new"]["errordocs"]) exec("mkdir -p ".$data["new"]["document_root"]."/web/error"); + //if(!is_dir($data["new"]["document_root"]."/log")) exec("mkdir -p ".$data["new"]["document_root"]."/log"); + if(!is_dir($data["new"]["document_root"]."/ssl")) exec("mkdir -p ".$data["new"]["document_root"]."/ssl"); + if(!is_dir($data["new"]["document_root"]."/cgi-bin")) exec("mkdir -p ".$data["new"]["document_root"]."/cgi-bin"); + if(!is_dir($data["new"]["document_root"]."/tmp")) exec("mkdir -p ".$data["new"]["document_root"]."/tmp"); + + // Remove the symlink for the site, if site is renamed + if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { + if(is_dir('/var/log/ispconfig/httpd/'.$data["old"]["domain"])) exec('rm -rf /var/log/ispconfig/httpd/'.$data["old"]["domain"]); + if(is_link($data["old"]["document_root"]."/log")) unlink($data["old"]["document_root"]."/log"); + } + + // Create the symlink for the logfiles + if(!is_dir('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data["new"]["domain"]); + if(!is_link($data["new"]["document_root"]."/log")) { + exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log"); + $app->log("Creating Symlink: ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log",LOGLEVEL_DEBUG); + } + /* + // Create the symlink for the logfiles + // This does not work as vlogger can not log trogh symlinks. + if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { + if(is_dir($data["old"]["document_root"]."/log")) exec('rm -rf '.$data["old"]["document_root"]."/log"); + if(is_link('/var/log/ispconfig/httpd/'.$data["old"]["domain"])) unlink('/var/log/ispconfig/httpd/'.$data["old"]["domain"]); + } + + // Create the symlink for the logfiles + if(!is_dir($data["new"]["document_root"]."/log")) exec('mkdir -p '.$data["new"]["document_root"]."/log"); + if(!is_link('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) { + exec("ln -s ".$data["new"]["document_root"]."/log /var/log/ispconfig/httpd/".$data["new"]["domain"]); + $app->log("Creating Symlink: ln -s ".$data["new"]["document_root"]."/log /var/log/ispconfig/httpd/".$data["new"]["domain"],LOGLEVEL_DEBUG); + } + */ + + // Get the client ID + $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["new"]["sys_groupid"])); + $client_id = intval($client["client_id"]); + unset($client); + + // Remove old symlinks, if site is renamed + if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { + $tmp_symlinks_array = explode(':',$web_config["website_symlinks"]); + if(is_array($tmp_symlinks_array)) { + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink); + $tmp_symlink = str_replace("[website_domain]",$data["old"]["domain"],$tmp_symlink); + // Remove trailing slash + if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); + // create the symlinks, if not exist + if(!is_link($tmp_symlink)) { + exec("rm -f ".escapeshellcmd($tmp_symlink)); + $app->log("Removed Symlink: rm -f ".$tmp_symlink,LOGLEVEL_DEBUG); + } + } + } + } + + // Create the symlinks for the sites + $tmp_symlinks_array = explode(':',$web_config["website_symlinks"]); + if(is_array($tmp_symlinks_array)) { + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink); + $tmp_symlink = str_replace("[website_domain]",$data["new"]["domain"],$tmp_symlink); + // Remove trailing slash + if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); + //* Remove symlink if target folder has been changed. + if($data["old"]["document_root"] != '' && $data["old"]["document_root"] != $data["new"]["document_root"] && is_link($tmp_symlink)) { + unlink($tmp_symlink); + } + // create the symlinks, if not exist + if(!is_link($tmp_symlink)) { + exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink)); + $app->log("Creating Symlink: ln -s ".$data["new"]["document_root"]."/ ".$tmp_symlink,LOGLEVEL_DEBUG); + } + } + } + + + if($this->action == 'insert' && $data["new"]["type"] == 'vhost') { + // Copy the error pages + if($data["new"]["errordocs"]){ + $error_page_path = escapeshellcmd($data["new"]["document_root"])."/web/error/"; + if (file_exists("/usr/local/ispconfig/server/conf-custom/error/".substr(escapeshellcmd($conf["language"]),0,2))){ + exec("cp /usr/local/ispconfig/server/conf-custom/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path); + } + else { + if (file_exists("/usr/local/ispconfig/server/conf-custom/error/fileNotFound.html")){ + exec("cp /usr/local/ispconfig/server/conf-custom/error/*.html ".$error_page_path); + } + else { + exec("cp /usr/local/ispconfig/server/conf/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path); + } + } + exec("chmod -R +r ".$error_page_path); + } + + // copy the standard index page + if (file_exists("/usr/local/ispconfig/server/conf-custom/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2))){ + exec("cp /usr/local/ispconfig/server/conf-custom/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2)." ".escapeshellcmd($data["new"]["document_root"])."/web/index.html"); + } + else { + if (file_exists("/usr/local/ispconfig/server/conf-custom/index/standard_index.html")){ + exec("cp /usr/local/ispconfig/server/conf-custom/index/standard_index.html ".escapeshellcmd($data["new"]["document_root"])."/web/index.html"); + } + else { + exec("cp /usr/local/ispconfig/server/conf/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2)." ".escapeshellcmd($data["new"]["document_root"])."/web/index.html"); + } + } + exec("chmod +r ".escapeshellcmd($data["new"]["document_root"])."/web/index.html"); + } + + // Create group and user, if not exist + $app->uses("system"); + + $groupname = escapeshellcmd($data["new"]["system_group"]); + if($data["new"]["system_group"] != '' && !$app->system->is_group($data["new"]["system_group"])) { + exec("groupadd $groupname"); + $app->log("Adding the group: $groupname",LOGLEVEL_DEBUG); + } + + $username = escapeshellcmd($data["new"]["system_user"]); + if($data["new"]["system_user"] != '' && !$app->system->is_user($data["new"]["system_user"])) { + exec("useradd -d ".escapeshellcmd($data["new"]["document_root"])." -g $groupname $username -s /bin/false"); + $app->log("Adding the user: $username",LOGLEVEL_DEBUG); + } + + // Set the quota for the user + if($username != '' && $app->system->is_user($username)) { + if($data["new"]["hd_quota"] > 0){ + $blocks_soft = $data["new"]["hd_quota"] * 1024; + $blocks_hard = $blocks_soft + 1024; + } else { + $blocks_soft = $blocks_hard = 0; + } + exec("setquota -u $username $blocks_soft $blocks_hard 0 0 -a &> /dev/null"); + exec("setquota -T -u $username 604800 604800 -a &> /dev/null"); + } + + + + // Chown and chmod the directories + exec("chown -R $username:$groupname ".escapeshellcmd($data["new"]["document_root"])); + + // make temp direcory writable for the apache user and the website user + exec("chmod 777 ".escapeshellcmd($data["new"]["document_root"]."/tmp")); + + + // Create the vhost config file + $app->load('tpl'); + + $tpl = new tpl(); + $tpl->newTemplate("vhost.conf.master"); + + $vhost_data = $data["new"]; + $vhost_data["web_document_root"] = $data["new"]["document_root"]."/web"; + $vhost_data["web_document_root_www"] = "/var/www/".$data["new"]["domain"]."/web"; + + // Check if a SSL cert exists + $ssl_dir = $data["new"]["document_root"]."/ssl"; + $domain = $data["new"]["domain"]; + $key_file = $ssl_dir.'/'.$domain.".key"; + $crt_file = $ssl_dir.'/'.$domain.".crt"; + $bundle_file = $ssl_dir.'/'.$domain.".bundle"; + + if($data["new"]["ssl"] == 'y' && @is_file($crt_file) && @is_file($key_file)) { + $vhost_data["ssl_enabled"] = 1; + $app->log("Enable SSL for: $domain",LOGLEVEL_DEBUG); + } else { + $vhost_data["ssl_enabled"] = 0; + $app->log("Disable SSL for: $domain",LOGLEVEL_DEBUG); + } + + if(@is_file($bundle_file)) $vhost_data['has_bundle_cert'] = 1; + + //$vhost_data["document_root"] = $data["new"]["document_root"]."/web"; + $tpl->setVar($vhost_data); + + // Rewrite rules + $rewrite_rules = array(); + if($data["new"]["redirect_type"] != '') { + $rewrite_rules[] = array( 'rewrite_domain' => $data["new"]["domain"], + 'rewrite_type' => $data["new"]["redirect_type"], + 'rewrite_target' => $data["new"]["redirect_path"]); + } + + // get alias domains (co-domains and subdomains) + $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]." AND active = 'y'"); + switch($data["new"]["subdomain"]) { + case 'www': + $server_alias .= 'www.'.$data["new"]["domain"].' '; + break; + case '*': + $server_alias .= '*.'.$data["new"]["domain"].' '; + break; + } + if(is_array($aliases)) { + foreach($aliases as $alias) { + switch($alias["subdomain"]) { + case 'www': + $server_alias .= 'www.'.$alias["domain"].' '.$alias["domain"].' '; + break; + case '*': + $server_alias .= '*.'.$alias["domain"].' '.$alias["domain"].' '; + break; + default: + $server_alias .= $alias["domain"].' '; + break; + } + $app->log("Add server alias: $alias[domain]",LOGLEVEL_DEBUG); + // Rewriting + if($alias["redirect_type"] != '') { + $rewrite_rules[] = array( 'rewrite_domain' => $alias["domain"], + 'rewrite_type' => $alias["redirect_type"], + 'rewrite_target' => $alias["redirect_path"]); + } + } + } + $tpl->setVar('alias',trim($server_alias)); + if(count($rewrite_rules) > 0) { + $tpl->setVar('rewrite_enabled',1); + } else { + $tpl->setVar('rewrite_enabled',0); + } + $tpl->setLoop('redirects',$rewrite_rules); + + /** + * install fast-cgi starter script and add script aliasd config + * first we create the script directory if not already created, then copy over the starter script + * settings are copied over from the server ini config for now + * TODO: Create form for fastcgi configs per site. + */ + + if ($data["new"]["php"] == "fast-cgi") + { + $fastcgi_config = $app->getconf->get_server_config($conf["server_id"], 'fastcgi'); + + $fastcgi_starter_path = str_replace("[system_user]",$data["new"]["system_user"],$fastcgi_config["fastcgi_starter_path"]); + $fastcgi_starter_path = str_replace("[client_id]",$client_id,$fastcgi_starter_path); + + if (!is_dir($fastcgi_starter_path)) + { + exec("mkdir -p ".escapeshellcmd($fastcgi_starter_path)); + exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." ".escapeshellcmd($fastcgi_starter_path)); + + + $app->log("Creating fastcgi starter script directory: $fastcgi_starter_path",LOGLEVEL_DEBUG); + } + + $fcgi_tpl = new tpl(); + $fcgi_tpl->newTemplate("php-fcgi-starter.master"); + + $fcgi_tpl->setVar('php_ini_path',$fastcgi_config["fastcgi_phpini_path"]); + $fcgi_tpl->setVar('document_root',$data["new"]["document_root"]); + $fcgi_tpl->setVar('php_fcgi_children',$fastcgi_config["fastcgi_children"]); + $fcgi_tpl->setVar('php_fcgi_max_requests',$fastcgi_config["fastcgi_max_requests"]); + $fcgi_tpl->setVar('php_fcgi_bin',$fastcgi_config["fastcgi_bin"]); + + $fcgi_starter_script = escapeshellcmd($fastcgi_starter_path.$fastcgi_config["fastcgi_starter_script"]); + file_put_contents($fcgi_starter_script,$fcgi_tpl->grab()); + unset($fcgi_tpl); + + $app->log("Creating fastcgi starter script: $fcgi_starter_script",LOGLEVEL_DEBUG); + + + exec("chmod 755 $fcgi_starter_script"); + exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." $fcgi_starter_script"); + + $tpl->setVar('fastcgi_alias',$fastcgi_config["fastcgi_alias"]); + $tpl->setVar('fastcgi_starter_path',$fastcgi_starter_path); + $tpl->setVar('fastcgi_starter_script',$fastcgi_config["fastcgi_starter_script"]); + + } + + $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["new"]["domain"].'.vhost'); + file_put_contents($vhost_file,$tpl->grab()); + $app->log("Writing the vhost file: $vhost_file",LOGLEVEL_DEBUG); + unset($tpl); + + // Set the symlink to enable the vhost + $vhost_symlink = escapeshellcmd($web_config["vhost_conf_enabled_dir"].'/'.$data["new"]["domain"].'.vhost'); + if($data["new"]["active"] == 'y' && !is_link($vhost_symlink)) { + symlink($vhost_file,$vhost_symlink); + $app->log("Creating the symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); + } + + // Remove the symlink, if site is inactive + if($data["new"]["active"] == 'n' && is_link($vhost_symlink)) { + unlink($vhost_symlink); + $app->log("Removing symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); + } + + // remove old symlink and vhost file, if domain name of the site has changed + if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) { + $vhost_symlink = escapeshellcmd($web_config["vhost_conf_enabled_dir"].'/'.$data["old"]["domain"].'.vhost'); + unlink($vhost_symlink); + $app->log("Removing symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); + $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["old"]["domain"].'.vhost'); + unlink($vhost_file); + $app->log("Removing File $vhost_file",LOGLEVEL_DEBUG); + } + + // request a httpd reload when all records have been processed + $app->services->restartServiceDelayed('httpd','reload'); + + } + + function delete($event_name,$data) { + global $app, $conf; + + // load the server configuration options + $app->uses("getconf"); + $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); + + // Deleting the vhost file, symlink and the data directory + $vhost_symlink = escapeshellcmd($web_config["vhost_conf_enabled_dir"].'/'.$data["old"]["domain"].'.vhost'); + unlink($vhost_symlink); + $app->log("Removing symlink: $vhost_symlink => $vhost_file",LOGLEVEL_DEBUG); + + $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["old"]["domain"].'.vhost'); + unlink($vhost_file); + $app->log("Removing vhost file: $vhost_file",LOGLEVEL_DEBUG); + + $docroot = escapeshellcmd($data["old"]["document_root"]); + if($docroot != '' && !stristr($docroot,'..')) exec("rm -rf $docroot"); + + + //remove the php fastgi starter script if available + if ($data["old"]["php"] == "fast-cgi") + { + $fastcgi_starter_path = str_replace("[system_user]",$data["old"]["system_user"],$web_config["fastcgi_starter_path"]); + if (is_dir($fastcgi_starter_path)) + { + exec("rm -rf $fastcgi_starter_path"); + } + } + + $app->log("Removing website: $docroot",LOGLEVEL_DEBUG); + + // Delete the symlinks for the sites + $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["old"]["sys_groupid"])); + $client_id = intval($client["client_id"]); + unset($client); + $tmp_symlinks_array = explode(':',$web_config["website_symlinks"]); + if(is_array($tmp_symlinks_array)) { + foreach($tmp_symlinks_array as $tmp_symlink) { + $tmp_symlink = str_replace("[client_id]",$client_id,$tmp_symlink); + $tmp_symlink = str_replace("[website_domain]",$data["old"]["domain"],$tmp_symlink); + // Remove trailing slash + if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1); + // create the symlinks, if not exist + if(is_link($tmp_symlink)) { + unlink($tmp_symlink); + $app->log("Removing symlink: ".$tmp_symlink,LOGLEVEL_DEBUG); + } + } + } + // end removing symlinks + + // Delete the log file directory + $vhost_logfile_dir = escapeshellcmd('/var/log/ispconfig/httpd/'.$data["old"]["domain"]); + if($data["old"]["domain"] != '' && !stristr($vhost_logfile_dir,'..')) exec("rm -rf $vhost_logfile_dir"); + $app->log("Removing website logfile directory: $vhost_logfile_dir",LOGLEVEL_DEBUG); + + //delete the web user + $command = 'userdel'; + $command .= ' '.$data["old"]["system_user"]; + exec($command); + } + + //* This function is called when a IP on the server is inserted, updated or deleted + function server_ip($event_name,$data) { + global $app, $conf; + + // Here we write the name virtualhost directives + // NameVirtualHost IP:80 + // NameVirtualHost IP:443 + + } + + +} // end class + +>>>>>>> .r745 ?> \ No newline at end of file -- Gitblit v1.9.1