From 686a66aa054f4090f3f7717b1736a3e9f5cac83d Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Sun, 2 Sep 2018 17:59:04 +0200 Subject: [PATCH] Sync gravatar in core and Spartacus. Bump version to 1.63. Signed-off-by: Thomas Hochstein --- serendipity_event_gravatar/ChangeLog | 73 +- .../UTF-8/lang_cs.inc.php | 3 +- .../UTF-8/lang_cz.inc.php | 3 +- .../UTF-8/lang_de.inc.php | 5 +- .../UTF-8/lang_pl.inc.php | 3 +- .../documentation/documentation.css | 13 +- .../documentation_cs.html | 356 ++++---- .../documentation_cz.html | 356 ++++---- .../documentation_de.html | 88 +- serendipity_event_gravatar/lang_cs.inc.php | 3 +- serendipity_event_gravatar/lang_cz.inc.php | 3 +- serendipity_event_gravatar/lang_de.inc.php | 5 +- serendipity_event_gravatar/lang_en.inc.php | 3 +- serendipity_event_gravatar/lang_pl.inc.php | 3 +- .../monsterid/monsterid.php | 12 +- .../serendipity_event_gravatar.php | 817 ++++++++---------- .../wavatars/wavatars.php | 8 +- .../ycon/ycon.image.php | 14 +- serendipity_event_gravatar/ycon/ycon.php | 13 +- 19 files changed, 833 insertions(+), 948 deletions(-) diff --git a/serendipity_event_gravatar/ChangeLog b/serendipity_event_gravatar/ChangeLog index 568de970..f820632d 100644 --- a/serendipity_event_gravatar/ChangeLog +++ b/serendipity_event_gravatar/ChangeLog @@ -1,12 +1,33 @@ -# -Version 1.60: +Version 1.63: +------------------------------------------------------------------------ + * Sync core and Spartacus. + +Version 1.62.2: +------------------------------------------------------------------------ * Add legal information to be used by serendipity_event_dsgvo_gpdr +Version 1.62.1: +------------------------------------------------------------------------ + * Remove defunct mybloglog + +Version 1.61.1: +------------------------------------------------------------------------ + * Workaround PHP < 5.6 bug, not verifying certs, stopping Request2 + +Version 1.61: +------------------------------------------------------------------------ + * Switch plugin to http_request2 + +Version 1.60: +------------------------------------------------------------------------ + * Consistent plugin usage + Version 1.59: +------------------------------------------------------------------------ * Allows other plugins to fetch user metadata via avatar_fetch_userinfos hook. * supports !# twitter links now, too. - + Version 1.57: (brockhaus) * Better Gravatar handling, as the call changed a little * Doesn't accept existing but empty images anymore. @@ -16,7 +37,7 @@ Version 1.56: (brockhaus) * Removed inline styles, added class avatar_right and avatar_left. If not found set in css, the plugin will emit a default style for those two. - + Version 1.55: (brockhaus) ------------------------------------------------------------------------ * Twitter and identica where not fetched correctly if fetched first. @@ -25,7 +46,7 @@ Version 1.54: ------------------------------------------------------------------------ * Made PLUGIN_GRAVATAR_SUPPORTED recognize %s as variable for list of supported services - + Version 1.52: ------------------------------------------------------------------------ * Changed display of supported avatars in the comment area in order @@ -44,7 +65,7 @@ Version 1.48 (brockhaus) ------------------------------------------------------------------------ * FIX: PHP compatibility was broken since 1.46 :-/ * Added Identica Avatar. - This is mainly used for Identica Pingbacks and should be used in + This is mainly used for Identica Pingbacks and should be used in front of Favatar, else the Identica sign will show up. * Code cleanup. @@ -72,7 +93,7 @@ Version 1.44 (brockhaus) * Added buildin wavatar suport. * Support for Gravatar fallbacks identyicon, monsterid and wavatar. * Optimized trackback avatars: Querypars will be stripped from URL. - Now in example S8Y blogs always get the same Avatar cached, not + Now in example S8Y blogs always get the same Avatar cached, not one per trackback. Version 1.43 (brockhaus) @@ -85,7 +106,7 @@ Version 1.43 (brockhaus) Version 1.42 (brockhaus) ------------------------------------------------------------------------ - * Encoded _ in user urls in order to differ them from the + * Encoded _ in user urls in order to differ them from the seperators. urlencode doesn't encode _. Thanks to Tino Schwarze finding and fixing this. @@ -93,12 +114,12 @@ Version 1.41 (garvinhicking) ------------------------------------------------------------------------ * Fixed Last-Modified Header of avatar images. - + Version 1.40 () ------------------------------------------------------------------------ * Added ycon support (mo, http://moblog.wiredwings.com) - + ------------------------------------------------------------------------ Version 1.39 (brockhaus): @@ -126,7 +147,7 @@ Version 1.37 (brockhaus): Version 1.36 (brockhaus): * Added new option: You can define, that the plugin should not - produce avatar image directly but a smarty tag only. If this + produce avatar image directly but a smarty tag only. If this option is switched on, you can define in your comments template, where the avatar should be displayed using the smarty tag $comment.comment_avatar @@ -152,7 +173,7 @@ Version 1.34 (brockhaus): * Gravatars rating doesn't work reliable. My G rated Gravatar is only shown, if I use Gravatar X rating. :-/ - Added an option to switch off Gravatars rating parameter (what + Added an option to switch off Gravatars rating parameter (what should be the same as using X rating) ------------------------------------------------------------------------ @@ -176,7 +197,7 @@ Version 1.31 (brockhaus): ------------------------------------------------------------------------ Version 1.30 (brockhaus): - * Standard Avatar was not displayed in subdirectory blog + * Standard Avatar was not displayed in subdirectory blog installtions. * Gravatar link was slightly wrong (but working) @@ -194,7 +215,7 @@ Version 1.28 (brockhaus): ------------------------------------------------------------------------ Version 1.27 (brockhaus): - * If the writer entered his url as www.domain.de instead of + * If the writer entered his url as www.domain.de instead of http://www.domain.de, the Avatar was not always loaded correctly ------------------------------------------------------------------------ @@ -219,7 +240,7 @@ Version 1.24 (brockhaus): ------------------------------------------------------------------------ Version 1.23 (brockhaus): - * While fresh fetching P/Favatars, the Plugin will only accept + * While fresh fetching P/Favatars, the Plugin will only accept responses declared as image by the remote server. This will prevent accepting potential error html pages as Avatar images. @@ -278,7 +299,7 @@ Version 1.14 (brockhaus): ------------------------------------------------------------------------ Version 1.13 (brockhaus): - * Advice changed: It is not the statistic plugin producing not + * Advice changed: It is not the statistic plugin producing not working Pavatars/Favatars but the exit tracking plugin. ------------------------------------------------------------------------ @@ -290,7 +311,7 @@ Version 1.12 (brockhaus): found, are supported now, too. Former the Avatar Plugin assumed, that the default page is the P/Favatar. - * Default configuration now ordered like this: Gravatar -> Pavatar + * Default configuration now ordered like this: Gravatar -> Pavatar -> Favatar -> Default Avatar. * Added advice, that this plugin has to be executed before any link @@ -310,13 +331,13 @@ Version 1.11, testing version not released to CVS/Spartacus (brockhaus): Version 1.10 (brockhaus): * Pavatar / Avatar information where never loaded from cache - + * .. but after beeing loaded from cache it produced an endless request loop for images loaded from the local blog (if comment sidebar plugin was enabled) * Height setting for image was called "heigth".. :-/ - + * Gravarar caching didn't work reliable, if a default avatar was given. @@ -337,7 +358,7 @@ Version 1.8 (brockhaus): Version 1.7 (brockhaus): * Added support for Pavatars (www.pavatar.com) - + * Added support for MyBlogLog Avatars (www.mybloglog.com) * The order for trying avatar methods and what kind of avatars are @@ -349,22 +370,22 @@ Version 1.7 (brockhaus): is defined. (We want less dataprofiles..) * Fetch default avatar via mediadatabase in the configuration. - + * Image size is assured now in HTML code. - + * Below the comment only actual configured avatar methods are shown as supported. ------------------------------------------------------------------------ -Version 1.6 (garvinhickins): +Version 1.6 (garvinhickins): ------------------------------------------------------------------------ -Version 1.5 (garvinhickins): +Version 1.5 (garvinhickins): ------------------------------------------------------------------------ -Version 1.4 (garvinhickins): +Version 1.4 (garvinhickins): ------------------------------------------------------------------------ -Version 1.3 (garvinhickins): +Version 1.3 (garvinhickins): * Fix errors on invalid domains diff --git a/serendipity_event_gravatar/UTF-8/lang_cs.inc.php b/serendipity_event_gravatar/UTF-8/lang_cs.inc.php index f2690be6..e31d5f09 100644 --- a/serendipity_event_gravatar/UTF-8/lang_cs.inc.php +++ b/serendipity_event_gravatar/UTF-8/lang_cs.inc.php @@ -59,4 +59,5 @@ @define('PLUGIN_EVENT_GRAVATAR_FALLBACK', 'Gravatar fallback'); @define('PLUGIN_EVENT_GRAVATAR_FALLBACK_DESC', 'Gravatar má implementovaných několik návratových metod pro případ, že pro požadovaného uživatele není znám žádný avatar. Implementovány jsou též Moster ID, Identicon a Wavatar. Pokud vyberete některý z těchto zíněných, nebudou uskutečňovány žádné další pokusy o načtení avataru, pokud uživatel zadá email.'); @define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS', 'Vždy návratová hodnota pro Gravatar'); -@define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS_DESC', 'Používat návratovou hodnotu Gravatar i v případě, že uživatel nezadá email (zadá tedy url nebo jméno)'); \ No newline at end of file +@define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS_DESC', 'Používat návratovou hodnotu Gravatar i v případě, že uživatel nezadá email (zadá tedy url nebo jméno)'); + diff --git a/serendipity_event_gravatar/UTF-8/lang_cz.inc.php b/serendipity_event_gravatar/UTF-8/lang_cz.inc.php index f2690be6..e31d5f09 100644 --- a/serendipity_event_gravatar/UTF-8/lang_cz.inc.php +++ b/serendipity_event_gravatar/UTF-8/lang_cz.inc.php @@ -59,4 +59,5 @@ @define('PLUGIN_EVENT_GRAVATAR_FALLBACK', 'Gravatar fallback'); @define('PLUGIN_EVENT_GRAVATAR_FALLBACK_DESC', 'Gravatar má implementovaných několik návratových metod pro případ, že pro požadovaného uživatele není znám žádný avatar. Implementovány jsou též Moster ID, Identicon a Wavatar. Pokud vyberete některý z těchto zíněných, nebudou uskutečňovány žádné další pokusy o načtení avataru, pokud uživatel zadá email.'); @define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS', 'Vždy návratová hodnota pro Gravatar'); -@define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS_DESC', 'Používat návratovou hodnotu Gravatar i v případě, že uživatel nezadá email (zadá tedy url nebo jméno)'); \ No newline at end of file +@define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS_DESC', 'Používat návratovou hodnotu Gravatar i v případě, že uživatel nezadá email (zadá tedy url nebo jméno)'); + diff --git a/serendipity_event_gravatar/UTF-8/lang_de.inc.php b/serendipity_event_gravatar/UTF-8/lang_de.inc.php index 83d2bd2e..53708b1a 100644 --- a/serendipity_event_gravatar/UTF-8/lang_de.inc.php +++ b/serendipity_event_gravatar/UTF-8/lang_de.inc.php @@ -1,4 +1,4 @@ -Monster ID avatars are localy created monster images unique for each writer.'); @define('PLUGIN_EVENT_GRAVATAR_EXTLING_WARNING', 'CAUTION! This plugin has to be executed before any plugin changing links (like i.e. the exit tracking plugin)! ' . 'Else Pavatars, Favatars and MayBlogLog avatars won\'t work!'); + diff --git a/serendipity_event_gravatar/documentation/documentation.css b/serendipity_event_gravatar/documentation/documentation.css index 8e08128d..344109bb 100644 --- a/serendipity_event_gravatar/documentation/documentation.css +++ b/serendipity_event_gravatar/documentation/documentation.css @@ -1,11 +1,12 @@ body { - font-family: Arial, sans-serif!important; - margin: 20; + font-family: Arial, sans-serif!important; + margin: 20; } #title { - background: #cfcfcf; + background: #cfcfcf; margin: 0; -}#content { - background: #efefef; +} +#content { + background: #efefef; margin: 0; -} \ No newline at end of file +} diff --git a/serendipity_event_gravatar/documentation_cs.html b/serendipity_event_gravatar/documentation_cs.html index b07b967c..8ebae732 100644 --- a/serendipity_event_gravatar/documentation_cs.html +++ b/serendipity_event_gravatar/documentation_cs.html @@ -49,7 +49,7 @@
  • Vdy vyadovat Gravatar Fallback
  • -
  • ChangeLog (historie verz)
  • +
  • ChangeLog (historie verz)
  • @@ -200,232 +200,232 @@ Avatary Identicon (identikony) jsou generov

    nahoru

    diff --git a/serendipity_event_gravatar/documentation_cz.html b/serendipity_event_gravatar/documentation_cz.html index c12ae4b7..64f284ca 100644 --- a/serendipity_event_gravatar/documentation_cz.html +++ b/serendipity_event_gravatar/documentation_cz.html @@ -49,7 +49,7 @@
  • Vdy vyadovat Gravatar Fallback
  • -
  • ChangeLog (historie verz)
  • +
  • ChangeLog (historie verz)
  • @@ -200,232 +200,232 @@ Avatary Identicon (identikony) jsou generov

    nahoru

    diff --git a/serendipity_event_gravatar/documentation_de.html b/serendipity_event_gravatar/documentation_de.html index 48f9e811..f2668cd8 100644 --- a/serendipity_event_gravatar/documentation_de.html +++ b/serendipity_event_gravatar/documentation_de.html @@ -49,97 +49,72 @@

    Überblick

    -

    Mit dem Avatar Plugin kann man Kommentatoren in seinem Blog "ein Gesicht" geben. -Für jeden einzelnen Kommentator im Blog wird ein so genanntes Avatar zur Verfügung gestellt, das ihn repräsentiert. -Dafür werden unterschiedliche Mechanismen angeboten, die nacheinander durchprobiert werden, ob sie ein Avatar für -den Kommentator liefern.

    -

    Der erste Mechanismus, der ein Avatar findet, wird benutzt, nachfolgende Mechanismen -dann nicht mehr ausprobiert. Dies bedeutet, dass man die Methoden so sortieren sollte, dass die am meisten bevorzugte -zuerst ausprobiert wird. Methoden, die auf jeden Fall immer ein Avatar liefern, sollten als letzte konfiguriert werden, -da nach diesen natürlich keine weiteren Methoden ausprobiert werden. -

    -

    Wichtig: Dieses Plugin muss vor allen Plugins in der Liste stehen, die Links verändern, wie -z.B. das "Exit Tracking Plugin". Ansonsten können Avatare, die auf den Links der Kommentatoren beruhen, nicht -funktionieren.

    +

    Mit dem Avatar Plugin kann man Kommentatoren in seinem Blog "ein Gesicht" geben. Für jeden einzelnen Kommentator im Blog wird ein so genanntes Avatar zur Verfügung gestellt, das ihn repräsentiert. Dafür werden unterschiedliche Mechanismen angeboten, die nacheinander durchprobiert werden, ob sie ein Avatar für den Kommentator liefern.

    +

    Der erste Mechanismus, der ein Avatar findet, wird benutzt, nachfolgende Mechanismen dann nicht mehr ausprobiert. Dies bedeutet, dass man die Methoden so sortieren sollte, dass die am meisten bevorzugte zuerst ausprobiert wird. Methoden, die auf jeden Fall immer ein Avatar liefern, sollten als letzte konfiguriert werden, da nach diesen natürlich keine weiteren Methoden ausprobiert werden.

    +

    Wichtig: Dieses Plugin muss vor allen Plugins in der Liste stehen, die Links verändern, wie z.B. das "Exit Tracking Plugin". Ansonsten können Avatare, die auf den Links der Kommentatoren beruhen, nicht funktionieren.

    Hier folgt eine Beschreibung der aktuell verfügbaren Mechanismen, ein Avatar für einen Kommentator zu ermitteln:

    top

    Gravatar

    -

    Gravatar ist einer der bekanntesten Services für Benutzer Avatare. -Benutzer können sich bei diesem Service mit einer EMail registrieren und für sich ein Avatar Bild hinterlegen

    -

    Gravatare sind also von der vom Kommentator eingegebenen EMail abhängig. Nur wenn eine solche angegeben wurde, kann -ermittelt werden, ob für diese ein Avatar beim Gravatar Service hinterlegt wurde.

    +

    Gravatar ist einer der bekanntesten Services für Benutzer Avatare. Benutzer können sich bei diesem Service mit einer EMail registrieren und für sich ein Avatar Bild hinterlegen

    +

    Gravatare sind also von der vom Kommentator eingegebenen EMail abhängig. Nur wenn eine solche angegeben wurde, kann ermittelt werden, ob für diese ein Avatar beim Gravatar Service hinterlegt wurde.

    top

    Pavatar

    -

    Pavatare sind Avatare (Bilddateien), die der Schreber genau -für diesen Zweck auf seiner Homepage hinterlegt hat.

    -

    Im Gegensatz zu den recht ähnlichen Favataren kann man hier also ein eigenes Avatar Bild -mit einer beliebigen Auflösung hinterlegen.

    -

    Hier wird anhand der vom Kommentator angegebenen Homepage ermittelt, ob diese ein Pavatar liefert. Pavatare sind -also nur ladbar, wenn der Kommentator eine Homepage angegeben hat

    +

    Pavatare sind Avatare (Bilddateien), die der Schreber genau für diesen Zweck auf seiner Homepage hinterlegt hat.

    +

    Im Gegensatz zu den recht ähnlichen Favataren kann man hier also ein eigenes Avatar Bild mit einer beliebigen Auflösung hinterlegen.

    +

    Hier wird anhand der vom Kommentator angegebenen Homepage ermittelt, ob diese ein Pavatar liefert. Pavatare sind also nur ladbar, wenn der Kommentator eine Homepage angegeben hat

    top

    Favatar

    Dies ist ein Konzept mit dem viele Hompage Besitzer automatisch einen Avatar haben, ohne dass sie dafür irgendetwas tun müssen:

    -

    Das Blog holt sich hier einfach das favicon der Homepage, die der Benutzer als seine URL angegeben hat. -Dafür ist das favicon aber eben ein Icon und somit normaler Weise auch recht klein und nicht immer als Avatar geeignet.

    +

    Das Blog holt sich hier einfach das favicon der Homepage, die der Benutzer als seine URL angegeben hat. Dafür ist das favicon aber eben ein Icon und somit normaler Weise auch recht klein und nicht immer als Avatar geeignet.

    top

    Twitter

    -

    Falls der Kommentator als URL ein Twitter Profil angegeben hat, dann wird versucht, hier das Profilbild für diesen -Benutzer zu laden.

    -

    Anmerkung: Falls auch Favatare geladen werden sollen, dann muss Twitter vor diesen versucht werden, sonst wird das -Favicon von Twitter geladen. Dies kann allerdings auch gewollt sein, um z.B. "Tweetbacks" von Twitter klar zu markieren.

    +

    Falls der Kommentator als URL ein Twitter Profil angegeben hat, dann wird versucht, hier das Profilbild für diesen Benutzer zu laden.

    +

    Anmerkung: Falls auch Favatare geladen werden sollen, dann muss Twitter vor diesen versucht werden, sonst wird das Favicon von Twitter geladen. Dies kann allerdings auch gewollt sein, um z.B. "Tweetbacks" von Twitter klar zu markieren.

    top

    Identica

    -

    Dies ist ein spezielles Avatar für Identica Pingbacks. Es wird versucht, -das Profilbild des Benutzers zu laden, der den Pingback ausgelöst hat.

    -

    Anmerkung: Falls auch Favatare geladen werden sollen, dann muss Identica vor diesen versucht werden, sonst wird das -Favicon von Identica geladen. Dies kann allerdings auch gewollt sein, um z.B. "Tweetbacks" von Identica klar zu markieren.

    +

    Dies ist ein spezielles Avatar für Identica Pingbacks. Es wird versucht, das Profilbild des Benutzers zu laden, der den Pingback ausgelöst hat.

    +

    Anmerkung: Falls auch Favatare geladen werden sollen, dann muss Identica vor diesen versucht werden, sonst wird das Favicon von Identica geladen. Dies kann allerdings auch gewollt sein, um z.B. "Tweetbacks" von Identica klar zu markieren.

    top

    MyBlogLog

    -

    Dies ist wieder ein (dem Gravatar Service sehr ähnlicher) zentraler Service. MyBlogLog ist eigentlich ein Blog Community Service, -aber man kann aus diesem ebenfalls Avatare ermitteln

    -

    Das Vorhandensein eines MyBlogLog Avatars wird über die Homepage Angabe des Kommentators ermittelt. +

    Dies ist wieder ein (dem Gravatar Service sehr ähnlicher) zentraler Service. MyBlogLog ist eigentlich ein Blog Community Service, aber man kann aus diesem ebenfalls Avatare ermitteln

    +

    Das Vorhandensein eines MyBlogLog Avatars wird über die Homepage Angabe des Kommentators ermittelt.

    top

    Wavatar

    -

    Das Wavatar wird dynamisch erzeugt aus der Eingabe von Hompage und EMail des Kommentators. Es liefert für jeden Benutzer ein anderes -aber immer selbes Avatar. Da es immer ein Avatar liefert, werden alle nachfolgenden Avatar Methoden ignoriert. -Wavatare sehen in etwa wie folgt aus:

    +

    Das Wavatar wird dynamisch erzeugt aus der Eingabe von Hompage und EMail des Kommentators. Es liefert für jeden Benutzer ein anderes aber immer selbes Avatar. Da es immer ein Avatar liefert, werden alle nachfolgenden Avatar Methoden ignoriert. Wavatare sehen in etwa wie folgt aus:

    top

    MonsterID

    -

    MonsterID Avatare werden nach dem selben Mechanismus erzeugt, wie Wavatare und Indenticons, hier werden kleine niedliche "Monster" -aus den Benutzer Angaben erzeugt.

    +

    MonsterID Avatare werden nach dem selben Mechanismus erzeugt, wie Wavatare und Indenticons, hier werden kleine niedliche "Monster" aus den Benutzer Angaben erzeugt.

    Genau wie Wavatar und Identicon liefern sie immer einen Avatar für den Kommentator.

    top

    Identicon/YCon

    -

    Identicon werden nach dem selben Mechanismus erzeugt, wie Wavatare und MonsterIDs, sie sehen nur anders aus. Hier werden -abstrakte Gebilde erzeugt.

    +

    Identicon werden nach dem selben Mechanismus erzeugt, wie Wavatare und MonsterIDs, sie sehen nur anders aus. Hier werden abstrakte Gebilde erzeugt.

    Genau wie Wavatar und MonsterID liefern sie immer einen Avatar für den Kommentator.

    top

    Standardavatar

    -

    Die Methode "Standardavatar" liefert immer das selbe Avatar für alle Benutzer. Das Bild, das hier benutzt werden soll, kann -weiter unten konfiguriert werden.

    +

    Die Methode "Standardavatar" liefert immer das selbe Avatar für alle Benutzer. Das Bild, das hier benutzt werden soll, kann weiter unten konfiguriert werden.

    top

    @@ -148,63 +123,62 @@ weiter unten konfiguriert werden.

    Avatar laden über

    Hiermit wird die Reihenfolge festgelegt, in der versucht wird, ein Avatar für den Kommentator zu erzeugen.

    -

    Es gibt derzeit 6 Einschübe, mit denen die Reihenfolge festgelegt wird. Zu beachten ist, dass Methoden, -die auf jeden Fall ein Avatar liefern, alle nachfolgenden Methoden nicht zur Probe bringen.

    +

    Es gibt derzeit 6 Einschübe, mit denen die Reihenfolge festgelegt wird. Zu beachten ist, dass Methoden, die auf jeden Fall ein Avatar liefern, alle nachfolgenden Methoden nicht zur Probe bringen.

    top

    Standard-Avatar

    -

    URL zu ihrem Standard-Avatar. Hier müssen Sie den relativen oder absoluten Pfad bezogen auf ihre Server URL zu ihrem Standard Avatar angeben.

    +

    URL zu ihrem Standard-Avatar. Hier müssen Sie den relativen oder absoluten Pfad bezogen auf ihre Server URL zu ihrem Standard Avatar angeben.

    top

    In der Seitenleiste anzeigen

    -

    Sollen Avatar Bilder auch in der Seitenleiste (letze Kommentare) angezeigt werden?

    +

    Sollen Avatar Bilder auch in der Seitenleiste (letze Kommentare) angezeigt werden?

    top

    Avatar Typ anzeigen

    -

    Wenn angeschaltet, wird eine Zeile unterhalb des Kommentar Editors ausgegeben, die angibt, welche Avatar Typen aktuell unterstützt werden.

    +

    Wenn angeschaltet, wird eine Zeile unterhalb des Kommentar Editors ausgegeben, die angibt, welche Avatar Typen aktuell unterstützt werden.

    top

    Autorenname im ALT Attribut

    -

    Normaler Weise wird der Autorenname im TITLE Attribut des Avatar Bildes angegeben, das ALT Attribut wird mit einem * gefüllt, um das Seitenlayout nicht zu zerstören, wenn der Browser das Bild nicht laden kann. Allerdings wird blinden Lesern das ALT Attribut vorgelesen. Falls Sie diese Leser unterstützen wollen, sollten Sie diese Option einschalten.

    +

    Normaler Weise wird der Autorenname im TITLE Attribut des Avatar Bildes angegeben, das ALT Attribut wird mit einem * gefüllt, um das Seitenlayout nicht zu zerstören, wenn der Browser das Bild nicht laden kann. Allerdings wird blinden Lesern das ALT Attribut vorgelesen. Falls Sie diese Leser unterstützen wollen, sollten Sie diese Option einschalten.

    top

    Smarty Tag erzeugen

    -

    Wenn diese Option eingeschaltet ist, so wird das Avatar Bild nicht direkt in den Kommentar geschrieben, sondern es wird ein Smarty Tag {$comment.avatar} erzeugt, in dem der HTML Code des Images steht. Sie sollten diese Option nur einschalten, wenn sie wissen, dass ihr Template dieses Smarty Tag unterstützt. Ob das der Fall ist, sollten sie einfach ausprobieren.

    +

    Wenn diese Option eingeschaltet ist, so wird das Avatar Bild nicht direkt in den Kommentar geschrieben, sondern es wird ein Smarty Tag {$comment.avatar} erzeugt, in dem der HTML Code des Images steht. Sie sollten diese Option nur einschalten, wenn sie wissen, dass ihr Template dieses Smarty Tag unterstützt. Ob das der Fall ist, sollten sie einfach ausprobieren.

    top

    Ausrichtung

    -

    Mit dieser Option kann die Ausrichtung des Avatars im Kommentar konfiguriert werden, falls sie nicht die Smarty Tag Option verwenden. Bei der Smarty Tag Option muss die Ausrichtung über die entsprechende CSS Klasse im Stylesheet konfiguriert werden.

    +

    Mit dieser Option kann die Ausrichtung des Avatars im Kommentar konfiguriert werden, falls sie nicht die Smarty Tag Option verwenden. Bei der Smarty Tag Option muss die Ausrichtung über die entsprechende CSS Klasse im Stylesheet konfiguriert werden.

    top

    Bildgröße

    -

    Maximal dargestellte Größe des Avatar-Bildes in Pixeln

    +

    Maximal dargestellte Größe des Avatar-Bildes in Pixeln

    top

    Cache Zeit

    -

    Wenn Avatare zwischengespeichert werden sollen (empfohlen!), muss hier die Anzahl der Stunden eingetragen werden, die Bilder vom eigenen Server anstatt vom externen Service abgeholt werden sollen. Dies wird mehr Traffic auf diesem Blog Server verursachen, dafür macht es die Avatar Darstellung unabhängiger vom externen zentralen Server. "0" stellt das Zwischenspeichern ab.

    +

    Wenn Avatare zwischengespeichert werden sollen (empfohlen!), muss hier die Anzahl der Stunden eingetragen werden, die Bilder vom eigenen Server anstatt vom externen Service abgeholt werden sollen. Dies wird mehr Traffic auf diesem Blog Server verursachen, dafür macht es die Avatar Darstellung unabhängiger vom externen zentralen Server. "0" stellt das Zwischenspeichern ab.

    top

    Gravatar Indizierung

    -

    Kinderschutz :)

    +

    Kinderschutz :)

    top

    Gravatar Fallback

    -

    Gravatar implementiert einige eigene Fallback Methoden für den Fal, dass kein Gravatar für den Benutzer gefunden wurde. Es wurde ebenso Moster ID, Identicon und Wavatar. Wenn Du einen dieser Fallbacks einstellst, so wird keine weitere Methode nach Gravatar versucht, falls der Benutzer eine EMail angegeben hat.

    +

    Gravatar implementiert einige eigene Fallback Methoden für den Fal, dass kein Gravatar für den Benutzer gefunden wurde. Es wurde ebenso Moster ID, Identicon und Wavatar. Wenn Du einen dieser Fallbacks einstellst, so wird keine weitere Methode nach Gravatar versucht, falls der Benutzer eine EMail angegeben hat.

    top

    Gravatar Fallback immer benutzen

    -

    Gravatar Fallbacks auch dann benutzen, wenn der Benutzer keine EMail (aber eine URL oder einen Namen) eingegeben hat.

    +

    Gravatar Fallbacks auch dann benutzen, wenn der Benutzer keine EMail (aber eine URL oder einen Namen) eingegeben hat.

    top

    diff --git a/serendipity_event_gravatar/lang_cs.inc.php b/serendipity_event_gravatar/lang_cs.inc.php index dca79ec0..24941d51 100644 --- a/serendipity_event_gravatar/lang_cs.inc.php +++ b/serendipity_event_gravatar/lang_cs.inc.php @@ -59,4 +59,5 @@ @define('PLUGIN_EVENT_GRAVATAR_FALLBACK', 'Gravatar fallback'); @define('PLUGIN_EVENT_GRAVATAR_FALLBACK_DESC', 'Gravatar m implementovanch nkolik nvratovch metod pro ppad, e pro poadovanho uivatele nen znm dn avatar. Implementovny jsou t Moster ID, Identicon a Wavatar. Pokud vyberete nkter z tchto znnch, nebudou uskuteovny dn dal pokusy o naten avataru, pokud uivatel zad email.'); @define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS', 'Vdy nvratov hodnota pro Gravatar'); -@define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS_DESC', 'Pouvat nvratovou hodnotu Gravatar i v ppad, e uivatel nezad email (zad tedy url nebo jmno)'); \ No newline at end of file +@define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS_DESC', 'Pouvat nvratovou hodnotu Gravatar i v ppad, e uivatel nezad email (zad tedy url nebo jmno)'); + diff --git a/serendipity_event_gravatar/lang_cz.inc.php b/serendipity_event_gravatar/lang_cz.inc.php index 5194bdb6..a133cb28 100644 --- a/serendipity_event_gravatar/lang_cz.inc.php +++ b/serendipity_event_gravatar/lang_cz.inc.php @@ -59,4 +59,5 @@ @define('PLUGIN_EVENT_GRAVATAR_FALLBACK', 'Gravatar fallback'); @define('PLUGIN_EVENT_GRAVATAR_FALLBACK_DESC', 'Gravatar m implementovanch nkolik nvratovch metod pro ppad, e pro poadovanho uivatele nen znm dn avatar. Implementovny jsou t Moster ID, Identicon a Wavatar. Pokud vyberete nkter z tchto znnch, nebudou uskuteovny dn dal pokusy o naten avataru, pokud uivatel zad email.'); @define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS', 'Vdy nvratov hodnota pro Gravatar'); -@define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS_DESC', 'Pouvat nvratovou hodnotu Gravatar i v ppad, e uivatel nezad email (zad tedy url nebo jmno)'); \ No newline at end of file +@define('PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS_DESC', 'Pouvat nvratovou hodnotu Gravatar i v ppad, e uivatel nezad email (zad tedy url nebo jmno)'); + diff --git a/serendipity_event_gravatar/lang_de.inc.php b/serendipity_event_gravatar/lang_de.inc.php index e04e584a..60d3261d 100644 --- a/serendipity_event_gravatar/lang_de.inc.php +++ b/serendipity_event_gravatar/lang_de.inc.php @@ -1,4 +1,4 @@ -Monster ID avatars are localy created monster images unique for each writer.'); @define('PLUGIN_EVENT_GRAVATAR_EXTLING_WARNING', 'CAUTION! This plugin has to be executed before any plugin changing links (like i.e. the exit tracking plugin)! ' . 'Else Pavatars, Favatars and MayBlogLog avatars won\'t work!'); + diff --git a/serendipity_event_gravatar/monsterid/monsterid.php b/serendipity_event_gravatar/monsterid/monsterid.php index 1370830a..4af69739 100644 --- a/serendipity_event_gravatar/monsterid/monsterid.php +++ b/serendipity_event_gravatar/monsterid/monsterid.php @@ -2,7 +2,7 @@ function build_monster($filename, $seed='',$size=''){ // init random seed - if($seed) srand( hexdec(substr(md5($seed),0,6)) ); + if ($seed) srand( hexdec(substr(md5($seed),0,6)) ); // throw the dice for body parts $parts = array( @@ -31,17 +31,17 @@ function build_monster($filename, $seed='',$size=''){ imagedestroy($im); // color the body - if($part == 'body'){ + if ($part == 'body') { $color = imagecolorallocate($monster, rand(20,235), rand(20,235), rand(20,235)); imagefill($monster,60,60,$color); } } // restore random seed - if($seed) srand(); + if ($seed) srand(); // resize if needed, then output - if($size && $size < 400){ + if ($size && $size < 400) { $out = @imagecreatetruecolor($size,$size); if (!$out) return false; // Problems creating image! imagecopyresampled($out,$monster,0,0,0,0,$size,$size,120,120); @@ -49,10 +49,12 @@ function build_monster($filename, $seed='',$size=''){ imagedestroy($out); imagedestroy($monster); return true; - }else{ + } else { //header ("Content-type: image/png"); imagepng($monster,$filename); imagedestroy($monster); return true; } } + +?> \ No newline at end of file diff --git a/serendipity_event_gravatar/serendipity_event_gravatar.php b/serendipity_event_gravatar/serendipity_event_gravatar.php index 28f8b89a..689d617f 100755 --- a/serendipity_event_gravatar/serendipity_event_gravatar.php +++ b/serendipity_event_gravatar/serendipity_event_gravatar.php @@ -1,20 +1,14 @@ -add('stackable', false); $propbag->add('author', 'Garvin Hicking, Grischa Brockhaus'); $propbag->add('requirements', array( - 'serendipity' => '0.7', + 'serendipity' => '1.6', 'smarty' => '2.6.7', 'php' => '4.1.0' )); $propbag->add('version', PLUGIN_EVENT_GRAVATAR_VERSION); - $propbag->add('groups', array('IMAGES')); - $propbag->add('event_hooks', array( + $propbag->add('groups', array('IMAGES')); + $propbag->add('event_hooks', array( 'frontend_display' => true, 'frontend_comment' => true, 'external_plugin' => true, @@ -78,10 +72,6 @@ class serendipity_event_gravatar extends serendipity_event 'url' => 'http://identi.ca', 'desc' => 'Transmits comment data to retrieve unique avatar for a user.' ), - 'mybloglog' => array( - 'url' => 'http://www.mybloglog.com', - 'desc' => 'Transmits comment data to retrieve unique avatar for a user.' - ), 'monsterid' => array( 'url' => 'http://www.splitbrain.org/go/monsterid', 'desc' => 'Transmits comment data to retrieve unique avatar for a user.' @@ -109,34 +99,32 @@ class serendipity_event_gravatar extends serendipity_event 'transmits_user_input' => true )); - $configuration = array('longdescription','seperator'); - $config_methods = array(); + + $configuration = array('longdescription', 'separator'); + $config_methods = array(); for ($idx=1; $idx<=PLUGIN_EVENT_GRAVATAR_METHOD_MAX; $idx++) { $config_methods[] = "method_$idx"; } - - + $propbag->add('configuration', array_merge($configuration, $config_methods, - array('defaultavatar', 'recent_entries', 'infoline', + array('defaultavatar', 'recent_entries', 'infoline', 'autoralt', 'smartyimage', 'align', 'size', 'cache', 'rating', 'gravatar_fallback','gravatar_fallback_use_always','warning') ) ); } - function introspect_config_item($name, &$propbag) { global $serendipity; - + $types = array( 'gravatar' => "Gravatar", 'favatar' => "Favatar", 'pavatar' => "Pavatar", 'twitter' => "Twitter", 'identica' => "Identica", - 'mybloglog' => "MyBlogLog", 'monsterid' => "Monster ID", 'wavatars' => "Wavatars", 'identicon' => "Identicon/YCon", @@ -155,7 +143,7 @@ class serendipity_event_gravatar extends serendipity_event return true; } } - + $gravatar_fallbacks = array( 'monsterid' => "Monster ID", 'wavatar' => "Wavatar", @@ -163,8 +151,9 @@ class serendipity_event_gravatar extends serendipity_event 'default' => "Gravatar symbol", 'none' => "---", ); - + switch($name) { + case 'smartyimage': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_GRAVATAR_USE_SMARTY); @@ -190,13 +179,16 @@ class serendipity_event_gravatar extends serendipity_event $propbag->add('type', 'content'); $propbag->add('default', PLUGIN_EVENT_GRAVATAR_EXTLING_WARNING); break; + case 'longdescription': $propbag->add('type', 'content'); $propbag->add('default', PLUGIN_EVENT_GRAVATAR_LONG_DESCRIPTION); break; - case 'seperator': - $propbag->add('type', 'seperator'); + + case 'separator': + $propbag->add('type', 'separator'); break; + case 'gravatar_fallback': $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_EVENT_GRAVATAR_FALLBACK); @@ -204,19 +196,16 @@ class serendipity_event_gravatar extends serendipity_event $propbag->add('select_values', $gravatar_fallbacks); $propbag->add('default', 'none'); break; + case 'gravatar_fallback_use_always': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS); $propbag->add('description',PLUGIN_EVENT_GRAVATAR_FALLBACK_ALLWAYS_DESC); $propbag->add('default', false); break; - + case 'defaultavatar': - if (version_compare('1.2',$serendipity['version'])==1) {// 1 if 1.2 higher than actual version number - $propbag->add('type', 'string'); - } else { - $propbag->add('type', 'media'); - } + $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EVENT_GRAVATAR_DEFAULTAVATAR); $propbag->add('description', PLUGIN_EVENT_GRAVATAR_DEFAULTAVATAR_DESC); $propbag->add('default', ''); @@ -247,7 +236,7 @@ class serendipity_event_gravatar extends serendipity_event $propbag->add('type', 'radio'); $propbag->add('name', PLUGIN_EVENT_GRAVATAR_RATING); $propbag->add('description', PLUGIN_EVENT_GRAVATAR_RATING_DESC); - $propbag->add('radio', array( + $propbag->add('radio', array( 'value' => array('-', 'G', 'PG', 'R', 'X'), 'desc' => array(PLUGIN_EVENT_GRAVATAR_RATING_NO,PLUGIN_EVENT_GRAVATAR_RATING_G, PLUGIN_EVENT_GRAVATAR_RATING_PG, PLUGIN_EVENT_GRAVATAR_RATING_R, PLUGIN_EVENT_GRAVATAR_RATING_X) )); @@ -276,20 +265,23 @@ class serendipity_event_gravatar extends serendipity_event $propbag->add('default', false); break; + default: + return false; } - return true; } - function generate_content(&$title) { + function generate_content(&$title) + { $title = PLUGIN_EVENT_GRAVATAR_NAME; } /** * Will be called while saving settings */ - function cleanup() { - // *Always* clean up the cache after changing configuration, else + function cleanup() + { + // *Always* clean up the cache after changing configuration, else // the configuration change will first be seen after cache time is run out. $this->log("-------"); $cacheDir = $this->getCacheDirectory(); @@ -303,13 +295,13 @@ class serendipity_event_gravatar extends serendipity_event } } } - - function event_hook($event, &$bag, &$eventData, $addData = null) + + function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; static $cache = null; static $method = null; - + $hooks = &$bag->get('event_hooks'); if ($cache === null) { @@ -323,7 +315,7 @@ class serendipity_event_gravatar extends serendipity_event if (isset($hooks[$event])) { switch($event) { - + // Catch external_plugin event for fresh fetching avatar icons // This will response with an image (not with html code) case 'external_plugin': @@ -359,49 +351,51 @@ class serendipity_event_gravatar extends serendipity_event } else { return false; } - - break; - // Print out image html for the user avatar into the frontend_display - case 'frontend_display': + // Print out image html for the user avatar into the frontend_display + case 'frontend_display': if (!isset($eventData['comment'])) { - return true; + return true; } $this->printAvatarHtml($eventData, $addData); - - return true; break; + case 'css': // avatar css has to be emitted no matter of smarty enabled: the sidebar needs it. - //$useSmarty = serendipity_db_bool($this->get_config('smartyimage', false)); - //if (!$useSmarty && !(strpos($eventData, '.avatar_left') || strpos($eventData, '.avatar_rigth'))) { - if (!(strpos($eventData, '.avatar_left') || strpos($eventData, '.avatar_rigth'))) { -?> + // CSS class does NOT exist by user customized template styles, include default + if (false === (strpos($eventData, '.avatar_left') || strpos($eventData, '.avatar_rigth'))) { + $eventData .= ' + +/* serendipity_event_gravatar start */ + .avatar_left { - float:left; - margin-left:0px; - margin-right:10px; + float:left; + margin-left:0px; + margin-right:10px; } .avatar_right { - float:right; - margin-right:0px; - margin-left:10px; + float:right; + margin-right:0px; + margin-left:10px; } -get_config('infoline', true))){ + if (!serendipity_db_bool($this->get_config('infoline', 'true'))){ return false; } - + // The contact form uses the comments, too. We don't want this information line there and detect it by the missing properties entry. if (empty($eventData['properties'])){ return false; @@ -432,7 +426,7 @@ class serendipity_event_gravatar extends serendipity_event $supported_methods .= (empty($supported_methods) ? '' : ', ') . 'Monster ID'; break; case 'identicon': - $supported_methods .= (empty($supported_methods) ? '' : ', ') . 'Identicon/Ycon'; + $supported_methods .= (empty($supported_methods) ? '' : ', ') . 'Identicon/Ycon'; break; case 'wavatars': $supported_methods .= (empty($supported_methods) ? '' : ', ') . 'Wavatars'; @@ -440,54 +434,55 @@ class serendipity_event_gravatar extends serendipity_event } } echo '
    ' . sprintf(PLUGIN_EVENT_GRAVATAR_SUPPORTED, $supported_methods) . '
    '; - return true; break; default: return false; + } + return true; } else { return false; } } - + /** * Returns HTML displaying the user avatar. This is done without any call to external servers. * If a cached avatar is found, the image will have it as SRC, else the SRC will be filled with * an external_plugin call, that will try to fetch a fresh avatar later. - * */ - function printAvatarHtml(&$eventData, &$addData){ + function printAvatarHtml(&$eventData, &$addData) + { global $serendipity; - - $useSmarty = serendipity_db_bool($this->get_config('smartyimage', false)); - + + $useSmarty = serendipity_db_bool($this->get_config('smartyimage', 'false')); + // comments sidebar plugin doesn't support smarty, so switch it off, if detected if ($addData['from'] == 'serendipity_plugin_comments:generate_content') { - if (!serendipity_db_bool($this->get_config('recent_entries', true))) { + if (!serendipity_db_bool($this->get_config('recent_entries', 'true'))) { return false; } $useSmarty = false; - } - + } + if (empty($eventData['url']) && empty($eventData['email']) && empty($eventData['author']) && !$this->supportDefaultAvatar()) { $this->log("No url nor email handed and default avatar not supported!"); return false; } - + if (!empty($eventData['url']) && !preg_match('@^https*://@i',$eventData['url'])){ $this->log("Changed wrong url: {$eventData['url']}"); $eventData['url'] = 'http://' . $eventData['url']; } - + $url = ''; if (!empty($eventData['url'])) { - $url = $eventData['url']; + $url = $eventData['url']; } - - if (!empty($eventData['url'])) { // Strip Query paras - $urlparts = explode('?', $eventData['url']); - $url = $urlparts[0]; + + if (!empty($eventData['url'])) { // Strip Query params + $urlparts = explode('?', $eventData['url']); + $url = $urlparts[0]; } $title = ''; $author = 'unknown'; @@ -495,38 +490,38 @@ class serendipity_event_gravatar extends serendipity_event $author = (function_exists('serendipity_specialchars') ? serendipity_specialchars($eventData['author']) : htmlspecialchars($eventData['author'], ENT_COMPAT, LANG_CHARSET)); $title = $author; } - + if (isset($eventData['email']) && !empty($eventData['email'])) { - $email_md5 = md5(strtolower($eventData['email'])); + $email_md5 = md5(strtolower($eventData['email'])); } else { - $email_md5 = ''; + $email_md5 = ''; } if ($this->cache_seconds > 0) { $cache_file = $this->getCacheFilePath($eventData); // if no cache filename was generated, no usable user data was found. - // this meens: it won't be possible to generate any image, so break at this point. + // this meens: it won't be possible to generate any image, so break at this point. if (!isset($cache_file)) { - return false; + return false; } $this->log("comment print: " . print_r($eventData, true)); - // If there is a cache file that's new enough, return the image immidiatly + // If there is a cache file that's new enough, return the image immidiatly if (file_exists($cache_file) && (time() - filemtime($cache_file) < $this->cache_seconds)) { $url = $serendipity['baseURL'] . $serendipity['indexFile'] . '?/' - . $this->getPermaPluginPath() . '/cachedAvatar_' . md5($url) . '_' . $email_md5 + . $this->getPermaPluginPath() . '/cachedAvatar_' . md5($url) . '_' . $email_md5 . '_' . md5($author); } else { // no image cached yet, call external plugin hook for fetching a new one $url = $serendipity['baseURL'] . $serendipity['indexFile'] . '?/' - . $this->getPermaPluginPath() . '/fetchAvatar_' . $this->urlencode($url) . '_' . $email_md5 + . $this->getPermaPluginPath() . '/fetchAvatar_' . $this->urlencode($url) . '_' . $email_md5 . '_' . $this->urlencode($author) . '_' . $eventData['id']; } - + } else { // call external plugin hook for fetching a new one $url = $serendipity['baseURL'] . $serendipity['indexFile'] . '?/' - . $this->getPermaPluginPath() . '/fetchAvatar_' . $this->urlencode($url) . '_' . $email_md5 + . $this->getPermaPluginPath() . '/fetchAvatar_' . $this->urlencode($url) . '_' . $email_md5 . '_' . $this->urlencode($author) . '_' . $eventData['id']; } - + $image_html = $this->generateImageHtml($url, $title, $this->get_config('align', 'right'), !$useSmarty, $this->generateAvatarCssClass($addData)); if ($useSmarty) { $eventData['avatar'] = $image_html; @@ -534,15 +529,16 @@ class serendipity_event_gravatar extends serendipity_event else { $eventData['comment'] = $image_html . $eventData['comment']; } - + return true; } - + /** - * Generates a CSS class for the avatar depending where it is displayed. + * Generates a CSS class for the avatar depending where it is displayed. * Defaults to comment_avatar in comments and is unique for plugins. */ - function generateAvatarCssClass($addData){ + function generateAvatarCssClass($addData) + { if (empty($addData)) { return "avatar"; } @@ -551,18 +547,19 @@ class serendipity_event_gravatar extends serendipity_event $css = $parts[0]; return ($css == 'functions_entries'? 'comment' : $css ) . '_avatar'; } - + /** * Tests wether the default avatar is supported */ - function supportDefaultAvatar(){ - + function supportDefaultAvatar() + { + // Check if a default avatar is defined $default = $this->getDefaultImageConfiguration(); if (empty($default['defaultavatar'])) { return false; } - + // check if default avatar method is configured as one of the avatar methods. for($methodnr = 1; $methodnr <= PLUGIN_EVENT_GRAVATAR_METHOD_MAX; $methodnr++){ $method = $this->get_config("method_" . $methodnr); @@ -571,7 +568,7 @@ class serendipity_event_gravatar extends serendipity_event if ($method == 'none'){ return false; } - + // return true if default avatar method is found if ($method == 'default'){ return true; @@ -579,20 +576,21 @@ class serendipity_event_gravatar extends serendipity_event } return false; } - + /** * Will try to fetch a fresh avatar image by user configuration. If retreiving was successfull, - * the image will cached and displayed as binary image response. + * the image will cached and displayed as binary image response. */ - function fetchAvatar(&$eventData) { + function fetchAvatar(&$eventData) + { global $serendipity; - + $methodnr = 1; - + // Assure existance of cache directory @mkdir($this->getCacheDirectory()); $default = $this->getDefaultImageConfiguration(); - + // load configuration of last run $lastrun_fname = $this->getCacheFilePath($eventData) . '.lastrun'; if (file_exists($lastrun_fname) && (time() - filemtime($lastrun_fname))< $this->cache_seconds) { @@ -606,7 +604,7 @@ class serendipity_event_gravatar extends serendipity_event $methodnr = $this->avatarConfiguration['methodnr']; $this->log("MethodNr by lastrun: $methodnr"); } - } + } $success = false; while (!$success && $methodnr <= PLUGIN_EVENT_GRAVATAR_METHOD_MAX) { @@ -627,16 +625,13 @@ class serendipity_event_gravatar extends serendipity_event case 'identica': $success = $this->fetchIdentica($eventData); break; - case 'mybloglog': - $success = $this->fetchMyBlogLog($eventData); - break; case 'monsterid': $success = $this->fetchMonster($eventData); break; case 'wavatars': $success = $this->fetchWavatar($eventData); break; - case 'identicon': + case 'identicon': $success = $this->fetchYcon($eventData); break; case 'default': @@ -664,13 +659,14 @@ class serendipity_event_gravatar extends serendipity_event /** * Fetches a Gravatar and returns it as a binary image response. - * + * * @param array eventdata the data given by the event * @param int cache hours for fetching images from cache - * + * * @return boolean true, if Avatar was found and added to the comment buffer */ - function fetchGravatar(&$eventData){ + function fetchGravatar(&$eventData) + { global $serendipity; $this->log("Gravatar: url=" . $eventData['url'] . " email_md5=" . $eventData['email_md5'] . " author=" .$eventData['author']) ; @@ -679,30 +675,30 @@ class serendipity_event_gravatar extends serendipity_event return false; } if (empty($eventData['email_md5'])) { - if (!serendipity_db_bool($this->get_config('gravatar_fallback_use_always', false)) || (empty($eventData['url']) && empty($eventData['author']))) { - return false; - } - else { - if (empty($eventData['url'])) $email_md5 = md5($eventData['author']); - else $email_md5 = md5($eventData['url']); - } + if (!serendipity_db_bool($this->get_config('gravatar_fallback_use_always', 'false')) || (empty($eventData['url']) && empty($eventData['author']))) { + return false; + } + else { + if (empty($eventData['url'])) $email_md5 = md5($eventData['author']); + else $email_md5 = md5($eventData['url']); + } } else { - $email_md5 = $eventData['email_md5']; + $email_md5 = $eventData['email_md5']; } $default = $this->getDefaultImageConfiguration(); - + $gravatar_fallback = $this->get_config("gravatar_fallback"); $fallback = ""; if ($gravatar_fallback != 'none') { - $fallback = '&d=' . $gravatar_fallback; + $fallback = '&d=' . $gravatar_fallback; } else { - //$defaultavatar = urlencode((empty($default['defaultavatar'])? $serendipity['baseURL'] . 'dummy.gif': 'http://' . $_SERVER['SERVER_NAME'] . $default['defaultavatar'])); - $defaultavatar = urlencode($serendipity['serendipityHTTPPath'] . 'dummy456.gif123'); // Add a not existing image to produce an error we can check - $fallback = '&d=' . $defaultavatar; + //$defaultavatar = urlencode((empty($default['defaultavatar'])? $serendipity['baseURL'] . 'dummy.gif': 'http://' . $_SERVER['SERVER_NAME'] . $default['defaultavatar'])); + $defaultavatar = urlencode($serendipity['serendipityHTTPPath'] . 'dummy456.gif123'); // Add a not existing image to produce an error we can check + $fallback = '&d=' . $defaultavatar; } - + $urltpl = 'http://www.gravatar.com/avatar.php?' . 'gravatar_id=' . $email_md5 . $fallback @@ -711,79 +707,44 @@ class serendipity_event_gravatar extends serendipity_event // Assure a default avatar, because we need it for testing if the avatar given by Gravatar is a dummy image. $this->log("Gravatar Link: " . $urltpl) ; - + $success = $this->saveAndResponseAvatar($eventData, $urltpl, 1); $this->avatarConfiguration['gravatar_found'] = $success; + return $success; } - /** - * Tries to add a MyBlogLog.com avatar to the comment. - * - * @param array eventdata the data given by the event - * @param int cache hours for fetching images from cache - * @param array default default values for avatar images - * - * @return boolean true, if Avatar was found and added to the comment buffer - */ - function fetchMyBlogLog(&$eventData){ - require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; - global $serendipity; - // Was lastrun successfull? - if (isset($this->avatarConfiguration['mybloglog_found']) && !$this->avatarConfiguration['mybloglog_found']) { - return false; - } - if (empty($eventData['url'])) { - return false; - } - - // Get configured plugin path: - $pluginPath = 'plugin'; - if (isset($serendipity['permalinkPluginPath'])){ - $pluginPath = $serendipity['permalinkPluginPath']; - } - - $author_url = 'http://pub.mybloglog.com/coiserv.php?' - . 'href=' . $eventData['url'] - . '&n=' . (!empty($eventData['author']) ? $eventData['author'] : '*'); - - $check = $this->saveAndResponseMyBlogAvatar($eventData, $author_url); - $this->avatarConfiguration['mybloglog_found'] = $check; - - return $check; - } - - /** * Tries to add a favatar or pavatar (depending on the given mode) to the comment. - * + * * @param array eventdata the data given by the event * @param int cache hours for fetching images from cache - * @param string mode has to be 'P' for Pavatar or 'F' for Favatar loading. - * + * @param string mode has to be 'P' for Pavatar or 'F' for Favatar loading. + * * @return boolean true, if Avatar was found and added to the comment buffer */ - function fetchPFavatar(&$eventData, $mode="F"){ - require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; + function fetchPFavatar(&$eventData, $mode="F") + { + require_once S9Y_PEAR_PATH . 'HTTP/Request2.php'; global $serendipity; - + $default = $this->getDefaultImageConfiguration(); - + $url = $eventData['url']; if (empty($url)) { return false; } $favicon = false; - + $this->log($mode . " - Trying to fetch for $url"); - + // Try to get the URL $parts = @parse_url($url); if (!is_array($parts)) { return false; } - + $ip = @gethostbyname($parts['host']); if (!$ip || $ip == $parts['host']) { return false; @@ -792,45 +753,42 @@ class serendipity_event_gravatar extends serendipity_event $this->log($mode . " - URL ok."); $cache_file = $this->getCacheFilePath($eventData); - + // Load icon url detected in last run if (isset($this->avatarConfiguration['img_url_'.$mode])){ $favicon = $this->avatarConfiguration['img_url_'.$mode]; $this->log($mode . " - using last run url: $favicon"); } - + if ($favicon === false) { // use optimization for localhost $islocalhost = ($_SERVER['HTTP_HOST'] == $parts['host']); - + if (function_exists('serendipity_request_start')) { serendipity_request_start(); } - - + // Evaluate URL of P/Favatar - $req = new HTTP_Request($url, array('allowRedirects' => true, 'maxRedirects' => 3)); + $options = array('follow_redirects' => true, 'max_redirects' => 3); + if (version_compare(PHP_VERSION, '5.6.0', '<')) { + // On earlier PHP versions, the certificate validation fails. We deactivate it on them to restore the functionality we had with HTTP/Request1 + $options['ssl_verify_peer'] = false; + } + $req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET, $options); $favicon = false; // code 200: OK, code 30x: REDIRECTION $responses = "/(200 OK)|(30[0-9] Found)/"; // |(30[0-9] Moved) - if (!$islocalhost && (PEAR::isError($req->sendRequest()) || preg_match($responses, $req->getResponseCode()))) { - // nothing to do, - $favicon = false; - $this->log($mode . " - Error fetching $url: " . $req->getResponseCode()); - } - else { - $pavatarHeaderIcon = $req->getResponseHeader("X-Pavatar"); - $fContent = $req->getResponseBody(); + try { + $response = $req->send(); + $pavatarHeaderIcon = $response->getHeader("X-Pavatar"); + $fContent = $response->getBody(); if ($mode=='P' && !empty($pavatarHeaderIcon)){ $faviconURL = $pavatarHeaderIcon; $this->log("Found x-pavatar in head: $faviconURL"); } - else if (!$islocalhost && - ($mode=='P' && preg_match('/]+rel="pavatar"[^>]+?href="([^"]+?)"/si', $fContent, $matches)) || - ($mode=='F' && preg_match('/]+rel="(?:shortcut )?icon"[^>]+?href="([^"]+?)"/si', $fContent, $matches)) - ) + else if (!$islocalhost && ($mode=='P' && preg_match('/]+rel="pavatar"[^>]+?href="([^"]+?)"/si', $fContent, $matches)) || + ($mode=='F' && preg_match('/]+rel="(?:shortcut )?icon"[^>]+?href="([^"]+?)"/si', $fContent, $matches))) { - // Attempt to grab an avatar link from their webpage url $linkUrl = (function_exists('serendipity_entity_decode') ? serendipity_entity_decode($matches[1]) : html_entity_decode($matches[1], ENT_COMPAT, LANG_CHARSET)); if (substr($linkUrl, 0, 1) == '/') { @@ -844,61 +802,65 @@ class serendipity_event_gravatar extends serendipity_event } else { $faviconURL = $url . '/' . $linkUrl; } - + $this->log($mode . " - Found link rel to url $faviconURL"); - } - else { + } else { // If unsuccessful, attempt to "guess" the favicon location $urlParts = parse_url($url); $faviconURL = $urlParts['scheme'] . '://' . $urlParts['host'] . ($mode=='F'?'/favicon.ico':'/pavatar.png'); $this->log($mode . " - Not found link rel, guessing $faviconURL"); } - + // Split image URL and check if image is available using a fast and timed out socket: - $url_parts = @parse_url($faviconURL); if (!is_array($url_parts)) { $url_parts = array(); } - + if (!empty($url_parts['path'])) { $documentpath = $url_parts['path']; } else { $documentpath = '/'; } - + if (!empty($url_parts['query'])) { $documentpath .= '?' . $url_parts["query"]; } - + if (empty($url_parts['port'])) { $url_parts['port'] = '80'; } - + if (!empty($url_parts['host'])) { $socket = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, 30); - + if ($socket) { fwrite($socket, "HEAD " . $documentpath . " HTTP/1.0\r\nHost: {$url_parts['host']}\r\n\r\n"); $http_response = fgets($socket, 25); - + $this->log($mode . ' Testing server ' . $url_parts['host'] . " dopath: $documentpath - HEAD Response: $http_response"); - - if (preg_match($responses, $http_response)) // We only test for server existance + + if (preg_match($responses, $http_response)) // We only test for server existance { $favicon = $faviconURL; } fclose($socket); } } - + // Remember the last result of the P/Favatar search - $this->avatarConfiguration['img_url_'.$mode] = $favicon; + $this->avatarConfiguration['img_url_'.$mode] = $favicon; + } catch (HTTP_Request2_Exception $e) { + if (!$islocalhost && preg_match($responses, $response->getStatus())) { + $favicon = false; + $this->log($mode . " - Error fetching $url: " . $response->getStatus()); + } } + if (function_exists('serendipity_request_end')) { serendipity_request_end(); } - } // if favicon url not loaded from cache + } // if favicon url not loaded from cache if (!empty($favicon)) { $this->log($mode . " - found at: $favicon"); @@ -907,11 +869,11 @@ class serendipity_event_gravatar extends serendipity_event else { return false; } - } - - function fetchTwitter(&$eventData) { - require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; + + function fetchTwitter(&$eventData) + { + require_once S9Y_PEAR_PATH . 'HTTP/Request2.php'; // Was lastrun successfull? if (isset($this->avatarConfiguration['twitter_found']) && !$this->avatarConfiguration['twitter_found']) { @@ -927,7 +889,7 @@ class serendipity_event_gravatar extends serendipity_event } catch (Exception $e) { $this->log($e); } - + if (empty($eventData['url'])) { return false; } @@ -941,22 +903,33 @@ class serendipity_event_gravatar extends serendipity_event $path = trim($parts['path']); $dirs = explode('/',$path); $twittername = $dirs[1]; - //if ($twittername=='#!') $twittername = $dirs[2]; - + $this->log("Twitteruser found ($url): $twittername"); - + $twitter_search = 'http://search.twitter.com/search.atom?q=from%3A' . $twittername . '&rpp=1'; serendipity_request_start(); - $req = new HTTP_Request($twitter_search); - $req->sendRequest(); - $this->last_error = $req->getResponseCode(); - if ($req->getResponseCode() != 200) { - $this->last_error = $req->getResponseCode(); + $options = array(); + if (version_compare(PHP_VERSION, '5.6.0', '<')) { + // On earlier PHP versions, the certificate validation fails. We deactivate it on them to restore the functionality we had with HTTP/Request1 + $options['ssl_verify_peer'] = false; + } + $req = new HTTP_Request2($twitter_search, HTTP_Request2::METHOD_GET, $options); + try { + $response = $req->send(); + + $this->last_error = $response->getStatus(); + if ($response->getStatus() != 200) { + throw new HTTP_Request2_Exception("Could not search on twitter"); + } + $response = trim($response->getBody()); + + } catch (HTTP_Request2_Exception $e) { + $this->last_error = $response->getStatus(); serendipity_request_end(); $this->log("Twitter Error: {$this->last_error}"); return false; } - $response = trim($req->getResponseBody()); + serendipity_request_end(); $parser = xml_parser_create(); $vals=array(); $index=array(); @@ -970,20 +943,21 @@ class serendipity_event_gravatar extends serendipity_event break; } } - if ($success) { + if ($success) { $success = $this->saveAndResponseAvatar($eventData, $img_url); } } $this->avatarConfiguration['twitter_found'] = $success; return $success; } - return false; - + return false; + } - - function fetchIdentica(&$eventData) { - require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; - + + function fetchIdentica(&$eventData) + { + require_once S9Y_PEAR_PATH . 'HTTP/Request2.php'; + // Was lastrun successfull? if (isset($this->avatarConfiguration['identica_found']) && !$this->avatarConfiguration['identica_found']) { return false; @@ -992,21 +966,30 @@ class serendipity_event_gravatar extends serendipity_event return false; } $url = $eventData['url']; - + if (preg_match('@^http://identi\.ca/notice/(\d+)$@',$url,$matches)) { $status_id = $matches[1]; $search = "http://identi.ca/api/statuses/show/$status_id.xml"; serendipity_request_start(); - $req = new HTTP_Request($search); - $req->sendRequest(); - $this->last_error = $req->getResponseCode(); - if ($req->getResponseCode() != 200) { - $this->last_error = $req->getResponseCode(); + $options = array(); + if (version_compare(PHP_VERSION, '5.6.0', '<')) { + // On earlier PHP versions, the certificate validation fails. We deactivate it on them to restore the functionality we had with HTTP/Request1 + $options['ssl_verify_peer'] = false; + } + $req = new HTTP_Request2($search, HTTP_Request2::METHOD_GET, $options); + try { + $response = $req->send(); + $this->last_error = $response->getStatus(); + if ($response->getStatus() != 200) { + throw new HTTP_Request2_Exception("Could not search on identica"); + } + $response = trim($response->getBody()); + } catch (HTTP_Request2_Exception $e) { + $this->last_error = $response->getStatus(); serendipity_request_end(); $this->log("Identica Error: {$this->last_error}"); return false; } - $response = trim($req->getResponseBody()); serendipity_request_end(); $parser = xml_parser_create(); $vals=array(); $index=array(); @@ -1020,20 +1003,21 @@ class serendipity_event_gravatar extends serendipity_event return $success; } - return false; - + return false; + } - + /** * Shows a monster id avatar. - * + * * @param array eventdata the data given by the event - * + * * @return boolean true, if Avatar was found and added to the comment buffer */ - function fetchMonster(&$eventData){ + function fetchMonster(&$eventData) + { require_once dirname(__FILE__) . '/monsterid/monsterid.php'; - + $seed = md5($eventData['author']) . $eventData['email_md5'] . md5($eventData['url']); $default = $this->getDefaultImageConfiguration(); $size = $default['size']; @@ -1051,19 +1035,20 @@ class serendipity_event_gravatar extends serendipity_event $this->fetchDefault(); } - return true; + return true; } /** * Shows a monster id avatar. - * + * * @param array eventdata the data given by the event - * + * * @return boolean true, if Avatar was found and added to the comment buffer */ - function fetchWavatar(&$eventData){ + function fetchWavatar(&$eventData) + { require_once dirname(__FILE__) . '/wavatars/wavatars.php'; - + $seed = md5($eventData['author']) . $eventData['email_md5'] . md5($eventData['url']); $default = $this->getDefaultImageConfiguration(); $size = $default['size']; @@ -1081,21 +1066,22 @@ class serendipity_event_gravatar extends serendipity_event $this->fetchDefault(); } - return true; + return true; } /** * Shows an identicon/ycon avatar (generated locally). * http://www.docuverse.com/blog/donpark/2007/01/18/visual-security-9-block-ip-identification * http://www.evilissexy.com/ - * + * * @param array eventdata the data given by the event - * + * * @return boolean true, if Avatar was found and added to the comment buffer */ - function fetchYcon(&$eventData){ + function fetchYcon(&$eventData) + { require_once dirname(__FILE__) . '/ycon/ycon.image.php'; - + $seed = md5($eventData['author']) . $eventData['email_md5'] . md5($eventData['url']); $default = $this->getDefaultImageConfiguration(); $size = $default['size']; @@ -1113,24 +1099,25 @@ class serendipity_event_gravatar extends serendipity_event $this->fetchDefault(); } - return true; + return true; } - + /** * Shows the local default avatar. - * + * * @param array eventdata the data given by the event - * + * * @return boolean true, if Avatar was found and added to the comment buffer */ - function fetchDefault(){ + function fetchDefault() + { global $serendipity; - + $default = $this->getDefaultImageConfiguration(); if (empty($default['defaultavatar'])) { return false; } - + $this->log("FetchDefault"); // Set fetch date. Show will use this for caclculating cache. $this->avatarConfiguration['fetch_date'] = time(); @@ -1141,65 +1128,67 @@ class serendipity_event_gravatar extends serendipity_event $this->log("DefaultUrl RPL: " . $defaultUrl); $this->log("FetchDefault: DOC_ROOT" . $_SERVER["DOCUMENT_ROOT"]); $this->show($_SERVER["DOCUMENT_ROOT"] . '/' . $defaultUrl); - + return true; } - /** - * Caches an avatar and streams it back to the browser. + * Caches an avatar and streams it back to the browser. */ - function saveAndResponseAvatar($eventData, $url, $allow_redirection = 3){ - require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; + function saveAndResponseAvatar($eventData, $url, $allow_redirection = 3) + { + require_once S9Y_PEAR_PATH . 'HTTP/Request2.php'; global $serendipity; $fContent = null; - + if (function_exists('serendipity_request_start')) { serendipity_request_start(); } - - if ($allow_redirection) { - $request_pars['allowRedirects'] = true; - $request_pars['maxRedirects'] = $allow_redirection; - } - else { - $request_pars['allowRedirects'] = false; - } - - $req = new HTTP_Request($url, $request_pars); - // if the request leads to an error we don't want to have it: return false - if (PEAR::isError($req->sendRequest()) || ($req->getResponseCode() != '200')) { - $fContent = null; - if ($req->getResponseCode() != '200') { - $this->log("Avatar fetch error: " . $req->getResponseCode() . " for url=" . $url); - } - else { - $this->log("Avatar fetch error: PEAR reported ERROR for url=" . $url); - } - + if ($allow_redirection) { + $request_pars['follow_redirects'] = true; + $request_pars['max_redirects'] = $allow_redirection; } else { + $request_pars['follow_redirects'] = false; + } + + if (version_compare(PHP_VERSION, '5.6.0', '<')) { + // On earlier PHP versions, the certificate validation fails. We deactivate it on them to restore the functionality we had with HTTP/Request1 + $request_pars['ssl_verify_peer'] = false; + } + + $req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET, $request_pars); + try { + $response = $req->send(); + if ($response->getStatus() != '200') { + throw new HTTP_Request2_Exception("Could not search on identica"); + } // Allow only images as Avatar! - $mime = $req->getResponseHeader("content-type"); + $mime = $response->getHeader("content-type"); + $this->avatarConfiguration['mime-type'] = $mime; $this->log("Avatar fetch mimetype: $mime" . " for url=" . $url); $mimeparts = explode('/',$mime); if (count($mimeparts)==2 && $mimeparts[0]=='image') { - $fContent = $req->getResponseBody(); + $fContent = $response->getBody(); } - } - + } catch (HTTP_Request2_Exception $e) { + $fContent = null; + $this->log("Avatar fetch error: " . $e); + + } + if (function_exists('serendipity_request_start')) { serendipity_request_end(); } - + // if no content was fetched, return false if (!isset($fContent) || empty($fContent)){ $this->log("Avatar fetch: no Content!"); return false; } - $cache_file = $this->cacheAvatar($eventData, $fContent,$req); + $cache_file = $this->cacheAvatar($eventData, $fContent); if ($cache_file) { $this->show($cache_file); } @@ -1210,135 +1199,18 @@ class serendipity_event_gravatar extends serendipity_event return true; } - function saveAndResponseMyBlogAvatar($eventData, $url) { - global $serendipity; - - $request_pars['allowRedirects'] = false; - - $this->log("saveAndResponseMyBlogAvatar: " . $url); - - // First a dummy icon is fetched. This is done by fetching a MyBlog Avatar for a not existing domain. - // If we have done this before, the dummy_md5 is already set, so we can skip this fetching here. - if (!isset($this->mybloglog_dummy_md5)) { - - $cachefilename = '_mybloglogdummy.md5'; - $cache_file = $this->getCacheDirectory() . '/' . $cachefilename; - - // Look up the cache for the md5 of the MyBlogLog dummy icon saved earlier: - if (file_exists($cache_file) && time() - filemtime($cache_file) < $this->cache_seconds){ - $fp = fopen($cache_file, 'rb'); - $this->mybloglog_dummy_md5 = fread($fp, filesize($cache_file)); - fclose($fp); - $this->log("Loaded dummy MD5: " . $this->mybloglog_dummy_md5); - } - else { // dummy MD5 file was not cached or was too old. We have to fetch the dummy icon now - $dummyurl = 'http://pub.mybloglog.com/coiserv.php?href=http://grunz.grunz.grunz&n=*'; - $this->log("trying dummyUrl: " . $dummyurl); - if (function_exists('serendipity_request_start')) { - serendipity_request_start(); - } - $reqdummy = new HTTP_Request($dummyurl, $request_pars); - if (PEAR::isError($reqdummy->sendRequest()) || ($reqdummy->getResponseCode() != '200')) { - if (function_exists('serendipity_request_start')) { - serendipity_request_end(); - } - $this->avatarConfiguration["mybloglog_dummy_error!"]=$reqdummy->getResponseCode(); - // unable to fetch a dummy picture! - $this->log("unable to fetch a dummy picture!" . $dummyurl); - return false; // what can we say else.. - } - else { - - // Allow only images as Avatar! - $mime = $reqdummy->getResponseHeader("content-type"); - $this->log("MyBlogLog Avatar fetch mimetype: $mime"); - $mimeparts = explode('/',$mime); - if (count($mimeparts)!=2 || $mimeparts[0]!='image') { - // unable to fetch a dummy picture! - $this->log("unable to fetch a dummy picture!" . $dummyurl); - if (function_exists('serendipity_request_start')) { - serendipity_request_end(); - } - return false; // what can we say else.. - } - - $fContent = $reqdummy->getResponseBody(); - $this->mybloglog_dummy_md5 = md5($fContent); - // Save MD5 of dummy icon for later runs - $fp = fopen($cache_file, 'wb'); - fwrite($fp,$this->mybloglog_dummy_md5); - fclose($fp); - $this->log("dummy MD5 saved: " . $this->mybloglog_dummy_md5); - } - if (function_exists('serendipity_request_start')) { - serendipity_request_end(); - } - } - } - - // Fetch the correct icon and compare: - if (isset($this->mybloglog_dummy_md5)) { - $cachefilename = $this->getCacheFilePath($eventData); - - // fetch the icon - if (function_exists('serendipity_request_start')) { - serendipity_request_start(); - } - $this->log("Fetching mbl: " . $url); - $req = new HTTP_Request($url, $request_pars); - if (PEAR::isError($req->sendRequest()) || ($req->getResponseCode() != '200')) { - if (function_exists('serendipity_request_start')) { - serendipity_request_end(); - } - $this->log("Unable to fetch the correct image!"); - // Unable to fetch the correct image! - return false; - } - else { - // Test, if this realy is an image! - $mime_type = $req->getResponseHeader('content-type'); - if (!empty($mime_type)) $mt_parts = explode('/',$mime_type); - if (isset($mt_parts) && is_array($mt_parts) && $mt_parts[0] == 'image') { - $fContent = $req->getResponseBody(); - $avtmd5 = md5($fContent); - $this->log("mbl image fetched, MD5: " . $avtmd5); - if ($this->mybloglog_dummy_md5 != $avtmd5) { - $this->log("caching mbl image: " . $cachefilename); - $this->cacheAvatar($eventData,$fContent,$req); - } - } else { - $this->log("MyBlogLog did not return an image: " . $mime_type ); - $avtmd5 = $this->mybloglog_dummy_md5; // Declare it as dummy in order not to save it. - } - - } - if (function_exists('serendipity_request_start')) { - serendipity_request_end(); - } - - if ($this->mybloglog_dummy_md5 == $avtmd5){ // This seems to be a dummy avatar! - return false; - } - else { - $this->show($cachefilename); - return true; - } - } - return false; - } - /** * Caches an avatar file. - * + * * @param string cache_file name of file used for caching * @param string fContent content to be cached - * @param request req optional the request that produced this content (for logging) */ - function cacheAvatar($eventData, $fContent, $req=null){ + function cacheAvatar($eventData, $fContent) + { $cache_file = $this->getCacheFilePath($eventData); $this->log("cacheAvatar: " . $cache_file); - + // Save image @mkdir($this->getCacheDirectory()); $fp = @fopen($cache_file, 'wb'); @@ -1354,20 +1226,14 @@ class serendipity_event_gravatar extends serendipity_event fwrite($fp, $fContent); fclose($fp); - if (isset($req)){ - // Remember mime type - $mime_type = $req->getResponseHeader('content-type'); - $this->avatarConfiguration['mime-type'] = $mime_type; - } return $cache_file; } - - /** * Return binary response for an image */ - function show($filename) { + function show($filename) + { $this->log("show: $filename"); if (!file_exists($filename)) { header('X-Avatar: No-Image'); @@ -1382,16 +1248,16 @@ class serendipity_event_gravatar extends serendipity_event if (!isset($mime_type)) { $size = @getimagesize($filename); $mime_type = $size['mime']; - $this->avatarConfiguration['mime-type'] = $mime_type; + $this->avatarConfiguration['mime-type'] = $mime_type; } - + // test wether this really is (at least declared as) an image! // else deny it. $mime_parts = explode('/', $mime_type); if (count($mime_parts)!=2 || $mime_parts[0]!='image') { return false; } - + $fp = @fopen($filename, "rb"); if ($fp) { if (isset($this->avatarConfiguration['fetch_date'])) { @@ -1426,67 +1292,71 @@ class serendipity_event_gravatar extends serendipity_event * @param string title the title for that image * @return string the html code representing the Avatar */ - function generateImageHtml($url, $title = null, $align = 'right', $addAlignClass = true, $cssClass = "comment_avatar"){ - + function generateImageHtml($url, $title = null, $align = 'right', $addAlignClass = true, $cssClass = "comment_avatar") + { $default = $this->getDefaultImageConfiguration(); - + if (empty($title)){ $title = 'Avatar'; } if (PLUGIN_EVENT_GRAVATAR_DEBUG) $title .= ' (Avatar Plugin V.' . PLUGIN_EVENT_GRAVATAR_VERSION . ' DEBUG)'; - + // set alignment by configuration $cssAlign = ''; if ($addAlignClass && ($align == 'right' || $align == 'left')) $cssAlign = "avatar_$align"; $alt = '*'; - if (serendipity_db_bool($this->get_config('autoralt', false))) { - $alt = $title; + if (serendipity_db_bool($this->get_config('autoralt', 'false'))) { + $alt = $title; } return '' . $alt . ''; } - + /** * Just generates comments into the comment block. Used for debugging only! */ - function generateComment(&$eventData, $comment){ + function generateComment(&$eventData, $comment) + { $eventData['comment'] = "-- $comment --
    \n" . $eventData['comment']; } /** * Returns the avatar cache directory */ - function getCacheDirectory(){ + function getCacheDirectory() + { global $serendipity; if ($this->cache_dir === null) { $this->cache_dir = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . '/serendipity_event_avatar'; } - return $this->cache_dir; + return $this->cache_dir; } - + /** * Returns the Path of the avatar cache file by the given user data found in eventData * If no relevant user data was found, null is returned. - * + * */ - function getCacheFilePath($eventData){ + function getCacheFilePath($eventData) + { global $serendipity; - + $cache_filename = $this->getCacheFileName($eventData); if (!isset($cache_filename)) { return null; } return $this->getCacheDirectory() .'/' . $cache_filename;; } - + /** * Returns the URL of the cached avatar by the given user data found in eventData * If no relevant user data was found, null is returned. - * + * */ - function getCacheFileUrl($eventData){ + function getCacheFileUrl($eventData) + { global $serendipity; - + $cache_filename = $this->getCacheFileName($eventData); if (!isset($cache_filename)) { return null; @@ -1497,32 +1367,35 @@ class serendipity_event_gravatar extends serendipity_event /** * Returns a URL encoded and signed variable. */ - function urlencode($url) { + function urlencode($url) + { $hash = md5($this->instance_id . $url); return $hash . str_replace ('_', '%5F', urlencode($url)); } - - function urldecode($url) { + + function urldecode($url) + { $hash = substr($url, 0, 32); $real_url = urldecode(substr($url, 32)); if ($hash == md5($this->instance_id . $real_url)) { // Valid hash was found. - return $real_url; + return $real_url; } else { // Invalid hash. return ''; } } - + /** * Returns only the name of the cached avatar by the given user data found in eventData * If no relevant user data was found, null is returned. - * + * */ - function getCacheFileName($eventData){ + function getCacheFileName($eventData) + { global $serendipity; - + if (!isset($eventData['email']) && !isset($eventData['email_md5']) && !isset($eventData['url'])) { return null; } @@ -1533,19 +1406,20 @@ class serendipity_event_gravatar extends serendipity_event else if (isset($eventData['email'])) { $email_md5 = md5(strtolower($eventData['email'])); } - + $author_md5= isset($eventData['author'])? md5($eventData['author']) : ''; $url_md5 = isset($eventData['url'])? md5($eventData['url']) : '' ; return $url_md5 . '_' . $email_md5 . '_' . $author_md5; } - + /** * Builds an array of default image configuration */ - function getDefaultImageConfiguration() { + function getDefaultImageConfiguration() + { global $serendipity; - + if ($this->defaultImageConfigurationdefault === null) { $this->defaultImageConfigurationdefault = array( 'defaultavatar' => ($this->get_config('defaultavatar')==''?'': $this->get_config('defaultavatar', '')), @@ -1556,26 +1430,29 @@ class serendipity_event_gravatar extends serendipity_event return $this->defaultImageConfigurationdefault; } - function getPermaPluginPath() { + function getPermaPluginPath() + { global $serendipity; - // Get configured plugin path: + // Get configured plugin path: $pluginPath = 'plugin'; if (isset($serendipity['permalinkPluginPath'])){ $pluginPath = $serendipity['permalinkPluginPath']; } - + return $pluginPath; - + } - - function log($message){ + + function log($message) + { if (!PLUGIN_EVENT_GRAVATAR_DEBUG) return; $fp = fopen($this->getCacheDirectory() . '.log','a'); fwrite($fp, $message . "\n"); fclose($fp); } + } /* vim: set sts=4 ts=4 expandtab : */ -?> +?> \ No newline at end of file diff --git a/serendipity_event_gravatar/wavatars/wavatars.php b/serendipity_event_gravatar/wavatars/wavatars.php index 9e075a6f..9be2cac5 100644 --- a/serendipity_event_gravatar/wavatars/wavatars.php +++ b/serendipity_event_gravatar/wavatars/wavatars.php @@ -99,9 +99,9 @@ Builds the avatar. function wavatar_build ($filename, $seed, $size) { - if (!function_exists (imagecreatetruecolor)) { - return false; - } + if (!function_exists (imagecreatetruecolor)) { + return false; + } $face = 1 + (hexdec (substr ($seed, 1, 2)) % (WAVATAR_FACES)); $bg_color = (hexdec (substr ($seed, 3, 2)) % 240); $fade = 1 + (hexdec (substr ($seed, 5, 2)) % (WAVATAR_BACKGROUNDS)); @@ -142,4 +142,4 @@ function wavatar_build ($filename, $seed, $size) return true; } -?> +?> \ No newline at end of file diff --git a/serendipity_event_gravatar/ycon/ycon.image.php b/serendipity_event_gravatar/ycon/ycon.image.php index b20a117b..6033e271 100644 --- a/serendipity_event_gravatar/ycon/ycon.image.php +++ b/serendipity_event_gravatar/ycon/ycon.image.php @@ -2,13 +2,13 @@ require_once 'ycon.php'; function build_ycon($filename, $seed='',$size=''){ - $hash = md5($seed); - $image = ycon($hash, $size, 255, 255, 255); - imagetruecolortopalette($image, false, 64); -// header('Content-type: image/png'); - imagepng($image,$filename); - imagedestroy($image); - return true; + $hash = md5($seed); + $image = ycon($hash, $size, 255, 255, 255); + imagetruecolortopalette($image, false, 64); +// header('Content-type: image/png'); + imagepng($image,$filename); + imagedestroy($image); + return true; } ?> \ No newline at end of file diff --git a/serendipity_event_gravatar/ycon/ycon.php b/serendipity_event_gravatar/ycon/ycon.php index 5574765f..21c04da2 100644 --- a/serendipity_event_gravatar/ycon/ycon.php +++ b/serendipity_event_gravatar/ycon/ycon.php @@ -52,7 +52,7 @@ function ycon($hash, $size, $bg_red, $bg_green, $bg_blue) $red = hexdec(substr($hash, 0, 3)) % 12; // 0-192 for color $green = hexdec(substr($hash, 3, 3)) % 12; // (in increments of 16) $blue = hexdec(substr($hash, 6, 3)) % 12; - + $corners = hexdec(substr($hash, 9, 1)) % 16; // 14 gylphs $corners_i = hexdec(substr($hash, 10, 1)) % 2; // inverted? $corners_a = hexdec(substr($hash, 11, 1)) % 4; // 4 rotations @@ -93,7 +93,7 @@ function ycon($hash, $size, $bg_red, $bg_green, $bg_blue) $shape = (int)($center / 2); $inverted = (($center % 2) == 0); - + draw_glpyh($draw_icon, $square, $square, $square, $color, $background, $shape, 0, $inverted); imagecopyresampled($icon, $draw_icon, 0, 0, 0, 0, $size, $size, $draw_size, $draw_size); @@ -230,7 +230,7 @@ function draw_glpyh(&$image, $x, $y, $full, $fg_color, $bg_color, $shape, $rotat 0, $full, $full, 0); break; - + case 13: // squat diamond $points = array( $quarter, 0, @@ -238,7 +238,7 @@ function draw_glpyh(&$image, $x, $y, $full, $fg_color, $bg_color, $shape, $rotat $quarter, $full, 0, $half); break; - + case 14: // hourglass on its side (and kinda' squished...) $points = array( 0, $half, @@ -253,7 +253,7 @@ function draw_glpyh(&$image, $x, $y, $full, $fg_color, $bg_color, $shape, $rotat $half, $half, $half, $full); break; - + default: die('$shape must be in range [0..13] (' . $shape . ' is out of range)'); } @@ -282,4 +282,5 @@ function draw_glpyh(&$image, $x, $y, $full, $fg_color, $bg_color, $shape, $rotat // draw the bastard imagefilledpolygon($image, $points, count($points) / 2, $drawing_color); } -?> + +?> \ No newline at end of file