-
Notifications
You must be signed in to change notification settings - Fork 1
/
tag.php
60 lines (46 loc) · 1.24 KB
/
tag.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
<?php
# TODO add .htaccess to remove this from indexing!
# TODO fix path
require_once("../../stacks-website-new/php/tags.php");
ini_set('display_errors', 1);
error_reporting(E_ALL);
// read configuration file
$config = parse_ini_file("../../stacks-website-new/config.ini"); # TODO config
// initialize the global database object
try {
$database = new PDO("sqlite:" . $config["database"]);
}
catch(PDOException $e) {
echo $e->getMessage();
}
function startsWith($haystack, $needle) {
return !strncmp($haystack, $needle, strlen($needle));
}
function removeProofs($content) {
$lines = explode("\n", $content);
$output = "";
$inProof = false;
foreach ($lines as $i => $line) {
if (startsWith($line, "\begin{proof}"))
$inProof = true;
if (!$inProof)
$output .= $line . "\n";
if (startsWith($line, "\end{proof}"))
$inProof = false;
}
return $output;
}
$tag = getTag($_GET["tag"]);
if (!array_key_exists("type", $_GET))
$type = "statement";
else
$type = $_GET["type"];
switch ($_GET["type"]) {
case "full":
print convertLaTeX($_GET["tag"], $tag["file"], $tag["value"]);
break;
case "statement":
print convertLaTeX($_GET["tag"], $tag["file"], removeProofs($tag["value"]));
break;
}
?>