Mxlist peut donner la liste en format json avec un check d'integrité
This commit is contained in:
parent
db5395c769
commit
5a3559a1fa
|
@ -29,19 +29,29 @@
|
|||
*/
|
||||
require_once("../class/config_nochk.php");
|
||||
|
||||
$fields = array (
|
||||
"json" => array ("get", "boolean", "0"),
|
||||
);
|
||||
getFields($fields);
|
||||
|
||||
|
||||
// Check for the http authentication
|
||||
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
||||
header('WWW-Authenticate: Basic realm="MX List Authentication"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
exit;
|
||||
} else {
|
||||
if ($mail->check_slave_account($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'])) {
|
||||
$mail->echo_domain_list();
|
||||
} else {
|
||||
header('WWW-Authenticate: Basic realm="MX List Authentication"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
if ($mail->check_slave_account($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'])) {
|
||||
if (!$json) {
|
||||
$mail->echo_domain_list();
|
||||
} else {
|
||||
print_r($mail->echo_domain_list("json"));
|
||||
}
|
||||
} else {
|
||||
header('WWW-Authenticate: Basic realm="MX List Authentication"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -785,13 +785,28 @@ ORDER BY
|
|||
/* ----------------------------------------------------------------- */
|
||||
/** Out (echo) the complete hosted domain list :
|
||||
*/
|
||||
function echo_domain_list() {
|
||||
global $db,$err;
|
||||
$db->query("SELECT domaine FROM domaines WHERE gesmx=1 ORDER BY domaine");
|
||||
while ($db->next_record()) {
|
||||
echo $db->f("domaine")."\n";
|
||||
}
|
||||
return true;
|
||||
function echo_domain_list($format=null) {
|
||||
global $db,$err;
|
||||
$db->query("SELECT domaine FROM domaines WHERE gesmx=1 ORDER BY domaine");
|
||||
$lst=array();
|
||||
$tt="";
|
||||
while ($db->next_record()) {
|
||||
$lst[]=$db->f("domaine");
|
||||
$tt.=$db->f("domaine");
|
||||
}
|
||||
|
||||
# Generate an integrity check
|
||||
$obj=array('integrity'=>md5($tt),'items'=>$lst);
|
||||
|
||||
switch($format) {
|
||||
case "json":
|
||||
return json_encode($obj);
|
||||
break;
|
||||
default:
|
||||
foreach ($lst as $l) { echo $l."\n"; }
|
||||
return true;
|
||||
break;
|
||||
} // switch
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue