Made masscreate max_execution_time safe
This commit is contained in:
parent
e958631c51
commit
da6603ca7e
|
@ -33,12 +33,14 @@ include_once('../lib/pdf.inc'); // Return a pdf-file
|
||||||
session_save_path('../sess');
|
session_save_path('../sess');
|
||||||
@session_start();
|
@session_start();
|
||||||
|
|
||||||
|
$time=time();
|
||||||
if ($_POST['tolist'] && ($_FILES['userfile']['size']>0)) $select = 'list';
|
if ($_POST['tolist'] && ($_FILES['userfile']['size']>0)) $select = 'list';
|
||||||
if ($_POST['back']) $select = 'main';
|
if ($_POST['back']) $select = 'main';
|
||||||
if ($_POST['cancel']) $select = 'cancel';
|
if ($_POST['cancel']) $select = 'cancel';
|
||||||
if ($_POST['create']) $select = 'create';
|
if ($_POST['create']) $select = 'create';
|
||||||
if ($_POST['pdf']) createpdf($_SESSION['accounts']);
|
if ($_POST['pdf']) createpdf($_SESSION['accounts']);
|
||||||
if (!$select) $select='main';
|
if (!$select && !$_SESSION['pointer']) $select='main';
|
||||||
|
if (!$select && $_SESSION['pointer']) $select='create';
|
||||||
|
|
||||||
|
|
||||||
// Write HTML-Header and part of Table
|
// Write HTML-Header and part of Table
|
||||||
|
@ -55,8 +57,15 @@ echo '</title>
|
||||||
switch ($select) {
|
switch ($select) {
|
||||||
case 'cancel':
|
case 'cancel':
|
||||||
if ( session_is_registered("accounts")) session_unregister("accounts");
|
if ( session_is_registered("accounts")) session_unregister("accounts");
|
||||||
|
if ( session_is_registered("pointer")) session_unregister("pointer");
|
||||||
echo '<meta http-equiv="refresh" content="0; URL=lists/listusers.php">';
|
echo '<meta http-equiv="refresh" content="0; URL=lists/listusers.php">';
|
||||||
break;
|
break;
|
||||||
|
case 'create':
|
||||||
|
if ($_SESSION['pointer'] < sizeof($_SESSION['accounts'])) {
|
||||||
|
$refresh = get_cfg_var('max_execution_time')-5;
|
||||||
|
echo '<meta http-equiv="refresh" content="'.$refresh.'; URL=masscreate.php">';
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</head><body>
|
echo '</head><body>
|
||||||
|
@ -67,7 +76,10 @@ echo '</head><body>
|
||||||
switch ($select) {
|
switch ($select) {
|
||||||
case 'main':
|
case 'main':
|
||||||
if ( session_is_registered("accounts")) session_unregister("accounts");
|
if ( session_is_registered("accounts")) session_unregister("accounts");
|
||||||
|
if ( session_is_registered("pointer")) session_unregister("pointer");
|
||||||
session_register("accounts");
|
session_register("accounts");
|
||||||
|
session_register("pointer");
|
||||||
|
$_SESSION['pointer']=0;
|
||||||
$profilelist = getUserProfiles();
|
$profilelist = getUserProfiles();
|
||||||
echo '<tr><td><input name="select" type="hidden" value="main">';
|
echo '<tr><td><input name="select" type="hidden" value="main">';
|
||||||
echo _('Mass Creation');
|
echo _('Mass Creation');
|
||||||
|
@ -182,31 +194,35 @@ switch ($select) {
|
||||||
echo '</td><td><input name="create" type="submit" value="'; echo _('Create'); echo '">';
|
echo '</td><td><input name="create" type="submit" value="'; echo _('Create'); echo '">';
|
||||||
break;
|
break;
|
||||||
case 'create':
|
case 'create':
|
||||||
$row=0;
|
|
||||||
$stay=true;
|
$stay=true;
|
||||||
while (($row < sizeof($_SESSION['accounts'])) && $stay) {
|
while (($_SESSION['pointer'] < sizeof($_SESSION['accounts'])) && $stay) {
|
||||||
if (getgid($_SESSION['accounts'][$row]->general_group)==-1) {
|
if (getgid($_SESSION['accounts'][$_SESSION['pointer']]->general_group)==-1) {
|
||||||
$group = new account();
|
$group = new account();
|
||||||
$group->general_username=$_SESSION['accounts'][$row]->general_group;
|
$group->general_username=$_SESSION['accounts'][$_SESSION['pointer']]->general_group;
|
||||||
$group->general_uidNumber=checkid($_SESSION['accounts'][$row], 'group');
|
$group->general_uidNumber=checkid($_SESSION['accounts'][$_SESSION['pointer']], 'group');
|
||||||
$group->general_gecos=$_SESSION['accounts'][$row]->general_group;
|
$group->general_gecos=$_SESSION['accounts'][$_SESSION['pointer']]->general_group;
|
||||||
creategroup($group);
|
creategroup($group);
|
||||||
}
|
}
|
||||||
$_SESSION['accounts'][$row]->general_uidNumber = checkid($_SESSION['accounts'][$row], 'user');
|
$_SESSION['accounts'][$_SESSION['pointer']]->general_uidNumber = checkid($_SESSION['accounts'][$_SESSION['pointer']], 'user');
|
||||||
$error = createuser($_SESSION['accounts'][$row]);
|
if ( time()-$time<(get_cfg_var('max_execution_time')-10)) {
|
||||||
if ($error==1) $row++;
|
$error = createuser($_SESSION['accounts'][$_SESSION['pointer']]);
|
||||||
|
if ($error==1) $_SESSION['pointer']++;
|
||||||
else {
|
else {
|
||||||
$stay = false;
|
$stay = false;
|
||||||
StatusMessage('ERROR', _('Could not create user'), _('Was unable to create ').$_SESSION['accounts'][$row]->general_username);
|
StatusMessage('ERROR', _('Could not create user'), _('Was unable to create ').$_SESSION['accounts'][$row]->general_username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$stay) { echo '<tr><td><input name="cancel" type="submit" value="'; echo _('Cancel'); echo '">'; }
|
else $stay=false;
|
||||||
|
}
|
||||||
|
if (!$stay) { echo '<tr><td><input name="cancel" type="submit" value="'; echo _('Cancel'); echo '">
|
||||||
|
<td>'._('Please wait until all users are created if no error is shown.').'</td></tr>'; }
|
||||||
else {
|
else {
|
||||||
echo '<tr><td>';
|
echo '<tr><td>';
|
||||||
echo _('All Users have been created');
|
echo _('All Users have been created');
|
||||||
echo '</td></tr><tr><td>';
|
echo '</td></tr><tr><td>';
|
||||||
echo '<tr><td><input name="cancel" type="submit" value="'; echo _('Mainmenu'); echo '">';
|
echo '<tr><td><input name="cancel" type="submit" value="'; echo _('Mainmenu'); echo '">';
|
||||||
echo '</td><td></td><td><input name="pdf" type="submit" value="'; echo _('Create PDF-File'); echo '">';
|
echo '</td><td></td><td><input name="pdf" type="submit" value="'; echo _('Create PDF-File'); echo '">';
|
||||||
|
echo '</td></tr>';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue