summaryrefslogtreecommitdiff
path: root/linkshorter/functions.php
blob: f6f021a2de452993fa242a5395e82e848de9b982 (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
52
53
54
55
56
57
58
<?php

function do_output($reason, $httpcode, $ajax = true,  $heading = NULL){
	header ($_SERVER['SERVER_PROTOCOL'] . " " . $httpcode);
	if( $ajax ){
		echo $reason;
		ob_end_flush();
		exit;
	}
?>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>Link Shorter</title>
	<!--style>html{position:relative;min-height:100%}body{margin-bottom:60px}.footer{position:absolute;bottom:0;width:100%}#copyright-text{text-decoration:underline;color:#333}</style-->
	<style>
	<?php echo file_get_contents("../tools/style.css"); ?>
	</style>
	<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
	<link rel='shortcut icon' href='../tools/favicon.ico' type='image/x-icon'>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
	<?php require("../tools/navbar.php"); ?>
<div class="container text-center pagination-centered">
	<div class="row">
		<?php echo $heading; ?>
	<hr>
	</div>
	<div class="text-center">
		<?php echo $reason; ?>
	</div>
</div>
	<?php require("../tools/footer.php"); ?>
</body>
<?php
	ob_end_flush();
	exit;
}

function sanitize_output($buffer) {

    $search = array(
        '/\>[^\S ]+/s',  // strip whitespaces after tags, except space
        '/[^\S ]+\</s',  // strip whitespaces before tags, except space
        '/(\s)+/s'       // shorten multiple whitespace sequences
    );

    $replace = array(
        '>',
        '<',
        '\\1'
    );

    $buffer = preg_replace($search, $replace, $buffer);

    return $buffer;
}