Public Member Functions | |
| ilWebAccessChecker () | |
| Constructor public. | |
| checkAccess () | |
| Check access rights of the requested file public. | |
| sendFile () | |
| Send the requested file as if directly delivered from the web server public. | |
| sendError () | |
| Send an error response for the requested file public. | |
Data Fields | |
| $lng | |
| $ilAccess | |
| $checked_list | |
| $subpath | |
| $file | |
| $mimetype | |
| $errorcode | |
| $errortext | |
Definition at line 44 of file class.ilWebAccessChecker.php.
| ilWebAccessChecker::checkAccess | ( | ) |
Check access rights of the requested file public.
Definition at line 143 of file class.ilWebAccessChecker.php.
References $obj_id, $ref_id, ilObject::_getAllReferences(), and ilObject::_lookupType().
{
// extract the object id (currently only for learning modules)
$pos1 = strpos($this->subpath, "lm_data/lm_") + 11;
$pos2 = strpos($this->subpath, "/", $pos1);
if ($pos1 === false or $pos2 === false)
{
$this->errorcode = 404;
$this->errortext = $this->lng->txt("url_not_found");
return false;
}
$obj_id = substr($this->subpath, $pos1, $pos2-$pos1);
if (!is_numeric($obj_id))
{
$this->errorcode = 404;
$this->errortext = $this->lng->txt("obj_not_found");
return false;
}
// look in cache, if already checked
if (is_array($this->checked_list))
{
if (in_array($obj_id, $this->checked_list))
{
return true;
}
}
// find the object references
$obj_type = ilObject::_lookupType($obj_id);
$ref_ids = ilObject::_getAllReferences($obj_id);
if (!$ref_ids)
{
$this->errorcode = 403;
$this->errortext = $this->lng->txt("permission_denied");
return false;
}
// check, if one of the references is readable
$readable = false;
foreach($ref_ids as $ref_id)
{
if ($this->ilAccess->checkAccess("read", "view", $ref_id, $obj_type, $obj_id))
{
$readable = true;
break;
}
}
if ($readable)
{
//add object to cache
$this->checked_list[] = $obj_id;
return true;
}
else
{
$this->errorcode = 403;
$this->errortext = $this->lng->txt("permission_denied");
return false;
}
}
Here is the call graph for this function:| ilWebAccessChecker::ilWebAccessChecker | ( | ) |
Constructor public.
Definition at line 92 of file class.ilWebAccessChecker.php.
References $_SESSION, $ilAccess, $lng, and ilObjMediaObject::getMimeType().
{
global $ilAccess, $lng;
$this->lng =& $lng;
$this->ilAccess =& $ilAccess;
$this->checked_list = & $_SESSION["WebAccessChecked"];
// get the requested file and its type
$uri = parse_url($_SERVER["REQUEST_URI"]);
$pattern = ILIAS_WEB_DIR . "/" . CLIENT_ID;
$this->subpath = substr($uri["path"], strpos($uri["path"], $pattern));
$this->file = realpath(ILIAS_ABSOLUTE_PATH . "/". $this->subpath);
/* debugging
echo "<pre>";
echo "REQUEST_URI: ". $_SERVER["REQUEST_URI"]. "\n";
echo "Parsed URI: ". $uri["path"]. "\n";
echo "DOCUMENT_ROOT: ". $_SERVER["DOCUMENT_ROOT"]. "\n";
echo "PHP_SELF: ". $_SERVER["PHP_SELF"]. "\n";
echo "SCRIPT_NAME: ". $_SERVER["SCRIPT_NAME"]. "\n";
echo "SCRIPT_FILENAME: ". $_SERVER["SCRIPT_FILENAME"]. "\n";
echo "PATH_TRANSLATED: ". $_SERVER["PATH_TRANSLATED"]. "\n";
echo "ILIAS_WEB_DIR: ". ILIAS_WEB_DIR. "\n";
echo "ILIAS_HTTP_PATH: ". ILIAS_HTTP_PATH. "\n";
echo "ILIAS_ABSOLUTE_PATH: ". ILIAS_ABSOLUTE_PATH. "\n";
echo "CLIENT_ID: ". CLIENT_ID. "\n";
echo "CLIENT_WEB_DIR: ". CLIENT_WEB_DIR. "\n";
echo "subpath: ". $this->subpath. "\n";
echo "file: ". $this->file. "\n";
echo "</pre>";
exit;
*/
if (file_exists($this->file))
{
$this->mimetype = ilObjMediaObject::getMimeType($this->file);
}
else
{
$this->errorcode = 404;
$this->errortext = $this->lng->txt("url_not_found");
return false;
}
}
Here is the call graph for this function:| ilWebAccessChecker::sendError | ( | ) |
Send an error response for the requested file public.
Definition at line 241 of file class.ilWebAccessChecker.php.
References exit.
{
switch ($this->errorcode)
{
case 403:
header("HTTP/1.0: 403 Forbidden");
break;
case 404:
header("HTTP/1.0: 404 Not Found");
break;
}
exit($this->errortext);
}
| ilWebAccessChecker::sendFile | ( | ) |
Send the requested file as if directly delivered from the web server public.
Copied from ilUtil - needed here? Set the following headers to make downloads work using IE in HTTPS mode.
Definition at line 209 of file class.ilWebAccessChecker.php.
References exit, and ilUtil::readFile().
{
if (isset($_SERVER["HTTPS"]))
{
header("Pragma: ");
header("Cache-Control: ");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
}
else
{
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
}
header("Content-Type: " . $this->mimetype);
header("Content-Length: ".(string)(filesize($this->file)));
header("Connection: close");
ilUtil::readFile( $this->file );
exit;
}
Here is the call graph for this function:| ilWebAccessChecker::$checked_list |
Definition at line 48 of file class.ilWebAccessChecker.php.
| ilWebAccessChecker::$errorcode |
Definition at line 77 of file class.ilWebAccessChecker.php.
| ilWebAccessChecker::$errortext |
Definition at line 85 of file class.ilWebAccessChecker.php.
| ilWebAccessChecker::$file |
Definition at line 62 of file class.ilWebAccessChecker.php.
| ilWebAccessChecker::$ilAccess |
Definition at line 47 of file class.ilWebAccessChecker.php.
Referenced by ilWebAccessChecker().
| ilWebAccessChecker::$lng |
Definition at line 46 of file class.ilWebAccessChecker.php.
Referenced by ilWebAccessChecker().
| ilWebAccessChecker::$mimetype |
Definition at line 70 of file class.ilWebAccessChecker.php.
| ilWebAccessChecker::$subpath |
Definition at line 55 of file class.ilWebAccessChecker.php.
1.7.1