function plan_update($edit = FALSE, $writer = FALSE) { if (!$writer) { $writer = $_SERVER['USER']; } if ($edit == 'tiny') { $tiny = TRUE; $edit = FALSE; } if ($tiny) { $content = "\n\t<style> textarea { font-size: 12pt; font-family: trebuchet ms; width: 300px; height: 300px; } </style>\n\t"; } // set dir for reading $plan_dir = "{$_SERVER['PWUSERS_DIR']}/{$writer}/plan"; // user_is_administrator() is here because admins can update the system plan // TODO(v5): add credentialing so people can easily write to multiple plans, multiple people can write to a given plan if (user_is_valid($writer, $_SERVER['USERINFO_ARRAY']['userpass']) || user_is_administrator() && $writer == 'system') { $journaling_test = plan_is_journaling($writer); if ($journaling_test) { $draft_links = plan_list_drafts(); } if (($journaling_test || $edit == 'header' || $edit == 'footer' || $edit == 'css') && $edit) { if ($edit == 'draft') { if ($_SERVER['URL_ARRAY'][4]) { $privateentry = ' CHECKED '; } if ($_SERVER['URL_ARRAY'][5]) { $nlb_check = ' CHECKED '; } if ($_SERVER['URL_ARRAY'][6]) { $markdown_check = ' CHECKED '; } if ($_SERVER['URL_ARRAY'][7]) { $nofeed_check = ' CHECKED '; } $plandata = stripslashes(file_get_contents("{$_SERVER['FILE_ROOT']}/temp/draft...{$writer}...{$_SERVER[URL_ARRAY][3]}...{$_SERVER[URL_ARRAY][4]}...{$_SERVER[URL_ARRAY][5]}...txt")); $edit = $_SERVER['URL_ARRAY'][3]; } elseif (file_exists("{$plan_dir}/plan{$edit}.txt") || file_exists("{$plan_dir}/plan{$edit}.txt.p") || file_exists("{$plan_dir}/draft{$edit}.txt")) { if (file_exists("{$plan_dir}/plan{$edit}.txt")) { $filename = "{$plan_dir}/plan{$edit}.txt"; } if (file_exists("{$plan_dir}/plan{$edit}.txt.p")) { $privateentry = ' CHECKED '; $filename = "{$plan_dir}/plan{$edit}.txt.p"; } if (file_exists("{$plan_dir}/draft{$edit}.txt")) { $filename = "{$plan_dir}/draft{$edit}.txt"; $draft_edit = $edit; } $plandata = stripslashes(file_get_contents($filename)); $plandata = preg_replace("|&(\\S+);|", "&\\1;", $plandata); if (strstr($plandata, '<!--markdown-->')) { $markdown_check = ' CHECKED '; $plandata = str_replace('<!--markdown-->', '', $plandata); } if (strstr($plandata, '<!--no feed-->')) { $nofeed_check = ' CHECKED '; $plandata = str_replace('<!--no feed-->', '', $plandata); } if (preg_match("|<!--title (.*)-->|", $plandata, $titlematches)) { $title = $titlematches[1]; $plandata = str_replace($titlematches[0], '', $plandata); } if (preg_match("|<!--tags (.*)-->|", $plandata, $tagmatches)) { $tags = $tagmatches[1]; $plandata = str_replace($tagmatches[0], '', $plandata); } } } elseif (!($journaling_test || $edit == 'header' || $edit == 'footer')) { $oldplan_fn = "{$_SERVER['PWUSERS_DIR']}/{$writer}/plan/plan.txt"; if (file_exists($oldplan_fn)) { $plandata = stripslashes(file_get_contents($oldplan_fn)); } else { // NOTE: the oldest nonjournaling plan entry will always be blank $plandata = ''; touch($oldplan_fn); } } if (strpos($plandata, 'nolinebreaks') !== FALSE) { $plandata = str_replace(array('<!--nolinebreaks-->', '#nolinebreaks#'), '', $plandata); $nlb_check = 'CHECKED'; } else { $nlb_check = ''; } if (!$edit) { $content .= "<h1><img src='{$GLOBALS['writeicon']}' /> Write a plan update</h1>"; } elseif (strpos($edit, 'er') || strpos($edit, 'ss')) { $content .= "<h1><img src='{$GLOBALS['writeicon']}' /> Edit your plan {$edit}</h1>"; } else { $content .= "<h1><img src='{$GLOBALS['writeicon']}' /> Edit your plan entry from " . formattime(substr($edit, 1)) . "</h1>"; } if (user_is_administrator() && $writer == 'system') { $content .= "{$_SERVER['USER']} editing the system plan.<br />"; } if ($_SERVER['OUTPUT_MODE'] != 'IPHONE' && $_SERVER['OUTPUT_MODE'] != 'MOBILE') { $formatlinks = "<script src='/resources/javascript/edit.js'></script>"; } $content .= "\n\t\t{$formatlinks}\n\t\t<form title='Write' selected='true' action='{$_SERVER['WEB_ROOT']}/scripts/plan_update.php' method='post' name='plan_update' enctype='multipart/form-data'>\n\n\t\t<textarea name='newplan' id='textbox' rows='12' cols='32'>" . trim($plandata . $autocontent) . "</textarea>\n\t\t<div class='settingsbox' >\n\t\t<div style='text-align: center;'>\n\t\t\t<input\n\t\t\t\t type = 'submit'\n\t\t\t\t name = 'update'\n\t\t\t\t value = 'Post'\n\t\t\t\t accesskey = 'x'\n\t\t\t\t style = 'font-size: 20px; font-family: {$GLOBALS['nfonts']}; background: {$GLOBALS['linkcolor']}; color: {$GLOBALS['planbgcolor']}; padding: 2px;'\n\t\t\t/>\n\t\t\t"; if ($journaling_test && $edit != 'divider' && $edit != 'header' && $edit != 'footer' && $edit != 'css') { if ($draft_edit) { $draft_time = str_replace(".", '', $draft_edit); } else { $draft_time = time(); $draft_edit = ".{$draft_time}"; } $_SERVER['PLAN_DRAFT_TIME'] = $draft_time; if (!$tiny) { $content .= "\n\t\t\t<input\n\t\t\t\t type = 'button'\n\t\t\t\t name = 'draft'\n\t\t\t\t value = 'Save'\n\t\t\t\t accesskey = 'd'\n\t\t\t\t onclick = \"loadXMLDoc('http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/scripts/plan_update.php','draft_time={$draft_time}&action=Autosave%20Ajax&newplan=' + escape(element('textbox').value),'autosave_alert',processReqChangePOST);\"\n\t\t\t\t style = 'font-size: 12px; font-family: {$GLOBALS['nfonts']}; background: {$GLOBALS['navlinkcolor']}; color: {$GLOBALS['listsbgcolor']}; padding: 2px;'\n\t\t\t/>\n\n\t\t\t<div id='autosave_alert'></div>\n\t\t\t</div>\n\n\t\t\t<div>Optional Info<br />\n\t\t\t\tTitle <input type='text' name='title' value='{$title}' style='width: 10%;' placeholder='Title'><br />\n\t\t\t\tTags <input type='text' name='tags' value='{$tags}' style='width: 10%;' placeholder='Private Tags'>\n\t\t\t</div>\n\n\t\t\t<div>\n\t\t\t\tprivacy<br/>\n\t\t\t\t<input type='checkbox' {$nofeed_check} name='nofeed' id='nofeed' value='<!--no feed-->' />\n\t\t\t\t<label for='nofeed'>not in feed</label>\n\t\t\t\t<a href='{$_SERVER['WEB_ROOT']}/help/writing#nofeed' target='_blank'>[?]</a><br />\n\t\t\t\t<input type='checkbox' name='private' id='private' value='.p' {$privateentry} onchange='if (this.checked) { document.getElementById(\"textbox\").style.background=\"#eeeeee\"; }'/>\n\t\t\t\t<label for='private'>private entry</label><br/>\n\t\t\t\t<a href='{$_SERVER['WEB_ROOT']}/help/privacy' target='_blank'>privacy help</a><br />\n\t\t\t\t<a href='{$_SERVER['WEB_ROOT']}/lists/edit/allowed' target='_blank'>edit allowed users</a><br />\n\t\t\t</div>\n\n\t\t\t<div>Attach a file<br /><input type='file' name='attached_file' style='width: 90px;' /></div>\n\t\t\t"; } else { $content .= "<br /><br /><br /><input type='checkbox' name='private' id='private' value='.p' {$privateentry} onchange='if (this.checked) { document.getElementById(\"textbox\").style.background=\"#eeeeee\"; }'/> <label for='private'>private</label> "; } } if (!strpos($edit, "er") && !strpos($edit, "ss")) { if (!$tiny) { $content .= "\n\t\t\t\t\t<div>\n\t\t\t\t\t\tdisplay<br/>\n\t\t\t\t\t\t<input type='checkbox' {$markdown_check} name='markdown' id='markdown' value='<!--markdown-->' />\n\t\t\t\t\t\t<label for='markdown'><a target='_blank' href='http://michelf.com/projects/php-markdown/concepts/'>markdown</a></label><br />\n\t\t\t\t\t\t<input type='checkbox' {$nlb_check} name='nolinebreaks' id='nolinebreaks' value='1' />\n\t\t\t\t\t\t<label for='nolinebreaks'>no line breaks</label>\n\t\t\t\t\t\t<a href='{$_SERVER['WEB_ROOT']}/help/writing#linebreaks' target='_blank'>[?]</a>\n\t\t\t\t\t\t<br />\n\t\t\t\t\t</div>\n"; if ($edit == 'divider') { $content .= "\n\t\t\t\t\t<div style='font-size: 9px; font-family: sans-serif; width: 100px;'>\n\t\t\t\t\t\t<a href='{$_SERVER['WEB_ROOT']}/help/divider' target='_blank'><img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['helpicon']}' alt='?' /> help customizing your divider</a>\n\t\t\t\t\t</div>\n\t\t\t\t\t"; } } else { $content .= "\n\t\t\t<input type='checkbox' {$markdown_check} name='markdown' id='markdown' value='<!--markdown-->' /> <label for='markdown'>markdown</label> <input type='checkbox' {$nofeed_check} name='nofeed' id='nofeed' value='<!--no feed-->' /> not in feed\n\t\t\t\t\t\t"; } } elseif (strstr($edit, 'er')) { $content .= "\n\t\t</div><div>\n\t\t<input type='checkbox' {$nlb_check} name='nolinebreaks' id='nolinebreaks' value='1' />\n\t\t<label for='nolinebreaks'>no line breaks</label>\n\t\t<a href='{$_SERVER['WEB_ROOT']}/help/writing#linebreaks' target='_blank'>[?]</a>\n\t\t<br />\n<input type='checkbox' {$markdown_check} name='markdown' id='markdown' value='<!--markdown-->' />\n<label for='markdown'><a target='_blank' href='http://michelf.com/projects/php-markdown/concepts/'>markdown</a></label>\n</div><div style='display: none;'>\n\t\t"; } elseif (strstr($edit, 'ss')) { $content .= "<br /><br /><a target='_blank' href='/help/formatting'>CSS formatting help</a> <br /><br /> <a href='/help/lynneformatting' target='_blank'>Lynne's CSS tips</a><br />\n\t\t<style>.CodeMirror-wrapping { width: 80% !important; float: left !important; clear: none !important; height: 350px !important; border: thin solid black !important; }</style>\n\t\t\n\t\t\t <script src='/resources/javascript/codemirror65/js/codemirror.js' type='text/javascript'></script>\n\t\t<script type='text/javascript'>\n\t\t var editor = CodeMirror.fromTextArea('textbox', {\n\t\t border: '1px solid black',\n\t\t parserfile: 'parsecss.js',\n\t\t stylesheet: '/resources/javascript/codemirror65/css/csscolors.css',\n\t\t path: '/resources/javascript/codemirror65/js/'\n\t\t });\n\t\t</script>\n\t\t"; } $content .= "\n\t\t\t<input type='hidden' id='draft_edit' name='draft_edit' value='{$draft_edit}'>\n\t\t\t<input type='hidden' name='writer' value='{$writer}'/>\n\t\t\t<input type='hidden' name='edit' value='{$edit}'/>\n\t\t\t<input type='hidden' name='fingerprint' value='" . $_COOKIE[$_SERVER['AUTH_COOKIE']] . "'/>\n\t\t\t<input type='hidden' name='sid' value='{$_SERVER['SESSION_ID']}'/>\n\t\t</div>"; if ($journaling_test || $edit == 'header' || $edit == 'footer') { $content .= "<input type='hidden' name='action' value='Update Journaling Plan' />\n"; } else { $content .= "<input type='hidden' name='action' value='Update Nonjournaling Plan' />\n"; } $content .= "</form><div id='draftList'></div>\n"; } else { $content = "<div class='alert'>Your attempt to update your plan failed because\n\tyou supplied an invalid username or password. Please login again, and mail\n\t<a href='mailto:help@planwatch.org'>help@planwatch.org</a> if you believe this message\n\tis in error.</div>"; } // if the form was actually presented, include the relevant javascript files to make it all work. if (!strpos($content, 'alert')) { $content .= "\n\n<script type='text/javascript' language='javascript'>document.getElementById('textbox').focus();</script>\n"; $content .= "\n\n<script language='javascript' type='text/javascript' src='{$_SERVER['WEB_ROOT']}/resources/javascript/setplan.js'></script>\n"; //$content.="<script language='javascript' type='text/javascript' src='$_SERVER[WEB_ROOT]/resources/javascript/speller/spellChecker.js'></script>\n\n"; } return $content; }
function menus_populate($button, $content = FALSE) { switch ($button) { case "view": $links .= "<li>\n<!--\nTHE VIEW MENUBOX\n-->\n\n\t\t<i>read your own plan. you know, in case you forgot.</i></li>\n\n\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/view'>view your plan</a></li>\n\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/read/{$_SERVER['USER']}/bio'>view your bio</a></li>\n"; if (plan_has_archives($_SERVER['USER'])) { $links .= "<li><a href='{$_SERVER['WEB_ROOT']}/read/{$_SERVER['USER']}/archives'>view your archives</a></li>\n"; } if (plan_is_journaling($_SERVER['USER'])) { $links .= "<li><hr /><a href='{$_SERVER['WEB_ROOT']}/view/all_hidden'>view your hidden entries</a></li>\n\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/view/all_private'>view your private entries</a></li>\n"; } break; case "write": $links .= "\n<!--\nTHE WRITE MENUBOX\n-->\n\n\t\t<li><i>write a plan update. you know you want to.</i></li>\n\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/write'>update your plan</a></li>\n\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/write/bio'>edit your bio</a></li>\n"; if (user_is_administrator()) { $links .= "<li><a href='{$_SERVER['WEB_ROOT']}/write/system'>update the system plan</a></li>\n"; } $links .= "<li><hr/>\n</li>\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/write/css'>change plan styles</a></li>\n\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/write/header'>change plan header</a></li>\n\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/write/footer'>change plan footer</a></li>\n"; if (plan_is_journaling($_SERVER['USER'])) { $links .= "<li><a href='{$_SERVER['WEB_ROOT']}/write/divider'>change your divider</a></li>\n"; } $links .= "<li><hr/></li>\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/send'>write a send</a></li>\n"; if ($content && plan_is_journaling($_SERVER['USER']) && strstr($_SERVER['REQUEST_URI'], "/read/{$_SERVER['USER']}")) { preg_match_all('|entry_content_([0-9]+)|', $content, $matches); $matches = $matches[1]; if (is_array($matches)) { $links .= "<li><hr/>edit recent entries...</li>\n"; foreach ($matches as $match) { $links .= "<li><a href='{$_SERVER['WEB_ROOT']}/write/.{$match}'>" . formattime($match) . "</a></li>\n"; } } } break; case "snitch": $links .= "\n<!--\nTHE SNITCH MENUBOX\n-->\n\n\t\t<li><i>snitch and other s-words.</i></li>\n\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/snitch'>snitch</a></li>\n"; $links .= "<li><hr/>\n</li>\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/snoop'>snoop</a></li>\n\n\t\t<li><a href='{$_SERVER['WEB_ROOT']}/send'>send</a></li>\n"; break; case "tools": $links .= "\n<!--\nTHE TOOLS MENUBOX\n-->\n"; $links .= "<li><i>tools to maintain and customize your account</i></li>"; $links .= "\n\t\t\t<li><a href='{$_SERVER['WEB_ROOT']}/feature/' title='report a bug or request a feature'>report a bug</a><br/><hr/></li>\n" . "<li><a href='{$_SERVER['WEB_ROOT']}/slogans/add' title='add your own pw.o slogan to the random selection'>add a new slogan</a><br/>\n\t\t\t<a href='{$_SERVER['WEB_ROOT']}/smileys/add' title='upload a new smiley for people to use on their plans'>add a new smiley</a><br/>\n\t\t\t<hr/></li>\n" . "<li><a href='{$_SERVER['WEB_ROOT']}/lists/edit/allowed' title='change who can read your private entries'>edit your allowed list</a><br/>\n\t\t\t<a href='{$_SERVER['WEB_ROOT']}/lists/edit/blocked' title='change who is prevented from reading you'>edit your blocked list</a><br/>\n\t\t\t<hr/>\n</li>" . "<li><a href='{$_SERVER['WEB_ROOT']}/prefs/styles'>customize colors</a></li>\n" . "<li><a href='{$_SERVER['WEB_ROOT']}/prefs/fonts'>customize fonts</a></li>\n" . "<li><a href='{$_SERVER['WEB_ROOT']}/prefs/custom_css' title='add custom css'>customize css</a></li>\n" . "<li><a href='{$_SERVER['WEB_ROOT']}/prefs/skin' title='pick a skin'>pick a skin</a></li>\n" . "<li><hr/></li>\n" . "<li><a href='{$_SERVER['WEB_ROOT']}/prefs/userinfo'>user settings</a></li>\n" . "<li><a href='{$_SERVER['WEB_ROOT']}/prefs/interface'>interface prefs</a></li>\n"; // ."<li>skin preview:<br/> <!--SKIN_SELECTOR--></li>\n" break; case "<!--TIME-->": $links .= "<!--LOADTIME-->"; break; case "watched": $links .= "\n\t\t\t<li><a href='{$_SERVER['WEB_ROOT']}/lists/edit/watched' title='edit your watched list'>edit</a></li>\n\t\t\t<li class='listheader'>move\n\t\t\t<a href='{$_SERVER['WEB_ROOT']}/lists/move/watched/top'>top</a>\n\t\t\t<a href='{$_SERVER['WEB_ROOT']}/lists/move/watched/left'>left</a>\n\t\t\t<a href='{$_SERVER['WEB_ROOT']}/lists/move/watched/right'>right</a></li>\n\t\t\t<!--<b>move AJAX</b>\n\t\t\t<li><a href=\"javascript:list_move('top');void(null);\">top</a></li>\n\t\t\t<li><a href=\"javascript:list_move('left');void(null);\">left</a></li>\n\t\t\t<li><a href=\"javascript:list_move('right');void(null);\">right</a></li>\n\t\t\t-->\n\t\t\t<li class='listheader'>sort\n\t\t\t<a href=\"javascript:loadXMLDoc('{$_SERVER['WEB_ROOT']}/lists/resort/name/ajax','','planwatch');void(null);\" title='sort alphabetically by name'>abc</a>\n\t\t\t<a href=\"javascript:loadXMLDoc('{$_SERVER['WEB_ROOT']}/lists/resort/time/ajax','','planwatch');void(null);\" title='sort by date and time'>321</a>\n\t\t\t<a href=\"javascript:loadXMLDoc('{$_SERVER['WEB_ROOT']}/lists/resort/inorder/ajax','','planwatch');void(null);\" title='do not sort, use in the order listed'>zfq</a></li>\n\t\t\t<li class='listheader'>status\n\t\t\t<a href='{$_SERVER['WEB_ROOT']}/lists/planwatch_mark_all_read' title='mark all plans as read'>update</a>\n\t\t\t<a href='{$_SERVER['WEB_ROOT']}/lists/planwatch_mark_all_unread' title='mark all plans as unread'>reset</a></li>\n\t\t\t<!--<li><b>lists</b></li>\n\t\t\t<li><a href='{$_SERVER['WEB_ROOT']}/lists/advertised_users' title='advertised users'>advertised users</a> </li>\n\t\t\t<li><a href='{$_SERVER['WEB_ROOT']}/lists/registered_users' title='registered users'>registered users</a></li>-->\n"; break; } return $links; }
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 .= " <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; }