function list_format_atom($list) { // get display names, prune headers // (the atom watched list is always sorted by time, and has no // sections or read plans listed) foreach ($list as $i => $plan) { unset($displayname); unset($url); $plan = str_replace('http://', 'http//', trim($plan)); list($url, $displayname) = explode(':', str_replace('!', '', $plan), 2); if (!$displayname) { $displayname = $url; } $displayname = htmlspecialchars($displayname); $plans_list[$i] = trim(str_replace('http//', 'http://', $url)); $plans_list_display[$i] = $displayname; } $ptime = plan_get_last_update($plans_list); $lastview = plan_get_last_view($plans_list); array_multisort($ptime, SORT_DESC, $plans_list, $lastview, $plans_list_display); foreach ($plans_list as $i => $plan) { if ($lastview[$i] < $ptime[$i]) { $plantime = gmdate('Y-m-d\\TH:i:s+00:00', $ptime[$i]); $humantime = str_replace(" ", ' ', formattime($ptime[$i])); $items .= "\n<rdf:li rdf:resource='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/read/{$plan}'/>"; $watchlist .= "\n\t\t\t\t\t<entry>\n\t\t\t\t\t\t<title type='html'>{$plans_list_display[$i]} updated {$humantime}</title>\n\t\t\t\t\t\t<summary> {$humantime}</summary>\n\t\t\t\t\t\t<link rel=\"alternate\" href=\"http://planwatch.org/read/{$plan}\" type=\"text/html\"/>\n\t\t\t\t\t\t<updated>{$plantime}</updated>\n\t\t\t\t\t\t<id>http://planwatch.org/read/{$plan}</id>\n\t\t\t\t\t\t<author>\n\t\t\t\t\t\t\t<name>{$plans_list_display[$i]}</name>\n\t\t\t\t\t\t</author>\n\t\t\t\t\t</entry>\n\t\t\t\t"; } } $watchlist = "{$watchlist}"; return $watchlist; }
function snoop_list($source = FALSE) { profile('snoop_list'); $snoop_filename = "{$_SERVER['USER_ROOT']}/stats/snoop.txt"; if ($source == 'planwatch' || $source == 'homesnoop') { $ignore = "ignore_ajax"; } else { $ignore = "ignore"; } if (file_exists($snoop_filename)) { $snoop_a = file($snoop_filename); foreach ($snoop_a as $i => $snoop) { $snoop = trim($snoop); list($snooper, $snooptime) = explode(':', $snoop); if ($snooper != $_SERVER['USER'] && trim($snooper)) { if ($snooptime > $snoop_times[$snooper]) { $snoop_times[$snooper] = $snooptime; } } } if (is_array($snoop_times)) { $snoopers_lastview = plan_get_last_view(array_keys($snoop_times)); arsort($snoop_times); // for very old snoops, we test them once a day to make sure they're // still valid // TODO:(v4.5) improve and re-enable the snoop test // if (filemtime("$_SERVER[USER_ROOT]/stats/snoop_lastcheck") < (time()-24*3600)) // { // $test_snoops=TRUE; // file_put_contents("$_SERVER[USER_ROOT]/stats/snoop_lastcheck",time()); // } foreach ($snoop_times as $snooper => $snooptime) { // the actual validity test gets called here // if (($snooptime < (time()-(72*3600))) && $test_snoops) // { // $valid_snoop=snoop_test($snoopers[$j]); // } // else $valid_snoop=TRUE; // if everything's OK, add it to the list if ($snooptime) { $snooptime_display = formattime($snooptime); if (strstr($snooper, '@')) { list($username, $host) = explode("@", $snooper); $displayname = "{$username} <span style='font-size: 60%;'>@{$host}</span>"; } else { $displayname = $snooper; } if ($snoopers_lastview[$snooper] < $snooptime) { $read_status = 'unread'; } else { $read_status = 'read'; } if ($ignore == "ignore") { $content .= "<li><a class='tool' target='_self' href='{$_SERVER['WEB_ROOT']}/snoop/{$ignore}/{$snooper}/{$source}'>☒</a>\n\t\t\t\t\t\t<a class='{$read_status}' href='{$_SERVER['WEB_ROOT']}/read/{$snooper}'>{$displayname}</a> <span style='font-size: 80%;'>{$snooptime_display}\n" . " </span>\n" . "</li>\n"; } else { $content .= "<li><a class='tool' target='_self' href='javascript:loadXMLDoc(\"{$_SERVER['WEB_ROOT']}/snoop/{$ignore}/{$snooper}/{$source}\",null,\"{$source}\");'>☒</a>\n\t\t\t\t\t\t\t<a class='{$read_status}' href='{$_SERVER['WEB_ROOT']}/read/{$snooper}'>{$displayname} <span class='updatetime'>{$snooptime_display}\n</span></a>\n" . "</li>\n"; } } } } else { $content .= "<li class='unread'>no snoops found</li>\n"; } } profile('snoop_list'); return $content; }
function list_format_rss($list, $sortby = 'time') { $sep = "\n"; $subkey = '#main'; foreach ($list as $z => $plan) { if ($th = strstr($plan, '!prune')) { $prune = TRUE; $threshhold = str_replace('!prune', '', $th); if (strstr($threshhold, 's')) { $threshhold = str_replace('s', '', $threshhold); } if (strstr($threshhold, 'm')) { $threshhold = str_replace('m', '', $threshhold) * 60; } if (strstr($threshhold, 'b')) { $threshhold = str_replace('b', '', $threshhold) * 86.40000000000001; } if (strstr($threshhold, 'h')) { $threshhold = str_replace('h', '', $threshhold) * 3600; } if (strstr($threshhold, 'd')) { $threshhold = str_replace('d', '', $threshhold) * 3600 * 24; } if (strstr($threshhold, 'w')) { $threshhold = str_replace('w', '', $threshhold) * 3600 * 24 * 7; } if (strstr($threshhold, 'n')) { $threshhold = str_replace('n', '', $threshhold) * 3600 * 24 * 30; } if (strstr($threshhold, 'y')) { $threshhold = str_replace('y', '', $threshhold) * 3600 * 24 * 365; } if (strstr($threshhold, 'k')) { $threshhold = str_replace('k', '', $threshhold) * 3600 * 24 * 365 * 10; } $threshhold = time() - $threshhold; } if ($plan == '!onlynew') { $onlynew = TRUE; } unset($displayname); unset($url); $plan = str_replace('http://', 'http//', trim($plan)); list($url, $displayname) = explode(':', str_replace('!', '', $plan), 2); if (!$displayname) { $displayname = $url; } $displayname = htmlspecialchars($displayname); if ($plan[0] == '#') { $subkey = $displayname; } if (trim($plan)) { $sublist[$subkey][] = str_replace('http//', 'http://', $url); $sublist_display[$subkey][] = $displayname; } } $items .= "\n<rdf:li rdf:resource='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/home'/>"; $watchlist .= "\n\t\t<item rdf:about='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/home'>\n\t\t\t<title>>> Planwatch Home</title>\n\t\t\t<link>http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/home</link>\n\t\t\t<description>Planwatch Home</description>\n\t\t</item>\n"; foreach ($sublist as $key => $list) { if (count($list) > 1) { $ptime = plan_get_last_update($list); $lastview = plan_get_last_view($list); $list_display = $sublist_display[$key]; if ($sortby == 'name') { array_multisort($list, SORT_ASC, $ptime, $lastview, $list_display); } if ($sortby == 'time') { array_multisort($ptime, SORT_DESC, $list, $lastview, $list_display); } if ($key != '#main') { $items .= "\n<rdf:li rdf:resource='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/{$key}'/>"; $watchlist .= "\n\t\t\t\t\t<item rdf:about='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/{$key}'>\n\t\t\t\t\t\t<title>__ " . str_replace('#', '', $key) . " __</title>\n\t\t\t\t\t\t<link>http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/</link>\n\t\t\t\t\t\t<description>category: " . str_replace('#', '', $key) . "</description>\n\t\t\t\t\t</item>\n"; } foreach ($list as $i => $plan) { $plantime = str_replace(' ', ' ', formattime($ptime[$i])); if ($plan[0] != '#' && $plan && ($ptime[$i] > $threshhold || !$threshhold)) { if ($lastview[$i] < $ptime[$i]) { $items .= "\n<rdf:li rdf:resource='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/read/{$plan}'/>"; $watchlist .= "\n\t\t\t\t\t<item rdf:about='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/read/{$plan}'>\n\t\t\t\t\t\t<link>http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/read/{$plan}</link>\n\t\t\t\t\t\t<title>*** {$list_display[$i]} {$plantime}</title>\n\t\t\t\t\t\t<description>read {$list_display[$i]}'s plan</description>\n\t\t\t\t\t</item>\n"; } elseif (!$onlynew) { $items .= "\n<rdf:li rdf:resource='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/read/{$plan}'/>"; $watchlist .= "\n\t\t\t\t\t<item rdf:about='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/read/{$plan}'>\n\t\t\t\t\t\t<title>{$list_display[$i]} {$plantime}</title>\n\t\t\t\t\t\t<link>http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/read/{$plan}</link>\n\t\t\t\t\t\t<description>read {$list_display[$i]}'s plan</description>\n\t\t\t\t\t</item>\n"; } } } } } $items .= "\n<rdf:li rdf:resource='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/look/{$_SERVER['FINGERPRINT']}'/>"; $watchlist .= "\n\t\t<item rdf:about='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/look/{$_SERVER['FINGERPRINT']}'/>\n\t\t\t<title>>> Planwatch Look</title>\n\t\t\t<link>http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/look/{$_SERVER['FINGERPRINT']}</link>\n\t\t\t<description>Planwatch Look</description>\n\t\t</item>\n"; $watchlist = "{$items}\n<!-- FEED_DIVIDER -->\n{$watchlist}"; return $watchlist; }
function list_format_iphone($list = FALSE, $sortby = FALSE) { profile('list_format_html', 'begin'); profile("prelist"); if ($_SERVER['USER_ROOT'] && is_dir("{$_SERVER['USER_ROOT']}/sends/")) { // echo $_SERVER['USER_ROOT']; $new_sends = files_list("{$_SERVER['USER_ROOT']}/sends/", "*..new"); } if ($new_sends) { $watchlist .= "<option value='/send'>sends</option>"; foreach ($new_sends as $new_send) { $sender = files_decode_safe_name(str_replace("..new", '', $new_send)); $watchlist .= "<option value='/send/{$sender}'>{$sender}</option>\n"; } } if (!$list) { $list_fn = "{$_SERVER['USER_ROOT']}/watchedlist.txt"; // reads in the user's watched list if (file_exists($list_fn)) { $list = file($list_fn); if ($list[0] == "sort by time\n") { $sortby = 'time'; } elseif ($list[0] == "sort by name\n") { $sortby = 'name'; } elseif ($list[0] == "sort by none\n") { $sortby = 'inorder'; } else { $sortby = 'inorder'; } if (strpos($list[0], 'sort by ') !== FALSE) { unset($list[0]); } } else { $list = array(); } $list = array_merge(array("#Watched Plans"), $list); } profile("prelist"); profile('list_format_html_prep', 'begin'); $ptime = plan_get_last_update($list); $lastview = plan_get_last_view($list); $ordinal = 0; foreach ($list as $z => $plan) { $plan = urldecode($plan); if (strstr($plan, '!!!')) { $prune = TRUE; $plan = ''; } if (strstr($plan, '!prune')) { // $prune=TRUE; $threshhold = str_replace('!prune', '', $plan); $threshhold = time_calculate_threshhold($threshhold); $threshhold = time() - $threshhold; $plan = ''; } if (trim($plan) == '!onlynew') { $onlynew = TRUE; } if (trim($plan) == '!alwaysnew') { $alwaysnew = TRUE; } $plan = str_replace(array('!alwaysnew', '!onlynew'), '', $plan); $alias_array = explode(':', str_replace('!', '', $plan)); $displayname = end($alias_array); $url = $alias_array[0]; if ($alias_array[1][0] == '/') { $url .= ":{$alias_array['1']}"; } if (!is_string($displayname) || $displayname == $url) { if (strstr($url, '@')) { list($username, $host) = explode("@", $url); $displayname = "{$username} <span style='font-size: smaller;'>@{$host}</span>"; } else { $displayname = $url; } } // else echo $displayname; if ($displayname[0] == '#') { $groupname = htmlentities(str_replace('#', '', $displayname)); $grouplist[] = $groupname; } if (trim($plan)) { if ($plan[0] != '#') { if (file_exists("{$_SERVER['USER_ROOT']}/send/" . files_encode_safe_name($url) . "..new")) { $send = "<a href='/send/{$url}'>SEND</a>"; } else { $send = ''; } $biglist[$ordinal] = array("group" => $groupname, "url" => trim($url), "name" => $displayname, "updated" => $ptime[$z], "viewed" => $lastview[$z], "send" => $send); $timelist[$ordinal] = $ptime[$z]; $namelist[$ordinal] = $displayname; $ordinal++; } } if (!is_array($grouplist)) { $grouplist = array(''); } } profile('list_format_html_prep', 'end'); if (!$prune) { $onlynew = FALSE; $alwaysnew = FALSE; $threshhold = 0; } profile("buildlist"); if ($sortby == 'inorder') { foreach ($biglist as $i => $plan_details) { $plan_details = $biglist[$i]; if ($plan_details['updated'] > $plan_details['viewed']) { $class = '* '; } else { $class = ''; } if ($plan_details['updated'] > $threshhold || !$prune || $alwaysnew && $class == 'unread') { $plan_details['updated'] = formattime($plan_details['updated']); $outputlist[$plan_details['group']] .= "<option value='/read/{$plan_details['url']}'>{$class}{$plan_details['name']}: {$plan_details['updated']}</option>\n"; } } } if ($sortby == 'name') { asort($namelist); foreach ($namelist as $i => $name) { $plan_details = $biglist[$i]; if ($plan_details['updated'] > $plan_details['viewed']) { $class = '* '; } else { $class = ''; } if ($plan_details['updated'] > $threshhold || !$prune || $alwaysnew && $class == 'unread') { $plan_details['updated'] = formattime($plan_details['updated']); $outputlist[$plan_details['group']] .= "<option value='/read/{$plan_details['url']}'>{$class}{$plan_details['name']}: {$plan_details['updated']}</option>\n"; } } } if ($sortby == 'time') { arsort($timelist); foreach ($timelist as $i => $time) { $plan_details = $biglist[$i]; if ($plan_details['updated'] > $plan_details['viewed']) { $class = '* '; } else { $class = ''; } if ($plan_details['updated'] > $threshhold || !$prune || $alwaysnew && $class == 'unread') { $plan_details['updated'] = formattime($plan_details['updated']); $outputlist[$plan_details['group']] .= "<option value='/read/{$plan_details['url']}'>{$class}{$plan_details['name']}: {$plan_details['updated']}</option>\n"; } } } foreach ($grouplist as $groupname) { $jsgroupname = trim(str_replace(" ", "_", $groupname)); if ($outputlist[$groupname] || strtolower($groupname) == 'watched plans') { $watchlist .= "\n\t\t<option value=''>---</option><option value='/look/group/" . urlencode(trim($groupname)) . "'>[{$groupname}]</option>\n{$outputlist[$groupname]}"; } } profile("buildlist"); profile('list_format_html', 'end'); return $watchlist; }
<?php $_SERVER['AUTH_COOKIE'] = 'fingerprint_v4'; $_SERVER['FILE_ROOT'] = '/home/planwatc/public_html'; include_once '/home/planwatc/public_html/scripts/siteconfig.php'; include_once '/home/planwatc/public_html/scripts/plan_read.php'; include_once '/home/planwatc/public_html/backend/xmlrpc.inc'; include_once '/home/planwatc/public_html/scripts/standard_library/user_info_functions.php'; include_once '/home/planwatc/public_html/scripts/standard_library/plan_info_functions.php'; include_once '/home/planwatc/public_html/scripts/standard_library/file_functions.php'; /* BACKUP */ $_COOKIE[$_SERVER['AUTH_COOKIE']] = "YmFja3Vw:::d53db979c480aa3ce0d9aaba69495fc8"; user_verify_fingerprint("YmFja3Vw:::d53db979c480aa3ce0d9aaba69495fc8"); $time = time(); $backup_permissions_dir = "{$_SERVER['FILE_ROOT']}/stats/backup_permissions"; $backup_users_list = files_list($backup_permissions_dir, "*.permission"); foreach ($backup_users_list as $userfile) { $username = trim(str_replace(".permission", "", basename($userfile))); $sptime = plan_get_last_update($username); $slastview = plan_get_last_view($username); if ($sptime > $slastview || !$sptime && filemtime("{$_SERVER['USER_ROOT']}/files/{$username}.latest.backup") < $time - 3600 * 6) { $plan = plan_read($username, FALSE, FALSE, FALSE, TRUE); $file = fopen("{$_SERVER['USER_ROOT']}/files/{$username}.{$time}.backup", 'w'); fwrite($file, $plan); fclose($file); $file = fopen("{$_SERVER['USER_ROOT']}/files/{$username}.latest.backup", 'w'); fwrite($file, $plan); fclose($file); } }
function snitch_read($owner, $threshhold) { if (!$threshhold) { $threshhold = '2dr'; } $writer = $_SERVER['USER']; if ($_SERVER['USER'] == $owner) { if ($threshhold == 'r' . $_SERVER['USERINFO_ARRAY']['snitch_default_days'] . 'd') { $mode = 'NORMAL'; } if ($threshhold == 'r2h') { $mode = 'BRIEF'; } $last_plan_update = plan_get_last_update($_SERVER['USER']); if (strpos($threshhold, 'r') !== FALSE) { $newest_first = 'SELECTED'; } else { $oldest_first = 'SELECTED'; } if (strpos($threshhold, 'w') !== FALSE) { $weeks_selected = 'SELECTED'; } elseif (strpos($threshhold, 'h') !== FALSE) { $hours_selected = 'SELECTED'; } elseif (strpos($threshhold, 'm') !== FALSE) { $minutes_selected = 'SELECTED'; } else { $days_selected = 'SELECTED'; } $threshvalue = str_replace(array('d', 'r', 'w', 'd', 'h', 'm'), '', $threshhold); if ($threshhold == 'sidebar') { $threshhold = '1d'; $reverse = 'true'; $sidebar = 1; } if (strstr($threshhold, 'r')) { $reverse = 'true'; $threshhold = str_replace('r', '', $threshhold); } $threshhold = time_calculate_threshhold($threshhold); $threshhold = time() - $threshhold; profile('snitch_read'); $snitch_fn = "{$_SERVER['USER_ROOT']}/stats/planlog.txt"; if (file_exists($snitch_fn)) { if ($mode == 'NORMAL') { exec("tail -n 200 {$snitch_fn}", $snitch_array); } if ($mode == 'BRIEF') { exec("tail -n 30 {$snitch_fn}", $snitch_array); } else { $snitch_array = explode("\n", file_get_contents($snitch_fn)); } } else { $snitch_array = array(); } profile('snitch_read'); if ($reverse) { $snitch_array = array_reverse($snitch_array); } foreach ($snitch_array as $k => $snitch_entry) { list($blah, $snitch_user, $blah) = explode(',', $snitch_entry); $snitch_users[] = $snitch_user; } if (is_array($snitch_users)) { $snitch_users = array_unique($snitch_users); } else { $snitch_users = 'No snitch'; } if ($mode) { $lastview = plan_get_last_view($snitch_users); } if ($mode) { $lastupdate = plan_get_last_update($snitch_users); } profile('snitch_format_begin'); foreach ($snitch_array as $k => $snitch_entry) { unset($style); unset($class); $snitch_entry = explode(',', $snitch_entry); if ($snitch_entry[0] > $threshhold) { if ($snitch_entry[0] < $last_plan_update) { $content .= "<li style='margin: 15px;'>" . str_replace(' ', ' ', formattime($last_plan_update)) . " Last Plan Update</li>"; $last_plan_update = 0; } $su_key = array_search($snitch_entry[1], $snitch_users); $snitchday = date('d', $snitch_entry[0]); if ($last_snitchday && $snitchday != $last_snitchday) { $style = "margin-top: 15px;"; } $time_string = str_replace(' ', ' ', formattime($snitch_entry[0])); if (strlen(date('g', $snitch_entry[0])) == 1) { $time_string .= " "; } if ($lastupdate[$su_key] > 0 && $lastupdate[$su_key] > $lastview[$su_key]) { $class = "unread"; } else { $class = 'read'; } if (strpos($snitch_entry[1], 'Anon') !== FALSE) { $snitch_ip = str_replace("Anonymous Coward from ", '', $snitch_entry[1]); if ($snitch_ip == 'livejournal.com') { $snitch_entry[1] = "LiveJournal"; } elseif (strstr($snitch_ip, 'facebook.com')) { $snitch_entry[1] = "Facebook"; } else { if (strpos($_SERVER['REQUEST_URI'], '/snitch') === 0 && $_SERVER['OUTPUT_MODE'] != 'IPHONE') { $ac = "Anonymous Coward "; } else { $ac = "AC "; } $numerical_ip = gethostbyname($snitch_ip); $snitch_entry[1] = "{$ac} from {$snitch_ip}"; if ($ac != 'AC ') { $snitch_entry[1] .= " <a href='{$_SERVER['WEB_ROOT']}/trace/{$snitch_ip}'>trace</a> | <a href='{$_SERVER['WEB_ROOT']}/lists/add/blocked/{$numerical_ip}'>block</a>\n"; } } } if (strpos($snitch_entry[2], 'archives') !== FALSE) { preg_match("|archives \\( (r.*d) 3(.*) \\)|", $snitch_entry[2], $matches); $length = $matches[1]; $timecode = $matches[2]; $url = date("Y/m/d/h:i", $timecode); $snitch_entry[2] = str_replace($matches[0], "<a href='/read/{$_SERVER['USER']}/{$length}/{$url}'>archives ({$length} from " . date("F jS Y g:ia", $timecode) . ")</a>", $snitch_entry[2]); } if (strpos($snitch_entry[1], 'RSS') !== FALSE) { $snitch_ip = str_replace("RSS Reader from ", '', $snitch_entry[1]); if (strstr($_SERVER['REQUEST_URI'], 'snitch')) { $rr = "RSS Reader "; } else { $rr = "RSS "; } $snitch_entry[1] = "{$rr} <span class='edit_links'>from {$snitch_ip}"; if ($rr != 'RSS ') { $snitch_entry[1] .= "[ <a href='{$_SERVER['WEB_ROOT']}/trace/{$snitch_ip}'>trace</a> | <a href='{$_SERVER['WEB_ROOT']}/lists/add/blocked/{$ip}'>block</a> ]</span>\n"; } } if (!strstr($snitch_entry[1], 'AC ') && !strstr($snitch_entry[1], 'Anon') && !strstr($snitch_entry[1], 'RSS') && !strstr($snitch_entry[1], 'LiveJournal') && !strstr($snitch_entry[1], 'Facebook')) { $content .= "<li class='{$class}' style='{$style}'><a href='{$_SERVER['WEB_ROOT']}/read/{$snitch_entry['1']}'>{$time_string} {$snitch_entry['1']}</a> {$snitch_entry['2']}</li>"; } elseif ($sidebar != 1) { $content .= "<li class='{$class}' style='{$style}'>{$time_string} {$snitch_entry['1']} {$snitch_entry['2']}</li>\n"; } else { $content .= "<li class='{$class}' style='{$style}'>{$time_string} AC {$snitch_entry['2']}</li>\n"; } $last_snitchday = $snitchday; } else { $k += 10000; } } profile('snitch_format_end'); } else { $content = "<li class='alert'>you are not the owner of {$owner}'s plan. you are {$user}. please re-login if this is an error.</li>"; } return $content; }
function plan_read_simplepie_rss($urls, $offset = 0, $item_count = 30) { if (IS_JOSH) { include_once 'simplepie.1.2.inc'; } else { include_once 'simplepie.inc'; } profile('rss_read'); $lastview = plan_get_last_view($urls); $multifeed = TRUE; if (is_string($urls)) { if (substr_count($urls, ",http") > 0) { $urls = explode(",http", $urls); foreach ($urls as $i => $url) { if (!strstr($url, 'http')) { $urls[$i] = "http" . $url; } } } else { $urls = array($urls); $multifeed = FALSE; } } preg_match("|\\/\\/(.*)@|", $urls[0], $match); if ($match[1]) { $_SERVER['DIGEST_USERINFO'] = $match[1]; $_SERVER['DIGEST_AUTH'] = TRUE; } profile("load feeds"); $feed = new SimplePie($urls); profile("load feeds"); $items = $feed->get_items(); usort($items, "plan_multifeed_sort_items"); $items = array_slice($items, $offset, $item_count); if (!is_object($items[0])) { // if(IS_JOSH) print_r($items); // do stuff to fix the url and try again preg_match("|.*://([^/]+)/|", $urls[0], $base_url_array); $base_link = "<a href='{$base_url_array['0']}'>{$base_url_array['1']}</a>"; if ($offset != "RECURSION") { $content = plan_read_simplepie_rss($base_url_array[0], "RECURSION"); } if (!$content) { $title = "Failed to read feed {$urls['0']}"; $content = "<h1>Plan Read Failed</h1> We tried <tt>{$urls['0']}</tt> and did not get a valid feed.<br />\n\t\t\tYou may want to try the site directly: {$base_link}<br />\n\t\t\tIf the feed address is incorrect, you can <a href='/lists/edit/watched'>edit your watched list</a> to correct it.<br /><br />\n\t\t\tStill have questions? Ask for <a href='mailto:help@planwatch.org'>help</a>."; $alternate_links = array_unique(array_merge(plan_feed_search(str_replace("http://", "http://www.", $base_url_array[0])), plan_feed_search($base_url_array[0]), plan_feed_search($urls[0]))); if ($alternate_links) { $content .= "<hr /><h2>Alternate Links</h2>Here are some possible alternate feed links:<ul>"; foreach ($alternate_links as $link) { $content .= "<li><a href='http://planwatch.org/read/{$link}'>{$link}</a></li>\n"; } } } } else { foreach ($items as $item) { unset($item_categories); $item_authors_string = ''; $entry_header = ''; $item_title = $item->get_title(); $item_link = $item->get_permalink(); $item_date = formattime($item->get_date('U')); $item_data = $item->get_content(); if ($item_category_list = $item->get_categories()) { foreach ($item_category_list as $category) { $item_categories .= " " . $category->get_label(); } } $item_authors = $item->get_authors(); $item_id = $item->get_id(); if ($item_authors) { foreach ($item_authors as $item_author) { if ($item_author->get_name()) { $item_authors_string .= "<a href='" . $item_author->get_link() . "'>" . $item_author->get_name() . "</a> "; } elseif ($item_author->get_email()) { $item_authors_string .= $item_author->get_email() . " "; } } } if ($item_title) { $feed = $item->get_feed(); $feed_title = $feed->get_title(); $feed_link = $feed->get_link(); $feed_url = $feed->feed_url; if ($multifeed) { $entry_header = "<a target='_self' href='/read/{$feed_url}'>{$feed_title}</a><br/><a target='_self' href='{$item_link}' class='entry_title'>{$item_title}</a>\n"; } else { $entry_header .= "<a target='_self' href='{$item_link}' class='entry_title'>{$item_title}</a>\n"; } } $entry_header .= "<span class='edit_links'>"; if ($item_categories) { $entry_header .= " {$item_categories}, "; } if ($item_date) { $entry_header .= " posted {$item_date} "; } if ($item_authors_string) { $entry_header .= "by {$item_authors_string} "; } $item_id_hash = md5($item_id); $entry_header .= "</span><br />\n"; //$entry_text=removeEvilTags($item_data); $entry_text = $item_data; $content .= "\n\t\t\t<div class='plan_entry' id='plan_entry_{$item_id_hash}'>\n\t\t\t{$entry_header}\n\t\t\t<div class='entry_content' id='entry_content_{$item_id_hash}'>"; $content .= str_replace("<a ", "<a target='_self' ", $entry_text); $content .= "\n\t\t\t</div>\n\t\t\t</div>\n\t\t\t"; } } if (!$multifeed && is_object($item)) { $feed = $item->get_feed(); $feed_title = $feed->get_title(); $feed_link = $feed->get_link(); $feed_description = $feed->get_description(); $content = "<h1><a href='{$feed_link}'>{$feed_title}</a></h1>{$feed_description}<br /><br />{$content}"; // if($urls[0]!=$feed_link) $content="<div class='message'><b>This feed is autodiscovered</b> based on the link you provided. It may keep working, but discovery is unpredictable. If you want to ".$content; } profile('rss_read'); return $content; }