diff options
Diffstat (limited to 'linkshorter/functions.php')
| -rw-r--r-- | linkshorter/functions.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/linkshorter/functions.php b/linkshorter/functions.php new file mode 100644 index 0000000..f6f021a --- /dev/null +++ b/linkshorter/functions.php @@ -0,0 +1,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; +} |
