2022-06-27 21:08:34 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* EGroupware Setup - Account import from LDAP (incl. ADS) to SQL
|
|
|
|
*
|
2022-06-28 16:58:38 +02:00
|
|
|
* @link https://www.egroupware.org
|
2022-06-27 21:08:34 +02:00
|
|
|
* @package setup
|
2022-06-28 16:58:38 +02:00
|
|
|
* @author Ralf Becker <rb@egroupware.org>
|
|
|
|
* @license https://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
2022-06-27 21:08:34 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
use EGroupware\Api;
|
|
|
|
|
|
|
|
include('./inc/functions.inc.php');
|
|
|
|
|
|
|
|
// Authorize the user to use setup app and load the database
|
|
|
|
if (!$GLOBALS['egw_setup']->auth('Config') || $_POST['cancel'])
|
|
|
|
{
|
|
|
|
Header('Location: index.php');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
// Does not return unless user is authorized
|
|
|
|
|
|
|
|
// check CSRF token for POST requests with any content (setup uses empty POST to call its modules!)
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST)
|
|
|
|
{
|
|
|
|
Api\Csrf::validate($_POST['csrf_token'], __FILE__);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2022-07-06 17:08:44 +02:00
|
|
|
$import = new Api\Accounts\Import(static function($str, $level)
|
2022-06-27 21:08:34 +02:00
|
|
|
{
|
2022-06-28 16:58:38 +02:00
|
|
|
switch($level)
|
2022-06-27 21:08:34 +02:00
|
|
|
{
|
2022-06-28 16:58:38 +02:00
|
|
|
case 'fatal':
|
|
|
|
echo "<p style='color: red'><b>$str</b></p>\n";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'error':
|
|
|
|
case 'info':
|
|
|
|
echo "<p><b>$str</b></p>\n";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
echo "<p>$str</p>\n";
|
|
|
|
break;
|
2022-06-27 21:08:34 +02:00
|
|
|
}
|
2022-06-28 16:58:38 +02:00
|
|
|
});
|
2022-07-06 17:08:44 +02:00
|
|
|
if (!empty($_GET['log']))
|
|
|
|
{
|
|
|
|
$import->showLog();
|
|
|
|
return;
|
|
|
|
}
|
2023-04-04 19:58:53 +02:00
|
|
|
$import->logger("Manual import started via setup: initial=$_GET[initial], dry-run=$_GET[dry_run]", 'info');
|
2022-11-21 10:10:08 +01:00
|
|
|
$import->run(!empty($_GET['initial']) && $_GET['initial'] !== 'false',
|
|
|
|
!empty($_GET['dry_run'] ?? $_GET['dry-run']) && ($_GET['dry_run'] ?? $_GET['dry-run']) !== 'false');
|
2022-06-27 21:08:34 +02:00
|
|
|
}
|
|
|
|
catch (\Exception $e) {
|
|
|
|
http_response_code(500);
|
2022-06-28 16:58:38 +02:00
|
|
|
// message already output through logger above
|
2022-06-27 21:08:34 +02:00
|
|
|
}
|