From 6b7f28b4c69729371d4055e4d8ccaa2c27c09d21 Mon Sep 17 00:00:00 2001 From: katagia Date: Wed, 9 Jul 2003 16:36:39 +0000 Subject: [PATCH] improved performance --- lam/templates/masscreate.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lam/templates/masscreate.php b/lam/templates/masscreate.php index 7d857bfc..9874a8dd 100644 --- a/lam/templates/masscreate.php +++ b/lam/templates/masscreate.php @@ -223,24 +223,24 @@ switch ($select) { $lastchars = substr($_SESSION['accounts'][$i]->general_username, $j+1, strlen($_SESSION['accounts'][$i]->general_username)-$j); $_SESSION['accounts'][$i]->general_username = $firstchars . (intval($lastchars)+1); } - } while ($temp = ldapexists($_SESSION['accounts'][$i], 'user')) { - // get last character of username - $lastchar = substr($_SESSION['accounts'][$i]->general_username, strlen($_SESSION['accounts'][$i]->general_username)-1, 1); - // Last character is no number - if ( !ereg('^([0-9])+$', $lastchar)) - $_SESSION['accounts'][$i]->general_username = $_SESSION['accounts'][$i]->general_username . '2'; - else { - $j=strlen($_SESSION['accounts'][$i]->general_username)-1; - $mark = false; - while (!$mark) { - if (ereg('^([0-9])+$',substr($_SESSION['accounts'][$i]->general_username, $j, strlen($_SESSION['accounts'][$i]->general_username)-$j))) $i--; - else $mark=true; + // get last character of username + $lastchar = substr($_SESSION['accounts'][$i]->general_username, strlen($_SESSION['accounts'][$i]->general_username)-1, 1); + // Last character is no number + if ( !ereg('^([0-9])+$', $lastchar)) + $_SESSION['accounts'][$i]->general_username = $_SESSION['accounts'][$i]->general_username . '2'; + else { + $j=strlen($_SESSION['accounts'][$i]->general_username)-1; + $mark = false; + while (!$mark) { + if (ereg('^([0-9])+$',substr($_SESSION['accounts'][$i]->general_username, $j, strlen($_SESSION['accounts'][$i]->general_username)-$j))) $i--; + else $mark=true; + } + // increase last number with one + $firstchars = substr($_SESSION['accounts'][$i]->general_username, 0, $j+1); + $lastchars = substr($_SESSION['accounts'][$i]->general_username, $j+1, strlen($_SESSION['accounts'][$i]->general_username)-$j); + $_SESSION['accounts'][$i]->general_username = $firstchars . (intval($lastchars)+1); } - // increase last number with one - $firstchars = substr($_SESSION['accounts'][$i]->general_username, 0, $j+1); - $lastchars = substr($_SESSION['accounts'][$i]->general_username, $j+1, strlen($_SESSION['accounts'][$i]->general_username)-$j); - $_SESSION['accounts'][$i]->general_username = $firstchars . (intval($lastchars)+1); } } }