improved PDF-support
fixed bug: unix-host option wasn't showed. allowed slashes '-' for telephone numbers changed sur- and givenname to first- and lastname changed order of first- and lastname for personal settings page
This commit is contained in:
parent
ae9920bec0
commit
a032ba1e2c
134
lam/lib/pdf.inc
134
lam/lib/pdf.inc
|
@ -3,7 +3,7 @@
|
|||
$Id$
|
||||
|
||||
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
|
||||
Copyright (C) 2003 Michael Dürgner
|
||||
Copyright (C) 2003 Michael Drgner
|
||||
|
||||
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
|
||||
|
@ -44,7 +44,7 @@ function createUserPDF($accounts) {
|
|||
$pdfFile->setFont("arial","",12);
|
||||
$pdfFile->setTitle("LDAP Account Manager");
|
||||
$pdfFile->setSubject(_("User information page"));
|
||||
$pdfFile->setAuthor("LDAP Account Manager Devel-Team -Michael Dürgner-");
|
||||
$pdfFile->setAuthor("LDAP Account Manager Devel-Team -Michael Drgner-");
|
||||
$pdfFile->setCreator("LDAP Account Manager (pdf.inc)");
|
||||
// Loop for every sumbitted account and print its values on a extra page
|
||||
for($i=0;$i<count($accounts);$i++) {
|
||||
|
@ -239,43 +239,18 @@ function createUserPDF($accounts) {
|
|||
|
||||
// Close PDF
|
||||
$pdfFile->Close();
|
||||
|
||||
// Delete old PDF older than 3 min
|
||||
$relpath = $_SESSION['lampath'].'tmp/';
|
||||
$t=time();
|
||||
$h=opendir("$relpath");
|
||||
while ($file=readdir($h)) {
|
||||
if (substr($file, -4)=='.pdf') {
|
||||
$path = $relpath.$file;
|
||||
if ($t-filemtime($path)>180) {
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($h);
|
||||
|
||||
// Get relative url path
|
||||
$fullpath = realpath('.');
|
||||
$subdirs = explode('/', str_replace($_SESSION['lampath'], '', $fullpath));
|
||||
for ($i=0; $i<count($subdirs); $i++ ) $filename .= '../';
|
||||
// use timestamp and random number from ldap.inc as filename so it should be unique.
|
||||
$time = time();
|
||||
$filename = $relpath . $_SESSION['ldap']->rand . $time .'.pdf';
|
||||
$fileurl = $_SESSION['lamurl'] . 'templates/getpdf.php?&f=' . $_SESSION['lampath'] . 'tmp/' . $_SESSION['ldap']->rand . $time .'.pdf';
|
||||
$filename .= 'tmp/' . $_SESSION['ldap']->rand . time() .'.pdf';
|
||||
// Save PDF
|
||||
$pdfFile->Output($filename);
|
||||
|
||||
// Create redirector page
|
||||
echo $_SESSION['header'];
|
||||
echo "<html><head><title>";
|
||||
echo _("PDF File");
|
||||
echo "</title>\n".
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"".$_SESSION['lamurl']."style/layout.css\">\n".
|
||||
"<meta http-equiv=\"pragma\" content=\"no-cache\">\n".
|
||||
"<meta http-equiv=\"cache-control\" content=\"no-cache\">\n".
|
||||
"<meta http-equiv=\"refresh\" content=\"2; URL=$fileurl\">\n".
|
||||
"</head><body>\n".
|
||||
"<a href=\"$fileurl\">";
|
||||
echo _('Please press here if meta-refresh didn\'t work.');
|
||||
echo "</a></body></html>";
|
||||
|
||||
return 0; // 0 means everything successful; page(s) printed
|
||||
// Output meta refresh to pdf-file
|
||||
metaRefresh($filename);
|
||||
// Return relative path of pdf-file
|
||||
return $filename;
|
||||
}
|
||||
|
||||
// creates a PDF with host accounts
|
||||
|
@ -391,43 +366,18 @@ function createHostPDF($accounts) {
|
|||
|
||||
// Close PDF
|
||||
$pdfFile->Close();
|
||||
|
||||
// Delete old PDF older than 3 min
|
||||
$relpath = $_SESSION['lampath'].'tmp/';
|
||||
|
||||
$t=time();
|
||||
$h=opendir("$relpath");
|
||||
while ($file=readdir($h)) {
|
||||
if (substr($file, -4)=='.pdf') {
|
||||
$path = $relpath.$file;
|
||||
if ($t-filemtime($path)>180)
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
closedir($h);
|
||||
|
||||
// Get relative url path
|
||||
$fullpath = realpath('.');
|
||||
$subdirs = explode('/', str_replace($_SESSION['lampath'], '', $fullpath));
|
||||
for ($i=0; $i<count($subdirs); $i++ ) $filename .= '../';
|
||||
// use timestamp and random number from ldap.inc as filename so it should be unique.
|
||||
$time = time();
|
||||
$filename = $relpath . $_SESSION['ldap']->rand . $time . '.pdf';
|
||||
$fileurl = $_SESSION['lamurl'] . 'templates/getpdf.php?&f=' . $_SESSION['lampath'] . 'tmp/'. $_SESSION['ldap']->rand . $time .'.pdf';
|
||||
$filename .= 'tmp/' . $_SESSION['ldap']->rand . time() .'.pdf';
|
||||
// Save PDF
|
||||
$pdfFile->Output($filename);
|
||||
|
||||
// Create redirector page
|
||||
echo $_SESSION['header'];
|
||||
echo "<html><head><title>";
|
||||
echo _("PDF File");
|
||||
echo "</title>\n".
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"".$_SESSION['lamurl']."style/layout.css\">\n".
|
||||
"<meta http-equiv=\"pragma\" content=\"no-cache\">\n".
|
||||
"<meta http-equiv=\"cache-control\" content=\"no-cache\">\n".
|
||||
"<meta http-equiv=\"refresh\" content=\"2; URL=$fileurl\">\n".
|
||||
"</head><body>\n".
|
||||
"<a href=\"$fileurl\">";
|
||||
echo _('Please press here if meta-refresh didn\'t work.');
|
||||
echo "</a></body></html>";
|
||||
|
||||
return 0; // 0 means everything successful; page(s) printed
|
||||
// Output meta refresh to pdf-file
|
||||
metaRefresh($filename);
|
||||
// Return relative path of pdf-file
|
||||
return $filename;
|
||||
}
|
||||
|
||||
// creates a PDF with groups
|
||||
|
@ -494,44 +444,18 @@ function createGroupPDF($accounts) {
|
|||
|
||||
// Close PDF
|
||||
$pdfFile->Close();
|
||||
|
||||
// Delete old PDF older than 3 min
|
||||
$relpath = $_SESSION['lampath'].'tmp/';
|
||||
|
||||
$t=time();
|
||||
$h=opendir("$relpath");
|
||||
while ($file=readdir($h)) {
|
||||
if (substr($file, -4)=='.pdf') {
|
||||
$path = $relpath.$file;
|
||||
if ($t-filemtime($path)>180)
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
closedir($h);
|
||||
|
||||
// Get relative url path
|
||||
$fullpath = realpath('.');
|
||||
$subdirs = explode('/', str_replace($_SESSION['lampath'], '', $fullpath));
|
||||
for ($i=0; $i<count($subdirs); $i++ ) $filename .= '../';
|
||||
// use timestamp and random number from ldap.inc as filename so it should be unique.
|
||||
$time = time();
|
||||
$filename = $relpath . $_SESSION['ldap']->rand . $time . '.pdf';
|
||||
$fileurl = $_SESSION['lamurl'] . 'templates/getpdf.php?&f=' . $_SESSION['lampath'] . 'tmp/'. $_SESSION['ldap']->rand . $time .'.pdf';
|
||||
|
||||
$filename .= 'tmp/' . $_SESSION['ldap']->rand . time() .'.pdf';
|
||||
// Save PDF
|
||||
$pdfFile->Output($filename);
|
||||
|
||||
// Create redirector page
|
||||
echo $_SESSION['header'];
|
||||
echo "<html><head><title>";
|
||||
echo _("PDF File");
|
||||
echo "</title>\n".
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"".$_SESSION['lamurl']."style/layout.css\">\n".
|
||||
"<meta http-equiv=\"pragma\" content=\"no-cache\">\n".
|
||||
"<meta http-equiv=\"cache-control\" content=\"no-cache\">\n".
|
||||
"<meta http-equiv=\"refresh\" content=\"2; URL=$fileurl\">\n".
|
||||
"</head><body>\n".
|
||||
"<a href=\"$fileurl\">";
|
||||
echo _('Please press here if meta-refresh didn\'t work.');
|
||||
echo "</a></body></html>";
|
||||
|
||||
return 0; // 0 means everything successful; page(s) printed
|
||||
// Output meta refresh to pdf-file
|
||||
metaRefresh($filename);
|
||||
// Return relative path of pdf-file
|
||||
return $filename;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -473,9 +473,9 @@ switch ($_POST['select']) {
|
|||
$account_new->personal_postalAddress = $_POST['f_personal_postalAddress'];
|
||||
$account_new->personal_employeeType = $_POST['f_personal_employeeType'];
|
||||
// Check if values are OK and set automatic values. if not error-variable will be set
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $account_new->personal_telephoneNumber)) $errors[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $account_new->personal_mobileTelephoneNumber)) $errors[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $account_new->personal_facsimileTelephoneNumber)) $errors[] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $account_new->personal_telephoneNumber)) $errors[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $account_new->personal_mobileTelephoneNumber)) $errors[] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/]|[-])*$', $account_new->personal_facsimileTelephoneNumber)) $errors[] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!'));
|
||||
if ( !ereg('^(([0-9]|[A-Z]|[a-z]|[.]|[-]|[_])+[@]([0-9]|[A-Z]|[a-z]|[-])+([.]([0-9]|[A-Z]|[a-z]|[-])+)*)*$', $account_new->personal_mail)) $errors[] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $account_new->personal_street)) $errors[] = array('ERROR', _('Street'), _('Please enter a valid street name!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $account_new->personal_postalAddress)) $errors[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'));
|
||||
|
@ -502,8 +502,7 @@ switch ($_POST['select']) {
|
|||
}
|
||||
}
|
||||
// Create / display PDf-file
|
||||
createUSerPDF(array($account_new));
|
||||
// Stop script
|
||||
createUserPDF(array($account_new));
|
||||
die;
|
||||
}
|
||||
break;
|
||||
|
@ -942,13 +941,13 @@ switch ($select_local) {
|
|||
'</td>'."\n".'<td>'.
|
||||
'<a href="../help.php?HelpNumber=401" target="lamhelp">'._('Help').'</a>'.
|
||||
'</td></tr>'."\n".'<tr><td>';
|
||||
echo _('Given name').'*';
|
||||
echo _('First name').'*';
|
||||
echo '</td>'."\n".'<td>'.
|
||||
'<input name="f_general_givenname" type="text" size="20" maxlength="20" value="' . $account_new->general_givenname . '">'.
|
||||
'</td>'."\n".'<td>'.
|
||||
'<a href="../help.php?HelpNumber=425" target="lamhelp">'._('Help').'</a>'.
|
||||
'</td>'."\n".'</tr>'."\n".'<tr><td>';
|
||||
echo _('Surname').'*';
|
||||
echo _('Last name').'*';
|
||||
echo '</td>'."\n".'<td>'.
|
||||
'<input name="f_general_surname" type="text" size="20" maxlength="20" value="' . $account_new->general_surname . '">'.
|
||||
'</td><td>'.
|
||||
|
@ -1110,7 +1109,7 @@ switch ($select_local) {
|
|||
'<a href="../help.php?HelpNumber=427" target="lamhelp">'._('Help').'</a>'.
|
||||
'</td></tr>'."\n";
|
||||
// show only hosts if schema does allow hosts
|
||||
if ($_SESSION['ldap']->support_unix_hosts) {
|
||||
if ($_SESSION['ldap']->supports_unix_hosts) {
|
||||
echo '<tr><td>';
|
||||
echo _('Unix workstations');
|
||||
echo '</td>'."\n".'<td><input name="f_unix_host" type="text" size="20" maxlength="80" value="' . $account_new->unix_host . '">'.
|
||||
|
@ -1457,7 +1456,7 @@ switch ($select_local) {
|
|||
echo _('Title');
|
||||
echo '</td>'."\n".'<td>'.
|
||||
'<input name="f_personal_title" type="text" size="10" maxlength="10" value="' . $account_new->personal_title . '"> ';
|
||||
echo $account_new->general_surname . ' ' . $account_new->general_givenname . '</td><td>'.
|
||||
echo $account_new->general_givenname . ' ' . $account_new->general_surname . '</td><td>'.
|
||||
'<a href="../help.php?HelpNumber=448" target="lamhelp">'._('Help').'</a>'.
|
||||
'</td></tr>'."\n".'<tr><td>';
|
||||
echo _('Employee type');
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
$f=$HTTP_GET_VARS['f'];
|
||||
//Check file (don't skip it!)
|
||||
//print $f;
|
||||
//if(substr($f,0,3)!='tmp' or strpos($f,'/') or strpos($f,'\\'))
|
||||
// die('Incorrect file name');
|
||||
if(!file_exists($f))
|
||||
die('File does not exist');
|
||||
//Handle special IE request if needed
|
||||
if($HTTP_SERVER_VARS['HTTP_USER_AGENT']=='contype')
|
||||
{
|
||||
Header('Content-Type: application/pdf');
|
||||
exit;
|
||||
}
|
||||
//Output PDF
|
||||
Header('Content-Type: application/pdf');
|
||||
Header('Content-Length: '.filesize($f));
|
||||
readfile($f);
|
||||
// Give Browserplugin some time to get file
|
||||
sleep(240);
|
||||
//Remove file
|
||||
unlink($f);
|
||||
exit;
|
||||
?>
|
||||
|
|
@ -280,7 +280,7 @@ switch ($select) {
|
|||
echo '</td></tr></table>'."\n</fieldset>\n";
|
||||
// unset variables
|
||||
if ( isset($_SESSION['pointer'])) unset($_SESSION['pointer']);
|
||||
if ( isset($_SESSION['errors'])) unset($_SESSION['errors']);
|
||||
if ( isset($_SESSION['mass_errors'])) unset($_SESSION['mass_errors']);
|
||||
if ( isset($_SESSION['group_suffix'])) unset($_SESSION['group_suffix']);
|
||||
if ( isset($_SESSION['group_selectprofile'])) unset($_SESSION['group_selectprofile']);
|
||||
}
|
||||
|
@ -309,31 +309,31 @@ switch ($select) {
|
|||
'<a target=_blank href="massdetail.php?row='.$row.'&type=detail">'._('Show Details.').'</a></td>'."\n".'<td>';
|
||||
$found=false;
|
||||
// Show infos
|
||||
for ($i=0; $i<sizeof($_SESSION['errors'][$row]); $i++)
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'INFO') $found=true;
|
||||
for ($i=0; $i<sizeof($_SESSION['mass_errors'][$row]); $i++)
|
||||
if ($_SESSION['mass_errors'][$row][$i][0] == 'INFO') $found=true;
|
||||
if ($found) echo '<a target="massdetail" href="massdetail.php?row='.$row.'&type=info">'._('Show Infos.').'</a>';
|
||||
echo '</td>'."\n".'<td>';
|
||||
$found=false;
|
||||
// Show warnings
|
||||
for ($i=0; $i<sizeof($_SESSION['errors'][$row]); $i++)
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'WARN') $found=true;
|
||||
for ($i=0; $i<sizeof($_SESSION['mass_errors'][$row]); $i++)
|
||||
if ($_SESSION['mass_errors'][$row][$i][0] == 'WARN') $found=true;
|
||||
if ($found) echo '<a target="massdetail" href="massdetail.php?row='.$row.'&type=warn">'._('Show Warnings.').'</a>';
|
||||
echo '</td>'."\n".'<td>';
|
||||
$found=false;
|
||||
// Show errors
|
||||
for ($i=0; $i<sizeof($_SESSION['errors'][$row]); $i++)
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'ERROR') $found=true;
|
||||
for ($i=0; $i<sizeof($_SESSION['mass_errors'][$row]); $i++)
|
||||
if ($_SESSION['mass_errors'][$row][$i][0] == 'ERROR') $found=true;
|
||||
if ($found) echo '<a target="massdetail" href="massdetail.php?row='.$row.'&type=error">'._('Show Errors.').'</a>';
|
||||
echo '</td></tr>'."\n";
|
||||
}
|
||||
$noerrors=true;
|
||||
for ($i=0; $i<sizeof($_SESSION['errors']); $i++)
|
||||
for ($j=0; $j<sizeof($_SESSION['errors'][$i]); $j++)
|
||||
if ($_SESSION['errors'][$i][$j][0] == 'ERROR') $noerrors=false;
|
||||
for ($i=0; $i<sizeof($_SESSION['mass_errors']); $i++)
|
||||
for ($j=0; $j<sizeof($_SESSION['mass_errors'][$i]); $j++)
|
||||
if ($_SESSION['mass_errors'][$i][$j][0] == 'ERROR') $noerrors=false;
|
||||
$nowarn=true;
|
||||
for ($i=0; $i<sizeof($_SESSION['errors']); $i++)
|
||||
for ($j=0; $j<sizeof($_SESSION['errors'][$i]); $j++)
|
||||
if ($_SESSION['errors'][$i][$j][0] == 'WARN') $nowarn=false;
|
||||
for ($i=0; $i<sizeof($_SESSION['mass_errors']); $i++)
|
||||
for ($j=0; $j<sizeof($_SESSION['mass_errors'][$i]); $j++)
|
||||
if ($_SESSION['mass_errors'][$i][$j][0] == 'WARN') $nowarn=false;
|
||||
echo '<br>';
|
||||
if (!$noerrors) { echo '<tr><td>'. _('There are some errors.') . '</td></tr>'."\n"; }
|
||||
if (!$nowarn) { echo '<tr><td>'. _('There are some warnings.') . '</td></tr>'."\n"; }
|
||||
|
@ -351,7 +351,7 @@ switch ($select) {
|
|||
// Unset old variables
|
||||
if ( isset($_SESSION['accounts'])) unset($_SESSION['accounts']);
|
||||
if ( isset($_SESSION['pointer'])) unset($_SESSION['pointer']);
|
||||
if ( isset($_SESSION['errors'])) unset($_SESSION['errors']);
|
||||
if ( isset($_SESSION['mass_errors'])) unset($_SESSION['mass_errors']);
|
||||
if ( isset($_SESSION['group_suffix'])) unset($_SESSION['group_suffix']);
|
||||
if ( isset($_SESSION['group_selectprofile'])) unset($_SESSION['group_selectprofile']);
|
||||
// Set pointer to 0, first user
|
||||
|
@ -575,35 +575,35 @@ function loadfile() {
|
|||
}
|
||||
// Add uername to array so it's not used again for another user in masscreate
|
||||
$users[] = $_SESSION['accounts'][$row2]->general_username;
|
||||
if ($_SESSION['accounts'][$row2]->general_username != $username) $_SESSION['errors'][$row2][] = array('WARN', _('Username'), _('Username in use. Selected next free username.'));
|
||||
if ($_SESSION['accounts'][$row2]->general_username != $username) $_SESSION['mass_errors'][$row2][] = array('WARN', _('Username'), _('Username in use. Selected next free username.'));
|
||||
// Check if givenname is valid
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $_SESSION['accounts'][$row2]->general_givenname)) $_SESSION['errors'][$row2][] = array('ERROR', _('Given name'), _('Given name contains invalid characters'));
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[]|[<5B>|[<5B>)+$', $_SESSION['accounts'][$row2]->general_givenname)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Given name'), _('Given name contains invalid characters'));
|
||||
// Check if surname is valid
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $_SESSION['accounts'][$row2]->general_surname)) $_SESSION['errors'][$row2][] = array('ERROR', _('Surname'), _('Surname contains invalid characters'));
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[]|[<5B>|[<5B>)+$', $_SESSION['accounts'][$row2]->general_surname)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Surname'), _('Surname contains invalid characters'));
|
||||
if ( ($_SESSION['accounts'][$row2]->general_gecos=='') || ($_SESSION['accounts'][$row2]->general_gecos==' ')) {
|
||||
$_SESSION['accounts'][$row2]->general_gecos = $_SESSION['accounts'][$row2]->general_givenname . " " . $_SESSION['accounts'][$row2]->general_surname ;
|
||||
$_SESSION['errors'][$row2][] = array('INFO', _('Gecos'), _('Inserted sur- and given name in gecos-field.'));
|
||||
$_SESSION['mass_errors'][$row2][] = array('INFO', _('Gecos'), _('Inserted sur- and given name in gecos-field.'));
|
||||
}
|
||||
$_SESSION['accounts'][$row2]->smb_displayName = $_SESSION['accounts'][$row2]->general_gecos;
|
||||
if ($_SESSION['accounts'][$row2]->general_group=='') $_SESSION['errors'][$row2][] = array('ERROR', _('Primary group'), _('No primary group defined!'));
|
||||
if ($_SESSION['accounts'][$row2]->general_group=='') $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Primary group'), _('No primary group defined!'));
|
||||
// Check if Username contains only valid characters
|
||||
if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $_SESSION['accounts'][$row2]->general_username))
|
||||
$_SESSION['errors'][$row2][] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !'));
|
||||
$_SESSION['mass_errors'][$row2][] = array('ERROR', _('Username'), _('Username contains invalid characters. Valid characters are: a-z, 0-9 and .-_ !'));
|
||||
// Check if Name-length is OK. minLength=3, maxLength=20
|
||||
if ( !ereg('.{3,20}', $_SESSION['accounts'][$row2]->general_username)) $_SESSION['errors'][$row2][] = array('ERROR', _('Name'), _('Name must contain between 3 and 20 characters.'));
|
||||
if ( !ereg('.{3,20}', $_SESSION['accounts'][$row2]->general_username)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Name'), _('Name must contain between 3 and 20 characters.'));
|
||||
// Check if Name starts with letter
|
||||
if ( !ereg('^([a-z]|[A-Z]).*$', $_SESSION['accounts'][$row2]->general_username))
|
||||
$_SESSION['errors'][$row2][] = array('ERROR', _('Name'), _('Name contains invalid characters. First character must be a letter'));
|
||||
$_SESSION['mass_errors'][$row2][] = array('ERROR', _('Name'), _('Name contains invalid characters. First character must be a letter'));
|
||||
// Personal Settings
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['accounts'][$row2]->personal_telephoneNumber)) $_SESSION['errors'][$row2][] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['accounts'][$row2]->personal_mobileTelephoneNumber)) $_SESSION['errors'][$row2][] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['accounts'][$row2]->personal_facsimileTelephoneNumber)) $_SESSION['errors'][$row2][] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!'));
|
||||
if ( !ereg('^(([0-9]|[A-Z]|[a-z]|[.]|[-]|[_])+[@]([0-9]|[A-Z]|[a-z]|[-])+([.]([0-9]|[A-Z]|[a-z]|[-])+)*)*$', $_SESSION['accounts'][$row2]->personal_mail)) $_SESSION['errors'][$row2][] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['accounts'][$row2]->personal_street)) $_SESSION['errors'][$row2][] = array('ERROR', _('Street'), _('Please enter a valid street name!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['accounts'][$row2]->personal_postalAddress)) $_SESSION['errors'][$row2][] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['accounts'][$row2]->personal_title)) $_SESSION['errors'][$row2][] = array('ERROR', _('Title'), _('Please enter a valid title!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_SESSION['accounts'][$row2]->personal_employeeType)) $_SESSION['errors'][$row2][] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $_SESSION['accounts']->personal_postalCode)) $_SESSION['errors'][$row2][] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['accounts'][$row2]->personal_telephoneNumber)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['accounts'][$row2]->personal_mobileTelephoneNumber)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Mobile number'), _('Please enter a valid mobile number!'));
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_SESSION['accounts'][$row2]->personal_facsimileTelephoneNumber)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Fax number'), _('Please enter a valid fax number!'));
|
||||
if ( !ereg('^(([0-9]|[A-Z]|[a-z]|[.]|[-]|[_])+[@]([0-9]|[A-Z]|[a-z]|[-])+([.]([0-9]|[A-Z]|[a-z]|[-])+)*)*$', $_SESSION['accounts'][$row2]->personal_mail)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('eMail address'), _('Please enter a valid eMail address!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[<5B>|[]|[<5B>)*$', $_SESSION['accounts'][$row2]->personal_street)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Street'), _('Please enter a valid street name!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[<5B>|[]|[<5B>)*$', $_SESSION['accounts'][$row2]->personal_postalAddress)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[<5B>|[]|[<5B>)*$', $_SESSION['accounts'][$row2]->personal_title)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Title'), _('Please enter a valid title!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[<5B>|[]|[<5B>)*$', $_SESSION['accounts'][$row2]->personal_employeeType)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $_SESSION['accounts']->personal_postalCode)) $_SESSION['mass_errors'][$row2][] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'));
|
||||
}
|
||||
}
|
||||
// Close file if it was opened
|
||||
|
|
|
@ -85,10 +85,10 @@ if ($_POST['apply']) {
|
|||
// Show Detail-page
|
||||
$select = 'detail';
|
||||
// Check if surname is valid
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $_POST['f_general_surname'])) $errors2[] = array('ERROR', _('Surname'), _('Surname contains invalid characters'));
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[]|[<5B>|[<5B>)+$', $_POST['f_general_surname'])) $errors2[] = array('ERROR', _('Surname'), _('Surname contains invalid characters'));
|
||||
else $_SESSION['accounts'][$row]->general_surname = $_POST['f_general_surname'];
|
||||
// Check if givenname is valid
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[ä]|[Ä]|[ö]|[Ö]|[ü]|[Ü]|[ß])+$', $_POST['f_general_givenname'])) $errors2[] = array('ERROR', _('Given name'), _('Given name contains invalid characters'));
|
||||
if ( !ereg('^([a-z]|[A-Z]|[-]|[ ]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[]|[<5B>|[<5B>)+$', $_POST['f_general_givenname'])) $errors2[] = array('ERROR', _('Given name'), _('Given name contains invalid characters'));
|
||||
else $_SESSION['accounts'][$row]->general_givenname = $_POST['f_general_givenname'];
|
||||
// Check if username is valid
|
||||
if ( !ereg('^([a-z]|[0-9]|[.]|[-]|[_])*$', $_POST['f_general_username']))
|
||||
|
@ -144,15 +144,15 @@ if ($_POST['apply']) {
|
|||
if ($_SESSION['accounts'][$row2]->general_username != $_POST['f_general_username']) $errors2[] = array('WARN', _('Username'), _('Username in use. Selected next free username.'));
|
||||
}
|
||||
// Check personal settings
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_POST['f_personal_title'])) $errors2[] = array('ERROR', _('Title'), _('Please enter a valid title!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[<5B>|[]|[<5B>)*$', $_POST['f_personal_title'])) $errors2[] = array('ERROR', _('Title'), _('Please enter a valid title!'));
|
||||
else $_SESSION['accounts'][$row]->personal_title = $_POST['f_personal_title'];
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_POST['f_personal_employeeType'])) $errors2[] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[<5B>|[]|[<5B>)*$', $_POST['f_personal_employeeType'])) $errors2[] = array('ERROR', _('Employee type'), _('Please enter a valid employee type!'));
|
||||
else $_SESSION['accounts'][$row]->personal_employeeType = $_POST['f_personal_employeeType'];
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_POST['f_personal_street'])) $errors2[] = array('ERROR', _('Street'), _('Please enter a valid street name!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[<5B>|[]|[<5B>)*$', $_POST['f_personal_street'])) $errors2[] = array('ERROR', _('Street'), _('Please enter a valid street name!'));
|
||||
else $_SESSION['accounts'][$row]->personal_street = $_POST['f_personal_street'];
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z])*$', $_POST['f_personal_postalCode'])) $errors2[] = array('ERROR', _('Postal code'), _('Please enter a valid postal code!'));
|
||||
else $_SESSION['accounts'][$row]->personal_postalCode = $_POST['f_personal_postalCode'];
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[Ä]|[ä]|[Ö]|[ö]|[Ü]|[ü]|[ß])*$', $_POST['f_personal_postalAddress'])) $errors2[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'));
|
||||
if ( !ereg('^([0-9]|[A-Z]|[a-z]|[ ]|[.]|[<EFBFBD>|[<5B>|[<5B>|[<5B>|[<5B>|[]|[<5B>)*$', $_POST['f_personal_postalAddress'])) $errors2[] = array('ERROR', _('Postal address'), _('Please enter a valid postal address!'));
|
||||
else $_SESSION['accounts'][$row]->personal_postalAddress = $_POST['f_personal_postalAddress'];
|
||||
if ( !ereg('^(\+)*([0-9]|[ ]|[.]|[(]|[)]|[/])*$', $_POST['f_personal_telephoneNumber'])) $errors2[] = array('ERROR', _('Telephone number'), _('Please enter a valid telephone number!'));
|
||||
else $_SESSION['accounts'][$row]->personal_telephoneNumber = $_POST['f_personal_telephoneNumber'];
|
||||
|
@ -187,19 +187,19 @@ switch ($select) {
|
|||
* error = Show all errors about user
|
||||
*/
|
||||
case 'error':
|
||||
for ($i=0; $i<sizeof($_SESSION['errors'][$row]); $i++)
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'ERROR')
|
||||
StatusMessage('ERROR', _('Invalid Value!'), $_SESSION['errors'][$row][$i][2]);
|
||||
for ($i=0; $i<sizeof($_SESSION['mass_errors'][$row]); $i++)
|
||||
if ($_SESSION['mass_errors'][$row][$i][0] == 'ERROR')
|
||||
StatusMessage('ERROR', _('Invalid Value!'), $_SESSION['mass_errors'][$row][$i][2]);
|
||||
break;
|
||||
case 'info':
|
||||
for ($i=0; $i<sizeof($_SESSION['errors'][$row]); $i++)
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'INFO')
|
||||
StatusMessage('INFO', _('Check values.'), $_SESSION['errors'][$row][$i][2]);
|
||||
for ($i=0; $i<sizeof($_SESSION['mass_errors'][$row]); $i++)
|
||||
if ($_SESSION['mass_errors'][$row][$i][0] == 'INFO')
|
||||
StatusMessage('INFO', _('Check values.'), $_SESSION['mass_errors'][$row][$i][2]);
|
||||
break;
|
||||
case 'warn':
|
||||
for ($i=0; $i<sizeof($_SESSION['errors'][$row]); $i++)
|
||||
if ($_SESSION['errors'][$row][$i][0] == 'WARN')
|
||||
StatusMessage('WARN', _('Check values.'), $_SESSION['errors'][$row][$i][2]);
|
||||
for ($i=0; $i<sizeof($_SESSION['mass_errors'][$row]); $i++)
|
||||
if ($_SESSION['mass_errors'][$row][$i][0] == 'WARN')
|
||||
StatusMessage('WARN', _('Check values.'), $_SESSION['mass_errors'][$row][$i][2]);
|
||||
break;
|
||||
case 'detail':
|
||||
echo '<table class="massdetail" width="100%">';
|
||||
|
|
Loading…
Reference in New Issue