Commit f9b3a277 authored by shammash's avatar shammash Committed by lechuck
Browse files

updated flattr to 0.9.25.4.1

parent cde470d0
<?php
if ( isset ($_REQUEST['oauth_token']) && isset ($_REQUEST['oauth_verifier'])) {
if ( isset ($_REQUEST['oauth_token']) && isset ($_REQUEST['oauth_verifier']) && isset($_REQUEST['page']) && ($_REQUEST['page']=="flattr/settings.php")) {
if (session_id() == '') { session_start(); }
......@@ -20,6 +20,13 @@ if ( isset ($_REQUEST['oauth_token']) && isset ($_REQUEST['oauth_verifier'])) {
add_option('flattrss_api_oauth_token_secret', $access_token['oauth_token_secret']);
update_option('flattrss_api_oauth_token_secret', $access_token['oauth_token_secret']);
require_once( ABSPATH . WPINC . '/registration.php');
$user_id = get_current_user_id( );
update_user_meta( $user_id, "user_flattrss_api_oauth_token", $access_token['oauth_token'] );
update_user_meta( $user_id, "user_flattrss_api_oauth_token_secret", $access_token['oauth_token_secret'] );
} else {
wp_die("<h1>Callback Error.</h1><p>Please clear browser cach and cookies, then try again. Sorry for the inconvenience.</p><p align='right'>Michael Henke</p>");
}
......
......@@ -2,13 +2,11 @@
/**
* @package Flattr
* @author Michael Henke
* @version 0.9.22.2
*/
/*
* @version 0.9.25.4.1
Plugin Name: Flattr
Plugin URI: http://wordpress.org/extend/plugins/flattr/
Description: Give your readers the opportunity to Flattr your effort
Version: 0.9.22.2
Version: 0.9.25.4.1
Author: Michael Henke
Author URI: http://allesblog.de/
License: This code is (un)licensed under the kopimi (copyme) non-license; http://www.kopimi.com. In other words you are free to copy it, taunt it, share it, fork it or whatever. :)
......@@ -22,4 +20,40 @@ if (version_compare(PHP_VERSION, '5.0.0', '<'))
else
{
require_once( WP_PLUGIN_DIR . '/' . plugin_basename( dirname(__FILE__) ) . '/flattr5.php');
}
$flattr_check = array();
if (isset ($_POST['flattr_warn_ignore'])) {
update_option('flattr_warn_ignore_version', Flattr::VERSION);
}
if (version_compare(get_option('flattr_warn_ignore_version'), Flattr::VERSION, '!=')) {
$flattr_check['DOMDocument'] = class_exists('DOMDocument');
$flattr_check['cURL'] = function_exists('curl_init');
$flattr_check['libxml'] = defined('LIBXML_VERSION');
if (in_array(FALSE, $flattr_check)) {
add_action( 'admin_notices','flattrCheckAdminNotice' );
}
}
function flattrCheckAdminNotice() {
global $flattr_check;
echo '<div id="message" class="error">';
echo '<div style="float:right"><form method="post">'.
'<input type="submit" class="button" name="flattr_warn_ignore" value="Ignore"/>'.
'</form></div>';
if (!$flattr_check['DOMDocument']) {
echo '<p><strong>Warning:</strong> You need <a href="http://php.net/manual/en/dom.installation.php" target="_blank">DOM support</a> enabled for Flattr Plugin to work properly.</p>';
}
if (!$flattr_check['cURL']) {
echo '<p><strong>Warning:</strong> You need <a href="http://php.net/manual/en/curl.installation.php" target="_blank">cURL support</a> enabled for Flattr Plugin to work properly.</p>';
}
if (!$flattr_check['libxml']) {
echo '<p><strong>Warning:</strong> You need <a href="http://de.php.net/manual/en/libxml.installation.php" target="_blank">libXML support</a> enabled for Flattr Plugin to work properly.</p>';
}
echo '</div>';
}
}
\ No newline at end of file
......@@ -4,8 +4,8 @@ if (session_id() == '') { session_start(); }
class Flattr
{
const VERSION = '0.9.22';
const WP_MIN_VER = '2.9';
const VERSION = '0.9.25.4';
const WP_MIN_VER = '3.0';
const API_SCRIPT = 'api.flattr.com/js/0.6/load.js?mode=auto';
/** @var array */
......@@ -31,17 +31,20 @@ class Flattr
}
$this->init();
}
if (( get_option('flattr_aut_page', 'off') == 'on' || get_option('flattr_aut', 'off') == 'on' ) && !in_array( 'live-blogging/live-blogging.php' , get_option('active_plugins') ))
{
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('the_content', array($this, 'injectIntoTheContent'),11);
add_filter('get_the_excerpt', array($this, 'filterGetExcerpt'), 1);
if ( get_option('flattr_override_sharethis', 'false') == 'true' ) {
add_action('plugins_loaded', array($this, 'overrideShareThis'));
}
}
} else {
if (( get_option('flattr_aut_page', 'off') == 'on' || get_option('flattr_aut', 'off') == 'on' ) && !in_array( 'live-blogging/live-blogging.php' , get_option('active_plugins') ))
{
if (get_option('flattr_handles_exerpt')==1) {
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', array($this, 'filterGetExcerpt'), 1);
}
if ( get_option('flattr_override_sharethis', 'false') == 'true' ) {
add_action('plugins_loaded', array($this, 'overrideShareThis'));
}
add_filter('the_content', array($this, 'injectIntoTheContent'), 32767);
}
}
wp_enqueue_script('flattrscript', ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https://' : 'http://' ) . self::API_SCRIPT, array(), '0.6', true);
}
......@@ -112,21 +115,24 @@ class Flattr
return '';
}
$flattr_uid = get_option('flattr_uid');
if (!$flattr_uid) {
if (get_option('user_based_flattr_buttons_since_time')< strtotime(get_the_time("c",$post)))
$flattr_uid = (get_option('user_based_flattr_buttons')&& get_user_meta(get_the_author_meta('ID'), "user_flattr_uid", true)!="")? get_user_meta(get_the_author_meta('ID'), "user_flattr_uid", true): get_option('flattr_uid');
else
$flattr_uid = get_option('flattr_uid');
if (!$flattr_uid) {
return '';
}
$selectedLanguage = get_post_meta($post->ID, '_flattr_post_language', true);
if (empty($selectedLanguage))
{
$selectedLanguage = get_option('flattr_lng');
$selectedLanguage = (get_option('user_based_flattr_buttons')&& get_user_meta(get_the_author_meta('ID'), "user_flattr_lng", true)!="")? get_user_meta(get_the_author_meta('ID'), "user_flattr_lng", true): get_option('flattr_lng');
}
$selectedCategory = get_post_meta($post->ID, '_flattr_post_category', true);
if (empty($selectedCategory))
{
$selectedCategory = get_option('flattr_cat');
$selectedCategory = (get_option('user_based_flattr_buttons')&& get_user_meta(get_the_author_meta('ID'), "user_flattr_cat", true)!="")? get_user_meta(get_the_author_meta('ID'), "user_flattr_cat", true): get_option('flattr_cat');
}
$hidden = get_post_meta($post->ID, '_flattr_post_hidden', true);
......@@ -151,7 +157,18 @@ class Flattr
if (isset($buttonData['user_id'], $buttonData['url'], $buttonData['language'], $buttonData['category']))
{
return $this->getButtonCode($buttonData);
$retval;
switch (get_option(flattr_button_style)) {
case "text":
$retval = '<a href="'. static_flattr_url($post).'" title="Flattr" target="_blank">Flattr this!</a>';
break;
case "image":
$retval = '<a href="'. static_flattr_url($post).'" title="Flattr" target="_blank"><img src="'. FLATTRSS_PLUGIN_PATH .'/img/flattr-badge-large.png" alt="flattr this!"/></a>';
break;
default:
$retval = $this->getButtonCode($buttonData);;
}
return $retval;
}
}
......@@ -192,7 +209,7 @@ class Flattr
$params['url'],
addslashes($params['title']),
$rev,
$params['body']
addslashes($params['body'])
);
}
......@@ -340,7 +357,8 @@ Flattr::getInstance();
*/
function get_the_flattr_permalink()
{
return Flattr::getInstance()->getButton(true);
return Flattr::getInstance()->getButton(true);
}
/**
......@@ -383,34 +401,49 @@ function tabber_stylesheet() {
add_option('flattrss_clicktrack_enabled', true);
add_option('flattrss_error_reporting', true);
add_option('flattrss_autosubmit', true);
add_option('flattrss_button_enabled', true);
add_option('flattr_post_types', array('post','page'));
add_option('flattr_handles_exerpt', true);
add_option('flattr_button_style','js');
function static_flattr_url($post) {
$id = $post->ID;
$md5 = md5($post->post_title);
return (get_bloginfo('wpurl') .'/?flattrss_redirect&amp;id='.$id.'&amp;md5='.$md5);
}
function flattr_post2rss($content) {
global $post;
$flattr = "";
$flattr_post_types = get_option('flattr_post_types');
if (is_feed() && in_array(get_post_type(), $flattr_post_types)) {
$id = $post->ID;
$md5 = md5($post->post_title);
$permalink = urlencode(get_permalink( $id ));
if (get_post_meta($post->ID, '_flattr_btn_disabled', false)) {
$flattr_post_types = get_option('flattr_post_types');
$flattr.= ' <p><a href="'. get_bloginfo('wpurl') .'/?flattrss_redirect&amp;id='.$id.'&amp;md5='.$md5.'" title="Flattr" target="_blank"><img src="'. FLATTRSS_PLUGIN_PATH .'/img/flattr-badge-large.png" alt="flattr this!"/></a></p>';
if (is_feed() && in_array(get_post_type(), $flattr_post_types)) {
$flattr.= ' <p><a href="'. static_flattr_url($post).'" title="Flattr" target="_blank"><img src="'. FLATTRSS_PLUGIN_PATH .'/img/flattr-badge-large.png" alt="flattr this!"/></a></p>';
}
}
return ($content.$flattr);
}
if(function_exists('curl_init')) {
if(function_exists('curl_init') && get_option('flattrss_button_enabled')) {
add_filter('the_content_feed', 'flattr_post2rss',999999);
}
$call_n = 0; # Do not delete! It will break autosubmit.
function new_flattrss_autosubmit_action () {
global $call_n;
$call_n += 1;
$post = $_POST;
if (((get_option('flattr_hide') == false) && $post['post_status'] == "publish") && ($post['original_post_status'] != "publish" && (strtotime($post['post_date_gmt']) - strtotime(gmdate("Y-m-d H:i:s")) <= 0)) && ($call_n == 1)) {
if (($post['post_status'] == "publish") && (get_post_meta($post['ID'], "flattrss_autosubmited", true)=="") && ($call_n == 2) && (get_the_time('U') <= time())) {
$e = error_reporting();
error_reporting(E_ERROR);
......@@ -419,7 +452,7 @@ function new_flattrss_autosubmit_action () {
$tagsA = get_the_tags($post['ID']);
$tags = "";
if ($tagsA) {
if (!empty($tagsA)) {
foreach ($tagsA as $tag) {
if (strlen($tags)!=0){
$tags .=",";
......@@ -429,7 +462,7 @@ function new_flattrss_autosubmit_action () {
}
if (trim($tags) == "") {
$tags .= "blog";
$tags = "blog";
}
$category = "text";
......@@ -487,9 +520,16 @@ function new_flattrss_autosubmit_action () {
$api_key = get_option('flattrss_api_key');
$api_secret = get_option('flattrss_api_secret');
$oauth_token = get_option('flattrss_api_oauth_token');
$oauth_token_secret = get_option('flattrss_api_oauth_token_secret');
if (get_option('user_based_flattr_buttons_since_time')< strtotime(get_the_time("c",$post))) {
$user_id = get_current_user_id();
$oauth_token = (get_user_meta( $user_id, "user_flattrss_api_oauth_token",true)!="")?get_user_meta( $user_id, "user_flattrss_api_oauth_token",true):get_option('flattrss_api_oauth_token');
$oauth_token_secret = (get_user_meta( $user_id, "user_flattrss_api_oauth_token_secret",true))?get_user_meta( $user_id, "user_flattrss_api_oauth_token_secret",true):get_option('flattrss_api_oauth_token_secret');
}
if (!class_exists('Flattr_Rest')) {
include 'oAuth/flattr_rest.php';
}
......@@ -510,19 +550,19 @@ function new_flattrss_autosubmit_action () {
}
}
#print_r(array($url, encode($title), $category, encode($content), $tags, $language));
$server = $_SERVER["SERVER_NAME"];
$server = preg_split("/:/", $server);
$server = $server[0];
$flattr_user->submitThing($url, encode($title), $category, encode($content), $tags, $language, get_option('flattr_hide'));
$hidden = (get_option('flattr_hide', true) || get_post_meta($post->ID, '_flattr_post_hidden', true) ||$server == "localhost")? true:false;
$flattr_user->submitThing($url, encode($title), $category, encode($content), $tags, $language, $hidden);
/*
if (get_option('flattrss_autodonate') && !isset($_SESSION['flattrss_autodonate_click'])) {
$flattr_user->clickThing("ead246fc95fc401ce69d15f3981da971");
$_SESSION['flattrss_autodonate_click'] = true;
}*/
if ($flattr_user->http_code == 200)
add_post_meta($post['ID'], "flattrss_autosubmited", "true");
error_reporting($e);
}
$call_n = 1;
}
......@@ -575,4 +615,100 @@ if(is_admin()) {
);
}
}
\ No newline at end of file
}
if (!empty($_POST) && $_POST['fsendmail']=="on") {
if ($_POST['fphpinfo']) {
ob_start();
phpinfo();
$mailtext = ob_get_clean();
}
$mailtext = $_POST['ftext'] ."\n<br/><br/>".$mailtext;
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$name = ($_POST['fname'] != "")? $_POST['fname'] : "unknown";
$from = ($_POST['femail'] != "")? $_POST['femail'] : "support@allesblog.de";
$header .= "From: $name <$from>\r\n";
$header .= "X-Mailer: PHP ". phpversion();
$fmail = mail( 'flattr@allesblog.de',
"Wordpress Flattr Plugin Support Request",
$mailtext,
$header);
$admin_notice = "";
if ($fmail) {
$admin_notice = 'echo \'<div id="message" class="updated"><p>Mail send successfully!</p></div>\';';
} else {
$admin_notice = 'echo \'<div id="message" class="error"><p>There was an error sending the email.</p></div>\';';
}
add_action( 'admin_notices',
create_function('', $admin_notice)
);
}
if (is_admin() && (ini_get('allow_url_fopen') || function_exists('curl_init')))
add_action('in_plugin_update_message-flattr/flattr.php', 'flattr_in_plugin_update_message');
function flattr_in_plugin_update_message() {
$url = 'http://plugins.trac.wordpress.org/browser/flattr/trunk/readme.txt?format=txt';
$data = "";
if ( ini_get('allow_url_fopen') )
$data = file_get_contents($url);
else
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
curl_close($ch);
}
if ($data) {
$matches = null;
$regexp = '~==\s*Changelog\s*==\s*=\s*[0-9.]+\s*=(.*)(=\s*' . preg_quote(Flattr::VERSION) . '\s*=|$)~Uis';
if (preg_match($regexp, $data, $matches)) {
$changelog = (array) preg_split('~[\r\n]+~', trim($matches[1]));
echo '</div><div class="update-message" style="font-weight: normal;"><strong>What\'s new:</strong>';
$ul = false;
$version = 99;
foreach ($changelog as $index => $line) {
if (version_compare($version, Flattr::VERSION,">"))
if (preg_match('~^\s*\*\s*~', $line)) {
if (!$ul) {
echo '<ul style="list-style: disc; margin-left: 20px;">';
$ul = true;
}
$line = preg_replace('~^\s*\*\s*~', '', htmlspecialchars($line));
echo '<li style="width: 50%; margin: 0;">' . $line . '</li>';
} else {
if ($ul) {
echo '</ul>';
$ul = false;
}
$version = trim($line, " =");
echo '<p style="margin: 5px 0;">' . htmlspecialchars($line) . '</p>';
}
}
if ($ul) {
echo '</ul><div style="clear: left;"></div>';
}
echo '</div>';
}
}
}
......@@ -15,14 +15,10 @@ class Flattr_Rest
private $apiVersion = '0.5';
private $error;
private $baseUrl = 'http://api.flattr.com';
private $baseUrl = 'https://api.flattr.com';
public function __construct($consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null)
{
if ( defined('LOCAL_DEV_ENV') )
{
$this->baseUrl = 'http://api.flattr.com';
}
$this->signature_method = new OAuthSignatureMethod_HMAC_SHA1();
$this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
......@@ -300,13 +296,15 @@ class Flattr_Rest
}
}
$dom = new DOMDocument();
$dom->loadXml($result);
$userXml = $dom->getElementsByTagName('user');
if ( ( $userXml = $userXml->item(0) ) !== null )
{
return Flattr_Xml::toArray( $userXml );
}
if (class_exists("DOMDocument")) {
$dom = new DOMDocument();
$dom->loadXml($result);
$userXml = $dom->getElementsByTagName('user');
if ( ( $userXml = $userXml->item(0) ) !== null )
{
return Flattr_Xml::toArray( $userXml );
}
}
return false;
}
......@@ -335,20 +333,26 @@ class Flattr_Rest
Flattr_Xml::addElement($node, 'language', $language);
Flattr_Xml::addElement($node, 'hidden', $hidden);
Flattr_Xml::addElement($node, 'temporary', $temporary);
$tagsNode = $node->appendChild( $dom->createElement('tags') );
foreach ( explode(',', $tags) as $tag )
{
Flattr_Xml::addElement($tagsNode, 'tag', trim($tag));
}
$result = $this->post($this->actionUrl('/thing/register'), array('data' => $dom->saveXml()));
$dom = new DOMDocument();
$dom->loadXml($result);
$thingXml = $dom->getElementsByTagName('thing');
return Flattr_Xml::toArray( $thingXml->item(0) );
if (trim($tags) != "") {
$tagsNode = $node->appendChild( $dom->createElement('tags') );
foreach ( explode(',', $tags) as $tag )
{
Flattr_Xml::addElement($tagsNode, 'tag', trim($tag));
}
}
$result = $this->post($this->actionUrl('/thing/register'), array('data' => $dom->saveXml()));
if (!empty ($result)) {
$dom = new DOMDocument();
$dom->loadXml($result);
$thingXml = $dom->getElementsByTagName('thing');
return Flattr_Xml::toArray( $thingXml->item(0) );
}
return false;
}
// Oauth specific
......
This diff is collapsed.
......@@ -2,8 +2,8 @@
Contributors: aphex3k
Donate link: https://flattr.com/donation/give/to/der_michael
Tags: flattr, donate, micropayments
Requires at least: 2.9.0
Tested up to: 3.0.5
Requires at least: 3.0
Tested up to: 3.2
Stable tag: trunk
This plugin allows you to easily add a Flattr button to your wordpress blog.
......@@ -37,7 +37,41 @@ To use advanced features like auto-submission or feed-buttons, your web server n
== Changelog ==
`Attention: ` It is mandatory to disable FlattRSS and Flattr Widget standalone plugins before upgrading.
= 0.9.25.4 =
* New Feature: Initial test with WP 3.2 passed
* Fix: saving option for user based flattr buttons
= 0.9.25.3 =
* Fix: typo in check time of post before autopublishing
= 0.9.25.2 =
* Fix: fixed a typo in the code, thanks to F. Holzhauer
= 0.9.25.1 =
* New Feature: Changelog Preview
* New Feature: Explicit warning messages about missing functionality
* Fix: Check time of post before autopublishing
= 0.9.25 =
* Requires at least Wordpress 3.0, tested against Wordpress 3.1.4
* New Feature: personalized Flattr buttons for every blog author
* New Feature: choose whether Flattr plugin handles excerpts or Wordpress
* New Feature: advanced feedback form
* New Feature: select JavaScript, static image or static text button
* Fix: buttons disabled for the post don't show up in the feed anymore
* Fix: Wordpress admin dashboard external resources fix
* Fix: trying to suggest the callback domain more reliably
= 0.9.24 =
* Fix: replaced the connect link for basic connect with Flattr with a text box where you enter your username yourself
= 0.9.23.1 =
* New Feature: reenabling auto-submit feature as soon as advanced account setup is complete.
* Fix: raising compatibility alongside other oauth plugins (Twitter Tools, etc.)
= 0.9.23 =
* New Feature: the Feed button can now be disabled
* Fix: fixed a bug that accidentally deletes authorization keys while "Save Changes"
= 0.9.22.2 =
* Plugin basic functionality will work even though cURL is not available
......@@ -165,4 +199,4 @@ A: Please clear session/cookie/browser cache and try again please.
For support requests regarding the wordpress plugin, please visit the plugin support forum: http://wordpress.org/tags/flattr?forum_id=10
For every other Flattr support request head over to the Flattr forum: http://forum.flattr.com/
For every other Flattr support request head over to the Flattr forum: http://forum.flattr.net/
......@@ -5,10 +5,7 @@ if (isset ($_GET['id'])&&
isset ($_GET['flattrss_redirect'])&&
function_exists('curl_init')) {
$e = error_reporting();
if (get_option('flattrss_error_reporting')) {
error_reporting(0);
}
header('Status-Code: 307');
$old_charset = ini_get('default_charset');
ini_set('default_charset',get_option('blog_charset'));
......@@ -17,46 +14,28 @@ if (isset ($_GET['id'])&&
$md5 = $_GET['md5'];
$post = get_post($id,ARRAY_A);
function return_error($x) { die(strval($x)); }
if (md5($post['post_title']) != $md5) {
return_error("Post title mismatch");
}
if ($post['post_status'] != "publish") {
return_error("Post status not published");
}
if (get_option('flattrss_clicktrack_enabled')) {
update_option('flattrss_clickthrough_n', get_option('flattrss_clickthrough_n')+1);
}
$url = get_permalink($post['ID']);
$tagsA = get_the_tags($post['ID']);
$tags = "";
$tags = "blog";
if ($tagsA) {
if (!empty($tagsA)) {
foreach ($tagsA as $tag) {
if (strlen($tags)!=0){
if (strlen($tags)>0){
$tags .=",";
}
$tags .= $tag->name;
}
}
if (trim($tags) == "") {
$tags .= "blog";
$category = get_post_meta($post['ID'], '_flattr_post_category', true);
if (empty($category)) {