Esempio n. 1
0
function bio_read($bio_owner, $which = 'both', $edit = FALSE)
{
    include_once 'plan_read.php';
    if (strpos($bio_owner, '@dl') || strpos($bio_owner, '@diaryland')) {
        $bio = bio_read_diaryland($bio_owner);
    }
    if (strpos($bio_owner, '@lj') || strpos($bio_owner, '@livejournal')) {
        $bio = bio_read_livejournal($bio_owner);
    }
    if (strpos($bio_owner, '@dj') || strpos($bio_owner, '@deadjournal')) {
        $bio = bio_read_livejournal($bio_owner, 'dead');
    }
    $bio_fn = "{$_SERVER['PWUSERS_DIR']}/{$bio_owner}/bio.txt";
    $bio_p_fn = $bio_fn . ".p";
    if (file_exists($bio_fn) && ($which == 'public' || $which == 'both')) {
        $bio = plan_add_user_links(stripslashes(stripslashes(file_get_contents($bio_fn))));
    }
    if (file_exists($bio_p_fn) && ($which == 'private' || $which == 'both') && user_is_authorized($bio_owner, $_SERVER['USER'])) {
        $bio_p = plan_add_user_links(stripslashes(stripslashes(file_get_contents($bio_p_fn))));
    }
    if ($bio != $bio_p && $which == 'both' && !$edit) {
        $bio .= "\n<br />\n" . $bio_p;
    }
    if ($which == 'private') {
        $bio = $bio_p;
    }
    if (!$bio) {
        $bio = '';
    }
    //	if($bio_owner==$_SERVER['USER'] && !$edit) $bio.="$bio_owner $_SERVER[USER] <br clear='all' /><a class='bigbutton' href='/write/bio'>&#x270e; edit your bio</a>";
    return $bio;
}
Esempio n. 2
0
function output_build_reader_toolbar_desktop($content)
{
    if ($_SERVER['URL_ARRAY'][1] == 'read' || $_SERVER['URL_ARRAY'][1] == 'send' && $_SERVER['URL_ARRAY'][2]) {
        // build a bio link if appropriate (and the bio isn't currently the content)
        if ((file_exists("{$_SERVER['PWUSERS_DIR']}/{$_SERVER['PLANOWNER']}/bio.txt") || (strpos($_SERVER['PLANOWNER_REAL_LOCATION'], 'diaryland') || strpos($_SERVER['PLANOWNER_REAL_LOCATION'], 'livejournal'))) && !($_SERVER['URL_ARRAY'][3] == 'bio')) {
            $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/read/{$_SERVER['PLANOWNER_REAL_LOCATION']}/bio'>bio</a>\n";
        }
        if ((strpos($_SERVER['PLANOWNER_REAL_LOCATION'], 'planworld.net') || strpos($_SERVER['PLANOWNER_REAL_LOCATION'], 'amherst.edu') || plan_is_local($_SERVER['PLANOWNER'])) && $_SERVER['PLANOWNER'] != $_SERVER['USER'] && $_SERVER['URL_ARRAY'][1] != 'send') {
            if (IS_JOSH) {
                $send_files = files_list("{$_SERVER['USER_ROOT']}/sends", files_encode_safe_name("{$_SERVER['PLANOWNER']}") . "*");
                if (is_array($send_files)) {
                    $lastsend = formattime(filemtime("{$_SERVER['USER_ROOT']}/sends/" . end($send_files)));
                    if (strstr(end($send_files), '.new')) {
                        $lastsend .= " <b>NEW</b>";
                    }
                }
                $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/send/{$_SERVER['PLANOWNER_REAL_LOCATION']}/'>send <span style='opacity: 0.5'>{$lastsend}</span></a>";
            } else {
                $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/send/{$_SERVER['PLANOWNER_REAL_LOCATION']}/'>send</a>\n";
            }
        }
        // build a plan link instead if the reader is reading the bio or send
        if ($_SERVER['URL_ARRAY'][3] == 'bio' || $_SERVER['URL_ARRAY'][1] == 'send') {
            $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/read/{$_SERVER['PLANOWNER_REAL_LOCATION']}' >plan</a>\n";
        }
        // build an archive link, if appropriate
        if (plan_has_archives($_SERVER['PLANOWNER_REAL_LOCATION'])) {
            if (!in_array('archives', $_SERVER['URL_ARRAY'])) {
                $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/read/{$_SERVER['PLANOWNER']}/archives' >archives</a>\n";
            } else {
                $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/read/{$_SERVER['PLANOWNER']}' >plan</a>\n";
            }
        }
        // If the reader isn't watching the writer, offer the option
        if (!stristr($testwatchlist, $_SERVER['PLANOWNER']) && !stristr($testwatchlist, $_SERVER['PLANOWNER_REAL_LOCATION'])) {
            $readertoolbar[] = "<span id='watch_link'><a class='action' href=\"javascript:loadXMLDoc('{$_SERVER['WEB_ROOT']}/lists/add_ajax/watched/!{$_SERVER['PLANOWNER_REAL_LOCATION']}:{$_SERVER['PLANOWNER_DISPLAY_NAME']}!',null,'planwatch');void(null);\" title='add {$_SERVER['PLANOWNER_DISPLAY_NAME']} to your watched list' >watch</a></span>\n";
        } else {
            $readertoolbar[] = "<span id='watch_link'><a class='action' href=\"javascript:loadXMLDoc('{$_SERVER['WEB_ROOT']}/lists/remove_ajax/watched/{$_SERVER['PLANOWNER_REAL_LOCATION']}',null,'planwatch');void(null);\" title='remove {$_SERVER['PLANOWNER_DISPLAY_NAME']} from your watched list' >unwatch</a></span>\n";
        }
        // if writer isn't a blog or the same as reader, offer the option of
        // blocking, unblocking, allowing, or disallowing access to reader's plan
        if ($_SERVER['PLANOWNER'] != $_SERVER['USER'] && !strpos($_SERVER['PLANOWNER'], '://')) {
            if (!user_is_blocked($_SERVER['USER'], $_SERVER[PLANOWNER])) {
                $readertoolbar[] = "<a class='action' href='{$_SERVER['WEB_ROOT']}/lists/add/blocked/{$_SERVER['PLANOWNER']}' title='block {$_SERVER['PLANOWNER_DISPLAY_NAME']} from reading your plan altogether' >block</a>\n";
            } else {
                $readertoolbar[] = "<a class='action' href='{$_SERVER['WEB_ROOT']}/lists/remove/blocked/{$_SERVER['PLANOWNER']}' title='unblock {$_SERVER['PLANOWNER_DISPLAY_NAME']} so they can read your public plan again' >unblock</a>\n";
            }
            if (!user_is_authorized($_SERVER['USER'], $_SERVER[PLANOWNER])) {
                $readertoolbar[] = "<a class='action' href='{$_SERVER['WEB_ROOT']}/lists/add/allowed/{$_SERVER['PLANOWNER']}' title='allow {$_SERVER['PLANOWNER_DISPLAY_NAME']} to read your private plan' >allow</a>\n";
            } else {
                $readertoolbar[] = "<a class='action' href='{$_SERVER['WEB_ROOT']}/lists/remove/allowed/{$_SERVER['PLANOWNER']}' title='disallow {$_SERVER['PLANOWNER_DISPLAY_NAME']} from reading your private plan'>disallow</a>\n";
            }
            // offer administrators a link to masquerade as writer
            // this is so it's easy to follow up on plan-reported bugs
            if (user_is_administrator() && file_exists("{$_SERVER['PWUSERS_DIR']}/{$_SERVER['PLANOWNER']}/userinfo.dat")) {
                $readertoolbar[] = "<a class='action' href='{$_SERVER['WEB_ROOT']}/masq/on/{$_SERVER['PLANOWNER']}'>masq</a>";
            }
            $readertoolbar[] = "<a class='action' href='/lists/unread/{$_SERVER['PLANOWNER']}'>unread</a>";
        }
        if ($_SERVER['PLANOWNER'] && $_SERVER['PLANOWNER'] == $_SERVER['USER'] && !strpos($_SERVER['PLANOWNER'], '@') && browser_is_modern()) {
            $readertoolbar[] = "<a class='action' href='/write'>new entry</a>";
        }
        // make the links into a string for output.
        foreach ($readertoolbar as $tool) {
            if (strstr($tool, 'action')) {
                $class = " class='action' ";
            } else {
                $class = '';
            }
            $readertoolbar_html .= "<li {$class}>{$tool}</li>";
        }
        $readertoolbar = "\n<li class='listheader'>{$_SERVER['PLANOWNER_DISPLAY_NAME']}</li>" . $readertoolbar_html;
        if (IS_JOSH) {
            if ($lasttime = plan_get_last_update($_SERVER['PLANOWNER'])) {
                $readertoolbar .= "<li class='action'  style='font-size: 80%; float: right;'>updated " . formattime($lasttime) . "</li>";
            }
            if ($lastlogin = plan_get_last_login($_SERVER['PLANOWNER'])) {
                if (trim($lastlogin) && $lastlogin > 0) {
                    $readertoolbar .= "<li class='action' style='font-size: 80%; float: right;'>active " . formattime($lastlogin) . "</li>";
                }
            }
        } else {
            if ($lasttime = plan_get_last_update($_SERVER['PLANOWNER'])) {
                $readertoolbar .= "<li class='plan_data_block'>Last Update: " . formattime($lasttime) . "</li>";
            }
            if ($lastlogin = plan_get_last_login($_SERVER['PLANOWNER'])) {
                if (trim($lastlogin) && $lastlogin > 0) {
                    $readertoolbar .= "<li class='plan_data_block' id='lastaction'>Last Action: " . formattime($lastlogin) . "</li>";
                }
            }
        }
    }
    return $readertoolbar;
}
function plan_test_privacy($reader, $planwriter, $remotesnitch = FALSE)
{
    $valid = FALSE;
    // if the reader is blocked, give up now
    if (!user_is_blocked($planwriter, $reader)) {
        $whitelist = file_get_contents("{$_SERVER['FILE_ROOT']}/resources/whitelist.txt");
        if (!strstr($reader, '@planworld.net') || user_is_authorized($planwriter, $reader) || strstr($whitelist, $reader)) {
            $_SERVER['whitelist_passed'] = TRUE;
        } else {
            $_SERVER['whitelist_passed'] = FALSE;
        }
        // if the writer is registered only, there are a few considerations:
        // 1. the reader is registered here
        // 2. OR the reader is registered elsewhere in planworld
        // 3. if the reader is offsite, they must have snitch on
        // 4. if the reader is from planworld.net, they must be on the whitelist
        // 5. if the reader is registered here, they must have confirmed their email address
        // 6. EXCEPT the writer can personally allow any reader, regardless of snitch status
        if (plan_is_registered_only($planwriter) && $reader != 'guest' && $reader != 'rss reader' && trim($reader) && !plan_is_private($planwriter) && !file_exists("{$_SERVER['PWUSERS_DIR']}/{$reader}/unconfirmed") && ($_SERVER['USERINFO_ARRAY']['snitchlevel'] >= 1 || user_is_authorized($planwriter, $reader) || $reader == 'cacheuser') && $_SERVER['whitelist_passed'] && !(strstr(strtolower($reader), 'anonymous') && $_SERVER['PLANOWNER_INFO_ARRAY']['snitchlevel'] > 2)) {
            $valid = 1;
        }
        // if the plan is public or advertised, we're clear
        if (!plan_is_registered_only($planwriter) && !plan_is_private($planwriter)) {
            $valid = 1;
        }
        // if plan is private, only personally allowed users may read
        if (plan_is_private($planwriter) && user_is_authorized($planwriter, $reader)) {
            $valid = 1;
        }
    }
    // provides limited secret feeds for private plans. user must enable.
    if ($_SERVER['OUTPUT_MODE'] == "ATOM_PRIVATE") {
        $valid = 1;
    }
    // if the writer isn't local, we let the other end handle privacy
    if (!file_exists("{$_SERVER['PWUSERS_DIR']}/{$planwriter}")) {
        $valid = TRUE;
    }
    return $valid;
}
Esempio n. 4
0
function plan_read_archives($planowner)
{
    if (!file_exists("{$_SERVER['PWUSERS_DIR']}/{$planowner}/plan/.arcprivate") || user_is_authorized($planowner, $_SERVER['USER'])) {
        if (plan_is_local($planowner) && plan_test_privacy($_SERVER['USER'], $planowner)) {
            if (plan_is_journaling($planowner)) {
                $m = array('', '', '', '', '', '', '', '', '', '', '', '');
                $m[date('n', time() - 24 * 3600 * 10)] = 'SELECTED';
                $d = date('j', time() - 24 * 3600 * 10);
                $y = date('Y', time() - 24 * 3600 * 10);
                $content = "\n\t\t<div align='center'>\n\t\t\t<form action='{$_SERVER['WEB_ROOT']}/scripts/form_shim.php' method='post'>\n\t\t\t\tview\n\t\t\t\t<input type='text' name='threshhold' value='10' size='5'/>\n\t\t\t\t<select name='units'>\n\t\t\t\t\t<option value='w'>weeks</option>\n\t\t\t\t\t<option value='d' SELECTED>days</option>\n\t\t\t\t\t<option value='h'>hours</option>\n\t\t\t\t\t<option value='m'>minutes</option>\n\t\t\t\t</select>\n\t\t\t\t<input type='hidden' value='{$planowner}' name='username'/>\n\t\t\t\tof {$planowner}'s archives\n\t\t\t\t<select name='reverse'>\n\t\t\t\t\t<option value=''>newest first</option>\n\t\t\t\t\t<option value='r' SELECTED>oldest first</option>\n\t\t\t\t</select><br />\n\t\t\t\tstarting\n\t\t\t\t<select name='startmonth'>\n\t\t\t\t\t<option value='1' {$m['1']}>January</option>\n\t\t\t\t\t<option value='2' {$m['2']}>February</option>\n\t\t\t\t\t<option value='3' {$m['3']}>March</option>\n\t\t\t\t\t<option value='4' {$m['4']}>April</option>\n\t\t\t\t\t<option value='5' {$m['5']}>May</option>\n\t\t\t\t\t<option value='6' {$m['6']}>June</option>\n\t\t\t\t\t<option value='7' {$m['7']}>July</option>\n\t\t\t\t\t<option value='8' {$m['8']}>August</option>\n\t\t\t\t\t<option value='9' {$m['9']}>September</option>\n\t\t\t\t\t<option value='10' {$m['10']}>October</option>\n\t\t\t\t\t<option value='11' {$m['11']}>November</option>\n\t\t\t\t\t<option value='12' {$m['12']}>December</option>\n\t\t\t\t</select>\n\t\t\t\t<input type='text' name='startdom' value='{$d}' size='5'/>\n\t\t\t\t<input type='text' name='startyear' value='{$y}' size='5'/>\n\t\t\t\t<select name='starttime'>\n";
                for ($i = 0; $i < 24; $i++) {
                    $hour = $i % 12;
                    if ($hour == 0) {
                        $hour = 12;
                    }
                    $pm = floor($i / 12);
                    if ($pm) {
                        $pm = 'pm';
                    } else {
                        $pm = 'am';
                    }
                    $content .= "\n\t\t\t\t\t\t<option value='{$i}'>{$hour} {$pm}</option>\n";
                }
                if (strstr($_SERVER['USER'], '@')) {
                    $authid = base64_encode("{$_SERVER['USER']}" . time());
                    file_put_contents("{$_SERVER['FILE_ROOT']}/temp/{$authid}.calauth", $planowner);
                }
                $content .= "\n\t\t\t\t</select>\n\t\t\t\t<input type='submit' value='go'/>\n\t\t\t\t</form>\n\n\t\t\t\t<b>search</b>: <form action='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/scripts/form_shim.php'><input type='text' name='keyword' value=''/><input type='hidden' name='writer' value='{$planowner}'/><input type='submit' name='submit' value='search'/><input type='hidden' name='action' value='archive_search'/></form>\n\n\t\t\t\t<object id='archives_calendar' align='bottom' standby='waiting for cal' data='http://planwatch.org/cal/{$planowner}/" . date("Y-m-01") . "/" . date("Y-m-t") . "' type='text/html' />\n\t\t\t\t</div>\n";
            } else {
                $content = "<b>Pick an archived plan to view or check several and click 'view checked':</b>\n\n\t\t\t\t<b>search</b>: <form action='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/scripts/form_shim.php'><input type='text' name='keyword' value=''/><input type='hidden' name='writer' value='{$planowner}'/><input type='submit' name='submit' value='search'/><input type='hidden' name='action' value='archive_search'/></form>\n\t\t\t\t<object id='archives_calendar' align='bottom' standby='waiting for cal' data='/cal/{$planowner}/" . date("Y-m-01") . "/" . date("Y-m-t") . "' type='text/html'></object>\n\n\t\t\t\t<form action='{$_SERVER['WEB_ROOT']}/scripts/form_shim.php' method='post'>\n\t\t\t\t<input type='hidden' name='username' value='{$planowner}'/>\n\t\t\t\t<input type='submit' value='view checked'/>\n\t\t\t\t<ul>";
                exec("ls {$_SERVER['PWUSERS_DIR']}/{$planowner}/plan/plan.*", $planlist);
                $planlist = array_reverse($planlist);
                foreach ($planlist as $i => $planentry) {
                    $pesize = filesize($planentry);
                    if (!$oldpesize) {
                        $oldpesize = 1.0E-5;
                    }
                    if ($pesize - $oldpesize > 100 || $pesize / $oldpesize >= 1.25 || $pesize / $oldpesize <= 0.75) {
                        $content .= "<br />\n";
                    }
                    $content .= "<br />";
                    $planentry = basename($planentry);
                    $planentry = str_replace('txt', '', $planentry);
                    $planentry = str_replace('plan', '', $planentry);
                    $planentry = str_replace('gz', '', $planentry);
                    $planentry = str_replace('.', '', $planentry);
                    $planentrydate = date('F jS Y, h:ia', $planentry);
                    $content .= "<li><input type='checkbox' name='archivelist[]' value='{$planentry}'/><a href='{$_SERVER['WEB_ROOT']}/read/{$planowner}/.{$planentry}'>{$planentrydate}</a>\n";
                    $content .= "<font size=-1>(" . files_format_size($pesize) . ")</font>\n";
                    if ($planowner == $_SERVER['USER']) {
                        $content .= " &nbsp;&nbsp;<a href='{$_SERVER['WEB_ROOT']}/deleteentry/.{$planentry}'>delete</a>\n";
                    }
                    $oldpesize = $pesize;
                }
                $content .= "</ul><input type='submit' value='view checked'/></form>";
            }
        } elseif (!plan_is_local($planowner)) {
            redirect($_SERVER['PLANOWNER_INFO_ARRAY']['archiveurl']);
            exit;
        } else {
            $content = "you are not allowed to view {$planowner}'s archives.";
        }
    } else {
        $content = "{$planowner}'s archives are private, and you do not have sufficient permission to view them.";
    }
    return $content;
}