Page MenuHomeGitPull.it

No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/www/domain.php b/www/domain.php
index 0f2f4bf..ace4475 100644
--- a/www/domain.php
+++ b/www/domain.php
@@ -1,77 +1,88 @@
<?php
# Copyright (C) 2018, 2019 Valerio Bozzolan
# Boz Libre Hosting Panel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
/*
* This is the domain edit page
*/
// load framework
require '../load.php';
// wanted domain
list( $domain_name ) = url_parts( 1, 0 );
$domain = null;
if( $domain_name ) {
// retrieve domain
$domain = ( new DomainAPI() )
->whereDomainName( $domain_name )
->whereDomainIsEditable()
->queryRow();
// 404?
$domain or PageNotFound::spawn();
} else {
// try to create
require_permission( 'edit-domain-all' );
if( is_action( 'add-domain' ) && isset( $_POST[ 'domain_name' ] ) ) {
+
+ // trim and normalize to max length
$domain_name = luser_input( $_POST[ 'domain_name' ], 64 );
- // @TODO: check for duplicates
+ // existing domain
+ $existing = ( new DomainAPI() )
+ ->whereDomainName( $domain_name )
+ ->queryRow();
+
+ // go to the existing one
+ if( $existing ) {
+ http_redirect( $existing->getDomainPermalink() );
+ }
+ // insert this new domain
insert_row( Domain::T, [
new DBCol( 'domain_name', $domain_name, 's' ),
new DBCol( 'domain_active', 1, 'd' ),
new DBCol( 'domain_born', 'NOW()', '-' ),
] );
- // POST -> redirect -> GET
+ // go to the new domain
http_redirect( Domain::permalink( $domain_name, true ) );
}
}
// spawn header
Header::spawn( [
'title-prefix' => __( "Domain" ),
'title' => $domain_name ? $domain_name : __( "Add" ),
] );
if( $domain ) {
// spawn the domain template
template( 'domain', [
'domain' => $domain,
] );
} else {
// form to create the domain
template( 'domain-create' );
}
// spawn the footer
Footer::spawn();

File Metadata

Mime Type
text/x-diff
Expires
Thu, Nov 19, 04:44 (12 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2264802
Default Alt Text
(2 KB)

Event Timeline