Page MenuHomeGitPull.it

No OneTemporary

Authored By
Unknown
Size
23 KB
Referenced Files
None
Subscribers
None
diff --git a/load-post.php b/load-post.php
index 4aad756..34b3cdf 100644
--- a/load-post.php
+++ b/load-post.php
@@ -1,84 +1,84 @@
<?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_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' );
-// limit session duration to 5 minutes (60s * 5m)
-define_default( 'SESSION_DURATION', 300 );
+// limit session duration to 5 minutes (60s * 100m)
+define_default( 'SESSION_DURATION', 6000 );
// register web pages
add_menu_entries( [
new MenuEntry( 'index', '/', __( "Dashboard" ) ),
new MenuEntry( 'login', 'login.php', __( "Login" ) ),
new MenuEntry( 'profile', 'profile.php', __( "Profile" ) ),
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/404.php b/www/404.php
similarity index 97%
rename from 404.php
rename to www/404.php
index a117860..5837edd 100644
--- a/404.php
+++ b/www/404.php
@@ -1,25 +1,25 @@
<?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 page not found
*/
// load framework
-require 'load.php';
+require '../load.php';
PageNotFound::spawn();
diff --git a/domain.php b/www/domain.php
similarity index 98%
rename from domain.php
rename to www/domain.php
index 56f4604..900b298 100644
--- a/domain.php
+++ b/www/domain.php
@@ -1,49 +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';
+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-prefix' => __( "Domain" ),
'title' => $domain_name,
] );
// spawn the domain template
template( 'domain', [
'domain' => $domain,
] );
// spawn the footer
Footer::spawn();
diff --git a/index.php b/www/index.php
similarity index 98%
rename from index.php
rename to www/index.php
index e6999eb..3c3a51d 100644
--- a/index.php
+++ b/www/index.php
@@ -1,76 +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 '../load.php';
// require read permissions
require_permission( 'read' );
// spawn header
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/login.php b/www/login.php
similarity index 99%
rename from login.php
rename to www/login.php
index 62fd5f2..710d371 100644
--- a/login.php
+++ b/www/login.php
@@ -1,79 +1,79 @@
<?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 login page
*/
// load framework
-require 'load.php';
+require '../load.php';
// spawn header
Header::spawn();
// go to the wanted page (or homepage)
if( login() ) {
http_redirect( after_login_url(), 307 );
}
?>
<?php if( isset( $_POST[ 'user_uid' ] ) ): ?>
<p class="alert alert-warning"><?php _e( "Authentication failed!" ) ?></p>
<?php endif ?>
<p><?php printf(
__( "You need %s credentials to proceed." ),
SITE_NAME
) ?></p>
<form method="post">
<div class="form-group">
<label for="user-uid"><?php _e( "Username" ) ?></label>
<input type="text" class="form-control" name="user_uid" id="user-uid" placeholder="<?php _e( "foo.bar" ) ?>"<?php _value( @ $_REQUEST[ 'user_uid' ] ) ?> />
</div>
<div class="form-group">
<label for="user-password"><?php _e( "Password" ) ?></label>
<input type="password" class="form-control" name="user_password" id="user-password" />
</div>
<?php if( ! empty( $_POST[ 'user_uid' ] ) ): ?>
<p><a href="<?php
// the password reset URL
echo http_build_get_query(
get_menu_entry( 'password-reset' )->getSitePage( ROOT ), [
'user_uid' => @ $_REQUEST[ 'user_uid' ],
] );
?>"><?php _e( "Lost password?" ) ?></a></p>
<?php endif ?>
<button type="submit" class="btn btn-default"><?php _e( "Login" ) ?></button>
</form>
<?php
// spawn footer
Footer::spawn();
/**
* Return the back URL to be redirected after the login action
*/
function after_login_URL() {
if( isset( $_GET[ 'redirect' ] ) && 0 === strpos( $_GET[ 'redirect' ], '/' ) ) {
return site_page( $_GET[ 'redirect' ], URL );
}
return get_menu_entry( 'index' )
->getSitePage( URL );
}
diff --git a/logout.php b/www/logout.php
similarity index 97%
rename from logout.php
rename to www/logout.php
index e0459d8..283bc89 100644
--- a/logout.php
+++ b/www/logout.php
@@ -1,42 +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';
+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 );
// spawn the logout template
template( 'logout' );
// spawn footer
Footer::spawn();
diff --git a/mailbox.php b/www/mailbox.php
similarity index 98%
rename from mailbox.php
rename to www/mailbox.php
index 919e193..95889d8 100644
--- a/mailbox.php
+++ b/www/mailbox.php
@@ -1,65 +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';
+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-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/mailforward.php b/www/mailforward.php
similarity index 99%
rename from mailforward.php
rename to www/mailforward.php
index 333e52d..6e4c0fa 100644
--- a/mailforward.php
+++ b/www/mailforward.php
@@ -1,178 +1,178 @@
<?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 single e-mail forwarding edit page
*/
// load framework
-require 'load.php';
+require '../load.php';
// wanted informations
$domain = null;
$mailforwardfrom = null;
// URL paramenters (maximum both domain and mailforward source, minimum just domain)
list( $domain_name, $mailforwardfrom_username ) = url_parts( 2, 1 );
// eventually retrieve mailforward from database
if( $mailforwardfrom_username ) {
$mailforwardfrom = ( new MailforwardfromAPI )
->select( [
'domain.domain_ID',
'domain_name',
'mailforwardfrom.mailforwardfrom_ID',
'mailforwardfrom_username',
] )
->whereDomainName( $domain_name )
->whereMailforwardfromUsername( $mailforwardfrom_username )
->whereDomainIsEditable()
->queryRow();
// 404
$mailforwardfrom or PageNotFound::spawn();
// recycle the mailforward object that has domain informations
$domain = $mailforwardfrom;
}
// 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( 'mailforward-save' ) ) {
// save source only during creation
if( ! $mailforwardfrom ) {
// sanitize
if( ! isset( $_POST[ 'mailforwardfrom_username' ] ) ) {
BadRequest::spawn( __( "missing parameter" ) );
}
$username = luser_input( $_POST[ 'mailforwardfrom_username' ], 128 );
if( ! validate_mailbox_username( $username ) ) {
BadRequest::spawn( __( "invalid mailbox name" ) );
}
// check existence
$mailforwardfrom_exists = ( new MailforwardfromAPI )
->select( 1 )
->whereDomain( $domain )
->whereMailforwardfromUsername( $source )
->queryRow();
// die if exists
if( $mailforwardfrom_exists ) {
BadRequest::spawn( __( "e-mail forwarding already existing" ) );
}
// insert as new row
insert_row( 'mailforwardfrom', [
new DBCol( 'domain_ID', $domain->getDomainID(), 'd' ),
new DBCol( 'mailforwardfrom_username', $username, 's' ),
] );
// POST/redirect/GET
http_redirect( Mailforwardfrom::permalink(
$domain->getDomainName(),
$username,
true
), 303 );
}
}
// delete action
if( $mailforwardfrom ) {
// action fired when deleting a whole mailforward
if( is_action( 'mailforward-delete' ) ) {
// drop th
query( sprintf(
"DELETE FROM %s WHERE domain_ID = %d AND mailforwardfrom_username = '%s'",
T( 'mailforwardfrom' ),
$mailforwardfrom->getDomainID(),
$mailforwardfrom->getMailforwardfromUsername()
) );
// POST/redirect/GET
http_redirect( $domain->getDomainPermalink( true ), 303 );
}
// action fired when adding/removing a mailforward
if( ( is_action( 'mailforwardto-add' ) || is_action( 'mailforwardto-remove' ) ) && isset( $_POST[ 'address' ] ) ) {
$address = require_email( $_POST[ 'address' ] );
$existing_address =
( new MailforwardtoAPI() )
->whereMailforwardfrom( $mailforwardfrom )
->whereMailforwardtoAddress( $address )
->queryRow();
// action fired when removing a mailforward
if( is_action( 'mailforwardto-remove' ) && $existing_address ) {
query( sprintf(
"DELETE FROM %s WHERE mailforwardfrom_ID = %d and mailforwardto_address = '%s'",
T( 'mailforwardto' ),
$mailforwardfrom->getMailforwardfromID(),
esc_sql( $address )
) );
}
// action fired when adding a mailforward
if( is_action( 'mailforwardto-add' ) && ! $existing_address ) {
insert_row( 'mailforwardto', [
new DBCol( 'mailforwardfrom_ID', $mailforwardfrom->getMailforwardfromID(), 'd' ),
new DBCol( 'mailforwardto_address', $address, 's' ),
] );
}
}
}
// spawn header
Header::spawn( [
'title-prefix' => __( "E-mail forwarding" ),
'title' => $mailforwardfrom
? $mailforwardfrom->getMailforwardfromAddress()
: __( "create" ),
'breadcrumb' => [
new MenuEntry( null, $domain->getDomainPermalink(), $domain->getDomainName() ),
],
] );
// spawn the page content
template( 'mailforward', [
'domain' => $domain,
'mailforwardfrom' => $mailforwardfrom,
] );
// spawn the footer
Footer::spawn();
diff --git a/password-reset.php b/www/password-reset.php
similarity index 98%
rename from password-reset.php
rename to www/password-reset.php
index 52e2fa3..82c59e2 100644
--- a/password-reset.php
+++ b/www/password-reset.php
@@ -1,50 +1,50 @@
<?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/>.
-require 'load.php';
+require '../load.php';
/*
* This is the password reset page
*/
// do something
if( is_action( 'password-reset' ) ) {
die( "Apologies. This feature is not ready :(" );
if( is_logged() ) {
send_email( __( "Password reset" ), $message, $to = false );
} else {
send_email( __( "Password reset" ), $message, $to = false );
}
}
// spawn header
Header::spawn();
?>
<form method="post">
<?php if( ! is_logged() ): ?>
<div class="form-group">
<label for="user-uid"><?php _e( "Username" ) ?></label>
<input type="text" class="form-control" name="user_uid" id="user-uid" placeholder="<?php _e( "foo.bar" ) ?>"<?php _value( @ $_REQUEST[ 'user_uid' ] ) ?> />
</div>
<?php endif ?>
<button type="submit" class="btn btn-default" name="action" value="password-reset"><?php _e( "Proceed" ) ?></button>
</form>
<?php
// spawn footer
Footer::spawn();
diff --git a/profile.php b/www/profile.php
similarity index 98%
rename from profile.php
rename to www/profile.php
index 844db56..6fbcbbf 100644
--- a/profile.php
+++ b/www/profile.php
@@ -1,83 +1,83 @@
<?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 user profile page
*/
// load framework
-require 'load.php';
+require '../load.php';
// must be logged
require_permission( 'read' );
// myself
$user = get_user();
// edit whatever user
if( isset( $_SERVER[ 'PATH_INFO' ] ) ) {
require_permission( 'edit-all-user' );
list( $user_uid ) = url_parts( 1 );
$user = Sessionuser::factoryFromUID( $user_uid )
->queryRow();
if( ! $user ) {
PageNotFound::spaqn();
}
}
// spawn header
Header::spawn( [
'title' => __( "Profile" ),
] );
// user e-mail
$email = $user->get( 'user_email' );
// handle send user password action
if( is_action( 'send-user-password' ) ) {
// generate
$password = generate_password();
// e-mail body
$mail_content = template_content( 'mail-user-password', [
'email' => $email,
'name' => $user->get( 'user_name' ),
'uid' => $user->get( 'user_uid' ),
'surname' => $user->get( 'user_surname' ),
'password' => $password,
] );
// update
query_update( 'user', [
new DBCol( 'user_password', Sessionuser::encryptPassword( $password ), 's' ),
], sprintf(
'user_ID = %d',
$user->get( 'user_ID' )
) );
// send
send_email( __( "Password reset" ), $mail_content, $email );
}
// spawn the profile page
template( 'profile', [ 'email' => $email ] );
// spawn footer
Footer::spawn();

File Metadata

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

Event Timeline