summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--app/app.php17
-rw-r--r--cron.php15
-rw-r--r--index.php30
-rw-r--r--postload.php13
5 files changed, 24 insertions, 52 deletions
diff --git a/.gitignore b/.gitignore
index 8d8bfc3..6d4215f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
custom/config.yml
+custom/people.opml
cache/*
diff --git a/app/app.php b/app/app.php
new file mode 100644
index 0000000..cd24c51
--- /dev/null
+++ b/app/app.php
@@ -0,0 +1,17 @@
+<?php
+
+//Debug ?
+$debug = isset($_GET['debug']) ? $_GET['debug'] : 0;
+if ($debug) {
+ error_reporting(E_ALL);
+} else {
+ error_reporting(0);
+}
+
+include_once(dirname(__FILE__).'/classes/Planet.class.php');
+
+if (is_file(dirname(__FILE__).'/../custom/config.yml')){
+ $conf = Spyc::YAMLLoad(dirname(__FILE__).'/../custom/config.yml');
+ $PlanetConfig = new PlanetConfig($conf);
+ $Planet = new Planet($PlanetConfig);
+}
diff --git a/cron.php b/cron.php
index 6ff46ae..1098e9b 100644
--- a/cron.php
+++ b/cron.php
@@ -1,18 +1,5 @@
<?php
-include_once(dirname(__FILE__).'/app/classes/Planet.class.php');
-include_once(dirname(__FILE__).'/app/lib/Cache.php');
-include_once(dirname(__FILE__).'/app/lib/lib.http.php');
-
-//Load configuration
-if (is_file(dirname(__FILE__).'/custom/config.yml')){
- $conf = Spyc::YAMLLoad(dirname(__FILE__).'/custom/config.yml');
- $PlanetConfig = new PlanetConfig($conf);
-} else {
- die('Config file (custom/config.yml) is missing.');
-}
-
-//Instantiate app
-$Planet = new Planet($PlanetConfig);
+include_once(dirname(__FILE__).'/app/app.php');
//Load OPML
if (0 < $Planet->loadOpml(dirname(__FILE__).'/custom/people.opml')) {
diff --git a/index.php b/index.php
index a92cbaf..cf23238 100644
--- a/index.php
+++ b/index.php
@@ -1,28 +1,12 @@
<?php
-$bench['start'] = microtime(true);
+include_once(dirname(__FILE__).'/app/app.php');
+include_once(dirname(__FILE__).'/app/lib/Cache.php');
-$debug = isset($_GET['debug']) ? $_GET['debug'] : 0;
-if ($debug) {
- error_reporting(E_ALL);
-} else {
- error_reporting(0);
-}
-
-include_once(dirname(__FILE__).'/app/classes/Planet.class.php');
-include_once(dirname(__FILE__).'/app/lib/Cache.php');
-
-//Load configuration
-if (is_file(dirname(__FILE__).'/custom/config.yml')){
- $conf = Spyc::YAMLLoad(dirname(__FILE__).'/custom/config.yml');
- $PlanetConfig = new PlanetConfig($conf);
-} else {
+//Installed ?
+if (!isset($Planet)) {
echo '<p>You might want to <a href="install.php">install moonmoon</a>.</p>';
exit;
}
-
-//Instantiate app
-$Planet = new Planet($PlanetConfig);
-$bench['codeloaded'] = microtime(true);
//Load from cache
$items = Array();
@@ -30,7 +14,6 @@ if (0 < $Planet->loadOpml(dirname(__FILE__).'/custom/people.opml')) {
$Planet->loadFeeds();
$items = $Planet->getItems();
}
-$bench['contentloaded'] = microtime(true);
//Prepare output cache
Cache::$enabled = false;
@@ -51,11 +34,6 @@ if (!OutputCache::Start($_GET['type'], $cache_key, $cache_duration)) {
OutputCache::End();
}
-$bench['contentdisplayed'] = microtime(true);
-
-echo "<!-- Load code: ".($bench['codeloaded'] - $bench['start'])." -->";
-echo "<!-- Load content: ".($bench['contentloaded'] - $bench['codeloaded'])." -->";
-echo "<!-- Display: ".($bench['contentdisplayed'] - $bench['contentloaded'])." -->";
echo "<!--";
var_dump($Planet->errors);
echo "-->"; \ No newline at end of file
diff --git a/postload.php b/postload.php
index de23799..281c4f7 100644
--- a/postload.php
+++ b/postload.php
@@ -1,9 +1,5 @@
<?php
-/**
- * Load one particular feed
- */
-error_reporting(0);
-include_once(dirname(__FILE__).'/app/classes/Planet.class.php');
+include_once(dirname(__FILE__).'/app/app.php');
function unhtmlspecialchars( $string ) {
$string = str_replace ( '&amp;', '&', $string );
@@ -15,13 +11,6 @@ function unhtmlspecialchars( $string ) {
return $string;
}
-//Build config object
-//Use OPML title if no title defined in the config file
-$PlanetConfig = new PlanetConfig(array());
-
-//Instantiate app
-$Planet = new Planet($PlanetConfig);
-
$Planet->addPerson(
new PlanetPerson(
'',