This repository has been archived by the owner on Oct 13, 2020. It is now read-only.
/
modifications.xml
58 lines (49 loc) · 2.39 KB
/
modifications.xml
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
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>xPandax:Auto_[iurl]_For_Internal_Links_And_"nofollow"_For_External_Links</id>
<version>1.0</version>
<file name="$sourcedir/Subs.php">
<operation>
<search position="replace"><![CDATA[
'tag' => 'url',
'type' => 'unparsed_content',
'content' => '<a href="$1" class="bbc_link" target="_blank">$1</a>',]]></search>
<add><![CDATA[
'tag' => 'url',
'type' => 'unparsed_content',
'content' => '<a href="$1" class="bbc_link" target="_blank" rel="nofollow">$1</a>',]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[
'tag' => 'url',
'type' => 'unparsed_equals',
'before' => '<a href="$1" class="bbc_link" target="_blank">',]]></search>
<add><![CDATA[
'tag' => 'url',
'type' => 'unparsed_equals',
'before' => '<a href="$1" class="bbc_link" target="_blank" rel="nofollow">',]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
if ($pos < $lastAutoPos)
$no_autolink_area = true;
$lastAutoPos = $pos;]]></search>
<add><![CDATA[
//Get the domain details of this website (Added by "Auto_[iurl]_For_Internal_Links_And_NoFollow_For_External_Links" Mod)
$domain_id = false;
$pattern = '~(?:http|https|)(?::\/\/|)(?:www.|)([^/?#]*)?([^?#]*)(\?([^#]*))?(#(.*))?~';
if (preg_match($pattern, $scripturl, $matches))
$domain_id = $matches[1];]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
// Switch out quotes really quick because they can cause problems.
$data = strtr($data, array(''' => '\'', ' ' => $context['utf8'] ? "\xC2\xA0" : "\xA0", '"' => '>">', '"' => '<"<', '<' => '<lt<'));]]></search>
<add><![CDATA[
//Check if its an internal url (Added by "Auto_[iurl]_For_Internal_Links_And_NoFollow_For_External_Links" Mod)
if (strpos($data, '$domain_id') !== true)
$data = preg_replace('~(?<=[\s>\.(;\'"]|^)((?:http|https|)(?::\/\/|)(?:www.|)(?:[0-9A-Za-z\-]+\.|)(' . $domain_id . '/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))*[/\w\-_\~%@\?;=#}\\\\])~i', '[iurl]$1[/iurl]', $data);]]></add>
</operation>
</file>
</modification>