26require_once
'./include/Unicode/UtfNormal.php';
62 include_once(
"./Services/Object/classes/class.ilObject.php");
65 return "<img src=\"" .
$filename .
"\" alt=\"" .
$lng->txt(
"obj_" . $a_type) .
"\" title=\"" .
$lng->txt(
"obj_" . $a_type) .
"\" border=\"0\" vspace=\"0\"/>";
82 include_once(
"./Services/Object/classes/class.ilObject.php");
96 public static function getImagePath(
$img, $module_path =
"", $mode =
"output", $offline =
false)
100 $styleDefinition =
null;
101 if (isset(
$DIC[
"styleDefinition"])) {
102 $styleDefinition =
$DIC[
"styleDefinition"];
105 if (is_int(strpos(
$_SERVER[
"PHP_SELF"],
"setup.php"))) {
108 if ($module_path !=
"") {
109 $module_path =
"/" . $module_path;
113 $default_img =
"." . $module_path .
"/templates/default/images/" .
$img;
116 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
120 if (is_object($styleDefinition)) {
121 $image_dir = $styleDefinition->getImageDirectory($current_style);
124 if ($current_skin ==
"default") {
125 $user_img =
"." . $module_path .
"/templates/default/" . $image_dir .
"/" .
$img;
126 $skin_img =
"." . $module_path .
"/templates/default/images/" .
$img;
127 } elseif (is_object($styleDefinition) && $current_skin !=
"default") {
128 $user_img =
"./Customizing/global/skin/" .
129 $current_skin . $module_path .
"/" . $image_dir .
"/" .
$img;
130 $skin_img =
"./Customizing/global/skin/" .
131 $current_skin . $module_path .
"/images/" .
$img;
148 return "./images/" .
$img;
149 } elseif (@file_exists($user_img) && $image_dir !=
"") {
151 } elseif (file_exists($skin_img)) {
170 if (substr($relative_path, 0, 2) ==
'./') {
171 $relative_path = (substr($relative_path, 1));
173 if (substr($relative_path, 0, 1) !=
'/') {
174 $relative_path =
'/' . $relative_path;
176 $htmlpath = ILIAS_HTTP_PATH . $relative_path;
200 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
201 $stylesheet_name = (strlen($a_css_name))
204 if (strlen($a_css_location) && (strcmp(substr($a_css_location, -1),
"/") != 0)) {
205 $a_css_location = $a_css_location .
"/";
210 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
215 $filename =
"./" . $a_css_location .
"templates/default/" . $stylesheet_name;
217 $skin_version_appendix =
"";
218 if ($mode !==
"filesystem") {
221 $skin_version = $skin->getVersion();
222 $skin_version_appendix .= ($skin_version !==
'' ? str_replace(
".",
"-", $skin_version) :
'0');
223 $skin_version_appendix =
"?skin_version=" . $skin_version_appendix;
225 return $filename . $skin_version_appendix;
238 public static function getJSLocation($a_js_name, $a_js_location =
"", $add_version =
false)
245 $js_name = $a_js_name;
246 if (strlen($a_js_location) && (strcmp(substr($a_js_location, -1),
"/") != 0)) {
247 $a_js_location = $a_js_location .
"/";
252 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
257 $filename =
"./" . $a_js_location .
"templates/default/" . $js_name;
271 if (defined(
"ILIAS_MODULE")) {
274 $base .=
"../Services/Privacy/";
277 $base =
"./Services/Privacy/";
280 if (is_file(
$base .
"w3c/p3p.xml")) {
281 return ILIAS_HTTP_PATH .
"w3c/p3p.xml";
283 return ILIAS_HTTP_PATH .
"/w3c/p3p_template.xml";
301 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
310 if (is_file(
"./" . $in_style)) {
313 return "templates/default/delos_cont.css";
340 $direct_text =
false,
350 if ($multiple ==
true) {
351 $multiple =
" multiple=\"multiple\"";
357 $class =
" class=\" form-control " . $style_class .
"\"";
363 if (is_array($attribs)) {
364 foreach ($attribs as $key => $val) {
369 $disabled =
' disabled=\"disabled\"';
374 $size_str =
' size="' .
$size .
'" ';
376 $str =
"<select name=\"" . $varname .
"\"" . $multiple .
" $class " . $size_str .
" $attributes $disabled>\n";
378 foreach ((array) $options as $key => $val) {
380 if (is_array($val)) {
381 $style = $val[
"style"];
385 $sty = ($style !=
"")
386 ?
' style="' . $style .
'" '
390 $str .=
" <option $sty value=\"" . $key .
"\"";
392 $str .=
" <option $sty value=\"" . $val .
"\"";
394 if (is_array($selected)) {
395 if (in_array($key, $selected)) {
396 $str .=
" selected=\"selected\"";
398 } elseif ($selected == $key) {
399 $str .=
" selected=\"selected\"";
403 $str .=
">" . $val .
"</option>\n";
405 $str .=
">" .
$lng->txt($val) .
"</option>\n";
409 $str .=
"</select>\n";
425 return($values[$selected]);
439 public static function formCheckbox($checked, $varname, $value, $disabled =
false)
441 $str =
"<input type=\"checkbox\" name=\"" . $varname .
"\"";
444 $str .=
" checked=\"checked\"";
448 $str .=
" disabled=\"disabled\"";
453 if (substr($varname, -2) ==
"[]") {
459 $varname_id = substr($varname, 0, -2) .
"_" . $value;
461 $varname_id = $varname;
465 $varname_id = str_replace(
"[",
"_", $varname_id);
466 $varname_id = str_replace(
"]",
"", $varname_id);
468 $str .=
" value=\"" . $value .
"\" id=\"" . $varname_id .
"\" />\n";
487 $str =
"<input disabled type=\"radio\" name=\"" . $varname .
"\"";
489 $str =
"<input type=\"radio\" name=\"" . $varname .
"\"";
492 $str .=
" checked=\"checked\"";
495 $str .=
" value=\"" . $value .
"\"";
496 $str .=
" id=\"" . $value .
"\" />\n";
512 public static function formRadioButton($checked, $varname, $value, $onclick =
null, $disabled =
false)
517 $str .= (
'onclick="' . $onclick .
'"');
520 $str .= (
" type=\"radio\" name=\"" . $varname .
"\"");
522 $str .=
" checked=\"checked\"";
526 $str .=
" disabled=\"disabled\"";
529 $str .=
" value=\"" . $value .
"\"";
531 $str .=
" id=\"" . $value .
"\" />\n";
546 public static function formInput($varname, $value, $disabled =
false)
548 $str =
"<input type=\"input\" name=\"" . $varname .
"\"";
553 $str .=
" value=\"" . $value .
"\"";
555 $str .=
" id=\"" . $value .
"\" />\n";
581 if (
"" != $a_path &&
"/" != substr($a_path, -1)) {
623 foreach ($emptyFields as $key => $val) {
625 if ($feedback !=
"") {
659 public static function Linkbar($AScript, $AHits, $ALimit, $AOffset, $AParams = array(), $ALayout = array(), $prefix =
'')
664 $layout_prev =
"<<";
665 $layout_next =
">>";
668 if ((is_array($ALayout) && (count($ALayout) > 0))) {
669 if ($ALayout[
"link"]) {
670 $layout_link =
" class=\"" . $ALayout[
"link"] .
"\"";
673 if ($ALayout[
"prev"]) {
674 $layout_prev = $ALayout[
"prev"];
677 if ($ALayout[
"next"]) {
678 $layout_next = $ALayout[
"next"];
684 if ($AHits > $ALimit || $AOffset > 0) {
685 if (!empty($AParams)) {
686 foreach ($AParams as $key => $value) {
687 $params .= $key .
"=" . $value .
"&";
691 if (strpos($AScript,
'&')) {
692 $link = $AScript .
"&" . $params . $prefix .
"offset=";
694 $link = $AScript .
"?" . $params . $prefix .
"offset=";
699 $prevoffset = $AOffset - $ALimit;
700 if ($prevoffset < 0) {
703 $LinkBar .=
"<a" . $layout_link .
" href=\"" . $link . $prevoffset .
"\">" . $layout_prev .
" </a>";
707 $pages = intval($AHits / $ALimit);
710 if (($AHits % $ALimit)) {
718 for (
$i = 1 ;
$i <= $pages ;
$i++) {
719 $newoffset = $ALimit * (
$i - 1);
721 if ($newoffset == $AOffset) {
722 $LinkBar .=
"[" .
$i .
"] ";
724 $LinkBar .=
'<a ' . $layout_link .
' href="' .
725 $link . $newoffset .
'">[' .
$i .
']</a> ';
732 if (!(($AOffset / $ALimit) == ($pages - 1)) && ($pages != 1)) {
733 $newoffset = $AOffset + $ALimit;
734 $LinkBar .=
"<a" . $layout_link .
" href=\"" . $link . $newoffset .
"\"> " . $layout_next .
"</a>";
760 "/(^|[\s]+)(www\.)([A-Za-z0-9#&=?.\/\-]+)/i",
767 "/(^|[\s]+)(ftp\.)([A-Za-z0-9#&=?.\/\-]+)/i",
777 $ret = str_replace(
'src="http://',
'"***masked_im_start***',
$ret);
779 include_once(
"./Services/Utilities/classes/class.ilMWParserAdapter.php");
780 $global_wgContLang =
$GLOBALS[
"wgContLang"];
783 $ret = $parser->replaceFreeExternalLinks(
$ret);
786 $ret = str_replace(
'"***masked_im_start***',
'src="http://',
$ret);
790 if ($detectGotoLinks) {
792 $regExp =
"<a[^>]*href=\"(" . str_replace(
"/",
"\/", ILIAS_HTTP_PATH) .
"\/goto.php\?target=\w+_(\d+)[^\"]*)\"[^>]*>[^<]*<\/a>";
794 $ret = preg_replace_callback(
795 "/" . $regExp .
"/i",
796 array(
"ilUtil",
"replaceLinkProperties"),
801 $regExp =
"<a[^>]*href=\"(" . str_replace(
"/",
"\/", ILIAS_HTTP_PATH) .
"\/goto_.*[a-z0-9]+_([0-9]+)\.html)\"[^>]*>[^<]*<\/a>";
803 $ret = preg_replace_callback(
804 "/" . $regExp .
"/i",
805 array(
"ilUtil",
"replaceLinkProperties"),
809 $GLOBALS[
"wgContLang"] = $global_wgContLang;
829 $ref_id = $matches[2];
835 $link =
"<a href=" . $matches[1] .
" target=\"_self\">" . $title .
"</a>";
859 public static function makeDateSelect($prefix, $year =
"", $month =
"", $day =
"", $startyear =
"", $a_long_month =
true, $a_further_options = array(), $emptyoption =
false)
866 if (isset($a_further_options[
'disabled']) and $a_further_options[
'disabled']) {
867 $disabled =
'disabled="disabled" ';
872 if (!strlen($year)) {
873 $year = $now[
"year"];
875 if (!strlen($month)) {
876 $month = $now[
"mon"];
884 $month = (int) $month;
889 $sel_day .=
'<select class="form-control" ';
890 if (isset($a_further_options[
'select_attributes'])) {
891 foreach ($a_further_options[
'select_attributes'] as
$name => $value) {
892 $sel_day .= (
$name .
'="' . $value .
'" ');
896 $sel_day .= $disabled .
"name=\"" . $prefix .
"[d]\" id=\"" . $prefix .
"_d\">\n";
899 $sel_day .=
"<option value=\"0\">--</option>\n";
901 for (
$i = 1;
$i <= 31;
$i++) {
902 $sel_day .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
904 $sel_day .=
"</select>\n";
905 $sel_day = preg_replace(
"/(value\=\"$day\")/",
"$1 selected=\"selected\"", $sel_day);
908 $sel_month =
'<select class="form-control" ';
909 if (isset($a_further_options[
'select_attributes'])) {
910 foreach ($a_further_options[
'select_attributes'] as
$name => $value) {
911 $sel_month .= (
$name .
'="' . $value .
'" ');
914 $sel_month .= $disabled .
"name=\"" . $prefix .
"[m]\" id=\"" . $prefix .
"_m\">\n";
917 $sel_month .=
"<option value=\"0\">--</option>\n";
919 for (
$i = 1;
$i <= 12;
$i++) {
921 $sel_month .=
"<option value=\"$i\">" .
$lng->txt(
"month_" . sprintf(
"%02d",
$i) .
"_long") .
"</option>\n";
923 $sel_month .=
"<option value=\"$i\">" .
$i .
"</option>\n";
926 $sel_month .=
"</select>\n";
927 $sel_month = preg_replace(
"/(value\=\"$month\")/",
"$1 selected=\"selected\"", $sel_month);
930 $sel_year =
'<select class="form-control" ';
931 if (isset($a_further_options[
'select_attributes'])) {
932 foreach ($a_further_options[
'select_attributes'] as
$name => $value) {
933 $sel_year .= (
$name .
'="' . $value .
'" ');
936 $sel_year .= $disabled .
"name=\"" . $prefix .
"[y]\" id=\"" . $prefix .
"_y\">\n";
937 if ((strlen($startyear) == 0) || ($startyear > $year)) {
938 if (!$emptyoption || $year != 0) {
939 $startyear = $year - 5;
943 if (($year + 5) < (date(
'Y', time()) + 5)) {
944 $end_year = date(
'Y', time()) + 5;
946 $end_year = $year + 5;
950 $sel_year .=
"<option value=\"0\">----</option>\n";
952 for (
$i = $startyear;
$i <= $end_year;
$i++) {
953 $sel_year .=
"<option value=\"$i\">" . sprintf(
"%04d",
$i) .
"</option>\n";
955 $sel_year .=
"</select>\n";
956 $sel_year = preg_replace(
"/(value\=\"$year\")/",
"$1 selected=\"selected\"", $sel_year);
959 $dateformat =
"d-m-Y";
960 $dateformat = strtolower(preg_replace(
"/\W/",
"", $dateformat));
961 $dateformat = strtolower(preg_replace(
"/(\w)/",
"%%$1", $dateformat));
962 $dateformat = preg_replace(
"/%%d/", $sel_day, $dateformat);
963 $dateformat = preg_replace(
"/%%m/", $sel_month, $dateformat);
964 $dateformat = preg_replace(
"/%%y/", $sel_year, $dateformat);
986 public static function makeTimeSelect($prefix, $short =
true, $hour =
"", $minute =
"", $second =
"", $a_use_default =
true, $a_further_options = array())
995 if (count($a_further_options)) {
996 if (isset($a_further_options[
'minute_steps'])) {
997 $minute_steps = $a_further_options[
'minute_steps'];
999 if (isset($a_further_options[
'disabled']) and $a_further_options[
'disabled']) {
1000 $disabled =
'disabled="disabled" ';
1004 if ($a_use_default and !strlen(
"$hour$minute$second")) {
1010 $hour = (int) $hour;
1011 $minute = (int) $minute;
1012 $second = (int) $second;
1015 $sel_hour =
'<select ';
1016 if (isset($a_further_options[
'select_attributes'])) {
1017 foreach ($a_further_options[
'select_attributes'] as
$name => $value) {
1018 $sel_hour .=
$name .
'=' . $value .
' ';
1021 $sel_hour .=
" " . $disabled .
"name=\"" . $prefix .
"[h]\" id=\"" . $prefix .
"_h\" class=\"form-control\">\n";
1024 for (
$i = 0;
$i <= 23;
$i++) {
1026 $sel_hour .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
1028 $sel_hour .=
"<option value=\"$i\">" . date(
"ga", mktime(
$i, 0, 0)) .
"</option>\n";
1031 $sel_hour .=
"</select>\n";
1032 $sel_hour = preg_replace(
"/(value\=\"$hour\")/",
"$1 selected=\"selected\"", $sel_hour);
1035 $sel_minute .=
"<select " . $disabled .
"name=\"" . $prefix .
"[m]\" id=\"" . $prefix .
"_m\" class=\"form-control\">\n";
1037 for (
$i = 0;
$i <= 59;
$i =
$i + $minute_steps) {
1038 $sel_minute .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
1040 $sel_minute .=
"</select>\n";
1041 $sel_minute = preg_replace(
"/(value\=\"$minute\")/",
"$1 selected=\"selected\"", $sel_minute);
1045 $sel_second .=
"<select " . $disabled .
"name=\"" . $prefix .
"[s]\" id=\"" . $prefix .
"_s\" class=\"form-control\">\n";
1047 for (
$i = 0;
$i <= 59;
$i++) {
1048 $sel_second .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
1050 $sel_second .=
"</select>\n";
1051 $sel_second = preg_replace(
"/(value\=\"$second\")/",
"$1 selected=\"selected\"", $sel_second);
1053 $timeformat =
$lng->text[
"lang_timeformat"];
1054 if (strlen($timeformat) == 0) {
1055 $timeformat =
"H:i:s";
1057 $timeformat = strtolower(preg_replace(
"/\W/",
"", $timeformat));
1058 $timeformat = preg_replace(
"/(\w)/",
"%%$1", $timeformat);
1059 $timeformat = preg_replace(
"/%%h/", $sel_hour, $timeformat);
1060 $timeformat = preg_replace(
"/%%i/", $sel_minute, $timeformat);
1062 $timeformat = preg_replace(
"/%%s/",
"", $timeformat);
1064 $timeformat = preg_replace(
"/%%s/", $sel_second, $timeformat);
1084 if (
null === $a_email || !is_string($a_email)) {
1088 if ($mailAddressParserFactory ===
null) {
1093 $parser = $mailAddressParserFactory->getParser((
string) $a_email);
1094 $addresses = $parser->parse();
1109 public static function isPassword($a_passwd, &$customError =
null)
1115 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1119 if (empty($a_passwd)) {
1120 $customError =
$lng->txt(
'password_empty');
1128 if ($security->getPasswordMinLength() > 0 && strlen($a_passwd) < $security->getPasswordMinLength()) {
1129 $errors[] = sprintf(
$lng->txt(
'password_to_short'), $security->getPasswordMinLength());
1130 $isPassword =
false;
1135 if ($security->getPasswordMaxLength() > 0 && strlen($a_passwd) > $security->getPasswordMaxLength()) {
1136 $errors[] = sprintf(
$lng->txt(
'password_to_long'), $security->getPasswordMaxLength());
1137 $isPassword =
false;
1141 if ($security->isPasswordCharsAndNumbersEnabled()) {
1142 $hasCharsAndNumbers =
true;
1145 if (!preg_match(
'/[A-Za-z]+/', $a_passwd)) {
1146 $hasCharsAndNumbers =
false;
1150 if (!preg_match(
'/[0-9]+/', $a_passwd)) {
1151 $hasCharsAndNumbers =
false;
1154 if (!$hasCharsAndNumbers) {
1155 $errors[] =
$lng->txt(
'password_must_chars_and_numbers');
1156 $isPassword =
false;
1160 require_once
'Services/Utilities/classes/class.ilStr.php';
1161 if ($security->getPasswordNumberOfUppercaseChars() > 0) {
1162 if (
ilStr::strLen($a_passwd) -
ilStr::strLen(preg_replace(
'/[A-Z]/',
'', $a_passwd)) < $security->getPasswordNumberOfUppercaseChars()) {
1163 $errors[] = sprintf(
$lng->txt(
'password_must_contain_ucase_chars'), $security->getPasswordNumberOfUppercaseChars());
1164 $isPassword =
false;
1168 if ($security->getPasswordNumberOfLowercaseChars() > 0) {
1169 if (
ilStr::strLen($a_passwd) -
ilStr::strLen(preg_replace(
'/[a-z]/',
'', $a_passwd)) < $security->getPasswordNumberOfLowercaseChars()) {
1170 $errors[] = sprintf(
$lng->txt(
'password_must_contain_lcase_chars'), $security->getPasswordNumberOfLowercaseChars());
1171 $isPassword =
false;
1176 if ($security->isPasswordSpecialCharsEnabled()) {
1178 if (!preg_match(self::getPasswordValidChars(
true,
true), $a_passwd)) {
1179 $errors[] =
$lng->txt(
'password_must_special_chars');
1180 $isPassword =
false;
1185 if (!preg_match(self::getPasswordValidChars(), $a_passwd)) {
1186 $errors[] =
$lng->txt(
'password_contains_invalid_chars');
1187 $isPassword =
false;
1193 } elseif (count(
$errors) > 1) {
1194 $customError =
$lng->txt(
'password_multiple_errors');
1195 $customError .=
'<br />' . implode(
'<br />',
$errors);
1209 include_once
'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
1214 if (is_string($user)) {
1216 } elseif (is_array($user)) {
1219 $userId = $user[
'id'];
1221 $login = $user->getLogin();
1222 $userId = $user->getId();
1227 if (
$login && (
int) $security->getPasswordMustNotContainLoginnameStatus() &&
1228 strpos(strtolower($clear_text_password), strtolower(
$login)) !==
false
1230 $error_language_variable =
'password_contains_parts_of_login_err';
1247 if ($a_only_special_chars) {
1248 return '/[_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+/';
1250 return '/^[A-Za-z0-9_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+$/';
1253 return 'A-Z a-z 0-9 _.+?#-*@!$%~/:;';
1270 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1273 $infos = array(sprintf(
$lng->txt(
'password_allow_chars'), self::getPasswordValidChars(
false)));
1276 if ($security->getPasswordMinLength() > 0) {
1277 $infos[] = sprintf(
$lng->txt(
'password_to_short'), $security->getPasswordMinLength());
1281 if ($security->getPasswordMaxLength() > 0) {
1282 $infos[] = sprintf(
$lng->txt(
'password_to_long'), $security->getPasswordMaxLength());
1286 if ($security->isPasswordCharsAndNumbersEnabled()) {
1287 $infos[] =
$lng->txt(
'password_must_chars_and_numbers');
1291 if ($security->isPasswordSpecialCharsEnabled()) {
1292 $infos[] =
$lng->txt(
'password_must_special_chars');
1295 if ($security->getPasswordNumberOfUppercaseChars() > 0) {
1296 $infos[] = sprintf(
$lng->txt(
'password_must_contain_ucase_chars'), $security->getPasswordNumberOfUppercaseChars());
1299 if ($security->getPasswordNumberOfLowercaseChars() > 0) {
1300 $infos[] = sprintf(
$lng->txt(
'password_must_contain_lcase_chars'), $security->getPasswordNumberOfLowercaseChars());
1303 return implode(
'<br />', $infos);
1314 if (empty($a_login)) {
1318 if (strlen($a_login) < 3) {
1325 if (!preg_match(
"/^[A-Za-z0-9_\.\+\*\@!\$\%\~\-]+$/", $a_login)) {
1349 $a_next_blank =
false,
1350 $a_keep_extension =
false
1352 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1354 if ($a_next_blank) {
1364 if ($a_keep_extension) {
1365 $p = strrpos($a_str,
'.');
1367 if ($p ===
false || $p == 0 || strlen($a_str) - $p > $a_len) {
1370 $a_str .=
"\xe2\x80\xa6";
1374 $a_str =
ilStr::subStr($a_str, 0, $len - (strlen($a_str) - $p + 1)) .
"\xe2\x80\xa6" . substr($a_str, $p);
1376 $a_str =
ilStr::subStr($a_str, 0, $len - (strlen($a_str) - $p + 1)) . substr($a_str, $p);
1399 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1400 $str_arr = explode(
" ", $a_str);
1402 for (
$i = 0;
$i < count($str_arr);
$i++) {
1406 $str_arr[
$i] .=
"...";
1411 return implode(
" ", $str_arr);
1426 while (is_int(strpos($a_str,
"="))) {
1427 $eq_pos = strpos($a_str,
"=");
1428 $qu1_pos = strpos($a_str,
"\"");
1429 $qu2_pos = strpos(substr($a_str, $qu1_pos + 1),
"\"") + $qu1_pos + 1;
1430 if (is_int($eq_pos) && is_int($qu1_pos) && is_int($qu2_pos)) {
1431 $var = trim(substr($a_str, 0, $eq_pos));
1432 $val = trim(substr($a_str, $qu1_pos + 1, ($qu2_pos - $qu1_pos) - 1));
1433 $attribs[$var] = $val;
1434 $a_str = substr($a_str, $qu2_pos + 1);
1460 public static function rCopy($a_sdir, $a_tdir, $preserveTimeAttributes =
false)
1462 $sourceFS = LegacyPathHelper::deriveFilesystemFrom($a_sdir);
1463 $targetFS = LegacyPathHelper::deriveFilesystemFrom($a_tdir);
1465 $sourceDir = LegacyPathHelper::createRelativePath($a_sdir);
1466 $targetDir = LegacyPathHelper::createRelativePath($a_tdir);
1469 if (!$sourceFS->hasDir($sourceDir)) {
1473 $sourceList = $sourceFS->listContents($sourceDir,
true);
1475 foreach ($sourceList as $item) {
1476 if ($item->isDir()) {
1480 $itemPath = $targetDir .
'/' . substr($item->getPath(), strlen($sourceDir));
1481 $stream = $sourceFS->readStream($item->getPath());
1482 $targetFS->writeStream($itemPath, $stream);
1509 if ($mode ==
"filesystem") {
1512 if (defined(
"ILIAS_MODULE")) {
1546 include_once(
"./Services/User/classes/class.ilObjUser.php");
1547 return ilObjUser::_getUsersOnline($a_user_id);
1560 if ($a_temp_path ===
null) {
1563 $temp_path = $a_temp_path;
1566 if (!is_dir($temp_path)) {
1569 $temp_name = $temp_path .
"/" . uniqid(
"tmp");
1595 string $path_to_zip_file,
1596 bool $overwrite_existing =
false,
1597 bool $unpack_flat =
false
1603 if (!is_file($path_to_zip_file)) {
1610 copy($path_to_zip_file, $temporary_unzip_directory . DIRECTORY_SEPARATOR . basename($path_to_zip_file));
1611 $original_path_to_zip_file = $path_to_zip_file;
1612 $path_to_zip_file = $temporary_unzip_directory . DIRECTORY_SEPARATOR . basename($path_to_zip_file);
1613 $original_zip_path_info = pathinfo($original_path_to_zip_file);
1614 $unzippable_zip_path_info = pathinfo($path_to_zip_file);
1616 $unzippable_zip_directory = $unzippable_zip_path_info[
"dirname"];
1617 $unzippable_zip_filename = $unzippable_zip_path_info[
"basename"];
1620 $current_directory = getcwd();
1621 chdir($unzippable_zip_directory);
1622 $unzip_command = PATH_TO_UNZIP;
1625 if (!$overwrite_existing) {
1632 chdir($current_directory);
1638 $dir_realpath = realpath($unzippable_zip_directory);
1639 foreach (
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($unzippable_zip_directory)) as
$name =>
$f) {
1640 if (is_link(
$name)) {
1641 $target = readlink(
$name);
1642 if (substr($target, 0, strlen($dir_realpath)) != $dir_realpath) {
1650 rename(
$name, $new_name);
1660 $target_dir_name = $original_zip_path_info[
"dirname"];
1661 $target_dir_name = realpath($target_dir_name);
1665 if (is_array($file_array[
"file"])) {
1666 foreach ($file_array[
"file"] as $k =>
$f) {
1668 substr(
$f, 0, 1) !==
"."
1669 &&
$f !== basename($original_path_to_zip_file)
1672 $file_array[
"path"][$k] .
$f,
1673 $target_dir_name . DIRECTORY_SEPARATOR .
$f
1679 $target_directory = $target_dir_name;
1681 $temporary_unzip_directory,
1695 public static function zip($a_dir, $a_file, $compress_content =
false)
1699 if ($compress_content) {
1701 $pathinfo = pathinfo($a_dir);
1702 chdir($pathinfo[
"dirname"]);
1705 $pathinfo = pathinfo($a_file);
1706 $dir = $pathinfo[
"dirname"];
1707 $file = $pathinfo[
"basename"];
1709 if (!$compress_content) {
1720 if (is_array($a_dir)) {
1722 foreach ($a_dir as $dir) {
1723 $name = basename($dir);
1727 $name = basename($a_dir);
1728 if (trim(
$name) !=
"*") {
1745 $pathinfo = pathinfo($a_dir);
1746 chdir($pathinfo[
"dirname"]);
1748 $pathinfo = pathinfo($a_file);
1749 $dir = $pathinfo[
"dirname"];
1750 $file = $pathinfo[
"basename"];
1753 $mkisofs = PATH_TO_MKISOFS;
1759 $name = basename($a_dir);
1762 $zipcmd =
"-r -J -o " . $a_file .
" " .
$source;
1778 return PATH_TO_CONVERT;
1805 if ($current_version >= $version) {
1819 if (preg_match(
"/([0-9]+)\.([0-9]+)\.([0-9]+)([\.|\-]([0-9]+))?/", $a_version, $match)) {
1820 $version = str_pad($match[1], 2, 0, STR_PAD_LEFT) .
1821 str_pad($match[2], 2, 0, STR_PAD_LEFT) .
1822 str_pad($match[3], 2, 0, STR_PAD_LEFT) .
1823 str_pad($match[5], 2, 0, STR_PAD_LEFT);
1824 return (
int) $version;
1840 $a_target_format =
"",
1842 $a_background_color =
""
1844 $format_str = ($a_target_format !=
"")
1845 ? strtoupper($a_target_format) .
":"
1848 if ($a_geometry !=
"") {
1849 if (is_int(strpos($a_geometry,
"x"))) {
1850 $geometry =
" -geometry " . $a_geometry .
" ";
1852 $geometry =
" -geometry " . $a_geometry .
"x" . $a_geometry .
" ";
1856 $bg_color = ($a_background_color !=
"")
1857 ?
" -background color " . $a_background_color .
" "
1874 public static function resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop =
false)
1876 if ($a_constrain_prop) {
1877 $size =
" -geometry " . $a_width .
"x" . $a_height .
" ";
1879 $size =
" -resize " . $a_width .
"x" . $a_height .
"! ";
1892 public static function img($a_src, $a_alt =
null, $a_width =
"", $a_height =
"", $a_border = 0, $a_id =
"", $a_class =
"")
1894 $img =
'<img src="' . $a_src .
'"';
1895 if (!is_null($a_alt)) {
1896 $img .=
' alt="' . htmlspecialchars($a_alt) .
'"';
1898 if ($a_width !=
"") {
1899 $img .=
' width="' . htmlspecialchars($a_width) .
'"';
1901 if ($a_height !=
"") {
1902 $img .=
' height="' . htmlspecialchars($a_height) .
'"';
1904 if ($a_class !=
"") {
1905 $img .=
' class="' . $a_class .
'"';
1908 $img .=
' id="' . $a_id .
'"';
1921 public static function deliverData($a_data, $a_filename, $mime =
"application/octet-stream", $charset =
"")
1923 $disposition =
"attachment";
1926 include_once
'./Services/Http/classes/class.ilHTTPS.php';
1935 #header("Pragma: ");
1936 #header("Cache-Control: ");
1937 #header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
1938 #header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
1939 #header("Cache-Control: no-store, no-cache, must-revalidate");
1940 #header("Cache-Control: post-check=0, pre-check=0", false);
1941 } elseif ($disposition ==
"attachment") {
1942 header(
"Cache-control: private");
1944 header(
"Cache-Control: no-cache, must-revalidate");
1945 header(
"Pragma: no-cache");
1950 if (strlen($charset)) {
1951 $charset =
"; charset=$charset";
1953 header(
"Content-Type: $mime$charset");
1954 header(
"Content-Disposition:$disposition; filename=\"" .
$ascii_filename .
"\"");
1956 header(
"Content-Length: " . (
string) (strlen($a_data)));
1960 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
1961 header(
'Pragma: public');
1964 header(
"Connection: close");
1981 $removeAfterDelivery =
false,
1982 $a_exit_after =
true
1986 if (!file_exists($a_file)) {
1997 if (strlen($a_mime)) {
1998 $delivery->setMimeType($a_mime);
2001 $delivery->setDownloadFileName($a_filename);
2002 $delivery->setConvertFileNameToAsci((
bool) !
$DIC->clientIni()->readVariable(
'file_access',
'disable_ascii'));
2003 $delivery->setDeleteFile($removeAfterDelivery);
2004 $delivery->deliver();
2019 $chunksize = 1 * (1024 * 1024);
2021 $handle = fopen($a_file,
'rb');
2022 if ($handle ===
false) {
2025 while (!feof($handle)) {
2026 $buffer = fread($handle, $chunksize);
2029 return fclose($handle);
2073 foreach ($umlauts as $src => $tgt) {
2074 $a_filename = str_replace($src, $tgt, $a_filename);
2095 $sep =
'###HTMLTAG###';
2097 preg_match_all(
"@<[^>]*>@", $htmlText, $matches);
2098 $tmp = preg_replace(
"@(<[^>]*>)@", $sep, $htmlText);
2099 $tmp = explode($sep, $tmp);
2101 for (
$i = 0;
$i < count($tmp);
$i++) {
2102 $tmp[
$i] = htmlentities($tmp[
$i], ENT_COMPAT,
"UTF-8");
2105 $tmp = join($sep, $tmp);
2107 for (
$i = 0;
$i < count($matches[0]);
$i++) {
2108 $tmp = preg_replace(
"@$sep@", $matches[0][
$i], $tmp, 1);
2122 return PATH_TO_JAVA;
2141 $url = (is_int(strpos($a_url,
"?")))
2142 ? $a_url . $amp . $a_par
2143 : $a_url .
"?" . $a_par;
2168 $a_dir = trim($a_dir);
2171 if (substr($a_dir, -1) ==
"/") {
2172 $a_dir = substr($a_dir, 0, -1);
2176 if (!($path = substr($a_dir, 0, strrpos($a_dir,
"/") - strlen($a_dir)))) {
2182 return @mkdir($a_dir, fileperms($path));
2207 $dirs = array($a_dir);
2208 $a_dir = dirname($a_dir);
2211 while ($last_dirname != $a_dir) {
2212 array_unshift($dirs, $a_dir);
2213 $last_dirname = $a_dir;
2214 $a_dir = dirname($a_dir);
2218 $reverse_paths = array_reverse($dirs,
true);
2220 foreach ($reverse_paths as $key => $value) {
2221 if ($found_index == -1) {
2222 if (is_dir($value)) {
2223 $found_index = $key;
2229 foreach ($dirs as $dirindex => $dir) {
2231 if ($dirindex >= $found_index) {
2232 if (!file_exists($dir)) {
2233 if (strcmp(substr($dir, strlen($dir) - 1, 1),
"/") == 0) {
2236 $dir = substr($dir, 0, strlen($dir) - 1);
2238 if (!mkdir($dir, $umask)) {
2239 error_log(
"Can't make directory: $dir");
2242 } elseif (!is_dir($dir)) {
2243 error_log(
"$dir is not a directory");
2247 $umask = fileperms($dir);
2270 public static function delDir($a_dir, $a_clean_only =
false)
2272 if (!is_dir($a_dir) || is_int(strpos($a_dir,
".."))) {
2276 $current_dir = opendir($a_dir);
2285 while ($entryname = readdir($current_dir)) {
2286 $files[] = $entryname;
2289 foreach ($files as $file) {
2290 if (is_dir($a_dir .
"/" . $file) and ($file !=
"." and $file !=
"..")) {
2292 } elseif ($file !=
"." and $file !=
"..") {
2293 unlink($a_dir .
"/" . $file);
2297 closedir($current_dir);
2298 if (!$a_clean_only) {
2319 public static function getDir($a_dir, $a_rec =
false, $a_sub_dir =
"")
2321 $current_dir = opendir($a_dir . $a_sub_dir);
2325 $subitems = array();
2326 while ($entry = readdir($current_dir)) {
2327 if (is_dir($a_dir .
"/" . $entry)) {
2328 $dirs[$entry] = array(
"type" =>
"dir",
"entry" => $entry,
2329 "subdir" => $a_sub_dir);
2330 if ($a_rec && $entry !=
"." && $entry !=
"..") {
2332 $subitems = array_merge($subitems,
$si);
2335 if ($entry !=
"." && $entry !=
"..") {
2336 $size = filesize($a_dir . $a_sub_dir .
"/" . $entry);
2337 $files[$entry] = array(
"type" =>
"file",
"entry" => $entry,
2338 "size" =>
$size,
"subdir" => $a_sub_dir);
2345 return array_merge($dirs, $files, $subitems);
2356 if (is_array($a_arr)) {
2357 foreach ($a_arr as $k => $v) {
2371 $df = new \ILIAS\Data\Factory;
2373 return $df->clientId($clientId);
2384 if (is_array($a_data)) {
2385 foreach ($a_data as $k => $v) {
2406 public static function stripSlashes($a_str, $a_strip_html =
true, $a_allow =
"")
2408 if (ini_get(
"magic_quotes_gpc")) {
2409 $a_str = stripslashes($a_str);
2425 if (ini_get(
"magic_quotes_gpc")) {
2426 $a_str = stripslashes($a_str);
2438 public static function secureString($a_str, $a_strip_html =
true, $a_allow =
"")
2441 $only_secure =
true;
2442 $allow_tags = explode(
">", $a_allow);
2444 $allow_array = array();
2445 foreach ($allow_tags as $allow) {
2447 $allow = str_replace(
"<",
"", $allow);
2449 if (!in_array($allow, $sec_tags)) {
2450 $only_secure =
false;
2452 $allow_array[] = $allow;
2457 if (($only_secure || $a_allow ==
"") && $a_strip_html) {
2458 if ($a_allow ==
"") {
2459 $allow_array = array(
"b",
"i",
"strong",
"em",
"code",
"cite",
2460 "gap",
"sub",
"sup",
"pre",
"strike",
"bdo");
2466 $a_str = strip_tags($a_str);
2478 if ($a_strip_html) {
2488 return array(
"strong",
"em",
"u",
"strike",
"ol",
"li",
"ul",
"p",
"div",
2489 "i",
"b",
"code",
"sup",
"sub",
"pre",
"gap",
"a",
"img",
"bdo");
2494 foreach ($allow_array as $t) {
2507 array(
"param" =>
"align",
"value" =>
"left"),
2508 array(
"param" =>
"align",
"value" =>
"center"),
2509 array(
"param" =>
"align",
"value" =>
"justify"),
2510 array(
"param" =>
"align",
"value" =>
"right")
2525 foreach ($allow_array as $t) {
2538 array(
"param" =>
"align",
"value" =>
"left"),
2539 array(
"param" =>
"align",
"value" =>
"center"),
2540 array(
"param" =>
"align",
"value" =>
"justify"),
2541 array(
"param" =>
"align",
"value" =>
"right")
2563 if (ini_get(
"magic_quotes_gpc")) {
2564 return stripslashes($a_str);
2589 if ($a_make_links_clickable) {
2606 $numberOfMatches = preg_match_all(
'/(?:(?:http|https|ftp|ftps|mailto):|www\.)(?:[a-zA-Z0-9]|[;\/?:|&=+$,]|[\\-_.!~*\'()]|%[0-9a-fA-F]{2}|#|[;?:@&=+$,])+/', $a_str, $matches, PREG_OFFSET_CAPTURE);
2610 foreach ($matches[0] as $match) {
2611 $matched_text = $match[0];
2615 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1, $pos2 - $pos1)));
2621 $pos1 = $pos2 + strlen($matched_text);
2623 if ($pos1 < strlen($a_str)) {
2624 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1)));
2627 $encoded = nl2br(htmlspecialchars($a_str));
2637 $ilLog =
$DIC[
"ilLog"];
2640 $att = $ws .
"[^>]*" . $ws;
2643 '/<(' . $tag . $att .
'(' . $tag_att . $ws .
'="' . $ws .
'(([$@!*()~;,_0-9A-z\/:=%.&#?+\-])*)")' . $att .
')>/i',
2648 $a_str = preg_replace(
2649 "/<" . preg_quote($found[1],
"/") .
">/i",
2650 '<' . $tag .
' ' . $tag_att . $tag_att .
'="' . $found[3] .
'">',
2653 if ($old_str == $a_str) {
2654 $ilLog->write(
"ilUtil::maskA-" . htmlentities($old_str) .
" == " .
2655 htmlentities($a_str));
2659 $a_str = str_ireplace(
2671 $ilLog =
$DIC[
"ilLog"];
2674 '/<(' . $tag .
' ' . $tag_att . $tag_att .
'="(([$@!*()~;,_0-9A-z\/:=%.&#?+\-])*)")>/i',
2679 $a_str = preg_replace(
2680 "/<" . preg_quote($found[1],
"/") .
">/i",
2684 if ($old_str == $a_str) {
2685 $ilLog->write(
"ilUtil::unmaskA-" . htmlentities($old_str) .
" == " .
2686 htmlentities($a_str));
2690 $a_str = str_replace(
'</' . $tag .
'>',
'</' . $tag .
'>', $a_str);
2694 public static function maskTag($a_str, $t, $fix_param =
"")
2696 $a_str = str_replace(
2697 array(
"<$t>",
"<" . strtoupper($t) .
">"),
2698 "<" . $t .
">",
2701 $a_str = str_replace(
2702 array(
"</$t>",
"</" . strtoupper($t) .
">"),
2703 "</" . $t .
">",
2707 if (is_array($fix_param)) {
2708 foreach ($fix_param as $p) {
2711 $a_str = str_replace(
2713 "<" .
"$t $k=\"$v\"" .
">",
2722 public static function unmaskTag($a_str, $t, $fix_param =
"")
2724 $a_str = str_replace(
"<" . $t .
">",
"<" . $t .
">", $a_str);
2725 $a_str = str_replace(
"</" . $t .
">",
"</" . $t .
">", $a_str);
2727 if (is_array($fix_param)) {
2728 foreach ($fix_param as $p) {
2731 $a_str = str_replace(
2732 "<$t $k=\"$v\">",
2733 "<" .
"$t $k=\"$v\"" .
">",
2743 $a_str = str_ireplace(
"javascript",
"jvscrpt", $a_str);
2744 $a_str = str_ireplace(array(
"%00",
"%0a",
"%0d",
"%1a",
"�",
"�",
2745 "�",
"�",
"
",
"
",
" ",
" "),
"-", $a_str);
2766 $negativestr =
"a,abbr,acronym,address,applet,area,base,basefont," .
2767 "big,blockquote,body,br,button,caption,center,cite,code,col," .
2768 "colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame," .
2769 "frameset,h1,h2,h3,h4,h5,h6,head,hr,html,i,iframe,img,input,ins,isindex,kbd," .
2770 "label,legend,li,link,map,menu,meta,noframes,noscript,object,ol," .
2771 "optgroup,option,p,param,q,s,samp,script,select,small,span," .
2772 "strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead," .
2773 "title,tr,tt,u,ul,var";
2774 $a_allow = strtolower($a_allow);
2775 $negatives = explode(
",", $negativestr);
2776 $outer_old_str =
"";
2777 while ($outer_old_str != $a_str) {
2778 $outer_old_str = $a_str;
2779 foreach ($negatives as $item) {
2780 $pos = strpos($a_allow,
"<$item>");
2783 if ($pos ===
false) {
2785 while ($old_str != $a_str) {
2787 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s*>/i",
"", $a_str);
2788 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s+([^>]*)>/i",
"", $a_str);
2796 $a_str = preg_replace(
"/<\s*\w*(\/?)(\s+[^>]*)?(\s+on[^>]*)>/i",
"", $a_str);
2799 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*javascript[^>]*>/i",
"", $a_str);
2803 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*expression[^>]*>/i",
"", $a_str);
2825 $a_str = htmlspecialchars($a_str);
2829 $a_str = str_replace(
"{",
"{", $a_str);
2830 $a_str = str_replace(
"}",
"}", $a_str);
2846 if (filter_var(
$url, FILTER_VALIDATE_URL) ===
false &&
2847 filter_var(
"http://" .
$url, FILTER_VALIDATE_URL) ===
false &&
2848 filter_var(
"http:" .
$url, FILTER_VALIDATE_URL) ===
false &&
2849 filter_var(
"http://de.de" .
$url, FILTER_VALIDATE_URL) ===
false &&
2850 filter_var(
"http://de.de/" .
$url, FILTER_VALIDATE_URL) ===
false) {
2853 if (trim(strtolower(parse_url(
$url, PHP_URL_SCHEME))) ==
"javascript") {
2856 $url = htmlspecialchars(
$url, ENT_QUOTES);
2873 return addslashes($a_str);
2891 while (($spos = strpos($a_parstr,
"=")) &&
$ok) {
2893 $cpar = substr($a_parstr, 0, $spos);
2894 $a_parstr = substr($a_parstr, $spos, strlen($a_parstr) - $spos);
2895 while (substr($cpar, 0, 1) ==
"," || substr($cpar, 0, 1) ==
" " || substr($cpar, 0, 1) == chr(13) || substr($cpar, 0, 1) == chr(10)) {
2896 $cpar = substr($cpar, 1, strlen($cpar) - 1);
2898 while (substr($cpar, strlen($cpar) - 1, 1) ==
" " || substr($cpar, strlen($cpar) - 1, 1) == chr(13) || substr($cpar, strlen($cpar) - 1, 1) == chr(10)) {
2899 $cpar = substr($cpar, 0, strlen($cpar) - 1);
2904 while ($cpar != $cpar_old) {
2906 $cpar = preg_replace(
"/[^a-zA-Z0-9_]/i",
"", $cpar);
2911 if ($spos = strpos($a_parstr,
"\"")) {
2912 $a_parstr = substr($a_parstr, $spos + 1, strlen($a_parstr) - $spos);
2913 $spos = strpos($a_parstr,
"\"");
2914 if (is_int($spos)) {
2915 $cval = substr($a_parstr, 0, $spos);
2916 $par[$cpar] = $cval;
2917 $a_parstr = substr($a_parstr, $spos + 1, strlen($a_parstr) - $spos - 1);
2936 if (is_array($a_par_arr)) {
2938 foreach ($a_par_arr as $par => $val) {
2955 $ret = $a_str .
": ";
2956 for (
$i = 0;
$i < strlen($a_str);
$i++) {
2957 $ret .= ord(substr($a_str,
$i, 1)) .
" ";
2971 if (strtolower($a_yn) ==
"y") {
3005 global $array_sortby,$array_sortorder;
3007 if (!isset($array_sortby)) {
3014 if ($array_sortorder ==
"asc") {
3018 if ($array_sortorder ==
"desc") {
3036 global $array_sortby,$array_sortorder;
3038 if ($array_sortorder ==
"asc") {
3039 return $a[
"$array_sortby"] >
$b[
"$array_sortby"];
3042 if ($array_sortorder ==
"desc") {
3043 return $a[
"$array_sortby"] <
$b[
"$array_sortby"];
3061 $a_array_sortorder = 0,
3063 $a_keep_keys =
false
3065 include_once(
"./Services/Utilities/classes/class.ilStr.php");
3067 if (!$a_keep_keys) {
3068 return self::stableSortArray($array, $a_array_sortby, $a_array_sortorder, $a_numeric, $a_keep_keys);
3071 global $array_sortby,$array_sortorder;
3072 $array_sortby = $a_array_sortby;
3074 if ($a_array_sortorder ==
"desc") {
3075 $array_sortorder =
"desc";
3077 $array_sortorder =
"asc";
3081 uasort($array, array(
"ilUtil",
"sort_func_numeric"));
3083 usort($array, array(
"ilUtil",
"sort_func_numeric"));
3087 uasort($array, array(
"ilUtil",
"sort_func"));
3089 usort($array, array(
"ilUtil",
"sort_func"));
3111 public static function stableSortArray($array, $a_array_sortby, $a_array_sortorder = 0, $a_numeric =
false)
3113 global $array_sortby,$array_sortorder;
3115 $array_sortby = $a_array_sortby;
3117 if ($a_array_sortorder ==
"desc") {
3118 $array_sortorder =
"desc";
3120 $array_sortorder =
"asc";
3124 $sort_array = array_values($array);
3135 public static function mergesort(&$array, $cmp_function =
'strcmp')
3138 if (count($array) < 2) {
3143 $halfway = count($array) / 2;
3144 $array1 = array_slice($array, 0, $halfway);
3145 $array2 = array_slice($array, $halfway);
3152 if (call_user_func($cmp_function, end($array1), $array2[0]) < 1) {
3153 $array = array_merge($array1, $array2);
3160 while ($ptr1 < count($array1) && $ptr2 < count($array2)) {
3161 if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1) {
3162 $array[] = $array1[$ptr1++];
3164 $array[] = $array2[$ptr2++];
3169 while ($ptr1 < count($array1)) {
3170 $array[] = $array1[$ptr1++];
3172 while ($ptr2 < count($array2)) {
3173 $array[] = $array2[$ptr2++];
3193 $existing_sub_key_values = array();
3195 foreach ($array as $key => $sub_array) {
3196 if (!in_array($sub_array[$sub_key], $existing_sub_key_values)) {
3197 $existing_sub_key_values[] = $sub_array[$sub_key];
3198 $target[$key] = $sub_array;
3217 $a_desired_type = strtolower($a_desired_type);
3219 $im_types = ImageTypes();
3221 switch ($a_desired_type) {
3224 if ($im_types & IMG_JPG) {
3227 if ($im_types & IMG_GIF) {
3230 if ($im_types & IMG_PNG) {
3236 if ($im_types & IMG_GIF) {
3239 if ($im_types & IMG_JPG) {
3242 if ($im_types & IMG_PNG) {
3248 if ($im_types & IMG_PNG) {
3251 if ($im_types & IMG_JPG) {
3254 if ($im_types & IMG_GIF) {
3260 if ($im_types & IMG_PNG) {
3263 if ($im_types & IMG_JPG) {
3266 if ($im_types & IMG_GIF) {
3286 if (($a_mime ==
"image/gif") || ($a_mime ==
"image/jpeg") ||
3287 ($a_mime ==
"image/png") || ($a_mime ==
"application/x-shockwave-flash") ||
3288 ($a_mime ==
"image/tiff") || ($a_mime ==
"image/x-ms-bmp") ||
3289 ($a_mime ==
"image/psd") || ($a_mime ==
"image/iff")) {
3306 if (!isset(
$DIC[
'ilCtrl']) || !
$DIC[
'ilCtrl'] instanceof
ilCtrl) {
3309 $ctrl =
$DIC->ctrl();
3311 $ctrl->redirectToURL($a_script);
3324 if (substr($a_value, 0, 4) ==
"il__") {
3325 $a_value =
"il_" .
IL_INST_ID .
"_" . substr($a_value, 4, strlen($a_value) - 4);
3348 if (isset(
$DIC[
"ilErr"])) {
3352 if (empty($a_group_name)) {
3353 $message = __METHOD__ .
": No groupname given!";
3357 $clause = ($a_id) ?
" AND obj_id != " .
$ilDB->quote($a_id) .
" " :
"";
3359 $q =
"SELECT obj_id FROM object_data " .
3360 "WHERE title = " .
$ilDB->quote($a_group_name,
"text") .
" " .
3361 "AND type = " .
$ilDB->quote(
"grp",
"text") .
3364 $r =
$ilDB->query($q);
3366 if ($r->numRows()) {
3381 $my_pid = getmypid();
3382 return (
"MEMORY USAGE (% KB PID ): " . `ps -eo%mem,rss,pid | grep $my_pid`);
3393 if (strtolower(substr(php_uname(), 0, 3)) ==
"win") {
3402 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3404 return escapeshellarg($a_arg);
3418 if (ini_get(
'safe_mode') == 1) {
3421 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3422 return escapeshellcmd($a_arg);
3438 if (
ilUtil::isWindows() && strpos($cmd,
" ") !==
false && substr($cmd, 0, 1) !==
'"') {
3440 $cmd =
'"' . $cmd .
'"';
3444 if (version_compare(phpversion(),
"5.2",
"<") && strpos($args,
'"') !==
false) {
3445 $cmd =
'"' . $cmd .
" " . $args .
'"';
3449 $cmd .=
" " . $args;
3455 $cmd .=
" " . $args;
3459 $DIC->logger()->root()->debug(
"ilUtil::execQuoted: " . $cmd .
".");
3486 public static function excelTime($year =
"", $month =
"", $day =
"", $hour =
"", $minute =
"", $second =
"")
3488 $starting_time = mktime(0, 0, 0, 1, 2, 1970);
3489 if (strcmp(
"$year$month$day$hour$minute$second",
"") == 0) {
3490 $target_time = time();
3496 $target_time = mktime($hour, $minute, $second, $month, $day, $year);
3497 $difference = $target_time - $starting_time;
3498 $days = (($difference - ($difference % 86400)) / 86400);
3499 $difference = $difference - ($days * 86400) + 3600;
3502 return str_replace(
",",
".", ($days + 25570 + ($difference / 86400)));
3513 $def_arr = explode(
",", SUFFIX_REPL_DEFAULT);
3514 foreach ($def_arr as $def) {
3518 $def_arr = explode(
",", SUFFIX_REPL_ADDITIONAL);
3519 foreach ($def_arr as $def) {
3530 $file_peaces = explode(
'.', $a_initial_filename);
3532 $file_extension = array_pop($file_peaces);
3534 if (SUFFIX_REPL_ADDITIONAL) {
3535 $string_extensions = SUFFIX_REPL_DEFAULT .
"," . SUFFIX_REPL_ADDITIONAL;
3537 $string_extensions = SUFFIX_REPL_DEFAULT;
3540 $sufixes = explode(
",", $string_extensions);
3542 if (in_array($file_extension, $sufixes)) {
3543 $file_extension =
"sec";
3546 array_push($file_peaces, $file_extension);
3548 $safe_filename =
"";
3549 foreach ($file_peaces as $piece) {
3550 $safe_filename .=
"$piece";
3551 if ($piece != end($file_peaces)) {
3552 $safe_filename .=
".";
3556 return $safe_filename;
3571 public static function rRenameSuffix(
string $a_dir,
string $a_old_suffix,
string $a_new_suffix) : bool
3575 || strpos($a_dir,
"..") !==
false
3576 || trim($a_old_suffix) ===
"") {
3581 if (!@is_dir($a_dir)) {
3586 $dir = opendir($a_dir);
3587 if ($dir ===
false) {
3595 while ($file = readdir($dir)) {
3601 if (in_array($file, $prohibited)) {
3602 unlink($a_dir .
"/" . $file);
3607 if (@is_dir($a_dir .
"/" . $file)) {
3612 if (@is_file($a_dir .
"/" . $file)) {
3614 if (strrpos($file,
'.') == (strlen($file) - 1)) {
3616 rename($a_dir .
'/' . $file, substr($a_dir .
'/' . $file, 0, -1));
3617 }
catch (Throwable $t) {
3619 unlink($a_dir .
'/' . $file);
3623 $file = substr($file, 0, -1);
3626 $path_info = pathinfo($a_dir .
"/" . $file);
3628 if (strtolower($path_info[
"extension"]) === strtolower($a_old_suffix)) {
3629 $pos = strrpos($a_dir .
"/" . $file,
".");
3630 $new_name = substr($a_dir .
"/" . $file, 0, $pos) .
"." . $a_new_suffix;
3632 if (file_exists($new_name)) {
3633 if (is_dir($new_name)) {
3639 rename($a_dir .
"/" . $file, $new_name);
3649 return strpos(
$_SERVER[
"SCRIPT_FILENAME"],
"api") !==
false ||
3650 strpos(
$_SERVER[
"SCRIPT_FILENAME"],
"dummy") !==
false;
3655 if (preg_match(
"/&" . $paramName .
"=/", $qstring)) {
3656 return preg_replace(
"/&" . $paramName .
"=[^&]+/",
"&" . $paramName .
"=" . urlencode($paramValue), $qstring);
3658 return $qstring .
"&" . $paramName .
"=" . urlencode($paramValue);
3664 foreach ($parametersArray as $paramName => $paramValue) {
3679 srand((
double) microtime() * 1000000);
3681 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
3684 for (
$i = 1;
$i <= $a_number;
$i++) {
3685 $min = ($security->getPasswordMinLength() > 0)
3686 ? $security->getPasswordMinLength()
3688 $max = ($security->getPasswordMaxLength() > 0)
3689 ? $security->getPasswordMaxLength()
3694 $random = new \ilRandom();
3695 $length = $random->int($min, $max);
3696 $next = $random->int(1, 2);
3698 $vowels_uc = strtoupper($vowels);
3699 $consonants =
"bcdfghjklmnpqrstvwxyz";
3700 $consonants_uc = strtoupper($consonants);
3701 $numbers =
"1234567890";
3702 $special =
"_.+?#-*@!$%~";
3705 if ($security->getPasswordNumberOfUppercaseChars() > 0) {
3706 for ($j = 0; $j < $security->getPasswordNumberOfUppercaseChars(); $j++) {
3709 $pw .= $consonants_uc[$random->int(0, strlen($consonants_uc) - 1)];
3714 $pw .= $vowels_uc[$random->int(0, strlen($vowels_uc) - 1)];
3721 if ($security->isPasswordCharsAndNumbersEnabled()) {
3722 $pw .= $numbers[$random->int(0, strlen($numbers) - 1)];
3725 if ($security->isPasswordSpecialCharsEnabled()) {
3726 $pw .= $special[$random->int(0, strlen($special) - 1)];
3729 $num_lcase_chars = max($security->getPasswordNumberOfLowercaseChars(), $length - strlen($pw));
3730 for ($j = 0; $j < $num_lcase_chars; $j++) {
3733 $pw .= $consonants[$random->int(0, strlen($consonants) - 1)];
3738 $pw .= $vowels[$random->int(0, strlen($vowels) - 1)];
3744 $pw = str_shuffle($pw);
3753 $path = preg_replace(
"/[\/\\\]+$/",
"", $path);
3773 foreach (
$data as $k => $datum) {
3774 if (is_null($datum)) {
3777 if (is_string($datum)) {
3778 $data[$k] =
"'" . $datum .
"'";
3780 if (is_array($datum)) {
3785 return "[" . implode(
', ',
$data) .
"]";
3794 public static function virusHandling($a_file, $a_orig_name =
"", $a_clean =
true)
3800 if ((defined(
'IL_VIRUS_SCANNER') && IL_VIRUS_SCANNER !=
"None") || (defined(
'IL_ICAP_HOST') && strlen(IL_ICAP_HOST) !== 0)) {
3801 require_once(
"./Services/VirusScanner/classes/class.ilVirusScannerFactory.php");
3803 if (($vs_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"") {
3804 if ($a_clean && (IL_VIRUS_CLEAN_COMMAND !=
"")) {
3805 $clean_txt = $vs->cleanFile($a_file, $a_orig_name);
3806 if ($vs->fileCleaned()) {
3807 $vs_txt .=
"<br />" .
$lng->txt(
"cleaned_file") .
3808 "<br />" . $clean_txt;
3809 $vs_txt .=
"<br />" .
$lng->txt(
"repeat_scan");
3810 if (($vs2_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"") {
3811 return array(
false, nl2br($vs_txt) .
"<br />" .
$lng->txt(
"repeat_scan_failed") .
3812 "<br />" . nl2br($vs2_txt));
3814 return array(
true, nl2br($vs_txt) .
"<br />" .
$lng->txt(
"repeat_scan_succeded"));
3817 return array(
false, nl2br($vs_txt) .
"<br />" .
$lng->txt(
"cleaning_failed"));
3820 return array(
false, nl2br($vs_txt));
3825 return array(
true,
"");
3848 public static function moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors =
true, $a_mode =
"move_uploaded")
3851 $target_filename = basename($a_target);
3853 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
3859 $upload =
$DIC->upload();
3862 if (!$upload->hasBeenProcessed()) {
3867 if (!$upload->hasUploads()) {
3868 throw new ilException(
$DIC->language()->txt(
"upload_error_file_not_found"));
3870 $upload_result = $upload->getResults()[$a_file] ??
null;
3872 $processing_status = $upload_result->getStatus();
3873 if ($processing_status->getCode() === ProcessingStatus::REJECTED
3874 || $processing_status->getCode() === ProcessingStatus::DENIED) {
3875 throw new ilException($processing_status->getMessage());
3881 if (!$a_raise_errors) {
3890 $upload->moveOneFileTo($upload_result, $target_dir, $target_filesystem, $target_filename,
true);
3904 list($datum, $uhrzeit) = explode(
" ", $mysql_date_time);
3905 list($jahr, $monat, $tag) = explode(
"-", $datum);
3906 list($std, $min, $sec) = explode(
":", $uhrzeit);
3907 return mktime((
int) $std, (
int) $min, (
int) $sec, (
int) $monat, (
int) $tag, (
int) $jahr);
3918 return date(
"Y-m-d H:i:s");
3936 public static function &
processCSVRow(&$row, $quoteAll =
false, $separator =
";", $outUTF8 =
false, $compatibleWithMSExcel =
true)
3938 $resultarray = array();
3939 foreach ($row as $rowindex => $entry) {
3944 if (strpos($entry,
"\"") !==
false) {
3945 $entry = str_replace(
"\"",
"\"\"", $entry);
3948 if (strpos($entry, $separator) !==
false) {
3951 if ($compatibleWithMSExcel) {
3953 $entry = str_replace(chr(13) . chr(10), chr(10), $entry);
3957 $resultarray[$rowindex] =
"\"" . $entry .
"\"";
3959 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
3963 $resultarray[$rowindex] = $entry;
3965 $resultarray[$rowindex] = utf8_decode($entry);
3969 return $resultarray;
3973 public static function isDN($a_str)
3975 return(preg_match(
"/^[a-z]+([a-z0-9-]*[a-z0-9]+)?(\.([a-z]+([a-z0-9-]*[a-z0-9]+)?)+)*$/", $a_str));
3981 return(preg_match(
"/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\." .
3982 "(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/", $a_str));
4019 $rbacreview =
$DIC->rbac()->review();
4020 $ilAccess =
$DIC->access();
4023 $tree =
$DIC->repositoryTree();
4025 if (!is_array($a_obj_type)) {
4026 $where =
"WHERE type = " .
$ilDB->quote($a_obj_type,
"text") .
" ";
4028 $where =
"WHERE " .
$ilDB->in(
"type", $a_obj_type,
false,
"text") .
" ";
4033 $limit =
$ilSetting->get(
'search_max_hits', 100);
4040 $a_usr_id = $a_usr_id ? $a_usr_id :
$ilUser->getId();
4041 $a_roles = $rbacreview->assignedRoles($a_usr_id);
4046 $query =
"SELECT ref_id FROM object_reference obr LEFT JOIN object_data obd ON obr.obj_id = obd.obj_id " .
4047 "LEFT JOIN tree ON obr.ref_id = tree.child " .
4053 while ($row =
$ilDB->fetchObject(
$res)) {
4059 if ($counter++ >= $limit) {
4063 $ref_ids[] = $row->ref_id;
4065 return $ref_ids ? $ref_ids : array();
4069 if ($a_operation ==
'edit_permissions' or strpos($a_operation,
'create') !==
false) {
4070 $check_owner =
") ";
4072 $check_owner =
"OR owner = " .
$ilDB->quote($a_usr_id,
"integer") .
") ";
4076 $ops_id = $ops_ids[0];
4078 $and =
"AND ((" .
$ilDB->in(
"rol_id", $a_roles,
false,
"integer") .
" ";
4080 $query =
"SELECT DISTINCT(obr.ref_id),obr.obj_id,type FROM object_reference obr " .
4081 "JOIN object_data obd ON obd.obj_id = obr.obj_id " .
4082 "LEFT JOIN rbac_pa ON obr.ref_id = rbac_pa.ref_id " .
4085 "AND (" .
$ilDB->like(
"ops_id",
"text",
"%i:" . $ops_id .
"%") .
" " .
4086 "OR " .
$ilDB->like(
"ops_id",
"text",
"%:\"" . $ops_id .
"\";%") .
")) " .
4092 if ($counter >= $limit) {
4102 if ($ilAccess->checkAccessOfUser($a_usr_id, $a_operation,
'', $row->ref_id, $row->type, $row->obj_id)) {
4104 $ref_ids[] = $row->ref_id;
4107 return $ref_ids ? $ref_ids : array();
4130 case strpos($a_target, ILIAS_ABSOLUTE_PATH .
'/Customizing') === 0:
4134 throw new InvalidArgumentException(
"Can not move files to \"$a_target\" because path can not be mapped to web, storage or customizing location.");
4137 $absTargetDir = dirname($a_target);
4138 $targetDir = LegacyPathHelper::createRelativePath($absTargetDir);
4140 return array( $targetFilesystem, $targetDir );
4150 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4160 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4170 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4171 return ilMathJax::getInstance()->insertLatexImages($a_text,
'[tex]',
'[/tex]', $a_dir .
'/teximg',
'./teximg');
4182 public static function prepareTextareaOutput($txt_output, $prepare_for_latex_output =
false, $omitNl2BrWhenTextArea =
false)
4189 if (!$omitNl2BrWhenTextArea) {
4195 if (preg_match_all(
"/(<pre>.*?<\/pre>)/ims",
$result, $matches)) {
4196 foreach ($matches[0] as $found) {
4198 if (strpos(
"\n", $found) ===
false) {
4199 $replacement =
"\n";
4201 $removed = preg_replace(
"/<br\s*?\/>/ims", $replacement, $found);
4209 if ($prepare_for_latex_output) {
4210 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4215 if ($prepare_for_latex_output) {
4236 if (strlen(strip_tags($a_text)) < strlen($a_text)) {
4264 $diff = $to->diff($from);
4267 $periods[
"years"] = $diff->format(
"%y");
4268 $periods[
"months"] = $diff->format(
"%m");
4269 $periods[
"days"] = $diff->format(
"%d");
4270 $periods[
"hours"] = $diff->format(
"%h");
4271 $periods[
"minutes"] = $diff->format(
"%i");
4272 $periods[
"seconds"] = $diff->format(
"%s");
4274 if (!array_sum($periods)) {
4278 foreach ($periods as $key => $value) {
4280 $segment_name = ($value > 1)
4282 : substr($key, 0, -1);
4283 $array[] = $value .
' ' .
$lng->txt($segment_name);
4287 $len =
sizeof($array);
4289 $array = array_slice($array, 0, (3 - $len));
4292 return implode(
', ', $array);
4298 self::getUploadSizeLimitBytes()
4314 return $lng->txt(
"file_notice") .
" $max_filesize.";
4319 $unit = array(
'',
'K',
'M',
'G',
'T',
'P');
4321 for (
$i = 0, $maxUnits = count($unit);
$size >= 1024 &&
$i <= $maxUnits;
$i++) {
4325 return round(
$size, $decimals) . $unit[
$i];
4330 $uploadSizeLimitBytes = min(
4331 self::convertPhpIniSizeValueToBytes(ini_get(
'post_max_size')),
4332 self::convertPhpIniSizeValueToBytes(ini_get(
'upload_max_filesize'))
4335 return $uploadSizeLimitBytes;
4340 if (is_numeric($phpIniSizeValue)) {
4341 return $phpIniSizeValue;
4344 $suffix = substr($phpIniSizeValue, -1);
4345 $value = substr($phpIniSizeValue, 0, -1);
4347 switch (strtoupper($suffix)) {
4378 $test_str = explode(
'_', $role_title);
4380 if ($test_str[0] ==
'il') {
4381 $test2 = (int) $test_str[3];
4382 return is_numeric($test2) ? (int) $test2 :
false;
4399 $test_str = explode(
'_', $ilias_id);
4401 if ($test_str[0] ==
'il' && $test_str[1] == $inst_id && count($test_str) == 4) {
4402 $test2 = (int) $test_str[3];
4403 return is_numeric($test2) ? (int) $test2 :
false;
4422 public static function _sortIds($a_ids, $a_table, $a_field, $a_id_name)
4433 $where =
"WHERE " . $a_id_name .
" IN (";
4437 $query =
"SELECT " . $a_id_name .
" FROM " . $a_table .
" " .
4439 "ORDER BY " . $a_field;
4443 $ids[] = $row->$a_id_name;
4445 return $ids ? $ids : array();
4479 if (!is_array($a_array) or !count($a_array)) {
4483 foreach ($a_array as $k => $item) {
4484 $a_array[$k] =
$ilDB->quote($item);
4501 $mtpl =
new ilTemplate(
"tpl.message.html",
true,
true,
"Services/Utilities");
4502 $mtpl->setCurrentBlock($a_type .
"_message");
4503 $mtpl->setVariable(
"TEXT", $a_txt);
4504 $mtpl->setVariable(
"MESSAGE_HEADING",
$lng->txt($a_type .
"_message"));
4505 $mtpl->parseCurrentBlock();
4507 return $mtpl->get();
4518 public static function sendInfo($a_info =
"", $a_keep =
false)
4523 $tpl->setOnScreenMessage(
"info", $a_info, $a_keep);
4538 if (isset(
$DIC[
"tpl"])) {
4540 $tpl->setOnScreenMessage(
"failure", $a_info, $a_keep);
4555 $tpl->setOnScreenMessage(
"question", $a_info, $a_keep);
4566 public static function sendSuccess($a_info =
"", $a_keep =
false)
4572 $tpl->setOnScreenMessage(
"success", $a_info, $a_keep);
4587 "tpl.infopanel.html",
4588 "Services/Utilities"
4590 $tpl->setCurrentBlock(
"infopanel");
4592 if (!empty(
$_SESSION[
"infopanel"][
"text"])) {
4593 $link =
"<a href=\"" .
$_SESSION[
"infopanel"][
"link"] .
"\" target=\"" .
4601 if (!empty(
$_SESSION[
"infopanel"][
"img"])) {
4602 $link .=
"<td><a href=\"" .
$_SESSION[
"infopanel"][
"link"] .
"\" target=\"" .
4605 $link .=
"<img src=\"" .
"./templates/" .
$ilUser->prefs[
"skin"] .
"/images/" .
4606 $_SESSION[
"infopanel"][
"img"] .
"\" border=\"0\" vspace=\"0\"/>";
4607 $link .=
"</a></td>";
4610 $tpl->setVariable(
"INFO_ICONS", $link);
4611 $tpl->parseCurrentBlock();
4632 if (!is_dir($directory)) {
4634 $size = @filesize($directory);
4637 if ($DIR = opendir($directory)) {
4638 while (($dirfile = readdir($DIR)) !==
false) {
4639 if (is_link($directory . DIRECTORY_SEPARATOR . $dirfile) || $dirfile ==
'.' || $dirfile ==
'..') {
4642 if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile)) {
4643 $size += filesize($directory . DIRECTORY_SEPARATOR . $dirfile);
4644 } elseif (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile)) {
4645 $dirSize =
ilUtil::dirsize($directory . DIRECTORY_SEPARATOR . $dirfile);
4646 if ($dirSize >= 0) {
4660 $random = new \ilRandom();
4661 return md5($random->int(1, 9999999) + str_replace(
" ",
"", (
string) microtime()));
4664 public static function setCookie($a_cookie_name, $a_cookie_value =
'', $a_also_set_super_global =
true, $a_set_cookie_invalid =
false)
4671 if (!(
bool) $a_set_cookie_invalid) {
4674 $expire = time() - (365 * 24 * 60 * 60);
4683 if (defined(
'IL_COOKIE_SECURE')) {
4684 $secure = IL_COOKIE_SECURE;
4687 $cookie_parameters = [
4688 'expires' => $expire,
4690 'domain' => IL_COOKIE_DOMAIN,
4691 'secure' => $secure,
4692 'httponly' => IL_COOKIE_HTTPONLY,
4697 (!isset(session_get_cookie_params()[
'samesite']) || strtolower(session_get_cookie_params()[
'samesite']) !==
'strict')
4699 $cookie_parameters[
'samesite'] =
'Lax';
4708 if ((
bool) $a_also_set_super_global) {
4709 $_COOKIE[$a_cookie_name] = $a_cookie_value;
4715 return strip_tags(self::stripSlashes($a_filename));
4724 if (
$_SERVER[
'SHELL'] || php_sapi_name() ==
'cli' ||
4729 return ILIAS_HTTP_PATH;
4740 $bt = debug_backtrace();
4742 foreach ($bt as $t) {
4743 if ($cnt != 0 && ($a_limit == 0 || $cnt <= $a_limit)) {
4744 echo
"<br>" . $t[
"file"] .
", " . $t[
"function"] .
" [" . $t[
"line"] .
"]";
4767 $exploded = explode(
'_', $a_import_id);
4769 $parsed[
'orig'] = $a_import_id;
4770 if ($exploded[0] ==
'il') {
4771 $parsed[
'prefix'] = $exploded[0];
4773 if (is_numeric($exploded[1])) {
4774 $parsed[
'inst_id'] = (int) $exploded[1];
4776 $parsed[
'type'] = $exploded[2];
4778 if (is_numeric($exploded[3])) {
4779 $parsed[
'id'] = (int) $exploded[3];
4793 '/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff^|]*)\|/',
4796 PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
4801 for (
$i = 0; $vars[
$i];
$i++) {
4823 $fp = @fopen($file,
'rb');
4825 $size = filesize($file);
4841 header(
"Accept-Ranges: 0-$length");
4845 if (isset(
$_SERVER[
'HTTP_RANGE'])) {
4849 list(, $range) = explode(
'=',
$_SERVER[
'HTTP_RANGE'], 2);
4851 if (strpos($range,
',') !==
false) {
4856 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
4857 header(
"Content-Range: bytes $start-$end/$size");
4864 if ($range ==
'-') {
4867 $c_start =
$size - substr($range, 1);
4869 $range = explode(
'-', $range);
4870 $c_start = $range[0];
4871 $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] :
$size;
4877 $c_end = ($c_end > $end) ? $end : $c_end;
4879 if ($c_start > $c_end || $c_start >
$size - 1 || $c_end >=
$size) {
4880 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
4881 header(
"Content-Range: bytes $start-$end/$size");
4887 $length = $end - $start + 1;
4889 header(
'HTTP/1.1 206 Partial Content');
4892 header(
"Content-Range: bytes $start-$end/$size");
4893 header(
"Content-Length: $length");
4897 while (!feof($fp) && ($p = ftell($fp)) <= $end) {
4898 if ($p + $buffer > $end) {
4902 $buffer = $end - $p + 1;
4905 echo fread($fp, $buffer);
4947 protected static function fmtFloat($a_float, $a_decimals = 0, $a_dec_point =
null, $a_thousands_sep =
null, $a_suppress_dot_zero =
false)
4953 if ($a_dec_point ==
null) {
4958 if ($a_dec_point ==
'-lang_sep_decimal-') {
4962 if ($a_thousands_sep ==
null) {
4963 $a_thousands_sep =
$lng->txt(
'lang_sep_thousand');
4965 if ($a_thousands_sep ==
'-lang_sep_thousand-') {
4966 $a_thousands_sep =
",";
4969 $txt = number_format($a_float, $a_decimals, $a_dec_point, $a_thousands_sep);
4972 if (($a_suppress_dot_zero == 0 || $a_decimals == 0)
4973 && substr(
$txt, -2) == $a_dec_point .
'0'
4977 if ($a_float == 0 and
$txt ==
"") {
5005 if ($a_lng ==
null) {
5011 if (
$size >= $mag * $mag * $mag) {
5012 $scaled_size =
$size / $mag / $mag / $mag;
5013 $scaled_unit =
'lang_size_gb';
5015 if (
$size >= $mag * $mag) {
5016 $scaled_size =
$size / $mag / $mag;
5017 $scaled_unit =
'lang_size_mb';
5019 if (
$size >= $mag) {
5020 $scaled_size =
$size / $mag;
5021 $scaled_unit =
'lang_size_kb';
5023 $scaled_size =
$size;
5024 $scaled_unit =
'lang_size_bytes';
5030 ==
'lang_size_bytes') ? 0 : 1, $a_lng->txt(
'lang_sep_decimal'), $a_lng->txt(
'lang_sep_thousand'),
true)
5031 .
' ' . $a_lng->txt($scaled_unit);
5032 if ($a_mode ==
'long' &&
$size > $mag) {
5034 . $a_lng->txt(
'lang_size_bytes') .
')';
5047 return ((
int) $a_value) * pow(self::_getSizeMagnitude(), 2);
5052 return ((
int) $a_value) / (pow(self::_getSizeMagnitude(), 2));
5066 if (!isset(self::$db_supports_distinct_umlauts)) {
5068 $set =
$ilDB->query(
"SELECT (" .
$ilDB->quote(
"A",
"text") .
" = " .
$ilDB->quote(
"Ä",
"text") .
") t FROM DUAL ");
5069 $rec =
$ilDB->fetchAssoc($set);
5070 self::$db_supports_distinct_umlauts = !(bool) $rec[
"t"];
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
Class LegacyPathHelper The legacy path helper provides convenient functions for the integration of th...
static usesHTTP()
Uses HTTP aka browser.
This class provides processing control methods.
@classDescription Date and time handling
get($a_format, $a_format_str='', $a_tz='')
get formatted date
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getValidFilename($a_filename)
Get valid filename.
static recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
static getInstance()
Get https instance.
Class ilMailRfc822AddressParserFactory.
static getInstance()
Singleton: get instance.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _getOperationIdsByName($operations)
get ops_id's by name.
static _getInstance()
Get instance of ilSecuritySettings.
static clear($a_var)
Unset a value.
static strPos($a_haystack, $a_needle, $a_offset=null)
static subStr($a_str, $a_start, $a_length=null)
static strCmp($a, $b)
Compare two strings.
static strToUpper($a_string)
static getCurrentSkin()
get the current skin
static getCurrentStyle()
get the current style or sub style
special template class to simplify handling of ITX/PEAR
static getPasswordValidChars($a_as_regex=true, $a_only_special_chars=false)
All valid chars for password.
static CreateIsoFromFolder($a_dir, $a_file)
static getDataDir()
get data directory (outside webspace)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static _getSizeMagnitude()
Returns the magnitude used for size units.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getJSLocation($a_js_name, $a_js_location="", $add_version=false)
get full javascript file name (path inclusive) of current user
static getMySQLTimestamp($a_ts)
Get MySQL timestamp in 4.1.x or higher format (yyyy-mm-dd hh:mm:ss) This function converts a timestam...
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static assembleParameterString($a_par_arr)
static dumpString($a_str)
dumps ord values of every character of string $a_str
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
static getMemString()
get current memory usage as string
static _sanitizeFilemame($a_filename)
static formRadioButton($checked, $varname, $value, $onclick=null, $disabled=false)
??? @access public
static checkInput($vars)
???
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
static unmaskSecureTags($a_str, $allow_array)
static insertLatexImages($a_text, $a_start='[tex]', $a_end='[/tex]')
replace [tex]...[/tex] tags with formula image code
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
static isConvertVersionAtLeast($a_version)
Compare convert version numbers.
static formDisabledRadioButton($checked, $varname, $value, $disabled)
??? @accesspublic @paramstring @paramstring @paramstring
static excelTime($year="", $month="", $day="", $hour="", $minute="", $second="")
Calculates a Microsoft Excel date/time value.
static formatBytes($size, $decimals=0)
static getUploadSizeLimitBytes()
static _sortIds($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,...
static checkFormEmpty($emptyFields)
??? @access public
static convertPhpIniSizeValueToBytes($phpIniSizeValue)
static isHTML($a_text)
Checks if a given string contains HTML or not.
static getGDSupportedImageType($a_desired_type)
returns the best supported image type by this PHP build
static setCookie($a_cookie_name, $a_cookie_value='', $a_also_set_super_global=true, $a_set_cookie_invalid=false)
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static stripOnlySlashes($a_str)
strip slashes if magic qoutes is enabled
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static execQuoted($cmd, $args=null)
exec command and fix spaces on windows
static replaceUrlParameterString($url, $parametersArray)
static insertInstIntoID($a_value)
inserts installation id into ILIAS id
static __extractRefId($role_title)
extract ref id from role title, e.g.
static KT_replaceParam($qstring, $paramName, $paramValue)
static tf2yn($a_tf)
convert true/false to "y"/"n"
static replaceLinkProperties($matches)
replaces target _blank with _self and the link text with the according object title.
static Linkbar($AScript, $AHits, $ALimit, $AOffset, $AParams=array(), $ALayout=array(), $prefix='')
Linkbar Diese Funktion erzeugt einen typischen Navigationsbalken mit "Previous"- und "Next"-Links und...
static parseImportId($a_import_id)
Parse an ilias import id Typically of type il_[IL_INST_ID]_[OBJ_TYPE]_[OBJ_ID] returns array( 'orig' ...
static getJavaPath()
get full java path (dir + java command)
static escapeShellArg($a_arg)
static setPathStr($a_path)
??? @access public
static getImageTagByType($a_type, $a_path, $a_big=false)
Builds an html image tag TODO: function still in use, but in future use getImagePath and move HTML-Co...
static readFile($a_file)
there are some known problems with the original readfile method, which sometimes truncates delivered ...
static getWebspaceDir($mode="filesystem")
get webspace directory
static unmaskAttributeTag($a_str, $tag, $tag_att)
rangeDownload($file)
Send a file via range request, see http://mobiforge.com/design-development/content-delivery-mobile-de...
static execConvert($args)
execute convert command
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static sanitateTargetPath($a_target)
static redirect($a_script)
static resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop=false)
resize image
static isPassword($a_passwd, &$customError=null)
validates a password @access public
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
static getClientIdByString(string $clientId)
static groupNameExists($a_group_name, $a_id=0)
checks if group name already exists.
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
static buildLatexImages($a_text, $a_dir)
replace [tex]...[/tex] tags with formula image code for offline use
static printBacktrace($a_limit=0)
printBacktrace
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static maskSecureTags($a_str, $allow_array)
static unmaskTag($a_str, $t, $fix_param="")
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static isWindows()
check wether the current client system is a windows system
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static dumpVar($mixed=null)
Dump var.
static getSafeFilename($a_initial_filename)
static fmtFloat($a_float, $a_decimals=0, $a_dec_point=null, $a_thousands_sep=null, $a_suppress_dot_zero=false)
format a float
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
static extractParameterString($a_parstr)
extracts parameter value pairs from a string into an array
static period2String(ilDateTime $a_from, $a_to=null)
Return a string of time period.
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive,...
static now()
Return current timestamp in Y-m-d H:i:s format.
static getConvertCmd()
get convert command
static getP3PLocation()
Get p3p file path.
static escapeShellCmd($a_arg)
escape shell cmd
static rRenameSuffix(string $a_dir, string $a_old_suffix, string $a_new_suffix)
Renames all files with certain suffix and gives them a new suffix.
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static maskAttributeTag($a_str, $tag, $tag_att)
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
static shortenWords($a_str, $a_len=30, $a_dots=true)
Ensure that the maximum word lenght within a text is not longer than $a_len.
static processConvertVersion($a_version)
Parse convert version string, e.g.
static getNewContentStyleSheetLocation($mode="output")
get full style sheet file name (path inclusive) of current user
static securePlainString($a_str)
Remove unsecure characters from a plain text string.
static dbSupportsDisctinctUmlauts()
Only temp fix for #8603, should go to db classes.
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static htmlentitiesOutsideHTMLTags($htmlText)
Encodes HTML entities outside of HTML tags.
static getHtmlPath($relative_path)
get url of path
static $db_supports_distinct_umlauts
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
static stripScriptHTML($a_str, $a_allow="", $a_rm_js=true)
strip only html tags (4.0) from text $allowed contains tags to be allowed, in format tags a and b ar...
static htmlencodePlainString($a_str, $a_make_links_clickable, $a_detect_goto_links=false)
Encodes a plain text string into HTML for display in a browser.
static array_php2js($data)
convert php arrays to javascript arrays
includeMathjax($a_tpl=null)
Include Mathjax.
static unique_multi_array($array, $sub_key)
Make a multi-dimensional array to have only DISTINCT values for a certain "column".
static makeDateSelect($prefix, $year="", $month="", $day="", $startyear="", $a_long_month=true, $a_further_options=array(), $emptyoption=false)
Creates a combination of HTML selects for date inputs.
static generatePasswords($a_number)
Generate a number of passwords.
static getSelectName($selected, $values)
???
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static date_mysql2time($mysql_date_time)
make time object from mysql_date_time
static MB2Bytes($a_value)
static yn2tf($a_yn)
convert "y"/"n" to true/false
static quoteArray($a_array)
Quotes all members of an array for usage in DB query statement.
static secureLink($a_str)
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
static sort_func_numeric($a, $b)
sub-function to sort an array
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static stableSortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getSystemMessageHTML($a_txt, $a_type="info")
Get HTML for a system message.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static deducibleSize($a_mime)
checks if mime type is provided by getimagesize()
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ... into an array
static maskTag($a_str, $t, $fix_param="")
static removeTrailingPathSeparators($path)
static infoPanel($a_keep=true)
static & processCSVRow(&$row, $quoteAll=false, $separator=";", $outUTF8=false, $compatibleWithMSExcel=true)
Convertes an array for CSV usage.
static secureUrl($url)
Prepare secure href attribute.
static unserializeSession($data)
Returns the unserialized ILIAS session data.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static createDirectory($a_dir, $a_mod=0755)
create directory
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static formInput($varname, $value, $disabled=false)
create html input area
static getUsersOnline($a_user_id=0)
reads all active sessions from db and returns users that are online OR returns only one active user i...
static Bytes2MB($a_value)
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
static dirsize($directory)
get size of a directory or a file.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
static makeTimeSelect($prefix, $short=true, $hour="", $minute="", $second="", $a_use_default=true, $a_further_options=array())
Creates a combination of HTML selects for time inputs.
static sort_func($a, $b)
sub-function to sort an array
static mergesort(&$array, $cmp_function='strcmp')
const TEMPORARY
The ILIAS temporary directory.
const CUSTOMIZING
The filesystem within the web root where all the skins and plugins are saved.
const WEB
The filesystem within the ilias web root.
const STORAGE
The filesystem outside of the ilias web root.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...
Class ChatMainBarProvider \MainMenu\Provider.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
foreach($_POST as $key=> $value) $res