示例#1
0
function output_iphone($title, $content)
{
    if (strstr($_SERVER['REQUEST_URI'], '/watched') || $_SERVER['REQUEST_URI'] == '/') {
        $current = 'watchedtab';
    }
    if (strstr($_SERVER['REQUEST_URI'], '/send')) {
        $current = 'sendtab';
    }
    if (strstr($_SERVER['REQUEST_URI'], '/tools')) {
        $current = 'toolstab';
    }
    if (strstr($_SERVER['REQUEST_URI'], '/snitch')) {
        $current = 'snitchtab';
    }
    if (strstr($_SERVER['REQUEST_URI'], '/write')) {
        $current = 'writetab';
    }
    if (strstr($_SERVER['REQUEST_URI'], '/read')) {
        $current = 'NULL';
    }
    if (strstr($_SERVER['REQUEST_URI'], '/read') || strstr($_SERVER['REQUEST_URI'], '/send') || strstr($_SERVER['REQUEST_URI'], '/bio')) {
        $readertoolbar = "<ul id='reader_toolbar'>" . output_build_reader_toolbar($content) . "</ul>";
    }
    $extracss = "<style type='text/css'>{$_SERVER['PLANOWNER_INFO']['css']}</style>";
    if ($_SERVER['USER'] && $_SERVER['USER'] != 'guest') {
        $tabbar = "\n\t\t\t<ul class=\"tabbar\">\n\t\t\t<li id='writetab'><a id='write' onclick='setCurrent(\"writetab\");' href=\"/write/\">Write</a></li>\n\t\t\t<li id='snitchtab'><a id='snitch' onclick='setCurrent(\"snitchtab\");void(0);' href=\"/snitch/\">Snitch</a></li>\n\t\t\t<li id='sendtab'><a id='send' onclick='setCurrent(\"sendtab\");void(0);' href=\"/send/\">Send</a></li>\n\t\t\t<li id='watchedtab'><a id='watched' onclick='setCurrent(\"watchedtab\");void(0);' href=\"/\">Watched</a></li>\n\t\t\t<!--<li style='border: 0px; background: transparent;'>&nbsp;</li>-->\n\t\t\t<!--<li id='viewtab'><a id='view' onclick='setCurrent(\"viewtab\");void(0);' href=\"/read/{$_SERVER['USER']}\">View</a></li>-->\n\t\t\t<li id='xtab' ><a onclick='setCurrent(\"xtab\");void(0);' href='/logout' style='color: {$GLOBALS['listsbgcolor']}; font-weight: bold;'>&nbsp; X &nbsp;</a></li>\n\t\t\t<li id='toolstab' ><a id='tools' style='color: {$GLOBALS['listsbgcolor']}; font-weight: bold;' onclick='setCurrent(\"toolstab\");void(0);' href=\"/tools/\">&#x2699;</a></li>\n\t\t</ul>\n";
    } else {
        $tabbar = "<!--\n\t\t\t<ul class=\"tabbar\">\n\t\t\t<li id='logintab'>Log In to Planwatch</li>\n\t\t\t</ul>-->\n";
    }
    if (agent_is_lowfi()) {
        $tabbar = str_replace(array("<ul", "</ul>", "<li", "</li>"), array("<div", "</div>", " [<span", "</span>] "), $tabbar);
        $content = str_replace(array("<ul", "</ul>", "<li", "</li>"), array("<div", "</div>", " <div", "</div> "), $content);
        $tabbar = str_replace(array("<ul", "</ul>", "<li", "</li>"), array("<div", "</div>", "<span", "</span>"), $tabbar);
        $tabbar = str_replace("> X <", ">Logout<", $tabbar);
        $tabbar .= "<hr />";
    }
    // READ IN AND POPULATE THE TEMPLATE
    if ((!strstr($_SERVER['HTTP_REFERER'], 'iphone.planwatch') && !strstr($_SERVER['HTTP_REFERER'], 'm.planwatch') && !strstr($_SERVER['HTTP_REFERER'], 'm2.planwatch') || $_COOKIE['redirected'] == "1" || agent_is_lowfi()) && !strstr($_SERVER['REQUEST_URI'], 'ajax')) {
        $cookie_host = $_SERVER['HTTP_HOST'];
        if (substr_count($cookie_host, '.') < 2) {
            $cookie_host = ".{$cookie_host}";
        }
        $cookie_host = str_replace('www', '', $cookie_host);
        setcookie("redirected", "0", time() - 1, $_SERVER['WEB_ROOT'] . "/", $cookie_host);
        $res_dir = "{$_SERVER['FILE_ROOT']}/resources/";
        $version = max(filemtime("{$res_dir}/javascript/ajax.js"), filemtime("{$res_dir}/javascript/iphone_ajax.js"), filemtime("{$res_dir}/javascript/iui.js"), filemtime("{$res_dir}/templates/iui.css"), filemtime("{$res_dir}/templates/rss.css"), filemtime("{$res_dir}/templates/atom.css"));
        $page = str_replace("/includes/", "/includes/{$version}/", $page);
        if ($_SERVER['HTTP_HOST'] == 'm2.planwatch.org') {
            $page = str_replace('"', '\\"', file_get_contents("{$_SERVER['FILE_ROOT']}/resources/templates/template.iui3.html"));
            if (strstr($page, '</body>')) {
                $page = str_replace('</body>', "<script type='application/x-javascript'>setCurrent('{$current}');</script>\n</body>", $page);
            } else {
                $page .= "n<script type='application/x-javascript'>setCurrent('{$current}');</script>";
            }
            eval("\$page=\"{$page}\";");
            $page = "<!DOCTYPE html>" . $page;
        } else {
            $page = str_replace('"', '\\"', file_get_contents("{$_SERVER['FILE_ROOT']}/resources/templates/template.iphone.html"));
            if (strstr($page, '</body>')) {
                $page = str_replace('</body>', "<script type='application/x-javascript'>setCurrent('{$current}');</script>\n</body>", $page);
            } else {
                $page .= "n<script type='application/x-javascript'>setCurrent('{$current}');</script>";
            }
            eval("\$page=\"{$page}\";");
            $page = str_replace(array("& ", "&& "), array("&amp;", "&amp;&amp;"), $page);
            $page = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" . $page;
        }
    } else {
        $page = "<div class='main_content' title='{$title}' id='{$_SERVER['QUERY_STRING']}'><style type='text/css'>{$_SERVER['PLANOWNER_INFO']['css']}</style>{$readertoolbar} {$content}</div>\n<script type='application/x-javascript'>setCurrent('{$current}');</script>";
    }
    @Header("Expires: 240");
    @Header("Cache-control: max-age=240, must-revalidate");
    return $page;
}
function format_watched_list_html($controls = TRUE)
{
    // WATCHED LIST
    //------------------------------------------------------------------------------
    if (!user_is_valid($_SERVER['USERINFO_ARRAY']['username'], $_SERVER['USERINFO_ARRAY']['userpass'])) {
        //		$planwatchlist = "\n<li class='listheader'>Advertised Plans</li>\n";
        $list_fn = "{$_SERVER['FILE_ROOT']}/resources/advertised.txt";
        // read in the advertised plans list, break it into an array,
        // and run it through the list formatter
        if (file_exists($list_fn)) {
            $list = file($list_fn);
            $list = array_merge(array("!!!", "!prune31d", "#Advertised Plans"), $list);
            $planwatchlist .= list_format_html($list, 'time');
        }
    } else {
        $_SERVER['STOPWATCH']['watched_begin'] = array_sum(explode(' ', microtime()));
        $loadtime = formattime(time());
        if ($controls) {
            $planwatchlist = "\n\t\t<li style='font-size: 120%; float: right;'>\n\t\t\t<a class='tool' id='menuwatched_icon' href='javascript:var editlinks=document.getElementById(\"watched_list_edit\");if (editlinks.style.display==\"none\") editlinks.style.display=\"block\"; else editlinks.style.display=\"none\"; void(null);' ><span class='hidden'>edit</span> &#x2699;</a>\n\t\t\t<a class='tool' href='javascript:watched_list_refresh();void(null);' title='{$loadtime}'><span class='hidden'>{$loadtime}</span> &#x21bb;\n\t\t\t</a>\n\t\t</li>\n\t\t<li><ul style='list-style: none; display: none; padding-left: 0px; margin-left: 0px; line-height: 100%; border-bottom: 1px dashed rgba(255,255,255,0.8); background: rgba(255,255,255,0.6); border-radius: 10px;' id='watched_list_edit'>" . menus_populate('watched') . "</ul></li>\n";
        }
        //		if ($_SERVER['USER']!='jwdavidson' && !strstr($_SERVER['REQUEST_URI'],'watched'))
        $planwatchlist .= list_format_html();
        $key = md5($planwatchlist);
        if (!stristr($_SERVER['HTTP_USER_AGENT'], 'blackberry')) {
            $planwatchlist .= "<li style='display: none;' id='key'>{$key}</li>";
        }
        $_SERVER['WATCHED_KEY'] = $key;
        $_SERVER['STOPWATCH']['watched_end'] = array_sum(explode(' ', microtime()));
        // SNOOP LIST
        //------------------------------------------------------------------------------
        include_once 'snoop.php';
        $_SERVER['STOPWATCH']['snoop_begin'] = array_sum(explode(' ', microtime()));
        if ($_SERVER['USERINFO_ARRAY']['showsnoop']) {
            $snooplinks = snoop_list("planwatch");
            if (trim(strip_tags($snooplinks))) {
                if (agent_is_lowfi()) {
                    $planwatchlist .= "\n<br /><br /><div><b>Snoops</b></div>\n{$snooplinks}\n\n";
                } else {
                    $planwatchlist .= "\n<li class='listheader'>Snoops</li>\n{$snooplinks}\n\n";
                }
            }
        }
        $_SERVER['STOPWATCH']['snoop_end'] = array_sum(explode(' ', microtime()));
    }
    // SPIEL LIST
    //------------------------------------------------------------------------------
    $_SERVER['STOPWATCH']['spiel_begin'] = array_sum(explode(' ', microtime()));
    include_once 'spiel.php';
    $planwatchlist .= spiel_format_list_html();
    $_SERVER['STOPWATCH']['spiel_end'] = array_sum(explode(' ', microtime()));
    return $planwatchlist;
}