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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<?php
function hl($xml, $class="xmlcode") {
$geshi = new GeSHi($xml, "XML", "../../include/geshi/");
$geshi->set_header_type(GESHI_HEADER_NONE);
print "<div class='".$class."'>".$geshi->parse_code()."</div>";
}
function hljava($code, $class="xmlcode") {
$geshi = new GeSHi($code, "Java5", "../../include/geshi/");
$geshi->set_header_type(GESHI_HEADER_NONE);
print "<div class='".$class."'>".$geshi->parse_code()."</div>";
}
function show_link($title, $url, $show_alt, $title_attr="") {
global $homepage;
$html = "";
$alt = "";
$img_path = "/images";
if( $homepage ) {
$img_path = "art";
}
if( strpos($url, "mailto:") === false && $show_alt ) {
if( strpos($url, "http:") === false ) {
$alt = "internal link to ".$title;
} else {
$alt = "external link to ".$title;
}
} else if ( $show_alt ) {
$alt = "email";
}
if( $title_attr ) {
$title_attr = 'title="'.$title_attr.'"';
}
if( strpos($url, "http:") === false ) {
$html .= '<a '.$title_attr.' href="'.$url.'"><img src="'.$img_path.'/link.png" border="0" hspace="2" width="8" height="9" alt="'.$alt.'" />';
} else {
$html .= '<a '.$title_attr.' href="'.$url.'"><img src="'.$img_path.'/link_extern.png" border="0" hspace="2" width="7" height="9" alt="'.$alt.'" />';
}
$html .= $title.'</a>';
return $html;
}
function getmicrotime() {
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function send_last_modified_header() {
global $last_update_full;
$timestamp = strtotime($last_update_full);
header("Last-Modified: ".date("D, j M Y G:i:s T", $timestamp));
}
/** Escape stuff that gets printed to page to avoid cross site scripting. */
function escape($string) {
$string = preg_replace("/&/", "&", $string);
$string = preg_replace("/\"/", """, $string);
$string = preg_replace("/'/", "'", $string);
$string = preg_replace("/</", "<", $string);
$string = preg_replace("/>/", ">", $string);
return $string;
}
/** Unescape stuff that gets printed to page to avoid cross site scripting. */
function unescape($string) {
$string = preg_replace("/"/", "\"", $string);
$string = preg_replace("/'/", "'", $string);
$string = preg_replace("/</", "<", $string);
$string = preg_replace("/>/", ">", $string);
$string = preg_replace("/&/", "&", $string);
return $string;
}
function post_request($url, $data, $optional_headers=null) {
$params = array('http' => array(
'method' => 'POST',
'content' => $data));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
return "";
}
$resp = @stream_get_contents($fp);
if ($resp === false) {
return "";
}
return $resp;
}
// see http://www.php.net/manual/en/function.substr.php:
function utf8_substr($str, $start) {
preg_match_all("/./u", $str, $ar);
if (func_num_args() >= 3) {
$end = func_get_arg(2);
return join("",array_slice($ar[0], $start, $end));
} else {
return join("",array_slice($ar[0], $start));
}
}
?>
|