ILIAS  Release_4_2_x_branch Revision 61807
 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 
34 // Now the ILIAS header can be included
35 require_once "./include/inc.header.php";
36 require_once "./Services/Utilities/classes/class.ilUtil.php";
37 require_once "./classes/class.ilObject.php";
38 require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
39 
40 
55 {
56  var $lng;
57  var $ilAccess;
58 
64  var $subpath;
65 
71  var $file;
72 
78  var $params;
79 
80 
86  var $disposition = "inline";
87 
93  var $check_ip = false;
94 
95 
103  var $check_users = array();
104 
110  var $send_mimetype = true;
111 
112 
119  var $mimetype = null;
120 
121 
128 
129 
136 
137 
143  {
144  global $ilUser, $ilAccess, $lng, $ilLog;
145 
146  $this->lng =& $lng;
147  $this->ilAccess =& $ilAccess;
148  $this->params = array();
149 
150  // get the requested file and its type
151  $uri = parse_url($_SERVER["REQUEST_URI"]);
152  parse_str($uri["query"], $this->params);
153 
154  $pattern = ILIAS_WEB_DIR . "/" . CLIENT_ID;
155  $this->subpath = urldecode(substr($uri["path"], strpos($uri["path"], $pattern)));
156  $this->file = realpath(ILIAS_ABSOLUTE_PATH . "/". $this->subpath);
157 
158  // build url path for virtual function
159  $this->virtual_path = str_replace($pattern, "virtual-" . $pattern, $uri["path"]);
160 
161 
162  // set the parameters provided with the checker call
163  if (isset($_GET['disposition']))
164  {
165  $this->setDisposition($_GET['disposition']);
166  }
167  if (isset($_GET['check_ip']))
168  {
169  $this->setCheckIp($_GET['check_ip']);
170  }
171  if (isset($_GET['send_mimetype']))
172  {
173  $this->setSendMimetype($_GET['send_mimetype']);
174  }
175 
176  // debugging
177  /*echo "<pre>";
178  echo "REQUEST_URI: ". $_SERVER["REQUEST_URI"]. "\n";
179  echo "Parsed URI: ". $uri["path"]. "\n";
180  echo "DOCUMENT_ROOT: ". $_SERVER["DOCUMENT_ROOT"]. "\n";
181  echo "PHP_SELF: ". $_SERVER["PHP_SELF"]. "\n";
182  echo "SCRIPT_NAME: ". $_SERVER["SCRIPT_NAME"]. "\n";
183  echo "SCRIPT_FILENAME: ". $_SERVER["SCRIPT_FILENAME"]. "\n";
184  echo "PATH_TRANSLATED: ". $_SERVER["PATH_TRANSLATED"]. "\n";
185  echo "ILIAS_WEB_DIR: ". ILIAS_WEB_DIR. "\n";
186  echo "ILIAS_HTTP_PATH: ". ILIAS_HTTP_PATH. "\n";
187  echo "ILIAS_ABSOLUTE_PATH: ". ILIAS_ABSOLUTE_PATH. "\n";
188  echo "CLIENT_ID: ". CLIENT_ID. "\n";
189  echo "CLIENT_WEB_DIR: ". CLIENT_WEB_DIR. "\n";
190  echo "subpath: ". $this->subpath. "\n";
191  echo "file: ". $this->file. "\n";
192  echo "disposition: ". $this->disposition. "\n";
193  echo "ckeck_ip: ". $this->check_ip. "\n";
194  echo "send_mimetype: ". $this->send_mimetype. "\n";
195  echo "</pre>";
196  echo phpinfo();
197  exit;*/
198 
199 
200  if (!file_exists($this->file))
201  {
202  $this->errorcode = 404;
203  $this->errortext = $this->lng->txt("url_not_found");
204  return false;
205  }
206  }
207 
211  public function determineUser()
212  {
213  global $ilUser;
214 
215  // a valid user session is found
216  if ($_SESSION["AccountId"])
217  {
218  $this->check_users = array($_SESSION["AccountId"]);
219  return;
220  }
221 
222  // no session cookie was delivered
223  // user identification by ip address is allowed
224  elseif ($GLOBALS['WEB_ACCESS_WITHOUT_SESSION'] and $this->getCheckIp())
225  {
226  $this->check_users = ilSession::_getUsersWithIp($_SERVER['REMOTE_ADDR']);
227 
228  if (count($this->check_users) == 0)
229  {
230  // no user was found for the ip address
231  $this->check_users = array(ANONYMOUS_USER_ID);
232 
233  $_SESSION["AccountId"] = ANONYMOUS_USER_ID;
234  $ilUser->setId(ANONYMOUS_USER_ID);
235  $ilUser->read();
236  }
237  elseif (count($this->check_users) == 1)
238  {
239  // exactly one user is found with an active session
240  $_SESSION["AccountId"] = current($this->check_users);
241  $ilUser->setId(current($this->check_users));
242  $ilUser->read();
243  }
244  else
245  {
246  // more than one user found for the ip address
247  // take the anonymous user for the session
248  $_SESSION["AccountId"] = ANONYMOUS_USER_ID;
249  $ilUser->setId(ANONYMOUS_USER_ID);
250  $ilUser->read();
251  }
252  return;
253  }
254 
255  // take the anonymous user as fallback
256  else
257  {
258  $this->check_users = array(ANONYMOUS_USER_ID);
259 
260  $_SESSION["AccountId"] = ANONYMOUS_USER_ID;
261  $ilUser->setId(ANONYMOUS_USER_ID);
262  $ilUser->read();
263 
264  return;
265  }
266  }
267 
272  public function checkAccess()
273  {
274  global $ilLog, $ilUser, $ilObjDataCache;
275 
276  // an error already occurred at class initialisation
277  if ($this->errorcode)
278  {
279  return false;
280  }
281 
282  // do this here because ip based checking may be set after construction
283  $this->determineUser();
284 
285  // check for type by subdirectory
286  $pos1 = strpos($this->subpath, "lm_data/lm_") + 11;
287  $pos2 = strpos($this->subpath, "mobs/mm_") + 8;
288  $pos3 = strpos($this->subpath, "usr_images/") + 11;
289 
290  $obj_id = 0;
291  $type = 'none';
292  // trying to access data within a learning module folder
293  if ($pos1 > 11)
294  {
295  $type = 'lm';
296  $seperator = strpos($this->subpath, '/', $pos1);
297  $obj_id = substr($this->subpath, $pos1, ($seperator > 0 ? $seperator : strlen($this->subpath))-$pos1);
298  }
299  //trying to access media data
300  else if ($pos2 > 8)
301  {
302  $type = 'mob';
303  $seperator = strpos($this->subpath, '/', $pos2);
304  $obj_id = substr($this->subpath, $pos2, ($seperator > 0 ? $seperator : strlen($this->subpath))-$pos2);
305  }
306  // trying to access a user image
307  elseif ($pos3 > 11)
308  {
309  $type = 'user_image';
310  // user images may be:
311  // upload_123pic, upload_123
312  // usr_123.jpg, usr_123_small.jpg, usr_123_xsmall.jpg, usr_123_xxsmall.jpg
313  $seperator = strpos($this->subpath, '_', $pos3);
314  $obj_id = (int) substr($this->subpath, $seperator + 1);
315  }
316 
317  if (!$obj_id || $type == 'none')
318  {
319  $this->errorcode = 404;
320  $this->errortext = $this->lng->txt("obj_not_found");
321  return false;
322  }
323 
324  switch($type)
325  {
326  // SCORM or HTML learning module
327  case 'lm':
328  if ($this->checkAccessObject($obj_id))
329  {
330  return true;
331  }
332  break;
333 
334  // media object
335  case 'mob':
336  if ($this->checkAccessMob($obj_id))
337  {
338  return true;
339  }
340  break;
341 
342  // image in user profile
343  case 'user_image':
344  if ($this->checkAccessUserImage($obj_id))
345  {
346  return true;
347  }
348  break;
349  }
350 
351  // none of the checks above gives access
352  $this->errorcode = 403;
353  $this->errortext = $this->lng->txt('msg_no_perm_read');
354  return false;
355  }
356 
363  function checkAccessMob($obj_id)
364  {
365  $usages = ilObjMediaObject::lookupUsages($obj_id);
366 
367  foreach($usages as $usage)
368  {
369  $oid = ilObjMediaObject::getParentObjectIdForUsage($usage, true);
370 
371  // for content snippets we must get their usages and check them
372  if ($usage["type"] == "mep:pg")
373  {
374  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
375  $usages2 = ilMediaPoolPage::lookupUsages($usage["id"]);
376  foreach($usages2 as $usage2)
377  {
378  $oid2 = ilObjMediaObject::getParentObjectIdForUsage($usage2, true);
379  if ($this->checkAccessMobUsage($usage2, $oid2))
380  {
381  return true;
382  }
383  }
384  }
385  else // none content snippets just go the usual way
386  {
387  if ($this->checkAccessMobUsage($usage, $oid))
388  {
389  return true;
390  }
391  }
392  }
393 
394  return false;
395  }
396 
403  function checkAccessMobUsage($usage, $oid)
404  {
405  switch($usage['type'])
406  {
407  case 'lm:pg':
408  if ($oid > 0)
409  {
410  if ($this->checkAccessLM($oid, 'lm', $usage['id']))
411  {
412  return true;
413  }
414  }
415  break;
416  case 'news':
417  // media objects in news (media casts)
418  include_once("./Modules/MediaCast/classes/class.ilObjMediaCastAccess.php");
419  include_once("./Services/News/classes/class.ilNewsItem.php");
420 
421  if ($this->checkAccessObject($oid, 'mcst'))
422  {
423  return true;
424  }
426  {
427  return true;
428  }
429  break;
430 
431 
432  case 'frm~:html':
433  // $oid = userid
434  foreach ($this->check_users as $user_id)
435  {
436  if ($ilObjDataCache->lookupType($oid) == 'usr' && $oid == $user_id)
437  {
438  return true;
439  }
440  }
441  break;
442 
443  case 'qpl:pg':
444  case 'qpl:html':
445  // test questions
446  if ($this->checkAccessTestQuestion($oid, $usage['id']))
447  {
448  return true;
449  }
450  break;
451 
452  case 'gdf:pg':
453  // special check for glossary terms
454  if ($this->checkAccessGlossaryTerm($oid, $usage['id']))
455  {
456  return true;
457  }
458  break;
459 
460  case 'sahs:pg':
461  // check for scorm pages
462  if ($this->checkAccessObject($oid, 'sahs'))
463  {
464  return true;
465  }
466  break;
467 
468  case 'prtf:pg':
469  // special check for portfolio pages
470  if ($this->checkAccessPortfolioPage($oid, $usage['id']))
471  {
472  return true;
473  }
474  break;
475 
476  case 'blp:pg':
477  // special check for blog pages
478  if ($this->checkAccessBlogPage($oid, $usage['id']))
479  {
480  return true;
481  }
482  break;
483 
484  default:
485  // standard object check
486  if ($this->checkAccessObject($oid))
487  {
488  return true;
489  }
490  break;
491  }
492 
493  return false;
494  }
495 
496 
505  private function checkAccessLM($obj_id, $obj_type, $page = 0)
506  {
507  global $lng;
508 
509  //if (!$page)
510  //{
511  $ref_ids = ilObject::_getAllReferences($obj_id);
512  foreach($ref_ids as $ref_id)
513  {
514  foreach ($this->check_users as $user_id)
515  {
516  if ($this->ilAccess->checkAccessOfUser($user_id, "read", "view", $ref_id, $obj_type, $obj_id))
517  {
518  return true;
519  }
520  }
521  }
522  return false;
523  //}
524  //else
525  //{
526  // $ref_ids = ilObject::_getAllReferences($obj_id);
527  // foreach($ref_ids as $ref_id)
528  // {
529  // if ($this->ilAccess->checkAccess("read", "", $ref_id))
530  // {
531  // require_once 'Modules/LearningModule/classes/class.ilObjLearningModule.php';
532  // $lm = new ilObjLearningModule($obj_id,false);
533  // if ($lm->_checkPreconditionsOfPage($ref_id, $obj_id, $page))
534  // return true;
535  // }
536  // }
537  // return false;
538  //}
539  }
540 
547  private function checkAccessObject($obj_id, $obj_type = '')
548  {
549  global $ilAccess;
550 
551  if (!$obj_type)
552  {
553  $obj_type = ilObject::_lookupType($obj_id);
554  }
555  $ref_ids = ilObject::_getAllReferences($obj_id);
556 
557  foreach($ref_ids as $ref_id)
558  {
559  foreach ($this->check_users as $user_id)
560  {
561  if ($ilAccess->checkAccessOfUser($user_id, "read", "view", $ref_id, $obj_type, $obj_id))
562  {
563  return true;
564  }
565  }
566  }
567  return false;
568  }
569 
570 
579  private function checkAccessTestQuestion($obj_id, $usage_id = 0)
580  {
581  global $ilAccess;
582 
583  // give access if direct usage is readable
584  if ($this->checkAccessObject($obj_id))
585  {
586  return true;
587  }
588 
589  $obj_type = ilObject::_lookupType($obj_id);
590  if ($obj_type == 'qpl')
591  {
592  // give access if question pool is used by readable test
593  // for random selection of questions
594  include_once('./Modules/Test/classes/class.ilObjTestAccess.php');
596  foreach ($tests as $test_id)
597  {
598  if ($this->checkAccessObject($test_id, 'tst'))
599  {
600  return true;
601  }
602  }
603  }
604  return false;
605  }
606 
607 
616  private function checkAccessGlossaryTerm($obj_id, $page_id)
617  {
618  // give access if glossary is readable
619  if ($this->checkAccessObject($obj_id))
620  {
621  return true;
622  }
623 
624  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
625  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
626  $term_id = ilGlossaryDefinition::_lookupTermId($page_id);
627 
628  include_once('./Services/COPage/classes/class.ilInternalLink.php');
629  $sources = ilInternalLink::_getSourcesOfTarget('git',$term_id, 0);
630 
631  if ($sources)
632  {
633  foreach ($sources as $src)
634  {
635  switch ($src['type'])
636  {
637  // Give access if term is linked by a learning module with read access.
638  // The term including media is shown by the learning module presentation!
639  case 'lm:pg':
640  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
641  $src_obj_id = ilLMObject::_lookupContObjID($src['id']);
642  if ($this->checkAccessObject($src_obj_id, 'lm'))
643  {
644  return true;
645  }
646  break;
647 
648  // Don't yet give access if the term is linked by another glossary
649  // The link will lead to the origin glossary which is already checked
650  /*
651  case 'gdf:pg':
652  $src_term_id = ilGlossaryDefinition::_lookupTermId($src['id']);
653  $src_obj_id = ilGlossaryTerm::_lookGlossaryID($src_term_id);
654  if ($this->checkAccessObject($src_obj_id, 'glo'))
655  {
656  return true;
657  }
658  break;
659  */
660  }
661  }
662  }
663  }
664 
672  private function checkAccessPortfolioPage($obj_id, $page_id)
673  {
674  include_once "Services/Portfolio/classes/class.ilPortfolioAccessHandler.php";
675  $access_handler = new ilPortfolioAccessHandler();
676  foreach ($this->check_users as $user_id)
677  {
678  if ($access_handler->checkAccessOfUser($user_id, "read", "view", $obj_id, "prtf"))
679  {
680  return true;
681  }
682  }
683  return false;
684  }
685 
693  private function checkAccessBlogPage($obj_id, $page_id)
694  {
695  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
696  $tree = new ilWorkspaceTree(0);
697  $node_id = $tree->lookupNodeId($obj_id);
698 
699  // repository
700  if(!$node_id)
701  {
702  return $this->checkAccessObject($obj_id);
703  }
704  // workspace
705  else
706  {
707  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
708  foreach ($this->check_users as $user_id)
709  {
710  $access_handler = new ilWorkspaceAccessHandler($tree);
711  if ($access_handler->checkAccessOfUser($tree, $user_id, "read", "view", $node_id, "blog"))
712  {
713  return true;
714  }
715  }
716  }
717  return false;
718  }
719 
729  private function checkAccessUserImage($usr_id)
730  {
731  global $ilUser, $ilSetting;
732 
733  // check if own image is viewed
734  if ($usr_id == $ilUser->getId())
735  {
736  return true;
737  }
738 
739  // check if image is in the public profile
740  $public_upload = ilObjUser::_lookupPref($usr_id, 'public_upload');
741  if ($public_upload != 'y')
742  {
743  return false;
744  }
745 
746  // check the publication status of the profile
747  $public_profile = ilObjUser::_lookupPref($usr_id, 'public_profile');
748 
749  if ($public_profile == 'g'
750  and $ilSetting->get('enable_global_profiles')
751  and $ilSetting->get('pub_section'))
752  {
753  // globally public
754  return true;
755  }
756  elseif (($public_profile == 'y' or $public_profile == 'g')
757  and $ilUser->getId() != ANONYMOUS_USER_ID)
758  {
759  // public for logged in users
760  return true;
761  }
762  else
763  {
764  // not public
765  return false;
766  }
767  }
768 
769 
775  public function setDisposition($a_disposition)
776  {
777  if (in_array(strtolower($a_disposition), array('inline','attachment','virtual')))
778  {
779  $this->disposition = strtolower($a_disposition);
780  }
781  else
782  {
783  $this->disposition = 'inline';
784  }
785  }
786 
792  public function getDisposition()
793  {
794  return $this->disposition;
795  }
796 
802  public function setSendMimetype($a_send_mimetype)
803  {
804  if (in_array(strtolower($a_send_mimetype), array('','0','off','false')))
805  {
806  $this->mimetype = null;
807  $this->send_mimetype = false;
808  }
809  elseif (in_array(strtolower($a_send_mimetype), array('1','on','true')))
810  {
811  $this->mimetype = null;
812  $this->send_mimetype = true;
813  }
814  else
815  {
816  $this->mimetype = $a_send_mimetype;
817  $this->send_mimetype = true;
818  }
819  }
820 
825  public function getSendMimetype()
826  {
827  return $this->send_mimetype;
828  }
829 
830 
836  public function setCheckIp($a_check_ip)
837  {
838  if (in_array(strtolower($a_check_ip), array('','0','off','false')))
839  {
840  $this->check_ip = false;
841  }
842  elseif (in_array(strtolower($a_check_ip), array('1','on','true')))
843  {
844  $this->check_ip = true;
845  }
846  }
847 
852  public function getCheckIp()
853  {
854  return $this->check_ip;
855  }
856 
857 
862  public function sendFile()
863  {
864  //$system_use_xsendfile = true;
865  $xsendfile_available = false;
866 
867  //if (function_exists('apache_get_modules'))
868  //{
869  // $modules = apache_get_modules();
870  // $xsendfile_available = in_array('mod_xsendfile', $modules);
871  //}
872 
873  //$xsendfile_available = $system_use_xsendfile & $xsendfile_available;
874 
875 
876  // delivery via apache virtual function
877  if ($this->getDisposition() == "virtual")
878  {
879  $this->sendFileVirtual();
880  exit;
881  }
882  // delivery for download dialogue
883  elseif ($this->getDisposition() == "attachment")
884  {
885  if ($xsendfile_available)
886  {
887  header('x-sendfile: ' . $this->file);
888  header("Content-Type: application/octet-stream");
889  }
890  else
891  ilUtil::deliverFile($this->file, basename($this->file));
892  exit;
893  }
894  // inline delivery
895  else
896  {
897  if (!isset($_SERVER["HTTPS"]))
898  {
899  header("Cache-Control: no-cache, must-revalidate");
900  header("Pragma: no-cache");
901  }
902 
903  if ($this->getSendMimetype())
904  {
905  header("Content-Type: " . $this->getMimeType());
906  }
907  header("Content-Length: ".(string)(filesize($this->file)));
908 
909  if (isset($_SERVER["HTTPS"]))
910  {
911  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
912  header('Pragma: public');
913  }
914 
915  header("Connection: close");
916 
917  if ($xsendfile_available)
918  {
919  header('x-sendfile: ' . $this->file);
920  if ($this->getSendMimetype())
921  {
922  header("Content-Type: " . $this->getMimeType());
923  }
924  }
925  else
926  {
927  ilUtil::readFile( $this->file);
928  }
929 
930  exit;
931  }
932  }
933 
943  public function sendFileVirtual()
944  {
945  header('Last-Modified: '. date ("D, j M Y H:i:s", filemtime($this->file)). " GMT");
946  header('ETag: "'. md5(filemtime($this->file).filesize($this->file)).'"');
947  header('Accept-Ranges: bytes');
948  header("Content-Length: ".(string)(filesize($this->file)));
949  if ($this->getSendMimetype())
950  {
951  header("Content-Type: " . $this->getMimeType());
952  }
953 
954  apache_setenv('ILIAS_CHECKED','1');
955  virtual($this->virtual_path);
956  exit;
957  }
958 
959 
964  public function sendError()
965  {
966  global $ilSetting, $ilUser, $tpl, $lng, $tree;
967 
968  switch ($this->errorcode)
969  {
970  case 404:
971  header("HTTP/1.0 404 Not Found");
972  break;
973  case 403:
974  default:
975  header("HTTP/1.0 403 Forbidden");
976  break;
977  }
978 
979  // set the page base to the ILIAS directory
980  // to get correct references for images and css files
981  $tpl->setCurrentBlock("HeadBaseTag");
982  $tpl->setVariable('BASE', ILIAS_HTTP_PATH . '/error.php');
983  $tpl->parseCurrentBlock();
984  $tpl->addBlockFile("CONTENT", "content", "tpl.error.html");
985 
986  // Check if user is logged in
987  $anonymous = ($ilUser->getId() == ANONYMOUS_USER_ID);
988 
989  if ($anonymous)
990  {
991  // Provide a link to the login screen for anonymous users
992 
993  $tpl->SetCurrentBlock("ErrorLink");
994  $tpl->SetVariable("TXT_LINK", $lng->txt('login_to_ilias'));
995  $tpl->SetVariable("LINK", ILIAS_HTTP_PATH. '/login.php?cmd=force_login&client_id='.CLIENT_ID);
996  $tpl->ParseCurrentBlock();
997  }
998  else
999  {
1000  // Provide a link to the repository for authentified users
1001 
1002  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
1003  $txt = $nd['title'] == 'ILIAS' ? $lng->txt('repository') : $nd['title'];
1004 
1005  $tpl->SetCurrentBlock("ErrorLink");
1006  $tpl->SetVariable("TXT_LINK", $txt);
1007  $tpl->SetVariable("LINK", ILIAS_HTTP_PATH. '/repository.php?client_id='.CLIENT_ID);
1008  $tpl->ParseCurrentBlock();
1009  }
1010 
1011  $tpl->setCurrentBlock("content");
1012  $tpl->setVariable("ERROR_MESSAGE",($this->errortext));
1013  $tpl->setVariable("SRC_IMAGE", ilUtil::getImagePath("mess_failure.gif"));
1014  $tpl->parseCurrentBlock();
1015 
1016  $tpl->show();
1017  exit;
1018  }
1019 
1026  public function getMimeType($default = 'application/octet-stream')
1027  {
1028  // take a previously set mimetype
1029  if (isset($this->mimetype))
1030  {
1031  return $this->mimetype;
1032  }
1033 
1034  $mime = '';
1035  if (extension_loaded('Fileinfo'))
1036  {
1037  $finfo = finfo_open(FILEINFO_MIME);
1038  $mime = finfo_file($finfo, $this->file);
1039  finfo_close($finfo);
1040  if ($pos = strpos($mime, ' '))
1041  {
1042  $mime = substr($mime, 0, $pos);
1043  }
1044  }
1045  else
1046  {
1047  $mime = ilObjMediaObject::getMimeType($this->file);
1048  }
1049 
1050  // set and return the mime type
1051  $this->mimetype = $mime ? $mime : $default;
1052  return $this->mimetype;
1053  }
1054 }
1055 ?>