-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontrols.php
63 lines (56 loc) · 1.41 KB
/
controls.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
61
62
63
<?php
/**
* TSW Details NanoBlog
* Author: Larry Judd Oliver @tradesouthwest | http://tradesouthwest.com/details
* Contributors in readme.md file
* License in LICENSE.md file
*/
// settings - functions - filters
function esc($s){
echo htmlspecialchars_decode($s, ENT_HTML5);
}
/**
* mimics the original mysql_real_escape_string but which doesn't need an active mysql connection.
* @is_arry
* @is_string
*/
function escmim($inp) {
if(is_array($inp))
return array_map(__METHOD__, $inp);
if(!empty($inp) && is_string($inp)) {
return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $inp);
}
return $inp;
}
// returns only letters and numbers
function alpha_only( $string )
{
return preg_replace('/[^a-zA-Z0-9\s]/', '', $string);
}
// safe redirect
function redirect($url)
{
if (!headers_sent())
{
header('Location: '.$url);
exit;
}
else
{
echo '<script type="text/javascript">';
echo 'window.location.href="'.$url.'";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="3;url='.$url.'" />';
echo '</noscript>'; exit;
}
}
// display sessions (for debug)
function display_sessions() {
$html=
$html .= '<pre>';
$html = print_r($_SESSION);
$html .= '<pre>';
return $html;
}
?>