diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..61cde56
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+composer.lock
+vendor/
+*~
diff --git a/cron.php b/cron.php
index d9ba29c..37fb26d 100644
--- a/cron.php
+++ b/cron.php
@@ -47,10 +47,10 @@ while ( $tmp = $stmt->fetch( PDO::FETCH_ASSOC ) ) {
$delete_prosody_archive->execute( [ $tmp[ 'local_part' ], $tmp[ 'domain' ] ] );
}
}
- if ( $tmp[ 'active' ] === '-2' ) {
+ if ( $tmp[ 'active' ] === -2 ) {
$delete->execute( [ $tmp[ 'username' ] ] );
}
- if ( $tmp[ 'active' ] === '-1' ) {
+ if ( $tmp[ 'active' ] === -1 ) {
$disable->execute( [ $tmp[ 'username' ] ] );
}
$delete_alias->execute( [ $tmp[ 'username' ] ] );
diff --git a/www/admin.php b/www/admin.php
index 577d457..f82a494 100644
--- a/www/admin.php
+++ b/www/admin.php
@@ -205,25 +205,37 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) {
$msg .= '
Successfully updated alias domain.
';
}
} elseif ( $_POST[ 'action' ] === 'save_new_domain' && ! empty( $_POST[ 'domain' ] ) && $_SESSION[ 'email_admin_superadmin' ] ) {
- $stmt = $db->prepare( 'SELECT null FROM domain WHERE domain = ?;' );
- $stmt->execute( [ $_POST[ 'domain' ] ] );
+ $stmt = $db->prepare( 'SELECT null FROM domain WHERE domain = ? UNION SELECT null FROM alias_domain WHERE alias_domain = ?;' );
+ $stmt->execute( [ $_POST[ 'domain' ], $_POST[ 'domain' ] ] );
if ( $stmt->fetch() ) {
$msg .= 'Oops, it looks like the domain "' . htmlspecialchars( $_POST[ 'domain' ] ) . '" already exists.
';
} else {
+ $ascii_domian = idn_to_ascii($_POST['domain'], IDNA_NONTRANSITIONAL_TO_ASCII);
+ $utf8_domian = idn_to_utf8($_POST['domain'], IDNA_NONTRANSITIONAL_TO_UNICODE);
$active = isset( $_POST[ 'active' ] ) ? 1 : 0;
$stmt = $db->prepare( 'INSERT INTO domain (active, domain, created, modified) VALUES (?, ?, NOW(), NOW());' );
- $stmt->execute( [ $active, $_POST[ 'domain' ] ] );
+ $stmt->execute( [ $active, $utf8_domain ] );
+ if($ascii_domain !== $utf8_domain){
+ $stmt = $db->prepare( 'INSERT INTO alias_domain (active, alias_domain, target_domain, created, modified) VALUES (1, ?, ?, NOW(), NOW());' );
+ $stmt->execute( [ $ascii_domain, $utf8_domain ] );
+ }
$msg .= 'Successfully created domain.
';
}
} elseif ( $_POST[ 'action' ] === 'save_new_alias_domain' && ! empty( $_POST[ 'alias_domain' ] ) && $_SESSION[ 'email_admin_superadmin' ] ) {
- $stmt = $db->prepare( 'SELECT null FROM alias_domain WHERE alias_domain = ?;' );
- $stmt->execute( [ $_POST[ 'alias_domain' ] ] );
+ $stmt = $db->prepare( 'SELECT null FROM domain WHERE domain = ? UNION SELECT null FROM alias_domain WHERE alias_domain = ?;' );
+ $stmt->execute( [ $_POST[ 'alias_domain' ], $_POST[ 'alias_domain' ] ] );
if ( $stmt->fetch() ) {
- $msg .= 'Oops, it looks like the alias domain "' . htmlspecialchars( $_POST[ 'domain' ] ) . '" already exists.
';
+ $msg .= 'Oops, it looks like the alias domain "' . htmlspecialchars( $_POST[ 'alias_domain' ] ) . '" already exists.
';
} else {
+ $ascii_domian = idn_to_ascii($_POST['alias_domain'], IDNA_NONTRANSITIONAL_TO_ASCII);
+ $utf8_domian = idn_to_utf8($_POST['alias_domain'], IDNA_NONTRANSITIONAL_TO_UNICODE);
$active = isset( $_POST[ 'active' ] ) ? 1 : 0;
$stmt = $db->prepare( 'INSERT INTO alias_domain (active, alias_domain, target_domain, created, modified) VALUES (?, ?, ?, NOW(), NOW());' );
- $stmt->execute( [ $active, $_POST[ 'alias_domain' ], $_POST[ 'target_domain' ] ] );
+ $stmt->execute( [ $active, $utf8_domain, $_POST[ 'target_domain' ] ] );
+ if($ascii_domain !== $utf8_domain){
+ $stmt = $db->prepare( 'INSERT INTO alias_domain (active, alias_domain, target_domain, created, modified) VALUES (?, ?, ?, NOW(), NOW());' );
+ $stmt->execute( [ $active, $ascii_domain, $_POST[ 'target_domain' ] ] );
+ }
$msg .= 'Successfully created alias domain.
';
}
} elseif ( $_POST[ 'action' ] === 'save_new_alias' && ! empty( $_POST[ 'alias' ] ) && ! empty( $_POST[ 'target' ] ) ) {
@@ -362,8 +374,8 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) {
-
-
+ E-Mail and XMPP - Admin managemen
+ if ( ! empty( $_SESSION[ 'email_admin_user' ] ) ) { ?>