upload process is now complete
This commit is contained in:
parent
66fa43498a
commit
9d9870f366
|
@ -7,19 +7,11 @@ Alle:
|
||||||
- lampath: String mit Pfad zum LAM-Verzeichnis
|
- lampath: String mit Pfad zum LAM-Verzeichnis
|
||||||
|
|
||||||
|
|
||||||
massdetail:
|
|
||||||
- accounts: Array aus account-Objekten
|
|
||||||
- errors: Array aus Fehlermeldungen. Index ist gleich Index von accounts
|
|
||||||
|
|
||||||
|
|
||||||
masscreate:
|
masscreate:
|
||||||
- accounts: Array aus account-Objekten
|
- mass_accounts: verschlüsseltes, serialisiertes Array mit Accounts
|
||||||
- pointer: Zeigt auf den aktuellen Startpunkt, ab dem Benutzer angelegt werden sollen.
|
- mass_dn: DN der Accounts
|
||||||
Noetig, da mit Meta-Refreshs gearbeitet werden muss
|
- mass_counter: aktuelle Position im Account-Array
|
||||||
- errors: Array aus Fehlermeldungen. Index ist gleich Index von accounts
|
- mass_errors: Fehlermeldungen beim Upload
|
||||||
- group_suffix: Suffix, unter welchem eine Gruppe bei Bedarf angelegt wird
|
|
||||||
- group_selectprofile: Profil, mit dem eine Gruppe bei Bedarf angelegt werden soll
|
|
||||||
- rowstart: ??? nicht mehr benutzt
|
|
||||||
|
|
||||||
|
|
||||||
main:
|
main:
|
||||||
|
|
|
@ -145,11 +145,8 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
|
||||||
$accounts[$i]['dn'] = $account_dn;
|
$accounts[$i]['dn'] = $account_dn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// accounts were built, now add them to LDAP
|
|
||||||
// TODO add to LDAP
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print_r($accounts);
|
|
||||||
// if input data is invalid just display error messages (max 50)
|
// if input data is invalid just display error messages (max 50)
|
||||||
if (sizeof($errors) > 0) {
|
if (sizeof($errors) > 0) {
|
||||||
for ($i = 0; (($i < sizeof($errors)) || ($i > 49)); $i++) StatusMessage("ERROR", $errors[$i][0], $errors[$i][1]);
|
for ($i = 0; (($i < sizeof($errors)) || ($i > 49)); $i++) StatusMessage("ERROR", $errors[$i][0], $errors[$i][1]);
|
||||||
|
@ -157,6 +154,8 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
|
||||||
else {
|
else {
|
||||||
// store accounts in session
|
// store accounts in session
|
||||||
$_SESSION['mass_accounts'] = $_SESSION['ldap']->encrypt(serialize($accounts));
|
$_SESSION['mass_accounts'] = $_SESSION['ldap']->encrypt(serialize($accounts));
|
||||||
|
$_SESSION['mass_counter'] = 0;
|
||||||
|
$_SESSION['mass_errors'] = array();
|
||||||
// show links for upload and LDIF export
|
// show links for upload and LDIF export
|
||||||
echo "<h1 align=\"center\">" . _("LAM has checked your input and is now ready to create the accounts.") . "</h1>\n";
|
echo "<h1 align=\"center\">" . _("LAM has checked your input and is now ready to create the accounts.") . "</h1>\n";
|
||||||
echo "<p> </p>\n";
|
echo "<p> </p>\n";
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
|
||||||
|
Copyright (C) 2004 Roland Gruber
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates LDAP accounts for file upload.
|
||||||
|
*
|
||||||
|
* @author Roland Gruber
|
||||||
|
* @package tools
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** access to configuration */
|
||||||
|
include_once('../lib/config.inc');
|
||||||
|
/** LDAP handle */
|
||||||
|
include_once('../lib/ldap.inc');
|
||||||
|
/** status messages */
|
||||||
|
include_once('../lib/status.inc');
|
||||||
|
/** account modules */
|
||||||
|
include_once('../lib/modules.inc');
|
||||||
|
|
||||||
|
|
||||||
|
// Start session
|
||||||
|
session_save_path('../sess');
|
||||||
|
@session_start();
|
||||||
|
|
||||||
|
// Redirect to startpage if user is not loged in
|
||||||
|
if (!isset($_SESSION['loggedIn'])) {
|
||||||
|
metaRefresh("login.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set correct language, codepages, ....
|
||||||
|
setlanguage();
|
||||||
|
|
||||||
|
echo $_SESSION['header'];
|
||||||
|
echo "<title>account upload</title>\n";
|
||||||
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\">\n";
|
||||||
|
|
||||||
|
// create accounts
|
||||||
|
$accounts = unserialize($_SESSION['ldap']->decrypt($_SESSION['mass_accounts']));
|
||||||
|
if ($_SESSION['mass_counter'] < sizeof($accounts)) {
|
||||||
|
$maxTime = get_cfg_var('max_execution_time') - 5;
|
||||||
|
$refreshTime = get_cfg_var('max_execution_time') + 1;
|
||||||
|
$startTime = time();
|
||||||
|
echo "<meta http-equiv=\"refresh\" content=\"2; URL=massDoUpload.php\">\n";
|
||||||
|
echo "</head>\n<body>\n";
|
||||||
|
echo "<h1>" . _("LDAP upload in progress. Please wait.") . "</h1>\n";
|
||||||
|
echo "<table align=\"center\" width=\"80%\" style=\"border-color: grey\" border=\"2\" cellspacing=\"0\" rules=\"none\">\n";
|
||||||
|
echo "<tr><td bgcolor=\"blue\" width=\"" . ($_SESSION['mass_counter'] * 100) / sizeof($accounts) . "%\"> </td>";
|
||||||
|
echo "<td bgcolor=\"grey\" width=\"" . (100 - (($_SESSION['mass_counter'] * 100) / sizeof($accounts))) . "%\"> </td></tr>\n";
|
||||||
|
echo "</table>";
|
||||||
|
flush(); // send HTML to browser
|
||||||
|
while (($_SESSION['mass_counter'] < sizeof($accounts)) && ($startTime + $maxTime > time())) {
|
||||||
|
// create accounts as long as max_execution_time is not near
|
||||||
|
$attrs = $accounts[$_SESSION['mass_counter']];
|
||||||
|
$dn = $attrs['dn'];
|
||||||
|
unset($attrs['dn']);
|
||||||
|
$success = @ldap_add($_SESSION['ldap']->server, $dn, $attrs);
|
||||||
|
if (!$success) {
|
||||||
|
$errorMessage = array(
|
||||||
|
"ERROR",
|
||||||
|
_("LAM was unable to create account %s! An LDAP error occured."),
|
||||||
|
ldap_errno($_SESSION[ldap]->server) . ": " . ldap_error($_SESSION[ldap]->server),
|
||||||
|
array($_SESSION['mass_counter']));
|
||||||
|
$_SESSION['mass_errors'][] = $errorMessage;
|
||||||
|
}
|
||||||
|
$_SESSION['mass_counter']++;
|
||||||
|
}
|
||||||
|
echo "</body></html>";
|
||||||
|
}
|
||||||
|
// all accounts have been created
|
||||||
|
else {
|
||||||
|
echo "</head>\n<body>\n";
|
||||||
|
echo "<h1>" . _("LDAP upload has finished") . "</h1>\n";
|
||||||
|
if (sizeof($_SESSION['mass_errors']) > 0) {
|
||||||
|
echo "<h2>" . _("There were errors while uploading:") . "</h2>\n";
|
||||||
|
for ($i = 0; $i < sizeof($_SESSION['mass_errors']); $i++) {
|
||||||
|
call_user_func_array('StatusMessage', $_SESSION['mass_errors'][$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</body></html>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue