private function li($lines) { //-- $markup = $this->lines($lines); //-- $trimmedMarkup = trim($markup); //-- if (!in_array('', $lines) and SmartUnicode::sub_str($trimmedMarkup, 0, 3) === '<p>') { //-- $markup = $trimmedMarkup; $markup = SmartUnicode::sub_str($markup, 3); //-- $position = SmartUnicode::str_pos($markup, '</p>'); //-- $markup = substr_replace($markup, '', $position, 4); //-- } //end if //-- return $markup; //-- }
private function _parseHeaderValue($input) { //-- if (($pos = SmartUnicode::str_pos($input, ';')) !== false) { //-- $return['value'] = trim(SmartUnicode::sub_str($input, 0, $pos)); $input = trim(SmartUnicode::sub_str($input, $pos + 1)); //-- if (strlen($input) > 0) { //-- This splits on a semi-colon, if there's no preceeding backslash. Can't handle if it's in double quotes however. (Of course anyone sending that needs a good slap). $parameters = preg_split('/\\s*(?<!\\\\);\\s*/i', (string) $input); //-- for ($i = 0; $i < Smart::array_size($parameters); $i++) { //-- $param_name = trim(SmartUnicode::sub_str($parameters[$i], 0, $pos = SmartUnicode::str_pos($parameters[$i], '='))); // added TRIM to fix invalid ' = ' case $param_value = trim(SmartUnicode::sub_str($parameters[$i], $pos + 1)); // added TRIM to fix invalid ' = ' case //-- if ((string) $param_value[0] == '"') { $param_value = SmartUnicode::sub_str($param_value, 1, -1); } //end if //-- $return['other'][$param_name] = $param_value; $return['other'][SmartUnicode::str_tolower($param_name)] = $param_value; //-- } //end for //-- } //end if //-- } else { //-- $return['value'] = trim($input); //-- } //end if else //-- return $return; //-- }
public function data_send($msg_data) { //-- if ($this->debug) { $this->log .= '[INF] Data-Send command is sent on Mail Server' . "\n"; } //end if //-- if (strlen($this->error) > 0) { return 0; } //end if //-- $reply = $this->send_cmd('DATA'); if (strlen($this->error) > 0) { return 0; } //end if //-- $test = $this->answer_code($reply); if ((string) $test != '354') { $this->error = '[ERR] Data-Send command Failed on Server :: ' . $test . ' // ' . $reply; return 0; } //end if //-- // The server is ready to accept data. According to rfc 821 we should not send more than 1000 characters including the CRLF on a single line // so we will break the data up into lines by \r and/or \n then if needed we will break each of those into smaller lines to fit within the limit. // In addition we will be looking for lines that start with a period '.' and append and additional period '.' to that line. // NOTE: this does not count towards are limit. //-- normalize the line breaks so we know the explode works $msg_data = str_replace(array("\r\n", "\r"), array("\n", "\n"), $msg_data); // replacing the CRLF to LF $lines = (array) explode("\n", (string) $msg_data); $msg_data = ''; // cleanup //-- // We need to find a good way to determine if headers are in the msg_data or if it is a straight msg body. // Currently assuming rfc 822 definitions of msg headers and if the first field of the first line (':' sperated) does not contain a space // then it _should_ be a header and we can process all lines before a blank "" line as headers. //-- $field = SmartUnicode::sub_str($lines[0], 0, SmartUnicode::str_pos($lines[0], ':')); $in_headers = false; //-- if (strlen($field) > 0 and !SmartUnicode::str_contains($field, ' ')) { $in_headers = true; } //end if //-- $max_line_length = 800; // used below ; set here for ease in change (we use a lower value than 1000 as we use UTF-8 text) //-- //while(list(,$line) = @each($lines)) { while (list($key, $line) = @each($lines)) { // FIX to be compatible with the upcoming PHP 7 //-- $lines_out = null; //-- if ((string) $line == '' and $in_headers) { $in_headers = false; } //end if //-- ok we need to break this line up into several smaller lines while (SmartUnicode::str_len($line) > $max_line_length) { //-- $pos = SmartUnicode::str_rpos(SmartUnicode::sub_str($line, 0, $max_line_length), ' '); // here we need reverse strpos $lines_out[] = SmartUnicode::sub_str($line, 0, $pos); $line = SmartUnicode::sub_str($line, $pos + 1); //-- if we are processing headers we need to add a LWSP-char to the front of the new line rfc 822 on long msg headers if ($in_headers) { $line = "\t" . $line; } //end if //-- } //end while //-- $lines_out[] = $line; //-- now send the lines to the server //while(list(,$line_out) = @each($lines_out)) { while (list($key, $line_out) = @each($lines_out)) { // FIX to be compatible with the upcoming PHP 7 //-- if (strlen($line_out) > 0) { if (SmartUnicode::sub_str($line_out, 0, 1) == '.') { $line_out = '.' . $line_out; } //end if } //end if //-- @fputs($this->socket, $line_out . "\r\n"); //-- } //end while //-- } //end while //-- ok all the message data has been sent so lets get this over with aleady @fputs($this->socket, "\r\n" . '.' . "\r\n"); //-- $reply = $this->retry_data(); $test = $this->answer_code($reply); //-- if ($this->debug) { $this->log .= '[INF] Data-Send Mail Server Reply is :: ' . $test . ' // ' . $reply . "\n"; } //end if //-- if (strlen($this->error) > 0) { return 0; } //end if //-- if ((string) $test != '250') { $this->error = '[ERR] Data-Send Finalize Failed on Server :: ' . $test . ' // ' . $reply; return 0; } //end if //-- return 1; //-- }