}
return $css;
}
-
+
/**
* @return string
* @param string
$tidy_config = array('drop-empty-paras' => true,
'drop-proprietary-attributes' => true,
'hide-comments' => true,
- 'logical-emphasis' => true,
+ 'logical-emphasis' => true,
'output-xhtml' => true,
'replace-color' => true,
'join-classes' => false,
// Use inlined style instead of old html attributes
if ($to_xhtml) {
$source = preg_replace('/<(\/?\w+)(.*?)(\/?>)/muise', "'<\\1' . banana_cleanStyles('\\1', '\\2') . '\\3'", $source);
- }
+ }
return preg_replace('/<(.*?)>/ie', "'<'.banana_removeEvilAttributes('\\1').'>'", $source);
}
$res = trim(strip_tags($res, '<div><br><p><blockquote>'));
$res = preg_replace("@</?(br|p|div).*?>@si", "\n", $res);
$res = banana__convertQuotes($res);
- return banana_html_entity_decode($res);
+ return banana_html_entity_decode($res);
}
function banana_formatHtml(BananaMimePart $part)
$text = banana_catchHtmlSignature($text);
if (!Banana::$msgshow_externalimages) {
$text = banana_hideExternalImages($text);
- }
+ }
$text = banana_catchPartLinks($text);
return banana_cleanHtml($text, true);
}
public function hasXFace()
{
- return Banana::$msgshow_xface &&
+ return Banana::$msgshow_xface &&
((function_exists('hook_hasxface') && hook_hasXFace($this->headers))
|| isset($this->headers['x-face']));
}
$this->body = null;
$this->format = null;
$this->id = null;
- }
+ }
}
public function addAttachment(array $file, $content_type = null, $disposition = 'attachment')
return trim($matches[1]);
}
return null;
- }
+ }
protected function fromRaw($data)
{
foreach ($parts as &$part) {
$newpart = new BananaMimePart($part);
if (!is_null($newpart->content_type)) {
- if ($signed && $newpart->content_type == $this->signature['protocole']) {
+ if ($signed && $newpart->content_type == $this->signature['protocole']) {
$signature = $newpart->body;
- } elseif ($signed) {
- $signed_message = $part;
- }
+ } elseif ($signed) {
+ $signed_message = $part;
+ }
$this->multipart[] = $newpart;
}
}
private function findUUEncoded()
{
$this->decodeContent();
- $parts = array();
+ $parts = array();
if (preg_match_all("/\n(begin \d+ ([^\r\n]+)\r?(?:\n(?!end)[^\n]*)*\nend)/",
$this->body, $matches, PREG_SET_ORDER)) {
foreach ($matches as &$match) {
$content = "";
if ($with_headers) {
foreach ($this->getHeaders() as $key => $value) {
- $line = "$key: $value";
+ $line = "$key: $value";
$line = explode("\n", wordwrap($line, Banana::$msgshow_wrap));
for ($i = 1 ; $i < count($line) ; $i++) {
$line[$i] = "\t" . $line[$i];
}
$content .= implode("\n", $line) . "\n";
- }
+ }
$content .= "\n";
- }
+ }
if ($this->isType('multipart')) {
$this->setBoundary();
foreach ($this->multipart as &$part) {
public function getText()
{
- $signed =& $this->getSignedPart();
- if ($signed !== $this) {
- return $signed->getText();
+ $signed =& $this->getSignedPart();
+ if ($signed !== $this) {
+ return $signed->getText();
}
$this->decodeContent();
return $this->body;
# Socket functions
/** get a line from server
- * @return STRING
+ * @return STRING
*/
private function &getLine()
{
private function putLine($line, $format = false)
{
if ($format) {
- $line = str_replace(array("\r", "\n"), '', $line);
+ $line = str_replace(array("\r", "\n"), '', $line);
$line .= "\r\n";
}
if ($this->debug) {
/** retrieves an article
* MSGID is a numeric ID a shown in article's headers. MSGNUM is a
- * server-dependent ID (see X-Ref on many servers) and retriving
+ * server-dependent ID (see X-Ref on many servers) and retriving
* an article by this way will change the current article pointer.
- * If an error occur, false is returned.
+ * If an error occur, false is returned.
* @param $_msgid STRING MSGID or MSGNUM of article
* @return ARRAY lines of the article
* @see body
/** post a message
* if an error occur, false is returned
* @param $_message STRING message to post
- * @return STRING MSGID of article
+ * @return STRING MSGID of article
*/
public function post($message)
{
}
/** set current group
- * @param $_group STRING
+ * @param $_group STRING
* @return ARRAY array : nb of articles in group, MSGNUM of first article, MSGNUM of last article, and group name
*/
public function group($group)
return gmdate("ymd His", $since) . ' GMT';
}
- /** get information about recent newsgroups
+ /** get information about recent newsgroups
* same as list, but information are limited to newgroups created after $_since
* @param $_since INTEGER unix timestamp
- * @param $_distributions STRING distributions
+ * @param $_distributions STRING distributions
* @return ARRAY same format as liste
* @see liste
*/
/** gets a list of new articles
* @param $_since INTEGER unix timestamp
- * @parma $_groups STRING pattern of intersting groups
+ * @parma $_groups STRING pattern of intersting groups
* @return ARRAY MSGID of new articles
*/
public function newnews($groups = '*', $since = 0, $distributions = '')
/** implements IHAVE method
* @param $_msgid STRING MSGID of article
* @param $_message STRING article
- * @return BOOLEAN
+ * @return BOOLEAN
*/
public function ihave($msgid, $message = false)
{
# NNTP Extensions [RFC 2980]
/** Returns the date on the remote server
- * @return INTEGER timestamp
+ * @return INTEGER timestamp
*/
public function date()
/** obtain the header field $hdr for all the messages specified
* @param $_hdr STRING name of the header (eg: 'From')
- * @param $_range STRING range of articles
+ * @param $_range STRING range of articles
* @return ARRAY MSGNUM => header value
*/
public function xhdr($hdr, $first = null, $last = null)
/** obtain the header field $_hdr matching $_pat for all the messages specified
* @param $_hdr STRING name of the header (eg: 'From')
- * @param $_range STRING range of articles
+ * @param $_range STRING range of articles
* @param $_pat STRING pattern
* @return ARRAY MSGNUM => header value
*/
}
}
-// vim:set et sw=4 sts=4 ts=4 enc=utf-8:
+// vim:set et sw=4 sts=4 ts=4 enc=utf-8:
?>
/** Indicate if the Protocole handler has been succesfully built
*/
public function isValid();
-
+
/** Indicate last error n°
*/
public function lastErrNo();
-
+
/** Indicate last error text
*/
public function lastError();
* @param id Id of the emssage (can be either an Message-id or a message index)
* @return The sources of the message (or null)
*/
- public function getMessageSource($id);
+ public function getMessageSource($id);
/** Return the indexes of the messages presents in the Box
* @return Array(number of messages, MSGNUM of the first message, MSGNUM of the last message)
-<?php\r
-/********************************************************************************\r
-* banana/text.php : text tools\r
-* ---------------\r
-*\r
-* This file is part of the banana distribution\r
-* Copyright: See COPYING files that comes with this distribution\r
-********************************************************************************/\r
-\r
-if (function_exists('dgettext')) {\r
- function _b_($str)\r
- {\r
- return dgettext('banana', $str);\r
- }\r
-} else {\r
- function _b_($str)\r
- {\r
- return $str;\r
- }\r
-}\r
-\r
-if (!function_exists('is_utf8')) {\r
- function is_utf8($s)\r
- {\r
- return @iconv('utf-8', 'utf-8', $s) == $s;\r
- }\r
-}\r
-\r
-function banana_entities($source)\r
-{\r
- if (is_string($source)) {\r
- return banana_htmlentities($source);\r
- } else {\r
- return $source;\r
- }\r
-}\r
-\r
-function banana_utf8entities($source)\r
-{\r
- // array used to figure what number to decrement from character order value \r
- // according to number of characters used to map unicode to ascii by utf-8\r
- $decrement[4] = 240;\r
- $decrement[3] = 224;\r
- $decrement[2] = 192;\r
- $decrement[1] = 0;\r
- \r
- // the number of bits to shift each charNum by\r
- $shift[1][0] = 0;\r
- $shift[2][0] = 6;\r
- $shift[2][1] = 0;\r
- $shift[3][0] = 12;\r
- $shift[3][1] = 6;\r
- $shift[3][2] = 0;\r
- $shift[4][0] = 18;\r
- $shift[4][1] = 12;\r
- $shift[4][2] = 6;\r
- $shift[4][3] = 0;\r
- \r
- $pos = 0;\r
- $len = strlen($source);\r
- $encodedString = '';\r
- while ($pos < $len)\r
- {\r
- $charPos = $source{$pos};\r
- $asciiPos = ord($charPos);\r
- if ($asciiPos < 128)\r
- {\r
- $encodedString .= $charPos;\r
- $pos++;\r
- continue;\r
- }\r
- \r
- $i=1;\r
- if (($asciiPos >= 240) && ($asciiPos <= 255)) // 4 chars representing one unicode character\r
- $i=4;\r
- else if (($asciiPos >= 224) && ($asciiPos <= 239)) // 3 chars representing one unicode character\r
- $i=3;\r
- else if (($asciiPos >= 192) && ($asciiPos <= 223)) // 2 chars representing one unicode character\r
- $i=2;\r
- else // 1 char (lower ascii)\r
- $i=1;\r
- $thisLetter = substr($source, $pos, $i);\r
- $pos += $i;\r
- \r
- // process the string representing the letter to a unicode entity\r
- $thisLen = strlen($thisLetter);\r
- $thisPos = 0;\r
- $decimalCode = 0;\r
- while ($thisPos < $thisLen)\r
- {\r
- $thisCharOrd = ord(substr($thisLetter, $thisPos, 1));\r
- if ($thisPos == 0)\r
- {\r
- $charNum = intval($thisCharOrd - $decrement[$thisLen]);\r
- $decimalCode += ($charNum << $shift[$thisLen][$thisPos]);\r
- }\r
- else\r
- {\r
- $charNum = intval($thisCharOrd - 128);\r
- $decimalCode += ($charNum << $shift[$thisLen][$thisPos]);\r
- }\r
- \r
- $thisPos++;\r
- }\r
- \r
- $encodedLetter = '&#'. str_pad($decimalCode, ($thisLen==1)?3:5, '0', STR_PAD_LEFT).';';\r
- $encodedString .= $encodedLetter;\r
- }\r
- \r
- return $encodedString;\r
-}\r
-\r
-// vim:set et sw=4 sts=4 ts=4 enc=utf-8:\r
-?>\r
+<?php
+/********************************************************************************
+* banana/text.php : text tools
+* ---------------
+*
+* This file is part of the banana distribution
+* Copyright: See COPYING files that comes with this distribution
+********************************************************************************/
+
+if (function_exists('dgettext')) {
+ function _b_($str)
+ {
+ return dgettext('banana', $str);
+ }
+} else {
+ function _b_($str)
+ {
+ return $str;
+ }
+}
+
+if (!function_exists('is_utf8')) {
+ function is_utf8($s)
+ {
+ return @iconv('utf-8', 'utf-8', $s) == $s;
+ }
+}
+
+function banana_entities($source)
+{
+ if (is_string($source)) {
+ return banana_htmlentities($source);
+ } else {
+ return $source;
+ }
+}
+
+function banana_utf8entities($source)
+{
+ // array used to figure what number to decrement from character order value
+ // according to number of characters used to map unicode to ascii by utf-8
+ $decrement[4] = 240;
+ $decrement[3] = 224;
+ $decrement[2] = 192;
+ $decrement[1] = 0;
+
+ // the number of bits to shift each charNum by
+ $shift[1][0] = 0;
+ $shift[2][0] = 6;
+ $shift[2][1] = 0;
+ $shift[3][0] = 12;
+ $shift[3][1] = 6;
+ $shift[3][2] = 0;
+ $shift[4][0] = 18;
+ $shift[4][1] = 12;
+ $shift[4][2] = 6;
+ $shift[4][3] = 0;
+
+ $pos = 0;
+ $len = strlen($source);
+ $encodedString = '';
+ while ($pos < $len)
+ {
+ $charPos = $source{$pos};
+ $asciiPos = ord($charPos);
+ if ($asciiPos < 128)
+ {
+ $encodedString .= $charPos;
+ $pos++;
+ continue;
+ }
+
+ $i=1;
+ if (($asciiPos >= 240) && ($asciiPos <= 255)) // 4 chars representing one unicode character
+ $i=4;
+ else if (($asciiPos >= 224) && ($asciiPos <= 239)) // 3 chars representing one unicode character
+ $i=3;
+ else if (($asciiPos >= 192) && ($asciiPos <= 223)) // 2 chars representing one unicode character
+ $i=2;
+ else // 1 char (lower ascii)
+ $i=1;
+ $thisLetter = substr($source, $pos, $i);
+ $pos += $i;
+
+ // process the string representing the letter to a unicode entity
+ $thisLen = strlen($thisLetter);
+ $thisPos = 0;
+ $decimalCode = 0;
+ while ($thisPos < $thisLen)
+ {
+ $thisCharOrd = ord(substr($thisLetter, $thisPos, 1));
+ if ($thisPos == 0)
+ {
+ $charNum = intval($thisCharOrd - $decrement[$thisLen]);
+ $decimalCode += ($charNum << $shift[$thisLen][$thisPos]);
+ }
+ else
+ {
+ $charNum = intval($thisCharOrd - 128);
+ $decimalCode += ($charNum << $shift[$thisLen][$thisPos]);
+ }
+
+ $thisPos++;
+ }
+
+ $encodedLetter = '&#'. str_pad($decimalCode, ($thisLen==1)?3:5, '0', STR_PAD_LEFT).';';
+ $encodedString .= $encodedLetter;
+ }
+
+ return $encodedString;
+}
+
+// vim:set et sw=4 sts=4 ts=4 enc=utf-8:
+?>