function spiel_find($plan, $planowner, $timecode) { preg_match_all("|!sp[ie][ie]l:([^!]*)!|", $plan, $matches); $matches = $matches[1]; foreach ($matches as $i => $match) { $summary_begin = strpos($plan, $match); $summary = substr($plan, $summary_begin + strlen($match) + 1, 1024); if ($endtag = strpos($plan, '!spiel!', $summary_begin)) { $summary = substr($plan, $summary_begin + strlen($match) + 1, $endtag - 1); } elseif (strlen($summary) > 1000) { $lastspace = strrpos($summary, ' '); $summary = substr($summary, 0, $lastspace + 1); $summary .= "..."; } if (strpos($summary, '!spiel') || strpos($summary, '!speil')) { $lastspace = max(strpos($summary, '!spiel'), strpos($summary, '!speil')); $summary = substr($summary, 0, $lastspace); } if (strpos($match, ':')) { list($topic, $title) = explode(':', $match); } else { $topic = $match; $title = $match; } $topic = files_encode_safe_name($topic); $link = $timecode; spiel_add_entry($topic, $planowner, $link, $summary, $title); $currentspiels = @implode('', @array_unique(@file("{$_SERVER['PWUSERS_DIR']}/{$planowner}/spielslist.txt"))); if (strpos($currentspiels, "\n{$topic}") === FALSE) { $currentspiels .= "\n{$topic}"; } file_put_contents("{$_SERVER['PWUSERS_DIR']}/{$planowner}/spielslist.txt", $currentspiels); } return TRUE; }
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; }
// modified to work with post-4.1 globals //------------------------------------------------------------------------------ if ($_POST['action'] == 'write files') { $fileowner = $_POST['fileowner']; if ($fileowner == $_SERVER['USER']) { $path_to_file = "{$_SERVER['PWUSERS_DIR']}/{$fileowner}/files"; if (!is_dir($path_to_file)) { mkdir($path_to_file, 0777); } $files = $_FILES['files']; // adds a trailing slash to the path name if necessary. if (!ereg("/\$", $path_to_file)) { $path_to_file = $path_to_file . "/"; } // iterates through the array foreach ($files['name'] as $key => $name) { if ($files['size'][$key]) { // clean up file name $name = files_encode_safe_name($name); $location = $path_to_file . $name; copy($files['tmp_name'][$key], $location); unlink($files['tmp_name'][$key]); } } } if ($source == 'menu') { redirect("/userfiles/list/{$fileowner}"); } else { redirect('/userfiles/manage'); } }
function writefeature() { extract($_POST); if (md5($_POST['animal']) != $_POST['animal_hash']) { output("Failed", "<h1>Sorry</h1> You can't seem to tell the\n\t\tdifference between cute animal babies, so I'm guessing you're not human. You can try again, if you want."); } // $title=str_replace("'",'"',$title); $title = htmlentities($title); $title_fn = files_encode_safe_name($title); $feature_fn = "{$_SERVER['FILE_ROOT']}/features/{$title_fn}.feature"; if (file_exists($feature_fn) && $oldtitle != "{$title_fn}.feature") { $title_fn .= time(); $feature_fn = "{$_SERVER['FILE_ROOT']}/features/{$title_fn}.feature"; } if ($oldtitle != "{$title}.feature" && $oldtitle != 'new') { rename("{$_SERVER['FILE_ROOT']}/features/{$oldtitle}", "{$_SERVER['FILE_ROOT']}/features/{$oldtitle}.off"); } if ($response || $latest_response) { $response .= "\n\n-----\n\n[{$latest_responder}]:\n{$latest_response}"; } if (!$latest_responder) { $latest_responder = $submitter; } $feature_data = "title=" . urlencode(stripslashes($title)) . "¬e=" . urlencode(stripslashes($note)) . "&status=" . urlencode(stripslashes($status)) . "&response=" . urlencode(stripslashes($response)) . "&submitter=" . urlencode(stripslashes($submitter)) . "&time_noticed=" . urlencode(stripslashes($time_noticed)) . "&user_agent=" . urlencode(stripslashes($user_agent)) . "&ip=" . urlencode(stripslashes($ip)) . "&priority=" . urlencode(stripslashes($priority)) . "&latest_responder=" . urlencode(stripslashes($latest_responder)); if (!$failed) { file_put_contents($feature_fn, $feature_data); mail("*****@*****.**", "Bug updated: " . urlencode(stripslashes($title)), stripslashes("{$title} [ {$priority} ] [ {$status} ]\n\t\t\t{$submitter} {$_SERVER['USER']} {$_SERVER['USERINFO_ARRAY']['email']} {$_SERVER['USERINFO_ARRAY']['real_name']}\n\t\t\t\n-------------------------------------------------------------\n\t\t\t\n[{$latest_responder}] {$latest_response}\n\t\t\t\n{$response}\n\t\t\t\n-------------------------------------------------------------\n\t\t\t\nOriginal report:\n{$note}\n\t\t\t\n-------------------------------------------------------------\n\t\t\t\nView: http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/feature/description/{$title_fn}.feature\n\t\t\t\nEdit: http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/feature/edit/{$title_fn}.feature"), "From: {$submitter} <*****@*****.**>"); exec("rm -f {$_SERVER['FILE_ROOT']}/temp/magpie_cache/" . base64_encode("http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/features/index.atom")); file_put_contents("{$_SERVER['FILE_ROOT']}/features/index.atom", getfeatures_atom()); redirect("/feature"); } return 0; }
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; }
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; }