Ejemplo n.º 1
0
function skin_select($output = 1)
{
    if ($_SERVER['USER']) {
        $styles_fn = "{$_SERVER['USER_ROOT']}/styles.txt";
        $styles_fn = "{$_SERVER['USER_ROOT']}/skin.txt";
        if (file_exists($styles_fn) && !file_exists($skin_fn)) {
            parse_str(file_get_contents($styles_fn));
            if ($skin) {
                @(include $skin);
            }
        } else {
            parse_str(file_get_contents($skin_fn));
            if ($skin) {
                include $skin;
            }
        }
        if (is_array($skinlist = files_list("{$_SERVER['FILE_ROOT']}/resources/skins", "*.skin"))) {
            $stylesheet_select = "<select name='skin' style='width: 200px;'\">\n\t\t\t<option value='Standard'>Current settings</option>\n";
            foreach ($skinlist as $skin) {
                $skin = str_replace('.skin', '', basename($skin));
                $stylesheets .= "<link rel='alternate stylesheet' type='text/css' href='/stylesheet/{$skin}.css' title='{$skin}' />\n";
                $prettyskin = str_replace('_', ' ', str_replace('-', ' ', $skin));
                $prettyskin = str_replace('  ', "'", str_replace('..', '(', str_replace("...", ")", $prettyskin)));
                $prettyskin = str_replace('(by', " <span class='edit_links'> (by", $prettyskin);
                $prettyskin = str_replace(')', ")</span>", $prettyskin);
                $stylesheet_select .= "<option value='{$skin}'>{$prettyskin}</option>\n";
            }
            $stylesheet_select .= "</select>\n";
        }
        $wrapper .= "\n\t\t<form name='skin' action='{$_SERVER['WEB_ROOT']}/scripts/editstyles.php'>\n\t    <h1><img src='{$GLOBALS['toolsicon']}' /> Choose A Planwatch Skin</h1>\n\t    <i>change all your colors and fonts to a preset style</i><br/>\n\t\t<input type='hidden' name='action' value='skin'/>\n";
        $content .= $stylesheet_select;
        $content .= "<br /><input type='checkbox' CHECKED name='keep_fonts' value='1' /> Keep current font settings";
        $content .= "<br /><input type='checkbox' CHECKED name='keep_colors' value='1' /> Keep current color settings";
        $content .= "<br /><input type='checkbox' CHECKED name='keep_css' value='1' /> Keep custom css settings";
        $wrapper .= "{$content}\n<br/><br/><input type='submit' value='select skin'/>\n</form>";
    } else {
        $wrapper = "only logged in users can select skins";
    }
    if ($output == 1) {
        output('choose a skin', "<div>{$wrapper}</div>", '', ' choosing a planwatch.org skin');
    } else {
        return $content;
    }
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
function files_get_entry_filename($entry)
{
    $entry_list = files_list("{$_SERVER['USER_ROOT']}/plan", "*{$entry}*");
    return basename($entry_list[0]);
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
0
    die;
}
if (isset($_GET["tabs"])) {
    tabs();
    exit;
}
if (isset($_GET["members"])) {
    members();
    exit;
}
if (isset($_GET["files"])) {
    files();
    exit;
}
if (isset($_GET["browse-files-list"])) {
    files_list();
    exit;
}
if (isset($_GET["browse-smbstatus-list"])) {
    members_list();
    exit;
}
js();
function js()
{
    $q = new mysql();
    $page = CurrentPageName();
    $tpl = new templates();
    $count = $q->COUNT_ROWS("smbstatus_users", "artica_events");
    $title = $tpl->_ENGINE_parse_body("{$count} {members_connected}");
    $html = "YahooWin4('720','{$page}?tabs=yes','{$title}');";
Ejemplo n.º 7
0
function help_display_list()
{
    profile('help', 'begin');
    //	$help_cache_fn="$_SERVER[FILE_ROOT]/temp/help.cache";
    if (!file_exists($help_cache_fn) || @filemtime($help_cache_fn) < time() - 1800) {
        $content .= "<style>.linkbox li { margin: 10px; }</style>";
        $helplist = files_list("{$_SERVER['HELP_ROOT']}/", "*.help");
        $content .= "<ul class='linkbox flicklist' style='float: left;'><br />";
        foreach ($helplist as $i => $helpfile) {
            $helpfile = basename($helpfile);
            include_once "{$_SERVER['HELP_ROOT']}/{$helpfile}";
            $helpname = str_replace('.help', '', $helpfile);
            $helpnum = substr($helpname, 0, strpos($helpname, '.'));
            if ($helpnum[0] > $lasthelpnum[0] && $lasthelpnum) {
                $content .= "</ul>\n<ul class='linkbox flicklist' style='float: left;'><br />";
            }
            $content .= "<li><a href='{$_SERVER['WEB_ROOT']}/help/{$helpname}'>{$title}</a></li>";
            $lasthelpnum = $helpnum;
        }
        $content .= "</ul>\n<a class='bigbutton' href='{$_SERVER['WEB_ROOT']}/help/edit/new'>+ new help file</a>\n";
        //		file_put_contents($help_cache_fn,$content);
    } else {
        $content = file_get_contents($help_cache_fn);
    }
    profile('help', 'end');
    return "\n" . $content . "\n";
}
Ejemplo n.º 8
0
$delivery_dir = $mniblogpub_props["mniblogpub.shared"]["delivery"];
$archive_dir = $mniblogpub_props["mniblogpub.shared"]["archive"];
$failure_dir = $mniblogpub_props["mniblogpub.shared"]["failure"];
$seo_writeback = $mniblogpub_props["mniblogpub.php"]["seo.writeback"];
$site_basepath = $mniblogpub_props["mniblogpub.php"]["basepath"];
if (!isset($load_setting) || $load_setting == null || $load_setting == "") {
    print "ERROR: No load property found in config. " . "Please set to args or file." . "\n";
    print_r($load_setting);
    exit(4);
}
if (!isset($seo_writeback) || $seo_writeback == null || $seo_writeback == "" || strtolower($seo_writeback) == "false") {
    $seo_writeback = false;
} else {
    $seo_writeback = true;
}
$files = files_list($argv);
// #############################################################################
//    Primary Loop
// #############################################################################
for ($i = 0; $i < count($files); $i++) {
    $file = $files[$i];
    $head = '';
    $body = '';
    $date = '';
    $data = array('ContentType' => 'STORY');
    $codes = array();
    $parse_result = parsenewsmlfile($bloghome . "/" . $delivery_dir . "/" . $file, &$head, &$body, &$codes, &$date, &$data);
    $a_loc = $bloghome . "/" . ($parse_result ? $archive_dir : $failure_dir) . "/" . $file;
    rename($bloghome . "/" . $delivery_dir . "/" . $file, $a_loc);
    if ($parse_result) {
        $node = newstory($head, $body, $codes, $date, $data);
function plan_get_salt($username)
{
    $files = files_list($_SERVER['PLANOWNER_ROOT'], "salt.*");
    $salt = str_replace('salt.', '', $files[0]);
    if (!$salt) {
        $salt = plan_generate_salt($username);
    }
    if (file_exists("{$_SERVER['PLANOWNER_ROOT']}/salt.")) {
        unlink("{$_SERVER['PLANOWNER_ROOT']}/salt.");
    }
    //	if ($_SERVER['USER']=='dskatz04') echo $salt;
    return $salt;
}
<?php

$_SERVER['AUTH_COOKIE'] = 'fingerprint_v4';
$_SERVER['FILE_ROOT'] = '/home/planwatc/public_html';
include_once '/home/planwatc/public_html/scripts/siteconfig.php';
include_once '/home/planwatc/public_html/scripts/plan_read.php';
include_once '/home/planwatc/public_html/backend/xmlrpc.inc';
include_once '/home/planwatc/public_html/scripts/standard_library/user_info_functions.php';
include_once '/home/planwatc/public_html/scripts/standard_library/plan_info_functions.php';
include_once '/home/planwatc/public_html/scripts/standard_library/file_functions.php';
/* BACKUP */
$_COOKIE[$_SERVER['AUTH_COOKIE']] = "YmFja3Vw:::d53db979c480aa3ce0d9aaba69495fc8";
user_verify_fingerprint("YmFja3Vw:::d53db979c480aa3ce0d9aaba69495fc8");
$time = time();
$backup_permissions_dir = "{$_SERVER['FILE_ROOT']}/stats/backup_permissions";
$backup_users_list = files_list($backup_permissions_dir, "*.permission");
foreach ($backup_users_list as $userfile) {
    $username = trim(str_replace(".permission", "", basename($userfile)));
    $sptime = plan_get_last_update($username);
    $slastview = plan_get_last_view($username);
    if ($sptime > $slastview || !$sptime && filemtime("{$_SERVER['USER_ROOT']}/files/{$username}.latest.backup") < $time - 3600 * 6) {
        $plan = plan_read($username, FALSE, FALSE, FALSE, TRUE);
        $file = fopen("{$_SERVER['USER_ROOT']}/files/{$username}.{$time}.backup", 'w');
        fwrite($file, $plan);
        fclose($file);
        $file = fopen("{$_SERVER['USER_ROOT']}/files/{$username}.latest.backup", 'w');
        fwrite($file, $plan);
        fclose($file);
    }
}
Ejemplo n.º 11
0
    $data['description'] = $seo['item']['description'];
} else {
    $data['description'] = 'Новостная лента сайта ' . $_SERVER['HTTP_HOST'];
}
$data['time'] = infra_admin_time();
$data['link'] = 'http://' . infra_view_getHost() . '/' . infra_view_getRoot();
$conf = infra_config();
$exts = array('docx', 'tpl', 'mht', 'html');
$files = $conf['files'];
$folders = array(array('dir' => $files['folder_blog'], 'link' => '?Блог/'), array('dir' => $files['folder_events'], 'link' => '?События/'), array('dir' => $files['folder_pages'], 'link' => '?'));
$items = array();
infra_forr($folders, function ($fold) use($exts, &$items) {
    if (!$fold['dir']) {
        return;
    }
    $ar = files_list($fold['dir'], 0, 100, $exts);
    if (!$ar) {
        return;
    }
    $ar = array_values($ar);
    infra_forr($ar, function (&$itm) use($fold) {
        $itm = array("title" => strip_tags($itm['title']), "link" => $itm['link'], "description" => strip_tags($itm['preview']), "pubDate" => $itm['date'], "link" => $fold['link'] . $itm['name']);
    });
    $items = array_merge($items, $ar);
});
usort($items, function ($i, $j) {
    if ($i['pubDate'] < $j['pubDate']) {
        return 1;
    }
});
$data['items'] = $items;
Ejemplo n.º 12
0
function get_recent($params)
{
    global $xmlrpcerruser;
    global $SYSTEM;
    $blogid = $params->getParam(0);
    $username = $params->getParam(1);
    $password = $params->getParam(2);
    $numposts = $params->getParam(3);
    $uid = $username->scalarval();
    $pwd = $password->scalarval();
    $usr = NewUser($uid);
    # Again, let's just skip the permissions check since this information is
    # public anyway.
    user_verify_fingerprint(user_get_fingerprint($username->scalarval(), $password->scalarval()));
    if (user_is_valid($username->scalarval(), $password->scalarval())) {
        $plan_array = array_merge($plan_array, files_list($plan_dir, "plan{$limiter}*.txt{$private}"));
        rsort($plan_array);
        $arr = array();
        for ($i = 0; $i < $numposts->scalarval(); $i++) {
        }
        $arr[] = entry_to_struct($plan_array[$i]);
        $ret = new xmlrpcresp(new xmlrpcval($arr, 'array'));
    } else {
        $ret = new xmlrpcresp(0, $xmlrpcerruser + 3, "Invalid login");
    }
    return $ret;
}
Ejemplo n.º 13
0
function plan_write_journaling($edit, $plandata, $private, $nolinebreaks = FALSE, $writer = FALSE)
{
    include_once 'plan_read.php';
    include_once 'snoop.php';
    include_once 'spiel.php';
    include_once 'send.php';
    $planowner = $writer;
    // make sure all the timecodes are the same
    $time = time();
    // find the character encoding of the plan entry, convert it to something
    // more universal
    mb_detect_order("UTF-8, UTF-8, Windows-1252");
    if (mb_detect_encoding($plandata) == "Windows-1252") {
        $plandata = mb_convert_encoding($plandata, UTF - 8, Windows - 1252);
    }
    // make sure no one can post an update to someone else's plan
    // this will need to be smarter if we ever implement group plans
    // but probably we won't, so no biggie.
    if ($planowner != $_SERVER['USER'] && !user_is_administrator()) {
        $planowner = $_SERVER['USER'];
    }
    $plan_dir = "{$_SERVER['PWUSERS_DIR']}/{$planowner}/plan";
    // Find the old snoops. We have to masquerade briefly as 'cacheuser' to do
    // this without leaving a spurious snitch or getting private entries.
    // We remain 'cacheuser' until after snoop_add() below.
    $_SERVER['USER'] = '******';
    // find old snoops, for later clearing
    $old_snoop_array = snoop_find(plan_read_local($planowner, $_SERVER['USERINFO_ARRAY']['defaultdays'] + 3 . 'd'), $planowner);
    // delete the (now-invalid) cache files
    cache_clear($planowner);
    // leave a reminder to plan_read_local to ignore linebreaks.
    if ($nolinebreaks) {
        $plandata .= "<!--nolinebreaks-->";
    }
    if ($_POST['title']) {
        $plandata .= "<!--title {$_POST['title']} -->";
    }
    if ($_POST['tags']) {
        $plandata .= "<!--tags {$_POST['tags']} -->";
    }
    // if we weren't editing an existing (already-posted) entry, set the filename for the current time.
    if (!$_POST['edit'] || $_POST['edit'] == $_POST['draft_edit']) {
        $_POST['edit'] = ".{$time}";
    }
    $plan_fn = "{$plan_dir}/plan{$_POST['edit']}.txt{$_POST['private']}";
    if (!file_exists($plan_fn)) {
        file_put_contents("{$_SERVER['PWUSERS_DIR']}/{$planowner}/stats/lastupdate", $time);
    }
    if ($_FILES['attached_file']['tmp_name']) {
        rename("{$_FILES['attached_file']['tmp_name']}", "{$_SERVER['USER_ROOT']}/files/{$_FILES['attached_file']['name']}");
        if (strstr($_FILES['attached_file']['name'], 'jpg') || strstr($_FILES['attached_file']['name'], 'gif') || strstr($_FILES['attached_file']['name'], 'png')) {
            $plandata .= "<img src='/userfiles/view/{$writer}/{$_FILES['attached_file']['name']}' />";
        } else {
            $plandata .= "\n<a href='/userfiles/view/{$writer}/{$_FILES['attached_file']['name']}'>{$_FILES['attached_file']['name']}</a>";
        }
    }
    //	else trigger_error("No Files Uploaded");
    $plandata .= $_POST['markdown'];
    $plandata .= $_POST['nofeed'];
    // save old headers and footers.
    if (strstr($plan_fn, 'header') || strstr($plan_fn, 'footer')) {
        exec("mv {$plan_fn} {$plan_fn}.{$time}");
    }
    // write the update to disk.
    file_put_contents($plan_fn, $plandata);
    // new feature: SPIEL
    // here's the part where spiels are found
    // TODO(v4.5): replace spiel syntax with hashtags
    if (!$private && !$edit) {
        spiel_find($plandata, $planowner, $time);
    }
    // here's the part where sends are found
    if (!$private && !$edit) {
        send_find($plandata, $planowner, $time);
    }
    if (file_exists($plan_fn)) {
        if ($private && file_exists("{$plan_dir}/plan{$edit}.txt")) {
            exec("mv {$plan_dir}/plan{$edit}.txt {$plan_dir}/rem.plan{$edit}.txt");
        }
        if (!$private && file_exists("{$plan_dir}/plan{$edit}.txt.p")) {
            exec("mv {$plan_dir}/plan{$edit}.txt.p {$plan_dir}/rem.plan{$edit}.txt.p");
        }
        if ($_POST['draft_edit'] && file_exists("{$plan_dir}/draft{$_POST['draft_edit']}.txt")) {
            unlink("{$plan_dir}/draft{$_POST['draft_edit']}.txt");
        }
        // clean up old drafts
        if ($drafts = files_list("{$plan_dir}/", "draft*.txt")) {
            foreach ($drafts as $draft) {
                if (filemtime("{$plan_dir}/{$draft}") < time() - 7 * 24 * 3600) {
                    unlink("{$plan_dir}/{$draft}");
                }
            }
        }
    }
    @chmod($plan_fn, 0755);
    // clean old snoops and add new ones
    $new_snoop_array = snoop_find(plan_read_local($planowner), $planowner);
    $snoops_to_remove = array_unique(array_diff($old_snoop_array, $new_snoop_array));
    $snoops_to_set = array_unique(array_diff($new_snoop_array, $old_snoop_array));
    $remove_status = snoop_clean($snoops_to_remove, $planowner);
    $add_status = snoop_add($snoops_to_set, $planowner);
    $_SERVER['USER'] = $_SERVER['USERINFO_ARRAY']['username'];
    // done masquerading
    // report the good news if we wrote the post to disk.
    if (file_exists($plan_fn)) {
        if ($_SERVER['AJAX_POST']) {
            return $plandata;
        }
        if (!$_SERVER['BLOGPOST']) {
            if ($_COOKIE[$_SERVER['AUTH_COOKIE']]) {
                if ($_SERVER['AJAX_POST']) {
                    return $plandata;
                } else {
                    redirect("/read/{$planowner}");
                }
            } elseif (user_is_valid($_SERVER['USERINFO_ARRAY']['username'], $_SERVER['USERINFO_ARRAY']['userpass'])) {
                if ($_POST['mailpost']) {
                    echo "posted";
                    exit;
                } else {
                    // If the writer's cookie expired while updating, log her back in.
                    login($_SERVER['USERINFO_ARRAY']['username'], $_SERVER['USERINFO_ARRAY']['userpass'], 0, "/read/{$planowner}");
                    exit;
                }
            }
        } else {
            return ".{$time}";
        }
    } else {
        if ($_SERVER['BLOGPOST']) {
            return FALSE;
        } else {
            output('Error Updating', "<div class='alert'>There was an error writing {$_SERVER['USER']}'s plan entry to {$plan_fn} {$edit}. <a href='{$_SERVER['WEB_ROOT']}/feature'>File a bug</a> so we know about this problem. Here's your plan text for safekeeping:<br /><br />{$plandata}</div>", '', ' had an error');
        }
    }
}
Ejemplo n.º 14
0
function plan_read_local($planowner, $threshhold = FALSE, $begindate = '', $source = FALSE)
{
    $prl_rand = rand();
    profile("plan_read_local_{$prl_rand}");
    profile('plan_read_local_head');
    $reader = $_SERVER['USER'];
    if (!$threshhold) {
        $threshhold = $_SERVER['PLANOWNER_INFO_ARRAY']['defaultdays'] . 'd';
    }
    // this also appears in caching
    if (user_is_authorized($planowner, $reader)) {
        $private = "*";
        $private_cache_fn = 'private';
    }
    // css has to be here so it can be placed properly even when the plan is cached.
    // this is especially important for offnode readers for some reason.
    $css_filename = "{$_SERVER['PLANOWNER_ROOT']}/plan/plancss.txt";
    if (file_exists($css_filename)) {
        $plan_dressing['css'] = stripslashes(file_get_contents($css_filename));
        $plan_dressing['css'] = str_replace(array("\r", "\n"), " ", $plan_dressing['css']);
        $plan_dressing['css'] = str_replace(array("\r", "\n"), " ", $plan_dressing['css']);
        $plan_dressing['css'] = str_replace(array("\r", "\n"), " ", $plan_dressing['css']);
        $_SERVER['PLANOWNER_INFO']['css'] = strip_tags(trim($plan_dressing['css']));
    }
    //		if ($_SERVER['USER']=='jwdavidson') return "got css $css_filename $plan_dressing[css]";
    // CACHING
    // this tests to see if there's a cached version. if not, it will write
    // one when it's done getting the plan together.
    //----------------------------------------------
    // first figure out the appropriate cache filename
    if ($_SERVER['OUTPUT_MODE'] == 'RSS') {
        $feed = 'feed';
    }
    if ($_SERVER['OUTPUT_MODE'] == 'ATOM') {
        $feed = 'atomfeed';
    }
    if ($_SERVER['OUTPUT_MODE'] == 'ATOM_PRIVATE') {
        $feed = rand(100, 999);
    }
    if ($_SERVER['OUTPUT_MODE'] == 'IPHONE') {
        $feed = 'phonefeed';
    }
    profile('plan_read_local_uia');
    if (user_is_authorized($planowner, $reader)) {
        $private = "*";
        $private_cache_fn = 'private';
    }
    profile('plan_read_local_uia');
    profile('plan_read_local_utp');
    if (!plan_test_privacy($reader, $planowner)) {
        $blocked_cache_fn = 'blocked';
    }
    profile('plan_read_local_utp');
    $fn_username = base64_encode($planowner);
    if ($planowner == $reader) {
        $self = 'self';
    }
    if ($remoteuser == 'rss reader') {
        $feed = 'feed';
    }
    if ($source) {
        $source = "source";
    }
    $cache_fn = "{$_SERVER['FILE_ROOT']}/temp/{$_SERVER['PLANOWNER_INFO_ARRAY']['salt']}.{$self}{$private_cache_fn}{$blocked_cache_fn}{$remote}{$feed}.{$threshhold}.{$begindate}.{$source}.cache";
    // then, if the file exists, read it
    if (file_exists($cache_fn) && plan_get_last_update($planowner) < filemtime($cache_fn) && filesize($cache_fn) > 256) {
        profile('plan_read_local_pis');
        if (plan_is_local($reader)) {
            user_update_lastread($planowner);
        }
        profile('plan_read_local_pis');
        return file_get_contents($cache_fn);
    }
    // END CACHING
    // if no valid cache is found, on with the show
    if ($threshhold[0] != '.') {
        if (strstr($threshhold, 'r')) {
            $threshhold = str_replace('r', '', $threshhold);
            $reverse = 1;
        }
        $threshhold = time_calculate_threshhold($threshhold);
        $threshhold = time() - $threshhold;
        if (!$begindate || $begindate < 100) {
            $begindate = $threshhold;
            $enddate = time();
            $default_view = TRUE;
        } else {
            $enddate = $begindate + (time() - $threshhold);
        }
    }
    profile('plan_read_local_head');
    profile('plan_read_local_styles');
    // if the user has local pref stuff, read it in
    if ($_SERVER['USER_ROOT']) {
        $styles_fn = "{$_SERVER['USER_ROOT']}/styles.txt";
        $skin_fn = "{$_SERVER['USER_ROOT']}/skin.txt";
        $colors_fn = "{$_SERVER['USER_ROOT']}/colors.txt";
        $fonts_fn = "{$_SERVER['USER_ROOT']}/fonts.txt";
        $css_fn = "{$_SERVER['USER_ROOT']}/user_css.txt";
        if (file_exists($styles_fn) && !file_exists($skin_fn) && !file_exists($colors_fn)) {
            parse_str(file_get_contents($styles_fn));
            if ($skin && file_exists("{$_SERVER['FILE_ROOT']}/resources/skins/{$skin}")) {
                @(include $skin);
            }
        }
        if (file_exists($skin_fn)) {
            parse_str(file_get_contents($skin_fn));
            if ($skin) {
                include $skin;
            }
        }
        if (file_exists($colors_fn)) {
            parse_str(file_get_contents($colors_fn));
        }
        if (file_exists($fonts_fn)) {
            parse_str(file_get_contents($fonts_fn));
        }
        if (file_exists($css_fn)) {
            eval(file_get_contents($css_fn));
        }
    }
    profile('plan_read_local_styles');
    // screen out blocked readers, readers that fall below
    // privacy levels set by planowner
    if (!plan_test_privacy($reader, $planowner)) {
        $blocked_fn = "{$_SERVER['PLANOWNER_ROOT']}/blockedmessage.txt";
        if (file_exists($blocked_fn)) {
            $plan = stripslashes(file_get_contents($blocked_fn));
            $plan = str_replace('MYUSER', $planowner, $plan);
            $plan = str_replace('READER', $reader, $plan);
            $plan .= " <!--planowner: {$planowner} | reader: {$reader}-->";
        } else {
            $plan = "{$planowner} has no plan... <!-- reader: {$reader} --- planowner: {$planowner} -->";
        }
    } else {
        // if there's a series of entries listed, break out that list
        if (strstr($threshhold, ',')) {
            $threshhold_array = explode(',', $threshhold);
        } else {
            $threshhold_array = array($threshhold);
        }
        $plan_array = array();
        // this either reads in all the files from the list of entries passed
        // OR it just gets a list of all the entries that pass privacy muster
        foreach ($threshhold_array as $threshholdline) {
            // if the first character of the threshhold is a '.' we
            // want to show the entry indicated by the remainder of the line
            if ($threshholdline[0] == '.') {
                $limiter = $threshholdline;
            } else {
                $limiter = '.';
            }
            //sets dir for reading
            $plan_dir = "{$_SERVER['PLANOWNER_ROOT']}/plan/";
            // gets the entries indicated by $limiter
            // if $limiter is unset, fills the array with all available entries
            $plan_array = array_merge($plan_array, files_list($plan_dir, "plan{$limiter}*.txt{$private}"));
            if (is_array($plan_array) && $threshholdline[0] == '.') {
                $begindate = 1;
                $enddate = time() + 1;
            }
        }
        // get all the plan 'dressing' -- sidebars, header, footer, etc.
        /* CSS taken care of outside of caching.
        		$css_filename="$_SERVER[PLANOWNER_ROOT]/plan/plancss.txt";
        		if (file_exists($css_filename))
        		{
        			$plan_dressing['css']=stripslashes(file_get_contents($css_filename));
        			$plan_dressing['css']=str_replace(array("\r","\n")," ",$plan_dressing['css']);
        			$plan_dressing['css']=str_replace(array("\r","\n")," ",$plan_dressing['css']);
        			$plan_dressing['css']=str_replace(array("\r","\n")," ",$plan_dressing['css']);
        			$_SERVER['PLANOWNER_INFO']['css']=strip_tags(trim($plan_dressing['css']));
        		}
        */
        $header_filename = "{$_SERVER['PLANOWNER_ROOT']}/plan/planheader.txt";
        if (file_exists($header_filename)) {
            $plan_dressing['header'] = stripslashes(file_get_contents($header_filename));
            if (strstr($plan_dressing['header'], 'nolinebreaks')) {
                $plan_dressing['header'] = str_replace(array("\r", "\n"), "", $plan_dressing['header']);
                $plan_dressing['header'] = str_replace(array("\r", "\n"), "", $plan_dressing['header']);
                $plan_dressing['header'] = str_replace(array("\r", "\n"), "", $plan_dressing['header']);
            }
            if (strpos($plan_dressing['header'], '<!--markdown-->')) {
                include_once 'markdown.php';
                $plan_dressing['header'] = Markdown(str_replace('<!--markdown-->', '', $plan_dressing['header']));
            }
            $plan_dressing['header'] = "<div id='plan_header_{$_SERVER['PLANOWNER']}' class='plan_header'>{$plan_dressing['header']}</div>";
        }
        $footer_filename = "{$_SERVER['PLANOWNER_ROOT']}/plan/planfooter.txt";
        if (file_exists($footer_filename)) {
            $plan_dressing['footer'] = stripslashes(file_get_contents($footer_filename));
            if (strstr($plan_dressing['footer'], 'nolinebreaks')) {
                $plan_dressing['footer'] = str_replace(array("\r", "\n"), "", $plan_dressing['footer']);
                $plan_dressing['footer'] = str_replace(array("\r", "\n"), "", $plan_dressing['footer']);
                $plan_dressing['footer'] = str_replace(array("\r", "\n"), "", $plan_dressing['footer']);
            }
            if (strpos($plan_dressing['footer'], '<!--markdown-->')) {
                include_once 'markdown.php';
                $plan_dressing['footer'] = Markdown($plan_dressing['footer']);
            }
            $plan_dressing['footer'] = "<div id='plan_footer_{$_SERVER['PLANOWNER']}' class='plan_footer'>{$plan_dressing['footer']}</div>";
        }
        $divider_filename = "{$_SERVER['PLANOWNER_ROOT']}/plan/plandivider.txt";
        if (file_exists($divider_filename)) {
            $plan_dressing['divider'] = stripslashes(file_get_contents($divider_filename));
        }
        if ($plan_dressing) {
            foreach ($plan_dressing as $area => $content) {
                $content = stripslashes($content);
                if (strpos($content, 'nolinebreaks') !== FALSE) {
                    $content = str_replace('#nolinebreaks#', '', $content);
                } else {
                    $content = smart_nl2br($content);
                }
                $plan_dressing[$area] = $content;
            }
        }
        if (plan_is_journaling($planowner)) {
            $plan_array[] = "plan.{$begindate}.fake";
            $plan_array[] = "plan.{$enddate}.fake";
            sort($plan_array);
            $plan_array = array_values($plan_array);
            // extract the update time for all the plan entries
            foreach ($plan_array as $z => $planfn) {
                $planfn_a = explode(".", $planfn);
                $nextplanfn_a = explode(".", $plan_array[$z + 1]);
                $lastplanfn_a = explode(".", $plan_array[$z - 1]);
                if (($planfn_a[1] >= $begindate && $planfn_a[1] <= $enddate || $nextplanfn_a[1] >= $begindate && $nextplanfn_a[1] <= $enddate || $lastplanfn_a[1] >= $begindate && $lastplanfn_a[1] <= $enddate) && !strstr($planfn, 'fake')) {
                    $plan_index_array[$planfn_a[1]] = $planfn;
                }
            }
            // if we don't have any entries, give up now
            if (!is_array($plan_index_array)) {
                return "no plan entries found.";
            }
            // sort the plan list in order of update time newest to oldest.
            // we'll account for $reverse later, when we're
            // actually writing the entries to strings.
            krsort($plan_index_array);
            foreach ($plan_index_array as $entry_timecode => $entry_filename) {
                if ($entry_timecode >= $begindate && $entry_timecode <= $enddate) {
                    $entry_filename = "{$_SERVER['PLANOWNER_ROOT']}/plan/{$entry_filename}";
                    if (file_exists($entry_filename)) {
                        $plan_entries[$entry_timecode] = file_get_contents($entry_filename);
                    }
                }
            }
            // if there were no entries within the threshhold
            // and the threshhold was near now, show the most recent entry
            if (!is_array($plan_entries) && $enddate > time() - 15) {
                // the most recent entry will be just after the beginning of the array
                // because the first two entries will be the $enddate test entry
                reset($plan_index_array);
                while (strpos(current($plan_index_array), 'FAKE')) {
                    next($plan_index_array);
                }
                $entry_filename = "{$_SERVER['PLANOWNER_ROOT']}/plan/" . current($plan_index_array);
                $entry_timecode = key($plan_index_array);
                if (file_exists($entry_filename)) {
                    $plan_entries[$entry_timecode] = file_get_contents($entry_filename);
                }
            }
            // if there's still no plan, and we're considering an archival view
            // find the nearest-neighbor plan entry
            if (!is_array($plan_entries) && $enddate < time() - 15) {
                // get the distance to the prev entry
                array_set_current($plan_index_array, $enddate);
                $previous_entry_filename = "{$_SERVER['PLANOWNER_ROOT']}/plan/" . prev($plan_index_array);
                $previous_entry_timecode = key($plan_index_array);
                if (file_exists($previous_entry_filename)) {
                    $plan_entries[$previous_entry_timecode] = file_get_contents($previous_entry_filename);
                }
                // get the distance to the next entry
                array_set_current($plan_index_array, $begindate);
                $next_entry_filename = "{$_SERVER['PLANOWNER_ROOT']}/plan/" . next($plan_index_array);
                $next_entry_timecode = key($plan_index_array);
                if (file_exists($next_entry_filename)) {
                    $plan_entries[$next_entry_timecode] = file_get_contents($next_entry_filename);
                }
                $plan_entries[1000000000000000] = "Nothing In Range";
            }
            if ($reverse) {
                ksort($plan_entries);
            } else {
                krsort($plan_entries);
            }
            // if we're ouputting to HTML, put it all together in tasty DIVs.
            if ($_SERVER['OUTPUT_MODE'] == 'HTML' || $_SERVER['OUTPUT_MODE'] == 'IPHONE' || $_SERVER['OUTPUT_MODE'] == 'MOBILE' || $_SERVER['OUTPUT_MODE'] == 'AJAX') {
                foreach ($plan_entries as $entry_time => $entry_text) {
                    $entry_text = trim(stripslashes($entry_text));
                    if (strpos($entry_text, 'nolinebreaks') || strpos($entry_text, '<!--markdown-->')) {
                        $entry_nolinebreaks = 1;
                        $entry_text = str_replace('#nolinebreaks#', '', $entry_text);
                    } else {
                        $entry_nolinebreaks = '';
                        $entry_text = smart_nl2br($entry_text);
                    }
                    if (strpos($entry_text, '<!--markdown-->')) {
                        include_once 'markdown.php';
                        $entry_text = Markdown(str_replace('<!--markdown-->', '', $entry_text));
                    }
                    // pretty up the divider (erm... entry header)
                    $entry_header = plan_prepare_divider($planowner, $reader, $plan_dressing['divider'], $entry_time, $plan_index_array[$entry_time], $entry_text, $entry_nolinebreaks);
                    $plan_content .= plan_prepare_entry($entry_time, $entry_header, $entry_text);
                }
                $plan .= $plan_dressing['header'] . "\n{$new_entry_link}\n<div class='plan_body' id='plan_body_{$_SERVER['PLANOWNER']}'>\n{$plan_content}\n</div>" . $plan_dressing['footer'];
            }
            // if we're building a feed, we want to do valid XML goodness
            if ($_SERVER['OUTPUT_MODE'] == 'RSS') {
                foreach ($plan_entries as $entry_time => $entry_text) {
                    $entry_text = trim(stripslashes($entry_text));
                    if (strpos($entry_text, 'nolinebreaks')) {
                        $entry_text = str_replace('#nolinebreaks#', '', $entry_text);
                    } else {
                        $entry_text = smart_nl2br($entry_text);
                    }
                    $rss_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/read/{$planowner}";
                    $entry_text = plan_add_user_links(plan_add_alias_links($entry_text, $planowner));
                    list($entry, $li) = plan_encapsulate_rss($planowner, $entry_time, $entry_text);
                    $plan .= $entry;
                    $items .= $li;
                }
                $plan = "{$items}\n<!-- FEED_DIVIDER -->\n{$plan}";
            }
            if (strstr($_SERVER['OUTPUT_MODE'], 'ATOM')) {
                foreach ($plan_entries as $entry_time => $entry_text) {
                    $entry_text = trim(stripslashes($entry_text));
                    if (strpos($entry_text, 'nolinebreaks')) {
                        $entry_text = str_replace('#nolinebreaks#', '', $entry_text);
                    } else {
                        $entry_text = smart_nl2br($entry_text);
                    }
                    $rss_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['WEB_ROOT']}/read/{$planowner}";
                    $entry_text = plan_add_user_links(plan_add_alias_links($entry_text, $planowner));
                    $entry = plan_encapsulate_atom($planowner, $entry_time, $entry_text);
                    $plan .= $entry;
                }
                $plan = "{$items}\n<!-- FEED_DIVIDER -->\n{$plan}";
            }
        } else {
            // TODO:(v4.5) RSS for traditional plans
            //if ($_SERVER['USER']=='dskatz04') echo "$threshhold ".(time()-21*24*3600)." this is a traditional plan\n<br />";
            if (strlen($threshhold) < 9) {
                $threshhold = '';
            } elseif (strpos($threshhold, ',')) {
                $threshhold_array = explode(',', $threshhold);
            } else {
                $threshhold_array = array($threshhold);
            }
            if (is_array($threshhold_array)) {
                $threshhold_array = array_reverse($threshhold_array);
            } else {
                $threshhold_array = array("1" => "");
            }
            foreach ($threshhold_array as $z => $threshhold) {
                if ($threshhold != time() - $_SERVER['PLANOWNER_INFO_ARRAY']['defaultdays'] * 24 * 3600) {
                    $plan_filenames = files_list("{$_SERVER['PLANOWNER_ROOT']}/plan", "*{$threshhold}*");
                } else {
                    $plan_filenames = array('plan.txt');
                }
                $entry_time = $threshhold;
                if (count($threshhold_array) > 1) {
                    $plan .= "<hr/>" . date('F jS Y, g:ia', $threshhold_array[$z]) . "<hr/>";
                    $entry_header = plan_prepare_divider($planowner, $reader, $plan_dressing['divider'], $entry_time, $plan_filenames[0], $entry_text, $entry_nolinebreaks);
                }
                if (is_array($plan_filenames)) {
                    foreach ($plan_filenames as $filename) {
                        if (file_exists("{$_SERVER['PLANOWNER_ROOT']}/plan/{$filename}")) {
                            if (strstr($filename, '.gz')) {
                                $plan .= stripslashes(file_get_contents("compress.zlib://{$_SERVER['PLANOWNER_ROOT']}/plan/" . basename($filename)));
                            } else {
                                $plan .= stripslashes(file_get_contents("{$_SERVER['PLANOWNER_ROOT']}/plan/" . basename($filename)));
                            }
                        }
                    }
                }
            }
            if (strlen(trim($plan)) > 10) {
                if (!strstr($plan, 'nolinebreaks')) {
                    $plan = smart_nl2br($plan);
                }
                $plan = "{$plan_dressing['header']}<div class='plan_body' id='plan_body_{$_SERVER['PLANOWNER']}'>{$plan}</div>\n{$plan_dressing['footer']}";
            }
        }
    }
    // MORE CACHING
    if (!file_exists($cache_fn) || plan_get_last_update($planowner) > filemtime($cache_fn) && $remoteuser != 'rss reader') {
        file_put_contents($cache_fn, $plan);
    }
    profile("plan_read_local_{$prl_rand}");
    return "<!-- since " . formattime($threshhold) . " " . formattime($begindate) . " -->\n" . $plan;
}
Ejemplo n.º 15
0
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;'>&mdash; {$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;
}