forked from webregie/rexseo42
-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.inc.php
85 lines (66 loc) · 2.57 KB
/
controller.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
global $REX;
if (rex_request('seo42_func')!='')
{
switch (rex_request('seo42_func'))
{
case 'sitemap':
require_once $REX['INCLUDE_PATH'].'/addons/seo42/classes/class.seo42_sitemap.inc.php';
$map = new seo42_sitemap();
switch(rex_request('mode'))
{
case'json':
$map->setMode('json');
$map->send();
break;
default:
$map->send();
}
die();
break;
case 'robots':
require_once $REX['INCLUDE_PATH'].'/addons/seo42/classes/class.seo42_robots.inc.php';
$robots = new seo42_robots();
$robots->setContent($REX['ADDON']['seo42']['settings']['robots']);
$robots->addSitemapLink();
$robots->send();
die();
break;
case 'download':
error_reporting(0);
@ini_set('display_errors', 0);
if ((isset($REX['ADDON']['seo42']['settings']['force_download_for_filetypes']) && is_array($REX['ADDON']['seo42']['settings']['force_download_for_filetypes']) && count($REX['ADDON']['seo42']['settings']['force_download_for_filetypes']) > 0) && isset($_GET["file"])) {
$file = strtolower(preg_replace("/[^a-zA-Z0-9.\-\$\+]/","_", rex_get('file', 'string')));
$file = urlencode(basename($file));
$fileWithPath = realpath('./' . $REX['MEDIA_DIR'] . '/' . $file);
$pathInfo = pathinfo($fileWithPath);
if (isset($pathInfo['extension']) && in_array($pathInfo['extension'], $REX['ADDON']['seo42']['settings']['force_download_for_filetypes']) && file_exists($fileWithPath)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $file);
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Link: <' . seo42::getServerUrl() . ltrim(seo42::getMediaFile($file), "./") . '>; rel="canonical"');
header('Content-Length: ' . filesize($fileWithPath));
ob_clean();
flush();
readfile($fileWithPath);
exit;
}
}
break;
case 'googlesiteverification':
$googleSiteVerificationFile = strtolower(preg_replace("/[^a-zA-Z0-9.\-\$\+]/","_", trim(trim($REX['ADDON']['seo42']['settings']['google_site_verification_filename']), '/')));
$requestedFile = strtolower(preg_replace("/[^a-zA-Z0-9.\-\$\+]/","_", trim($_SERVER['REQUEST_URI'], '/')));
if ($googleSiteVerificationFile != '' && $requestedFile == $googleSiteVerificationFile) {
ob_clean();
flush();
echo 'google-site-verification: ' . $googleSiteVerificationFile;
exit;
}
break;
default:
break;
}
}