<? /*
// File: apache.sys.phps
// Purpose: apache system update
// Author: Felix <hide@address.com>
*/
// Domain Update
if ($type == "domain") {
// Load current file
$sysfile['include.httpd'] = implode("",file($cfg['basedir']."/httpd/include/include.httpd"));
// New files
$newfile['include.httpd'] = '# This file is automatically generated by web://cp
# Please make custom changes with the web panel
# ================================================
';
$dbp = mysql_query("SELECT DISTINCT(ip) AS ip FROM domains ORDER BY ip");
while ($data = mysql_fetch_array($dbp)) {
$newfile['include.httpd'] .= "NameVirtualHost ".$data['ip'].":".$cfg['apache']['port']."\n";
}
// Initialize reseller ID
unset($oldowner);
// make http & mail config
$dbp = mysql_query("SELECT * FROM domains WHERE type='domain' ORDER BY priority, owner, domain") or die(mysql_error());
while ($data = mysql_fetch_array($dbp)) {
// Prepare include.httpd
$newfile['include.httpd'] .= "\n\n";
if (!$data['priority'])
$newfile['include.httpd'] .= "## IP Priority (reseller ".$data['owner'].") ";
elseif ($oldowner != $data['owner']) {
$oldowner = $data['owner'];
$newfile['include.httpd'] .= "##\n## Domains under reseller ".$data['owner']."\n\n";
}
$newfile['include.httpd'] .= "## Domain ".$data['host'].".".$data['domain']." >> ".$data['ip']."\nInclude ".$cfg['basedir']."/httpd/include/".$data['id'].".httpd\n";
// Check if domain has pointers / sub-domains, set them here
$dbp2 = mysql_query("SELECT * FROM domains WHERE owner='".$data['id']."' ORDER BY domain");
while ($subdata = mysql_fetch_array($dbp2)) {
if ($subdata['type'] == "subdomain")
$subtype = "Sub-Domain";
else
$subtype = "Domain Pointer";
if (is_dir($subdata['path']))
$newfile['include.httpd'] .= "#### ".$subtype." ".$subdata['host'].".".$subdata['domain']." >> ".$subdata['ip']."\nInclude ".$cfg['basedir']."/httpd/include/".$subdata['id'].".httpd\n";
else
$newfile['include.httpd'] .= "#### ".$subtype." ".$subdata['host'].".".$subdata['domain']." >> ".$subdata['ip']."\n#Include ".$cfg['basedir']."/httpd/include/".$subdata['id'].".httpd ## Invalid DocumentRoot!!\n";
}
}
// Check if there was really any update and signal which service to restart
if ($newfile['include.httpd'] != $sysfile['include.httpd']) {
$fp = fopen($cfg['basedir']."/httpd/include/include.httpd","w+");
fwrite($fp,$newfile['include.httpd']);
$restarthttp = TRUE;
fclose($fp);
}
}
// end of updatesys("domain");
///
?>