-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.php
149 lines (109 loc) · 3.42 KB
/
plugin.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
class robotsStrong extends Plugin {
public function init()
{
$this->dbFields = array(
'robotsMode' => 'strong',
'userRobotsTxt' => ''
);
}
public function form()
{
global $L;
$html .= '<div>';
$html .= '<label>'. $L->get('mode') .'</label>';
$html .= '<select name="robotsMode">';
$html .= '<option value="strong" ' . ($this->getValue('robotsMode') === 'strong' ? 'selected' : '') . '>'. $L->get('strong') .'</option>';
$html .= '<option value="strongest" ' . ($this->getValue('robotsMode') === 'strongest' ? 'selected' : '') . '>'. $L->get('strongest') .'</option>';
$html .= '</select>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'. $L->get('user-defined-rules') .'</label>';
$html .= '<textarea name="userRobotsTxt">'.$this->getValue('userRobotsTxt').'</textarea>';
$html .= '</div>';
return $html;
}
public function siteHead()
{
$metaTag = '<meta name="GOOGLEBOT" content="NOINDEX, NOFOLLOW, NOARCHIVE, NOIMAGEINDEX">
<meta name="ROBOTS" content="NOARCHIVE, NOINDEX, NOFOLLOW, NOIMAGEINDEX">'.PHP_EOL;
$metaTag2 = '<meta name="robots" content="noindex, nofollow, noarchive, noimageindex">'.PHP_EOL;
$additionalMetaTag = '<meta name="robots" content="noindex, nofollow, noarchive, noimageindex, noimageai, noai">
<meta name="bingbot" content="noarchive">
<meta name="msnbot" content="noarchive">
<meta name="pinterest" content="nopin">'.PHP_EOL;
echo $metaTag;
if ($this->getValue('robotsMode') == 'strong') {
echo $metaTag2;
} elseif ($this->getValue('robotsMode') == 'strongest') {
echo $additionalMetaTag;
}
}
public function beforeAll()
{
$webhook = 'robots.txt';
if ($this->webhook($webhook)) {
header('Content-type: text/plain');
// Include link to sitemap in robots.txt if the plugin is enabled
if (pluginActivated('pluginSitemap')) {
echo 'Sitemap: '.DOMAIN_BASE.'sitemap.xml'.PHP_EOL;
}
$robotsTxt = <<<EOF
User-agent: *
Disallow: /
EOF;
$additionalRobotsTxt = <<<EOF
User-agent: GPTBot
Disallow: /
User-agent: ChatGPT-User
Disallow: /
User-agent: Google-Extended
Disallow: /
User-agent: GoogleOther
Disallow: /
User-agent: GoogleOther-Image
Disallow: /
User-agent: GoogleOther-Video
Disallow: /
User-agent: CCBot
Disallow: /
User-agent: ClaudeBot
Disallow: /
User-agent: PerplexityBot
Disallow: /
User-agent: Applebot-Extended
Disallow: /
User-agent: OAI-SearchBot
Disallow: /
User-agent: amazon-kendra
Disallow: /
Mozilla/5.0 (compatible; ImagesiftBot; +imagesift.com)
User-Agent: ImagesiftBot
Disallow: /
User-agent: Diffbot
Disallow: /
User-agent: meta-externalagent
Disallow: /
User-agent: meta-externalfetcher
Disallow: /
User-agent: cohere-ai
Disallow: /
User-agent: AI2Bot
Disallow: /
User-agent: Bytespider
Disallow: /
User-agent: ICC-Crawler
Disallow: /
EOF;
$userRobotsTxt = $this->getValue('userRobotsTxt');
echo $robotsTxt;
if ($this->getValue('robotsMode') == 'strongest') {
echo $additionalRobotsTxt;
}
if ($this->getValue('userRobotsTxt')) {
echo $userRobotsTxt;
}
exit(0);
}
}
}