html.func.php
2.15 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
<?php
// PHP xml sitemap generator
// this function returns an array containg all emails in the page
function parseEMails($source) {
$rows = array();
$ne = preg_match_all("#([_A-Za-z0-9+-+]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#", $source, $res);
$rows = array_unique($res[0]);
return $rows;
}
// this function returns a string containing the value of the field of an html tag
function getTagField($tag, $fieldname) {
$field = "";
$ttag = substr($tag, 1, strpos($tag, '>') - 1);
if(($pos = strposi($ttag, $fieldname)) > 0) {
$tmpfield = substr($ttag, $pos + strlen($fieldname));
if($tmpfield[0] == '"' || $tmpfield[0] == "'") {
if($tmpfield[0] == '"') {
$tmpfield = substr($tmpfield, 1);
$field = substr($tmpfield, 0, strpos($tmpfield, '"'));
}
if($tmpfield[0] == "'") {
$tmpfield = substr($tmpfield, 1);
$field = substr($tmpfield, 0, strpos($tmpfield, "'"));
}
}
else {
if(strpos($tmpfield, ' ') > 0)
$field = substr($tmpfield, 0, strpos($tmpfield, ' '));
else
$field = $tmpfield;
}
}
return $field;
}
// this function returns an array of strings starting with $start and ending with $end
function getTags($source, $start, $end) {
$tmp = $source;
for($i = 0; strlen($tmp) > 0; $i++) {
if(($postagst = strposi($tmp, $start)) == false)
break;
$tmp = substr($tmp, $postagst);
$postagend = strposi($tmp, $end);
if($postagend > 0)
$tags[$i] = substr($tmp, 0, $postagend + strlen($end));
else {
$tags[$i] = $tmp;
}
$tmp = substr($tmp, strlen($tags[$i]));
}
return $tags;
}
?>