summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorGreg Aker <greg@gregaker.net>2011-12-27 08:40:26 +0100
committerGreg Aker <greg@gregaker.net>2011-12-27 08:40:26 +0100
commitd6a874038bec160dbcc07f1410ce8a242a9d977e (patch)
tree1393674e68724d9460fb41e648ba6ecc4e699f28 /system
parent51ba4387d7ca788e4bbfd6c2ac8208d8c2167f8c (diff)
parentcdf0c01f65f0b024fedc474a988957ed45a771e7 (diff)
Merge pull request #828 from narfbg/develop-trackback
Improve the Trackback library
Diffstat (limited to 'system')
-rw-r--r--system/libraries/Trackback.php68
1 files changed, 15 insertions, 53 deletions
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index 1e5928314..b5e68507f 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -47,11 +47,6 @@ class CI_Trackback {
public $response = '';
public $error_msg = array();
- /**
- * Constructor
- *
- * @access public
- */
public function __construct()
{
log_message('debug', "Trackback Class Initialized");
@@ -62,7 +57,6 @@ class CI_Trackback {
/**
* Send Trackback
*
- * @access public
* @param array
* @return bool
*/
@@ -96,20 +90,9 @@ class CI_Trackback {
}
// Convert High ASCII Characters
- if ($this->convert_ascii == TRUE)
+ if ($this->convert_ascii == TRUE && in_array($item, array('excerpt', 'title', 'blog_name')))
{
- if ($item == 'excerpt')
- {
- $$item = $this->convert_ascii($$item);
- }
- elseif ($item == 'title')
- {
- $$item = $this->convert_ascii($$item);
- }
- elseif ($item == 'blog_name')
- {
- $$item = $this->convert_ascii($$item);
- }
+ $$item = $this->convert_ascii($$item);
}
}
@@ -144,7 +127,6 @@ class CI_Trackback {
* If the data is valid it is set to the $this->data array
* so that it can be inserted into a database.
*
- * @access public
* @return bool
*/
public function receive()
@@ -186,7 +168,6 @@ class CI_Trackback {
* sends the "incomplete information" error, as that's
* the most common one.
*
- * @access public
* @param string
* @return void
*/
@@ -204,7 +185,6 @@ class CI_Trackback {
* This should be called when a trackback has been
* successfully received and inserted.
*
- * @access public
* @return void
*/
public function send_success()
@@ -218,7 +198,6 @@ class CI_Trackback {
/**
* Fetch a particular item
*
- * @access public
* @param string
* @return string
*/
@@ -235,7 +214,6 @@ class CI_Trackback {
* Opens a socket connection and passes the data to
* the server. Returns TRUE on success, FALSE on failure
*
- * @access public
* @param string
* @param string
* @return bool
@@ -280,15 +258,9 @@ class CI_Trackback {
@fclose($fp);
- if (stristr($this->response, '<error>0</error>') === FALSE)
+ if (stripos($this->response, '<error>0</error>') === FALSE)
{
- $message = 'An unknown error was encountered';
-
- if (preg_match("/<message>(.*?)<\/message>/is", $this->response, $match))
- {
- $message = trim($match['1']);
- }
-
+ $message = (preg_match('/<message>(.*?)<\/message>/is', $this->response, $match)) ? trim($match[1]) : 'An unknown error was encountered';
$this->set_error($message);
return FALSE;
}
@@ -305,7 +277,6 @@ class CI_Trackback {
* It takes a string of URLs (separated by comma or
* space) and puts each URL into an array
*
- * @access public
* @param string
* @return string
*/
@@ -318,7 +289,7 @@ class CI_Trackback {
$urls = str_replace(",,", ",", $urls);
// Remove any comma that might be at the end
- if (substr($urls, -1) == ",")
+ if (substr($urls, -1) === ',')
{
$urls = substr($urls, 0, -1);
}
@@ -341,7 +312,6 @@ class CI_Trackback {
*
* Simply adds "http://" if missing
*
- * @access public
* @param string
* @return string
*/
@@ -349,9 +319,9 @@ class CI_Trackback {
{
$url = trim($url);
- if (substr($url, 0, 4) != "http")
+ if (strpos($url, 'http') !== 0)
{
- $url = "http://".$url;
+ $url = 'http://'.$url;
}
}
@@ -360,7 +330,6 @@ class CI_Trackback {
/**
* Find the Trackback URL's ID
*
- * @access public
* @param string
* @return string
*/
@@ -409,7 +378,6 @@ class CI_Trackback {
/**
* Convert Reserved XML characters to Entities
*
- * @access public
* @param string
* @return string
*/
@@ -417,15 +385,13 @@ class CI_Trackback {
{
$temp = '__TEMP_AMPERSANDS__';
- $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
- $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
+ $str = preg_replace(array('/&#(\d+);/', '/&(\w+);/'), "$temp\\1;", $str);
$str = str_replace(array("&","<",">","\"", "'", "-"),
array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
$str);
- $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
- $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
+ $str = preg_replace(array("/$temp(\d+);/", "/$temp(\w+);/"), array('&#\\1;', '&\\1;'), $str);
return $str;
}
@@ -437,7 +403,6 @@ class CI_Trackback {
*
* Limits the string based on the character count. Will preserve complete words.
*
- * @access public
* @param string
* @param integer
* @param string
@@ -457,13 +422,13 @@ class CI_Trackback {
return $str;
}
- $out = "";
+ $out = '';
foreach (explode(' ', trim($str)) as $val)
{
$out .= $val.' ';
if (strlen($out) >= $n)
{
- return trim($out).$end_char;
+ return rtrim($out).$end_char;
}
}
}
@@ -476,7 +441,6 @@ class CI_Trackback {
* Converts Hight ascii text and MS Word special chars
* to character entities
*
- * @access public
* @param string
* @return string
*/
@@ -496,16 +460,16 @@ class CI_Trackback {
}
else
{
- if (count($temp) == 0)
+ if (count($temp) === 0)
{
$count = ($ordinal < 224) ? 2 : 3;
}
$temp[] = $ordinal;
- if (count($temp) == $count)
+ if (count($temp) === $count)
{
- $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+ $number = ($count == 3) ? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64) : (($temp[0] % 32) * 64) + ($temp[1] % 64);
$out .= '&#'.$number.';';
$count = 1;
@@ -522,7 +486,6 @@ class CI_Trackback {
/**
* Set error message
*
- * @access public
* @param string
* @return void
*/
@@ -537,7 +500,6 @@ class CI_Trackback {
/**
* Show error messages
*
- * @access public
* @param string
* @param string
* @return string