Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of CURLOPT_FAILONERROR and other minor changes #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 8 additions & 23 deletions plugin_component.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# plugin_component.php - Include component plugin
# ------------------------------------------------------------------------
# author Ander Juaristi
# copyright Copyright (C) 2013-2014 Ander Juaristi. All Rights Reserved.
# copyright Copyright (C) 2014 Ander Juaristi. All Rights Reserved.
# @license - http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Websites: http://www.burgersoftware.es
# Technical Support: http://www.burgersoftware.es
Expand All @@ -13,6 +13,9 @@
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

define('IC_AUTHOR', 'Ander Juaristi');
define('IC_VERSION', 1.15);

jimport( 'joomla.plugin.plugin' );
jimport( 'joomla.html.parameter' );

Expand Down Expand Up @@ -99,26 +102,7 @@ public function onAfterInitialise()
*/
public function onContentPrepare($context, &$article, &$params, $limitstart=0)
{
$app = JFactory::getApplication();
if($app->isAdmin()) {
return;
}

// get document types
$this->_getdoc();

$text = &$article->text;
$introtext = &$article->introtext;

// check whether plugin has been unpublished
if ( !$this->params->get( 'enabled', 1 ) ) {
$text = preg_replace( $this->regex, '', $text );
return true;
}

// perform the replacement
$this->_replace( $text );
$this->_replace( $introtext );
return $this->onPrepareContent($article);
}

/**
Expand Down Expand Up @@ -520,7 +504,7 @@ function _process( $url ) {
}
}

$content = "\n<!-- Plugin Include component version 1.13 by Mike Reumer";
$content = "\n<!-- Plugin Include component version " . IC_VERSION . " by " . IC_AUTHOR;
$content .= "\n for: ".$url." -->";
$content .= "\n".$response;
$content .= "\n<!-- End Plugin Include component -->";
Expand Down Expand Up @@ -555,6 +539,7 @@ function _getURL($url, $sef) {
if (function_exists('curl_init')) {
$ch = curl_init( $url );
// Set curl options, see: http://www.php.net/manual/en/function.curl-setopt.php
curl_setopt ($ch, CURLOPT_FAILONERROR, true); // check if there is a 400+ error
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); // to return the transfer as a string
curl_setopt ($ch, CURLOPT_USERAGENT, 'spider'); // The contents of the "User-Agent: " header
curl_setopt ($ch, CURLOPT_AUTOREFERER, true); // set referer on redirect
Expand Down Expand Up @@ -632,4 +617,4 @@ function _addStyleSheet($style) {
}
}

?>
?>