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/classes/class.ilStyleDefinition.php");
89 $current_skin = ilStyleDefinition::getCurrentSkin();
92 if (is_object($styleDefinition))
94 $image_dir = $styleDefinition->getImageDirectory(
98 if ($current_skin ==
"default")
100 $user_img =
".".$module_path.
"/templates/default/".$image_dir.
"/".
$img;
101 $skin_img =
".".$module_path.
"/templates/default/images/".
$img;
103 else if (is_object($styleDefinition) && $current_skin !=
"default")
105 $user_img =
"./Customizing/global/skin/".
106 $current_skin.$module_path.
"/".$image_dir.
"/".
$img;
107 $skin_img =
"./Customizing/global/skin/".
108 $current_skin.$module_path.
"/images/".
$img;
126 return "./images/".$img;
128 else if (@file_exists($user_img) && $image_dir !=
"")
132 else if (file_exists($skin_img))
152 if (substr($relative_path, 0, 2) ==
'./')
154 $relative_path = (substr($relative_path, 1));
156 if (substr($relative_path, 0, 1) !=
'/')
158 $relative_path =
'/' . $relative_path;
160 $htmlpath = ILIAS_HTTP_PATH . $relative_path;
182 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
183 $stylesheet_name = (strlen($a_css_name))
186 if (strlen($a_css_location) && (strcmp(substr($a_css_location, -1),
"/") != 0))
188 $a_css_location = $a_css_location .
"/";
193 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
194 if (ilStyleDefinition::getCurrentSkin() !=
"default")
196 $filename =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/".$a_css_location.$stylesheet_name;
200 $filename =
"./" . $a_css_location .
"templates/default/".$stylesheet_name;
203 if ($mode !=
"filesystem")
205 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
206 $vers =
"?vers=".str_replace(
".",
"-", $vers);
221 public static function getJSLocation($a_js_name, $a_js_location =
"", $add_version = FALSE)
226 $js_name = $a_js_name;
227 if (strlen($a_js_location) && (strcmp(substr($a_js_location, -1),
"/") != 0)) $a_js_location = $a_js_location .
"/";
231 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
232 if (ilStyleDefinition::getCurrentSkin() !=
"default")
234 $filename =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/".$a_js_location.$js_name;
238 $filename =
"./" . $a_js_location .
"templates/default/".$js_name;
243 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
244 $vers =
"?vers=".str_replace(
".",
"-", $vers);
260 if (defined(
"ILIAS_MODULE"))
265 $base .=
"../Services/Privacy/";
270 $base =
"./Services/Privacy/";
273 if (is_file($base.
"w3c/p3p.xml"))
275 return ILIAS_HTTP_PATH.
"w3c/p3p.xml";
279 return ILIAS_HTTP_PATH.
"/w3c/p3p_template.xml";
295 if ($mode !=
"filesystem")
297 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
298 $vers =
"?vers=".str_replace(
".",
"-", $vers);
302 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
303 if (ilStyleDefinition::getCurrentSkin() ==
"default")
305 $in_style =
"./templates/".ilStyleDefinition::getCurrentSkin().
"/"
306 .ilStyleDefinition::getCurrentStyle().
"_cont.css";
310 $in_style =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/"
311 .ilStyleDefinition::getCurrentStyle().
"_cont.css";
314 if (is_file(
"./".$in_style))
316 return $in_style.$vers;
320 return "templates/default/delos_cont.css".$vers;
343 $style_class =
"", $attribs =
"",$disabled =
false)
347 if ($multiple ==
true)
349 $multiple =
" multiple=\"multiple\"";
357 $class =
" class=\" form-control ".$style_class.
"\"";
363 if (is_array($attribs))
365 foreach ($attribs as $key => $val)
367 $attributes .=
" ".$key.
"=\"".$val.
"\"";
372 $disabled =
' disabled=\"disabled\"';
375 $str =
"<select name=\"".$varname .
"\"".$multiple.
" $class size=\"".
$size.
"\" $attributes $disabled>\n";
377 foreach ((array)
$options as $key => $val)
382 $style = $val[
"style"];
386 $sty = ($style !=
"")
387 ?
' style="'.$style.
'" '
392 $str .=
" <option $sty value=\"".$key.
"\"";
396 $str .=
" <option $sty value=\"".$val.
"\"";
398 if (is_array($selected) )
400 if (in_array($key,$selected))
402 $str .=
" selected=\"selected\"";
405 else if ($selected == $key)
407 $str .=
" selected=\"selected\"";
412 $str .=
">".$val.
"</option>\n";
416 $str .=
">".$lng->txt($val).
"</option>\n";
420 $str .=
"</select>\n";
436 return($values[$selected]);
450 public static function formCheckbox ($checked,$varname,$value,$disabled =
false)
452 $str =
"<input type=\"checkbox\" name=\"".$varname.
"\"";
456 $str .=
" checked=\"checked\"";
461 $str .=
" disabled=\"disabled\"";
466 if (substr($varname,-2) ==
"[]")
474 $varname_id = substr($varname,0,-2).
"_".$value;
478 $varname_id = $varname;
482 $varname_id = ereg_replace(
"\[",
"_",$varname_id);
483 $varname_id = ereg_replace(
"\]",
"",$varname_id);
485 $str .=
" value=\"".$value.
"\" id=\"".$varname_id.
"\" />\n";
504 $str =
"<input disabled type=\"radio\" name=\"".$varname.
"\"";
507 $str =
"<input type=\"radio\" name=\"".$varname.
"\"";
511 $str .=
" checked=\"checked\"";
514 $str .=
" value=\"".$value.
"\"";
515 $str .=
" id=\"".$value.
"\" />\n";
532 public static function formRadioButton($checked,$varname,$value,$onclick=null, $disabled =
false)
538 $str .= (
'onclick="'.$onclick.
'"');
541 $str .= (
" type=\"radio\" name=\"".$varname.
"\"");
544 $str .=
" checked=\"checked\"";
549 $str .=
" disabled=\"disabled\"";
552 $str .=
" value=\"".$value.
"\"";
554 $str .=
" id=\"".$value.
"\" />\n";
569 public static function formInput($varname,$value,$disabled =
false)
572 $str =
"<input type=\"input\" name=\"".$varname.
"\"";
578 $str .=
" value=\"".$value.
"\"";
580 $str .=
" id=\"".$value.
"\" />\n";
606 if (
"" != $a_path &&
"/" != substr($a_path, -1))
653 foreach ($emptyFields as $key => $val)
656 if ($feedback !=
"") $feedback .=
", ";
688 public static function Linkbar ($AScript,$AHits,$ALimit,$AOffset,$AParams = array(),$ALayout = array(), $prefix =
'')
693 $layout_prev =
"<<";
694 $layout_next =
">>";
697 if (count($ALayout > 0))
699 if ($ALayout[
"link"])
701 $layout_link =
" class=\"".$ALayout[
"link"].
"\"";
704 if ($ALayout[
"prev"])
706 $layout_prev = $ALayout[
"prev"];
709 if ($ALayout[
"next"])
711 $layout_next = $ALayout[
"next"];
717 if ($AHits > $ALimit || $AOffset > 0)
719 if (!empty($AParams))
721 foreach ($AParams as $key => $value)
723 $params.= $key.
"=".$value.
"&";
727 if(strpos($AScript,
'&'))
729 $link = $AScript.
"&".$params.$prefix.
"offset=";
733 $link = $AScript.
"?".$params.$prefix.
"offset=";
739 $prevoffset = $AOffset - $ALimit;
740 if ($prevoffset < 0) $prevoffset = 0;
741 $LinkBar .=
"<a".$layout_link.
" href=\"".$link.$prevoffset.
"\">".$layout_prev.
" </a>";
745 $pages=intval($AHits/$ALimit);
748 if (($AHits % $ALimit))
755 for ($i = 1 ;$i <= $pages ; $i++)
757 $newoffset=$ALimit*($i-1);
759 if ($newoffset == $AOffset)
761 $LinkBar .=
"[".$i.
"] ";
765 $LinkBar .=
'<a '.$layout_link.
' href="'.
766 $link.$newoffset.
'">['.$i.
']</a> ';
773 if (! ( ($AOffset/$ALimit)==($pages-1) ) && ($pages!=1) )
775 $newoffset=$AOffset+$ALimit;
776 $LinkBar .=
"<a".$layout_link.
" href=\"".$link.$newoffset.
"\"> ".$layout_next.
"</a>";
804 $ret = eregi_replace(
"(^|[[:space:]]+)(www\.)([[:alnum:]#?/&=\.-]+)",
805 "\\1http://\\2\\3",
$ret);
808 $ret = eregi_replace(
"(^|[[:space:]]+)(ftp\.)([[:alnum:]#?/&=\.-]+)",
809 "\\1ftp://\\2\\3",
$ret);
816 $ret = str_replace(
'src="http://',
'"***masked_im_start***',
$ret);
818 include_once(
"./Services/Utilities/classes/class.ilMWParserAdapter.php");
820 $ret = $parser->replaceFreeExternalLinks(
$ret);
823 $ret = str_replace(
'"***masked_im_start***',
'src="http://',
$ret);
827 if ($detectGotoLinks)
830 $regExp =
"<a[^>]*href=\"(".str_replace(
"/",
"\/",ILIAS_HTTP_PATH).
"\/goto.php\?target=\w+_(\d+)[^\"]*)\"[^>]*>[^<]*<\/a>";
832 $ret = preg_replace_callback(
834 array(
"ilUtil",
"replaceLinkProperties"),
838 $regExp =
"<a[^>]*href=\"(".str_replace(
"/",
"\/",ILIAS_HTTP_PATH).
"\/goto_.*[a-z0-9]+_([0-9]+)\.html)\"[^>]*>[^<]*<\/a>";
840 $ret = preg_replace_callback(
842 array(
"ilUtil",
"replaceLinkProperties"),
873 $link =
"<a href=".$matches[1].
" target=\"_self\">".$title.
"</a>";
897 public static function makeDateSelect($prefix, $year =
"", $month =
"", $day =
"", $startyear =
"",$a_long_month =
true,$a_further_options = array(), $emptyoption =
false)
902 if(isset($a_further_options[
'disabled']) and $a_further_options[
'disabled'])
904 $disabled =
'disabled="disabled" ';
910 if (!strlen($year)) $year = $now[
"year"];
911 if (!strlen($month)) $month = $now[
"mon"];
912 if (!strlen($day)) $day = $now[
"mday"];
916 $month = (int) $month;
921 $sel_day .=
'<select class="form-control" ';
922 if(isset($a_further_options[
'select_attributes']))
924 foreach($a_further_options[
'select_attributes'] as $name => $value)
926 $sel_day .= ($name.
'="'.$value.
'" ');
930 $sel_day .= $disabled.
"name=\"".$prefix.
"[d]\" id=\"".$prefix.
"_d\">\n";
932 if ($emptyoption) $sel_day .=
"<option value=\"0\">--</option>\n";
933 for ($i = 1; $i <= 31; $i++)
935 $sel_day .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
937 $sel_day .=
"</select>\n";
938 $sel_day = preg_replace(
"/(value\=\"$day\")/",
"$1 selected=\"selected\"", $sel_day);
941 $sel_month =
'<select class="form-control" ';
942 if(isset($a_further_options[
'select_attributes']))
944 foreach($a_further_options[
'select_attributes'] as $name => $value)
946 $sel_month .= ($name.
'="'.$value.
'" ');
949 $sel_month .= $disabled.
"name=\"".$prefix.
"[m]\" id=\"".$prefix.
"_m\">\n";
951 if ($emptyoption) $sel_month .=
"<option value=\"0\">--</option>\n";
952 for ($i = 1; $i <= 12; $i++)
956 $sel_month .=
"<option value=\"$i\">" . $lng->txt(
"month_" . sprintf(
"%02d", $i) .
"_long") .
"</option>\n";
960 $sel_month .=
"<option value=\"$i\">" . $i .
"</option>\n";
963 $sel_month .=
"</select>\n";
964 $sel_month = preg_replace(
"/(value\=\"$month\")/",
"$1 selected=\"selected\"", $sel_month);
967 $sel_year =
'<select class="form-control" ';
968 if(isset($a_further_options[
'select_attributes']))
970 foreach($a_further_options[
'select_attributes'] as $name => $value)
972 $sel_year .= ($name.
'="'.$value.
'" ');
975 $sel_year .= $disabled.
"name=\"".$prefix.
"[y]\" id=\"".$prefix.
"_y\">\n";
976 if ((strlen($startyear) == 0) || ($startyear > $year))
978 if (!$emptyoption || $year != 0) $startyear = $year - 5;
981 if(($year + 5) < (date(
'Y',time()) + 5))
983 $end_year = date(
'Y',time()) + 5;
987 $end_year = $year + 5;
990 if ($emptyoption) $sel_year .=
"<option value=\"0\">----</option>\n";
991 for ($i = $startyear; $i <= $end_year; $i++)
993 $sel_year .=
"<option value=\"$i\">" . sprintf(
"%04d", $i) .
"</option>\n";
995 $sel_year .=
"</select>\n";
996 $sel_year = preg_replace(
"/(value\=\"$year\")/",
"$1 selected=\"selected\"", $sel_year);
999 $dateformat =
"d-m-Y";
1000 $dateformat = strtolower(preg_replace(
"/\W/",
"", $dateformat));
1001 $dateformat = strtolower(preg_replace(
"/(\w)/",
"%%$1", $dateformat));
1002 $dateformat = preg_replace(
"/%%d/", $sel_day, $dateformat);
1003 $dateformat = preg_replace(
"/%%m/", $sel_month, $dateformat);
1004 $dateformat = preg_replace(
"/%%y/", $sel_year, $dateformat);
1026 public static function makeTimeSelect($prefix, $short =
true, $hour =
"", $minute =
"", $second =
"",$a_use_default =
true,$a_further_options = array())
1032 if(count($a_further_options))
1034 if(isset($a_further_options[
'minute_steps']))
1036 $minute_steps = $a_further_options[
'minute_steps'];
1038 if(isset($a_further_options[
'disabled']) and $a_further_options[
'disabled'])
1040 $disabled =
'disabled="disabled" ';
1044 if ($a_use_default and !strlen(
"$hour$minute$second")) {
1051 $minute = (int)$minute;
1052 $second = (int)$second;
1055 $sel_hour =
'<select ';
1056 if(isset($a_further_options[
'select_attributes']))
1058 foreach($a_further_options[
'select_attributes'] as $name => $value)
1060 $sel_hour .= $name.
'='.$value.
' ';
1063 $sel_hour .=
" ".$disabled.
"name=\"".$prefix.
"[h]\" id=\"".$prefix.
"_h\" class=\"form-control\">\n";
1065 $format = $ilUser->getTimeFormat();
1066 for ($i = 0; $i <= 23; $i++)
1070 $sel_hour .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1074 $sel_hour .=
"<option value=\"$i\">" . date(
"ga", mktime($i, 0, 0)) .
"</option>\n";
1077 $sel_hour .=
"</select>\n";
1078 $sel_hour = preg_replace(
"/(value\=\"$hour\")/",
"$1 selected=\"selected\"", $sel_hour);
1081 $sel_minute .=
"<select ".$disabled.
"name=\"".$prefix.
"[m]\" id=\"".$prefix.
"_m\" class=\"form-control\">\n";
1083 for ($i = 0; $i <= 59; $i = $i + $minute_steps)
1085 $sel_minute .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1087 $sel_minute .=
"</select>\n";
1088 $sel_minute = preg_replace(
"/(value\=\"$minute\")/",
"$1 selected=\"selected\"", $sel_minute);
1092 $sel_second .=
"<select ".$disabled.
"name=\"".$prefix.
"[s]\" id=\"".$prefix.
"_s\" class=\"form-control\">\n";
1094 for ($i = 0; $i <= 59; $i++)
1096 $sel_second .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1098 $sel_second .=
"</select>\n";
1099 $sel_second = preg_replace(
"/(value\=\"$second\")/",
"$1 selected=\"selected\"", $sel_second);
1101 $timeformat = $lng->text[
"lang_timeformat"];
1102 if (strlen($timeformat) == 0) $timeformat =
"H:i:s";
1103 $timeformat = strtolower(preg_replace(
"/\W/",
"", $timeformat));
1104 $timeformat = preg_replace(
"/(\w)/",
"%%$1", $timeformat);
1105 $timeformat = preg_replace(
"/%%h/", $sel_hour, $timeformat);
1106 $timeformat = preg_replace(
"/%%i/", $sel_minute, $timeformat);
1108 $timeformat = preg_replace(
"/%%s/",
"", $timeformat);
1110 $timeformat = preg_replace(
"/%%s/", $sel_second, $timeformat);
1135 if(is_object($ilErr))
1137 require_once
'./Services/PEAR/lib/Mail/RFC822.php';
1140 $addresses = $parser->parseAddressList($a_email,
'ilias',
false,
true);
1141 if(!is_a($addresses,
'PEAR_Error') &&
1142 count($addresses) == 1 && $addresses[0]->host !=
'ilias'
1157 "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|".
1158 "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|".
1159 "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|".
1160 "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|".
1161 "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|".
1162 "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|".
1163 "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|".
1164 "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|".
1165 "WF|WS|XN|YE|YT|YU|ZA|ZM|ZW");
1167 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));
1180 public static function isPassword($a_passwd, &$customError = null)
1184 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1188 if( empty($a_passwd) )
1190 $customError = $lng->txt(
'password_empty');
1198 if( $security->getPasswordMinLength() > 0 && strlen($a_passwd) < $security->getPasswordMinLength() )
1200 $errors[] = sprintf( $lng->txt(
'password_to_short'), $security->getPasswordMinLength() );
1201 $isPassword =
false;
1206 if( $security->getPasswordMaxLength() > 0 && strlen($a_passwd) > $security->getPasswordMaxLength() )
1208 $errors[] = sprintf( $lng->txt(
'password_to_long'), $security->getPasswordMaxLength() );
1209 $isPassword =
false;
1213 if( $security->isPasswordCharsAndNumbersEnabled() )
1215 $hasCharsAndNumbers =
true;
1218 if( !preg_match(
'/[A-Za-z]+/',$a_passwd) )
1220 $hasCharsAndNumbers =
false;
1224 if( !preg_match(
'/[0-9]+/',$a_passwd) )
1226 $hasCharsAndNumbers =
false;
1229 if( !$hasCharsAndNumbers )
1231 $errors[] = $lng->txt(
'password_must_chars_and_numbers');
1232 $isPassword =
false;
1236 require_once
'Services/Utilities/classes/class.ilStr.php';
1237 if($security->getPasswordNumberOfUppercaseChars() > 0)
1239 if(
ilStr::strLen($a_passwd) -
ilStr::strLen(preg_replace(
'/[A-Z]/',
'', $a_passwd)) < $security->getPasswordNumberOfUppercaseChars())
1241 $errors[] = sprintf($lng->txt(
'password_must_contain_ucase_chars'), $security->getPasswordNumberOfUppercaseChars());
1242 $isPassword =
false;
1246 if($security->getPasswordNumberOfLowercaseChars() > 0)
1248 if(
ilStr::strLen($a_passwd) -
ilStr::strLen(preg_replace(
'/[a-z]/',
'', $a_passwd)) < $security->getPasswordNumberOfLowercaseChars())
1250 $errors[] = sprintf($lng->txt(
'password_must_contain_lcase_chars'), $security->getPasswordNumberOfLowercaseChars());
1251 $isPassword =
false;
1256 if( $security->isPasswordSpecialCharsEnabled() )
1259 if( !preg_match( self::getPasswordValidChars(
true,
true) , $a_passwd) )
1261 $errors[] = $lng->txt(
'password_must_special_chars');
1262 $isPassword =
false;
1267 if( !preg_match( self::getPasswordValidChars() , $a_passwd) )
1269 $errors[] = $lng->txt(
'password_contains_invalid_chars');
1270 $isPassword =
false;
1280 $customError = $lng->txt(
'password_multiple_errors');
1281 $customError .=
'<br />'.implode(
'<br />',
$errors);
1295 include_once
'Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
1300 if(is_string($user))
1304 else if(is_array($user))
1307 $login = $user[
'login'];
1308 $userId = $user[
'id'];
1312 $login = $user->getLogin();
1313 $userId = $user->getId();
1318 if($login && (
int)$security->getPasswordMustNotContainLoginnameStatus() &&
1319 strpos(strtolower($clear_text_password), strtolower($login)) !== false
1322 $error_language_variable =
'password_contains_parts_of_login_err';
1340 if( $a_only_special_chars )
1342 return '/[_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+/';
1346 return '/^[A-Za-z0-9_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+$/';
1351 return 'A-Z a-z 0-9 _.+?#-*@!$%~/:;';
1366 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1372 if( $security->getPasswordMinLength() > 0 )
1374 $infos[] = sprintf( $lng->txt(
'password_to_short'), $security->getPasswordMinLength() );
1378 if( $security->getPasswordMaxLength() > 0 )
1380 $infos[] = sprintf( $lng->txt(
'password_to_long'), $security->getPasswordMaxLength() );
1384 if( $security->isPasswordCharsAndNumbersEnabled() )
1386 $infos[] = $lng->txt(
'password_must_chars_and_numbers');
1390 if( $security->isPasswordSpecialCharsEnabled() )
1392 $infos[] = $lng->txt(
'password_must_special_chars');
1395 if($security->getPasswordNumberOfUppercaseChars() > 0)
1397 $infos[] = sprintf($lng->txt(
'password_must_contain_ucase_chars'), $security->getPasswordNumberOfUppercaseChars());
1400 if($security->getPasswordNumberOfLowercaseChars() > 0)
1402 $infos[] = sprintf($lng->txt(
'password_must_contain_lcase_chars'), $security->getPasswordNumberOfLowercaseChars());
1405 return implode(
'<br />', $infos);
1416 if (empty($a_login))
1421 if (strlen($a_login) < 3)
1429 if (!ereg(
"^[A-Za-z0-9_\.\+\*\@!\$\%\~\-]+$", $a_login))
1450 public static function shortenText ($a_str, $a_len, $a_dots =
false, $a_next_blank =
false,
1451 $a_keep_extension =
false)
1453 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1469 if ($a_keep_extension)
1471 $p = strrpos($a_str,
'.');
1473 if ($p ===
false || $p == 0 || strlen($a_str) - $p > $a_len)
1478 $a_str .=
"\xe2\x80\xa6";
1485 $a_str =
ilStr::subStr($a_str,0,$len - (strlen($a_str) - $p + 1)).
"\xe2\x80\xa6".substr($a_str, $p);
1489 $a_str =
ilStr::subStr($a_str,0,$len - (strlen($a_str) - $p + 1)).substr($a_str, $p);
1509 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1510 $str_arr = explode(
" ", $a_str);
1512 for ($i = 0; $i < count($str_arr); $i++)
1519 $str_arr[$i].=
"...";
1524 return implode($str_arr,
" ");
1539 while (is_int(strpos($a_str,
"=")))
1541 $eq_pos = strpos($a_str,
"=");
1542 $qu1_pos = strpos($a_str,
"\"");
1543 $qu2_pos = strpos(substr($a_str, $qu1_pos + 1),
"\"") + $qu1_pos + 1;
1544 if (is_int($eq_pos) && is_int($qu1_pos) && is_int($qu2_pos))
1546 $var = trim(substr($a_str, 0, $eq_pos));
1547 $val = trim(substr($a_str, $qu1_pos + 1, ($qu2_pos - $qu1_pos) - 1));
1548 $attribs[$var] = $val;
1549 $a_str = substr($a_str, $qu2_pos + 1);
1570 public static function rCopy ($a_sdir, $a_tdir, $preserveTimeAttributes =
false)
1573 if (!@is_dir($a_sdir) or
1580 $dir = opendir($a_sdir);
1582 while(
$file = readdir($dir))
1584 if (
$file !=
"." and
1588 if (@is_dir($a_sdir.
"/".
$file))
1590 if (!@is_dir($a_tdir.
"/".
$file))
1605 if (@is_file($a_sdir.
"/".
$file))
1607 if (!copy($a_sdir.
"/".
$file,$a_tdir.
"/".
$file))
1611 if ($preserveTimeAttributes)
1612 touch($a_tdir.
"/".
$file, filectime($a_sdir.
"/".
$file));
1631 if ($mode ==
"filesystem")
1633 return "./".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1637 if (defined(
"ILIAS_MODULE"))
1639 return "../".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1643 return "./".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1658 return CLIENT_DATA_DIR;
1675 include_once(
"./Services/User/classes/class.ilObjUser.php");
1676 return ilObjUser::_getUsersOnline($a_user_id);
1691 include_once(
"./Services/User/classes/class.ilObjUser.php");
1705 if (!is_dir($temp_path))
1709 $temp_name = tempnam($temp_path,
"tmp");
1715 $temp_name = str_replace(
"\\",
"/", $temp_name);
1745 public static function unzip($a_file, $overwrite =
false, $a_flat =
false)
1747 if (!is_file($a_file))
1757 copy($a_file, $tmpdir.DIRECTORY_SEPARATOR.basename($a_file));
1758 $orig_file = $a_file;
1759 $a_file = $tmpdir.DIRECTORY_SEPARATOR.basename($a_file);
1760 $origpathinfo = pathinfo($orig_file);
1763 $pathinfo = pathinfo($a_file);
1764 $dir = $pathinfo[
"dirname"];
1765 $file = $pathinfo[
"basename"];
1770 $unzip = PATH_TO_UNZIP;
1816 $unzipcmd =
"-o ".ilUtil::escapeShellArg(
$file);
1825 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
1826 $filearray = array();
1828 if (is_array($filearray[
"file"]))
1830 foreach ($filearray[
"file"] as $k => $f)
1832 if (substr($f, 0, 1) !=
"." && $f != basename($orig_file))
1834 copy($filearray[
"path"][$k].$f, $origpathinfo[
"dirname"].DIRECTORY_SEPARATOR.$f);
1848 public static function zip($a_dir, $a_file, $compress_content =
false)
1852 if($compress_content)
1855 $pathinfo = pathinfo($a_dir);
1856 chdir($pathinfo[
"dirname"]);
1859 $pathinfo = pathinfo($a_file);
1860 $dir = $pathinfo[
"dirname"];
1861 $file = $pathinfo[
"basename"];
1863 if(!$compress_content)
1876 if (is_array($a_dir))
1879 foreach($a_dir as $dir)
1881 $name = basename($dir);
1882 $source.=
" ".ilUtil::escapeShellArg($name);
1887 $name = basename($a_dir);
1888 if (trim($name) !=
"*")
1898 $zipcmd =
"-r ".ilUtil::escapeShellArg($a_file).
" ".$source;
1908 $pathinfo = pathinfo($a_dir);
1909 chdir($pathinfo[
"dirname"]);
1911 $pathinfo = pathinfo($a_file);
1912 $dir = $pathinfo[
"dirname"];
1913 $file = $pathinfo[
"basename"]; $zipcmd =
"-r ".ilUtil::escapeShellArg($a_file).
" ".$source;
1915 $mkisofs = PATH_TO_MKISOFS;
1922 $name = basename($a_dir);
1925 $zipcmd =
"-r -J -o ".$a_file.
" ".$source;
1941 return PATH_TO_CONVERT;
1967 if($current_version >= $version)
1982 if(preg_match(
"/([0-9]+)\.([0-9]+)\.([0-9]+)([\.|\-]([0-9]+))?/", $a_version, $match))
1984 $version = str_pad($match[1], 2, 0, STR_PAD_LEFT).
1985 str_pad($match[2], 2, 0, STR_PAD_LEFT).
1986 str_pad($match[3], 2, 0, STR_PAD_LEFT).
1987 str_pad($match[5], 2, 0, STR_PAD_LEFT);
1988 return (
int)$version;
2001 public static function convertImage($a_from, $a_to, $a_target_format =
"", $a_geometry =
"",
2002 $a_background_color =
"")
2004 $format_str = ($a_target_format !=
"")
2005 ? strtoupper($a_target_format).
":"
2008 if ($a_geometry !=
"")
2010 if (is_int(strpos($a_geometry,
"x")))
2012 $geometry =
" -geometry ".$a_geometry.
" ";
2016 $geometry =
" -geometry ".$a_geometry.
"x".$a_geometry.
" ";
2020 $bg_color = ($a_background_color !=
"")
2021 ?
" -background color ".$a_background_color.
" "
2023 $convert_cmd =
ilUtil::escapeShellArg($a_from).
" ".$bg_color.$geometry.ilUtil::escapeShellArg($format_str.$a_to);
2038 public static function resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop =
false)
2040 if ($a_constrain_prop)
2042 $size =
" -geometry ".$a_width.
"x".$a_height.
" ";
2046 $size =
" -resize ".$a_width.
"x".$a_height.
"! ";
2059 public static function img($a_src, $a_alt =
"", $a_width =
"", $a_height =
"", $a_border = 0, $a_id =
"", $a_class =
"")
2061 $img =
'<img src="'.$a_src.
'"';
2064 $img.=
' alt="'.$a_alt.
'" title="'.$a_alt.
'"';
2068 $img.=
' width="'.$a_width.
'"';
2070 if ($a_height !=
"")
2072 $img.=
' height="'.$a_height.
'"';
2076 $img.=
' class="'.$a_class.
'"';
2080 $img.=
' id="'.$a_id.
'"';
2082 $img.=
' border="'.(int) $a_border.
'"/>';
2096 $html_file = str_replace(
".pdf",
".html",$pdf_file);
2098 $fp = fopen( $html_file ,
"wb");
2113 $htmldoc_path = PATH_TO_HTMLDOC;
2115 $htmldoc =
"--no-toc ";
2116 $htmldoc .=
"--no-jpeg ";
2117 $htmldoc .=
"--webpage ";
2119 $htmldoc .=
"--bodyfont Arial ";
2120 $htmldoc .=
"--charset iso-8859-15 ";
2121 $htmldoc .=
"--color ";
2122 $htmldoc .=
"--size A4 ";
2123 $htmldoc .=
"--format pdf ";
2124 $htmldoc .=
"--footer ... ";
2125 $htmldoc .=
"--header ... ";
2126 $htmldoc .=
"--left 60 ";
2128 $htmldoc .= $html_file;
2139 public static function deliverData($a_data, $a_filename, $mime =
"application/octet-stream", $charset =
"")
2141 $disposition =
"attachment";
2144 include_once
'./Services/Http/classes/class.ilHTTPS.php';
2154 #header("Pragma: ");
2155 #header("Cache-Control: ");
2156 #header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
2157 #header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
2158 #header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
2159 #header("Cache-Control: post-check=0, pre-check=0", false);
2161 else if ($disposition ==
"attachment")
2163 header(
"Cache-control: private");
2167 header(
"Cache-Control: no-cache, must-revalidate");
2168 header(
"Pragma: no-cache");
2173 if (strlen($charset))
2175 $charset =
"; charset=$charset";
2177 header(
"Content-Type: $mime$charset");
2178 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
2179 header(
"Content-Description: ".$ascii_filename);
2180 header(
"Content-Length: ".(
string)(strlen($a_data)));
2185 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
2186 header(
'Pragma: public');
2189 header(
"Connection: close");
2202 public static function deliverFile($a_file, $a_filename,$a_mime =
'', $isInline =
false, $removeAfterDelivery =
false,
2203 $a_exit_after =
true)
2206 if(!file_exists($a_file))
2212 $disposition =
"inline";
2214 $disposition =
"attachment";
2225 $mime =
"application/octet-stream";
2229 if ($disposition ==
"attachment")
2231 header(
"Cache-control: private");
2235 header(
"Cache-Control: no-cache, must-revalidate");
2236 header(
"Pragma: no-cache");
2241 header(
"Content-Type: $mime");
2242 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
2243 header(
"Content-Description: ".$ascii_filename);
2246 $filesize = @filesize($a_file);
2249 header(
"Content-Length: ".(
string)$filesize);
2252 include_once
'./Services/Http/classes/class.ilHTTPS.php';
2253 #if($_SERVER['HTTPS'])
2256 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
2257 header(
'Pragma: public');
2260 header(
"Connection: close");
2262 if ($removeAfterDelivery)
2284 $chunksize = 1*(1024*1024);
2286 $handle = fopen($a_file,
'rb');
2287 if ($handle ===
false)
2291 while (!feof($handle))
2293 $buffer = fread($handle, $chunksize);
2296 return fclose($handle);
2326 $ascii_filename = htmlentities($a_filename, ENT_NOQUOTES,
'UTF-8');
2327 $ascii_filename = preg_replace(
'/\&(.)[^;]*;/',
'\\1', $ascii_filename);
2328 $ascii_filename = preg_replace(
'/[\x7f-\xff]/',
'_', $ascii_filename);
2331 $ascii_filename = preg_replace(
'/[:\x5c\/\*\?\"<>\|]/',
'_', $ascii_filename);
2332 return $ascii_filename;
2344 $sep =
'###HTMLTAG###';
2346 preg_match_all(
"@<[^>]*>@", $htmlText, $matches);
2347 $tmp = preg_replace(
"@(<[^>]*>)@", $sep, $htmlText);
2348 $tmp = explode($sep, $tmp);
2350 for ($i=0; $i<count($tmp); $i++)
2351 $tmp[$i] = htmlentities($tmp[$i], ENT_COMPAT,
"UTF-8");
2353 $tmp = join($sep, $tmp);
2355 for ($i=0; $i<count($matches[0]); $i++)
2356 $tmp = preg_replace(
"@$sep@", $matches[0][$i], $tmp, 1);
2369 return PATH_TO_JAVA;
2388 $url = (is_int(strpos($a_url,
"?")))
2389 ? $a_url.$amp.$a_par
2390 : $a_url.
"?".$a_par;
2412 $a_dir = trim($a_dir);
2415 if (substr($a_dir,-1) ==
"/")
2417 $a_dir = substr($a_dir,0,-1);
2421 if (!(
$path = substr($a_dir,0, strrpos($a_dir,
"/") - strlen($a_dir))))
2428 return @mkdir($a_dir,fileperms(
$path));
2448 $dirs = array($a_dir);
2449 $a_dir = dirname($a_dir);
2452 while($last_dirname != $a_dir)
2454 array_unshift(
$dirs, $a_dir);
2455 $last_dirname = $a_dir;
2456 $a_dir = dirname($a_dir);
2460 $reverse_paths = array_reverse(
$dirs, TRUE);
2462 foreach ($reverse_paths as $key => $value)
2464 if ($found_index == -1)
2468 $found_index = $key;
2474 foreach (
$dirs as $dirindex => $dir)
2477 if ($dirindex >= $found_index)
2479 if (! file_exists($dir))
2481 if (strcmp(substr($dir,strlen($dir)-1,1),
"/") == 0)
2485 $dir = substr($dir,0,strlen($dir)-1);
2487 if (! mkdir($dir, $umask))
2489 error_log(
"Can't make directory: $dir");
2493 elseif (! is_dir($dir))
2495 error_log(
"$dir is not a directory");
2501 $umask = fileperms($dir);
2517 public static function delDir($a_dir, $a_clean_only =
false)
2519 if (!is_dir($a_dir) || is_int(strpos($a_dir,
"..")))
2524 $current_dir = opendir($a_dir);
2533 while($entryname = readdir($current_dir))
2535 $files[] = $entryname;
2538 foreach($files as
$file)
2540 if(is_dir($a_dir.
"/".$file) and ($file !=
"." and $file!=
".."))
2544 elseif ($file !=
"." and $file !=
"..")
2546 unlink(${a_dir}.
"/".${file});
2550 closedir($current_dir);
2564 public static function getDir($a_dir, $a_rec =
false, $a_sub_dir =
"")
2566 $current_dir = opendir($a_dir.$a_sub_dir);
2570 $subitems = array();
2571 while($entry = readdir($current_dir))
2573 if(is_dir($a_dir.
"/".$entry))
2575 $dirs[$entry] = array(
"type" =>
"dir",
"entry" => $entry,
2576 "subdir" => $a_sub_dir);
2577 if ($a_rec && $entry !=
"." && $entry !=
"..")
2580 $subitems = array_merge($subitems,
$si);
2585 if ($entry !=
"." && $entry !=
"..")
2587 $size = filesize($a_dir.$a_sub_dir.
"/".$entry);
2588 $files[$entry] = array(
"type" =>
"file",
"entry" => $entry,
2589 "size" =>
$size,
"subdir" => $a_sub_dir);
2596 return array_merge(
$dirs, $files, $subitems);
2607 if (is_array($a_arr))
2609 foreach ($a_arr as $k => $v)
2626 if (is_array($a_data))
2628 foreach ($a_data as $k => $v)
2655 public static function stripSlashes($a_str, $a_strip_html =
true, $a_allow =
"")
2657 if (ini_get(
"magic_quotes_gpc"))
2659 $a_str = stripslashes($a_str);
2675 if (ini_get(
"magic_quotes_gpc"))
2677 $a_str = stripslashes($a_str);
2689 public static function secureString($a_str, $a_strip_html =
true, $a_allow =
"")
2692 $only_secure =
true;
2693 $allow_tags = explode(
">", $a_allow);
2695 $allow_array = array();
2696 foreach($allow_tags as $allow)
2700 $allow = str_replace(
"<",
"", $allow);
2702 if (!in_array($allow, $sec_tags))
2704 $only_secure =
false;
2706 $allow_array[] = $allow;
2711 if (($only_secure || $a_allow ==
"") && $a_strip_html)
2715 $allow_array = array (
"b",
"i",
"strong",
"em",
"code",
"cite",
2716 "gap",
"sub",
"sup",
"pre",
"strike");
2722 $a_str = strip_tags($a_str);
2747 return array(
"strong",
"em",
"u",
"strike",
"ol",
"li",
"ul",
"p",
"div",
2748 "i",
"b",
"code",
"sup",
"sub",
"pre",
"gap",
"a",
"img");
2753 foreach ($allow_array as
$t)
2768 array(
"param" =>
"align",
"value" =>
"left"),
2769 array(
"param" =>
"align",
"value" =>
"center"),
2770 array(
"param" =>
"align",
"value" =>
"justify"),
2771 array(
"param" =>
"align",
"value" =>
"right")
2786 foreach ($allow_array as
$t)
2801 array(
"param" =>
"align",
"value" =>
"left"),
2802 array(
"param" =>
"align",
"value" =>
"center"),
2803 array(
"param" =>
"align",
"value" =>
"justify"),
2804 array(
"param" =>
"align",
"value" =>
"right")
2826 if (ini_get(
"magic_quotes_gpc"))
2828 return stripslashes($a_str);
2855 if ($a_make_links_clickable)
2873 $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);
2876 foreach ($matches as $match)
2879 foreach ($matches[0] as $match)
2881 $matched_text = $match[0];
2883 if ($matched_offset != previous_offset)
2886 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1, $pos2 - $pos1)));
2892 $pos1 = $pos2 + strlen($matched_text);
2894 if ($pos1 < strlen($a_str))
2896 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1)));
2901 $encoded = nl2br(htmlspecialchars($a_str));
2911 $ws =
"[ \t\r\f\v\n]*";
2912 $att = $ws.
"[^>]*".$ws;
2914 while (eregi(
"<($tag$att($tag_att$ws=$ws\"(([\$@!*()~;,_0-9A-z/:=%\\.&#?+\\-])*)\")$att)>",
2917 $un = array(
".",
"-",
"+",
"?",
'$',
"*",
"(",
")");
2923 $ff = str_replace($un, $esc, $found[1]);
2926 $a_str = eregi_replace(
"<".$ff.
">",
2927 "<$tag $tag_att$tag_att=\"".$found[3].
"\">", $a_str);
2928 if ($old_str == $a_str)
2930 $ilLog->write(
"ilUtil::maskA-".htmlentities($old_str).
" == ".
2931 htmlentities($a_str));
2935 $a_str = str_ireplace(
"</$tag>",
2936 "</$tag>", $a_str);
2944 while (eregi(
"<($tag $tag_att$tag_att=\"(([\$@!*()~;,_0-9A-z/:=%\\.&#?+\\-])*)\")>",
2947 $un = array(
".",
"-",
"+",
"?",
'$',
"*",
"(",
")");
2953 $ff = str_replace($un, $esc, $found[1]);
2956 $a_str = eregi_replace(
"<".$ff.
">",
2957 "<$tag $tag_att=\"".ilUtil::secureLink($found[2]).
"\">", $a_str);
2958 if ($old_str == $a_str)
2960 $ilLog->write(
"ilUtil::unmaskA-".htmlentities($old_str).
" == ".
2961 htmlentities($a_str));
2965 $a_str = str_replace(
"</$tag>",
"</$tag>", $a_str);
2971 $a_str = str_replace(array(
"<$t>",
"<".strtoupper(
$t).
">"),
2972 "<".
$t.
">", $a_str);
2973 $a_str = str_replace(array(
"</$t>",
"</".strtoupper(
$t).
">"),
2974 "</".
$t.
">", $a_str);
2976 if (is_array($fix_param))
2978 foreach ($fix_param as $p)
2982 $a_str = str_replace(
"<$t $k=\"$v\">",
2983 "<".
"$t $k=\"$v\"".
">", $a_str);
2992 $a_str = str_replace(
"<".
$t.
">",
"<".$t.
">", $a_str);
2993 $a_str = str_replace(
"</".
$t.
">",
"</".$t.
">", $a_str);
2995 if (is_array($fix_param))
2997 foreach ($fix_param as $p)
3001 $a_str = str_replace(
"<$t $k=\"$v\">",
3002 "<".
"$t $k=\"$v\"".
">", $a_str);
3010 $a_str = str_ireplace(
"javascript",
"jvscrpt", $a_str);
3011 $a_str = str_ireplace(array(
"%00",
"%0a",
"%0d",
"%1a",
"�",
"�",
3012 "�",
"�",
"
",
"
",
" ",
" "),
"-", $a_str);
3033 $negativestr =
"a,abbr,acronym,address,applet,area,b,base,basefont,".
3034 "bdo,big,blockquote,body,br,button,caption,center,cite,code,col,".
3035 "colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame,".
3036 "frameset,h1,h2,h3,h4,h5,h6,head,hr,html,i,iframe,img,input,ins,isindex,kbd,".
3037 "label,legend,li,link,map,menu,meta,noframes,noscript,object,ol,".
3038 "optgroup,option,p,param,q,s,samp,script,select,small,span,".
3039 "strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,".
3040 "title,tr,tt,u,ul,var";
3041 $a_allow = strtolower ($a_allow);
3042 $negatives = explode(
",",$negativestr);
3043 $outer_old_str =
"";
3044 while($outer_old_str != $a_str)
3046 $outer_old_str = $a_str;
3047 foreach ($negatives as $item)
3049 $pos = strpos($a_allow,
"<$item>");
3055 while($old_str != $a_str)
3058 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s*>/i",
"", $a_str);
3059 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s+([^>]*)>/i",
"", $a_str);
3068 $a_str = preg_replace(
"/<\s*\w*(\/?)(\s+[^>]*)?(\s+on[^>]*)>/i",
"", $a_str);
3071 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*javascript[^>]*>/i",
"", $a_str);
3075 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*expression[^>]*>/i",
"", $a_str);
3098 $a_str = htmlspecialchars($a_str);
3102 $a_str = str_replace(
"{",
"{", $a_str);
3103 $a_str = str_replace(
"}",
"}", $a_str);
3122 return addslashes($a_str);
3154 while(($spos=strpos($a_parstr,
"=")) &&
$ok)
3157 $cpar = substr($a_parstr,0,$spos);
3158 $a_parstr = substr($a_parstr,$spos,strlen($a_parstr)-$spos);
3159 while(substr($cpar,0,1)==
"," ||substr($cpar,0,1)==
" " || substr($cpar,0,1)==chr(13) || substr($cpar,0,1)==chr(10))
3160 $cpar = substr($cpar,1,strlen($cpar)-1);
3161 while(substr($cpar,strlen($cpar)-1,1)==
" " || substr($cpar,strlen($cpar)-1,1)==chr(13) || substr($cpar,strlen($cpar)-1,1)==chr(10))
3162 $cpar = substr($cpar,0,strlen($cpar)-1);
3166 while($cpar != $cpar_old)
3169 $cpar = eregi_replace(
"[^a-zA-Z0-9_]",
"", $cpar);
3175 if($spos=strpos($a_parstr,
"\""))
3177 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos);
3178 $spos=strpos($a_parstr,
"\"");
3181 $cval = substr($a_parstr,0,$spos);
3183 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos-1);
3193 if(
$ok)
return $par;
else return false;
3198 if (is_array($a_par_arr))
3201 foreach ($a_par_arr as $par => $val)
3220 for($i=0; $i<strlen($a_str); $i++)
3222 $ret.= ord(substr($a_str,$i,1)).
" ";
3236 if(strtolower($a_yn) ==
"y")
3276 global $array_sortby,$array_sortorder;
3278 if(!isset($array_sortby))
3286 if ($array_sortorder ==
"asc")
3291 if ($array_sortorder ==
"desc")
3293 return !
ilStr::strCmp($a[$array_sortby], $b[$array_sortby]);
3310 global $array_sortby,$array_sortorder;
3312 if ($array_sortorder ==
"asc")
3314 return $a[
"$array_sortby"] > $b[
"$array_sortby"];
3317 if ($array_sortorder ==
"desc")
3319 return $a[
"$array_sortby"] < $b[
"$array_sortby"];
3334 public static function sortArray($array,$a_array_sortby,$a_array_sortorder = 0,$a_numeric =
false,
3335 $a_keep_keys =
false)
3337 include_once(
"./Services/Utilities/classes/class.ilStr.php");
3340 if (! $a_keep_keys) {
3345 global $array_sortby,$array_sortorder;
3347 $array_sortby = $a_array_sortby;
3349 if ($a_array_sortorder ==
"desc")
3351 $array_sortorder =
"desc";
3355 $array_sortorder =
"asc";
3361 uasort($array, array(
"ilUtil",
"sort_func_numeric"));
3365 usort($array, array(
"ilUtil",
"sort_func_numeric"));
3372 uasort($array, array(
"ilUtil",
"sort_func"));
3376 usort($array, array(
"ilUtil",
"sort_func"));
3398 public static function stableSortArray($array,$a_array_sortby,$a_array_sortorder = 0,$a_numeric =
false)
3400 global $array_sortby,$array_sortorder;
3402 $array_sortby = $a_array_sortby;
3404 if ($a_array_sortorder ==
"desc")
3406 $array_sortorder =
"desc";
3410 $array_sortorder =
"asc";
3414 $sort_array = array_values($array);
3427 public static function mergesort(&$array, $cmp_function =
'strcmp') {
3429 if (count($array) < 2)
return;
3432 $halfway = count($array) / 2;
3433 $array1 = array_slice($array, 0, $halfway);
3434 $array2 = array_slice($array, $halfway);
3441 if (call_user_func($cmp_function, end($array1), $array2[0]) < 1) {
3442 $array = array_merge($array1, $array2);
3449 while ($ptr1 < count($array1) && $ptr2 < count($array2)) {
3450 if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1) {
3451 $array[] = $array1[$ptr1++];
3454 $array[] = $array2[$ptr2++];
3459 while ($ptr1 < count($array1)) $array[] = $array1[$ptr1++];
3460 while ($ptr2 < count($array2)) $array[] = $array2[$ptr2++];
3480 $existing_sub_key_values = array();
3482 foreach ($array as $key=>$sub_array)
3484 if (!in_array($sub_array[$sub_key], $existing_sub_key_values))
3486 $existing_sub_key_values[] = $sub_array[$sub_key];
3487 $target[$key] = $sub_array;
3506 $a_desired_type = strtolower($a_desired_type);
3508 $im_types = ImageTypes();
3510 switch($a_desired_type)
3514 if ($im_types & IMG_JPG)
return "jpg";
3515 if ($im_types & IMG_GIF)
return "gif";
3516 if ($im_types & IMG_PNG)
return "png";
3520 if ($im_types & IMG_GIF)
return "gif";
3521 if ($im_types & IMG_JPG)
return "jpg";
3522 if ($im_types & IMG_PNG)
return "png";
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);
3602 header(
"Location: ".$a_script);
3616 if (substr($a_value, 0, 4) ==
"il__")
3618 $a_value =
"il_".IL_INST_ID.
"_".substr($a_value, 4, strlen($a_value) - 4);
3638 if (empty($a_group_name))
3640 $message = __METHOD__.
": No groupname given!";
3641 $ilErr->raiseError($message,$ilErr->WARNING);
3644 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
3646 $q =
"SELECT obj_id FROM object_data ".
3647 "WHERE title = ".$ilDB->quote($a_group_name,
"text").
" ".
3648 "AND type = ".$ilDB->quote(
"grp",
"text").
3651 $r = $ilDB->query($q);
3671 $my_pid = getmypid();
3672 return (
"MEMORY USAGE (% KB PID ): ".`ps -eo%mem,rss,pid | grep $my_pid`);
3683 if (strtolower(substr(php_uname(), 0, 3)) ==
"win")
3693 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3695 return escapeshellarg($a_arg);
3709 if(ini_get(
'safe_mode') == 1)
3713 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3714 return escapeshellcmd($a_arg);
3733 $cmd =
'"'.$cmd.
'"';
3738 if (version_compare(phpversion(),
"5.2",
"<") && strpos($args,
'"') !==
false)
3740 $cmd =
'"'.$cmd.
" ".$args.
'"';
3782 public static function excelTime($year =
"", $month =
"", $day =
"", $hour =
"", $minute =
"", $second =
"")
3784 $starting_time = mktime(0, 0, 0, 1, 2, 1970);
3785 if (strcmp(
"$year$month$day$hour$minute$second",
"") == 0)
3787 $target_time = time();
3796 $target_time = mktime($hour, $minute, $second, $month, $day, $year);
3797 $difference = $target_time - $starting_time;
3798 $days = (($difference - ($difference % 86400)) / 86400);
3799 $difference = $difference - ($days * 86400) + 3600;
3802 return str_replace(
",",
".", ($days + 25570 + ($difference / 86400)));
3813 $def_arr = explode(
",", SUFFIX_REPL_DEFAULT);
3814 foreach ($def_arr as $def)
3819 $def_arr = explode(
",", SUFFIX_REPL_ADDITIONAL);
3820 foreach ($def_arr as $def)
3840 if ($a_dir ==
"/" || $a_dir ==
"" || is_int(strpos($a_dir,
".."))
3841 || trim($a_old_suffix) ==
"")
3847 if (!@is_dir($a_dir))
3853 $dir = opendir($a_dir);
3855 while(
$file = readdir($dir))
3857 if (
$file !=
"." and
3861 if (@is_dir($a_dir.
"/".
$file))
3867 if (@is_file($a_dir.
"/".
$file))
3870 if(strrpos(
$file,
'.') == (strlen(
$file) - 1))
3872 rename($a_dir.
'/'.
$file,substr($a_dir.
'/'.
$file,0,-1));
3876 $path_info = pathinfo($a_dir.
"/".
$file);
3878 if (strtolower($path_info[
"extension"]) ==
3879 strtolower($a_old_suffix))
3881 $pos = strrpos($a_dir.
"/".
$file,
".");
3882 $new_name = substr($a_dir.
"/".
$file, 0, $pos).
".".$a_new_suffix;
3883 rename($a_dir.
"/".
$file, $new_name);
3892 return strpos($_SERVER[
"SCRIPT_FILENAME"],
"api") !==
false ||
3893 strpos($_SERVER[
"SCRIPT_FILENAME"],
"dummy") !==
false;
3897 if (preg_match(
"/&" . $paramName .
"=/", $qstring)) {
3898 return preg_replace(
"/&" . $paramName .
"=[^&]+/",
"&" . $paramName .
"=" . urlencode($paramValue), $qstring);
3900 return $qstring .
"&" . $paramName .
"=" . urlencode($paramValue);
3906 foreach ($parametersArray as $paramName => $paramValue ) {
3921 srand((
double) microtime()*1000000);
3923 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
3926 for ($i=1; $i<=$a_number; $i++)
3928 $min = ($security->getPasswordMinLength() > 0)
3929 ? $security->getPasswordMinLength()
3931 $max = ($security->getPasswordMaxLength() > 0)
3932 ? $security->getPasswordMaxLength()
3938 $length = rand($min,$max);
3941 $vowels_uc = strtoupper($vowels);
3942 $consonants =
"bcdfghjklmnpqrstvwxyz";
3943 $consonants_uc = strtoupper($consonants);
3944 $numbers =
"1234567890";
3945 $special =
"_.+?#-*@!$%~";
3948 if($security->getPasswordNumberOfUppercaseChars() > 0)
3950 for($j = 0; $j < $security->getPasswordNumberOfUppercaseChars(); $j++)
3955 $pw.= $consonants_uc[rand(0, strlen($consonants_uc) - 1)];
3960 $pw.= $vowels_uc[rand(0, strlen($vowels_uc) - 1)];
3967 if($security->isPasswordCharsAndNumbersEnabled())
3969 $pw.= $numbers[rand(0, strlen($numbers) - 1)];
3972 if($security->isPasswordSpecialCharsEnabled())
3974 $pw.= $special[rand(0, strlen($special) - 1)];
3977 $num_lcase_chars = max($security->getPasswordNumberOfLowercaseChars(), $length - strlen($pw));
3978 for($j = 0; $j < $num_lcase_chars; $j++)
3983 $pw.= $consonants[rand(0, strlen($consonants) - 1)];
3988 $pw.= $vowels[rand(0, strlen($vowels) - 1)];
3994 $pw = str_shuffle($pw);
4003 $path = preg_replace(
"/[\/\\\]+$/",
"",
$path);
4024 foreach($data as $k=>$datum)
4026 if(is_null($datum)) $data[$k] =
'null';
4027 if(is_string($datum)) $data[$k] =
"'" . $datum .
"'";
4031 return "[" . implode(
', ', $data) .
"]";
4040 public static function virusHandling($a_file, $a_orig_name =
"", $a_clean =
true)
4044 if (IL_VIRUS_SCANNER !=
"None")
4046 require_once(
"./Services/VirusScanner/classes/class.ilVirusScannerFactory.php");
4048 if (($vs_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
4050 if ($a_clean && (IL_VIRUS_CLEAN_COMMAND !=
""))
4052 $clean_txt = $vs->cleanFile($a_file, $a_orig_name);
4053 if ($vs->fileCleaned())
4055 $vs_txt.=
"<br />".$lng->txt(
"cleaned_file").
4056 "<br />".$clean_txt;
4057 $vs_txt.=
"<br />".$lng->txt(
"repeat_scan");
4058 if (($vs2_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
4060 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_failed").
4061 "<br />".nl2br($vs2_txt));
4065 return array(
true, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_succeded"));
4070 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"cleaning_failed"));
4075 return array(
false, nl2br($vs_txt));
4080 return array(
true,
"");
4091 $a_mode =
"move_uploaded")
4093 global
$lng, $ilias;
4096 if (!is_file($a_file))
4098 if ($a_raise_errors)
4100 $ilias->raiseError($lng->txt(
"upload_error_file_not_found"), $ilias->error_obj->MESSAGE);
4114 if ($a_raise_errors)
4116 $ilias->raiseError($lng->txt(
"file_is_infected").
"<br />".
4118 $ilias->error_obj->MESSAGE);
4136 return rename($a_file, $a_target);
4140 return copy($a_file, $a_target);
4144 return move_uploaded_file($a_file, $a_target);
4158 list($datum, $uhrzeit) = explode (
" ",$mysql_date_time);
4159 list($jahr, $monat, $tag) = explode(
"-", $datum);
4160 list($std, $min, $sec) = explode(
":", $uhrzeit);
4161 return mktime ((
int) $std, (
int) $min, (
int) $sec, (
int) $monat, (
int) $tag, (
int) $jahr);
4172 return date(
"Y-m-d H:i:s");
4192 $resultarray = array();
4193 foreach (
$row as $rowindex => $entry)
4200 if (strpos($entry,
"\"") !== FALSE)
4202 $entry = str_replace(
"\"",
"\"\"", $entry);
4209 if ($compatibleWithMSExcel)
4212 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
4218 $resultarray[$rowindex] =
"\"" . $entry .
"\"";
4222 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
4229 $resultarray[$rowindex] = $entry;
4233 $resultarray[$rowindex] = utf8_decode($entry);
4237 return $resultarray;
4241 public static function isDN($a_str)
4243 return(preg_match(
"/^[a-z]+([a-z0-9-]*[a-z0-9]+)?(\.([a-z]+([a-z0-9-]*[a-z0-9]+)?)+)*$/",$a_str));
4249 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])\.".
4250 "(\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));
4284 global
$ilDB,$rbacreview,$ilAccess,
$ilUser,$ilias,$tree;
4286 if(!is_array($a_obj_type))
4288 $where =
"WHERE type = ".$ilDB->quote($a_obj_type,
"text").
" ";
4292 $where =
"WHERE ".$ilDB->in(
"type", $a_obj_type,
false,
"text").
" ";
4298 $limit = $ilias->getSetting(
'search_max_hits',100);
4306 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
4307 $a_roles = $rbacreview->assignedRoles($a_usr_id);
4311 if($rbacreview->isAssigned($a_usr_id,SYSTEM_ROLE_ID))
4313 $query =
"SELECT ref_id FROM object_reference obr LEFT JOIN object_data obd ON obr.obj_id = obd.obj_id ".
4314 "LEFT JOIN tree ON obr.ref_id = tree.child ".
4320 while(
$row = $ilDB->fetchObject(
$res))
4323 if($tree->isGrandChild(RECOVERY_FOLDER_ID,
$row->ref_id))
4328 if($counter++ >= $limit)
4333 $ref_ids[] =
$row->ref_id;
4335 return $ref_ids ? $ref_ids : array();
4339 if($a_operation ==
'edit_permissions' or strpos($a_operation,
'create') !==
false)
4341 $check_owner =
") ";
4345 $check_owner =
"OR owner = ".$ilDB->quote($a_usr_id,
"integer").
") ";
4349 $ops_id = $ops_ids[0];
4351 $and =
"AND ((".$ilDB->in(
"rol_id", $a_roles,
false,
"integer").
" ";
4353 $query =
"SELECT DISTINCT(obr.ref_id),obr.obj_id,type FROM object_reference obr ".
4354 "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
4355 "LEFT JOIN rbac_pa ON obr.ref_id = rbac_pa.ref_id ".
4358 "AND (".$ilDB->like(
"ops_id",
"text",
"%i:".$ops_id.
"%").
" ".
4359 "OR ".$ilDB->like(
"ops_id",
"text",
"%:\"".$ops_id.
"\";%").
")) ".
4366 if($counter >= $limit)
4372 if($tree->isGrandChild(RECOVERY_FOLDER_ID,
$row->ref_id))
4378 if($ilAccess->checkAccessOfUser($a_usr_id,$a_operation,
'',
$row->ref_id,
$row->type,
$row->obj_id))
4381 $ref_ids[] =
$row->ref_id;
4384 return $ref_ids ? $ref_ids : array();
4404 include_once
"./Services/Administration/classes/class.ilSetting.php";
4427 $cgi = URL_TO_LATEX;
4430 include_once
"./Services/Administration/classes/class.ilSetting.php";
4435 $a_text = preg_replace(
"/\\\\([RZN])([^a-zA-Z]|<\/span>)/",
"\\mathbb{".
"$1".
"}".
"$2", $a_text);
4441 $o_start = $a_start;
4443 $a_start = str_replace(
"\\",
"", $a_start);
4444 $a_end = str_replace(
"\\",
"", $a_end);
4446 while (is_int($spos = stripos($a_text, $a_start, $cpos)))
4448 if (is_int ($epos = stripos($a_text, $a_end, $spos + 1)))
4450 $tex = substr($a_text, $spos + strlen($a_start), $epos - $spos - strlen($a_start));
4453 if (!is_int(strpos($tex,
"</div>")))
4457 $a_text = substr($a_text, 0, $spos).
4458 "<img alt=\"".htmlentities($tex).
"\" src=\"".$cgi.
"?".
4459 rawurlencode(str_replace(
'&',
'&', str_replace(
'>',
'>', str_replace(
'<',
'<', $tex)))).
"\" ".
4461 substr($a_text, $epos + strlen($a_end));
4465 $tex = $a_start.$tex.$a_end;
4470 $mj_start =
"[tex]";
4475 $mj_start =
'<span class="math">';
4476 $mj_end =
'</span>';
4486 preg_replace(
'/' . $o_start .
'(.*?)' . $o_end .
'/ie',
4487 "'".$mj_start.
"' . preg_replace('/[\\\\\\\\\\]{2}/', '\\cr', str_replace('<', '<', str_replace('<br/>', '', str_replace('<br />', '', str_replace('<br>', '', '$1'))))) . '".$mj_end.
"'", $tex);
4489 $a_text = substr($a_text, 0, $spos).
4491 substr($a_text, $epos + strlen($a_end));
4498 $result_text = $a_text;
4500 return $result_text;
4514 $result_text = $a_text;
4519 $cgi = URL_TO_LATEX;
4523 while (preg_match(
'/' . $start .
'(.*?)' . $end .
'/ie', $result_text, $found))
4525 $cnt = (int)
$GLOBALS[
"teximgcnt"]++;
4527 $fpr = @fopen($cgi.
"?".rawurlencode($found[1]),
"r");
4533 $buf = fread($fpr, 1024);
4536 if (is_int(strpos(strtoupper(substr($buf, 0, 5)),
"GIF")))
4544 $fpw = fopen($a_dir.
"/teximg/img".$cnt.
".".$suffix,
"w");
4554 $img_str =
"./teximg/img".$cnt.
".".$suffix;
4555 $result_text = str_replace($found[0],
4556 '<img alt="'.$found[1].
'" src="'.$img_str.
'" />', $result_text);
4560 return $result_text;
4571 public static function prepareTextareaOutput($txt_output, $prepare_for_latex_output = FALSE, $omitNl2BrWhenTextArea =
false)
4576 if ($prepare_for_latex_output)
4585 if(!$omitNl2BrWhenTextArea)
4594 if (preg_match_all(
"/(<pre>.*?<\/pre>)/ims",
$result, $matches))
4596 foreach ($matches[0] as $found)
4599 if (strpos(
"\n", $found) === FALSE)
4601 $replacement =
"\n";
4603 $removed = preg_replace(
"/<br\s*?\/>/ims", $replacement, $found);
4608 if ($prepare_for_latex_output)
4630 if( preg_match(
"/<[^>]*?>/", $a_text) )
4646 public static function int2array ($seconds, $periods = null)
4649 if (!is_array($periods))
4652 'years' => 31536000,
4653 'months' => 2592000,
4662 $seconds = (float) $seconds;
4663 foreach ($periods as $period => $value)
4665 $count = floor($seconds / $value);
4672 $values[$period] = $count;
4673 $seconds = $seconds % $value;
4696 if (!is_array($duration))
4701 foreach ($duration as $key => $value) {
4706 $segment_name = $key;
4707 $segment_name = $lng->txt($segment_name);
4708 $segment = $value .
' ' . $segment_name;
4712 $segment_name = substr($key, 0, -1);
4713 $segment_name = $lng->txt($segment_name);
4714 $segment = $value .
' ' . $segment_name;
4717 $array[] = $segment;
4719 $len = count($array);
4723 $array=array_slice($array,0,(3-$len));
4726 $str = implode(
', ', $array);
4736 $umf=get_cfg_var(
"upload_max_filesize");
4738 $pms=get_cfg_var(
"post_max_size");
4741 $max_filesize=min($umf, $pms);
4742 if (!$max_filesize) $max_filesize=max($umf, $pms);
4744 return $lng->txt(
"file_notice").
" $max_filesize.";
4758 $test_str = explode(
'_',$role_title);
4760 if ($test_str[0] ==
'il')
4762 $test2 = (int) $test_str[3];
4763 return is_numeric ($test2) ? (int) $test2 :
false;
4781 $test_str = explode(
'_',$ilias_id);
4783 if ($test_str[0] ==
'il' && $test_str[1] == $inst_id && count($test_str) == 4)
4785 $test2 = (int) $test_str[3];
4786 return is_numeric ($test2) ? (int) $test2 :
false;
4805 public static function _sortIds($a_ids,$a_table,$a_field,$a_id_name)
4815 $where =
"WHERE ".$a_id_name.
" IN (";
4819 $query =
"SELECT ".$a_id_name.
" FROM ".$a_table.
" ".
4821 "ORDER BY ".$a_field;
4826 $ids[] =
$row->$a_id_name;
4828 return $ids ? $ids : array();
4858 if(!is_array($a_array) or !count($a_array))
4863 foreach($a_array as $k => $item)
4865 $a_array[$k] = $ilDB->quote($item);
4879 public static function sendInfo($a_info =
"",$a_keep =
false)
4882 $tpl->setMessage(
"info", $a_info, $a_keep);
4896 $tpl->setMessage(
"failure", $a_info, $a_keep);
4908 $tpl->setMessage(
"question", $a_info, $a_keep);
4922 $tpl->setMessage(
"success", $a_info, $a_keep);
4931 $tpl->addBlockFile(
"INFOPANEL",
"infopanel",
"tpl.infopanel.html",
4932 "Services/Utilities");
4933 $tpl->setCurrentBlock(
"infopanel");
4935 if (!empty(
$_SESSION[
"infopanel"][
"text"]))
4937 $link =
"<a href=\"".$dir.$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4940 $link .= $lng->txt(
$_SESSION[
"infopanel"][
"text"]);
4945 if (!empty(
$_SESSION[
"infopanel"][
"img"]))
4947 $link .=
"<td><a href=\"".$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4950 $link .=
"<img src=\"".$ilias->tplPath.$ilias->account->prefs[
"skin"].
"/images/".
4951 $_SESSION[
"infopanel"][
"img"].
"\" border=\"0\" vspace=\"0\"/>";
4952 $link .=
"</a></td>";
4955 $tpl->setVariable(
"INFO_ICONS",$link);
4956 $tpl->parseCurrentBlock();
4977 if (!is_dir($directory))
4981 $size = @filesize($directory);
4985 if ($DIR = opendir($directory))
4987 while (($dirfile = readdir($DIR)) !==
false)
4989 if (is_link($directory . DIRECTORY_SEPARATOR . $dirfile) || $dirfile ==
'.' || $dirfile ==
'..')
4991 if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile))
4992 $size += filesize($directory . DIRECTORY_SEPARATOR . $dirfile);
4993 else if (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile))
4996 $dirSize =
ilUtil::dirsize($directory . DIRECTORY_SEPARATOR . $dirfile);
5010 return md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
5013 public static function setCookie($a_cookie_name,$a_cookie_value =
'', $a_also_set_super_global =
true, $a_set_cookie_invalid =
false)
5020 if(!(
bool)$a_set_cookie_invalid) $expire = 0;
5021 else $expire = time() - (365*24*60*60);
5025 if( version_compare(PHP_VERSION,
'5.2.0',
'>=') )
5028 setcookie( $a_cookie_name, $a_cookie_value, $expire,
5029 IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE, IL_COOKIE_HTTPONLY
5035 setcookie( $a_cookie_name, $a_cookie_value, $expire,
5040 if((
bool)$a_also_set_super_global)
$_COOKIE[$a_cookie_name] = $a_cookie_value;
5045 return strip_tags(self::stripSlashes($a_filename));
5052 if($_SERVER[
'SHELL'] || php_sapi_name() ==
'cli' ||
5056 return $ilIliasIniFile->readVariable(
'server',
'http_path');
5060 return ILIAS_HTTP_PATH;
5071 $bt = debug_backtrace();
5075 if ($cnt != 0 && ($a_limit == 0 || $cnt <= $a_limit))
5077 echo
"<br>".$t[
"file"].
", ".$t[
"function"].
" [".$t[
"line"].
"]";
5100 $exploded = explode(
'_',$a_import_id);
5102 $parsed[
'orig'] = $a_import_id;
5103 if($exploded[0] ==
'il')
5105 $parsed[
'prefix'] = $exploded[0];
5107 if(is_numeric($exploded[1]))
5109 $parsed[
'inst_id'] = (int) $exploded[1];
5111 $parsed[
'type'] = $exploded[2];
5113 if(is_numeric($exploded[3]))
5115 $parsed[
'id'] = (int) $exploded[3];
5129 '/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff^|]*)\|/',
5132 PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
5137 for($i = 0; $vars[$i]; $i++)
5139 $result[$vars[$i++]] = unserialize($vars[$i]);
5158 $fp = @fopen(
$file,
'rb');
5176 header(
"Accept-Ranges: 0-$length");
5180 if (isset($_SERVER[
'HTTP_RANGE'])) {
5185 list(, $range) = explode(
'=', $_SERVER[
'HTTP_RANGE'], 2);
5187 if (strpos($range,
',') !==
false) {
5192 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
5193 header(
"Content-Range: bytes $start-$end/$size");
5200 if ($range ==
'-') {
5203 $c_start =
$size - substr($range, 1);
5207 $range = explode(
'-', $range);
5208 $c_start = $range[0];
5209 $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] :
$size;
5215 $c_end = ($c_end > $end) ? $end : $c_end;
5217 if ($c_start > $c_end || $c_start >
$size - 1 || $c_end >=
$size) {
5219 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
5220 header(
"Content-Range: bytes $start-$end/$size");
5226 $length = $end - $start + 1;
5228 header(
'HTTP/1.1 206 Partial Content');
5231 header(
"Content-Range: bytes $start-$end/$size");
5232 header(
"Content-Length: $length");
5236 while(!feof($fp) && ($p = ftell($fp)) <= $end) {
5238 if ($p + $buffer > $end) {
5242 $buffer = $end - $p + 1;
5245 echo fread($fp, $buffer);