-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.php
170 lines (141 loc) · 3.67 KB
/
demo.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
if (isset($_GET['download'])) {
header('Content-Type: text/plain', true);
echo file_get_contents(dirname(__FILE__).'/autolinks.php');
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Auto-Linking URLs Demo</title>
<style type="text/css">
body {
padding: 50px 75px;
}
ul {
margin: 0;
padding: 0;
background: #F9FF90;
overflow: hidden;
}
li {
list-style: none;
margin: 0 10px;
padding: 5px;
float: left;
}
</style>
</head>
<body>
<h1>Auto-Linking URLs Demo</h1>
<ul>
<li class="first"><a href="?download">Download the source</a></li>
<li><a href="http://iamseanmurphy.com/2008/12/01/auto-linking-urls-with-php/">Read the blog post</a></li>
</ul>
<pre>
<?php
$text = <<<DEL
example
http://example
http://example/
http://example/path
http://example.com
https://example.com
ftp://example.com
ftps://example.com
http://[email protected]
http://user:[email protected]
http://example.com:8080
http://www.example.com
http://example.com/
http://example.com/path
http://example.com/path.html
http://example.com/path.html#fragment
http://example.com/path.php?foo=bar&bar=foo
http://müllärör.de
http://ﺱﺲﺷ.com
http://сделаткартинки.com
http://tūdaliņ.lv
http://brændendekærlighed.com
http://あーるいん.com
http://예비교사.com
http://example.com.
http://example.com?
http://example.com!
http://example.com,
http://example.com;
http://example.com:
'http://example.com'
"http://example.com"
`http://example.com`
(http://example.com)
[http://example.com]
<http://example.com>
http://example.com/path/(foo)/bar
http://example.com/path/[foo]/bar
http://example.com/path/foo/(bar)
http://example.com/path/foo/[bar]
Hey, check out my cool site http://example.com okay?
What about parens (e.g. http://example.com/path/foo/(bar))?
What about parens (e.g. http://example.com/path/foo/(bar)?
What about parens (e.g. http://example.com/path/foo/(bar).)?
What about parens (e.g. http://example.com/path/(foo,bar)?
Unbalanced too (e.g. http://example.com/path/((((foo)/bar)?
Unbalanced too (e.g. http://example.com/path/(foo))))/bar)?
Unbalanced too (e.g. http://example.com/path/foo/((((bar)?
Unbalanced too (e.g. http://example.com/path/foo/(bar))))?
example.com
example.org
example.co.uk
www.example.co.uk
farm1.images.example.co.uk
example.museum
example.travel
example.com.
example.com?
example.com!
example.com,
example.com;
example.com:
'example.com'
"example.com"
`example.com`
(example.com)
[example.com]
<example.com>
Hey, check out my cool site example.com okay?
Hey, check out my cool site example.com.I made it.
Hey, check out my cool site example.com.Funny thing...
Hey, check out my cool site example.com.You will love it.
What about parens (e.g. example.com/path/foo/(bar))?
What about parens (e.g. example.com/path/foo/(bar)?
What about parens (e.g. example.com/path/foo/(bar).)?
What about parens (e.g. example.com/path/(foo,bar)?
file.ext
file.html
file.php
DEL;
$text2 = <<<DEL
[Coming soon: IDNA TLDs]
http://例子.测试
http://उदाहरण.परीक्षा
http://пример.испытание
http://실례.테스트
http://בײַשפּיל.טעסט
http://例子.測試
http://مثال.آزمایشی
http://உதாரணம்.பரிட்சை
http://παράδειγμα.δοκιμή
http://مثال.إختبار
http://例え.テスト
DEL;
mb_internal_encoding('UTF-8');
include_once(dirname(__FILE__).'/autolinks.php');
echo replace_urls_callback($text, 'linkify');
?>
</pre>
</body>
</html>