function plan_get_owner_info($planowner)
{
    $planowner = trim($planowner);
    // if we're reading a feed, get the whole url
    if ($planowner == 'http:' || $planowner == 'feed:') {
        //		$planowner_a=$_SERVER['URL_ARRAY'];
        //		unset($planowner_a[0],$planowner_a[1]);
        $planowner = str_replace('/read/', '', $_SERVER['REQUEST_URI']);
        //		$planowner=implode('/',$planowner_a);
        //		if ($planowner[strlen($planowner)-1]=='/')
        //			$planowner=substr($planowner,0,strlen($planowner)-1);
    }
    // if the user isn't local, don't try to read their info in.
    if (user_is_local($planowner)) {
        $planowner = plan_repair_local_name($planowner);
        if (file_exists("{$_SERVER['PWUSERS_DIR']}/{$planowner}/userinfo.dat") && file_exists("{$_SERVER['PWUSERS_DIR']}/{$planowner}/preferences.dat")) {
            $_SERVER['PLANOWNER_INFO_ARRAY'] = array_merge(unserialize(file_get_contents("{$_SERVER['PWUSERS_DIR']}/{$planowner}/userinfo.dat")), unserialize(file_get_contents("{$_SERVER['PWUSERS_DIR']}/{$planowner}/preferences.dat")));
        }
        $_SERVER['PLANOWNER_ROOT'] = "{$_SERVER['PWUSERS_DIR']}/{$planowner}";
        $_SERVER['PLANOWNER_INFO_ARRAY']['salt'] = plan_get_salt($planowner);
    }
    // let all the other functions know who the planowner is.
    $_SERVER['PLANOWNER'] = $planowner;
    $_SERVER['PLANOWNER_REAL_LOCATION'] = plan_get_real_location($planowner);
    //	if ($_SERVER['USER']=='jwdavidson') echo $_SERVER['PLANOWNER'];
    // always present the case the planowner specified for their name
    $_SERVER['PLANOWNER_DISPLAY_NAME'] = plan_repair_local_name($planowner);
    // if it's a blog, use the title as the display name instead of the url
    if (strpos($_SERVER['PLANOWNER_REAL_LOCATION'], '://')) {
        //		if (substr_count($_SERVER['PLANOWNER_REAL_LOCATION'],"://"))
        //		{
        //			$_SERVER['PLANOWNER_DISPLAY_NAME']="Metafeed";
        //		}
        //		else
        $_SERVER['PLANOWNER_DISPLAY_NAME'] = plan_repair_blog_name($planowner);
    }
}
Пример #2
0
function buttons_populate($content)
{
    //TOP LINK ICONS
    if (strlen($GLOBALS['viewicon']) > 1) {
        $vistring = "<img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['viewicon']}' border='0' align='bottom' vspace='2' id='viewicon' alt='icon' />";
    }
    if (strlen($GLOBALS['writeicon']) > 1) {
        $wistring = "<img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['writeicon']}' border='0' align='bottom' vspace='2' id='writeicon' alt='icon' />";
    }
    if (strlen($GLOBALS['toolsicon']) > 1) {
        $tistring = "<img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['toolsicon']}' border='0' align='bottom' vspace='2' id='toolsicon' alt='icon' />";
    }
    if (strlen($GLOBALS['snitchicon']) > 1) {
        $sistring = "<img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['snitchicon']}' border='0' align='bottom' vspace='2' id='snitchicon' alt='icon' />";
    }
    if (strlen($GLOBALS['helpicon']) > 1) {
        $histring = "<img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['helpicon']}' border='0' align='bottom' vspace='2' id='helpicon' alt='icon' />";
    }
    if (strlen($GLOBALS['logouticon']) > 1) {
        $listring = "<img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['logouticon']}' border='0' align='bottom' vspace='2' id='logouticon' alt='icon' />";
    }
    if ($GLOBALS['hfsize'] > 0 && $GLOBALS['hfsize'] != '1px') {
        $viewtext = ' view';
        $toolstext = ' tools';
        $writetext = ' write';
        $snitchtext = ' snitch';
        $helptext = ' help';
        $logouttext = ' logout';
        $masqtext = ' masq off';
    }
    $view = "<li class='menuicon'><a style='z-index: 21;' href='{$_SERVER['WEB_ROOT']}/view'>{$vistring}{$viewtext}</a>\n<ul>" . menus_populate('view') . "</ul></li>";
    if (user_is_local($_SERVER['USER'])) {
        $write = "<li class='menuicon'><a style='z-index: 23;' href='{$_SERVER['WEB_ROOT']}/write'>{$wistring}{$writetext}</a>\n<ul>" . menus_populate('write', $content) . "</ul></li>";
    }
    $tools = "<li class='menuicon'><a style='z-index: 30;' href='{$_SERVER['WEB_ROOT']}/tools'>{$tistring}{$toolstext}</a>\n<ul>" . menus_populate('tools') . "</ul></li>";
    $snitch = "<li class='menuicon'><a href='{$_SERVER['WEB_ROOT']}/snitch' title='see who reads you, and read them back'>{$sistring}{$snitchtext}</a>\n<ul>" . menus_populate('snitch') . "</ul></li>\n";
    $help = "<li class='menuicon'><a href='{$_SERVER['WEB_ROOT']}/help'>{$histring}{$helptext}</a></li>\n";
    if ($_SERVER['MASQUERADE']) {
        $logout = "<li class='menuicon'><a href='{$_SERVER['WEB_ROOT']}/masq/off' title='end the masquerade!'>{$listring}{$masqtext}</a></li>\n";
    } else {
        $logout = "<li class='menuicon'><a href='{$_SERVER['WEB_ROOT']}/logout' title='log out {$_SERVER['USER']}'>{$listring}{$logouttext}</a></li>\n";
    }
    if ($_SERVER['USERINFO_ARRAY']['displayloadtime']) {
        $time_icon_string = "<img src='{$_SERVER['WEB_ROOT']}/resources/graphics/clock.png' id='timeicon' alt='time icon'/>";
        $time = "<li class='menuicon'>{$time_icon_string} <span style='font-size: 8pt;'><!--TIME--></span><ul>" . menus_populate('<!--TIME-->') . "</ul></li>";
    }
    return $view . $write . $snitch . $tools . $help . $logout . $time;
}
Пример #3
0
function plan_read($planowner, $threshhold = FALSE, $begindate = FALSE, $unformatted = FALSE, $remotesnitch = FALSE)
{
    if ($planowner == 'invite' || $planowner == '*****@*****.**') {
        return plan_read_invite($reader);
    }
    if ($planowner == 'backup' || $planowner == '*****@*****.**') {
        return plan_read_backup($reader);
    }
    if ($planowner == 'backup_archives' || $planowner == '*****@*****.**') {
        return plan_read_backup($reader, "archives");
    }
    $reader = $_SERVER['USER'];
    if ($reader == 'cacheuser') {
        $utility = 1;
    }
    $plan_read_rand = rand();
    if (!isset($_SERVER['PLANOWNER_INFO_ARRAY']) || $_SERVER['PLANOWNER'] != $planowner) {
        plan_get_owner_info($planowner);
    }
    profile("plan_read_{$plan_read_rand}");
    profile("plan_read_head_{$plan_read_rand}");
    if (plan_is_local($planowner)) {
        $islocal = TRUE;
        $planowner = plan_repair_local_name($planowner);
    } else {
        if (user_is_local($planowner)) {
            $localusernotplan = TRUE;
            $localusername = $planowner;
        }
    }
    include_once 'snitch.php';
    include_once 'spiel.php';
    if ($_SERVER['REMOTENODE']) {
        if (isset($_SERVER['PLANOWNER_INFO_ARRAY']['fingerpref']) && $_SERVER['PLANOWNER_INFO_ARRAY']['fingerpref'] == 0) {
            snitch_write($reader, $planowner, ' failed');
            return "{$planowner}'s plan is not available for reading outside planwatch.org.";
        }
    }
    // tests the user against the planowner's privacy settings,
    // blocked list, and allowed list
    $plan_test_privacy = plan_test_privacy($reader, $planowner, $remotesnitch);
    $authorized = user_is_authorized($planowner, $reader);
    if (!$_SERVER['PLANOWNER_REAL_LOCATION']) {
        plan_get_owner_info($planowner);
    }
    if (user_is_local($planowner) && !plan_is_local($planowner)) {
        $localplan = plan_read_local($planowner, $threshhold, $begindate, $unformatted);
    }
    if ($_SERVER['PLANOWNER_REAL_LOCATION']) {
        $planowner = $_SERVER['PLANOWNER_REAL_LOCATION'];
    }
    profile("plan_read_head_{$plan_read_rand}");
    // on with the show
    if ($plan_test_privacy) {
        if ($islocal) {
            $plan = plan_read_local($planowner, $threshhold, $begindate, $unformatted);
        }
        //		elseif($localusernotplan) $localplan=plan_read_local($localusername,$threshhold,$begindate,$unformatted);
        if (strpos($planowner, '@') !== FALSE && !strpos($planowner, '://') && !$plan) {
            // if it comes from another planworld node (we used to fingertest in here too)
            list($xmlrpc_username, $xmlrpc_node) = explode('@', $planowner);
            $plan = plan_read_xmlrpc($xmlrpc_username, $xmlrpc_node);
        }
        if (strpos($planowner, '://') && !$plan) {
            // if it's a URL call plan_read_web()
            // plan_read_web passes it on to plan_read_rss_simplepie if necessary.
            $url = $planowner;
            $plan = plan_read_web($url);
        }
        // Valid snitches only get set here
        if ((!$threshhold || $threshhold == '2d' || $threshhold == $_SERVER['PLANOWNER_INFO_ARRAY']['defaultdays'] . "d") && !$begindate) {
            snitch_write($reader, $planowner);
        } else {
            snitch_write($reader, $planowner, " archives ( {$threshhold} {$_SERVER['PLANOWNER_INFO_ARRAY']['defaultdays']}{$begindate} )");
        }
        if (file_exists("{$_SERVER['PWUSERS_DIR']}/{$_SERVER['USER']}/userinfo.dat")) {
            user_update_lastread($planowner);
        }
        $plan = trim($localplan) . $plan;
    } else {
        // if the privacy test didn't check out, display the blocked message
        $blocked_fn = "{$_SERVER['PWUSERS_DIR']}/{$planowner}/blockedmessage.txt";
        if (file_exists($blocked_fn)) {
            $plan = stripslashes(stripslashes(file_get_contents($blocked_fn)));
            $plan = str_replace('MYUSER', $planowner, $plan);
            $plan = str_replace('READER', $reader, $plan);
        } else {
            if ($_SERVER['whitelist_passed'] === FALSE) {
                $plan = "<h1>Security Error</h1>Unverified readers from planworld.net are not allowed to read protected planwatch.org plans without\n\t\t\t\tspecific permission from the author. Please send the owner of this plan, or email <a href='mailto:help@planwatch.org'>help@planwatch.org</a>\n\t\t\t\tto be added to the list of verified readers. ";
            } else {
                $plan = "<h1>Error: No Such User</h1>No user found by that name. Please try again, {$reader}.";
            }
        }
        snitch_write($reader, $planowner, ' failed');
        if (file_exists("{$_SERVER['PWUSERS_DIR']}/{$_SERVER['USER']}/userinfo.dat")) {
            user_update_lastread($planowner);
        }
    }
    profile("plan_format_{$plan_read_rand}");
    if (!$utility && !$unformatted) {
        profile("plan_read_tail_{$plan_read_rand}");
        $plan = plan_add_alias_links($plan, $planowner);
        if (!$_SERVER['REMOTENODE']) {
            $plan = spiel_format($plan, $planowner);
            $plan = plan_add_user_links($plan);
        } else {
            preg_replace("|!sp[ie][ie]l:(.*):(.*)!|", "<a href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/spiel/view/\\1'>\\2</a>", $plan);
            preg_replace("|!sp[ei][ie]l:(.*)!|", "<a href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/spiel/view/\\1'>\\1</a>", $plan);
            $plan = plan_process_directives($plan, TRUE);
            // turn on remotepatch to avoid processing directives other nodes will handle
            if (strstr($plan, "aside")) {
                $plan = "<style>aside.sidebar { float: right; width: 200px; margin-left: 20px; }</style>{$plan}";
            }
        }
        if (strstr($plan, 'http://')) {
            $plan = plan_match_embed_urls($plan);
        }
        $plan = plan_embed_player($plan);
        $plan = str_replace(array("id=\"content\"", "id='content'"), "id='content2'", $plan);
        $plan = str_replace("#content", "#content2", $plan);
        $plan = str_replace("font-color:", "color:", $plan);
        $plan = str_replace("position: absolute", "position: relative;", $plan);
        $plan = hyperlink($plan);
        if (strpos($plan, "/read/{$_SERVER['USER']}")) {
            $plan = str_replace("<a target='_self' href='/read/{$_SERVER['USER']}'", "<a target='_self' id='snoop' href='/read/{$_SERVER['USER']}'", $plan);
        }
        $plan = str_replace("@note", "@amherst.edu", $plan);
        $plan = str_replace("@pwn", "@planworld.net", $plan);
        $remoteuser = str_replace($_SERVER['REMOTENODE'], "", $_SERVER['USER']);
        if (strpos($plan, "?id={$remoteuser}")) {
            $plan = str_replace("<a href='?id={$remoteuser}", "<a id='snoop' href='?id={$remoteuser}", $plan);
        }
        if (strpos($plan, "!{$_SERVER['USER']}")) {
            $plan = preg_replace("/!{$_SERVER['USER']}:([^!]+)!/", "<a id='snoop' href='?id={$remoteuser}'>\\1</a>", $plan);
            $plan = preg_replace("/!{$_SERVER['USER']}!/", "<a id='snoop' href='?id={$remoteuser}'>{$_SERVER['USER']}</a>", $plan);
        }
        if (strpos($plan, "id='snoop'")) {
            if ($_SERVER['OUTPUT_MODE'] == 'HTML') {
                $plan = "<a href='#snoop'>Find My Snoop</a><br />\n{$plan}";
            }
            if ($_SERVER['OUTPUT_MODE'] == 'IPHONE' || $_SERVER['OUTPUT_MODE'] == 'MOBILE') {
                $plan = "<a href='javascript:alert(getRealTop(\"snoop\"));'>Find My Snoop</a><br />\n{$plan}";
            }
        }
        if ($_SERVER['USERINFO_ARRAY']['strip_css'] == 1) {
            $plan = plan_strip_css($plan);
        }
        if ($_SERVER['USERINFO_ARRAY']['strip_css'] == 2) {
            $plan = plan_confine_css($plan);
        }
    }
    profile('encoding');
    if (!$url) {
        $encoding = mb_detect_encoding($plan, 'UTF-8, ISO-8859-1');
        if ($encoding !== 'UTF-8') {
            $plan = mb_convert_encoding($plan, 'UTF-8', $encoding);
        }
    }
    profile('encoding');
    profile("plan_read_tail_{$plan_read_rand}");
    profile("plan_read_{$plan_read_rand}");
    profile("plan_format_{$plan_read_rand}");
    return $plan;
}