39 return "<img src=\"".ilUtil::getImagePath(
$filename).
"\" alt=\"".$lng->txt(
"obj_".$a_type).
"\" title=\"".$lng->txt(
"obj_".$a_type).
"\" border=\"0\" vspace=\"0\"/>";
59 if($ilSetting->get(
"custom_icons"))
66 include_once(
'./Services/Container/classes/class.ilContainer.php');
74 if ($objDefinition->isPluginTypeName($a_type))
76 $class_name =
"il".$objDefinition->getClassName($a_type).
'Plugin';
77 $location = $objDefinition->getLocation($a_type);
78 include_once(
$location.
"/class.".$class_name.
".php");
79 return call_user_func(array($class_name,
"_getIcon"), $a_type, $a_size, $a_obj_id);
107 public static function getImagePath(
$img, $module_path =
"", $mode =
"output", $offline =
false)
111 if (is_int(strpos($_SERVER[
"PHP_SELF"],
"setup.php")))
115 if ($module_path !=
"")
117 $module_path =
"/".$module_path;
121 $default_img =
".".$module_path.
"/templates/default/images/".
$img;
124 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
128 if (is_object($styleDefinition))
130 $image_dir = $styleDefinition->getImageDirectory(
134 if ($current_skin ==
"default")
136 $user_img =
".".$module_path.
"/templates/default/".$image_dir.
"/".
$img;
137 $skin_img =
".".$module_path.
"/templates/default/images/".
$img;
139 else if (is_object($styleDefinition) && $current_skin !=
"default")
141 $user_img =
"./Customizing/global/skin/".
142 $current_skin.$module_path.
"/".$image_dir.
"/".
$img;
143 $skin_img =
"./Customizing/global/skin/".
144 $current_skin.$module_path.
"/images/".
$img;
149 return "./images/".$img;
151 else if (@file_exists($user_img) && $image_dir !=
"")
155 else if (file_exists($skin_img))
175 if (substr($relative_path, 0, 2) ==
'./')
177 $relative_path = (substr($relative_path, 1));
179 if (substr($relative_path, 0, 1) !=
'/')
181 $relative_path =
'/' . $relative_path;
183 $htmlpath = ILIAS_HTTP_PATH . $relative_path;
205 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
206 $stylesheet_name = (strlen($a_css_name))
209 if (strlen($a_css_location) && (strcmp(substr($a_css_location, -1),
"/") != 0))
211 $a_css_location = $a_css_location .
"/";
216 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
219 $filename =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/".$a_css_location.$stylesheet_name;
223 $filename =
"./" . $a_css_location .
"templates/default/".$stylesheet_name;
226 if ($mode !=
"filesystem")
228 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
229 $vers =
"?vers=".str_replace(
".",
"-", $vers);
244 public static function getJSLocation($a_js_name, $a_js_location =
"", $add_version = FALSE)
249 $js_name = $a_js_name;
250 if (strlen($a_js_location) && (strcmp(substr($a_js_location, -1),
"/") != 0)) $a_js_location = $a_js_location .
"/";
254 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
257 $filename =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/".$a_js_location.$js_name;
261 $filename =
"./" . $a_js_location .
"templates/default/".$js_name;
266 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
267 $vers =
"?vers=".str_replace(
".",
"-", $vers);
283 if (defined(
"ILIAS_MODULE"))
288 $base .=
"../Services/Privacy/";
293 $base =
"./Services/Privacy/";
296 if (is_file($base.
"w3c/p3p.xml"))
298 return ILIAS_HTTP_PATH.
"w3c/p3p.xml";
302 return ILIAS_HTTP_PATH.
"/w3c/p3p_template.xml";
318 if ($mode !=
"filesystem")
320 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
321 $vers =
"?vers=".str_replace(
".",
"-", $vers);
325 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
328 $in_style =
"./templates/".ilStyleDefinition::getCurrentSkin().
"/"
329 .ilStyleDefinition::getCurrentStyle().
"_cont.css";
333 $in_style =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/"
334 .ilStyleDefinition::getCurrentStyle().
"_cont.css";
337 if (is_file(
"./".$in_style))
339 return $in_style.$vers;
343 return "templates/default/delos_cont.css".$vers;
366 $style_class =
"", $attribs =
"",$disabled =
false)
370 if ($multiple ==
true)
372 $multiple =
" multiple=\"multiple\"";
380 if ($style_class !=
"")
382 $class =
" class=\"".$style_class.
"\"";
389 if (is_array($attribs))
391 foreach ($attribs as $key => $val)
393 $attributes .=
" ".$key.
"=\"".$val.
"\"";
398 $disabled =
' disabled=\"disabled\"';
401 $str =
"<select name=\"".$varname .
"\"".$multiple.
" $class size=\"".
$size.
"\" $attributes $disabled>\n";
403 foreach ((array)
$options as $key => $val)
408 $style = $val[
"style"];
412 $sty = ($style !=
"")
413 ?
' style="'.$style.
'" '
418 $str .=
" <option $sty value=\"".$key.
"\"";
422 $str .=
" <option $sty value=\"".$val.
"\"";
424 if (is_array($selected) )
426 if (in_array($key,$selected))
428 $str .=
" selected=\"selected\"";
431 else if ($selected == $key)
433 $str .=
" selected=\"selected\"";
438 $str .=
">".$val.
"</option>\n";
442 $str .=
">".$lng->txt($val).
"</option>\n";
446 $str .=
"</select>\n";
462 return($values[$selected]);
476 public static function formCheckbox ($checked,$varname,$value,$disabled =
false)
478 $str =
"<input type=\"checkbox\" name=\"".$varname.
"\"";
482 $str .=
" checked=\"checked\"";
487 $str .=
" disabled=\"disabled\"";
492 if (substr($varname,-2) ==
"[]")
500 $varname_id = substr($varname,0,-2).
"_".$value;
504 $varname_id = $varname;
508 $varname_id = ereg_replace(
"\[",
"_",$varname_id);
509 $varname_id = ereg_replace(
"\]",
"",$varname_id);
511 $str .=
" value=\"".$value.
"\" id=\"".$varname_id.
"\" />\n";
530 $str =
"<input disabled type=\"radio\" name=\"".$varname.
"\"";
533 $str =
"<input type=\"radio\" name=\"".$varname.
"\"";
537 $str .=
" checked=\"checked\"";
540 $str .=
" value=\"".$value.
"\"";
541 $str .=
" id=\"".$value.
"\" />\n";
558 public static function formRadioButton($checked,$varname,$value,$onclick=null, $disabled =
false)
564 $str .= (
'onclick="'.$onclick.
'"');
567 $str .= (
" type=\"radio\" name=\"".$varname.
"\"");
570 $str .=
" checked=\"checked\"";
575 $str .=
" disabled=\"disabled\"";
578 $str .=
" value=\"".$value.
"\"";
580 $str .=
" id=\"".$value.
"\" />\n";
595 public static function formInput($varname,$value,$disabled =
false)
598 $str =
"<input type=\"input\" name=\"".$varname.
"\"";
604 $str .=
" value=\"".$value.
"\"";
606 $str .=
" id=\"".$value.
"\" />\n";
632 if (
"" != $a_path &&
"/" != substr($a_path, -1))
679 foreach ($emptyFields as $key => $val)
682 if ($feedback !=
"") $feedback .=
", ";
714 public static function Linkbar ($AScript,$AHits,$ALimit,$AOffset,$AParams = array(),$ALayout = array(), $prefix =
'')
719 $layout_prev =
"<<";
720 $layout_next =
">>";
723 if (count($ALayout > 0))
725 if ($ALayout[
"link"])
727 $layout_link =
" class=\"".$ALayout[
"link"].
"\"";
730 if ($ALayout[
"prev"])
732 $layout_prev = $ALayout[
"prev"];
735 if ($ALayout[
"next"])
737 $layout_next = $ALayout[
"next"];
743 if ($AHits > $ALimit || $AOffset > 0)
745 if (!empty($AParams))
747 foreach ($AParams as $key => $value)
749 $params.= $key.
"=".$value.
"&";
753 if(strpos($AScript,
'&'))
755 $link = $AScript.
"&".$params.$prefix.
"offset=";
759 $link = $AScript.
"?".$params.$prefix.
"offset=";
765 $prevoffset = $AOffset - $ALimit;
766 if ($prevoffset < 0) $prevoffset = 0;
767 $LinkBar .=
"<a".$layout_link.
" href=\"".$link.$prevoffset.
"\">".$layout_prev.
" </a>";
771 $pages=intval($AHits/$ALimit);
774 if (($AHits % $ALimit))
781 for ($i = 1 ;$i <= $pages ; $i++)
783 $newoffset=$ALimit*($i-1);
785 if ($newoffset == $AOffset)
787 $LinkBar .=
"[".$i.
"] ";
791 $LinkBar .=
'<a '.$layout_link.
' href="'.
792 $link.$newoffset.
'">['.$i.
']</a> ';
799 if (! ( ($AOffset/$ALimit)==($pages-1) ) && ($pages!=1) )
801 $newoffset=$AOffset+$ALimit;
802 $LinkBar .=
"<a".$layout_link.
" href=\"".$link.$newoffset.
"\"> ".$layout_next.
"</a>";
830 $ret = eregi_replace(
"(^|[[:space:]]+)(www\.)([[:alnum:]#?/&=\.-]+)",
831 "\\1http://\\2\\3",
$ret);
834 $ret = eregi_replace(
"(^|[[:space:]]+)(ftp\.)([[:alnum:]#?/&=\.-]+)",
835 "\\1ftp://\\2\\3",
$ret);
842 $ret = str_replace(
'src="http://',
'"***masked_im_start***',
$ret);
844 include_once(
"./Services/Utilities/classes/class.ilMWParserAdapter.php");
846 $ret = $parser->replaceFreeExternalLinks(
$ret);
849 $ret = str_replace(
'"***masked_im_start***',
'src="http://',
$ret);
853 if ($detectGotoLinks)
856 $regExp =
"<a[^>]*href=\"(".str_replace(
"/",
"\/",ILIAS_HTTP_PATH).
"\/goto.php\?target=\w+_(\d+)[^\"]*)\"[^>]*>[^<]*<\/a>";
858 $ret = preg_replace_callback(
860 array(
"ilUtil",
"replaceLinkProperties"),
864 $regExp =
"<a[^>]*href=\"(".str_replace(
"/",
"\/",ILIAS_HTTP_PATH).
"\/goto_.*[a-z0-9]+_([0-9]+)\.html)\"[^>]*>[^<]*<\/a>";
866 $ret = preg_replace_callback(
868 array(
"ilUtil",
"replaceLinkProperties"),
899 $link =
"<a href=".$matches[1].
" target=\"_self\">".$title.
"</a>";
923 public static function makeDateSelect($prefix, $year =
"", $month =
"", $day =
"", $startyear =
"",$a_long_month =
true,$a_further_options = array(), $emptyoption =
false)
928 if(isset($a_further_options[
'disabled']) and $a_further_options[
'disabled'])
930 $disabled =
'disabled="disabled" ';
936 if (!strlen($year)) $year = $now[
"year"];
937 if (!strlen($month)) $month = $now[
"mon"];
938 if (!strlen($day)) $day = $now[
"mday"];
942 $month = (int) $month;
947 $sel_day .=
'<select ';
948 if(isset($a_further_options[
'select_attributes']))
950 foreach($a_further_options[
'select_attributes'] as $name => $value)
952 $sel_day .= ($name.
'="'.$value.
'" ');
956 $sel_day .= $disabled.
"name=\"".$prefix.
"[d]\" id=\"".$prefix.
"_d\">\n";
958 if ($emptyoption) $sel_day .=
"<option value=\"0\">--</option>\n";
959 for ($i = 1; $i <= 31; $i++)
961 $sel_day .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
963 $sel_day .=
"</select>\n";
964 $sel_day = preg_replace(
"/(value\=\"$day\")/",
"$1 selected=\"selected\"", $sel_day);
967 $sel_month =
'<select ';
968 if(isset($a_further_options[
'select_attributes']))
970 foreach($a_further_options[
'select_attributes'] as $name => $value)
972 $sel_month .= ($name.
'="'.$value.
'" ');
975 $sel_month .= $disabled.
"name=\"".$prefix.
"[m]\" id=\"".$prefix.
"_m\">\n";
977 if ($emptyoption) $sel_month .=
"<option value=\"0\">--</option>\n";
978 for ($i = 1; $i <= 12; $i++)
982 $sel_month .=
"<option value=\"$i\">" . $lng->txt(
"month_" . sprintf(
"%02d", $i) .
"_long") .
"</option>\n";
986 $sel_month .=
"<option value=\"$i\">" . $i .
"</option>\n";
989 $sel_month .=
"</select>\n";
990 $sel_month = preg_replace(
"/(value\=\"$month\")/",
"$1 selected=\"selected\"", $sel_month);
993 $sel_year =
'<select ';
994 if(isset($a_further_options[
'select_attributes']))
996 foreach($a_further_options[
'select_attributes'] as $name => $value)
998 $sel_year .= ($name.
'="'.$value.
'" ');
1001 $sel_year .= $disabled.
"name=\"".$prefix.
"[y]\" id=\"".$prefix.
"_y\">\n";
1002 if ((strlen($startyear) == 0) || ($startyear > $year))
1004 if (!$emptyoption || $year != 0) $startyear = $year - 5;
1007 if(($year + 5) < (date(
'Y',time()) + 5))
1009 $end_year = date(
'Y',time()) + 5;
1013 $end_year = $year + 5;
1016 if ($emptyoption) $sel_year .=
"<option value=\"0\">----</option>\n";
1017 for ($i = $startyear; $i <= $end_year; $i++)
1019 $sel_year .=
"<option value=\"$i\">" . sprintf(
"%04d", $i) .
"</option>\n";
1021 $sel_year .=
"</select>\n";
1022 $sel_year = preg_replace(
"/(value\=\"$year\")/",
"$1 selected=\"selected\"", $sel_year);
1025 $dateformat =
"d-m-Y";
1026 $dateformat = strtolower(preg_replace(
"/\W/",
"", $dateformat));
1027 $dateformat = strtolower(preg_replace(
"/(\w)/",
"%%$1", $dateformat));
1028 $dateformat = preg_replace(
"/%%d/", $sel_day, $dateformat);
1029 $dateformat = preg_replace(
"/%%m/", $sel_month, $dateformat);
1030 $dateformat = preg_replace(
"/%%y/", $sel_year, $dateformat);
1052 public static function makeTimeSelect($prefix, $short =
true, $hour =
"", $minute =
"", $second =
"",$a_use_default =
true,$a_further_options = array())
1058 if(count($a_further_options))
1060 if(isset($a_further_options[
'minute_steps']))
1062 $minute_steps = $a_further_options[
'minute_steps'];
1064 if(isset($a_further_options[
'disabled']) and $a_further_options[
'disabled'])
1066 $disabled =
'disabled="disabled" ';
1070 if ($a_use_default and !strlen(
"$hour$minute$second")) {
1077 $minute = (int)$minute;
1078 $second = (int)$second;
1081 $sel_hour =
'<select ';
1082 if(isset($a_further_options[
'select_attributes']))
1084 foreach($a_further_options[
'select_attributes'] as $name => $value)
1086 $sel_hour .= $name.
'='.$value.
' ';
1089 $sel_hour .=
" ".$disabled.
"name=\"".$prefix.
"[h]\" id=\"".$prefix.
"_h\">\n";
1091 $format = $ilUser->getTimeFormat();
1092 for ($i = 0; $i <= 23; $i++)
1096 $sel_hour .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1100 $sel_hour .=
"<option value=\"$i\">" . date(
"ga", mktime($i, 0, 0)) .
"</option>\n";
1103 $sel_hour .=
"</select>\n";
1104 $sel_hour = preg_replace(
"/(value\=\"$hour\")/",
"$1 selected=\"selected\"", $sel_hour);
1107 $sel_minute .=
"<select ".$disabled.
"name=\"".$prefix.
"[m]\" id=\"".$prefix.
"_m\">\n";
1109 for ($i = 0; $i <= 59; $i = $i + $minute_steps)
1111 $sel_minute .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1113 $sel_minute .=
"</select>\n";
1114 $sel_minute = preg_replace(
"/(value\=\"$minute\")/",
"$1 selected=\"selected\"", $sel_minute);
1118 $sel_second .=
"<select ".$disabled.
"name=\"".$prefix.
"[s]\" id=\"".$prefix.
"_s\">\n";
1120 for ($i = 0; $i <= 59; $i++)
1122 $sel_second .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1124 $sel_second .=
"</select>\n";
1125 $sel_second = preg_replace(
"/(value\=\"$second\")/",
"$1 selected=\"selected\"", $sel_second);
1127 $timeformat = $lng->text[
"lang_timeformat"];
1128 if (strlen($timeformat) == 0) $timeformat =
"H:i:s";
1129 $timeformat = strtolower(preg_replace(
"/\W/",
"", $timeformat));
1130 $timeformat = preg_replace(
"/(\w)/",
"%%$1", $timeformat);
1131 $timeformat = preg_replace(
"/%%h/", $sel_hour, $timeformat);
1132 $timeformat = preg_replace(
"/%%i/", $sel_minute, $timeformat);
1134 $timeformat = preg_replace(
"/%%s/",
"", $timeformat);
1136 $timeformat = preg_replace(
"/%%s/", $sel_second, $timeformat);
1161 if(is_object($ilias))
1163 require_once
'./Services/PEAR/lib/Mail/RFC822.php';
1168 $addresses = $parser->parseAddressList($a_email,
'ilias',
false,
true);
1169 if(!is_a($addresses,
'PEAR_Error') &&
1170 count($addresses) == 1 && $addresses[0]->host !=
'ilias'
1188 "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|".
1189 "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|".
1190 "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|".
1191 "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|".
1192 "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|".
1193 "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|".
1194 "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|".
1195 "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|".
1196 "WF|WS|XN|YE|YT|YU|ZA|ZM|ZW");
1198 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));
1211 public static function isPassword($a_passwd, &$customError = null)
1215 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1219 if( empty($a_passwd) )
1221 $customError = $lng->txt(
'password_empty');
1229 if( $security->getPasswordMinLength() > 0 && strlen($a_passwd) < $security->getPasswordMinLength() )
1231 $errors[] = sprintf( $lng->txt(
'password_to_short'), $security->getPasswordMinLength() );
1232 $isPassword =
false;
1237 if( $security->getPasswordMaxLength() > 0 && strlen($a_passwd) > $security->getPasswordMaxLength() )
1239 $errors[] = sprintf( $lng->txt(
'password_to_long'), $security->getPasswordMaxLength() );
1240 $isPassword =
false;
1244 if( $security->isPasswordCharsAndNumbersEnabled() )
1246 $hasCharsAndNumbers =
true;
1249 if( !preg_match(
'/[A-Za-z]+/',$a_passwd) )
1251 $hasCharsAndNumbers =
false;
1255 if( !preg_match(
'/[0-9]+/',$a_passwd) )
1257 $hasCharsAndNumbers =
false;
1260 if( !$hasCharsAndNumbers )
1262 $errors[] = $lng->txt(
'password_must_chars_and_numbers');
1263 $isPassword =
false;
1267 require_once
'Services/Utilities/classes/class.ilStr.php';
1268 if($security->getPasswordNumberOfUppercaseChars() > 0)
1270 if(
ilStr::strLen($a_passwd) -
ilStr::strLen(preg_replace(
'/[A-Z]/',
'', $a_passwd)) < $security->getPasswordNumberOfUppercaseChars())
1272 $errors[] = sprintf($lng->txt(
'password_must_contain_ucase_chars'), $security->getPasswordNumberOfUppercaseChars());
1273 $isPassword =
false;
1277 if($security->getPasswordNumberOfLowercaseChars() > 0)
1279 if(
ilStr::strLen($a_passwd) -
ilStr::strLen(preg_replace(
'/[a-z]/',
'', $a_passwd)) < $security->getPasswordNumberOfLowercaseChars())
1281 $errors[] = sprintf($lng->txt(
'password_must_contain_lcase_chars'), $security->getPasswordNumberOfLowercaseChars());
1282 $isPassword =
false;
1287 if( $security->isPasswordSpecialCharsEnabled() )
1290 if( !preg_match( self::getPasswordValidChars(
true,
true) , $a_passwd) )
1292 $errors[] = $lng->txt(
'password_must_special_chars');
1293 $isPassword =
false;
1298 if( !preg_match( self::getPasswordValidChars() , $a_passwd) )
1300 $errors[] = $lng->txt(
'password_contains_invalid_chars');
1301 $isPassword =
false;
1311 $customError = $lng->txt(
'password_multiple_errors');
1312 $customError .=
'<br />'.implode(
'<br />',
$errors);
1326 include_once
'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
1331 if(is_string($user))
1335 else if(is_array($user))
1338 $login = $user[
'login'];
1339 $userId = $user[
'id'];
1343 $login = $user->getLogin();
1344 $userId = $user->getId();
1349 if($login && (
int)$security->getPasswordMustNotContainLoginnameStatus() &&
1350 strpos(strtolower($clear_text_password), strtolower($login)) !== false
1353 $error_language_variable =
'password_contains_parts_of_login_err';
1371 if( $a_only_special_chars )
1373 return '/[_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+/';
1377 return '/^[A-Za-z0-9_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+$/';
1382 return 'A-Z a-z 0-9 _.+?#-*@!$%~/:;';
1397 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1403 if( $security->getPasswordMinLength() > 0 )
1405 $infos[] = sprintf( $lng->txt(
'password_to_short'), $security->getPasswordMinLength() );
1409 if( $security->getPasswordMaxLength() > 0 )
1411 $infos[] = sprintf( $lng->txt(
'password_to_long'), $security->getPasswordMaxLength() );
1415 if( $security->isPasswordCharsAndNumbersEnabled() )
1417 $infos[] = $lng->txt(
'password_must_chars_and_numbers');
1421 if( $security->isPasswordSpecialCharsEnabled() )
1423 $infos[] = $lng->txt(
'password_must_special_chars');
1426 if($security->getPasswordNumberOfUppercaseChars() > 0)
1428 $infos[] = sprintf($lng->txt(
'password_must_contain_ucase_chars'), $security->getPasswordNumberOfUppercaseChars());
1431 if($security->getPasswordNumberOfLowercaseChars() > 0)
1433 $infos[] = sprintf($lng->txt(
'password_must_contain_lcase_chars'), $security->getPasswordNumberOfLowercaseChars());
1436 return implode(
'<br />', $infos);
1447 if (empty($a_login))
1452 if (strlen($a_login) < 3)
1460 if (!ereg(
"^[A-Za-z0-9_\.\+\*\@!\$\%\~\-]+$", $a_login))
1481 public static function shortenText ($a_str, $a_len, $a_dots =
false, $a_next_blank =
false,
1482 $a_keep_extension =
false)
1484 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1500 if ($a_keep_extension)
1502 $p = strrpos($a_str,
'.');
1504 if ($p ===
false || $p == 0 || strlen($a_str) - $p > $a_len)
1509 $a_str .=
"\xe2\x80\xa6";
1516 $a_str =
ilStr::subStr($a_str,0,$len - (strlen($a_str) - $p + 1)).
"\xe2\x80\xa6".substr($a_str, $p);
1520 $a_str =
ilStr::subStr($a_str,0,$len - (strlen($a_str) - $p + 1)).substr($a_str, $p);
1540 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1541 $str_arr = explode(
" ", $a_str);
1543 for ($i = 0; $i < count($str_arr); $i++)
1550 $str_arr[$i].=
"...";
1555 return implode($str_arr,
" ");
1570 while (is_int(strpos($a_str,
"=")))
1572 $eq_pos = strpos($a_str,
"=");
1573 $qu1_pos = strpos($a_str,
"\"");
1574 $qu2_pos = strpos(substr($a_str, $qu1_pos + 1),
"\"") + $qu1_pos + 1;
1575 if (is_int($eq_pos) && is_int($qu1_pos) && is_int($qu2_pos))
1577 $var = trim(substr($a_str, 0, $eq_pos));
1578 $val = trim(substr($a_str, $qu1_pos + 1, ($qu2_pos - $qu1_pos) - 1));
1579 $attribs[$var] = $val;
1580 $a_str = substr($a_str, $qu2_pos + 1);
1601 public static function rCopy ($a_sdir, $a_tdir, $preserveTimeAttributes =
false)
1604 if (!@is_dir($a_sdir) or
1611 $dir = opendir($a_sdir);
1613 while(
$file = readdir($dir))
1615 if (
$file !=
"." and
1619 if (@is_dir($a_sdir.
"/".
$file))
1621 if (!@is_dir($a_tdir.
"/".
$file))
1636 if (@is_file($a_sdir.
"/".
$file))
1638 if (!copy($a_sdir.
"/".
$file,$a_tdir.
"/".
$file))
1642 if ($preserveTimeAttributes)
1643 touch($a_tdir.
"/".
$file, filectime($a_sdir.
"/".
$file));
1662 if ($mode ==
"filesystem")
1664 return "./".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1668 if (defined(
"ILIAS_MODULE"))
1670 return "../".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1674 return "./".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1689 return CLIENT_DATA_DIR;
1706 include_once(
"./Services/User/classes/class.ilObjUser.php");
1707 return ilObjUser::_getUsersOnline($a_user_id);
1722 include_once(
"./Services/User/classes/class.ilObjUser.php");
1736 if (!is_dir($temp_path))
1740 $temp_name = tempnam($temp_path,
"tmp");
1746 $temp_name = str_replace(
"\\",
"/", $temp_name);
1776 public static function unzip($a_file, $overwrite =
false, $a_flat =
false)
1778 if (!is_file($a_file))
1788 copy($a_file, $tmpdir.DIRECTORY_SEPARATOR.basename($a_file));
1789 $orig_file = $a_file;
1790 $a_file = $tmpdir.DIRECTORY_SEPARATOR.basename($a_file);
1791 $origpathinfo = pathinfo($orig_file);
1794 $pathinfo = pathinfo($a_file);
1795 $dir = $pathinfo[
"dirname"];
1796 $file = $pathinfo[
"basename"];
1801 $unzip = PATH_TO_UNZIP;
1847 $unzipcmd =
"-o ".ilUtil::escapeShellArg(
$file);
1856 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
1857 $filearray = array();
1859 if (is_array($filearray[
"file"]))
1861 foreach ($filearray[
"file"] as $k => $f)
1863 if (substr($f, 0, 1) !=
"." && $f != basename($orig_file))
1865 copy($filearray[
"path"][$k].$f, $origpathinfo[
"dirname"].DIRECTORY_SEPARATOR.$f);
1879 public static function zip($a_dir, $a_file, $compress_content =
false)
1883 if($compress_content)
1886 $pathinfo = pathinfo($a_dir);
1887 chdir($pathinfo[
"dirname"]);
1890 $pathinfo = pathinfo($a_file);
1891 $dir = $pathinfo[
"dirname"];
1892 $file = $pathinfo[
"basename"];
1894 if(!$compress_content)
1907 if (is_array($a_dir))
1910 foreach($a_dir as $dir)
1912 $name = basename($dir);
1913 $source.=
" ".ilUtil::escapeShellArg($name);
1918 $name = basename($a_dir);
1919 if (trim($name) !=
"*")
1929 $zipcmd =
"-r ".ilUtil::escapeShellArg($a_file).
" ".$source;
1939 $pathinfo = pathinfo($a_dir);
1940 chdir($pathinfo[
"dirname"]);
1942 $pathinfo = pathinfo($a_file);
1943 $dir = $pathinfo[
"dirname"];
1944 $file = $pathinfo[
"basename"]; $zipcmd =
"-r ".ilUtil::escapeShellArg($a_file).
" ".$source;
1946 $mkisofs = PATH_TO_MKISOFS;
1953 $name = basename($a_dir);
1956 $zipcmd =
"-r -J -o ".$a_file.
" ".$source;
1972 return PATH_TO_CONVERT;
1998 if($current_version >= $version)
2013 if(preg_match(
"/([0-9]+)\.([0-9]+)\.([0-9]+)([\.|\-]([0-9]+))?/", $a_version, $match))
2015 $version = str_pad($match[1], 2, 0, STR_PAD_LEFT).
2016 str_pad($match[2], 2, 0, STR_PAD_LEFT).
2017 str_pad($match[3], 2, 0, STR_PAD_LEFT).
2018 str_pad($match[5], 2, 0, STR_PAD_LEFT);
2019 return (
int)$version;
2032 public static function convertImage($a_from, $a_to, $a_target_format =
"", $a_geometry =
"",
2033 $a_background_color =
"")
2035 $format_str = ($a_target_format !=
"")
2036 ? strtoupper($a_target_format).
":"
2039 if ($a_geometry !=
"")
2041 if (is_int(strpos($a_geometry,
"x")))
2043 $geometry =
" -geometry ".$a_geometry.
" ";
2047 $geometry =
" -geometry ".$a_geometry.
"x".$a_geometry.
" ";
2051 $bg_color = ($a_background_color !=
"")
2052 ?
" -background color ".$a_background_color.
" "
2054 $convert_cmd =
ilUtil::escapeShellArg($a_from).
" ".$bg_color.$geometry.ilUtil::escapeShellArg($format_str.$a_to);
2069 public static function resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop =
false)
2071 if ($a_constrain_prop)
2073 $size =
" -geometry ".$a_width.
"x".$a_height.
" ";
2077 $size =
" -resize ".$a_width.
"x".$a_height.
"! ";
2090 public static function img($a_src, $a_alt =
"", $a_width =
"", $a_height =
"", $a_border = 0, $a_id =
"")
2092 $img =
'<img src="'.$a_src.
'"';
2095 $img.=
' alt="'.$a_alt.
'" title="'.$a_alt.
'"';
2099 $img.=
' width="'.$a_width.
'"';
2101 if ($a_height !=
"")
2103 $img.=
' height="'.$a_height.
'"';
2107 $img.=
' id="'.$a_id.
'"';
2109 $img.=
' border="'.(int) $a_border.
'"/>';
2123 $html_file = str_replace(
".pdf",
".html",$pdf_file);
2125 $fp = fopen( $html_file ,
"wb");
2140 $htmldoc_path = PATH_TO_HTMLDOC;
2142 $htmldoc =
"--no-toc ";
2143 $htmldoc .=
"--no-jpeg ";
2144 $htmldoc .=
"--webpage ";
2146 $htmldoc .=
"--bodyfont Arial ";
2147 $htmldoc .=
"--charset iso-8859-15 ";
2148 $htmldoc .=
"--color ";
2149 $htmldoc .=
"--size A4 ";
2150 $htmldoc .=
"--format pdf ";
2151 $htmldoc .=
"--footer ... ";
2152 $htmldoc .=
"--header ... ";
2153 $htmldoc .=
"--left 60 ";
2155 $htmldoc .= $html_file;
2166 public static function deliverData($a_data, $a_filename, $mime =
"application/octet-stream", $charset =
"")
2168 $disposition =
"attachment";
2171 include_once
'./Services/Http/classes/class.ilHTTPS.php';
2181 #header("Pragma: ");
2182 #header("Cache-Control: ");
2183 #header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
2184 #header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
2185 #header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
2186 #header("Cache-Control: post-check=0, pre-check=0", false);
2188 else if ($disposition ==
"attachment")
2190 header(
"Cache-control: private");
2194 header(
"Cache-Control: no-cache, must-revalidate");
2195 header(
"Pragma: no-cache");
2200 if (strlen($charset))
2202 $charset =
"; charset=$charset";
2204 header(
"Content-Type: $mime$charset");
2205 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
2206 header(
"Content-Description: ".$ascii_filename);
2207 header(
"Content-Length: ".(
string)(strlen($a_data)));
2212 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
2213 header(
'Pragma: public');
2216 header(
"Connection: close");
2229 public static function deliverFile($a_file, $a_filename,$a_mime =
'', $isInline =
false, $removeAfterDelivery =
false,
2230 $a_exit_after =
true)
2233 if(!file_exists($a_file))
2239 $disposition =
"inline";
2241 $disposition =
"attachment";
2252 $mime =
"application/octet-stream";
2256 if ($disposition ==
"attachment")
2258 header(
"Cache-control: private");
2262 header(
"Cache-Control: no-cache, must-revalidate");
2263 header(
"Pragma: no-cache");
2268 header(
"Content-Type: $mime");
2269 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
2270 header(
"Content-Description: ".$ascii_filename);
2273 $filesize = @filesize($a_file);
2276 header(
"Content-Length: ".(
string)$filesize);
2279 include_once
'./Services/Http/classes/class.ilHTTPS.php';
2280 #if($_SERVER['HTTPS'])
2283 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
2284 header(
'Pragma: public');
2287 header(
"Connection: close");
2289 if ($removeAfterDelivery)
2311 $chunksize = 1*(1024*1024);
2313 $handle = fopen($a_file,
'rb');
2314 if ($handle ===
false)
2318 while (!feof($handle))
2320 $buffer = fread($handle, $chunksize);
2323 return fclose($handle);
2353 $ascii_filename = htmlentities($a_filename, ENT_NOQUOTES,
'UTF-8');
2354 $ascii_filename = preg_replace(
'/\&(.)[^;]*;/',
'\\1', $ascii_filename);
2355 $ascii_filename = preg_replace(
'/[\x7f-\xff]/',
'_', $ascii_filename);
2358 $ascii_filename = preg_replace(
'/[:\x5c\/\*\?\"<>\|]/',
'_', $ascii_filename);
2360 return $ascii_filename;
2372 $sep =
'###HTMLTAG###';
2374 preg_match_all(
"@<[^>]*>@", $htmlText, $matches);
2375 $tmp = preg_replace(
"@(<[^>]*>)@", $sep, $htmlText);
2376 $tmp = explode($sep, $tmp);
2378 for ($i=0; $i<count($tmp); $i++)
2379 $tmp[$i] = htmlentities($tmp[$i], ENT_COMPAT,
"UTF-8");
2381 $tmp = join($sep, $tmp);
2383 for ($i=0; $i<count($matches[0]); $i++)
2384 $tmp = preg_replace(
"@$sep@", $matches[0][$i], $tmp, 1);
2397 return PATH_TO_JAVA;
2416 $url = (is_int(strpos($a_url,
"?")))
2417 ? $a_url.$amp.$a_par
2418 : $a_url.
"?".$a_par;
2440 $a_dir = trim($a_dir);
2443 if (substr($a_dir,-1) ==
"/")
2445 $a_dir = substr($a_dir,0,-1);
2449 if (!(
$path = substr($a_dir,0, strrpos($a_dir,
"/") - strlen($a_dir))))
2456 return @mkdir($a_dir,fileperms(
$path));
2476 $dirs = array($a_dir);
2477 $a_dir = dirname($a_dir);
2480 while($last_dirname != $a_dir)
2482 array_unshift(
$dirs, $a_dir);
2483 $last_dirname = $a_dir;
2484 $a_dir = dirname($a_dir);
2488 $reverse_paths = array_reverse(
$dirs, TRUE);
2490 foreach ($reverse_paths as $key => $value)
2492 if ($found_index == -1)
2496 $found_index = $key;
2502 foreach (
$dirs as $dirindex => $dir)
2505 if ($dirindex >= $found_index)
2507 if (! file_exists($dir))
2509 if (strcmp(substr($dir,strlen($dir)-1,1),
"/") == 0)
2513 $dir = substr($dir,0,strlen($dir)-1);
2515 if (! mkdir($dir, $umask))
2517 error_log(
"Can't make directory: $dir");
2521 elseif (! is_dir($dir))
2523 error_log(
"$dir is not a directory");
2529 $umask = fileperms($dir);
2545 public static function delDir($a_dir, $a_clean_only =
false)
2547 if (!is_dir($a_dir) || is_int(strpos($a_dir,
"..")))
2552 $current_dir = opendir($a_dir);
2561 while($entryname = readdir($current_dir))
2563 $files[] = $entryname;
2566 foreach($files as
$file)
2568 if(is_dir($a_dir.
"/".$file) and ($file !=
"." and $file!=
".."))
2572 elseif ($file !=
"." and $file !=
"..")
2574 unlink(${a_dir}.
"/".${file});
2578 closedir($current_dir);
2592 public static function getDir($a_dir, $a_rec =
false, $a_sub_dir =
"")
2594 $current_dir = opendir($a_dir.$a_sub_dir);
2598 $subitems = array();
2599 while($entry = readdir($current_dir))
2601 if(is_dir($a_dir.
"/".$entry))
2603 $dirs[$entry] = array(
"type" =>
"dir",
"entry" => $entry,
2604 "subdir" => $a_sub_dir);
2605 if ($a_rec && $entry !=
"." && $entry !=
"..")
2608 $subitems = array_merge($subitems,
$si);
2613 if ($entry !=
"." && $entry !=
"..")
2615 $size = filesize($a_dir.$a_sub_dir.
"/".$entry);
2616 $files[$entry] = array(
"type" =>
"file",
"entry" => $entry,
2617 "size" =>
$size,
"subdir" => $a_sub_dir);
2624 return array_merge(
$dirs, $files, $subitems);
2635 if (is_array($a_arr))
2637 foreach ($a_arr as $k => $v)
2654 if (is_array($a_data))
2656 foreach ($a_data as $k => $v)
2683 public static function stripSlashes($a_str, $a_strip_html =
true, $a_allow =
"")
2685 if (ini_get(
"magic_quotes_gpc"))
2687 $a_str = stripslashes($a_str);
2703 if (ini_get(
"magic_quotes_gpc"))
2705 $a_str = stripslashes($a_str);
2717 public static function secureString($a_str, $a_strip_html =
true, $a_allow =
"")
2720 $only_secure =
true;
2721 $allow_tags = explode(
">", $a_allow);
2723 $allow_array = array();
2724 foreach($allow_tags as $allow)
2728 $allow = str_replace(
"<",
"", $allow);
2730 if (!in_array($allow, $sec_tags))
2732 $only_secure =
false;
2734 $allow_array[] = $allow;
2739 if (($only_secure || $a_allow ==
"") && $a_strip_html)
2743 $allow_array = array (
"b",
"i",
"strong",
"em",
"code",
"cite",
2744 "gap",
"sub",
"sup",
"pre",
"strike");
2750 $a_str = strip_tags($a_str);
2775 return array(
"strong",
"em",
"u",
"strike",
"ol",
"li",
"ul",
"p",
"div",
2776 "i",
"b",
"code",
"sup",
"sub",
"pre",
"gap",
"a",
"img");
2781 foreach ($allow_array as
$t)
2796 array(
"param" =>
"align",
"value" =>
"left"),
2797 array(
"param" =>
"align",
"value" =>
"center"),
2798 array(
"param" =>
"align",
"value" =>
"justify"),
2799 array(
"param" =>
"align",
"value" =>
"right")
2814 foreach ($allow_array as
$t)
2829 array(
"param" =>
"align",
"value" =>
"left"),
2830 array(
"param" =>
"align",
"value" =>
"center"),
2831 array(
"param" =>
"align",
"value" =>
"justify"),
2832 array(
"param" =>
"align",
"value" =>
"right")
2854 if (ini_get(
"magic_quotes_gpc"))
2856 return stripslashes($a_str);
2883 if ($a_make_links_clickable)
2901 $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);
2904 foreach ($matches as $match)
2907 foreach ($matches[0] as $match)
2909 $matched_text = $match[0];
2911 if ($matched_offset != previous_offset)
2914 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1, $pos2 - $pos1)));
2920 $pos1 = $pos2 + strlen($matched_text);
2922 if ($pos1 < strlen($a_str))
2924 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1)));
2929 $encoded = nl2br(htmlspecialchars($a_str));
2939 $ws =
"[ \t\r\f\v\n]*";
2940 $att = $ws.
"[^>]*".$ws;
2942 while (eregi(
"<($tag$att($tag_att$ws=$ws\"(([\$@!*()~;,_0-9A-z/:=%\\.&#?+\\-])*)\")$att)>",
2945 $un = array(
".",
"-",
"+",
"?",
'$',
"*",
"(",
")");
2951 $ff = str_replace($un, $esc, $found[1]);
2954 $a_str = eregi_replace(
"<".$ff.
">",
2955 "<$tag $tag_att$tag_att=\"".$found[3].
"\">", $a_str);
2956 if ($old_str == $a_str)
2958 $ilLog->write(
"ilUtil::maskA-".htmlentities($old_str).
" == ".
2959 htmlentities($a_str));
2963 $a_str = str_ireplace(
"</$tag>",
2964 "</$tag>", $a_str);
2972 while (eregi(
"<($tag $tag_att$tag_att=\"(([\$@!*()~;,_0-9A-z/:=%\\.&#?+\\-])*)\")>",
2975 $un = array(
".",
"-",
"+",
"?",
'$',
"*",
"(",
")");
2981 $ff = str_replace($un, $esc, $found[1]);
2984 $a_str = eregi_replace(
"<".$ff.
">",
2985 "<$tag $tag_att=\"".ilUtil::secureLink($found[2]).
"\">", $a_str);
2986 if ($old_str == $a_str)
2988 $ilLog->write(
"ilUtil::unmaskA-".htmlentities($old_str).
" == ".
2989 htmlentities($a_str));
2993 $a_str = str_replace(
"</$tag>",
"</$tag>", $a_str);
2999 $a_str = str_replace(array(
"<$t>",
"<".strtoupper(
$t).
">"),
3000 "<".
$t.
">", $a_str);
3001 $a_str = str_replace(array(
"</$t>",
"</".strtoupper(
$t).
">"),
3002 "</".
$t.
">", $a_str);
3004 if (is_array($fix_param))
3006 foreach ($fix_param as $p)
3010 $a_str = str_replace(
"<$t $k=\"$v\">",
3011 "<".
"$t $k=\"$v\"".
">", $a_str);
3020 $a_str = str_replace(
"<".
$t.
">",
"<".$t.
">", $a_str);
3021 $a_str = str_replace(
"</".
$t.
">",
"</".$t.
">", $a_str);
3023 if (is_array($fix_param))
3025 foreach ($fix_param as $p)
3029 $a_str = str_replace(
"<$t $k=\"$v\">",
3030 "<".
"$t $k=\"$v\"".
">", $a_str);
3038 $a_str = str_ireplace(
"javascript",
"jvscrpt", $a_str);
3039 $a_str = str_ireplace(array(
"%00",
"%0a",
"%0d",
"%1a",
"�",
"�",
3040 "�",
"�",
"
",
"
",
" ",
" "),
"-", $a_str);
3061 $negativestr =
"a,abbr,acronym,address,applet,area,b,base,basefont,".
3062 "bdo,big,blockquote,body,br,button,caption,center,cite,code,col,".
3063 "colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame,".
3064 "frameset,h1,h2,h3,h4,h5,h6,head,hr,html,i,iframe,img,input,ins,isindex,kbd,".
3065 "label,legend,li,link,map,menu,meta,noframes,noscript,object,ol,".
3066 "optgroup,option,p,param,q,s,samp,script,select,small,span,".
3067 "strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,".
3068 "title,tr,tt,u,ul,var";
3069 $a_allow = strtolower ($a_allow);
3070 $negatives = explode(
",",$negativestr);
3071 $outer_old_str =
"";
3072 while($outer_old_str != $a_str)
3074 $outer_old_str = $a_str;
3075 foreach ($negatives as $item)
3077 $pos = strpos($a_allow,
"<$item>");
3083 while($old_str != $a_str)
3086 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s*>/i",
"", $a_str);
3087 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s+([^>]*)>/i",
"", $a_str);
3096 $a_str = preg_replace(
"/<\s*\w*(\/?)(\s+[^>]*)?(\s+on[^>]*)>/i",
"", $a_str);
3099 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*javascript[^>]*>/i",
"", $a_str);
3103 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*expression[^>]*>/i",
"", $a_str);
3120 if (ini_get(
"magic_quotes_gpc"))
3126 return addslashes($a_str);
3147 $a_str = htmlspecialchars($a_str);
3151 $a_str = str_replace(
"{",
"{", $a_str);
3152 $a_str = str_replace(
"}",
"}", $a_str);
3171 return addslashes($a_str);
3203 while(($spos=strpos($a_parstr,
"=")) &&
$ok)
3206 $cpar = substr($a_parstr,0,$spos);
3207 $a_parstr = substr($a_parstr,$spos,strlen($a_parstr)-$spos);
3208 while(substr($cpar,0,1)==
"," ||substr($cpar,0,1)==
" " || substr($cpar,0,1)==chr(13) || substr($cpar,0,1)==chr(10))
3209 $cpar = substr($cpar,1,strlen($cpar)-1);
3210 while(substr($cpar,strlen($cpar)-1,1)==
" " || substr($cpar,strlen($cpar)-1,1)==chr(13) || substr($cpar,strlen($cpar)-1,1)==chr(10))
3211 $cpar = substr($cpar,0,strlen($cpar)-1);
3215 while($cpar != $cpar_old)
3218 $cpar = eregi_replace(
"[^a-zA-Z0-9_]",
"", $cpar);
3224 if($spos=strpos($a_parstr,
"\""))
3226 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos);
3227 $spos=strpos($a_parstr,
"\"");
3230 $cval = substr($a_parstr,0,$spos);
3232 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos-1);
3242 if(
$ok)
return $par;
else return false;
3247 if (is_array($a_par_arr))
3250 foreach ($a_par_arr as $par => $val)
3269 for($i=0; $i<strlen($a_str); $i++)
3271 $ret.= ord(substr($a_str,$i,1)).
" ";
3285 if(strtolower($a_yn) ==
"y")
3325 global $array_sortby,$array_sortorder;
3329 if ($array_sortorder ==
"asc")
3334 if ($array_sortorder ==
"desc")
3336 return !
ilStr::strCmp($a[$array_sortby], $b[$array_sortby]);
3353 global $array_sortby,$array_sortorder;
3355 if ($array_sortorder ==
"asc")
3357 return $a[
"$array_sortby"] > $b[
"$array_sortby"];
3360 if ($array_sortorder ==
"desc")
3362 return $a[
"$array_sortby"] < $b[
"$array_sortby"];
3377 public static function sortArray($array,$a_array_sortby,$a_array_sortorder = 0,$a_numeric =
false,
3378 $a_keep_keys =
false)
3380 include_once(
"./Services/Utilities/classes/class.ilStr.php");
3383 if (! $a_keep_keys) {
3388 global $array_sortby,$array_sortorder;
3390 $array_sortby = $a_array_sortby;
3392 if ($a_array_sortorder ==
"desc")
3394 $array_sortorder =
"desc";
3398 $array_sortorder =
"asc";
3404 uasort($array, array(
"ilUtil",
"sort_func_numeric"));
3408 usort($array, array(
"ilUtil",
"sort_func_numeric"));
3415 uasort($array, array(
"ilUtil",
"sort_func"));
3419 usort($array, array(
"ilUtil",
"sort_func"));
3441 public static function stableSortArray($array,$a_array_sortby,$a_array_sortorder = 0,$a_numeric =
false)
3443 global $array_sortby,$array_sortorder;
3445 $array_sortby = $a_array_sortby;
3447 if ($a_array_sortorder ==
"desc")
3449 $array_sortorder =
"desc";
3453 $array_sortorder =
"asc";
3457 $sort_array = array_values($array);
3470 public static function mergesort(&$array, $cmp_function =
'strcmp') {
3472 if (count($array) < 2)
return;
3475 $halfway = count($array) / 2;
3476 $array1 = array_slice($array, 0, $halfway);
3477 $array2 = array_slice($array, $halfway);
3484 if (call_user_func($cmp_function, end($array1), $array2[0]) < 1) {
3485 $array = array_merge($array1, $array2);
3492 while ($ptr1 < count($array1) && $ptr2 < count($array2)) {
3493 if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1) {
3494 $array[] = $array1[$ptr1++];
3497 $array[] = $array2[$ptr2++];
3502 while ($ptr1 < count($array1)) $array[] = $array1[$ptr1++];
3503 while ($ptr2 < count($array2)) $array[] = $array2[$ptr2++];
3523 $existing_sub_key_values = array();
3525 foreach ($array as $key=>$sub_array)
3527 if (!in_array($sub_array[$sub_key], $existing_sub_key_values))
3529 $existing_sub_key_values[] = $sub_array[$sub_key];
3530 $target[$key] = $sub_array;
3549 $a_desired_type = strtolower($a_desired_type);
3551 $im_types = ImageTypes();
3553 switch($a_desired_type)
3556 if ($im_types & IMG_JPG)
return "jpg";
3557 if ($im_types & IMG_GIF)
return "gif";
3558 if ($im_types & IMG_PNG)
return "png";
3562 if ($im_types & IMG_GIF)
return "gif";
3563 if ($im_types & IMG_JPG)
return "jpg";
3564 if ($im_types & IMG_PNG)
return "png";
3568 if ($im_types & IMG_PNG)
return "png";
3569 if ($im_types & IMG_JPG)
return "jpg";
3570 if ($im_types & IMG_GIF)
return "gif";
3588 if (($a_mime ==
"image/gif") || ($a_mime ==
"image/jpeg") ||
3589 ($a_mime ==
"image/png") || ($a_mime ==
"application/x-shockwave-flash") ||
3590 ($a_mime ==
"image/tiff") || ($a_mime ==
"image/x-ms-bmp") ||
3591 ($a_mime ==
"image/psd") || ($a_mime ==
"image/iff"))
3611 global
$log, $PHP_SELF;
3614 if (!is_int(strpos($a_script,
"://")))
3616 if (substr($a_script, 0, 1) !=
"/" && defined(
"ILIAS_HTTP_PATH"))
3618 if (is_int(strpos($_SERVER[
"PHP_SELF"],
"/setup/")))
3620 $a_script =
"setup/".$a_script;
3622 $a_script = ILIAS_HTTP_PATH.
"/".$a_script;
3628 global $ilPluginAdmin;
3629 if (is_object($ilPluginAdmin))
3631 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_SERVICE,
"UIComponent",
"uihk");
3632 foreach ($pl_names as $pl)
3635 $gui_class = $ui_plugin->getUIClassInstance();
3636 $resp = $gui_class->getHTML(
"Services/Utilities",
"redirect", array(
"html" => $a_script));
3639 $a_script = $gui_class->modifyHTML($a_script, $resp);
3644 header(
"Location: ".$a_script);
3658 if (substr($a_value, 0, 4) ==
"il__")
3660 $a_value =
"il_".IL_INST_ID.
"_".substr($a_value, 4, strlen($a_value) - 4);
3680 if (empty($a_group_name))
3682 $message = __METHOD__.
": No groupname given!";
3683 $ilErr->raiseError($message,$ilErr->WARNING);
3686 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
3688 $q =
"SELECT obj_id FROM object_data ".
3689 "WHERE title = ".$ilDB->quote($a_group_name,
"text").
" ".
3690 "AND type = ".$ilDB->quote(
"grp",
"text").
3693 $r = $ilDB->query($q);
3713 $my_pid = getmypid();
3714 return (
"MEMORY USAGE (% KB PID ): ".`ps -eo%mem,rss,pid | grep $my_pid`);
3725 if (strtolower(substr(php_uname(), 0, 3)) ==
"win")
3735 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3737 return escapeshellarg($a_arg);
3751 if(ini_get(
'safe_mode') == 1)
3755 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3756 return escapeshellcmd($a_arg);
3775 $cmd =
'"'.$cmd.
'"';
3780 if (version_compare(phpversion(),
"5.2",
"<") && strpos($args,
'"') !==
false)
3782 $cmd =
'"'.$cmd.
" ".$args.
'"';
3824 public static function excelTime($year =
"", $month =
"", $day =
"", $hour =
"", $minute =
"", $second =
"")
3826 $starting_time = mktime(0, 0, 0, 1, 2, 1970);
3827 if (strcmp(
"$year$month$day$hour$minute$second",
"") == 0)
3829 $target_time = time();
3838 $target_time = mktime($hour, $minute, $second, $month, $day, $year);
3839 $difference = $target_time - $starting_time;
3840 $days = (($difference - ($difference % 86400)) / 86400);
3841 $difference = $difference - ($days * 86400) + 3600;
3842 return ($days + 25570 + ($difference / 86400));
3853 $def_arr = explode(
",", SUFFIX_REPL_DEFAULT);
3854 foreach ($def_arr as $def)
3859 $def_arr = explode(
",", SUFFIX_REPL_ADDITIONAL);
3860 foreach ($def_arr as $def)
3880 if ($a_dir ==
"/" || $a_dir ==
"" || is_int(strpos($a_dir,
".."))
3881 || trim($a_old_suffix) ==
"")
3887 if (!@is_dir($a_dir))
3893 $dir = opendir($a_dir);
3895 while(
$file = readdir($dir))
3897 if (
$file !=
"." and
3901 if (@is_dir($a_dir.
"/".
$file))
3907 if (@is_file($a_dir.
"/".
$file))
3910 if(strrpos(
$file,
'.') == (strlen(
$file) - 1))
3912 rename($a_dir.
'/'.
$file,substr($a_dir.
'/'.
$file,0,-1));
3916 $path_info = pathinfo($a_dir.
"/".
$file);
3918 if (strtolower($path_info[
"extension"]) ==
3919 strtolower($a_old_suffix))
3921 $pos = strrpos($a_dir.
"/".
$file,
".");
3922 $new_name = substr($a_dir.
"/".
$file, 0, $pos).
".".$a_new_suffix;
3923 rename($a_dir.
"/".
$file, $new_name);
3932 return strpos($_SERVER[
"SCRIPT_FILENAME"],
"api") !==
false ||
3933 strpos($_SERVER[
"SCRIPT_FILENAME"],
"dummy") !==
false;
3937 if (preg_match(
"/&" . $paramName .
"=/", $qstring)) {
3938 return preg_replace(
"/&" . $paramName .
"=[^&]+/",
"&" . $paramName .
"=" . urlencode($paramValue), $qstring);
3940 return $qstring .
"&" . $paramName .
"=" . urlencode($paramValue);
3946 foreach ($parametersArray as $paramName => $paramValue ) {
3961 srand((
double) microtime()*1000000);
3963 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
3966 for ($i=1; $i<=$a_number; $i++)
3968 $min = ($security->getPasswordMinLength() > 0)
3969 ? $security->getPasswordMinLength()
3971 $max = ($security->getPasswordMaxLength() > 0)
3972 ? $security->getPasswordMaxLength()
3978 $length = rand($min,$max);
3981 $vowels_uc = strtoupper($vowels);
3982 $consonants =
"bcdfghjklmnpqrstvwxyz";
3983 $consonants_uc = strtoupper($consonants);
3984 $numbers =
"1234567890";
3985 $special =
"_.+?#-*@!$%~";
3988 if($security->getPasswordNumberOfUppercaseChars() > 0)
3990 for($j = 0; $j < $security->getPasswordNumberOfUppercaseChars(); $j++)
3995 $pw.= $consonants_uc[rand(0, strlen($consonants_uc) - 1)];
4000 $pw.= $vowels_uc[rand(0, strlen($vowels_uc) - 1)];
4007 if($security->isPasswordCharsAndNumbersEnabled())
4009 $pw.= $numbers[rand(0, strlen($numbers) - 1)];
4012 if($security->isPasswordSpecialCharsEnabled())
4014 $pw.= $special[rand(0, strlen($special) - 1)];
4017 $num_lcase_chars = max($security->getPasswordNumberOfLowercaseChars(), $length - strlen($pw));
4018 for($j = 0; $j < $num_lcase_chars; $j++)
4023 $pw.= $consonants[rand(0, strlen($consonants) - 1)];
4028 $pw.= $vowels[rand(0, strlen($vowels) - 1)];
4034 $pw = str_shuffle($pw);
4043 $path = preg_replace(
"/[\/\\\]+$/",
"",
$path);
4064 foreach($data as $k=>$datum)
4066 if(is_null($datum)) $data[$k] =
'null';
4067 if(is_string($datum)) $data[$k] =
"'" . $datum .
"'";
4071 return "[" . implode(
', ', $data) .
"]";
4080 public static function virusHandling($a_file, $a_orig_name =
"", $a_clean =
true)
4084 if (IL_VIRUS_SCANNER !=
"None")
4086 require_once(
"./Services/VirusScanner/classes/class.ilVirusScannerFactory.php");
4088 if (($vs_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
4090 if ($a_clean && (IL_VIRUS_CLEAN_COMMAND !=
""))
4092 $clean_txt = $vs->cleanFile($a_file, $a_orig_name);
4093 if ($vs->fileCleaned())
4095 $vs_txt.=
"<br />".$lng->txt(
"cleaned_file").
4096 "<br />".$clean_txt;
4097 $vs_txt.=
"<br />".$lng->txt(
"repeat_scan");
4098 if (($vs2_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
4100 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_failed").
4101 "<br />".nl2br($vs2_txt));
4105 return array(
true, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_succeded"));
4110 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"cleaning_failed"));
4115 return array(
false, nl2br($vs_txt));
4120 return array(
true,
"");
4131 $a_mode =
"move_uploaded")
4133 global
$lng, $ilias;
4136 if (!is_file($a_file))
4138 if ($a_raise_errors)
4140 $ilias->raiseError($lng->txt(
"upload_error_file_not_found"), $ilias->error_obj->MESSAGE);
4154 if ($a_raise_errors)
4156 $ilias->raiseError($lng->txt(
"file_is_infected").
"<br />".
4158 $ilias->error_obj->MESSAGE);
4176 return rename($a_file, $a_target);
4180 return copy($a_file, $a_target);
4184 return move_uploaded_file($a_file, $a_target);
4198 list($datum, $uhrzeit) = explode (
" ",$mysql_date_time);
4199 list($jahr, $monat, $tag) = explode(
"-", $datum);
4200 list($std, $min, $sec) = explode(
":", $uhrzeit);
4201 return mktime ((
int) $std, (
int) $min, (
int) $sec, (
int) $monat, (
int) $tag, (
int) $jahr);
4212 return date(
"Y-m-d H:i:s");
4232 $resultarray = array();
4233 foreach (
$row as $rowindex => $entry)
4240 if (strpos($entry,
"\"") !== FALSE)
4242 $entry = str_replace(
"\"",
"\"\"", $entry);
4249 if ($compatibleWithMSExcel)
4252 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
4258 $resultarray[$rowindex] =
"\"" . $entry .
"\"";
4262 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
4269 $resultarray[$rowindex] = $entry;
4273 $resultarray[$rowindex] = utf8_decode($entry);
4277 return $resultarray;
4281 public static function isDN($a_str)
4283 return(preg_match(
"/^[a-z]+([a-z0-9-]*[a-z0-9]+)?(\.([a-z]+([a-z0-9-]*[a-z0-9]+)?)+)*$/",$a_str));
4289 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])\.".
4290 "(\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));
4324 global $ilDB,$rbacreview,$ilAccess,
$ilUser,$ilias,$tree;
4326 if(!is_array($a_obj_type))
4328 $where =
"WHERE type = ".$ilDB->quote($a_obj_type,
"text").
" ";
4332 $where =
"WHERE ".$ilDB->in(
"type", $a_obj_type,
false,
"text").
" ";
4338 $limit = $ilias->getSetting(
'search_max_hits',100);
4346 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
4347 $a_roles = $rbacreview->assignedRoles($a_usr_id);
4351 if($rbacreview->isAssigned($a_usr_id,SYSTEM_ROLE_ID))
4353 $query =
"SELECT ref_id FROM object_reference obr LEFT JOIN object_data obd ON obr.obj_id = obd.obj_id ".
4354 "LEFT JOIN tree ON obr.ref_id = tree.child ".
4360 while(
$row = $ilDB->fetchObject(
$res))
4363 if($tree->isGrandChild(RECOVERY_FOLDER_ID,
$row->ref_id))
4368 if($counter++ >= $limit)
4373 $ref_ids[] =
$row->ref_id;
4375 return $ref_ids ? $ref_ids : array();
4379 if($a_operation ==
'edit_permissions' or strpos($a_operation,
'create') !==
false)
4381 $check_owner =
") ";
4385 $check_owner =
"OR owner = ".$ilDB->quote($a_usr_id,
"integer").
") ";
4389 $ops_id = $ops_ids[0];
4391 $and =
"AND ((".$ilDB->in(
"rol_id", $a_roles,
false,
"integer").
" ";
4393 $query =
"SELECT DISTINCT(obr.ref_id),obr.obj_id,type FROM object_reference obr ".
4394 "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
4395 "LEFT JOIN rbac_pa ON obr.ref_id = rbac_pa.ref_id ".
4398 "AND (".$ilDB->like(
"ops_id",
"text",
"%i:".$ops_id.
"%").
" ".
4399 "OR ".$ilDB->like(
"ops_id",
"text",
"%:\"".$ops_id.
"\";%").
")) ".
4406 if($counter >= $limit)
4412 if($tree->isGrandChild(RECOVERY_FOLDER_ID,
$row->ref_id))
4418 if($ilAccess->checkAccessOfUser($a_usr_id,$a_operation,
'',
$row->ref_id,
$row->type,
$row->obj_id))
4421 $ref_ids[] =
$row->ref_id;
4424 return $ref_ids ? $ref_ids : array();
4444 include_once
"./Services/Administration/classes/class.ilSetting.php";
4467 $cgi = URL_TO_LATEX;
4470 include_once
"./Services/Administration/classes/class.ilSetting.php";
4475 $a_text = preg_replace(
"/\\\\([RZN])([^a-zA-Z]|<\/span>)/",
"\\mathbb{".
"$1".
"}".
"$2", $a_text);
4481 $o_start = $a_start;
4483 $a_start = str_replace(
"\\",
"", $a_start);
4484 $a_end = str_replace(
"\\",
"", $a_end);
4486 while (is_int($spos = stripos($a_text, $a_start, $cpos)))
4488 if (is_int ($epos = stripos($a_text, $a_end, $spos + 1)))
4490 $tex = substr($a_text, $spos + strlen($a_start), $epos - $spos - strlen($a_start));
4493 if (!is_int(strpos($tex,
"</div>")))
4497 $a_text = substr($a_text, 0, $spos).
4498 "<img alt=\"".htmlentities($tex).
"\" src=\"".$cgi.
"?".
4499 rawurlencode(str_replace(
'&',
'&', str_replace(
'>',
'>', str_replace(
'<',
'<', $tex)))).
"\" ".
4501 substr($a_text, $epos + strlen($a_end));
4505 $tex = $a_start.$tex.$a_end;
4510 $mj_start =
"[tex]";
4515 $mj_start =
'<span class="math">';
4516 $mj_end =
'</span>';
4526 preg_replace(
'/' . $o_start .
'(.*?)' . $o_end .
'/ie',
4527 "'".$mj_start.
"' . preg_replace('/[\\\\\\\\\\]{2}/', '\\cr', str_replace('<', '<', str_replace('<br/>', '', str_replace('<br />', '', str_replace('<br>', '', '$1'))))) . '".$mj_end.
"'", $tex);
4529 $a_text = substr($a_text, 0, $spos).
4531 substr($a_text, $epos + strlen($a_end));
4538 $result_text = $a_text;
4540 return $result_text;
4554 $result_text = $a_text;
4559 $cgi = URL_TO_LATEX;
4563 while (preg_match(
'/' . $start .
'(.*?)' . $end .
'/ie', $result_text, $found))
4565 $cnt = (int)
$GLOBALS[
"teximgcnt"]++;
4567 $fpr = @fopen($cgi.
"?".rawurlencode($found[1]),
"r");
4573 $buf = fread($fpr, 1024);
4576 if (is_int(strpos(strtoupper(substr($buf, 0, 5)),
"GIF")))
4584 $fpw = fopen($a_dir.
"/teximg/img".$cnt.
".".$suffix,
"w");
4594 $img_str =
"./teximg/img".$cnt.
".".$suffix;
4595 $result_text = str_replace($found[0],
4596 '<img alt="'.$found[1].
'" src="'.$img_str.
'" />', $result_text);
4600 return $result_text;
4616 if ($prepare_for_latex_output)
4631 if (preg_match_all(
"/(<pre>.*?<\/pre>)/ims",
$result, $matches))
4633 foreach ($matches[0] as $found)
4636 if (strpos(
"\n", $found) === FALSE)
4638 $replacement =
"\n";
4640 $removed = preg_replace(
"/<br\s*?\/>/ims", $replacement, $found);
4645 if ($prepare_for_latex_output)
4667 if( preg_match(
"/<[^>]*?>/", $a_text) )
4683 public static function int2array ($seconds, $periods = null)
4686 if (!is_array($periods))
4689 'years' => 31536000,
4690 'months' => 2592000,
4699 $seconds = (float) $seconds;
4700 foreach ($periods as $period => $value)
4702 $count = floor($seconds / $value);
4709 $values[$period] = $count;
4710 $seconds = $seconds % $value;
4733 if (!is_array($duration))
4738 foreach ($duration as $key => $value) {
4743 $segment_name = $key;
4744 $segment_name = $lng->txt($segment_name);
4745 $segment = $value .
' ' . $segment_name;
4749 $segment_name = substr($key, 0, -1);
4750 $segment_name = $lng->txt($segment_name);
4751 $segment = $value .
' ' . $segment_name;
4754 $array[] = $segment;
4756 $len = count($array);
4760 $array=array_slice($array,0,(3-$len));
4763 $str = implode(
', ', $array);
4773 $umf=get_cfg_var(
"upload_max_filesize");
4775 $pms=get_cfg_var(
"post_max_size");
4778 $max_filesize=min($umf, $pms);
4779 if (!$max_filesize) $max_filesize=max($umf, $pms);
4781 return $lng->txt(
"file_notice").
" $max_filesize.";
4795 $test_str = explode(
'_',$role_title);
4797 if ($test_str[0] ==
'il')
4799 $test2 = (int) $test_str[3];
4800 return is_numeric ($test2) ? (int) $test2 :
false;
4818 $test_str = explode(
'_',$ilias_id);
4820 if ($test_str[0] ==
'il' && $test_str[1] == $inst_id && count($test_str) == 4)
4822 $test2 = (int) $test_str[3];
4823 return is_numeric ($test2) ? (int) $test2 :
false;
4842 public static function _sortIds($a_ids,$a_table,$a_field,$a_id_name)
4852 $where =
"WHERE ".$a_id_name.
" IN (";
4856 $query =
"SELECT ".$a_id_name.
" FROM ".$a_table.
" ".
4858 "ORDER BY ".$a_field;
4863 $ids[] =
$row->$a_id_name;
4865 return $ids ? $ids : array();
4895 if(!is_array($a_array) or !count($a_array))
4900 foreach($a_array as $k => $item)
4902 $a_array[$k] = $ilDB->quote($item);
4916 public static function sendInfo($a_info =
"",$a_keep =
false)
4919 $tpl->setMessage(
"info", $a_info, $a_keep);
4933 $tpl->setMessage(
"failure", $a_info, $a_keep);
4945 $tpl->setMessage(
"question", $a_info, $a_keep);
4959 $tpl->setMessage(
"success", $a_info, $a_keep);
4968 $tpl->addBlockFile(
"INFOPANEL",
"infopanel",
"tpl.infopanel.html",
4969 "Services/Utilities");
4970 $tpl->setCurrentBlock(
"infopanel");
4972 if (!empty(
$_SESSION[
"infopanel"][
"text"]))
4974 $link =
"<a href=\"".$dir.$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4977 $link .= $lng->txt(
$_SESSION[
"infopanel"][
"text"]);
4982 if (!empty(
$_SESSION[
"infopanel"][
"img"]))
4984 $link .=
"<td><a href=\"".$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4987 $link .=
"<img src=\"".$ilias->tplPath.$ilias->account->prefs[
"skin"].
"/images/".
4988 $_SESSION[
"infopanel"][
"img"].
"\" border=\"0\" vspace=\"0\"/>";
4989 $link .=
"</a></td>";
4992 $tpl->setVariable(
"INFO_ICONS",$link);
4993 $tpl->parseCurrentBlock();
5014 if (!is_dir($directory))
5018 $size = @filesize($directory);
5022 if ($DIR = opendir($directory))
5024 while (($dirfile = readdir($DIR)) !==
false)
5026 if (is_link($directory . DIRECTORY_SEPARATOR . $dirfile) || $dirfile ==
'.' || $dirfile ==
'..')
5028 if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile))
5029 $size += filesize($directory . DIRECTORY_SEPARATOR . $dirfile);
5030 else if (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile))
5033 $dirSize =
ilUtil::dirsize($directory . DIRECTORY_SEPARATOR . $dirfile);
5047 return md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
5050 public static function setCookie($a_cookie_name,$a_cookie_value =
'', $a_also_set_super_global =
true, $a_set_cookie_invalid =
false)
5057 if(!(
bool)$a_set_cookie_invalid) $expire = 0;
5058 else $expire = time() - (365*24*60*60);
5062 if( version_compare(PHP_VERSION,
'5.2.0',
'>=') )
5065 setcookie( $a_cookie_name, $a_cookie_value, $expire,
5066 IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE, IL_COOKIE_HTTPONLY
5072 setcookie( $a_cookie_name, $a_cookie_value, $expire,
5077 if((
bool)$a_also_set_super_global)
$_COOKIE[$a_cookie_name] = $a_cookie_value;
5082 return strip_tags(self::stripSlashes($a_filename));
5089 if($_SERVER[
'SHELL'] || php_sapi_name() ==
'cli' ||
5093 return $ilIliasIniFile->readVariable(
'server',
'http_path');
5097 return ILIAS_HTTP_PATH;
5108 $bt = debug_backtrace();
5112 if ($cnt != 0 && ($a_limit == 0 || $cnt <= $a_limit))
5114 echo
"<br>".$t[
"file"].
", ".$t[
"function"].
" [".$t[
"line"].
"]";
5137 $exploded = explode(
'_'.$a_import_id);
5139 $parsed[
'orig'] = $a_import_id;
5140 if($exploded[0] ==
'il')
5142 $parsed[
'prefix'] = $exploded[0];
5144 if(is_numeric($exploded[1]))
5146 $parsed[
'inst_id'] = (int) $exploded[1];
5148 $parsed[
'type'] = $exploded[2];
5150 if(is_numeric($exploded[3]))
5152 $parsed[
'id'] = (int) $exploded[3];
5166 '/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff^|]*)\|/',
5169 PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
5174 for($i = 0; $vars[$i]; $i++)
5176 $result[$vars[$i++]] = unserialize($vars[$i]);
5195 $fp = @fopen(
$file,
'rb');
5213 header(
"Accept-Ranges: 0-$length");
5217 if (isset($_SERVER[
'HTTP_RANGE'])) {
5222 list(, $range) = explode(
'=', $_SERVER[
'HTTP_RANGE'], 2);
5224 if (strpos($range,
',') !==
false) {
5229 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
5230 header(
"Content-Range: bytes $start-$end/$size");
5237 if ($range ==
'-') {
5240 $c_start =
$size - substr($range, 1);
5244 $range = explode(
'-', $range);
5245 $c_start = $range[0];
5246 $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] :
$size;
5252 $c_end = ($c_end > $end) ? $end : $c_end;
5254 if ($c_start > $c_end || $c_start >
$size - 1 || $c_end >=
$size) {
5256 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
5257 header(
"Content-Range: bytes $start-$end/$size");
5263 $length = $end - $start + 1;
5265 header(
'HTTP/1.1 206 Partial Content');
5268 header(
"Content-Range: bytes $start-$end/$size");
5269 header(
"Content-Length: $length");
5273 while(!feof($fp) && ($p = ftell($fp)) <= $end) {
5275 if ($p + $buffer > $end) {
5279 $buffer = $end - $p + 1;
5282 echo fread($fp, $buffer);