37 include_once(
"./Services/Object/classes/class.ilObject.php");
40 return "<img src=\"".$filename.
"\" alt=\"".$lng->txt(
"obj_".
$a_type).
"\" title=\"".$lng->txt(
"obj_".
$a_type).
"\" border=\"0\" vspace=\"0\"/>";
57 include_once(
"./Services/Object/classes/class.ilObject.php");
71 public static function getImagePath(
$img, $module_path =
"", $mode =
"output", $offline =
false)
75 if (is_int(strpos(
$_SERVER[
"PHP_SELF"],
"setup.php")))
79 if ($module_path !=
"")
81 $module_path =
"/".$module_path;
85 $default_img =
".".$module_path.
"/templates/default/images/".
$img;
88 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
89 $current_skin = ilStyleDefinition::getCurrentSkin();
90 $current_style = ilStyleDefinition::getCurrentStyle();
92 if (is_object($styleDefinition))
94 $image_dir = $styleDefinition->getImageDirectory($current_style);
96 if ($current_skin ==
"default")
98 $user_img =
".".$module_path.
"/templates/default/".$image_dir.
"/".
$img;
99 $skin_img =
".".$module_path.
"/templates/default/images/".
$img;
101 else if (is_object($styleDefinition) && $current_skin !=
"default")
103 $user_img =
"./Customizing/global/skin/".
104 $current_skin.$module_path.
"/".$image_dir.
"/".
$img;
105 $skin_img =
"./Customizing/global/skin/".
106 $current_skin.$module_path.
"/images/".
$img;
124 return "./images/".$img;
126 else if (@file_exists($user_img) && $image_dir !=
"")
130 else if (file_exists($skin_img))
150 if (substr($relative_path, 0, 2) ==
'./')
152 $relative_path = (substr($relative_path, 1));
154 if (substr($relative_path, 0, 1) !=
'/')
156 $relative_path =
'/' . $relative_path;
158 $htmlpath = ILIAS_HTTP_PATH . $relative_path;
180 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
181 $stylesheet_name = (strlen($a_css_name))
183 : ilStyleDefinition::getCurrentStyle().
".css";
184 if (strlen($a_css_location) && (strcmp(substr($a_css_location, -1),
"/") != 0))
186 $a_css_location = $a_css_location .
"/";
191 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
192 if (ilStyleDefinition::getCurrentSkin() !=
"default")
194 $filename =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/".$a_css_location.$stylesheet_name;
198 $filename =
"./" . $a_css_location .
"templates/default/".$stylesheet_name;
201 if ($mode !=
"filesystem")
203 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
204 $vers =
"?vers=".str_replace(
".",
"-", $vers);
207 $vers .= ($skin->getVersion() !=
'' ? str_replace(
".",
"-",
'-' . $skin->getVersion()) :
'');
222 public static function getJSLocation($a_js_name, $a_js_location =
"", $add_version = FALSE)
227 $js_name = $a_js_name;
228 if (strlen($a_js_location) && (strcmp(substr($a_js_location, -1),
"/") != 0)) $a_js_location = $a_js_location .
"/";
232 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
233 if (ilStyleDefinition::getCurrentSkin() !=
"default")
235 $filename =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/".$a_js_location.$js_name;
239 $filename =
"./" . $a_js_location .
"templates/default/".$js_name;
244 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
245 $vers =
"?vers=".str_replace(
".",
"-", $vers);
266 $base .=
"../Services/Privacy/";
271 $base =
"./Services/Privacy/";
274 if (is_file($base.
"w3c/p3p.xml"))
276 return ILIAS_HTTP_PATH.
"w3c/p3p.xml";
280 return ILIAS_HTTP_PATH.
"/w3c/p3p_template.xml";
296 if ($mode !=
"filesystem")
298 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
299 $vers =
"?vers=".str_replace(
".",
"-", $vers);
303 require_once(
"./Services/Style/System/classes/class.ilStyleDefinition.php");
304 if (ilStyleDefinition::getCurrentSkin() ==
"default")
306 $in_style =
"./templates/".ilStyleDefinition::getCurrentSkin().
"/" 307 .ilStyleDefinition::getCurrentStyle().
"_cont.css";
311 $in_style =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/" 312 .ilStyleDefinition::getCurrentStyle().
"_cont.css";
315 if (is_file(
"./".$in_style))
317 return $in_style.$vers;
321 return "templates/default/delos_cont.css".$vers;
344 $style_class =
"", $attribs =
"",$disabled =
false)
348 if ($multiple ==
true)
350 $multiple =
" multiple=\"multiple\"";
358 $class =
" class=\" form-control ".$style_class.
"\"";
364 if (is_array($attribs))
366 foreach ($attribs as $key => $val)
368 $attributes .=
" ".$key.
"=\"".$val.
"\"";
373 $disabled =
' disabled=\"disabled\"';
376 $str =
"<select name=\"".$varname .
"\"".$multiple.
" $class size=\"".
$size.
"\" $attributes $disabled>\n";
393 $str .=
" <option $sty value=\"".$key.
"\"";
397 $str .=
" <option $sty value=\"".$val.
"\"";
399 if (is_array($selected) )
401 if (in_array($key,$selected))
403 $str .=
" selected=\"selected\"";
406 else if ($selected == $key)
408 $str .=
" selected=\"selected\"";
413 $str .=
">".$val.
"</option>\n";
417 $str .=
">".$lng->txt($val).
"</option>\n";
421 $str .=
"</select>\n";
437 return($values[$selected]);
451 public static function formCheckbox ($checked,$varname,$value,$disabled =
false)
453 $str =
"<input type=\"checkbox\" name=\"".$varname.
"\"";
457 $str .=
" checked=\"checked\"";
462 $str .=
" disabled=\"disabled\"";
467 if (substr($varname,-2) ==
"[]")
475 $varname_id = substr($varname,0,-2).
"_".$value;
479 $varname_id = $varname;
483 $varname_id = str_replace(
"[",
"_",$varname_id);
484 $varname_id = str_replace(
"]",
"",$varname_id);
486 $str .=
" value=\"".$value.
"\" id=\"".$varname_id.
"\" />\n";
505 $str =
"<input disabled type=\"radio\" name=\"".$varname.
"\"";
508 $str =
"<input type=\"radio\" name=\"".$varname.
"\"";
512 $str .=
" checked=\"checked\"";
515 $str .=
" value=\"".$value.
"\"";
516 $str .=
" id=\"".$value.
"\" />\n";
533 public static function formRadioButton($checked,$varname,$value,$onclick=null, $disabled =
false)
539 $str .= (
'onclick="'.$onclick.
'"');
542 $str .= (
" type=\"radio\" name=\"".$varname.
"\"");
545 $str .=
" checked=\"checked\"";
550 $str .=
" disabled=\"disabled\"";
553 $str .=
" value=\"".$value.
"\"";
555 $str .=
" id=\"".$value.
"\" />\n";
570 public static function formInput($varname,$value,$disabled =
false)
573 $str =
"<input type=\"input\" name=\"".$varname.
"\"";
579 $str .=
" value=\"".$value.
"\"";
581 $str .=
" id=\"".$value.
"\" />\n";
607 if (
"" != $a_path &&
"/" != substr($a_path, -1))
654 foreach ($emptyFields as $key => $val)
657 if ($feedback !=
"") $feedback .=
", ";
689 public static function Linkbar ($AScript,$AHits,$ALimit,$AOffset,$AParams =
array(),$ALayout =
array(), $prefix =
'')
694 $layout_prev =
"<<";
695 $layout_next =
">>";
698 if (count($ALayout > 0))
700 if ($ALayout[
"link"])
702 $layout_link =
" class=\"".$ALayout[
"link"].
"\"";
705 if ($ALayout[
"prev"])
707 $layout_prev = $ALayout[
"prev"];
710 if ($ALayout[
"next"])
712 $layout_next = $ALayout[
"next"];
718 if ($AHits > $ALimit || $AOffset > 0)
720 if (!empty($AParams))
722 foreach ($AParams as $key => $value)
728 if(strpos($AScript,
'&'))
730 $link = $AScript.
"&".
$params.$prefix.
"offset=";
734 $link = $AScript.
"?".
$params.$prefix.
"offset=";
740 $prevoffset = $AOffset - $ALimit;
741 if ($prevoffset < 0) $prevoffset = 0;
742 $LinkBar .=
"<a".$layout_link.
" href=\"".$link.$prevoffset.
"\">".$layout_prev.
" </a>";
746 $pages=intval($AHits/$ALimit);
749 if (($AHits % $ALimit))
756 for ($i = 1 ;$i <= $pages ; $i++)
758 $newoffset=$ALimit*($i-1);
760 if ($newoffset == $AOffset)
762 $LinkBar .=
"[".$i.
"] ";
766 $LinkBar .=
'<a '.$layout_link.
' href="'.
767 $link.$newoffset.
'">['.$i.
']</a> ';
774 if (! ( ($AOffset/$ALimit)==($pages-1) ) && ($pages!=1) )
776 $newoffset=$AOffset+$ALimit;
777 $LinkBar .=
"<a".$layout_link.
" href=\"".$link.$newoffset.
"\"> ".$layout_next.
"</a>";
805 $ret = preg_replace(
"/(^|[\s]+)(www\.)([A-Za-z0-9#&=?.\/\-]+)/i",
806 "$1http://$2$3",
$ret);
809 $ret = preg_replace(
"/(^|[\s]+)(ftp\.)([A-Za-z0-9#&=?.\/\-]+)/i",
810 "$1ftp://$2$3",
$ret);
817 $ret = str_replace(
'src="http://',
'"***masked_im_start***',
$ret);
819 include_once(
"./Services/Utilities/classes/class.ilMWParserAdapter.php");
824 $ret = str_replace(
'"***masked_im_start***',
'src="http://',
$ret);
828 if ($detectGotoLinks)
831 $regExp =
"<a[^>]*href=\"(".str_replace(
"/",
"\/",ILIAS_HTTP_PATH).
"\/goto.php\?target=\w+_(\d+)[^\"]*)\"[^>]*>[^<]*<\/a>";
833 $ret = preg_replace_callback(
835 array(
"ilUtil",
"replaceLinkProperties"),
839 $regExp =
"<a[^>]*href=\"(".str_replace(
"/",
"\/",ILIAS_HTTP_PATH).
"\/goto_.*[a-z0-9]+_([0-9]+)\.html)\"[^>]*>[^<]*<\/a>";
841 $ret = preg_replace_callback(
843 array(
"ilUtil",
"replaceLinkProperties"),
874 $link =
"<a href=".$matches[1].
" target=\"_self\">".
$title.
"</a>";
898 public static function makeDateSelect($prefix, $year =
"", $month =
"", $day =
"", $startyear =
"",$a_long_month =
true,$a_further_options =
array(), $emptyoption =
false)
903 if(isset($a_further_options[
'disabled'])
and $a_further_options[
'disabled'])
905 $disabled =
'disabled="disabled" ';
911 if (!strlen($year)) $year = $now[
"year"];
912 if (!strlen($month)) $month = $now[
"mon"];
913 if (!strlen($day)) $day = $now[
"mday"];
917 $month = (int) $month;
922 $sel_day .=
'<select class="form-control" ';
923 if(isset($a_further_options[
'select_attributes']))
925 foreach($a_further_options[
'select_attributes'] as $name => $value)
927 $sel_day .= ($name.
'="'.$value.
'" ');
931 $sel_day .= $disabled.
"name=\"".$prefix.
"[d]\" id=\"".$prefix.
"_d\">\n";
933 if ($emptyoption) $sel_day .=
"<option value=\"0\">--</option>\n";
934 for ($i = 1; $i <= 31; $i++)
936 $sel_day .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
938 $sel_day .=
"</select>\n";
939 $sel_day = preg_replace(
"/(value\=\"$day\")/",
"$1 selected=\"selected\"", $sel_day);
942 $sel_month =
'<select class="form-control" ';
943 if(isset($a_further_options[
'select_attributes']))
945 foreach($a_further_options[
'select_attributes'] as $name => $value)
947 $sel_month .= ($name.
'="'.$value.
'" ');
950 $sel_month .= $disabled.
"name=\"".$prefix.
"[m]\" id=\"".$prefix.
"_m\">\n";
952 if ($emptyoption) $sel_month .=
"<option value=\"0\">--</option>\n";
953 for ($i = 1; $i <= 12; $i++)
957 $sel_month .=
"<option value=\"$i\">" . $lng->txt(
"month_" . sprintf(
"%02d", $i) .
"_long") .
"</option>\n";
961 $sel_month .=
"<option value=\"$i\">" . $i .
"</option>\n";
964 $sel_month .=
"</select>\n";
965 $sel_month = preg_replace(
"/(value\=\"$month\")/",
"$1 selected=\"selected\"", $sel_month);
968 $sel_year =
'<select class="form-control" ';
969 if(isset($a_further_options[
'select_attributes']))
971 foreach($a_further_options[
'select_attributes'] as $name => $value)
973 $sel_year .= ($name.
'="'.$value.
'" ');
976 $sel_year .= $disabled.
"name=\"".$prefix.
"[y]\" id=\"".$prefix.
"_y\">\n";
977 if ((strlen($startyear) == 0) || ($startyear > $year))
979 if (!$emptyoption || $year != 0) $startyear = $year - 5;
982 if(($year + 5) < (
date(
'Y',
time()) + 5))
988 $end_year = $year + 5;
991 if ($emptyoption) $sel_year .=
"<option value=\"0\">----</option>\n";
992 for ($i = $startyear; $i <= $end_year; $i++)
994 $sel_year .=
"<option value=\"$i\">" . sprintf(
"%04d", $i) .
"</option>\n";
996 $sel_year .=
"</select>\n";
997 $sel_year = preg_replace(
"/(value\=\"$year\")/",
"$1 selected=\"selected\"", $sel_year);
1000 $dateformat =
"d-m-Y";
1001 $dateformat = strtolower(preg_replace(
"/\W/",
"", $dateformat));
1002 $dateformat = strtolower(preg_replace(
"/(\w)/",
"%%$1", $dateformat));
1003 $dateformat = preg_replace(
"/%%d/", $sel_day, $dateformat);
1004 $dateformat = preg_replace(
"/%%m/", $sel_month, $dateformat);
1005 $dateformat = preg_replace(
"/%%y/", $sel_year, $dateformat);
1027 public static function makeTimeSelect($prefix, $short =
true, $hour =
"", $minute =
"", $second =
"",$a_use_default =
true,$a_further_options =
array())
1033 if(count($a_further_options))
1035 if(isset($a_further_options[
'minute_steps']))
1037 $minute_steps = $a_further_options[
'minute_steps'];
1039 if(isset($a_further_options[
'disabled'])
and $a_further_options[
'disabled'])
1041 $disabled =
'disabled="disabled" ';
1045 if ($a_use_default
and !strlen(
"$hour$minute$second")) {
1052 $minute = (int)$minute;
1053 $second = (int)$second;
1056 $sel_hour =
'<select ';
1057 if(isset($a_further_options[
'select_attributes']))
1059 foreach($a_further_options[
'select_attributes'] as $name => $value)
1061 $sel_hour .= $name.
'='.$value.
' ';
1064 $sel_hour .=
" ".$disabled.
"name=\"".$prefix.
"[h]\" id=\"".$prefix.
"_h\" class=\"form-control\">\n";
1066 $format = $ilUser->getTimeFormat();
1067 for ($i = 0; $i <= 23; $i++)
1071 $sel_hour .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1075 $sel_hour .=
"<option value=\"$i\">" .
date(
"ga", mktime($i, 0, 0)) .
"</option>\n";
1078 $sel_hour .=
"</select>\n";
1079 $sel_hour = preg_replace(
"/(value\=\"$hour\")/",
"$1 selected=\"selected\"", $sel_hour);
1082 $sel_minute .=
"<select ".$disabled.
"name=\"".$prefix.
"[m]\" id=\"".$prefix.
"_m\" class=\"form-control\">\n";
1084 for ($i = 0; $i <= 59; $i = $i + $minute_steps)
1086 $sel_minute .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1088 $sel_minute .=
"</select>\n";
1089 $sel_minute = preg_replace(
"/(value\=\"$minute\")/",
"$1 selected=\"selected\"", $sel_minute);
1093 $sel_second .=
"<select ".$disabled.
"name=\"".$prefix.
"[s]\" id=\"".$prefix.
"_s\" class=\"form-control\">\n";
1095 for ($i = 0; $i <= 59; $i++)
1097 $sel_second .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1099 $sel_second .=
"</select>\n";
1100 $sel_second = preg_replace(
"/(value\=\"$second\")/",
"$1 selected=\"selected\"", $sel_second);
1102 $timeformat = $lng->text[
"lang_timeformat"];
1103 if (strlen($timeformat) == 0) $timeformat =
"H:i:s";
1104 $timeformat = strtolower(preg_replace(
"/\W/",
"", $timeformat));
1105 $timeformat = preg_replace(
"/(\w)/",
"%%$1", $timeformat);
1106 $timeformat = preg_replace(
"/%%h/", $sel_hour, $timeformat);
1107 $timeformat = preg_replace(
"/%%i/", $sel_minute, $timeformat);
1109 $timeformat = preg_replace(
"/%%s/",
"", $timeformat);
1111 $timeformat = preg_replace(
"/%%s/", $sel_second, $timeformat);
1135 if(is_object($ilErr))
1139 require_once
'Services/Mail/classes/Address/Parser/class.ilMailRfc822AddressParserFactory.php';
1141 $addresses =
$parser->parse();
1152 "AC|AD|AE|AERO|AF|AG|AI|AL|AM|AN|AO|AQ|AR|ARPA|AS|ASIA|AT|AU|AW|AX|AZ|BA|BB|BD|BE|BF|BG|BH|BI|BIZ|BJ|BM|BN|BO|BR|BS|BT|BV|BW|BY|".
1153 "BZ|CA|CAT|CC|CD|CF|CG|CH|CI|CK|CL|CM|CN|CO|COM|COOP|CR|CU|CV|CX|CY|CZ|DE|DJ|DK|DM|DO|DZ|EC|EDU|EE|EG|".
1154 "ER|ES|ET|EU|FI|FJ|FK|FM|FO|FR|GA|GB|GD|GE|GF|GG|GH|GI|GL|GM|GN|GOV|GP|GQ|GR|GS|GT|GU|GW|GY|HK|HM|HN|HR|HT|".
1155 "HU|ID|IE|IL|IM|IN|INFO|INT|IO|IQ|IR|IS|IT|JE|JM|JO|JOBS|JP|KE|KG|KH|KI|KM|KN|KP|KR|KW|KY|KZ|LA|LB|LC|".
1156 "LI|LK|LR|LS|LT|LU|LV|LY|MA|MC|MD|ME|MG|MH|MIL|MK|ML|MM|MN|MO|MOBI|MP|MQ|MR|MS|MT|MU|MUSEUM|MV|MW|MX|".
1157 "MY|MZ|NA|NAME|NC|NE|NET|NF|NG|NI|NL|NO|NP|NR|NU|NZ|OM|ORG|PA|PE|PF|PG|PH|PK|PL|PM|PN|PR|PRO|PS|".
1158 "PT|PW|PY|QA|RE|RO|RS|RU|RW|SA|SB|SC|SD|SE|SG|SH|SI|SJ|SK|SL|SM|SN|SO|SR|ST|SU|SV|SY|SZ|TC|TD|TEL|".
1159 "TF|TG|TH|TJ|TK|TL|TM|TN|TO|TP|TR|TRAVEL|TT|TV|TW|TZ|UA|UG|UK|US|UY|UZ|VA|VC|VE|VG|VI|VN|VU|".
1160 "WF|WS|XN|YE|YT|YU|ZA|ZM|ZW");
1162 return(preg_match(
"/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(".$tlds.
")|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$a_email));
1174 public static function isPassword($a_passwd, &$customError = null)
1178 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1182 if( empty($a_passwd) )
1184 $customError = $lng->txt(
'password_empty');
1192 if( $security->getPasswordMinLength() > 0 && strlen($a_passwd) < $security->getPasswordMinLength() )
1194 $errors[] = sprintf( $lng->txt(
'password_to_short'), $security->getPasswordMinLength() );
1195 $isPassword =
false;
1200 if( $security->getPasswordMaxLength() > 0 && strlen($a_passwd) > $security->getPasswordMaxLength() )
1202 $errors[] = sprintf( $lng->txt(
'password_to_long'), $security->getPasswordMaxLength() );
1203 $isPassword =
false;
1207 if( $security->isPasswordCharsAndNumbersEnabled() )
1209 $hasCharsAndNumbers =
true;
1212 if( !preg_match(
'/[A-Za-z]+/',$a_passwd) )
1214 $hasCharsAndNumbers =
false;
1218 if( !preg_match(
'/[0-9]+/',$a_passwd) )
1220 $hasCharsAndNumbers =
false;
1223 if( !$hasCharsAndNumbers )
1225 $errors[] = $lng->txt(
'password_must_chars_and_numbers');
1226 $isPassword =
false;
1230 require_once
'Services/Utilities/classes/class.ilStr.php';
1231 if($security->getPasswordNumberOfUppercaseChars() > 0)
1233 if(
ilStr::strLen($a_passwd) -
ilStr::strLen(preg_replace(
'/[A-Z]/',
'', $a_passwd)) < $security->getPasswordNumberOfUppercaseChars())
1235 $errors[] = sprintf($lng->txt(
'password_must_contain_ucase_chars'), $security->getPasswordNumberOfUppercaseChars());
1236 $isPassword =
false;
1240 if($security->getPasswordNumberOfLowercaseChars() > 0)
1242 if(
ilStr::strLen($a_passwd) -
ilStr::strLen(preg_replace(
'/[a-z]/',
'', $a_passwd)) < $security->getPasswordNumberOfLowercaseChars())
1244 $errors[] = sprintf($lng->txt(
'password_must_contain_lcase_chars'), $security->getPasswordNumberOfLowercaseChars());
1245 $isPassword =
false;
1250 if( $security->isPasswordSpecialCharsEnabled() )
1253 if( !preg_match( self::getPasswordValidChars(
true,
true) , $a_passwd) )
1255 $errors[] = $lng->txt(
'password_must_special_chars');
1256 $isPassword =
false;
1261 if( !preg_match( self::getPasswordValidChars() , $a_passwd) )
1263 $errors[] = $lng->txt(
'password_contains_invalid_chars');
1264 $isPassword =
false;
1274 $customError = $lng->txt(
'password_multiple_errors');
1275 $customError .=
'<br />'.implode(
'<br />',
$errors);
1289 include_once
'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
1294 if(is_string($user))
1298 else if(is_array($user))
1301 $login = $user[
'login'];
1302 $userId = $user[
'id'];
1306 $login = $user->getLogin();
1307 $userId = $user->getId();
1312 if($login && (
int)$security->getPasswordMustNotContainLoginnameStatus() &&
1313 strpos(strtolower($clear_text_password), strtolower($login)) !== false
1316 $error_language_variable =
'password_contains_parts_of_login_err';
1334 if( $a_only_special_chars )
1336 return '/[_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+/';
1340 return '/^[A-Za-z0-9_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+$/';
1345 return 'A-Z a-z 0-9 _.+?#-*@!$%~/:;';
1360 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1363 $infos =
array(sprintf($lng->txt(
'password_allow_chars'), self::getPasswordValidChars(
false)));
1366 if( $security->getPasswordMinLength() > 0 )
1368 $infos[] = sprintf( $lng->txt(
'password_to_short'), $security->getPasswordMinLength() );
1372 if( $security->getPasswordMaxLength() > 0 )
1374 $infos[] = sprintf( $lng->txt(
'password_to_long'), $security->getPasswordMaxLength() );
1378 if( $security->isPasswordCharsAndNumbersEnabled() )
1380 $infos[] = $lng->txt(
'password_must_chars_and_numbers');
1384 if( $security->isPasswordSpecialCharsEnabled() )
1386 $infos[] = $lng->txt(
'password_must_special_chars');
1389 if($security->getPasswordNumberOfUppercaseChars() > 0)
1391 $infos[] = sprintf($lng->txt(
'password_must_contain_ucase_chars'), $security->getPasswordNumberOfUppercaseChars());
1394 if($security->getPasswordNumberOfLowercaseChars() > 0)
1396 $infos[] = sprintf($lng->txt(
'password_must_contain_lcase_chars'), $security->getPasswordNumberOfLowercaseChars());
1399 return implode(
'<br />', $infos);
1410 if (empty($a_login))
1415 if (strlen($a_login) < 3)
1423 if (!preg_match(
"/^[A-Za-z0-9_\.\+\*\@!\$\%\~\-]+$/", $a_login))
1444 public static function shortenText ($a_str, $a_len, $a_dots =
false, $a_next_blank =
false,
1445 $a_keep_extension =
false)
1447 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1463 if ($a_keep_extension)
1465 $p = strrpos($a_str,
'.');
1467 if ($p ===
false || $p == 0 || strlen($a_str) - $p > $a_len)
1472 $a_str .=
"\xe2\x80\xa6";
1479 $a_str =
ilStr::subStr($a_str,0,$len - (strlen($a_str) - $p + 1)).
"\xe2\x80\xa6".substr($a_str, $p);
1483 $a_str =
ilStr::subStr($a_str,0,$len - (strlen($a_str) - $p + 1)).substr($a_str, $p);
1503 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1504 $str_arr = explode(
" ", $a_str);
1506 for ($i = 0; $i < count($str_arr); $i++)
1513 $str_arr[$i].=
"...";
1518 return implode($str_arr,
" ");
1533 while (is_int(strpos($a_str,
"=")))
1535 $eq_pos = strpos($a_str,
"=");
1536 $qu1_pos = strpos($a_str,
"\"");
1537 $qu2_pos = strpos(substr($a_str, $qu1_pos + 1),
"\"") + $qu1_pos + 1;
1538 if (is_int($eq_pos) && is_int($qu1_pos) && is_int($qu2_pos))
1540 $var = trim(substr($a_str, 0, $eq_pos));
1541 $val = trim(substr($a_str, $qu1_pos + 1, ($qu2_pos - $qu1_pos) - 1));
1542 $attribs[$var] = $val;
1543 $a_str = substr($a_str, $qu2_pos + 1);
1564 public static function rCopy ($a_sdir, $a_tdir, $preserveTimeAttributes =
false)
1567 if (!@is_dir($a_sdir)
or 1574 $dir = opendir($a_sdir);
1576 while(
$file = readdir($dir))
1582 if (@is_dir($a_sdir.
"/".
$file))
1584 if (!@is_dir($a_tdir.
"/".
$file))
1599 if (@is_file($a_sdir.
"/".
$file))
1601 if (!copy($a_sdir.
"/".
$file,$a_tdir.
"/".
$file))
1605 if ($preserveTimeAttributes)
1606 touch($a_tdir.
"/".
$file, filectime($a_sdir.
"/".
$file));
1625 if ($mode ==
"filesystem")
1627 return "./".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1633 return "../".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1637 return "./".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1652 return CLIENT_DATA_DIR;
1669 include_once(
"./Services/User/classes/class.ilObjUser.php");
1670 return ilObjUser::_getUsersOnline($a_user_id);
1685 include_once(
"./Services/User/classes/class.ilObjUser.php");
1698 if($a_temp_path === null )
1704 $temp_path = $a_temp_path;
1707 if (!is_dir($temp_path))
1711 $temp_name = tempnam($temp_path,
"tmp");
1717 $temp_name = str_replace(
"\\",
"/", $temp_name);
1747 public static function unzip($a_file, $overwrite =
false, $a_flat =
false)
1751 $log = $DIC->logger()->root();
1753 if (!is_file($a_file))
1763 copy($a_file, $tmpdir.DIRECTORY_SEPARATOR.basename($a_file));
1764 $orig_file = $a_file;
1765 $a_file = $tmpdir.DIRECTORY_SEPARATOR.basename($a_file);
1766 $origpathinfo = pathinfo($orig_file);
1769 $pathinfo = pathinfo($a_file);
1770 $dir = $pathinfo[
"dirname"];
1771 $file = $pathinfo[
"basename"];
1776 $unzip = PATH_TO_UNZIP;
1822 $unzipcmd =
"-o ".ilUtil::escapeShellArg(
$file);
1830 $dir_realpath = realpath($dir);
1836 if (substr(
$target, 0, strlen($dir_realpath)) != $dir_realpath)
1839 $log->info(
"Removed symlink " . $name);
1847 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
1848 $filearray =
array();
1850 if (is_array($filearray[
"file"]))
1852 foreach ($filearray[
"file"] as $k => $f)
1854 if (substr($f, 0, 1) !=
"." && $f != basename($orig_file))
1856 copy($filearray[
"path"][$k].$f, $origpathinfo[
"dirname"].DIRECTORY_SEPARATOR.$f);
1870 public static function zip($a_dir, $a_file, $compress_content =
false)
1874 if($compress_content)
1877 $pathinfo = pathinfo($a_dir);
1878 chdir($pathinfo[
"dirname"]);
1881 $pathinfo = pathinfo($a_file);
1882 $dir = $pathinfo[
"dirname"];
1883 $file = $pathinfo[
"basename"];
1885 if(!$compress_content)
1898 if (is_array($a_dir))
1901 foreach($a_dir as $dir)
1903 $name = basename($dir);
1904 $source.=
" ".ilUtil::escapeShellArg($name);
1909 $name = basename($a_dir);
1910 if (trim($name) !=
"*")
1920 $zipcmd =
"-r ".ilUtil::escapeShellArg($a_file).
" ".$source;
1930 $pathinfo = pathinfo($a_dir);
1931 chdir($pathinfo[
"dirname"]);
1933 $pathinfo = pathinfo($a_file);
1934 $dir = $pathinfo[
"dirname"];
1935 $file = $pathinfo[
"basename"]; $zipcmd =
"-r ".ilUtil::escapeShellArg($a_file).
" ".$source;
1937 $mkisofs = PATH_TO_MKISOFS;
1944 $name = basename($a_dir);
1947 $zipcmd =
"-r -J -o ".$a_file.
" ".$source;
1963 return PATH_TO_CONVERT;
1987 $current_version = self::processConvertVersion($current_version[0]);
1988 $version = self::processConvertVersion($a_version);
2004 if(preg_match(
"/([0-9]+)\.([0-9]+)\.([0-9]+)([\.|\-]([0-9]+))?/", $a_version, $match))
2006 $version = str_pad($match[1], 2, 0, STR_PAD_LEFT).
2007 str_pad($match[2], 2, 0, STR_PAD_LEFT).
2008 str_pad($match[3], 2, 0, STR_PAD_LEFT).
2009 str_pad($match[5], 2, 0, STR_PAD_LEFT);
2023 public static function convertImage($a_from, $a_to, $a_target_format =
"", $a_geometry =
"",
2024 $a_background_color =
"")
2026 $format_str = ($a_target_format !=
"")
2027 ? strtoupper($a_target_format).
":" 2030 if ($a_geometry !=
"")
2032 if (is_int(strpos($a_geometry,
"x")))
2034 $geometry =
" -geometry ".$a_geometry.
" ";
2038 $geometry =
" -geometry ".$a_geometry.
"x".$a_geometry.
" ";
2042 $bg_color = ($a_background_color !=
"")
2043 ?
" -background color ".$a_background_color.
" " 2045 $convert_cmd =
ilUtil::escapeShellArg($a_from).
" ".$bg_color.$geometry.ilUtil::escapeShellArg($format_str.$a_to);
2060 public static function resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop =
false)
2062 if ($a_constrain_prop)
2064 $size =
" -geometry ".$a_width.
"x".$a_height.
" ";
2068 $size =
" -resize ".$a_width.
"x".$a_height.
"! ";
2081 public static function img($a_src, $a_alt =
"", $a_width =
"", $a_height =
"", $a_border = 0, $a_id =
"", $a_class =
"")
2083 $img =
'<img src="'.$a_src.
'"';
2086 $img.=
' alt="'.htmlspecialchars($a_alt).
'" title="'.htmlspecialchars($a_alt).
'"';
2090 $img.=
' width="'.htmlspecialchars($a_width).
'"';
2092 if ($a_height !=
"")
2094 $img.=
' height="'.htmlspecialchars($a_height).
'"';
2098 $img.=
' class="'.$a_class.
'"';
2102 $img.=
' id="'.$a_id.
'"';
2104 $img.=
' border="'.(int) $a_border.
'"/>';
2115 public static function deliverData($a_data, $a_filename, $mime =
"application/octet-stream", $charset =
"")
2117 $disposition =
"attachment";
2120 include_once
'./Services/Http/classes/class.ilHTTPS.php';
2130 #header("Pragma: "); 2131 #header("Cache-Control: "); 2132 #header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 2133 #header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 2134 #header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 2135 #header("Cache-Control: post-check=0, pre-check=0", false); 2137 else if ($disposition ==
"attachment")
2139 header(
"Cache-control: private");
2143 header(
"Cache-Control: no-cache, must-revalidate");
2144 header(
"Pragma: no-cache");
2149 if (strlen($charset))
2151 $charset =
"; charset=$charset";
2153 header(
"Content-Type: $mime$charset");
2154 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
2155 header(
"Content-Description: ".$ascii_filename);
2156 header(
"Content-Length: ".(
string)(strlen($a_data)));
2161 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
2162 header(
'Pragma: public');
2165 header(
"Connection: close");
2178 public static function deliverFile($a_file, $a_filename,$a_mime =
'', $isInline =
false, $removeAfterDelivery =
false,
2179 $a_exit_after =
true)
2182 if(!file_exists($a_file))
2188 $disposition =
"inline";
2190 $disposition =
"attachment";
2201 $mime =
"application/octet-stream";
2205 if ($disposition ==
"attachment")
2207 header(
"Cache-control: private");
2211 header(
"Cache-Control: no-cache, must-revalidate");
2212 header(
"Pragma: no-cache");
2217 header(
"Content-Type: $mime");
2218 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
2219 header(
"Content-Description: ".$ascii_filename);
2222 $filesize = @filesize($a_file);
2225 header(
"Content-Length: ".(
string)$filesize);
2228 include_once
'./Services/Http/classes/class.ilHTTPS.php';
2229 #if($_SERVER['HTTPS']) 2232 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
2233 header(
'Pragma: public');
2236 header(
"Connection: close");
2238 if ($removeAfterDelivery)
2260 $chunksize = 1*(1024*1024);
2262 $handle = fopen($a_file,
'rb');
2263 if ($handle ===
false)
2267 while (!feof($handle))
2269 $buffer = fread($handle, $chunksize);
2272 return fclose($handle);
2303 $umlauts =
array(
"Ä"=>
"Ae",
"Ö"=>
"Oe",
"Ü"=>
"Ue",
2304 "ä"=>
"ae",
"ö"=>
"oe",
"ü"=>
"ue",
"ß"=>
"ss");
2305 foreach($umlauts as $src => $tgt)
2307 $a_filename = str_replace($src, $tgt, $a_filename);
2310 $ascii_filename = htmlentities($a_filename, ENT_NOQUOTES,
'UTF-8');
2311 $ascii_filename = preg_replace(
'/\&(.)[^;]*;/',
'\\1', $ascii_filename);
2312 $ascii_filename = preg_replace(
'/[\x7f-\xff]/',
'_', $ascii_filename);
2315 $ascii_filename = preg_replace(
'/[:\x5c\/\*\?\"<>\|]/',
'_', $ascii_filename);
2316 return $ascii_filename;
2328 $sep =
'###HTMLTAG###';
2330 preg_match_all(
"@<[^>]*>@", $htmlText, $matches);
2331 $tmp = preg_replace(
"@(<[^>]*>)@", $sep, $htmlText);
2332 $tmp = explode($sep, $tmp);
2334 for ($i=0; $i<count($tmp); $i++)
2335 $tmp[$i] = htmlentities($tmp[$i], ENT_COMPAT,
"UTF-8");
2337 $tmp = join($sep, $tmp);
2339 for ($i=0; $i<count($matches[0]); $i++)
2340 $tmp = preg_replace(
"@$sep@", $matches[0][$i], $tmp, 1);
2353 return PATH_TO_JAVA;
2372 $url = (is_int(strpos($a_url,
"?")))
2373 ? $a_url.$amp.$a_par
2374 : $a_url.
"?".$a_par;
2396 $a_dir = trim($a_dir);
2399 if (substr($a_dir,-1) ==
"/")
2401 $a_dir = substr($a_dir,0,-1);
2405 if (!(
$path = substr($a_dir,0, strrpos($a_dir,
"/") - strlen($a_dir))))
2412 return @mkdir($a_dir,fileperms(
$path));
2432 $dirs =
array($a_dir);
2433 $a_dir = dirname($a_dir);
2436 while($last_dirname != $a_dir)
2438 array_unshift($dirs, $a_dir);
2439 $last_dirname = $a_dir;
2440 $a_dir = dirname($a_dir);
2444 $reverse_paths = array_reverse($dirs, TRUE);
2446 foreach ($reverse_paths as $key => $value)
2448 if ($found_index == -1)
2452 $found_index = $key;
2458 foreach ($dirs as $dirindex => $dir)
2461 if ($dirindex >= $found_index)
2463 if (! file_exists($dir))
2465 if (strcmp(substr($dir,strlen($dir)-1,1),
"/") == 0)
2469 $dir = substr($dir,0,strlen($dir)-1);
2471 if (! mkdir($dir, $umask))
2473 error_log(
"Can't make directory: $dir");
2477 elseif (! is_dir($dir))
2485 $umask = fileperms($dir);
2501 public static function delDir($a_dir, $a_clean_only =
false)
2503 if (!is_dir($a_dir) || is_int(strpos($a_dir,
"..")))
2508 $current_dir = opendir($a_dir);
2517 while($entryname = readdir($current_dir))
2524 if(is_dir($a_dir.
"/".$file)
and ($file !=
"." and $file!=
".."))
2528 elseif ($file !=
"." and $file !=
"..")
2530 unlink(${a_dir}.
"/".${
file});
2534 closedir($current_dir);
2548 public static function getDir($a_dir, $a_rec =
false, $a_sub_dir =
"")
2550 $current_dir = opendir($a_dir.$a_sub_dir);
2554 $subitems =
array();
2555 while($entry = readdir($current_dir))
2557 if(is_dir($a_dir.
"/".$entry))
2559 $dirs[$entry] =
array(
"type" =>
"dir",
"entry" => $entry,
2560 "subdir" => $a_sub_dir);
2561 if ($a_rec && $entry !=
"." && $entry !=
"..")
2564 $subitems = array_merge($subitems,
$si);
2569 if ($entry !=
"." && $entry !=
"..")
2571 $size = filesize($a_dir.$a_sub_dir.
"/".$entry);
2572 $files[$entry] =
array(
"type" =>
"file",
"entry" => $entry,
2573 "size" =>
$size,
"subdir" => $a_sub_dir);
2580 return array_merge($dirs,
$files, $subitems);
2591 if (is_array($a_arr))
2593 foreach ($a_arr as $k => $v)
2610 if (is_array($a_data))
2612 foreach ($a_data as $k => $v)
2639 public static function stripSlashes($a_str, $a_strip_html =
true, $a_allow =
"")
2641 if (ini_get(
"magic_quotes_gpc"))
2643 $a_str = stripslashes($a_str);
2659 if (ini_get(
"magic_quotes_gpc"))
2661 $a_str = stripslashes($a_str);
2673 public static function secureString($a_str, $a_strip_html =
true, $a_allow =
"")
2676 $only_secure =
true;
2677 $allow_tags = explode(
">", $a_allow);
2679 $allow_array =
array();
2680 foreach($allow_tags as $allow)
2684 $allow = str_replace(
"<",
"", $allow);
2686 if (!in_array($allow, $sec_tags))
2688 $only_secure =
false;
2690 $allow_array[] = $allow;
2695 if (($only_secure || $a_allow ==
"") && $a_strip_html)
2699 $allow_array =
array (
"b",
"i",
"strong",
"em",
"code",
"cite",
2700 "gap",
"sub",
"sup",
"pre",
"strike",
"bdo");
2706 $a_str = strip_tags($a_str);
2731 return array(
"strong",
"em",
"u",
"strike",
"ol",
"li",
"ul",
"p",
"div",
2732 "i",
"b",
"code",
"sup",
"sub",
"pre",
"gap",
"a",
"img",
"bdo");
2737 foreach ($allow_array as
$t)
2752 array(
"param" =>
"align",
"value" =>
"left"),
2753 array(
"param" =>
"align",
"value" =>
"center"),
2754 array(
"param" =>
"align",
"value" =>
"justify"),
2755 array(
"param" =>
"align",
"value" =>
"right")
2770 foreach ($allow_array as
$t)
2785 array(
"param" =>
"align",
"value" =>
"left"),
2786 array(
"param" =>
"align",
"value" =>
"center"),
2787 array(
"param" =>
"align",
"value" =>
"justify"),
2788 array(
"param" =>
"align",
"value" =>
"right")
2810 if (ini_get(
"magic_quotes_gpc"))
2812 return stripslashes($a_str);
2839 if ($a_make_links_clickable)
2857 $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);
2860 foreach ($matches as $match)
2863 foreach ($matches[0] as $match)
2865 $matched_text = $match[0];
2867 if ($matched_offset != previous_offset)
2870 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1, $pos2 - $pos1)));
2876 $pos1 = $pos2 + strlen($matched_text);
2878 if ($pos1 < strlen($a_str))
2880 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1)));
2885 $encoded = nl2br(htmlspecialchars($a_str));
2896 $att = $ws.
"[^>]*".$ws;
2898 while (preg_match(
'/<('.$tag.$att.
'('.$tag_att.$ws.
'="'.$ws.
'(([$@!*()~;,_0-9A-z\/:=%.&#?+\-])*)")'.$att.
')>/i',
2902 $a_str = preg_replace(
"/<".preg_quote($found[1],
"/").
">/i",
2903 '<'.$tag.
' '.$tag_att.$tag_att.
'="'.$found[3].
'">', $a_str);
2904 if ($old_str == $a_str)
2906 $ilLog->write(
"ilUtil::maskA-".htmlentities($old_str).
" == ".
2907 htmlentities($a_str));
2911 $a_str = str_ireplace(
"</$tag>",
2912 "</$tag>", $a_str);
2920 while (preg_match(
'/<('.$tag.
' '.$tag_att.$tag_att.
'="(([$@!*()~;,_0-9A-z\/:=%.&#?+\-])*)")>/i',
2924 $a_str = preg_replace(
"/<".preg_quote($found[1],
"/").
">/i",
2926 if ($old_str == $a_str)
2928 $ilLog->write(
"ilUtil::unmaskA-".htmlentities($old_str).
" == ".
2929 htmlentities($a_str));
2933 $a_str = str_replace(
'</'.$tag.
'>',
'</'.$tag.
'>', $a_str);
2939 $a_str = str_replace(
array(
"<$t>",
"<".strtoupper(
$t).
">"),
2940 "<".
$t.
">", $a_str);
2941 $a_str = str_replace(
array(
"</$t>",
"</".strtoupper(
$t).
">"),
2942 "</".
$t.
">", $a_str);
2944 if (is_array($fix_param))
2946 foreach ($fix_param as $p)
2950 $a_str = str_replace(
"<$t $k=\"$v\">",
2951 "<".
"$t $k=\"$v\"".
">", $a_str);
2960 $a_str = str_replace(
"<".
$t.
">",
"<".$t.
">", $a_str);
2961 $a_str = str_replace(
"</".
$t.
">",
"</".$t.
">", $a_str);
2963 if (is_array($fix_param))
2965 foreach ($fix_param as $p)
2969 $a_str = str_replace(
"<$t $k=\"$v\">",
2970 "<".
"$t $k=\"$v\"".
">", $a_str);
2978 $a_str = str_ireplace(
"javascript",
"jvscrpt", $a_str);
2979 $a_str = str_ireplace(
array(
"%00",
"%0a",
"%0d",
"%1a",
"�",
"�",
2980 "�",
"�",
"
",
"
",
" ",
" "),
"-", $a_str);
3001 $negativestr =
"a,abbr,acronym,address,applet,area,base,basefont,".
3002 "big,blockquote,body,br,button,caption,center,cite,code,col,".
3003 "colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame,".
3004 "frameset,h1,h2,h3,h4,h5,h6,head,hr,html,i,iframe,img,input,ins,isindex,kbd,".
3005 "label,legend,li,link,map,menu,meta,noframes,noscript,object,ol,".
3006 "optgroup,option,p,param,q,s,samp,script,select,small,span,".
3007 "strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,".
3008 "title,tr,tt,u,ul,var";
3009 $a_allow = strtolower ($a_allow);
3010 $negatives = explode(
",",$negativestr);
3011 $outer_old_str =
"";
3012 while($outer_old_str != $a_str)
3014 $outer_old_str = $a_str;
3015 foreach ($negatives as $item)
3017 $pos = strpos($a_allow,
"<$item>");
3023 while($old_str != $a_str)
3026 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s*>/i",
"", $a_str);
3027 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s+([^>]*)>/i",
"", $a_str);
3036 $a_str = preg_replace(
"/<\s*\w*(\/?)(\s+[^>]*)?(\s+on[^>]*)>/i",
"", $a_str);
3039 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*javascript[^>]*>/i",
"", $a_str);
3043 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*expression[^>]*>/i",
"", $a_str);
3066 $a_str = htmlspecialchars($a_str);
3070 $a_str = str_replace(
"{",
"{", $a_str);
3071 $a_str = str_replace(
"}",
"}", $a_str);
3087 if (filter_var(
$url, FILTER_VALIDATE_URL) ===
false &&
3088 filter_var(
"http://".
$url, FILTER_VALIDATE_URL) ===
false &&
3089 filter_var(
"http:".
$url, FILTER_VALIDATE_URL) ===
false &&
3090 filter_var(
"http://de.de".
$url, FILTER_VALIDATE_URL) ===
false &&
3091 filter_var(
"http://de.de/".
$url, FILTER_VALIDATE_URL) ===
false)
3095 if (trim(strtolower(parse_url(
$url, PHP_URL_SCHEME))) ==
"javascript")
3099 $url = htmlspecialchars(
$url, ENT_QUOTES);
3116 return addslashes($a_str);
3148 while(($spos=strpos($a_parstr,
"=")) &&
$ok)
3151 $cpar = substr($a_parstr,0,$spos);
3152 $a_parstr = substr($a_parstr,$spos,strlen($a_parstr)-$spos);
3153 while(substr($cpar,0,1)==
"," ||substr($cpar,0,1)==
" " || substr($cpar,0,1)==chr(13) || substr($cpar,0,1)==chr(10))
3154 $cpar = substr($cpar,1,strlen($cpar)-1);
3155 while(substr($cpar,strlen($cpar)-1,1)==
" " || substr($cpar,strlen($cpar)-1,1)==chr(13) || substr($cpar,strlen($cpar)-1,1)==chr(10))
3156 $cpar = substr($cpar,0,strlen($cpar)-1);
3160 while($cpar != $cpar_old)
3163 $cpar = preg_replace(
"/[^a-zA-Z0-9_]/i",
"", $cpar);
3169 if($spos=strpos($a_parstr,
"\""))
3171 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos);
3172 $spos=strpos($a_parstr,
"\"");
3175 $cval = substr($a_parstr,0,$spos);
3177 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos-1);
3187 if(
$ok)
return $par;
else return false;
3192 if (is_array($a_par_arr))
3195 foreach ($a_par_arr as $par => $val)
3214 for($i=0; $i<strlen($a_str); $i++)
3216 $ret.= ord(substr($a_str,$i,1)).
" ";
3230 if(strtolower($a_yn) ==
"y")
3270 global $array_sortby,$array_sortorder;
3272 if(!isset($array_sortby))
3280 if ($array_sortorder ==
"asc")
3285 if ($array_sortorder ==
"desc")
3287 return !
ilStr::strCmp($a[$array_sortby], $b[$array_sortby]);
3304 global $array_sortby,$array_sortorder;
3306 if ($array_sortorder ==
"asc")
3308 return $a[
"$array_sortby"] > $b[
"$array_sortby"];
3311 if ($array_sortorder ==
"desc")
3313 return $a[
"$array_sortby"] < $b[
"$array_sortby"];
3328 public static function sortArray($array,$a_array_sortby,$a_array_sortorder = 0,$a_numeric =
false,
3329 $a_keep_keys =
false)
3331 include_once(
"./Services/Utilities/classes/class.ilStr.php");
3334 if (! $a_keep_keys) {
3335 return self::stableSortArray($array,$a_array_sortby,$a_array_sortorder,$a_numeric,$a_keep_keys);
3339 global $array_sortby,$array_sortorder;
3341 $array_sortby = $a_array_sortby;
3343 if ($a_array_sortorder ==
"desc")
3345 $array_sortorder =
"desc";
3349 $array_sortorder =
"asc";
3355 uasort($array,
array(
"ilUtil",
"sort_func_numeric"));
3359 usort($array,
array(
"ilUtil",
"sort_func_numeric"));
3366 uasort($array,
array(
"ilUtil",
"sort_func"));
3370 usort($array,
array(
"ilUtil",
"sort_func"));
3392 public static function stableSortArray($array,$a_array_sortby,$a_array_sortorder = 0,$a_numeric =
false)
3394 global $array_sortby,$array_sortorder;
3396 $array_sortby = $a_array_sortby;
3398 if ($a_array_sortorder ==
"desc")
3400 $array_sortorder =
"desc";
3404 $array_sortorder =
"asc";
3408 $sort_array = array_values($array);
3421 public static function mergesort(&$array, $cmp_function =
'strcmp') {
3423 if (count($array) < 2)
return;
3426 $halfway = count($array) / 2;
3427 $array1 = array_slice($array, 0, $halfway);
3428 $array2 = array_slice($array, $halfway);
3435 if (call_user_func($cmp_function, end($array1), $array2[0]) < 1) {
3436 $array = array_merge($array1, $array2);
3443 while ($ptr1 < count($array1) && $ptr2 < count($array2)) {
3444 if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1) {
3445 $array[] = $array1[$ptr1++];
3448 $array[] = $array2[$ptr2++];
3453 while ($ptr1 < count($array1)) $array[] = $array1[$ptr1++];
3454 while ($ptr2 < count($array2)) $array[] = $array2[$ptr2++];
3474 $existing_sub_key_values =
array();
3476 foreach ($array as $key=>$sub_array)
3478 if (!in_array($sub_array[$sub_key], $existing_sub_key_values))
3480 $existing_sub_key_values[] = $sub_array[$sub_key];
3500 $a_desired_type = strtolower($a_desired_type);
3502 $im_types = ImageTypes();
3504 switch($a_desired_type)
3508 if ($im_types & IMG_JPG)
return "jpg";
3509 if ($im_types & IMG_GIF)
return "gif";
3510 if ($im_types & IMG_PNG)
return "png";
3514 if ($im_types & IMG_GIF)
return "gif";
3515 if ($im_types & IMG_JPG)
return "jpg";
3516 if ($im_types & IMG_PNG)
return "png";
3520 if ($im_types & IMG_PNG)
return "png";
3521 if ($im_types & IMG_JPG)
return "jpg";
3522 if ($im_types & IMG_GIF)
return "gif";
3526 if ($im_types & IMG_PNG)
return "png";
3527 if ($im_types & IMG_JPG)
return "jpg";
3528 if ($im_types & IMG_GIF)
return "gif";
3546 if (($a_mime ==
"image/gif") || ($a_mime ==
"image/jpeg") ||
3547 ($a_mime ==
"image/png") || ($a_mime ==
"application/x-shockwave-flash") ||
3548 ($a_mime ==
"image/tiff") || ($a_mime ==
"image/x-ms-bmp") ||
3549 ($a_mime ==
"image/psd") || ($a_mime ==
"image/iff"))
3569 global
$log, $PHP_SELF;
3572 if (!is_int(strpos($a_script,
"://")))
3574 if (substr($a_script, 0, 1) !=
"/" &&
defined(
"ILIAS_HTTP_PATH"))
3576 if (is_int(strpos(
$_SERVER[
"PHP_SELF"],
"/setup/")))
3578 $a_script =
"setup/".$a_script;
3580 $a_script = ILIAS_HTTP_PATH.
"/".$a_script;
3586 global $ilPluginAdmin;
3587 if (is_object($ilPluginAdmin))
3589 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_SERVICE,
"UIComponent",
"uihk");
3590 foreach ($pl_names as $pl)
3593 $gui_class = $ui_plugin->getUIClassInstance();
3594 $resp = $gui_class->getHTML(
"Services/Utilities",
"redirect",
array(
"html" => $a_script));
3597 $a_script = $gui_class->modifyHTML($a_script, $resp);
3606 session_write_close();
3608 header(
"Location: ".$a_script);
3622 if (substr($a_value, 0, 4) ==
"il__")
3624 $a_value =
"il_".IL_INST_ID.
"_".substr($a_value, 4, strlen($a_value) - 4);
3644 if (empty($a_group_name))
3646 $message = __METHOD__.
": No groupname given!";
3647 $ilErr->raiseError($message,$ilErr->WARNING);
3650 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
3652 $q =
"SELECT obj_id FROM object_data ".
3653 "WHERE title = ".$ilDB->quote($a_group_name,
"text").
" ".
3654 "AND type = ".$ilDB->quote(
"grp",
"text").
3657 $r = $ilDB->query($q);
3677 $my_pid = getmypid();
3678 return (
"MEMORY USAGE (% KB PID ): ".`ps -eo%mem,rss,pid | grep $my_pid`);
3689 if (strtolower(substr(php_uname(), 0, 3)) ==
"win")
3699 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3701 return escapeshellarg($a_arg);
3715 if(ini_get(
'safe_mode') == 1)
3719 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3720 return escapeshellcmd($a_arg);
3739 $cmd =
'"'.$cmd.
'"';
3744 if (version_compare(phpversion(),
"5.2",
"<") && strpos($args,
'"') !==
false)
3746 $cmd =
'"'.$cmd.
" ".$args.
'"';
3789 public static function excelTime($year =
"", $month =
"", $day =
"", $hour =
"", $minute =
"", $second =
"")
3791 $starting_time = mktime(0, 0, 0, 1, 2, 1970);
3792 if (strcmp(
"$year$month$day$hour$minute$second",
"") == 0)
3794 $target_time =
time();
3803 $target_time = mktime($hour, $minute, $second, $month, $day, $year);
3804 $difference = $target_time - $starting_time;
3805 $days = (($difference - ($difference % 86400)) / 86400);
3806 $difference = $difference - ($days * 86400) + 3600;
3809 return str_replace(
",",
".", ($days + 25570 + ($difference / 86400)));
3820 $def_arr = explode(
",", SUFFIX_REPL_DEFAULT);
3821 foreach ($def_arr as $def)
3826 $def_arr = explode(
",", SUFFIX_REPL_ADDITIONAL);
3827 foreach ($def_arr as $def)
3847 if ($a_dir ==
"/" || $a_dir ==
"" || is_int(strpos($a_dir,
".."))
3848 || trim($a_old_suffix) ==
"")
3854 if (!@is_dir($a_dir))
3860 $dir = opendir($a_dir);
3862 while(
$file = readdir($dir))
3868 if (@is_dir($a_dir.
"/".
$file))
3874 if (@is_file($a_dir.
"/".
$file))
3877 if(strrpos(
$file,
'.') == (strlen(
$file) - 1))
3879 rename($a_dir.
'/'.
$file,substr($a_dir.
'/'.
$file,0,-1));
3883 $path_info = pathinfo($a_dir.
"/".
$file);
3885 if (strtolower($path_info[
"extension"]) ==
3886 strtolower($a_old_suffix))
3888 $pos = strrpos($a_dir.
"/".
$file,
".");
3889 $new_name = substr($a_dir.
"/".
$file, 0, $pos).
".".$a_new_suffix;
3890 rename($a_dir.
"/".
$file, $new_name);
3899 return strpos(
$_SERVER[
"SCRIPT_FILENAME"],
"api") !==
false ||
3900 strpos(
$_SERVER[
"SCRIPT_FILENAME"],
"dummy") !==
false;
3904 if (preg_match(
"/&" . $paramName .
"=/", $qstring)) {
3905 return preg_replace(
"/&" . $paramName .
"=[^&]+/",
"&" . $paramName .
"=" . urlencode($paramValue), $qstring);
3907 return $qstring .
"&" . $paramName .
"=" . urlencode($paramValue);
3913 foreach ($parametersArray as $paramName => $paramValue ) {
3928 srand((
double) microtime()*1000000);
3930 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
3933 for ($i=1; $i<=$a_number; $i++)
3935 $min = ($security->getPasswordMinLength() > 0)
3936 ? $security->getPasswordMinLength()
3938 $max = ($security->getPasswordMaxLength() > 0)
3939 ? $security->getPasswordMaxLength()
3945 $length = rand($min,$max);
3948 $vowels_uc = strtoupper($vowels);
3949 $consonants =
"bcdfghjklmnpqrstvwxyz";
3950 $consonants_uc = strtoupper($consonants);
3951 $numbers =
"1234567890";
3952 $special =
"_.+?#-*@!$%~";
3955 if($security->getPasswordNumberOfUppercaseChars() > 0)
3957 for($j = 0; $j < $security->getPasswordNumberOfUppercaseChars(); $j++)
3962 $pw.= $consonants_uc[rand(0, strlen($consonants_uc) - 1)];
3967 $pw.= $vowels_uc[rand(0, strlen($vowels_uc) - 1)];
3974 if($security->isPasswordCharsAndNumbersEnabled())
3976 $pw.= $numbers[rand(0, strlen($numbers) - 1)];
3979 if($security->isPasswordSpecialCharsEnabled())
3981 $pw.= $special[rand(0, strlen($special) - 1)];
3984 $num_lcase_chars = max($security->getPasswordNumberOfLowercaseChars(), $length - strlen($pw));
3985 for($j = 0; $j < $num_lcase_chars; $j++)
3990 $pw.= $consonants[rand(0, strlen($consonants) - 1)];
3995 $pw.= $vowels[rand(0, strlen($vowels) - 1)];
4001 $pw = str_shuffle($pw);
4010 $path = preg_replace(
"/[\/\\\]+$/",
"",
$path);
4031 foreach(
$data as $k=>$datum)
4033 if(is_null($datum))
$data[$k] =
'null';
4034 if(is_string($datum))
$data[$k] =
"'" . $datum .
"'";
4038 return "[" . implode(
', ',
$data) .
"]";
4047 public static function virusHandling($a_file, $a_orig_name =
"", $a_clean =
true)
4051 if (IL_VIRUS_SCANNER !=
"None")
4053 require_once(
"./Services/VirusScanner/classes/class.ilVirusScannerFactory.php");
4055 if (($vs_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
4057 if ($a_clean && (IL_VIRUS_CLEAN_COMMAND !=
""))
4059 $clean_txt = $vs->cleanFile($a_file, $a_orig_name);
4060 if ($vs->fileCleaned())
4062 $vs_txt.=
"<br />".$lng->txt(
"cleaned_file").
4063 "<br />".$clean_txt;
4064 $vs_txt.=
"<br />".$lng->txt(
"repeat_scan");
4065 if (($vs2_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
4067 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_failed").
4068 "<br />".nl2br($vs2_txt));
4072 return array(
true, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_succeded"));
4077 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"cleaning_failed"));
4082 return array(
false, nl2br($vs_txt));
4087 return array(
true,
"");
4097 $a_mode =
"move_uploaded")
4099 global
$lng, $ilias;
4101 if (!is_file($a_file))
4103 if ($a_raise_errors)
4105 $ilias->raiseError($lng->txt(
"upload_error_file_not_found"), $ilias->error_obj->MESSAGE);
4119 if ($a_raise_errors)
4121 $ilias->raiseError($lng->txt(
"file_is_infected").
"<br />".
4123 $ilias->error_obj->MESSAGE);
4138 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
4143 return rename($a_file, $a_target);
4147 return copy($a_file, $a_target);
4151 return move_uploaded_file($a_file, $a_target);
4165 list($datum, $uhrzeit) = explode (
" ",$mysql_date_time);
4166 list($jahr, $monat, $tag) = explode(
"-", $datum);
4167 list($std, $min, $sec) = explode(
":", $uhrzeit);
4168 return mktime ((
int) $std, (
int) $min, (
int) $sec, (
int) $monat, (
int) $tag, (
int) $jahr);
4179 return date(
"Y-m-d H:i:s");
4197 public static function &
processCSVRow(&
$row, $quoteAll = FALSE, $separator =
";", $outUTF8 = FALSE, $compatibleWithMSExcel = TRUE)
4199 $resultarray =
array();
4200 foreach (
$row as $rowindex => $entry)
4207 if (strpos($entry,
"\"") !== FALSE)
4209 $entry = str_replace(
"\"",
"\"\"", $entry);
4212 if (strpos($entry, $separator) !== FALSE)
4216 if ($compatibleWithMSExcel)
4219 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
4225 $resultarray[$rowindex] =
"\"" . $entry .
"\"";
4229 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
4236 $resultarray[$rowindex] = $entry;
4240 $resultarray[$rowindex] = utf8_decode($entry);
4244 return $resultarray;
4248 public static function isDN($a_str)
4250 return(preg_match(
"/^[a-z]+([a-z0-9-]*[a-z0-9]+)?(\.([a-z]+([a-z0-9-]*[a-z0-9]+)?)+)*$/",$a_str));
4256 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])\.".
4257 "(\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));
4291 global
$ilDB,$rbacreview,$ilAccess,
$ilUser,$ilias,$tree;
4293 if(!is_array($a_obj_type))
4295 $where =
"WHERE type = ".$ilDB->quote($a_obj_type,
"text").
" ";
4299 $where =
"WHERE ".$ilDB->in(
"type", $a_obj_type,
false,
"text").
" ";
4305 $limit = $ilias->getSetting(
'search_max_hits',100);
4313 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
4314 $a_roles = $rbacreview->assignedRoles($a_usr_id);
4318 if($rbacreview->isAssigned($a_usr_id,SYSTEM_ROLE_ID))
4320 $query =
"SELECT ref_id FROM object_reference obr LEFT JOIN object_data obd ON obr.obj_id = obd.obj_id ".
4321 "LEFT JOIN tree ON obr.ref_id = tree.child ".
4327 while(
$row = $ilDB->fetchObject(
$res))
4330 if($tree->isGrandChild(RECOVERY_FOLDER_ID,
$row->ref_id))
4340 $ref_ids[] =
$row->ref_id;
4342 return $ref_ids ? $ref_ids :
array();
4346 if($a_operation ==
'edit_permissions' or strpos($a_operation,
'create') !==
false)
4348 $check_owner =
") ";
4352 $check_owner =
"OR owner = ".$ilDB->quote($a_usr_id,
"integer").
") ";
4356 $ops_id = $ops_ids[0];
4358 $and =
"AND ((".$ilDB->in(
"rol_id", $a_roles,
false,
"integer").
" ";
4360 $query =
"SELECT DISTINCT(obr.ref_id),obr.obj_id,type FROM object_reference obr ".
4361 "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
4362 "LEFT JOIN rbac_pa ON obr.ref_id = rbac_pa.ref_id ".
4365 "AND (".$ilDB->like(
"ops_id",
"text",
"%i:".$ops_id.
"%").
" ".
4366 "OR ".$ilDB->like(
"ops_id",
"text",
"%:\"".$ops_id.
"\";%").
")) ".
4379 if($tree->isGrandChild(RECOVERY_FOLDER_ID,
$row->ref_id))
4385 if($ilAccess->checkAccessOfUser($a_usr_id,$a_operation,
'',
$row->ref_id,
$row->type,
$row->obj_id))
4388 $ref_ids[] =
$row->ref_id;
4391 return $ref_ids ? $ref_ids :
array();
4400 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4410 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4420 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4421 return ilMathJax::getInstance()->insertLatexImages($a_text,
'[tex]',
'[/tex]', $a_dir.
'/teximg',
'./teximg');
4432 public static function prepareTextareaOutput($txt_output, $prepare_for_latex_output = FALSE, $omitNl2BrWhenTextArea =
false)
4435 $is_html = self::isHTML(
$result);
4437 if ($prepare_for_latex_output)
4439 include_once
'./Services/MathJax/classes/class.ilMathJax.php';
4447 if(!$omitNl2BrWhenTextArea)
4456 if (preg_match_all(
"/(<pre>.*?<\/pre>)/ims",
$result, $matches))
4458 foreach ($matches[0] as $found)
4461 if (strpos(
"\n", $found) === FALSE)
4463 $replacement =
"\n";
4465 $removed = preg_replace(
"/<br\s*?\/>/ims", $replacement, $found);
4470 if ($prepare_for_latex_output)
4492 if( strlen(strip_tags($a_text)) < strlen($a_text) )
4520 $diff = $to->diff($from);
4523 $periods[
"years"] = $diff->format(
"%y");
4524 $periods[
"months"] = $diff->format(
"%m");
4525 $periods[
"days"] = $diff->format(
"%d");
4526 $periods[
"hours"] = $diff->format(
"%h");
4527 $periods[
"minutes"] = $diff->format(
"%i");
4528 $periods[
"seconds"] = $diff->format(
"%s");
4535 foreach (
$periods as $key => $value)
4539 $segment_name = ($value > 1)
4541 : substr($key, 0, -1);
4542 $array[] = $value .
' ' . $lng->txt($segment_name);
4546 $len =
sizeof($array);
4549 $array = array_slice($array, 0, (3-$len));
4552 return implode(
', ', $array);
4557 $max_filesize = self::formatBytes(
4558 self::getUploadSizeLimitBytes()
4572 return $lng->txt(
"file_notice").
" $max_filesize.";
4577 $unit =
array(
'',
'K',
'M',
'G',
'T',
'P');
4579 for($i = 0, $maxUnits = count($unit);
$size >= 1024 && $i <= $maxUnits; $i++)
4584 return round(
$size, $decimals).$unit[$i];
4589 $uploadSizeLimitBytes = min(
4590 self::convertPhpIniSizeValueToBytes(ini_get(
'post_max_size')),
4591 self::convertPhpIniSizeValueToBytes(ini_get(
'upload_max_filesize'))
4594 return $uploadSizeLimitBytes;
4599 if( is_numeric($phpIniSizeValue) )
4601 return $phpIniSizeValue;
4604 $suffix = substr($phpIniSizeValue, -1);
4605 $value = substr($phpIniSizeValue, 0, -1);
4607 switch( strtoupper($suffix) )
4636 $test_str = explode(
'_',$role_title);
4638 if ($test_str[0] ==
'il')
4640 $test2 = (int) $test_str[3];
4641 return is_numeric ($test2) ? (int) $test2 :
false;
4659 $test_str = explode(
'_',$ilias_id);
4661 if ($test_str[0] ==
'il' && $test_str[1] == $inst_id && count($test_str) == 4)
4663 $test2 = (int) $test_str[3];
4664 return is_numeric ($test2) ? (int) $test2 :
false;
4683 public static function _sortIds($a_ids,$a_table,$a_field,$a_id_name)
4693 $where =
"WHERE ".$a_id_name.
" IN (";
4697 $query =
"SELECT ".$a_id_name.
" FROM ".$a_table.
" ".
4699 "ORDER BY ".$a_field;
4704 $ids[] =
$row->$a_id_name;
4706 return $ids ? $ids :
array();
4736 if(!is_array($a_array)
or !count($a_array))
4741 foreach($a_array as $k => $item)
4743 $a_array[$k] = $ilDB->quote($item);
4757 public static function sendInfo($a_info =
"",$a_keep =
false)
4760 $tpl->setMessage(
"info", $a_info, $a_keep);
4777 $tpl->setMessage(
"failure", $a_info, $a_keep);
4790 $tpl->setMessage(
"question", $a_info, $a_keep);
4804 $tpl->setMessage(
"success", $a_info, $a_keep);
4813 $tpl->addBlockFile(
"INFOPANEL",
"infopanel",
"tpl.infopanel.html",
4814 "Services/Utilities");
4815 $tpl->setCurrentBlock(
"infopanel");
4817 if (!empty(
$_SESSION[
"infopanel"][
"text"]))
4819 $link =
"<a href=\"".$dir.$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4822 $link .= $lng->txt(
$_SESSION[
"infopanel"][
"text"]);
4827 if (!empty(
$_SESSION[
"infopanel"][
"img"]))
4829 $link .=
"<td><a href=\"".$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4832 $link .=
"<img src=\"".$ilias->tplPath.$ilias->account->prefs[
"skin"].
"/images/".
4833 $_SESSION[
"infopanel"][
"img"].
"\" border=\"0\" vspace=\"0\"/>";
4834 $link .=
"</a></td>";
4837 $tpl->setVariable(
"INFO_ICONS",$link);
4838 $tpl->parseCurrentBlock();
4859 if (!is_dir($directory))
4863 $size = @filesize($directory);
4867 if ($DIR = opendir($directory))
4869 while (($dirfile = readdir($DIR)) !==
false)
4871 if (is_link($directory . DIRECTORY_SEPARATOR . $dirfile) || $dirfile ==
'.' || $dirfile ==
'..')
4873 if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile))
4874 $size += filesize($directory . DIRECTORY_SEPARATOR . $dirfile);
4875 else if (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile))
4878 $dirSize =
ilUtil::dirsize($directory . DIRECTORY_SEPARATOR . $dirfile);
4892 return md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
4895 public static function setCookie($a_cookie_name,$a_cookie_value =
'', $a_also_set_super_global =
true, $a_set_cookie_invalid =
false)
4902 if(!(
bool)$a_set_cookie_invalid) $expire = 0;
4903 else $expire =
time() - (365*24*60*60);
4905 if(!
defined(
'IL_COOKIE_SECURE'))
4907 define(
'IL_COOKIE_SECURE',
false);
4910 setcookie( $a_cookie_name, $a_cookie_value, $expire,
4911 IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE, IL_COOKIE_HTTPONLY
4914 if((
bool)$a_also_set_super_global)
$_COOKIE[$a_cookie_name] = $a_cookie_value;
4919 return strip_tags(self::stripSlashes($a_filename));
4926 if(
$_SERVER[
'SHELL'] || php_sapi_name() ==
'cli' ||
4930 return $ilIliasIniFile->readVariable(
'server',
'http_path');
4934 return ILIAS_HTTP_PATH;
4945 $bt = debug_backtrace();
4949 if ($cnt != 0 && ($a_limit == 0 || $cnt <= $a_limit))
4951 echo "<br>".$t[
"file"].
", ".$t[
"function"].
" [".$t[
"line"].
"]";
4974 $exploded = explode(
'_',$a_import_id);
4976 $parsed[
'orig'] = $a_import_id;
4977 if($exploded[0] ==
'il')
4979 $parsed[
'prefix'] = $exploded[0];
4981 if(is_numeric($exploded[1]))
4983 $parsed[
'inst_id'] = (int) $exploded[1];
4985 $parsed[
'type'] = $exploded[2];
4987 if(is_numeric($exploded[3]))
4989 $parsed[
'id'] = (int) $exploded[3];
5003 '/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff^|]*)\|/',
5006 PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
5011 for($i = 0; $vars[$i]; $i++)
5013 $result[$vars[$i++]] = unserialize($vars[$i]);
5034 $fp = @fopen(
$file,
'rb');
5052 header(
"Accept-Ranges: 0-$length");
5056 if (isset(
$_SERVER[
'HTTP_RANGE'])) {
5061 list(, $range) = explode(
'=',
$_SERVER[
'HTTP_RANGE'], 2);
5063 if (strpos($range,
',') !==
false) {
5068 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
5069 header(
"Content-Range: bytes $start-$end/$size");
5076 if ($range ==
'-') {
5079 $c_start =
$size - substr($range, 1);
5083 $range = explode(
'-', $range);
5084 $c_start = $range[0];
5085 $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] :
$size;
5091 $c_end = ($c_end > $end) ? $end : $c_end;
5093 if ($c_start > $c_end || $c_start >
$size - 1 || $c_end >=
$size) {
5095 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
5096 header(
"Content-Range: bytes $start-$end/$size");
5102 $length = $end -
$start + 1;
5104 header(
'HTTP/1.1 206 Partial Content');
5107 header(
"Content-Range: bytes $start-$end/$size");
5108 header(
"Content-Length: $length");
5112 while(!feof($fp) && ($p = ftell($fp)) <= $end) {
5114 if ($p + $buffer > $end) {
5118 $buffer = $end - $p + 1;
5121 echo fread($fp, $buffer);
5163 protected static function fmtFloat($a_float, $a_decimals=0, $a_dec_point = null, $a_thousands_sep = null, $a_suppress_dot_zero=
false)
5167 if ($a_dec_point == null) {
5172 if ($a_dec_point ==
'-lang_sep_decimal-') {
5176 if ($a_thousands_sep == null) {
5177 $a_thousands_sep = $lng->txt(
'lang_sep_thousand');
5179 if ($a_thousands_sep ==
'-lang_sep_thousand-') {
5180 $a_thousands_sep =
",";
5183 $txt = number_format($a_float, $a_decimals, $a_dec_point, $a_thousands_sep);
5186 if (($a_suppress_dot_zero == 0 || $a_decimals == 0)
5187 && substr(
$txt, - 2) == $a_dec_point .
'0' 5191 if ($a_float == 0
and $txt ==
"") {
5217 if ($a_lng == null) {
5221 $mag = self::_getSizeMagnitude();
5223 if (
$size >= $mag * $mag * $mag) {
5224 $scaled_size =
$size / $mag / $mag / $mag;
5225 $scaled_unit =
'lang_size_gb';
5227 if (
$size >= $mag * $mag) {
5228 $scaled_size =
$size / $mag / $mag;
5229 $scaled_unit =
'lang_size_mb';
5231 if (
$size >= $mag) {
5232 $scaled_size =
$size / $mag;
5233 $scaled_unit =
'lang_size_kb';
5235 $scaled_size =
$size;
5236 $scaled_unit =
'lang_size_bytes';
5241 $result = self::fmtFloat($scaled_size, ($scaled_unit
5242 ==
'lang_size_bytes') ? 0 : 1, $a_lng->txt(
'lang_sep_decimal'), $a_lng->txt(
'lang_sep_thousand'),
true)
5243 .
' ' . $a_lng->txt($scaled_unit);
5244 if ($a_mode ==
'long' &&
$size > $mag) {
5245 $result .=
' (' . self::fmtFloat(
$size, 0, $a_lng->txt(
'lang_sep_decimal'), $a_lng->txt(
'lang_sep_thousand')) .
' ' 5246 . $a_lng->txt(
'lang_size_bytes') .
')';
5259 return $a_value * pow(self::_getSizeMagnitude(), 2);
5264 return $a_value / (pow(self::_getSizeMagnitude(), 2));
static maskTag($a_str, $t, $fix_param="")
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static isConvertVersionAtLeast($a_version)
Compare convert version numbers.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static getMemString()
get current memory usage as string
static tf2yn($a_tf)
convert true/false to "y"/"n"
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static removeItemFromDesktops($a_id)
removes object from all user's desktops public
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.
Base class for ILIAS Exception handling.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ...
static securePlainString($a_str)
Remove unsecure characters from a plain text string.
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 rRenameSuffix($a_dir, $a_old_suffix, $a_new_suffix)
Renames all files with certain suffix and gives them a new suffix.
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
static _getOperationIdsByName($operations)
get ops_id's by name.
static usesHTTP()
Uses HTTP aka browser.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static convertPhpIniSizeValueToBytes($phpIniSizeValue)
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static unserializeSession($data)
Returns the unserialized ILIAS session data.
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
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 sort_func_numeric($a, $b)
sub-function to sort an array
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 Linkbar($AScript, $AHits, $ALimit, $AOffset, $AParams=array(), $ALayout=array(), $prefix='')
Linkbar Diese Funktion erzeugt einen typischen Navigationsbalken mit "Previous"- und "Next"-Links und...
static strPos($a_haystack, $a_needle, $a_offset=NULL)
static unmaskAttributeTag($a_str, $tag, $tag_att)
static getSelectName($selected, $values)
???
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 _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, instead it parses the serialized rbac_pa entries.
static MB2Bytes($a_value)
static execQuoted($cmd, $args=NULL)
exec command and fix spaces on windows
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
static getParser($a_address)
static groupNameExists($a_group_name, $a_id=0)
checks if group name already exists.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
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 shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static getNewContentStyleSheetLocation($mode="output")
get full style sheet file name (path inclusive) of current user
static _getSizeMagnitude()
Returns the magnitude used for size units.
static unique_multi_array($array, $sub_key)
Make a multi-dimensional array to have only DISTINCT values for a certain "column".
static getPasswordValidChars($a_as_regex=true, $a_only_special_chars=false)
All valid chars for password.
static _lookupTitle($a_id)
lookup object title
static assembleParameterString($a_par_arr)
static generatePasswords($a_number)
Generate a number of passwords.
static deducibleSize($a_mime)
checks if mime type is provided by getimagesize()
static dumpVar($mixed=null)
Dump var.
static formatBytes($size, $decimals=0)
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 maskSecureTags($a_str, $allow_array)
Util class various functions, usage as namespace.
static isPassword($a_passwd, &$customError=null)
validates a password public
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static now()
Return current timestamp in Y-m-d H:i:s format.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
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 escapeShellCmd($a_arg)
escape shell cmd
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 getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
static isWindows()
check wether the current client system is a windows system
static processConvertVersion($a_version)
Parse convert version string, e.g.
static stripOnlySlashes($a_str)
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static buildLatexImages($a_text, $a_dir)
replace [tex]...[/tex] tags with formula image code for offline use
static _removeItemFromDesktops($a_id)
removes object from all user's desktops public
static getP3PLocation()
Get p3p file path.
static maskAttributeTag($a_str, $tag, $tag_att)
static unmaskSecureTags($a_str, $allow_array)
static _sanitizeFilemame($a_filename)
static getAssociatedUsersOnline($a_user_id)
reads all active sessions from db and returns users that are online and who have a local role in a gr...
static __extractRefId($role_title)
extract ref id from role title, e.g.
static getJavaPath()
get full java path (dir + java command)
static getConvertCmd()
get convert command
static setCookie($a_cookie_name, $a_cookie_value='', $a_also_set_super_global=true, $a_set_cookie_invalid=false)
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static formDisabledRadioButton($checked, $varname, $value, $disabled)
???
static replaceUrlParameterString($url, $parametersArray)
static resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop=false)
resize image
static execConvert($args)
execute convert command
if(!is_array($argv)) $options
static date_mysql2time($mysql_date_time)
make time object from mysql_date_time
const IL_COOKIE_PATH(isset($_GET["client_id"]))
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,7),'usr_data','lastname','usr_id') => sorts by lastname.
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 h...
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static getJSLocation($a_js_name, $a_js_location="", $add_version=FALSE)
get full javascript file name (path inclusive) of current user
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 moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static KT_replaceParam($qstring, $paramName, $paramValue)
static _lookupObjId($a_id)
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static mergesort(&$array, $cmp_function='strcmp')
static getUploadSizeLimitBytes()
static Bytes2MB($a_value)
static period2String(ilDateTime $a_from, $a_to=null)
Return a string of time period.
static setPathStr($a_path)
??? public
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static infoPanel($a_keep=true)
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
static CreateIsoFromFolder($a_dir, $a_file)
static getGDSupportedImageType($a_desired_type)
returns the best supported image type by this PHP build
static sort_func($a, $b)
sub-function to sort an array
static createDirectory($a_dir, $a_mod=0755)
create directory
Reload workbook from saved file
static clear($a_var)
Unset a value.
Add a drawing to the header
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static & processCSVRow(&$row, $quoteAll=FALSE, $separator=";", $outUTF8=FALSE, $compatibleWithMSExcel=TRUE)
Convertes an array for CSV usage.
get($a_format, $a_format_str='', $a_tz='')
get formatted date
static removeTrailingPathSeparators($path)
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
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 unmaskTag($a_str, $t, $fix_param="")
static getHtmlPath($relative_path)
get url of path
static _getAssociatedUsersOnline($a_user_id, $a_no_anonymous=false)
reads all active sessions from db and returns users that are online and who have a local role in a gr...
Create styles array
The data for the language used.
static array_php2js($data)
convert php arrays to javascript arrays
static replaceLinkProperties($matches)
replaces target _blank with _self and the link text with the according object title.
rangeDownload($file)
Send a file via range request, see http://mobiforge.com/design-development/content-delivery-mobile-de...
static formRadioButton($checked, $varname, $value, $onclick=null, $disabled=false)
??? public
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
includeMathjax($a_tpl=null)
Include Mathjax.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getInstance()
Get https instance.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
static htmlentitiesOutsideHTMLTags($htmlText)
Encodes HTML entities outside of HTML tags.
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
static secureUrl($url)
Prepare secure href attribute.
static dirsize($directory)
get size of a directory or a file.
static quoteArray($a_array)
Quotes all members of an array for usage in DB query statement.
static secureLink($a_str)
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static getDataDir()
get data directory (outside webspace)
static strToUpper($a_string)
static getInstance()
Singleton: get instance.
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
static escapeShellArg($a_arg)
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 prepareDBString($a_str)
prepare a string for db writing (insert/update)
static checkInput($vars)
???
static insertInstIntoID($a_value)
inserts installation id into ILIAS id
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
static insertLatexImages($a_text, $a_start='[tex]', $a_end='[/tex]')
replace [tex]...[/tex] tags with formula image code
static formInput($varname, $value, $disabled=false)
create html input area
static recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
static isHTML($a_text)
Checks if a given string contains HTML or not.
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 yn2tf($a_yn)
convert "y"/"n" to true/false
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
static checkFormEmpty($emptyFields)
??? public
static subStr($a_str, $a_start, $a_length=NULL)
static redirect($a_script)
http redirect to other script
static extractParameterString($a_parstr)
extracts parameter value pairs from a string into an array
static excelTime($year="", $month="", $day="", $hour="", $minute="", $second="")
Calculates a Microsoft Excel date/time value.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
static _getInstance()
Get instance of ilSecuritySettings.
static fmtFloat($a_float, $a_decimals=0, $a_dec_point=null, $a_thousands_sep=null, $a_suppress_dot_zero=false)
format a float
static getValidFilename($a_filename)
Get valid filename.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public
static printBacktrace($a_limit=0)
printBacktrace
static strCmp($a, $b)
Compare two strings.
static dumpString($a_str)
dumps ord values of every character of string $a_str
static readFile($a_file)
there are some known problems with the original readfile method, which sometimes truncates delivered ...