ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilWebAccessCheckerDelivery.php
Go to the documentation of this file.
1 <?php
2 require_once('./Services/WebAccessChecker/classes/class.ilWebAccessChecker.php');
3 require_once('./Services/WebAccessChecker/classes/class.ilHTTP.php');
4 require_once('./Services/FileDelivery/classes/class.ilFileDelivery.php');
5 
12 
16  protected $ilWebAccessChecker = null;
17 
18 
22  public static function run($raw_path) {
23  $obj = new self($raw_path);
24  $obj->handleRequest();
25  }
26 
27 
33  public function __construct($raw_path) {
34  $this->ilWebAccessChecker = new ilWebAccessChecker(rawurldecode($raw_path));
35  }
36 
37 
38  protected function handleRequest() {
39  // Set errorreporting
41 
42  // Set customizing
44  $this->ilWebAccessChecker->setDisposition($_GET[ilWebAccessChecker::DISPOSITION]);
45  }
47  $this->ilWebAccessChecker->setSendStatusCode($_GET[ilWebAccessChecker::STATUS_CODE]);
48  }
50  $this->ilWebAccessChecker->setRevalidateFolderTokens($_GET[ilWebAccessChecker::REVALIDATE]);
51  }
52 
53  // Check if File can be delivered
54  try {
55  if ($this->ilWebAccessChecker->check()) {
56  $this->deliver();
57  } else {
58  $this->deny();
59  }
60  } catch (ilWACException $e) {
61  switch ($e->getCode()) {
65  $this->handleAccessErrors($e);
66  break;
70  default:
71  $this->handleErrors($e);
72  break;
73  }
74  }
75  }
76 
77 
78  protected function deny() {
79  if (!$this->ilWebAccessChecker->isChecked()) {
81  }
83  }
84 
85 
86  protected function deliverDummyImage() {
87  $ilFileDelivery = new ilFileDelivery('./Services/WebAccessChecker/templates/images/access_denied.png', $this->ilWebAccessChecker->getPathObject()
88  ->getFileName());
89  $ilFileDelivery->setDisposition($this->ilWebAccessChecker->getDisposition());
90  $ilFileDelivery->deliver();
91  }
92 
93 
94  protected function deliverDummyVideo() {
95  $ilFileDelivery = new ilFileDelivery('./Services/WebAccessChecker/templates/images/access_denied.mp4', $this->ilWebAccessChecker->getPathObject()
96  ->getFileName());
97  $ilFileDelivery->setDisposition($this->ilWebAccessChecker->getDisposition());
98  $ilFileDelivery->stream();
99  }
100 
101 
105  protected function handleAccessErrors(ilWACException $e) {
106  if ($this->ilWebAccessChecker->isSendStatusCode()) {
107  ilHTTP::status(401);
108  }
109  if ($this->ilWebAccessChecker->getPathObject()->isImage()) {
110  $this->deliverDummyImage();
111  }
112  if ($this->ilWebAccessChecker->getPathObject()->isVideo()) {
113  $this->deliverDummyVideo();
114  }
115  try {
116  $this->ilWebAccessChecker->initILIAS();
117  } catch (ilWACException $ilWACException) {
118  }
119 
120  global $tpl, $ilLog;
121  $ilLog->write($e->getMessage());
122  $tpl->setVariable('BASE', strstr($_SERVER['REQUEST_URI'], '/data', true) . '/');
123  ilUtil::sendFailure($e->getMessage());
124  $tpl->getStandardTemplate();
125  $tpl->show();
126  }
127 
128 
132  protected function handleErrors(ilWACException $e) {
133  ilHTTP::status(500);
134  echo $e->getMessage();
135  }
136 
137 
138  protected function deliver() {
139  if (!$this->ilWebAccessChecker->isChecked()) {
141  }
142 
143  $ilFileDelivery = new ilFileDelivery($this->ilWebAccessChecker->getPathObject()->getPath());
144  $ilFileDelivery->setCache(false);
145  $ilFileDelivery->setDisposition($this->ilWebAccessChecker->getDisposition());
146  ilWACLog::getInstance()->write('Deliver file using ' . $ilFileDelivery->getDeliveryType());
147  if ($this->ilWebAccessChecker->getPathObject()->isStreamable()) { // fixed 0016468
148  ilWACLog::getInstance()->write('begin streaming');
149  $ilFileDelivery->stream();
150  } else {
151  $ilFileDelivery->deliver();
152  }
153  }
154 }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
Class ilWACException.
$_GET["client_id"]
__construct($raw_path)
ilWebAccessCheckerDelivery constructor.
static getInstance()
setRevalidateFolderTokens($revalidate_folder_tokens)
static status($status)
global $tpl
Definition: ilias.php:8
Class ilWebAccessChecker.
setSendStatusCode($send_status_code)
setDisposition($disposition)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilFileDelivery.
Class ilWebAccessCheckerDelivery.
static handleErrorReporting()
Set error reporting level.