39 return "<img src=\"".ilUtil::getImagePath(
$filename).
"\" alt=\"".$lng->txt(
"obj_".$a_type).
"\" title=\"".$lng->txt(
"obj_".$a_type).
"\" border=\"0\" vspace=\"0\"/>";
59 if($ilSetting->get(
"custom_icons"))
66 include_once(
'./Services/Container/classes/class.ilContainer.php');
99 public static function getImagePath(
$img, $module_path =
"", $mode =
"output", $offline =
false)
101 global $ilias, $styleDefinition,
$ilCtrl, $ilUser;
103 if (is_int(strpos($_SERVER[
"PHP_SELF"],
"setup.php")))
107 if ($module_path !=
"")
109 $module_path =
"/".$module_path;
113 $default_img =
".".$module_path.
"/templates/default/images/".
$img;
116 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
120 if (is_object($styleDefinition))
122 $image_dir = $styleDefinition->getImageDirectory($current_style);
124 if ($current_skin ==
"default")
126 $user_img =
".".$module_path.
"/templates/default/".$image_dir.
"/".
$img;
127 $skin_img =
".".$module_path.
"/templates/default/images/".
$img;
129 else if (is_object($styleDefinition) && $current_skin !=
"default")
131 $user_img =
"./Customizing/global/skin/".
132 $current_skin.$module_path.
"/".$image_dir.
"/".
$img;
133 $skin_img =
"./Customizing/global/skin/".
134 $current_skin.$module_path.
"/images/".
$img;
139 return "./images/".$img;
141 else if (@file_exists($user_img) && $image_dir !=
"")
145 else if (file_exists($skin_img))
165 if (substr($relative_path, 0, 2) ==
'./')
167 $relative_path = (substr($relative_path, 1));
169 if (substr($relative_path, 0, 1) !=
'/')
171 $relative_path =
'/' . $relative_path;
173 $htmlpath = ILIAS_HTTP_PATH . $relative_path;
195 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
197 if (strlen($a_css_location) && (strcmp(substr($a_css_location, -1),
"/") != 0)) $a_css_location = $a_css_location .
"/";
201 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
204 $filename =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/".$a_css_location.$stylesheet_name;
208 $filename =
"./" . $a_css_location .
"templates/default/".$stylesheet_name;
211 if ($mode !=
"filesystem")
213 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
214 $vers =
"?vers=".str_replace(
".",
"-", $vers);
229 public static function getJSLocation($a_js_name, $a_js_location =
"", $add_version = FALSE)
234 $js_name = $a_js_name;
235 if (strlen($a_js_location) && (strcmp(substr($a_js_location, -1),
"/") != 0)) $a_js_location = $a_js_location .
"/";
239 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
242 $filename =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/".$a_js_location.$js_name;
246 $filename =
"./" . $a_js_location .
"templates/default/".$js_name;
251 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
252 $vers =
"?vers=".str_replace(
".",
"-", $vers);
268 if (defined(
"ILIAS_MODULE"))
273 $base .=
"../Services/Privacy/";
278 $base =
"./Services/Privacy/";
281 if (is_file($base.
"w3c/p3p.xml"))
283 return ILIAS_HTTP_PATH.
"w3c/p3p.xml";
287 return ILIAS_HTTP_PATH.
"/w3c/p3p_template.xml";
303 if ($mode !=
"filesystem")
305 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
306 $vers =
"?vers=".str_replace(
".",
"-", $vers);
310 require_once(
"./Services/Style/classes/class.ilStyleDefinition.php");
313 $in_style =
"./templates/".ilStyleDefinition::getCurrentSkin().
"/"
314 .ilStyleDefinition::getCurrentStyle().
"_cont.css";
318 $in_style =
"./Customizing/global/skin/".ilStyleDefinition::getCurrentSkin().
"/"
319 .ilStyleDefinition::getCurrentStyle().
"_cont.css";
322 if (is_file(
"./".$in_style))
324 return $in_style.$vers;
328 return "templates/default/delos_cont.css".$vers;
350 public static function formSelect($selected,$varname,$options,$multiple =
false,$direct_text =
false,
$size =
"0",
351 $style_class =
"", $attribs =
"",$disabled =
false)
355 if ($multiple ==
true)
357 $multiple =
" multiple=\"multiple\"";
365 if ($style_class !=
"")
367 $class =
" class=\"".$style_class.
"\"";
374 if (is_array($attribs))
376 foreach ($attribs as $key => $val)
378 $attributes .=
" ".$key.
"=\"".$val.
"\"";
383 $disabled =
' disabled=\"disabled\"';
386 $str =
"<select name=\"".$varname .
"\"".$multiple.
" $class size=\"".
$size.
"\" $attributes $disabled>\n";
388 foreach ((array) $options as $key => $val)
393 $style = $val[
"style"];
397 $sty = ($style !=
"")
398 ?
' style="'.$style.
'" '
403 $str .=
" <option $sty value=\"".$key.
"\"";
407 $str .=
" <option $sty value=\"".$val.
"\"";
409 if (is_array($selected) )
411 if (in_array($key,$selected))
413 $str .=
" selected=\"selected\"";
416 else if ($selected == $key)
418 $str .=
" selected=\"selected\"";
423 $str .=
">".$val.
"</option>\n";
427 $str .=
">".$lng->txt($val).
"</option>\n";
431 $str .=
"</select>\n";
447 return($values[$selected]);
461 public static function formCheckbox ($checked,$varname,$value,$disabled =
false)
463 $str =
"<input type=\"checkbox\" name=\"".$varname.
"\"";
467 $str .=
" checked=\"checked\"";
472 $str .=
" disabled=\"disabled\"";
477 if (substr($varname,-2) ==
"[]")
485 $varname_id = substr($varname,0,-2).
"_".$value;
489 $varname_id = $varname;
493 $varname_id = ereg_replace(
"\[",
"_",$varname_id);
494 $varname_id = ereg_replace(
"\]",
"",$varname_id);
496 $str .=
" value=\"".$value.
"\" id=\"".$varname_id.
"\" />\n";
515 $str =
"<input disabled type=\"radio\" name=\"".$varname.
"\"";
518 $str =
"<input type=\"radio\" name=\"".$varname.
"\"";
522 $str .=
" checked=\"checked\"";
525 $str .=
" value=\"".$value.
"\"";
526 $str .=
" id=\"".$value.
"\" />\n";
545 $str =
"<input type=\"radio\" name=\"".$varname.
"\"";
548 $str .=
" checked=\"checked\"";
551 $str .=
" value=\"".$value.
"\"";
553 $str .=
" id=\"".$value.
"\" />\n";
568 public static function formInput($varname,$value,$disabled =
false)
571 $str =
"<input type=\"input\" name=\"".$varname.
"\"";
577 $str .=
" value=\"".$value.
"\"";
579 $str .=
" id=\"".$value.
"\" />\n";
605 if (
"" != $a_path &&
"/" != substr($a_path, -1))
654 $tpltab =
new ilTemplate(
"tpl.tabs.html",
true,
true);
656 for ($i=1; $i<=4; $i++)
658 $tpltab->setCurrentBlock(
"tab");
661 $tabtype =
"tabactive";
666 $tabtype =
"tabinactive";
673 $txt = $lng->txt(
"view_content");
676 $txt = $lng->txt(
"edit_properties");
679 $txt = $lng->txt(
"perm_settings");
682 $txt = $lng->txt(
"show_owner");
685 $tpltab->setVariable(
"CONTENT", $txt);
686 $tpltab->setVariable(
"TABTYPE", $tabtype);
687 $tpltab->setVariable(
"TAB",
$tab);
688 $tpltab->setVariable(
"LINK", $a_o[
"LINK".$i]);
689 $tpltab->parseCurrentBlock();
692 return $tpltab->get();
710 foreach ($emptyFields as $key => $val)
713 if ($feedback !=
"") $feedback .=
", ";
745 public static function Linkbar ($AScript,$AHits,$ALimit,$AOffset,$AParams = array(),$ALayout = array(), $prefix =
'')
750 $layout_prev =
"<<";
751 $layout_next =
">>";
754 if (count($ALayout > 0))
756 if ($ALayout[
"link"])
758 $layout_link =
" class=\"".$ALayout[
"link"].
"\"";
761 if ($ALayout[
"prev"])
763 $layout_prev = $ALayout[
"prev"];
766 if ($ALayout[
"next"])
768 $layout_next = $ALayout[
"next"];
774 if ($AHits > $ALimit || $AOffset > 0)
776 if (!empty($AParams))
778 foreach ($AParams as $key => $value)
780 $params.= $key.
"=".$value.
"&";
784 if(strpos($AScript,
'&'))
786 $link = $AScript.
"&".$params.$prefix.
"offset=";
790 $link = $AScript.
"?".$params.$prefix.
"offset=";
796 $prevoffset = $AOffset - $ALimit;
797 if ($prevoffset < 0) $prevoffset = 0;
798 $LinkBar .=
"<a".$layout_link.
" href=\"".$link.$prevoffset.
"\">".$layout_prev.
" </a>";
802 $pages=intval($AHits/$ALimit);
805 if (($AHits % $ALimit))
812 for ($i = 1 ;$i <= $pages ; $i++)
814 $newoffset=$ALimit*($i-1);
816 if ($newoffset == $AOffset)
818 $LinkBar .=
"[".$i.
"] ";
822 $LinkBar .=
'<a '.$layout_link.
' href="'.
823 $link.$newoffset.
'">['.$i.
']</a> ';
830 if (! ( ($AOffset/$ALimit)==($pages-1) ) && ($pages!=1) )
832 $newoffset=$AOffset+$ALimit;
833 $LinkBar .=
"<a".$layout_link.
" href=\"".$link.$newoffset.
"\"> ".$layout_next.
"</a>";
861 $ret = eregi_replace(
"(^|[[:space:]]+)(www\.)([[:alnum:]#?/&=\.-]+)",
862 "\\1http://\\2\\3",
$ret);
865 $ret = eregi_replace(
"(^|[[:space:]]+)(ftp\.)([[:alnum:]#?/&=\.-]+)",
866 "\\1ftp://\\2\\3",
$ret);
873 $ret = str_replace(
'src="http://',
'"***masked_im_start***',
$ret);
875 include_once(
"./Services/Utilities/classes/class.ilMWParserAdapter.php");
877 $ret = $parser->replaceFreeExternalLinks(
$ret);
880 $ret = str_replace(
'"***masked_im_start***',
'src="http://',
$ret);
884 if ($detectGotoLinks)
887 $regExp =
"<a[^>]*href=\"(".str_replace(
"/",
"\/",ILIAS_HTTP_PATH).
"\/goto.php\?target=\w+_(\d+)[^\"]*)\"[^>]*>[^<]*<\/a>";
889 $ret = preg_replace_callback(
891 array(
"ilUtil",
"replaceLinkProperties"),
895 $regExp =
"<a[^>]*href=\"(".str_replace(
"/",
"\/",ILIAS_HTTP_PATH).
"\/goto_.*[a-z0-9]+_([0-9]+)\.html)\"[^>]*>[^<]*<\/a>";
897 $ret = preg_replace_callback(
899 array(
"ilUtil",
"replaceLinkProperties"),
930 $link =
"<a href=".$matches[1].
" target=\"_self\">".
$title.
"</a>";
956 $m = explode(
" ",microtime());
985 public static function makeDateSelect($prefix, $year =
"", $month =
"", $day =
"", $startyear =
"",$a_long_month =
true,$a_further_options = array(), $emptyoption =
false)
990 if(isset($a_further_options[
'disabled']) and $a_further_options[
'disabled'])
992 $disabled =
'disabled="disabled" ';
998 if (!strlen($year)) $year = $now[
"year"];
999 if (!strlen($month)) $month = $now[
"mon"];
1000 if (!strlen($day)) $day = $now[
"mday"];
1003 $year = (int) $year;
1004 $month = (int) $month;
1009 $sel_day .=
'<select ';
1010 if(isset($a_further_options[
'select_attributes']))
1012 foreach($a_further_options[
'select_attributes'] as $name => $value)
1014 $sel_day .= ($name.
'="'.$value.
'" ');
1018 $sel_day .= $disabled.
"name=\"".$prefix.
"[d]\" id=\"".$prefix.
"_d\">\n";
1020 if ($emptyoption) $sel_day .=
"<option value=\"0\">--</option>\n";
1021 for ($i = 1; $i <= 31; $i++)
1023 $sel_day .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1025 $sel_day .=
"</select>\n";
1026 $sel_day = preg_replace(
"/(value\=\"$day\")/",
"$1 selected=\"selected\"", $sel_day);
1029 $sel_month =
'<select ';
1030 if(isset($a_further_options[
'select_attributes']))
1032 foreach($a_further_options[
'select_attributes'] as $name => $value)
1034 $sel_month .= ($name.
'="'.$value.
'" ');
1037 $sel_month .= $disabled.
"name=\"".$prefix.
"[m]\" id=\"".$prefix.
"_m\">\n";
1039 if ($emptyoption) $sel_month .=
"<option value=\"0\">--</option>\n";
1040 for ($i = 1; $i <= 12; $i++)
1044 $sel_month .=
"<option value=\"$i\">" . $lng->txt(
"month_" . sprintf(
"%02d", $i) .
"_long") .
"</option>\n";
1048 $sel_month .=
"<option value=\"$i\">" . $i .
"</option>\n";
1051 $sel_month .=
"</select>\n";
1052 $sel_month = preg_replace(
"/(value\=\"$month\")/",
"$1 selected=\"selected\"", $sel_month);
1055 $sel_year =
'<select ';
1056 if(isset($a_further_options[
'select_attributes']))
1058 foreach($a_further_options[
'select_attributes'] as $name => $value)
1060 $sel_year .= ($name.
'="'.$value.
'" ');
1063 $sel_year .= $disabled.
"name=\"".$prefix.
"[y]\" id=\"".$prefix.
"_y\">\n";
1064 if ((strlen($startyear) == 0) || ($startyear > $year))
1066 if (!$emptyoption || $year != 0) $startyear = $year - 5;
1069 if(($year + 5) < (date(
'Y',time()) + 5))
1071 $end_year = date(
'Y',time()) + 5;
1075 $end_year = $year + 5;
1078 if ($emptyoption) $sel_year .=
"<option value=\"0\">----</option>\n";
1079 for ($i = $startyear; $i <= $end_year; $i++)
1081 $sel_year .=
"<option value=\"$i\">" . sprintf(
"%04d", $i) .
"</option>\n";
1083 $sel_year .=
"</select>\n";
1084 $sel_year = preg_replace(
"/(value\=\"$year\")/",
"$1 selected=\"selected\"", $sel_year);
1087 $dateformat =
"d-m-Y";
1088 $dateformat = strtolower(preg_replace(
"/\W/",
"", $dateformat));
1089 $dateformat = strtolower(preg_replace(
"/(\w)/",
"%%$1", $dateformat));
1090 $dateformat = preg_replace(
"/%%d/", $sel_day, $dateformat);
1091 $dateformat = preg_replace(
"/%%m/", $sel_month, $dateformat);
1092 $dateformat = preg_replace(
"/%%y/", $sel_year, $dateformat);
1114 public static function makeTimeSelect($prefix, $short =
true, $hour =
"", $minute =
"", $second =
"",$a_use_default =
true,$a_further_options = array())
1116 global
$lng, $ilUser;
1120 if(count($a_further_options))
1122 if(isset($a_further_options[
'minute_steps']))
1124 $minute_steps = $a_further_options[
'minute_steps'];
1126 if(isset($a_further_options[
'disabled']) and $a_further_options[
'disabled'])
1128 $disabled =
'disabled="disabled" ';
1132 if ($a_use_default and !strlen(
"$hour$minute$second")) {
1139 $minute = (int)$minute;
1140 $second = (int)$second;
1143 $sel_hour =
'<select ';
1144 if(isset($a_further_options[
'select_attributes']))
1146 foreach($a_further_options[
'select_attributes'] as $name => $value)
1148 $sel_hour .= $name.
'='.$value.
' ';
1151 $sel_hour .=
" ".$disabled.
"name=\"".$prefix.
"[h]\" id=\"".$prefix.
"_h\">\n";
1153 $format = $ilUser->getTimeFormat();
1154 for ($i = 0; $i <= 23; $i++)
1158 $sel_hour .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1162 $sel_hour .=
"<option value=\"$i\">" . date(
"ga", mktime($i, 0, 0)) .
"</option>\n";
1165 $sel_hour .=
"</select>\n";
1166 $sel_hour = preg_replace(
"/(value\=\"$hour\")/",
"$1 selected=\"selected\"", $sel_hour);
1169 $sel_minute .=
"<select ".$disabled.
"name=\"".$prefix.
"[m]\" id=\"".$prefix.
"_m\">\n";
1171 for ($i = 0; $i <= 59; $i = $i + $minute_steps)
1173 $sel_minute .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1175 $sel_minute .=
"</select>\n";
1176 $sel_minute = preg_replace(
"/(value\=\"$minute\")/",
"$1 selected=\"selected\"", $sel_minute);
1180 $sel_second .=
"<select ".$disabled.
"name=\"".$prefix.
"[s]\" id=\"".$prefix.
"_s\">\n";
1182 for ($i = 0; $i <= 59; $i++)
1184 $sel_second .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1186 $sel_second .=
"</select>\n";
1187 $sel_second = preg_replace(
"/(value\=\"$second\")/",
"$1 selected=\"selected\"", $sel_second);
1189 $timeformat = $lng->text[
"lang_timeformat"];
1190 if (strlen($timeformat) == 0) $timeformat =
"H:i:s";
1191 $timeformat = strtolower(preg_replace(
"/\W/",
"", $timeformat));
1192 $timeformat = preg_replace(
"/(\w)/",
"%%$1", $timeformat);
1193 $timeformat = preg_replace(
"/%%h/", $sel_hour, $timeformat);
1194 $timeformat = preg_replace(
"/%%i/", $sel_minute, $timeformat);
1196 $timeformat = preg_replace(
"/%%s/",
"", $timeformat);
1198 $timeformat = preg_replace(
"/%%s/", $sel_second, $timeformat);
1223 $successfulInclude = @include_once (
'Services/Mail/classes/class.ilMail.php');
1229 require_once
'Mail/RFC822.php';
1233 $addresses = $parser->parseAddressList($a_email,
'ilias',
false,
true);
1234 if (! is_a($addresses,
'PEAR_Error') &&
1235 count($addresses) == 1 && $addresses[0]->host !=
'ilias')
1250 "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|".
1251 "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|".
1252 "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|".
1253 "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|".
1254 "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|".
1255 "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|".
1256 "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|".
1257 "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|".
1258 "WF|WS|XN|YE|YT|YU|ZA|ZM|ZW");
1260 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));
1273 public static function isPassword($a_passwd, &$customError = null)
1277 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1284 $customError = null;
1289 case empty($a_passwd):
1292 case strlen($a_passwd) < 6:
1295 case !preg_match(
"/^[A-Za-z0-9_\.\+\?\#\-\*\@!\$\%\~]+$/", $a_passwd):
1308 if( empty($a_passwd) )
1310 $customError = $lng->txt(
'password_empty');
1318 if( $security->getPasswordMinLength() > 0 && strlen($a_passwd) < $security->getPasswordMinLength() )
1320 $errors[] = sprintf( $lng->txt(
'password_to_short'), $security->getPasswordMinLength() );
1321 $isPassword =
false;
1325 if( $security->getPasswordMaxLength() > 0 && strlen($a_passwd) > $security->getPasswordMaxLength() )
1327 $errors[] = sprintf( $lng->txt(
'password_to_long'), $security->getPasswordMaxLength() );
1328 $isPassword =
false;
1332 if( $security->isPasswordCharsAndNumbersEnabled() )
1334 $hasCharsAndNumbers =
true;
1337 if( !preg_match(
'/[A-Za-z]+/',$a_passwd) )
1339 $hasCharsAndNumbers =
false;
1343 if( !preg_match(
'/[0-9]+/',$a_passwd) )
1345 $hasCharsAndNumbers =
false;
1348 if( !$hasCharsAndNumbers )
1350 $errors[] = $lng->txt(
'password_must_chars_and_numbers');
1351 $isPassword =
false;
1356 if( $security->isPasswordSpecialCharsEnabled() )
1358 $specialCharsReg =
'/[_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+/';
1361 if( !preg_match($specialCharsReg, $a_passwd) )
1363 $errors[] = $lng->txt(
'password_must_special_chars');
1364 $isPassword =
false;
1369 if( !preg_match(
"/^[A-Za-z0-9_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+$/", $a_passwd) )
1371 $errors[] = $lng->txt(
'password_contains_invalid_chars');
1372 $isPassword =
false;
1382 $customError = $lng->txt(
'password_multiple_errors');
1383 $customError .=
'<br />'.implode(
'<br />',
$errors);
1401 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1406 $validPasswordChars =
'A-Z a-z 0-9 _.+?#-*@!$%~/:;';
1410 $validPasswordChars =
'A-Z a-z 0-9 _.+?#-*@!$%~';
1413 return sprintf($lng->txt(
'password_allow_chars'), $validPasswordChars);
1424 if (empty($a_login))
1429 if (strlen($a_login) < 3)
1437 if (!ereg(
"^[A-Za-z0-9_\.\+\*\@!\$\%\~\-]+$", $a_login))
1458 public static function shortenText ($a_str, $a_len, $a_dots =
false, $a_next_blank =
false,
1459 $a_keep_extension =
false)
1461 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1477 if ($a_keep_extension)
1479 $p = strrpos($a_str,
'.');
1481 if ($p ===
false || $p == 0 || strlen($a_str) - $p > $a_len)
1486 $a_str .=
"\xe2\x80\xa6";
1493 $a_str =
ilStr::subStr($a_str,0,$len - (strlen($a_str) - $p + 1)).
"\xe2\x80\xa6".substr($a_str, $p);
1497 $a_str =
ilStr::subStr($a_str,0,$len - (strlen($a_str) - $p + 1)).substr($a_str, $p);
1517 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1518 $str_arr = explode(
" ", $a_str);
1520 for ($i = 0; $i < count($str_arr); $i++)
1527 $str_arr[$i].=
"...";
1532 return implode($str_arr,
" ");
1547 while (is_int(strpos($a_str,
"=")))
1549 $eq_pos = strpos($a_str,
"=");
1550 $qu1_pos = strpos($a_str,
"\"");
1551 $qu2_pos = strpos(substr($a_str, $qu1_pos + 1),
"\"") + $qu1_pos + 1;
1552 if (is_int($eq_pos) && is_int($qu1_pos) && is_int($qu2_pos))
1554 $var = trim(substr($a_str, 0, $eq_pos));
1555 $val = trim(substr($a_str, $qu1_pos + 1, ($qu2_pos - $qu1_pos) - 1));
1556 $attribs[$var] = $val;
1557 $a_str = substr($a_str, $qu2_pos + 1);
1578 public static function rCopy ($a_sdir, $a_tdir, $preserveTimeAttributes =
false)
1581 if (!@is_dir($a_sdir) or
1588 $dir = opendir($a_sdir);
1592 if (
$file !=
"." and
1596 if (@is_dir($a_sdir.
"/".
$file))
1598 if (!@is_dir($a_tdir.
"/".
$file))
1613 if (@is_file($a_sdir.
"/".
$file))
1615 if (!copy($a_sdir.
"/".
$file,$a_tdir.
"/".
$file))
1619 if ($preserveTimeAttributes)
1620 touch($a_tdir.
"/".
$file, filectime($a_sdir.
"/".
$file));
1639 if ($mode ==
"filesystem")
1641 return "./".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1645 if (defined(
"ILIAS_MODULE"))
1647 return "../".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1651 return "./".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1666 return CLIENT_DATA_DIR;
1683 include_once(
"./Services/User/classes/class.ilObjUser.php");
1699 include_once(
"./Services/User/classes/class.ilObjUser.php");
1713 if (!is_dir($temp_path))
1717 $temp_name = tempnam($temp_path,
"tmp");
1723 $temp_name = str_replace(
"\\",
"/", $temp_name);
1753 public static function unzip($a_file, $overwrite =
false, $a_flat =
false)
1755 if (!is_file($a_file))
1765 copy($a_file, $tmpdir.DIRECTORY_SEPARATOR.basename($a_file));
1766 $orig_file = $a_file;
1767 $a_file = $tmpdir.DIRECTORY_SEPARATOR.basename($a_file);
1768 $origpathinfo = pathinfo($orig_file);
1771 $pathinfo = pathinfo($a_file);
1772 $dir = $pathinfo[
"dirname"];
1773 $file = $pathinfo[
"basename"];
1778 $unzip = PATH_TO_UNZIP;
1783 $unzipcmd =
"-Z -1 ".ilUtil::escapeShellArg(
$file);
1787 foreach($arr as $line)
1789 if(is_int(strpos($line,
"/")))
1791 $zdir = substr($line, 0, strrpos($line,
"/"));
1792 $nr = substr_count($zdir,
"/");
1796 $nr = substr_count($zdir,
"/");
1797 $zdirs[$zdir] = $nr;
1799 $zdir = substr($zdir, 0, strrpos($zdir,
"/"));
1806 foreach($zdirs as $zdir => $nr)
1818 $unzipcmd =
"-o ".ilUtil::escapeShellArg(
$file);
1827 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
1828 $filearray = array();
1830 if (is_array($filearray[
"file"]))
1832 foreach ($filearray[
"file"] as $k => $f)
1834 if (substr($f, 0, 1) !=
"." && $f != basename($orig_file))
1836 copy($filearray[
"path"][$k].$f, $origpathinfo[
"dirname"].DIRECTORY_SEPARATOR.$f);
1850 public static function zip($a_dir, $a_file, $compress_content =
false)
1854 if($compress_content)
1857 $pathinfo = pathinfo($a_dir);
1858 chdir($pathinfo[
"dirname"]);
1861 $pathinfo = pathinfo($a_file);
1862 $dir = $pathinfo[
"dirname"];
1863 $file = $pathinfo[
"basename"];
1865 if(!$compress_content)
1878 if (is_array($a_dir))
1881 foreach($a_dir as
$dir)
1883 $name = basename($dir);
1884 $source.=
" ".ilUtil::escapeShellArg($name);
1889 $name = basename($a_dir);
1890 if (trim($name) !=
"*")
1900 $zipcmd =
"-r ".ilUtil::escapeShellArg($a_file).
" ".$source;
1910 $pathinfo = pathinfo($a_dir);
1911 chdir($pathinfo[
"dirname"]);
1913 $pathinfo = pathinfo($a_file);
1914 $dir = $pathinfo[
"dirname"];
1915 $file = $pathinfo[
"basename"]; $zipcmd =
"-r ".ilUtil::escapeShellArg($a_file).
" ".$source;
1917 $mkisofs = PATH_TO_MKISOFS;
1924 $name = basename($a_dir);
1927 $zipcmd =
"-r -J -o ".$a_file.
" ".$source;
1943 return PATH_TO_CONVERT;
1969 if($current_version >= $version)
1984 if(preg_match(
"/([0-9]+)\.([0-9]+)\.([0-9]+)[\.|\-]([0-9]+)/", $a_version, $match))
1986 $version = str_pad($match[1], 2, 0, STR_PAD_LEFT).
1987 str_pad($match[2], 2, 0, STR_PAD_LEFT).
1988 str_pad($match[3], 2, 0, STR_PAD_LEFT).
1989 str_pad($match[4], 2, 0, STR_PAD_LEFT);
1990 return (
int)$version;
2003 public static function convertImage($a_from, $a_to, $a_target_format =
"", $a_geometry =
"",
2004 $a_background_color =
"")
2006 $format_str = ($a_target_format !=
"")
2007 ? strtoupper($a_target_format).
":"
2009 $geometry = ($a_geometry !=
"")
2010 ?
" -geometry ".$a_geometry.
"x".$a_geometry.
" "
2012 $bg_color = ($a_background_color !=
"")
2013 ?
" -background color ".$a_background_color.
" "
2015 $convert_cmd =
ilUtil::escapeShellArg($a_from).
" ".$bg_color.$geometry.ilUtil::escapeShellArg($format_str.$a_to);
2030 public static function resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop =
false)
2032 if ($a_constrain_prop)
2034 $size =
" -geometry ".$a_width.
"x".$a_height.
" ";
2038 $size =
" -resize ".$a_width.
"x".$a_height.
"! ";
2051 public static function img($a_src, $a_alt =
"", $a_width =
"", $a_height =
"", $a_border = 0)
2053 $img =
'<img src="'.$a_src.
'"';
2056 $img.=
' alt="'.$a_alt.
'" title="'.$a_alt.
'"';
2060 $img.=
' width="'.$a_width.
'"';
2062 if ($a_height !=
"")
2064 $img.=
' height="'.$a_height.
'"';
2066 $img.=
' border="'.(int) $a_border.
'"/>';
2080 $html_file = str_replace(
".pdf",
".html",$pdf_file);
2082 $fp = fopen( $html_file ,
"wb");
2097 $htmldoc_path = PATH_TO_HTMLDOC;
2099 $htmldoc =
"--no-toc ";
2100 $htmldoc .=
"--no-jpeg ";
2101 $htmldoc .=
"--webpage ";
2103 $htmldoc .=
"--bodyfont Arial ";
2104 $htmldoc .=
"--charset iso-8859-15 ";
2105 $htmldoc .=
"--color ";
2106 $htmldoc .=
"--size A4 ";
2107 $htmldoc .=
"--format pdf ";
2108 $htmldoc .=
"--footer ... ";
2109 $htmldoc .=
"--header ... ";
2110 $htmldoc .=
"--left 60 ";
2112 $htmldoc .= $html_file;
2123 public static function deliverData($a_data, $a_filename, $mime =
"application/octet-stream", $charset =
"")
2125 $disposition =
"attachment";
2128 include_once
'./classes/class.ilHTTPS.php';
2138 #header("Pragma: ");
2139 #header("Cache-Control: ");
2140 #header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
2141 #header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
2142 #header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
2143 #header("Cache-Control: post-check=0, pre-check=0", false);
2145 else if ($disposition ==
"attachment")
2147 header(
"Cache-control: private");
2151 header(
"Cache-Control: no-cache, must-revalidate");
2152 header(
"Pragma: no-cache");
2157 if (strlen($charset))
2159 $charset =
"; charset=$charset";
2161 header(
"Content-Type: $mime$charset");
2162 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
2163 header(
"Content-Description: ".$ascii_filename);
2164 header(
"Content-Length: ".(
string)(strlen($a_data)));
2169 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
2170 header(
'Pragma: public');
2173 header(
"Connection: close");
2186 public static function deliverFile($a_file, $a_filename,$a_mime =
'', $isInline =
false, $removeAfterDelivery =
false,
2187 $a_exit_after =
true)
2190 if(!file_exists($a_file))
2196 $disposition =
"inline";
2198 $disposition =
"attachment";
2209 $mime =
"application/octet-stream";
2213 if ($disposition ==
"attachment")
2215 header(
"Cache-control: private");
2219 header(
"Cache-Control: no-cache, must-revalidate");
2220 header(
"Pragma: no-cache");
2225 header(
"Content-Type: $mime");
2226 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
2227 header(
"Content-Description: ".$ascii_filename);
2230 $filesize = @filesize($a_file);
2233 header(
"Content-Length: ".(
string)$filesize);
2236 include_once
'./classes/class.ilHTTPS.php';
2237 #if($_SERVER['HTTPS'])
2240 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
2241 header(
'Pragma: public');
2244 header(
"Connection: close");
2246 if ($removeAfterDelivery)
2268 $chunksize = 1*(1024*1024);
2270 $handle = fopen($a_file,
'rb');
2271 if ($handle ===
false)
2275 while (!feof($handle))
2277 $buffer = fread($handle, $chunksize);
2280 return fclose($handle);
2310 $ascii_filename = htmlentities($a_filename, ENT_NOQUOTES,
'UTF-8');
2311 $ascii_filename = preg_replace(
'/\&(.)[^;]*;/',
'\\1', $ascii_filename);
2312 $ascii_filename = preg_replace(
'/[\x7f-\xff]/',
'_', $ascii_filename);
2315 $ascii_filename = preg_replace(
'/[:\x5c\/\*\?\"<>\|]/',
'_', $ascii_filename);
2317 return $ascii_filename;
2329 $sep =
'###HTMLTAG###';
2331 preg_match_all(
"@<[^>]*>@", $htmlText, $matches);
2332 $tmp = preg_replace(
"@(<[^>]*>)@", $sep, $htmlText);
2333 $tmp = explode($sep, $tmp);
2335 for ($i=0; $i<count($tmp); $i++)
2336 $tmp[$i] = htmlentities($tmp[$i], ENT_COMPAT,
"UTF-8");
2338 $tmp = join($sep, $tmp);
2340 for ($i=0; $i<count($matches[0]); $i++)
2341 $tmp = preg_replace(
"@$sep@", $matches[0][$i], $tmp, 1);
2354 return PATH_TO_JAVA;
2373 $url = (is_int(strpos($a_url,
"?")))
2374 ? $a_url.$amp.$a_par
2375 : $a_url.
"?".$a_par;
2397 $a_dir = trim($a_dir);
2400 if (substr($a_dir,-1) ==
"/")
2402 $a_dir = substr($a_dir,0,-1);
2406 if (!(
$path = substr($a_dir,0, strrpos($a_dir,
"/") - strlen($a_dir))))
2413 return @mkdir($a_dir,fileperms(
$path));
2433 $dirs = array($a_dir);
2434 $a_dir = dirname($a_dir);
2437 while($last_dirname != $a_dir)
2439 array_unshift(
$dirs, $a_dir);
2440 $last_dirname = $a_dir;
2441 $a_dir = dirname($a_dir);
2445 $reverse_paths = array_reverse(
$dirs, TRUE);
2447 foreach ($reverse_paths as $key => $value)
2449 if ($found_index == -1)
2453 $found_index = $key;
2462 if ($dirindex >= $found_index)
2464 if (! file_exists(
$dir))
2466 if (strcmp(substr(
$dir,strlen(
$dir)-1,1),
"/") == 0)
2472 if (! mkdir(
$dir, $umask))
2474 error_log(
"Can't make directory: $dir");
2478 elseif (! is_dir(
$dir))
2480 error_log(
"$dir is not a directory");
2486 $umask = fileperms(
$dir);
2502 public static function delDir($a_dir, $a_clean_only =
false)
2504 if (!is_dir($a_dir) || is_int(strpos($a_dir,
"..")))
2509 $current_dir = opendir($a_dir);
2518 while($entryname = readdir($current_dir))
2525 if(is_dir($a_dir.
"/".$file) and ($file !=
"." and $file!=
".."))
2529 elseif ($file !=
"." and $file !=
"..")
2531 unlink(${a_dir}.
"/".${file});
2535 closedir($current_dir);
2549 public static function getDir($a_dir, $a_rec =
false, $a_sub_dir =
"")
2551 $current_dir = opendir($a_dir.$a_sub_dir);
2555 $subitems = array();
2556 while($entry = readdir($current_dir))
2558 if(is_dir($a_dir.
"/".$entry))
2560 $dirs[$entry] = array(
"type" =>
"dir",
"entry" => $entry,
2561 "subdir" => $a_sub_dir);
2562 if ($a_rec && $entry !=
"." && $entry !=
"..")
2565 $subitems = array_merge($subitems, $si);
2570 if ($entry !=
"." && $entry !=
"..")
2572 $size = filesize($a_dir.$a_sub_dir.
"/".$entry);
2573 $files[$entry] = array(
"type" =>
"file",
"entry" => $entry,
2574 "size" =>
$size,
"subdir" => $a_sub_dir);
2592 if (is_array($a_arr))
2594 foreach ($a_arr as $k => $v)
2611 if (is_array($a_data))
2613 foreach ($a_data as $k => $v)
2640 public static function stripSlashes($a_str, $a_strip_html =
true, $a_allow =
"")
2642 if (ini_get(
"magic_quotes_gpc"))
2644 $a_str = stripslashes($a_str);
2660 if (ini_get(
"magic_quotes_gpc"))
2662 $a_str = stripslashes($a_str);
2674 public static function secureString($a_str, $a_strip_html =
true, $a_allow =
"")
2677 $only_secure =
true;
2678 $allow_tags = explode(
">", $a_allow);
2680 $allow_array = array();
2681 foreach($allow_tags as $allow)
2685 $allow = str_replace(
"<",
"", $allow);
2687 if (!in_array($allow, $sec_tags))
2689 $only_secure =
false;
2691 $allow_array[] = $allow;
2696 if (($only_secure || $a_allow ==
"") && $a_strip_html)
2700 $allow_array = array (
"b",
"i",
"strong",
"em",
"code",
"cite",
2701 "gap",
"sub",
"sup",
"pre",
"strike");
2707 $a_str = strip_tags($a_str);
2732 return array(
"strong",
"em",
"u",
"strike",
"ol",
"li",
"ul",
"p",
"div",
2733 "i",
"b",
"code",
"sup",
"sub",
"pre",
"gap",
"a",
"img");
2738 foreach ($allow_array as
$t)
2753 array(
"param" =>
"align",
"value" =>
"left"),
2754 array(
"param" =>
"align",
"value" =>
"center"),
2755 array(
"param" =>
"align",
"value" =>
"justify"),
2756 array(
"param" =>
"align",
"value" =>
"right")
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")
2811 if (ini_get(
"magic_quotes_gpc"))
2813 return stripslashes($a_str);
2840 if ($a_make_links_clickable)
2858 $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);
2861 foreach ($matches as $match)
2864 foreach ($matches[0] as $match)
2866 $matched_text = $match[0];
2868 if ($matched_offset != previous_offset)
2871 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1, $pos2 - $pos1)));
2877 $pos1 = $pos2 + strlen($matched_text);
2879 if ($pos1 < strlen($a_str))
2881 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1)));
2886 $encoded = nl2br(htmlspecialchars($a_str));
2896 $ws =
"[ \t\r\f\v\n]*";
2897 $att = $ws.
"[^>]*".$ws;
2899 while (eregi(
"<($tag$att($tag_att$ws=$ws\"(([\$@!*()~;,_0-9A-z/:=%\\.&#?+\\-])*)\")$att)>",
2902 $un = array(
".",
"-",
"+",
"?",
'$',
"*",
"(",
")");
2908 $ff = str_replace($un, $esc, $found[1]);
2911 $a_str = eregi_replace(
"<".$ff.
">",
2912 "<$tag $tag_att$tag_att=\"".$found[3].
"\">", $a_str);
2913 if ($old_str == $a_str)
2915 $ilLog->write(
"ilUtil::maskA-".htmlentities($old_str).
" == ".
2916 htmlentities($a_str));
2920 $a_str = str_ireplace(
"</$tag>",
2921 "</$tag>", $a_str);
2929 while (eregi(
"<($tag $tag_att$tag_att=\"(([\$@!*()~;,_0-9A-z/:=%\\.&#?+\\-])*)\")>",
2932 $un = array(
".",
"-",
"+",
"?",
'$',
"*",
"(",
")");
2938 $ff = str_replace($un, $esc, $found[1]);
2941 $a_str = eregi_replace(
"<".$ff.
">",
2942 "<$tag $tag_att=\"".ilUtil::secureLink($found[2]).
"\">", $a_str);
2943 if ($old_str == $a_str)
2945 $ilLog->write(
"ilUtil::unmaskA-".htmlentities($old_str).
" == ".
2946 htmlentities($a_str));
2950 $a_str = str_replace(
"</$tag>",
"</$tag>", $a_str);
2956 $a_str = str_replace(array(
"<$t>",
"<".strtoupper(
$t).
">"),
2957 "<".
$t.
">", $a_str);
2958 $a_str = str_replace(array(
"</$t>",
"</".strtoupper(
$t).
">"),
2959 "</".
$t.
">", $a_str);
2961 if (is_array($fix_param))
2963 foreach ($fix_param as $p)
2967 $a_str = str_replace(
"<$t $k=\"$v\">",
2968 "<".
"$t $k=\"$v\"".
">", $a_str);
2977 $a_str = str_replace(
"<".
$t.
">",
"<".$t.
">", $a_str);
2978 $a_str = str_replace(
"</".
$t.
">",
"</".$t.
">", $a_str);
2980 if (is_array($fix_param))
2982 foreach ($fix_param as $p)
2986 $a_str = str_replace(
"<$t $k=\"$v\">",
2987 "<".
"$t $k=\"$v\"".
">", $a_str);
2995 $a_str = str_ireplace(
"javascript",
"jvscrpt", $a_str);
2996 $a_str = str_ireplace(array(
"%00",
"%0a",
"%0d",
"%1a",
"�",
"�",
2997 "�",
"�",
"
",
"
",
" ",
" "),
"-", $a_str);
3018 $negativestr =
"a,abbr,acronym,address,applet,area,b,base,basefont,".
3019 "bdo,big,blockquote,body,br,button,caption,center,cite,code,col,".
3020 "colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame,".
3021 "frameset,h1,h2,h3,h4,h5,h6,head,hr,html,i,iframe,img,input,ins,isindex,kbd,".
3022 "label,legend,li,link,map,menu,meta,noframes,noscript,object,ol,".
3023 "optgroup,option,p,param,q,s,samp,script,select,small,span,".
3024 "strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,".
3025 "title,tr,tt,u,ul,var";
3026 $a_allow = strtolower ($a_allow);
3027 $negatives = explode(
",",$negativestr);
3028 $outer_old_str =
"";
3029 while($outer_old_str != $a_str)
3031 $outer_old_str = $a_str;
3032 foreach ($negatives as $item)
3034 $pos = strpos($a_allow,
"<$item>");
3040 while($old_str != $a_str)
3043 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s*>/i",
"", $a_str);
3044 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s+([^>]*)>/i",
"", $a_str);
3053 $a_str = preg_replace(
"/<\s*\w*(\/?)(\s+[^>]*)?(\s+on[^>]*)>/i",
"", $a_str);
3056 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*javascript[^>]*>/i",
"", $a_str);
3060 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*expression[^>]*>/i",
"", $a_str);
3077 if (ini_get(
"magic_quotes_gpc"))
3083 return addslashes($a_str);
3104 $a_str = htmlspecialchars($a_str);
3108 $a_str = str_replace(
"{",
"{", $a_str);
3109 $a_str = str_replace(
"}",
"}", $a_str);
3128 return addslashes($a_str);
3160 while(($spos=strpos($a_parstr,
"=")) &&
$ok)
3163 $cpar = substr($a_parstr,0,$spos);
3164 $a_parstr = substr($a_parstr,$spos,strlen($a_parstr)-$spos);
3165 while(substr($cpar,0,1)==
"," ||substr($cpar,0,1)==
" " || substr($cpar,0,1)==chr(13) || substr($cpar,0,1)==chr(10))
3166 $cpar = substr($cpar,1,strlen($cpar)-1);
3167 while(substr($cpar,strlen($cpar)-1,1)==
" " || substr($cpar,strlen($cpar)-1,1)==chr(13) || substr($cpar,strlen($cpar)-1,1)==chr(10))
3168 $cpar = substr($cpar,0,strlen($cpar)-1);
3172 while($cpar != $cpar_old)
3175 $cpar = eregi_replace(
"[^a-zA-Z0-9_]",
"", $cpar);
3181 if($spos=strpos($a_parstr,
"\""))
3183 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos);
3184 $spos=strpos($a_parstr,
"\"");
3187 $cval = substr($a_parstr,0,$spos);
3189 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos-1);
3199 if(
$ok)
return $par;
else return false;
3204 if (is_array($a_par_arr))
3207 foreach ($a_par_arr as $par => $val)
3226 for($i=0; $i<strlen($a_str); $i++)
3228 $ret.= ord(substr($a_str,$i,1)).
" ";
3242 if(strtolower($a_yn) ==
"y")
3282 global $array_sortby,$array_sortorder;
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)
3513 if ($im_types & IMG_JPG)
return "jpg";
3514 if ($im_types & IMG_GIF)
return "gif";
3515 if ($im_types & IMG_PNG)
return "png";
3519 if ($im_types & IMG_GIF)
return "gif";
3520 if ($im_types & IMG_JPG)
return "jpg";
3521 if ($im_types & IMG_PNG)
return "png";
3525 if ($im_types & IMG_PNG)
return "png";
3526 if ($im_types & IMG_JPG)
return "jpg";
3527 if ($im_types & IMG_GIF)
return "gif";
3545 if (($a_mime ==
"image/gif") || ($a_mime ==
"image/jpeg") ||
3546 ($a_mime ==
"image/png") || ($a_mime ==
"application/x-shockwave-flash") ||
3547 ($a_mime ==
"image/tiff") || ($a_mime ==
"image/x-ms-bmp") ||
3548 ($a_mime ==
"image/psd") || ($a_mime ==
"image/iff"))
3568 global
$log, $PHP_SELF;
3571 if (!is_int(strpos($a_script,
"://")))
3573 if (substr($a_script, 0, 1) !=
"/" && defined(
"ILIAS_HTTP_PATH"))
3575 if (is_int(strpos($_SERVER[
"PHP_SELF"],
"/setup/")))
3577 $a_script =
"setup/".$a_script;
3579 $a_script = ILIAS_HTTP_PATH.
"/".$a_script;
3585 global $ilPluginAdmin;
3586 if (is_object($ilPluginAdmin))
3588 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_SERVICE,
"UIComponent",
"uihk");
3589 foreach ($pl_names as $pl)
3592 $gui_class = $ui_plugin->getUIClassInstance();
3593 $resp = $gui_class->getHTML(
"Services/Utilities",
"redirect", array(
"html" => $a_script));
3596 $a_script = $gui_class->modifyHTML($a_script, $resp);
3601 header(
"Location: ".$a_script);
3615 if (substr($a_value, 0, 4) ==
"il__")
3617 $a_value =
"il_".IL_INST_ID.
"_".substr($a_value, 4, strlen($a_value) - 4);
3637 if (empty($a_group_name))
3639 $message = __METHOD__.
": No groupname given!";
3640 $ilErr->raiseError($message,$ilErr->WARNING);
3643 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
3645 $q =
"SELECT obj_id FROM object_data ".
3646 "WHERE title = ".$ilDB->quote($a_group_name,
"text").
" ".
3647 "AND type = ".$ilDB->quote(
"grp",
"text").
3650 $r = $ilDB->query($q);
3675 "FROM object_data ,object_reference ".
3676 "WHERE (".$ilDB->like(
"object_data.title",
"text",
"%".$a_search_str.
"%").
" ".
3677 "OR ".$ilDB->like(
"object_data.description",
"text",
"%".$a_search_str.
"%").
") ".
3678 "AND object_data.type = 'grp' ".
3679 "AND object_data.obj_id = object_reference.obj_id ".
3682 $res = $ilDB->query($q);
3688 $ids[
$row->obj_id] = array(
3689 "ref_id" =>
$row->ref_id,
3690 "title" =>
$row->title,
3691 "description" =>
$row->description);
3694 return $ids ? $ids : array();
3705 $my_pid = getmypid();
3706 return (
"MEMORY USAGE (% KB PID ): ".`ps -eo%mem,rss,pid | grep $my_pid`);
3717 if (strtolower(substr(php_uname(), 0, 3)) ==
"win")
3727 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3729 return escapeshellarg($a_arg);
3743 if(ini_get(
'safe_mode') == 1)
3747 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3748 return escapeshellcmd($a_arg);
3765 $cmd =
'"'.$cmd.
'"';
3770 if (version_compare(phpversion(),
"5.2",
"<") && strpos($args,
'"') !==
false)
3772 $cmd =
'"'.$cmd.
" ".$args.
'"';
3813 public static function excelTime($year =
"", $month =
"", $day =
"", $hour =
"", $minute =
"", $second =
"")
3815 $starting_time = mktime(0, 0, 0, 1, 2, 1970);
3816 if (strcmp(
"$year$month$day$hour$minute$second",
"") == 0)
3818 $target_time = time();
3827 $target_time = mktime($hour, $minute, $second, $month, $day, $year);
3828 $difference = $target_time - $starting_time;
3829 $days = (($difference - ($difference % 86400)) / 86400);
3830 $difference = $difference - ($days * 86400) + 3600;
3831 return ($days + 25570 + ($difference / 86400));
3842 $def_arr = explode(
",", SUFFIX_REPL_DEFAULT);
3843 foreach ($def_arr as $def)
3848 $def_arr = explode(
",", SUFFIX_REPL_ADDITIONAL);
3849 foreach ($def_arr as $def)
3869 if ($a_dir ==
"/" || $a_dir ==
"" || is_int(strpos($a_dir,
".."))
3870 || trim($a_old_suffix) ==
"")
3876 if (!@is_dir($a_dir))
3882 $dir = opendir($a_dir);
3886 if (
$file !=
"." and
3890 if (@is_dir($a_dir.
"/".
$file))
3896 if (@is_file($a_dir.
"/".
$file))
3899 if(strrpos(
$file,
'.') == (strlen(
$file) - 1))
3901 rename($a_dir.
'/'.
$file,substr($a_dir.
'/'.
$file,0,-1));
3905 $path_info = pathinfo($a_dir.
"/".
$file);
3907 if (strtolower($path_info[
"extension"]) ==
3908 strtolower($a_old_suffix))
3910 $pos = strrpos($a_dir.
"/".
$file,
".");
3911 $new_name = substr($a_dir.
"/".
$file, 0, $pos).
".".$a_new_suffix;
3912 rename($a_dir.
"/".
$file, $new_name);
3921 return strpos($_SERVER[
"SCRIPT_FILENAME"],
"api") !==
false ||
3922 strpos($_SERVER[
"SCRIPT_FILENAME"],
"dummy") !==
false;
3926 if (preg_match(
"/&" . $paramName .
"=/", $qstring)) {
3927 return preg_replace(
"/&" . $paramName .
"=[^&]+/",
"&" . $paramName .
"=" . urlencode($paramValue), $qstring);
3929 return $qstring .
"&" . $paramName .
"=" . urlencode($paramValue);
3935 foreach ($parametersArray as $paramName => $paramValue ) {
3950 srand((
double) microtime()*1000000);
3952 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
3955 for ($i=1; $i<=$a_number; $i++)
3957 $min = ($security->getPasswordMinLength() > 0)
3958 ? $security->getPasswordMinLength()
3960 $max = ($security->getPasswordMaxLength() > 0)
3961 ? $security->getPasswordMaxLength()
3967 $length = rand($min,$max);
3970 $consonants =
"bcdfghjklmnpqrstvwxyz";
3971 $numbers =
"1234567890";
3972 $special =
"_.+?#-*@!$%~";
3976 if ($security->isPasswordCharsAndNumbersEnabled())
3978 $num_pos = rand(0, $length - 1);
3982 if ($security->isPasswordSpecialCharsEnabled())
3984 $spec_pos = rand(0, $length - 1);
3985 if ($security->isPasswordCharsAndNumbersEnabled())
3987 if ($num_pos == $spec_pos)
4000 for ($j=0; $j < $length; $j++)
4002 if ($security->isPasswordCharsAndNumbersEnabled() && $num_pos == $j)
4004 $pw.= $numbers[rand(0,strlen($numbers)-1)];
4006 else if ($security->isPasswordSpecialCharsEnabled() && $spec_pos == $j)
4008 $pw.= $special[rand(0,strlen($special)-1)];
4015 $pw.= $consonants[rand(0,strlen($consonants)-1)];
4020 $pw.= $vowels[rand(0,strlen($vowels)-1)];
4034 $path = preg_replace(
"/[\/\\\]+$/",
"",
$path);
4055 foreach(
$data as $k=>$datum)
4057 if(is_null($datum))
$data[$k] =
'null';
4058 if(is_string($datum))
$data[$k] =
"'" . $datum .
"'";
4062 return "[" . implode(
', ',
$data) .
"]";
4071 public static function virusHandling($a_file, $a_orig_name =
"", $a_clean =
true)
4075 if (IL_VIRUS_SCANNER !=
"None")
4077 require_once(
"classes/class.ilVirusScannerFactory.php");
4079 if (($vs_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
4081 if ($a_clean && (IL_VIRUS_CLEAN_COMMAND !=
""))
4083 $clean_txt = $vs->cleanFile($a_file, $a_orig_name);
4084 if ($vs->fileCleaned())
4086 $vs_txt.=
"<br />".$lng->txt(
"cleaned_file").
4087 "<br />".$clean_txt;
4088 $vs_txt.=
"<br />".$lng->txt(
"repeat_scan");
4089 if (($vs2_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
4091 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_failed").
4092 "<br />".nl2br($vs2_txt));
4096 return array(
true, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_succeded"));
4101 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"cleaning_failed"));
4106 return array(
false, nl2br($vs_txt));
4111 return array(
true,
"");
4122 $a_mode =
"move_uploaded")
4124 global
$lng, $ilias;
4127 if (!is_file($a_file))
4129 if ($a_raise_errors)
4131 $ilias->raiseError($lng->txt(
"upload_error_file_not_found"), $ilias->error_obj->MESSAGE);
4145 if ($a_raise_errors)
4147 $ilias->raiseError($lng->txt(
"file_is_infected").
"<br />".
4149 $ilias->error_obj->MESSAGE);
4167 return rename($a_file, $a_target);
4171 return copy($a_file, $a_target);
4175 return move_uploaded_file($a_file, $a_target);
4189 list($datum, $uhrzeit) = explode (
" ",$mysql_date_time);
4190 list($jahr, $monat, $tag) = explode(
"-", $datum);
4191 list($std, $min, $sec) = explode(
":", $uhrzeit);
4192 return mktime ((
int) $std, (
int) $min, (
int) $sec, (
int) $monat, (
int) $tag, (
int) $jahr);
4203 return date(
"Y-m-d H:i:s");
4223 $resultarray = array();
4224 foreach (
$row as $rowindex => $entry)
4231 if (strpos($entry,
"\"") !== FALSE)
4233 $entry = str_replace(
"\"",
"\"\"", $entry);
4240 if ($compatibleWithMSExcel)
4243 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
4249 $resultarray[$rowindex] =
"\"" . $entry .
"\"";
4253 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
4260 $resultarray[$rowindex] = $entry;
4264 $resultarray[$rowindex] = utf8_decode($entry);
4268 return $resultarray;
4272 public static function isDN($a_str)
4274 return(preg_match(
"/^[a-z]+([a-z0-9-]*[a-z0-9]+)?(\.([a-z]+([a-z0-9-]*[a-z0-9]+)?)+)*$/",$a_str));
4280 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])\.".
4281 "(\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));
4315 global
$ilDB,$rbacreview,$ilAccess,$ilUser,$ilias,$tree;
4317 if(!is_array($a_obj_type))
4319 $where =
"WHERE type = ".$ilDB->quote($a_obj_type,
"text").
" ";
4323 $where =
"WHERE ".$ilDB->in(
"type", $a_obj_type,
false,
"text").
" ";
4329 $limit = $ilias->getSetting(
'search_max_hits',100);
4337 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
4338 $a_roles = $rbacreview->assignedRoles($a_usr_id);
4342 if($rbacreview->isAssigned($a_usr_id,SYSTEM_ROLE_ID))
4344 $query =
"SELECT ref_id FROM object_reference obr LEFT JOIN object_data obd ON obr.obj_id = obd.obj_id ".
4345 "LEFT JOIN tree ON obr.ref_id = tree.child ".
4351 while(
$row = $ilDB->fetchObject(
$res))
4354 if($tree->isGrandChild(RECOVERY_FOLDER_ID,
$row->ref_id))
4359 if($counter++ >= $limit)
4364 $ref_ids[] =
$row->ref_id;
4366 return $ref_ids ? $ref_ids : array();
4370 if($a_operation ==
'edit_permissions' or strpos($a_operation,
'create') !==
false)
4372 $check_owner =
") ";
4376 $check_owner =
"OR owner = ".$ilDB->quote($a_usr_id,
"integer").
") ";
4380 $ops_id = $ops_ids[0];
4382 $and =
"AND ((".$ilDB->in(
"rol_id", $a_roles,
false,
"integer").
" ";
4384 $query =
"SELECT DISTINCT(obr.ref_id),obr.obj_id,type FROM object_reference obr ".
4385 "JOIN object_data obd ON obd.obj_id = obr.obj_id ".
4386 "LEFT JOIN rbac_pa ON obr.ref_id = rbac_pa.ref_id ".
4389 "AND (".$ilDB->like(
"ops_id",
"text",
"%i:".$ops_id.
"%").
" ".
4390 "OR ".$ilDB->like(
"ops_id",
"text",
"%:\"".$ops_id.
"\";%").
")) ".
4397 if($counter >= $limit)
4403 if($tree->isGrandChild(RECOVERY_FOLDER_ID,
$row->ref_id))
4409 if($ilAccess->checkAccessOfUser($a_usr_id,$a_operation,
'',
$row->ref_id,
$row->type,
$row->obj_id))
4412 $ref_ids[] =
$row->ref_id;
4415 return $ref_ids ? $ref_ids : array();
4427 public static function insertLatexImages($a_text, $a_start =
"\[tex\]", $a_end =
"\[\/tex\]", $a_cgi = URL_TO_LATEX)
4432 include_once
"./Services/Administration/classes/class.ilSetting.php";
4433 $jsMathSetting =
new ilSetting(
"jsMath");
4435 $jsMathSetting->get(
"enable") && ($ilUser->getPref(
"js_math") || ($ilUser->getPref(
"js_math") === FALSE && ($jsMathSetting->get(
"makedefault"))));
4440 if (!$tpl->out_jsmath_info)
4442 include_once
"./classes/class.ilTemplate.php";
4443 $template =
new ilTemplate(
"tpl.jsmath_warning.html", TRUE, TRUE);
4444 $lng->loadLanguageModule(
"jsmath");
4445 $template->setVariable(
"TEXT_JSMATH_NO_JAVASCRIPT", $lng->txt(
"jsmath_no_javascript"));
4446 $info = $template->get();
4447 $tpl->out_jsmath_info = TRUE;
4449 $a_text = preg_replace(
"/\\\\([RZN])([^a-zA-Z]|<\/span>)/",
"\\mathbb{".
"$1".
"}".
"$2", $a_text);
4450 $tpl->addJavaScript($jsMathSetting->get(
"path_to_jsmath") .
"/easy/load.js");
4455 $o_start = $a_start;
4457 $a_start = str_replace(
"\\",
"", $a_start);
4458 $a_end = str_replace(
"\\",
"", $a_end);
4465 while (is_int($spos = stripos($a_text, $a_start, $cpos)))
4467 if (is_int ($epos = stripos($a_text, $a_end, $spos + 1)))
4469 $tex = substr($a_text, $spos + strlen($a_start), $epos - $spos - strlen($a_start));
4472 if (!is_int(strpos($tex,
"</div>")))
4476 $a_text = substr($a_text, 0, $spos).
4477 "<img alt=\"".htmlentities($tex).
"\" src=\"".$a_cgi.
"?".
4478 rawurlencode(str_replace(
'&',
'&', str_replace(
'>',
'>', str_replace(
'<',
'<', $tex)))).
"\" ".
4480 substr($a_text, $epos + strlen($a_end));
4484 $tex = $a_start.$tex.$a_end;
4487 preg_replace(
'/' . $o_start .
'(.*?)' . $o_end .
'/ie',
4488 "'<span class=\"math\">' . preg_replace('/[\\\\\\\\\\]{2}/', '\\cr', str_replace('<', '<', str_replace('<br/>', '', str_replace('<br />', '', str_replace('<br>', '', '$1'))))) . '</span>[[info]]'", $tex);
4491 $a_text = substr($a_text, 0, $spos).
4493 substr($a_text, $epos + strlen($a_end));
4502 $a_text = str_replace(
"[[info]]", $info, $a_text);
4505 $result_text = $a_text;
4513 return $result_text;
4525 public static function __insertLatexImages($a_text, $a_start =
"\[tex\]", $a_end =
"\[\/tex\]", $a_cgi = URL_TO_LATEX)
4533 include_once
"./Services/Administration/classes/class.ilSetting.php";
4534 $jsMathSetting =
new ilSetting(
"jsMath");
4535 if ($jsMathSetting->get(
"enable") && ($ilUser->getPref(
"js_math") || ($ilUser->getPref(
"js_math") === FALSE && ($jsMathSetting->get(
"makedefault")))))
4538 if (!$tpl->out_jsmath_info)
4540 include_once
"./classes/class.ilTemplate.php";
4541 $template =
new ilTemplate(
"tpl.jsmath_warning.html", TRUE, TRUE);
4542 $lng->loadLanguageModule(
"jsmath");
4543 $template->setVariable(
"TEXT_JSMATH_NO_JAVASCRIPT", $lng->txt(
"jsmath_no_javascript"));
4544 $info = $template->get();
4545 $tpl->out_jsmath_info = TRUE;
4547 $a_text = preg_replace(
"/\\\\([RZN])([^a-zA-Z]|<\/span>)/",
"\\mathbb{".
"$1".
"}".
"$2", $a_text);
4548 $result_text = preg_replace(
'/' . $a_start .
'(.*?)' . $a_end .
'/ie',
4549 "'<span class=\"math\">' . preg_replace('/[\\\\\\\\\\]{2}/', '\\cr', str_replace('<', '<', str_replace('<br/>', '', str_replace('<br />', '', str_replace('<br>', '', '$1'))))) . '</span>[[info]]'", $a_text);
4551 $result_text = str_replace(
"[[info]]", $info, $result_text);
4552 $tpl->addJavaScript($jsMathSetting->get(
"path_to_jsmath") .
"/easy/load.js");
4556 $result_text = preg_replace(
'/' . $a_start .
'(.*?)' . $a_end .
'/ie',
4557 "'<img alt=\"'.htmlentities('$1').'\" src=\"$a_cgi?'.rawurlencode(str_replace('&', '&', str_replace('>', '>', str_replace('<', '<', '$1')))).'\" ".
4561 return $result_text;
4573 public static function buildLatexImages($a_text, $a_dir ,$a_start =
"\[tex\]", $a_end =
"\[\/tex\]", $a_cgi = URL_TO_LATEX)
4575 $result_text = $a_text;
4579 while (preg_match(
'/' . $a_start .
'(.*?)' . $a_end .
'/ie', $result_text, $found))
4581 $cnt = (int)
$GLOBALS[
"teximgcnt"]++;
4583 $fpr = @fopen($a_cgi.
"?".rawurlencode($found[1]),
"r");
4589 $buf = fread($fpr, 1024);
4592 if (is_int(strpos(strtoupper(substr($buf, 0, 5)),
"GIF")))
4600 $fpw = fopen($a_dir.
"/teximg/img".$cnt.
".".$suffix,
"w");
4610 $img_str =
"./teximg/img".$cnt.
".".$suffix;
4611 $result_text = str_replace($found[0],
4612 '<img alt="'.$found[1].
'" src="'.$img_str.
'" />', $result_text);
4616 return $result_text;
4630 $is_html = $this->isHTML(
$result);
4632 if ($prepare_for_latex_output)
4647 if (preg_match_all(
"/(<pre>.*?<\/pre>)/ims",
$result, $matches))
4649 foreach ($matches[0] as $found)
4652 if (strpos(
"\n", $found) === FALSE)
4654 $replacement =
"\n";
4656 $removed = preg_replace(
"/<br\s*?\/>/ims", $replacement, $found);
4661 if ($prepare_for_latex_output)
4681 public static function int2array ($seconds, $periods = null)
4684 if (!is_array($periods))
4687 'years' => 31536000,
4688 'months' => 2592000,
4697 $seconds = (float) $seconds;
4698 foreach ($periods as $period => $value)
4700 $count = floor($seconds / $value);
4707 $values[$period] = $count;
4708 $seconds = $seconds % $value;
4731 if (!is_array($duration))
4736 foreach ($duration as $key => $value) {
4741 $segment_name = $key;
4742 $segment_name = $lng->txt($segment_name);
4743 $segment = $value .
' ' . $segment_name;
4747 $segment_name = substr($key, 0, -1);
4748 $segment_name = $lng->txt($segment_name);
4749 $segment = $value .
' ' . $segment_name;
4752 $array[] = $segment;
4754 $len = count($array);
4758 $array=array_slice($array,0,(3-$len));
4761 $str = implode(
', ', $array);
4771 $umf=get_cfg_var(
"upload_max_filesize");
4773 $pms=get_cfg_var(
"post_max_size");
4776 $max_filesize=min($umf, $pms);
4777 if (!$max_filesize) $max_filesize=max($umf, $pms);
4779 return $lng->txt(
"file_notice").
" $max_filesize.";
4793 $test_str = explode(
'_',$role_title);
4795 if ($test_str[0] ==
'il')
4797 $test2 = (int) $test_str[3];
4798 return is_numeric ($test2) ? (int) $test2 :
false;
4816 $test_str = explode(
'_',$ilias_id);
4818 if ($test_str[0] ==
'il' && $test_str[1] == $inst_id && count($test_str) == 4)
4820 $test2 = (int) $test_str[3];
4821 return is_numeric ($test2) ? (int) $test2 :
false;
4840 public static function _sortIds($a_ids,$a_table,$a_field,$a_id_name)
4850 $where =
"WHERE ".$a_id_name.
" IN (";
4854 $query =
"SELECT ".$a_id_name.
" FROM ".$a_table.
" ".
4856 "ORDER BY ".$a_field;
4861 $ids[] =
$row->$a_id_name;
4863 return $ids ? $ids : array();
4893 if(!is_array($a_array) or !count($a_array))
4898 foreach($a_array as $k => $item)
4900 $a_array[$k] = $ilDB->quote($item);
4914 public static function sendInfo($a_info =
"",$a_keep =
false)
4917 $tpl->setMessage(
"info", $a_info, $a_keep);
4931 $tpl->setMessage(
"failure", $a_info, $a_keep);
4943 $tpl->setMessage(
"question", $a_info, $a_keep);
4957 $tpl->setMessage(
"success", $a_info, $a_keep);
4966 $tpl->addBlockFile(
"INFOPANEL",
"infopanel",
"tpl.infopanel.html");
4967 $tpl->setCurrentBlock(
"infopanel");
4969 if (!empty(
$_SESSION[
"infopanel"][
"text"]))
4971 $link =
"<a href=\"".$dir.$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4974 $link .= $lng->txt(
$_SESSION[
"infopanel"][
"text"]);
4979 if (!empty(
$_SESSION[
"infopanel"][
"img"]))
4981 $link .=
"<td><a href=\"".$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4984 $link .=
"<img src=\"".$ilias->tplPath.$ilias->account->prefs[
"skin"].
"/images/".
4985 $_SESSION[
"infopanel"][
"img"].
"\" border=\"0\" vspace=\"0\"/>";
4986 $link .=
"</a></td>";
4989 $tpl->setVariable(
"INFO_ICONS",$link);
4990 $tpl->parseCurrentBlock();
5012 if (!is_dir($directory))
5016 $size = @filesize($directory);
5020 if ($DIR = opendir($directory))
5022 while (($dirfile = readdir($DIR)) !==
false)
5024 if (is_link($directory . DIRECTORY_SEPARATOR . $dirfile) || $dirfile ==
'.' || $dirfile ==
'..')
5026 if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile))
5027 $size += filesize($directory . DIRECTORY_SEPARATOR . $dirfile);
5028 else if (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile))
5031 $dirSize =
ilUtil::dirsize($directory . DIRECTORY_SEPARATOR . $dirfile);
5045 return md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
5048 public static function setCookie($a_cookie_name,$a_cookie_value =
'', $a_also_set_super_global =
true, $a_set_cookie_invalid =
false)
5055 if(!(
bool)$a_set_cookie_invalid) $expire = 0;
5056 else $expire = time() - (365*24*60*60);
5060 if( version_compare(PHP_VERSION,
'5.2.0',
'>=') )
5063 setcookie( $a_cookie_name, $a_cookie_value, $expire,
5064 IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE, IL_COOKIE_HTTPONLY
5070 setcookie( $a_cookie_name, $a_cookie_value, $expire,
5075 if((
bool)$a_also_set_super_global)
$_COOKIE[$a_cookie_name] = $a_cookie_value;
5080 return strip_tags(self::stripSlashes($a_filename));
5087 if($_SERVER[
'SHELL'])
5089 return $ilIliasIniFile->readVariable(
'server',
'http_path');
5093 return ILIAS_HTTP_PATH;
5107 $bt = debug_backtrace();
5110 echo
"<br>".$t[
"file"].
", ".$t[
"function"].
" [".$t[
"line"].
"]";
5130 $exploded = explode(
'_'.$a_import_id);
5132 $parsed[
'orig'] = $a_import_id;
5133 if($exploded[0] ==
'il')
5135 $parsed[
'prefix'] = $exploded[0];
5137 if(is_numeric($exploded[1]))
5139 $parsed[
'inst_id'] = (int) $exploded[1];
5141 $parsed[
'type'] = $exploded[2];
5143 if(is_numeric($exploded[3]))
5145 $parsed[
'id'] = (int) $exploded[3];