Skip to content

Commit

Permalink
Introduced new fixes to reported issues (#541)
Browse files Browse the repository at this point in the history
* Fixed Expiration issue and other minor issues

* Fixed quick installation section
  • Loading branch information
filippolauria authored Jul 5, 2024
1 parent 2777cb8 commit 3d6149d
Show file tree
Hide file tree
Showing 679 changed files with 128,191 additions and 149,145 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ To quickly install a basic standalone AAA infrastructure - based on daloRADIUS -
```bash
wget -qO - https://raw.githubusercontent.com/lirantal/daloradius/master/setup/install.sh | bash
```
At the end of this procedure, **the installation script will generate random credentials to be used for the operator's first login**.

---
### installation guide
To install daloRADIUS, you can follow the installation guide available in the project's official wiki:
Expand Down
2 changes: 2 additions & 0 deletions app/common/includes/config_read.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
$configValues['OPERATORS_INCLUDE_CONFIG'] = implode(DIRECTORY_SEPARATOR, [ $configValues['OPERATORS_INCLUDE'], 'config' ]);
$configValues['OPERATORS_LIBRARY'] = implode(DIRECTORY_SEPARATOR, [ $configValues['OPERATORS_ROOT'], 'library' ]);
$configValues['OPERATORS_LIBRARY_EXTENSIONS'] = implode(DIRECTORY_SEPARATOR, [ $configValues['OPERATORS_LIBRARY'], 'extensions' ]);
$configValues['OPERATORS_NOTIFICATIONS'] = implode(DIRECTORY_SEPARATOR, [ $configValues['OPERATORS_ROOT'], 'notifications' ]);
$configValues['OPERATORS_NOTIFICATIONS_TEMPLATES'] = implode(DIRECTORY_SEPARATOR, [ $configValues['OPERATORS_NOTIFICATIONS'], 'templates' ]);

$configValues['USERS_ROOT'] = implode(DIRECTORY_SEPARATOR, [ $configValues['APP_ROOT'], 'users' ]);

Expand Down
6 changes: 2 additions & 4 deletions app/common/includes/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -776,17 +776,15 @@ function print_input_field($input_descriptor) {

}

if (array_key_exists('tooltipText', $input_descriptor)) {
if (array_key_exists('tooltipText', $input_descriptor) && !empty($input_descriptor['tooltipText'])) {
$tooltipText = str_replace('"', "'", strip_tags($input_descriptor['tooltipText']));

printf(' placeholder="%s"', $tooltipText);

if (array_key_exists('sidebar', $input_descriptor) && $input_descriptor['sidebar'] !== false) {
printf(' tooltipText="%s"', $tooltipText);
}
}

if (array_key_exists('tooltipText', $input_descriptor) && !empty($input_descriptor['tooltipText'])) {
$describedby_id = $input_descriptor['id'] . '-help';
printf(' aria-describedby="%s"', $describedby_id);
}
Expand Down Expand Up @@ -815,7 +813,7 @@ function print_input_field($input_descriptor) {
$value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
printf('<option value="%s">' . "\n", $value);
}
echo '';
echo '</datalist>';
break;

case 'ajax':
Expand Down
89 changes: 89 additions & 0 deletions app/common/includes/mail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php
/*
*********************************************************************************************************
* daloRADIUS - RADIUS Web Platform
* Copyright (C) 2007 - Liran Tal <liran@enginx.com> All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*********************************************************************************************************
*
* Authors: Filippo Lauria <filippo.lauria@iit.cnr.it>
*
*********************************************************************************************************
*/

// prevent this file to be directly accessed
if (strpos($_SERVER['PHP_SELF'], '/common/includes/mail.php') !== false) {
http_response_code(404);
exit;
}

include_once 'config_read.php';

// Include PHPMailer classes
include implode(DIRECTORY_SEPARATOR, [ $configValues['COMMON_LIBRARY'], 'phpmailer', 'Exception.php' ]);
include implode(DIRECTORY_SEPARATOR, [ $configValues['COMMON_LIBRARY'], 'phpmailer', 'SMTP.php' ]);
include implode(DIRECTORY_SEPARATOR, [ $configValues['COMMON_LIBRARY'], 'phpmailer', 'PHPMailer.php' ]);


/**
* Function for sending an email using PHPMailer.
*
* @param array $config_values Configuration values.
* @param string $recipient_email_address Recipient's email address.
* @param string $recipient_name Recipient's name.
* @param string $subject Email subject.
* @param string $body Email body.
*
* @return array [bool, string] An array indicating success or failure and a message.
*/
function send_email($config_values, $recipient_email_address, $recipient_name, $subject, $body, $attachment=array()) {
// Create a PHPMailer instance
$mail = new PHPMailer\PHPMailer\PHPMailer(true);

try {
// Configure SMTP settings
$mail->isSMTP();
$mail->Host = $config_values['CONFIG_MAIL_SMTPADDR'];
$mail->Port = $config_values['CONFIG_MAIL_SMTPPORT'];
$mail->SMTPSecure = $config_values['CONFIG_MAIL_SMTP_SECURITY'];

// Check if the username and password are not empty before enabling authentication
if (!empty($config_values['CONFIG_MAIL_SMTP_USERNAME']) && !empty($config_values['CONFIG_MAIL_SMTP_PASSWORD'])) {
$mail->SMTPAuth = true;
$mail->Username = $config_values['CONFIG_MAIL_SMTP_USERNAME'];
$mail->Password = $config_values['CONFIG_MAIL_SMTP_PASSWORD'];
}

// Set sender and recipient
$mail->setFrom($config_values['CONFIG_MAIL_SMTPFROM'], $config_values['CONFIG_MAIL_SMTP_SENDER_NAME']);
$mail->addAddress(trim($recipient_email_address), trim($recipient_name));

// Set email content
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $body;

if (is_array($attachment) && array_key_exists('content', $attachment) && array_key_exists('filename', $attachment) ) {
$mail->addStringAttachment($attachment['content'], $attachment['filename'],
PHPMailer\PHPMailer\PHPMailer::ENCODING_BASE64, 'application/pdf', 'attachment');
}

// Send the email
$mail->send();

return [true, "Email sent successfully"];
} catch (Exception $e) {
return [false, $e->getMessage()];
}

return [false, "Cannot send the email"];
}
32 changes: 26 additions & 6 deletions app/common/includes/notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
exit;
}

include_once 'config_read.php';

// Include PHPMailer classes
include __DIR__ . '/../library/phpmailer/Exception.php';
include __DIR__ . '/../library/phpmailer/SMTP.php';
include __DIR__ . '/../library/phpmailer/PHPMailer.php';
include implode(DIRECTORY_SEPARATOR, [ $configValues['COMMON_LIBRARY'], 'phpmailer', 'Exception.php' ]);
include implode(DIRECTORY_SEPARATOR, [ $configValues['COMMON_LIBRARY'], 'phpmailer', 'SMTP.php' ]);
include implode(DIRECTORY_SEPARATOR, [ $configValues['COMMON_LIBRARY'], 'phpmailer', 'PHPMailer.php' ]);

// Include the dompdf class
require_once __DIR__ . '/../library/dompdf/dompdf_config.inc.php';

include implode(DIRECTORY_SEPARATOR, [ $configValues['COMMON_LIBRARY'], 'dompdf', 'vendor', 'autoload.php' ]);

/**
* createPDF()
Expand All @@ -58,6 +59,20 @@ function createPDF($html, $base_path) {
return $dompdf->output();
}

function create_pdf($html_content) {
// instantiate and use the dompdf class
$dompdf = new Dompdf\Dompdf();
$dompdf->loadHtml($html_content);

// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
return $dompdf->output();
}

/**
* Function for sending an email using PHPMailer.
Expand All @@ -70,7 +85,7 @@ function createPDF($html, $base_path) {
*
* @return array [bool, string] An array indicating success or failure and a message.
*/
function send_email($config_values, $recipient_email_address, $recipient_name, $subject, $body) {
function send_email($config_values, $recipient_email_address, $recipient_name, $subject, $body, $attachment=array()) {
// Create a PHPMailer instance
$mail = new PHPMailer\PHPMailer\PHPMailer(true);

Expand All @@ -97,6 +112,11 @@ function send_email($config_values, $recipient_email_address, $recipient_name, $
$mail->Subject = $subject;
$mail->Body = $body;

if (is_array($attachment) && array_key_exists('content', $attachment) && array_key_exists('filename', $attachment) ) {
$mail->addStringAttachment($attachment['content'], $attachment['filename'],
PHPMailer\PHPMailer\PHPMailer::ENCODING_BASE64, 'application/pdf', 'attachment');
}

// Send the email
$mail->send();

Expand Down
48 changes: 48 additions & 0 deletions app/common/includes/pdf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/*
*********************************************************************************************************
* daloRADIUS - RADIUS Web Platform
* Copyright (C) 2007 - Liran Tal <liran@enginx.com> All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*********************************************************************************************************
*
* Authors: Filippo Lauria <filippo.lauria@iit.cnr.it>
*
*********************************************************************************************************
*/

// prevent this file to be directly accessed
if (strpos($_SERVER['PHP_SELF'], '/common/includes/pdf.php') !== false) {
http_response_code(404);
exit;
}

include_once 'config_read.php';

// Include the dompdf class
include implode(DIRECTORY_SEPARATOR, [ $configValues['COMMON_LIBRARY'], 'dompdf', 'vendor', 'autoload.php' ]);


function create_pdf($html_content) {
// instantiate and use the dompdf class
$dompdf = new Dompdf\Dompdf();
$dompdf->loadHtml($html_content);

// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
return $dompdf->output();
}
13 changes: 0 additions & 13 deletions app/common/library/dompdf/.gitattributes

This file was deleted.

8 changes: 0 additions & 8 deletions app/common/library/dompdf/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions app/common/library/dompdf/.gitmodules

This file was deleted.

24 changes: 24 additions & 0 deletions app/common/library/dompdf/AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Dompdf was designed and developed by Benj Carson.

### Current Team

* **Brian Sweeney** (maintainer)
* **Till Berger**

### Alumni

* **Benj Carson** (creator)
* **Fabien Ménager**
* **Simon Berger**
* **Orion Richardson**

### Contributors
* **Gabriel Bull**
* **Barry vd. Heuvel**
* **Ryan H. Masten**
* **Helmut Tischer**
* [and many more...](https://github.com/dompdf/dompdf/graphs/contributors)

### Thanks

Dompdf would not have been possible without strong community support.
76 changes: 0 additions & 76 deletions app/common/library/dompdf/CONTRIBUTING.md

This file was deleted.

Loading

0 comments on commit 3d6149d

Please sign in to comment.