@import 'default.css'; "; echo ""; ?>

$value) $templates[] = $key ; $status = ""; if ($_POST["action"] == "upload") { // obtenemos los datos del archivo $tamano = $_FILES["archivo"]['size']; $tipo = $_FILES["archivo"]['type']; $archivo = $_FILES["archivo"]['name']; //$prefijo = substr(md5(uniqid(rand())),0,6); if ($archivo != "") { //guardamos el archivo a la carpeta files $maxcount=0; if ($file = file($_FILES["archivo"]["tmp_name"])) { $status = _("File uploaded").": ".$archivo.""; for ($i=0;$i0) //No tratamos lineas en blanco { $line=split (";", $file[$i]); if (count($line)!=count($fields)) //Debe haber 6 campos { print("

"._("Unknown file format")."

"); exit ; } //cargamos los campos $count=0; foreach ($line as $value) { $campo=$fields[$count]; $cells[$i][$campo] =utf8_encode(trim($value)); $count++; } } } } else { $status =_("An error has occurred while uploading the file"); print $status; exit; } }else { $status =_("An error has occurred while uploading the file"); print $status; exit; } echo ""; $users=0; $usersfail=0; $excludes = array() ; //Validamos Campos foreach ($cells as $key => $value) { $error=0; foreach ($fields as $field) { //muestra($key." => ".$value[$field]) ; switch ($field) { case "Template": if (!in_array ($value[$field], $templates)) { //print(" *** No existe la plantilla: ".$value[$field]."
"); $error=1; } break; case "fullName": if ($value[$field] == "") { //muestra(" *** El usuario de tener Nombre y Apellidos"."
"); $error=2; }else { if (!existFullname($ldap,$value[$field],$value["Template"])) $value[$field]=$value[$field]; else $error=4; } break; case "userName": if ($value[$field] == "") $value[$field] = get_username ($ldap, $value["fullName"], $excludes) ; else { if(chk_username ($ldap, $value[$field], $excludes)) $value[$field] = chk_username ($ldap, $value[$field], $excludes); else $value[$field] = get_username ($ldap, $value["fullName"], $excludes) ; } break; case "password": if ($value[$field] == "") $value[$field] = pwgen () ; break; case "groups": $grupos=array(); if ($value[$field] != "") { $grupos= explode (" ", $value[$field]); } break; case "profile": if (!in_array ($value[$field], $sabayones)) { //muestra(" *** No existe el perfil: ".$value[$field]."
"); $error=3; } break; } } if ($error==0 && @ldapAddUser ($ldap, $value["fullName"], $value["Template"],$value["userName"], $value["password"],$grupos,$value["profile"],$value["name"],$value["surName"])) { //muestra($value["Template"].";".$value["fullName"].";".$value["userName"].";".$value["password"].";".$value["groups"].";".$value["profile"]); print ""; print("".""."".""."".""); print ""; $users++; } else { switch ($error) { case 1: $mensaje=_("The template doesn't exists"); break; case 2: $mensaje=_("The user must have name and surname"); break; case 3: $mensaje=_("The profile doesn't exists"); break; case 4: $mensaje=_("The user already exists"); break; default: $mensaje=_("Error LDAP"); } //muestra("ERROR: ".$error); $nousers=$nousers.""."".""."".""; $usersfail++; } } print ""; print "
"._("Imported Users")."
"._("Template")." "._("Full Name")." "._("User Name")." "._("Password")." "._("Groups")." "._("Profile")."
".$value["Template"]."".$value["fullName"]."".$value["userName"]."".$value["password"]."".$value["groups"]."".$value["profile"]."
".$value["Template"]."".$value["fullName"]."".$value["groups"]."".$value["profile"]."".$mensaje."
Total {$users} "._("users")."
"; //Tabla erroneos if ($usersfail>0) { echo ""; echo $nousers; print ""; print "
Not Imported Users
"._("Template")." "._("Full Name")." "._("Groups")." "._("Profile")." "._("Error")."
Total {$usersfail} "._("users")."
"; } } ?>