Esempio n. 1
0
function output_build_reader_toolbar_mobile($content)
{
    if ($_SERVER['URL_ARRAY'][3] == 'bio') {
        $is_bio = TRUE;
    } elseif ($_SERVER['URL_ARRAY'][1] == 'send') {
        $is_send = TRUE;
    } elseif (in_array('archives', $_SERVER['URL_ARRAY'])) {
        $is_archives = TRUE;
    } else {
        $is_plan = TRUE;
    }
    $planwatchlist = file_get_contents("{$_SERVER['USER_ROOT']}/watchedlist.txt");
    if ($is_send) {
        $_SERVER['PLANOWNER'] = $_SERVER['URL_ARRAY'][2];
        plan_get_owner_info($_SERVER['PLANOWNER']);
    }
    if (user_is_valid($_SERVER['USERINFO_ARRAY']['username'], $_SERVER['USERINFO_ARRAY']['userpass']) && $_SERVER['PLANOWNER'] && !strstr($content, '<h1>Plan Read Failed</h1>')) {
        profile('reader_toolbar', 'begin');
        if ($is_plan || $is_bio || $is_archives || $is_send && $_SERVER['URL_ARRAY'][2]) {
            // bio
            if ((file_exists("{$_SERVER['PWUSERS_DIR']}/{$_SERVER['PLANOWNER']}/bio.txt") || (strpos($_SERVER['PLANOWNER_REAL_LOCATION'], 'diaryland') || strpos($_SERVER['PLANOWNER_REAL_LOCATION'], 'livejournal'))) && !$is_bio) {
                $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/read/{$_SERVER['PLANOWNER_REAL_LOCATION']}/bio'>bio</a>";
            }
            // send
            if ((strpos($_SERVER['PLANOWNER_REAL_LOCATION'], 'planworld.net') || strpos($_SERVER['PLANOWNER_REAL_LOCATION'], 'amherst.edu') || plan_is_local($_SERVER['PLANOWNER'])) && $_SERVER['PLANOWNER'] != $_SERVER['USER'] && !$is_send) {
                $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>";
                    }
                    $lastsend = "({$lastsend})";
                }
                $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/send/{$_SERVER['PLANOWNER_REAL_LOCATION']}/'>send</a>";
            }
            // planread
            if ($is_send || $is_bio) {
                $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/read/{$_SERVER['PLANOWNER_REAL_LOCATION']}/'>plan</a>";
            }
            // archives
            if (plan_has_archives($_SERVER['PLANOWNER_REAL_LOCATION'])) {
                if (!$is_archives) {
                    $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/read/{$_SERVER['PLANOWNER']}/archives' >archives</a>";
                } else {
                    $readertoolbar[] = "<a href='{$_SERVER['WEB_ROOT']}/read/{$_SERVER['PLANOWNER']}' >plan</a>";
                }
            }
            // If the reader isn't watching the writer, offer the option
            if (!stristr($planwatchlist, $_SERVER['PLANOWNER']) && $is_plan) {
                $readertoolbar[] = "<span id='watch_link'><a 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>";
            }
            // 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'], '://')) {
                // 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 href='{$_SERVER['WEB_ROOT']}/masq/on/{$_SERVER['PLANOWNER']}'>masq</a>";
                }
                if ($is_plan) {
                    $readertoolbar[] = "<a href='/lists/unread/{$_SERVER['PLANOWNER']}'>unread</a>";
                }
                if ($is_send) {
                    $readertoolbar[] = "<a href='/send/{$_SERVER['PLANOWNER']}/unread'>unread</a>";
                }
            }
            // make the links into a string for output.
            $readertoolbar = "<li class='toolbutton'>" . implode("</li><li class='toolbutton'>", $readertoolbar) . "</li>\n";
            $readertoolbar = str_replace("<li class='toolbutton'></li>", "", $readertoolbar);
            if (($lasttime = plan_get_last_update($_SERVER['PLANOWNER'])) && $is_plan) {
                $readertoolbar = "<li class='plan_data_block'>Last Update: " . formattime($lasttime) . "</li>" . $readertoolbar;
            }
            if ($lastlogin = plan_get_last_login($_SERVER['PLANOWNER'])) {
                if ($lastlogin > 1) {
                    $readertoolbar = "<li class='plan_data_block' id='lastaction'>Last Action: " . formattime($lastlogin) . "</li>" . $readertoolbar;
                }
            }
        }
        profile('reader_toolbar', 'end');
    }
    return $readertoolbar;
}
function plan_get_last_login($planowner)
{
    $planowner_pl = $_SERVER['PLAN_LOCATION_ARRAY'][$planowner];
    if (!$planowner_pl && !$_SERVER['PLAN_LOCATION_FAILED_ARRAY'][$planowner]) {
        $planowner = plan_get_real_location($planowner);
    } else {
        $planowner = $planowner_pl;
    }
    if (plan_is_local($planowner)) {
        $lastlogin = user_get_last_action($planowner);
    } else {
        list($user, $node) = explode('@', $planowner);
        if (!$node) {
            $node = 'planwatch.org';
        }
        $_SERVER['STOPWATCH']["lastlogin.rpc_begin"] = array_sum(explode(' ', microtime()));
        $f = new xmlrpcmsg('planworld.user.getLastLogin');
        $f->addParam(new xmlrpcval("{$user}", "string"));
        $nodeinfo = planworld_node_getinfo($node);
        $c = new xmlrpc_client($nodeinfo['directory'], $nodeinfo['server'], $nodeinfo['port']);
        $c->setDebug(0);
        //if (user_is_administrator()) $c->setDebug(1);
        $r = $c->send($f);
        if (!$r) {
            $lastlogin = "******";
        } elseif (!$r->faultCode()) {
            $lastlogin = xmlrpc_decode($r->value());
        }
        $_SERVER['STOPWATCH']["lastlogin.rpc_end"] = array_sum(explode(' ', microtime()));
    }
    return $lastlogin;
}
Esempio n. 3
0
function snoop_add($addlist, $remote = 0)
{
    //	if(IS_JOSH) { echo "<hr>"; print_r($addlist); echo "<hr>"; }
    if ($remote == FALSE) {
        $snoop_setter = $_SERVER['USER'];
    } else {
        $snoop_setter = $remote;
    }
    if (is_string($addlist)) {
        $addlist = array($addlist);
    }
    if (!$addlist) {
        $addlist = array();
    }
    foreach ($addlist as $i => $newsnoop) {
        $newsnoop = plan_get_real_location($newsnoop);
        if (!strstr($newsnoop, 'ttp:') && ($newsnoop = trim($newsnoop))) {
            //		    if(IS_JOSH) { echo "$newsnoop<br>"; }
            if (plan_is_local($newsnoop)) {
                $success = snoop_add_xmlrpc($newsnoop, "@planwatch.org", $snoop_setter);
                if (!$success) {
                    $_SERVER['ERRORS'] .= "{$newsnoop} snoop failed<br />\n";
                }
            } else {
                list($snoop_target, $node) = explode("@", $newsnoop);
                $success = snoop_add_xmlrpc($snoop_target, '@' . $node, $snoop_setter);
                if (!$success) {
                    $_SERVER['ERRORS'] .= "{$newsnoop} snoop failed<br />\n";
                }
            }
            $success_list[$snoop_target] = $success;
        }
    }
    return $success_list;
}
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;
}