-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcommon.php
executable file
·79 lines (67 loc) · 2.22 KB
/
common.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/* common.php
2009-10-26 created by Tantek Çelik http://tantek.com
NOTES:
This depends on code from CASSIS V0 by Tantek Celik http://tantek.com
http://tantek.pbworks.com/CassisProject
http://creativecommons.org/licenses/by-sa/3.0/
--------------------------------------------------------------------- */
ob_start();
include 'cassis.js';
ob_end_clean();
/* php only functions */
function geturiparam($pathdelimiter, $addhttp) {
$uri = @$_REQUEST['uri']; // use explicitly specified uri parameter if any
// if no explict url is found, get it from the path
if ($uri=='') {
if ($pathdelimiter=='') {
$pathdelimiter = '.com/';
}
$uri = explode($pathdelimiter, $_SERVER['REQUEST_URI'], 2);
$uri = $uri[1];
}
$uri = webaddresstouri(urldecode($uri), $addhttp);
// if no explicit nor path uri, look for use referrer request
if ($uri=='referrer' || $uri== 'referer' || $uri=='http://referrer' || $uri=='http://referer') {
$uri=getenv("HTTP_REFERER");
}
return $uri;
}
/**
* Run tidy on the given string if it is installed.
*
* @param string $html the html to run through tidy.
* @return the tidied html or false if tidy is not installed.
* @author Matt Harris
*/
function html5_tidy($html) {
if (class_exists('tidy')) {
$tidy = new tidy();
$config = array(
'bare' => TRUE,
'clean' => TRUE,
'indent' => TRUE,
'output-xhtml' => TRUE,
'wrap' => 200,
'hide-comments' => TRUE,
'new-blocklevel-tags' => implode(' ', array(
'header', 'footer', 'main', 'article', 'section', 'aside', 'nav', 'hgroup', 'figure',
)),
'new-inline-tags' => implode(' ', array(
'mark', 'time', 'meter', 'progress',
)),
);
$tidy->parseString( $html, $config, 'utf8' );
$tidy->cleanRepair();
// $html = str_ireplace( '<wbr />','­', (string)$tidy );
// wbr to ­ conversion commented out due to Safari copy/paste bug:
// -- Safari emits an actual hyphen when copy/pasting markup with ­
unset($tidy);
return $html;
} else {
echo 'no tidy :(';
}
return false;
}
/* end php only functions */
?>