Gehe zu deutscher Webseite

ViaThinkSoft CodeLib

This article is in:
CodeLibProgramming aidsPHP

function get_url_from_urlfile($file) {
        if (!file_exists($file)) return false;
        if (!is_readable($file)) return false;

        $raw = file_get_contents($file);
        $raw = str_replace("\r", "\n", $raw);
        $ary = explode("\n", $raw);

        $in_section = false;
        foreach ($ary as $val) {
                if ($in_section) {
                        $bry = explode('=', $val);
                        if (trim(strtolower($bry[0])) == strtolower('URL')) {
                                array_shift($bry);
                                return implode('=', $bry);
                        }
                }

                if (substr(trim($val), 0, 1) == '[') {
                        $in_section = false;
                }
                if (str_replace(' ', '', strtolower($val)) == strtolower('[InternetShortcut]')) {
                        $in_section = true;
                }
        }
        unset($in_section);
        unset($val);

        return false;
}
Daniel Marschall
ViaThinkSoft Co-Founder