diff --git a/README.md b/README.md index f527998..bb2dbe5 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,30 @@ # Boz Libre Hosting Panel This projects was started to create another _keep it simple and stupid_ libre web hosting control panel suitable for providers of everyday shared hosting services. ## Features Let me say that I love listening to the whishlist of my costumers. Here are the most important features/TODOs: - administration of own mailboxes - [X] password reset - [ ] add - [ ] remove - [ ] view quota - administration of own mail aliases (thanks to Postfix and Dovecot over MariaDB) - [X] change foward destination(s) - [X] add - - [ ] remove + - [X] remove - [ ] administration of own FTP accounts (thanks to Pure-FTPd over MariaDB) - [ ] administration of own MariaDB databases ## License Copyright (C) 2018 [Valerio Bozzolan](https://boz.reyboz.it/) - _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 Affero General Public License along with this program. If not, see . diff --git a/mailfoward.php b/mailfoward.php index 6dda173..6f2af19 100644 --- a/mailfoward.php +++ b/mailfoward.php @@ -1,157 +1,170 @@ . /* * This is the single e-mail fowarding edit page */ // load framework require 'load.php'; // wanted informations $domain = null; $mailfoward = null; // URL paramenters (maximum both domain and mailfoward source, minimum just domain) list( $domain_name, $mailfoward_source ) = url_parts( 2, 1 ); // eventually retrieve mailfoward from database if( $mailfoward_source ) { $mailfoward = ( new MailfowardFullAPI ) ->select( [ 'domain.domain_ID', 'domain.domain_name', 'mailfoward_source', 'mailfoward_destination', ] ) ->whereDomainName( $domain_name ) ->whereMailfowardSource( $mailfoward_source ) ->whereDomainIsEditable() ->queryRow(); // 404 $mailfoward or PageNotFound::spawn(); // recycle the mailfoward object that has domain informations $domain = $mailfoward; } // eventually retrieve domain from database if( ! $domain ) { $domain = ( new DomainAPI() ) ->select( [ 'domain.domain_ID', 'domain.domain_name', ] ) ->whereDomainName( $domain_name ) ->whereDomainIsEditable() ->queryRow(); // 404 $domain or PageNotFound::spawn(); } // save destination action if( is_action( 'mailfoward-save' ) ) { // columns to be saved $changes = []; // always require destination if( empty( $_POST[ 'mailfoward_destination' ] ) ) { BadRequest::spawn( __( "missing parameter" ) ); } // validate destination $destination = luser_input( $_POST[ 'mailfoward_destination' ], 128 ); if( filter_var( $destination, FILTER_VALIDATE_EMAIL ) ) { $changes[] = new DBCol( 'mailfoward_destination', $destination, 's' ); } else { BadRequest::spawn( __( "fail e-mail validation" ) ); } // save source only during creation if( ! $mailfoward ) { // require source (can be empty) if( ! isset( $_POST[ 'mailfoward_source' ] ) ) { BadRequest::spawn( __( "missing parameter" ) ); } $source = luser_input( $_POST[ 'mailfoward_source' ], 128 ); if( ! empty( $source ) && ! validate_mailbox_username( $source ) ) { BadRequest::spawn( __( "invalid mailbox name" ) ); } $changes[] = new DBCol( 'mailfoward_source', $source, 's' ); } if( $changes ) { if( $mailfoward ) { // update existing $mailfoward->update( $changes ); // POST/redirect/GET http_redirect( $mailfoward->getMailfowardPermalink( true ), 303 ); } else { // insert as new // check existence $mailfoward_exists = ( new MailfowardAPI ) ->select( 1 ) ->whereDomain( $domain ) ->whereMailfowardSource( $source ) ->queryRow(); // die if exists if( $mailfoward_exists ) { BadRequest::spawn( __( "e-mail fowarding already existing" ) ); } // insert as new row insert_row( 'mailfoward', array_merge( $changes, [ new DBCol( 'domain_ID', $domain->getDomainID(), 'd' ), ] ) ); // POST/redirect/GET http_redirect( Mailfoward::permalink( $domain->getDomainName(), $source, true ), 303 ); } } } +// delete action +if( $mailfoward && is_action( 'mailfoward-delete' ) ) { + query( sprintf( + "DELETE FROM %s WHERE domain_ID = %d AND mailfoward_source = '%s'", + T( 'mailfoward' ), + $mailfoward->getDomainID(), + esc_html( $mailfoward->getMailfowardSource() ) + ) ); + + // POST/redirect/GET + http_redirect( $domain->getDomainPermalink( true ), 303 ); +} + // spawn header Header::spawn( [ 'title-prefix' => __( "E-mail fowarding" ), 'title' => $mailfoward ? $mailfoward->getMailfowardAddress() : __( "create" ), 'breadcrumb' => [ new MenuEntry( null, $domain->getDomainPermalink(), $domain->getDomainName() ), ], ] ); // spawn the page content template( 'mailfoward', [ 'domain' => $domain, 'mailfoward' => $mailfoward, ] ); // spawn the footer Footer::spawn(); diff --git a/template/mailfoward.php b/template/mailfoward.php index 75b2a7a..688ae02 100644 --- a/template/mailfoward.php +++ b/template/mailfoward.php @@ -1,59 +1,64 @@ . /* * This is the template for a single e-mail fowarding * * Called from: * mailfoward.php * * Available variables: * $domain Domain object * $mailfoward Mailfoward object */ // unuseful when load directly defined( 'BOZ_PHP' ) or die; ?>


getMailfowardAddress() ) ?> /> getMailfowardSource() ); } ?> /> @getDomainName() ) ?>


getMailfowardDestination() ); } ?> />

-

+

+ + + + +