]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/robotstxt.php
Reinstate profile_info in author/actor
[quix0rs-gnu-social.git] / actions / robotstxt.php
1 <?php
2 /**
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2010, StatusNet, Inc.
5  *
6  * robots.txt generator
7  *
8  * PHP version 5
9  *
10  * @category Action
11  * @package  StatusNet
12  * @author   Evan Prodromou <evan@status.net>
13  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
14  * @link     http://status.net/
15  *
16  * This program is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU Affero General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU Affero General Public License for more details.
25  *
26  * You should have received a copy of the GNU Affero General Public License
27  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
28  */
29
30 if (!defined('STATUSNET')) {
31     exit(1);
32 }
33
34 /**
35  * Prints out a static robots.txt
36  *
37  * @category Action
38  * @package  StatusNet
39  * @author   Evan Prodromou <evan@status.net>
40  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
41  * @link     http://status.net/
42  */
43
44 class RobotstxtAction extends Action
45 {
46     /**
47      * Handles requests
48      *
49      * Since this is a relatively static document, we
50      * don't do a prepare()
51      *
52      * @param array $args GET, POST, and URL params; unused.
53      *
54      * @return void
55      */
56
57     function handle($args)
58     {
59         if (Event::handle('StartRobotsTxt', array($this))) {
60
61             header('Content-Type: text/plain');
62
63             print "User-Agent: *\n";
64
65             if (common_config('site', 'private')) {
66
67                 print "Disallow: /\n";
68
69             } else {
70
71                 $disallow = common_config('robotstxt', 'disallow');
72
73                 foreach ($disallow as $dir) {
74                     print "Disallow: /$dir/\n";
75                 }
76
77                 $crawldelay = common_config('robotstxt', 'crawldelay');
78
79                 if (!empty($crawldelay)) {
80                     print "Crawl-delay: " . $crawldelay . "\n";
81                 }
82             }
83
84             Event::handle('EndRobotsTxt', array($this));
85         }
86     }
87
88     /**
89      * Return true; this page doesn't touch the DB.
90      *
91      * @param array $args other arguments
92      *
93      * @return boolean is read only action?
94      */
95
96     function isReadOnly($args)
97     {
98         return true;
99     }
100 }