/** * Create an active table * * @access private * @internal * * @param STRING $y_size [the table size px / %] * @param STRING $y_title [the table title] * @param ARRAY $y_arr_addlink [associative, 'link', 'title'] :: REPLACEMENTS {{{id}}} * @param ARRAY $y_arr_edtlink [associative, 'link', 'title'] :: REPLACEMENTS {{{id}}} * @param ARRAY $y_arr_dellink [associative, 'link', 'title'] :: REPLACEMENTS {{{id}}} * @param ARRAY $y_arr_fields [non-associative, fields] * @param ARRAY $y_arr_process [non-associative array(0, 1, 2, ...), process ($tmp_id / $value) | associative array( 'objects' => array(0, 1, 2, ...), 'handlers' => array('obj1' => $obj1, obj2=>$obj2, ...) )] * @param ARRAY $y_arr_data [non-associative, data] * * @return STRING [html code] */ public static function table($y_size, $y_title, $y_arr_addlink, $y_arr_edtlink, $y_arr_dellink, $y_arr_fields, $y_arr_process, $y_arr_data, $y_arr_align = array(), $y_arr_width = array(), $y_form_action = array(), $y_form_actoptions = array(), $y_wnd_js = '', $y_form_name = 'smart_table_form', $y_arr_styles = array('heading' => 'smart_active_table_heading', 'subheading' => 'smart_active_table_subheading', 'hilite' => 'smart_active_table_row_hilite', 'alt1' => 'smart_active_table_row_alt1', 'alt2' => 'smart_active_table_row_alt2', 'click' => 'smart_active_table_row_click')) { // [v.150105] // now can handle passed objects //$y_form_actoptions = array(array('button_img'=>'lib/core/img/op_insert.png', 'button_act'=>'action2', 'button_title'=>'Some Action'), array('button_img'=>'lib/core/img/op_edit.png', 'button_act'=>'eeee', 'button_title'=>'Some Other Action')); //-- protection if (Smart::array_size($y_arr_fields) <= 0) { return self::operation_error('WARNING: Build Table has been invoked with a Zero Fields Array !'); } //end if //-- //-- transform the $y_arr_process for handle objects // ths $y_arr_process can be either: // DEFAULT: array(0, 1, 2, ...) // non associative // ADVANCED: array( // 'objects' => array(0, 1, 2, ...), // non associative // 'handlers' => array('obj1' => $obj1, obj2=>$obj2, ...) // ) //-- if (is_array($y_arr_process)) { //-- if (is_array($y_arr_process['handlers']) or is_array($y_arr_process['objects'])) { //-- if (is_array($y_arr_process['handlers'])) { $the_arr_process = (array) $y_arr_process['handlers']; } else { $the_arr_process = array(); } //end if else //-- if (is_array($y_arr_process['objects'])) { //-- foreach ($y_arr_process['objects'] as $key => $val) { eval("\n" . '$obj__' . $key . ' = &$val;' . "\n"); // register local objects } //end foreach //-- } //end if else //-- restore back $y_arr_process = array(); $y_arr_process = (array) $the_arr_process; //-- } //end if //-- } else { //-- $y_arr_process = array(); //-- } //end if //-- //-- if ((string) $y_wnd_js == '' or (string) $y_wnd_js == 'smart_table_detail') { $y_wnd_js = 'smart_table_detail_' . sha1($y_title); } else { $y_wnd_js = (string) $y_wnd_js; } //end if else //-- //-------------------------------------------------------- INITS //-- $color_title = $y_arr_styles['heading']; // #ECECEC $color_subtitle = $y_arr_styles['subheading']; // #FFFFFF $bgcolor_highlight = $y_arr_styles['hilite']; // #DDEEFF $alt_color_one = $y_arr_styles['alt1']; // #FAFAFA $alt_color_two = $y_arr_styles['alt2']; // #F3F3F3 $click_color = $y_arr_styles['click']; // #FFCC00 //-- //-------------------------------------------------------- $out = ''; //-------------------------------------------------------- START $tbl_plus_cols = 2; //-- $translator_core_window = SmartTextTranslations::getTranslator('@core', 'window'); //-- if (Smart::array_size($y_form_action) > 0) { //-- if ((string) $y_form_action['method'] == '') { $y_form_action['method'] = 'post'; $y_form_action['enctype'] = 'multipart/form-data'; } //end if //- if ((string) $y_form_action['target'] == '') { $y_form_action['target'] = '_self'; } //end if //-- if ((string) $y_form_action['jscript'] == '') { $y_form_action['jscript'] = 'onClick=" ' . self::js_draw_html_confirm_form_submit($translator_core_window->text('confirm_action')) . ' "'; } //end if //-- if ((string) $y_form_action['button_img'] == '') { $y_form_action['button_img'] = 'lib/core/img/op_delete.png'; } //end if //-- $out .= '<form class="ux-form" name="' . Smart::escape_html($y_form_name) . '" action="' . Smart::escape_html($y_form_action['action']) . '" method="' . Smart::escape_html($y_form_action['method']) . '" enctype="' . Smart::escape_html($y_form_action['enctype']) . '" target="' . Smart::escape_html($y_form_action['target']) . '">' . "\n"; //-- } //end if else //-- if (Smart::array_size($y_arr_dellink) <= 0) { $tbl_plus_cols = $tbl_plus_cols - 1; } //end if if (Smart::array_size($y_arr_edtlink) <= 0) { $tbl_plus_cols = $tbl_plus_cols - 1; } //end if if (Smart::array_size($y_arr_addlink) > 0) { if (Smart::array_size($y_arr_dellink) > 0 and Smart::array_size($y_arr_edtlink) > 0) { $tbl_plus_cols = 2; // fix again } else { $tbl_plus_cols = 1; // fix again } //end if else } //end if //-- $out .= '<!-- require: activetable.css -->' . "\n"; $out .= '<div style="width:100%;">' . "\n"; // style += overflow:auto; $out .= '<script type="text/javascript">var Smart_Table_Notification_ID;</script>' . "\n"; $out .= '<table id="' . Smart::escape_html($color_subtitle) . '" align="center" width="' . Smart::escape_html($y_size) . '" border="0" cellspacing="1" cellpadding="2" title="' . Smart::escape_html(Smart::striptags($y_title, 'no')) . '">' . "\n"; //-------------------------------------------------------- TITLE $out .= '<tr id="' . Smart::escape_html($color_title) . '">' . "\n"; //-- if (Smart::array_size($y_arr_addlink) > 0) { //-- if (Smart::array_size($y_arr_dellink) > 0 and Smart::array_size($y_arr_edtlink) > 0) { $out .= '<td valign="middle" align="center" colspan="2">' . "\n"; } else { $out .= '<td valign="middle" align="center">' . "\n"; } //end if else //-- if ((string) $y_arr_addlink['target'] != '') { $new_tgt = $y_arr_addlink['target']; } else { $new_tgt = $y_wnd_js; } //end if else //-- if (strlen($y_arr_addlink['custom_picture']) > 0) { eval("\n" . $y_arr_addlink['custom_picture'] . "\n"); $the_add_pict = $add_custom_picture; } else { $the_add_pict = 'lib/core/img/op_insert.png'; } //end if else //-- if (Smart::format_number_int($y_arr_addlink['width']) > 0 and Smart::format_number_int($y_arr_addlink['height']) > 0) { $the_onclick = 'SmartJS_BrowserUtils.PopUpLink(this.href, this.target, ' . Smart::format_number_int($y_arr_addlink['width']) . ', ' . Smart::format_number_int($y_arr_addlink['height']) . ', 0, 1);'; } else { $the_onclick = 'SmartJS_BrowserUtils.PopUpLink(this.href, this.target);'; } //end if else //-- $out .= '<a href="' . Smart::escape_html(str_replace('{{{id}}}', '', $y_arr_addlink['link'])) . '" target="' . Smart::escape_html($new_tgt) . '" onClick="' . $the_onclick . ' return false;"><img src="' . Smart::escape_html($the_add_pict) . '" border="0" title="' . $y_arr_addlink['title'] . '" alt="' . $y_arr_addlink['title'] . '"></a>'; //-- $out .= '</td>' . "\n"; //-- } else { //-- if ((int) $tbl_plus_cols > 0) { //-- if ((int) $tbl_plus_cols > 1) { $out .= '<td valign="middle" align="center" colspan="' . $tbl_plus_cols . '">' . "\n"; } else { $out .= '<td valign="middle" align="center">' . "\n"; } //end if else $out .= ' '; $out .= '</td>' . "\n"; } //end if //-- } //end if else //-- $out .= '<td width="99%" align="left" valign="middle" colspan="' . Smart::array_size($y_arr_fields) . '">' . "\n"; //-- if (strpos($y_title, '<') !== false) { $out .= $y_title; // is html } elseif ((string) $y_title != '') { $out .= '<h1> ' . $y_title . ' </h1>'; } //end if else //-- $out .= '</td>' . "\n"; $out .= '</tr>' . "\n"; //-------------------------------------------------------- EXTRA BUTTONS $extra_bttns = ''; if (Smart::array_size($y_form_action) > 0) { $extra_bttns .= '<td><table width="50%" cellpadding="0" cellspacing="0">'; if (Smart::array_size($y_form_actoptions) > 0) { $extra_bttns .= '<tr>' . "\n"; $extra_bttns .= '<td align="left" valign="middle" colspan="' . Smart::array_size($y_arr_fields) . '">' . "\n"; for ($i = 0; $i < Smart::array_size($y_form_actoptions); $i++) { $the_actopts_arr = $y_form_actoptions[$i]; if ((string) $the_actopts_arr['jscript'] == '') { $the_actopts_arr['jscript'] = 'onClick=" ' . self::js_draw_html_confirm_form_submit($translator_core_window->text('confirm_action')) . ' "'; } //end if $extra_bttns .= '<input type="image" id="bttn_f_action' . $i . '" name="bttn_f_action" value="' . Smart::escape_html($the_actopts_arr['button_act']) . '" src="' . Smart::escape_html($the_actopts_arr['button_img']) . '" ' . $the_actopts_arr['jscript'] . ' style="border:none" title="' . $the_actopts_arr['button_title'] . '" alt="' . $the_actopts_arr['button_title'] . '"> '; } //end for $extra_bttns .= '</td>' . "\n"; $extra_bttns .= '</tr>' . "\n"; } //end if $extra_bttns .= '</table></td>'; //-- $the_hd_size_del = '32'; $the_hd_size_edt = '32'; //-- } else { //-- if (Smart::array_size($y_arr_dellink) > 0) { $the_hd_size_del = '32'; } else { $the_hd_size_del = '1'; } //end if else //-- if (Smart::array_size($y_arr_edtlink) > 0) { $the_hd_size_edt = '32'; } else { $the_hd_size_edt = '1'; } //end if else //-- } //end if else //-------------------------------------------------------- HEADING $out .= '<tr>' . "\n"; if (Smart::array_size($y_form_action) > 0) { $out .= '<td width="' . Smart::format_number_int($the_hd_size_del + $the_hd_size_edt) . '" align="center" colspan="2">' . "\n"; $out .= '<table border="0" cellspacing="0" cellpadding="2"><tr>'; $out .= '<td width="' . Smart::format_number_int($the_hd_size_del) . '"><input type="checkbox" name="' . Smart::escape_html($y_form_name) . '_toggle" value="" onClick="this.checked=!this.checked;' . self::js_draw_checkbox_checkall($y_form_name) . '">' . '</td>' . "\n"; $out .= '<td width="' . Smart::format_number_int($the_hd_size_edt) . '"><input type="image" id="bttn_f_action" name="bttn_f_action" value="' . Smart::escape_html($y_form_action['button_act']) . '" src="' . Smart::escape_html($y_form_action['button_img']) . '" ' . $y_form_action['jscript'] . ' style="border:none" title="' . $y_form_action['button_title'] . '" alt="' . $y_form_action['button_title'] . '"></td>' . "\n"; $out .= '</tr></table>'; $out .= '</td>' . "\n"; } else { if (Smart::array_size($y_arr_dellink) > 0 and Smart::array_size($y_arr_edtlink) > 0) { $out .= '<td width="' . Smart::format_number_int($the_hd_size_del + $the_hd_size_edt) . '" align="center" colspan="2">' . "\n"; $out .= ''; $out .= '</td>' . "\n"; } elseif (Smart::array_size($y_arr_dellink) > 0) { $out .= '<td width="' . Smart::format_number_int($the_hd_size_del) . '" align="center">' . "\n"; $out .= ''; $out .= '</td>' . "\n"; } elseif (Smart::array_size($y_arr_edtlink) > 0) { $out .= '<td width="' . Smart::format_number_int($the_hd_size_edt) . '" align="center">' . "\n"; $out .= ''; $out .= '</td>' . "\n"; } else { // nothing } //end if else } //end if else //-- for ($i = 0; $i < Smart::array_size($y_arr_fields); $i++) { $out .= '<td align="center" valign="middle" width="' . Smart::escape_html($y_arr_width[$i]) . '">' . "\n"; $out .= '<table width="100%" border="0"><tr>'; if ($i == 0) { if (Smart::array_size($y_form_action) > 0) { $out .= $extra_bttns; } //end if } //end if $out .= '<td align="center"><b>' . $y_arr_fields[$i] . '</b></td>'; $out .= '</tr></table>'; $out .= '</td>' . "\n"; } //end for //-- $out .= '</tr>' . "\n"; //-------------------------------------------------------- DATA $the_alt_cnt = 0; for ($n = 0; $n < Smart::array_size($y_arr_data); $n++) { //-- $the_alt_cnt += 1; if ($the_alt_cnt % 2) { $the_alt_color = $alt_color_two; } else { $the_alt_color = $alt_color_one; } //end else //-- $tmp_id = $y_arr_data[$n]; // the id must be get first //-- $out .= '<tr valign="top" ' . self::table_active_row($the_alt_color, $bgcolor_highlight, $click_color) . '>' . "\n"; //-- if (Smart::array_size($y_form_action) > 0) { //-- $out .= '<td align="center" width="' . Smart::format_number_int($the_hd_size_del) . '">' . "\n"; $out .= '<input type="checkbox" name="id[]" value="' . Smart::escape_html($tmp_id) . '">'; $out .= '</td>' . "\n"; //-- } else { //-- if (Smart::array_size($y_arr_dellink) > 0) { //-- $out .= '<td align="center" width="' . Smart::format_number_int($the_hd_size_del) . '" onClick="this.parentNode.title=\'**\';">' . "\n"; //-- if (strlen($y_arr_dellink['custom_picture']) > 0) { eval("\n" . $y_arr_dellink['custom_picture'] . "\n"); $the_del_pict = $delete_custom_picture; } else { $the_del_pict = 'lib/core/img/op_delete.png'; } //end if else //-- if (Smart::format_number_int($y_arr_dellink['width']) > 0 and Smart::format_number_int($y_arr_dellink['height']) > 0) { $the_onclick = 'SmartJS_BrowserUtils.PopUpLink(this.href, this.target, ' . Smart::format_number_int($y_arr_dellink['width']) . ', ' . Smart::format_number_int($y_arr_dellink['height']) . ', 0, 1);'; } else { $the_onclick = 'SmartJS_BrowserUtils.PopUpLink(this.href, this.target);'; } //end if else //-- $out .= '<a href="' . Smart::escape_html(str_replace('{{{id}}}', rawurlencode($tmp_id), $y_arr_dellink['link'])) . '" target="' . 'del__' . Smart::escape_html($y_wnd_js) . '" onClick="' . $the_onclick . ' return false;"><img src="' . Smart::escape_html($the_del_pict) . '" border="0" title="' . $y_arr_dellink['title'] . '" alt="' . $y_arr_dellink['title'] . '"></a>'; //-- $out .= '</td>' . "\n"; //-- } //end if //-- } //end if else //-- if (Smart::array_size($y_arr_edtlink) > 0) { //-- $out .= '<td align="center" width="' . Smart::format_number_int($the_hd_size_edt) . '" onClick="this.parentNode.title=\'**\';">' . "\n"; // disable onclick for parent row (fix) //-- if (strlen($y_arr_edtlink['custom_picture']) > 0) { eval("\n" . $y_arr_edtlink['custom_picture'] . "\n"); $the_edt_pict = $edit_custom_picture; } else { $the_edt_pict = 'lib/core/img/op_edit.png'; } //end if else //-- if (Smart::format_number_int($y_arr_edtlink['width']) > 0 and Smart::format_number_int($y_arr_edtlink['height']) > 0) { $the_onclick = 'SmartJS_BrowserUtils.PopUpLink(this.href, this.target, ' . Smart::format_number_int($y_arr_edtlink['width']) . ', ' . Smart::format_number_int($y_arr_edtlink['height']) . ', 0, 1);'; } else { $the_onclick = 'SmartJS_BrowserUtils.PopUpLink(this.href, this.target);'; } //end if else //-- $out .= '<a href="' . Smart::escape_html(str_replace('{{{id}}}', rawurlencode($tmp_id), $y_arr_edtlink['link'])) . '" target="' . 'edt__' . Smart::escape_html($y_wnd_js) . '_' . sha1(date('Y-m-d H:i:s') . $tmp_id) . '" onClick="' . $the_onclick . ' return false;"><img src="' . Smart::escape_html($the_edt_pict) . '" border="0" title="' . $y_arr_edtlink['title'] . '" alt="' . $y_arr_edtlink['title'] . '"></a>'; //-- $out .= '</td>' . "\n"; //-- } //end if //-- $a = 0; for ($i = 0; $i < Smart::array_size($y_arr_fields); $i++) { //-- $the_align = 'center'; if ((string) $y_arr_align[$a] != '') { $the_align = $y_arr_align[$a]; } // end if //-- $a += 1; //-- $kk = $i + $n; $value = $y_arr_data[$kk]; //-- $out .= '<td align="' . $the_align . '">' . "\n"; if ((string) $y_arr_process[$i] == '') { $out .= Smart::escape_html($value); } else { eval("\n" . $y_arr_process[$i] . "\n"); $out .= $value; } //end if else //-- $out .= '</td>' . "\n"; //-- } //end for //-- $out .= '</tr>' . "\n"; //-- $n += Smart::array_size($y_arr_fields) - 1; // salt //-- } //end for //-------------------------------------------------------- END LINE $out .= '<tr id="' . $color_title . '">' . "\n"; //-- if ((int) $tbl_plus_cols > 0) { //-- if ((int) $tbl_plus_cols > 1) { $out .= '<td valign="middle" align="center" colspan="' . $tbl_plus_cols . '">' . "\n"; } else { $out .= '<td valign="middle" align="center">' . "\n"; } //end if else $out .= '<font size="1"> </font>'; $out .= '</td>' . "\n"; //-- } else { // nothing } //end if else //-- $out .= '<td width="99%" align="center" valign="middle" colspan="' . Smart::array_size($y_arr_fields) . '">' . "\n"; $out .= '<font size="1"> </font>'; $out .= '</td>' . "\n"; $out .= '</tr>' . "\n"; //-------------------------------------------------------- END $out .= '</table>' . "\n"; $out .= '</div>' . "\n"; //-- if (Smart::array_size($y_form_action) > 0) { $out .= '</form>' . "\n"; } //end if //-------------------------------------------------------- //-- return $out; //-- }
public static function extract_words_from_text_html($ytxt) { //-- $ytxt = Smart::striptags((string) $ytxt, 'no'); //-- make spaces $ytxt = str_replace(array("\r\n", "\r", "\n", "\t"), array(' ', ' ', ' ', ' '), (string) $ytxt); //-- return (array) explode(' ', (string) $ytxt); //-- }
/** * Parse Simple Notes :: '-----< yyyy-mm-dd hh:ii:ss >----- some note\nsome other line' * * @param STRING $ynotes :: The Text or HTML to be processed * @param YES/NO $y_hide_times :: Show / Hide the time stamps * @param #SIZE $y_tblsize :: HTML Table Size * @param #COLOR $ytxtcolor :: HTML Table Color for Text * @param #COLOR $ycolor :: HTML Table Row Color * @param #COLOR $ycolor_alt :: HTML Table Row Alternate Color * @param #COLOR $ybrdcolor :: HTML Table Border Color * @param #STYLE $y_style :: HTML Extra Style * * @access private * @internal * * @return STRING :: The HTML processed code */ public static function simple_notes($ynotes, $y_hide_times, $y_tblsize = '100%', $ytxtcolor = '#000000', $ycolor = '#FFFFFF', $ycolor_alt = '#FFFFFF', $ybrdcolor = '#CCCCCC', $y_style = ' style="overflow: auto; height:200px;"') { //-- if (strpos((string) $ynotes, '-----<') === false) { return $tbl_start . '<tr><td bgcolor="' . $ycolor . '" valign="top"><font size="1">' . Smart::nl_2_br(Smart::escape_html($ynotes)) . '</font></td></tr>' . $tbl_end; // not compatible notes, so we not parse them } //end if //-- $out = ''; //-- $tbl_start = '<table width="' . $y_tblsize . '" cellspacing="0" cellpadding="2" border="1" bordercolor="' . $ybrdcolor . '" style="border-style: solid; border-collapse: collapse;">' . "\n"; $tbl_end = '</table>'; //-- $tmp_shnotes_arr = (array) explode('-----<', (string) $ynotes); //-- $i_alt = 0; //-- if (Smart::array_size($tmp_shnotes_arr) > 0) { //-- $out .= '<!-- OVERFLOW START (S.NOTES) -->' . '<div title="#S.NOTES#"' . $y_style . '>' . "\n"; $out .= $tbl_start; //-- for ($i = 0; $i < Smart::array_size($tmp_shnotes_arr); $i++) { //-- $tmp_shnotes_arr[$i] = (string) trim((string) $tmp_shnotes_arr[$i]); //-- if (Smart::striptags(str_replace('-----<', '', (string) $tmp_shnotes_arr[$i])) != '') { //-- $tmp_expld = (array) explode('>-----', (string) $tmp_shnotes_arr[$i]); //-- $tmp_meta_expl = (array) explode('|', (string) $tmp_expld[0]); $tmp_meta_date = trim((string) $tmp_meta_expl[0]); if (strlen(trim((string) $tmp_meta_expl[1])) > 0) { $tmp_metainfo = ' :: ' . trim($tmp_meta_expl[1]); } else { $tmp_metainfo = ''; } //end if else //-- if (strlen(trim((string) $tmp_expld[1])) > 0) { //-- $i_alt += 1; //-- alternate if ($i_alt % 2) { $alt_color = $ycolor; } else { $alt_color = $ycolor_alt; } //end if else //-- $out .= '<tr>' . "\n"; $out .= '<td bgcolor="' . $alt_color . '" valign="top">' . "\n"; //-- if ((string) $y_hide_times != 'yes') { $out .= '<div align="right" title="' . Smart::escape_html('#' . $i_alt . '.' . $tmp_metainfo) . '"><font size="1" color="' . $ytxtcolor . '"><b>' . Smart::escape_html($tmp_meta_date) . '</b></font></div><font size="1" color="' . $ytxtcolor . '">' . Smart::nl_2_br(Smart::escape_html(trim($tmp_expld[1]))) . '</font>'; } else { $out .= '<div title="' . Smart::escape_html('#' . $i_alt . '. ' . $tmp_meta_date . $tmp_metainfo) . '"><font size="1" color="' . $ytxtcolor . '">' . Smart::nl_2_br(Smart::escape_html(trim($tmp_expld[1]))) . '</font></div>'; } //end if else //-- $out .= '</td>' . "\n"; $out .= '</tr>' . "\n"; //-- } //end if //-- } //end if //-- } //end for //-- $out .= $tbl_end; $out .= '</div>' . '<!-- OVERFLOW END (S.NOTES) -->' . "\n"; //-- } //end if //-- if ($i_alt <= 0) { $out = ''; } //end if //-- return $out; //-- }
private static function read_mime_message($y_enc_msg_file, $y_ctrl_key, $y_process_mode, $y_show_headers, $y_title, $y_link, $y_target) { // $y_process_mode : 'default' | 'print' | 'data-full' | 'data-reply' // $y_show_headers : 'default' | 'subject' (just for mode: 'default' | 'print') //-- $msg_decode_arr = (array) self::decode_mime_fileurl((string) $y_enc_msg_file, (string) $y_ctrl_key); //-- if ((string) $msg_decode_arr['error'] != '') { Smart::raise_error('ERROR: MIME Parser // Mesage File Decode: ' . $msg_decode_arr['error'], 'ERROR: MIME Parser // Mesage File Decode // See error log for details ...'); return ''; } //end if //-- //-- $the_message_eml = (string) trim((string) $msg_decode_arr['message-file']); $the_part_id = (string) trim((string) $msg_decode_arr['message-part']); //-- //-- if ((string) $the_message_eml == '' or !is_file((string) $the_message_eml)) { Smart::raise_error('ERROR: MIME Parser // Message File EMPTY or NOT FOUND !: ' . $the_message_eml, 'ERROR: MIME Parser // Mesage File Decode // See error log for details ...'); return ''; } //end if //-- if (substr((string) $the_message_eml, -4, 4) != '.eml') { Smart::raise_error('ERROR: MIME Parser // Message File Extension is not .eml !: ' . $the_message_eml, 'ERROR: MIME Parser // Mesage File Decode // See error log for details ...'); return ''; } //end if //-- //-- $out = ''; // init $reply_text = array(); // init //-- //== //-- $content = SmartFileSystem::read((string) $the_message_eml); $eml = new SmartMailerMimeDecode(); $head = $eml->get_header(SmartUnicode::sub_str((string) $content, 0, 65535)); // some messages fail with 8192 to decode ; a faster compromise would be 16384, but here we can use a higher value since is done once (text 65535) $msg = $eml->get_bodies((string) $content, (string) $the_part_id); unset($eml); unset($content); //-- //== //-- $reg_atts_num = 0; $reg_atts_list = ''; // list separed by \n //-- if (strlen($the_part_id) <= 0) { //-- display whole message $reg_is_part = 'no'; $skip_part_processing = 'no'; $skip_part_linking = 'no'; //-- } else { //-- display only a part of the message $reg_is_part = 'yes'; $skip_part_processing = 'no'; $skip_part_linking = 'yes'; //-- if (substr($the_part_id, 0, 4) == 'txt_') { //-- text part $tmp_part = $msg['texts'][$the_part_id]; $msg = array(); $msg['texts'][$the_part_id] = (array) $tmp_part; unset($tmp_part); //-- } else { //-- att / cid part $skip_part_processing = 'yes'; //-- if (!is_array($msg['attachments'][$the_part_id])) { // try to normalize name $the_part_id = trim(str_replace(' ', '', $the_part_id)); } //end if //-- $out = (string) $msg['attachments'][$the_part_id]['content']; // DO NO MORE ADD ANYTHING TO $out ... downloading, there are no risk of code injection //-- } //end if else //-- } //end if else //-- //-- if ((string) $y_process_mode == 'print') { $skip_part_linking = 'yes'; // skip links to other sub-parts like texts / attachments but not cids ! } elseif ((string) $y_process_mode == 'data-reply') { $skip_part_linking = 'yes'; } //end if //-- //-- if ((string) $skip_part_processing != 'yes') { //-- if ((string) $y_title != '') { $out .= (string) $y_title; // expects '' or valid HTML } //end if //-- $out .= '<!-- Smart.Framework // MIME MESSAGE HTML --><div align="left"><div id="mime_msg_box">'; //-- if (strlen($the_part_id) <= 0) { //-- $priority_img = ''; switch ((string) $head['priority']) { case '1': // high $priority_img = '<img src="lib/core/plugins/img/email/priority_high.png" align="left" alt="High Priority" title="High Priority">'; break; case '5': // low $priority_img = '<img src="lib/core/plugins/img/email/priority_low.png" align="left" alt="Low Priority" title="Low Priority">'; break; case '3': // medium // medium default: $priority_img = ''; //$priority_img = '<img src="lib/core/plugins/img/email/priority_normal.png" align="left" alt="Normal Priority" title="Normal Priority">'; } //end switch //-- if ((string) $skip_part_linking != 'yes') { // avoid display the print link when only a part is displayed $out .= '<a href="' . self::mime_link($y_ctrl_key, $the_message_eml, $the_part_id, $y_link, $eval_arr[0], $eval_arr[1], 'print') . '" target="' . $y_target . '__mimepart" data-smart="open.modal">' . '<img align="right" src="lib/core/img/buttons/bttn_print.png">' . '</a>'; } //end if //-- switch ((string) $y_show_headers) { case 'subject': //-- if ((string) $head['subject'] != '[?]') { $out .= '<h1><font size="4">' . Smart::escape_html($head['subject']) . '</font></h1><br>'; } //end if //-- break; case 'default': default: //-- if ((string) $head['subject'] != '[?]') { $out .= '<h1><font size="4"> ' . Smart::escape_html($head['subject']) . '</font>' . $priority_img . '</h1><hr>'; } //end if //-- if ((string) $head['date'] != '(?)') { $out .= '<font size="3"><b>Date:</b> ' . Smart::escape_html(date('Y-m-d H:i:s O', @strtotime($head['date']))) . '</font><br>'; } //end if //-- $out .= '<font size="2"><b>From:</b> ' . Smart::escape_html($head['from_addr']) . ' <i>' . Smart::escape_html($head['from_name']) . '</i>' . '</font><br>'; $out .= '<font size="2"><b>To:</b> ' . Smart::escape_html($head['to_addr']) . ' <i>' . Smart::escape_html($head['to_name']) . '</i>' . '</font><br>'; //-- if (strlen($head['cc_addr']) > 0) { $out .= '<font size="2"><b>Cc:</b> '; if (SmartUnicode::str_contains($head['cc_addr'], ',')) { $arr_cc_addr = (array) explode(',', (string) $head['cc_addr']); $arr_cc_name = (array) explode(',', (string) $head['cc_name']); $out .= '[@]'; for ($z = 0; $z < Smart::array_size($arr_cc_addr); $z++) { $out .= '<br> ' . Smart::escape_html(trim($arr_cc_addr[$z])) . ' <i>' . Smart::escape_html(trim($arr_cc_name[$z])) . '</i>'; } //end for } else { $out .= Smart::escape_html($head['cc_addr']) . ' <i>' . Smart::escape_html($head['cc_name']) . '</i>'; } //end if else $out .= '</font><br>'; } //end if //-- if (strlen($head['bcc_addr']) > 0) { $out .= '<font size="2"><b>Bcc:</b> '; $out .= Smart::escape_html($head['bcc_addr']) . ' <i>' . Smart::escape_html($head['bcc_name']) . '</i>'; $out .= '</font><br>'; } //end if //-- } //end switch //-- print attachments if (is_array($msg['attachments'])) { //-- $cnt = 0; //-- $atts = ''; // atts with link $xatts = ''; // atts without link //-- $tmp_att_img = '<img src="lib/core/plugins/img/email/attachment.png">'; //-- foreach ($msg['attachments'] as $key => $val) { //-- $tmp_arr = array(); $tmp_arr = (array) $val; //-- if ((string) $tmp_arr['mode'] == 'normal') { //-- $cnt += 1; //-- $eval_arr = SmartFileSysUtils::mime_eval((string) $tmp_arr['filename']); $tmp_att_name = Smart::escape_html((string) $tmp_arr['filename']); $tmp_att_size = Smart::escape_html((string) SmartUtils::pretty_print_bytes((int) $tmp_arr['filesize'], 1)); //-- $reg_atts_num += 1; $reg_atts_list .= str_replace(array("\r", "\n", "\t"), array('', '', ''), (string) $tmp_arr['filename']) . "\n"; //-- $atts .= '<div align="left"><table border="0" cellpadding="2" cellspacing="0" title="Attachment #' . $cnt . '"><tr><td>' . $tmp_att_img . '</td><td> </td><td><a href="' . self::mime_link($y_ctrl_key, $the_message_eml, $key, $y_link, $eval_arr[0], $eval_arr[1]) . '" target="' . $y_target . '__mimepart" data-smart="open.modal"><font size="1"><b>' . $tmp_att_name . '</b></font></a></td><td><font size="1"> <b><i>' . $tmp_att_size . '</i></b></font></td></tr></table></div>'; $xatts .= '<div align="left">' . $tmp_att_img . ' <font size="1">' . $tmp_att_name . ' <i>' . $tmp_att_size . '</i></font></div>'; //-- } //end if //-- } //end foreach //-- if ($cnt > 0) { if ((string) $skip_part_linking == 'yes') { // avoid displaying attachments links when only a part is displayed $out .= '<hr><div align="left">' . $xatts . '</div>'; } else { $out .= '<hr><div align="left">' . $atts . '</div>'; } //end if } //end if //-- $tmp_att_name = ''; $tmp_att_size = ''; //-- $atts = ''; $xatts = ''; //-- } //end if //-- } else { //-- $out .= '<div align="right"><font size="1">' . Smart::escape_html($head['subject']) . ' // ' . 'MIME Part ID : <i>' . Smart::escape_html($the_part_id) . '</i></font></div>'; //-- } //end if //-- print text bodies $markup_multipart = 'This is a multi-part message in MIME format.'; if (is_array($msg['texts'])) { //-- check similarity and prepare the HTML parts $buff = ''; $buff_id = ''; $xbuff = ''; $xbuff_id = ''; $skips = array(); $numparts = 0; foreach ($msg['texts'] as $key => $val) { //-- $numparts += 1; //-- if ((string) $val['type'] == 'text') { // assure we don't print other things //-- if ((string) $val['mode'] == 'text/plain') { // Plain TEXT //-- sanitize text $val['content'] = '<!-- MIMEREAD:PART:TEXT -->' . Smart::escape_html($val['content']); $val['content'] = str_replace(array("\r\n", "\r", "\n"), array("\n", "\n", '<br>'), $val['content']); $val['content'] = SmartParser::text_urls($val['content']); //-- $msg['texts'][$key]['content'] = $val['content']; // rewrite back //-- assign buffer $buff = SmartUnicode::sub_str($val['content'], 0, 16384); $buff_id = $key; //-- $percent_similar = 0; if (strlen($the_part_id) <= 0) { @similar_text($buff, $markup_multipart, $percent_similar); if ($percent_similar >= 25) { // 25% at least similarity $skips[$buff_id] = $percent_similar; // skip this alternate html part ... } //end if } //end if //-- // clean buffer $xbuff = ''; $xbuff_id = ''; //-- } else { // HTML Parts :: check similarity //-- $val['content'] = '<!-- MIMEREAD:PART:HTML -->' . preg_replace("'" . '<\\?xml' . ".*?" . '>' . "'si", " ", (string) $val['content']); // remove always fake "< ?" as "< ?xml" (fixed with /u modifier for unicode strings) //-- if (SmartUnicode::str_contains($val['content'], '<' . '?') or SmartUnicode::str_contains($val['content'], '?' . '>') or SmartUnicode::str_contains($val['content'], '<' . '%') or SmartUnicode::str_contains($val['content'], '%' . '>')) { //-- $val['content'] = @highlight_string($val['content'], 1); // highlight the PHP* code & sanitize the parts //-- } else { //-- sanitize this html part $val['content'] = (new SmartHtmlParser($val['content']))->get_clean_html(); //-- replace cid images $tmp_matches = array(); preg_match_all('/<img[^>]+src=[\'"]?(cid:)([^\'"]*)[\'"]?[^>]*>/si', (string) $val['content'], $tmp_matches); // fix: previous was just i (not si) ; modified on 160205 // $tmp_matches[0][i] : the full link // $tmp_matches[1][i] : 'cid:' // $tmp_matches[2][i] : cid part id for ($cids = 0; $cids < Smart::array_size($tmp_matches[0]); $cids++) { $tmp_replace_cid_link = ''; $tmp_replace_cid_link = (string) $tmp_matches[0][$cids]; $tmp_replace_cid_link = str_replace("\n", ' ', $tmp_replace_cid_link); $tmp_replace_cid_link = str_replace($tmp_matches[1][$cids] . $tmp_matches[2][$cids], self::mime_link($y_ctrl_key, $the_message_eml, 'cid_' . $tmp_matches[2][$cids], $y_link, 'image', 'inline'), $tmp_replace_cid_link); //echo '<pre>'.Smart::escape_html($tmp_replace_cid_link).'</pre>'; $val['content'] = str_replace($tmp_matches[0][$cids], $tmp_replace_cid_link, $val['content']); } //end for $tmp_matches = array(); //-- } //end if else //-- $msg['texts'][$key]['content'] = $val['content']; // rewrite back //-- $xbuff = SmartUnicode::sub_str(Smart::striptags($val['content']), 0, 16384); $xbuff_id = $key; //-- $percent_similar = 0; if (strlen($the_part_id) <= 0) { @similar_text($buff, $xbuff, $percent_similar); if ($percent_similar >= 15) { // 15% at least similarity $skips[$buff_id] = $percent_similar; // skip this alternate text part ... } //end if } //end if //-- // clean buffer $buff = ''; $buff_id = ''; //-- } //end if //-- } //end if //-- } //end foreach //-- if ($numparts <= 1) { $skips = array(); // disallow skips if only one part } //end if //-- print bodies except the skipped by similarity $out .= '<hr>'; //-- $cnt = 0; foreach ($msg['texts'] as $key => $val) { //-- if ((string) $val['type'] == 'text') { // assure we don't print other things //-- $cnt += 1; //-- $eval_arr = array(); $eval_arr = SmartFileSysUtils::mime_eval('part_' . $cnt . '.html', 'inline'); //-- $tmp_link_pre = '<span title="Mime Part #' . $cnt . ' ( ' . Smart::escape_html(strtolower($val['mode']) . ' : ' . strtoupper($val['charset'])) . ' )"><a href="' . self::mime_link($y_ctrl_key, $the_message_eml, $key, $y_link, $eval_arr[0], $eval_arr[1], 'minimal') . '" target="' . $y_target . '__mimepart" data-smart="open.modal">'; $tmp_link_pst = '</a></span>'; //-- if (strlen($skips[$key]) <= 0) { // print part if not skipped by similarity ... //-- if ((string) $skip_part_linking == 'yes') { // avoid display sub-text part links when only a part is displayed $tmp_pict_img = ''; } else { $tmp_pict_img = '<div align="right">' . $tmp_link_pre . '<img src="lib/framework/img/mark_right.gif">' . $tmp_link_pst . '</div>'; } //end if //-- if ((string) $y_process_mode == 'data-reply') { if (strlen($reply_text['message']) <= 0) { $reply_text['message'] = (string) $val['content']; } //end if } else { $out .= $tmp_pict_img; $out .= $val['content']; $out .= '<br><hr><br>'; } //end if //-- } else { //-- if ((string) $skip_part_linking != 'yes') { // for replies, avoid display sub-text part links when only a part is displayed if ((string) $y_process_mode == 'data-reply') { // nothing } else { $out .= '<div align="right">' . '<span title="' . '~' . Smart::escape_html(Smart::format_number_dec($skips[$key], 0, '.', ',') . '%') . '"> </span>' . $tmp_link_pre . '<img src="lib/framework/img/mark_check.gif">' . $tmp_link_pst . '</div>'; } //end if else } //end if //-- } //end if else //-- } //end if //-- } //end foreach //-- } //end if //-- $out .= '</div></div><!-- END MIME MESSAGE HTML -->'; //-- } //end if else //-- //-- if ((string) $y_process_mode == 'data-full') { // output an array with message and all header info as data structure //-- return array('message' => (string) $out, 'message-id' => (string) $head['message-id'], 'in-reply-to' => (string) $head['in-reply-to'], 'from' => (string) $head['from_addr'], 'to' => (string) $head['to_addr'], 'cc' => (string) $head['cc_addr'], 'date' => (string) $head['date'], 'atts_num' => (int) $reg_atts_num, 'atts_lst' => (string) $reg_atts_list, 'filepath' => (string) $the_message_eml, 'is_part' => (string) $reg_is_part); //-- } elseif ((string) $y_process_mode == 'data-reply') { // output a special array for replies only //-- $reply_text['message'] = (string) $reply_text['message']; // this comes from above $reply_text['from'] = (string) $head['from_addr']; $reply_text['to'] = (string) $head['to_addr']; $reply_text['cc'] = (string) $head['cc_addr']; $reply_text['date'] = (string) $head['date']; $reply_text['subject'] = (string) $head['subject']; $reply_text['message-id'] = (string) $head['message-id']; $reply_text['in-reply-to'] = (string) $head['in-reply-to']; //-- return (array) $reply_text; //-- } else { // 'default' or 'print' :: message as html view //-- return (string) $out; //-- } //end if //-- }