ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilWebAccessChecker.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 // Prevent a general redirect to the login screen for anonymous users.
5 // The checker will show an error page with login link instead
6 // (see ilInitialisation::InitILIAS() for details)
7 $_GET["baseClass"] = "ilStartUpGUI";
8 
9 // Define a pseudo module to get a correct ILIAS_HTTP_PATH
10 // (needed for links on the error page).
11 // "data" is assumed to be the ILIAS_WEB_DIR
12 // (see ilInitialisation::buildHTTPPath() for details)
13 define("ILIAS_MODULE", substr($_SERVER['PHP_SELF'],
14  strpos($_SERVER['PHP_SELF'], "/data/") + 6));
15 
16 // Define the cookie path to prevent a different session created for web access
17 // (see ilInitialisation::setCookieParams() for details)
18 $GLOBALS['COOKIE_PATH'] = substr($_SERVER['PHP_SELF'], 0,
19  strpos($_SERVER['PHP_SELF'], "/data/"));
20 
21 // Determine the ILIAS client from the web path
22 // This is needed because a session cookie may not yet exist
23 // (see ilINITIALISATION::determineClient() for details)
24 $client_start = strpos($_SERVER['PHP_SELF'], "/data/") + 6;
25 $client_end = strpos($_SERVER['PHP_SELF'], "/", $client_start);
26 $_GET['client_id'] = substr($_SERVER['PHP_SELF'], $client_start, $client_end - $client_start);
27 
28 // Remember if the initial session was empty
29 // Then a new session record should not be written
30 // (see ilSession::_writeData for details)
31 $GLOBALS['WEB_ACCESS_WITHOUT_SESSION'] = (session_id() == "");
32 
33 include_once "Services/Context/classes/class.ilContext.php";
35 
36 // Now the ILIAS header can be included
37 require_once "./include/inc.header.php";
38 require_once "./Services/Utilities/classes/class.ilUtil.php";
39 require_once "./Services/Object/classes/class.ilObject.php";
40 require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
41 
42 
57 {
58  var $lng;
59  var $ilAccess;
60 
66  var $subpath;
67 
73  var $file;
74 
80  var $params;
81 
82 
88  var $disposition = "inline";
89 
95  var $check_ip = false;
96 
97 
105  var $check_users = array();
106 
112  var $send_mimetype = true;
113 
114 
121  var $mimetype = null;
122 
123 
130 
131 
138 
139 
145  {
146  global $ilUser, $ilAccess, $lng, $ilLog;
147 
148  $this->lng =& $lng;
149  $this->ilAccess =& $ilAccess;
150  $this->params = array();
151 
152  // get the requested file and its type
153  $uri = parse_url($_SERVER["REQUEST_URI"]);
154  parse_str($uri["query"], $this->params);
155 
156  $pattern = ILIAS_WEB_DIR . "/" . CLIENT_ID;
157  $this->subpath = urldecode(substr($uri["path"], strpos($uri["path"], $pattern)));
158  $this->file = realpath(ILIAS_ABSOLUTE_PATH . "/". $this->subpath);
159 
160  // build url path for virtual function
161  $this->virtual_path = str_replace($pattern, "virtual-" . $pattern, $uri["path"]);
162 
163 
164  // set the parameters provided with the checker call
165  if (isset($_GET['disposition']))
166  {
167  $this->setDisposition($_GET['disposition']);
168  }
169  if (isset($_GET['check_ip']))
170  {
171  $this->setCheckIp($_GET['check_ip']);
172  }
173  if (isset($_GET['send_mimetype']))
174  {
175  $this->setSendMimetype($_GET['send_mimetype']);
176  }
177 
178  // debugging
179  /*echo "<pre>";
180  echo "REQUEST_URI: ". $_SERVER["REQUEST_URI"]. "\n";
181  echo "Parsed URI: ". $uri["path"]. "\n";
182  echo "DOCUMENT_ROOT: ". $_SERVER["DOCUMENT_ROOT"]. "\n";
183  echo "PHP_SELF: ". $_SERVER["PHP_SELF"]. "\n";
184  echo "SCRIPT_NAME: ". $_SERVER["SCRIPT_NAME"]. "\n";
185  echo "SCRIPT_FILENAME: ". $_SERVER["SCRIPT_FILENAME"]. "\n";
186  echo "PATH_TRANSLATED: ". $_SERVER["PATH_TRANSLATED"]. "\n";
187  echo "ILIAS_WEB_DIR: ". ILIAS_WEB_DIR. "\n";
188  echo "ILIAS_HTTP_PATH: ". ILIAS_HTTP_PATH. "\n";
189  echo "ILIAS_ABSOLUTE_PATH: ". ILIAS_ABSOLUTE_PATH. "\n";
190  echo "CLIENT_ID: ". CLIENT_ID. "\n";
191  echo "CLIENT_WEB_DIR: ". CLIENT_WEB_DIR. "\n";
192  echo "subpath: ". $this->subpath. "\n";
193  echo "file: ". $this->file. "\n";
194  echo "disposition: ". $this->disposition. "\n";
195  echo "ckeck_ip: ". $this->check_ip. "\n";
196  echo "send_mimetype: ". $this->send_mimetype. "\n";
197  echo "</pre>";
198  echo phpinfo();
199  exit;*/
200 
201 
202  if (!file_exists($this->file))
203  {
204  $this->errorcode = 404;
205  $this->errortext = $this->lng->txt("url_not_found");
206  return false;
207  }
208  }
209 
213  public function determineUser()
214  {
215  global $ilUser;
216 
217  // a valid user session is found
218  if ($_SESSION["AccountId"])
219  {
220  $this->check_users = array($_SESSION["AccountId"]);
221  return;
222  }
223 
224  // no session cookie was delivered
225  // user identification by ip address is allowed
226  elseif ($GLOBALS['WEB_ACCESS_WITHOUT_SESSION'] and $this->getCheckIp())
227  {
228  $this->check_users = ilSession::_getUsersWithIp($_SERVER['REMOTE_ADDR']);
229 
230  if (count($this->check_users) == 0)
231  {
232  // no user was found for the ip address
233  $this->check_users = array(ANONYMOUS_USER_ID);
234 
235  $_SESSION["AccountId"] = ANONYMOUS_USER_ID;
236  $ilUser->setId(ANONYMOUS_USER_ID);
237  $ilUser->read();
238  }
239  elseif (count($this->check_users) == 1)
240  {
241  // exactly one user is found with an active session
242  $_SESSION["AccountId"] = current($this->check_users);
243  $ilUser->setId(current($this->check_users));
244  $ilUser->read();
245  }
246  else
247  {
248  // more than one user found for the ip address
249  // take the anonymous user for the session
250  $_SESSION["AccountId"] = ANONYMOUS_USER_ID;
251  $ilUser->setId(ANONYMOUS_USER_ID);
252  $ilUser->read();
253  }
254  return;
255  }
256 
257  // take the anonymous user as fallback
258  else
259  {
260  $this->check_users = array(ANONYMOUS_USER_ID);
261 
262  $_SESSION["AccountId"] = ANONYMOUS_USER_ID;
263  $ilUser->setId(ANONYMOUS_USER_ID);
264  $ilUser->read();
265 
266  return;
267  }
268  }
269 
274  public function checkAccess()
275  {
276  global $ilLog, $ilUser, $ilObjDataCache;
277 
278  // an error already occurred at class initialisation
279  if ($this->errorcode)
280  {
281  return false;
282  }
283 
284  // do this here because ip based checking may be set after construction
285  $this->determineUser();
286 
287  // check for type by subdirectory
288  $pos1 = strpos($this->subpath, "lm_data/lm_") + 11;
289  $pos2 = strpos($this->subpath, "mobs/mm_") + 8;
290  $pos3 = strpos($this->subpath, "usr_images/") + 11;
291 
292  $obj_id = 0;
293  $type = 'none';
294  // trying to access data within a learning module folder
295  if ($pos1 > 11)
296  {
297  $type = 'lm';
298  $seperator = strpos($this->subpath, '/', $pos1);
299  $obj_id = substr($this->subpath, $pos1, ($seperator > 0 ? $seperator : strlen($this->subpath))-$pos1);
300  }
301  //trying to access media data
302  else if ($pos2 > 8)
303  {
304  $type = 'mob';
305  $seperator = strpos($this->subpath, '/', $pos2);
306  $obj_id = substr($this->subpath, $pos2, ($seperator > 0 ? $seperator : strlen($this->subpath))-$pos2);
307  }
308  // trying to access a user image
309  elseif ($pos3 > 11)
310  {
311  $type = 'user_image';
312  // user images may be:
313  // upload_123pic, upload_123
314  // usr_123.jpg, usr_123_small.jpg, usr_123_xsmall.jpg, usr_123_xxsmall.jpg
315  $seperator = strpos($this->subpath, '_', $pos3);
316  $obj_id = (int) substr($this->subpath, $seperator + 1);
317  }
318 
319  if (!$obj_id || $type == 'none')
320  {
321  $this->errorcode = 404;
322  $this->errortext = $this->lng->txt("obj_not_found");
323  return false;
324  }
325 
326  switch($type)
327  {
328  // SCORM or HTML learning module
329  case 'lm':
330  if ($this->checkAccessObject($obj_id))
331  {
332  return true;
333  }
334  break;
335 
336  // media object
337  case 'mob':
338  if ($this->checkAccessMob($obj_id))
339  {
340  return true;
341  }
342  break;
343 
344  // image in user profile
345  case 'user_image':
346  if ($this->checkAccessUserImage($obj_id))
347  {
348  return true;
349  }
350  break;
351  }
352 
353  // none of the checks above gives access
354  $this->errorcode = 403;
355  $this->errortext = $this->lng->txt('msg_no_perm_read');
356  return false;
357  }
358 
365  function checkAccessMob($obj_id)
366  {
367  $usages = ilObjMediaObject::lookupUsages($obj_id);
368 
369  foreach($usages as $usage)
370  {
371  $oid = ilObjMediaObject::getParentObjectIdForUsage($usage, true);
372 
373  // for content snippets we must get their usages and check them
374  if ($usage["type"] == "mep:pg")
375  {
376  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
377  $usages2 = ilMediaPoolPage::lookupUsages($usage["id"]);
378  foreach($usages2 as $usage2)
379  {
380  $oid2 = ilObjMediaObject::getParentObjectIdForUsage($usage2, true);
381  if ($this->checkAccessMobUsage($usage2, $oid2))
382  {
383  return true;
384  }
385  }
386  }
387  else // none content snippets just go the usual way
388  {
389  if ($this->checkAccessMobUsage($usage, $oid))
390  {
391  return true;
392  }
393  }
394  }
395 
396  return false;
397  }
398 
405  function checkAccessMobUsage($usage, $oid)
406  {
410  global $ilObjDataCache;
411 
412  switch($usage['type'])
413  {
414  case 'lm:pg':
415  if ($oid > 0)
416  {
417  if ($this->checkAccessLM($oid, 'lm', $usage['id']))
418  {
419  return true;
420  }
421  }
422  break;
423  case 'news':
424  // media objects in news (media casts)
425  include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
426  include_once("./Services/News/classes/class.ilNewsItem.php");
427 
428  if ($this->checkAccessObject($oid, 'mcst'))
429  {
430  return true;
431  }
433  {
434  return true;
435  }
436  break;
437 
438  case 'dcl:html':
439  include_once("./Modules/DataCollection/classes/class.ilObjDataCollectionAccess.php");
440  include_once("./Services/Object/classes/class.ilObject2.php");
441  $ref_ids = ilObject2::_getAllReferences($oid);
442  foreach($ref_ids as $ref_id)
443  if(ilObjDataCollectionAccess::_checkAccess("view", "read", $ref_id, $oid))
444  return true;
445  break;
446 
447  case 'frm~:html':
448  // $oid = userid
449  foreach ($this->check_users as $user_id)
450  {
451  if ($ilObjDataCache->lookupType($oid) == 'usr' && $oid == $user_id)
452  {
453  return true;
454  }
455  }
456  break;
457 
458  case 'qpl:pg':
459  case 'qpl:html':
460  // test questions
461  if ($this->checkAccessTestQuestion($oid, $usage['id']))
462  {
463  return true;
464  }
465  break;
466 
467  case 'gdf:pg':
468  // special check for glossary terms
469  if ($this->checkAccessGlossaryTerm($oid, $usage['id']))
470  {
471  return true;
472  }
473  break;
474 
475  case 'sahs:pg':
476  // check for scorm pages
477  if ($this->checkAccessObject($oid, 'sahs'))
478  {
479  return true;
480  }
481  break;
482 
483  case 'prtf:pg':
484  // special check for portfolio pages
485  if ($this->checkAccessPortfolioPage($oid, $usage['id']))
486  {
487  return true;
488  }
489  break;
490 
491  case 'blp:pg':
492  // special check for blog pages
493  if ($this->checkAccessBlogPage($oid, $usage['id']))
494  {
495  return true;
496  }
497  break;
498 
499  case 'impr:pg':
500  include_once 'Services/Imprint/classes/class.ilImprint.php';
501  return (ilImprint::isActive() || $this->checkAccessObject(SYSTEM_FOLDER_ID, 'adm'));
502 
503  default:
504  // standard object check
505  if ($this->checkAccessObject($oid))
506  {
507  return true;
508  }
509  break;
510  }
511 
512  return false;
513  }
514 
515 
524  private function checkAccessLM($obj_id, $obj_type, $page = 0)
525  {
526  global $lng;
527 
528  //if (!$page)
529  //{
530  $ref_ids = ilObject::_getAllReferences($obj_id);
531  foreach($ref_ids as $ref_id)
532  {
533  foreach ($this->check_users as $user_id)
534  {
535  if ($this->ilAccess->checkAccessOfUser($user_id, "read", "view", $ref_id, $obj_type, $obj_id))
536  {
537  return true;
538  }
539  }
540  }
541  return false;
542  //}
543  //else
544  //{
545  // $ref_ids = ilObject::_getAllReferences($obj_id);
546  // foreach($ref_ids as $ref_id)
547  // {
548  // if ($this->ilAccess->checkAccess("read", "", $ref_id))
549  // {
550  // require_once 'Modules/LearningModule/classes/class.ilObjLearningModule.php';
551  // $lm = new ilObjLearningModule($obj_id,false);
552  // if ($lm->_checkPreconditionsOfPage($ref_id, $obj_id, $page))
553  // return true;
554  // }
555  // }
556  // return false;
557  //}
558  }
559 
566  private function checkAccessObject($obj_id, $obj_type = '')
567  {
568  global $ilAccess;
569 
570  if (!$obj_type)
571  {
572  $obj_type = ilObject::_lookupType($obj_id);
573  }
574  $ref_ids = ilObject::_getAllReferences($obj_id);
575 
576  foreach($ref_ids as $ref_id)
577  {
578  foreach ($this->check_users as $user_id)
579  {
580  if ($ilAccess->checkAccessOfUser($user_id, "read", "view", $ref_id, $obj_type, $obj_id))
581  {
582  return true;
583  }
584  }
585  }
586  return false;
587  }
588 
589 
598  private function checkAccessTestQuestion($obj_id, $usage_id = 0)
599  {
600  global $ilAccess;
601 
602  // give access if direct usage is readable
603  if ($this->checkAccessObject($obj_id))
604  {
605  return true;
606  }
607 
608  $obj_type = ilObject::_lookupType($obj_id);
609  if ($obj_type == 'qpl')
610  {
611  // give access if question pool is used by readable test
612  // for random selection of questions
613  include_once('./Modules/Test/classes/class.ilObjTestAccess.php');
615  foreach ($tests as $test_id)
616  {
617  if ($this->checkAccessObject($test_id, 'tst'))
618  {
619  return true;
620  }
621  }
622  }
623  return false;
624  }
625 
626 
635  private function checkAccessGlossaryTerm($obj_id, $page_id)
636  {
637  // give access if glossary is readable
638  if ($this->checkAccessObject($obj_id))
639  {
640  return true;
641  }
642 
643  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
644  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
645  $term_id = ilGlossaryDefinition::_lookupTermId($page_id);
646 
647  include_once('./Services/COPage/classes/class.ilInternalLink.php');
648  $sources = ilInternalLink::_getSourcesOfTarget('git',$term_id, 0);
649 
650  if ($sources)
651  {
652  foreach ($sources as $src)
653  {
654  switch ($src['type'])
655  {
656  // Give access if term is linked by a learning module with read access.
657  // The term including media is shown by the learning module presentation!
658  case 'lm:pg':
659  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
660  $src_obj_id = ilLMObject::_lookupContObjID($src['id']);
661  if ($this->checkAccessObject($src_obj_id, 'lm'))
662  {
663  return true;
664  }
665  break;
666 
667  // Don't yet give access if the term is linked by another glossary
668  // The link will lead to the origin glossary which is already checked
669  /*
670  case 'gdf:pg':
671  $src_term_id = ilGlossaryDefinition::_lookupTermId($src['id']);
672  $src_obj_id = ilGlossaryTerm::_lookGlossaryID($src_term_id);
673  if ($this->checkAccessObject($src_obj_id, 'glo'))
674  {
675  return true;
676  }
677  break;
678  */
679  }
680  }
681  }
682  }
683 
691  private function checkAccessPortfolioPage($obj_id, $page_id)
692  {
693  include_once "Services/Portfolio/classes/class.ilPortfolioAccessHandler.php";
694  $access_handler = new ilPortfolioAccessHandler();
695  foreach ($this->check_users as $user_id)
696  {
697  if ($access_handler->checkAccessOfUser($user_id, "read", "view", $obj_id, "prtf"))
698  {
699  return true;
700  }
701  }
702  return false;
703  }
704 
712  private function checkAccessBlogPage($obj_id, $page_id)
713  {
714  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
715  $tree = new ilWorkspaceTree(0);
716  $node_id = $tree->lookupNodeId($obj_id);
717 
718  // repository
719  if(!$node_id)
720  {
721  return $this->checkAccessObject($obj_id);
722  }
723  // workspace
724  else
725  {
726  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
727  foreach ($this->check_users as $user_id)
728  {
729  $access_handler = new ilWorkspaceAccessHandler($tree);
730  if ($access_handler->checkAccessOfUser($tree, $user_id, "read", "view", $node_id, "blog"))
731  {
732  return true;
733  }
734  }
735  }
736  return false;
737  }
738 
748  private function checkAccessUserImage($usr_id)
749  {
750  global $ilUser, $ilSetting;
751 
752  // check if own image is viewed
753  if ($usr_id == $ilUser->getId())
754  {
755  return true;
756  }
757 
758  // check if image is in the public profile
759  $public_upload = ilObjUser::_lookupPref($usr_id, 'public_upload');
760  if ($public_upload != 'y')
761  {
762  return false;
763  }
764 
765  // check the publication status of the profile
766  $public_profile = ilObjUser::_lookupPref($usr_id, 'public_profile');
767 
768  if ($public_profile == 'g'
769  and $ilSetting->get('enable_global_profiles')
770  and $ilSetting->get('pub_section'))
771  {
772  // globally public
773  return true;
774  }
775  elseif (($public_profile == 'y' or $public_profile == 'g')
776  and $ilUser->getId() != ANONYMOUS_USER_ID)
777  {
778  // public for logged in users
779  return true;
780  }
781  else
782  {
783  // not public
784  return false;
785  }
786  }
787 
788 
794  public function setDisposition($a_disposition)
795  {
796  if (in_array(strtolower($a_disposition), array('inline','attachment','virtual')))
797  {
798  $this->disposition = strtolower($a_disposition);
799  }
800  else
801  {
802  $this->disposition = 'inline';
803  }
804  }
805 
811  public function getDisposition()
812  {
813  return $this->disposition;
814  }
815 
821  public function setSendMimetype($a_send_mimetype)
822  {
823  if (in_array(strtolower($a_send_mimetype), array('','0','off','false')))
824  {
825  $this->mimetype = null;
826  $this->send_mimetype = false;
827  }
828  elseif (in_array(strtolower($a_send_mimetype), array('1','on','true')))
829  {
830  $this->mimetype = null;
831  $this->send_mimetype = true;
832  }
833  else
834  {
835  $this->mimetype = $a_send_mimetype;
836  $this->send_mimetype = true;
837  }
838  }
839 
844  public function getSendMimetype()
845  {
846  return $this->send_mimetype;
847  }
848 
849 
855  public function setCheckIp($a_check_ip)
856  {
857  if (in_array(strtolower($a_check_ip), array('','0','off','false')))
858  {
859  $this->check_ip = false;
860  }
861  elseif (in_array(strtolower($a_check_ip), array('1','on','true')))
862  {
863  $this->check_ip = true;
864  }
865  }
866 
871  public function getCheckIp()
872  {
873  return $this->check_ip;
874  }
875 
876 
881  public function sendFile()
882  {
883  //$system_use_xsendfile = true;
884  $xsendfile_available = false;
885 
886  //if (function_exists('apache_get_modules'))
887  //{
888  // $modules = apache_get_modules();
889  // $xsendfile_available = in_array('mod_xsendfile', $modules);
890  //}
891 
892  //$xsendfile_available = $system_use_xsendfile & $xsendfile_available;
893 
894 
895  // delivery via apache virtual function
896  if ($this->getDisposition() == "virtual")
897  {
898  $this->sendFileVirtual();
899  exit;
900  }
901  // delivery for download dialogue
902  elseif ($this->getDisposition() == "attachment")
903  {
904  if ($xsendfile_available)
905  {
906  header('x-sendfile: ' . $this->file);
907  header("Content-Type: application/octet-stream");
908  }
909  else
910  ilUtil::deliverFile($this->file, basename($this->file));
911  exit;
912  }
913  // inline delivery
914  else
915  {
916  if (!isset($_SERVER["HTTPS"]))
917  {
918  header("Cache-Control: no-cache, must-revalidate");
919  header("Pragma: no-cache");
920  }
921 
922  if ($this->getSendMimetype())
923  {
924  header("Content-Type: " . $this->getMimeType());
925  }
926  header("Content-Length: ".(string)(filesize($this->file)));
927 
928  if (isset($_SERVER["HTTPS"]))
929  {
930  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
931  header('Pragma: public');
932  }
933 
934  header("Connection: close");
935 
936  if ($xsendfile_available)
937  {
938  header('x-sendfile: ' . $this->file);
939  if ($this->getSendMimetype())
940  {
941  header("Content-Type: " . $this->getMimeType());
942  }
943  }
944  else
945  {
946  ilUtil::readFile( $this->file);
947  }
948 
949  exit;
950  }
951  }
952 
962  public function sendFileVirtual()
963  {
967  global $ilLog;
968 
969  header('Last-Modified: '. date ("D, j M Y H:i:s", filemtime($this->file)). " GMT");
970  header('ETag: "'. md5(filemtime($this->file).filesize($this->file)).'"');
971  header('Accept-Ranges: bytes');
972  header("Content-Length: ".(string)(filesize($this->file)));
973  if ($this->getSendMimetype())
974  {
975  header("Content-Type: " . $this->getMimeType());
976  }
977 
978  if(!apache_setenv('ILIAS_CHECKED','1'))
979  {
980  $ilLog->write(__METHOD__.' '.__LINE__.': Could not set the environment variable ILIAS_CHECKED.');
981  }
982 
983  if(!virtual($this->virtual_path))
984  {
985  $ilLog->write(__METHOD__.' '.__LINE__.': Could not perform the required sub-request to deliver the file: '.$this->virtual_path);
986  }
987  exit;
988  }
989 
990 
995  public function sendError()
996  {
997  global $ilSetting, $ilUser, $tpl, $lng, $tree;
998 
999  switch ($this->errorcode)
1000  {
1001  case 404:
1002  header("HTTP/1.0 404 Not Found");
1003  break;
1004  case 403:
1005  default:
1006  header("HTTP/1.0 403 Forbidden");
1007  break;
1008  }
1009 
1010  // set the page base to the ILIAS directory
1011  // to get correct references for images and css files
1012  $tpl->setCurrentBlock("HeadBaseTag");
1013  $tpl->setVariable('BASE', ILIAS_HTTP_PATH . '/error.php');
1014  $tpl->parseCurrentBlock();
1015  $tpl->addBlockFile("CONTENT", "content", "tpl.error.html");
1016 
1017  // Check if user is logged in
1018  $anonymous = ($ilUser->getId() == ANONYMOUS_USER_ID);
1019 
1020  if ($anonymous)
1021  {
1022  // Provide a link to the login screen for anonymous users
1023 
1024  $tpl->SetCurrentBlock("ErrorLink");
1025  $tpl->SetVariable("TXT_LINK", $lng->txt('login_to_ilias'));
1026  $tpl->SetVariable("LINK", ILIAS_HTTP_PATH. '/login.php?cmd=force_login&client_id='.CLIENT_ID);
1027  $tpl->ParseCurrentBlock();
1028  }
1029  else
1030  {
1031  // Provide a link to the repository for authentified users
1032 
1033  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
1034  $txt = $nd['title'] == 'ILIAS' ? $lng->txt('repository') : $nd['title'];
1035 
1036  $tpl->SetCurrentBlock("ErrorLink");
1037  $tpl->SetVariable("TXT_LINK", $txt);
1038  $tpl->SetVariable("LINK", ILIAS_HTTP_PATH. '/ilias.php?baseClass=ilRepositoryGUI&amp;client_id='.CLIENT_ID);
1039  $tpl->ParseCurrentBlock();
1040  }
1041 
1042  $tpl->setCurrentBlock("content");
1043  $tpl->setVariable("ERROR_MESSAGE",($this->errortext));
1044  $tpl->setVariable("SRC_IMAGE", ilUtil::getImagePath("mess_failure.png"));
1045  $tpl->parseCurrentBlock();
1046 
1047  $tpl->show();
1048  exit;
1049  }
1050 
1057  public function getMimeType($default = 'application/octet-stream')
1058  {
1059  // take a previously set mimetype
1060  if (isset($this->mimetype))
1061  {
1062  return $this->mimetype;
1063  }
1064 
1065  $mime = '';
1066  // alex: changed due to bug http://www.ilias.de/mantis/view.php?id=9332
1067 /* if (extension_loaded('Fileinfo'))
1068  {
1069  $finfo = finfo_open(FILEINFO_MIME);
1070  $mime = finfo_file($finfo, $this->file);
1071  finfo_close($finfo);
1072  if ($pos = strpos($mime, ' '))
1073  {
1074  $mime = substr($mime, 0, $pos);
1075  }
1076  }
1077  else
1078  {*/
1079  include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
1080  $mime = ilMimeTypeUtil::getMimeType($this->file);
1081  //$mime = ilObjMediaObject::getMimeType($this->file);
1082 // }
1083 
1084  // set and return the mime type
1085  $this->mimetype = $mime ? $mime : $default;
1086  return $this->mimetype;
1087  }
1088 }
1089 ?>