function plan_update_2010($edit = FALSE, $writer = FALSE) { if (!$writer) { $writer = $_SERVER['USER']; } // set dir for reading $_SERVER['WRITER']['plan_dir'] = "{$_SERVER['PWUSERS_DIR']}/{$writer}/plan"; $_SERVER['WRITER']['journaling'] = plan_is_journaling($writer); if (browser_is_modern()) { $content = plan_update_modern($edit, $writer); } if ($edit == 'tiny') { $content = plan_update_tiny($edit, $writer); } if ($_SERVER['OUTPUT_MODE'] == 'AJAX') { $content = plan_update_tweak($edit, $writer); } if ($_SERVER['OUTPUT_MODE'] == 'IPHONE') { $content = plan_update_mobile($edit, $writer); } if (!browser_is_modern()) { $content = plan_update_lowfi($edit, $writer); } return $content; }
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_prepare_divider($planowner, $reader, $divider, $entry_time, $entry_filename, $entry_text, $entry_nolinebreaks) { $entry_header = "<header class='entry_header' id='entry_header_{$entry_time}'><!--EDIT_LINKS-->\n{$divider}\n</header>"; if (strpos($entry_filename, '.p')) { $entry_is_private = 1; if ($reader == $planowner && browser_is_modern()) { $publicize_link = " <span id='privacy_{$entry_time}'><a href=\"javascript:loadXMLDoc('http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/entry/publicize/.{$entry_time}/ajax',null,'privacy_{$entry_time}');document.getElementById('privacy_marker_{$entry_time}').innerHTML='';void(null);\">publicize</a></span> "; } $entry_header = str_replace('PRIVATE', " <span class='private_marker' id='privacy_marker_{$entry_time}'>private entry</span> ", $entry_header); } else { $entry_is_private = ''; if ($reader == $planowner && browser_is_modern()) { $privatize_link = " <span id='privacy_{$entry_time}'><a href=\"javascript:loadXMLDoc('http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/entry/privatize/.{$entry_time}/ajax',null,'privacy_{$entry_time}');document.getElementById('privacy_marker_{$entry_time}').innerHTML='private entry';void(null);\">privatize</a></span> "; } $entry_header = str_replace('PRIVATE', " <span class='private_marker' id='privacy_marker_{$entry_time}'></span> ", $entry_header); } if (strstr($entry_text, '<!--no feed-->')) { $entry_is_nonfeed = 1; $entry_header = str_replace('NOFEED', " <span class='feed_marker' id='feed_marker_{$entry_time}'>not in feed</span> ", $entry_header); } else { $entry_is_nonfeed = ''; $entry_header = str_replace('NOFEED', "", $entry_header); } $entry_header = preg_replace('|LINK\\[(.*)\\]|', "<a href='{$_SERVER['WEB_ROOT']}/read/{$planowner}/.{$entry_time}' title='permanent link to this entry'>\\1</a>", $entry_header); preg_match_all('|DATE\\[(.*)\\]|', $entry_header, $matches); foreach ($matches[0] as $z => $ds) { $entry_header = str_replace($matches[0][$z], date($matches[1][$z], $entry_time), $entry_header); } // create the editing links if ($reader == $planowner && browser_is_modern()) { $edit_links .= "<a href=\"javascript:layerToggle('edit_links_{$entry_time}');\" class='tool'><span class='hidden'>editing tools </span> ⚙</a>" . " <div id='edit_links_{$entry_time}' class='edit_links' style='display: none;'>\n" . " <a href=\"/write/.{$entry_time}\">edit</a>\n" . " <a href=\"javascript:displayEditLayer('{$entry_time}');\">tweak</a>\n" . " <a href=\"javascript:loadXMLDoc('http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/entry/delete/.{$entry_time}/ajax',null,'plan_entry_{$entry_time}');\">delete</a> \n" . " <a href=\"javascript:loadXMLDoc('http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/entry/hide/.{$entry_time}/ajax',null,'plan_entry_{$entry_time}');\">hide</a> \n" . "{$privatize_link} {$publicize_link}\n</div>"; $entry_header = str_replace("<!--EDIT_LINKS-->", "\n{$edit_links}\n", $entry_header); $entry_header = str_replace("<header class='entry_header' id='entry_header_{$entry_time}'>", "<header class='entry_header' id='entry_header_{$entry_time}' ondblclick=\"displayEditLayer('{$entry_time}');\">", $entry_header); // $entry_header.=" // <div class='editLayer' id='editLayer_$entry_time'> // </div>"; } if (preg_match("<!--title (.*) -->", $entry_text, $titlematches)) { $entry_header .= "<header id='{$entry_time}' style='visibility: hidden;'>{$titlematches['1']}</header>"; } return $entry_header; }
function send_display($correspondent, $form = TRUE, $offset = 0) { $correspondent = str_replace("@planwatch.org", '', $correspondent); $send_dir = "{$_SERVER['USER_ROOT']}/sends"; if (!is_dir($send_dir)) { umask(0); mkdir($send_dir, 0755); } $sendlist = files_list($send_dir, files_encode_safe_name($correspondent) . "*message*"); if (is_array($sendlist)) { foreach ($sendlist as $i => $send) { $send_fn = basename($send); $send = str_replace("@planwatch.org", '', files_decode_safe_name($send_fn)); list($recipient, $time, $direction) = explode("..", $send); if ($direction == 'messagefrom') { $from = $correspondent; $style = ' class="send_from" '; } else { $from = $_SERVER['USER']; $style = ' class="send_to" '; } if (IS_JOSH) { $sendarray[$time] = "<div {$style}>" . smart_nl2br(removeEvilTags(file_get_contents($send_dir . "/{$send_fn}"))) . "<div style='text-align: right; font-size: 70%; font-weight: normal;'>— {$from} <span style='font-size: 70%; font-weight: normal;'>(" . formattime($time) . ")</span></div> </div>\n"; } else { $sendarray[$time] = "<div {$style}> {$from} (" . formattime($time) . "): " . smart_nl2br(removeEvilTags(file_get_contents($send_dir . "/{$send_fn}"))) . "</div>\n"; } } krsort($sendarray); if (IS_JOSH) { $firstmessage = reset($sendarray); unset($sendarray[key($sendarray)]); } if (OUTPUT_MODE == 'MOBILE') { $sendarray = array_slice($sendarray, $offset, 20); } else { $sendarray = array_slice($sendarray, $offset, 100); } $latest_time = array_shift(array_keys($sendarray)); // if ($latest_time < time() - 600 && $_SERVER['OUTPUT_MODE']=='AJAX') $content="IGNORE.NULL"; //else $content = implode("\n", $sendarray); if (file_exists("{$send_dir}/" . files_encode_safe_name("{$correspondent}..new"))) { unlink("{$send_dir}/" . files_encode_safe_name("{$correspondent}..new")); } if (file_exists("{$send_dir}/" . files_encode_safe_name("{$correspondent}@planwatch.org..new"))) { unlink("{$send_dir}/" . files_encode_safe_name("{$correspondent}@planwatch.org..new")); } } $content = hyperlink($content); if ($form) { if (browser_is_modern() && $_SERVER['OUTPUT_MODE'] != 'IPHONE' && $_SERVER['OUTPUT_MODE'] != 'MOBILE') { $sendbutton = "<input type='button' onclick='sendMessage();' value='Send' style='font-size: 20px; color: white; background: {$GLOBALS['linkcolor']}; font-family: {$GLOBALS['pfont']},{$GLOBALS['pfonts']}; font-weight: bold; ' />"; } else { $sendbutton = "<input type=\"submit\" value='Send' class='whiteButton' href=\"#\" style='' />"; } if (!$offset) { if (IS_JOSH) { $content = "\n\t\t\t\t{$firstmessage}<br clear='all' />\n\t\t\t\t<form action='{$_SERVER['WEB_ROOT']}/scripts/send.php' style='margin: 0px; display: block; ' method='post' class='panel'>\n\t\t\t\t<textarea id='textbox' name='sendmessage' style='width: 90%; font-size: 16px; height: 40px;' onfocus='this.style.height=\"200px;\"' onblur='this.style.height=\"40px;\"'></textarea>\n\t\t\t\t{$sendbutton}<br clear='all' />\n\n\t\t\t\t<hr />\n\t\t\t\t<h2>previously...</h2>\n\t\t\t\t<input type='hidden' name='action' value='send'/>\n\t\t\t\t<input type='hidden' id='recipient' name='recipient' value='{$correspondent}'/>\n\t\t\t\t<input type='hidden' id='sender' name='sender' value='{$_SERVER['USER']}'/>\n\t\t\t\t</form>\n\t\t\t\t<div id='send_div'>\n\t\t\t\t{$content}\n\t\t\t\t</div>\n\t\t\t\t<script type='text/javascript'>\tsetInterval(\"send_refresh();\",9757);</script>\n\n\t\t\t\t"; return $content; } if ($_SERVER['OUTPUT_MODE'] == 'HTML') { $content = "\n\t\t\t\t<form action='{$_SERVER['WEB_ROOT']}/scripts/send.php' style='margin: 0px;' method='post' class='panel'>\n\t\t\t\t<h1>Send with <a href='/read/{$correspondent}'>{$correspondent}</a></h1>\n\t\t\t\t<div id='send_div' style='overflow: auto; height: 200px; margin-bottom: 30px; width: 80%;'>\n\t\t\t\t{$content}\n\t\t\t\t</div>\n<!--\t\t\t\t<script src='/resources/javascript/edit.js'></script>-->\n\t\t\t\t<textarea id='textbox' name='sendmessage'></textarea>\n\t\t\t\t{$sendbutton}\n\t\t\t\t<input type='hidden' name='action' value='send'/>\n\t\t\t\t<input type='hidden' id='recipient' name='recipient' value='{$correspondent}'/>\n\t\t\t\t<input type='hidden' id='sender' name='sender' value='{$_SERVER['USER']}'/>\n\t\t\t\t</form>\n<!--\t\t\t\t<a href='/send/{$correspondent}/" . ($offset + 100) . "'>more...</a>-->\n\t\t\t\t<script type='text/javascript'>\tsetInterval(\"send_refresh();\",9757);</script>\n"; } if ($_SERVER['OUTPUT_MODE'] == 'IPHONE' || $_SERVER['OUTPUT_MODE'] == 'MOBILE') { $content = "\n\t\t\t\t<style type='text/css'>.send_from { background-color: #ffc; }</style>\n\t\t\t\t<form action='{$_SERVER['WEB_ROOT']}/scripts/send.php' style='margin: 0px;' method='post' class='panel'>\n\t\t\t\t<h3>Send with <a href='/read/{$correspondent}'>{$correspondent}</a></h3>\n<!--\t\t\t\t<script src='/resources/javascript/edit.js'></script>-->\n\t\t\t\t<textarea id='textbox' name='sendmessage' style='width: 300px; font-size: 16px;'></textarea>\n<!--\t\t\t\t<textarea id='sendmessage' style='width: 300px; height: 80px;' name='sendmessage'></textarea>-->\n\t\t\t\t{$sendbutton}<br clear='all' />\n\t\t\t\t<input type='hidden' name='action' value='send'/>\n\t\t\t\t<input type='hidden' id='recipient' name='recipient' value='{$correspondent}'/>\n\t\t\t\t<input type='hidden' id='sender' name='sender' value='{$_SERVER['USER']}'/>\n\t\t\t\t</form>\n\t\t\t\t<div id='send_div'>\n\t\t\t\t{$content}\n\t\t\t\t</div>\n\t\t\t\t<a target='_replace' href='/send/{$correspondent}/" . ($offset + 20) . "'>more...</a>\n\t\t\t\t<script type='text/javascript'>\tsetInterval(\"send_refresh();\",9757);</script>\n"; } } else { output("send from {$correspondent} starting at {$offset}", $content); } } return $content; }