summaryrefslogtreecommitdiff
path: root/archives/html/msgtxt.php
blob: 1d2c792e0962a7384ea56feed8eaf4b7946ec276 (plain)
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
<?php

$id = $_GET["id"];
$id = str_replace("/", "_", $id);

if (strpos($id, "@") == FALSE) {
	header("Status: 404 fucked up message-id");
	print("go away, you insensitive clod\n");
	exit;
}
	
$parts = split("@", $id, 2);

header("Content-type: text/plain");

if (strlen($parts[1]) < 4 || strlen($parts[0]) < 4) {
	header("Status: 404 probably unindexed message");
	print "maybe this message is valid, but we don't have it\n";
	exit;
}

$dir = substr($parts[1], 0, 2) .
	"/" .
	substr($parts[1], 2, 2) .
	"/@" .
	$parts[1] .
	"/" .
	substr($parts[0], 0, 2) .
	"/" .
	substr($parts[0], 2, 2);


$filename= $_SERVER['DOCUMENT_ROOT'] . "/../messages/" . $dir . "/" . $id;
if (!file_exists($filename)) {
	header("Status: 404 No such Message-Id");
	print "No message with Message-Id " . $_GET["id"] ." found\n";
	exit;
}

$file = fopen($filename, "r");
if (!$file) {
        print "not found\n";
        exit;
}

while ($line = fread($file, 8192)) {
        print $line;
}

?>