56 return "<img src=\"".ilUtil::getImagePath(
$filename).
"\" alt=\"".$lng->txt(
"obj_".$a_type).
"\" title=\"".$lng->txt(
"obj_".$a_type).
"\" border=\"0\" vspace=\"0\"/>";
75 if($ilSetting->get(
"custom_icons"))
82 include_once(
'./Services/Container/classes/class.ilContainer.php');
115 global $ilias, $styleDefinition,
$ilCtrl;
117 if ($module_path !=
"")
119 $module_path =
"/".$module_path;
123 $default_img =
".".$module_path.
"/templates/default/images/".
$img;
125 if (is_object($styleDefinition))
127 $image_dir = $styleDefinition->getImageDirectory($ilias->account->prefs[
"style"]);
129 if ($ilUser->skin ==
"default")
131 $user_img =
".".$module_path.
"/templates/default/".$image_dir.
"/".
$img;
132 $skin_img =
".".$module_path.
"/templates/default/images/".
$img;
134 else if (is_object($styleDefinition) && $ilUser->skin !=
"default")
136 $user_img =
"./Customizing/global/skin/".
137 $ilias->account->skin.$module_path.
"/".$image_dir.
"/".
$img;
138 $skin_img =
"./Customizing/global/skin/".
139 $ilias->account->skin.$module_path.
"/images/".
$img;
144 return "./images/".$img;
146 else if (@file_exists($user_img) && $image_dir !=
"")
150 else if (file_exists($skin_img))
168 if (substr($relative_path, 0, 2) ==
'./')
170 $relative_path = (substr($relative_path, 1));
172 if (substr($relative_path, 0, 1) !=
'/')
174 $relative_path =
'/' . $relative_path;
176 $htmlpath = ILIAS_HTTP_PATH . $relative_path;
195 $stylesheet_name = (strlen($a_css_name)) ? $a_css_name : $ilias->account->prefs[
"style"].
".css";
196 if (strlen($a_css_location) && (strcmp(substr($a_css_location, -1),
"/") != 0)) $a_css_location = $a_css_location .
"/";
199 if ($ilias->account->skin !=
"default")
201 $filename =
"./Customizing/global/skin/".$ilias->account->skin.
"/".$a_css_location.$stylesheet_name;
205 $filename =
"./" . $a_css_location .
"templates/default/".$stylesheet_name;
208 if ($mode !=
"filesystem")
210 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
211 $vers =
"?vers=".str_replace(
".",
"-", $vers);
224 function getJSLocation($a_js_name, $a_js_location =
"", $add_version = FALSE)
229 $js_name = $a_js_name;
230 if (strlen($a_js_location) && (strcmp(substr($a_js_location, -1),
"/") != 0)) $a_js_location = $a_js_location .
"/";
233 if ($ilias->account->skin !=
"default")
235 $filename =
"./Customizing/global/skin/".$ilias->account->skin.
"/".$a_js_location.$js_name;
239 $filename =
"./" . $a_js_location .
"templates/default/".$js_name;
244 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
245 $vers =
"?vers=".str_replace(
".",
"-", $vers);
259 if (defined(
"ILIAS_MODULE"))
264 $base .=
"../Services/Privacy/";
269 $base =
"./Services/Privacy/";
272 if (is_file($base.
"w3c/p3p.xml"))
274 return ILIAS_HTTP_PATH.
"w3c/p3p.xml";
278 return ILIAS_HTTP_PATH.
"/w3c/p3p_template.xml";
292 if ($mode !=
"filesystem")
294 $vers = str_replace(
" ",
"-", $ilias->getSetting(
"ilias_version"));
295 $vers =
"?vers=".str_replace(
".",
"-", $vers);
298 if ($ilias->account->skin ==
"default")
300 $in_style =
"./templates/".$ilias->account->skin.
"/".$ilias->account->prefs[
"style"].
"_cont.css";
304 $in_style =
"./Customizing/global/skin/".$ilias->account->skin.
"/".$ilias->account->prefs[
"style"].
"_cont.css";
307 if (is_file(
"./".$in_style))
309 return $base.$in_style.$vers;
313 return $base.
"templates/default/delos_cont.css".$vers;
333 function formSelect($selected,$varname,$options,$multiple =
false,$direct_text =
false,
$size =
"0",
334 $style_class =
"", $attribs =
"",$disabled =
false)
338 if ($multiple ==
true)
340 $multiple =
" multiple=\"multiple\"";
348 if ($style_class !=
"")
350 $class =
" class=\"".$style_class.
"\"";
357 if (is_array($attribs))
359 foreach ($attribs as $key => $val)
361 $attributes .=
" ".$key.
"=\"".$val.
"\"";
366 $disabled =
' disabled=\"disabled\"';
369 $str =
"<select name=\"".$varname .
"\"".$multiple.
" $class size=\"".
$size.
"\" $attributes $disabled>\n";
371 foreach ($options as $key => $val)
375 $str .=
" <option value=\"".$key.
"\"";
379 $str .=
" <option value=\"".$val.
"\"";
381 if (is_array($selected) )
383 if (in_array($key,$selected))
385 $str .=
" selected=\"selected\"";
388 else if ($selected == $key)
390 $str .=
" selected=\"selected\"";
395 $str .=
">".$val.
"</option>\n";
399 $str .=
">".$lng->txt($val).
"</option>\n";
403 $str .=
"</select>\n";
417 return($values[$selected]);
431 $str =
"<input type=\"checkbox\" name=\"".$varname.
"\"";
435 $str .=
" checked=\"checked\"";
440 $str .=
" disabled=\"disabled\"";
445 if (substr($varname,-2) ==
"[]")
453 $varname_id = substr($varname,0,-2).
"_".$value;
457 $varname_id = $varname;
461 $varname_id = ereg_replace(
"\[",
"_",$varname_id);
462 $varname_id = ereg_replace(
"\]",
"",$varname_id);
464 $str .=
" value=\"".$value.
"\" id=\"".$varname_id.
"\" />\n";
481 $str =
"<input disabled type=\"radio\" name=\"".$varname.
"\"";
484 $str =
"<input type=\"radio\" name=\"".$varname.
"\"";
488 $str .=
" checked=\"checked\"";
491 $str .=
" value=\"".$value.
"\"";
492 $str .=
" id=\"".$value.
"\" />\n";
509 $str =
"<input type=\"radio\" name=\"".$varname.
"\"";
512 $str .=
" checked=\"checked\"";
515 $str .=
" value=\"".$value.
"\"";
517 $str .=
" id=\"".$value.
"\" />\n";
534 $str =
"<input type=\"input\" name=\"".$varname.
"\"";
540 $str .=
" value=\"".$value.
"\"";
542 $str .=
" id=\"".$value.
"\" />\n";
565 if (
"" != $a_path &&
"/" != substr($a_path, -1))
610 $tpltab =
new ilTemplate(
"tpl.tabs.html",
true,
true);
612 for ($i=1; $i<=4; $i++)
614 $tpltab->setCurrentBlock(
"tab");
617 $tabtype =
"tabactive";
622 $tabtype =
"tabinactive";
629 $txt = $lng->txt(
"view_content");
632 $txt = $lng->txt(
"edit_properties");
635 $txt = $lng->txt(
"perm_settings");
638 $txt = $lng->txt(
"show_owner");
641 $tpltab->setVariable(
"CONTENT", $txt);
642 $tpltab->setVariable(
"TABTYPE", $tabtype);
643 $tpltab->setVariable(
"TAB",
$tab);
644 $tpltab->setVariable(
"LINK", $a_o[
"LINK".$i]);
645 $tpltab->parseCurrentBlock();
648 return $tpltab->get();
664 foreach ($emptyFields as $key => $val)
667 if ($feedback !=
"") $feedback .=
", ";
697 function Linkbar ($AScript,$AHits,$ALimit,$AOffset,$AParams = array(),$ALayout = array(), $prefix =
'')
702 $layout_prev =
"<<";
703 $layout_next =
">>";
706 if (count($ALayout > 0))
708 if ($ALayout[
"link"])
710 $layout_link =
" class=\"".$ALayout[
"link"].
"\"";
713 if ($ALayout[
"prev"])
715 $layout_prev = $ALayout[
"prev"];
718 if ($ALayout[
"next"])
720 $layout_next = $ALayout[
"next"];
726 if ($AHits > $ALimit || $AOffset > 0)
728 if (!empty($AParams))
730 foreach ($AParams as $key => $value)
732 $params.= $key.
"=".$value.
"&";
736 if(strpos($AScript,
'&'))
738 $link = $AScript.
"&".$params.$prefix.
"offset=";
742 $link = $AScript.
"?".$params.$prefix.
"offset=";
748 $prevoffset = $AOffset - $ALimit;
749 if ($prevoffset < 0) $prevoffset = 0;
750 $LinkBar .=
"<a".$layout_link.
" href=\"".$link.$prevoffset.
"\">".$layout_prev.
" </a>";
754 $pages=intval($AHits/$ALimit);
757 if (($AHits % $ALimit))
764 for ($i = 1 ;$i <= $pages ; $i++)
766 $newoffset=$ALimit*($i-1);
768 if ($newoffset == $AOffset)
770 $LinkBar .=
"[".$i.
"] ";
774 $LinkBar .=
'<a '.$layout_link.
' href="'.
775 $link.$newoffset.
'">['.$i.
']</a> ';
782 if (! ( ($AOffset/$ALimit)==($pages-1) ) && ($pages!=1) )
784 $newoffset=$AOffset+$ALimit;
785 $LinkBar .=
"<a".$layout_link.
" href=\"".$link.$newoffset.
"\"> ".$layout_next.
"</a>";
811 $ret = eregi_replace(
"(^|[[:space:]]+)(www\.)([[:alnum:]#?/&=\.-]+)",
812 "\\1http://\\2\\3",
$ret);
815 $ret = eregi_replace(
"(^|[[:space:]]+)(ftp\.)([[:alnum:]#?/&=\.-]+)",
816 "\\1ftp://\\2\\3",
$ret);
822 include_once(
"./Services/Utilities/classes/class.ilMWParserAdapter.php");
824 $ret = $parser->replaceFreeExternalLinks(
$ret);
850 if ($detectGotoLinks)
853 $regExp =
"<a[^>]*href=\"(".str_replace(
"/",
"\/",ILIAS_HTTP_PATH).
"\/goto.php\?target=\w+_(\d+)[^\"]*)\"[^>]*>[^<]*<\/a>";
855 $ret = preg_replace_callback(
857 array(
"ilUtil",
"replaceLinkProperties"),
861 $regExp =
"<a[^>]*href=\"(".str_replace(
"/",
"\/",ILIAS_HTTP_PATH).
"\/goto_.*[a-z0-9]+_([0-9]+)\.html)\"[^>]*>[^<]*<\/a>";
863 $ret = preg_replace_callback(
865 array(
"ilUtil",
"replaceLinkProperties"),
894 $link =
"<a href=".$matches[1].
" target=\"_self\">".
$title.
"</a>";
918 $m = explode(
" ",microtime());
945 function makeDateSelect($prefix, $year =
"", $month =
"", $day =
"", $startyear =
"",$a_long_month =
true,$a_further_options = array())
950 if(isset($a_further_options[
'disabled']) and $a_further_options[
'disabled'])
952 $disabled =
'disabled="disabled" ';
956 if (!strlen($year)) $year = $now[
"year"];
957 if (!strlen($month)) $month = $now[
"mon"];
958 if (!strlen($day)) $day = $now[
"mday"];
961 $month = (int) $month;
965 $sel_day .=
"<select ".$disabled.
"name=\"".$prefix.
"[d]\" id=\"".$prefix.
"_d\">\n";
967 for ($i = 1; $i <= 31; $i++)
969 $sel_day .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
971 $sel_day .=
"</select>\n";
972 $sel_day = preg_replace(
"/(value\=\"$day\")/",
"$1 selected=\"selected\"", $sel_day);
975 $sel_month .=
"<select ".$disabled.
"name=\"".$prefix.
"[m]\" id=\"".$prefix.
"_m\">\n";
977 for ($i = 1; $i <= 12; $i++)
981 $sel_month .=
"<option value=\"$i\">" . $lng->txt(
"month_" . sprintf(
"%02d", $i) .
"_long") .
"</option>\n";
985 $sel_month .=
"<option value=\"$i\">" . $i .
"</option>\n";
988 $sel_month .=
"</select>\n";
989 $sel_month = preg_replace(
"/(value\=\"$month\")/",
"$1 selected=\"selected\"", $sel_month);
992 $sel_year .=
"<select ".$disabled.
"name=\"".$prefix.
"[y]\" id=\"".$prefix.
"_y\">\n";
993 if ((strlen($startyear) == 0) || ($startyear > $year))
995 $startyear = $year - 5;
998 if(($year + 5) < (date(
'Y',time()) + 5))
1000 $end_year = date(
'Y',time()) + 5;
1004 $end_year = $year + 5;
1007 for ($i = $startyear; $i <= $end_year; $i++)
1009 $sel_year .=
"<option value=\"$i\">" . sprintf(
"%04d", $i) .
"</option>\n";
1011 $sel_year .=
"</select>\n";
1012 $sel_year = preg_replace(
"/(value\=\"$year\")/",
"$1 selected=\"selected\"", $sel_year);
1015 $dateformat =
"d-m-Y";
1016 $dateformat = strtolower(preg_replace(
"/\W/",
"", $dateformat));
1017 $dateformat = strtolower(preg_replace(
"/(\w)/",
"%%$1", $dateformat));
1018 $dateformat = preg_replace(
"/%%d/", $sel_day, $dateformat);
1019 $dateformat = preg_replace(
"/%%m/", $sel_month, $dateformat);
1020 $dateformat = preg_replace(
"/%%y/", $sel_year, $dateformat);
1040 function makeTimeSelect($prefix, $short =
true, $hour =
"", $minute =
"", $second =
"",$a_use_default =
true,$a_further_options = array())
1046 if(count($a_further_options))
1048 if(isset($a_further_options[
'minute_steps']))
1050 $minute_steps = $a_further_options[
'minute_steps'];
1052 if(isset($a_further_options[
'disabled']) and $a_further_options[
'disabled'])
1054 $disabled =
'disabled="disabled" ';
1058 if ($a_use_default and !strlen(
"$hour$minute$second")) {
1065 $minute = (int)$minute;
1066 $second = (int)$second;
1069 $sel_hour .=
"<select ".$disabled.
"name=\"".$prefix.
"[h]\" id=\"".$prefix.
"_h\">\n";
1071 for ($i = 0; $i <= 23; $i++)
1073 $sel_hour .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1075 $sel_hour .=
"</select>\n";
1076 $sel_hour = preg_replace(
"/(value\=\"$hour\")/",
"$1 selected=\"selected\"", $sel_hour);
1079 $sel_minute .=
"<select ".$disabled.
"name=\"".$prefix.
"[m]\" id=\"".$prefix.
"_m\">\n";
1081 for ($i = 0; $i <= 59; $i = $i + $minute_steps)
1083 $sel_minute .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1085 $sel_minute .=
"</select>\n";
1086 $sel_minute = preg_replace(
"/(value\=\"$minute\")/",
"$1 selected=\"selected\"", $sel_minute);
1090 $sel_second .=
"<select ".$disabled.
"name=\"".$prefix.
"[s]\" id=\"".$prefix.
"_s\">\n";
1092 for ($i = 0; $i <= 59; $i++)
1094 $sel_second .=
"<option value=\"$i\">" . sprintf(
"%02d", $i) .
"</option>\n";
1096 $sel_second .=
"</select>\n";
1097 $sel_second = preg_replace(
"/(value\=\"$second\")/",
"$1 selected=\"selected\"", $sel_second);
1099 $timeformat = $lng->text[
"lang_timeformat"];
1100 if (strlen($timeformat) == 0) $timeformat =
"H:i:s";
1101 $timeformat = strtolower(preg_replace(
"/\W/",
"", $timeformat));
1102 $timeformat = preg_replace(
"/(\w)/",
"%%$1", $timeformat);
1103 $timeformat = preg_replace(
"/%%h/", $sel_hour, $timeformat);
1104 $timeformat = preg_replace(
"/%%i/", $sel_minute, $timeformat);
1106 $timeformat = preg_replace(
"/%%s/",
"", $timeformat);
1108 $timeformat = preg_replace(
"/%%s/", $sel_second, $timeformat);
1131 $successfulInclude = @include_once (
'Services/Mail/classes/class.ilMail.php');
1137 require_once
'Mail/RFC822.php';
1138 $parser = &
new Mail_RFC822();
1139 PEAR::setErrorHandling(PEAR_ERROR_EXCEPTION);
1141 $addresses = $parser->parseAddressList($a_email,
'ilias',
false,
true);
1142 if (! is_a($addresses,
'PEAR_Error') &&
1143 count($addresses) == 1 && $addresses[0]->host !=
'ilias')
1145 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr,
"errorHandler"));
1149 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr,
"errorHandler"));
1152 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr,
"errorHandler"));
1158 "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|".
1159 "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|".
1160 "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|".
1161 "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|".
1162 "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|".
1163 "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|".
1164 "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|".
1165 "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|".
1166 "WF|WS|XN|YE|YT|YU|ZA|ZM|ZW");
1168 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));
1182 $a_custom_error =
'';
1185 include_once(
'./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1192 if( $a_passwd ==
'' )
1194 $custom_error = $lng->txt(
'password_empty');
1198 if( $security->getPasswordMinLength() > 0 &&
1199 strlen($a_passwd) < $security->getPasswordMinLength() )
1201 $custom_error = sprintf( $lng->txt(
'password_to_short'), $security->getPasswordMinLength() );
1205 elseif( $security->getPasswordMaxLength() > 0 &&
1206 strlen($a_passwd) > $security->getPasswordMaxLength() )
1208 $custom_error = sprintf( $lng->txt(
'password_to_long'), $security->getPasswordMaxLength() );
1214 if( $security->isPasswordCharsAndNumbersEnabled() )
1216 $reg =
'/[A-Za-z]+/';
1217 if( !preg_match($reg,$a_passwd) )
1219 $custom_error = $lng->txt(
'password_must_chars_and_numbers');
1224 if( !preg_match($reg,$a_passwd) )
1226 $custom_error = $lng->txt(
'password_must_chars_and_numbers');
1232 if( $security->isPasswordSpecialCharsEnabled() )
1234 $reg =
'/[_\.\+\?\#\-\*\@!\$\%\~]+/';
1235 if( !preg_match($reg,$a_passwd) )
1237 $custom_error = $lng->txt(
'password_must_special_chars');
1245 if (empty($a_passwd))
1249 if (strlen($a_passwd) < 6)
1256 if (!preg_match(
"/^[A-Za-z0-9_\.\+\?\#\-\*\@!\$\%\~]+$/", $a_passwd))
1273 if (empty($a_login))
1278 if (strlen($a_login) < 3)
1286 if (!ereg(
"^[A-Za-z0-9_\.\+\*\@!\$\%\~\-]+$", $a_login))
1305 function shortenText ($a_str, $a_len, $a_dots =
false, $a_next_blank =
false)
1307 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1323 $p = strrpos($a_str,
'.');
1324 if ($p ===
false || $p == 0 || strlen($a_str) - $p > $a_len)
1329 $a_str .=
"\xe2\x80\xa6";
1336 $a_str =
ilStr::subStr($a_str,0,$len - (strlen($a_str) - $p + 1)).
"\xe2\x80\xa6".substr($a_str, $p);
1340 $a_str =
ilStr::subStr($a_str,0,$len - (strlen($a_str) - $p + 1)).substr($a_str, $p);
1358 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1359 $str_arr = explode(
" ", $a_str);
1361 for ($i = 0; $i < count($str_arr); $i++)
1368 $str_arr[$i].=
"...";
1373 return implode($str_arr,
" ");
1386 while (is_int(strpos($a_str,
"=")))
1388 $eq_pos = strpos($a_str,
"=");
1389 $qu1_pos = strpos($a_str,
"\"");
1390 $qu2_pos = strpos(substr($a_str, $qu1_pos + 1),
"\"") + $qu1_pos + 1;
1391 if (is_int($eq_pos) && is_int($qu1_pos) && is_int($qu2_pos))
1393 $var = trim(substr($a_str, 0, $eq_pos));
1394 $val = trim(substr($a_str, $qu1_pos + 1, ($qu2_pos - $qu1_pos) - 1));
1395 $attribs[$var] = $val;
1396 $a_str = substr($a_str, $qu2_pos + 1);
1415 function rCopy ($a_sdir, $a_tdir, $preserveTimeAttributes =
false)
1418 if (!@is_dir($a_sdir) or
1425 $dir = opendir($a_sdir);
1429 if (
$file !=
"." and
1433 if (@is_dir($a_sdir.
"/".
$file))
1435 if (!@is_dir($a_tdir.
"/".
$file))
1450 if (@is_file($a_sdir.
"/".
$file))
1452 if (!copy($a_sdir.
"/".
$file,$a_tdir.
"/".
$file))
1456 if ($preserveTimeAttributes)
1457 touch($a_tdir.
"/".
$file, filectime($a_sdir.
"/".
$file));
1475 if ($mode ==
"filesystem")
1477 return "./".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1481 if (defined(
"ILIAS_MODULE"))
1483 return "../".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1487 return "./".ILIAS_WEB_DIR.
"/".$ilias->client_id;
1499 return CLIENT_DATA_DIR;
1514 global $ilias, $ilDB;
1517 $atime = $pd_set->get(
"user_activity_time") * 60;
1520 if ($a_user_id == 0)
1522 $where =
"WHERE user_id != 0 AND agree_date != '0000-00-00 00:00:00'";
1526 $where =
"WHERE user_id = ".$ilDB->quote($a_user_id).
" ";
1530 $q =
"SELECT count(user_id) as num,user_id,firstname,lastname,title,login,last_login,max(ctime) AS ctime FROM usr_session ".
1531 "LEFT JOIN usr_data ON user_id=usr_id ".$where.
1532 "AND expires>UNIX_TIMESTAMP() ".
1533 "GROUP BY user_id ".
1534 "ORDER BY lastname, firstname";
1536 $r = $ilias->db->query($q);
1541 ||
$user[
"ctime"] + $atime > $ctime)
1547 return $users ? $users : array();
1560 global $ilias, $ilDB;
1563 $atime = $pd_set->get(
"user_activity_time") * 60;
1573 $q =
"SELECT DISTINCT dat.obj_id as obj_id ".
1574 "FROM rbac_ua AS ua ".
1575 "JOIN rbac_fa AS fa ON fa.rol_id = ua.rol_id ".
1576 "JOIN object_reference AS r1 ON r1.ref_id = fa.parent ".
1577 "JOIN tree ON tree.child = r1.ref_id ".
1578 "JOIN object_reference AS r2 ON r2.ref_id = tree.parent ".
1579 "JOIN object_data AS dat ON dat.obj_id = r2.obj_id ".
1580 "WHERE ua.usr_id = ".$ilDB->quote($a_user_id).
" ".
1581 "AND fa.assign = 'y' ".
1582 "AND dat.type IN ('grp','crs')";
1583 $r = $ilias->db->query($q);
1586 $groups_and_courses_of_user[] = $row[
"obj_id"];
1590 if (count($groups_and_courses_of_user) == 0)
1592 $q =
"SELECT count(user_id) as num,ctime,user_id,firstname,lastname,title,login,last_login ".
1593 "FROM usr_session ".
1594 "JOIN usr_data ON user_id=usr_id ".
1595 "WHERE user_id = ".$ilDB->quote($a_user_id).
" ".
1596 " AND agree_date != '0000-00-00 00:00:00' ".
1597 "AND expires > UNIX_TIMESTAMP() - ".$time_diff.
" ".
1602 $q =
"SELECT count(user_id) as num,s.ctime,s.user_id,ud.firstname,ud.lastname,ud.title,ud.login,ud.last_login ".
1603 "FROM usr_session AS s ".
1604 "JOIN usr_data AS ud ON ud.usr_id = s.user_id ".
1605 "JOIN rbac_ua AS ua ON ua.usr_id = s.user_id ".
1606 "JOIN rbac_fa AS fa ON fa.rol_id = ua.rol_id ".
1607 "JOIN tree ON tree.child = fa.parent ".
1608 "JOIN object_reference AS or1 ON or1.ref_id = tree.parent ".
1609 "JOIN object_data AS od ON od.obj_id = or1.obj_id ".
1610 "WHERE s.user_id != 0 ".
1611 "AND s.expires > UNIX_TIMESTAMP() - ".$time_diff.
" ".
1612 "AND fa.assign = 'y' ".
1613 " AND ud.agree_date != '0000-00-00 00:00:00' ".
1614 "AND od.obj_id IN (".implode(
",",
ilUtil::quoteArray($groups_and_courses_of_user)).
") ".
1615 "GROUP BY s.user_id ".
1616 "ORDER BY ud.lastname, ud.firstname";
1618 $r = $ilias->db->query($q);
1623 ||
$user[
"ctime"] + $atime > $ctime)
1629 return $users ? $users : array();
1640 if (!is_dir($temp_path))
1644 $temp_name = tempnam($temp_path,
"tmp");
1650 $temp_name = str_replace(
"\\",
"/", $temp_name);
1675 function unzip($a_file, $overwrite =
false)
1679 $pathinfo = pathinfo($a_file);
1680 $dir = $pathinfo[
"dirname"];
1681 $file = $pathinfo[
"basename"];
1686 $unzip = PATH_TO_UNZIP;
1693 exec($unzipcmd, $arr);
1696 foreach($arr as $line)
1698 if(is_int(strpos($line,
"/")))
1700 $zdir = substr($line, 0, strrpos($line,
"/"));
1701 $nr = substr_count($zdir,
"/");
1705 $nr = substr_count($zdir,
"/");
1706 $zdirs[$zdir] = $nr;
1708 $zdir = substr($zdir, 0, strrpos($zdir,
"/"));
1715 foreach($zdirs as $zdir => $nr)
1741 $pathinfo = pathinfo($a_file);
1742 $dir = $pathinfo[
"dirname"];
1757 if (is_array($a_dir))
1760 foreach($a_dir as
$dir)
1762 $name = basename($dir);
1763 $source.=
" ".ilUtil::escapeShellArg($name);
1768 $name = basename($a_dir);
1784 return PATH_TO_CONVERT;
1797 function convertImage($a_from, $a_to, $a_target_format =
"", $a_geometry =
"",
1798 $a_background_color =
"")
1800 $format_str = ($a_target_format !=
"")
1801 ? strtoupper($a_target_format).
":"
1803 $geometry = ($a_geometry !=
"")
1804 ?
" -geometry ".$a_geometry.
"x".$a_geometry.
" "
1806 $bg_color = ($a_background_color !=
"")
1807 ?
" -background color ".$a_background_color.
" "
1811 system($convert_cmd);
1824 $size =
" -resize ".$a_width.
"x".$a_height.
"! ";
1827 system($convert_cmd);
1839 $html_file = str_replace(
".pdf",
".html",$pdf_file);
1841 $fp = fopen( $html_file ,
"wb");
1845 $htmldoc_path = PATH_TO_HTMLDOC;
1848 $htmldoc = $htmldoc_path.
" ";
1849 $htmldoc .=
"--no-toc ";
1850 $htmldoc .=
"--no-jpeg ";
1851 $htmldoc .=
"--webpage ";
1853 $htmldoc .=
"--bodyfont Arial ";
1854 $htmldoc .=
"--charset iso-8859-15 ";
1855 $htmldoc .=
"--color ";
1856 $htmldoc .=
"--size A4 ";
1857 $htmldoc .=
"--format pdf ";
1858 $htmldoc .=
"--footer ... ";
1859 $htmldoc .=
"--header ... ";
1860 $htmldoc .=
"--left 60 ";
1862 $htmldoc .= $html_file;
1870 function deliverData($a_data, $a_filename, $mime =
"application/octet-stream", $charset =
"")
1872 $disposition =
"attachment";
1875 if (isset($_SERVER[
"HTTPS"])) {
1881 #header("Pragma: ");
1882 #header("Cache-Control: ");
1883 #header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
1884 #header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
1885 #header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
1886 #header("Cache-Control: post-check=0, pre-check=0", false);
1888 else if ($disposition ==
"attachment")
1890 header(
"Cache-control: private");
1894 header(
"Cache-Control: no-cache, must-revalidate");
1895 header(
"Pragma: no-cache");
1900 if (strlen($charset))
1902 $charset =
"; charset=$charset";
1904 header(
"Content-Type: $mime$charset");
1905 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
1906 header(
"Content-Description: ".$ascii_filename);
1907 header(
"Content-Length: ".(
string)(strlen($a_data)));
1909 if($_SERVER[
'HTTPS'])
1911 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
1912 header(
'Pragma: public');
1915 header(
"Connection: close");
1926 function deliverFile($a_file, $a_filename,$a_mime =
'', $isInline =
false, $removeAfterDelivery =
false)
1929 $disposition =
"inline";
1931 $disposition =
"attachment";
1942 $mime =
"application/octet-stream";
1946 if ($disposition ==
"attachment")
1948 header(
"Cache-control: private");
1952 header(
"Cache-Control: no-cache, must-revalidate");
1953 header(
"Pragma: no-cache");
1958 header(
"Content-Type: $mime");
1959 header(
"Content-Disposition:$disposition; filename=\"".$ascii_filename.
"\"");
1960 header(
"Content-Description: ".$ascii_filename);
1961 header(
"Content-Length: ".(
string)(filesize($a_file)));
1963 if($_SERVER[
'HTTPS'])
1965 header(
'Cache-Control: must-revalidate, post-check=0, pre-check=0');
1966 header(
'Pragma: public');
1969 header(
"Connection: close");
1971 if ($removeAfterDelivery)
1987 $chunksize = 1*(1024*1024);
1989 $handle = fopen($a_file,
'rb');
1990 if ($handle ===
false)
1994 while (!feof($handle))
1996 $buffer = fread($handle, $chunksize);
1999 return fclose($handle);
2027 $user_agent = strtolower($_SERVER[
"HTTP_USER_AGENT"]);
2028 if ((is_integer(strpos($user_agent,
"msie"))) && is_integer(strpos($user_agent,
"win")))
2033 $ascii_filename = utf8_decode($a_filename);
2040 $ascii_filename = htmlentities($a_filename,ENT_NOQUOTES,
'UTF-8');
2041 $ascii_filename = preg_replace(
'/\&(.)[^;]*;/',
'\\1', $ascii_filename);
2042 $ascii_filename = preg_replace(
'/[\x7f-\xff]/',
'_', $ascii_filename);
2049 $ascii_filename = preg_replace(
'/[:\x5c\/\*\?\"<>\|]/',
'_', $ascii_filename);
2052 return $ascii_filename;
2060 return PATH_TO_JAVA;
2072 $url = (is_int(strpos($a_url,
"?")))
2074 : $a_url.
"?".$a_par;
2095 $a_dir = trim($a_dir);
2098 if (substr($a_dir,-1) ==
"/")
2100 $a_dir = substr($a_dir,0,-1);
2104 if (!($path = substr($a_dir,0, strrpos($a_dir,
"/") - strlen($a_dir))))
2111 return @mkdir($a_dir,fileperms($path));
2129 $dirs = array($a_dir);
2130 $a_dir = dirname($a_dir);
2132 while($last_dirname != $a_dir)
2134 array_unshift(
$dirs, $a_dir);
2135 $last_dirname = $a_dir;
2136 $a_dir = dirname($a_dir);
2140 $reverse_paths = array_reverse(
$dirs, TRUE);
2142 foreach ($reverse_paths as $key => $value)
2144 if ($found_index == -1)
2148 $found_index = $key;
2157 if ($dirindex >= $found_index)
2159 if (! file_exists(
$dir))
2161 if (strcmp(substr(
$dir,strlen(
$dir)-1,1),
"/") == 0)
2167 if (! mkdir(
$dir, $umask))
2169 error_log(
"Can't make directory: $dir");
2173 elseif (! is_dir(
$dir))
2175 error_log(
"$dir is not a directory");
2181 $umask = fileperms(
$dir);
2197 if (!is_dir($a_dir) || is_int(strpos($a_dir,
"..")))
2202 $current_dir = opendir($a_dir);
2211 while($entryname = readdir($current_dir))
2218 if(is_dir($a_dir.
"/".$file) and ($file !=
"." and $file!=
".."))
2222 elseif ($file !=
"." and $file !=
"..")
2224 unlink(${a_dir}.
"/".${file});
2228 closedir($current_dir);
2238 $current_dir = opendir($a_dir);
2242 while($entry = readdir($current_dir))
2244 if(is_dir($a_dir.
"/".$entry))
2246 $dirs[$entry] = array(
"type" =>
"dir",
"entry" => $entry);
2250 if ($entry !=
"." && $entry !=
"..")
2252 $size = filesize($a_dir.
"/".$entry);
2253 $files[$entry] = array(
"type" =>
"file",
"entry" => $entry,
2276 global $ilias, $ilDB;
2278 $q =
"SELECT DISTINCT tree FROM grp_tree WHERE child=".
2279 $ilDB->quote($a_parent_ref);
2280 $r = $ilias->db->query($q);
2281 $row = $r->fetchRow();
2283 return $row[0] ? $row[0] :
false;
2291 if (is_array($a_arr))
2293 foreach ($a_arr as $k => $v)
2309 if (ini_get(
"magic_quotes_gpc"))
2311 $a_str = stripslashes($a_str);
2323 $only_secure =
true;
2324 $allow_tags = explode(
">", $a_allow);
2326 $allow_array = array();
2327 foreach($allow_tags as $allow)
2331 $allow = str_replace(
"<",
"", $allow);
2333 if (!in_array($allow, $sec_tags))
2335 $only_secure =
false;
2337 $allow_array[] = $allow;
2342 if (($only_secure || $a_allow ==
"") && $a_strip_html)
2346 $allow_array = array (
"b",
"i",
"strong",
"em",
"code",
"cite",
2347 "gap",
"sub",
"sup",
"pre",
"strike");
2353 $a_str = strip_tags($a_str);
2378 return array(
"strong",
"em",
"u",
"strike",
"ol",
"li",
"ul",
"p",
"div",
2379 "i",
"b",
"code",
"sup",
"sub",
"pre",
"gap",
"a",
"img");
2384 foreach ($allow_array as
$t)
2399 array(
"param" =>
"align",
"value" =>
"left"),
2400 array(
"param" =>
"align",
"value" =>
"center"),
2401 array(
"param" =>
"align",
"value" =>
"justify"),
2402 array(
"param" =>
"align",
"value" =>
"right")
2417 foreach ($allow_array as
$t)
2432 array(
"param" =>
"align",
"value" =>
"left"),
2433 array(
"param" =>
"align",
"value" =>
"center"),
2434 array(
"param" =>
"align",
"value" =>
"justify"),
2435 array(
"param" =>
"align",
"value" =>
"right")
2454 if (ini_get(
"magic_quotes_gpc"))
2456 return stripslashes($a_str);
2481 if ($a_make_links_clickable)
2499 $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);
2502 foreach ($matches as $match)
2505 foreach ($matches[0] as $match)
2507 $matched_text = $match[0];
2509 if ($matched_offset != previous_offset)
2512 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1, $pos2 - $pos1)));
2518 $pos1 = $pos2 + strlen($matched_text);
2520 if ($pos1 < strlen($a_str))
2522 $encoded .= nl2br(htmlspecialchars(substr($a_str, $pos1)));
2527 $encoded = nl2br(htmlspecialchars($a_str));
2537 $ws =
"[ \t\r\f\v\n]*";
2538 $att = $ws.
"[^>]*".$ws;
2540 while (eregi(
"<($tag$att($tag_att$ws=$ws\"(([\$@!*()~;,_0-9A-z/:=%\\.&#?+\\-])*)\")$att)>",
2543 $un = array(
".",
"-",
"+",
"?",
'$',
"*",
"(",
")");
2549 $ff = str_replace($un, $esc, $found[1]);
2552 $a_str = eregi_replace(
"<".$ff.
">",
2553 "<$tag $tag_att$tag_att=\"".$found[3].
"\">", $a_str);
2554 if ($old_str == $a_str)
2556 $ilLog->write(
"ilUtil::maskA-".htmlentities($old_str).
" == ".
2557 htmlentities($a_str));
2561 $a_str = str_ireplace(
"</$tag>",
2562 "</$tag>", $a_str);
2570 while (eregi(
"<($tag $tag_att$tag_att=\"(([\$@!*()~;,_0-9A-z/:=%\\.&#?+\\-])*)\")>",
2573 $un = array(
".",
"-",
"+",
"?",
'$',
"*",
"(",
")");
2579 $ff = str_replace($un, $esc, $found[1]);
2582 $a_str = eregi_replace(
"<".$ff.
">",
2583 "<$tag $tag_att=\"".ilUtil::secureLink($found[2]).
"\">", $a_str);
2584 if ($old_str == $a_str)
2586 $ilLog->write(
"ilUtil::unmaskA-".htmlentities($old_str).
" == ".
2587 htmlentities($a_str));
2591 $a_str = str_replace(
"</$tag>",
"</$tag>", $a_str);
2597 $a_str = str_replace(array(
"<$t>",
"<".strtoupper(
$t).
">"),
2598 "<".
$t.
">", $a_str);
2599 $a_str = str_replace(array(
"</$t>",
"</".strtoupper(
$t).
">"),
2600 "</".
$t.
">", $a_str);
2602 if (is_array($fix_param))
2604 foreach ($fix_param as $p)
2608 $a_str = str_replace(
"<$t $k=\"$v\">",
2609 "<".
"$t $k=\"$v\"".
">", $a_str);
2618 $a_str = str_replace(
"<".
$t.
">",
"<".$t.
">", $a_str);
2619 $a_str = str_replace(
"</".
$t.
">",
"</".$t.
">", $a_str);
2621 if (is_array($fix_param))
2623 foreach ($fix_param as $p)
2627 $a_str = str_replace(
"<$t $k=\"$v\">",
2628 "<".
"$t $k=\"$v\"".
">", $a_str);
2636 $a_str = str_ireplace(
"javascript",
"jvscrpt", $a_str);
2637 $a_str = str_ireplace(array(
"%00",
"%0a",
"%0d",
"%1a",
"�",
"�",
2638 "�",
"�",
"
",
"
",
" ",
" "),
"-", $a_str);
2657 $negativestr =
"a,abbr,acronym,address,applet,area,b,base,basefont,".
2658 "bdo,big,blockquote,body,br,button,caption,center,cite,code,col,".
2659 "colgroup,dd,del,dfn,dir,div,dl,dt,em,fieldset,font,form,frame,".
2660 "frameset,h1,h2,h3,h4,h5,h6,head,hr,html,i,iframe,img,input,ins,isindex,kbd,".
2661 "label,legend,li,link,map,menu,meta,noframes,noscript,object,ol,".
2662 "optgroup,option,p,param,q,s,samp,script,select,small,span,".
2663 "strike,strong,style,sub,sup,table,tbody,td,textarea,tfoot,th,thead,".
2664 "title,tr,tt,u,ul,var";
2665 $a_allow = strtolower ($a_allow);
2666 $negatives = split (
",",$negativestr);
2667 $outer_old_str =
"";
2668 while($outer_old_str != $a_str)
2670 $outer_old_str = $a_str;
2671 foreach ($negatives as $item)
2673 $pos = strpos($a_allow,
"<$item>");
2679 while($old_str != $a_str)
2682 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s*>/i",
"", $a_str);
2683 $a_str = preg_replace(
"/<\/?\s*$item(\/?)\s+([^>]*)>/i",
"", $a_str);
2692 $a_str = preg_replace(
"/<\s*\w*(\/?)(\s+[^>]*)?(\s+on[^>]*)>/i",
"", $a_str);
2695 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*javascript[^>]*>/i",
"", $a_str);
2699 $a_str = preg_replace(
"/<\s*\w*(\/?)\s+[^>]*expression[^>]*>/i",
"", $a_str);
2713 if (ini_get(
"magic_quotes_gpc"))
2719 return addslashes($a_str);
2738 $a_str = htmlspecialchars($a_str);
2742 $a_str = str_replace(
"{",
"{", $a_str);
2743 $a_str = str_replace(
"}",
"}", $a_str);
2760 return addslashes($a_str);
2774 $q =
"SELECT user_id FROM desktop_item WHERE item_id = ".$ilDB->quote($a_id);
2775 $r = $ilDB->query($q);
2781 $users[] = $row->user_id;
2784 if (count($users) > 0)
2786 $q =
"DELETE FROM desktop_item WHERE item_id = ".
2787 $ilDB->quote($a_id);
2807 while(($spos=strpos($a_parstr,
"=")) &&
$ok)
2810 $cpar = substr($a_parstr,0,$spos);
2811 $a_parstr = substr($a_parstr,$spos,strlen($a_parstr)-$spos);
2812 while(substr($cpar,0,1)==
"," ||substr($cpar,0,1)==
" " || substr($cpar,0,1)==chr(13) || substr($cpar,0,1)==chr(10))
2813 $cpar = substr($cpar,1,strlen($cpar)-1);
2814 while(substr($cpar,strlen($cpar)-1,1)==
" " || substr($cpar,strlen($cpar)-1,1)==chr(13) || substr($cpar,strlen($cpar)-1,1)==chr(10))
2815 $cpar = substr($cpar,0,strlen($cpar)-1);
2819 while($cpar != $cpar_old)
2822 $cpar = eregi_replace(
"[^a-zA-Z0-9_]",
"", $cpar);
2828 if($spos=strpos($a_parstr,
"\""))
2830 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos);
2831 $spos=strpos($a_parstr,
"\"");
2834 $cval = substr($a_parstr,0,$spos);
2836 $a_parstr = substr($a_parstr,$spos+1,strlen($a_parstr)-$spos-1);
2846 if(
$ok)
return $par;
else return false;
2851 if (is_array($a_par_arr))
2854 foreach ($a_par_arr as $par => $val)
2870 for($i=0; $i<strlen($a_str); $i++)
2872 $ret.= ord(substr($a_str,$i,1)).
" ";
2883 if(strtolower($a_yn) ==
"y")
2918 global $array_sortby,$array_sortorder;
2920 if ($array_sortorder ==
"asc")
2922 return strnatcasecmp($a[$array_sortby], $b[$array_sortby]);
2925 if ($array_sortorder ==
"desc")
2927 return strnatcasecmp($b[$array_sortby], $a[$array_sortby]);
2941 global $array_sortby,$array_sortorder;
2943 if ($array_sortorder ==
"asc")
2945 return $a[
"$array_sortby"] > $b[
"$array_sortby"];
2948 if ($array_sortorder ==
"desc")
2950 return $a[
"$array_sortby"] < $b[
"$array_sortby"];
2963 function sortArray($array,$a_array_sortby,$a_array_sortorder = 0,$a_numeric =
false,
2964 $a_keep_keys =
false)
2967 if (! $a_keep_keys) {
2972 global $array_sortby,$array_sortorder;
2974 $array_sortby = $a_array_sortby;
2976 if ($a_array_sortorder ==
"desc")
2978 $array_sortorder =
"desc";
2982 $array_sortorder =
"asc";
2988 uasort($array, array(
"ilUtil",
"sort_func_numeric"));
2992 usort($array, array(
"ilUtil",
"sort_func_numeric"));
2999 uasort($array, array(
"ilUtil",
"sort_func"));
3003 usort($array, array(
"ilUtil",
"sort_func"));
3023 function stableSortArray($array,$a_array_sortby,$a_array_sortorder = 0,$a_numeric =
false)
3025 global $array_sortby,$array_sortorder;
3027 $array_sortby = $a_array_sortby;
3029 if ($a_array_sortorder ==
"desc")
3031 $array_sortorder =
"desc";
3035 $array_sortorder =
"asc";
3039 $sort_array = array_values($array);
3053 if (count($array) < 2)
return;
3056 $halfway = count($array) / 2;
3057 $array1 = array_slice($array, 0, $halfway);
3058 $array2 = array_slice($array, $halfway);
3065 if (call_user_func($cmp_function, end($array1), $array2[0]) < 1) {
3066 $array = array_merge($array1, $array2);
3073 while ($ptr1 < count($array1) && $ptr2 < count($array2)) {
3074 if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1) {
3075 $array[] = $array1[$ptr1++];
3078 $array[] = $array2[$ptr2++];
3083 while ($ptr1 < count($array1)) $array[] = $array1[$ptr1++];
3084 while ($ptr2 < count($array2)) $array[] = $array2[$ptr2++];
3102 $existing_sub_key_values = array();
3104 foreach ($array as $key=>$sub_array)
3106 if (!in_array($sub_array[$sub_key], $existing_sub_key_values))
3108 $existing_sub_key_values[] = $sub_array[$sub_key];
3109 $target[$key] = $sub_array;
3126 $a_desired_type = strtolower($a_desired_type);
3128 $im_types = ImageTypes();
3130 switch($a_desired_type)
3133 if ($im_types & IMG_JPG)
return "jpg";
3134 if ($im_types & IMG_GIF)
return "gif";
3135 if ($im_types & IMG_PNG)
return "png";
3139 if ($im_types & IMG_GIF)
return "gif";
3140 if ($im_types & IMG_JPG)
return "jpg";
3141 if ($im_types & IMG_PNG)
return "png";
3145 if ($im_types & IMG_PNG)
return "png";
3146 if ($im_types & IMG_JPG)
return "jpg";
3147 if ($im_types & IMG_GIF)
return "gif";
3163 if (($a_mime ==
"image/gif") || ($a_mime ==
"image/jpeg") ||
3164 ($a_mime ==
"image/png") || ($a_mime ==
"application/x-shockwave-flash") ||
3165 ($a_mime ==
"image/tiff") || ($a_mime ==
"image/x-ms-bmp") ||
3166 ($a_mime ==
"image/psd") || ($a_mime ==
"image/iff"))
3184 global
$log, $PHP_SELF;
3187 header(
"Location: ".$a_script);
3198 if (substr($a_value, 0, 4) ==
"il__")
3200 $a_value =
"il_".IL_INST_ID.
"_".substr($a_value, 4, strlen($a_value) - 4);
3218 if (empty($a_group_name))
3220 $message = get_class($this).
"::_NameExists(): No groupname given!";
3221 $ilErr->raiseError($message,$ilErr->WARNING);
3224 $clause = ($a_id) ?
" AND obj_id != ".$ilDB->quote($a_id).
" " :
"";
3226 $q =
"SELECT obj_id FROM object_data ".
3227 "WHERE title = ".$ilDB->quote($a_group_name).
" ".
3231 $r = $ilDB->query($q);
3254 "FROM object_data ,object_reference ".
3255 "WHERE (object_data.title LIKE ".$ilDB->quote(
"%".$a_search_str.
"%").
" ".
3256 "OR object_data.description LIKE ".$ilDB->quote(
"%".$a_search_str.
"%").
") ".
3257 "AND object_data.type = 'grp' ".
3258 "AND object_data.obj_id = object_reference.obj_id ".
3261 $res = $ilDB->query($q);
3267 $ids[$row->obj_id] = array(
3268 "ref_id" => $row->ref_id,
3269 "title" => $row->title,
3270 "description" => $row->description);
3273 return $ids ? $ids : array();
3281 $my_pid = getmypid();
3282 return (
"MEMORY USAGE (% KB PID ): ".`ps -eo%mem,rss,pid | grep $my_pid`);
3290 if (strtolower(substr(php_uname(), 0, 3)) ==
"win")
3300 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3301 return escapeshellarg($a_arg);
3313 if(ini_get(
'safe_mode') == 1)
3317 setlocale(LC_CTYPE,
"UTF8",
"en_US.UTF-8");
3318 return escapeshellcmd($a_arg);
3342 function excelTime($year =
"", $month =
"", $day =
"", $hour =
"", $minute =
"", $second =
"")
3344 $starting_time = mktime(0, 0, 0, 1, 2, 1970);
3345 if (strcmp(
"$year$month$day$hour$minute$second",
"") == 0)
3347 $target_time = time();
3356 $target_time = mktime($hour, $minute, $second, $month, $day, $year);
3357 $difference = $target_time - $starting_time;
3358 $days = (($difference - ($difference % 86400)) / 86400);
3359 $difference = $difference - ($days * 86400) + 3600;
3360 return ($days + 25570 + ($difference / 86400));
3368 $def_arr = explode(
",", SUFFIX_REPL_DEFAULT);
3369 foreach ($def_arr as $def)
3374 $def_arr = explode(
",", SUFFIX_REPL_ADDITIONAL);
3375 foreach ($def_arr as $def)
3393 if ($a_dir ==
"/" || $a_dir ==
"" || is_int(strpos($a_dir,
".."))
3394 || trim($a_old_suffix) ==
"")
3400 if (!@is_dir($a_dir))
3406 $dir = opendir($a_dir);
3410 if (
$file !=
"." and
3414 if (@is_dir($a_dir.
"/".
$file))
3420 if (@is_file($a_dir.
"/".
$file))
3423 if(strrpos(
$file,
'.') == (strlen(
$file) - 1))
3425 rename($a_dir.
'/'.
$file,substr($a_dir.
'/'.
$file,0,-1));
3429 $path_info = pathinfo($a_dir.
"/".
$file);
3431 if (strtolower($path_info[
"extension"]) ==
3432 strtolower($a_old_suffix))
3434 $pos = strrpos($a_dir.
"/".
$file,
".");
3435 $new_name = substr($a_dir.
"/".
$file, 0, $pos).
".".$a_new_suffix;
3436 rename($a_dir.
"/".
$file, $new_name);
3445 return strpos($_SERVER[
"SCRIPT_FILENAME"],
"api") !==
false ||
3446 strpos($_SERVER[
"SCRIPT_FILENAME"],
"dummy") !==
false;
3450 if (preg_match(
"/&" . $paramName .
"=/", $qstring)) {
3451 return preg_replace(
"/&" . $paramName .
"=[^&]+/",
"&" . $paramName .
"=" . urlencode($paramValue), $qstring);
3453 return $qstring .
"&" . $paramName .
"=" . urlencode($paramValue);
3459 foreach ($parametersArray as $paramName => $paramValue ) {
3468 srand((
double) microtime()*1000000);
3470 for ($i=1; $i<=$a_number; $i++)
3472 $length = rand(6,10);
3476 $consonants =
"bcdfghjklmnpqrstvwxyz";
3479 for ($j=0; $j < $length; $j++)
3484 $pw.= $consonants[rand(0,strlen($consonants)-1)];
3489 $pw.= $vowels[rand(0,strlen($vowels)-1)];
3503 $path = preg_replace(
"/[\/\\\]+$/",
"", $path);
3522 foreach(
$data as $k=>$datum)
3524 if(is_null($datum))
$data[$k] =
'null';
3525 if(is_string($datum))
$data[$k] =
"'" . $datum .
"'";
3529 return "[" . implode(
', ',
$data) .
"]";
3540 if (IL_VIRUS_SCANNER !=
"None")
3542 require_once(
"classes/class.ilVirusScannerFactory.php");
3544 if (($vs_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
3546 if ($a_clean && (IL_VIRUS_CLEAN_COMMAND !=
""))
3548 $clean_txt = $vs->cleanFile($a_file, $a_orig_name);
3549 if ($vs->fileCleaned())
3551 $vs_txt.=
"<br />".$lng->txt(
"cleaned_file").
3552 "<br />".$clean_txt;
3553 $vs_txt.=
"<br />".$lng->txt(
"repeat_scan");
3554 if (($vs2_txt = $vs->scanFile($a_file, $a_orig_name)) !=
"")
3556 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_failed").
3557 "<br />".nl2br($vs2_txt));
3561 return array(
true, nl2br($vs_txt).
"<br />".$lng->txt(
"repeat_scan_succeded"));
3566 return array(
false, nl2br($vs_txt).
"<br />".$lng->txt(
"cleaning_failed"));
3571 return array(
false, nl2br($vs_txt));
3576 return array(
true,
"");
3585 global
$lng, $ilias;
3587 if (!is_file($a_file))
3589 $lng->txt(
"upload_error_file_not_found");
3597 if ($a_raise_errors)
3599 $ilias->raiseError($lng->txt(
"file_is_infected").
"<br />".
3601 $ilias->error_obj->MESSAGE);
3616 return move_uploaded_file($a_file, $a_target);
3625 list($datum, $uhrzeit) = explode (
" ",$mysql_date_time);
3626 list($jahr, $monat, $tag) = explode(
"-", $datum);
3627 list($std, $min, $sec) = explode(
":", $uhrzeit);
3628 return mktime ((
int) $std, (
int) $min, (
int) $sec, (
int) $monat, (
int) $tag, (
int) $jahr);
3636 return date(
"Y-m-d H:i:s");
3654 $resultarray = array();
3655 foreach ($row as $rowindex => $entry)
3662 if (strpos($entry,
"\"") !== FALSE)
3664 $entry = str_replace(
"\"",
"\"\"", $entry);
3671 if ($compatibleWithMSExcel)
3674 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
3680 $resultarray[$rowindex] =
"\"" . $entry .
"\"";
3684 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
3691 $resultarray[$rowindex] = $entry;
3695 $resultarray[$rowindex] = utf8_decode($entry);
3699 return $resultarray;
3705 return(preg_match(
"/^[a-z]+([a-z0-9-]*[a-z0-9]+)?(\.([a-z]+([a-z0-9-]*[a-z0-9]+)?)+)*$/",$a_str));
3711 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])\.".
3712 "(\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));
3744 global $ilDB,$rbacreview,$ilAccess,$ilUser,$ilias;
3746 if(!is_array($a_obj_type))
3748 $where =
"WHERE type = ".$ilDB->quote($a_obj_type).
" ";
3752 $where =
"WHERE type IN(";
3760 $limit = $ilias->getSetting(
'search_max_hits',100);
3768 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
3769 $a_roles = $rbacreview->assignedRoles($a_usr_id);
3773 if($rbacreview->isAssigned($a_usr_id,SYSTEM_ROLE_ID))
3775 $query =
"SELECT ref_id FROM object_reference AS obr LEFT JOIN object_data AS obd USING(obj_id) ".
3776 "LEFT JOIN tree ON obr.ref_id = tree.child ".
3780 $res = $ilDB->query($query);
3785 if($counter++ >= $limit)
3789 $ref_ids[] = $row->ref_id;
3791 return $ref_ids ? $ref_ids : array();
3795 if($a_operation ==
'edit_permissions' or strpos($a_operation,
'create') !==
false)
3797 $check_owner =
") ";
3801 $check_owner =
"OR owner = ".$ilDB->quote($a_usr_id).
") ";
3805 $ops_id = $ops_ids[0];
3809 $query =
"SELECT DISTINCT(obr.ref_id),obr.obj_id,type FROM object_reference AS obr ".
3810 "JOIN object_data AS obd ON obd.obj_id = obr.obj_id ".
3811 "JOIN rbac_pa ON obr.ref_id = rbac_pa.ref_id ".
3814 "AND (ops_id LIKE ".$ilDB->quote(
"%i:".$ops_id.
"%").
" ".
3815 "OR ops_id LIKE".$ilDB->quote(
"%:\"".$ops_id.
"\";%").
")) ".
3818 $res = $ilDB->query($query);
3822 if($counter >= $limit)
3827 if($ilAccess->checkAccessOfUser($a_usr_id,$a_operation,
'',$row->ref_id,$row->type,$row->obj_id))
3830 $ref_ids[] = $row->ref_id;
3833 return $ref_ids ? $ref_ids : array();
3842 function insertLatexImages($a_text, $a_start =
"\[tex\]", $a_end =
"\[\/tex\]", $a_cgi = URL_TO_LATEX)
3850 include_once
"./Services/Administration/classes/class.ilSetting.php";
3851 $jsMathSetting =
new ilSetting(
"jsMath");
3853 $jsMathSetting->get(
"enable") && ($ilUser->getPref(
"js_math") || ($ilUser->getPref(
"js_math") === FALSE && ($jsMathSetting->get(
"makedefault"))));
3858 if (!$tpl->out_jsmath_info)
3860 include_once
"./classes/class.ilTemplate.php";
3861 $template =
new ilTemplate(
"tpl.jsmath_warning.html", TRUE, TRUE);
3862 $lng->loadLanguageModule(
"jsmath");
3863 $template->setVariable(
"TEXT_JSMATH_NO_JAVASCRIPT", $lng->txt(
"jsmath_no_javascript"));
3864 $info = $template->get();
3865 $tpl->out_jsmath_info = TRUE;
3867 $a_text = preg_replace(
"/\\\\([RZN])([^a-zA-Z]|<\/span>)/",
"\\mathbb{".
"$1".
"}".
"$2", $a_text);
3868 $tpl->addJavaScript($jsMathSetting->get(
"path_to_jsmath") .
"/easy/load.js");
3873 $o_start = $a_start;
3875 $a_start = str_replace(
"\\",
"", $a_start);
3876 $a_end = str_replace(
"\\",
"", $a_end);
3883 while (is_int($spos = stripos($a_text, $a_start, $cpos)))
3885 if (is_int ($epos = stripos($a_text, $a_end, $spos + 1)))
3887 $tex = substr($a_text, $spos + strlen($a_start), $epos - $spos - strlen($a_start));
3890 if (!is_int(strpos($tex,
"</div>")))
3894 $a_text = substr($a_text, 0, $spos).
3895 "<img alt=\"".htmlentities($tex).
"\" src=\"".$a_cgi.
"?".
3896 rawurlencode(str_replace(
'&',
'&', str_replace(
'>',
'>', str_replace(
'<',
'<', $tex)))).
"\" ".
3898 substr($a_text, $epos + strlen($a_end));
3902 $tex = $a_start.$tex.$a_end;
3905 preg_replace(
'/' . $o_start .
'(.*?)' . $o_end .
'/ie',
3906 "'<span class=\"math\">' . preg_replace('/[\\\\\\\\\\]{2}/', '\\cr', str_replace('<', '<', str_replace('<br/>', '', str_replace('<br />', '', str_replace('<br>', '', '$1'))))) . '</span>[[info]]'", $tex);
3909 $a_text = substr($a_text, 0, $spos).
3911 substr($a_text, $epos + strlen($a_end));
3920 $a_text = str_replace(
"[[info]]", $info, $a_text);
3923 $result_text = $a_text;
3931 return $result_text;
3990 function buildLatexImages($a_text, $a_dir ,$a_start =
"\[tex\]", $a_end =
"\[\/tex\]", $a_cgi = URL_TO_LATEX)
3992 $result_text = $a_text;
3996 while (preg_match(
'/' . $a_start .
'(.*?)' . $a_end .
'/ie', $result_text, $found))
3998 $cnt = (int)
$GLOBALS[
"teximgcnt"]++;
4000 $fpr = @fopen($a_cgi.
"?".rawurlencode($found[1]),
"r");
4006 $buf = fread($fpr, 1024);
4009 if (is_int(strpos(strtoupper(substr($buf, 0, 5)),
"GIF")))
4017 $fpw = fopen($a_dir.
"/teximg/img".$cnt.
".".$suffix,
"w");
4027 $img_str =
"./teximg/img".$cnt.
".".$suffix;
4028 $result_text = str_replace($found[0],
4029 '<img alt="'.$found[1].
'" src="'.$img_str.
'" />', $result_text);
4033 return $result_text;
4046 $is_html = $this->isHTML(
$result);
4047 if ($prepare_for_latex_output)
4062 if (preg_match_all(
"/(<pre>.*?<\/pre>)/ims",
$result, $matches))
4064 foreach ($matches[0] as $found)
4067 if (strpos(
"\n", $found) === FALSE)
4069 $replacement =
"\n";
4071 $removed = preg_replace(
"/<br\s*?\/>/ims", $replacement, $found);
4076 if ($prepare_for_latex_output)
4097 if (!is_array($periods))
4100 'years' => 31536000,
4101 'months' => 2592000,
4110 $seconds = (float) $seconds;
4111 foreach ($periods as $period => $value)
4113 $count = floor($seconds / $value);
4120 $values[$period] = $count;
4121 $seconds = $seconds % $value;
4142 if (!is_array($duration))
4147 foreach ($duration as $key => $value) {
4152 $segment_name = $key;
4153 $segment_name = $lng->txt($segment_name);
4154 $segment = $value .
' ' . $segment_name;
4158 $segment_name = substr($key, 0, -1);
4159 $segment_name = $lng->txt($segment_name);
4160 $segment = $value .
' ' . $segment_name;
4163 $array[] = $segment;
4165 $len = count($array);
4169 $array=array_slice($array,0,(3-$len));
4172 $str = implode(
', ', $array);
4182 $umf=get_cfg_var(
"upload_max_filesize");
4184 $pms=get_cfg_var(
"post_max_size");
4187 $max_filesize=min($umf, $pms);
4188 if (!$max_filesize) $max_filesize=max($umf, $pms);
4190 return $lng->txt(
"file_notice").
" $max_filesize.";
4202 $test_str = explode(
'_',$role_title);
4204 if ($test_str[0] ==
'il')
4206 $test2 = (int) $test_str[3];
4207 return is_numeric ($test2) ? (int) $test2 :
false;
4224 $test_str = explode(
'_',$ilias_id);
4226 if ($test_str[0] ==
'il' && $test_str[1] == $inst_id && count($test_str) == 4)
4228 $test2 = (int) $test_str[3];
4229 return is_numeric ($test2) ? (int) $test2 :
false;
4256 $where =
"WHERE ".$a_id_name.
" IN (";
4260 $query =
"SELECT ".$a_id_name.
" FROM ".$a_table.
" ".
4262 "ORDER BY ".$a_field;
4264 $res = $ilDB->query($query);
4267 $ids[] = $row->$a_id_name;
4269 return $ids ? $ids : array();
4283 if ($ilDB->isMysql4_1OrHigher())
4290 $ts = substr(
$t, 0, 4).
"-".substr(
$t, 4, 2).
"-".substr(
$t, 6, 2).
4291 " ".substr(
$t, 8, 2).
":".substr(
$t, 10, 2).
":".substr(
$t, 12, 2);
4304 if(!is_array($a_array) or !count($a_array))
4309 foreach($a_array as $k => $item)
4311 $a_array[$k] = $ilDB->quote($item);
4329 if (!empty($a_info))
4335 $tpl->addBlockFile(
"MESSAGE",
"message",
"tpl.message.html");
4336 # $tpl->setCurrentBlock("message");
4337 $tpl->setVariable(
"INFO",
$_SESSION[
"info"]);
4338 # $tpl->parseCurrentBlock();
4343 session_unregister(
"info");
4353 $tpl->addBlockFile(
"INFOPANEL",
"infopanel",
"tpl.infopanel.html");
4354 $tpl->setCurrentBlock(
"infopanel");
4356 if (!empty(
$_SESSION[
"infopanel"][
"text"]))
4358 $link =
"<a href=\"".$dir.$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4361 $link .= $lng->txt(
$_SESSION[
"infopanel"][
"text"]);
4366 if (!empty(
$_SESSION[
"infopanel"][
"img"]))
4368 $link .=
"<td><a href=\"".$_SESSION[
"infopanel"][
"link"].
"\" target=\"".
4371 $link .=
"<img src=\"".$ilias->tplPath.$ilias->account->prefs[
"skin"].
"/images/".
4372 $_SESSION[
"infopanel"][
"img"].
"\" border=\"0\" vspace=\"0\"/>";
4373 $link .=
"</a></td>";
4376 $tpl->setVariable(
"INFO_ICONS",$link);
4377 $tpl->parseCurrentBlock();
4382 session_unregister(
"infopanel");
4396 if (!is_dir($directory))
4400 $size = @filesize($directory);
4404 if ($DIR = opendir($directory))
4406 while (($dirfile = readdir($DIR)) !==
false)
4408 if (is_link($directory . DIRECTORY_SEPARATOR . $dirfile) || $dirfile ==
'.' || $dirfile ==
'..')
4410 if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile))
4411 $size += filesize($directory . DIRECTORY_SEPARATOR . $dirfile);
4412 else if (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile))
4415 $dirSize =
ilUtil::dirsize($directory . DIRECTORY_SEPARATOR . $dirfile);
4429 return md5(rand(1,9999999) + str_replace(
" ",
"", (
string) microtime()));
4434 return strip_tags($a_filename);