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');
1369 $infos = array(sprintf($lng->txt(
'password_allow_chars'), self::getPasswordValidChars(
false)));
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)
1749 if (!is_file($a_file))
1759 copy($a_file, $tmpdir.DIRECTORY_SEPARATOR.basename($a_file));
1760 $orig_file = $a_file;
1761 $a_file = $tmpdir.DIRECTORY_SEPARATOR.basename($a_file);
1762 $origpathinfo = pathinfo($orig_file);
1765 $pathinfo = pathinfo($a_file);
1766 $dir = $pathinfo[
"dirname"];
1767 $file = $pathinfo[
"basename"];
1772 $unzip = PATH_TO_UNZIP;
1818 $unzipcmd =
"-o ".ilUtil::escapeShellArg(
$file);
1826 $dir_realpath = realpath($dir);
1827 foreach (
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir)) as $name => $f)
1831 $target = readlink($name);
1832 if (substr($target, 0, strlen($dir_realpath)) != $dir_realpath)
1835 $ilLog->write(
"Remove symlink ".$name);
1843 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
1844 $filearray = array();
1846 if (is_array($filearray[
"file"]))
1848 foreach ($filearray[
"file"] as $k => $f)
1850 if (substr($f, 0, 1) !=
"." && $f != basename($orig_file))
1852 copy($filearray[
"path"][$k].$f, $origpathinfo[
"dirname"].DIRECTORY_SEPARATOR.$f);
1866 public static function zip($a_dir, $a_file, $compress_content =
false)
1870 if($compress_content)
1873 $pathinfo = pathinfo($a_dir);
1874 chdir($pathinfo[
"dirname"]);
1877 $pathinfo = pathinfo($a_file);
1878 $dir = $pathinfo[
"dirname"];
1879 $file = $pathinfo[
"basename"];
1881 if(!$compress_content)
1894 if (is_array($a_dir))
1897 foreach($a_dir as $dir)
1899 $name = basename($dir);
1900 $source.=
" ".ilUtil::escapeShellArg($name);
1905 $name = basename($a_dir);
1906 if (trim($name) !=
"*")
1916 $zipcmd =
"-r ".ilUtil::escapeShellArg($a_file).
" ".$source;
1926 $pathinfo = pathinfo($a_dir);
1927 chdir($pathinfo[
"dirname"]);
1929 $pathinfo = pathinfo($a_file);
1930 $dir = $pathinfo[
"dirname"];
1931 $file = $pathinfo[
"basename"]; $zipcmd =
"-r ".ilUtil::escapeShellArg($a_file).
" ".$source;
1933 $mkisofs = PATH_TO_MKISOFS;
1940 $name = basename($a_dir);
1943 $zipcmd =
"-r -J -o ".$a_file.
" ".$source;
1959 return PATH_TO_CONVERT;
1983 $current_version = self::processConvertVersion($current_version[0]);
1984 $version = self::processConvertVersion($a_version);
1985 if($current_version >= $version)
2000 if(preg_match(
"/([0-9]+)\.([0-9]+)\.([0-9]+)([\.|\-]([0-9]+))?/", $a_version, $match))
2002 $version = str_pad($match[1], 2, 0, STR_PAD_LEFT).
2003 str_pad($match[2], 2, 0, STR_PAD_LEFT).
2004 str_pad($match[3], 2, 0, STR_PAD_LEFT).
2005 str_pad($match[5], 2, 0, STR_PAD_LEFT);
2006 return (
int)$version;
2019 public static function convertImage($a_from, $a_to, $a_target_format =
"", $a_geometry =
"",
2020 $a_background_color =
"")
2022 $format_str = ($a_target_format !=
"")
2023 ? strtoupper($a_target_format).
":" 2026 if ($a_geometry !=
"")
2028 if (is_int(strpos($a_geometry,
"x")))
2030 $geometry =
" -geometry ".$a_geometry.
" ";
2034 $geometry =
" -geometry ".$a_geometry.
"x".$a_geometry.
" ";
2038 $bg_color = ($a_background_color !=
"")
2039 ?
" -background color ".$a_background_color.
" " 2041 $convert_cmd =
ilUtil::escapeShellArg($a_from).
" ".$bg_color.$geometry.ilUtil::escapeShellArg($format_str.$a_to);
2056 public static function resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop =
false)
2058 if ($a_constrain_prop)
2060 $size =
" -geometry ".$a_width.
"x".$a_height.
" ";
2064 $size =
" -resize ".$a_width.
"x".$a_height.
"! ";
2077 public static function img($a_src, $a_alt =
"", $a_width =
"", $a_height =
"", $a_border = 0, $a_id =
"", $a_class =
"")
2079 $img =
'<img src="'.$a_src.
'"';
2082 $img.=
' alt="'.htmlspecialchars($a_alt).
'" title="'.htmlspecialchars($a_alt).
'"';
2086 $img.=
' width="'.htmlspecialchars($a_width).
'"';
2088 if ($a_height !=
"")
2090 $img.=
' height="'.htmlspecialchars($a_height).
'"';
2094 $img.=
' class="'.$a_class.
'"';
2098 $img.=
' id="'.$a_id.
'"';
2100 $img.=
' border="'.(int) $a_border.
'"/>';
2114 $html_file = str_replace(
".pdf",
".html",$pdf_file);
2116 $fp = fopen( $html_file ,
"wb");
2131 $htmldoc_path = PATH_TO_HTMLDOC;
2133 $htmldoc =
"--no-toc ";
2134 $htmldoc .=
"--no-jpeg ";
2135 $htmldoc .=
"--webpage ";
2137 $htmldoc .=
"--bodyfont Arial ";
2138 $htmldoc .=
"--charset iso-8859-15 ";
2139 $htmldoc .=
"--color ";
2140 $htmldoc .=
"--size A4 ";
2141 $htmldoc .=
"--format pdf ";
2142 $htmldoc .=
"--footer ... ";
2143 $htmldoc .=
"--header ... ";
2144 $htmldoc .=
"--left 60 ";
2146 $htmldoc .= $html_file;
2157 public static function deliverData($a_data, $a_filename, $mime =
"application/octet-stream", $charset =
"")
2159 $disposition =
"attachment";
2162 include_once
'./Services/Http/classes/class.ilHTTPS.php';
2172 #header("Pragma: "); 2173 #header("Cache-Control: "); 2174 #header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 2175 #header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 2176 #header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 2177 #header("Cache-Control: post-check=0, pre-check=0", false); 2179 else if ($disposition ==
"attachment")
2181 header(
"Cache-control: private");
2185 header(
"Cache-Control: no-cache, must-revalidate");
2186 header(
"Pragma: no-cache");
2191 if (strlen($charset))
2193 $charset =
"; charset=$charset";
2195 header(
"Content-Type: $mime$charset");
2196 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
2197 header(
"Content-Description: ".$ascii_filename);
2198 header(
"Content-Length: ".(
string)(strlen($a_data)));
2203 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
2204 header(
'Pragma: public');
2207 header(
"Connection: close");
2220 public static function deliverFile($a_file, $a_filename,$a_mime =
'', $isInline =
false, $removeAfterDelivery =
false,
2221 $a_exit_after =
true)
2224 if(!file_exists($a_file))
2230 $disposition =
"inline";
2232 $disposition =
"attachment";
2243 $mime =
"application/octet-stream";
2247 if ($disposition ==
"attachment")
2249 header(
"Cache-control: private");
2253 header(
"Cache-Control: no-cache, must-revalidate");
2254 header(
"Pragma: no-cache");
2259 header(
"Content-Type: $mime");
2260 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
2261 header(
"Content-Description: ".$ascii_filename);
2264 $filesize = @filesize($a_file);
2267 header(
"Content-Length: ".(
string)$filesize);
2270 include_once
'./Services/Http/classes/class.ilHTTPS.php';
2271 #if($_SERVER['HTTPS']) 2274 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
2275 header(
'Pragma: public');
2278 header(
"Connection: close");
2280 if ($removeAfterDelivery)
2302 $chunksize = 1*(1024*1024);
2304 $handle = fopen($a_file,
'rb');
2305 if ($handle ===
false)
2309 while (!feof($handle))
2311 $buffer = fread($handle, $chunksize);
2314 return fclose($handle);
2344 $ascii_filename = htmlentities($a_filename, ENT_NOQUOTES,
'UTF-8');
2345 $ascii_filename = preg_replace(
'/\&(.)[^;]*;/',
'\\1', $ascii_filename);
2346 $ascii_filename = preg_replace(
'/[\x7f-\xff]/',
'_', $ascii_filename);
2349 $ascii_filename = preg_replace(
'/[:\x5c\/\*\?\"<>\|]/',
'_', $ascii_filename);
2350 return $ascii_filename;
2362 $sep =
'###HTMLTAG###';
2364 preg_match_all(
"@<[^>]*>@", $htmlText, $matches);
2365 $tmp = preg_replace(
"@(<[^>]*>)@", $sep, $htmlText);
2366 $tmp = explode($sep, $tmp);
2368 for ($i=0; $i<count($tmp); $i++)
2369 $tmp[$i] = htmlentities($tmp[$i], ENT_COMPAT,
"UTF-8");
2371 $tmp = join($sep, $tmp);
2373 for ($i=0; $i<count($matches[0]); $i++)
2374 $tmp = preg_replace(
"@$sep@", $matches[0][$i], $tmp, 1);
2387 return PATH_TO_JAVA;
2406 $url = (is_int(strpos($a_url,
"?")))
2407 ? $a_url.$amp.$a_par
2408 : $a_url.
"?".$a_par;
2430 $a_dir = trim($a_dir);
2433 if (substr($a_dir,-1) ==
"/")
2435 $a_dir = substr($a_dir,0,-1);
2439 if (!(
$path = substr($a_dir,0, strrpos($a_dir,
"/") - strlen($a_dir))))
2446 return @mkdir($a_dir,fileperms(
$path));
2466 $dirs = array($a_dir);
2467 $a_dir = dirname($a_dir);
2470 while($last_dirname != $a_dir)
2472 array_unshift(
$dirs, $a_dir);
2473 $last_dirname = $a_dir;
2474 $a_dir = dirname($a_dir);
2478 $reverse_paths = array_reverse(
$dirs, TRUE);
2480 foreach ($reverse_paths as $key => $value)
2482 if ($found_index == -1)
2486 $found_index = $key;
2492 foreach (
$dirs as $dirindex => $dir)
2495 if ($dirindex >= $found_index)
2497 if (! file_exists($dir))
2499 if (strcmp(substr($dir,strlen($dir)-1,1),
"/") == 0)
2503 $dir = substr($dir,0,strlen($dir)-1);
2505 if (! mkdir($dir, $umask))
2507 error_log(
"Can't make directory: $dir");
2511 elseif (! is_dir($dir))
2513 error_log(
"$dir is not a directory");
2519 $umask = fileperms($dir);
2535 public static function delDir($a_dir, $a_clean_only =
false)
2537 if (!is_dir($a_dir) || is_int(strpos($a_dir,
"..")))
2542 $current_dir = opendir($a_dir);
2551 while($entryname = readdir($current_dir))
2553 $files[] = $entryname;
2556 foreach($files as
$file)
2558 if(is_dir($a_dir.
"/".$file) and ($file !=
"." and $file!=
".."))
2562 elseif ($file !=
"." and $file !=
"..")
2564 unlink(${a_dir}.
"/".${file});
2568 closedir($current_dir);
2582 public static function getDir($a_dir, $a_rec =
false, $a_sub_dir =
"")
2584 $current_dir = opendir($a_dir.$a_sub_dir);
2588 $subitems = array();
2589 while($entry = readdir($current_dir))
2591 if(is_dir($a_dir.
"/".$entry))
2593 $dirs[$entry] = array(
"type" =>
"dir",
"entry" => $entry,
2594 "subdir" => $a_sub_dir);
2595 if ($a_rec && $entry !=
"." && $entry !=
"..")
2598 $subitems = array_merge($subitems,
$si);
2603 if ($entry !=
"." && $entry !=
"..")
2605 $size = filesize($a_dir.$a_sub_dir.
"/".$entry);
2606 $files[$entry] = array(
"type" =>
"file",
"entry" => $entry,
2607 "size" =>
$size,
"subdir" => $a_sub_dir);
2614 return array_merge(
$dirs, $files, $subitems);
2625 if (is_array($a_arr))
2627 foreach ($a_arr as $k => $v)
2644 if (is_array($a_data))
2646 foreach ($a_data as $k => $v)
2673 public static function stripSlashes($a_str, $a_strip_html =
true, $a_allow =
"")
2675 if (ini_get(
"magic_quotes_gpc"))
2677 $a_str = stripslashes($a_str);
2693 if (ini_get(
"magic_quotes_gpc"))
2695 $a_str = stripslashes($a_str);
2707 public static function secureString($a_str, $a_strip_html =
true, $a_allow =
"")
2710 $only_secure =
true;
2711 $allow_tags = explode(
">", $a_allow);
2713 $allow_array = array();
2714 foreach($allow_tags as $allow)
2718 $allow = str_replace(
"<",
"", $allow);
2720 if (!in_array($allow, $sec_tags))
2722 $only_secure =
false;
2724 $allow_array[] = $allow;
2729 if (($only_secure || $a_allow ==
"") && $a_strip_html)
2733 $allow_array = array (
"b",
"i",
"strong",
"em",
"code",
"cite",
2734 "gap",
"sub",
"sup",
"pre",
"strike");
2740 $a_str = strip_tags($a_str);
2765 return array(
"strong",
"em",
"u",
"strike",
"ol",
"li",
"ul",
"p",
"div",
2766 "i",
"b",
"code",
"sup",
"sub",
"pre",
"gap",
"a",
"img");
2771 foreach ($allow_array as
$t)
2786 array(
"param" =>
"align",
"value" =>
"left"),
2787 array(
"param" =>
"align",
"value" =>
"center"),
2788 array(
"param" =>
"align",
"value" =>
"justify"),
2789 array(
"param" =>
"align",
"value" =>
"right")
2804 foreach ($allow_array as
$t)
2819 array(
"param" =>
"align",
"value" =>
"left"),
2820 array(
"param" =>
"align",
"value" =>
"center"),
2821 array(
"param" =>
"align",
"value" =>
"justify"),
2822 array(
"param" =>
"align",
"value" =>
"right")
2844 if (ini_get(
"magic_quotes_gpc"))
2846 return stripslashes($a_str);
2873 if ($a_make_links_clickable)
2891 $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);
2894 foreach ($matches as $match)
2897 foreach ($matches[0] as $match)
2899 $matched_text = $match[0];
2901 if ($matched_offset != previous_offset)
2904 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1, $pos2 - $pos1)));
2910 $pos1 = $pos2 + strlen($matched_text);
2912 if ($pos1 < strlen($a_str))
2914 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1)));
2919 $encoded = nl2br(htmlspecialchars($a_str));
2929 $ws =
"[ \t\r\f\v\n]*";
2930 $att = $ws.
"[^>]*".$ws;
2932 while (eregi(
"<($tag$att($tag_att$ws=$ws\"(([\$@!*()~;,_0-9A-z/:=%\\.&#?+\\-])*)\")$att)>",
2935 $un = array(
".",
"-",
"+",
"?",
'$',
"*",
"(",
")");
2941 $ff = str_replace($un, $esc, $found[1]);
2944 $a_str = eregi_replace(
"<".$ff.
">",
2945 "<$tag $tag_att$tag_att=\"".$found[3].
"\">", $a_str);
2946 if ($old_str == $a_str)
2948 $ilLog->write(
"ilUtil::maskA-".htmlentities($old_str).
" == ".
2949 htmlentities($a_str));
2953 $a_str = str_ireplace(
"</$tag>",
2954 "</$tag>", $a_str);
2962 while (eregi(
"<($tag $tag_att$tag_att=\"(([\$@!*()~;,_0-9A-z/:=%\\.&#?+\\-])*)\")>",
2965 $un = array(
".",
"-",
"+",
"?",
'$',
"*",
"(",
")");
2971 $ff = str_replace($un, $esc, $found[1]);
2974 $a_str = eregi_replace(
"<".$ff.
">",
2975 "<$tag $tag_att=\"".ilUtil::secureLink($found[2]).
"\">", $a_str);
2976 if ($old_str == $a_str)
2978 $ilLog->write(
"ilUtil::unmaskA-".htmlentities($old_str).
" == ".
2979 htmlentities($a_str));
2983 $a_str = str_replace(
"</$tag>",
"</$tag>", $a_str);
2989 $a_str = str_replace(array(
"<$t>",
"<".strtoupper(
$t).
">"),
2990 "<".
$t.
">", $a_str);
2991 $a_str = str_replace(array(
"</$t>",
"</".strtoupper(
$t).
">"),
2992 "</".
$t.
">", $a_str);
2994 if (is_array($fix_param))
2996 foreach ($fix_param as $p)
3000 $a_str = str_replace(
"<$t $k=\"$v\">",
3001 "<".
"$t $k=\"$v\"".
">", $a_str);
3010 $a_str = str_replace(
"<".
$t.
">",
"<".$t.
">", $a_str);
3011 $a_str = str_replace(
"</".
$t.
">",
"</".$t.
">", $a_str);
3013 if (is_array($fix_param))
3015 foreach ($fix_param as $p)
3019 $a_str = str_replace(
"<$t $k=\"$v\">",
3020 "<".
"$t $k=\"$v\"".
">", $a_str);
3028 $a_str = str_ireplace(
"javascript",
"jvscrpt", $a_str);
3029 $a_str = str_ireplace(array(
"%00",
"%0a",
"%0d",
"%1a",
"�",
"�",
3030 "�",
"�",
"
",
"
",
" ",
" "),
"-", $a_str);
3051 $negativestr =
"a,abbr,acronym,address,applet,area,b,base,basefont,".
3052 "bdo,big,blockquote,body,br,button,caption,center,cite,code,col,".
3053 "colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame,".
3054 "frameset,h1,h2,h3,h4,h5,h6,head,hr,html,i,iframe,img,input,ins,isindex,kbd,".
3055 "label,legend,li,link,map,menu,meta,noframes,noscript,object,ol,".
3056 "optgroup,option,p,param,q,s,samp,script,select,small,span,".
3057 "strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,".
3058 "title,tr,tt,u,ul,var";
3059 $a_allow = strtolower ($a_allow);
3060 $negatives = explode(
",",$negativestr);
3061 $outer_old_str =
"";
3062 while($outer_old_str != $a_str)
3064 $outer_old_str = $a_str;
3065 foreach ($negatives as $item)
3067 $pos = strpos($a_allow,
"<$item>");
3073 while($old_str != $a_str)
3076 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s*>/i",
"", $a_str);
3077 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s+([^>]*)>/i",
"", $a_str);
3086 $a_str = preg_replace(
"/<\s*\w*(\/?)(\s+[^>]*)?(\s+on[^>]*)>/i",
"", $a_str);
3089 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*javascript[^>]*>/i",
"", $a_str);
3093 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*expression[^>]*>/i",
"", $a_str);
3116 $a_str = htmlspecialchars($a_str);
3120 $a_str = str_replace(
"{",
"{", $a_str);
3121 $a_str = str_replace(
"}",
"}", $a_str);
3137 if (filter_var($url, FILTER_VALIDATE_URL) ===
false &&
3138 filter_var(
"http://".$url, FILTER_VALIDATE_URL) ===
false &&
3139 filter_var(
"http:".$url, FILTER_VALIDATE_URL) ===
false &&
3140 filter_var(
"http://de.de".$url, FILTER_VALIDATE_URL) ===
false &&
3141 filter_var(
"http://de.de/".$url, FILTER_VALIDATE_URL) ===
false)
3145 if (trim(strtolower(parse_url($url, PHP_URL_SCHEME))) ==
"javascript")
3149 $url = htmlspecialchars($url, ENT_QUOTES);
3166 return addslashes($a_str);
3198 while(($spos=strpos($a_parstr,
"=")) &&
$ok)
3201 $cpar = substr($a_parstr,0,$spos);
3202 $a_parstr = substr($a_parstr,$spos,strlen($a_parstr)-$spos);
3203 while(substr($cpar,0,1)==
"," ||substr($cpar,0,1)==
" " || substr($cpar,0,1)==chr(13) || substr($cpar,0,1)==chr(10))
3204 $cpar = substr($cpar,1,strlen($cpar)-1);
3205 while(substr($cpar,strlen($cpar)-1,1)==
" " || substr($cpar,strlen($cpar)-1,1)==chr(13) || substr($cpar,strlen($cpar)-1,1)==chr(10))
3206 $cpar = substr($cpar,0,strlen($cpar)-1);
3210 while($cpar != $cpar_old)
3213 $cpar = eregi_replace(
"[^a-zA-Z0-9_]",
"", $cpar);
3219 if($spos=strpos($a_parstr,
"\""))
3221 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos);
3222 $spos=strpos($a_parstr,
"\"");
3225 $cval = substr($a_parstr,0,$spos);
3227 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos-1);
3237 if(
$ok)
return $par;
else return false;
3242 if (is_array($a_par_arr))
3245 foreach ($a_par_arr as $par => $val)
3264 for($i=0; $i<strlen($a_str); $i++)
3266 $ret.= ord(substr($a_str,$i,1)).
" ";
3280 if(strtolower($a_yn) ==
"y")
3320 global $array_sortby,$array_sortorder;
3322 if(!isset($array_sortby))
3330 if ($array_sortorder ==
"asc")
3335 if ($array_sortorder ==
"desc")
3337 return !
ilStr::strCmp($a[$array_sortby], $b[$array_sortby]);
3354 global $array_sortby,$array_sortorder;
3356 if ($array_sortorder ==
"asc")
3358 return $a[
"$array_sortby"] > $b[
"$array_sortby"];
3361 if ($array_sortorder ==
"desc")
3363 return $a[
"$array_sortby"] < $b[
"$array_sortby"];
3378 public static function sortArray($array,$a_array_sortby,$a_array_sortorder = 0,$a_numeric =
false,
3379 $a_keep_keys =
false)
3381 include_once(
"./Services/Utilities/classes/class.ilStr.php");
3384 if (! $a_keep_keys) {
3385 return self::stableSortArray($array,$a_array_sortby,$a_array_sortorder,$a_numeric,$a_keep_keys);
3389 global $array_sortby,$array_sortorder;
3391 $array_sortby = $a_array_sortby;
3393 if ($a_array_sortorder ==
"desc")
3395 $array_sortorder =
"desc";
3399 $array_sortorder =
"asc";
3405 uasort($array, array(
"ilUtil",
"sort_func_numeric"));
3409 usort($array, array(
"ilUtil",
"sort_func_numeric"));
3416 uasort($array, array(
"ilUtil",
"sort_func"));
3420 usort($array, array(
"ilUtil",
"sort_func"));
3442 public static function stableSortArray($array,$a_array_sortby,$a_array_sortorder = 0,$a_numeric =
false)
3444 global $array_sortby,$array_sortorder;
3446 $array_sortby = $a_array_sortby;
3448 if ($a_array_sortorder ==
"desc")
3450 $array_sortorder =
"desc";
3454 $array_sortorder =
"asc";
3458 $sort_array = array_values($array);
3471 public static function mergesort(&$array, $cmp_function =
'strcmp') {
3473 if (count($array) < 2)
return;
3476 $halfway = count($array) / 2;
3477 $array1 = array_slice($array, 0, $halfway);
3478 $array2 = array_slice($array, $halfway);
3485 if (call_user_func($cmp_function, end($array1), $array2[0]) < 1) {
3486 $array = array_merge($array1, $array2);
3493 while ($ptr1 < count($array1) && $ptr2 < count($array2)) {
3494 if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1) {
3495 $array[] = $array1[$ptr1++];
3498 $array[] = $array2[$ptr2++];
3503 while ($ptr1 < count($array1)) $array[] = $array1[$ptr1++];
3504 while ($ptr2 < count($array2)) $array[] = $array2[$ptr2++];
3524 $existing_sub_key_values = array();
3526 foreach ($array as $key=>$sub_array)
3528 if (!in_array($sub_array[$sub_key], $existing_sub_key_values))
3530 $existing_sub_key_values[] = $sub_array[$sub_key];
3531 $target[$key] = $sub_array;
3550 $a_desired_type = strtolower($a_desired_type);
3552 $im_types = ImageTypes();
3554 switch($a_desired_type)
3558 if ($im_types & IMG_JPG)
return "jpg";
3559 if ($im_types & IMG_GIF)
return "gif";
3560 if ($im_types & IMG_PNG)
return "png";
3564 if ($im_types & IMG_GIF)
return "gif";
3565 if ($im_types & IMG_JPG)
return "jpg";
3566 if ($im_types & IMG_PNG)
return "png";
3570 if ($im_types & IMG_PNG)
return "png";
3571 if ($im_types & IMG_JPG)
return "jpg";
3572 if ($im_types & IMG_GIF)
return "gif";
3590 if (($a_mime ==
"image/gif") || ($a_mime ==
"image/jpeg") ||
3591 ($a_mime ==
"image/png") || ($a_mime ==
"application/x-shockwave-flash") ||
3592 ($a_mime ==
"image/tiff") || ($a_mime ==
"image/x-ms-bmp") ||
3593 ($a_mime ==
"image/psd") || ($a_mime ==
"image/iff"))
3613 global
$log, $PHP_SELF;
3616 if (!is_int(strpos($a_script,
"://")))
3618 if (substr($a_script, 0, 1) !=
"/" && defined(
"ILIAS_HTTP_PATH"))
3620 if (is_int(strpos($_SERVER[
"PHP_SELF"],
"/setup/")))
3622 $a_script =
"setup/".$a_script;
3624 $a_script = ILIAS_HTTP_PATH.
"/".$a_script;
3630 global $ilPluginAdmin;
3631 if (is_object($ilPluginAdmin))
3633 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_SERVICE,
"UIComponent",
"uihk");
3634 foreach ($pl_names as $pl)
3637 $gui_class = $ui_plugin->getUIClassInstance();
3638 $resp = $gui_class->getHTML(
"Services/Utilities",
"redirect", array(
"html" => $a_script));
3641 $a_script = $gui_class->modifyHTML($a_script, $resp);
3646 header(
"Location: ".$a_script);
3660 if (substr($a_value, 0, 4) ==
"il__")
3662 $a_value =
"il_".IL_INST_ID.
"_".substr($a_value, 4, strlen($a_value) - 4);
3682 if (empty($a_group_name))
3684 $message = __METHOD__.
": No groupname given!";
3685 $ilErr->raiseError($message,$ilErr->WARNING);
3688 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
3690 $q =
"SELECT obj_id FROM object_data ".
3691 "WHERE title = ".$ilDB->quote($a_group_name,
"text").
" ".
3692 "AND type = ".$ilDB->quote(
"grp",
"text").
3695 $r = $ilDB->query($q);
3715 $my_pid = getmypid();
3716 return (
"MEMORY USAGE (% KB PID ): ".`ps -eo%mem,rss,pid | grep $my_pid`);
3727 if (strtolower(substr(php_uname(), 0, 3)) ==
"win")
3737 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3739 return escapeshellarg($a_arg);
3753 if(ini_get(
'safe_mode') == 1)
3757 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3758 return escapeshellcmd($a_arg);
3777 $cmd =
'"'.$cmd.
'"';
3782 if (version_compare(phpversion(),
"5.2",
"<") && strpos($args,
'"') !==
false)
3784 $cmd =
'"'.$cmd.
" ".$args.
'"';
3826 public static function excelTime($year =
"", $month =
"", $day =
"", $hour =
"", $minute =
"", $second =
"")
3828 $starting_time = mktime(0, 0, 0, 1, 2, 1970);
3829 if (strcmp(
"$year$month$day$hour$minute$second",
"") == 0)
3831 $target_time = time();
3840 $target_time = mktime($hour, $minute, $second, $month, $day, $year);
3841 $difference = $target_time - $starting_time;
3842 $days = (($difference - ($difference % 86400)) / 86400);
3843 $difference = $difference - ($days * 86400) + 3600;
3846 return str_replace(
",",
".", ($days + 25570 + ($difference / 86400)));
3857 $def_arr = explode(
",", SUFFIX_REPL_DEFAULT);
3858 foreach ($def_arr as $def)
3863 $def_arr = explode(
",", SUFFIX_REPL_ADDITIONAL);
3864 foreach ($def_arr as $def)
3884 if ($a_dir ==
"/" || $a_dir ==
"" || is_int(strpos($a_dir,
".."))
3885 || trim($a_old_suffix) ==
"")
3891 if (!@is_dir($a_dir))
3897 $dir = opendir($a_dir);
3899 while(
$file = readdir($dir))
3901 if (
$file !=
"." and
3905 if (@is_dir($a_dir.
"/".
$file))
3911 if (@is_file($a_dir.
"/".
$file))
3914 if(strrpos(
$file,
'.') == (strlen(
$file) - 1))
3916 rename($a_dir.
'/'.
$file,substr($a_dir.
'/'.
$file,0,-1));
3920 $path_info = pathinfo($a_dir.
"/".
$file);
3922 if (strtolower($path_info[
"extension"]) ==
3923 strtolower($a_old_suffix))
3925 $pos = strrpos($a_dir.
"/".
$file,
".");
3926 $new_name = substr($a_dir.
"/".
$file, 0, $pos).
".".$a_new_suffix;
3927 rename($a_dir.
"/".
$file, $new_name);
3936 return strpos($_SERVER[
"SCRIPT_FILENAME"],
"api") !==
false ||
3937 strpos($_SERVER[
"SCRIPT_FILENAME"],
"dummy") !==
false;
3941 if (preg_match(
"/&" . $paramName .
"=/", $qstring)) {
3942 return preg_replace(
"/&" . $paramName .
"=[^&]+/",
"&" . $paramName .
"=" . urlencode($paramValue), $qstring);
3944 return $qstring .
"&" . $paramName .
"=" . urlencode($paramValue);
3950 foreach ($parametersArray as $paramName => $paramValue ) {
3965 srand((
double) microtime()*1000000);
3967 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
3970 for ($i=1; $i<=$a_number; $i++)
3972 $min = ($security->getPasswordMinLength() > 0)
3973 ? $security->getPasswordMinLength()
3975 $max = ($security->getPasswordMaxLength() > 0)
3976 ? $security->getPasswordMaxLength()
3982 $length = rand($min,$max);
3985 $vowels_uc = strtoupper($vowels);
3986 $consonants =
"bcdfghjklmnpqrstvwxyz";
3987 $consonants_uc = strtoupper($consonants);
3988 $numbers =
"1234567890";
3989 $special =
"_.+?#-*@!$%~";
3992 if($security->getPasswordNumberOfUppercaseChars() > 0)
3994 for($j = 0; $j < $security->getPasswordNumberOfUppercaseChars(); $j++)
3999 $pw.= $consonants_uc[rand(0, strlen($consonants_uc) - 1)];
4004 $pw.= $vowels_uc[rand(0, strlen($vowels_uc) - 1)];
4011 if($security->isPasswordCharsAndNumbersEnabled())
4013 $pw.= $numbers[rand(0, strlen($numbers) - 1)];
4016 if($security->isPasswordSpecialCharsEnabled())
4018 $pw.= $special[rand(0, strlen($special) - 1)];
4021 $num_lcase_chars = max($security->getPasswordNumberOfLowercaseChars(), $length - strlen($pw));
4022 for($j = 0; $j < $num_lcase_chars; $j++)
4027 $pw.= $consonants[rand(0, strlen($consonants) - 1)];
4032 $pw.= $vowels[rand(0, strlen($vowels) - 1)];
4038 $pw = str_shuffle($pw);
4047 $path = preg_replace(
"/[\/\\\]+$/",
"",
$path);
4068 foreach(
$data as $k=>$datum)
4070 if(is_null($datum))
$data[$k] =
'null';
4071 if(is_string($datum))
$data[$k] =
"'" . $datum .
"'";
4075 return "[" . implode(
', ',
$data) .
"]";
4084 public static function virusHandling($a_file, $a_orig_name =
"", $a_clean =
true)
4088 if (IL_VIRUS_SCANNER !=
"None")
4090 require_once(
"./Services/VirusScanner/classes/class.ilVirusScannerFactory.php");
4092 if (($vs_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
4094 if ($a_clean && (IL_VIRUS_CLEAN_COMMAND !=
""))
4096 $clean_txt = $vs->cleanFile($a_file, $a_orig_name);
4097 if ($vs->fileCleaned())
4099 $vs_txt.=
"<br />".$lng->txt(
"cleaned_file").
4100 "<br />".$clean_txt;
4101 $vs_txt.=
"<br />".$lng->txt(
"repeat_scan");
4102 if (($vs2_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
4104 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_failed").
4105 "<br />".nl2br($vs2_txt));
4109 return array(
true, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_succeded"));
4114 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"cleaning_failed"));
4119 return array(
false, nl2br($vs_txt));
4124 return array(
true,
"");
4135 $a_mode =
"move_uploaded")
4137 global
$lng, $ilias;
4140 if (!is_file($a_file))
4142 if ($a_raise_errors)
4144 $ilias->raiseError($lng->txt(
"upload_error_file_not_found"), $ilias->error_obj->MESSAGE);
4158 if ($a_raise_errors)
4160 $ilias->raiseError($lng->txt(
"file_is_infected").
"<br />".
4162 $ilias->error_obj->MESSAGE);
4180 return rename($a_file, $a_target);
4184 return copy($a_file, $a_target);
4188 return move_uploaded_file($a_file, $a_target);
4202 list($datum, $uhrzeit) = explode (
" ",$mysql_date_time);
4203 list($jahr, $monat, $tag) = explode(
"-", $datum);
4204 list($std, $min, $sec) = explode(
":", $uhrzeit);
4205 return mktime ((
int) $std, (
int) $min, (
int) $sec, (
int) $monat, (
int) $tag, (
int) $jahr);
4216 return date(
"Y-m-d H:i:s");
4236 $resultarray = array();
4237 foreach (
$row as $rowindex => $entry)
4244 if (strpos($entry,
"\"") !== FALSE)
4246 $entry = str_replace(
"\"",
"\"\"", $entry);
4253 if ($compatibleWithMSExcel)
4256 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
4262 $resultarray[$rowindex] =
"\"" . $entry .
"\"";
4266 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
4273 $resultarray[$rowindex] = $entry;
4277 $resultarray[$rowindex] = utf8_decode($entry);
4281 return $resultarray;
4285 public static function isDN($a_str)
4287 return(preg_match(
"/^[a-z]+([a-z0-9-]*[a-z0-9]+)?(\.([a-z]+([a-z0-9-]*[a-z0-9]+)?)+)*$/",$a_str));
4293 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])\.".
4294 "(\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));
4328 global
$ilDB,$rbacreview,$ilAccess,
$ilUser,$ilias,$tree;
4330 if(!is_array($a_obj_type))
4332 $where =
"WHERE type = ".$ilDB->quote($a_obj_type,
"text").
" ";
4336 $where =
"WHERE ".$ilDB->in(
"type", $a_obj_type,
false,
"text").
" ";
4342 $limit = $ilias->getSetting(
'search_max_hits',100);
4350 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
4351 $a_roles = $rbacreview->assignedRoles($a_usr_id);
4355 if($rbacreview->isAssigned($a_usr_id,SYSTEM_ROLE_ID))
4357 $query =
"SELECT ref_id FROM object_reference obr LEFT JOIN object_data obd ON obr.obj_id = obd.obj_id ".
4358 "LEFT JOIN tree ON obr.ref_id = tree.child ".
4364 while(
$row = $ilDB->fetchObject(
$res))
4367 if($tree->isGrandChild(RECOVERY_FOLDER_ID,
$row->ref_id))
4372 if($counter++ >= $limit)
4377 $ref_ids[] =
$row->ref_id;
4379 return $ref_ids ? $ref_ids : array();
4383 if($a_operation ==
'edit_permissions' or strpos($a_operation,
'create') !==
false)
4385 $check_owner =
") ";
4389 $check_owner =
"OR owner = ".$ilDB->quote($a_usr_id,
"integer").
") ";
4393 $ops_id = $ops_ids[0];
4395 $and =
"AND ((".$ilDB->in(
"rol_id", $a_roles,
false,
"integer").
" ";
4397 $query =
"SELECT DISTINCT(obr.ref_id),obr.obj_id,type FROM object_reference obr ".
4398 "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
4399 "LEFT JOIN rbac_pa ON obr.ref_id = rbac_pa.ref_id ".
4402 "AND (".$ilDB->like(
"ops_id",
"text",
"%i:".$ops_id.
"%").
" ".
4403 "OR ".$ilDB->like(
"ops_id",
"text",
"%:\"".$ops_id.
"\";%").
")) ".
4410 if($counter >= $limit)
4416 if($tree->isGrandChild(RECOVERY_FOLDER_ID,
$row->ref_id))
4422 if($ilAccess->checkAccessOfUser($a_usr_id,$a_operation,
'',
$row->ref_id,
$row->type,
$row->obj_id))
4425 $ref_ids[] =
$row->ref_id;
4428 return $ref_ids ? $ref_ids : array();
4448 include_once
"./Services/Administration/classes/class.ilSetting.php";
4471 $cgi = URL_TO_LATEX;
4474 include_once
"./Services/Administration/classes/class.ilSetting.php";
4479 $a_text = preg_replace(
"/\\\\([RZN])([^a-zA-Z]|<\/span>)/",
"\\mathbb{".
"$1".
"}".
"$2", $a_text);
4485 $o_start = $a_start;
4487 $a_start = str_replace(
"\\",
"", $a_start);
4488 $a_end = str_replace(
"\\",
"", $a_end);
4490 while (is_int($spos = stripos($a_text, $a_start, $cpos)))
4492 if (is_int ($epos = stripos($a_text, $a_end, $spos + 1)))
4494 $tex = substr($a_text, $spos + strlen($a_start), $epos - $spos - strlen($a_start));
4497 if (!is_int(strpos($tex,
"</div>")))
4501 $a_text = substr($a_text, 0, $spos).
4502 "<img alt=\"".htmlentities($tex).
"\" src=\"".$cgi.
"?".
4503 rawurlencode(str_replace(
'&',
'&', str_replace(
'>',
'>', str_replace(
'<',
'<', $tex)))).
"\" ".
4505 substr($a_text, $epos + strlen($a_end));
4509 $tex = $a_start.$tex.$a_end;
4514 $mj_start =
"[tex]";
4519 $mj_start =
'<span class="math">';
4520 $mj_end =
'</span>';
4530 preg_replace(
'/' . $o_start .
'(.*?)' . $o_end .
'/ie',
4531 "'".$mj_start.
"' . preg_replace('/[\\\\\\\\\\]{2}/', '\\cr', str_replace('<', '<', str_replace('<br/>', '', str_replace('<br />', '', str_replace('<br>', '', '$1'))))) . '".$mj_end.
"'", $tex);
4533 $a_text = substr($a_text, 0, $spos).
4535 substr($a_text, $epos + strlen($a_end));
4542 $result_text = $a_text;
4544 return $result_text;
4558 $result_text = $a_text;
4563 $cgi = URL_TO_LATEX;
4567 while (preg_match(
'/' . $start .
'(.*?)' . $end .
'/ie', $result_text, $found))
4569 $cnt = (int)
$GLOBALS[
"teximgcnt"]++;
4571 $fpr = @fopen($cgi.
"?".rawurlencode($found[1]),
"r");
4577 $buf = fread($fpr, 1024);
4580 if (is_int(strpos(strtoupper(substr($buf, 0, 5)),
"GIF")))
4588 $fpw = fopen($a_dir.
"/teximg/img".$cnt.
".".$suffix,
"w");
4598 $img_str =
"./teximg/img".$cnt.
".".$suffix;
4599 $result_text = str_replace($found[0],
4600 '<img alt="'.$found[1].
'" src="'.$img_str.
'" />', $result_text);
4604 return $result_text;
4615 public static function prepareTextareaOutput($txt_output, $prepare_for_latex_output = FALSE, $omitNl2BrWhenTextArea =
false)
4618 $is_html = self::isHTML(
$result);
4620 if ($prepare_for_latex_output)
4629 if(!$omitNl2BrWhenTextArea)
4638 if (preg_match_all(
"/(<pre>.*?<\/pre>)/ims",
$result, $matches))
4640 foreach ($matches[0] as $found)
4643 if (strpos(
"\n", $found) === FALSE)
4645 $replacement =
"\n";
4647 $removed = preg_replace(
"/<br\s*?\/>/ims", $replacement, $found);
4652 if ($prepare_for_latex_output)
4674 if( preg_match(
"/<[^>]*?>/", $a_text) )
4702 $diff = $to->diff($from);
4705 $periods[
"years"] = $diff->format(
"%y");
4706 $periods[
"months"] = $diff->format(
"%m");
4707 $periods[
"days"] = $diff->format(
"%d");
4708 $periods[
"hours"] = $diff->format(
"%h");
4709 $periods[
"minutes"] = $diff->format(
"%i");
4710 $periods[
"seconds"] = $diff->format(
"%s");
4712 if (!array_sum($periods))
4717 foreach ($periods as $key => $value)
4721 $segment_name = ($value > 1)
4723 : substr($key, 0, -1);
4724 $array[] = $value .
' ' . $lng->txt($segment_name);
4728 $len =
sizeof($array);
4731 $array = array_slice($array, 0, (3-$len));
4734 return implode(
', ', $array);
4742 $umf=get_cfg_var(
"upload_max_filesize");
4744 $pms=get_cfg_var(
"post_max_size");
4747 $max_filesize=min($umf, $pms);
4748 if (!$max_filesize) $max_filesize=max($umf, $pms);
4750 return $lng->txt(
"file_notice").
" $max_filesize.";
4764 $test_str = explode(
'_',$role_title);
4766 if ($test_str[0] ==
'il')
4768 $test2 = (int) $test_str[3];
4769 return is_numeric ($test2) ? (int) $test2 :
false;
4787 $test_str = explode(
'_',$ilias_id);
4789 if ($test_str[0] ==
'il' && $test_str[1] == $inst_id && count($test_str) == 4)
4791 $test2 = (int) $test_str[3];
4792 return is_numeric ($test2) ? (int) $test2 :
false;
4811 public static function _sortIds($a_ids,$a_table,$a_field,$a_id_name)
4821 $where =
"WHERE ".$a_id_name.
" IN (";
4825 $query =
"SELECT ".$a_id_name.
" FROM ".$a_table.
" ".
4827 "ORDER BY ".$a_field;
4832 $ids[] =
$row->$a_id_name;
4834 return $ids ? $ids : array();
4864 if(!is_array($a_array) or !count($a_array))
4869 foreach($a_array as $k => $item)
4871 $a_array[$k] = $ilDB->quote($item);
4885 public static function sendInfo($a_info =
"",$a_keep =
false)
4888 $tpl->setMessage(
"info", $a_info, $a_keep);
4902 $tpl->setMessage(
"failure", $a_info, $a_keep);
4914 $tpl->setMessage(
"question", $a_info, $a_keep);
4928 $tpl->setMessage(
"success", $a_info, $a_keep);
4937 $tpl->addBlockFile(
"INFOPANEL",
"infopanel",
"tpl.infopanel.html",
4938 "Services/Utilities");
4939 $tpl->setCurrentBlock(
"infopanel");
4941 if (!empty(
$_SESSION[
"infopanel"][
"text"]))
4943 $link =
"<a href=\"".$dir.$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4946 $link .= $lng->txt(
$_SESSION[
"infopanel"][
"text"]);
4951 if (!empty(
$_SESSION[
"infopanel"][
"img"]))
4953 $link .=
"<td><a href=\"".$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4956 $link .=
"<img src=\"".$ilias->tplPath.$ilias->account->prefs[
"skin"].
"/images/".
4957 $_SESSION[
"infopanel"][
"img"].
"\" border=\"0\" vspace=\"0\"/>";
4958 $link .=
"</a></td>";
4961 $tpl->setVariable(
"INFO_ICONS",$link);
4962 $tpl->parseCurrentBlock();
4983 if (!is_dir($directory))
4987 $size = @filesize($directory);
4991 if ($DIR = opendir($directory))
4993 while (($dirfile = readdir($DIR)) !==
false)
4995 if (is_link($directory . DIRECTORY_SEPARATOR . $dirfile) || $dirfile ==
'.' || $dirfile ==
'..')
4997 if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile))
4998 $size += filesize($directory . DIRECTORY_SEPARATOR . $dirfile);
4999 else if (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile))
5002 $dirSize =
ilUtil::dirsize($directory . DIRECTORY_SEPARATOR . $dirfile);
5016 return md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
5019 public static function setCookie($a_cookie_name,$a_cookie_value =
'', $a_also_set_super_global =
true, $a_set_cookie_invalid =
false)
5026 if(!(
bool)$a_set_cookie_invalid) $expire = 0;
5027 else $expire = time() - (365*24*60*60);
5031 if( version_compare(PHP_VERSION,
'5.2.0',
'>=') )
5034 setcookie( $a_cookie_name, $a_cookie_value, $expire,
5035 IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE, IL_COOKIE_HTTPONLY
5041 setcookie( $a_cookie_name, $a_cookie_value, $expire,
5046 if((
bool)$a_also_set_super_global)
$_COOKIE[$a_cookie_name] = $a_cookie_value;
5051 return strip_tags(self::stripSlashes($a_filename));
5058 if($_SERVER[
'SHELL'] || php_sapi_name() ==
'cli' ||
5062 return $ilIliasIniFile->readVariable(
'server',
'http_path');
5066 return ILIAS_HTTP_PATH;
5077 $bt = debug_backtrace();
5081 if ($cnt != 0 && ($a_limit == 0 || $cnt <= $a_limit))
5083 echo
"<br>".$t[
"file"].
", ".$t[
"function"].
" [".$t[
"line"].
"]";
5106 $exploded = explode(
'_',$a_import_id);
5108 $parsed[
'orig'] = $a_import_id;
5109 if($exploded[0] ==
'il')
5111 $parsed[
'prefix'] = $exploded[0];
5113 if(is_numeric($exploded[1]))
5115 $parsed[
'inst_id'] = (int) $exploded[1];
5117 $parsed[
'type'] = $exploded[2];
5119 if(is_numeric($exploded[3]))
5121 $parsed[
'id'] = (int) $exploded[3];
5135 '/([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff^|]*)\|/',
5138 PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
5143 for($i = 0; $vars[$i]; $i++)
5145 $result[$vars[$i++]] = unserialize($vars[$i]);
5164 $fp = @fopen(
$file,
'rb');
5182 header(
"Accept-Ranges: 0-$length");
5186 if (isset($_SERVER[
'HTTP_RANGE'])) {
5191 list(, $range) = explode(
'=', $_SERVER[
'HTTP_RANGE'], 2);
5193 if (strpos($range,
',') !==
false) {
5198 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
5199 header(
"Content-Range: bytes $start-$end/$size");
5206 if ($range ==
'-') {
5209 $c_start =
$size - substr($range, 1);
5213 $range = explode(
'-', $range);
5214 $c_start = $range[0];
5215 $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] :
$size;
5221 $c_end = ($c_end > $end) ? $end : $c_end;
5223 if ($c_start > $c_end || $c_start >
$size - 1 || $c_end >=
$size) {
5225 header(
'HTTP/1.1 416 Requested Range Not Satisfiable');
5226 header(
"Content-Range: bytes $start-$end/$size");
5232 $length = $end - $start + 1;
5234 header(
'HTTP/1.1 206 Partial Content');
5237 header(
"Content-Range: bytes $start-$end/$size");
5238 header(
"Content-Length: $length");
5242 while(!feof($fp) && ($p = ftell($fp)) <= $end) {
5244 if ($p + $buffer > $end) {
5248 $buffer = $end - $p + 1;
5251 echo fread($fp, $buffer);
static maskTag($a_str, $t, $fix_param="")
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static isConvertVersionAtLeast($a_version)
Compare convert version numbers.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static getMemString()
get current memory usage as string
static tf2yn($a_tf)
convert true/false to "y"/"n"
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static removeItemFromDesktops($a_id)
removes object from all user's desktops public
static shortenWords($a_str, $a_len=30, $a_dots=true)
Ensure that the maximum word lenght within a text is not longer than $a_len.
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ...
setErrorHandling($mode=null, $options=null)
Sets how errors generated by this object should be handled.
static securePlainString($a_str)
Remove unsecure characters from a plain text string.
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=FALSE, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
const PEAR_ERROR_CALLBACK
static rRenameSuffix($a_dir, $a_old_suffix, $a_new_suffix)
Renames all files with certain suffix and gives them a new suffix.
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
static _getOperationIdsByName($operations)
get ops_id's by name.
static usesHTTP()
Uses HTTP aka browser.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static unserializeSession($data)
Returns the unserialized ILIAS session data.
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
static insertLatexImages($a_text, $a_start="\ex\, $a_end="\\tex\")
replace [text]...[/tex] tags with formula image code
if(strpos($jquery_path, './')===0) else if(strpos($jquery_path, '.')===0) $mathJaxSetting
static getImageTagByType($a_type, $a_path, $a_big=false)
Builds an html image tag TODO: function still in use, but in future use getImagePath and move HTML-Co...
static sort_func_numeric($a, $b)
sub-function to sort an array
static getMySQLTimestamp($a_ts)
Get MySQL timestamp in 4.1.x or higher format (yyyy-mm-dd hh:mm:ss) This function converts a timestam...
static Linkbar($AScript, $AHits, $ALimit, $AOffset, $AParams=array(), $ALayout=array(), $prefix='')
Linkbar Diese Funktion erzeugt einen typischen Navigationsbalken mit "Previous"- und "Next"-Links und...
static strPos($a_haystack, $a_needle, $a_offset=NULL)
static unmaskAttributeTag($a_str, $tag, $tag_att)
static getSelectName($selected, $values)
???
static parseImportId($a_import_id)
Parse an ilias import id Typically of type il_[IL_INST_ID]_[OBJ_TYPE]_[OBJ_ID] returns array( 'orig' ...
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive, instead it parses the serialized rbac_pa entries.
static execQuoted($cmd, $args=NULL)
exec command and fix spaces on windows
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
static groupNameExists($a_group_name, $a_id=0)
checks if group name already exists.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static getUsersOnline($a_user_id=0)
reads all active sessions from db and returns users that are online OR returns only one active user i...
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static getNewContentStyleSheetLocation($mode="output")
get full style sheet file name (path inclusive) of current user
static htmlfile2pdf($html_file, $pdf_file)
produce pdf out of html with htmldoc
static unique_multi_array($array, $sub_key)
Make a multi-dimensional array to have only DISTINCT values for a certain "column".
static getPasswordValidChars($a_as_regex=true, $a_only_special_chars=false)
All valid chars for password.
static _lookupTitle($a_id)
lookup object title
static assembleParameterString($a_par_arr)
static generatePasswords($a_number)
Generate a number of passwords.
static deducibleSize($a_mime)
checks if mime type is provided by getimagesize()
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
static maskSecureTags($a_str, $allow_array)
Util class various functions, usage as namespace.
static isPassword($a_passwd, &$customError=null)
validates a password public
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static now()
Return current timestamp in Y-m-d H:i:s format.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static stripScriptHTML($a_str, $a_allow="", $a_rm_js=true)
strip only html tags (4.0) from text $allowed contains tags to be allowed, in format tags a and b ar...
static escapeShellCmd($a_arg)
escape shell cmd
static makeTimeSelect($prefix, $short=true, $hour="", $minute="", $second="", $a_use_default=true, $a_further_options=array())
Creates a combination of HTML selects for time inputs.
const DB_FETCHMODE_OBJECT
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
static isWindows()
check wether the current client system is a windows system
static processConvertVersion($a_version)
Parse convert version string, e.g.
static stripOnlySlashes($a_str)
strip slashes if magic qoutes is enabled
static getCurrentMasterStyle()
get the current style
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static buildLatexImages($a_text, $a_dir)
replace [text]...[/tex] tags with formula image code //////// added additional parameters to make thi...
static _removeItemFromDesktops($a_id)
removes object from all user's desktops public
static getP3PLocation()
Get p3p file path.
static maskAttributeTag($a_str, $tag, $tag_att)
static unmaskSecureTags($a_str, $allow_array)
static _sanitizeFilemame($a_filename)
static html2pdf($html, $pdf_file)
produce pdf out of html with htmldoc
static getAssociatedUsersOnline($a_user_id)
reads all active sessions from db and returns users that are online and who have a local role in a gr...
static __extractRefId($role_title)
extract ref id from role title, e.g.
static getJavaPath()
get full java path (dir + java command)
static getConvertCmd()
get convert command
static setCookie($a_cookie_name, $a_cookie_value='', $a_also_set_super_global=true, $a_set_cookie_invalid=false)
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static formDisabledRadioButton($checked, $varname, $value, $disabled)
???
static replaceUrlParameterString($url, $parametersArray)
static resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop=false)
resize image
static execConvert($args)
execute convert command
if(!is_array($argv)) $options
static date_mysql2time($mysql_date_time)
make time object from mysql_date_time
static _sortIds($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),'usr_data','lastname','usr_id') => sorts by lastname.
static stableSortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which h...
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static getJSLocation($a_js_name, $a_js_location="", $add_version=FALSE)
get full javascript file name (path inclusive) of current user
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static KT_replaceParam($qstring, $paramName, $paramValue)
static _lookupObjId($a_id)
static makeClickable($a_text, $detectGotoLinks=false)
makeClickable In Texten enthaltene URLs und Mail-Adressen klickbar machen
static mergesort(&$array, $cmp_function='strcmp')
const PEAR_ERROR_RETURN
#+ ERROR constants
static period2String(ilDateTime $a_from, $a_to=null)
Return a string of time period.
static setPathStr($a_path)
??? public
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static infoPanel($a_keep=true)
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
static CreateIsoFromFolder($a_dir, $a_file)
static getGDSupportedImageType($a_desired_type)
returns the best supported image type by this PHP build
static sort_func($a, $b)
sub-function to sort an array
static createDirectory($a_dir, $a_mod=0755)
create directory
static clear($a_var)
Unset a value.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static & processCSVRow(&$row, $quoteAll=FALSE, $separator=";", $outUTF8=FALSE, $compatibleWithMSExcel=TRUE)
Convertes an array for CSV usage.
get($a_format, $a_format_str='', $a_tz='')
get formatted date
static removeTrailingPathSeparators($path)
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static makeDateSelect($prefix, $year="", $month="", $day="", $startyear="", $a_long_month=true, $a_further_options=array(), $emptyoption=false)
Creates a combination of HTML selects for date inputs.
static unmaskTag($a_str, $t, $fix_param="")
static getHtmlPath($relative_path)
get url of path
secureUrl($url)
Prepare secure href attribute.
static _getAssociatedUsersOnline($a_user_id, $a_no_anonymous=false)
reads all active sessions from db and returns users that are online and who have a local role in a gr...
static array_php2js($data)
convert php arrays to javascript arrays
static replaceLinkProperties($matches)
replaces target _blank with _self and the link text with the according object title.
rangeDownload($file)
Send a file via range request, see http://mobiforge.com/design-development/content-delivery-mobile-de...
static formRadioButton($checked, $varname, $value, $onclick=null, $disabled=false)
??? public
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
includeMathjax($a_tpl=null)
Include Mathjax.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getInstance()
Get https instance.
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
static htmlentitiesOutsideHTMLTags($htmlText)
Encodes HTML entities outside of HTML tags.
if(!file_exists(getcwd().'/ilias.ini.php')) if(isset( $_GET["client_id"]))
registration confirmation script for ilias
static dirsize($directory)
get size of a directory or a file.
static quoteArray($a_array)
Quotes all members of an array for usage in DB query statement.
static secureLink($a_str)
& _getInstance()
Constructor public.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static getDataDir()
get data directory (outside webspace)
static ilTempnam()
Create a temporary file in an ILIAS writable directory.
static strToUpper($a_string)
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
static escapeShellArg($a_arg)
recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
static checkInput($vars)
???
static insertInstIntoID($a_value)
inserts installation id into ILIAS id
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
static formInput($varname, $value, $disabled=false)
create html input area
static isHTML($a_text)
Checks if a given string contains HTML or not.
static getCurrentStyle()
get the current style
static htmlencodePlainString($a_str, $a_make_links_clickable, $a_detect_goto_links=false)
Encodes a plain text string into HTML for display in a browser.
static yn2tf($a_yn)
convert "y"/"n" to true/false
static checkFormEmpty($emptyFields)
??? public
static subStr($a_str, $a_start, $a_length=NULL)
static redirect($a_script)
http redirect to other script
static extractParameterString($a_parstr)
extracts parameter value pairs from a string into an array
static excelTime($year="", $month="", $day="", $hour="", $minute="", $second="")
Calculates a Microsoft Excel date/time value.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
static _getInstance()
Get instance of ilSecuritySettings.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public
static printBacktrace($a_limit=0)
printBacktrace
static strCmp($a, $b)
Compare two strings.
static dumpString($a_str)
dumps ord values of every character of string $a_str
static readFile($a_file)
there are some known problems with the original readfile method, which sometimes truncates delivered ...