<?php

require_once dirname(__FILE__) . '/inc/auth.inc.php';
require_once dirname(__FILE__) . '/../app/lib/lib.opml.php';
$opml = OpmlManager::load(dirname(__FILE__) . '/../custom/people.opml');
$opml_people = $opml->getPeople();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/HTML; charset=UTF-8" />
    <meta http-equiv="Content-Script-Type" content="text/javascript" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <meta http-equiv="Content-Language" content="en" />

    <title>moonmoon administration</title>
    <link rel="stylesheet" media="screen" type="text/css" href="default.css" />
    <script>
    window.onload = function(){
        var formManage = document.getElementById('frmPurge');
        formManage.onsubmit = function(){
            return confirm('Are you sure you want to purge the cache?');
        }
    }
    </script>
</head>

<body id="admin-admin">
    <div id="page">
        <div id="header">
                if (!isset($person['delete'])) {
                    $newOpml->entries[] = $person;
                }
            } else {
                $newOpml->entries[] = $person;
            }
        }
    }
    // Add feed
    if (isset($_POST['add'])) {
        if ('http://' != $_POST['url']) {
            //autodiscover feed
            $feed = new SimplePie();
            $feed->enable_cache(false);
            $feed->set_feed_url($_POST['url']);
            $feed->init();
            $feed->handle_content_type();
            $person['name'] = $feed->get_title();
            $person['website'] = $feed->get_permalink();
            $person['feed'] = $feed->feed_url;
            $oldOpml->entries[] = $person;
            $newOpml->entries = $oldOpml->entries;
        }
    }
    // Backup old OPML
    OpmlManager::backup(dirname(__FILE__) . '/../custom/people.opml');
    // Save new OPML
    OpmlManager::save($newOpml, dirname(__FILE__) . '/../custom/people.opml');
}
header("Location: index.php");
die;
<?php

require_once __DIR__ . '/../app/app.php';
require_once __DIR__ . '/inc/auth.inc.php';
$opml = OpmlManager::load(__DIR__ . '/../custom/people.opml');
$opml_people = $opml->getPeople();
$page_id = 'admin-admin';
$header_extra = <<<HTML
    <script>
    window.onload = function(){
        var formManage = document.getElementById('frmPurge');
        formManage.onsubmit = function(){
            return confirm("{$l10n->getString('Are you sure you want to purge the cache?')}");
        }
    }
    </script>

HTML;
$page_content = <<<FRAGMENT

            <div class="widget">
                <h3>{$l10n->getString('Clear cache')}</h3>
                <form action="purgecache.php" method="post" id="frmPurge">
                    <p><label>{$l10n->getString('Clear cache:')}</label><input type="submit" class="submit delete" name="purge" id="purge" value="{$l10n->getString('Clear')}" /></p>
                    <p class="help">{$l10n->getString('Clearing the cache will make moonmoon reload all feeds.')}</p>
                </form>
            </div>

            <div class="widget">
                <h3>{$l10n->getString('Change administrator password')}</h3>
                <form action="changepassword.php" method="post" id="frmPassword">
 /**
  * Load people from an OPML
  * @return integer Number of people loaded
  */
 function loadOpml($file)
 {
     if (!is_file($file)) {
         $this->errors[] = new PlanetError(3, $file . ' is missing.');
         return 0;
     }
     $opml = OpmlManager::load($file);
     $opml_people = $opml->getPeople();
     foreach ($opml_people as $opml_person) {
         $this->addPerson(new PlanetPerson($opml_person['name'], $opml_person['feed'], $opml_person['website']));
     }
     return count($opml_people);
 }
Exemple #5
0
 /**
  * Download
  * @var $max_load percentage of feeds to load
  */
 public function download($max_load = 0.1)
 {
     $max_load_feeds = ceil(count($this->people) * $max_load);
     $opml = OpmlManager::load(__DIR__ . '/../../custom/people.opml');
     foreach ($this->people as $feed) {
         //Avoid mass loading with variable cache duration
         //$feed->set_cache_duration($this->config->getCacheTimeout()+rand(0,30));
         $feed->set_cache_duration($this->config->getCacheTimeout());
         //Load only a few feeds, force other to fetch from the cache
         if (0 > $max_load_feeds--) {
             $feed->set_timeout(-1);
             $this->errors[] = new PlanetError(1, 'Forced from cache : ' . $feed->getFeed());
         }
         //Load feed
         $feed->init();
         $isDown = '';
         // http://simplepie.org/wiki/reference/simplepie/merge_items ?
         //Add items to index
         if ($feed->data && $feed->get_item_quantity() > 0) {
             $items = $feed->get_items();
             $this->items = array_merge($this->items, $items);
         } else {
             $this->errors[] = new PlanetError(1, 'No items : ' . $feed->getFeed());
             $isDown = '1';
         }
         //Mark if the feed is temporary unavailable
         foreach ($opml->entries as $key => $entrie) {
             if ($feed->getFeed() === $entrie['feed']) {
                 $opml->entries[$key]['isDown'] = $isDown;
             }
         }
     }
     OpmlManager::save($opml, __DIR__ . '/../../custom/people.opml');
 }
                    $newOpml->entries[] = $person;
                }
            } else {
                $newOpml->entries[] = $person;
            }
        }
    }
    // Add feed
    if (isset($_POST['add'])) {
        if ('http://' != $_POST['url']) {
            //autodiscover feed
            $feed = new SimplePie();
            $feed->enable_cache(false);
            $feed->set_feed_url($_POST['url']);
            $feed->init();
            $feed->handle_content_type();
            $person['name'] = $feed->get_title();
            $person['website'] = $feed->get_permalink();
            $person['feed'] = $feed->feed_url;
            $person['isDown'] = '0';
            $oldOpml->entries[] = $person;
        }
        $newOpml->entries = $oldOpml->entries;
    }
    // Backup old OPML
    OpmlManager::backup(__DIR__ . '/../custom/people.opml');
    // Save new OPML
    OpmlManager::save($newOpml, __DIR__ . '/../custom/people.opml');
}
header("Location: index.php");
die;