Page MenuHomeGitPull.it

No OneTemporary

Authored By
Unknown
Size
41 KB
Referenced Files
None
Subscribers
None
diff --git a/content/style.css b/content/style.css
new file mode 100644
index 0000000..e85b1fa
--- /dev/null
+++ b/content/style.css
@@ -0,0 +1,14 @@
+/**
+ * This is your custom stylesheet
+ *
+ * It overrides the default one
+ */
+#breadcrumb {
+ padding-left:0;
+}
+#breadcrumb li {
+ display:inline;
+}
+#breadcrumb li:not(:last-child)::after {
+ content: ' >';
+}
diff --git a/domain.php b/domain.php
index 42eb738..56f4604 100644
--- a/domain.php
+++ b/domain.php
@@ -1,67 +1,49 @@
<?php
# Copyright (C) 2018 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 );
// retrieve domain
$domain = ( new DomainAPI() )
->whereDomainName( $domain_name )
->whereDomainIsEditable()
->queryRow();
// 404?
$domain or PageNotFound::spawn();
// spawn header
Header::spawn( [
- 'title' => sprintf(
- __( "Domain: %s" ),
- "<em>" . esc_html( $domain_name ) . "</em>"
- ),
+ 'title-prefix' => __( "Domain" ),
+ 'title' => $domain_name,
] );
// spawn the domain template
template( 'domain', [
- 'mailboxes' =>
- $domain->factoryMailbox()
- ->select( [
- 'domain_name',
- 'mailbox_username',
- 'mailbox_receive',
- ] )
- ->queryGenerator(),
-
- 'mailfowards' =>
- $domain->factoryMailfoward()
- ->select( [
- 'domain_name',
- 'mailfoward_source',
- 'mailfoward_destination',
- ] )
- ->queryGenerator()
+ 'domain' => $domain,
] );
// spawn the footer
Footer::spawn();
diff --git a/include/class-Breadcrumb.php b/include/class-Breadcrumb.php
new file mode 100644
index 0000000..80a326d
--- /dev/null
+++ b/include/class-Breadcrumb.php
@@ -0,0 +1,71 @@
+<?php
+# Copyright (C) 2018 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/>.
+
+/**
+ * Handle a breadcrumb with the related microdata
+ *
+ * @url https://schema.org/BreadcrumbList
+ * @url https://developers.google.com/search/docs/data-types/breadcrumb
+ */
+class Breadcrumb {
+
+ /**
+ * Spawn the breadcrumb
+ *
+ * @param $uid string|null Starting menu uid
+ * @param $title string|null Starting title
+ * @param $parent_uid string|null Parent menu uid
+ */
+ public static function spawn( $breadcrumbs ) {
+ ?>
+ <ol itemscope itemtype="http://schema.org/BreadcrumbList" id="breadcrumb">
+ <?php $i = 0 ?>
+ <?php foreach( $breadcrumbs as $crumb ): ?>
+ <?php self::menuEntryLink( ++$i, $crumb ) ?>
+ <?php endforeach ?>
+ </ol>
+ <?php
+ }
+
+ /**
+ * Spawn a link from a menu entry
+ *
+ * @param $i int
+ * @param $entry MenuEntry
+ */
+ public static function menuEntryLink( $i, $entry ) {
+ $url = $entry->url ? $entry->getSitePage() : null;
+ return self::link( $i, $url, $entry->name );
+ }
+
+ /**
+ * Spawn a link with microdata
+ */
+ public static function link( $i, $url, $title ) {
+ echo '<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">';
+ if( $url ) {
+ echo '<a itemprop="item" href="' . esc_attr( $url ) . '">';
+ echo '<span itemprop="name">' . esc_html( $title ) . '</span>';
+ echo '</a>';
+ } else {
+ echo '<span itemprop="name">' . _esc_html( $title ) . '</span>';
+ }
+ echo '<meta itemprop="position" content="' . $i . '" />';
+ echo "</li>\n";
+ }
+
+}
diff --git a/include/class-Domain.php b/include/class-Domain.php
index bf65865..086de37 100644
--- a/include/class-Domain.php
+++ b/include/class-Domain.php
@@ -1,68 +1,77 @@
<?php
# Copyright (C) 2018 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/>.
/**
* A domain handled by the user
*/
class Domain extends Queried {
const T = 'domain';
const UID = 'domain_name';
public function __construct() {
$this->integers( 'domain_ID' );
$this->booleans( 'domain_active' );
$this->dates( 'domain_born', 'domain_expiration' );
}
/**
* Get domain ID
*
* @return int
*/
public function getDomainID() {
return $this->get( 'domain_ID' );
}
+ /**
+ * Get domain name
+ *
+ * @return string
+ */
+ public function getDomainName() {
+ return $this->get( 'domain_name' );
+ }
+
/**
* Get the domain edit URl
*
* @return string
*/
public function getDomainPermalink( $absolute = false ) {
return ROOT . '/domain.php/' . $this->get( 'domain_name' );
}
/**
* Factory mailbox from this domain
*
* @return MailboxFullAPI
*/
public function factoryMailbox() {
return ( new MailboxFullAPI() )->whereDomain( $this );
}
/**
* Factory e-mail foward from this domain
*
* @return MailfowardFullAPI
*/
public function factoryMailfoward() {
return ( new MailfowardFullAPI() )->whereDomain( $this );
}
}
diff --git a/include/class-Header.php b/include/class-Header.php
index 5f0548a..e4e81aa 100644
--- a/include/class-Header.php
+++ b/include/class-Header.php
@@ -1,88 +1,91 @@
<?php
# Copyright (C) 2018 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/>.
/**
* The header of the web page
*/
class Header {
/**
* Header arguments
*
* It's public because the Footer reads it.
*
* @var array
*/
public static $args;
/**
* Spawn the header to standard output
*
* @param $args mixed Can be the page UID, or arguments where:
* uid: menu UID like 'home'
* title: document title
*/
public static function spawn( $args = [] ) {
// store arguments for future reads
self::$args = & $args;
// shortcut
if( is_string( $args ) ) {
$args = [ 'uid' => $args ];
}
// eventually retrieve actual page UID
if( ! isset( $args[ 'uid' ] ) ) {
$args[ 'uid' ] = self::actualPageUID();
}
// retrieve page informations
$page = isset( $args[ 'uid' ] )
? get_menu_entry( $args[ 'uid' ] )
: null;
// populate the page informations
if( $page ) {
$args = array_replace( [
'title' => $page->name,
], $args );
+ } else {
+ $args[ 'uid' ] = null;
}
// populate default arguments
$args = array_replace( [
- 'container' => true,
- 'sidebar' => true,
+ 'container' => true,
+ 'sidebar' => true,
+ 'breadcrumb' => [],
], $args );
// charset is usually UTF-8
header( 'Content-Type: text/html; charset=' . CHARSET );
// spawn header template
- template( 'header', $args );
+ template( 'header', [ 'args' => $args ] );
}
/**
* Get the default page UID
*
* @return string
*/
public static function actualPageUID() {
$page = basename( $_SERVER[ 'SCRIPT_NAME' ] );
return str_replace( '.php', '', $page );
}
}
diff --git a/include/functions.php b/include/functions.php
index 1a2a758..f6f32ff 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1,110 +1,138 @@
<?php
# Copyright (C) 2018 Valerio Bozzolan
# Reyboz another self-hosting panel project
#
# 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/>.
/**
* Require a certain page from the template directory
*
* @param $name string page name (to be sanitized)
* @param $args mixed arguments to be passed to the page scope
*/
function template( $name, $args = [] ) {
extract( $args );
require TEMPLATE_PATH . __ . "$name.php";
}
/**
* Print an e-mail (safe for bots)
*
* @param $email string
*/
function email_blur( $email ) {
$dot = strip_tags( __( " dot <!-- . -->" ) );
$at = strip_tags( __( " at <!-- @ -->" ) );
$email = esc_html( $email );
echo str_replace( [ '.', '@' ], [ $dot, $at ], $email );
}
/**
* Send an e-mail to someone
*
* @param $subject string E-mail subject
* @param $message string E-mail message
* @param $to string E-mail recipient (from current logged-in user as default)
*/
function send_email( $subject, $message, $to = false ) {
if( ! $to ) {
if( ! is_logged() ) {
die( "can't retrieve e-mail address from anon user" );
}
$to = get_user( 'user_email' );
}
return SMTPMail::instance()
->to( $to )
->message( $subject, $message )
->disconnect();
}
/**
* Require a certain permission
*
* @param $permission string An internal permission like 'edit-all-user'
* @param $redirect boolean Enable or disable the redirect
*/
function require_permission( $permission, $redirect = true ) {
if( ! has_permission( $permission ) ) {
if( is_logged() ) {
Header::spawn( [
'title' => __( "Permission denied" ),
] );
Footer::spawn();
exit;
} else {
$login = get_menu_entry( 'login' );
$url = $login->getSitePage( URL );
if( $redirect && isset( $_SERVER[ 'REQUEST_URI' ] ) ) {
$url = http_build_get_query( $url, [
'redirect' => $_SERVER[ 'REQUEST_URI' ],
] );
}
http_redirect( $url, 307 );
}
}
}
/**
* Check the POST action
*
* @param $action string e.g. 'save-domain'
* @return bool
*/
function is_action( $action ) {
return isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] === $action;
}
/**
* Get URL parts
*
* @param $n
*/
function url_parts( $n ) {
$parts = explode( _, $_SERVER[ 'PATH_INFO' ] );
array_shift( $parts );
if( count( $parts ) !== $n ) {
BadRequest::spawn();
}
return $parts;
}
+
+/**
+ * Link to an existing page from the menu
+ *
+ * @param $uid string E.g. 'index'
+ * @param $args mixed Arguments
+ */
+function the_menu_link( $uid ) {
+ $page = get_menu_entry( $uid );
+ the_link( $page->getSitePage(), $page->name, $args );
+}
+
+/**
+ * Link to a whatever page
+ *
+ * P.S. link() is a reserved function
+ *
+ * @param $url string
+ * @param $title string
+ * @param $args mixed Arguments
+ */
+function the_link( $url, $title, $args = [] ) {
+ template( 'link', [
+ 'title' => $title,
+ 'url' => $url,
+ 'args' => $args,
+ ] );
+}
diff --git a/index.php b/index.php
index dbc0b94..e6999eb 100644
--- a/index.php
+++ b/index.php
@@ -1,74 +1,76 @@
<?php
# Copyright (C) 2018 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 homepage of your hosting panel
*/
// load framework
require 'load.php';
// require read permissions
require_permission( 'read' );
// spawn header
-Header::spawn();
+Header::spawn( [
+ 'breadcrumb' => false,
+] );
// user domains
$domains = ( new DomainAPI() )
->select( [
'domain.domain_ID',
'domain_name',
'domain_active',
] )
->whereDomainIsEditable()
->orderBy( 'domain_name' )
->queryGenerator();
?>
<p class="lead"><?php printf(
__( "Welcome in your %s dashboard!" ),
SITE_NAME
) ?></p>
<?php if( $domains->valid() ): ?>
<h3><?php printf(
__( "Your %s" ),
__( "domains" )
) ?></h3>
<ul>
<?php foreach( $domains as $domain ): ?>
<li>
<code>
<?php if( $domain->domain_active ): ?>
<?php echo HTML::a(
$domain->getDomainPermalink(),
$domain->domain_name
) ?>
<?php else: ?>
<del><?php _esc_html( $domain->domain_name ) ?></del>
<?php endif ?>
</code>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
<?php
// spawn footer
Footer::spawn();
diff --git a/load-post.php b/load-post.php
index e3f1a55..bb5f345 100644
--- a/load-post.php
+++ b/load-post.php
@@ -1,84 +1,80 @@
<?php
# Copyright (C) 2018 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/>.
// include path
define_default( 'INCLUDE_PATH', ABSPATH . __ . 'include' );
// template path
define_default( 'TEMPLATE_PATH', ABSPATH . __ . 'template' );
// autoload classes from the /include directory
spl_autoload_register( function( $name ) {
$path = INCLUDE_PATH . __ . "class-$name.php";
if( is_file( $path ) ) {
require $path;
}
} );
// load common functions
require INCLUDE_PATH . __ . 'functions.php';
// jquery URL
// provided by the libjs-jquery package as default
define_default( 'JQUERY_URL', '/javascript/jquery/jquery.min.js' );
// Bootstrap CSS/JavaScript files without trailing slash
// provided by the libjs-bootstrap package as default
define_default( 'BOOTSTRAP_DIR_URL', '/javascript/bootstrap' );
// path to the Net SMTP class
// provided by the php-net-smtp package as default
define_default( 'NET_SMTP', '/usr/share/php/Net/SMTP.php' );
// register JavaScript/CSS files
-register_js( 'jquery', JQUERY_URL );
-register_js( 'bootstrap', BOOTSTRAP_DIR_URL . '/js/bootstrap.min.js' );
-register_css( 'bootstrap', BOOTSTRAP_DIR_URL . '/css/bootstrap.min.css' );
+register_js( 'jquery', JQUERY_URL );
+register_js( 'bootstrap', BOOTSTRAP_DIR_URL . '/js/bootstrap.min.js' );
+register_css( 'bootstrap', BOOTSTRAP_DIR_URL . '/css/bootstrap.min.css' );
+register_css( 'custom-css', ROOT . '/content/style.css' );
// GNU Gettext i18n
define( 'GETTEXT_DOMAIN', 'reyboz-hosting-panel' );
define( 'GETTEXT_DIRECTORY', 'l10n' );
define( 'GETTEXT_DEFAULT_ENCODE', CHARSET ); // UTF-8
// common strings
define_default( 'SITE_NAME', "Boz Libre Hosting Panel" );
define_default( 'CONTACT_EMAIL', 'support@' . DOMAIN );
define_default( 'REPO_URL', 'https://github.com/valerio-bozzolan/boz-libre-hosting-panel' );
// register web pages
-call_user_func( function () {
- $logged = is_logged();
- $show_to_user = $logged ? null : 'hidden';
- $show_to_anon = ! $logged ? null : 'hidden';
- add_menu_entries( [
- new MenuEntry( 'index', '', __( "Dashboard" ), $show_to_user ),
- new MenuEntry( 'login', 'login.php', __( "Login" ), $show_to_anon ),
- new MenuEntry( 'logout', 'logout.php', __( "Logout" ), $show_to_user ),
- new MenuEntry( 'password-reset', 'password-reset.php', __( "Password reset" ), $show_to_anon ),
- ] );
-} );
+add_menu_entries( [
+ new MenuEntry( 'index', '/', __( "Dashboard" ) ),
+ new MenuEntry( 'login', 'login.php', __( "Login" ) ),
+ new MenuEntry( 'logout', 'logout.php', __( "Logout" ) ),
+ new MenuEntry( 'password-reset', 'password-reset.php', __( "Password reset" ) ),
+] );
// permissions
register_permissions( 'user', [
'read',
'backend',
] );
inherit_permissions( 'admin', 'user', [
'edit-user-all',
'edit-email-all',
'edit-domain-all',
] );
diff --git a/logout.php b/logout.php
index 6510afe..e0459d8 100644
--- a/logout.php
+++ b/logout.php
@@ -1,47 +1,42 @@
<?php
# Copyright (C) 2018 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 logout page
*/
// load framework
require 'load.php';
// spawn header
Header::spawn( [
'title' => __( "Please confirm logout" ),
] );
// check login
if( is_action( 'logout' ) ) {
logout();
}
// require to be logged, but do not redirect again here otherwise
require_permission( 'read', false );
-?>
- <p class="alert alert-warning"><?php _e( "Please manually confirm your action." ) ?></p>
+// spawn the logout template
+template( 'logout' );
- <form method="post">
- <button type="submit" name="action" value="logout" class="btn btn-default"><?php _e( "Logout" ) ?></button>
- </form>
-
-<?php
// spawn footer
Footer::spawn();
diff --git a/mailbox.php b/mailbox.php
index 35aa5d5..919e193 100644
--- a/mailbox.php
+++ b/mailbox.php
@@ -1,64 +1,65 @@
<?php
# Copyright (C) 2018 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 mailbox edit page
*/
// load framework
require 'load.php';
// wanted domain and mailbox username
list( $domain_name, $mailbox_username ) = url_parts( 2 );
// retrieve domain
$mailbox = ( new MailboxFullAPI() )
->select( [
'domain.domain_ID',
'domain.domain_name',
'domain.domain_active',
'mailbox_username',
] )
->whereStr( 'domain_name', $domain_name )
->whereStr( 'mailbox_username', $mailbox_username )
->whereDomainIsEditable()
->queryRow();
// 404?
$mailbox or PageNotFound::spawn();
$password = null;
if( is_action( 'mailbox-password-reset' ) ) {
$password = $mailbox->updateMailboxPassword();
}
// spawn header
Header::spawn( [
- 'title' => sprintf(
- __( "Mailbox: %s" ),
- "<em>" . esc_html( $mailbox->getMailboxAddress() ) . "</em>"
- ),
+ 'title-prefix' => __( "Mailbox" ),
+ 'title' => $mailbox->getMailboxAddress(),
+ 'breadcrumb' => [
+ new MenuEntry( null, $mailbox->getDomainPermalink(), $mailbox->getDomainName() ),
+ ],
] );
// spawn the page content
template( 'mailbox', [
'mailbox' => $mailbox,
'password' => $password,
] );
// spawn the footer
Footer::spawn();
diff --git a/mailfoward.php b/mailfoward.php
index 3539442..b2fd733 100644
--- a/mailfoward.php
+++ b/mailfoward.php
@@ -1,72 +1,73 @@
<?php
# Copyright (C) 2018 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 single e-mail fowarding edit page
*/
// load framework
require 'load.php';
// wanted domain and mail fowarding source
list( $domain_name, $mailfoward_source ) = url_parts( 2 );
// retrieve domain
$mailfoward = ( new MailfowardFullAPI )
->select( [
'domain.domain_ID',
'domain.domain_name',
'domain.domain_active',
'mailfoward_source',
'mailfoward_destination',
] )
->whereDomainName( $domain_name )
->whereMailfowardSource( $mailfoward_source )
->whereDomainIsEditable()
->queryRow();
// 404?
$mailfoward or PageNotFound::spawn();
// handle save destination action
if( is_action( 'mailfoward-save-destination' ) ) {
$destination = $_POST[ 'mailfoward_destination' ];
if( filter_var( $destination, FILTER_VALIDATE_EMAIL ) ) {
$mailfoward->update( [
new DBCol( 'mailfoward_destination', $destination, 's' ),
] );
// POST/redirect/GET
- http_redirect( URL . $_SERVER[ 'REQUEST_URI' ] );
+ http_redirect( URL . $_SERVER[ 'REQUEST_URI' ], 303 );
}
}
// spawn header
Header::spawn( [
- 'title' => sprintf(
- _( "Mailfoward: %s" ),
- "<em>" . esc_html( $mailfoward->getMailfowardAddress() ) . "</em>"
- ),
+ 'title-prefix' => __( "Mail fowarding" ),
+ 'title' => $mailfoward->getMailfowardAddress(),
+ 'breadcrumb' => [
+ new MenuEntry( null, $mailfoward->getDomainPermalink(), $mailfoward->getDomainName() ),
+ ],
] );
// spawn the page content
template( 'mailfoward', [
'mailfoward' => $mailfoward,
] );
// spawn the footer
Footer::spawn();
diff --git a/template/sidebar.php b/template/breadcrumb.php
similarity index 67%
copy from template/sidebar.php
copy to template/breadcrumb.php
index c59da84..9e36951 100644
--- a/template/sidebar.php
+++ b/template/breadcrumb.php
@@ -1,36 +1,37 @@
<?php
# Copyright (C) 2018 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 template for the website sidebar
+ * This is the template for the website breadcrumb navigation menu
*
* Called from:
- * template/footer.php
+ * template/header.php
*/
// unuseful when load directly
defined( 'BOZ_PHP' ) or die;
-?>
-<?php if( is_logged() ): ?>
- <p><?php printf(
- __( "Welcome %s!" ),
- esc_html( get_user( 'user_name' ) )
- ) ?></p>
-<?php endif ?>
+// add home to the breadcrumb
+array_unshift( $args[ 'breadcrumb' ], get_menu_entry( 'index' ) );
+
+// add "this page" to the breadcrumb
+if( $args[ 'uid' ] !== 'index' ) {
+ $args[ 'breadcrumb' ][] = new MenuEntry( null, null, $args[ 'title' ] );
+}
+?>
-<?php MenuTree::spawn() ?>
+<?php Breadcrumb::spawn( $args[ 'breadcrumb' ] ) ?>
diff --git a/template/domain.php b/template/domain.php
index 5e8b84d..5b80c6d 100644
--- a/template/domain.php
+++ b/template/domain.php
@@ -1,34 +1,32 @@
<?php
# Copyright (C) 2018 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 template for the website domain dashboard page
*
* Called from:
* domain.php
*/
// unuseful when load directly
defined( 'BOZ_PHP' ) or die;
// spawn the mailboxes list
-template( 'mailboxes', [ 'mailboxes' => $mailboxes ] );
+template( 'mailboxes', [ 'domain' => $domain ] );
// spawn the mail fowardings list
-template( 'mailfowards', [ 'mailfowards' => $mailfowards ] );
-
-
+template( 'mailfowards', [ 'domain' => $domain ] );
diff --git a/template/footer.php b/template/footer.php
index 7aab1f5..9a5124f 100644
--- a/template/footer.php
+++ b/template/footer.php
@@ -1,77 +1,77 @@
<?php
# Copyright (C) 2018 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 template for the website footer
*
* Called from:
* include/class-Footer.php
*/
// unuseful when load directly
defined( 'BOZ_PHP' ) or die;
load_module( 'footer' );
?>
</div>
<!-- /sidebar content -->
<!-- sidebar -->
- <?php if( $sidebar ): ?>
+ <?php if( $args[ 'sidebar' ] ): ?>
<div class="col-sm-4">
<?php template( 'sidebar' ) ?>
</div>
<?php endif ?>
<!-- /sidebar -->
<!-- page row -->
</div>
- <?php if( $container ): ?>
+ <?php if( $args[ 'container' ] ): ?>
</div>
<!-- /page container -->
<?php endif ?>
<hr />
<!-- footer -->
<div class="container">
<div class="row">
<!-- help -->
<?php if( CONTACT_EMAIL ): ?>
<div class="col-sm-2">
<?php _e( "Help:" ) ?><br />
<?php email_blur( CONTACT_EMAIL ) ?>
</div>
<?php endif ?>
<!-- end help -->
<!-- fork -->
<?php if( REPO_URL ): ?>
<div class="col-sm-2">
<?php _e( "Contribute:" ) ?><br />
<a href="<?php echo REPO_URL ?>" target="_blank"><?php _e( "project repository" ) ?></a>
</div>
<?php endif ?>
<!-- end for -->
</div>
</div>
<!-- /footer -->
</body>
</html>
diff --git a/template/header.php b/template/header.php
index 5b5875f..fe738dd 100644
--- a/template/header.php
+++ b/template/header.php
@@ -1,59 +1,69 @@
<?php
# Copyright (C) 2018 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 template for the website header
*
* Called from:
* include/class-Header.php
*/
// unuseful when load directly
defined( 'BOZ_PHP' ) or die;
// load Bootstrap stuff
-enqueue_js( 'jquery' );
-enqueue_js( 'bootstrap' );
-enqueue_css( 'bootstrap' );
+enqueue_js( 'jquery' );
+enqueue_js( 'bootstrap' );
+enqueue_css( 'bootstrap' );
+enqueue_css( 'custom-css' );
?>
<!DOCTYPE html>
<html>
<head>
- <title><?php echo strip_tags( $title ) ?> - <?php echo strip_tags( SITE_NAME ) ?></title>
+ <title><?php echo strip_tags( $args[ 'title' ] ) ?> - <?php echo strip_tags( SITE_NAME ) ?></title>
<link rel="icon" href="<?php echo ROOT ?>/content/logo/logo-64.png" type="image/png" /><?php load_module( 'header' ) ?>
</head>
<body>
<div class="container">
<h1><?php echo SITE_NAME ?></h1>
- <h2><?php echo $title ?></h2>
+
+ <?php if( isset( $args[ 'title-prefix' ] ) ): ?>
+ <h2><?php _esc_html( $args[ 'title-prefix' ] ) ?>: <em><?php _esc_html( $args[ 'title' ] ) ?></em></h2>
+ <?php else: ?>
+ <h2><?php _esc_html( $args[ 'title' ] ) ?></h2>
+ <?php endif ?>
+
+ <?php if( isset( $args[ 'breadcrumb' ] ) && $args[ 'breadcrumb' ] !== false ): ?>
+ <?php template( 'breadcrumb', [ 'args' => $args ] ) ?>
+ <?php endif ?>
</div>
- <?php if( $container ): ?>
+ <?php if( $args[ 'container' ] ): ?>
<!-- page container -->
<div class="container">
<?php endif ?>
<!-- page row -->
<div class="row">
<!-- sidebar content -->
- <?php if( $sidebar ): ?>
+ <?php if( $args[ 'sidebar' ] ): ?>
<div class="col-sm-8">
<?php else: ?>
<div class="col-sm-12">
<?php endif ?>
diff --git a/template/domain.php b/template/link.php
similarity index 73%
copy from template/domain.php
copy to template/link.php
index 5e8b84d..4839ad7 100644
--- a/template/domain.php
+++ b/template/link.php
@@ -1,34 +1,33 @@
<?php
# Copyright (C) 2018 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 template for the website domain dashboard page
+ * This is the template for a link
*
- * Called from:
- * domain.php
+ * Called from
+ * include/functions.php - the_link() function
+ *
+ * Available variables:
+ * $title string e.g. "Home"
+ * $href string e.g. "/"
+ * $args mixed
*/
// unuseful when load directly
defined( 'BOZ_PHP' ) or die;
-// spawn the mailboxes list
-template( 'mailboxes', [ 'mailboxes' => $mailboxes ] );
-
-// spawn the mail fowardings list
-template( 'mailfowards', [ 'mailfowards' => $mailfowards ] );
-
-
+?><a class="btn btn-link" href="<?php _esc_attr( $href ) ?>"><?php _esc_html( $title ) ?></a>
diff --git a/template/sidebar.php b/template/logout.php
similarity index 72%
copy from template/sidebar.php
copy to template/logout.php
index c59da84..e7817d0 100644
--- a/template/sidebar.php
+++ b/template/logout.php
@@ -1,36 +1,33 @@
<?php
# Copyright (C) 2018 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 template for the website sidebar
+ * This is the template for the logout page
*
- * Called from:
- * template/footer.php
+ * Called from
+ * logout.php
*/
// unuseful when load directly
defined( 'BOZ_PHP' ) or die;
?>
-<?php if( is_logged() ): ?>
- <p><?php printf(
- __( "Welcome %s!" ),
- esc_html( get_user( 'user_name' ) )
- ) ?></p>
-<?php endif ?>
+<p class="alert alert-warning"><?php _e( "Please manually confirm your action." ) ?></p>
-<?php MenuTree::spawn() ?>
+<form method="post">
+ <button type="submit" name="action" value="logout" class="btn btn-default"><?php _e( "Logout" ) ?></button>
+</form>
diff --git a/template/mailboxes.php b/template/mailboxes.php
index 390a033..753c945 100644
--- a/template/mailboxes.php
+++ b/template/mailboxes.php
@@ -1,50 +1,58 @@
<?php
# Copyright (C) 2018 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 template for the mailboxes list
*
* Called from:
* template/domain.php
*/
// unuseful when load directly
defined( 'BOZ_PHP' ) or die;
+// domain mailboxes
+$mailboxes = $domain->factoryMailbox()
+ ->select( [
+ 'domain_name',
+ 'mailbox_username',
+ 'mailbox_receive',
+ ] )
+ ->queryGenerator();
?>
<!-- mail boxes -->
<?php if( $mailboxes->valid() ): ?>
<h3><?php printf(
__( "Your %s" ),
__( "mailboxes" )
) ?></h3>
<?php template( 'mailbox-description' ) ?>
<ul>
<?php foreach( $mailboxes as $mailbox ): ?>
<li>
<code><?php echo HTML::a(
$mailbox->getMailboxPermalink(),
$mailbox->getMailboxAddress()
) ?></code>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
<!-- end mail boxes -->
diff --git a/template/mailfoward.php b/template/mailfoward.php
index d377b5f..cc22a7f 100644
--- a/template/mailfoward.php
+++ b/template/mailfoward.php
@@ -1,43 +1,43 @@
<?php
# Copyright (C) 2018 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 template for a single e-mail fowarding
*
* Called from:
* mailfoward.php
*/
// unuseful when load directly
defined( 'BOZ_PHP' ) or die;
?>
<?php template( 'mailfoward-description' ) ?>
<h3><?php _e( "Destination" ) ?></h3>
<form method="post">
<p>
<label for="mailfoward-destination"><?php printf(
- __( "Your incoming e-mails from %s will be fowarded to %s. Here you can change this destination." ),
+ __( "Your incoming e-mails from %s will be fowarded to %s. Here you can change this destination:" ),
esc_html( $mailfoward->getMailfowardAddress() ),
esc_html( $mailfoward->getMailfowardDestination() )
) ?></label>
<br />
- <input type="text" name="mailfoward_destination" id="mailfoward-destination"<?php _value( $mailfoward->getMailfowardDestination() ) ?> />
+ <input type="email" name="mailfoward_destination" id="mailfoward-destination"<?php _value( $mailfoward->getMailfowardDestination() ) ?> />
</p>
<p><button type="submit" class="btn btn-default" name="action" value="mailfoward-save-destination"><?php _e( "Save" ) ?></button></p>
</form>
diff --git a/template/mailfowards.php b/template/mailfowards.php
index cdbdff9..6637bcd 100644
--- a/template/mailfowards.php
+++ b/template/mailfowards.php
@@ -1,49 +1,57 @@
<?php
# Copyright (C) 2018 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 template for the mailboxes list
*
* Called from:
* template/domain.php
*/
// unuseful when load directly
defined( 'BOZ_PHP' ) or die;
+// domain mail fowardings
+$mailfowards = $domain->factoryMailfoward()
+ ->select( [
+ 'domain_name',
+ 'mailfoward_source',
+ 'mailfoward_destination',
+ ] )
+ ->queryGenerator();
?>
<!-- mail fowardings -->
<?php if( $mailfowards->valid() ): ?>
<h3><?php printf(
__( "Your %s" ),
__( "mail fowardings" )
) ?></h3>
<?php template( 'mailfoward-description' ) ?>
<ul>
<?php foreach( $mailfowards as $mailfoward ): ?>
<li>
<code><?php echo HTML::a(
$mailfoward->getMailfowardPermalink(),
$mailfoward->getMailfowardAddress()
) ?></code>
</li>
<?php endforeach ?>
</ul>
<?php endif ?>
<!-- end mail fowardings -->
diff --git a/template/sidebar.php b/template/sidebar.php
index c59da84..d951844 100644
--- a/template/sidebar.php
+++ b/template/sidebar.php
@@ -1,36 +1,39 @@
<?php
# Copyright (C) 2018 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 template for the website sidebar
*
* Called from:
* template/footer.php
*/
// unuseful when load directly
defined( 'BOZ_PHP' ) or die;
?>
<?php if( is_logged() ): ?>
<p><?php printf(
__( "Welcome %s!" ),
esc_html( get_user( 'user_name' ) )
) ?></p>
+
+ <?php if( is_logged() ): ?>
+ <?php the_menu_link( 'logout' ) ?>
+ <?php endif ?>
<?php endif ?>
-<?php MenuTree::spawn() ?>

File Metadata

Mime Type
text/x-diff
Expires
Thu, Nov 19, 04:48 (17 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2264832
Default Alt Text
(41 KB)

Event Timeline