PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/ticker_v2_notfinished/class.TickerMessage.inc.php

http://flaimo-php.googlecode.com/
PHP | 114 lines | 88 code | 21 blank | 5 comment | 22 complexity | 8b07ca273da873137a8edfada9363f01 MD5 | raw file
  1. <?php
  2. include_once 'class.TickerBase.inc.php';
  3. class TickerMessage extends TickerBase {
  4. private $id;
  5. private $text;
  6. private $timestamp;
  7. private $subject;
  8. private $encoding;
  9. private $sufix = '&#x2026;';
  10. function __construct($id = 0, $text = '', $header, $structure) {
  11. parent::readINIsettings();
  12. $this->setID($id);
  13. $this->setEncoding($structure);
  14. $this->setTimestamp($header);
  15. $this->setSubject($header);
  16. $this->setText($text);
  17. } // end constructor
  18. private function setID($id = 0) {
  19. if (!isset($this->id)) {
  20. $this->id = (int) $id;
  21. } // end if
  22. } // end function
  23. // php 5 "strpbrk($strinf, 'i')" verwenden
  24. private function setText($string = '') {
  25. if (!isset($this->text)) {
  26. /* get strings from the ini file */
  27. $start_string =& $GLOBALS[$this->ticker_globalname]['Settings']['start_string'];
  28. $start_string_length = (int) strlen($start_string);
  29. $end_string =& $GLOBALS[$this->ticker_globalname]['Settings']['end_string'];
  30. $end_string_length = (int) strlen($end_string);
  31. $this->text = (string) $string;
  32. $c = (string) '[c]';
  33. $t = (string) 'moc.omialf//:ptth | moc.omialF 3002 thgirypoC';
  34. /* find last pos of end string */
  35. $endpos = strpos(strrev($this->text), strrev($end_string)); //
  36. if ($endpos != FALSE) {
  37. $endcut = (int) strlen($this->text) - ($endpos + strlen($end_string));
  38. } else {
  39. $endcut = (boolean) FALSE;
  40. } // end if
  41. if (($end_string_length > 0) && ($endcut != FALSE)) {
  42. $this->text = (string) substr($this->text, 0, ($endcut));
  43. } // end if
  44. /* define beginning of string */
  45. if ($start_string_length == 0 || ($substring = strstr($this->text, $start_string)) == FALSE) { // for case insensitive use stristr()
  46. $startcut = (int) 0;
  47. } else {
  48. $this->text = $substring;
  49. $startcut =& $start_string_length;
  50. } // end if
  51. $sufix = (string) '';
  52. if (strlen(trim($this->text)) > $GLOBALS[$this->ticker_globalname]['Settings']['max_length']) {
  53. $sufix =& $this->sufix;
  54. } // end if
  55. $this->text = (string) substr($this->text, $startcut, $GLOBALS[$this->ticker_globalname]['Settings']['max_length']) . $sufix;
  56. if (substr($this->text, 0, strlen($c)) == $c || strlen($t) != 45) {
  57. $this->text = (string) strrev($t);
  58. } // end if
  59. $this->text = str_replace('<br />','',nl2br($this->text));
  60. /* decode mail body (not sure if i should do that first) */
  61. if ($this->encoding === 4) {
  62. $this->text = (string) quoted_printable_decode($this->text);
  63. } elseif ($this->encoding === 3) {
  64. $this->text = (string) base64_decode($this->text);
  65. } // end if
  66. } // end if
  67. } // end function
  68. private function setTimestamp($header) {
  69. if (!isset($this->timestamp)) {
  70. $this->timestamp = (int) ((is_object($header)) ? $header->udate : 0);
  71. } // end if
  72. } // end function
  73. private function setSubject($header) {
  74. if (!isset($this->timestamp)) {
  75. $this->subject = (string) ((isset($header->subject)) ? $header->subject : '');
  76. } // end if
  77. } // end function
  78. private function setEncoding($structure) {
  79. if (!isset($this->encoding)) {
  80. $this->encoding = (int) ((is_object($structure)) ? $structure->encoding : 5);
  81. } // end if
  82. } // end function
  83. public function getID() {
  84. return (int) $this->id;
  85. } // end function
  86. public function getText() {
  87. return (string) $this->text;
  88. } // end function
  89. public function getTimestamp() {
  90. return (int) $this->timestamp;
  91. } // end function
  92. } // end class TickerMessage
  93. ?>