2010-01-20 16:55:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2010-01-25 10:06:34 +00:00
|
|
|
* This file is part of the Froxlor project.
|
|
|
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
2010-01-20 16:55:27 +00:00
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* 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.
|
2010-01-20 16:55:27 +00:00
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* 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 General Public License for more details.
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2022-04-28 18:48:00 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you can also view it online at
|
|
|
|
* https://files.froxlor.org/misc/COPYING.txt
|
|
|
|
*
|
|
|
|
* @copyright the authors
|
|
|
|
* @author Froxlor team <team@froxlor.org>
|
|
|
|
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
2010-01-20 16:55:27 +00:00
|
|
|
*/
|
2022-04-28 18:48:00 +00:00
|
|
|
|
2022-02-20 17:00:44 +00:00
|
|
|
const AREA = 'customer';
|
|
|
|
require __DIR__ . '/lib/init.php';
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2023-06-07 09:37:00 +00:00
|
|
|
use Froxlor\Api\Commands\DataDump as DataDump;
|
2018-12-18 12:45:05 +00:00
|
|
|
use Froxlor\Api\Commands\DirOptions as DirOptions;
|
|
|
|
use Froxlor\Api\Commands\DirProtections as DirProtections;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\Customer\Customer;
|
|
|
|
use Froxlor\FileDir;
|
|
|
|
use Froxlor\FroxlorLogger;
|
|
|
|
use Froxlor\PhpHelper;
|
2022-02-20 17:00:44 +00:00
|
|
|
use Froxlor\Settings;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\UI\Collection;
|
|
|
|
use Froxlor\UI\HTML;
|
|
|
|
use Froxlor\UI\Listing;
|
2022-02-21 16:42:04 +00:00
|
|
|
use Froxlor\UI\Panel\UI;
|
2022-02-20 17:00:44 +00:00
|
|
|
use Froxlor\UI\Request;
|
2022-04-28 18:48:00 +00:00
|
|
|
use Froxlor\UI\Response;
|
2018-12-18 12:45:05 +00:00
|
|
|
|
2016-07-27 11:45:54 +00:00
|
|
|
// redirect if this customer page is hidden via settings
|
2018-12-20 11:38:18 +00:00
|
|
|
if (Settings::IsInList('panel.customer_hide_options', 'extras')) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo('customer_index.php');
|
2016-07-27 11:45:54 +00:00
|
|
|
}
|
|
|
|
|
2022-12-30 20:43:27 +00:00
|
|
|
$id = (int)Request::any('id');
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2022-02-25 19:13:13 +00:00
|
|
|
if ($page == 'overview' || $page == 'htpasswds') {
|
2016-07-27 11:45:54 +00:00
|
|
|
// redirect if this customer sub-page is hidden via settings
|
2018-12-20 11:38:18 +00:00
|
|
|
if (Settings::IsInList('panel.customer_hide_options', 'extras.directoryprotection')) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo('customer_index.php');
|
2016-07-27 11:45:54 +00:00
|
|
|
}
|
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if ($action == '') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htpasswds");
|
|
|
|
$fields = [
|
|
|
|
'username' => lng('login.username'),
|
|
|
|
'path' => lng('panel.path')
|
|
|
|
];
|
2019-11-10 17:35:32 +00:00
|
|
|
try {
|
2022-02-25 16:17:29 +00:00
|
|
|
$htpasswd_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.htpasswd.php';
|
2022-04-28 18:48:00 +00:00
|
|
|
$collection = (new Collection(DirProtections::class, $userinfo))
|
2022-09-30 07:44:11 +00:00
|
|
|
->withPagination($htpasswd_list_data['htpasswd_list']['columns'], $htpasswd_list_data['htpasswd_list']['default_sorting']);
|
2019-11-10 17:35:32 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2019-11-10 17:35:32 +00:00
|
|
|
}
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2023-09-24 14:04:20 +00:00
|
|
|
$actions_links = [];
|
|
|
|
$actions_links[] = [
|
|
|
|
'href' => $linker->getLink(['section' => 'extras', 'page' => 'htpasswds', 'action' => 'add']),
|
|
|
|
'label' => lng('extras.directoryprotection_add')
|
|
|
|
];
|
|
|
|
|
|
|
|
$actions_links[] = [
|
2024-05-12 11:51:03 +00:00
|
|
|
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/extras/',
|
2023-09-24 14:04:20 +00:00
|
|
|
'target' => '_blank',
|
|
|
|
'icon' => 'fa-solid fa-circle-info',
|
|
|
|
'class' => 'btn-outline-secondary'
|
|
|
|
];
|
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/table.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'listing' => Listing::format($collection, $htpasswd_list_data, 'htpasswd_list'),
|
2023-09-24 14:04:20 +00:00
|
|
|
'actions_links' => $actions_links,
|
2022-04-28 18:48:00 +00:00
|
|
|
'entity_info' => lng('extras.description')
|
2022-02-25 16:17:29 +00:00
|
|
|
]);
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
2018-03-12 21:07:51 +00:00
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$json_result = DirProtections::getLocal($userinfo, [
|
2018-03-12 21:07:51 +00:00
|
|
|
'id' => $id
|
2022-04-28 18:48:00 +00:00
|
|
|
])->get();
|
2018-03-12 21:07:51 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-03-12 21:07:51 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-11-03 20:48:57 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if (isset($result['username']) && $result['username'] != '') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2018-03-12 21:07:51 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
DirProtections::getLocal($userinfo, Request::postAll())->delete();
|
2018-03-12 21:07:51 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-03-12 21:07:51 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2013-11-03 20:48:57 +00:00
|
|
|
} else {
|
2018-12-22 07:15:31 +00:00
|
|
|
if (strpos($result['path'], $userinfo['documentroot']) === 0) {
|
|
|
|
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
HTML::askYesNo('extras_reallydelete', $filename, [
|
2016-04-28 07:20:35 +00:00
|
|
|
'id' => $id,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
2022-04-28 18:48:00 +00:00
|
|
|
], $result['username'] . ' (' . $result['path'] . ')');
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($action == 'add') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2018-03-15 10:01:17 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
DirProtections::getLocal($userinfo, Request::postAll())->add();
|
2018-03-15 10:01:17 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2013-11-03 20:48:57 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
|
2011-02-12 15:47:07 +00:00
|
|
|
|
2016-04-28 07:20:35 +00:00
|
|
|
$htpasswd_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_add.php';
|
2011-02-12 15:47:07 +00:00
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/form.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'extras']),
|
2022-02-21 16:42:04 +00:00
|
|
|
'formdata' => $htpasswd_add_data['htpasswd_add']
|
|
|
|
]);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($action == 'edit' && $id != 0) {
|
2018-03-15 10:01:17 +00:00
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$json_result = DirProtections::getLocal($userinfo, [
|
2018-03-15 10:01:17 +00:00
|
|
|
'id' => $id
|
2022-04-28 18:48:00 +00:00
|
|
|
])->get();
|
2018-03-15 10:01:17 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-03-15 10:01:17 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-11-03 20:48:57 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if (isset($result['username']) && $result['username'] != '') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2018-03-15 10:01:17 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
DirProtections::getLocal($userinfo, Request::postAll())->update();
|
2018-03-15 10:01:17 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2013-11-03 20:48:57 +00:00
|
|
|
} else {
|
2018-12-22 07:15:31 +00:00
|
|
|
if (strpos($result['path'], $userinfo['documentroot']) === 0) {
|
|
|
|
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
$result = PhpHelper::htmlentitiesArray($result);
|
2011-02-12 15:47:07 +00:00
|
|
|
|
2016-04-28 07:20:35 +00:00
|
|
|
$htpasswd_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htpasswd_edit.php';
|
2011-02-12 15:47:07 +00:00
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/form.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'extras', 'id' => $id]),
|
2022-02-28 09:51:19 +00:00
|
|
|
'formdata' => $htpasswd_edit_data['htpasswd_edit'],
|
|
|
|
'editid' => $id
|
2022-02-21 16:42:04 +00:00
|
|
|
]);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($page == 'htaccess') {
|
2016-07-27 11:45:54 +00:00
|
|
|
// redirect if this customer sub-page is hidden via settings
|
2018-12-20 11:38:18 +00:00
|
|
|
if (Settings::IsInList('panel.customer_hide_options', 'extras.pathoptions')) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo('customer_index.php');
|
2016-07-27 11:45:54 +00:00
|
|
|
}
|
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if ($action == '') {
|
2022-04-28 18:48:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htaccess");
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
$cperlenabled = Customer::customerHasPerlEnabled($userinfo['customerid']);
|
2010-07-22 06:02:38 +00:00
|
|
|
|
2022-02-25 16:17:29 +00:00
|
|
|
try {
|
|
|
|
$htaccess_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.htaccess.php';
|
2022-04-28 18:48:00 +00:00
|
|
|
$collection = (new Collection(DirOptions::class, $userinfo))
|
2022-09-30 07:44:11 +00:00
|
|
|
->withPagination($htaccess_list_data['htaccess_list']['columns'], $htaccess_list_data['htaccess_list']['default_sorting']);
|
2022-02-25 16:17:29 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
2023-09-24 14:04:20 +00:00
|
|
|
$actions_links = [];
|
|
|
|
$actions_links[] = [
|
|
|
|
'href' => $linker->getLink(['section' => 'extras', 'page' => 'htaccess', 'action' => 'add']),
|
|
|
|
'label' => lng('extras.pathoptions_add')
|
|
|
|
];
|
|
|
|
|
|
|
|
$actions_links[] = [
|
2024-05-12 11:51:03 +00:00
|
|
|
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/extras/',
|
2023-09-24 14:04:20 +00:00
|
|
|
'target' => '_blank',
|
|
|
|
'icon' => 'fa-solid fa-circle-info',
|
|
|
|
'class' => 'btn-outline-secondary'
|
|
|
|
];
|
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/table.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'listing' => Listing::format($collection, $htaccess_list_data, 'htaccess_list'),
|
2023-09-24 14:04:20 +00:00
|
|
|
'actions_links' => $actions_links,
|
2022-04-28 18:48:00 +00:00
|
|
|
'entity_info' => lng('extras.description')
|
2022-02-25 16:17:29 +00:00
|
|
|
]);
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
2018-03-15 18:35:56 +00:00
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$json_result = DirOptions::getLocal($userinfo, [
|
2018-03-15 18:35:56 +00:00
|
|
|
'id' => $id
|
2022-04-28 18:48:00 +00:00
|
|
|
])->get();
|
2018-03-15 18:35:56 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-03-15 18:35:56 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-11-03 20:48:57 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
if (isset($result['customerid']) && $result['customerid'] != '' && $result['customerid'] == $userinfo['customerid']) {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2018-03-15 18:35:56 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
DirOptions::getLocal($userinfo, Request::postAll())->delete();
|
2018-03-15 18:35:56 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2015-11-29 17:21:30 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2013-11-03 20:48:57 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
HTML::askYesNo('extras_reallydelete_pathoptions', $filename, [
|
2016-04-28 07:20:35 +00:00
|
|
|
'id' => $id,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
2022-04-28 18:48:00 +00:00
|
|
|
], str_replace($userinfo['documentroot'], '/', $result['path']));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($action == 'add') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2018-03-15 18:35:56 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
DirOptions::getLocal($userinfo, Request::postAll())->add();
|
2018-03-15 18:35:56 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2013-11-03 20:48:57 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
|
|
|
|
$cperlenabled = Customer::customerHasPerlEnabled($userinfo['customerid']);
|
2011-02-12 15:42:25 +00:00
|
|
|
|
2016-04-28 07:20:35 +00:00
|
|
|
$htaccess_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_add.php';
|
2011-02-12 15:42:25 +00:00
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/form.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'extras']),
|
2022-02-21 16:42:04 +00:00
|
|
|
'formdata' => $htaccess_add_data['htaccess_add']
|
|
|
|
]);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif (($action == 'edit') && ($id != 0)) {
|
2018-03-15 18:35:56 +00:00
|
|
|
try {
|
2022-04-28 18:48:00 +00:00
|
|
|
$json_result = DirOptions::getLocal($userinfo, [
|
2018-03-15 18:35:56 +00:00
|
|
|
'id' => $id
|
2022-04-28 18:48:00 +00:00
|
|
|
])->get();
|
2018-03-15 18:35:56 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-03-15 18:35:56 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-11-03 20:48:57 +00:00
|
|
|
|
2018-12-22 07:15:31 +00:00
|
|
|
if ((isset($result['customerid'])) && ($result['customerid'] != '') && ($result['customerid'] == $userinfo['customerid'])) {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2018-03-15 18:35:56 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
DirOptions::getLocal($userinfo, Request::postAll())->update();
|
2018-03-15 18:35:56 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo($filename, [
|
2022-03-14 21:51:59 +00:00
|
|
|
'page' => $page
|
2022-04-28 18:48:00 +00:00
|
|
|
]);
|
2013-11-03 20:48:57 +00:00
|
|
|
} else {
|
2018-12-22 07:15:31 +00:00
|
|
|
if (strpos($result['path'], $userinfo['documentroot']) === 0) {
|
|
|
|
$result['path'] = str_replace($userinfo['documentroot'], "/", $result['path']);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2022-04-28 18:48:00 +00:00
|
|
|
$cperlenabled = Customer::customerHasPerlEnabled($userinfo['customerid']);
|
2022-02-21 16:42:04 +00:00
|
|
|
|
2022-04-28 18:48:00 +00:00
|
|
|
$result = PhpHelper::htmlentitiesArray($result);
|
2011-02-12 15:42:25 +00:00
|
|
|
|
2016-04-28 07:20:35 +00:00
|
|
|
$htaccess_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.htaccess_edit.php';
|
2011-02-12 15:42:25 +00:00
|
|
|
|
2022-03-18 11:53:34 +00:00
|
|
|
UI::view('user/form.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'extras', 'id' => $id]),
|
2022-02-28 09:51:19 +00:00
|
|
|
'formdata' => $htaccess_edit_data['htaccess_edit'],
|
|
|
|
'editid' => $id
|
2022-02-21 16:42:04 +00:00
|
|
|
]);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-06-07 09:37:00 +00:00
|
|
|
} elseif ($page == 'export') {
|
2016-07-27 11:45:54 +00:00
|
|
|
// redirect if this customer sub-page is hidden via settings
|
2023-06-07 09:37:00 +00:00
|
|
|
if (Settings::IsInList('panel.customer_hide_options', 'extras.export')) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::redirectTo('customer_index.php');
|
2016-07-27 11:45:54 +00:00
|
|
|
}
|
|
|
|
|
2023-06-07 09:37:00 +00:00
|
|
|
if (Settings::Get('system.exportenabled') == 1) {
|
2022-05-13 09:22:14 +00:00
|
|
|
if ($action == 'abort') {
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2023-06-07 09:37:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "customer_extras::export - aborted scheduled data export job");
|
2022-05-13 09:22:14 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
DataDump::getLocal($userinfo, Request::postAll())->delete();
|
2022-05-13 09:22:14 +00:00
|
|
|
} catch (Exception $e) {
|
|
|
|
Response::dynamicError($e->getMessage());
|
|
|
|
}
|
|
|
|
Response::redirectTo($filename, [
|
|
|
|
'page' => $page,
|
|
|
|
'action' => ''
|
|
|
|
]);
|
|
|
|
} else {
|
2023-06-07 09:37:00 +00:00
|
|
|
HTML::askYesNo('extras_reallydelete_export', $filename, [
|
|
|
|
'job_entry' => $id,
|
2022-05-13 09:22:14 +00:00
|
|
|
'section' => 'extras',
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
|
|
|
]);
|
2016-05-22 09:08:44 +00:00
|
|
|
}
|
2022-05-13 09:22:14 +00:00
|
|
|
} elseif ($action == '') {
|
2023-06-07 09:37:00 +00:00
|
|
|
$log->logAction(FroxlorLogger::USR_ACTION, LOG_INFO, "viewed customer_extras::export");
|
2016-04-28 07:20:35 +00:00
|
|
|
|
2016-05-05 06:23:46 +00:00
|
|
|
// check whether there is a backup-job for this customer
|
2018-03-19 09:45:12 +00:00
|
|
|
try {
|
2023-06-07 09:37:00 +00:00
|
|
|
$export_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.export.php';
|
|
|
|
$collection = (new Collection(DataDump::class, $userinfo));
|
2018-03-19 09:45:12 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2018-03-19 09:45:12 +00:00
|
|
|
}
|
2016-05-05 06:23:46 +00:00
|
|
|
|
2024-05-09 13:48:23 +00:00
|
|
|
if (Request::post('send') == 'send') {
|
2018-03-19 09:45:12 +00:00
|
|
|
try {
|
2024-05-09 13:48:23 +00:00
|
|
|
DataDump::getLocal($userinfo, Request::postAll())->add();
|
2018-03-19 09:45:12 +00:00
|
|
|
} catch (Exception $e) {
|
2022-04-28 18:48:00 +00:00
|
|
|
Response::dynamicError($e->getMessage());
|
2016-04-28 13:27:59 +00:00
|
|
|
}
|
2023-06-07 09:37:00 +00:00
|
|
|
Response::standardSuccess('exportscheduled');
|
2016-04-28 13:27:59 +00:00
|
|
|
} else {
|
2022-04-28 18:48:00 +00:00
|
|
|
$pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
|
2023-06-07 09:37:00 +00:00
|
|
|
$export_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.export.php';
|
2022-02-25 16:17:29 +00:00
|
|
|
|
2023-09-24 14:04:20 +00:00
|
|
|
$actions_links = [
|
|
|
|
[
|
2024-05-12 11:51:03 +00:00
|
|
|
'href' => \Froxlor\Froxlor::getDocsUrl() . 'user-guide/extras/',
|
2023-09-24 14:04:20 +00:00
|
|
|
'target' => '_blank',
|
|
|
|
'icon' => 'fa-solid fa-circle-info',
|
|
|
|
'class' => 'btn-outline-secondary'
|
|
|
|
]
|
|
|
|
];
|
|
|
|
|
2022-03-27 11:19:26 +00:00
|
|
|
UI::view('user/form-datatable.html.twig', [
|
2022-04-28 18:48:00 +00:00
|
|
|
'formaction' => $linker->getLink(['section' => 'extras']),
|
2023-06-07 09:37:00 +00:00
|
|
|
'formdata' => $export_data['export'],
|
2023-09-24 14:04:20 +00:00
|
|
|
'actions_links' => $actions_links,
|
2023-06-07 09:37:00 +00:00
|
|
|
'tabledata' => Listing::format($collection, $export_list_data, 'export_list'),
|
2022-02-25 16:17:29 +00:00
|
|
|
]);
|
2016-04-28 07:20:35 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-20 11:38:18 +00:00
|
|
|
} else {
|
2023-06-07 09:37:00 +00:00
|
|
|
Response::standardError('exportfunctionnotenabled');
|
2016-04-28 13:27:59 +00:00
|
|
|
}
|
|
|
|
}
|