\n"; } // Functions function checkUrl ($url) { $url = trim($url); // Secured urls doen we niet aan... if (preg_match("/^https:\/\/.*$/i", $url)) { return false; } // Voeg http:// toe als dit niet is ingetypt // en de url niet begint met https:// if (!preg_match("/^https?:\/\/.*$/i", $url)) { $url = "http://" . $url; } return $url; } function getHTML (&$url) { if ($handle = @fopen($url, "rb")) { $meta_data = stream_get_meta_data($handle); $html = stream_get_contents($handle); fclose($handle); $headers = $meta_data['wrapper_data']; // Als de ingevoerde url eindigt op een dir ipv een file, // dan is er door apache server een Location toegevoegd. // Gebruik deze location dan als de url. foreach ($headers as $value) { if (preg_match ("/Location: (http:\/\/.*)$/is", $value, $matches)) { $url = trim($matches[1]); } } // If not utf-8, convert to utf-8. if(mb_detect_encoding($html, "UTF-8, ISO-8859-1, GBK") != "UTF-8") { $html = utf8_encode($html); } return $html; } else { return false; } } function HTMLtoText ($html) { // Verwijder eerst alles tussen \n"; $script .= "\n"; if (stripos($html, "]*>)/is", "$1\n " . $script, $html); } elseif (stripos($html, "]*>)/is", "$1\n" . $script . "\n", $html); } else { $html = "\n" . $script . "\n" . $html . "\n"; } return $html; } function addBaseTagToHTML ($html, $url) { $base = "\n"; // Als er al een basetag is, doe niks en return de html // Als er een head tag is, vervang deze door head en de base tag. if (preg_match("/]*href=/i", $html)) { return $html; } else { $html = preg_replace("/(]*>)/is", "$1\n " . $base, $html); } return $html; } function addBodyTagToHTML ($html) { if (stripos($html, "") !== false) { $html = str_ireplace("", "\n", $html); $html = str_ireplace("", "\n", $html); } else { $html = str_ireplace("", "\n", $html); $html .= "\n"; } } $script = "\n"; $html = str_ireplace("", "$script\n\n", $html); return $html; } ?>