function input($url, $pos = "")
{
    $t_html = cacheurl($url);
    preg_match_all('/<entry>(.*?)<\\/entry>/si', $t_html, $row);
    foreach ($row[1] as $mov) {
        preg_match('/<title (.*?)>(.*?)<\\/title>/i', $mov, $matches);
        $tmp_array['title'] = reducehtml($matches[2]);
        preg_match("/<link(.*?)href='(.*?)'\\/>/i", $mov, $matches);
        $tmp_array['url'] = $matches[2];
        preg_match("/<content(.*?)>(.*?)<\\/content>/i", $mov, $matches);
        $tmp_array['details'] = $matches[2];
        preg_match("/duration seconds='(\\d+)'/i", $mov, $matches);
        $tmp_array['size'] = $matches[1];
        preg_match("/<published>(.*?)<\\/published>/is", $mov, $matches);
        $tmp_array['time'] = strtotime($matches[1]);
        #		$tmp_array['size']=$tmp_array['dauer']*40000;
        $tmp_array['type'] = "file";
        if ($pos != "") {
            $txt = md5($pos . "/" . $tmp_array['title']);
            if (file_exists("fav/" . $txt)) {
                $tmp_array['title'] = "x" . $tmp_array['title'];
            }
        }
        $out[$tmp_array['title']] = $tmp_array;
    }
    return $out;
}
function dlflv_old($url)
{
    $page = cacheurl($url, false);
    preg_match('|video_id": "(.*?)"(?:.*?)"t": "(.*?)"|i', $page, $matches);
    $video = "http://www.youtube.com/get_video?video_id=" . $matches[1] . "&t=" . $matches[2];
    return $video;
}
function dlflv($url)
{
    if (EndsWith($url, ".flv")) {
        return $url;
    }
    $html = cacheurl($url);
    preg_match('|"videoUrl","(.*?)"|is', $html, $matches);
    # $tmp_array['title'] = rep($matches[2]);
    return "http://video.sat1.de" . urldecode($matches[1]);
}
function geturl($pfad)
{
    global $links;
    $r = explode("/", trim($pfad, "/"));
    $first = input($links[$r[2]]['url']);
    $trailer = trailer($first[$r[3]]['url']);
    $url = $trailer[$r[4]]['url'];
    $html = cacheurl($url);
    preg_match('|"file","/media/(.*?)"|si', $html, $matches);
    return "http://www.moviemaze.de/media/" . $matches[1];
}
function geturl($pfad)
{
    global $links;
    $r = explode("/", trim($pfad, "/"));
    $links = input($links[$r[2]]);
    $link = $links[$r[3]];
    $videos = tvtotal_video_list($link['url']);
    $selected_vid = $videos[$r[4]];
    $page = cacheurl('http://tvtotal.prosieben.de/tvtotal/includes/php/videoplayer_metadata.php?id=' . $selected_vid['id']);
    $cdata = preger('url_flv', $page);
    preg_match('|<\\!\\[CDATA\\[(.*?)\\]\\]>|', $cdata, $filter);
    return $filter[1];
}
function sub_navi($url)
{
    $t_html = cacheurl($url);
    #         preg_match_all('|onclick="xajax_show_top_and_movies(.*?)"(?:.*?)void\(0\)(?:.*?)>(.*?)</a>|si',$t_html,$matches);
    preg_match_all('|<div id="reiter(\\d+)"(.*?)</div>|si', $t_html, $matches);
    foreach ($matches[0] as $row) {
        preg_match('|onclick="xajax_show_top_and_movies\\((.*?)\\)|si', $row, $clickevent);
        $tmp_array['url'] = $url;
        $tmp_array['keys'] = $clickevent[1];
        $tmp_array['title'] = reducehtml(strip_tags($row));
        $out[$tmp_array['title']] = $tmp_array;
    }
    return $out;
}
function input()
{
    $t_html = cacheurl('http://www.shoutcast.com/sbin/newtvlister.phtml?alltv=1');
    preg_match_all('|<station(?:.*?)></station>|si', $t_html, $row);
    foreach ($row[0] as $mov) {
        preg_match('/id="(\\d+)"/i', $mov, $matches);
        $tmp_array['url'] = "http://www.shoutcast.com/sbin/tunein-tvstation.pls?id=" . $matches[1];
        preg_match('/name="(.*?)"/i', $mov, $matches);
        $tmp_array['title'] = reducehtml($matches[1]);
        $tmp_array['type'] = "file";
        $out[$tmp_array['title']] = $tmp_array;
    }
    return $out;
}
function input($url)
{
    $t_html = cacheurl($url, false);
    # echo $t_html;
    preg_match_all('/<item>(.*?)<\\/item>/si', $t_html, $row);
    foreach ($row[1] as $mov) {
        $tmp_array['title'] = reducehtml(preger("title", $mov));
        preg_match('/url="(.*?)"/is', $mov, $matches);
        $tmp_array['url'] = $matches[1];
        $tmp_array['type'] = "file";
        $out[$tmp_array['title']] = $tmp_array;
    }
    return $out;
}
function input($url, $pos = "")
{
    $t_html = cacheurl($url, true, array("age_check" => "1"), "Blanko");
    preg_match_all('|<li>(.*?)</li>|si', $t_html, $row);
    foreach ($row[1] as $mov) {
        preg_match('|class="title">(?:.*?)>(.*?)</a>|i', $mov, $matches);
        $tmp_array['title'] = reducehtml($matches[1]);
        preg_match('|href="(.*?)"|i', $mov, $matches);
        $tmp_array['url'] = "http://www.youporn.com" . $matches[1];
        preg_match('|<p class="duration">(\\d+)(?:.*?)(\\d+)(?:.*?)</p>|i', $mov, $matches);
        $tmp_array['time'] = $matches[1] * 60 + $matches[2];
        $tmp_array['type'] = "file";
        $out[$tmp_array['title']] = $tmp_array;
    }
    return $out;
}
function input()
{
    $t_html = cacheurl('http://www.apple.com/trailers/home/xml/current.xml');
    preg_match_all('/<movieinfo id="(.*?)">(.*?)<\\/movieinfo>/si', $t_html, $row);
    foreach ($row[2] as $mov) {
        preg_match("/<postdate>(.*?)<\\/postdate>/i", $mov, $matches);
        $tmp_array['time'] = strtotime($matches[1]);
        preg_match("/<title>(.*?)<\\/title>/i", $mov, $matches);
        $tmp_array['title'] = $matches[1];
        preg_match("/<large filesize=\"(.*?)\">(.*?)<\\/large>/i", $mov, $matches);
        $tmp_array['size'] = $matches[1];
        $tmp_array['url'] = $matches[2];
        $tmp_array['type'] = "file";
        $out[$tmp_array['title']] = $tmp_array;
    }
    return $out;
}
function getdir()
{
    global $UpdURL, $faketxt, $faketxtDL, $links;
    $r = split("/", trim($_GET['dir'], "/"));
    if (count($r) == 2) {
        $retArray = $links;
    }
    if (count($r) == 3) {
        $UpdURL = $links[$r[2]]['url'];
        $retArray = input($UpdURL);
    }
    if (count($r) == 4) {
        $retArray = $faketxt;
    }
    if (count($r) == 5) {
        $UpdURL = $links[$r[2]]['url'];
        $scripts = input($UpdURL);
        $scriptUrl = $scripts[$r[3]][url];
        $scriptName = $scripts[$r[3]][name];
        $down = cacheurl($scriptUrl);
        $sFunction = $r[4];
        switch ($sFunction) {
            case "Download":
                d_write("scripts/" . urldecode($scriptName), $down);
                $retArray = $faketxtDL;
                break;
            case "Info":
                preg_match('|<info>(.*?)</info>|si', $down, $row);
                $infoText = $row[1];
                $retArray = showText($infoText);
                break;
            case "Changelog":
                preg_match('|<changelog>(.*?)</changelog>|si', $down, $row);
                $infoText = $row[1];
                $retArray = showText($infoText);
                break;
            default:
                break;
        }
    }
    return gennavi($retArray);
}
/**
 * parse spiegeltv video id and returns the url
 *
 * @param string $id
 *   the id of the video
 * @param string $type=4
 *   the video quality
 * @return string 
 *   the url
 */
function spiegeltv_getvideo_url($id, $type = 4)
{
    $t_html = cacheurl('http://video.spiegel.de/flash/' . $id . '.xml');
    preg_match_all('|<filename>(.*?)</filename>|i', $t_html, $row);
    return 'http://video.spiegel.de/flash/' . $row[1][$type];
    /*
    	http://video.spiegel.de/flash/1036941.xml
    	http://video.spiegel.de/flash/1036941_480x360_H264_1400.mp4
        [1] => Array
            (
                [0] => 1032099_180x100_VP6_388.flv
                [1] => 1032099_560x315_VP6_576.flv
                [2] => 1032099_180x100_VP6_64.flv
                [3] => 1032099_996x560_VP6_928.flv
                [4] => 1032099_996x560_H264_1400.mp4
                [5] => 1032099.3gp
                [6] => 1032099_small.3gp
                [7] => 1032099_iphone.mp4
                [8] => 1032099_podcast.mp4
            )
    */
}
function input($url, $sub = false, $function = '')
{
    if ($sub == true) {
        return call_user_func($function, $url);
    }
    # we extract the links
    $html = cacheurl($url, USE_BROWSER_REQUEST);
    preg_match_all('|<a class="resultlink" href="/iplayer/page/item/(.*?).shtml.*?">(.*?)</a>|i', $html, $matches);
    foreach ($matches[2] as $key => $row) {
        $tmp_array['title'] = reducehtml($row);
        $tmp_array['url'] = "http://" . $_SERVER['SERVER_ADDR'] . ":" . $_SERVER['SERVER_PORT'] . "/requests/scripts/inc/iplayer_stream.php?pid=" . $matches[1][$key];
        $tmp_array['type'] = 'file';
        $out[$tmp_array['title']] = $tmp_array;
    }
    return $out;
}
function dlflv($url)
{
    $html = cacheurl($url);
    preg_match('|"videoUrl","(.*?)"|is', $html, $matches);
    # $tmp_array['title'] = rep($matches[2]);
    return "http://video.kabeleins.de/" . urldecode($matches[1]);
}
/**
 * peforms a search on myvideo and returns the videos as array
 *
 * @param string $string
 *   the searchstring
 * @param string $page
 *   the page of the results to display
 * @param string $orderby
 *   order the results: relevance=0,date=1,views=5
 * @return array
 *   returns videopages as array
 */
function myvideo_search_input($string, $page = 0, $orderby = 0)
{
    global $search;
    $url = str_replace("%string%", urlencode($string), $search);
    $url = str_replace("%orderby%", $orderby, $url);
    $url = str_replace("%page%", $page, $url);
    $t_html = cacheurl($url);
    $out = array();
    preg_match_all("|<span class='title'>(.*?)</span>|si", $t_html, $row);
    foreach ($row[0] as $mov) {
        preg_match("/title='(.*?)'/is", $mov, $matches);
        $tmp_array['title'] = reducehtml($matches[1]);
        preg_match("/href='(.*?)'/is", $mov, $matches);
        $tmp_array['url'] = "http://www.myvideo.de/" . $matches[1];
        $tmp_array['type'] = "file";
        $out[$tmp_array['title']] = $tmp_array;
    }
    return $out;
}
function mediaplayer($url)
{
    $html = cacheurl($url);
    preg_match('|initItemXML = "(.*?)"|is', $html, $xmlUrl);
    $html = cacheurl($xmlUrl[1]);
    preg_match('|<url>(.*?)</url>|is', $html, $matches);
    # $tmp_array['title'] = rep($matches[2]);
    return $matches[1];
}
/**
 * Reads available shows on zdfmediathek on the given char url 
 * they only returns 50 items so use characterRangeEnd and characterRangeEnd
 *
 * @param $url
 *  complete url: http://www.zdf.de/ZDFmediathek/xmlservice/web/sendungenAbisZ?characterRangeStart=A&characterRangeEnd=C&detailLevel=2
 * @return array
 *  list of shows
 */
function get_alpa_show($url)
{
    $html = cacheurl($url);
    preg_match_all('/<information>(.*?)<\\/assetId>/si', $html, $shows);
    $out = array();
    foreach ($shows[0] as $show) {
        $tmp_array = array();
        preg_match('/<title>(.*?)<\\/title>/i', $show, $title);
        $tmp_array['title'] = reducehtml($title[1]);
        preg_match('/<detail>(.*?)<\\/detail>/i', $show, $detail);
        $tmp_array['detail'] = $detail[1];
        preg_match('/<assetId>(.*?)<\\/assetId>/i', $show, $assetId);
        $tmp_array['assetId'] = $assetId[1];
        $out[$tmp_array['title']] = $tmp_array;
    }
    return $out;
}
function getflv($id)
{
    $t_html = cacheurl("http://mediaservices.myspace.com/services/rss.ashx?type=video&videoID=" . $id);
    preg_match('|<media:content url="(.*?)"|is', $t_html, $matches);
    return $matches[1];
}