function userfiles_build_menu() { $quota = 10000; // in kilobytes if ($_SERVER['USER'] == 'listen') { $quota = 10000000; } if ($_SERVER['USER'] == 'jwdavidson') { $quota = 10000000; } $content .= "<html>\n\t<head>\n\t<script type='text/javascript' src='{$_SERVER['WEB_ROOT']}/resources/javascript/setplan.js' />\n\t<link rel='stylesheet' href='{$_SERVER['WEB_ROOT']}/stylesheet'>\n\t</head>\n\t<body>"; $fileowner = $_SERVER['USER']; $fileowner_files_dir = "{$_SERVER['USER_ROOT']}/files"; if (is_dir($fileowner_files_dir)) { $groupmembers = files_list("{$fileowner_files_dir}", "*", "date"); } else { $groupmembers = array(); } if (count($groupmembers) > 0) { foreach ($groupmembers as $fileownerfile) { $fileownerfile = basename($fileownerfile); if (strpos($fileownerfile, '.jpg') || strpos($fileownerfile, '.png') || strpos($fileownerfile, '.gif')) { $photolist[] = $fileownerfile; } elseif (strpos($fileownerfile, '.wav') || strpos($fileownerfile, '.mp3') || strpos($fileownerfile, '.m4a') || strpos($fileownerfile, '.au') || strpos($fileownerfile, '.wma') || strpos($fileownerfile, '.ogg')) { $audiolist[] = $fileownerfile; } else { $misclist[] = $fileownerfile; } } } unset($groupmembers); if (isset($photolist)) { foreach ($photolist as $photo) { $photosize = getimagesize("{$_SERVER['USER_ROOT']}/files/{$photo}"); $photo_link = "<img src=\\'http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/userfiles/view/{$fileowner}/{$photo}\\' alt=\\'{$photo}\\' title=\\'{$photo}\\' width=\\'{$photosize['0']}\\' height=\\'{$photosize['1']}\\' />"; $photo_content .= "\n\t\t\t<li><a href=\"javascript:insertTag('textbox','{$photo_link}',''); window.parent.document.getElementById('insert').style.display='none'; void(0);\">\n\t\t\t<img src='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/resources/graphics/posticon.gif' />\n\t\t\t{$photo}\n\t\t\t</a>\n\t\t\t<a href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/userfiles/delete/{$fileowner}/{$photo}/menu'>\n\t\t\t<img src='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/resources/graphics/x.gif' width='8' height='8' />\n\t\t\t</a></li>\n"; } $content .= "<li class='listheader'>Images</li>\n{$photo_content}\n\n"; } if (isset($audiolist)) { foreach ($audiolist as $audio) { $audio_link = "<a href=\\'http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/userfiles/view/{$fileowner}/{$audio}\\' alt=\\'{$audio}\\'/>"; $audio_content .= "\n\t\t\t<li><a href=\"javascript:insertTag('textbox','{$audio_link}',''); window.parent.document.getElementById('insert').style.display='none'; void(0);\">\n\t\t\t<img src='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/resources/graphics/smallaudio.gif' />\n\t\t\t{$audio}\n\t\t\t</a>\n\t\t\t<a href='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/userfiles/delete/{$fileowner}/{$audio}/menu'>\n\t\t\t<img src='http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/resources/graphics/x.gif' width='8' height='8' />\n\t\t\t</a></li>\n"; } $content .= "<li class='listheader'>Sounds</li>\n{$audio_content}\n\n"; } if (isset($misclist)) { foreach ($misclist as $misc) { $misc_display = files_decode_safe_name($misc); $misc_link = "<a href=\\'http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/userfiles/view/{$fileowner}/{$misc}\\'>{$misc_display}</a>"; $misc_content .= "\n\t\t\t<li><a href=\"javascript:insertTag('textbox','{$misc_link}',''); window.parent.document.getElementById('insert').style.display='none'; void(0);\">\n\t\t\t<img src='{$_SERVER['WEB_ROOT']}/resources/graphics/posticon.gif' />\n\t\t\t{$misc}\n\t\t\t</a>\n\t\t\t<a href='{$_SERVER['WEB_ROOT']}/userfiles/delete/{$fileowner}/{$misc}/menu'>\n\t\t\t<img src='{$_SERVER['WEB_ROOT']}/resources/graphics/x.gif' width='8' height='8' />\n\t\t\t</a></li>\n"; } $content .= "<li class='listheader'>Documents</li>\n{$misc_content}\n\n"; } if (($ds = dir_size("{$_SERVER['USER_ROOT']}/files/")) < 1024 * $quota) { $uploadform = "<li>" . round($ds / 1024) . " K used of {$quota} K total\n\t\t<form target='hiddenUploadFrame' action='{$_SERVER['WEB_ROOT']}/scripts/userfiles.php' method='post' enctype='multipart/form-data'>\n\t\t<input type='file' name='files[1]' id='fileToUpload'/>\n\t\t<input type='submit' value='upload file' onclick=\"element('insert').style.display='none';void(0);\"/>\n\t\t<input type='hidden' name='action' value='write files'/>\n\t\t<input type='hidden' name='fileowner' value='{$_SERVER['USER']}'/>\n\t\t<input type='hidden' name='source' value='menu'/>\n\t\t<iframe id='hiddenUploadFrame' name='hiddenUploadFrame' style='height: 1px; width: 1px; visibility: hidden;'></iframe>\n\t\t</form></li>\n"; } else { $content .= "<li><strong>QUOTA EXCEEDED. Please delete " . files_format_size($ds - $quota * 1024) . " of files.</li>"; } $content .= "<li><a href='{$_SERVER['WEB_ROOT']}/userfiles/manage/{$_SERVER['USER']}' target='_top'><img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['toolsicon']}'> manage your files</a></li>\n"; $content .= "<li><a href='javascript:window.location.reload();'><img src='{$_SERVER['WEB_ROOT']}{$GLOBALS['toolsicon']}'> refresh the list</a></li>\n"; $content = $uploadform . $content; return $content; }
function spiel_format_list_html() { $already_listed = array(); if (file_exists("{$_SERVER['PWUSERS_DIR']}/{$_SERVER['USER']}/spielslist.txt")) { $list = array_unique(file("{$_SERVER['PWUSERS_DIR']}/{$_SERVER['USER']}/spielslist.txt")); } if (is_array($list)) { foreach ($list as $item) { if (($item = trim($item)) && !in_array(trim($item), $already_listed)) { $content .= "<li><a href='{$_SERVER['WEB_ROOT']}/spiel/view/{$item}'>" . files_decode_safe_name($item) . "</a> " . formattime(spiel_get_last_update($item)) . " [ <a href='{$_SERVER['WEB_ROOT']}/spiel/ignore/{$item}'>x</a> ]\n </li>"; } $already_listed[] = trim($item); } } if ($content) { $content = "<li class='listheader'>Watched Spiels</li>\n {$content}"; } return $content; }
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; }