File tree 6 files changed +73
-1
lines changed
6 files changed +73
-1
lines changed Original file line number Diff line number Diff line change 26
26
"hide_popular_documents" : false ,
27
27
"hide_popular_packets" : false
28
28
},
29
+ "robotstxt" : {
30
+ "*" : [{"Disallow" : " /" }]
31
+ },
29
32
"server_update_job_token" : null ,
30
33
"user_login_disabled" : false ,
31
34
"user_password_bcrypt_cost" : 12 ,
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace BNETDocs \Controllers ;
4
+
5
+ use \BNETDocs \Models \Robotstxt as RobotstxtModel ;
6
+ use \CarlBennett \MVC \Libraries \Common ;
7
+ use \CarlBennett \MVC \Libraries \Controller ;
8
+ use \CarlBennett \MVC \Libraries \Router ;
9
+ use \CarlBennett \MVC \Libraries \View ;
10
+
11
+ class Robotstxt extends Controller {
12
+ public function &run (Router &$ router , View &$ view , array &$ args ) {
13
+ $ model = new RobotstxtModel ();
14
+ $ model ->rules = Common::$ config ->bnetdocs ->robotstxt ;
15
+ $ view ->render ($ model );
16
+ $ model ->_responseCode = 200 ;
17
+ return $ model ;
18
+ }
19
+ }
Original file line number Diff line number Diff line change @@ -201,6 +201,9 @@ function main() {
201
201
$ router ->addRoute ( // URL: /packet/search
202
202
"#^/packet/search/?$# " , "Packet \\Search " , "Packet \\SearchHtml "
203
203
);
204
+ $ router ->addRoute ( // URL: /robots.txt
205
+ "#^/robots.txt/?$# " , "Robotstxt " , "Robotstxt "
206
+ );
204
207
$ router ->addRoute ( // URL: /server/:id.json
205
208
"#^/server/(\d+)/?.*\.json$# " , "Server \\View " , "Server \\ViewJSON "
206
209
);
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace BNETDocs \Models ;
4
+
5
+ use \CarlBennett \MVC \Libraries \Model ;
6
+
7
+ class Robotstxt extends Model {
8
+
9
+ public $ rules ;
10
+
11
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace BNETDocs \Views ;
3
+
4
+ use \BNETDocs \Models \Robotstxt as RobotstxtModel ;
5
+ use \CarlBennett \MVC \Libraries \Exceptions \IncorrectModelException ;
6
+ use \CarlBennett \MVC \Libraries \Model ;
7
+ use \CarlBennett \MVC \Libraries \View ;
8
+
9
+ class Robotstxt extends View
10
+ {
11
+ public function getMimeType ()
12
+ {
13
+ return 'text/plain;charset=utf-8 ' ;
14
+ }
15
+
16
+ public function render (Model &$ model )
17
+ {
18
+ if (!$ model instanceof RobotstxtModel)
19
+ {
20
+ throw new IncorrectModelException ();
21
+ }
22
+ $ model ->_responseHeaders ['Content-Type ' ] = $ this ->getMimeType ();
23
+
24
+ foreach ($ model ->rules as $ useragent => $ rules )
25
+ {
26
+ printf ("User-agent: %s \r\n" , $ useragent );
27
+
28
+ foreach ($ rules as $ rule )
29
+ {
30
+ foreach ($ rule as $ action => $ url )
31
+ {
32
+ printf ("%s: %s \r\n" , $ action , $ url );
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments