示例#1
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;
}
function user_list_aliases($planowner)
{
    profile('alias_list_pre');
    if (file_exists("{$_SERVER['PWUSERS_DIR']}/{$planowner}/watchedlist.txt")) {
        $watchedlist = @file("{$_SERVER['PWUSERS_DIR']}/{$planowner}/watchedlist.txt");
        if (!$watchedlist) {
            $watchedlist = array();
        }
        // don't bother if there aren't aliases to link
        $watchstring = implode(' ', $watchedlist);
        profile('alias_list_pre');
        if (strpos($watchstring, '!') && strpos($watchstring, ':')) {
            unset($watchstring);
            profile('alias_list_loop');
            foreach ($watchedlist as $i => $item) {
                $item = trim($item);
                if (strpos($item, '!') !== FALSE && strpos($item, ':') !== FALSE) {
                    $item = str_replace('://', '//', $item);
                    list($item, $alias) = explode(':', str_replace('!', '', $item), 2);
                    $item = str_replace('//', '://', $item);
                    $item = plan_get_real_location($item);
                    $alias_list[$alias] = $item;
                    //	            if ($_SERVER['USER']=='jwdavidson') echo "ULA $alias: $item<br/>\n";
                }
            }
            profile('alias_list_loop');
        }
    }
    return $alias_list;
}
示例#3
0
function plan_read_simplepie_single($url, $id)
{
    $url = str_replace("feed://", "http://", $url);
    if (!strstr($url, '://')) {
        $url = plan_get_real_location($url);
    }
    $feed = new SimplePie();
    $feed->set_feed_url($url);
    $feed->set_output_encoding('utf-8');
    $feed->init();
    $feed->handle_content_type();
    $these_items = $feed->get_items();
    $items = array_merge($items, $these_items);
    foreach ($items as $item) {
        if (md5($item->get_id()) == $id) {
            $item_data = $item->get_content();
            //$entry_text=removeEvilTags($item_data);
            $entry_text = $item_data;
            $content .= "{$entry_text}";
        }
    }
    return $content;
}
function plan_get_last_update($list)
{
    profile("plan_get_last_update_{$list['0']}", 'begin');
    if (is_string($list)) {
        //		$_SERVER['DEBUG_INFO'].="solo timing: $list<br/>\n ";
        $list = array($list);
        $isstring = 1;
    }
    if (!isset($_SERVER['PLAN_TIMES_ARRAY'])) {
        $_SERVER['PLAN_TIMES_ARRAY'] = unserialize(file_get_contents("{$_SERVER['FILE_ROOT']}/stats/allplantimes.dat"));
    }
    if (is_array($list)) {
        foreach ($list as $i => $plan) {
            $rand = rand();
            $plan = trim($plan);
            //		$_SERVER['DEBUG_INFO'].="trimmed: $plan<br/>\n ";
            profile("pglu_loop_{$rand}{$plan}", 'begin');
            //alias handling
            if ($plan[0] == '!') {
                if (strpos($plan, '!') !== false && strpos($plan, ':') !== false) {
                    $plan = str_replace("!", '', $plan);
                    $finalpos = strrpos($plan, ':');
                    $url = trim(substr($plan, 0, $finalpos));
                    $displayname = trim(substr($plan, $finalpos + 1, strlen($plan) - $finalpos - 1));
                    $plan = $url;
                }
                if (strstr($plan, 'diaryland')) {
                    $plan = str_replace(array('http://', '.diaryland.com/'), '', $plan) . "@DL";
                }
            }
            // if we know the real location, get it now
            if (array_key_exists($plan, $_SERVER['PLAN_LOCATION_ARRAY'])) {
                if (trim($_SERVER['PLAN_LOCATION_ARRAY'][$plan])) {
                    $plan = $_SERVER['PLAN_LOCATION_ARRAY'][$plan];
                }
                //			$_SERVER['DEBUG_INFO'].="found: $plan<br/>\n ";
            } else {
                // if we know there isn't a real location, give up
                if (isset($_SERVER['PLAN_LOCATION_FAILED_ARRAY'][$plan]) || $plan[0] == '#' || strstr($plan, '/') || !$plan || $plan == 'onlynew' || $plan == 'alwaysnew') {
                    $plan = FALSE;
                    $pt[$i] = -1;
                } else {
                    $plan = plan_get_real_location($plan, $_SERVER['USER'] == 'jwdavidson');
                }
            }
            if ($_SERVER['PLAN_TIMES_ARRAY'][$plan]) {
                $pt[$i] = $_SERVER['PLAN_TIMES_ARRAY'][$plan];
            } elseif (!isset($pt[$i])) {
                //			$pt[$i]=-1;
                /*
                			if($_SERVER['USER']=='jwdavidson')
                			{
                				if(strstr($plan,'diaryland') || strstr($plan,'ttp:')) $pt[$i]=plan_find_time($plan);
                				if(strstr($plan,'@amherst')) $amfindlist[$i]=$plan;
                				if(strstr($plan,'@planworld.net')) $pwnfindlist[$i]=$plan;
                			}
                			else
                */
                $pt[$i] = plan_find_time($plan);
            }
            profile("pglu_loop_{$plan}", 'end');
        }
    }
    profile("plan_get_last_update_{$list['0']}", 'end');
    if ($_SERVER['USER'] == 'jwdavidson') {
        if ($amfindlist) {
            $amtimes = plan_find_xn_times($amfindlist);
        }
        if ($pwnfindlist) {
            $pwntimes = plan_find_xn_times($pwnfindlist);
        }
        if ($amtimes || $pwntimes) {
            $pt = array_merge($pt, $amtimes, $pwntimes);
        }
    }
    if ($isstring) {
        return $pt[0];
    } else {
        return $pt;
    }
}
function form_process_with_struct()
{
    include_once 'snoop.php';
    include_once 'plan_read.php';
    extract($_POST);
    unlink("{$_SERVER['FILE_ROOT']}/stats/planlocations.dat");
    unlink("{$_SERVER['FILE_ROOT']}/stats/plan_locations.dat");
    unlink("{$_SERVER['FILE_ROOT']}/stats/plan_failures.dat");
    foreach ($_FILES as $i => $file) {
        if ($file['size'] > 0) {
            move_uploaded_file($file['tmp_name'], "{$_SERVER['FILE_ROOT']}/resources/" . $file['name']);
        }
    }
    $olduserinfo = $_SERVER['USERINFO_ARRAY'];
    $form_definitions = unserialize(base64_decode($form_definitions));
    extract($form_definitions['form_disposition']);
    unset($form_definitions['form_disposition']);
    if ($storage_format == 'file') {
        $keys = array_keys($form_definitions);
        foreach ($keys as $key) {
            $output_array[$key] = $_POST[$key];
        }
        file_put_contents("{$storage_directory}/{$storage_filename}", serialize($output_array));
        // CHANGING PLAN TYPE
        if ($olduserinfo['journaling'] != $output_array['journaling'] && isset($output_array['journaling'])) {
            if ($olduserinfo['journaling']) {
                $plan_fn = "{$_SERVER['PWUSERS_DIR']}/{$olduserinfo['username']}/plan/plan.txt";
                @rename($plan_fn, $plan_fn . time());
                file_put_contents($plan_fn, $oldplan);
            }
            if ($output_array['journaling']) {
                $plan_fn = "{$_SERVER['PWUSERS_DIR']}/{$olduserinfo['username']}/plan/plan." . time() . ".txt";
                file_put_contents($plan_fn, $oldplan);
            }
        }
        // ADVERTISED LIST HANDLING
        $advlist = @file_get_contents("{$_SERVER['FILE_ROOT']}/stats/advertised.txt");
        if ($output_array['privacy'] == 1 && strpos($advlist, $output_array['username']) === FALSE) {
            file_put_contents("{$_SERVER['FILE_ROOT']}/stats/advertised.txt", "\n" . $output_array['username'], FILE_APPEND);
        }
        if ($output_array['privacy'] != 1 && strpos($advlist, $output_array['username']) !== FALSE) {
            file_put_contents("{$_SERVER['FILE_ROOT']}/stats/advertised.txt", str_replace("\n{$output_array['username']}", '', $advlist));
        }
        // private feed
        unlink("{$_SERVER['FILE_ROOT']}/resources/privatefeeds/{$olduserinfo['secretword']}.owner");
        file_put_contents("{$_SERVER['FILE_ROOT']}/resources/privatefeeds/{$output_array['secretfeedword']}.owner", "{$output_array['planusername']}");
        $oa_un = $output_array['username'];
        exec("rm -f {$_SERVER['FILE_ROOT']}/temp/*{$oa_un}*.cache");
        $_SERVER['PLAN_LOCATION_ARRAY'] = unserialize(file_get_contents("{$_SERVER['FILE_ROOT']}/stats/plan_locations.dat"));
        $_SERVER['PLAN_LOCATION_ARRAY'][$oa_un] = plan_get_real_location($output_array['planusername'] . str_replace(array('RSS', '@local'), '', $output_array['plantype']));
        file_put_contents("{$_SERVER['FILE_ROOT']}/stats/plan_locations.dat", serialize($_SERVER['PLAN_LOCATION_ARRAY']));
        // RENAMED USER HANDLING
        if ($output_array['username'] && $output_array['username'] != $_SERVER['USER']) {
            rename($storage_directory, str_replace($_SERVER['USER'], $output_array['username'], $storage_directory));
            // SNOOP STUFF
            if ($output_array['plantype'] == '@local') {
                if ($old_snoop_array != FALSE) {
                    $new_snoop_array = snoop_find(plan_read($output_array['username']));
                    snoop_clean(array_unique($old_snoop_array), $olduserinfo['username']);
                    snoop_add(array_unique($new_snoop_array), $output_array['username']);
                }
            }
            exec("ls {$_SERVER['PWUSERS_DIR']}/*/*list.txt", $list_list);
            foreach ($list_list as $list) {
                $list_data = file_get_contents($list);
                $list_data = str_replace($olduserinfo['username'], $output_array['username'], $list_data);
                file_put_contents($list, $list_data);
            }
            login($output_array['username'], $output_array['userpass']);
        } else {
            redirect('/');
        }
    }
}