classe dom & fichiers section admin associés

This commit is contained in:
quenenni 2017-08-16 02:23:22 +02:00
parent 8d5953f1c4
commit 31d024c5a1
14 changed files with 224 additions and 239 deletions

View File

@ -45,12 +45,12 @@ if (!isset($dns)) $dns="1";
<h3><?php __("Domain hosting"); ?></h3> <h3><?php __("Domain hosting"); ?></h3>
<hr /> <hr />
<?php <?php
if (!$quota->cancreate("dom")) { ?> if (!$quota->cancreate("dom")) {
<p class="alert alert-danger"><?php echo _("You cannot add any new domain, your quota is over.")." "._("Contact your administrator for more information."); ?></p> $msg->raise('Alert', "dom", _("You cannot add any new domain, your quota is over.")." "._("Contact your administrator for more information."));
<?php echo $msg->msg_html_all();
exit(); exit();
} }
if (isset($error) && $error) echo "<p class=\"alert alert-danger\">$error</p>"; echo $msg->msg_html_all();
?> ?>
<form method="post" action="dom_doadd.php" id="main"> <form method="post" action="dom_doadd.php" id="main">
<?php csrf_get(); ?> <?php csrf_get(); ?>

View File

@ -41,17 +41,19 @@ getFields($fields);
$dom->lock(); $dom->lock();
if (!$dom->add_domain($newdomain,$dns,0,0,$newisslave,$slavedom)) { if (!$dom->add_domain($newdomain,$dns,0,0,$newisslave,$slavedom)) {
$error=$err->errstr();
include("dom_add.php"); include("dom_add.php");
exit(); exit();
} } else
$msg->raise('Ok', "dom", _("Your new domain %s has been successfully installed"),$newdomain);
$dom->unlock(); $dom->unlock();
?> ?>
<h3><?php __("Add a domain"); ?></h3> <h3><?php __("Add a domain"); ?></h3>
<p> <p>
<?php printf(_("Your new domain %s has been successfully installed"),$newdomain); ?><br /><br /> <?php
echo $msg->msg_html_all();
?>
<span class="inb"><a href="dom_edit.php?domain=<?php echo urlencode($newdomain);?>" ><?php __("Click here to continue"); ?></a></span><br /> <span class="inb"><a href="dom_edit.php?domain=<?php echo urlencode($newdomain);?>" ><?php __("Click here to continue"); ?></a></span><br />
<?php $mem->show_help("add_domain"); ?> <?php $mem->show_help("add_domain"); ?>
<br /> <br />

View File

@ -37,21 +37,22 @@ $fields = array (
); );
getFields($fields); getFields($fields);
$dom->lock(); if ($del_confirm=="y") {
if ($del_confirm=="y")
if (!$dom->del_domain($domain)) { if (!$dom->del_domain($domain)) {
$error=$err->errstr();
include("dom_edit.php"); include("dom_edit.php");
$dom->unlock();
exit(); exit();
} }
}
$dom->unlock();
if (! empty($del_cancel)) { if (! empty($del_cancel)) {
$dom->lock();
$dom->del_domain_cancel($domain); $dom->del_domain_cancel($domain);
$dom->unlock();
// The link to this function is disable : the del_domain_cancel function need some modification // The link to this function is disable : the del_domain_cancel function need some modification
__("Deletion have been successfully cancelled");?><br/> $msg->raise('Ok', "dom", _("Deletion have been successfully cancelled"));
echo $msg->msg_html_all();
?>
<p> <p>
<span class="ina"><a href="main.php" target="_parent"><?php __("Click here to continue"); ?></a></span> <span class="ina"><a href="main.php" target="_parent"><?php __("Click here to continue"); ?></a></span>
</p> </p>
@ -77,13 +78,16 @@ if ($del_confirm!="y") {
</form> </form>
<?php include_once("foot.php"); <?php include_once("foot.php");
exit(); exit();
} }
?> ?>
<h3><?php printf(_("Domain %s deleted"),$domain); ?></h3> <h3><?php printf(_("Domain %s deleted"),$domain); ?></h3>
<hr id="topbar"/> <hr id="topbar"/>
<br /> <br />
<p> <?php
<?php printf(_("The domain %s has been successfully deleted."),$domain); ?><br /><br /> $msg->raise('Ok', "dom", _("The domain %s has been successfully deleted."),$domain);
echo $msg->msg_html_all();
?>
</p>
<span class="ina"><a href="main.php" target="_parent"><?php __("Click here to continue"); ?></a></span> <span class="ina"><a href="main.php" target="_parent"><?php __("Click here to continue"); ?></a></span>
<?php $mem->show_help("del_domain"); ?> <?php $mem->show_help("del_domain"); ?>
</p> </p>

View File

@ -6,18 +6,15 @@ include_once("head.php");
# Take the values of the subdomain in arguments # Take the values of the subdomain in arguments
function sub_domains_edit($domain, $sub_domain_id=false) { function sub_domains_edit($domain, $sub_domain_id=false) {
global $admin, $err, $oldid, $isedit; global $admin, $msg, $oldid, $isedit;
$dom=new m_dom(); $dom=new m_dom();
$dom->lock(); $dom->lock();
if (!$r=$dom->get_domain_all($domain)) {
$error=$err->errstr(); $r=$dom->get_domain_all($domain);
}
/* /*
if (! empty($sub)) { if (! empty($sub)) {
if (!$sd=$dom->get_sub_domain_all($domain,$sub,$type,$value)) { $sd=$dom->get_sub_domain_all($domain,$sub,$type,$value);
$error=$err->errstr();
}
} }
*/ */
$sd=$dom->get_sub_domain_all($sub_domain_id); $sd=$dom->get_sub_domain_all($sub_domain_id);
@ -26,6 +23,7 @@ $type=$sd['type'];
$sub=$sd['name']; $sub=$sd['name'];
$dom->unlock(); $dom->unlock();
?> ?>
<form action="dom_subdoedit.php" method="post" name="main" id="main"> <form action="dom_subdoedit.php" method="post" name="main" id="main">

View File

@ -38,16 +38,17 @@ getFields($fields);
$dom->lock(); $dom->lock();
if (!$r=$dom->get_domain_all($domain)) { if (!$r=$dom->get_domain_all($domain)) {
$error=$err->errstr(); $dom->unlock();
echo "<p class=\"alert alert-danger\">$error</p>"; echo $msg->msg_html_all();
include('foot.php'); include('foot.php');
die(); die();
} }
if (isset($error) && $error ) {
echo "<p class=\"alert alert-danger\">$error</p>";
}
$dom->unlock(); $dom->unlock();
?>
<h3><img src="images/dom.png" alt="" />&nbsp;<?php printf(_("Manage %s"),$domain); ?></h3>
<?php
echo $msg->msg_html_all();
?> ?>
<script type="text/javascript"> <script type="text/javascript">
function dnson() { function dnson() {
@ -88,8 +89,6 @@ function destruction_alert() {
} }
</script> </script>
<h3><img src="images/dom.png" alt="" />&nbsp;<?php printf(_("Manage %s"),$domain); ?></h3>
<?php <?php
if ($r['dns_action']=='UPDATE') {?> if ($r['dns_action']=='UPDATE') {?>

View File

@ -40,25 +40,17 @@ getFields($fields);
$dom->lock(); $dom->lock();
if (!$dom->edit_domain($domain,$dns,$email,0,$ttl)) { $r = $dom->get_domain_all($domain);
$error=$err->errstr(); if ($r["dns"] == $dns && $r["mail"] == $email && $r["zonettl"] == $ttl) {
include("dom_edit.php"); $msg->raise('Ok', "dom", _("No change has been requested..."));
$dom->unlock(); } else if ($dom->edit_domain($domain,$dns,$email,0,$ttl)) {
exit(); $msg->raise('Ok', "dom", _("The domain %s has been changed."),$domain);
}
$dom->unlock();
?>
<h3><?php printf(_("Editing domain %s"),$domain); ?></h3>
<hr id="topbar"/>
<br />
<p>
<?php
printf(_("The domain %s has been changed."),$domain);
$t = time(); $t = time();
// XXX: we assume the cron job is at every 5 minutes // XXX: we assume the cron job is at every 5 minutes
print strtr(_("The modifications will take effect at %time. Server time is %now."), array('%now' => date('H:i:s', $t), '%time' => date('H:i:s', ($t-($t%300)+300)))); $msg->raise('Ok', "dom", _("The modifications will take effect at %s. Server time is %s."), array(date('H:i:s', ($t-($t%300)+300)), date('H:i:s', $t)));
?><br /><br /> }
<span class="ina"><a href="dom_edit.php?domain=<?php echo urlencode($domain) ?>" ><?php __("Click here to continue"); ?></a></span> $dom->unlock();
</p>
<?php include_once("foot.php"); ?> include("dom_edit.php");
exit();
?>

View File

@ -45,16 +45,16 @@ $domain=trim($domain);
<br /> <br />
<?php <?php
if (!empty($error)) { if ( !empty($zone) && empty($domain) ) {
echo '<p class="alert alert-danger">'.$error.'</p>'; $msg->raise('Alert', "dom", _("The domain field seems to be empty"));
} }
echo $msg->msg_html_all();
?> ?>
<?php if ( !empty($zone) ) { <?php if ( !empty($zone) ) {
if ( empty($domain) ) { if ( !empty($domain) ) {
echo '<p class="alert alert-danger">'._("The domain field seems to be empty").'</p>'; __("Here is my proposition. Modify your zone until my proposition seems good to you"); ?>
} else { ?>
<?php __("Here is my proposition. Modify your zone until my proposition seems good to you"); ?>
<table class="tlist"> <table class="tlist">
<tr><th colspan=3><h2><?php printf(_("Working on %s"),$domain); ?></h2></th></tr> <tr><th colspan=3><h2><?php printf(_("Working on %s"),$domain); ?></h2></th></tr>
<tr> <tr>

View File

@ -36,22 +36,21 @@ $fields = array (
getFields($fields); getFields($fields);
$dom->lock(); $dom->lock();
if (!$r=$dom->get_sub_domain_all($sub_domain_id)) { $r=$dom->get_sub_domain_all($sub_domain_id);
$error=$err->errstr();
}
$dom->unlock(); $dom->unlock();
$dt=$dom->domains_type_lst(); $dt=$dom->domains_type_lst();
if (!$isinvited && $dt[strtolower($r['type'])]["enable"] != "ALL" ) { if (!$isinvited && $dt[strtolower($r['type'])]["enable"] != "ALL" ) {
__("This page is restricted to authorized staff"); $msg->raise('Error', "dom", _("This page is restricted to authorized staff"));
echo $msg->msg_html_all();
exit(); exit();
} }
?> ?>
<h3><?php printf(_("Deleting subdomain %s"),ife($r['name'],$r['name'].".").$r['domain']); ?> : </h3> <h3><?php printf(_("Deleting subdomain %s"),ife($r['name'],$r['name'].".").$r['domain']); ?> : </h3>
<?php <?php
if (isset($error) && $error) { if ($msg->has_msgs('Error')) {
echo "<p class=\"alert alert-danger\">$error</p>"; echo $msg->msg_html_all();
include_once("foot.php"); include_once("foot.php");
exit(); exit();
} }
@ -78,7 +77,7 @@ if (isset($error) && $error) {
</p> </p>
<blockquote> <blockquote>
<input type="submit" class="inb" name="confirm" value="<?php __("Yes"); ?>" />&nbsp;&nbsp; <input type="submit" class="inb" name="confirm" value="<?php __("Yes"); ?>" />&nbsp;&nbsp;
<input type="button" class="inb" name="cancel" value="<?php __("No"); ?>" onclick="history.back();" /> <span class="ina"><a href="dom_edit.php?domain=<?php echo urlencode($r['domain']) ?>"><?php __("No"); ?></a></span></p>
</blockquote> </blockquote>
</form> </form>
<?php include_once("foot.php"); ?> <?php include_once("foot.php"); ?>

View File

@ -36,28 +36,20 @@ $fields = array (
getFields($fields); getFields($fields);
$dom->lock(); $dom->lock();
if (!$r=$dom->get_sub_domain_all($sub_domain_id)) { $r=$dom->get_sub_domain_all($sub_domain_id);
$error=$err->errstr(); $dt=$dom->domains_type_lst();
}
$dom->unlock(); $dom->unlock();
$dt=$dom->domains_type_lst();
if (!$isinvited && $dt[strtolower($r['type'])]["enable"] != "ALL" ) { if (!$isinvited && $dt[strtolower($r['type'])]["enable"] != "ALL" ) {
__("This page is restricted to authorized staff"); $msg->raise('Error', "dom", _("This page is restricted to authorized staff"));
echo $msg->msg_html_all();
exit(); exit();
} }
$dom->lock(); $dom->lock();
if (!$r=$dom->get_sub_domain_all($sub_domain_id)) { $r=$dom->get_sub_domain_all($sub_domain_id);
$error=$err->errstr(); $dom->del_sub_domain($sub_domain_id);
}
if (!$dom->del_sub_domain($sub_domain_id)) {
$error=$err->errstr();
}
$dom->unlock(); $dom->unlock();
?> ?>
@ -65,15 +57,15 @@ $dom->unlock();
<hr id="topbar"/> <hr id="topbar"/>
<br /> <br />
<?php <?php
if (isset($error) && $error) { if ($msg->has_msgs('Error')) {
echo "<p class=\"alert alert-danger\">$error</p>"; echo $msg->msg_html_all();
include_once("foot.php"); include_once("foot.php");
exit(); exit();
} else { } else {
$t = time(); $t = time();
// XXX: we assume the cron job is at every 5 minutes // XXX: we assume the cron job is at every 5 minutes
$error=strtr(_("The modifications will take effect at %time. Server time is %now."), array('%now' => date('H:i:s', $t), '%time' => date('H:i:s', ($t-($t%300)+300)))); $msg->raise('Ok', "dom", _("The modifications will take effect at %s. Server time is %s."), array(date('H:i:s', ($t-($t%300)+300)), date('H:i:s', $t)));
echo "<p class=\"alert alert-info\">".$error."</p>"; echo $msg->msg_html_all();
} }
?> ?>
<p><span class="ina"><a href="dom_edit.php?domain=<?php echo urlencode($r['domain']) ?>"><?php __("Click here to continue"); ?></a></span></p> <p><span class="ina"><a href="dom_edit.php?domain=<?php echo urlencode($r['domain']) ?>"><?php __("Click here to continue"); ?></a></span></p>

View File

@ -50,18 +50,17 @@ $dom->lock();
$dt=$dom->domains_type_lst(); $dt=$dom->domains_type_lst();
if ( (!isset($isinvited) || !$isinvited) && $dt[strtolower($type)]["enable"] != "ALL" ) { if ( (!isset($isinvited) || !$isinvited) && $dt[strtolower($type)]["enable"] != "ALL" ) {
__("This page is restricted to authorized staff"); $msg->raise('Error', "dom", _("This page is restricted to authorized staff"));
include("dom_edit.php");
exit(); exit();
} }
if (empty($sub_domain_id)) $sub_domain_id=null;
$r=$dom->set_sub_domain($domain,$sub,$type,$value, $sub_domain_id); $r=$dom->set_sub_domain($domain,$sub,$type,$value, $sub_domain_id);
$dom->unlock(); $dom->unlock();
if (!$r) { if (!$r) {
$error=$err->errstr();
$noread=true; $noread=true;
include("dom_subedit.php"); include("dom_subedit.php");
exit(); exit();
@ -69,7 +68,7 @@ if (!$r) {
$t = time(); $t = time();
// XXX: we assume the cron job is at every 5 minutes // XXX: we assume the cron job is at every 5 minutes
$noread=false; $noread=false;
$error=strtr(_("The modifications will take effect at %time. Server time is %now."), array('%now' => date('H:i:s', $t), '%time' => date('H:i:s', ($t-($t%300)+300)))); $msg->raise('Ok', "dom", _("The modifications will take effect at %s. Server time is %s."), array(date('H:i:s', ($t-($t%300)+300)), date('H:i:s', $t)));
foreach($fields as $k=>$v) unset($$k); foreach($fields as $k=>$v) unset($$k);
} }
include("dom_edit.php"); include("dom_edit.php");

View File

@ -41,8 +41,7 @@ $dom->lock();
$r=true; $r=true;
if (!isset($noread) || !$noread) { if (!isset($noread) || !$noread) {
if (!$r=$dom->get_sub_domain_all($sub_domain_id)) { if (!$r=$dom->get_sub_domain_all($sub_domain_id)) {
$error=$err->errstr(); echo $msg->msg_html_all();
echo "<p class=\"alert alert-danger\">$error</p>";
include_once('foot.php'); include_once('foot.php');
die(); die();
} }
@ -56,21 +55,24 @@ if (!$r) {
$dt=$dom->domains_type_lst(); $dt=$dom->domains_type_lst();
if (!$isinvited && $dt[strtolower($r['type'])]["enable"] != "ALL" ) { if (!$isinvited && $dt[strtolower($r['type'])]["enable"] != "ALL" ) {
__("This page is restricted to authorized staff"); $msg->raise('Error', "dom", _("This page is restricted to authorized staff"));
include("dom_edit.php");
exit(); exit();
} }
$domroot=$dom->get_domain_all($r['domain']); $domroot=$dom->get_domain_all($r['domain']);
$dom->unlock();
if ($msg->has_msgs("Error")) {
include_once("dom_edit.php");
exit();
}
echo "<h3>"; echo "<h3>";
__("Editing subdomain"); __("Editing subdomain");
echo " http://"; ecif($r['name'],$r['name']."."); echo $r['domain']."</h3>"; echo " http://"; ecif($r['name'],$r['name']."."); echo $r['domain']."</h3>";
if (isset($error) && $error) {
echo "<p class=\"alert alert-danger\">$error</p>"; echo $msg->msg_html_all();
include_once("foot.php");
exit();
}
$dom->unlock();
?> ?>
<hr id="topbar"/> <hr id="topbar"/>

View File

@ -19,14 +19,13 @@ $sub=$domi['name'];
$dom->unlock(); $dom->unlock();
if (!$r) { if (!$r) {
$error=$err->errstr();
$noread=true; $noread=true;
include("dom_edit.php"); include("dom_edit.php");
exit(); exit();
} else { } else {
$t = time(); $t = time();
// XXX: we assume the cron job is at every 5 minutes // XXX: we assume the cron job is at every 5 minutes
$error=strtr(_("The modifications will take effect at %time. Server time is %now."), array('%now' => date('H:i:s', $t), '%time' => date('H:i:s', ($t-($t%300)+300)))); $msg->raise('Ok', "dom", _("The modifications will take effect at %s. Server time is %s."), array(date('H:i:s', ($t-($t%300)+300)), date('H:i:s', $t)));
foreach($fields as $k=>$v) unset($k); foreach($fields as $k=>$v) unset($k);
} }
include("dom_edit.php"); include("dom_edit.php");

View File

@ -54,7 +54,6 @@ if(!empty($confirm_del)) {
foreach($lst_todel as $v) { foreach($lst_todel as $v) {
$r=$ftp->delete_ftp($v); $r=$ftp->delete_ftp($v);
if ($r) { if ($r) {
$success=true;
$msg->raise("Ok", "ftp", _("The ftp account %s has been successfully deleted"),$r); $msg->raise("Ok", "ftp", _("The ftp account %s has been successfully deleted"),$r);
} }
} }

View File

@ -91,8 +91,8 @@ class m_dom {
} }
function get_panel_url_list() { function get_panel_url_list() {
global $db, $err; global $db, $msg;
$err->log("dom", "get_panel_url_list"); $msg->log("dom", "get_panel_url_list");
$db->query("SELECT sd.id as sub_id, if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) as fqdn from sub_domaines sd where type = 'PANEL';"); $db->query("SELECT sd.id as sub_id, if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) as fqdn from sub_domaines sd where type = 'PANEL';");
$t = array(); $t = array();
while ($db->next_record()) { while ($db->next_record()) {
@ -105,8 +105,8 @@ class m_dom {
* @param string $fqdn * @param string $fqdn
*/ */
public static function get_sub_domain_id_and_member_by_name($fqdn) { public static function get_sub_domain_id_and_member_by_name($fqdn) {
global $db, $err; global $db, $msg;
$err->log("dom", "get_sub_domain_by_name"); $msg->log("dom", "get_sub_domain_by_name");
$db->query("select sd.* from sub_domaines sd where if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) = ?;", array($fqdn)); $db->query("select sd.* from sub_domaines sd where if(length(sd.sub)>0,concat_ws('.',sd.sub,sd.domaine),sd.domaine) = ?;", array($fqdn));
if (!$db->next_record()) { if (!$db->next_record()) {
return false; return false;
@ -151,8 +151,8 @@ class m_dom {
* authorisé. Retourne FALSE si une erreur s'est produite. * authorisé. Retourne FALSE si une erreur s'est produite.
*/ */
function domains_type_lst() { function domains_type_lst() {
global $db, $err; global $db, $msg;
$err->log("dom", "domains_type_lst"); $msg->log("dom", "domains_type_lst");
if (empty($this->cache_domains_type_lst)) { if (empty($this->cache_domains_type_lst)) {
$db->query("select * from domaines_type order by advanced;"); $db->query("select * from domaines_type order by advanced;");
$this->cache_domains_type_lst = array(); $this->cache_domains_type_lst = array();
@ -164,8 +164,8 @@ class m_dom {
} }
function domains_type_enable_values() { function domains_type_enable_values() {
global $db, $err, $cuid; global $db, $msg, $cuid;
$err->log("dom", "domains_type_target_values"); $msg->log("dom", "domains_type_target_values");
$db->query("desc domaines_type;"); $db->query("desc domaines_type;");
$r = array(); $r = array();
while ($db->next_record()) { while ($db->next_record()) {
@ -183,8 +183,8 @@ class m_dom {
* @param integer $type * @param integer $type
*/ */
function domains_type_target_values($type = null) { function domains_type_target_values($type = null) {
global $db, $err; global $db, $msg;
$err->log("dom", "domains_type_target_values"); $msg->log("dom", "domains_type_target_values");
if (is_null($type)) { if (is_null($type)) {
$db->query("desc domaines_type;"); $db->query("desc domaines_type;");
$r = array(); $r = array();
@ -207,10 +207,10 @@ class m_dom {
} }
function import_manual_dns_zone($zone, $domain, $detect_redirect = true, $save = false) { function import_manual_dns_zone($zone, $domain, $detect_redirect = true, $save = false) {
global $err; global $msg;
if ($save) { if ($save) {
if (!$this->import_manual_dns_prep_zone($domain)) { if (!$this->import_manual_dns_prep_zone($domain)) {
$err->raise('dom', _("Err: failed to prepare the zone")); $msg->raise('Error', 'dom', _("Err: failed to prepare the zone"));
return false; return false;
} }
} }
@ -230,8 +230,8 @@ class m_dom {
* @param string $zone * @param string $zone
*/ */
function import_manual_dns_entry($zone, $domain, $detect_redirect = true, $save = false) { function import_manual_dns_entry($zone, $domain, $detect_redirect = true, $save = false) {
global $err; global $msg;
$err->log("dom", "import_manual_dns_entry"); $msg->log("dom", "import_manual_dns_entry");
$zone = trim($zone); $zone = trim($zone);
if (empty($zone)) { if (empty($zone)) {
return false; return false;
@ -239,7 +239,7 @@ class m_dom {
$domain = trim($domain); $domain = trim($domain);
if (empty($domain)) { if (empty($domain)) {
$err->raise("dom", _("Missing domain name")); $msg->raise('Error', "dom", _("Missing domain name"));
return false; return false;
} }
@ -446,7 +446,7 @@ class m_dom {
} }
private function import_manual_dns_prep_zone($domain) { private function import_manual_dns_prep_zone($domain) {
global $err; global $msg;
// Prepare a domain to be importer : // Prepare a domain to be importer :
// * create the domain // * create the domain
// * delete all automatic subdomain // * delete all automatic subdomain
@ -455,7 +455,7 @@ class m_dom {
// function add_domain($domain,$dns,$noerase=0,$force=0,$isslave=0,$slavedom="") // function add_domain($domain,$dns,$noerase=0,$force=0,$isslave=0,$slavedom="")
if (!$this->add_domain($domain, true, false, true)) { if (!$this->add_domain($domain, true, false, true)) {
$err->raise('dom', "Error adding domain"); $msg->raise('Error', 'dom', "Error adding domain");
return false; return false;
} }
@ -519,7 +519,7 @@ class m_dom {
} }
function domains_type_regenerate($name) { function domains_type_regenerate($name) {
global $db, $err, $cuid; global $db, $msg, $cuid;
$db->query("update sub_domaines set web_action='UPDATE' where lower(type) = lower(?) ;", array($name)); $db->query("update sub_domaines set web_action='UPDATE' where lower(type) = lower(?) ;", array($name));
$db->query("update domaines d, sub_domaines sd set d.dns_action = 'UPDATE' where lower(sd.type)=lower(?);", array($name)); $db->query("update domaines d, sub_domaines sd set d.dns_action = 'UPDATE' where lower(sd.type)=lower(?);", array($name));
return true; return true;
@ -539,10 +539,10 @@ class m_dom {
} }
function domains_type_update($name, $description, $target, $entry, $compatibility, $enable, $only_dns, $need_dns, $advanced, $create_tmpdir, $create_targetdir) { function domains_type_update($name, $description, $target, $entry, $compatibility, $enable, $only_dns, $need_dns, $advanced, $create_tmpdir, $create_targetdir) {
global $err, $db; global $msg, $db;
// The name MUST contain only letter and digits, it's an identifier after all ... // The name MUST contain only letter and digits, it's an identifier after all ...
if (!preg_match("#^[a-z0-9]+$#", $name)) { if (!preg_match("#^[a-z0-9]+$#", $name)) {
$err->raise("dom", _("The name MUST contain only letter and digits")); $msg->raise('Error', "dom", _("The name MUST contain only letter and digits"));
return false; return false;
} }
$only_dns = intval($only_dns); $only_dns = intval($only_dns);
@ -555,8 +555,8 @@ class m_dom {
} }
function sub_domain_change_status($sub_id, $status) { function sub_domain_change_status($sub_id, $status) {
global $db, $err; global $db, $msg;
$err->log("dom", "sub_domain_change_status"); $msg->log("dom", "sub_domain_change_status");
$sub_id = intval($sub_id); $sub_id = intval($sub_id);
$status = strtoupper($status); $status = strtoupper($status);
if (!in_array($status, array('ENABLE', 'DISABLE'))) { if (!in_array($status, array('ENABLE', 'DISABLE'))) {
@ -566,7 +566,7 @@ class m_dom {
$jh = $this->get_sub_domain_all($sub_id); $jh = $this->get_sub_domain_all($sub_id);
if ($status == 'ENABLE') { // check compatibility with existing sub_domains if ($status == 'ENABLE') { // check compatibility with existing sub_domains
if (!$this->can_create_subdomain($jh['domain'], $jh['name'], $jh['type'], $sub_id)) { if (!$this->can_create_subdomain($jh['domain'], $jh['name'], $jh['type'], $sub_id)) {
$err->raise("dom", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility")); $msg->raise('Error', "dom", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility"));
return false; return false;
} }
} }
@ -588,8 +588,8 @@ class m_dom {
* erreur s'est produite. * erreur s'est produite.
*/ */
function enum_domains($uid = -1) { function enum_domains($uid = -1) {
global $db, $err, $cuid; global $db, $msg, $cuid;
$err->log("dom", "enum_domains"); $msg->log("dom", "enum_domains");
if ($uid == -1) { if ($uid == -1) {
$uid = $cuid; $uid = $cuid;
} }
@ -604,8 +604,8 @@ class m_dom {
} }
function del_domain_cancel($dom) { function del_domain_cancel($dom) {
global $db, $err, $classes, $cuid; global $db, $msg, $classes, $cuid;
$err->log("dom", "del_domaini_canl", $dom); $msg->log("dom", "del_domain_cancel", $dom);
$dom = strtolower($dom); $dom = strtolower($dom);
$db->query("UPDATE sub_domaines SET web_action='UPDATE' WHERE domaine= ?;", array($dom)); $db->query("UPDATE sub_domaines SET web_action='UPDATE' WHERE domaine= ?;", array($dom));
$this->set_dns_action($dom, 'UPDATE'); $this->set_dns_action($dom, 'UPDATE');
@ -627,8 +627,8 @@ class m_dom {
* @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon. * @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
*/ */
function del_domain($dom) { function del_domain($dom) {
global $db, $err, $hooks; global $db, $msg, $hooks;
$err->log("dom", "del_domain", $dom); $msg->log("dom", "del_domain", $dom);
$dom = strtolower($dom); $dom = strtolower($dom);
$this->lock(); $this->lock();
@ -678,54 +678,54 @@ class m_dom {
$ @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon. $ @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
*/ */
function add_domain($domain, $dns, $noerase = false, $force = false, $isslave = false, $slavedom = "") { function add_domain($domain, $dns, $noerase = false, $force = false, $isslave = false, $slavedom = "") {
global $db, $err, $quota, $L_FQDN, $tld, $cuid, $hooks; global $db, $msg, $quota, $L_FQDN, $tld, $cuid, $hooks;
$err->log("dom", "add_domain", $domain); $msg->log("dom", "add_domain", $domain);
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom", _("--- Program error --- No lock on the domains!")); $msg->raise('Error', "dom", _("--- Program error --- No lock on the domains!"));
return false; return false;
} }
// Verifie que le domaine est rfc-compliant // Verifie que le domaine est rfc-compliant
$domain = strtolower($domain); $domain = strtolower($domain);
$t = checkfqdn($domain); $t = checkfqdn($domain);
if ($t) { if ($t) {
$err->raise("dom", _("The domain name is syntaxically incorrect")); $msg->raise('Error', "dom", _("The domain name is syntaxically incorrect"));
return false; return false;
} }
// Interdit les domaines clés (table forbidden_domains) sauf en cas FORCE // Interdit les domaines clés (table forbidden_domains) sauf en cas FORCE
$db->query("SELECT domain FROM forbidden_domains WHERE domain= ? ;", array($domain)); $db->query("SELECT domain FROM forbidden_domains WHERE domain= ? ;", array($domain));
if ($db->num_rows() && !$force) { if ($db->num_rows() && !$force) {
$err->raise("dom", _("The requested domain is forbidden in this server, please contact the administrator")); $msg->raise('Error', "dom", _("The requested domain is forbidden in this server, please contact the administrator"));
return false; return false;
} }
if ($domain == $L_FQDN || $domain == "www.$L_FQDN") { if ($domain == $L_FQDN || $domain == "www.$L_FQDN") {
$err->raise("dom", _("This domain is the server's domain! You cannot host it on your account!")); $msg->raise('Error', "dom", _("This domain is the server's domain! You cannot host it on your account!"));
return false; return false;
} }
$db->query("SELECT compte FROM domaines WHERE domaine= ?;", array($domain)); $db->query("SELECT compte FROM domaines WHERE domaine= ?;", array($domain));
if ($db->num_rows()) { if ($db->num_rows()) {
$err->raise("dom", _("The domain already exist")); $msg->raise('Error', "dom", _("The domain already exist"));
return false; return false;
} }
$db->query("SELECT compte FROM `sub_domaines` WHERE sub != \"\" AND concat( sub, \".\", domaine )= ? OR domaine= ?;", array($domain, $domain)); $db->query("SELECT compte FROM `sub_domaines` WHERE sub != \"\" AND concat( sub, \".\", domaine )= ? OR domaine= ?;", array($domain, $domain));
if ($db->num_rows()) { if ($db->num_rows()) {
$err->raise("dom", _("The domain already exist")); $msg->raise('Error', "dom", _("The domain already exist"));
return false; return false;
} }
$this->dns = $this->whois($domain); $this->dns = $this->whois($domain);
if (!$force) { if (!$force) {
$v = checkhostallow($domain, $this->dns); $v = checkhostallow($domain, $this->dns);
if ($v == -1) { if ($v == -1) {
$err->raise("dom", _("The last member of the domain name is incorrect or cannot be hosted in that server")); $msg->raise('Error', "dom", _("The last member of the domain name is incorrect or cannot be hosted in that server"));
return false; return false;
} }
if ($dns && $v == -2) { if ($dns && $v == -2) {
$err->raise("dom", _("The domain cannot be found in the whois database")); $msg->raise('Alert', "dom", _("The domain cannot be found in the whois database"));
return false; return false;
} }
if ($dns && $v == -3) { if ($dns && $v == -3) {
$err->raise("dom", _("The domain cannot be found in the whois database")); $msg->raise('Alert', "dom", _("The domain cannot be found in the whois database"));
return false; return false;
} }
@ -742,14 +742,14 @@ class m_dom {
if (!$dns) { if (!$dns) {
$v = checkhostallow_nodns($domain); $v = checkhostallow_nodns($domain);
if ($v) { if ($v) {
$err->raise("dom", _("The requested domain is forbidden in this server, please contact the administrator")); $msg->raise('Error', "dom", _("The requested domain is forbidden in this server, please contact the administrator"));
return false; return false;
} }
} }
} }
// Check the quota : // Check the quota :
if (!$quota->cancreate("dom")) { if (!$quota->cancreate("dom")) {
$err->raise("dom", _("Your domain quota is over, you cannot create more domain names")); $msg->raise('Aler', "dom", _("Your domain quota is over, you cannot create more domain names"));
return false; return false;
} }
if ($noerase) { if ($noerase) {
@ -764,7 +764,7 @@ class m_dom {
} }
$db->query("INSERT INTO domaines (compte,domaine,gesdns,gesmx,noerase,dns_action) VALUES (?, ?, ?, ?, ?, 'UPDATE');", array($cuid,$domain,$dns,$gesmx,$noerase)); $db->query("INSERT INTO domaines (compte,domaine,gesdns,gesmx,noerase,dns_action) VALUES (?, ?, ?, ?, ?, 'UPDATE');", array($cuid,$domain,$dns,$gesmx,$noerase));
if (!($id = $db->lastid())) { if (!($id = $db->lastid())) {
$err->raise("dom", _("An unexpected error occured when creating the domain")); $msg->raise('Error', "dom", _("An unexpected error occured when creating the domain"));
return false; return false;
} }
@ -773,7 +773,7 @@ class m_dom {
$db->query("SELECT domaine FROM domaines WHERE compte= ? AND domaine= ?;", array($cuid, $slavedom)); $db->query("SELECT domaine FROM domaines WHERE compte= ? AND domaine= ?;", array($cuid, $slavedom));
$db->next_record(); $db->next_record();
if (!$db->Record["domaine"]) { if (!$db->Record["domaine"]) {
$err->raise("dom", _("Domain '%s' not found"), $slavedom); $msg->raise('Error', "dom", _("Domain '%s' not found"), $slavedom);
$isslave = false; $isslave = false;
} }
// Point to the master domain : // Point to the master domain :
@ -803,8 +803,8 @@ class m_dom {
* @param string $domain * @param string $domain
*/ */
function create_default_subdomains($domain, $target_domain = "") { function create_default_subdomains($domain, $target_domain = "") {
global $db, $err; global $db, $msg;
$err->log("dom", "create_default_subdomains", $domain); $msg->log("dom", "create_default_subdomains", $domain);
$query = "SELECT sub, domain_type, domain_type_parameter FROM default_subdomains WHERE (concerned = 'SLAVE' or concerned = 'BOTH') and enabled=1;"; $query = "SELECT sub, domain_type, domain_type_parameter FROM default_subdomains WHERE (concerned = 'SLAVE' or concerned = 'BOTH') and enabled=1;";
if (empty($target_domain)) { if (empty($target_domain)) {
$query = "SELECT sub, domain_type, domain_type_parameter FROM default_subdomains WHERE (concerned = 'MAIN' or concerned = 'BOTH') and enabled=1;"; $query = "SELECT sub, domain_type, domain_type_parameter FROM default_subdomains WHERE (concerned = 'MAIN' or concerned = 'BOTH') and enabled=1;";
@ -837,8 +837,8 @@ class m_dom {
} }
function lst_default_subdomains() { function lst_default_subdomains() {
global $db, $err; global $db, $msg;
$err->log("dom", "lst_default_subdomains"); $msg->log("dom", "lst_default_subdomains");
$c = array(); $c = array();
$db->query("select * from default_subdomains;"); $db->query("select * from default_subdomains;");
@ -856,8 +856,8 @@ class m_dom {
} }
function update_default_subdomains($arr) { function update_default_subdomains($arr) {
global $err; global $msg;
$err->log("dom", "update_default_subdomains"); $msg->log("dom", "update_default_subdomains");
$ok = true; $ok = true;
foreach ($arr as $a) { foreach ($arr as $a) {
if (!isset($a['id'])) { if (!isset($a['id'])) {
@ -877,8 +877,8 @@ class m_dom {
} }
function update_one_default($domain_type, $sub, $domain_type_parameter, $concerned, $enabled, $id = null) { function update_one_default($domain_type, $sub, $domain_type_parameter, $concerned, $enabled, $id = null) {
global $db, $err; global $db, $msg;
$err->log("dom", "update_one_default"); $msg->log("dom", "update_one_default");
if ($id == null) { if ($id == null) {
$db->query("INSERT INTO default_subdomains values ('', ?, ?, ?, ?, ?);", array($sub, $domain_type, $domain_type_parameter, $concerned, $enabled)); $db->query("INSERT INTO default_subdomains values ('', ?, ?, ?, ?, ?);", array($sub, $domain_type, $domain_type_parameter, $concerned, $enabled));
@ -890,11 +890,11 @@ class m_dom {
} }
function del_default_type($id) { function del_default_type($id) {
global $err, $db; global $msg, $db;
$err->log("dom", "del_default_type"); $msg->log("dom", "del_default_type");
if (!$db->query("delete from default_subdomains where id= ?;", array($id))) { if (!$db->query("delete from default_subdomains where id= ?;", array($id))) {
$err->raise("dom", _("Could not delete default type")); $msg->raise('Error', "dom", _("Could not delete default type"));
return false; return false;
} }
@ -918,8 +918,8 @@ class m_dom {
* *
*/ */
function whois($domain) { function whois($domain) {
global $err; global $msg;
$err->log("dom", "whois", $domain); $msg->log("dom", "whois", $domain);
// pour ajouter un nouveau TLD, utiliser le code ci-dessous. // pour ajouter un nouveau TLD, utiliser le code ci-dessous.
// echo "whois : $domain<br />"; // echo "whois : $domain<br />";
preg_match("#.*\.([^\.]*)#", $domain, $out); preg_match("#.*\.([^\.]*)#", $domain, $out);
@ -1065,14 +1065,14 @@ class m_dom {
} // while } // while
fclose($fp); fclose($fp);
} else { } else {
$err->raise("dom", _("The Whois database is unavailable, please try again later")); $msg->raise('Alert', "dom", _("The Whois database is unavailable, please try again later"));
return false; return false;
} }
if ($found) { if ($found) {
return $serveurList; return $serveurList;
} else { } else {
$err->raise("dom", _("The domain cannot be found in the Whois database")); $msg->raise('Alert', "dom", _("The domain cannot be found in the Whois database"));
return false; return false;
} }
} }
@ -1149,23 +1149,23 @@ class m_dom {
* *
*/ */
function get_domain_all($dom) { function get_domain_all($dom) {
global $db, $err, $cuid; global $db, $msg, $cuid;
$err->log("dom", "get_domain_all", $dom); $msg->log("dom", "get_domain_all", $dom);
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom", _("--- Program error --- No lock on the domains!")); $msg->raise('Error', "dom", _("--- Program error --- No lock on the domains!"));
return false; return false;
} }
$t = checkfqdn($dom); $t = checkfqdn($dom);
if ($t) { if ($t) {
$err->raise("dom", _("The domain name is syntaxically incorrect")); $msg->raise('Error', "dom", _("The domain name is syntaxically incorrect"));
return false; return false;
} }
$r = array(); $r = array();
$r["name"] = $dom; $r["name"] = $dom;
$db->query("SELECT * FROM domaines WHERE compte= ? AND domaine= ?;", array($cuid, $dom)); $db->query("SELECT * FROM domaines WHERE compte= ? AND domaine= ?;", array($cuid, $dom));
if ($db->num_rows() == 0) { if ($db->num_rows() == 0) {
$err->raise("dom", sprintf(_("Domain '%s' not found"), $dom)); $msg->raise('Error', "dom", sprintf(_("Domain '%s' not found"), $dom));
return false; return false;
} }
$db->next_record(); $db->next_record();
@ -1221,16 +1221,16 @@ class m_dom {
* Retourne FALSE si une erreur s'est produite. * Retourne FALSE si une erreur s'est produite.
*/ */
function get_sub_domain_all($sub_domain_id) { function get_sub_domain_all($sub_domain_id) {
global $db, $err, $cuid; global $db, $msg, $cuid;
$err->log("dom", "get_sub_domain_all", $sub_domain_id); $msg->log("dom", "get_sub_domain_all", $sub_domain_id);
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom", _("--- Program error --- No lock on the domains!")); $msg->raise('Error', "dom", _("--- Program error --- No lock on the domains!"));
return false; return false;
} }
$db->query("select sd.*, dt.description as type_desc, dt.only_dns, dt.advanced from sub_domaines sd, domaines_type dt where compte= ? and sd.id= ? and upper(dt.name)=upper(sd.type) ORDER BY dt.advanced, sd.sub;", array($cuid, $sub_domain_id)); $db->query("select sd.*, dt.description as type_desc, dt.only_dns, dt.advanced from sub_domaines sd, domaines_type dt where compte= ? and sd.id= ? and upper(dt.name)=upper(sd.type) ORDER BY dt.advanced, sd.sub;", array($cuid, $sub_domain_id));
if ($db->num_rows() == 0) { if ($db->num_rows() == 0) {
$err->raise("dom", _("The sub-domain does not exist")); $msg->raise('Error', "dom", _("The sub-domain does not exist"));
return false; return false;
} }
$db->next_record(); $db->next_record();
@ -1255,7 +1255,7 @@ class m_dom {
* @param string $value * @param string $value
*/ */
function check_type_value($type, $value) { function check_type_value($type, $value) {
global $err; global $msg;
// check the type we can have in domaines_type.target // check the type we can have in domaines_type.target
switch ($this->domains_type_target_values($type)) { switch ($this->domains_type_target_values($type)) {
@ -1269,7 +1269,7 @@ class m_dom {
if (filter_var($value, FILTER_VALIDATE_URL)) { if (filter_var($value, FILTER_VALIDATE_URL)) {
return true; return true;
} else { } else {
$err->raise("dom", _("invalid url")); $msg->raise('Error', "dom", _("invalid url"));
return false; return false;
} }
} }
@ -1279,7 +1279,7 @@ class m_dom {
$value = "/" . $value; $value = "/" . $value;
} }
if (!checkuserpath($value)) { if (!checkuserpath($value)) {
$err->raise("dom", _("The folder you entered is incorrect or does not exist")); $msg->raise('Error', "dom", _("The folder you entered is incorrect or does not exist"));
return false; return false;
} }
return true; return true;
@ -1287,7 +1287,7 @@ class m_dom {
if (checkip($value)) { if (checkip($value)) {
return true; return true;
} else { } else {
$err->raise("dom", _("The ip address is invalid")); $msg->raise('Error', "dom", _("The ip address is invalid"));
return false; return false;
} }
break; break;
@ -1295,7 +1295,7 @@ class m_dom {
if (checkipv6($value)) { if (checkipv6($value)) {
return true; return true;
} else { } else {
$err->raise("dom", _("The ip address is invalid")); $msg->raise('Error', "dom", _("The ip address is invalid"));
return false; return false;
} }
break; break;
@ -1303,7 +1303,7 @@ class m_dom {
if (checkcname($value)) { if (checkcname($value)) {
return true; return true;
} else { } else {
$err->raise("dom", _("The name you entered is incorrect or not fully qualified (it must end with a DOT, like example.com<b>.</b>)")); $msg->raise('Error', "dom", _("The name you entered is incorrect or not fully qualified (it must end with a DOT, like example.com<b>.</b>)"));
return false; return false;
} }
break; break;
@ -1311,12 +1311,12 @@ class m_dom {
if ($value == strval($value)) { if ($value == strval($value)) {
return true; return true;
} else { } else {
$err->raise("dom", _("The TXT value you entered is incorrect")); $msg->raise('Error', "dom", _("The TXT value you entered is incorrect"));
return false; return false;
} }
break; break;
default: default:
$err->raise("dom", _("Invalid domain type selected, please check")); $msg->raise('Error', "dom", _("Invalid domain type selected, please check"));
return false; return false;
} }
return false; return false;
@ -1333,8 +1333,8 @@ class m_dom {
* @return boolean tell you if the subdomain can be installed there * @return boolean tell you if the subdomain can be installed there
*/ */
function can_create_subdomain($dom, $sub, $type, $sub_domain_id = 'null') { function can_create_subdomain($dom, $sub, $type, $sub_domain_id = 'null') {
global $db, $err; global $db, $msg;
$err->log("dom", "can_create_subdomain", $dom . "/" . $sub); $msg->log("dom", "can_create_subdomain", $dom . "/" . $sub);
// Get the compatibility list for this domain type // Get the compatibility list for this domain type
$db->query("select upper(compatibility) as compatibility from domaines_type where upper(name)=upper(?);", array($type)); $db->query("select upper(compatibility) as compatibility from domaines_type where upper(name)=upper(?);", array($type));
@ -1377,11 +1377,11 @@ class m_dom {
* @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon. * @return boolean Retourne FALSE si une erreur s'est produite, TRUE sinon.
*/ */
function set_sub_domain($dom, $sub, $type, $dest, $sub_domain_id = null) { function set_sub_domain($dom, $sub, $type, $dest, $sub_domain_id = null) {
global $db, $err, $cuid, $bro; global $db, $msg, $cuid, $bro;
$err->log("dom", "set_sub_domain", $dom . "/" . $sub . "/" . $type . "/" . $dest); $msg->log("dom", "set_sub_domain", $dom . "/" . $sub . "/" . $type . "/" . $dest);
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom", _("--- Program error --- No lock on the domains!")); $msg->raise('Error', "dom", _("--- Program error --- No lock on the domains!"));
return false; return false;
} }
$dest = trim($dest); $dest = trim($dest);
@ -1393,7 +1393,7 @@ class m_dom {
$fqdn = checkfqdn($sub); $fqdn = checkfqdn($sub);
// Special cases : * (all subdomains at once) and '' empty subdomain are allowed. // Special cases : * (all subdomains at once) and '' empty subdomain are allowed.
if (($sub != '*' && $sub != '') && !($fqdn == 0 || $fqdn == 4)) { if (($sub != '*' && $sub != '') && !($fqdn == 0 || $fqdn == 4)) {
$err->raise("dom", _("There is some forbidden characters in the sub domain (only A-Z 0-9 and - are allowed)")); $msg->raise('Alert', "dom", _("There is some forbidden characters in the sub domain (only A-Z 0-9 and - are allowed)"));
return false; return false;
} }
@ -1405,16 +1405,16 @@ class m_dom {
// On a épuré $dir des problémes eventuels ... On est en DESSOUS du dossier de l'utilisateur. // On a épuré $dir des problémes eventuels ... On est en DESSOUS du dossier de l'utilisateur.
if (($t = checkfqdn($dom))) { if (($t = checkfqdn($dom))) {
$err->raise("dom", _("The domain name is syntaxically incorrect")); $msg->raise('Error', "dom", _("The domain name is syntaxically incorrect"));
return false; return false;
} }
if (!$this->can_create_subdomain($dom, $sub, $type, $sub_domain_id)) { if (!$this->can_create_subdomain($dom, $sub, $type, $sub_domain_id)) {
$err->raise("dom", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility")); $msg->raise('Error', "dom", _("The parameters for this subdomain and domain type are invalid. Please check for subdomain entries incompatibility"));
return false; return false;
} }
if (!is_null($sub_domain_id)) { // It's not a creation, it's an edit. Delete the old one if (!is_null($sub_domain_id) && !empty($sub_domain_id)) { // It's not a creation, it's an edit. Delete the old one
$this->del_sub_domain($sub_domain_id); $this->del_sub_domain($sub_domain_id);
} }
@ -1432,7 +1432,7 @@ class m_dom {
if ($db->f('create_tmpdir')) { if ($db->f('create_tmpdir')) {
if (!is_dir($dest_root . "/tmp")) { if (!is_dir($dest_root . "/tmp")) {
if (!@mkdir($dest_root . "/tmp", 0777, true)) { if (!@mkdir($dest_root . "/tmp", 0777, true)) {
$err->raise("dom", _("Cannot write to the destination folder")); $msg->raise('Error', "dom", _("Cannot write to the destination folder"));
} }
} }
} }
@ -1443,7 +1443,7 @@ class m_dom {
if (!is_dir($dirr)) { if (!is_dir($dirr)) {
$old = umask(0); $old = umask(0);
if (!@mkdir($dirr, 0770, true)) { if (!@mkdir($dirr, 0770, true)) {
$err->raise("dom", _("Cannot write to the destination folder")); $msg->raise('Error', "dom", _("Cannot write to the destination folder"));
} }
umask($old); umask($old);
} }
@ -1464,15 +1464,15 @@ class m_dom {
* *
*/ */
function del_sub_domain($sub_domain_id) { function del_sub_domain($sub_domain_id) {
global $db, $err; global $db, $msg;
$err->log("dom", "del_sub_domain", $sub_domain_id); $msg->log("dom", "del_sub_domain", $sub_domain_id);
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom", _("--- Program error --- No lock on the domains!")); $msg->raise('Error', "dom", _("--- Program error --- No lock on the domains!"));
return false; return false;
} }
if (!$r = $this->get_sub_domain_all($sub_domain_id)) { if (!$r = $this->get_sub_domain_all($sub_domain_id)) {
$err->raise("dom", _("The sub-domain does not exist")); $msg->raise('Error', "dom", _("The sub-domain does not exist"));
return false; return false;
} else { } else {
$db->query("update sub_domaines set web_action='DELETE' where id= ?; ", array($sub_domain_id)); $db->query("update sub_domaines set web_action='DELETE' where id= ?; ", array($sub_domain_id));
@ -1485,8 +1485,8 @@ class m_dom {
* @param integer $dom_id * @param integer $dom_id
*/ */
function set_ttl($dom_id, $ttl) { function set_ttl($dom_id, $ttl) {
global $err; global $msg;
$err->log("dom", "set_ttl", "$dom_id / $ttl"); $msg->log("dom", "set_ttl", "$dom_id / $ttl");
$this->lock(); $this->lock();
$domaine = $this->get_domain_byid($dom_id); $domaine = $this->get_domain_byid($dom_id);
$d = $this->get_domain_all($domaine); $d = $this->get_domain_all($domaine);
@ -1511,26 +1511,26 @@ class m_dom {
* *
*/ */
function edit_domain($dom, $dns, $gesmx, $force = false, $ttl = 86400) { function edit_domain($dom, $dns, $gesmx, $force = false, $ttl = 86400) {
global $db, $err, $hooks; global $db, $msg, $hooks;
$err->log("dom", "edit_domain", $dom . "/" . $dns . "/" . $gesmx); $msg->log("dom", "edit_domain", $dom . "/" . $dns . "/" . $gesmx);
// Locked ? // Locked ?
if (!$this->islocked && !$force) { if (!$this->islocked && !$force) {
$err->raise("dom", _("--- Program error --- No lock on the domains!")); $msg->raise('Error', "dom", _("--- Program error --- No lock on the domains!"));
return false; return false;
} }
if ($dns == true && !$force) { if ($dns == true && !$force) {
$this->dns = $this->whois($dom); $this->dns = $this->whois($dom);
$v = checkhostallow($dom, $this->dns); $v = checkhostallow($dom, $this->dns);
if ($v == -1) { if ($v == -1) {
$err->raise("dom", _("The last member of the domain name is incorrect or cannot be hosted in that server")); $msg->raise('Error', "dom", _("The last member of the domain name is incorrect or cannot be hosted in that server"));
return false; return false;
} }
if ($dns && $v == -2) { if ($dns && $v == -2) {
$err->raise("dom", _("The domain cannot be found in the Whois database")); $msg->raise('Alert', "dom", _("The domain cannot be found in the Whois database"));
return false; return false;
} }
if ($dns && $v == -3) { if ($dns && $v == -3) {
$err->raise("dom", _("The DNS of this domain do not match the server's DNS. Please change your domain's DNS before you install it again")); $msg->raise('Alert', "dom", _("The DNS of this domain do not match the server's DNS. Please change your domain's DNS before you install it again"));
return false; return false;
} }
} }
@ -1542,12 +1542,12 @@ class m_dom {
$t = checkfqdn($dom); $t = checkfqdn($dom);
if ($t) { if ($t) {
$err->raise("dom", _("The domain name is syntaxically incorrect")); $msg->raise('Error', "dom", _("The domain name is syntaxically incorrect"));
return false; return false;
} }
if (!$r = $this->get_domain_all($dom)) { if (!$r = $this->get_domain_all($dom)) {
// Le domaine n'existe pas, Failure // Le domaine n'existe pas, Failure
$err->raise("dom", _("The domain name %s does not exist"), $dom); $msg->raise('Error', "dom", _("The domain name %s does not exist"), $dom);
return false; return false;
} }
if ($dns != "1") { if ($dns != "1") {
@ -1555,7 +1555,7 @@ class m_dom {
} }
// On vérifie que des modifications ont bien eu lieu :) // On vérifie que des modifications ont bien eu lieu :)
if ($r["dns"] == $dns && $r["mail"] == $gesmx && $r["zonettl"] == $ttl) { if ($r["dns"] == $dns && $r["mail"] == $gesmx && $r["zonettl"] == $ttl) {
$err->raise("dom", _("No change has been requested...")); $msg->raise('Info', "dom", _("No change has been requested..."));
return true; return true;
} }
@ -1563,12 +1563,12 @@ class m_dom {
if ($dns == "0" && $gesmx == "1" && !$force) { if ($dns == "0" && $gesmx == "1" && !$force) {
$vmx = $this->checkmx($dom); $vmx = $this->checkmx($dom);
if ($vmx == 1) { if ($vmx == 1) {
$err->raise("dom", _("There is no MX record pointing to this server, and you are asking us to host the mail here. Make sure to update your MX entries or no mail will be received")); $msg->raise('Alert', "dom", _("There is no MX record pointing to this server, and you are asking us to host the mail here. Make sure to update your MX entries or no mail will be received"));
} }
if ($vmx == 2) { if ($vmx == 2) {
// Serveur non spécifié parmi les champx mx // Serveur non spécifié parmi les champx mx
$err->raise("dom", _("There is no MX record pointing to this server, and you are asking us to host the mail here. Make sure to update your MX entries or no mail will be received")); $msg->raise('Alert', "dom", _("There is no MX record pointing to this server, and you are asking us to host the mail here. Make sure to update your MX entries or no mail will be received"));
} }
} }
@ -1596,7 +1596,7 @@ class m_dom {
* through AXFR Transfers from the bind server. * through AXFR Transfers from the bind server.
*/ */
function enum_slave_ip() { function enum_slave_ip() {
global $db, $err; global $db, $msg;
$db->query("SELECT * FROM slaveip;"); $db->query("SELECT * FROM slaveip;");
if (!$db->next_record()) { if (!$db->next_record()) {
return false; return false;
@ -1613,9 +1613,9 @@ class m_dom {
/** Add an ip address (or a ip class) to the list of allowed slave ip access list. /** Add an ip address (or a ip class) to the list of allowed slave ip access list.
*/ */
function add_slave_ip($ip, $class = "32") { function add_slave_ip($ip, $class = "32") {
global $db, $err; global $db, $msg;
if (!checkip($ip)) { if (!checkip($ip)) {
$err->raise("dom", _("The IP address you entered is incorrect")); $msg->raise('Error', "dom", _("The IP address you entered is incorrect"));
return false; return false;
} }
$class = intval($class); $class = intval($class);
@ -1624,7 +1624,7 @@ class m_dom {
} }
$db->query("SELECT * FROM slaveip WHERE ip= ? AND class= ?;", array($ip, $class)); $db->query("SELECT * FROM slaveip WHERE ip= ? AND class= ?;", array($ip, $class));
if ($db->next_record()) { if ($db->next_record()) {
$err->raise("err", _("The requested domain is forbidden in this server, please contact the administrator")); $msg->raise('Error', "err", _("The requested domain is forbidden in this server, please contact the administrator"));
return false; return false;
} }
$db->query("INSERT INTO slaveip (ip,class) VALUES (?, ?);", array($ip, $class)); $db->query("INSERT INTO slaveip (ip,class) VALUES (?, ?);", array($ip, $class));
@ -1639,9 +1639,9 @@ class m_dom {
/** Remove an ip address (or a ip class) from the list of allowed slave ip access list. /** Remove an ip address (or a ip class) from the list of allowed slave ip access list.
*/ */
function del_slave_ip($ip) { function del_slave_ip($ip) {
global $db, $err; global $db, $msg;
if (!checkip($ip)) { if (!checkip($ip)) {
$err->raise("dom", _("The IP address you entered is incorrect")); $msg->raise('Error', "dom", _("The IP address you entered is incorrect"));
return false; return false;
} }
$db->query("DELETE FROM slaveip WHERE ip= ?;", array($ip)); $db->query("DELETE FROM slaveip WHERE ip= ?;", array($ip));
@ -1733,19 +1733,19 @@ class m_dom {
* @return string the domain name, or false with an error raised. * @return string the domain name, or false with an error raised.
*/ */
function get_domain_byid($dom_id) { function get_domain_byid($dom_id) {
global $db, $err, $cuid; global $db, $msg, $cuid;
$dom_id = intval($dom_id); $dom_id = intval($dom_id);
$db->query("SELECT domaine FROM domaines WHERE id= ? AND compte= ?;", array($dom_id, $cuid)); $db->query("SELECT domaine FROM domaines WHERE id= ? AND compte= ?;", array($dom_id, $cuid));
if ($db->next_record()) { if ($db->next_record()) {
$domain = $db->f("domaine"); $domain = $db->f("domaine");
if (!$domain) { if (!$domain) {
$err->raise("dom", _("This domain is not installed in your account")); $msg->raise('Error', "dom", _("This domain is not installed in your account"));
return false; return false;
} else { } else {
return $domain; return $domain;
} }
} else { } else {
$err->raise("dom", _("This domain is not installed in your account")); $msg->raise('Error', "dom", _("This domain is not installed in your account"));
return false; return false;
} }
} }
@ -1757,19 +1757,19 @@ class m_dom {
* @return integer the domain id, or false with an error raised. * @return integer the domain id, or false with an error raised.
*/ */
function get_domain_byname($domain) { function get_domain_byname($domain) {
global $db, $err, $cuid; global $db, $msg, $cuid;
$domain = trim($domain); $domain = trim($domain);
$db->query("SELECT id FROM domaines WHERE domaine= ? AND compte= ?;", array($domain, $cuid)); $db->query("SELECT id FROM domaines WHERE domaine= ? AND compte= ?;", array($domain, $cuid));
if ($db->next_record()) { if ($db->next_record()) {
$id = $db->f("id"); $id = $db->f("id");
if (!$id) { if (!$id) {
$err->raise("dom", _("This domain is not installed in your account")); $msg->raise('Error', "dom", _("This domain is not installed in your account"));
return false; return false;
} else { } else {
return $id; return $id;
} }
} else { } else {
$err->raise("dom", _("This domain is not installed in your account")); $msg->raise('Error', "dom", _("This domain is not installed in your account"));
return false; return false;
} }
} }
@ -1810,10 +1810,10 @@ class m_dom {
/** Add a slave account that will be allowed to access the domain list /** Add a slave account that will be allowed to access the domain list
*/ */
function add_slave_account($login, $pass) { function add_slave_account($login, $pass) {
global $db, $err; global $db, $msg;
$db->query("SELECT * FROM slaveaccount WHERE login= ?", array($login)); $db->query("SELECT * FROM slaveaccount WHERE login= ?", array($login));
if ($db->next_record()) { if ($db->next_record()) {
$err->raise("dom", _("The specified slave account already exists")); $msg->raise('Error', "dom", _("The specified slave account already exists"));
return false; return false;
} }
$db->query("INSERT INTO slaveaccount (login,pass) VALUES (?, ?)", array($login, $pass)); $db->query("INSERT INTO slaveaccount (login,pass) VALUES (?, ?)", array($login, $pass));
@ -1825,7 +1825,7 @@ class m_dom {
/** Remove a slave account /** Remove a slave account
*/ */
function del_slave_account($login) { function del_slave_account($login) {
global $db, $err; global $db, $msg;
$db->query("DELETE FROM slaveaccount WHERE login= ?", array($login)); $db->query("DELETE FROM slaveaccount WHERE login= ?", array($login));
return true; return true;
} }
@ -1841,10 +1841,10 @@ class m_dom {
* @access private * @access private
*/ */
function lock() { function lock() {
global $err; global $msg;
$err->log("dom", "lock"); $msg->log("dom", "lock");
if ($this->islocked) { if ($this->islocked) {
$err->raise("dom", _("--- Program error --- Lock already obtained!")); $msg->raise('Error', "dom", _("--- Program error --- Lock already obtained!"));
} }
while (file_exists($this->fic_lock_cron)) { while (file_exists($this->fic_lock_cron)) {
sleep(2); sleep(2);
@ -1860,10 +1860,10 @@ class m_dom {
* @access private * @access private
*/ */
function unlock() { function unlock() {
global $err; global $msg;
$err->log("dom", "unlock"); $msg->log("dom", "unlock");
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom", _("--- Program error --- No lock on the domains!")); $msg->raise('Error', "dom", _("--- Program error --- No lock on the domains!"));
} }
$this->islocked = false; $this->islocked = false;
return true; return true;
@ -1875,9 +1875,9 @@ class m_dom {
* This adds 2 MX entries in this domain (if required) * This adds 2 MX entries in this domain (if required)
*/ */
function hook_dom_add_mx_domain($dom_id) { function hook_dom_add_mx_domain($dom_id) {
global $err; global $msg;
$domain = $this->get_domain_byid($dom_id); $domain = $this->get_domain_byid($dom_id);
$err->log("dom", "hook_dom_add_mx_domain"); $msg->log("dom", "hook_dom_add_mx_domain");
$this->set_sub_domain($domain, '', $this->type_defmx, ''); $this->set_sub_domain($domain, '', $this->type_defmx, '');
if (!empty($GLOBALS['L_DEFAULT_SECONDARY_MX'])) { if (!empty($GLOBALS['L_DEFAULT_SECONDARY_MX'])) {
$this->set_sub_domain($domain, '', $this->type_defmx2, ''); $this->set_sub_domain($domain, '', $this->type_defmx2, '');
@ -1890,9 +1890,9 @@ class m_dom {
/** /**
* Delete an account (all his domains) * Delete an account (all his domains)
*/ */
function hook_admin_del_member() { function admin_del_member() {
global $err; global $msg;
$err->log("dom", "alternc_del_member"); $msg->log("dom", "alternc_del_member");
$li = $this->enum_domains(); $li = $this->enum_domains();
foreach ($li as $dom) { foreach ($li as $dom) {
$this->del_domain($dom); $this->del_domain($dom);
@ -1908,8 +1908,8 @@ class m_dom {
* @access private * @access private
*/ */
function hook_quota_get() { function hook_quota_get() {
global $db, $err, $cuid; global $db, $msg, $cuid;
$err->log("dom", "get_quota"); $msg->log("dom", "get_quota");
$q = Array("name" => "dom", "description" => _("Domain name"), "used" => 0); $q = Array("name" => "dom", "description" => _("Domain name"), "used" => 0);
$db->query("SELECT COUNT(*) AS cnt FROM domaines WHERE compte= ?", array($cuid)); $db->query("SELECT COUNT(*) AS cnt FROM domaines WHERE compte= ?", array($cuid));
if ($db->next_record()) { if ($db->next_record()) {
@ -1924,8 +1924,8 @@ class m_dom {
* No parameters needed * No parameters needed
* */ * */
function alternc_export_conf() { function alternc_export_conf() {
global $err; global $msg;
$err->log("dom", "export"); $msg->log("dom", "export");
$this->enum_domains(); $this->enum_domains();
$str = ""; $str = "";
foreach ($this->domains as $d) { foreach ($this->domains as $d) {
@ -1974,8 +1974,8 @@ class m_dom {
* Optionnal parameters: id of the sub_domaines * Optionnal parameters: id of the sub_domaines
* */ * */
function generation_parameters($id = null, $only_apache = true) { function generation_parameters($id = null, $only_apache = true) {
global $db, $err; global $db, $msg;
$err->log("dom", "generation_parameters"); $msg->log("dom", "generation_parameters");
$params = ""; $params = "";
/** 2016_05_18 : this comments was here before escaping the request... is there still something to do here ? /** 2016_05_18 : this comments was here before escaping the request... is there still something to do here ?
* // BUG BUG BUG FIXME * // BUG BUG BUG FIXME
@ -2126,8 +2126,8 @@ class m_dom {
// Return an array with the list of id of sub_domains waiting for an action // Return an array with the list of id of sub_domains waiting for an action
function generation_todo() { function generation_todo() {
global $db, $err; global $db, $msg;
$err->log("dom", "generation_todo"); $msg->log("dom", "generation_todo");
$db->query("select id as sub_id, web_action, type from sub_domaines where web_action !='ok';"); $db->query("select id as sub_id, web_action, type from sub_domaines where web_action !='ok';");
$r = array(); $r = array();
while ($db->next_record()) { while ($db->next_record()) {