true);
}
+ /**
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
function csrf_ignore($method) {
return false;
}
+ /**
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
function before($method) {
return true;
}
if ($hash) {
- $filename = $this->cache_dir . "/" . $hash;
- $is_video = strpos($filename, ".mp4") !== FALSE;
+ $filename = $this->cache_dir . "/" . basename($hash);
if (file_exists($filename)) {
- /* See if we can use X-Sendfile */
- $xsendfile = false;
- if (function_exists('apache_get_modules') &&
- array_search('mod_xsendfile', apache_get_modules()))
- $xsendfile = true;
-
- if ($xsendfile) {
- header("X-Sendfile: $filename");
- header("Content-type: application/octet-stream");
- header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
- } else {
- header("Content-type: " . ($is_video ? "video/mp4" : "image/png"));
- $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)). " GMT";
- header("Last-Modified: $stamp", true);
- readfile($filename);
- }
+ header("Content-Disposition: attachment; filename=\"$hash\"");
+
+ send_local_file($filename);
} else {
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
echo "File not found.";
}
}
+ /**
+ * @SuppressWarnings(PHPMD.UnusedLocalVariable)
+ */
function hook_house_keeping() {
$files = glob($this->cache_dir . "/*.{png,mp4}", GLOB_BRACE);
}
}
+ /**
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) {
$xpath = new DOMXpath($doc);
}
}
+ /**
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
function cache_article_images($content, $site_url, $owner_uid, $article_id) {
libxml_use_internal_errors(true);
foreach ($entries as $entry) {
- if ($entry->hasAttribute('src')) {
+ if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) {
+
$has_images = true;
$src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
if (!file_exists($local_filename)) {
$file_content = fetch_file_contents($src);
- if ($file_content && strlen($file_content) > 0) {
+ if ($file_content && strlen($file_content) > MIN_CACHE_FILE_SIZE) {
file_put_contents($local_filename, $file_content);
$success = true;
}
return 2;
}
}
-?>