46 include_once(
"./Services/Object/classes/class.ilObject.php");
49 return "<img src=\"" .
$filename .
"\" alt=\"" .
$lng->txt(
"obj_" .
$a_type) .
"\" title=\"" .
$lng->txt(
"obj_" .
$a_type) .
"\" border=\"0\" vspace=\"0\"/>";
66 include_once(
"./Services/Object/classes/class.ilObject.php");
67 return ilObject::_getIcon($a_obj_id, $a_size,
$a_type);
80 public static function getImagePath(
$img, $module_path =
"", $mode =
"output", $offline =
false)
84 $styleDefinition =
null;
85 if (isset(
$DIC[
"styleDefinition"])) {
86 $styleDefinition =
$DIC[
"styleDefinition"];
89 if (is_int(strpos(
$_SERVER[
"PHP_SELF"],
"setup.php"))) {
92 if ($module_path !=
"") {
93 $module_path =
"/" . $module_path;
97 $default_img =
"." . $module_path .
"/templates/default/images/" .
$img;
100 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
104 if (is_object($styleDefinition)) {
105 $image_dir = $styleDefinition->getImageDirectory($current_style);
107 if ($current_skin ==
"default") {
108 $user_img =
"." . $module_path .
"/templates/default/" . $image_dir .
"/" .
$img;
109 $skin_img =
"." . $module_path .
"/templates/default/images/" .
$img;
110 } elseif (is_object($styleDefinition) && $current_skin !=
"default") {
111 $user_img =
"./Customizing/global/skin/" .
112 $current_skin . $module_path .
"/" . $image_dir .
"/" .
$img;
113 $skin_img =
"./Customizing/global/skin/" .
114 $current_skin . $module_path .
"/images/" .
$img;
131 return "./images/" .
$img;
132 } elseif (@file_exists($user_img) && $image_dir !=
"") {
134 } elseif (file_exists($skin_img)) {
153 if (substr($relative_path, 0, 2) ==
'./') {
154 $relative_path = (substr($relative_path, 1));
156 if (substr($relative_path, 0, 1) !=
'/') {
157 $relative_path =
'/' . $relative_path;
183 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
184 $stylesheet_name = (strlen($a_css_name))
187 if (strlen($a_css_location) && (strcmp(substr($a_css_location, -1),
"/") != 0)) {
188 $a_css_location = $a_css_location .
"/";
193 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
198 $filename =
"./" . $a_css_location .
"templates/default/" . $stylesheet_name;
201 if ($mode !=
"filesystem") {
202 $vers = str_replace(
" ",
"-",
$ilSetting->get(
"ilias_version"));
203 $vers =
"?vers=" . str_replace(
".",
"-", $vers);
206 $vers .= ($skin->getVersion() !=
'' ? str_replace(
".",
"-",
'-' . $skin->getVersion()) :
'');
221 public static function getJSLocation($a_js_name, $a_js_location =
"", $add_version =
false)
228 $js_name = $a_js_name;
229 if (strlen($a_js_location) && (strcmp(substr($a_js_location, -1),
"/") != 0)) {
230 $a_js_location = $a_js_location .
"/";
235 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
240 $filename =
"./" . $a_js_location .
"templates/default/" . $js_name;
244 $vers = str_replace(
" ",
"-",
$ilSetting->get(
"ilias_version"));
245 $vers =
"?vers=" . str_replace(
".",
"-", $vers);
259 if (defined(
"ILIAS_MODULE")) {
262 $base .=
"../Services/Privacy/";
265 $base =
"./Services/Privacy/";
268 if (is_file(
$base .
"w3c/p3p.xml")) {
289 if ($mode !=
"filesystem") {
290 $vers = str_replace(
" ",
"-",
$ilSetting->get(
"ilias_version"));
291 $vers =
"?vers=" . str_replace(
".",
"-", $vers);
295 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
304 if (is_file(
"./" . $in_style)) {
305 return $in_style . $vers;
307 return "templates/default/delos_cont.css" . $vers;
334 $direct_text =
false,
344 if ($multiple ==
true) {
345 $multiple =
" multiple=\"multiple\"";
351 $class =
" class=\" form-control " . $style_class .
"\"";
357 if (is_array($attribs)) {
358 foreach ($attribs as $key => $val) {
363 $disabled =
' disabled=\"disabled\"';
368 $size_str =
' size="'.$size.
'" ';
370 $str =
"<select name=\"" . $varname .
"\"" . $multiple .
" $class " . $size_str .
" $attributes $disabled>\n";
372 foreach ((array) $options as $key => $val) {
374 if (is_array($val)) {
375 $style = $val[
"style"];
379 $sty = ($style !=
"")
380 ?
' style="' . $style .
'" '
384 $str .=
" <option $sty value=\"" . $key .
"\"";
386 $str .=
" <option $sty value=\"" . $val .
"\"";
388 if (is_array($selected)) {
389 if (in_array($key, $selected)) {
390 $str .=
" selected=\"selected\"";
392 } elseif ($selected == $key) {
393 $str .=
" selected=\"selected\"";
397 $str .=
">" . $val .
"</option>\n";
399 $str .=
">" .
$lng->txt($val) .
"</option>\n";
403 $str .=
"</select>\n";
419 return($values[$selected]);
433 public static function formCheckbox($checked, $varname, $value, $disabled =
false)
435 $str =
"<input type=\"checkbox\" name=\"" . $varname .
"\"";
438 $str .=
" checked=\"checked\"";
442 $str .=
" disabled=\"disabled\"";
447 if (substr($varname, -2) ==
"[]") {
453 $varname_id = substr($varname, 0, -2) .
"_" . $value;
455 $varname_id = $varname;
459 $varname_id = str_replace(
"[",
"_", $varname_id);
460 $varname_id = str_replace(
"]",
"", $varname_id);
462 $str .=
" value=\"" . $value .
"\" id=\"" . $varname_id .
"\" />\n";
481 $str =
"<input disabled type=\"radio\" name=\"" . $varname .
"\"";
483 $str =
"<input type=\"radio\" name=\"" . $varname .
"\"";
486 $str .=
" checked=\"checked\"";
489 $str .=
" value=\"" . $value .
"\"";
490 $str .=
" id=\"" . $value .
"\" />\n";
506 public static function formRadioButton($checked, $varname, $value, $onclick =
null, $disabled =
false)
511 $str .= (
'onclick="' . $onclick .
'"');
514 $str .= (
" type=\"radio\" name=\"" . $varname .
"\"");
516 $str .=
" checked=\"checked\"";
520 $str .=
" disabled=\"disabled\"";
523 $str .=
" value=\"" . $value .
"\"";
525 $str .=
" id=\"" . $value .
"\" />\n";
540 public static function formInput($varname, $value, $disabled =
false)
542 $str =
"<input type=\"input\" name=\"" . $varname .
"\"";
547 $str .=
" value=\"" . $value .
"\"";
549 $str .=
" id=\"" . $value .
"\" />\n";
575 if (
"" != $a_path &&
"/" != substr($a_path, -1)) {
617 foreach ($emptyFields as $key => $val) {
619 if ($feedback !=
"") {
653 public static function Linkbar($AScript, $AHits, $ALimit, $AOffset, $AParams = array(), $ALayout = array(), $prefix =
'')
658 $layout_prev =
"<<";
659 $layout_next =
">>";
662 if ((is_array($ALayout) && (count($ALayout) > 0))) {
663 if ($ALayout[
"link"]) {
664 $layout_link =
" class=\"" . $ALayout[
"link"] .
"\"";
667 if ($ALayout[
"prev"]) {
668 $layout_prev = $ALayout[
"prev"];
671 if ($ALayout[
"next"]) {
672 $layout_next = $ALayout[
"next"];
678 if ($AHits > $ALimit || $AOffset > 0) {
679 if (!empty($AParams)) {
680 foreach ($AParams as $key => $value) {
681 $params .= $key .
"=" . $value .
"&";
685 if (strpos($AScript,
'&')) {
686 $link = $AScript .
"&" . $params . $prefix .
"offset=";
688 $link = $AScript .
"?" . $params . $prefix .
"offset=";
693 $prevoffset = $AOffset - $ALimit;
694 if ($prevoffset < 0) {
697 $LinkBar .=
"<a" . $layout_link .
" href=\"" . $link . $prevoffset .
"\">" . $layout_prev .
" </a>";
701 $pages = intval($AHits / $ALimit);
704 if (($AHits % $ALimit)) {
712 for (
$i = 1 ;
$i <= $pages ;
$i++) {
713 $newoffset = $ALimit * (
$i - 1);
715 if ($newoffset == $AOffset) {
716 $LinkBar .=
"[" .
$i .
"] ";
718 $LinkBar .=
'<a ' . $layout_link .
' href="' .
719 $link . $newoffset .
'">[' .
$i .
']</a> ';
726 if (!(($AOffset / $ALimit) == ($pages - 1)) && ($pages != 1)) {
727 $newoffset = $AOffset + $ALimit;
728 $LinkBar .=
"<a" . $layout_link .
" href=\"" . $link . $newoffset .
"\"> " . $layout_next .
"</a>";
755 "/(^|[\s]+)(www\.)([A-Za-z0-9#&=?.\/\-]+)/i",
762 "/(^|[\s]+)(ftp\.)([A-Za-z0-9#&=?.\/\-]+)/i",
772 $ret = str_replace(
'src="http://',
'"***masked_im_start***',
$ret);
774 include_once(
"./Services/Utilities/classes/class.ilMWParserAdapter.php");
779 $ret = str_replace(
'"***masked_im_start***',
'src="http://',
$ret);
783 if ($detectGotoLinks) {
785 $regExp =
"<a[^>]*href=\"(" . str_replace(
"/",
"\/",
ILIAS_HTTP_PATH) .
"\/goto.php\?target=\w+_(\d+)[^\"]*)\"[^>]*>[^<]*<\/a>";
787 $ret = preg_replace_callback(
788 "/" . $regExp .
"/i",
789 array(
"ilUtil",
"replaceLinkProperties"),
794 $regExp =
"<a[^>]*href=\"(" . str_replace(
"/",
"\/",
ILIAS_HTTP_PATH) .
"\/goto_.*[a-z0-9]+_([0-9]+)\.html)\"[^>]*>[^<]*<\/a>";
796 $ret = preg_replace_callback(
797 "/" . $regExp .
"/i",
798 array(
"ilUtil",
"replaceLinkProperties"),
822 $ref_id = $matches[2];
828 $link =
"<a href=" . $matches[1] .
" target=\"_self\">" . $title .
"</a>";
852 public static function makeDateSelect($prefix, $year =
"", $month =
"", $day =
"", $startyear =
"", $a_long_month =
true, $a_further_options = array(), $emptyoption =
false)
859 if (isset($a_further_options[
'disabled']) and $a_further_options[
'disabled']) {
860 $disabled =
'disabled="disabled" ';
865 if (!strlen($year)) {
866 $year = $now[
"year"];
868 if (!strlen($month)) {
869 $month = $now[
"mon"];
877 $month = (int) $month;
882 $sel_day .=
'<select class="form-control" ';
883 if (isset($a_further_options[
'select_attributes'])) {
884 foreach ($a_further_options[
'select_attributes'] as
$name => $value) {
885 $sel_day .= (
$name .
'="' . $value .
'" ');
889 $sel_day .= $disabled .
"name=\"" . $prefix .
"[d]\" id=\"" . $prefix .
"_d\">\n";
892 $sel_day .=
"<option value=\"0\">--</option>\n";
894 for (
$i = 1;
$i <= 31;
$i++) {
895 $sel_day .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
897 $sel_day .=
"</select>\n";
898 $sel_day = preg_replace(
"/(value\=\"$day\")/",
"$1 selected=\"selected\"", $sel_day);
901 $sel_month =
'<select class="form-control" ';
902 if (isset($a_further_options[
'select_attributes'])) {
903 foreach ($a_further_options[
'select_attributes'] as
$name => $value) {
904 $sel_month .= (
$name .
'="' . $value .
'" ');
907 $sel_month .= $disabled .
"name=\"" . $prefix .
"[m]\" id=\"" . $prefix .
"_m\">\n";
910 $sel_month .=
"<option value=\"0\">--</option>\n";
912 for (
$i = 1;
$i <= 12;
$i++) {
914 $sel_month .=
"<option value=\"$i\">" .
$lng->txt(
"month_" . sprintf(
"%02d",
$i) .
"_long") .
"</option>\n";
916 $sel_month .=
"<option value=\"$i\">" .
$i .
"</option>\n";
919 $sel_month .=
"</select>\n";
920 $sel_month = preg_replace(
"/(value\=\"$month\")/",
"$1 selected=\"selected\"", $sel_month);
923 $sel_year =
'<select class="form-control" ';
924 if (isset($a_further_options[
'select_attributes'])) {
925 foreach ($a_further_options[
'select_attributes'] as
$name => $value) {
926 $sel_year .= (
$name .
'="' . $value .
'" ');
929 $sel_year .= $disabled .
"name=\"" . $prefix .
"[y]\" id=\"" . $prefix .
"_y\">\n";
930 if ((strlen($startyear) == 0) || ($startyear > $year)) {
931 if (!$emptyoption || $year != 0) {
932 $startyear = $year - 5;
936 if (($year + 5) < (date(
'Y', time()) + 5)) {
937 $end_year = date(
'Y', time()) + 5;
939 $end_year = $year + 5;
943 $sel_year .=
"<option value=\"0\">----</option>\n";
945 for (
$i = $startyear;
$i <= $end_year;
$i++) {
946 $sel_year .=
"<option value=\"$i\">" . sprintf(
"%04d",
$i) .
"</option>\n";
948 $sel_year .=
"</select>\n";
949 $sel_year = preg_replace(
"/(value\=\"$year\")/",
"$1 selected=\"selected\"", $sel_year);
952 $dateformat =
"d-m-Y";
953 $dateformat = strtolower(preg_replace(
"/\W/",
"", $dateformat));
954 $dateformat = strtolower(preg_replace(
"/(\w)/",
"%%$1", $dateformat));
955 $dateformat = preg_replace(
"/%%d/", $sel_day, $dateformat);
956 $dateformat = preg_replace(
"/%%m/", $sel_month, $dateformat);
957 $dateformat = preg_replace(
"/%%y/", $sel_year, $dateformat);
979 public static function makeTimeSelect($prefix, $short =
true, $hour =
"", $minute =
"", $second =
"", $a_use_default =
true, $a_further_options = array())
988 if (count($a_further_options)) {
989 if (isset($a_further_options[
'minute_steps'])) {
990 $minute_steps = $a_further_options[
'minute_steps'];
992 if (isset($a_further_options[
'disabled']) and $a_further_options[
'disabled']) {
993 $disabled =
'disabled="disabled" ';
997 if ($a_use_default and !strlen(
"$hour$minute$second")) {
1003 $hour = (int) $hour;
1004 $minute = (int) $minute;
1005 $second = (int) $second;
1008 $sel_hour =
'<select ';
1009 if (isset($a_further_options[
'select_attributes'])) {
1010 foreach ($a_further_options[
'select_attributes'] as
$name => $value) {
1011 $sel_hour .=
$name .
'=' . $value .
' ';
1014 $sel_hour .=
" " . $disabled .
"name=\"" . $prefix .
"[h]\" id=\"" . $prefix .
"_h\" class=\"form-control\">\n";
1017 for (
$i = 0;
$i <= 23;
$i++) {
1019 $sel_hour .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
1021 $sel_hour .=
"<option value=\"$i\">" . date(
"ga", mktime(
$i, 0, 0)) .
"</option>\n";
1024 $sel_hour .=
"</select>\n";
1025 $sel_hour = preg_replace(
"/(value\=\"$hour\")/",
"$1 selected=\"selected\"", $sel_hour);
1028 $sel_minute .=
"<select " . $disabled .
"name=\"" . $prefix .
"[m]\" id=\"" . $prefix .
"_m\" class=\"form-control\">\n";
1030 for (
$i = 0;
$i <= 59;
$i =
$i + $minute_steps) {
1031 $sel_minute .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
1033 $sel_minute .=
"</select>\n";
1034 $sel_minute = preg_replace(
"/(value\=\"$minute\")/",
"$1 selected=\"selected\"", $sel_minute);
1038 $sel_second .=
"<select " . $disabled .
"name=\"" . $prefix .
"[s]\" id=\"" . $prefix .
"_s\" class=\"form-control\">\n";
1040 for (
$i = 0;
$i <= 59;
$i++) {
1041 $sel_second .=
"<option value=\"$i\">" . sprintf(
"%02d",
$i) .
"</option>\n";
1043 $sel_second .=
"</select>\n";
1044 $sel_second = preg_replace(
"/(value\=\"$second\")/",
"$1 selected=\"selected\"", $sel_second);
1046 $timeformat =
$lng->text[
"lang_timeformat"];
1047 if (strlen($timeformat) == 0) {
1048 $timeformat =
"H:i:s";
1050 $timeformat = strtolower(preg_replace(
"/\W/",
"", $timeformat));
1051 $timeformat = preg_replace(
"/(\w)/",
"%%$1", $timeformat);
1052 $timeformat = preg_replace(
"/%%h/", $sel_hour, $timeformat);
1053 $timeformat = preg_replace(
"/%%i/", $sel_minute, $timeformat);
1055 $timeformat = preg_replace(
"/%%s/",
"", $timeformat);
1057 $timeformat = preg_replace(
"/%%s/", $sel_second, $timeformat);
1077 if (
null === $a_email || !is_string($a_email)) {
1081 if ($mailAddressParserFactory ===
null) {
1086 $parser = $mailAddressParserFactory->getParser((
string) $a_email);
1087 $addresses =
$parser->parse();
1102 public static function isPassword($a_passwd, &$customError =
null)
1108 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1112 if (empty($a_passwd)) {
1113 $customError =
$lng->txt(
'password_empty');
1121 if ($security->getPasswordMinLength() > 0 && strlen($a_passwd) < $security->getPasswordMinLength()) {
1122 $errors[] = sprintf(
$lng->txt(
'password_to_short'), $security->getPasswordMinLength());
1123 $isPassword =
false;
1128 if ($security->getPasswordMaxLength() > 0 && strlen($a_passwd) > $security->getPasswordMaxLength()) {
1129 $errors[] = sprintf(
$lng->txt(
'password_to_long'), $security->getPasswordMaxLength());
1130 $isPassword =
false;
1134 if ($security->isPasswordCharsAndNumbersEnabled()) {
1135 $hasCharsAndNumbers =
true;
1138 if (!preg_match(
'/[A-Za-z]+/', $a_passwd)) {
1139 $hasCharsAndNumbers =
false;
1143 if (!preg_match(
'/[0-9]+/', $a_passwd)) {
1144 $hasCharsAndNumbers =
false;
1147 if (!$hasCharsAndNumbers) {
1148 $errors[] =
$lng->txt(
'password_must_chars_and_numbers');
1149 $isPassword =
false;
1153 require_once
'Services/Utilities/classes/class.ilStr.php';
1154 if ($security->getPasswordNumberOfUppercaseChars() > 0) {
1155 if (
ilStr::strLen($a_passwd) -
ilStr::strLen(preg_replace(
'/[A-Z]/',
'', $a_passwd)) < $security->getPasswordNumberOfUppercaseChars()) {
1156 $errors[] = sprintf(
$lng->txt(
'password_must_contain_ucase_chars'), $security->getPasswordNumberOfUppercaseChars());
1157 $isPassword =
false;
1161 if ($security->getPasswordNumberOfLowercaseChars() > 0) {
1162 if (
ilStr::strLen($a_passwd) -
ilStr::strLen(preg_replace(
'/[a-z]/',
'', $a_passwd)) < $security->getPasswordNumberOfLowercaseChars()) {
1163 $errors[] = sprintf(
$lng->txt(
'password_must_contain_lcase_chars'), $security->getPasswordNumberOfLowercaseChars());
1164 $isPassword =
false;
1169 if ($security->isPasswordSpecialCharsEnabled()) {
1171 if (!preg_match(self::getPasswordValidChars(
true,
true), $a_passwd)) {
1172 $errors[] =
$lng->txt(
'password_must_special_chars');
1173 $isPassword =
false;
1178 if (!preg_match(self::getPasswordValidChars(), $a_passwd)) {
1179 $errors[] =
$lng->txt(
'password_contains_invalid_chars');
1180 $isPassword =
false;
1186 } elseif (count(
$errors) > 1) {
1187 $customError =
$lng->txt(
'password_multiple_errors');
1188 $customError .=
'<br />' . implode(
'<br />',
$errors);
1202 include_once
'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
1207 if (is_string($user)) {
1209 } elseif (is_array($user)) {
1212 $userId = $user[
'id'];
1214 $login = $user->getLogin();
1215 $userId = $user->getId();
1220 if (
$login && (
int) $security->getPasswordMustNotContainLoginnameStatus() &&
1221 strpos(strtolower($clear_text_password), strtolower(
$login)) !==
false
1223 $error_language_variable =
'password_contains_parts_of_login_err';
1240 if ($a_only_special_chars) {
1241 return '/[_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+/';
1243 return '/^[A-Za-z0-9_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+$/';
1246 return 'A-Z a-z 0-9 _.+?#-*@!$%~/:;';
1263 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1266 $infos = array(sprintf(
$lng->txt(
'password_allow_chars'), self::getPasswordValidChars(
false)));
1269 if ($security->getPasswordMinLength() > 0) {
1270 $infos[] = sprintf(
$lng->txt(
'password_to_short'), $security->getPasswordMinLength());
1274 if ($security->getPasswordMaxLength() > 0) {
1275 $infos[] = sprintf(
$lng->txt(
'password_to_long'), $security->getPasswordMaxLength());
1279 if ($security->isPasswordCharsAndNumbersEnabled()) {
1280 $infos[] =
$lng->txt(
'password_must_chars_and_numbers');
1284 if ($security->isPasswordSpecialCharsEnabled()) {
1285 $infos[] =
$lng->txt(
'password_must_special_chars');
1288 if ($security->getPasswordNumberOfUppercaseChars() > 0) {
1289 $infos[] = sprintf(
$lng->txt(
'password_must_contain_ucase_chars'), $security->getPasswordNumberOfUppercaseChars());
1292 if ($security->getPasswordNumberOfLowercaseChars() > 0) {
1293 $infos[] = sprintf(
$lng->txt(
'password_must_contain_lcase_chars'), $security->getPasswordNumberOfLowercaseChars());
1296 return implode(
'<br />', $infos);
1307 if (empty($a_login)) {
1311 if (strlen($a_login) < 3) {
1318 if (!preg_match(
"/^[A-Za-z0-9_\.\+\*\@!\$\%\~\-]+$/", $a_login)) {
1342 $a_next_blank =
false,
1343 $a_keep_extension =
false
1345 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1347 if ($a_next_blank) {
1357 if ($a_keep_extension) {
1358 $p = strrpos($a_str,
'.');
1360 if ($p ===
false || $p == 0 || strlen($a_str) - $p > $a_len) {
1363 $a_str .=
"\xe2\x80\xa6";
1367 $a_str =
ilStr::subStr($a_str, 0, $len - (strlen($a_str) - $p + 1)) .
"\xe2\x80\xa6" . substr($a_str, $p);
1369 $a_str =
ilStr::subStr($a_str, 0, $len - (strlen($a_str) - $p + 1)) . substr($a_str, $p);
1392 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1393 $str_arr = explode(
" ", $a_str);
1395 for (
$i = 0;
$i < count($str_arr);
$i++) {
1399 $str_arr[
$i] .=
"...";
1404 return implode(
" ", $str_arr);
1419 while (is_int(strpos($a_str,
"="))) {
1420 $eq_pos = strpos($a_str,
"=");
1421 $qu1_pos = strpos($a_str,
"\"");
1422 $qu2_pos = strpos(substr($a_str, $qu1_pos + 1),
"\"") + $qu1_pos + 1;
1423 if (is_int($eq_pos) && is_int($qu1_pos) && is_int($qu2_pos)) {
1424 $var = trim(substr($a_str, 0, $eq_pos));
1425 $val = trim(substr($a_str, $qu1_pos + 1, ($qu2_pos - $qu1_pos) - 1));
1426 $attribs[$var] = $val;
1427 $a_str = substr($a_str, $qu2_pos + 1);
1453 public static function rCopy($a_sdir, $a_tdir, $preserveTimeAttributes =
false)
1455 $sourceFS = LegacyPathHelper::deriveFilesystemFrom($a_sdir);
1456 $targetFS = LegacyPathHelper::deriveFilesystemFrom($a_tdir);
1458 $sourceDir = LegacyPathHelper::createRelativePath($a_sdir);
1459 $targetDir = LegacyPathHelper::createRelativePath($a_tdir);
1462 if (!$sourceFS->hasDir($sourceDir)) {
1466 $sourceList = $sourceFS->listContents($sourceDir,
true);
1468 foreach ($sourceList as $item) {
1469 if ($item->isDir()) {
1473 $itemPath = $targetDir .
'/' . substr($item->getPath(), strlen($sourceDir));
1474 $stream = $sourceFS->readStream($item->getPath());
1475 $targetFS->writeStream($itemPath, $stream);
1502 if ($mode ==
"filesystem") {
1503 return "./" . ILIAS_WEB_DIR .
"/" . CLIENT_ID;
1505 if (defined(
"ILIAS_MODULE")) {
1506 return "../" . ILIAS_WEB_DIR .
"/" . CLIENT_ID;
1508 return "./" . ILIAS_WEB_DIR .
"/" . CLIENT_ID;
1525 return CLIENT_DATA_DIR;
1539 include_once(
"./Services/User/classes/class.ilObjUser.php");
1540 return ilObjUser::_getUsersOnline($a_user_id);
1553 if ($a_temp_path ===
null) {
1556 $temp_path = $a_temp_path;
1559 if (!is_dir($temp_path)) {
1562 $temp_name = $temp_path .
"/" . uniqid(
"tmp");
1596 public static function unzip($a_file, $overwrite =
false, $a_flat =
false)
1602 if (!is_file($a_file)) {
1610 copy($a_file, $tmpdir . DIRECTORY_SEPARATOR . basename($a_file));
1611 $orig_file = $a_file;
1612 $a_file = $tmpdir . DIRECTORY_SEPARATOR . basename($a_file);
1613 $origpathinfo = pathinfo($orig_file);
1616 $pathinfo = pathinfo($a_file);
1617 $dir = $pathinfo[
"dirname"];
1618 $file = $pathinfo[
"basename"];
1623 $unzip = PATH_TO_UNZIP;
1674 $dir_realpath = realpath($dir);
1675 foreach (
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir)) as
$name =>
$f) {
1676 if (is_link(
$name)) {
1677 $target = readlink(
$name);
1678 if (substr($target, 0, strlen($dir_realpath)) != $dir_realpath) {
1687 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
1688 $filearray = array();
1690 if (is_array($filearray[
"file"])) {
1691 foreach ($filearray[
"file"] as $k =>
$f) {
1692 if (substr(
$f, 0, 1) !=
"." &&
$f != basename($orig_file)) {
1693 copy($filearray[
"path"][$k] .
$f, $origpathinfo[
"dirname"] . DIRECTORY_SEPARATOR .
$f);
1707 public static function zip($a_dir, $a_file, $compress_content =
false)
1711 if ($compress_content) {
1713 $pathinfo = pathinfo($a_dir);
1714 chdir($pathinfo[
"dirname"]);
1717 $pathinfo = pathinfo($a_file);
1718 $dir = $pathinfo[
"dirname"];
1719 $file = $pathinfo[
"basename"];
1721 if (!$compress_content) {
1732 if (is_array($a_dir)) {
1734 foreach ($a_dir as $dir) {
1735 $name = basename($dir);
1739 $name = basename($a_dir);
1740 if (trim(
$name) !=
"*") {
1757 $pathinfo = pathinfo($a_dir);
1758 chdir($pathinfo[
"dirname"]);
1760 $pathinfo = pathinfo($a_file);
1761 $dir = $pathinfo[
"dirname"];
1762 $file = $pathinfo[
"basename"];
1765 $mkisofs = PATH_TO_MKISOFS;
1771 $name = basename($a_dir);
1774 $zipcmd =
"-r -J -o " . $a_file .
" " .
$source;
1790 return PATH_TO_CONVERT;
1817 if ($current_version >= $version) {
1831 if (preg_match(
"/([0-9]+)\.([0-9]+)\.([0-9]+)([\.|\-]([0-9]+))?/", $a_version, $match)) {
1832 $version = str_pad($match[1], 2, 0, STR_PAD_LEFT) .
1833 str_pad($match[2], 2, 0, STR_PAD_LEFT) .
1834 str_pad($match[3], 2, 0, STR_PAD_LEFT) .
1835 str_pad($match[5], 2, 0, STR_PAD_LEFT);
1836 return (
int) $version;
1852 $a_target_format =
"",
1854 $a_background_color =
""
1856 $format_str = ($a_target_format !=
"")
1857 ? strtoupper($a_target_format) .
":"
1860 if ($a_geometry !=
"") {
1861 if (is_int(strpos($a_geometry,
"x"))) {
1862 $geometry =
" -geometry " . $a_geometry .
" ";
1864 $geometry =
" -geometry " . $a_geometry .
"x" . $a_geometry .
" ";
1868 $bg_color = ($a_background_color !=
"")
1869 ?
" -background color " . $a_background_color .
" "
1886 public static function resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop =
false)
1888 if ($a_constrain_prop) {
1889 $size =
" -geometry " . $a_width .
"x" . $a_height .
" ";
1891 $size =
" -resize " . $a_width .
"x" . $a_height .
"! ";
1904 public static function img($a_src, $a_alt =
null, $a_width =
"", $a_height =
"", $a_border = 0, $a_id =
"", $a_class =
"")
1906 $img =
'<img src="' . $a_src .
'"';
1907 if (!is_null($a_alt)) {
1908 $img .=
' alt="' . htmlspecialchars($a_alt) .
'"';
1910 if ($a_width !=
"") {
1911 $img .=
' width="' . htmlspecialchars($a_width) .
'"';
1913 if ($a_height !=
"") {
1914 $img .=
' height="' . htmlspecialchars($a_height) .
'"';
1916 if ($a_class !=
"") {
1917 $img .=
' class="' . $a_class .
'"';
1920 $img .=
' id="' . $a_id .
'"';
1933 public static function deliverData($a_data, $a_filename, $mime =
"application/octet-stream", $charset =
"")
1935 $disposition =
"attachment";
1938 include_once
'./Services/Http/classes/class.ilHTTPS.php';
1947 #header("Pragma: ");
1948 #header("Cache-Control: ");
1949 #header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
1950 #header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
1951 #header("Cache-Control: no-store, no-cache, must-revalidate");
1952 #header("Cache-Control: post-check=0, pre-check=0", false);
1953 } elseif ($disposition ==
"attachment") {
1954 header(
"Cache-control: private");
1956 header(
"Cache-Control: no-cache, must-revalidate");
1957 header(
"Pragma: no-cache");
1962 if (strlen($charset)) {
1963 $charset =
"; charset=$charset";
1965 header(
"Content-Type: $mime$charset");
1966 header(
"Content-Disposition:$disposition; filename=\"" .
$ascii_filename .
"\"");
1968 header(
"Content-Length: " . (
string) (strlen($a_data)));
1972 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
1973 header(
'Pragma: public');
1976 header(
"Connection: close");
1994 $removeAfterDelivery =
false,
1995 $a_exit_after =
true
1999 if (!file_exists($a_file)) {
2010 if (strlen($a_mime)) {
2011 $delivery->setMimeType($a_mime);
2014 $delivery->setDownloadFileName($a_filename);
2015 $delivery->setConvertFileNameToAsci((
bool) !
$DIC->clientIni()->readVariable(
'file_access',
'disable_ascii'));
2016 $delivery->setDeleteFile($removeAfterDelivery);
2017 $delivery->deliver();
2032 $chunksize = 1 * (1024 * 1024);
2034 $handle = fopen($a_file,
'rb');
2035 if ($handle ===
false) {
2038 while (!feof($handle)) {
2039 $buffer = fread($handle, $chunksize);
2042 return fclose($handle);
2073 $umlauts = array(
"Ä" =>
"Ae",
"Ö" =>
"Oe",
"Ü" =>
"Ue",
2074 "ä" =>
"ae",
"ö" =>
"oe",
"ü" =>
"ue",
"ß" =>
"ss");
2075 foreach ($umlauts as $src => $tgt) {
2076 $a_filename = str_replace($src, $tgt, $a_filename);
2097 $sep =
'###HTMLTAG###';
2099 preg_match_all(
"@<[^>]*>@", $htmlText, $matches);
2100 $tmp = preg_replace(
"@(<[^>]*>)@", $sep, $htmlText);
2101 $tmp = explode($sep, $tmp);
2103 for (
$i = 0;
$i < count($tmp);
$i++) {
2104 $tmp[
$i] = htmlentities($tmp[
$i], ENT_COMPAT,
"UTF-8");
2107 $tmp = join($sep, $tmp);
2109 for (
$i = 0;
$i < count($matches[0]);
$i++) {
2110 $tmp = preg_replace(
"@$sep@", $matches[0][
$i], $tmp, 1);
2124 return PATH_TO_JAVA;
2143 $url = (is_int(strpos($a_url,
"?")))
2144 ? $a_url . $amp . $a_par
2145 : $a_url .
"?" . $a_par;
2170 $a_dir = trim($a_dir);
2173 if (substr($a_dir, -1) ==
"/") {
2174 $a_dir = substr($a_dir, 0, -1);
2178 if (!($path = substr($a_dir, 0, strrpos($a_dir,
"/") - strlen($a_dir)))) {
2184 return @mkdir($a_dir, fileperms($path));
2209 $dirs = array($a_dir);
2210 $a_dir = dirname($a_dir);
2213 while ($last_dirname != $a_dir) {
2214 array_unshift($dirs, $a_dir);
2215 $last_dirname = $a_dir;
2216 $a_dir = dirname($a_dir);
2220 $reverse_paths = array_reverse($dirs,
true);
2222 foreach ($reverse_paths as $key => $value) {
2223 if ($found_index == -1) {
2224 if (is_dir($value)) {
2225 $found_index = $key;
2231 foreach ($dirs as $dirindex => $dir) {
2233 if ($dirindex >= $found_index) {
2234 if (!file_exists($dir)) {
2235 if (strcmp(substr($dir, strlen($dir) - 1, 1),
"/") == 0) {
2238 $dir = substr($dir, 0, strlen($dir) - 1);
2240 if (!mkdir($dir, $umask)) {
2241 error_log(
"Can't make directory: $dir");
2244 } elseif (!is_dir($dir)) {
2245 error_log(
"$dir is not a directory");
2249 $umask = fileperms($dir);
2272 public static function delDir($a_dir, $a_clean_only =
false)
2274 if (!is_dir($a_dir) || is_int(strpos($a_dir,
".."))) {
2278 $current_dir = opendir($a_dir);
2287 while ($entryname = readdir($current_dir)) {
2288 $files[] = $entryname;
2291 foreach ($files as $file) {
2292 if (is_dir($a_dir .
"/" . $file) and ($file !=
"." and $file !=
"..")) {
2294 } elseif ($file !=
"." and $file !=
"..") {
2295 unlink($a_dir .
"/" . $file);
2299 closedir($current_dir);
2300 if (!$a_clean_only) {
2321 public static function getDir($a_dir, $a_rec =
false, $a_sub_dir =
"")
2323 $current_dir = opendir($a_dir . $a_sub_dir);
2327 $subitems = array();
2328 while ($entry = readdir($current_dir)) {
2329 if (is_dir($a_dir .
"/" . $entry)) {
2330 $dirs[$entry] = array(
"type" =>
"dir",
"entry" => $entry,
2331 "subdir" => $a_sub_dir);
2332 if ($a_rec && $entry !=
"." && $entry !=
"..") {
2334 $subitems = array_merge($subitems,
$si);
2337 if ($entry !=
"." && $entry !=
"..") {
2338 $size = filesize($a_dir . $a_sub_dir .
"/" . $entry);
2339 $files[$entry] = array(
"type" =>
"file",
"entry" => $entry,
2340 "size" =>
$size,
"subdir" => $a_sub_dir);
2347 return array_merge($dirs, $files, $subitems);
2358 if (is_array($a_arr)) {
2359 foreach ($a_arr as $k => $v) {
2373 $df = new \ILIAS\Data\Factory;
2375 return $df->clientId($clientId);
2386 if (is_array($a_data)) {
2387 foreach ($a_data as $k => $v) {
2408 public static function stripSlashes($a_str, $a_strip_html =
true, $a_allow =
"")
2410 if (ini_get(
"magic_quotes_gpc")) {
2411 $a_str = stripslashes($a_str);
2427 if (ini_get(
"magic_quotes_gpc")) {
2428 $a_str = stripslashes($a_str);
2440 public static function secureString($a_str, $a_strip_html =
true, $a_allow =
"")
2443 $only_secure =
true;
2444 $allow_tags = explode(
">", $a_allow);
2446 $allow_array = array();
2447 foreach ($allow_tags as $allow) {
2449 $allow = str_replace(
"<",
"", $allow);
2451 if (!in_array($allow, $sec_tags)) {
2452 $only_secure =
false;
2454 $allow_array[] = $allow;
2459 if (($only_secure || $a_allow ==
"") && $a_strip_html) {
2460 if ($a_allow ==
"") {
2461 $allow_array = array(
"b",
"i",
"strong",
"em",
"code",
"cite",
2462 "gap",
"sub",
"sup",
"pre",
"strike",
"bdo");
2468 $a_str = strip_tags($a_str);
2480 if ($a_strip_html) {
2490 return array(
"strong",
"em",
"u",
"strike",
"ol",
"li",
"ul",
"p",
"div",
2491 "i",
"b",
"code",
"sup",
"sub",
"pre",
"gap",
"a",
"img",
"bdo");
2496 foreach ($allow_array as $t) {
2509 array(
"param" =>
"align",
"value" =>
"left"),
2510 array(
"param" =>
"align",
"value" =>
"center"),
2511 array(
"param" =>
"align",
"value" =>
"justify"),
2512 array(
"param" =>
"align",
"value" =>
"right")
2527 foreach ($allow_array as $t) {
2540 array(
"param" =>
"align",
"value" =>
"left"),
2541 array(
"param" =>
"align",
"value" =>
"center"),
2542 array(
"param" =>
"align",
"value" =>
"justify"),
2543 array(
"param" =>
"align",
"value" =>
"right")
2565 if (ini_get(
"magic_quotes_gpc")) {
2566 return stripslashes($a_str);
2591 if ($a_make_links_clickable) {
2608 $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);
2612 foreach ($matches[0] as $match) {
2613 $matched_text = $match[0];
2617 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1, $pos2 - $pos1)));
2623 $pos1 = $pos2 + strlen($matched_text);
2625 if ($pos1 < strlen($a_str)) {
2626 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1)));
2629 $encoded = nl2br(htmlspecialchars($a_str));
2642 $att = $ws .
"[^>]*" . $ws;
2645 '/<(' . $tag . $att .
'(' . $tag_att . $ws .
'="' . $ws .
'(([$@!*()~;,_0-9A-z\/:=%.&#?+\-])*)")' . $att .
')>/i',
2650 $a_str = preg_replace(
2651 "/<" . preg_quote($found[1],
"/") .
">/i",
2652 '<' . $tag .
' ' . $tag_att . $tag_att .
'="' . $found[3] .
'">',
2655 if ($old_str == $a_str) {
2656 $ilLog->write(
"ilUtil::maskA-" . htmlentities($old_str) .
" == " .
2657 htmlentities($a_str));
2661 $a_str = str_ireplace(
2676 '/<(' . $tag .
' ' . $tag_att . $tag_att .
'="(([$@!*()~;,_0-9A-z\/:=%.&#?+\-])*)")>/i',
2681 $a_str = preg_replace(
2682 "/<" . preg_quote($found[1],
"/") .
">/i",
2686 if ($old_str == $a_str) {
2687 $ilLog->write(
"ilUtil::unmaskA-" . htmlentities($old_str) .
" == " .
2688 htmlentities($a_str));
2692 $a_str = str_replace(
'</' . $tag .
'>',
'</' . $tag .
'>', $a_str);
2696 public static function maskTag($a_str, $t, $fix_param =
"")
2698 $a_str = str_replace(
2699 array(
"<$t>",
"<" . strtoupper($t) .
">"),
2700 "<" . $t .
">",
2703 $a_str = str_replace(
2704 array(
"</$t>",
"</" . strtoupper($t) .
">"),
2705 "</" . $t .
">",
2709 if (is_array($fix_param)) {
2710 foreach ($fix_param as $p) {
2713 $a_str = str_replace(
2715 "<" .
"$t $k=\"$v\"" .
">",
2724 public static function unmaskTag($a_str, $t, $fix_param =
"")
2726 $a_str = str_replace(
"<" . $t .
">",
"<" . $t .
">", $a_str);
2727 $a_str = str_replace(
"</" . $t .
">",
"</" . $t .
">", $a_str);
2729 if (is_array($fix_param)) {
2730 foreach ($fix_param as $p) {
2733 $a_str = str_replace(
2734 "<$t $k=\"$v\">",
2735 "<" .
"$t $k=\"$v\"" .
">",
2745 $a_str = str_ireplace(
"javascript",
"jvscrpt", $a_str);
2746 $a_str = str_ireplace(array(
"%00",
"%0a",
"%0d",
"%1a",
"�",
"�",
2747 "�",
"�",
"
",
"
",
" ",
" "),
"-", $a_str);
2768 $negativestr =
"a,abbr,acronym,address,applet,area,base,basefont," .
2769 "big,blockquote,body,br,button,caption,center,cite,code,col," .
2770 "colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame," .
2771 "frameset,h1,h2,h3,h4,h5,h6,head,hr,html,i,iframe,img,input,ins,isindex,kbd," .
2772 "label,legend,li,link,map,menu,meta,noframes,noscript,object,ol," .
2773 "optgroup,option,p,param,q,s,samp,script,select,small,span," .
2774 "strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead," .
2775 "title,tr,tt,u,ul,var";
2776 $a_allow = strtolower($a_allow);
2777 $negatives = explode(
",", $negativestr);
2778 $outer_old_str =
"";
2779 while ($outer_old_str != $a_str) {
2780 $outer_old_str = $a_str;
2781 foreach ($negatives as $item) {
2782 $pos = strpos($a_allow,
"<$item>");
2785 if ($pos ===
false) {
2787 while ($old_str != $a_str) {
2789 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s*>/i",
"", $a_str);
2790 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s+([^>]*)>/i",
"", $a_str);
2798 $a_str = preg_replace(
"/<\s*\w*(\/?)(\s+[^>]*)?(\s+on[^>]*)>/i",
"", $a_str);
2801 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*javascript[^>]*>/i",
"", $a_str);
2805 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*expression[^>]*>/i",
"", $a_str);
2827 $a_str = htmlspecialchars($a_str);
2831 $a_str = str_replace(
"{",
"{", $a_str);
2832 $a_str = str_replace(
"}",
"}", $a_str);
2848 if (filter_var(
$url, FILTER_VALIDATE_URL) ===
false &&
2849 filter_var(
"http://" .
$url, FILTER_VALIDATE_URL) ===
false &&
2850 filter_var(
"http:" .
$url, FILTER_VALIDATE_URL) ===
false &&
2851 filter_var(
"http://de.de" .
$url, FILTER_VALIDATE_URL) ===
false &&
2852 filter_var(
"http://de.de/" .
$url, FILTER_VALIDATE_URL) ===
false) {
2855 if (trim(strtolower(parse_url(
$url, PHP_URL_SCHEME))) ==
"javascript") {
2858 $url = htmlspecialchars(
$url, ENT_QUOTES);
2875 return addslashes($a_str);
2893 while (($spos = strpos($a_parstr,
"=")) &&
$ok) {
2895 $cpar = substr($a_parstr, 0, $spos);
2896 $a_parstr = substr($a_parstr, $spos, strlen($a_parstr) - $spos);
2897 while (substr($cpar, 0, 1) ==
"," || substr($cpar, 0, 1) ==
" " || substr($cpar, 0, 1) == chr(13) || substr($cpar, 0, 1) == chr(10)) {
2898 $cpar = substr($cpar, 1, strlen($cpar) - 1);
2900 while (substr($cpar, strlen($cpar) - 1, 1) ==
" " || substr($cpar, strlen($cpar) - 1, 1) == chr(13) || substr($cpar, strlen($cpar) - 1, 1) == chr(10)) {
2901 $cpar = substr($cpar, 0, strlen($cpar) - 1);
2906 while ($cpar != $cpar_old) {
2908 $cpar = preg_replace(
"/[^a-zA-Z0-9_]/i",
"", $cpar);
2913 if ($spos = strpos($a_parstr,
"\"")) {
2914 $a_parstr = substr($a_parstr, $spos + 1, strlen($a_parstr) - $spos);
2915 $spos = strpos($a_parstr,
"\"");
2916 if (is_int($spos)) {
2917 $cval = substr($a_parstr, 0, $spos);
2918 $par[$cpar] = $cval;
2919 $a_parstr = substr($a_parstr, $spos + 1, strlen($a_parstr) - $spos - 1);
2938 if (is_array($a_par_arr)) {
2940 foreach ($a_par_arr as $par => $val) {
2957 $ret = $a_str .
": ";
2958 for (
$i = 0;
$i < strlen($a_str);
$i++) {
2959 $ret .= ord(substr($a_str,
$i, 1)) .
" ";
2973 if (strtolower($a_yn) ==
"y") {
3007 global $array_sortby,$array_sortorder;
3009 if (!isset($array_sortby)) {
3016 if ($array_sortorder ==
"asc") {
3020 if ($array_sortorder ==
"desc") {
3038 global $array_sortby,$array_sortorder;
3040 if ($array_sortorder ==
"asc") {
3041 return $a[
"$array_sortby"] >
$b[
"$array_sortby"];
3044 if ($array_sortorder ==
"desc") {
3045 return $a[
"$array_sortby"] <
$b[
"$array_sortby"];
3063 $a_array_sortorder = 0,
3065 $a_keep_keys =
false
3067 include_once(
"./Services/Utilities/classes/class.ilStr.php");
3070 if (!$a_keep_keys) {
3071 return self::stableSortArray($array, $a_array_sortby, $a_array_sortorder, $a_numeric, $a_keep_keys);
3075 global $array_sortby,$array_sortorder;
3076 $array_sortby = $a_array_sortby;
3078 if ($a_array_sortorder ==
"desc") {
3079 $array_sortorder =
"desc";
3081 $array_sortorder =
"asc";
3085 uasort($array, array(
"ilUtil",
"sort_func_numeric"));
3087 usort($array, array(
"ilUtil",
"sort_func_numeric"));
3091 uasort($array, array(
"ilUtil",
"sort_func"));
3093 usort($array, array(
"ilUtil",
"sort_func"));
3115 public static function stableSortArray($array, $a_array_sortby, $a_array_sortorder = 0, $a_numeric =
false)
3117 global $array_sortby,$array_sortorder;
3119 $array_sortby = $a_array_sortby;
3121 if ($a_array_sortorder ==
"desc") {
3122 $array_sortorder =
"desc";
3124 $array_sortorder =
"asc";
3128 $sort_array = array_values($array);
3138 public static function mergesort(&$array, $cmp_function =
'strcmp')
3141 if (count($array) < 2) {
3146 $halfway = count($array) / 2;
3147 $array1 = array_slice($array, 0, $halfway);
3148 $array2 = array_slice($array, $halfway);
3155 if (call_user_func($cmp_function, end($array1), $array2[0]) < 1) {
3156 $array = array_merge($array1, $array2);
3163 while ($ptr1 < count($array1) && $ptr2 < count($array2)) {
3164 if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1) {
3165 $array[] = $array1[$ptr1++];
3167 $array[] = $array2[$ptr2++];
3172 while ($ptr1 < count($array1)) {
3173 $array[] = $array1[$ptr1++];
3175 while ($ptr2 < count($array2)) {
3176 $array[] = $array2[$ptr2++];
3197 $existing_sub_key_values = array();
3199 foreach ($array as $key => $sub_array) {
3200 if (!in_array($sub_array[$sub_key], $existing_sub_key_values)) {
3201 $existing_sub_key_values[] = $sub_array[$sub_key];
3202 $target[$key] = $sub_array;
3221 $a_desired_type = strtolower($a_desired_type);
3223 $im_types = ImageTypes();
3225 switch ($a_desired_type) {
3228 if ($im_types & IMG_JPG) {
3231 if ($im_types & IMG_GIF) {
3234 if ($im_types & IMG_PNG) {
3240 if ($im_types & IMG_GIF) {
3243 if ($im_types & IMG_JPG) {
3246 if ($im_types & IMG_PNG) {
3252 if ($im_types & IMG_PNG) {
3255 if ($im_types & IMG_JPG) {
3258 if ($im_types & IMG_GIF) {
3264 if ($im_types & IMG_PNG) {
3267 if ($im_types & IMG_JPG) {
3270 if ($im_types & IMG_GIF) {
3290 if (($a_mime ==
"image/gif") || ($a_mime ==
"image/jpeg") ||
3291 ($a_mime ==
"image/png") || ($a_mime ==
"application/x-shockwave-flash") ||
3292 ($a_mime ==
"image/tiff") || ($a_mime ==
"image/x-ms-bmp") ||
3293 ($a_mime ==
"image/psd") || ($a_mime ==
"image/iff")) {
3310 if (!isset(
$DIC[
'ilCtrl']) || !
$DIC[
'ilCtrl'] instanceof
ilCtrl) {
3313 $ctrl =
$DIC->ctrl();
3315 $ctrl->redirectToURL($a_script);
3328 if (substr($a_value, 0, 4) ==
"il__") {
3329 $a_value =
"il_" . IL_INST_ID .
"_" . substr($a_value, 4, strlen($a_value) - 4);
3352 if (isset(
$DIC[
"ilErr"])) {
3356 if (empty($a_group_name)) {
3357 $message = __METHOD__ .
": No groupname given!";
3361 $clause = ($a_id) ?
" AND obj_id != " .
$ilDB->quote($a_id) .
" " :
"";
3363 $q =
"SELECT obj_id FROM object_data " .
3364 "WHERE title = " .
$ilDB->quote($a_group_name,
"text") .
" " .
3365 "AND type = " .
$ilDB->quote(
"grp",
"text") .
3368 $r =
$ilDB->query($q);
3370 if ($r->numRows()) {
3385 $my_pid = getmypid();
3386 return (
"MEMORY USAGE (% KB PID ): " . `ps -eo%mem,rss,pid | grep $my_pid`);
3397 if (strtolower(substr(php_uname(), 0, 3)) ==
"win") {
3406 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3408 return escapeshellarg($a_arg);
3422 if (ini_get(
'safe_mode') == 1) {
3425 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3426 return escapeshellcmd($a_arg);
3442 if (
ilUtil::isWindows() && strpos($cmd,
" ") !==
false && substr($cmd, 0, 1) !==
'"') {
3444 $cmd =
'"' . $cmd .
'"';
3448 if (version_compare(phpversion(),
"5.2",
"<") && strpos($args,
'"') !==
false) {
3449 $cmd =
'"' . $cmd .
" " . $args .
'"';
3453 $cmd .=
" " . $args;
3459 $cmd .=
" " . $args;
3463 $DIC->logger()->root()->debug(
"ilUtil::execQuoted: " . $cmd .
".");
3490 public static function excelTime($year =
"", $month =
"", $day =
"", $hour =
"", $minute =
"", $second =
"")
3492 $starting_time = mktime(0, 0, 0, 1, 2, 1970);
3493 if (strcmp(
"$year$month$day$hour$minute$second",
"") == 0) {
3494 $target_time = time();
3500 $target_time = mktime($hour, $minute, $second, $month, $day, $year);
3501 $difference = $target_time - $starting_time;
3502 $days = (($difference - ($difference % 86400)) / 86400);
3503 $difference = $difference - ($days * 86400) + 3600;
3506 return str_replace(
",",
".", ($days + 25570 + ($difference / 86400)));
3517 $def_arr = explode(
",", SUFFIX_REPL_DEFAULT);
3518 foreach ($def_arr as $def) {
3522 $def_arr = explode(
",", SUFFIX_REPL_ADDITIONAL);
3523 foreach ($def_arr as $def) {
3534 $file_peaces = explode(
'.', $a_initial_filename);
3536 $file_extension = array_pop($file_peaces);
3538 if (SUFFIX_REPL_ADDITIONAL) {
3539 $string_extensions = SUFFIX_REPL_DEFAULT .
"," . SUFFIX_REPL_ADDITIONAL;
3541 $string_extensions = SUFFIX_REPL_DEFAULT;
3544 $sufixes = explode(
",", $string_extensions);
3546 if (in_array($file_extension, $sufixes)) {
3547 $file_extension =
"sec";
3550 array_push($file_peaces, $file_extension);
3552 $safe_filename =
"";
3553 foreach ($file_peaces as $piece) {
3554 $safe_filename .=
"$piece";
3555 if ($piece != end($file_peaces)) {
3556 $safe_filename .=
".";
3560 return $safe_filename;
3577 if ($a_dir ==
"/" || $a_dir ==
"" || is_int(strpos($a_dir,
".."))
3578 || trim($a_old_suffix) ==
"") {
3583 if (!@is_dir($a_dir)) {
3588 $dir = opendir($a_dir);
3590 while ($file = readdir($dir)) {
3591 if ($file !=
"." and
3594 if ($file ===
'...') {
3595 unlink($a_dir .
"/" . $file);
3600 if (@is_dir($a_dir .
"/" . $file)) {
3605 if (@is_file($a_dir .
"/" . $file)) {
3607 if (strrpos($file,
'.') == (strlen($file) - 1)) {
3609 rename($a_dir .
'/' . $file, substr($a_dir .
'/' . $file, 0, -1));
3610 }
catch (Throwable $t) {
3612 unlink($a_dir .
'/' . $file);
3616 $file = substr($file, 0, -1);
3619 $path_info = pathinfo($a_dir .
"/" . $file);
3621 if (strtolower($path_info[
"extension"]) ==
3622 strtolower($a_old_suffix)) {
3623 $pos = strrpos($a_dir .
"/" . $file,
".");
3624 $new_name = substr($a_dir .
"/" . $file, 0, $pos) .
"." . $a_new_suffix;
3625 rename($a_dir .
"/" . $file, $new_name);
3635 return strpos(
$_SERVER[
"SCRIPT_FILENAME"],
"api") !==
false ||
3636 strpos(
$_SERVER[
"SCRIPT_FILENAME"],
"dummy") !==
false;
3641 if (preg_match(
"/&" . $paramName .
"=/", $qstring)) {
3642 return preg_replace(
"/&" . $paramName .
"=[^&]+/",
"&" . $paramName .
"=" . urlencode($paramValue), $qstring);
3644 return $qstring .
"&" . $paramName .
"=" . urlencode($paramValue);
3650 foreach ($parametersArray as $paramName => $paramValue) {
3665 srand((
double) microtime() * 1000000);
3667 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
3670 for (
$i = 1;
$i <= $a_number;
$i++) {
3671 $min = ($security->getPasswordMinLength() > 0)
3672 ? $security->getPasswordMinLength()
3674 $max = ($security->getPasswordMaxLength() > 0)
3675 ? $security->getPasswordMaxLength()
3680 $random = new \ilRandom();
3681 $length = $random->int($min, $max);
3682 $next = $random->int(1, 2);
3684 $vowels_uc = strtoupper($vowels);
3685 $consonants =
"bcdfghjklmnpqrstvwxyz";
3686 $consonants_uc = strtoupper($consonants);
3687 $numbers =
"1234567890";
3688 $special =
"_.+?#-*@!$%~";
3691 if ($security->getPasswordNumberOfUppercaseChars() > 0) {
3692 for ($j = 0; $j < $security->getPasswordNumberOfUppercaseChars(); $j++) {
3695 $pw.= $consonants_uc[$random->int(0, strlen($consonants_uc) - 1)];
3700 $pw.= $vowels_uc[$random->int(0, strlen($vowels_uc) - 1)];
3707 if ($security->isPasswordCharsAndNumbersEnabled()) {
3708 $pw.= $numbers[$random->int(0, strlen($numbers) - 1)];
3711 if ($security->isPasswordSpecialCharsEnabled()) {
3712 $pw.= $special[$random->int(0, strlen($special) - 1)];
3715 $num_lcase_chars = max($security->getPasswordNumberOfLowercaseChars(), $length - strlen($pw));
3716 for ($j = 0; $j < $num_lcase_chars; $j++) {
3719 $pw.= $consonants[$random->int(0, strlen($consonants) - 1)];
3724 $pw.= $vowels[$random->int(0, strlen($vowels) - 1)];
3730 $pw = str_shuffle($pw);
3739 $path = preg_replace(
"/[\/\\\]+$/",
"", $path);
3759 foreach (
$data as $k => $datum) {
3760 if (is_null($datum)) {
3763 if (is_string($datum)) {
3764 $data[$k] =
"'" . $datum .
"'";
3766 if (is_array($datum)) {
3771 return "[" . implode(
', ',
$data) .
"]";
3780 public static function virusHandling($a_file, $a_orig_name =
"", $a_clean =
true)
3786 if (IL_VIRUS_SCANNER !=
"None") {
3787 require_once(
"./Services/VirusScanner/classes/class.ilVirusScannerFactory.php");
3789 if (($vs_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"") {
3790 if ($a_clean && (IL_VIRUS_CLEAN_COMMAND !=
"")) {
3791 $clean_txt = $vs->cleanFile($a_file, $a_orig_name);
3792 if ($vs->fileCleaned()) {
3793 $vs_txt .=
"<br />" .
$lng->txt(
"cleaned_file") .
3794 "<br />" . $clean_txt;
3795 $vs_txt .=
"<br />" .
$lng->txt(
"repeat_scan");
3796 if (($vs2_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"") {
3797 return array(
false, nl2br($vs_txt) .
"<br />" .
$lng->txt(
"repeat_scan_failed") .
3798 "<br />" . nl2br($vs2_txt));
3800 return array(
true, nl2br($vs_txt) .
"<br />" .
$lng->txt(
"repeat_scan_succeded"));
3803 return array(
false, nl2br($vs_txt) .
"<br />" .
$lng->txt(
"cleaning_failed"));
3806 return array(
false, nl2br($vs_txt));
3811 return array(
true,
"");
3834 public static function moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors =
true, $a_mode =
"move_uploaded")
3837 $target_filename = basename($a_target);
3839 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
3845 $upload =
$DIC->upload();
3848 if (!$upload->hasBeenProcessed()) {
3853 if (!$upload->hasUploads()) {
3854 throw new ilException(
$DIC->language()->txt(
"upload_error_file_not_found"));
3856 $upload_result = $upload->getResults()[$a_file];
3858 $processing_status = $upload_result->getStatus();
3859 if ($processing_status->getCode() === ProcessingStatus::REJECTED) {
3860 throw new ilException($processing_status->getMessage());
3866 if (!$a_raise_errors) {
3875 $upload->moveOneFileTo($upload_result, $target_dir, $target_filesystem, $target_filename,
true);
3889 list($datum, $uhrzeit) = explode(
" ", $mysql_date_time);
3890 list($jahr, $monat, $tag) = explode(
"-", $datum);
3891 list($std, $min, $sec) = explode(
":", $uhrzeit);
3892 return mktime((
int) $std, (
int) $min, (
int) $sec, (
int) $monat, (
int) $tag, (
int) $jahr);
3903 return date(
"Y-m-d H:i:s");
3921 public static function &
processCSVRow(&$row, $quoteAll =
false, $separator =
";", $outUTF8 =
false, $compatibleWithMSExcel =
true)
3923 $resultarray = array();
3924 foreach ($row as $rowindex => $entry) {
3929 if (strpos($entry,
"\"") !==
false) {
3930 $entry = str_replace(
"\"",
"\"\"", $entry);
3933 if (strpos($entry, $separator) !==
false) {
3936 if ($compatibleWithMSExcel) {
3938 $entry = str_replace(chr(13) . chr(10), chr(10), $entry);
3942 $resultarray[$rowindex] =
"\"" . $entry .
"\"";
3944 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
3948 $resultarray[$rowindex] = $entry;
3950 $resultarray[$rowindex] = utf8_decode($entry);
3954 return $resultarray;
3958 public static function isDN($a_str)
3960 return(preg_match(
"/^[a-z]+([a-z0-9-]*[a-z0-9]+)?(\.([a-z]+([a-z0-9-]*[a-z0-9]+)?)+)*$/", $a_str));
3966 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])\." .
3967 "(\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));
4004 $rbacreview =
$DIC->rbac()->review();
4005 $ilAccess =
$DIC->access();
4008 $tree =
$DIC->repositoryTree();
4010 if (!is_array($a_obj_type)) {
4011 $where =
"WHERE type = " .
$ilDB->quote($a_obj_type,
"text") .
" ";
4013 $where =
"WHERE " .
$ilDB->in(
"type", $a_obj_type,
false,
"text") .
" ";
4018 $limit =
$ilSetting->get(
'search_max_hits', 100);
4025 $a_usr_id = $a_usr_id ? $a_usr_id :
$ilUser->getId();
4026 $a_roles = $rbacreview->assignedRoles($a_usr_id);
4030 if ($rbacreview->isAssigned($a_usr_id, SYSTEM_ROLE_ID)) {
4031 $query =
"SELECT ref_id FROM object_reference obr LEFT JOIN object_data obd ON obr.obj_id = obd.obj_id " .
4032 "LEFT JOIN tree ON obr.ref_id = tree.child " .
4038 while ($row =
$ilDB->fetchObject(
$res)) {
4040 if ($tree->isGrandChild(RECOVERY_FOLDER_ID, $row->ref_id)) {
4044 if ($counter++ >= $limit) {
4048 $ref_ids[] = $row->ref_id;
4050 return $ref_ids ? $ref_ids : array();
4054 if ($a_operation ==
'edit_permissions' or strpos($a_operation,
'create') !==
false) {
4055 $check_owner =
") ";
4057 $check_owner =
"OR owner = " .
$ilDB->quote($a_usr_id,
"integer") .
") ";
4061 $ops_id = $ops_ids[0];
4063 $and =
"AND ((" .
$ilDB->in(
"rol_id", $a_roles,
false,
"integer") .
" ";
4065 $query =
"SELECT DISTINCT(obr.ref_id),obr.obj_id,type FROM object_reference obr " .
4066 "JOIN object_data obd ON obd.obj_id = obr.obj_id " .
4067 "LEFT JOIN rbac_pa ON obr.ref_id = rbac_pa.ref_id " .
4070 "AND (" .
$ilDB->like(
"ops_id",
"text",
"%i:" . $ops_id .
"%") .
" " .
4071 "OR " .
$ilDB->like(
"ops_id",
"text",
"%:\"" . $ops_id .
"\";%") .
")) " .
4077 if ($counter >= $limit) {
4082 if ($tree->isGrandChild(RECOVERY_FOLDER_ID, $row->ref_id)) {
4087 if ($ilAccess->checkAccessOfUser($a_usr_id, $a_operation,
'', $row->ref_id, $row->type, $row->obj_id)) {
4089 $ref_ids[] = $row->ref_id;
4092 return $ref_ids ? $ref_ids : array();
4104 case strpos($a_target, ILIAS_WEB_DIR .
'/' . CLIENT_ID) === 0:
4105 case strpos($a_target,
'./' . ILIAS_WEB_DIR .
'/' . CLIENT_ID) === 0:
4106 case strpos($a_target, CLIENT_WEB_DIR) === 0:
4109 case strpos($a_target, CLIENT_DATA_DIR .
"/temp") === 0:
4112 case strpos($a_target, CLIENT_DATA_DIR) === 0:
4115 case strpos($a_target, ILIAS_ABSOLUTE_PATH .
'/Customizing') === 0:
4119 throw new InvalidArgumentException(
"Can not move files to \"$a_target\" because path can not be mapped to web, storage or customizing location.");
4122 $absTargetDir = dirname($a_target);
4123 $targetDir = LegacyPathHelper::createRelativePath($absTargetDir);
4125 return array( $targetFilesystem, $targetDir );
4135 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4145 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4155 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4156 return ilMathJax::getInstance()->insertLatexImages($a_text,
'[tex]',
'[/tex]', $a_dir .
'/teximg',
'./teximg');
4167 public static function prepareTextareaOutput($txt_output, $prepare_for_latex_output =
false, $omitNl2BrWhenTextArea =
false)
4174 if (!$omitNl2BrWhenTextArea) {
4180 if (preg_match_all(
"/(<pre>.*?<\/pre>)/ims",
$result, $matches)) {
4181 foreach ($matches[0] as $found) {
4183 if (strpos(
"\n", $found) ===
false) {
4184 $replacement =
"\n";
4186 $removed = preg_replace(
"/<br\s*?\/>/ims", $replacement, $found);
4194 if ($prepare_for_latex_output) {
4195 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4200 if ($prepare_for_latex_output) {
4221 if (strlen(strip_tags($a_text)) < strlen($a_text)) {
4249 $diff = $to->diff($from);
4252 $periods[
"years"] = $diff->format(
"%y");
4253 $periods[
"months"] = $diff->format(
"%m");
4254 $periods[
"days"] = $diff->format(
"%d");
4255 $periods[
"hours"] = $diff->format(
"%h");
4256 $periods[
"minutes"] = $diff->format(
"%i");
4257 $periods[
"seconds"] = $diff->format(
"%s");
4259 if (!array_sum($periods)) {
4263 foreach ($periods as $key => $value) {
4265 $segment_name = ($value > 1)
4267 : substr($key, 0, -1);
4268 $array[] = $value .
' ' .
$lng->txt($segment_name);
4272 $len =
sizeof($array);
4274 $array = array_slice($array, 0, (3 - $len));
4277 return implode(
', ', $array);
4283 self::getUploadSizeLimitBytes()
4299 return $lng->txt(
"file_notice") .
" $max_filesize.";
4304 $unit = array(
'',
'K',
'M',
'G',
'T',
'P');
4306 for (
$i = 0, $maxUnits = count($unit);
$size >= 1024 &&
$i <= $maxUnits;
$i++) {
4310 return round(
$size, $decimals) . $unit[
$i];
4315 $uploadSizeLimitBytes = min(
4316 self::convertPhpIniSizeValueToBytes(ini_get(
'post_max_size')),
4317 self::convertPhpIniSizeValueToBytes(ini_get(
'upload_max_filesize'))
4320 return $uploadSizeLimitBytes;
4325 if (is_numeric($phpIniSizeValue)) {
4326 return $phpIniSizeValue;
4329 $suffix = substr($phpIniSizeValue, -1);
4330 $value = substr($phpIniSizeValue, 0, -1);
4332 switch (strtoupper($suffix)) {
4363 $test_str = explode(
'_', $role_title);
4365 if ($test_str[0] ==
'il') {
4366 $test2 = (int) $test_str[3];
4367 return is_numeric($test2) ? (int) $test2 :
false;
4384 $test_str = explode(
'_', $ilias_id);
4386 if ($test_str[0] ==
'il' && $test_str[1] == $inst_id && count($test_str) == 4) {
4387 $test2 = (int) $test_str[3];
4388 return is_numeric($test2) ? (int) $test2 :
false;
4407 public static function _sortIds($a_ids, $a_table, $a_field, $a_id_name)
4418 $where =
"WHERE " . $a_id_name .
" IN (";
4422 $query =
"SELECT " . $a_id_name .
" FROM " . $a_table .
" " .
4424 "ORDER BY " . $a_field;
4428 $ids[] = $row->$a_id_name;
4430 return $ids ? $ids : array();
4464 if (!is_array($a_array) or !count($a_array)) {
4468 foreach ($a_array as $k => $item) {
4469 $a_array[$k] =
$ilDB->quote($item);
4486 $mtpl =
new ilTemplate(
"tpl.message.html",
true,
true,
"Services/Utilities");
4487 $mtpl->setCurrentBlock(
$a_type .
"_message");
4488 $mtpl->setVariable(
"TEXT", $a_txt);
4489 $mtpl->setVariable(
"MESSAGE_HEADING",
$lng->txt(
$a_type .
"_message"));
4490 $mtpl->parseCurrentBlock();
4492 return $mtpl->get();
4503 public static function sendInfo($a_info =
"", $a_keep =
false)
4508 $tpl->setOnScreenMessage(
"info", $a_info, $a_keep);
4523 if (isset(
$DIC[
"tpl"])) {
4525 $tpl->setOnScreenMessage(
"failure", $a_info, $a_keep);
4540 $tpl->setOnScreenMessage(
"question", $a_info, $a_keep);
4551 public static function sendSuccess($a_info =
"", $a_keep =
false)
4557 $tpl->setOnScreenMessage(
"success", $a_info, $a_keep);
4572 "tpl.infopanel.html",
4573 "Services/Utilities"
4575 $tpl->setCurrentBlock(
"infopanel");
4577 if (!empty(
$_SESSION[
"infopanel"][
"text"])) {
4578 $link =
"<a href=\"" .
$_SESSION[
"infopanel"][
"link"] .
"\" target=\"" .
4586 if (!empty(
$_SESSION[
"infopanel"][
"img"])) {
4587 $link .=
"<td><a href=\"" .
$_SESSION[
"infopanel"][
"link"] .
"\" target=\"" .
4590 $link .=
"<img src=\"" .
"./templates/" .
$ilUser->prefs[
"skin"] .
"/images/" .
4591 $_SESSION[
"infopanel"][
"img"] .
"\" border=\"0\" vspace=\"0\"/>";
4592 $link .=
"</a></td>";
4595 $tpl->setVariable(
"INFO_ICONS", $link);
4596 $tpl->parseCurrentBlock();
4617 if (!is_dir($directory)) {
4620 $size = @filesize($directory);
4624 if ($DIR = opendir($directory)) {
4625 while (($dirfile = readdir($DIR)) !==
false) {
4626 if (is_link($directory . DIRECTORY_SEPARATOR . $dirfile) || $dirfile ==
'.' || $dirfile ==
'..') {
4629 if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile)) {
4630 $size += filesize($directory . DIRECTORY_SEPARATOR . $dirfile);
4631 } elseif (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile)) {
4633 $dirSize =
ilUtil::dirsize($directory . DIRECTORY_SEPARATOR . $dirfile);
4635 if ($dirSize >= 0) {
4649 $random = new \ilRandom();
4650 return md5($random->int(1, 9999999) + str_replace(
" ",
"", (
string) microtime()));
4653 public static function setCookie($a_cookie_name, $a_cookie_value =
'', $a_also_set_super_global =
true, $a_set_cookie_invalid =
false)
4660 if (!(
bool) $a_set_cookie_invalid) {
4663 $expire = time() - (365 * 24 * 60 * 60);
4672 if (defined(
'IL_COOKIE_SECURE')) {
4673 $secure = IL_COOKIE_SECURE;
4686 if ((
bool) $a_also_set_super_global) {
4687 $_COOKIE[$a_cookie_name] = $a_cookie_value;
4693 return strip_tags(self::stripSlashes($a_filename));
4702 if (
$_SERVER[
'SHELL'] || php_sapi_name() ==
'cli' ||
4718 $bt = debug_backtrace();
4720 foreach ($bt as $t) {
4721 if ($cnt != 0 && ($a_limit == 0 || $cnt <= $a_limit)) {
4722 echo
"<br>" . $t[
"file"] .
", " . $t[
"function"] .
" [" . $t[
"line"] .
"]";
4745 $exploded = explode(
'_', $a_import_id);
4747 $parsed[
'orig'] = $a_import_id;
4748 if ($exploded[0] ==
'il') {
4749 $parsed[
'prefix'] = $exploded[0];
4751 if (is_numeric($exploded[1])) {
4752 $parsed[
'inst_id'] = (int) $exploded[1];
4754 $parsed[
'type'] = $exploded[2];
4756 if (is_numeric($exploded[3])) {
4757 $parsed[
'id'] = (int) $exploded[3];
4771 '/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff^|]*)\|/',
4774 PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
4779 for (
$i = 0; $vars[
$i];
$i++) {
4801 $fp = @fopen($file,
'rb');
4803 $size = filesize($file);
4819 header(
"Accept-Ranges: 0-$length");
4823 if (isset(
$_SERVER[
'HTTP_RANGE'])) {
4827 list(, $range) = explode(
'=',
$_SERVER[
'HTTP_RANGE'], 2);
4829 if (strpos($range,
',') !==
false) {
4834 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
4835 header(
"Content-Range: bytes $start-$end/$size");
4842 if ($range ==
'-') {
4845 $c_start =
$size - substr($range, 1);
4847 $range = explode(
'-', $range);
4848 $c_start = $range[0];
4849 $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] :
$size;
4855 $c_end = ($c_end > $end) ? $end : $c_end;
4857 if ($c_start > $c_end || $c_start >
$size - 1 || $c_end >=
$size) {
4858 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
4859 header(
"Content-Range: bytes $start-$end/$size");
4865 $length = $end - $start + 1;
4867 header(
'HTTP/1.1 206 Partial Content');
4870 header(
"Content-Range: bytes $start-$end/$size");
4871 header(
"Content-Length: $length");
4875 while (!feof($fp) && ($p = ftell($fp)) <= $end) {
4876 if ($p + $buffer > $end) {
4880 $buffer = $end - $p + 1;
4883 echo fread($fp, $buffer);
4925 protected static function fmtFloat($a_float, $a_decimals = 0, $a_dec_point =
null, $a_thousands_sep =
null, $a_suppress_dot_zero =
false)
4931 if ($a_dec_point ==
null) {
4936 if ($a_dec_point ==
'-lang_sep_decimal-') {
4940 if ($a_thousands_sep ==
null) {
4941 $a_thousands_sep =
$lng->txt(
'lang_sep_thousand');
4943 if ($a_thousands_sep ==
'-lang_sep_thousand-') {
4944 $a_thousands_sep =
",";
4947 $txt = number_format($a_float, $a_decimals, $a_dec_point, $a_thousands_sep);
4950 if (($a_suppress_dot_zero == 0 || $a_decimals == 0)
4951 && substr(
$txt, -2) == $a_dec_point .
'0'
4955 if ($a_float == 0 and
$txt ==
"") {
4983 if ($a_lng ==
null) {
4989 if (
$size >= $mag * $mag * $mag) {
4990 $scaled_size =
$size / $mag / $mag / $mag;
4991 $scaled_unit =
'lang_size_gb';
4993 if (
$size >= $mag * $mag) {
4994 $scaled_size =
$size / $mag / $mag;
4995 $scaled_unit =
'lang_size_mb';
4997 if (
$size >= $mag) {
4998 $scaled_size =
$size / $mag;
4999 $scaled_unit =
'lang_size_kb';
5001 $scaled_size =
$size;
5002 $scaled_unit =
'lang_size_bytes';
5008 ==
'lang_size_bytes') ? 0 : 1, $a_lng->txt(
'lang_sep_decimal'), $a_lng->txt(
'lang_sep_thousand'),
true)
5009 .
' ' . $a_lng->txt($scaled_unit);
5010 if ($a_mode ==
'long' &&
$size > $mag) {
5012 . $a_lng->txt(
'lang_size_bytes') .
')';
5025 return ((
int) $a_value) * pow(self::_getSizeMagnitude(), 2);
5030 return ((
int) $a_value) / (pow(self::_getSizeMagnitude(), 2));
5044 if (!isset(self::$db_supports_distinct_umlauts)) {
5046 $set =
$ilDB->query(
"SELECT (" .
$ilDB->quote(
"A",
"text") .
" = " .
$ilDB->quote(
"Ä",
"text") .
") t FROM DUAL ");
5047 $rec =
$ilDB->fetchAssoc($set);
5048 self::$db_supports_distinct_umlauts = !(bool) $rec[
"t"];
An exception for terminatinating execution or to throw for unit testing.
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
Base class for ILIAS Exception handling.
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 _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
Util class various functions, usage as namespace.
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 rRenameSuffix($a_dir, $a_old_suffix, $a_new_suffix)
Renames all files with certain suffix and gives them a new suffix.
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 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 unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
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.
Class FlySystemFileAccessTest.
Class ChatMainBarProvider \MainMenu\Provider.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
foreach($_POST as $key=> $value) $res
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl