Skip to content

Commit d9affcd

Browse files
committed
[chore] Added robots noindex
1 parent 0e5c6e2 commit d9affcd

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ There is only 1 page available when you install this script, `index.txt`.
3434
* In order to view it, open a browser at `http://localhost/`
3535
* Make it editable with `chmod 666 /var/www/html/code/index.txt` or directly from your favorite file explorer
3636

37-
Page names contain only lower-case alpha-numeric characters and dashes (regex `[\w\-]{1,256}`).
37+
Page names contain only lower-case alpha-numeric characters and dashes (regex `[\w\-]{1,128}`).
3838
Page URLs correspond to text files without the ".txt" extension.
3939

4040
3. Last but not least, [install **Docker**](https://docs.docker.com/engine/install/ubuntu/)

src/api.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ public function __construct() {
6868

6969
if (isset($input[self::REQUEST_PAGE])) {
7070
$methodPage = strtolower(
71-
preg_replace(
72-
'%[^\w\-]+%i',
73-
'',
74-
substr($input[self::REQUEST_PAGE], 0, 256)
75-
)
71+
substr(
72+
preg_replace('%[^\w\-]+%i', '', $input[self::REQUEST_PAGE]),
73+
0,
74+
128
75+
)
7676
);
7777
}
7878
}
@@ -106,7 +106,7 @@ public function __construct() {
106106
* Write in the code.txt file
107107
*
108108
* @var string $content Content - limited in length to self::MAX_INPUT
109-
* @var string $page Page - limited in length to 256; pre-sanitized
109+
* @var string $page Page - limited in length to 128; pre-sanitized
110110
* @throws Exception
111111
*/
112112
public function apiWrite($content = null, $page = null) {
@@ -130,7 +130,7 @@ public function apiWrite($content = null, $page = null) {
130130
* Execute the code.txt file; limit output size and prevent OOM attack vectors
131131
*
132132
* @var string $content (optional) Content - limited in length to self::MAX_INPUT
133-
* @var string $page Page - limited in length to 256; pre-sanitized
133+
* @var string $page Page - limited in length to 128; pre-sanitized
134134
* @return string Output limited in length to self::MAX_OUTPUT
135135
* @throws Exception
136136
*/

src/index.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
<?php
2-
// Trying to read inside the code repo
3-
if (preg_match('%^\/?code\/[\w\-]+\.txt$%i', $_SERVER['REQUEST_URI'])) {
4-
header('HTTP/1.0 404 Not Found', true, 404);
5-
exit();
6-
}
7-
82
// Prepare the page name
93
$page = strtolower(
10-
preg_replace(
11-
'%[^\w\-]+%i',
12-
'',
13-
substr($_SERVER['REQUEST_URI'], 0, 256)
4+
substr(
5+
preg_replace('%[^\w\-]+%i', '', $_SERVER['REQUEST_URI']),
6+
0,
7+
128
148
)
159
);
1610

@@ -28,19 +22,18 @@
2822
$titleFragment = (
2923
strlen($page)
3024
? (
31-
': '
32-
. implode(
25+
implode(
3326
' ',
3427
array_map(
3528
'ucfirst',
3629
preg_split(
37-
'%[\s\_\-]+%i',
30+
'%[\_\-]+%',
3831
$page
3932
)
4033
)
41-
)
34+
) . ' | PHP Sandbox'
4235
)
43-
: ' by Mark Jivko'
36+
: 'PHP Sandbox by Mark Jivko'
4437
);
4538
?><!doctype html>
4639
<!--
@@ -52,10 +45,11 @@
5245
-->
5346
<html lang="en">
5447
<head>
55-
<title>PHP Sandbox<?php echo $titleFragment;?></title>
48+
<title><?php echo $titleFragment;?></title>
5649
<meta charset="UTF-8">
5750
<link rel="stylesheet" href="/css/style.css">
5851
<link rel="icon" type="image/ico" href="/favicon.ico">
52+
<meta name="robots" content="noindex" />
5953
<meta name="Author" content="Mark Jivko">
6054
<meta name="Description" content="Live coding tool">
6155
<meta name="apple-mobile-web-app-capable" content="yes">

src/robots.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Disallow: /

0 commit comments

Comments
 (0)