removing unused code from m_dom, adding translation request for new domaines types
This commit is contained in:
parent
e09006b69e
commit
0b0f08c739
|
@ -1991,200 +1991,6 @@ class m_dom {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array with all the needed parameters to generate conf
|
||||
* of a vhost.
|
||||
* If no parameters, return the parameters for ALL the vhost.
|
||||
* Optionnal parameters: id of the sub_domaines
|
||||
* */
|
||||
function generation_parameters($id = null, $only_apache = true) {
|
||||
global $db, $msg;
|
||||
$msg->log("dom", "generation_parameters");
|
||||
$params = "";
|
||||
/** 2016_05_18 : this comments was here before escaping the request... is there still something to do here ?
|
||||
* // BUG BUG BUG FIXME
|
||||
* // Suppression de comptes -> membres existe pas -> domaines a supprimer ne sont pas lister
|
||||
*/
|
||||
$query = "
|
||||
select
|
||||
sd.id as sub_id,
|
||||
lower(sd.type) as type,
|
||||
m.login,
|
||||
m.uid as uid,
|
||||
if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) as fqdn,
|
||||
concat_ws('@',m.login,v.value) as mail,
|
||||
sd.valeur
|
||||
from
|
||||
sub_domaines sd left join membres m on sd.compte=m.uid,
|
||||
variable v,
|
||||
domaines_type dt
|
||||
where
|
||||
v.name='mailname_bounce'
|
||||
and lower(dt.name) = lower(sd.type)";
|
||||
$query_args = array();
|
||||
|
||||
if (!is_null($id) && intval($id) == $id) {
|
||||
$query .= " AND sd.id = ? ";
|
||||
array_push($query_args, intval($id));
|
||||
}
|
||||
if ($only_apache) {
|
||||
$query .=" and dt.only_dns is false ";
|
||||
}
|
||||
|
||||
$query .= "
|
||||
order by
|
||||
m.login,
|
||||
sd.domaine,
|
||||
sd.sub;";
|
||||
|
||||
|
||||
$db->query($query, $query_args);
|
||||
|
||||
$r = array();
|
||||
while ($db->next_record()) {
|
||||
$r[$db->Record['sub_id']] = $db->Record;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array with all informations of the domains_type
|
||||
* used to generate Apache conf.
|
||||
* Die if templates missing.
|
||||
* Warning: an Apache domains_type must have 'only_dns' == TRUE
|
||||
*
|
||||
* */
|
||||
function generation_domains_type() {
|
||||
global $dom;
|
||||
$d = array();
|
||||
foreach ($dom->domains_type_lst() as $k => $v) {
|
||||
if ($v['only_dns'] == true) {
|
||||
continue;
|
||||
}
|
||||
if (!$j = file_get_contents(ALTERNC_APACHE2_GEN_TMPL_DIR . '/' . strtolower($k) . '.conf')) {
|
||||
die("Error: missing file for $k");
|
||||
}
|
||||
$d[$k] = $v;
|
||||
$d[$k]['tpl'] = $j;
|
||||
}
|
||||
return $d;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Launch old fashionned hooks as there was in AlternC 1.0
|
||||
* @TODO: do we still need that?
|
||||
*/
|
||||
function generate_conf_oldhook($action, $lst_sub, $sub_obj = null) {
|
||||
if (is_null($sub_obj)) {
|
||||
$sub_obj = $this->generation_parameters(null, false);
|
||||
}
|
||||
if (!isset($lst_sub[strtoupper($action)]) || empty($lst_sub[strtoupper($action)])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$lst_by_type = $lst_sub[strtoupper($action)];
|
||||
|
||||
foreach ($lst_by_type as $type => $lid_arr) {
|
||||
$script = "/etc/alternc/functions_hosting/hosting_" . strtolower($type) . ".sh";
|
||||
if (!@is_executable($script)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($lid_arr as $lid) {
|
||||
$o = $sub_obj[$lid];
|
||||
$cmd = $script . " " . escapeshellcmd(strtolower($action)) . " ";
|
||||
$cmd .= escapeshellcmd($o['fqdn']) . " " . escapeshellcmd($o['valeur']);
|
||||
|
||||
system($cmd);
|
||||
}
|
||||
} // foreach $lst_by_type
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate apache configuration.
|
||||
* Die if a specific FQDN have 2 vhost conf.
|
||||
*
|
||||
* */
|
||||
function generate_apacheconf($p = null) {
|
||||
// Get the parameters
|
||||
$lst = $this->generation_parameters($p);
|
||||
|
||||
$gdt = $this->generation_domains_type();
|
||||
|
||||
// Initialize duplicate check
|
||||
$check_dup = array();
|
||||
|
||||
$ret = '';
|
||||
foreach ($lst as $p) {
|
||||
// Check if duplicate
|
||||
if (in_array($p['fqdn'], $check_dup)) {
|
||||
die("Error: duplicate fqdn : " . $p['fqdn']);
|
||||
} else {
|
||||
$check_dup[] = $p['fqdn'];
|
||||
}
|
||||
|
||||
// Get the needed template
|
||||
$tpl = $gdt[$p['type']] ['tpl'];
|
||||
|
||||
// Replace needed vars
|
||||
$tpl = strtr($tpl, array(
|
||||
"%%LOGIN%%" => $p['login'],
|
||||
"%%fqdn%%" => $p['fqdn'],
|
||||
"%%document_root%%" => getuserpath($p['login']) . $p['valeur'],
|
||||
"%%account_root%%" => getuserpath($p['login']),
|
||||
"%%redirect%%" => $p['valeur'],
|
||||
"%%UID%%" => $p['uid'],
|
||||
"%%GID%%" => $p['uid'],
|
||||
"%%mail_account%%" => $p['mail'],
|
||||
"%%user%%" => "FIXME",
|
||||
));
|
||||
|
||||
// Security check
|
||||
if ($p['uid'] < 1999) { // if UID is not an AlternC uid
|
||||
$ret.= "# ERROR: Sub_id: " . $p['sub_id'] . "- The uid seem to be dangerous\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
// Return the conf
|
||||
$ret.= "# Sub_id: " . $p['sub_id'] . "\n" . $tpl;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array with the list of id of sub_domains waiting for an action
|
||||
*/
|
||||
function generation_todo() {
|
||||
global $db, $msg;
|
||||
$msg->debug("dom", "generation_todo");
|
||||
$db->query("select id as sub_id, web_action, type from sub_domaines where web_action !='ok';");
|
||||
$r = array();
|
||||
while ($db->next_record()) {
|
||||
$r[strtoupper($db->Record['web_action'])][strtoupper($db->Record['type'])][] = $db->f('sub_id');
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
function subdomain_modif_are_done($sub_domain_id, $action) {
|
||||
global $db;
|
||||
$sub_domain_id = intval($sub_domain_id);
|
||||
switch (strtolower($action)) {
|
||||
case "delete":
|
||||
$sql = "DELETE FROM sub_domaines WHERE id =$sub_domain_id;";
|
||||
break;
|
||||
default:
|
||||
$sql = "UPDATE sub_domaines SET web_action='OK' WHERE id='$sub_domain_id'; ";
|
||||
}
|
||||
$db->query($sql);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $dns_action
|
||||
*/
|
||||
|
@ -2195,15 +2001,8 @@ class m_dom {
|
|||
}
|
||||
|
||||
|
||||
function set_dns_result($domain, $dns_result) {
|
||||
global $db;
|
||||
$db->query("UPDATE domaines SET dns_result= ? WHERE domaine= ?; ", array($dns_result, $domain));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List if there is problems in the domains.
|
||||
* List if there are problems on the domain.
|
||||
* Problems can appear when editing domains type properties
|
||||
*/
|
||||
function get_problems($domain) {
|
||||
|
@ -2260,6 +2059,8 @@ class m_dom {
|
|||
_("Default mail server");
|
||||
_("Default backup mail server");
|
||||
_("AlternC panel access");
|
||||
_("DKIM Key");
|
||||
_("Email autoconfiguration");
|
||||
}
|
||||
|
||||
} /* Class m_domains */
|
||||
|
|
|
@ -690,101 +690,6 @@ class m_domTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers m_dom::generation_parameters
|
||||
* @todo Implement testGeneration_parameters().
|
||||
*/
|
||||
public function testGeneration_parameters()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers m_dom::generation_domains_type
|
||||
* @todo Implement testGeneration_domains_type().
|
||||
*/
|
||||
public function testGeneration_domains_type()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers m_dom::generate_conf_oldhook
|
||||
* @todo Implement testGenerate_conf_oldhook().
|
||||
*/
|
||||
public function testGenerate_conf_oldhook()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers m_dom::generate_apacheconf
|
||||
* @todo Implement testGenerate_apacheconf().
|
||||
*/
|
||||
public function testGenerate_apacheconf()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers m_dom::generation_todo
|
||||
* @todo Implement testGeneration_todo().
|
||||
*/
|
||||
public function testGeneration_todo()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers m_dom::subdomain_modif_are_done
|
||||
* @todo Implement testSubdomain_modif_are_done().
|
||||
*/
|
||||
public function testSubdomain_modif_are_done()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers m_dom::set_dns_action
|
||||
* @todo Implement testSet_dns_action().
|
||||
*/
|
||||
public function testSet_dns_action()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers m_dom::set_dns_result
|
||||
* @todo Implement testSet_dns_result().
|
||||
*/
|
||||
public function testSet_dns_result()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers m_dom::get_problems
|
||||
|
|
Loading…
Reference in New Issue