forked from chrisbratlien/weepy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
88 lines (75 loc) · 2.21 KB
/
functions.php
File metadata and controls
88 lines (75 loc) · 2.21 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
date_default_timezone_set('America/Chicago');
require_once 'local.php';
require_once 'core.php';
if (!function_exists('pp')) { //Pretty Print
function pp($obj,$label = '') {
$data = json_encode(print_r($obj,true));
?>
<style type="text/css">
#bsdLogger {
position: absolute;
top: 0px;
right: 0px;
border-left: 4px solid #bbb;
padding: 6px;
background: white;
color: #444;
z-index: 999;
font-size: 1.25em;
width: 400px;
height: 800px;
overflow: scroll;
}
</style>
<script type="text/javascript">
var doStuff = function(){
var obj = <?php echo $data; ?>;
var logger = document.getElementById('bsdLogger');
if (!logger) {
logger = document.createElement('div');
logger.id = 'bsdLogger';
document.body.appendChild(logger);
}
////console.log(obj);
var pre = document.createElement('pre');
var h2 = document.createElement('h2');
pre.innerHTML = obj;
h2.innerHTML = '<?php echo addslashes($label); ?>';
logger.appendChild(h2);
logger.appendChild(pre);
};
window.addEventListener ("DOMContentLoaded", doStuff, false);
</script>
<?php
}
}
function pr($obj,$label = '') {
echo sprintf('%s: %s',$label,print_r($obj,true));
}
function curl_get($url, array $get = array(), array $options = array())
{
$defaults = array(
CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ''). http_build_query($get),
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 30// I35TIED_CURL_TIMEOUT
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
if( ! $result = curl_exec($ch))
{
trigger_error(curl_error($ch));
}
curl_close($ch);
return $result;
}
function slugify_string($str) {
$result = strtolower($str);
$result = preg_replace('/\ /','-',$result);
$result = preg_replace('/\//','-',$result);
$result = preg_replace('/\:/','-',$result);
$result = preg_replace('/\./','-',$result);
$result = preg_replace('/\-+/','-',$result);
return $result;
}