Permalink
Browse files

fixed #2 and #22

  • Loading branch information...
1 parent 6baa13f commit 71bb931bb5d9741d52665ff3877a6c53004dd6af @remiprev remiprev committed Oct 14, 2009
View
@@ -1,6 +1,7 @@
<?php
define( 'PUBWICH_CRON', true );
+ define( 'PUBWICH', 1 );
require( dirname(__FILE__) . '/../lib/Pubwich.php');
Pubwich::init();
View
@@ -2,6 +2,7 @@
// $Id$
+ define( 'PUBWICH', 1 );
require( dirname(__FILE__) . '/lib/Pubwich.php' );
Pubwich::init();
Pubwich::renderTemplate();
View
@@ -1,4 +1,6 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
+
/**
* Récupérateur de contenu provenant de fichiers à distance
*
View
@@ -1,4 +1,5 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
define( 'PUBWICH_VERSION', 'trunk' );
@@ -68,6 +69,7 @@ static public function init() {
// Events logger (and first message)
require('PubwichLog.php');
+ PubwichLog::init();
PubwichLog::log( 1, Pubwich::_("Pubwich object initialization") );
// Theme
View
@@ -1,4 +1,5 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
/**
* @classname PubwichErreur
View
@@ -1,31 +1,43 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
/**
* @classname PubwichLog
+ * @author remi (exomel.com)
*
* Niveau 1 : Informations générales
* Niveau 2 : Informations détaillées
* Niveau 3 : ???
*/
class PubwichLog {
- static public function log( $level, $msg ) {
+ static private $file;
+
+ static public function init() {
+
+ if ( PUBWICH_LOGTOFILE === true && PUBWICH_LOGLEVEL > 0 ) {
+ $log_dir = dirname(__FILE__).'/../logs';
+ if ( !is_dir( $log_dir ) ) {
+ mkdir( $log_dir );
+ }
+ $log_file = $log_dir . '/pubwich-'.date('Y-m-d').'.log';
+ self::$file = fopen($log_file, 'a+');
+ // what will happen if several sessions are started simultaneously?
+ //self::log( 0, '----[ Log for Pubwich session ('.date('Y-m-d h:i:s').') ]-----------------------------', true );
+ }
+
+ }
+
+ static public function log( $level, $msg, $nodate=false ) {
if ( $level <= PUBWICH_LOGLEVEL ) {
if ( !PUBWICH_LOGTOFILE ) {
echo $msg . "<br />\n";
} else {
- /*
- $log_file = dirname(__FILE__).'/../logs/pubwich-'.date('Y-m-d').'.log';
- $fh = fopen($log_file, 'a');
- if ( !$fh ) { return false; }
- $stringData = Date('Y m d h:i:s').' '. $msg ."\n";
- fwrite($fh, $stringData);
- fclose($fh);
- */
+ $stringData = ($nodate === true) ? $msg ."\n" : Date('Y-m-d h:i:s').' '. $msg ."\n";
+ fwrite(self::$file, $stringData);
}
}
-
}
}
View
@@ -1,4 +1,5 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
/**
* @classname PubwichTemplate
View
@@ -1,4 +1,6 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
+
/**
* @classname Atom
* @description Fetch Atom feeds
@@ -18,7 +20,6 @@ public function __construct( $config ){
}
/**
- * Surcharge de parent::getData()
* @return SimpleXMLElement
*/
public function getData() {
@@ -27,7 +28,6 @@ public function getData() {
}
/**
- * Retourne un item formatté selon le gabarit
* @return array
*/
public function populateItemTemplate( &$item ) {
@@ -1,4 +1,6 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
+
/**
* @classname Delicious
* @description Fetch Del.icio.us bookmarks
@@ -1,4 +1,6 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
+
/**
* @classname Facebook
* @description Fetch Facebook statuses
View
@@ -1,4 +1,6 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
+
/**
* @classname Flickr
* @description Retreives photos from Flickr
View
@@ -1,4 +1,6 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
+
/**
* @classname LastFM
* @description Fetch data from Last.fm
@@ -95,7 +97,7 @@ public function buildCache() {
}
/**
- * @param bool $rebuildCache Si vrai, force la reconstruction du cache
+ * @param bool $rebuildCache Force cache rebuild
* @return void
*/
public function buildAlbumCache( $rebuildCache ) {
@@ -112,7 +114,7 @@ public function buildAlbumCache( $rebuildCache ) {
/**
* @param SimpleXMLElement $album
- * [@param bool $rebuildCache Si vrai, force la reconstruction du cache]
+ * [@param bool $rebuildCache]
* @return void
*/
public function fetchAlbum($album, $rebuildCache=false) {
@@ -174,7 +176,7 @@ public function populateItemTemplate( &$item ) {
}
/**
- * @var $albumdata Contient les informations relatives aux albums
+ * @var $albumdata
*/
public $albumdata;
@@ -206,5 +208,4 @@ public function init() {
return $this;
}
-
}
View
@@ -1,4 +1,6 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
+
/**
* @classname RSS
* @description Fetch RSS feeds
@@ -12,15 +14,12 @@ class RSS extends Service {
public function __construct( $config ){
$this->setURL( $config['url'] );
$this->total = $config['total'];
-
$this->setItemTemplate('<li><a href="{%link%}">{%title%}</a> {%date%}</li>'."\n");
$this->setURLTemplate( $config['link'] );
-
parent::__construct( $config );
}
/**
- * Surcharge de parent::getData()
* @return SimpleXMLElement
*/
public function getData() {
@@ -29,7 +28,6 @@ public function getData() {
}
/**
- * Retourne un item formatté selon le gabarit
* @return array
*/
public function populateItemTemplate( &$item ) {
@@ -1,4 +1,6 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
+
/**
* @classname Readernaut
* @description Fetch Readernaut books
@@ -39,10 +41,8 @@ class ReadernautBooks extends Readernaut {
public function __construct( $config ){
parent::setVariables( $config );
$this->setURL( sprintf( 'http://readernaut.com/api/v1/xml/%s/books/?order_by=-created', $config['username'] ) );
-
$this->setItemTemplate('<li><a class="clearfix" href="{%link%}"><img src="{%image%}" width="{%size%}" alt="{%title%}" /><strong><span>{%title%}</span> {%author%}</strong></a></li>'."\n");
$this->setURLTemplate('http://www.readernaut.com/'.$config['username'].'/books/');
-
parent::__construct( $config );
}
@@ -55,7 +55,6 @@ public function getData() {
}
/**
- * Retourne un item formatté selon le gabarit
* @return array
*/
public function populateItemTemplate( &$item ) {
@@ -85,10 +84,8 @@ class ReadernautNotes extends Readernaut {
public function __construct( $config ){
parent::setVariables( $config );
$this->setURL( sprintf( 'http://readernaut.com/api/v1/xml/%s/notes/?order_by=-created', $config['username'] ) );
-
$this->setItemTemplate('<li><a class="clearfix" href="{%link%}"><img src="{%image%}" width="{%size%}" alt="{%title%}" /><strong><span>{%title%}</span> {%author%}</strong></a>{%body%}</li>'."\n");
$this->setURLTemplate('http://www.readernaut.com/'.$config['username'].'/notes/');
-
parent::__construct( $config );
}
@@ -101,10 +98,10 @@ public function getData() {
}
/**
- * Retourne un item formatté selon le gabarit
* @return array
*/
public function populateItemTemplate( &$item ) {
+ // yep, this is actually book_edtion. Readernaut's creator Nathan Borror has been notified about this type :)
return array(
'id' => $item->reader_book_id,
'link' => $item->book_edtion->permalink,
View
@@ -1,4 +1,5 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
/**
* @classname Service
@@ -128,23 +129,23 @@ public function getVariable() {
}
/**
- * @param string $variable Le nom de la variable
+ * @param string $variable
* @return void
*/
public function setVariable( $variable ) {
$this->variable = $variable;
}
/**
- * @param string $template Le template
+ * @param string $template
* @return void
*/
public function setURLTemplate( $template ) {
$this->urlTemplate = $template;
}
/**
- * @param string $template Le template
+ * @param string $template
* @return void
*/
public function setItemTemplate( $template ) {
@@ -163,7 +164,7 @@ public function getItemTemplate() {
}
/**
- * @param string $template Le template
+ * @param string $template
*/
public function setBoxTemplate( $template ) {
if ( !$this->boxTemplate ) {
@@ -181,7 +182,7 @@ public function getBoxTemplate() {
}
/*
- * @param Service &$classe La référence de l’instancedu service à afficher
+ * @param Service &$classe
* @return string
*/
public function renderBox( ) {
View
@@ -1,5 +1,13 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
+ /**
+ * @classname Text
+ * @description Display a simple text block
+ * @version 1.1 (20090929)
+ * @author Rémi Prévost (exomel.com)
+ * @methods None
+ */
class Text extends Service {
public function __construct( $config ){
@@ -18,15 +26,13 @@ public function __construct( $config ){
}
/**
- * Surcharge de parent::getData()
* @return SimpleXMLElement
*/
public function getData() {
return array( $this->text );
}
/**
- * Retourne un item formatté selon le gabarit
* @return array
*/
public function populateItemTemplate( &$item ) {
View
@@ -1,4 +1,6 @@
<?php
+ defined('PUBWICH') or die('No direct access allowed.');
+
/**
* @classname Twitter
* @description Retrieves statuses from Twitter
View
@@ -0,0 +1 @@
+Deny from all

0 comments on commit 71bb931

Please sign in to comment.