Manages APACHE 2.4+ vhosts templates in AlternC 3.5+.
More...
|
| concat () |
| Concatenate all files under $this->vhostroot into one (mindepth=2 though), this function is faster than any shell stuff :D. More...
|
|
| subconcat ($f, $root) |
|
Manages APACHE 2.4+ vhosts templates in AlternC 3.5+.
- Copyright
- AlternC-Team 2000-2018 https://alternc.com/
Definition at line 26 of file m_apache.php.
◆ concat()
Concatenate all files under $this->vhostroot into one (mindepth=2 though), this function is faster than any shell stuff :D.
Definition at line 150 of file m_apache.php.
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");
References $c, $d, $f, $msg, and subconcat().
Referenced by hook_updatedomains_web_post().
◆ hook_updatedomains_web_add()
m_apache::hook_updatedomains_web_add |
( |
|
$subdomid | ) |
|
Definition at line 46 of file m_apache.php.
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;
getuserpath($user=null)
get the home of the user
References $cert, $db, $msg, and getuserpath().
◆ hook_updatedomains_web_del()
m_apache::hook_updatedomains_web_del |
( |
|
$subdomid | ) |
|
launched for each FQDN for which we want to delete a vhost template
Definition at line 108 of file m_apache.php.
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;
References $db, and $msg.
◆ hook_updatedomains_web_post()
m_apache::hook_updatedomains_web_post |
( |
| ) |
|
launched at the very end of updatedomains
Definition at line 124 of file m_apache.php.
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");
concat()
Concatenate all files under $this->vhostroot into one (mindepth=2 though), this function is faster th...
References $msg, and concat().
◆ hook_updatedomains_web_pre()
m_apache::hook_updatedomains_web_pre |
( |
| ) |
|
Definition at line 41 of file m_apache.php.
42 $this->shouldreload=
false;
◆ subconcat()
m_apache::subconcat |
( |
|
$f, |
|
|
|
$root |
|
) |
| |
|
private |
◆ $httpsmodes
m_apache::$httpsmodes =array("http","https","both") |
◆ $reloadfile
m_apache::$reloadfile ="/run/alternc/apache-reload" |
◆ $shouldreload
◆ $templatedir
m_apache::$templatedir ="/etc/alternc/templates/apache2" |
◆ $vhostroot
m_apache::$vhostroot ="/var/lib/alternc/apache-vhost/" |
The documentation for this class was generated from the following file: