blob: b0a767822da9c9332a779ef71af19caf13e4defd [file] [log] [blame]
Derek Allard2067d1a2008-11-13 22:59:24 +00001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
Greg Aker0711dc82011-01-05 10:49:40 -06009 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
Derek Allard2067d1a2008-11-13 22:59:24 +000010 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
12 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * Trackback Class
20 *
21 * Trackback Sending/Receiving Class
22 *
23 * @package CodeIgniter
24 * @subpackage Libraries
25 * @category Trackbacks
26 * @author ExpressionEngine Dev Team
27 * @link http://codeigniter.com/user_guide/libraries/trackback.html
28 */
29class CI_Trackback {
Barry Mienydd671972010-10-04 16:33:58 +020030
Derek Allard2067d1a2008-11-13 22:59:24 +000031 var $time_format = 'local';
32 var $charset = 'UTF-8';
33 var $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '');
34 var $convert_ascii = TRUE;
35 var $response = '';
36 var $error_msg = array();
37
38 /**
39 * Constructor
40 *
41 * @access public
42 */
Greg Akera9263282010-11-10 15:26:43 -060043 public function __construct()
Derek Allard2067d1a2008-11-13 22:59:24 +000044 {
45 log_message('debug', "Trackback Class Initialized");
46 }
Barry Mienydd671972010-10-04 16:33:58 +020047
Derek Allard2067d1a2008-11-13 22:59:24 +000048 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +020049
Derek Allard2067d1a2008-11-13 22:59:24 +000050 /**
51 * Send Trackback
52 *
53 * @access public
54 * @param array
55 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +020056 */
Derek Allard2067d1a2008-11-13 22:59:24 +000057 function send($tb_data)
Barry Mienydd671972010-10-04 16:33:58 +020058 {
Derek Allard2067d1a2008-11-13 22:59:24 +000059 if ( ! is_array($tb_data))
60 {
61 $this->set_error('The send() method must be passed an array');
62 return FALSE;
63 }
Barry Mienydd671972010-10-04 16:33:58 +020064
Derek Allard2067d1a2008-11-13 22:59:24 +000065 // Pre-process the Trackback Data
66 foreach (array('url', 'title', 'excerpt', 'blog_name', 'ping_url') as $item)
67 {
68 if ( ! isset($tb_data[$item]))
69 {
70 $this->set_error('Required item missing: '.$item);
71 return FALSE;
72 }
Barry Mienydd671972010-10-04 16:33:58 +020073
Derek Allard2067d1a2008-11-13 22:59:24 +000074 switch ($item)
75 {
76 case 'ping_url' : $$item = $this->extract_urls($tb_data[$item]);
77 break;
78 case 'excerpt' : $$item = $this->limit_characters($this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
79 break;
Barry Mienydd671972010-10-04 16:33:58 +020080 case 'url' : $$item = str_replace('&#45;', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
Derek Allard2067d1a2008-11-13 22:59:24 +000081 break;
82 default : $$item = $this->convert_xml(strip_tags(stripslashes($tb_data[$item])));
83 break;
84 }
85
86 // Convert High ASCII Characters
87 if ($this->convert_ascii == TRUE)
88 {
89 if ($item == 'excerpt')
90 {
91 $$item = $this->convert_ascii($$item);
92 }
93 elseif ($item == 'title')
94 {
95 $$item = $this->convert_ascii($$item);
96 }
Pascal Kriete14287f32011-02-14 13:39:34 -050097 elseif ($item == 'blog_name')
Derek Allard2067d1a2008-11-13 22:59:24 +000098 {
99 $$item = $this->convert_ascii($$item);
100 }
101 }
102 }
103
104 // Build the Trackback data string
105 $charset = ( ! isset($tb_data['charset'])) ? $this->charset : $tb_data['charset'];
Barry Mienydd671972010-10-04 16:33:58 +0200106
Derek Allard2067d1a2008-11-13 22:59:24 +0000107 $data = "url=".rawurlencode($url)."&title=".rawurlencode($title)."&blog_name=".rawurlencode($blog_name)."&excerpt=".rawurlencode($excerpt)."&charset=".rawurlencode($charset);
Barry Mienydd671972010-10-04 16:33:58 +0200108
Derek Allard2067d1a2008-11-13 22:59:24 +0000109 // Send Trackback(s)
110 $return = TRUE;
111 if (count($ping_url) > 0)
112 {
113 foreach ($ping_url as $url)
114 {
115 if ($this->process($url, $data) == FALSE)
116 {
117 $return = FALSE;
118 }
Barry Mienydd671972010-10-04 16:33:58 +0200119 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000120 }
121
122 return $return;
123 }
Barry Mienydd671972010-10-04 16:33:58 +0200124
Derek Allard2067d1a2008-11-13 22:59:24 +0000125 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200126
Derek Allard2067d1a2008-11-13 22:59:24 +0000127 /**
128 * Receive Trackback Data
129 *
130 * This function simply validates the incoming TB data.
Derek Jones5052e272010-03-02 22:53:38 -0600131 * It returns FALSE on failure and TRUE on success.
Derek Allard2067d1a2008-11-13 22:59:24 +0000132 * If the data is valid it is set to the $this->data array
133 * so that it can be inserted into a database.
134 *
135 * @access public
136 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200137 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000138 function receive()
Barry Mienydd671972010-10-04 16:33:58 +0200139 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000140 foreach (array('url', 'title', 'blog_name', 'excerpt') as $val)
141 {
142 if ( ! isset($_POST[$val]) OR $_POST[$val] == '')
143 {
144 $this->set_error('The following required POST variable is missing: '.$val);
145 return FALSE;
146 }
Barry Mienydd671972010-10-04 16:33:58 +0200147
Derek Allard2067d1a2008-11-13 22:59:24 +0000148 $this->data['charset'] = ( ! isset($_POST['charset'])) ? 'auto' : strtoupper(trim($_POST['charset']));
Barry Mienydd671972010-10-04 16:33:58 +0200149
Derek Allard2067d1a2008-11-13 22:59:24 +0000150 if ($val != 'url' && function_exists('mb_convert_encoding'))
151 {
152 $_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']);
153 }
Barry Mienydd671972010-10-04 16:33:58 +0200154
Derek Allard2067d1a2008-11-13 22:59:24 +0000155 $_POST[$val] = ($val != 'url') ? $this->convert_xml(strip_tags($_POST[$val])) : strip_tags($_POST[$val]);
Barry Mienydd671972010-10-04 16:33:58 +0200156
Derek Allard2067d1a2008-11-13 22:59:24 +0000157 if ($val == 'excerpt')
158 {
159 $_POST['excerpt'] = $this->limit_characters($_POST['excerpt']);
160 }
Barry Mienydd671972010-10-04 16:33:58 +0200161
Derek Allard2067d1a2008-11-13 22:59:24 +0000162 $this->data[$val] = $_POST[$val];
163 }
164
165 return TRUE;
Barry Mienydd671972010-10-04 16:33:58 +0200166 }
167
Derek Allard2067d1a2008-11-13 22:59:24 +0000168 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200169
Derek Allard2067d1a2008-11-13 22:59:24 +0000170 /**
171 * Send Trackback Error Message
172 *
173 * Allows custom errors to be set. By default it
174 * sends the "incomplete information" error, as that's
175 * the most common one.
176 *
177 * @access public
178 * @param string
179 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200180 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000181 function send_error($message = 'Incomplete Information')
182 {
183 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>1</error>\n<message>".$message."</message>\n</response>";
184 exit;
185 }
Barry Mienydd671972010-10-04 16:33:58 +0200186
Derek Allard2067d1a2008-11-13 22:59:24 +0000187 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200188
Derek Allard2067d1a2008-11-13 22:59:24 +0000189 /**
190 * Send Trackback Success Message
191 *
192 * This should be called when a trackback has been
193 * successfully received and inserted.
194 *
195 * @access public
196 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200197 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000198 function send_success()
199 {
200 echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>0</error>\n</response>";
201 exit;
202 }
Barry Mienydd671972010-10-04 16:33:58 +0200203
Derek Allard2067d1a2008-11-13 22:59:24 +0000204 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200205
Derek Allard2067d1a2008-11-13 22:59:24 +0000206 /**
207 * Fetch a particular item
208 *
209 * @access public
210 * @param string
211 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200212 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000213 function data($item)
214 {
215 return ( ! isset($this->data[$item])) ? '' : $this->data[$item];
216 }
217
218 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200219
Derek Allard2067d1a2008-11-13 22:59:24 +0000220 /**
221 * Process Trackback
222 *
223 * Opens a socket connection and passes the data to
Derek Jones5052e272010-03-02 22:53:38 -0600224 * the server. Returns TRUE on success, FALSE on failure
Derek Allard2067d1a2008-11-13 22:59:24 +0000225 *
226 * @access public
227 * @param string
228 * @param string
229 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200230 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000231 function process($url, $data)
232 {
233 $target = parse_url($url);
Barry Mienydd671972010-10-04 16:33:58 +0200234
Derek Allard2067d1a2008-11-13 22:59:24 +0000235 // Open the socket
236 if ( ! $fp = @fsockopen($target['host'], 80))
237 {
238 $this->set_error('Invalid Connection: '.$url);
239 return FALSE;
240 }
241
242 // Build the path
243 $ppath = ( ! isset($target['path'])) ? $url : $target['path'];
Barry Mienydd671972010-10-04 16:33:58 +0200244
Derek Allard2067d1a2008-11-13 22:59:24 +0000245 $path = (isset($target['query']) && $target['query'] != "") ? $ppath.'?'.$target['query'] : $ppath;
246
247 // Add the Trackback ID to the data string
248 if ($id = $this->get_id($url))
249 {
250 $data = "tb_id=".$id."&".$data;
251 }
252
253 // Transfer the data
254 fputs ($fp, "POST " . $path . " HTTP/1.0\r\n" );
255 fputs ($fp, "Host: " . $target['host'] . "\r\n" );
256 fputs ($fp, "Content-type: application/x-www-form-urlencoded\r\n" );
257 fputs ($fp, "Content-length: " . strlen($data) . "\r\n" );
258 fputs ($fp, "Connection: close\r\n\r\n" );
259 fputs ($fp, $data);
260
261 // Was it successful?
262 $this->response = "";
Barry Mienydd671972010-10-04 16:33:58 +0200263
Pascal Kriete14287f32011-02-14 13:39:34 -0500264 while ( ! feof($fp))
Derek Allard2067d1a2008-11-13 22:59:24 +0000265 {
266 $this->response .= fgets($fp, 128);
267 }
268 @fclose($fp);
Barry Mienydd671972010-10-04 16:33:58 +0200269
270
Derek Jones1322ec52009-03-11 17:01:14 +0000271 if (stristr($this->response, '<error>0</error>') === FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000272 {
273 $message = 'An unknown error was encountered';
Barry Mienydd671972010-10-04 16:33:58 +0200274
Derek Allard2067d1a2008-11-13 22:59:24 +0000275 if (preg_match("/<message>(.*?)<\/message>/is", $this->response, $match))
276 {
277 $message = trim($match['1']);
278 }
Barry Mienydd671972010-10-04 16:33:58 +0200279
Derek Allard2067d1a2008-11-13 22:59:24 +0000280 $this->set_error($message);
281 return FALSE;
282 }
283
284 return TRUE;
285 }
Barry Mienydd671972010-10-04 16:33:58 +0200286
Derek Allard2067d1a2008-11-13 22:59:24 +0000287 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200288
Derek Allard2067d1a2008-11-13 22:59:24 +0000289 /**
290 * Extract Trackback URLs
291 *
292 * This function lets multiple trackbacks be sent.
293 * It takes a string of URLs (separated by comma or
294 * space) and puts each URL into an array
295 *
296 * @access public
297 * @param string
298 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200299 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000300 function extract_urls($urls)
Barry Mienydd671972010-10-04 16:33:58 +0200301 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000302 // Remove the pesky white space and replace with a comma.
303 $urls = preg_replace("/\s*(\S+)\s*/", "\\1,", $urls);
Barry Mienydd671972010-10-04 16:33:58 +0200304
Derek Allard2067d1a2008-11-13 22:59:24 +0000305 // If they use commas get rid of the doubles.
306 $urls = str_replace(",,", ",", $urls);
Barry Mienydd671972010-10-04 16:33:58 +0200307
Derek Allard2067d1a2008-11-13 22:59:24 +0000308 // Remove any comma that might be at the end
309 if (substr($urls, -1) == ",")
310 {
311 $urls = substr($urls, 0, -1);
312 }
Barry Mienydd671972010-10-04 16:33:58 +0200313
Derek Allard2067d1a2008-11-13 22:59:24 +0000314 // Break into an array via commas
315 $urls = preg_split('/[,]/', $urls);
Barry Mienydd671972010-10-04 16:33:58 +0200316
Derek Allard2067d1a2008-11-13 22:59:24 +0000317 // Removes duplicates
318 $urls = array_unique($urls);
Barry Mienydd671972010-10-04 16:33:58 +0200319
Derek Allard2067d1a2008-11-13 22:59:24 +0000320 array_walk($urls, array($this, 'validate_url'));
Barry Mienydd671972010-10-04 16:33:58 +0200321
Derek Allard2067d1a2008-11-13 22:59:24 +0000322 return $urls;
323 }
Barry Mienydd671972010-10-04 16:33:58 +0200324
Derek Allard2067d1a2008-11-13 22:59:24 +0000325 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200326
Derek Allard2067d1a2008-11-13 22:59:24 +0000327 /**
328 * Validate URL
329 *
330 * Simply adds "http://" if missing
331 *
332 * @access public
333 * @param string
334 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200335 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000336 function validate_url($url)
337 {
338 $url = trim($url);
339
340 if (substr($url, 0, 4) != "http")
341 {
342 $url = "http://".$url;
343 }
344 }
Barry Mienydd671972010-10-04 16:33:58 +0200345
Derek Allard2067d1a2008-11-13 22:59:24 +0000346 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200347
Derek Allard2067d1a2008-11-13 22:59:24 +0000348 /**
349 * Find the Trackback URL's ID
350 *
351 * @access public
352 * @param string
353 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200354 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000355 function get_id($url)
Barry Mienydd671972010-10-04 16:33:58 +0200356 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000357 $tb_id = "";
Barry Mienydd671972010-10-04 16:33:58 +0200358
Robin Sowell76b369e2010-03-19 11:15:28 -0400359 if (strpos($url, '?') !== FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000360 {
361 $tb_array = explode('/', $url);
362 $tb_end = $tb_array[count($tb_array)-1];
Barry Mienydd671972010-10-04 16:33:58 +0200363
Derek Allard2067d1a2008-11-13 22:59:24 +0000364 if ( ! is_numeric($tb_end))
365 {
366 $tb_end = $tb_array[count($tb_array)-2];
367 }
Barry Mienydd671972010-10-04 16:33:58 +0200368
Derek Allard2067d1a2008-11-13 22:59:24 +0000369 $tb_array = explode('=', $tb_end);
370 $tb_id = $tb_array[count($tb_array)-1];
371 }
372 else
373 {
Derek Jones1322ec52009-03-11 17:01:14 +0000374 $url = rtrim($url, '/');
Barry Mienydd671972010-10-04 16:33:58 +0200375
Derek Allard2067d1a2008-11-13 22:59:24 +0000376 $tb_array = explode('/', $url);
377 $tb_id = $tb_array[count($tb_array)-1];
Barry Mienydd671972010-10-04 16:33:58 +0200378
Derek Allard2067d1a2008-11-13 22:59:24 +0000379 if ( ! is_numeric($tb_id))
380 {
381 $tb_id = $tb_array[count($tb_array)-2];
382 }
Barry Mienydd671972010-10-04 16:33:58 +0200383 }
384
Derek Allard2067d1a2008-11-13 22:59:24 +0000385 if ( ! preg_match ("/^([0-9]+)$/", $tb_id))
386 {
Derek Jones5052e272010-03-02 22:53:38 -0600387 return FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000388 }
389 else
390 {
391 return $tb_id;
Barry Mienydd671972010-10-04 16:33:58 +0200392 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000393 }
Barry Mienydd671972010-10-04 16:33:58 +0200394
Derek Allard2067d1a2008-11-13 22:59:24 +0000395 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200396
Derek Allard2067d1a2008-11-13 22:59:24 +0000397 /**
398 * Convert Reserved XML characters to Entities
399 *
400 * @access public
401 * @param string
402 * @return string
403 */
404 function convert_xml($str)
405 {
406 $temp = '__TEMP_AMPERSANDS__';
Barry Mienydd671972010-10-04 16:33:58 +0200407
Derek Allard2067d1a2008-11-13 22:59:24 +0000408 $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
409 $str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
Barry Mienydd671972010-10-04 16:33:58 +0200410
Derek Allard2067d1a2008-11-13 22:59:24 +0000411 $str = str_replace(array("&","<",">","\"", "'", "-"),
Barry Mienydd671972010-10-04 16:33:58 +0200412 array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
413 $str);
414
Derek Allard2067d1a2008-11-13 22:59:24 +0000415 $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
416 $str = preg_replace("/$temp(\w+);/","&\\1;", $str);
Barry Mienydd671972010-10-04 16:33:58 +0200417
Derek Allard2067d1a2008-11-13 22:59:24 +0000418 return $str;
Barry Mienydd671972010-10-04 16:33:58 +0200419 }
420
Derek Allard2067d1a2008-11-13 22:59:24 +0000421 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200422
Derek Allard2067d1a2008-11-13 22:59:24 +0000423 /**
424 * Character limiter
425 *
426 * Limits the string based on the character count. Will preserve complete words.
427 *
428 * @access public
429 * @param string
430 * @param integer
431 * @param string
432 * @return string
433 */
434 function limit_characters($str, $n = 500, $end_char = '&#8230;')
435 {
436 if (strlen($str) < $n)
437 {
438 return $str;
439 }
Barry Mienydd671972010-10-04 16:33:58 +0200440
Derek Allard2067d1a2008-11-13 22:59:24 +0000441 $str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
Barry Mienydd671972010-10-04 16:33:58 +0200442
Derek Allard2067d1a2008-11-13 22:59:24 +0000443 if (strlen($str) <= $n)
444 {
445 return $str;
446 }
Barry Mienydd671972010-10-04 16:33:58 +0200447
Derek Allard2067d1a2008-11-13 22:59:24 +0000448 $out = "";
449 foreach (explode(' ', trim($str)) as $val)
450 {
Barry Mienydd671972010-10-04 16:33:58 +0200451 $out .= $val.' ';
Derek Allard2067d1a2008-11-13 22:59:24 +0000452 if (strlen($out) >= $n)
453 {
454 return trim($out).$end_char;
Barry Mienydd671972010-10-04 16:33:58 +0200455 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000456 }
457 }
Barry Mienydd671972010-10-04 16:33:58 +0200458
Derek Allard2067d1a2008-11-13 22:59:24 +0000459 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200460
Derek Allard2067d1a2008-11-13 22:59:24 +0000461 /**
462 * High ASCII to Entities
463 *
464 * Converts Hight ascii text and MS Word special chars
465 * to character entities
466 *
467 * @access public
468 * @param string
469 * @return string
470 */
471 function convert_ascii($str)
472 {
Barry Mienydd671972010-10-04 16:33:58 +0200473 $count = 1;
474 $out = '';
475 $temp = array();
476
477 for ($i = 0, $s = strlen($str); $i < $s; $i++)
478 {
479 $ordinal = ord($str[$i]);
480
481 if ($ordinal < 128)
482 {
483 $out .= $str[$i];
484 }
485 else
486 {
487 if (count($temp) == 0)
488 {
489 $count = ($ordinal < 224) ? 2 : 3;
490 }
491
492 $temp[] = $ordinal;
493
494 if (count($temp) == $count)
495 {
496 $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
497
498 $out .= '&#'.$number.';';
499 $count = 1;
500 $temp = array();
501 }
502 }
503 }
504
505 return $out;
Derek Allard2067d1a2008-11-13 22:59:24 +0000506 }
Barry Mienydd671972010-10-04 16:33:58 +0200507
Derek Allard2067d1a2008-11-13 22:59:24 +0000508 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200509
Derek Allard2067d1a2008-11-13 22:59:24 +0000510 /**
511 * Set error message
512 *
513 * @access public
514 * @param string
515 * @return void
Barry Mienydd671972010-10-04 16:33:58 +0200516 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000517 function set_error($msg)
518 {
519 log_message('error', $msg);
520 $this->error_msg[] = $msg;
521 }
Barry Mienydd671972010-10-04 16:33:58 +0200522
Derek Allard2067d1a2008-11-13 22:59:24 +0000523 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200524
Derek Allard2067d1a2008-11-13 22:59:24 +0000525 /**
526 * Show error messages
527 *
528 * @access public
529 * @param string
530 * @param string
531 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200532 */
Derek Allard2067d1a2008-11-13 22:59:24 +0000533 function display_errors($open = '<p>', $close = '</p>')
Barry Mienydd671972010-10-04 16:33:58 +0200534 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000535 $str = '';
536 foreach ($this->error_msg as $val)
537 {
538 $str .= $open.$val.$close;
539 }
Barry Mienydd671972010-10-04 16:33:58 +0200540
Derek Allard2067d1a2008-11-13 22:59:24 +0000541 return $str;
542 }
543
544}
545// END Trackback Class
546
547/* End of file Trackback.php */
Derek Jonesa3ffbbb2008-05-11 18:18:29 +0000548/* Location: ./system/libraries/Trackback.php */