Move ajaxfunctions.php into ajax.php

This commit is contained in:
Ulrich Block 2016-05-07 13:04:33 +02:00
parent c4e1517434
commit ac99fafdf6
5 changed files with 114 additions and 120 deletions

View File

@ -24,7 +24,7 @@
<FilesMatch "\.php$">
Require all denied
</FilesMatch>
<FilesMatch "^(admin|ajax|api|cloud|get_password|images|index|install|jobs|lend|login|protectioncheck|reboot|serverallocation|startupdates|statuscheck|switch|update|userpanel|ajaxfunctions)\.php$">
<FilesMatch "^(admin|ajax|api|cloud|get_password|images|index|install|jobs|lend|login|protectioncheck|reboot|serverallocation|startupdates|statuscheck|switch|update|userpanel)\.php$">
Require all granted
</FilesMatch>
</IfVersion>
@ -46,7 +46,7 @@
Order deny,allow
deny from all
</FilesMatch>
<FilesMatch "^(admin|ajax|api|cloud|get_password|images|index|install|jobs|lend|login|protectioncheck|reboot|serverallocation|startupdates|statuscheck|switch|update|userpanel|ajaxfunctions)\.php$">
<FilesMatch "^(admin|ajax|api|cloud|get_password|images|index|install|jobs|lend|login|protectioncheck|reboot|serverallocation|startupdates|statuscheck|switch|update|userpanel)\.php$">
Order allow,deny
allow from all
</FilesMatch>

View File

@ -319,6 +319,11 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') {
require_once(EASYWIDIR . '/stuff/ajax/userpanel_mapgroup.php');
die;
} else if (isset($admin_id) and $pa['settings'] and $ui->w('d', 8, 'get') == 'smtptest' and $ui->id('email_settings_port', 5, 'post')) {
require_once(EASYWIDIR . '/stuff/ajax/email_smtp_test.php');
die;
}
die('No Access:' . $ui->smallletters('d', 200, 'get'));

View File

@ -1,101 +0,0 @@
<?php
/**
* File: ajaxfunctions.php
* Author: Daniel Rodriguez Baumann
* Contact: <daniel@triopsi.com>
* Author: Ulrich Block
* Contact: <ulrich.block@easy-wi.com>
*
* This file is part of Easy-WI.
*
* Easy-WI 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 3 of the License, or
* (at your option) any later version.
*
* Easy-WI 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
*
* Diese Datei ist Teil von Easy-WI.
*
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
* der GNU General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
*
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
* Siehe die GNU General Public License fuer weitere Details.
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*/
define('EASYWIDIR', dirname(__FILE__));
include(EASYWIDIR . '/stuff/methods/vorlage.php');
include(EASYWIDIR . '/stuff/methods/class_validator.php');
include(EASYWIDIR . '/stuff/methods/functions.php');
include(EASYWIDIR . '/stuff/settings.php');
include(EASYWIDIR . '/third_party/phpmailer/class.phpmailer.php');
if (!class_exists('SSH2')) {
include(EASYWIDIR . '/third_party/phpseclib/autoloader.php');
}
// No access
if ((!isset($admin_id)) or (isset($admin_id) and !$pa['settings'])) {
redirect('login.php');
}
$data = array();
//Mail Test
if ($ui->w('d', 7, 'get') == 'smttest' and $ui->id('email_settings_port', 5, 'post')) {
$errors = array();
try{
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = $ui->escaped('email_settings_host','post');
$mail->Username = $ui->escaped('email_settings_user','post');
$mail->Password = $ui->escaped('email_settings_password','post');
if ($ui->escaped('email_settings_ssl','post') == 'T') {
$mail->SMTPSecure = 'tls';
} else if ($ui->escaped('email_settings_ssl','post') == 'S') {
$mail->SMTPSecure = 'ssl';
}
$mail->Port = $ui->id('email_settings_port', 5, 'post');
$mail->setFrom('noreply@easy-wi');
if(!$mail->smtpConnect()) {
$errors[]= 'Mailer Error: Invalide Data';
} else {
$mail->smtpClose();
}
} catch (phpmailerException $e) {
$errors[] = 'Mailer Error EXP: ' . $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
$errors[] = 'Mailer Error EXP: ' . $e->getMessage(); //Boring error messages from anything else!
}
if (count($errors) == 0) {
$data = array('success' => 'OK');
} else {
$data = array('error' => $errors);
}
}
echo json_encode($data);

View File

@ -0,0 +1,90 @@
<?php
/**
* File: email_smtp_test.php.
* Author: Daniel Rodriguez Baumann
* Contact: <daniel@triopsi.com>
* Author: Ulrich Block
* Contact: <ulrich.block@easy-wi.com>
*
* This file is part of Easy-WI.
*
* Easy-WI 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 3 of the License, or
* (at your option) any later version.
*
* Easy-WI 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
*
* Diese Datei ist Teil von Easy-WI.
*
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
* der GNU General Public License, wie von der Free Software Foundation,
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
*
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
* Siehe die GNU General Public License fuer weitere Details.
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*/
if (!defined('AJAXINCLUDED')) {
die('Do not access directly!');
}
include(EASYWIDIR . '/third_party/phpmailer/class.phpmailer.php');
$data = array();
//Mail Test
$errors = array();
try {
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = $ui->escaped('email_settings_host','post');
$mail->Username = $ui->escaped('email_settings_user','post');
$mail->Password = $ui->escaped('email_settings_password','post');
if ($ui->escaped('email_settings_ssl','post') == 'T') {
$mail->SMTPSecure = 'tls';
} else if ($ui->escaped('email_settings_ssl','post') == 'S') {
$mail->SMTPSecure = 'ssl';
}
$mail->Port = $ui->id('email_settings_port', 5, 'post');
$mail->setFrom('noreply@easy-wi');
if (!$mail->smtpConnect()) {
$errors[]= 'Mailer Error: Invalid data';
} else {
$mail->smtpClose();
}
} catch (phpmailerException $e) {
$errors[] = 'Mailer Error EXP: ' . $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
$errors[] = 'Mailer Error EXP: ' . $e->getMessage(); //Boring error messages from anything else!
}
if (count($errors) == 0) {
$data = array('success' => 'OK');
} else {
$data = array('error' => $errors);
}
die(json_encode($data));

View File

@ -130,6 +130,7 @@
event.preventDefault();
event.stopPropagation();
$('.boxtest').append('<div class="overlay imagelay"><i class="fa fa-refresh fa-spin"></i></div>');
var data = new FormData();
@ -152,37 +153,36 @@
//E-Mail
data.append('inputEmail', $('#inputEmail').val());
$.ajax({
url: 'ajaxfunctions.php?d=smttest',
type: 'POST',
data: data,
$.post({
url: 'ajax.php?d=smtptest',
data: {
email_settings_host: $('#inputHost').val(),
email_settings_port: $('#inputPort').val(),
email_settings_ssl: $('#inputSSL').val(),
email_settings_user: $('#inputUser').val(),
email_settings_password: $('#inputPassword').val(),
inputEmail: $('#inputEmail').val()
},
cache: false,
dataType: 'json',
processData: false,
contentType: false,
success: function(data, textStatus, jqXHR)
{
if(typeof data.error === 'undefined')
{
success: function(data, textStatus, jqXHR) {
if (typeof data.error === 'undefined') {
$('#smtptestresult').append('<div><span style="font-size:2em;color:#00a65a;" class="fa fa-check"></span></div>');
$('.smtp').removeClass('has-error');
$('.smtp').addClass('has-success');
$('.smtpresult').append('<i class="fa fa-check"></i>');
}
else
{
} else {
$('#smtptestresult').append('<div><span style="font-size:2em;color:#d73925;" class="fa fa-times"></span></div>');
$('.smtp').addClass('has-error');
}
},
error: function(jqXHR, textStatus, errorThrown)
{
error: function(jqXHR, textStatus, errorThrown) {
$('#smtptestresult').append('<div><span style="font-size:2em;color:#d73925;" class="fa fa-times"></span></div>');
$('.smtp').addClass('has-error');
// STOP LOADING SPINNER
},
complete: function()
{
complete: function() {
$( "div" ).remove( ".imagelay" );
}
});