6 require_once(
'rights/User_SQL.php');
28 const WRONG_IP_TEXT =
'Sie dürfen sich auf Grund der IP-Beschränkungen nicht anmelden';
32 const WRONG_TIME_TEXT =
'Sie dürfen sich auf Grund der Zeit-Beschränkung nicht anmelden';
48 const CONCURRENT_USERS_LIMIT_TEXT =
'Sie dürfen sich derzeit am System nicht anmelden, da die maximale Anzahl an gleichzeitigen Benutzern erreicht ist. Bitte versuchen Sie es später erneut.';
66 const LOST_PASSWORD_TEXT =
'Geben Sie die E-Mail Adresse des Benutzers an, für den ein neues Passwort angefordert werden soll.';
70 const LOST_PASSWORD_SUCCESS_TEXT =
'Falls ein Benutzer mit der eingegebenen E-Mail Adresse gefunden wurde, hat dieser eine E-Mail mit den Anweisungen zum Zurücksetzen seines Passworts erhalten.';
101 $bf_file = $GLOBALS[
'egotec_conf'][
'tmp_dir'].
'wrong_pwd'.md5(
Ego_System::getIp());
102 if(file_exists($bf_file))
104 [$s, $n] = explode(
' ', file_get_contents($bf_file));
106 file_put_contents($bf_file, $s.
' '.(++$n));
108 parent::__construct($text, $nr);
134 private static $_userRecord = array();
135 private $superUserFlag =
null;
147 public function __construct($force_login=
false, $id=
'', $action=
'', $param=array())
156 $this->_id = $this->
validate($param[
'username'], $param[
'password']);
167 $param = array_merge([
168 'email' => $_REQUEST[
'email'],
169 'lostpw_lock' =>
true,
170 'lostpw_expire' =>
'+1 hour'
172 $this->lostPassword($param[
'email'], (
bool) $param[
'lostpw_lock'], (
string) $param[
'lostpw_expire']);
175 $param = array_merge([
176 'user_id' => $_REQUEST[
'user_id'],
177 'new_password1' => $_REQUEST[
'new_password1'],
178 'new_password2' => $_REQUEST[
'new_password2'],
181 trim($param[
'new_password1']) ==
''
182 || trim($param[
'new_password2']) ==
''
183 || $param[
'new_password1'] != $param[
'new_password2']
187 $this->_id = $param[
'user_id'];
189 $GLOBALS[
'auth'] = $this;
191 if (($errors = self::checkPassword($param[
'new_password1'], $this->user->field[
'username'],
true)) !==
true) {
193 $GLOBALS[
'check_password_errors'] = $errors;
199 $this->user->setPassword($param[
'new_password1']);
200 unset($this->user->extra[
'resetpw']);
201 $this->user->update();
206 case AUTH::TWO_FACTOR_AUTH:
208 require_once
'auth/Ego_TwoFactorAuth.php';
209 $tfa =
new Ego_TwoFactorAuth();
211 $this->_id = $_SESSION[
'AUTH_VALIDATED'];
213 $secret = $this->user->extra[
'tfa_secret'] ?: $_SESSION[
'TFA_SECRET'];
216 if ($tfa->verifyCode($secret, $param[
'verification'])) {
218 if (empty($this->user->extra[
'tfa_secret']) && isset($_SESSION[
'TFA_SECRET'])) {
219 $this->user->extra[
'tfa_secret'] = $_SESSION[
'TFA_SECRET'];
220 unset($_SESSION[
'TFA_SECRET']);
221 $this->user->update();
228 if (!$this->_id && $force_login)
234 if (!$action && $_SESSION[
'AUTH_TIME'][$this->_id] && $_SESSION[
'AUTH_TIME'][$this->_id]+$GLOBALS[
'egotec_conf'][
'auth_timeout']<time())
239 !empty($param[
'tfa'])
241 && empty($_SESSION[
'AUTH_TIME'])
242 && version_compare(PHP_VERSION,
'8.1.0') >= 0
243 && !$_SERVER[
'HTTP_X_UNIT_TEST']
247 require_once
'auth/Ego_TwoFactorAuth.php';
248 $tfa =
new Ego_TwoFactorAuth();
250 if ($tfa->isEnabled($this->user))
255 if (empty($this->user->extra[
'tfa_secret'])) {
257 $_SESSION[
'TFA_SECRET'] = $tfa->createSecret(128);
261 $_SESSION[
'TFA_SECRET'] = $this->user->extra[
'tfa_secret'];
273 if (in_array($action, array(
Auth::LOGIN,
Auth::ID)) && $GLOBALS[
'admin_area'] !==
'webdav')
275 $this->user->extra[
'Anzahl_login'] = ((int) $this->user->extra[
'Anzahl_login']) + 1;
276 $this->user->extra[
'Anzahl_login_'.$GLOBALS[
'site']->name] = ((int) $this->user->extra[
'Anzahl_login_'.$GLOBALS[
'site']->name]) + 1;
278 $now = date(
'Y-m-d H:i:s');
281 if (!empty($param[
'persist'])) {
282 unset($this->user->extra[
'auth_persist_expire']);
286 $this->user->update(array(
299 public function reset($remove_cookie =
false)
302 unset($_SESSION[
'AUTH_TIME']);
303 unset($_SESSION[
'auth_id']);
304 unset($_SESSION[
'intranet_admin']);
305 unset($_SESSION[
'is_adoptuser']);
306 unset($_SESSION[
'login']);
307 unset($_SESSION[
'TFA_SECRET']);
308 if (!empty($GLOBALS[
'egotec_conf'][
'auth'][
'sso_logout'])) {
309 $_SESSION[
'logout'] =
true;
313 $db = new_db_connection();
315 'table' =>
'egotec_page_lock',
316 'where' =>
'user_id=\''.$this->_id.
'\''
319 'table' =>
'egotec_user',
320 'set' => array(
'sid' =>
''),
321 'where' =>
'user_id=\''.$this->_id.
'\''
326 if ($remove_cookie) {
362 $db = new_db_connection(array(
364 'from' =>
'egotec_user',
365 'where' =>
'LOWER(username) = LOWER(:username) AND deleted = 0',
367 'username' => $username
370 $found = $db->nextRecord();
373 if (!$found && trim($username) !=
'' && $GLOBALS[
'egotec_conf'][
'auth'][
'email_login']) {
374 $db = new_db_connection(array(
376 'from' =>
'egotec_user',
377 'where' =>
'LOWER(email) = LOWER(:email) AND deleted = 0',
382 $found = $db->nextRecord();
387 $id = $db->Record[
'user_id'];
391 if (!$this->user->isPassword($password)) {
394 } elseif (!$this->user->field[
'salt']) {
396 $this->user->setPassword($password);
397 $this->user->update();
413 foreach ($users as
$user) {
417 return $this->
translate(
"Der Benutzer Papierkorb wurde geleert.");
426 $db = new_db_connection();
428 'table' =>
'egotec_user',
429 'where' =>
'deleted = 1'
432 while ($db->nextRecord()) {
434 $user =
new User_SQL($db->Record[
'user_id']);
435 $rel =
$user->getGroupRoleRelations();
438 foreach ($rel as $group => $roles) {
439 $roles = explode(
',', $roles);
440 foreach ($roles as $role) {
441 if ($this->
hasPermission($group, $role,
false,
false,
false)) {
452 $users[] = $db->Record;
467 $this->user =
new User_SQL($this->_id);
468 }
catch (User_Exception $e) {
472 $this->extra = $this->user->extra;
482 $days = array(
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun");
483 $group_ips = array();
485 $group_times = array();
486 $user_times = array();
488 if ($this->user->extra[
'ip_rights'] !=
"")
490 $user_ip_arr = explode(
"\n", $this->user->extra[
'ip_rights']);
491 foreach ($user_ip_arr as $entry)
493 $entry = str_replace(
'*',
'', $entry);
494 $entry = trim($entry);
497 $user_ips[
'_'.$entry] = $entry;
502 if ($this->user->extra[
'time_rights'] !=
'')
504 $user_time_arr = explode(
"\n", $this->user->extra[
'time_rights']);
505 foreach ($user_time_arr as $entry)
507 $day_arr = explode(
" ",$entry);
508 $user_times[$day_arr[0]] = $day_arr[1];
512 $db = new_db_connection(array(
514 'from' =>
'egotec_user_group',
515 'join' => array(
'egotec_group on egotec_group.group_id = egotec_user_group.group_id'),
516 'where' =>
"user_id='$this->_id'"
519 $groupDesc_arr = array();
521 $groupDesc = str_replace(
"\n\r",
"\n", $db->Record[
'group_descr']);
522 if (strpos($groupDesc,
"\n\n")>=0)
524 $groupDesc_arr1 = explode(
"\n", $groupDesc);
525 foreach ($groupDesc_arr1 as $line)
532 $groupDesc_arr[] = trim($line);
536 }
while($db->nextRecord());
543 foreach ($groupDesc_arr as $entry)
546 if (strpos($entry,
'IP:') === 0)
548 $entry = str_replace(
'IP:',
'', $entry);
549 $entry = trim($entry);
550 $ip_arr = explode(
' ',$entry);
551 $ip_arr[0] = trim(str_replace(
'*',
'',$ip_arr[0]));
552 $group_ips[
'_'.$ip_arr[0]] = $ip_arr[0];
557 foreach ($days as $day)
560 if (strpos($entry,
"$day ") === 0)
562 $group_times[] = $entry;
568 $ips = array_merge($group_ips,$user_ips);
569 $times = array_merge($group_times,$user_times);
576 foreach ($ips as $ip)
578 if (strpos($currentIP, $ip)===0)
592 if (count($times) > 0)
599 $dayTime_arr = explode(
'-', date(
'D-H'));
601 foreach($times as $entry)
603 $day_arr = explode(
' ',$entry);
606 $time_arr = explode(
"-",$time);
607 $day_start = $time_arr[0];
608 $day_end = $time_arr[1];
610 if($day == $dayTime_arr[0])
612 if($dayTime_arr[1] < $day_start)
616 elseif($dayTime_arr[1] >= $day_end)
633 if (isset($GLOBALS[
'admin_area']) && $GLOBALS[
'egotec_conf'][
'liveserver'])
635 if (!$this->user->extra[
'liveserver'])
640 if ($this->user->isInactive() && !$this->user->extra[
'saml2']) {
644 if (!$this->user->getGroupRoleRelations()) {
648 if ($this->user->field[
'sid']
649 && !$this->user->field[
'multiple_login']
650 && $this->user->field[
'sid']!=$_COOKIE[EGOTEC]
651 && $this->user->isActive()
652 && $GLOBALS[
'admin_area'] !=
'webdav'
655 sess_destroy($this->user->field[
'sid']);
658 if ($GLOBALS[
'admin_area']) {
660 $_SESSION[
'login'][
'admin'] =
true;
703 public function translate($string, $placeholders = array(), $language =
null)
706 require_once(
'smarty/Ego_Smarty.php');
707 require_once(
'smarty/plugins/block.t.php');
708 $smarty = $GLOBALS[
'smarty']?$GLOBALS[
'smarty']:
new Ego_Smarty();
711 $params[
'language'] = $language;
712 } elseif (!$GLOBALS[
'admin_area']) {
713 $params[
'language'] = $site->language;
715 $params[
'language'] = $this->user&&$this->user->extra[
'lang']?$this->user->extra[
'lang']:
'de';
717 $params[
'placeholders'] = $placeholders;
718 return smarty_block_t($params, $string, $smarty);
737 if (is_array($rights))
739 if (
sizeof($rights)>1)
741 $rights_condition =
' IN (\''.join(
'\',\
'', $rights).
'\')
';
743 foreach ($rights as $right)
745 if (strpos(Auth::NO_NULL_RIGHTS, ',
'.$right.',
')===false)
752 $rights_condition = '=\
''.$rights[0].
'\'';
760 $rights_condition =
'=\''.$rights.
'\'';
766 if ($param[
'user_id'])
768 $user_id = $param[
'user_id'];
777 $as_page_table = $query[
'page_table'] ?? $page_table;
779 if (isset($query[
'join']) && !is_array($query[
'join'])) {
780 $query[
'join'] = [$query[
'join']];
781 egotec_deprecated_log(
'14.6.3');
785 $query[
'join'][] = $page_table .
'_rights ON ' .
786 $page_table .
'_rights.page_id=' . $as_page_table .
'.id AND ' .
787 $page_table .
'_rights.perm' . $rights_condition;
788 $query[
'join'][] =
'egotec_user_group_flat ON ' .
789 $page_table .
'_rights.group_id=egotec_user_group_flat.group_id AND ' .
790 $page_table .
'_rights.role_id=egotec_user_group_flat.role_id AND ' .
791 'egotec_user_group_flat.user_id=\'' . $user_id .
'\'';
792 $query[
'join'][] = $page_table .
'_users ON ' .
793 $page_table .
'_users.page_id=' . $as_page_table .
'.id AND ' .
794 $page_table .
'_users.perm' . $rights_condition .
' AND ' .
795 $page_table .
'_users.user_id=\'' . $user_id .
'\'';
796 $query[
'where'] = ($query[
'where'] ? $query[
'where'] .
' AND ' :
'') .
797 '(egotec_user_group_flat.user_id IS NOT NULL OR ' .
798 $page_table .
'_rights.group_id=\'*\' OR ' .
799 $page_table .
'_users.user_id IS NOT NULL' .
800 ($is_null ?
' OR ' . $page_table .
'_rights.group_id IS NULL' :
'') .
801 ($param[
'auth_or'] ?
' OR ' . $param[
'auth_or'] :
'') .
')';
802 $query[
'distinct'] = 1;
804 $query[
'join'][] = $page_table .
'_rights on ' . $page_table .
'_rights.page_id=' . $as_page_table .
'.id AND ' . $page_table .
'_rights.perm ' . $rights_condition;
805 $query[
'where'] = ($query[
'where'] ?
'(' . $query[
'where'] .
') AND ' :
'') .
806 '(' . $page_table .
"_rights.group_id='*' AND " . $page_table .
"_rights.role_id='*')";
839 function hasPermission($group, $role=
'', $flag=
false, $user_id=
false, $equal=
true)
841 if ($this->superUserFlag && !$user_id) {
844 if (is_array($group))
846 $role = $group[
'role'];
847 $flag = $group[
'flag'];
848 $group = $group[
'group'];
850 if (!$group && !$role)
860 $db = new_db_connection(array(
861 'from' =>
'egotec_user_group'.
862 ($group?
', egotec_group, egotec_group user_group':
'').
863 ($role?
', egotec_role, egotec_role user_role':
''),
864 'where' =>
"egotec_user_group.user_id = '".$user_id.
"'
866 egotec_user_group.group_id = user_group.group_id AND
867 egotec_group.group_id = '$group' AND
868 user_group.links <= egotec_group.links AND
869 user_group.rechts >= egotec_group.rechts
871 egotec_user_group.role_id = user_role.role_id AND
872 egotec_role.role_id = '$role' AND
873 user_role.links <= egotec_role.links AND
874 user_role.rechts >= egotec_role.rechts
875 ":
'').(!$equal && $group && $role ?
" AND (
876 user_group.links != egotec_group.links OR
877 user_role.links != egotec_role.links)
882 $db = new_db_connection(array(
883 'from' =>
'egotec_user_group'.
884 ($group?
', egotec_group, egotec_group user_group':
'').
885 ($role?
', egotec_role, egotec_role user_role':
''),
886 'where' =>
"egotec_user_group.user_id = '".$user_id.
"'
888 egotec_user_group.group_id = user_group.group_id AND
889 egotec_group.group_id = '$group' AND ( (
890 user_group.links <= egotec_group.links AND
891 user_group.rechts >= egotec_group.rechts
893 egotec_group.links <= user_group.links AND
894 egotec_group.rechts >= user_group.rechts
897 egotec_user_group.role_id = user_role.role_id AND
898 egotec_role.role_id = '$role' AND ( (
899 user_role.links <= egotec_role.links AND
900 user_role.rechts >= egotec_role.rechts
902 egotec_role.links <= user_role.links AND
903 egotec_role.rechts >= user_role.rechts
908 return (
bool) $db->next();
919 if (is_a($object,
'User_SQL')) {
920 $relations = $object->getGroupRoleRelations();
921 if (empty($relations)) {
925 foreach ($relations as $group => $roles) {
926 foreach (explode(
',', $roles) as $role) {
927 if ($this->
hasPermission($group, $role,
false,
false, $equal)) {
932 } elseif (is_a($object,
'Group_SQL')) {
934 } elseif (is_a($object,
'Role_SQL')) {
958 $this->superUserFlag =
null;
959 } elseif ($GLOBALS[
'soap'] || $GLOBALS[
'rest']) {
962 if ($this->superUserFlag ===
null || !$session) {
963 $is_superuser = (!$session || $_COOKIE[EGOTEC_SU])
965 $GLOBALS[
'egotec_conf'][
'superuser'][
'group'],
966 $GLOBALS[
'egotec_conf'][
'superuser'][
'role']
971 return $is_superuser;
973 $this->superUserFlag = $is_superuser;
975 return $this->superUserFlag;
985 if ($this->user->extra[
'anrede'] ==
"SOAP")
1009 return $this->_id==NULL;
1036 return $this->
checkPermission($GLOBALS[
'egotec_conf'][
'superuser'][
'group'], $GLOBALS[
'egotec_conf'][
'superuser'][
'role']);
1093 $languages = array();
1094 $handle = opendir($GLOBALS[
'egotec_conf'][
'lib_dir'].
'locale');
1095 while ($file = readdir ($handle))
1097 if ($file[0] !=
'.'&& $file !=
'blocks')
1099 $languages[] = $file;
1106 $handle2 = opendir($GLOBALS[
'egotec_conf'][
'var_dir'].
'lib/locale');
1107 while ($file = readdir ($handle2))
1109 if ($file[0] !=
'.' && $file !=
'blocks')
1111 $languages[] = $file;
1117 return array_unique($languages);
1137 if (isset(Auth::$_userRecord[$user_id]))
1139 return Auth::$_userRecord[$user_id];
1141 $db = new_db_connection(array(
1142 'table' =>
'egotec_user',
1143 'where' =>
"user_id='".$user_id.
"'"
1145 if ($db->nextRecord())
1147 $user_record = $db->Record;
1148 $user_record[
'extra'] = unserialize($user_record[
'extra']);
1151 require_once(
'rights/User_SQL.php');
1152 $user =
new User_SQL($user_id, $db->Record);
1153 $user_record[
'fullname'] =
$user->getFullname();
1154 }
catch (User_Exception $e) {
1159 $user_record = array(
'username' => $GLOBALS[
'auth']->
translate(
'unbekannt'));
1160 $user_record[
'fullname'] = $user_record[
'username'];
1162 AUTH::$_userRecord[$user_id] = $user_record;
1163 return $user_record;
1211 static function getUsers($rights, $users=array(), $direct_flag=
false)
1213 require_once(
'rights/User_Iterator.php');
1219 $query[
'distinct'] =
true;
1220 $query[
'fields'] =
'egotec_user.*';
1221 $query[
'table'] =
'egotec_user';
1222 $query[
'join'][] =
'egotec_user_group ON egotec_user.user_id = egotec_user_group.user_id';
1224 foreach ($rights as $right)
1226 $where[] =
"egotec_user_group.group_id='".$right[
'group_id'].
"' AND egotec_user_group.role_id='".$right[
'role_id'].
"'";
1228 $query[
'where'] =
'('.join(
') OR (', $where).
')';
1231 $query[
'distinct'] =
true;
1232 $query[
'fields'] =
'egotec_user.*';
1233 $query[
'from'] =
'egotec_user';
1234 $query[
'join'][] =
'egotec_user_group ON egotec_user_group.user_id = egotec_user.user_id';
1235 $query[
'join'][] =
'egotec_group direct_group ON egotec_user_group.group_id = direct_group.group_id';
1236 $query[
'join'][] =
"egotec_group ON egotec_group.links >= direct_group.links AND egotec_group.rechts <= direct_group.rechts";
1237 $query[
'join'][] =
'egotec_role direct_role ON egotec_user_group.role_id = direct_role.role_id';
1238 $query[
'join'][] =
"egotec_role ON egotec_role.links >= direct_role.links AND egotec_role.rechts <= direct_role.rechts";
1240 foreach ($rights as $right)
1242 $where[] =
"egotec_group.group_id='".$right[
'group_id'].
"' AND egotec_role.role_id='".$right[
'role_id'].
"'";
1244 $query[
'where'] =
'('.join(
') OR (', $where).
')';
1248 $query2[
'fields'] =
'egotec_user.*';
1249 $query2[
'table'] =
'egotec_user';
1250 foreach ($users as
$user)
1252 if (is_array(
$user)) {
1253 $user_ids[] =
$user[
'user_id'];
1255 $user_ids[] =
$user;
1258 $query2[
'where'] =
"user_id IN ('".join(
"','", $user_ids).
"')";
1259 return new User_Iterator(new_db_connection(array(
1260 'union' => array($query, $query2)
1263 return new User_Iterator(new_db_connection($query));
1267 foreach ($users as
$user)
1269 if (is_array(
$user)) {
1270 $user_ids[] =
$user[
'user_id'];
1272 $user_ids[] =
$user;
1275 $db = new_db_connection(array(
1277 'table' =>
'egotec_user',
1278 'where' =>
"user_id IN ('".join(
"','", $user_ids).
"')"
1280 return new User_Iterator($db);
1283 return new User_Iterator();
1294 $cache_dir = $GLOBALS[
'egotec_conf'][
'cache_dir'].
'_user/'.
$this->_id;
1309 $min_len = $GLOBALS[
'egotec_conf'][
'auth'][
'min_passw_chars'];
1310 $min_upper = $GLOBALS[
'egotec_conf'][
'auth'][
'min_big_chars'];
1311 $min_lower = $GLOBALS[
'egotec_conf'][
'auth'][
'min_small_chars'];
1312 $min_numbers = $GLOBALS[
'egotec_conf'][
'auth'][
'min_digits'];
1313 $min_special = $GLOBALS[
'egotec_conf'][
'auth'][
'min_extra_chars'];
1314 $max_same_chars = ($GLOBALS[
'egotec_conf'][
'auth'][
'no_chars_from_username'])?$GLOBALS[
'egotec_conf'][
'auth'][
'no_chars_from_username']-1:
false;
1315 $min_erfuellt = ($GLOBALS[
'egotec_conf'][
'auth'][
'min_ok_parameters'])?$GLOBALS[
'egotec_conf'][
'auth'][
'min_ok_parameters']:0;
1317 $nicht_erfuellt = array();
1322 if (strlen($pwd) >= $min_len) $erfuellt++;
1323 else $nicht_erfuellt[] = $return_text
1324 ? $GLOBALS[
'auth']->translate(
'Das Passwort ist zu kurz (vorgegeben: %n).', array(
'n' => $min_len))
1330 for($i=0;$i<strlen($pwd);$i++)
1332 $ascii = ord($pwd[$i]);
1333 if ($ascii > 64 && $ascii < 91) $anz++;
1335 if ($anz >= $min_upper) $erfuellt++;
1336 else $nicht_erfuellt[] = $return_text
1337 ? $GLOBALS[
'auth']->translate(
'Das Passwort hat zu wenige Großbuchstaben (vorgegeben: %n).', array(
'n' => $min_upper))
1343 for($i=0;$i<strlen($pwd);$i++)
1345 $ascii = ord($pwd[$i]);
1346 if ($ascii > 96 && $ascii < 123) $anz++;
1348 if ($anz >= $min_lower) $erfuellt++;
1349 else $nicht_erfuellt[] = $return_text
1350 ? $GLOBALS[
'auth']->translate(
'Das Passwort hat zu wenige Kleinbuchstaben (vorgegeben: %n).', array(
'n' => $min_lower))
1356 for($i=0;$i<strlen($pwd);$i++)
1358 $ascii = ord($pwd[$i]);
1359 if ($ascii > 47 && $ascii < 58) $anz++;
1361 if ($anz >= $min_numbers) $erfuellt++;
1362 else $nicht_erfuellt[] = $return_text
1363 ? $GLOBALS[
'auth']->translate(
'Das Passwort hat zu wenige Zahlen (vorgegeben: %n).', array(
'n' => $min_numbers))
1369 for($i=0;$i<strlen($pwd);$i++)
1371 $ascii = ord($pwd[$i]);
1373 ($ascii > 31 && $ascii < 48) ||
1374 ($ascii > 57 && $ascii < 65) ||
1375 ($ascii > 90 && $ascii < 95) ||
1376 ($ascii > 122 && $ascii < 127)
1379 if ($anz >= $min_special) $erfuellt++;
1380 else $nicht_erfuellt[] = $return_text
1381 ? $GLOBALS[
'auth']->translate(
'Das Passwort hat zu wenige Sonderzeichen (vorgegeben: %n).', array(
'n' => $min_special))
1388 if ($max_same_chars !==
false)
1391 for ($i=0;$i<strlen($pwd);$i++)
1393 for ($ii=0;$ii<strlen($name);$ii++)
1395 if ($name[$ii] == $pwd[$i])
1401 if ($same_chars <= $max_same_chars) $erfuellt++;
1402 else $nicht_erfuellt[] = $return_text
1403 ? $GLOBALS[
'auth']->translate(
'Das Passwort hat zu viele Zeichen aus dem Benutzernamen (vorgegeben: %n).', array(
'n' => $max_same_chars))
1409 if (file_exists($GLOBALS[
'egotec_conf'][
'var_dir'].
'conf/pw_exclusion_list.txt'))
1411 $words_array = file($GLOBALS[
'egotec_conf'][
'var_dir'].
'conf/pw_exclusion_list.txt');
1414 foreach ($words_array as $word)
1416 if ($pwd == trim($word,
"\n\r"))
1420 ? $GLOBALS[
'auth']->
translate(
'Das Passwort darf nicht verwendet werden.')
1421 :
'pw_exclusion_list'
1428 if ($min_erfuellt == 0)
1430 if (
sizeof($nicht_erfuellt) == 0)
1434 }
else if ($erfuellt >= $min_erfuellt)
1439 return $nicht_erfuellt;
1451 private function lostPassword($email, $lock =
false, $expire =
'') {
1452 if (empty($email)) {
1457 $lock_file = $GLOBALS[
'egotec_conf'][
'tmp_dir'] .
'LOSTPW.LOCK';
1459 $data = unserialize($data);
1465 $db = new_db_connection([
1466 'table' =>
'egotec_user',
1467 'where' =>
'email = :email AND deleted = 0',
1472 while ($db->nextRecord()) {
1474 $user =
new User_SQL($db->Record[
'user_id'], $db->Record);
1475 if (
$user->isInactive()) {
1481 $hash = md5(microtime() . $db->Record[
'user_id']);
1482 $user->extra[
'resetpw'] = [
1483 'expire' => date(
'Y-m-d H:i:s', strtotime($expire)),
1490 $url =
'<a href="' . $url .
'">' . $url .
'</a>';
1494 $user->field[
'email']
1497 ($lang =
$user->extra[
'lang'])
1498 &&
Ego_System::file_exists($template = $GLOBALS[
'egotec_conf'][
'var_dir'].
'lib/mail/auth/lostPassword.'.$lang.
'.xml')
1500 ||
Ego_System::file_exists($template = $GLOBALS[
'egotec_conf'][
'var_dir'].
'lib/mail/auth/lostPassword.de.xml')
1503 require_once
'base/template/Ego_Template_Mail.php';
1504 $mail =
new Ego_Template_Mail(
'file:'.$template);
1505 $mail->addRecipients([
'default' => [
1506 'text' => [
$user->field[
'email']]
1508 $mail->setPlaceholders([
1509 'user' =>
$user->field[
'username'],
1510 'email' =>
$user->field[
'email'],
1511 'anrede' =>
$user->extra[
'anrede'],
1512 'vorname' =>
$user->extra[
'vorname'],
1513 'name' =>
$user->extra[
'name'],
1514 'date' =>
$user->extra[
'resetpw'][
'expire'],
1521 'subject' => $this->
translate(
'Ihre Anfrage zum Zurücksetzen Ihres Passworts'),
1522 'message' => $this->
translate(
'Es wurde eine Anfrage zum Zurücksetzen Ihres Passworts gestellt. Sollten Sie diese Anfrage nicht gestellt haben, ignorieren Sie einfach diese E-Mail.')
1524 . $this->
translate(
'Über folgenden Link können Sie ein neues Passwort erstellen. Dieser Link ist gültig bis %date:', [
'date' =>
$user->extra[
'resetpw'][
'expire']])
1536 if (!isset($data)) {
1543 unset($_REQUEST[
'doauth']);
1554 $db = new_db_connection(
1556 'fields' =>
'group_id',
1557 'table' =>
'egotec_group'
1560 return new Group_Iterator($db);
1570 $db = new_db_connection(
1572 'fields' =>
'role_id',
1573 'table' =>
'egotec_role'
1576 return new Role_Iterator($db);
1586 require_once(
'rights/User_SQL.php');
1587 return new User_SQL($this->_id);
1596 $clear_cache =
false;
1599 $db = new_db_connection(array(
1600 'fields' =>
'egotec_group.group_id AS group_id, egotec_role.role_id AS role_id',
1601 'table' =>
'egotec_user_group',
1602 'where' =>
'egotec_user_group.user_id=:userid',
1604 'egotec_group direct_group ON direct_group.group_id=egotec_user_group.group_id',
1605 'egotec_group ON egotec_group.links>=direct_group.links AND egotec_group.rechts<=direct_group.rechts',
1606 'egotec_role direct_role ON direct_role.role_id=egotec_user_group.role_id',
1607 'egotec_role ON egotec_role.links>=direct_role.links AND egotec_role.rechts<=direct_role.rechts'
1617 $db2 = new_db_connection(array(
1618 'fields' =>
'group_id, role_id',
1619 'table' =>
'egotec_user_group_flat',
1620 'where' =>
'user_id=:userid',
1625 $old_rights = array();
1626 while ($db2->nextRecord()) {
1627 $old_rights[$db2->Record[
'group_id'].
"####".$db2->Record[
'role_id']] = 1;
1635 while ($db->nextRecord()) {
1636 if (empty($old_rights[$db->Record[
'group_id'].
"####".$db->Record[
'role_id']])) {
1637 $db->Record[
'user_id'] = $id;
1639 $db->Record[
'group_id'] !=
'*'
1640 && $db->Record[
'role_id'] !=
'*'
1641 && !empty($db->Record[
'group_id'])
1642 && !empty($db->Record[
'role_id'])
1645 'table' =>
'egotec_user_group_flat',
1646 'set' => $db->Record,
1649 $clear_cache =
true;
1653 $old_rights[$db->Record[
'group_id'].
"####".$db->Record[
'role_id']] = 2;
1659 foreach ($old_rights as $key => $val) {
1660 if ($val == 1 && $key !=
"*####*") {
1661 $rights = explode(
"####", $key);
1663 'table' =>
'egotec_user_group_flat',
1664 'where' =>
'user_id=\''.$id.
'\' AND group_id=\
''.$rights[0].
'\' AND role_id=\
''.$rights[1].
'\'',
1667 $clear_cache =
true;
1672 if (!isset($old_rights[
"*####*"])) {
1674 'table' =>
'egotec_user_group_flat',
1699 require_once
'rights/Group_SQL.php';
1700 $root =
new Group_SQL($GLOBALS[
'egotec_conf'][
'superuser'][
'group']);
1701 foreach ($root->getAllUsers() as
$user) {
1702 if (
$user->hasGroupRoleRelation(
1703 $GLOBALS[
'egotec_conf'][
'superuser'][
'group'],
1704 $GLOBALS[
'egotec_conf'][
'superuser'][
'role']
1718 require_once
'rights/Group_SQL.php';
1719 $root =
new Group_SQL($GLOBALS[
'egotec_conf'][
'superuser'][
'group']);
1720 foreach ($root->getAllUsers() as
$user) {
1722 empty(
$user->field[
'no_admin'])
1723 &&
$user->hasGroupRoleRelation(
1724 $GLOBALS[
'egotec_conf'][
'superuser'][
'group'],
1725 $GLOBALS[
'egotec_conf'][
'superuser'][
'role']
1743 'expire' => (int) $GLOBALS[
'egotec_conf'][
'auth'][
'persist_days'],
1744 'refresh' => isset($GLOBALS[
'egotec_conf'][
'auth'][
'persist_refresh'])
1748 if (isset($GLOBALS[
'site']) && !empty($GLOBALS[
'site']->admin[
'auth'][
'persist_overwrite'])) {
1750 'expire' => (int) $GLOBALS[
'site']->admin[
'auth'][
'persist_days'],
1751 'refresh' => isset($GLOBALS[
'site']->admin[
'auth'][
'persist_refresh'])
1756 $persist_token = sha1(rand() ^ date(
'U'));
1757 $user->extra[
'auth_persist_token'] = $persist_token;
1760 $persist_expire = (int)
$user->extra[
'auth_persist_expire'];
1761 if ($conf[
'refresh'] || !$persist_expire) {
1762 $persist_expire = strtotime(
'+' . ($conf[
'expire'] ?: 30) .
' days');
1763 $user->extra[
'auth_persist_expire'] = $persist_expire;
const CONCURRENT_USERS_LIMIT_TEXT
const LOGIN_REQUIRED_TEXT
const LOST_PASSWORD_DENIED
const LOST_PASSWORD_DENIED_TEXT
const CONCURRENT_USERS_LIMIT
const WRONG_PASSWORD_LIMIT
const TWO_FACTOR_AUTH_ERROR
const NO_MULTIPLE_LOGIN_TEXT
const PERMISSION_DENIED_TEXT
const TWO_FACTOR_AUTH_VERIFY_TEXT
const TWO_FACTOR_AUTH_ERROR_TEXT
const LOST_PASSWORD_SUCCESS_TEXT
const MUST_CHANGE_PASSWORD_TEXT
const LOGIN_TIMED_OUT_TEXT
const WRONG_PASSWORD_LIMIT_TEXT
const INVALID_LOGIN_PARAMETERS_TEXT
const MUST_CHANGE_PASSWORD
const TWO_FACTOR_AUTH_SETUP
const TWO_FACTOR_AUTH_VERIFY
const WRONG_PASSWORD_TEXT
const TWO_FACTOR_AUTH_SETUP_TEXT
const INVALID_LOGIN_PARAMETERS
const INVALID_NEW_PASSWORD
const INVALID_NEW_PASSWORD_TEXT
const PASSWORD_CHANGED_TEXT
const LOST_PASSWORD_SUCCESS
checkSuperuserPermission()
static checkPassword($pwd, $name=0, $return_text=false)
static makeFlatSuperusers()
static getFirstSuperuser()
hasSuperuserPermission($session=true, $recalc=false)
static setAuthPersist(User_SQL $user)
static getUserRecord($user_id)
__construct($force_login=false, $id='', $action='', $param=array())
translate($string, $placeholders=array(), $language=null)
checkPermission($group, $role='', $flag=false)
static getUsers($rights, $users=array(), $direct_flag=false)
hasPermission($group, $role='', $flag=false, $user_id=false, $equal=true)
getPageTableQuery($page_table, $rights, $query=array(), $param=array())
validate($username, $password)
reset($remove_cookie=false)
hasPermissionOn($object, $equal=true)
static clearCacheAllSites()
static file_put_contents($filename, $data, $flags=0, $context=null)
static getProtocol($https=false)
static getIp($anonymized=false)
static removeCookie($name, $expires=-1, $path='/', $cross_domain=true, $secure=false, $httponly=true)
static deldir($location, $del=true, $without='', $rename=true)
static file_exists($file)
static file_get_contents($filename, $utf8=true, $context=null)
static setCookie($name, $value, $expires=0, $path='/', $cross_domain=true, $secure=false, $httponly=true)