42 $this->shouldreload=
false;
49 $db->query(
"SELECT sd.*, dt.only_dns, dt.has_https_option, m.login FROM domaines_type dt, sub_domaines sd LEFT JOIN membres m ON m.uid=sd.compte WHERE dt.name=sd.type AND sd.web_action!='OK' AND id=?;",array($subdomid));
54 if ($subdom[
"compte"]<1999) {
55 $msg->raise(
"ERROR",
"apache",
"Subdom ".$subdom[
"id"].
" for domain ".$subdom[
"sub"].
".".$subdom[
"domaine"].
" has id ".$subdom[
"compte"].
". Skipped");
60 $template = $this->templatedir.
"/".strtolower($subdom[
"type"]);
61 if ($subdom[
"has_https_option"] && in_array($subdom[
"https"],$this->httpsmodes)) {
62 $template.=
"-".$subdom[
"https"];
65 if (!is_file($template)) {
66 $msg->raise(
"ERROR",
"apache",
"Template $template not found for subdom ".$subdom[
"id"].
" for domain ".$subdom[
"sub"].
".".$subdom[
"domaine"].
". Skipped");
70 $subdom[
"fqdn"]=$subdom[
"sub"].(($subdom[
"sub"])?
".":
"").$subdom[
"domaine"];
72 $cert = $ssl->get_certificate_path($subdom[
"certificate_id"]);
74 $chainline=
"SSLCertificateChainFile ".$cert[
"chain"];
79 $tpl=file_get_contents($template);
80 $tpl = strtr($tpl, array(
81 "%%LOGIN%%" => $subdom[
'login'],
82 "%%fqdn%%" => $subdom[
'fqdn'],
83 "%%document_root%%" =>
getuserpath($subdom[
'login']) . $subdom[
'valeur'],
84 "%%account_root%%" =>
getuserpath($subdom[
'login']),
85 "%%redirect%%" => $subdom[
'valeur'],
86 "%%UID%%" => $subdom[
'compte'],
87 "%%GID%%" => $subdom[
'compte'],
88 "%%mail_account%%" => $subdom[
'login'].
"@".$L_FQDN,
89 "%%user%%" =>
"FIXME",
90 "%%CRT%%" =>
$cert[
"cert"],
91 "%%KEY%%" =>
$cert[
"key"],
92 "%%CHAINLINE%%" => $chainline,
95 $confdir = $this->vhostroot.
"/".substr($subdom[
"compte"],-1).
"/".$subdom[
"compte"];
96 @mkdir($confdir,0755,
true);
97 file_put_contents($confdir.
"/".$subdom[
"fqdn"].
".conf",$tpl);
98 $this->shouldreload=
true;
110 $db->query(
"SELECT sd.*, dt.only_dns, dt.has_https_option, m.login FROM domaines_type dt, sub_domaines sd LEFT JOIN membres m ON m.uid=sd.compte WHERE dt.name=sd.type AND sd.web_action!='OK' AND id=?;",array($subdomid));
113 $confdir = $this->vhostroot.
"/".substr($subdom[
"compte"],-1).
"/".$subdom[
"compte"];
114 $deleteme= $subdom[
"sub"].(($subdom[
"sub"])?
".":
"").$subdom[
"domaine"].
".conf";
115 @unlink($confdir.
"/".$deleteme);
116 $this->shouldreload=
true;
126 if ($this->shouldreload) {
133 exec(
"apache2ctl graceful 2>&1",$out,$ret);
134 touch($this->reloadfile);
136 $msg->raise(
"ERROR",
"apache",
"Error while reloading apache, error code is $ret\n".implode(
"\n",$out));
138 $msg->raise(
"INFO",
"apache",
"Apache reloaded");
152 $d=opendir($this->vhostroot);
153 $f=fopen($this->vhostroot.
"/vhosts_all.conf.new",
"wb");
155 $msg->raise(
"FATAL",
"apache",
"Can't write vhosts_all file");
158 while ((
$c=readdir(
$d))!==
false) {
159 if (substr(
$c,0,1)!=
"." && is_dir($this->vhostroot.
"/".
$c)) {
165 rename($this->vhostroot.
"/vhosts_all.conf.new", $this->vhostroot.
"/vhosts_all.conf");
171 while ((
$c=readdir(
$d))!==
false) {
172 if (substr(
$c,0,1)!=
".") {
177 fputs(
$f,file_get_contents(
$root.
"/".
$c).
"\n");
Manages APACHE 2.4+ vhosts templates in AlternC 3.5+.
hook_updatedomains_web_del($subdomid)
launched for each FQDN for which we want to delete a vhost template
hook_updatedomains_web_post()
launched at the very end of updatedomains
concat()
Concatenate all files under $this->vhostroot into one (mindepth=2 though), this function is faster th...
hook_updatedomains_web_pre()
hook_updatedomains_web_add($subdomid)
getuserpath($user=null)
get the home of the user