Implement serendipity_request_url() for plugins when available.

This commit is contained in:
Garvin Hicking 2016-09-22 16:03:33 +02:00
parent 2b9fdb4619
commit db32114108
63 changed files with 781 additions and 413 deletions

View file

@ -1,3 +1,11 @@
0.33:
-----
* Added serendipity_request_url API method
0.32:
-----
* Compatibility check for Serendipity 2+
0.31: 0.31:
----- -----
* Adapted backend markup for 2.0 backend (yellowled) * Adapted backend markup for 2.0 backend (yellowled)

View file

@ -72,7 +72,7 @@ class serendipity_event_aggregator extends serendipity_event {
'php' => '4.1.0' 'php' => '4.1.0'
)); ));
$propbag->add('version', '0.31.1'); $propbag->add('version', '0.33');
$propbag->add('author', 'Evan Nemerson, Garvin Hicking, Kristian Koehntopp, Thomas Schulz, Claus Schmidt'); $propbag->add('author', 'Evan Nemerson, Garvin Hicking, Kristian Koehntopp, Thomas Schulz, Claus Schmidt');
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('event_hooks', array( $propbag->add('event_hooks', array(
@ -664,7 +664,7 @@ class serendipity_event_aggregator extends serendipity_event {
'last_update' => time() 'last_update' => time()
); );
if ($serendipity['version'][0] == '2') { if ($serendipity['version'][0] > 1) {
echo '<span class="msg_notice"><span class="icon-info-circled"></span> '; echo '<span class="msg_notice"><span class="icon-info-circled"></span> ';
} }
echo PLUGIN_AGGREGATOR_DESC; echo PLUGIN_AGGREGATOR_DESC;
@ -673,7 +673,7 @@ class serendipity_event_aggregator extends serendipity_event {
} else { } else {
echo '</span>'; echo '</span>';
} }
if ($serendipity['version'][0] == '2') { if ($serendipity['version'][0] > 1) {
echo '<span class="msg_hint"><span class="icon-help-circled"></span> '; echo '<span class="msg_hint"><span class="icon-help-circled"></span> ';
} }
echo PLUGIN_AGGREGATOR_FEEDLIST; echo PLUGIN_AGGREGATOR_FEEDLIST;
@ -912,24 +912,30 @@ class serendipity_event_aggregator extends serendipity_event {
global $serendipity; global $serendipity;
$file = $serendipity['POST']['aggregatorOPML']; $file = $serendipity['POST']['aggregatorOPML'];
require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
if (function_exists('serendipity_request_start')) {
serendipity_request_start();
}
$req = new HTTP_Request($file);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { if (function_exists('serendipity_request_url')) {
$data = file_get_contents($file); $data = serendipity_request_url($file);
if (empty($data)) { if (empty($data)) return false;
return false;
}
} else { } else {
// Fetch file require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
$data = $req->getResponseBody(); if (function_exists('serendipity_request_start')) {
} serendipity_request_start();
}
$req = new HTTP_Request($file);
if (function_exists('serendipity_request_end')) { if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
serendipity_request_end(); $data = file_get_contents($file);
if (empty($data)) {
return false;
}
} else {
// Fetch file
$data = $req->getResponseBody();
}
if (function_exists('serendipity_request_end')) {
serendipity_request_end();
}
} }
// XML functions // XML functions
@ -1136,16 +1142,22 @@ class serendipity_event_aggregator extends serendipity_event {
function checkCharset(&$feed) function checkCharset(&$feed)
{ {
global $serendipity; global $serendipity;
require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
$req = new HTTP_Request($feed['feedurl']); if (function_exists('serendipity_request_url')) {
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { $data = serendipity_request_url($feed['feedurl']);
$data = file_get_contents($feed['feedurl']); if (empty($data)) return false;
if (empty($data)) {
return false;
}
} else { } else {
# Fetch file require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
$data = $req->getResponseBody(); $req = new HTTP_Request($feed['feedurl']);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
$data = file_get_contents($feed['feedurl']);
if (empty($data)) {
return false;
}
} else {
# Fetch file
$data = $req->getResponseBody();
}
} }
#XML functions #XML functions
$xml_string = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>'; $xml_string = '<' . '?xml version="1.0" encoding="UTF-8"?' . '>';

View file

@ -595,16 +595,29 @@ function Amazon_ItemLookup ($AWSAccessKey,$AssociateTag,$secretKey,$SearchIndex,
} }
function Amazon_Request ($request) { function Amazon_Request ($request) {
require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php'; global $serendipity;
$items = array(); $items = array();
$totalcount = -1; $totalcount = -1;
$error_message = ""; $error_message = "";
$error_result = ""; $error_result = "";
$req = new HTTP_Request($request);
if (!(PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200')) { if (function_exists('serendipity_request_url')) {
$xml = xml_parser_create(LANG_CHARSET); $bodyxml = serendipity_request_url($file);
$totalcount = 0; if (empty($bodyxml)) return false;
$bodyxml = $req->getResponseBody(); $responseCode = $serendipity['last_http_request']['responseCode'];
} else {
$bodyxml = false;
require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
$req = new HTTP_Request($request);
if (!(PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200')) {
$xml = xml_parser_create(LANG_CHARSET);
$totalcount = 0;
$bodyxml = $req->getResponseBody();
$responseCode = $req->getResponseCode();
}
}
if ($bodyxml) {
$initem = false; $initem = false;
$inattrib = false; $inattrib = false;
if ( xml_parse_into_struct($xml, $bodyxml, $struct, $index) == 1 ) { if ( xml_parse_into_struct($xml, $bodyxml, $struct, $index) == 1 ) {
@ -699,7 +712,7 @@ function Amazon_Request ($request) {
} }
xml_parser_free($xml); xml_parser_free($xml);
} else { } else {
if ($req->getResponseCode() == "403") { if ($responseCode == "403") {
$error_message = constant('PLUGIN_EVENT_AMAZONCHOOSER_HTTPREQFAIL'); $error_message = constant('PLUGIN_EVENT_AMAZONCHOOSER_HTTPREQFAIL');
$error_result = constant('PLUGIN_EVENT_AMAZONCHOOSER_RESPONSE') . ": ".$req->getResponseCode()."<br />".constant('PLUGIN_EVENT_AMAZONCHOOSER_SETTINGS_PROBLEM'); $error_result = constant('PLUGIN_EVENT_AMAZONCHOOSER_RESPONSE') . ": ".$req->getResponseCode()."<br />".constant('PLUGIN_EVENT_AMAZONCHOOSER_SETTINGS_PROBLEM');
} else { } else {

View file

@ -1,3 +1,7 @@
0.76:
-----
* Added serendipity_request_url API method
0.75: 0.75:
----- -----
* Use native API method parseTemplate() (only) * Use native API method parseTemplate() (only)

View file

@ -29,7 +29,7 @@ class serendipity_event_amazonchooser extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_AMAZONCHOOSER_DESC); $propbag->add('description', PLUGIN_EVENT_AMAZONCHOOSER_DESC);
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('author', 'Matthew Groeninger, Ian'); $propbag->add('author', 'Matthew Groeninger, Ian');
$propbag->add('version', '0.75'); $propbag->add('version', '0.76');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '1.3', 'serendipity' => '1.3',
'smarty' => '2.6.7', 'smarty' => '2.6.7',

View file

@ -1,3 +1,7 @@
1.08:
-----
* Added serendipity_request_url API method
Version 1.06 Version 1.06
* Add ability to formular custom comment texts. * Add ability to formular custom comment texts.

View file

@ -34,7 +34,7 @@ class serendipity_event_commentspice extends serendipity_event
'smarty' => '2.6.7', 'smarty' => '2.6.7',
'php' => '4.1.0' 'php' => '4.1.0'
)); ));
$propbag->add('version', '1.07'); $propbag->add('version', '1.08');
$propbag->add('event_hooks', array( $propbag->add('event_hooks', array(
'entry_display' => true, 'entry_display' => true,
@ -683,14 +683,20 @@ class serendipity_event_commentspice extends serendipity_event
function readRssRemote($url) { function readRssRemote($url) {
$this->log("Fetchig remote rss from: " . $url); $this->log("Fetchig remote rss from: " . $url);
require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php'; if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($url, array('allowRedirects' => true, 'maxRedirects' => 3)); $data = serendipity_request_url($url);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { if (empty($data)) return false;
$this->log("Error reading $url"); } else {
return;
} require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
# Fetch html content: $req = new HTTP_Request($url, array('allowRedirects' => true, 'maxRedirects' => 3));
$data = $req->getResponseBody(); if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
$this->log("Error reading $url");
return;
}
# Fetch html content:
$data = $req->getResponseBody();
}
$this->log("Have data!"); $this->log("Have data!");
// Check if page defines a RSS link // Check if page defines a RSS link

View file

@ -1 +1,5 @@
1.12:
-----
* Added serendipity_request_url API method
latest: Smarty3 forward compatibility latest: Smarty3 forward compatibility

View file

@ -26,7 +26,7 @@ class serendipity_event_communityrating extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_COMMUNITYRATING_DESC); $propbag->add('description', PLUGIN_EVENT_COMMUNITYRATING_DESC);
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking, Lewe Zipfel'); $propbag->add('author', 'Garvin Hicking, Lewe Zipfel');
$propbag->add('version', '1.11.1'); $propbag->add('version', '1.12');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.9', 'serendipity' => '0.9',
'smarty' => '2.6.7', 'smarty' => '2.6.7',

View file

@ -32,33 +32,40 @@ function communityrating_serendipity_show($params, &$smarty) {
fwrite($fp, date('d.m.Y H:i')); fwrite($fp, date('d.m.Y H:i'));
fclose($fp); fclose($fp);
} }
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$req = new HTTP_Request($url);
if (!PEAR::isError($req->sendRequest()) || $req->getResponseCode() == '200') { if (function_exists('serendipity_request_url')) {
$data = $req->getResponseBody(); $data = serendipity_request_url($url);
} else {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$req = new HTTP_Request($url);
$id = ''; if (!PEAR::isError($req->sendRequest()) || $req->getResponseCode() == '200') {
if (preg_match('@<rating>(.+)</rating>@imsU', $data, $match)) { $data = $req->getResponseBody();
$id = $match[1]; } else {
$data = '';
} }
}
$url = ''; $id = '';
if (preg_match('@<url>(.+)</url>@imsU', $data, $match)) { if (preg_match('@<rating>(.+)</rating>@imsU', $data, $match)) {
$url = $match[1]; $id = $match[1];
} }
$fp = fopen($cache . '.id', 'w'); $url = '';
if ($fp) { if (preg_match('@<url>(.+)</url>@imsU', $data, $match)) {
fwrite($fp, $id); $url = $match[1];
fclose($fp); }
}
$fp = fopen($cache . '.url', 'w'); $fp = fopen($cache . '.id', 'w');
if ($fp) { if ($fp) {
fwrite($fp, $url); fwrite($fp, $id);
fclose($fp); fclose($fp);
} }
$fp = fopen($cache . '.url', 'w');
if ($fp) {
fwrite($fp, $url);
fclose($fp);
} }
} }

View file

@ -1,3 +1,7 @@
0.5.2:
-----
* Added serendipity_request_url API method
0.4: Properly use the example() API method by returning, not echo'ing. Unimportant update. 0.4: Properly use the example() API method by returning, not echo'ing. Unimportant update.
0.3: 0.3:
---- ----

View file

@ -33,7 +33,7 @@ class serendipity_event_facebook extends serendipity_event {
'smarty' => '2.6.7', 'smarty' => '2.6.7',
'php' => '4.1.0' 'php' => '4.1.0'
)); ));
$propbag->add('version', '0.5.1'); $propbag->add('version', '0.5.2');
$propbag->add('groups', array('FRONTEND_VIEWS')); $propbag->add('groups', array('FRONTEND_VIEWS'));
$propbag->add('event_hooks', array( $propbag->add('event_hooks', array(
'frontend_display' => true, 'frontend_display' => true,
@ -222,8 +222,10 @@ class serendipity_event_facebook extends serendipity_event {
header('Content-Type: text/plain; charset=' . LANG_CHARSET); header('Content-Type: text/plain; charset=' . LANG_CHARSET);
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; if (!function_exists('serendipity_request_url')) {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
}
$users = explode(',', $this->get_config('facebook_users')); $users = explode(',', $this->get_config('facebook_users'));
foreach($users AS $user) { foreach($users AS $user) {
$user = trim($user); $user = trim($user);
@ -231,16 +233,25 @@ class serendipity_event_facebook extends serendipity_event {
$url = 'http://graph.facebook.com/' . $user . '/posts?limit=' . $this->get_config('limit'); $url = 'http://graph.facebook.com/' . $user . '/posts?limit=' . $this->get_config('limit');
serendipity_request_start();
$req = new HTTP_Request($url, array('allowRedirects' => true, 'maxRedirects' => 3)); if (function_exists('serendipity_request_url')) {
// code 200: OK, code 30x: REDIRECTION $data = serendipity_request_url($url);
if (PEAR::isError($req->sendRequest()) || !preg_match('/200/', $req->getResponseCode())) { $code = $serendipity['last_http_request']['responseCode'];
if ($this->debug) echo "Request failed. (" . $req->getResponseCode() . ")";
serendipity_request_end();
continue;
} else { } else {
$data = $req->getResponseBody(); serendipity_request_start();
serendipity_request_end(); $req = new HTTP_Request($url, array('allowRedirects' => true, 'maxRedirects' => 3));
// code 200: OK, code 30x: REDIRECTION
if (PEAR::isError($req->sendRequest()) || !preg_match('/200/', $req->getResponseCode())) {
if ($this->debug) echo "Request failed. (" . $req->getResponseCode() . ")";
serendipity_request_end();
continue;
} else {
$data = $req->getResponseBody();
serendipity_request_end();
}
}
if (!empty($data)) {
$fb = json_decode($data); $fb = json_decode($data);
#print_r($fb); #print_r($fb);
@ -276,12 +287,17 @@ class serendipity_event_facebook extends serendipity_event {
// NO, link not yet stored. Request final location. // NO, link not yet stored. Request final location.
if ($this->debug) echo "(No metadata yet)\n"; if ($this->debug) echo "(No metadata yet)\n";
serendipity_request_start(); if (function_exists('serendipity_request_url')) {
$subreq = new HTTP_Request($fb_item->link, array('allowRedirects' => true, 'maxRedirects' => 3)); $subdata = serendipity_request_url($fb_item->link);
$ret = $subreq->sendRequest(); $check_url = $serendipity['last_http_request']['effectiveUrl'];
serendipity_request_end(); } else {
serendipity_request_start();
$check_url = $subreq->_url->url; $subreq = new HTTP_Request($fb_item->link, array('allowRedirects' => true, 'maxRedirects' => 3));
$ret = $subreq->sendRequest();
serendipity_request_end();
$check_url = $subreq->_url->url;
}
$entry_id = $this->linkmatch($check_url); $entry_id = $this->linkmatch($check_url);
@ -302,11 +318,15 @@ class serendipity_event_facebook extends serendipity_event {
$curl = 'http://graph.facebook.com/' . $fb_item->id . '/comments'; $curl = 'http://graph.facebook.com/' . $fb_item->id . '/comments';
if ($this->debug) echo $curl . "\n"; if ($this->debug) echo $curl . "\n";
serendipity_request_start(); if (function_exists('serendipity_request_url')) {
$subreq = new HTTP_Request($curl, array('allowRedirects' => true, 'maxRedirects' => 3)); $cdata = serendipity_request_url($curl);
$ret = $subreq->sendRequest(); } else {
$cdata = $subreq->getResponseBody(); serendipity_request_start();
serendipity_request_end(); $subreq = new HTTP_Request($curl, array('allowRedirects' => true, 'maxRedirects' => 3));
$ret = $subreq->sendRequest();
$cdata = $subreq->getResponseBody();
serendipity_request_end();
}
$cfb = json_decode($cdata); $cfb = json_decode($cdata);
#print_r($cfb); #print_r($cfb);

View file

@ -1 +1,5 @@
0.5.2:
-----
* Added serendipity_request_url API method
Properly use the example() API method by returning, not echo'ing. Unimportant update. Properly use the example() API method by returning, not echo'ing. Unimportant update.

View file

@ -31,7 +31,7 @@ class serendipity_event_flickr extends serendipity_event
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('license', 'GPL'); $propbag->add('license', 'GPL');
$propbag->add('author', 'Jay Bertrand'); $propbag->add('author', 'Jay Bertrand');
$propbag->add('version', '0.5.1'); $propbag->add('version', '0.5.2');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.9', 'serendipity' => '0.9',
'smarty' => '2.6.7', 'smarty' => '2.6.7',

View file

@ -1,3 +1,7 @@
1.33.2:
-----
* Added serendipity_request_url API method
1.33 (mattsches) 1.33 (mattsches)
---------------------------------- ----------------------------------
* Fix bug when post title contains apostrophe. * Fix bug when post title contains apostrophe.

View file

@ -1,5 +1,5 @@
<?php <?php
// Actual version of both plugins // Actual version of both plugins
@define('PLUGIN_EVENT_GEOTAG_VERSION', '1.33.1'); @define('PLUGIN_EVENT_GEOTAG_VERSION', '1.33.2');
@define('PLUGIN_EVENT_GEOTAG_AUTHOR', 'Zoran Kovacevic, Grischa Brockhaus, Matthias Gutjahr'); @define('PLUGIN_EVENT_GEOTAG_AUTHOR', 'Zoran Kovacevic, Grischa Brockhaus, Matthias Gutjahr');

View file

@ -281,13 +281,24 @@ class serendipity_event_geotag extends serendipity_event
if($this->get_config('hdr_default_lat') && $this->get_config('hdr_default_long')) { if($this->get_config('hdr_default_lat') && $this->get_config('hdr_default_long')) {
echo '<div class="serendipityAdminMsgSuccess">'; echo '<div class="serendipityAdminMsgSuccess">';
// Try to get the URL // Try to get the URL
include_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$geourl = "http://geourl.org/ping/?p=" . $serendipity['baseURL']; $geourl = "http://geourl.org/ping/?p=" . $serendipity['baseURL'];
$req = new HTTP_Request($geourl);
if (PEAR::isError($req->sendRequest($geourl))) { if (function_exists('serendipity_request_url')) {
printf(REMOTE_FILE_NOT_FOUND, $geourl); $data = serendipity_request_url($geourl);
if (empty($data)) {
printf(REMOTE_FILE_NOT_FOUND, $geourl);
} else {
echo PLUGIN_EVENT_GEOTAG_GEOURL_PINGED;
}
} else { } else {
echo PLUGIN_EVENT_GEOTAG_GEOURL_PINGED; include_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$req = new HTTP_Request($geourl);
if (PEAR::isError($req->sendRequest($geourl))) {
printf(REMOTE_FILE_NOT_FOUND, $geourl);
} else {
echo PLUGIN_EVENT_GEOTAG_GEOURL_PINGED;
}
} }
echo '</div>'; echo '</div>';
} }
@ -707,32 +718,35 @@ class serendipity_event_geotag extends serendipity_event
* Caches a map and streams it back to the browser. * Caches a map and streams it back to the browser.
*/ */
function saveAndResponseMap($url, $lat, $long, $isArticle) { function saveAndResponseMap($url, $lat, $long, $isArticle) {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
global $serendipity; global $serendipity;
$fContent = null; $fContent = null;
if (function_exists('serendipity_request_start')) { if (function_exists('serendipity_request_url')) {
serendipity_request_start(); $fContent = serendipity_request_url($url);
} } else {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$request_pars['allowRedirects'] = TRUE; if (function_exists('serendipity_request_start')) {
$req = new HTTP_Request($url, $request_pars); serendipity_request_start();
}
// if the request leads to an error we don't want to have it: return false $request_pars['allowRedirects'] = TRUE;
if (PEAR::isError($req->sendRequest()) || ($req->getResponseCode() != '200')) { $req = new HTTP_Request($url, $request_pars);
$fContent = null;
} // if the request leads to an error we don't want to have it: return false
else { if (PEAR::isError($req->sendRequest()) || ($req->getResponseCode() != '200')) {
// Allow only images! $fContent = null;
$mime = $req->getResponseHeader("content-type"); }
$mimeparts = explode('/',$mime); else {
if (count($mimeparts)==2 && $mimeparts[0]=='image') { // Allow only images!
$fContent = $req->getResponseBody(); $mime = $req->getResponseHeader("content-type");
$mimeparts = explode('/',$mime);
if (count($mimeparts)==2 && $mimeparts[0]=='image') {
$fContent = $req->getResponseBody();
}
}
if (function_exists('serendipity_request_start')) {
serendipity_request_end();
} }
}
if (function_exists('serendipity_request_start')) {
serendipity_request_end();
} }
// if no content was fetched, return false // if no content was fetched, return false

View file

@ -1,5 +1,7 @@
# 1.4.2:
-----
* Added serendipity_request_url API method
Version 1.3 (brockhaus) Version 1.3 (brockhaus)
------------------------------------------------------------------------ ------------------------------------------------------------------------

View file

@ -32,7 +32,7 @@ class serendipity_event_geourl extends serendipity_event {
$propbag->add('event_hooks', array('frontend_header' => true)); $propbag->add('event_hooks', array('frontend_header' => true));
$propbag->add('configuration', array('lat', 'long')); $propbag->add('configuration', array('lat', 'long'));
$propbag->add('description', PLUGIN_EVENT_GEOURL_DESC); $propbag->add('description', PLUGIN_EVENT_GEOURL_DESC);
$propbag->add('version', '1.4.1'); $propbag->add('version', '1.4.2');
$propbag->add('groups', array('BACKEND_METAINFORMATION')); $propbag->add('groups', array('BACKEND_METAINFORMATION'));
} }
@ -88,14 +88,23 @@ class serendipity_event_geourl extends serendipity_event {
echo '<div class="serendipity_msg_notice">'; echo '<div class="serendipity_msg_notice">';
if($this->get_config('lat') && $this->get_config('long')) { if($this->get_config('lat') && $this->get_config('long')) {
// Try to get the URL // Try to get the URL
include_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$geourl = "http://geourl.org/ping/?p=" . $serendipity['baseURL']; $geourl = "http://geourl.org/ping/?p=" . $serendipity['baseURL'];
$req = new HTTP_Request($geourl);
if (PEAR::isError($req->sendRequest($geourl))) { if (function_exists('serendipity_request_url')) {
printf(REMOTE_FILE_NOT_FOUND, $geourl); $data = serendipity_request_url($geourl);
if (empty($data)) {
printf(REMOTE_FILE_NOT_FOUND, $geourl);
} else {
echo PLUGIN_EVENT_GEOURL_PINGED;
}
} else { } else {
echo PLUGIN_EVENT_GEOURL_PINGED; include_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$req = new HTTP_Request($geourl);
if (PEAR::isError($req->sendRequest($geourl))) {
printf(REMOTE_FILE_NOT_FOUND, $geourl);
} else {
echo PLUGIN_EVENT_GEOURL_PINGED;
}
} }
} else { } else {
echo PLUGIN_EVENT_GEOURL_NOLATLONG; echo PLUGIN_EVENT_GEOURL_NOLATLONG;

View file

@ -1,3 +1,7 @@
0.58.2:
-----
* Added serendipity_request_url API method
0.58: 0.58:
----- -----

View file

@ -30,7 +30,7 @@ class serendipity_event_google_sitemap extends serendipity_event {
$propbag->add('name', PLUGIN_EVENT_SITEMAP_TITLE); $propbag->add('name', PLUGIN_EVENT_SITEMAP_TITLE);
$propbag->add('description', PLUGIN_EVENT_SITEMAP_DESC); $propbag->add('description', PLUGIN_EVENT_SITEMAP_DESC);
$propbag->add('author', 'Boris'); $propbag->add('author', 'Boris');
$propbag->add('version', '0.58.1'); $propbag->add('version', '0.58.2');
$propbag->add('event_hooks', array( $propbag->add('event_hooks', array(
'backend_publish' => true, 'backend_publish' => true,
'backend_save' => true, 'backend_save' => true,
@ -715,14 +715,30 @@ class serendipity_event_google_sitemap extends serendipity_event {
function send_ping($loc) { function send_ping($loc) {
global $serendipity; global $serendipity;
require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
$req = new HTTP_Request($loc);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { if (function_exists('serendipity_request_url')) {
print_r($req); $data = serendipity_request_url($loc);
return false; if (empty($data)) return false;
} else {
return true; return true;
} else {
if (function_exists('serendipity_request_url')) {
$data = serendipity_request_url($loc);
if ($serendipity['last_http_request']['responseCode'] == '200') {
return true;
}
return false;
} else {
require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
$req = new HTTP_Request($loc);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
print_r($req);
return false;
} else {
return true;
}
}
} }
} }
} }

View file

@ -1,5 +1,9 @@
# #
1.04.2:
-----
* Added serendipity_request_url API method
1.04: Properly use the example() API method by returning, not echo'ing. Unimportant update. 1.04: Properly use the example() API method by returning, not echo'ing. Unimportant update.
1.03: 1.03:

View file

@ -14,7 +14,7 @@ TODO:
if (IN_serendipity !== true) { if (IN_serendipity !== true) {
die ("Don't hack!"); die ("Don't hack!");
} }
@define('PLUGIN_EVENT_MOBILE_VERSION','1.04.1'); @define('PLUGIN_EVENT_MOBILE_VERSION','1.04.2');
@define('PLUGIN_EVENT_MOBILE_AUTHORS','Pelle Boese, Grischa Brockhaus'); @define('PLUGIN_EVENT_MOBILE_AUTHORS','Pelle Boese, Grischa Brockhaus');
@define('PLUGIN_EVENT_MOBILE_TPL_IPHONE','iphone.app'); @define('PLUGIN_EVENT_MOBILE_TPL_IPHONE','iphone.app');
@ -574,14 +574,23 @@ class serendipity_event_mobile_output extends serendipity_event
function send_ping($loc) { function send_ping($loc) {
global $serendipity; global $serendipity;
require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
$req = new HTTP_Request($loc);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { if (function_exists('serendipity_request_url')) {
print_r($req); $data = serendipity_request_url($loc);
if ($serendipity['last_http_request']['responseCode'] == '200') {
return true;
}
return false; return false;
} else { } else {
return true; require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
$req = new HTTP_Request($loc);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
print_r($req);
return false;
} else {
return true;
}
} }
} }

View file

@ -1 +1,5 @@
1.6:
-----
* Added serendipity_request_url API method
1.5: Move to the correct nav section for 2.0 backend (yellowled) 1.5: Move to the correct nav section for 2.0 backend (yellowled)

View file

@ -34,9 +34,14 @@ class AmazonSearchEngine {
); );
} }
function doSearch($url) { function doSearch($url) {
$req = new HTTP_Request($url); if (function_exists('serendipity_request_url')) {
$req->sendRequest(); $contents = serendipity_request_url($url);
$contents = $req->getResponseBody(); } else {
$req = new HTTP_Request($url);
$req->sendRequest();
$contents = $req->getResponseBody();
}
if (!xml_parse($this->_parser, $contents)) { if (!xml_parse($this->_parser, $contents)) {
die(sprintf('XML error: %s at line %d', die(sprintf('XML error: %s at line %d',
xml_error_string(xml_get_error_code($this->_parser)), xml_error_string(xml_get_error_code($this->_parser)),

View file

@ -28,7 +28,7 @@ class serendipity_event_motm extends serendipity_event {
$propbag->add('description', PLUGIN_SIDEBAR_MOTM_DESC); $propbag->add('description', PLUGIN_SIDEBAR_MOTM_DESC);
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('author', 'Tys von Gaza'); $propbag->add('author', 'Tys von Gaza');
$propbag->add('version', '1.5'); $propbag->add('version', '1.6');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.8', 'serendipity' => '0.8',
'php' => '4.1.0' 'php' => '4.1.0'

View file

@ -0,0 +1,4 @@
0.10:
-----
* Added serendipity_request_url API method

View file

@ -25,7 +25,7 @@ class serendipity_event_phoneblogz extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_PHONEBLOGZ_DESC); $propbag->add('description', PLUGIN_EVENT_PHONEBLOGZ_DESC);
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking, phoneblogz.com'); $propbag->add('author', 'Garvin Hicking, phoneblogz.com');
$propbag->add('version', '0.9'); $propbag->add('version', '0.10');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.8', 'serendipity' => '0.8',
'smarty' => '2.6.7', 'smarty' => '2.6.7',
@ -206,14 +206,22 @@ class serendipity_event_phoneblogz extends serendipity_event
return array('error' => "Could not write file $new_file."); return array('error' => "Could not write file $new_file.");
} }
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($url); $fc = serendipity_request_url($url);
if ($serendipity['last_http_request']['responseCode'] != '200') {
return array('error' => "Could not download file " . htmlspecialchars($url));
}
return false;
} else {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$req = new HTTP_Request($url);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
return array('error' => "Could not download file " . htmlspecialchars($url)); return array('error' => "Could not download file " . htmlspecialchars($url));
}
$fc = $req->getResponseBody();
} }
$fc = $req->getResponseBody();
$success = @fwrite($ifp, $fc); $success = @fwrite($ifp, $fc);
fclose($ifp); fclose($ifp);
// Set correct file permissions // Set correct file permissions

View file

@ -1,4 +1,8 @@
# #
1.37.2:
-----
* Added serendipity_request_url API method
1.37: 1.37:
* Increased debug verbosity * Increased debug verbosity

View file

@ -14,7 +14,7 @@ if (file_exists($probelang)) {
include_once dirname(__FILE__) . '/lang_en.inc.php'; include_once dirname(__FILE__) . '/lang_en.inc.php';
include_once dirname(__FILE__) . '/podcast_player.php'; include_once dirname(__FILE__) . '/podcast_player.php';
@define("SERENDIPITY_EVENT_PODCAST_VERSION", "1.37.1"); @define("SERENDIPITY_EVENT_PODCAST_VERSION", "1.37.2");
class serendipity_event_podcast extends serendipity_event { class serendipity_event_podcast extends serendipity_event {
/** /**
@ -951,24 +951,35 @@ class serendipity_event_podcast extends serendipity_event{
request and get the size that way (and MD5, if possible). Let's see if this works: request and get the size that way (and MD5, if possible). Let's see if this works:
*/ */
elseif (preg_match('@https?://@', $url)){ elseif (preg_match('@https?://@', $url)){
include_once(S9Y_PEAR_PATH . 'HTTP/Request.php');
if (function_exists('serendipity_request_start')) {
serendipity_request_start();
}
$this->Log("Execute HTTP_Request for $url"); $this->Log("Execute HTTP_Request for $url");
$http = new HTTP_Request($url);
$http->setMethod(HTTP_REQUEST_METHOD_HEAD);
if (!PEAR::isError($http->sendRequest(false))){ if (function_exists('serendipity_request_url')) {
$fileInfo['length'] = intval($http->getResponseHeader('content-length')); $data = serendipity_request_url($url, 'HEAD');
$fileInfo['md5'] = $http->getResponseHeader('content-md5'); //will return false if not present $header = $serendipity['last_http_request']['header'];
$fileInfo['mime'] =$http->getResponseHeader('content-type'); $fileInfo['length'] = intval($header['content-length']);
$fileInfo['md5'] = $header['content-md5']; //will return false if not present
$fileInfo['mime'] = $header['content-type'];
$this->Log("Filling MIME with HTTP Header: " . print_r($fileInfo, true)); $this->Log("Filling MIME with HTTP Header: " . print_r($fileInfo, true));
} } else {
include_once(S9Y_PEAR_PATH . 'HTTP/Request.php');
if (function_exists('serendipity_request_start')) {
serendipity_request_start();
}
if (function_exists('serendipity_request_end')) { $http = new HTTP_Request($url);
serendipity_request_end(); $http->setMethod(HTTP_REQUEST_METHOD_HEAD);
if (!PEAR::isError($http->sendRequest(false))){
$fileInfo['length'] = intval($http->getResponseHeader('content-length'));
$fileInfo['md5'] = $http->getResponseHeader('content-md5'); //will return false if not present
$fileInfo['mime'] = $http->getResponseHeader('content-type');
$this->Log("Filling MIME with HTTP Header: " . print_r($fileInfo, true));
}
if (function_exists('serendipity_request_end')) {
serendipity_request_end();
}
} }
} else { // Not found locally and no URL } else { // Not found locally and no URL
$fileInfo['notfound'] = true; $fileInfo['notfound'] = true;

View file

@ -0,0 +1,5 @@
1.6:
----
Try to change preg_replace('/e/') modifier calls with preg_replace_calllback.
Probably a mess.

View file

@ -0,0 +1,3 @@
1.09:
-----
* Added serendipity_request_url API method

View file

@ -2,7 +2,6 @@
if (IN_serendipity !== true) { die ("Don't hack!"); } if (IN_serendipity !== true) { die ("Don't hack!"); }
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
@serendipity_plugin_api::load_language(dirname(__FILE__)); @serendipity_plugin_api::load_language(dirname(__FILE__));
class serendipity_event_weblogping extends serendipity_event class serendipity_event_weblogping extends serendipity_event
@ -17,7 +16,7 @@ class serendipity_event_weblogping extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_WEBLOGPING_DESC); $propbag->add('description', PLUGIN_EVENT_WEBLOGPING_DESC);
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('author', 'Serendipity Team'); $propbag->add('author', 'Serendipity Team');
$propbag->add('version', '1.08.2'); $propbag->add('version', '1.09');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '1.6', 'serendipity' => '1.6',
'smarty' => '2.6.7', 'smarty' => '2.6.7',
@ -206,28 +205,35 @@ class serendipity_event_weblogping extends serendipity_event
# 15 second timeout may not be long enough for weblogs.com # 15 second timeout may not be long enough for weblogs.com
$message->createPayload(); $message->createPayload();
$options = array();
serendipity_plugin_api::hook_event('backend_http_request', $options, 'weblogping');
serendipity_request_start();
$req = new HTTP_Request("http://".$service['host'].$service['path'], $options);
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addHeader("Content-Type", "text/xml");
if (strtoupper(LANG_CHARSET) != 'UTF-8') { if (strtoupper(LANG_CHARSET) != 'UTF-8') {
$payload = utf8_encode($message->payload); $payload = utf8_encode($message->payload);
} else { } else {
$payload = $message->payload; $payload = $message->payload;
} }
$req->addRawPostData($payload);
$http_result = $req->sendRequest(); if (function_exists('serendipity_request_url')) {
$http_response = $req->getResponseBody(); $http_response = serendipity_request_url("http://".$service['host'].$service['path'], 'POST', 'text/xml', $payload, null, 'weblogping');
} else {
$options = array();
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
serendipity_plugin_api::hook_event('backend_http_request', $options, 'weblogping');
serendipity_request_start();
$req = new HTTP_Request("http://".$service['host'].$service['path'], $options);
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addHeader("Content-Type", "text/xml");
$req->addRawPostData($payload);
$http_result = $req->sendRequest();
$http_response = $req->getResponseBody();
serendipity_request_end();
}
$xmlrpc_result = $message->parseResponse($http_response); $xmlrpc_result = $message->parseResponse($http_response);
if ($xmlrpc_result->faultCode()) { if ($xmlrpc_result->faultCode()) {
$out = sprintf(PLUGIN_EVENT_WEBLOGPING_SEND_FAILURE . "<br />", (function_exists('serendipity_specialchars') ? serendipity_specialchars($xmlrpc_result->faultString()) : htmlspecialchars($xmlrpc_result->faultString(), ENT_COMPAT, LANG_CHARSET))); $out = sprintf(PLUGIN_EVENT_WEBLOGPING_SEND_FAILURE . "<br />", (function_exists('serendipity_specialchars') ? serendipity_specialchars($xmlrpc_result->faultString()) : htmlspecialchars($xmlrpc_result->faultString(), ENT_COMPAT, LANG_CHARSET)));
} else { } else {
$out = PLUGIN_EVENT_WEBLOGPING_SEND_SUCCESS . "<br />"; $out = PLUGIN_EVENT_WEBLOGPING_SEND_SUCCESS . "<br />";
} }
serendipity_request_end();
if (!defined('SERENDIPITY_IS_XMLRPC') || defined('SERENDIPITY_XMLRPC_VERBOSE')) { if (!defined('SERENDIPITY_IS_XMLRPC') || defined('SERENDIPITY_XMLRPC_VERBOSE')) {
echo $out; echo $out;

View file

@ -1,3 +1,7 @@
1.23:
-----
* Added serendipity_request_url API method
1.22: Patch by danst0, added analytics tracking 1.22: Patch by danst0, added analytics tracking
Version 1.21 Version 1.21

View file

@ -1,7 +1,5 @@
<?php # <?php #
require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
if (IN_serendipity !== true) { if (IN_serendipity !== true) {
die ("Don't hack!"); die ("Don't hack!");
} }
@ -22,7 +20,7 @@ class serendipity_plugin_amazon extends serendipity_plugin {
$propbag->add('configuration', array('title','server', 'newwindows', 'small_medium_large','button','asin','cnt','cache','tracking')); $propbag->add('configuration', array('title','server', 'newwindows', 'small_medium_large','button','asin','cnt','cache','tracking'));
$propbag->add('author', 'Matthew Groeninger, (original plugin by Thomas Nesges)'); $propbag->add('author', 'Matthew Groeninger, (original plugin by Thomas Nesges)');
$propbag->add('stackable', true); $propbag->add('stackable', true);
$propbag->add('version', '1.22'); $propbag->add('version', '1.23');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.8', 'serendipity' => '0.8',
'smarty' => '2.6.7', 'smarty' => '2.6.7',

View file

@ -0,0 +1,3 @@
1.25.2:
-----
* Added serendipity_request_url API method

View file

@ -26,17 +26,23 @@ class s9y_audioscrobbler_XMLParser {
xml_parser_free($xml_parser); xml_parser_free($xml_parser);
return $xml_array; return $xml_array;
} }
function getXMLArray($file, $forced_encoding = null) { function getXMLArray($file, $forced_encoding = null) {
require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php'; if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($file); $data = serendipity_request_url($file);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { if (empty($data)) return false;
if ( ini_get( "allow_url_fopen")) {
$data = file_get_contents($file);
} else {
$data = "";
}
} else { } else {
$data = $req->getResponseBody(); require_once (defined('S9Y_PEAR_PATH') ? S9Y_PEAR_PATH : S9Y_INCLUDE_PATH . 'bundled-libs/') . 'HTTP/Request.php';
$req = new HTTP_Request($file);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
if ( ini_get( "allow_url_fopen")) {
$data = file_get_contents($file);
} else {
$data = "";
}
} else {
$data = $req->getResponseBody();
}
} }
if (trim($data)== '') return false; if (trim($data)== '') return false;
return $this->parseXML($data, $forced_encoding); return $this->parseXML($data, $forced_encoding);
@ -63,7 +69,7 @@ class serendipity_plugin_audioscrobbler extends serendipity_plugin {
$propbag->add('description', PLUGIN_AUDIOSCROBBLER_TITLE_BLAHBLAH); $propbag->add('description', PLUGIN_AUDIOSCROBBLER_TITLE_BLAHBLAH);
$propbag->add('stackable', true); $propbag->add('stackable', true);
$propbag->add('author', 'Flo Solcher'); $propbag->add('author', 'Flo Solcher');
$propbag->add('version', '1.25.1'); $propbag->add('version', '1.25.2');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.8', 'serendipity' => '0.8',
'smarty' => '2.6.7', 'smarty' => '2.6.7',

View file

@ -0,0 +1,4 @@
0.12:
-----
* Added serendipity_request_url API method

View file

@ -7,7 +7,7 @@
* *
* @author Lars Strojny <lars@strojny.net> * @author Lars Strojny <lars@strojny.net>
*/ */
@define('SERENDIPITY_PLUGIN_FLICKRBADGE_VERSION', '0.11'); @define('SERENDIPITY_PLUGIN_FLICKRBADGE_VERSION', '0.12');
if (IN_SERENDIPITY != true) die("Don't hack"); if (IN_SERENDIPITY != true) die("Don't hack");

View file

@ -0,0 +1,4 @@
1.9:
-----
* Added serendipity_request_url API method

View file

@ -1,8 +1,5 @@
<?php # <?php #
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
if (IN_serendipity !== true) { if (IN_serendipity !== true) {
die ("Don't hack!"); die ("Don't hack!");
} }
@ -26,7 +23,7 @@ class serendipity_plugin_gallery_menalto_random extends serendipity_plugin {
$propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_DESC); $propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_DESC);
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('author', 'Andrew Brown, Tadashi Jokagi'); $propbag->add('author', 'Andrew Brown, Tadashi Jokagi');
$propbag->add('version', '1.8'); $propbag->add('version', '1.9');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.8', 'serendipity' => '0.8',
'smarty' => '2.6.7', 'smarty' => '2.6.7',
@ -133,16 +130,27 @@ class serendipity_plugin_gallery_menalto_random extends serendipity_plugin {
for ($i=1; $i <= $repeat; $i++) { for ($i=1; $i <= $repeat; $i++) {
$options = array(); $options = array();
$req = new HTTP_Request($path.$file,$options);
$req_result = $req->sendRequest(); if (function_exists('serendipity_request_url')) {
if ( PEAR::isError( $req_result)) { $data = serendipity_request_url($path . $file);
echo PLUGIN_GALLERYRANDOMBLOCK_ERROR_CONNECT . "<br />\n"; if ($serendipity['last_http_request']['responseCode'] != '200') {
} else {
$res_code = $req->getResponseCode();
if ($res_code != "200") {
printf( PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP . "<br />\n", $res_code); printf( PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP . "<br />\n", $res_code);
} else { } else {
echo $req->getResponseBody(); echo $data;
}
} else {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$req = new HTTP_Request($path.$file,$options);
$req_result = $req->sendRequest();
if ( PEAR::isError( $req_result)) {
echo PLUGIN_GALLERYRANDOMBLOCK_ERROR_CONNECT . "<br />\n";
} else {
$res_code = $req->getResponseCode();
if ($res_code != "200") {
printf( PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP . "<br />\n", $res_code);
} else {
echo $req->getResponseBody();
}
} }
} }
if ($i < $repeat) { if ($i < $repeat) {
@ -153,4 +161,3 @@ class serendipity_plugin_gallery_menalto_random extends serendipity_plugin {
} }
} }
/* vim: set sts=4 ts=4 expandtab : */ /* vim: set sts=4 ts=4 expandtab : */
?>

View file

@ -0,0 +1,3 @@
1.4:
-----
* Added serendipity_request_url API method

View file

@ -33,7 +33,7 @@ class serendipity_plugin_ggopis extends serendipity_plugin {
$propbag->add('description', PLUGIN_GGOPIS_DESC); $propbag->add('description', PLUGIN_GGOPIS_DESC);
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('author', 'Piotr Borys'); $propbag->add('author', 'Piotr Borys');
$propbag->add('version', '1.3'); $propbag->add('version', '1.4');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.9', 'serendipity' => '0.9',
'smarty' => '2.6.7', 'smarty' => '2.6.7',
@ -149,20 +149,30 @@ class serendipity_plugin_ggopis extends serendipity_plugin {
// //
// Getting a logon server // Getting a logon server
// //
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; if (function_exists('serendipity_request_url')) {
serendipity_request_start(); $buf = serendipity_request_url('http://appmsg.gadu-gadu.pl:80/appsvc/appmsg.asp?fmnumber=<'.$numer_gg.'>');
$req = new HTTP_Request('http://appmsg.gadu-gadu.pl:80/appsvc/appmsg.asp?fmnumber=<'.$numer_gg.'>'); if ($serendipity['last_http_request']['responseCode'] != '200') {
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { $error = PLUGIN_GGOPIS_MSG_NOCONNTOAPPMSG . $errno . " - " . $errstr . "\n";
$error = PLUGIN_GGOPIS_MSG_NOCONNTOAPPMSG . $errno . " - " . $errstr . "\n"; return false;
serendipity_request_end(); }
return false; } else {
} else { require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$buf = $req->getResponseBody(); serendipity_request_start();
preg_match("/\s([\d\.]{8,16})\:([\d]{1,5})\s/", $buf, $adres); $req = new HTTP_Request('http://appmsg.gadu-gadu.pl:80/appsvc/appmsg.asp?fmnumber=<'.$numer_gg.'>');
$host = $adres[1]; if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
$port = $adres[2]; $error = PLUGIN_GGOPIS_MSG_NOCONNTOAPPMSG . $errno . " - " . $errstr . "\n";
serendipity_request_end(); serendipity_request_end();
} return false;
} else {
$buf = $req->getResponseBody();
serendipity_request_end();
}
}
preg_match("/\s([\d\.]{8,16})\:([\d]{1,5})\s/", $buf, $adres);
$host = $adres[1];
$port = $adres[2];
// //
// Connecting to a server // Connecting to a server

View file

@ -0,0 +1,3 @@
0.10:
-----
* Added serendipity_request_url API method

View file

@ -16,10 +16,14 @@ abstract class serendipity_plugin_heavyrotation_helper_abstract
*/ */
protected function _fetch($url) protected function _fetch($url)
{ {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; if (function_exists('serendipity_request_url')) {
$request = new HTTP_Request($url); return serendipity_request_url($url);
$request->setMethod(HTTP_REQUEST_METHOD_GET); } else {
$request->sendRequest(); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
return $request->getResponseBody(); $request = new HTTP_Request($url);
$request->setMethod(HTTP_REQUEST_METHOD_GET);
$request->sendRequest();
return $request->getResponseBody();
}
} }
} }

View file

@ -7,7 +7,7 @@
* *
* @author Lars Strojny <lars@strojny.net> * @author Lars Strojny <lars@strojny.net>
*/ */
@define('SERENDIPITY_PLUGIN_HEAVYROTATION_VERSION', '0.9'); @define('SERENDIPITY_PLUGIN_HEAVYROTATION_VERSION', '0.10');
if (IN_SERENDIPITY != true) die("Don't hack"); if (IN_SERENDIPITY != true) die("Don't hack");

View file

@ -1 +1,5 @@
0.99:
-----
* Added serendipity_request_url API method
0.98 - add lightbox option for media_sidebar "In Page" only 0.98 - add lightbox option for media_sidebar "In Page" only

View file

@ -221,21 +221,26 @@ class menalto_sidebar extends subplug_sidebar {
$output_str = ''; $output_str = '';
for ($i=1; $i <= $repeat; $i++) { for ($i=1; $i <= $repeat; $i++) {
$options = array();
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; if (function_exists('serendipity_request_url')) {
if (function_exists('serendipity_request_start')) { $output_str .= serendipity_request_url($path . $file);
serendipity_request_start(); } else {
} $options = array();
$req = new HTTP_Request($path.$file,$options); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$req_result = $req->sendRequest(); if (function_exists('serendipity_request_start')) {
if ( PEAR::isError( $req_result)) { serendipity_request_start();
$output_str = $output_str. PLUGIN_GALLERYRANDOMBLOCK_ERROR_CONNECT . "<br />\n"; }
} else { $req = new HTTP_Request($path.$file,$options);
$res_code = $req->getResponseCode(); $req_result = $req->sendRequest();
if ($res_code != "200") { if ( PEAR::isError( $req_result)) {
$output_str = $output_str. sprintf( PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP . "<br />\n", $res_code); $output_str = $output_str. PLUGIN_GALLERYRANDOMBLOCK_ERROR_CONNECT . "<br />\n";
} else { } else {
$output_str = $output_str. $req->getResponseBody(); $res_code = $req->getResponseCode();
if ($res_code != "200") {
$output_str = $output_str. sprintf( PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP . "<br />\n", $res_code);
} else {
$output_str = $output_str. $req->getResponseBody();
}
} }
} }
if ($i < $repeat) { if ($i < $repeat) {

View file

@ -75,7 +75,7 @@ class serendipity_plugin_imagesidebar extends serendipity_plugin {
$propbag->add('description', PLUGIN_SIDEBAR_IMAGESIDEBAR_DESC); $propbag->add('description', PLUGIN_SIDEBAR_IMAGESIDEBAR_DESC);
$propbag->add('stackable', true); $propbag->add('stackable', true);
$propbag->add('author', 'Andrew Brown (Menalto code), Matthew Groeninger (Unified/Media Lib. Code), Stefan Lange-Hegermann (Zooomr Code), Matthew Maude (Coppermine code)'); $propbag->add('author', 'Andrew Brown (Menalto code), Matthew Groeninger (Unified/Media Lib. Code), Stefan Lange-Hegermann (Zooomr Code), Matthew Maude (Coppermine code)');
$propbag->add('version', '0.98'); $propbag->add('version', '0.99');
$propbag->add('license', 'BSD'); $propbag->add('license', 'BSD');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.8', 'serendipity' => '0.8',

View file

@ -101,22 +101,26 @@ class zooomr_sidebar extends subplug_sidebar {
* @return string downloaded Data from "$url" * @return string downloaded Data from "$url"
*/ */
function getURL($url) { function getURL($url) {
$options = array(); if (function_exists('serendipity_request_url')) {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; $store = serendipity_request_url($url);
if (function_exists('serendipity_request_start')) {
serendipity_request_start();
}
$req = new HTTP_Request($url,$options);
$req_result = $req->sendRequest();
if ( PEAR::isError( $req_result)) {
echo PLUGIN_GALLERYRANDOMBLOCK_ERROR_CONNECT . "<br />\n";
} else { } else {
$res_code = $req->getResponseCode(); $options = array();
if ($res_code != "200") { require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
printf( PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP . "<br />\n", $res_code); if (function_exists('serendipity_request_start')) {
serendipity_request_start();
}
$req = new HTTP_Request($url,$options);
$req_result = $req->sendRequest();
if ( PEAR::isError( $req_result)) {
echo PLUGIN_GALLERYRANDOMBLOCK_ERROR_CONNECT . "<br />\n";
} else { } else {
$store = $req->getResponseBody(); $res_code = $req->getResponseCode();
if ($res_code != "200") {
printf( PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP . "<br />\n", $res_code);
} else {
$store = $req->getResponseBody();
}
} }
} }
return $store; return $store;

View file

@ -0,0 +1,3 @@
0.33:
-----
* Added serendipity_request_url API method

View file

@ -33,7 +33,7 @@ class serendipity_plugin_pagerank extends serendipity_plugin
$propbag->add('description', PLUGIN_PAGERANK_DETAIL); $propbag->add('description', PLUGIN_PAGERANK_DETAIL);
$propbag->add('stackable', false); $propbag->add('stackable', false);
$propbag->add('author', 'Christian Lescuyer'); $propbag->add('author', 'Christian Lescuyer');
$propbag->add('version', '0.32'); $propbag->add('version', '0.33');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '0.8', 'serendipity' => '0.8',
'smarty' => '2.6.7', 'smarty' => '2.6.7',
@ -213,11 +213,15 @@ class serendipity_plugin_pagerank extends serendipity_plugin
if (ini_get('allow_url_fopen')) { if (ini_get('allow_url_fopen')) {
$data = file_get_contents($url, 128); $data = file_get_contents($url, 128);
} else { } else {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($url); $data = serendipity_request_url($url);
if (!PEAR::isError($req->sendRequest())) { } else {
$data = $req->getResponseBody(); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
} $req = new HTTP_Request($url);
if (!PEAR::isError($req->sendRequest())) {
$data = $req->getResponseBody();
}
}
} }
$rankarray = explode (':', $data); $rankarray = explode (':', $data);

View file

@ -1,3 +1,6 @@
0.4.2:
* Added serendipity_request_url API method
0.4.1 0.4.1
* set correct requirement version * set correct requirement version

View file

@ -1,6 +1,5 @@
<?php <?php
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
@serendipity_plugin_api::load_language(dirname(__FILE__)); @serendipity_plugin_api::load_language(dirname(__FILE__));
@ -31,7 +30,7 @@ class serendipity_plugin_piwik extends serendipity_plugin
$propbag->add('description', PLUGIN_SIDEBAR_PIWIK_DESC); $propbag->add('description', PLUGIN_SIDEBAR_PIWIK_DESC);
$propbag->add('stackable', true); $propbag->add('stackable', true);
$propbag->add('author', 'Bernd Distler'); $propbag->add('author', 'Bernd Distler');
$propbag->add('version', '0.4.1'); $propbag->add('version', '0.4.2');
$propbag->add('requirements', array( $propbag->add('requirements', array(
'serendipity' => '1.6', 'serendipity' => '1.6',
'smarty' => '2.6.7', 'smarty' => '2.6.7',
@ -278,14 +277,20 @@ class serendipity_plugin_piwik extends serendipity_plugin
*/ */
protected function requestPiwikData($api_url) protected function requestPiwikData($api_url)
{ {
serendipity_request_start();
$req = new HTTP_Request($api_url); if (function_exists('serendipity_request_url')) {
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') { $piwik_fetched = serendipity_request_url($api_url);
$piwik_fetched = file_get_contents($api_url);
} else { } else {
$piwik_fetched = $req->getResponseBody(); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
serendipity_request_start();
$req = new HTTP_Request($api_url);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
$piwik_fetched = file_get_contents($api_url);
} else {
$piwik_fetched = $req->getResponseBody();
}
serendipity_request_end();
} }
serendipity_request_end();
return $piwik_fetched; return $piwik_fetched;
} }

View file

@ -9,6 +9,10 @@ TODO:
* Twitter announcements/credentials etc. per author instead of * Twitter announcements/credentials etc. per author instead of
only per central blog only per central blog
1.67:
-----
* Added serendipity_request_url API method
1.63 1.63
-------------------------- --------------------------
* Fix emitting the backend nav link twice (yellowled) * Fix emitting the backend nav link twice (yellowled)

View file

@ -96,8 +96,7 @@ class Twitter {
* @return entry[] results as array of entry arrays or false, if an error occured * @return entry[] results as array of entry arrays or false, if an error occured
*/ */
function search($search, $entries=null, $fetchall=true) { function search($search, $entries=null, $fetchall=true) {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; global $serendipity;
$search_uri = $this->get_search_url() . '.json?q=' . $search; $search_uri = $this->get_search_url() . '.json?q=' . $search;
// Special Twitter search params // Special Twitter search params
@ -111,18 +110,29 @@ class Twitter {
while ($paging) { while ($paging) {
if (function_exists('serendipity_request_start')) serendipity_request_start(); if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($search_uri, array('timeout' => 20, 'readTimeout' => array(5,0))); $response = trim(serendipity_request_url($search_uri));
$req->sendRequest(); if (empty($response)) return false;
$this->last_error = $req->getResponseCode(); $this->last_error = $serendipity['last_http_request']['responseCode'];
if ($req->getResponseCode() != 200) { if ($this->last_error != 200) {
$this->error_response = $response;
return false;
}
} else {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
if (function_exists('serendipity_request_start')) serendipity_request_start();
$req = new HTTP_Request($search_uri, array('timeout' => 20, 'readTimeout' => array(5,0)));
$req->sendRequest();
$this->last_error = $req->getResponseCode(); $this->last_error = $req->getResponseCode();
$this->error_response = trim($req->getResponseBody()); if ($req->getResponseCode() != 200) {
$this->last_error = $req->getResponseCode();
$this->error_response = trim($req->getResponseBody());
if (function_exists('serendipity_request_start')) serendipity_request_end();
return false;
}
$response = trim($req->getResponseBody());
if (function_exists('serendipity_request_start')) serendipity_request_end(); if (function_exists('serendipity_request_start')) serendipity_request_end();
return false;
} }
$response = trim($req->getResponseBody());
if (function_exists('serendipity_request_start')) serendipity_request_end();
$json = @json_decode($response); $json = @json_decode($response);
@ -206,22 +216,33 @@ class Twitter {
} }
*/ */
function get_twitter_config() { function get_twitter_config() {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; global $serendipity;
$config_url = "https://api.twitter.com/1/help/configuration.json"; $config_url = "https://api.twitter.com/1/help/configuration.json";
if (function_exists('serendipity_request_start')) serendipity_request_start(); if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($config_url, array('timeout' => 20, 'readTimeout' => array(5,0))); $response = serendipity_request_url($config_url);
$req->sendRequest(); if (empty($response)) return false;
// We are static $this->last_error = $serendipity['last_http_request']['responseCode'];
//$this->last_error = $req->getResponseCode(); if ($this->last_error != 200) {
if ($req->getResponseCode() != 200) { $this->error_response = $response;
$this->last_error = $req->getResponseCode(); return false;
$this->error_response = trim($req->getResponseBody()); }
} else {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
if (function_exists('serendipity_request_start')) serendipity_request_start();
$req = new HTTP_Request($config_url, array('timeout' => 20, 'readTimeout' => array(5,0)));
$req->sendRequest();
// We are static
//$this->last_error = $req->getResponseCode();
if ($req->getResponseCode() != 200) {
$this->last_error = $req->getResponseCode();
$this->error_response = trim($req->getResponseBody());
if (function_exists('serendipity_request_start')) serendipity_request_end();
return false;
}
$response = trim($req->getResponseBody());
if (function_exists('serendipity_request_start')) serendipity_request_end(); if (function_exists('serendipity_request_start')) serendipity_request_end();
return false;
} }
$response = trim($req->getResponseBody());
if (function_exists('serendipity_request_start')) serendipity_request_end();
return @json_decode($response); return @json_decode($response);
} }
@ -275,35 +296,48 @@ class Twitter {
} }
function update( $login, $pass, $update, $geo_lat = NULL, $geo_long = NULL ) { function update( $login, $pass, $update, $geo_lat = NULL, $geo_long = NULL ) {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; global $serendipity;
if (empty($login) || empty($pass) || empty($update)) return; if (empty($login) || empty($pass) || empty($update)) return;
$status_url = $this->get_api_url() . 'statuses/update.json'; $status_url = $this->get_api_url() . 'statuses/update.json';
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
if (function_exists('serendipity_request_start')) serendipity_request_start();
$par['user'] = $login; $par['user'] = $login;
$par['pass'] = $pass; $par['pass'] = $pass;
$par['method'] = HTTP_REQUEST_METHOD_POST; $par['method'] = HTTP_REQUEST_METHOD_POST;
$par['timeout'] = 20; $par['timeout'] = 20;
$par['readTimeout'] = array(5,0); $par['readTimeout'] = array(5,0);
$req = new HTTP_Request($status_url, $par);
$update = urlencode($update); $update = urlencode($update);
if (function_exists('serendipity_request_url')) {
$post_data = array(
'status' => $update,
'source' => 's9y',
);
$req->addPostData('status',$update, true); if (!empty($geo_lat) && !empty($geo_long)) {
$req->addPostData('source','s9y', true); $post_data['lat'] = $geo_lat;
if (!empty($geo_lat) && !empty($geo_long)) { $post_data['long'] = $geo_long;
$req->addPostData('lat',$geo_lat, true); }
$req->addPostData('long',$geo_long, true);
$response = serendipity_request_url($status_url, 'POST', null, null, $post_data, null, array('user' => $par['user'], 'pass' => $par['pass']));
if (empty($response)) return false;
$errorcode = $serendipity['last_http_request']['responseCode'];
} else {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
if (function_exists('serendipity_request_start')) serendipity_request_start();
$req = new HTTP_Request($status_url, $par);
$req->addPostData('status',$update, true);
$req->addPostData('source','s9y', true);
if (!empty($geo_lat) && !empty($geo_long)) {
$req->addPostData('lat',$geo_lat, true);
$req->addPostData('long',$geo_long, true);
}
$req->sendRequest();
$response = $req->getResponseBody();
$errorcode = $req->getResponseCode();
if (function_exists('serendipity_request_start')) serendipity_request_end();
} }
$req->sendRequest();
$response = $req->getResponseBody();
$errorcode = $req->getResponseCode();
if (function_exists('serendipity_request_start')) serendipity_request_end();
if ($errorcode == 200) { if ($errorcode == 200) {
$json = @json_decode($response); $json = @json_decode($response);
@ -321,25 +355,32 @@ class Twitter {
// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-friends_timeline // http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-friends_timeline
function timeline( $login, $pass, $count=10, $withfriends=true) { function timeline( $login, $pass, $count=10, $withfriends=true) {
global $serendipity;
if (empty($login) || empty($pass)) return; if (empty($login) || empty($pass)) return;
$timeline_url = $this->get_api_url() . 'statuses/friends_timeline.json?'; $timeline_url = $this->get_api_url() . 'statuses/friends_timeline.json?';
$timeline_url .= "count=$count"; $timeline_url .= "count=$count";
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; if (function_exists('serendipity_request_url')) {
if (function_exists('serendipity_request_start')) serendipity_request_start(); $response = serendipity_request_url($status_url, 'GET', null, null, null, null, array('user' => $par['user'], 'pass' => $par['pass']));
$par['user'] = $login; if (empty($response)) return false;
$par['pass'] = $pass; $errorcode = $serendipity['last_http_request']['responseCode'];
$par['method'] = HTTP_REQUEST_METHOD_GET; } else {
$par['timeout'] = 20; require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$par['readTimeout'] = array(5,0); if (function_exists('serendipity_request_start')) serendipity_request_start();
$par['user'] = $login;
$par['pass'] = $pass;
$par['method'] = HTTP_REQUEST_METHOD_GET;
$par['timeout'] = 20;
$par['readTimeout'] = array(5,0);
$req = new HTTP_Request($timeline_url, $par); $req = new HTTP_Request($timeline_url, $par);
$req->sendRequest(); $req->sendRequest();
$response = trim($req->getResponseBody()); $response = trim($req->getResponseBody());
if (function_exists('serendipity_request_start')) serendipity_request_end(); if (function_exists('serendipity_request_start')) serendipity_request_end();
}
return @json_decode($response); return @json_decode($response);
@ -352,17 +393,19 @@ class Twitter {
return; return;
} }
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$requrl = $this->get_api_url() . 'users/show.json?screen_name=' . $screenname; $requrl = $this->get_api_url() . 'users/show.json?screen_name=' . $screenname;
if (function_exists('serendipity_request_start')) serendipity_request_start(); if (function_exists('serendipity_request_url')) {
$response = serendipity_request_url($requrl);
$req = new HTTP_Request($requrl); if (empty($response)) return false;
$req->sendRequest(); } else {
$response = trim($req->getResponseBody()); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
if (function_exists('serendipity_request_start')) serendipity_request_start();
if (function_exists('serendipity_request_start')) serendipity_request_end(); $req = new HTTP_Request($requrl);
$req->sendRequest();
$response = trim($req->getResponseBody());
if (function_exists('serendipity_request_start')) serendipity_request_end();
}
return @json_decode($response); return @json_decode($response);
} }

View file

@ -109,17 +109,23 @@ class UrlShortener {
* @access private * @access private
*/ */
function shorten_via_simple( &$shorturls, $servicename, $servicecall ) { function shorten_via_simple( &$shorturls, $servicename, $servicecall ) {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
// if we already evaluated the shorturl, stop here // if we already evaluated the shorturl, stop here
if (!empty($shorturls[$servicename])) return; if (!empty($shorturls[$servicename])) return;
serendipity_request_start(); if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($servicecall, array('timeout' => 20, 'readTimeout' => array(5,0))); $short_url = serendipity_request_url($servicecall);
$req->sendRequest(); if (empty($short_url)) return false;
$short_url = $req->getResponseBody(); } else {
serendipity_request_end(); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
if ($req->getResponseCode()==200) {
serendipity_request_start();
$req = new HTTP_Request($servicecall, array('timeout' => 20, 'readTimeout' => array(5,0)));
$req->sendRequest();
$short_url = $req->getResponseBody();
serendipity_request_end();
}
if (!empty($short_url)) {
$short_url = trim($short_url); $short_url = trim($short_url);
if (strlen($short_url)<255) { // Should be an URL at least if (strlen($short_url)<255) { // Should be an URL at least
$shorturls[$servicename] = trim($short_url); $shorturls[$servicename] = trim($short_url);
@ -153,19 +159,26 @@ class UrlShortener {
// works *sometimes* // works *sometimes*
// tinyburner.com // tinyburner.com
function shorten_via_twurl( $url, &$shorturls ) { function shorten_via_twurl( $url, &$shorturls ) {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
// if we already evaluated the shorturl, stop here // if we already evaluated the shorturl, stop here
if (!empty($shorturls['twurl'])) return; if (!empty($shorturls['twurl'])) return;
serendipity_request_start();
$req_url = "http://tweetburner.com/links"; $req_url = "http://tweetburner.com/links";
$req = new HTTP_Request($req_url, array('method' => HTTP_REQUEST_METHOD_POST, 'timeout' => 20, 'readTimeout' => array(5,0)));
$req->addPostData('link[url]',$url, true); if (function_exists('serendipity_request_url')) {
$req->sendRequest(); $short_url = serendipity_request_url($req_url, 'POST', null, array('link[url]' => $url));
$short_url = trim($req->getResponseBody()); if (empty($short_url)) return false;
serendipity_request_end(); } else {
if ($req->getResponseCode()==200) { require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
serendipity_request_start();
$req = new HTTP_Request($req_url, array('method' => HTTP_REQUEST_METHOD_POST, 'timeout' => 20, 'readTimeout' => array(5,0)));
$req->addPostData('link[url]',$url, true);
$req->sendRequest();
$short_url = trim($req->getResponseBody());
serendipity_request_end();
}
if ($short_url != '') {
$shorturls['twurl'] = $short_url; $shorturls['twurl'] = $short_url;
} }
} }
@ -202,22 +215,26 @@ class UrlShortener {
/* bit.ly called via api */ /* bit.ly called via api */
function _make_bitly_api_url($url,$format = 'xml',$domain='bit.ly') function _make_bitly_api_url($url,$format = 'xml',$domain='bit.ly')
{ {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
//create the API Call URL //create the API Call URL
$bitly = 'http://api.bit.ly/v3/shorten?longUrl='.urlencode($url).'&login='.$this->bitly_login.'&apiKey='.$this->bitly_apikey.'&format='.$format.'&domain='.$domain; $bitly = 'http://api.bit.ly/v3/shorten?longUrl='.urlencode($url).'&login='.$this->bitly_login.'&apiKey='.$this->bitly_apikey.'&format='.$format.'&domain='.$domain;
//get the url //get the url
serendipity_request_start(); if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($bitly, array('timeout' => 20, 'readTimeout' => array(5,0))); $response = serendipity_request_url($bitlyreq_url, 'POST');
$req->sendRequest(); if (empty($response)) return false;
$response = $req->getResponseBody(); } else {
serendipity_request_end(); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
if ($req->getResponseCode()!=200) { serendipity_request_start();
return false; $req = new HTTP_Request($bitly, array('timeout' => 20, 'readTimeout' => array(5,0)));
} $req->sendRequest();
if (strlen($response) < 1) { $response = $req->getResponseBody();
return false; serendipity_request_end();
if ($req->getResponseCode()!=200) {
return false;
}
if (strlen($response) < 1) {
return false;
}
} }
//parse depending on desired format //parse depending on desired format
@ -242,8 +259,6 @@ class UrlShortener {
* Doesn't work realy and is ultra slow.. * Doesn't work realy and is ultra slow..
*/ */
function shorten_via_delivr( $url, &$shorturls ) { function shorten_via_delivr( $url, &$shorturls ) {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
// if we already evaluated the shorturl, stop here // if we already evaluated the shorturl, stop here
if (!empty($shorturls['delivr'])) return; if (!empty($shorturls['delivr'])) return;
@ -253,13 +268,19 @@ class UrlShortener {
$url = urlencode($url); $url = urlencode($url);
$req_url = "http://api.delivr.com/shorten?username=$login&apiKey=$apikey&format=xml&url=" . $url; $req_url = "http://api.delivr.com/shorten?username=$login&apiKey=$apikey&format=xml&url=" . $url;
serendipity_request_start(); if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($req_url, array('timeout' => 20, 'readTimeout' => array(5,0))); $xml = serendipity_request_url($req_url);
$req->sendRequest(); if (empty($xml)) return false;
$xml = $req->getResponseBody(); } else {
serendipity_request_end(); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
serendipity_request_start();
$req = new HTTP_Request($req_url, array('timeout' => 20, 'readTimeout' => array(5,0)));
$req->sendRequest();
$xml = $req->getResponseBody();
serendipity_request_end();
}
if ($req->getResponseCode()==200) { if ($xml != '') {
$vals = array(); $vals = array();
$index = array(); $index = array();
$parser = xml_parser_create(); $parser = xml_parser_create();

View file

@ -1,4 +1,4 @@
<?php <?php
// Actual version of both plugins // Actual version of both plugins
@define('PLUGIN_TWITTER_VERSION', '1.66'); @define('PLUGIN_TWITTER_VERSION', '1.67');

View file

@ -1859,7 +1859,6 @@ a.twitter_update_time {
function updateTwitterTimelineCache($parts){ function updateTwitterTimelineCache($parts){
global $serendipity; global $serendipity;
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
if (count($parts)<5) return time() + (60 * 60); // params corrupted next try allowed one minute later if (count($parts)<5) return time() + (60 * 60); // params corrupted next try allowed one minute later
@ -1922,12 +1921,19 @@ a.twitter_update_time {
$search_twitter_uri = 'https://api.twitter.com/1/statuses/user_timeline.json?screen_name=' . $username . '&count=' . $number; $search_twitter_uri = 'https://api.twitter.com/1/statuses/user_timeline.json?screen_name=' . $username . '&count=' . $number;
} }
serendipity_request_start();
$req = new HTTP_Request($search_twitter_uri); if (function_exists('serendipity_request_url')) {
$req->sendRequest(); $response = serendipity_request_url($search_twitter_uri);
$response = trim($req->getResponseBody()); $error = $serendipity['last_http_request']['responseCode'];
$error = $req->getResponseCode(); } else {
serendipity_request_end(); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
serendipity_request_start();
$req = new HTTP_Request($search_twitter_uri);
$req->sendRequest();
$response = trim($req->getResponseBody());
$error = $req->getResponseCode();
serendipity_request_end();
}
} }
$this->log("error: {$error}"); $this->log("error: {$error}");

View file

@ -421,8 +421,7 @@ class serendipity_plugin_twitter extends serendipity_plugin {
$cachetime = (int)$this->get_config('cachetime', 300); $cachetime = (int)$this->get_config('cachetime', 300);
if (!file_exists($cachefile) || filemtime($cachefile) < (time()-$cachetime)) { if (!file_exists($cachefile) || filemtime($cachefile) < (time()-$cachetime)) {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$service = $this->get_config('service'); $service = $this->get_config('service');
$username = $this->get_config('username'); $username = $this->get_config('username');
$number = $this->get_config('number'); $number = $this->get_config('number');
@ -442,12 +441,18 @@ class serendipity_plugin_twitter extends serendipity_plugin {
$search_twitter_uri = 'https://api.twitter.com/1/statuses/user_timeline.json?screen_name=' . $username . '&count=' . $number; $search_twitter_uri = 'https://api.twitter.com/1/statuses/user_timeline.json?screen_name=' . $username . '&count=' . $number;
} }
serendipity_request_start(); if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($search_twitter_uri); $response = serendipity_request_url($search_twitter_uri);
$req->sendRequest(); $error = $serendipity['last_http_request']['responseCode'];
$response = trim($req->getResponseBody()); } else {
$error = $req->getResponseCode(); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
serendipity_request_end(); serendipity_request_start();
$req = new HTTP_Request($search_twitter_uri);
$req->sendRequest();
$response = trim($req->getResponseBody());
$error = $req->getResponseCode();
serendipity_request_end();
}
if ($error==200 &&!empty($response)) { if ($error==200 &&!empty($response)) {
$fp = fopen($cachefile, 'w'); $fp = fopen($cachefile, 'w');

View file

@ -195,6 +195,7 @@ class TwitterOAuth {
* @return API results * @return API results
*/ */
function http($url, $method, $postfields = NULL) { function http($url, $method, $postfields = NULL) {
global $serendipity;
$this->http_info = array(); $this->http_info = array();
if (function_exists('curl_init')) { if (function_exists('curl_init')) {
@ -230,32 +231,41 @@ class TwitterOAuth {
$this->url = $url; $this->url = $url;
curl_close ($ci); curl_close ($ci);
} else { } else {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; if (function_exists('serendipity_request_url')) {
serendipity_request_start(); if ($method == 'DELETE' && !empty($postfields)) {
$req = new HTTP_Request($url);
switch ($method) {
case 'POST':
$req->setMethod(HTTP_REQUEST_METHOD_POST);
if (!empty($postfields)) {
$fields = explode('&', $postfields);
foreach($fields AS $field) {
$data = explode('=', $field);
$req->addPostData($data[0], $data[1], true);
}
}
break;
case 'DELETE':
$req->setMethod(HTTP_REQUEST_METHOD_DELETE);
if (!empty($postfields)) {
$url = "{$url}?{$postfields}"; $url = "{$url}?{$postfields}";
} }
} $response = trim(serendipity_request_url($url, $method, null, $postfields));
$this->url = $url;
$this->http_code = $serendipity['last_http_request']['responseCode'];
} else {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
serendipity_request_start();
$req = new HTTP_Request($url);
$req->sendRequest(); switch ($method) {
$response = trim($req->getResponseBody()); case 'POST':
$this->url = $url; $req->setMethod(HTTP_REQUEST_METHOD_POST);
$this->http_code = $req->getResponseCode(); if (!empty($postfields)) {
$fields = explode('&', $postfields);
foreach($fields AS $field) {
$data = explode('=', $field);
$req->addPostData($data[0], $data[1], true);
}
}
break;
case 'DELETE':
$req->setMethod(HTTP_REQUEST_METHOD_DELETE);
if (!empty($postfields)) {
$url = "{$url}?{$postfields}";
}
}
$req->sendRequest();
$response = trim($req->getResponseBody());
$this->url = $url;
$this->http_code = $req->getResponseCode();
}
serendipity_event_twitter::twitteroalog($url . " - " . $postfields . " (Code: " . $this->http_code . ")\n" . $response); serendipity_event_twitter::twitteroalog($url . " - " . $postfields . " (Code: " . $this->http_code . ")\n" . $response);

View file

@ -0,0 +1,3 @@
0.4:
-----
* Added serendipity_request_url API method

View file

@ -23,14 +23,18 @@ class serendipity_plugin_zooomr extends serendipity_plugin {
*/ */
function get_url($url) function get_url($url)
{ {
require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; if (function_exists('serendipity_request_url')) {
$req = new HTTP_Request($url); return serendipity_request_url($url);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
$store = file_get_contents($url);
} else { } else {
$store = $req->getResponseBody(); require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
} $req = new HTTP_Request($url);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
$store = file_get_contents($url);
} else {
$store = $req->getResponseBody();
}
}
return $store; return $store;
} }
@ -100,7 +104,7 @@ class serendipity_plugin_zooomr extends serendipity_plugin {
'smarty' => '2.6.7', 'smarty' => '2.6.7',
'php' => '4.1.0' 'php' => '4.1.0'
)); ));
$propbag->add('version', '0.3'); $propbag->add('version', '0.4');
$propbag->add('author', 'Stefan Lange-Hegermann'); $propbag->add('author', 'Stefan Lange-Hegermann');
$propbag->add('configuration', array('title', 'feed','imagecount','imagewidth', 'dlink','logo')); $propbag->add('configuration', array('title', 'feed','imagecount','imagewidth', 'dlink','logo'));