コード例 #1
0
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;
}
コード例 #2
0
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 .= " &nbsp;&nbsp;<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;
}