/**
  * Function: JS Draw SList
  *
  */
 public static function js_draw_sel_list($y_var_name, $y_options_arr, $y_size = '8')
 {
     //--
     $tmp_init_slist = "\n";
     //--
     $tmp_suffix = '_' . sha1('The-SList-JSComponent:@#' . $y_var_name);
     //--
     $options_html = '';
     //--
     if (is_array($y_options_arr)) {
         foreach ($y_options_arr as $key => $val) {
             // warehouses as arr[]=id
             if (strlen($key) > 0 and strlen($val) > 0) {
                 $options_html .= '<option value="' . \Smart::escape_html((string) $key) . '">' . \Smart::escape_html((string) $val) . '</option>';
             }
             //end if
         }
         //end foreach
     }
     //end if
     //--
     $translator_core_js_messages = \SmartTextTranslations::getTranslator('@core', 'js_messages');
     //--
     $tmp_slist = \SmartMarkersTemplating::render_file_template('modules/mod-js-components/views/js/jsjsslist/slist.inc.htm', array('SIZE' => (int) $y_size, 'VARIABLE_NAME' => \Smart::escape_html((string) $y_var_name), 'TXT_SELECT' => $translator_core_js_messages->text('btn_select'), 'TXT_RESET' => $translator_core_js_messages->text('btn_reset'), 'SLIST_SRC' => 'smartframeworkComponents_SList_SRC' . $tmp_suffix, 'SLIST_SEL' => 'smartframeworkComponents_SList_SEL' . $tmp_suffix, 'SLIST_VAL' => 'smartframeworkComponents_SList_VAL' . $tmp_suffix, 'OPTIONS' => $options_html), 'yes');
     //--
     return (string) $tmp_init_slist . $tmp_slist;
     //--
 }
 private function inlineCode($Excerpt)
 {
     //--
     $marker = $Excerpt['text'][0];
     //--
     if (preg_match('/^(' . $marker . '+)[ ]*(.+?)[ ]*(?<!' . $marker . ')\\1(?!' . $marker . ')/s', $Excerpt['text'], $matches)) {
         //--
         $text = $matches[2];
         $text = Smart::escape_html($text);
         // fix from: html special chars ENT_NOQUOTES UTF-8
         $text = preg_replace("/[ ]*\n/", ' ', $text);
         //--
         return array('extent' => strlen($matches[0]), 'element' => array('name' => 'code', 'text' => $text));
         //--
     }
     //end if
     //--
 }
 private function mov_draw_box($y_dir, $y_video_file, $y_type)
 {
     //--
     $description = Smart::escape_html($this->standardize_title($y_video_file));
     //--
     //--
     $base_preview = SmartFileSysUtils::version_add($y_video_file, 'mg-vpreview') . '.jpg';
     $preview_file = $y_dir . $base_preview;
     $video_file = $y_dir . $y_video_file;
     //--
     //--
     if ((string) $this->use_secure_links == 'yes') {
         // OK
         $the_preview = (string) $this->secure_download_link . SmartUtils::create_download_link($preview_file, $this->secure_download_ctrl_key);
         $the_video = (string) $this->secure_download_link . SmartUtils::create_download_link($video_file, $this->secure_download_ctrl_key);
     } else {
         $the_preview = (string) $preview_file;
         $the_video = (string) $video_file;
     }
     //end if else
     //--
     //--
     if ((string) $y_type == 'ogv' or (string) $y_type == 'webm' or (string) $y_type == 'mp4') {
         // {{{SYNC-MOVIE-TYPE}}}
         $link = $this->url_player_mov . $the_video;
     } else {
         // mp4, mov, flv
         //if((string)self::get_server_current_protocol() == 'https://'){} // needs fix: the Flash player do not work with mixing http/https
         $link = $this->url_player_mov . $the_video;
     }
     //end if else
     //--
     $link = str_replace(array('{{{MOVIE-FILE}}}', '{{{MOVIE-TYPE}}}', '{{{MOVIE-TITLE}}}'), array(rawurlencode($the_video), rawurlencode($y_type), rawurlencode($description)), $link);
     //--
     //--
     $out = '';
     //--
     if (strlen($this->force_preview_w) > 0) {
         $forced_dim = ' width="' . $this->force_preview_w . '"';
     } elseif (strlen($this->force_preview_h) > 0) {
         $forced_dim = ' height="' . $this->force_preview_h . '"';
     } else {
         $forced_dim = '';
     }
     //end if else
     //--
     $out .= '<div align="center" id="mediagallery_box_item">';
     //--
     if ((string) $this->preview_description == 'no') {
         $description = '';
     }
     //end if
     //--
     $out .= '<a data-smart="open.modal 780 475 1" rel="nofollow" href="' . $link . '" target="media-gallery-movie-player" ' . 'title="' . $description . '"' . '>';
     $out .= '<img src="' . Smart::escape_html($the_preview) . '" border="0" alt="' . $description . '" title="' . $description . '"' . $forced_dim . '>';
     $out .= '</a>';
     //--
     if (strlen($this->preview_formvar) > 0) {
         $out .= '<input type="checkbox" name="' . $this->preview_formvar . '[]" value="' . Smart::escape_html($y_video_file . '|' . $base_preview) . '" title="' . Smart::escape_html($y_video_file . '|' . $base_preview) . '">' . $this->preview_formpict;
     }
     //end if
     //--
     if ((string) $this->preview_description != 'no') {
         if (strlen($description) > 0) {
             $out .= '<div id="mediagallery_label">' . $description . '</div>';
         }
         //end if
     }
     //end if
     //--
     $out .= '</div>';
     //--
     //--
     return $out;
     //--
 }
示例#4
0
 private function clean_html($y_comments, $y_extra_tags_remove = array(), $y_extra_tags_clean = array(), $y_allowed_tags = array())
 {
     //-- CLEANUP DISSALOWED AND FIX INVALID HTML TAGS
     // * it will use code standardize before to fix active PHP tags and weird characters
     // * will convert all UTF-8 characters to the coresponding HTML-ENTITIES
     // * will remove all tags that are unsafe like <script> or <head> and many other dissalowed unsafe tags
     // * if allowed tags are specified they will take precedence and will be filtered via strip_tags by allowing only these tags, at the end of cleanup to be safer !
     // * if DomDocument is detected and is allowed to be used by current settings will be used finally to do (post-processing) extra cleanup and fixes
     //--
     //--
     if ($this->is_clean != false) {
         return;
         // avoid to re-parse
     }
     //end if
     //--
     $this->is_clean = true;
     //--
     //--
     $this->standardize_html();
     // first, standardize the HTML Code
     //--
     //--
     $arr_tags_0x_list_comments = array('#\\<\\s*?\\!\\-?\\-?(.*?)\\-?\\-?\\>#si');
     //--
     $arr_tags_2x_list_bad = array('head', 'style', 'script', 'noscript', 'frameset', 'frame', 'iframe', 'canvas', 'audio', 'video', 'applet', 'param', 'object', 'form', 'xml', 'xmp', 'o:p');
     if (Smart::array_size($y_extra_tags_remove) > 0) {
         // add extra entries such as: img, p, div, ...
         for ($i = 0; $i < count($y_extra_tags_remove); $i++) {
             if (preg_match((string) $this->regex_tag_name, (string) $y_extra_tags_remove[$i])) {
                 if (!in_array((string) $y_extra_tags_remove[$i], $arr_tags_2x_list_bad)) {
                     $arr_tags_2x_list_bad[] = (string) $y_extra_tags_remove[$i];
                 }
                 //end if
             }
             //end if
         }
         //end for
     }
     //end if
     $arr_tags_2x_repl_bad = (array) $arr_tags_0x_list_comments;
     for ($i = 0; $i < count($arr_tags_0x_list_comments); $i++) {
         $arr_tags_2x_repl_good[] = '<!-- # -->';
         // comment
     }
     //end for
     for ($i = 0; $i < count($arr_tags_2x_list_bad); $i++) {
         $tmp_regex_tag = (array) $this->regex_tag((string) $arr_tags_2x_list_bad[$i]);
         // currently if nested tags some content between those tags may remain not removed ... but that is ok as long as the tag is replaced ; possible fix: match with siU instead of si but will go ungreedy and will match all content until very last end tag ... which may remove too many content
         $arr_tags_2x_repl_bad[] = $tmp_regex_tag['delimiter'] . '(' . $tmp_regex_tag['tag-start'] . ')' . '.*?' . '(' . $tmp_regex_tag['tag-end'] . ')' . $tmp_regex_tag['delimiter'] . 'si';
         // fix: paranthesis are required to correct match in this case (balanced regex)
         $arr_tags_2x_repl_good[] = '<!-- ' . Smart::escape_html((string) $arr_tags_2x_list_bad[$i]) . '/ -->';
     }
     //end if
     //--
     //--
     $arr_tags_1x_list_bad = (array) array_merge((array) $arr_tags_2x_list_bad, array('!doctype', 'html', 'body', 'base', 'meta', 'link', 'track', 'source', 'plaintext', 'marquee'));
     if (Smart::array_size($y_extra_tags_clean) > 0) {
         // add extra entries such as: img, p, div, ...
         for ($i = 0; $i < count($y_extra_tags_clean); $i++) {
             if (preg_match((string) $this->regex_tag_name, (string) $y_extra_tags_clean[$i])) {
                 if (!in_array((string) $y_extra_tags_clean[$i], $arr_tags_1x_list_bad)) {
                     $arr_tags_1x_list_bad[] = (string) $y_extra_tags_clean[$i];
                 }
                 //end if
             }
             //end if
         }
         //end for
     }
     //end if
     $arr_tags_1x_repl_bad = array();
     $arr_tags_1x_repl_good = array();
     for ($i = 0; $i < count($arr_tags_1x_list_bad); $i++) {
         $tmp_regex_tag = (array) $this->regex_tag((string) $arr_tags_1x_list_bad[$i]);
         $arr_tags_1x_repl_bad[] = $tmp_regex_tag['delimiter'] . $tmp_regex_tag['tag-start'] . $tmp_regex_tag['delimiter'] . 'si';
         $arr_tags_1x_repl_bad[] = $tmp_regex_tag['delimiter'] . $tmp_regex_tag['tag-end'] . $tmp_regex_tag['delimiter'] . 'si';
         $arr_tags_1x_repl_good[] = '<!-- ' . Smart::escape_html((string) $arr_tags_1x_list_bad[$i]) . ' -->';
         $arr_tags_1x_repl_good[] = '<!-- /' . Smart::escape_html((string) $arr_tags_1x_list_bad[$i]) . ' -->';
     }
     //end if
     //--
     //--
     $arr_all_repl_bad = (array) array_merge((array) $arr_tags_2x_repl_bad, (array) $arr_tags_1x_repl_bad);
     $arr_all_repl_good = (array) array_merge((array) $arr_tags_2x_repl_good, (array) $arr_tags_1x_repl_good);
     //--
     //print_r($arr_tags_2x_repl_bad);
     //print_r($arr_tags_2x_repl_good);
     //print_r($arr_tags_1x_repl_bad);
     //print_r($arr_tags_1x_repl_good);
     //print_r($arr_all_repl_bad);
     //print_r($arr_all_repl_good);
     //die('');
     //--
     //--
     $this->html = (string) preg_replace((array) $arr_all_repl_bad, (array) $arr_all_repl_good, (string) $this->html);
     //--
     //--
     $this->parse_elements();
     //--
     //--
     for ($i = 0; $i < Smart::array_size($this->elements); $i++) {
         //--
         $code = (string) $this->elements[$i];
         if (substr($code, 0, 4) != '<!--' and (strpos($code, '<') !== false or strpos($code, '>') !== false)) {
             // if valid tag and not a comment
             //--
             $tag_have_endline = false;
             if (substr($code, -1, 1) === "\n") {
                 $tag_have_endline = true;
             }
             //end if
             //--
             $code = trim(str_replace(array("\t", "\n", "\r"), array(' ', ' ', ' '), (string) $code));
             // make tabs and new lines as simple space
             $tmp_parse_attr = (array) $this->get_attributes($code);
             //--
             if (strpos($code, ' ') !== false and Smart::array_size($tmp_parse_attr) > 0) {
                 // tag have attributes
                 //--
                 $tmp_arr = explode(' ', $code);
                 // get tag parts
                 $this->elements[$i] = strtolower((string) $tmp_arr[0]);
                 // recompose the tags
                 foreach ($tmp_parse_attr as $key => $val) {
                     $tmp_is_valid_attr = true;
                     if (!preg_match((string) $this->regex_tag_name, (string) $key)) {
                         $tmp_is_valid_attr = false;
                         // remove invalid attributes
                     } elseif (substr((string) trim((string) $key), 0, 2) == 'on') {
                         $tmp_is_valid_attr = false;
                         // remove attributes starting with 'on' (all JS Events)
                     } elseif (substr((string) trim((string) $key), 0, 10) == 'formaction') {
                         $tmp_is_valid_attr = false;
                         // remove attributes starting with 'formaction'
                     } elseif (substr((string) trim((string) $val), 0, 2) == '&{') {
                         $tmp_is_valid_attr = false;
                         // remove attributes of which value are old Netscape JS ; Ex: border="&{getBorderWidth( )};"
                     } elseif (substr((string) trim((string) $val), 0, 11) == 'javascript:') {
                         $tmp_is_valid_attr = false;
                         // remove attributes that contain javascript:
                     } elseif (stripos((string) trim((string) $val), 'java') !== false and stripos((string) trim((string) $val), 'script') !== false and strpos((string) trim((string) $val), ':') !== false) {
                         $tmp_is_valid_attr = false;
                         // remove attributes that contain java + script + :
                     }
                     //end for
                     if ($tmp_is_valid_attr) {
                         $this->elements[$i] .= ' ' . strtolower($key) . '=' . '"' . str_replace(array('"', '<', '>'), array('&quot;', '&lt;', '&gt;'), (string) $val) . '"';
                     }
                     //end if
                 }
                 //end foreach
                 $this->elements[$i] .= '>';
                 if ($tag_have_endline) {
                     $this->elements[$i] .= "\n";
                 }
                 //end if
                 $tmp_arr = array();
                 //--
             } elseif (preg_match('/^[<' . $this->expr_tag_name . '\\/ >]+$/si', (string) $code)) {
                 // simple tags (includding tags like <br />) ; needs extra / and space
                 //--
                 $this->elements[$i] = strtolower((string) $code);
                 if ($tag_have_endline) {
                     $this->elements[$i] .= "\n";
                 }
                 //end if
                 //--
             } else {
                 //--
                 $this->elements[$i] = '';
                 // invalid tags, clear
                 //--
             }
             //end if
         }
         //end if
         //--
     }
     //end for
     //--
     //--
     $this->html = (string) SmartUnicode::convert_charset((string) implode('', (array) $this->elements), 'UTF-8', 'HTML-ENTITIES');
     //--
     if ($y_comments === false) {
         $this->html = preg_replace((array) $arr_tags_0x_list_comments, '', $this->html);
     }
     //end if
     //--
     //--
     if (Smart::array_size($y_allowed_tags) > 0) {
         $arr_striptags_allow = array();
         for ($i = 0; $i < count($y_allowed_tags); $i++) {
             if (preg_match((string) $this->regex_tag_name, (string) $y_allowed_tags[$i])) {
                 if (!in_array((string) $y_allowed_tags[$i], (array) $arr_striptags_allow)) {
                     // despite if a tag is specified as unallowed, if allowed here will take precedence
                     $arr_striptags_allow[] = '<' . $y_allowed_tags[$i] . '>';
                 }
                 //end if
             }
             //end if
         }
         //end for
         if (Smart::array_size($arr_striptags_allow) > 0) {
             //print_r($arr_striptags_allow);
             $str_striptags_allow = (string) implode(',', (array) $arr_striptags_allow);
             //echo $str_striptags_allow;
             $this->html = (string) strip_tags((string) $this->html, (string) $str_striptags_allow);
         }
         //end if
     }
     //end if
     //--
     //--
     $this->html = (string) trim((string) $this->html);
     //--
     //--
     $use_dom = false;
     //--
     if ($this->dom_processing !== false and class_exists('DOMDocument')) {
         //--
         $use_dom = true;
         //--
         if ((string) $this->html != '') {
             //--
             @libxml_use_internal_errors(true);
             @libxml_clear_errors();
             //--
             $dom = new DOMDocument(5, (string) SMART_FRAMEWORK_CHARSET);
             //--
             $dom->encoding = (string) SMART_FRAMEWORK_CHARSET;
             $dom->strictErrorChecking = false;
             // do not throw errors
             $dom->preserveWhiteSpace = true;
             // do not remove redundant white space
             $dom->formatOutput = true;
             // try to format pretty-print the code
             $dom->resolveExternals = false;
             // disable load external entities from a doctype declaration
             $dom->validateOnParse = false;
             // this must be explicit disabled as if set to true it may try to download the DTD and after to validate (insecure ...)
             //--
             @$dom->loadHTML((string) $this->html, LIBXML_ERR_WARNING | LIBXML_NONET | LIBXML_PARSEHUGE | LIBXML_BIGLINES | LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
             $this->html = (string) @$dom->saveHTML();
             // get back from DOM
             //print_r($this->html);
             unset($dom);
             // clear DOM
             $this->html = (string) trim((string) preg_replace('~<(?:!DOCTYPE|/?(?:html|head|body))[^>]*>\\s*~i', '', (string) $this->html));
             // cleanup ; fixes: normally with the above options will add no doctype or html / body tags, but use it just in case ; alternative to this: explode by body to get content
             //--
             if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes' or $this->dom_log_errors === true) {
                 // log errors if set :: OR ((string)$this->html == '')
                 $errors = (array) @libxml_get_errors();
                 if (Smart::array_size($errors) > 0) {
                     $notice_log = '';
                     foreach ($errors as $z => $error) {
                         if (is_object($error)) {
                             $notice_log .= 'PARSE-ERROR: [' . $the_ercode . '] / Level: ' . $error->level . ' / Line: ' . $error->line . ' / Column: ' . $error->column . ' / Code: ' . $error->code . ' / Message: ' . $error->message . "\n";
                         }
                         //end if
                     }
                     //end foreach
                     if ((string) $notice_log != '') {
                         Smart::log_notice('SmartHtmlParser NOTICE [DOMDocument]:' . "\n" . $notice_log . "\n" . '#END' . "\n");
                     }
                     //end if
                     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
                         Smart::log_notice('SmartHtmlParser / Debug HTML-String:' . "\n" . $this->html . "\n" . '#END');
                     }
                     //end if
                 }
                 //end if
             }
             //end if
             //--
             @libxml_clear_errors();
             @libxml_use_internal_errors(false);
             //--
         }
         //end if
         //--
     }
     //end if
     //--
     //--
     if ($this->signature) {
         if ($use_dom) {
             $start_signature = '<!-- Smart/HTML.Cleaner [@] -->';
             $end_signature = '<!-- [/@] Smart/HTML.Cleaner -->';
         } else {
             $start_signature = '<!-- Smart/HTML.Cleaner [#] -->';
             $end_signature = '<!-- [/#] Smart/HTML.Cleaner -->';
         }
         //end if else
     } else {
         $start_signature = '';
         $end_signature = '';
     }
     //end if else
     //--
     //--
     $this->html = (string) $start_signature . $this->html . $end_signature;
     //--
 }
 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">&nbsp;' . 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']) . ' &nbsp; <i>' . Smart::escape_html($head['from_name']) . '</i>' . '</font><br>';
                     $out .= '<font size="2"><b>To:</b> ' . Smart::escape_html($head['to_addr']) . ' &nbsp; <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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . Smart::escape_html(trim($arr_cc_addr[$z])) . ' &nbsp; <i>' . Smart::escape_html(trim($arr_cc_name[$z])) . '</i>';
                             }
                             //end for
                         } else {
                             $out .= Smart::escape_html($head['cc_addr']) . ' &nbsp; <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']) . ' &nbsp; <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>&nbsp;</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"> &nbsp;<b><i>' . $tmp_att_size . '</i></b></font></td></tr></table></div>';
                         $xatts .= '<div align="left">' . $tmp_att_img . '&nbsp;&nbsp;<font size="1">' . $tmp_att_name . '&nbsp;&nbsp;<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, '.', ',') . '%') . '">&nbsp;</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
     //--
 }
 public static function Run()
 {
     //--
     global $configs;
     //--
     //==
     //--
     if (self::$MiddlewareCompleted !== false) {
         // avoid to execute more than 1 this middleware !
         self::Raise500Error('Middleware App Execution already completed ...');
         return;
     }
     //end if
     self::$MiddlewareCompleted = true;
     //--
     $the_midmark = '[A]';
     //--
     if (SMART_FRAMEWORK_ADMIN_AREA !== true) {
         Smart::raise_error('Admin Middleware ERROR: SMART_FRAMEWORK_ADMIN_AREA is not set to TRUE', 'Invalid Area / This middleware is designed for Admin area and requires to turn ON the Administration flag ...');
         return;
     }
     //end if
     //--
     if (!defined('SMART_APP_TEMPLATES_DIR')) {
         self::Raise500Error('The SMART_APP_TEMPLATES_DIR not defined ...');
         return;
     }
     //end if
     //--
     if (defined('SMART_APP_MODULE_AREA')) {
         self::Raise500Error('Smart App Area must NOT be Defined outside controllers ...');
         return;
     }
     //end if
     if (defined('SMART_APP_MODULE_AUTH')) {
         self::Raise500Error('Smart App Module Auth must NOT be Defined outside controllers ...');
         return;
     }
     //end if
     if (defined('SMART_APP_MODULE_REALM_AUTH')) {
         self::Raise500Error('Smart App Module Realm Auth must NOT be Defined outside controllers ...');
         return;
     }
     //end if
     if (defined('SMART_APP_MODULE_DIRECT_OUTPUT')) {
         self::Raise500Error('Smart App Module Direct Output must NOT be Defined outside controllers ...');
         return;
     }
     //end if
     //--
     //==
     //--
     $smartframeworkservice = '';
     // special operation
     if (SmartFrameworkRegistry::issetRequestVar('smartframeworkservice') === true) {
         $smartframeworkservice = (string) strtolower((string) SmartUnicode::utf8_to_iso((string) SmartFrameworkRegistry::getRequestVar('smartframeworkservice')));
         switch ((string) $smartframeworkservice) {
             case 'status':
             case 'debug':
                 break;
             default:
                 // invalid value
                 $smartframeworkservice = '';
         }
         //end switch
     }
     //end if
     //--
     //==
     //-- switch language by cookie (this needs to be before loading the app core)
     if (strlen(trim((string) $_COOKIE['SmartApp_ADM_LANGUAGE_SET'])) > 0) {
         SmartTextTranslations::setLanguage(trim((string) $_COOKIE['SmartApp_ADM_LANGUAGE_SET']));
     }
     //end if
     //-- switch language by print cookie (this needs to be before loading the app core and after language by cookie)
     if (SmartFrameworkRegistry::issetRequestVar((string) SMART_FRAMEWORK_URL_PARAM_PRINTABLE) === true) {
         if (strtolower((string) SmartFrameworkRegistry::getRequestVar((string) SMART_FRAMEWORK_URL_PARAM_PRINTABLE)) == strtolower((string) SMART_FRAMEWORK_URL_VALUE_ENABLED)) {
             if (strlen(trim((string) $_COOKIE['SmartApp_ADM_PRINT_LANGUAGE_SET'])) > 0) {
                 SmartTextTranslations::setLanguage(trim((string) $_COOKIE['SmartApp_ADM_PRINT_LANGUAGE_SET']));
             }
             //end if
         }
         //end if
     }
     //end if
     //--
     //== RAW OUTPUT FOR STATUS
     //--
     if ((string) $smartframeworkservice == 'status') {
         //--
         if (SMART_SOFTWARE_DISABLE_STATUS_POWERED === true) {
             $status_powered_info = '';
         } else {
             $status_powered_info = (string) SmartComponents::draw_powered_info('no');
         }
         //end if else
         //--
         self::HeadersNoCache();
         // headers: cache control, force no-cache
         echo SmartComponents::http_status_message('Smart.Framework :: Status :: [OK]', '<script type="text/javascript">setTimeout(function(){ self.location = self.location; }, 60000);</script><img src="lib/core/img/busy_bar.gif"><div><h1>' . date('Y-m-d H:i:s O') . ' // Service Ready :: ' . $the_midmark . '</h1></div>' . $status_powered_info . '<br>');
         //--
         return;
         // break stop
         //--
     }
     //end if
     //--
     //== OVERALL AUTHENTICATION BREAKPOINT
     //--
     SmartAppBootstrap::Authenticate('admin');
     // if the auth uses session it may start now
     //--
     //== RAW OUTPUT FOR DEBUG
     //--
     if ((string) $smartframeworkservice == 'debug') {
         //--
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             self::HeadersNoCache();
             // headers: cache control, force no-cache
             $the_debug_cookie = trim((string) $_COOKIE['SmartFramework__DebugAdmID']);
             echo SmartDebugProfiler::print_debug_info('adm', $the_debug_cookie);
         } else {
             http_response_code(404);
             echo SmartComponents::http_message_404_notfound('No Debug service has been activated on this server ...');
         }
         //end if
         //--
         return;
         // break stop
         //--
     }
     //end if else
     //--
     //== LOAD THE MODULE (OR DEFAULT MODULE)
     //--
     $reserved_controller_names = ['php', 'html', 'stml', 'css', 'js', 'json', 'xml', 'rss', 'txt', 'csv', 'sql', 'png', 'gif', 'jpg', 'pdf', 'svg', 'zip', '7z', 'netarch'];
     // these are reserved extensions and cannot be used as controller names because they need to be used also with friendly URLs as the 2nd param if module is missing from URL page param
     //--
     $err404 = '';
     $arr = array();
     //--
     $page = (string) SmartUnicode::utf8_to_iso((string) SmartFrameworkRegistry::getRequestVar('page'));
     $page = trim(str_replace(array('/', '\\', ':', '?', '&', '=', '%'), array('', '', '', '', '', '', ''), $page));
     // fix for get as it automatically replaces . with _ (so, reverse), but also fix some invalid characters ...
     if ((string) $page == '') {
         $page = (string) $configs['app']['admin-home'];
     }
     //end if
     //--
     if (strpos($page, '.') !== false) {
         // page can be as module.controller / module.controller(.php|html|stml|css|js|json|xml|rss|txt|csv|sql|png|gif|jpg|pdf|svg|zip|7z|netarch)
         //--
         $arr = (array) explode('.', (string) $page, 3);
         // separe 1st and 2nd from the rest
         //--
         //#
         //#
         $arr[0] = trim(strtolower((string) $arr[0]));
         // module
         $arr[1] = trim(strtolower((string) $arr[1]));
         // controller
         //#
         //# Admin will NOT integrate with friendly URLs SMART_FRAMEWORK_SEMANTIC_URL_SKIP_MODULE
         //# that feature is just for Index
         //#
         //--
     } elseif ((string) $configs['app']['admin-default-module'] != '') {
         //--
         $arr[0] = trim(strtolower((string) $configs['app']['admin-default-module']));
         // get default module
         $arr[1] = trim(strtolower((string) $page));
         // controller
         //--
     } else {
         //--
         if ((string) $err404 == '') {
             $err404 = 'Invalid Page (Invalid URL Page Segments Syntax): ' . $page;
         }
         //end if
         //--
     }
     //end if else
     //--
     if ((string) $arr[0] == '' or (string) $arr[1] == '') {
         if ((string) $err404 == '') {
             $err404 = 'Invalid Page (Empty or Missing URL Page Segments): ' . $page;
         }
         //end if
     }
     //end if
     if (!preg_match('/^[a-z0-9_\\-]+$/', (string) $arr[0]) or !preg_match('/^[a-z0-9_\\-]+$/', (string) $arr[1])) {
         if ((string) $err404 == '') {
             $err404 = 'Invalid Page (Invalid Characters in the URL Page Segments): ' . $page;
         }
         //end if
     }
     //end if
     if (in_array((string) $arr[1], (array) $reserved_controller_names)) {
         if ((string) $err404 == '') {
             $err404 = 'Invalid Page (Reserved Page Controller Name): [' . $arr[1] . '] in: ' . $page;
         }
         //end if
     }
     //end if
     //--
     $the_controller_name = (string) $arr[0] . '.' . $arr[1];
     $the_path_to_module = Smart::safe_pathname(SmartFileSysUtils::add_dir_last_slash('modules/mod-' . Smart::safe_filename($arr[0])));
     $the_module = Smart::safe_pathname($the_path_to_module . Smart::safe_filename($arr[1]) . '.php');
     if (!is_file($the_module)) {
         if ((string) $err404 == '') {
             $err404 = 'Page does not exist: ' . $page;
         }
         //end if
     }
     //end if
     //--
     if ((string) $err404 != '') {
         self::Raise404Error((string) $err404);
         return;
     }
     //end if
     //--
     if (!SmartFileSysUtils::check_file_or_dir_name($the_path_to_module) or !SmartFileSysUtils::check_file_or_dir_name($the_module)) {
         self::Raise400Error('Insecure Module Access for Page: ' . $page);
         return;
     }
     //end if
     //--
     if (class_exists('SmartAppIndexController') or class_exists('SmartAppAdminController')) {
         self::Raise500Error('Module Class Runtimes must be defined only in modules ...');
         return;
     }
     //end if
     //--
     require (string) $the_module;
     //--
     if ((string) SMART_APP_MODULE_AREA !== 'ADMIN' and (string) SMART_APP_MODULE_AREA !== 'SHARED') {
         self::Raise403Error('Page Access Denied for Admin Area: ' . $page);
         return;
     }
     //end if
     if (defined('SMART_APP_MODULE_AUTH')) {
         if (SmartAuth::check_login() !== true) {
             self::Raise403Error('Page Access Denied ! No Authentication: ' . $page);
             return;
         }
         //end if
         if (defined('SMART_APP_MODULE_REALM_AUTH')) {
             if ((string) SmartAuth::get_login_realm() !== (string) SMART_APP_MODULE_REALM_AUTH) {
                 self::Raise403Error('Page Access Denied ! Invalid Login Realm: ' . $page);
                 return;
             }
             //end if
         }
         //end if
     }
     //end if
     //--
     if (!class_exists('SmartAppAdminController')) {
         self::Raise500Error('Invalid Module Class Runtime for Page: ' . $page);
         return;
     }
     //end if
     if (!is_subclass_of('SmartAppAdminController', 'SmartAbstractAppController')) {
         self::Raise500Error('Invalid Module Class Inheritance for Controller Page: ' . $page);
         return;
     }
     //end if
     //--
     //== PATHS
     //--
     $base_script = SmartUtils::get_server_current_script();
     $base_full_path = SmartUtils::get_server_current_path();
     $base_full_url = SmartUtils::get_server_current_url();
     //--
     //== RUN THE MODULE
     //--
     $appModule = new SmartAppAdminController($the_path_to_module, $base_script, $base_full_path, $base_full_url, $page, $the_controller_name);
     //--
     if (SMART_APP_MODULE_DIRECT_OUTPUT !== true) {
         ob_start();
     }
     //end if
     $appStatusCode = (int) $appModule->Run();
     $appModule->ShutDown();
     if (SMART_APP_MODULE_DIRECT_OUTPUT !== true) {
         $ctrl_output = ob_get_contents();
         ob_end_clean();
         if ((string) $ctrl_output != '') {
             Smart::log_warning('The middleware service ' . $the_midmark . ' detected an illegal output in the controller: ' . $page . "\n" . 'The result of this output is: ' . $ctrl_output);
         }
         //end if
         $ctrl_output = '';
     } else {
         return;
         // break stop after the controller has terminated the direct output
     }
     //end if else
     //--
     $appSettings = (array) $appModule->PageViewGetCfgs();
     //--
     //== CACHE CONTROL
     //--
     if ((int) $appSettings['expires'] > 0 and (string) SMART_FRAMEWORK_DEBUG_MODE != 'yes') {
         self::HeadersCacheExpire((int) $appSettings['expires'], (int) $appSettings['modified']);
         // headers: cache expiration control
     } else {
         self::HeadersNoCache();
         // headers: cache control, force no-cache
     }
     //end if else
     //--
     //== STATUS CODE
     //--
     switch ((int) $appStatusCode) {
         //-- client errors
         case 400:
             self::Raise400Error((string) $appSettings['error']);
             return;
             break;
         case 401:
             self::Raise401Error((string) $appSettings['error']);
             return;
             break;
         case 403:
             self::Raise403Error((string) $appSettings['error']);
             return;
             break;
         case 404:
             self::Raise404Error((string) $appSettings['error']);
             return;
             break;
         case 429:
             self::Raise429Error((string) $appSettings['error']);
             return;
             break;
             //-- server errors
         //-- server errors
         case 500:
             self::Raise500Error((string) $appSettings['error']);
             return;
             break;
         case 502:
             self::Raise502Error((string) $appSettings['error']);
             return;
             break;
         case 503:
             self::Raise503Error((string) $appSettings['error']);
             return;
             break;
         case 504:
             self::Raise504Error((string) $appSettings['error']);
             return;
             break;
             //-- extended 2xx statuses: NOTICE / WARNING / ERROR that can be used for REST / API
         //-- extended 2xx statuses: NOTICE / WARNING / ERROR that can be used for REST / API
         case 202:
             // NOTICE
             if (!headers_sent()) {
                 http_response_code(202);
                 // Accepted (this should be used only as an alternate SUCCESS code instead of 200 for NOTICES)
             } else {
                 Smart::log_warning('Headers Already Sent before 202 ...');
             }
             //end if else
             break;
         case 203:
             // WARNING
             if (!headers_sent()) {
                 http_response_code(203);
                 // Non-Authoritative Information (this should be used only as an alternate SUCCESS code instead of 200 for WARNINGS)
             } else {
                 Smart::log_warning('Headers Already Sent before 203 ...');
             }
             //end if else
             break;
         case 208:
             // ERROR
             if (!headers_sent()) {
                 http_response_code(208);
                 // Already Reported (this should be used only as an alternate SUCCESS code instead of 200 for ERRORS)
             } else {
                 Smart::log_warning('Headers Already Sent before 208 ...');
             }
             //end if else
             break;
             //-- DEFAULT: OK
         //-- DEFAULT: OK
         case 200:
         default:
             // any other codes not listed above are not supported and will be interpreted as 200
             // nothing to do here ...
     }
     //end switch
     //--
     //== PREPARE THE OUTPUT
     //--
     if (stripos((string) $configs['js']['popup-override-mobiles'], '<' . SmartUtils::get_os_browser_ip('os') . '>') !== false) {
         $configs['js']['popup-mode'] = 'popup';
         // particular os settings for mobiles
     }
     //end if
     //--
     $rawpage = '';
     if (isset($appSettings['rawpage'])) {
         $rawpage = strtolower((string) $appSettings['rawpage']);
         if ((string) $rawpage == 'yes') {
             $rawpage = 'yes';
             // standardize the value
         }
         //end if
     }
     //end if
     if ((string) $rawpage != 'yes') {
         $rawpage = '';
     }
     //end if
     //--
     $rawmime = '';
     if (isset($appSettings['rawmime'])) {
         $rawmime = (string) $appSettings['rawmime'];
         if ((string) $rawmime != '') {
             $rawmime = SmartValidator::validate_mime_type($rawmime);
         }
         //end if
     }
     //end if else
     //--
     $rawdisp = '';
     if (isset($appSettings['rawdisp'])) {
         $rawdisp = (string) $appSettings['rawdisp'];
         if ((string) $rawdisp != '') {
             $rawdisp = SmartValidator::validate_mime_disposition($rawdisp);
         }
         //end if
     }
     //end if else
     //--
     $appData = (array) $appModule->PageViewGetVars();
     //--
     $appData['base-path'] = (string) $base_full_path;
     $appData['base-url'] = (string) $base_full_url;
     //--
     //== REDIRECTION HANDLER (this can be set only explicit from Controllers)
     //--
     if ((string) $appSettings['redirect-url'] != '') {
         // expects a valid URL
         //--
         $the_redirect_link = '<a href="' . Smart::escape_html((string) $appSettings['redirect-url']) . '">' . Smart::escape_html((string) $appSettings['redirect-url']) . '</a>';
         //--
         if (headers_sent()) {
             Smart::log_warning('Headers Already Sent before Redirection: [' . $appStatusCode . '] ; URL: ' . $appSettings['redirect-url']);
             self::Raise500Error('The app failed to Redirect to: ' . $the_redirect_link);
             return;
         }
         //end if
         switch ((int) $appStatusCode) {
             case 301:
                 http_response_code(301);
                 $the_redirect_text = 'Moved Permanently';
                 // permanent redirect for HTTP 1.0 / HTTP 1.1
                 break;
             case 302:
             default:
                 // any other code will be interpreted as 302 (the default redirection in PHP)
                 http_response_code(302);
                 $the_redirect_text = 'Found';
                 // temporary redirect for HTTP 1.0 / HTTP 1.1
                 break;
         }
         //end switch
         header('Location: ' . SmartFrameworkSecurity::FilterUnsafeString((string) $appSettings['redirect-url']));
         echo '<h1>' . Smart::escape_html($the_redirect_text) . '</h1>' . '<br>' . 'If the page redirection fails, click on the below link:' . '<br>' . $the_redirect_link;
         return;
         // break stop
     }
     //end if
     //--
     //== DOWNLOADS HANDLER (downloads can be set only explicit from Controllers)
     //--
     if ((string) $appSettings['download-packet'] != '' and (string) $appSettings['download-key'] != '') {
         // expects an encrypted data packet and a key
         $dwl_result = self::DownloadsHandler((string) $appSettings['download-packet'], (string) $appSettings['download-key']);
         if ((string) $dwl_result != '') {
             Smart::log_info('File Download - Client: ' . SmartUtils::get_visitor_signature(), (string) $dwl_result);
             // log result and mark it as finalized
         }
         //end if
         return;
         // break stop
     }
     //end if
     //--
     //== RAW OUTPUT FOR PAGES
     //--
     if ((string) $rawpage == 'yes') {
         //-- {{{SYNC-RESOURCES}}}
         if (function_exists('memory_get_peak_usage')) {
             $res_memory = @memory_get_peak_usage(false);
         } else {
             $res_memory = 'unknown';
         }
         //end if else
         $res_time = (double) (microtime(true) - (double) SMART_FRAMEWORK_RUNTIME_READY);
         //-- #END-SYNC
         if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
             //-- {{{SYNC-DEBUG-META-INFO}}}
             SmartFrameworkRegistry::setDebugMsg('stats', 'memory', $res_memory);
             // bytes
             SmartFrameworkRegistry::setDebugMsg('stats', 'time', $res_time);
             // seconds
             //-- #END-SYNC
             $the_debug_cookie = trim((string) $_COOKIE['SmartFramework__DebugAdmID']);
             SmartDebugProfiler::save_debug_info('adm', $the_debug_cookie, false);
         } else {
             $the_debug_cookie = '';
         }
         //end if
         //--
         if (headers_sent()) {
             Smart::raise_error('Middleware ERROR: Headers already sent', 'ERROR: Headers already sent !');
             return;
             // avoid serve raw pages with errors injections before headers
         }
         //end if
         //--
         if ((string) $rawmime != '') {
             header('Content-Type: ' . $rawmime);
         }
         //end if
         if ((string) $rawdisp != '') {
             header('Content-Disposition: ' . $rawdisp);
         }
         //end if
         header('Content-Length: ' . (0 + strlen((string) $appData['main'])));
         // must be strlen NOT SmartUnicode::str_len as it must get number of bytes not characters
         echo (string) $appData['main'];
         return;
         // break stop
         //--
     }
     //end if else
     //--
     //== DEFAULT OUTPUT
     //--
     if (isset($appSettings['template-path'])) {
         if ((string) $appSettings['template-path'] == '@') {
             // if template path is set to self (module)
             $the_template_path = '@';
             // this is a special setting
         } else {
             $the_template_path = Smart::safe_pathname(SmartFileSysUtils::add_dir_last_slash(trim((string) $appSettings['template-path'])));
         }
         //end if else
     } else {
         $the_template_path = Smart::safe_pathname(SmartFileSysUtils::add_dir_last_slash(trim((string) $configs['app']['admin-template-path'])));
         // use default template path
     }
     //end if else
     //--
     if (isset($appSettings['template-file'])) {
         $the_template_file = Smart::safe_filename(trim((string) $appSettings['template-file']));
     } else {
         $the_template_file = Smart::safe_filename(trim((string) $configs['app']['admin-template-file']));
         // use default template
     }
     //end if else
     //--
     if ((string) $the_template_path == '@') {
         $the_template_path = (string) $the_path_to_module . 'templates/';
         // must have the dir last slash as above
     } else {
         $the_template_path = (string) SMART_APP_TEMPLATES_DIR . $the_template_path;
         // finally normalize and set the complete template path
     }
     //end if else
     $the_template_file = (string) $the_template_file;
     // finally normalize
     //--
     if (!SmartFileSysUtils::check_file_or_dir_name($the_template_path)) {
         Smart::log_warning('Invalid Page Template Path: ' . $the_template_path);
         self::Raise500Error('Invalid Page Template Path. See the error log !');
         return;
     }
     //end if
     if (!is_dir($the_template_path)) {
         Smart::log_warning('Page Template Path does not Exists: ' . $the_template_path);
         self::Raise500Error('Page Template Path does not Exists. See the error log !');
         return;
     }
     //end if
     if (!SmartFileSysUtils::check_file_or_dir_name($the_template_path . $the_template_file)) {
         Smart::log_warning('Invalid Page Template File: ' . $the_template_path . $the_template_file);
         self::Raise500Error('Invalid Page Template File. See the error log !');
         return;
     }
     //end if
     if (!is_file($the_template_path . $the_template_file)) {
         Smart::log_warning('Page Template File does not Exists: ' . $the_template_path . $the_template_file);
         self::Raise500Error('Page Template File does not Exists. See the error log !');
         return;
     }
     //end if
     //--
     $the_template_content = trim(SmartMarkersTemplating::read_template_file($the_template_path . $the_template_file));
     if ((string) $the_template_content == '') {
         Smart::log_warning('Page Template File is Empty or cannot be read: ' . $the_template_path . $the_template_file);
         self::Raise500Error('Page Template File is Empty or cannot be read. See the error log !');
         return;
     }
     //end if
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         $the_template_content = str_ireplace('</head>', "\n" . SmartDebugProfiler::js_headers_debug('admin.php?smartframeworkservice=debug') . "\n" . '</head>', $the_template_content);
         $the_template_content = str_ireplace('</body>', "\n" . SmartDebugProfiler::div_main_debug() . "\n" . '</body>', $the_template_content);
     }
     //end if
     //--
     $appData['app-domain'] = (string) $configs['app']['admin-domain'];
     $appData['template-file'] = $the_template_path . $the_template_file;
     $appData['template-path'] = $the_template_path;
     $appData['js.settings'] = SmartComponents::js_inc_settings((string) $configs['js']['popup-mode'], true, (bool) SMART_APP_VISITOR_COOKIE);
     $appData['head-meta'] = (string) $appData['head-meta'];
     if ((string) $appData['head-meta'] == '') {
         $appData['head-meta'] = '<!-- Head Meta -->';
     }
     //end if
     $appData['title'] = (string) $appData['title'];
     $appData['main'] = (string) $appData['main'];
     $appData['lang'] = SmartTextTranslations::getLanguage();
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         //--
         $the_debug_cookie = 'adm-' . Smart::uuid_10_seq() . '-' . Smart::uuid_10_num() . '-' . Smart::uuid_10_str();
         @setcookie('SmartFramework__DebugAdmID', (string) $the_debug_cookie, 0, '/');
         // debug token cookie is set just on main request
         //--
     }
     //end if
     //--
     echo SmartMarkersTemplating::render_mixed_template((string) $the_template_content, (array) $appData, (string) $appData['template-path'], 'no', 'no');
     //-- {{{SYNC-RESOURCES}}}
     if (function_exists('memory_get_peak_usage')) {
         $res_memory = @memory_get_peak_usage(false);
     } else {
         $res_memory = 'unknown';
     }
     //end if else
     $res_time = (double) (microtime(true) - (double) SMART_FRAMEWORK_RUNTIME_READY);
     //-- #END-SYNC
     if ((string) SMART_FRAMEWORK_DEBUG_MODE == 'yes') {
         //-- {{{SYNC-DEBUG-META-INFO}}}
         SmartFrameworkRegistry::setDebugMsg('stats', 'memory', $res_memory);
         // bytes
         SmartFrameworkRegistry::setDebugMsg('stats', 'time', $res_time);
         // seconds
         //-- #END-SYNC
         SmartDebugProfiler::save_debug_info('adm', $the_debug_cookie, true);
         //--
     }
     //end if else
     //--
     if (SMART_SOFTWARE_DISABLE_STATUS_POWERED !== true) {
         echo "\n" . '<!-- Smart.Framework スマート.フレームワーク :: ' . SMART_FRAMEWORK_RELEASE_TAGVERSION . ' / ' . SMART_FRAMEWORK_RELEASE_VERSION . ' @ ' . $the_midmark . ' :: ' . SMART_FRAMEWORK_RELEASE_URL . ' -->';
     }
     //end if
     echo "\n" . '<!-- Resources: [' . Smart::format_number_dec($res_time, 13, '.', '') . ' sec.] / [' . Smart::format_number_dec($res_memory, 0, '.', ' ') . ' by.]' . ' -->' . "\n";
     //--
 }
 /**
  * Function: Get BarCode as PNG embedded in HTML
  *
  * @access 		private
  * @internal
  *
  */
 public static function getBarcodeEmbeddedHTMLPNG($barcode_arr, $z = 3, $color = '#000000')
 {
     //--
     if (!is_array($barcode_arr)) {
         return '<span style="background:#FAFAFA; color:#FF5500;"><font size="1">[ INVALID BARCODE ]</font></span>';
     }
     //end if
     $z = self::conformZ($z);
     //--
     $microtime = microtime(true);
     //--
     return "\n" . '<!-- Barcode2D / PNG -->' . '<img src="data:image/png;base64,' . Smart::escape_html(base64_encode(self::getBarcodePNG($barcode_arr, $z, $color))) . '" alt="BarCode2D-PNG">' . '<!-- END :: Barcode2D [' . (microtime(true) - $microtime) . '] -->' . "\n";
     //--
 }
 private static function replace_marker($mtemplate, $key, $val)
 {
     //--
     if ((string) $key != '' and preg_match('/^[A-Z0-9_\\-\\.]+$/', (string) $key) and strpos((string) $mtemplate, '[####' . $key) !== false) {
         //--
         $regex = '/\\[####' . preg_quote((string) $key, '/') . '(\\|bool|\\|num|\\|htmid|\\|jsvar|\\|json)?(\\|url)?(\\|js)?(\\|html)?(\\|nl2br)?' . '####\\]/';
         //--
         if ((string) $val != '') {
             $val = (string) str_replace(array('[####', '####]', '[%%%%', '%%%%]', '[@@@@', '@@@@]'), array('(####+', '+####)', '(%%%%+', '+%%%%)', '(@@@@+', '+@@@@)'), (string) $val);
             // protect against cascade / recursion / undefined variables - for content injections of: variables / syntax / sub-templates
         }
         //end if
         //--
         $mtemplate = (string) preg_replace_callback((string) $regex, function ($matches) use($val) {
             //-- Format
             if ((string) $matches[1] == '|num') {
                 // Number
                 $val = (string) (double) $val;
             } elseif ((string) $matches[1] == '|bool') {
                 // Boolean
                 if ($val) {
                     $val = 'true';
                 } else {
                     $val = 'false';
                 }
                 //end if else
             } elseif ((string) $matches[1] == '|htmid') {
                 // HTML ID
                 $val = (string) trim((string) preg_replace('/[^a-zA-Z0-9_\\-]/', '', (string) $val));
             } elseif ((string) $matches[1] == '|jsvar') {
                 // JS Variable
                 $val = (string) trim((string) preg_replace('/[^a-zA-Z0-9_]/', '', (string) $val));
             } elseif ((string) $matches[1] == '|json') {
                 // Json Data (!!! DO NOT ENCLOSE IN ' or " as it can contain them as well as it can be [] or {} ... this is pure JSON !!!)
                 $val = (string) Smart::json_encode($val, false, false);
                 // no pretty print, escape unicode as it is served inline !
             }
             //end if
             //-- Escape
             if ((string) $matches[2] == '|url') {
                 $val = (string) Smart::escape_url((string) $val);
             }
             //end if
             if ((string) $matches[3] == '|js') {
                 $val = (string) Smart::escape_js((string) $val);
             }
             //end if
             if ((string) $matches[4] == '|html') {
                 $val = (string) Smart::escape_html((string) $val);
             }
             //end if
             //--
             if ((string) $matches[5] == '|nl2br') {
                 $val = (string) Smart::nl_2_br((string) $val);
             }
             //end if
             //--
             return (string) $val;
             //--
         }, (string) $mtemplate);
         //--
     }
     //end if
     //--
     return (string) $mtemplate;
     //--
 }
 /**
  * Function: Get BarCode as PNG embedded in HTML
  *
  * @access 		private
  * @internal
  *
  */
 public static function getBarcodeEmbeddedHTMLPNG($barcode_arr, $w = 2, $h = 30, $color = '#000000', $display_text = false)
 {
     //--
     if (!is_array($barcode_arr)) {
         return '<span style="background:#FAFAFA; color:#FF5500;"><font size="1">[ INVALID BARCODE ]</font></span>';
     }
     //end if
     $w = self::conformW($w);
     $h = self::conformH($h);
     //--
     $microtime = microtime(true);
     //--
     $html = '';
     $html .= "\n" . '<!-- Barcode1D / PNG -->';
     $html .= '<img src="data:image/png;base64,' . Smart::escape_html(base64_encode(self::getBarcodePNG($barcode_arr, $w, $h, $color, $display_text))) . '" alt="BarCode1D-PNG">';
     $html .= '<!-- END :: Barcode1D [' . (microtime(true) - $microtime) . '] -->' . "\n";
     //--
     return $html;
     //--
 }
示例#10
0
 public static final function Raise504Error($y_msg)
 {
     //--
     if (!headers_sent()) {
         http_response_code(504);
     } else {
         Smart::log_warning('Headers Already Sent before 504 ...');
     }
     //end if else
     die(SmartComponents::http_message_504_gatewaytimeout(Smart::escape_html((string) $y_msg)));
     //--
 }
示例#11
0
 public static function print_array_to_html($y_aray)
 {
     $out = '';
     if (is_array($y_aray)) {
         $out .= '<table border="0"><tr><td>';
         foreach ($y_aray as $key => $val) {
             $out .= '&middot;&nbsp;' . Smart::escape_html($val) . '<br>';
         }
         //end foreach
         $out .= '</td></tr></table>';
     } else {
         Smart::log_warning('ERROR: SmartUtils print_array_to_html expect the 1st param to be array !');
         return '';
     }
     //end if else
     return $out;
 }
示例#12
0
 public function generate($y_mode = 'raw')
 {
     //--
     $this->color = array();
     $this->biggest_x = NULL;
     $this->biggest_y = NULL;
     $this->exists_graph2 = false;
     $this->total_parameters = 0;
     $this->sum_total = 1;
     //--
     //--
     $this->legend_exists = preg_match("/(5|6)/", (string) $this->type) ? true : false;
     $this->biggest_graphic_name = strlen($this->graphic_1) > strlen($this->graphic_2) ? $this->graphic_1 : $this->graphic_2;
     $this->height_title = !empty($this->title) ? $this->string_height($this->tsize) + 15 : 0;
     $this->space_between_bars = $this->type == 1 ? 40 : 30;
     $this->space_between_dots = 40;
     $this->higher_value = 0;
     $this->higher_strvalue = 0;
     //--
     //--
     $this->width = 0;
     $this->height = 0;
     $this->graphic_area_width = 0;
     $this->graphic_area_height = 0;
     $this->graphic_area_x1 = 30;
     $this->graphic_area_y1 = 20 + $this->height_title;
     $this->graphic_area_x2 = $this->graphic_area_x1 + $this->graphic_area_width;
     $this->graphic_area_y2 = $this->graphic_area_y1 + $this->graphic_area_height;
     //--
     //--
     if (count($this->z) && preg_match("/(1|2|3|4)/", (string) $this->type)) {
         $this->exists_graph2 = true;
     }
     //end if
     //--
     $this->total_parameters = count($this->x);
     //--
     for ($i = 0; $i < $this->total_parameters; $i++) {
         //--
         if (strlen($this->x[$i]) > strlen($this->biggest_x)) {
             $this->biggest_x = $this->x[$i];
         }
         //end if
         //--
         if ($this->y[$i] > $this->biggest_y) {
             $this->biggest_y = Smart::format_number_dec(round($this->y[$i], 1), 1, ".", "");
         }
         //end if
         //--
         if ($this->exists_graph2) {
             if (isset($this->z[$i]) && $this->z[$i] > $this->biggest_y) {
                 $this->biggest_y = Smart::format_number_dec(round($this->z[$i], 1), 1, ".", "");
             }
             //end if
         }
         //end if
         //--
     }
     // end for
     //--
     //--
     if ($this->exists_graph2 == true && (!empty($this->graphic_1) || !empty($this->graphic_2))) {
         $this->legend_exists = true;
     }
     //end if
     //--
     //--
     $this->sum_total = array_sum($this->y);
     $this->space_between_bars += $this->exists_graph2 == true ? 10 : 0;
     //--
     //--
     $this->calculate_higher_value();
     $this->calculate_width();
     $this->calculate_height();
     //--
     //--
     if ((string) $y_mode == 'html') {
         return (string) '<img src="data:image/' . $this->format . ';base64,' . Smart::escape_html(base64_encode((string) $this->draw_chart())) . '">';
     } else {
         return (string) $this->draw_chart();
     }
     //end if else
     //--
 }
示例#13
0
 private function create_from_array($y_array)
 {
     //--
     if (!is_array($y_array)) {
         Smart::log_warning('SmartXmlComposer / create_from_array expects an Array as parameter ...');
         return '<error>XML Writer requires an Array as parameter</error>';
     }
     //end if
     //--
     //--
     $out = '';
     //--
     $arrtype = Smart::array_type_test($y_array);
     // 0: not an array ; 1: non-associative ; 2: associative
     //--
     foreach ($y_array as $key => $val) {
         //--
         if ($arrtype === 2) {
             // fix keys for associative array
             if (is_numeric($key) or (string) $key == '') {
                 $key = (string) '_' . $key;
                 // numeric or empty keys are not allowed: _#
             }
             //end if
         }
         //end if
         //--
         if (is_array($val)) {
             if (is_numeric($key)) {
                 // this can happen only if non-associative array as for associative arrays the numeric key is fixed above as _#
                 $out .= $this->create_from_array($val);
             } else {
                 $out .= '<' . Smart::escape_html($key) . '>' . "\n" . $this->create_from_array($val) . '</' . Smart::escape_html($key) . '>' . "\n";
             }
             //end if else
         } elseif ((string) $val != '') {
             $out .= '<' . Smart::escape_html($key) . '>' . Smart::escape_html($val) . '</' . Smart::escape_html($key) . '>' . "\n";
         } else {
             $out .= '<' . Smart::escape_html($key) . ' />' . "\n";
         }
         //end if else
         //--
     }
     //end foreach
     //--
     //--
     return (string) $out;
     //--
 }
示例#14
0
 public static function captcha_form($y_captcha_image_url, $y_form_name, $y_width = '120', $y_text = 'Verification', $y_refresh = 'Click to Refresh Image', $y_textcolor = '#000000', $y_bgcolor = '#FFFFFF', $y_bordercolor = '#CCCCCC')
 {
     //--
     $y_form_name = trim((string) $y_form_name);
     //--
     $js_cookie_name = self::jscookiename($y_form_name);
     //--
     $captcha_url = $y_captcha_image_url;
     $captcha_url = Smart::url_add_suffix($captcha_url, 'captcha_form=' . rawurlencode($y_form_name));
     $captcha_url = Smart::url_add_suffix($captcha_url, 'captcha_mode=image');
     $captcha_url = Smart::url_add_suffix($captcha_url, 'new=' . time() . Smart::random_number(10, 99));
     //-- output
     $ptmp_out = '<div id="Captcha-Div">';
     $ptmp_out .= '<table width="' . ($y_width + 25) . '" border="0" cellpadding="4" bgcolor="' . $y_bgcolor . '" style="border-width: 1px; border-spacing: 1px; border-style: dashed; border-color: ' . $y_bordercolor . ';"><tr>';
     $ptmp_out .= '<tr valign="top">';
     $ptmp_out .= '<td width="50%" align="left">' . '<img id="smart__CaptchaFrm__img" style="cursor: pointer; cursor: hand;" border="0" src="' . Smart::escape_html($captcha_url) . '" onClick="javascript: var captcha_date = new Date(); this.src=\'' . Smart::escape_js($y_captcha_image_url . '&captcha_form=' . rawurlencode($y_form_name) . '&captcha_mode=image&new=') . '\'+captcha_date.getTime()+\'\'+captcha_date.getMilliseconds();" alt="' . $y_refresh . '" title="' . $y_refresh . '">' . '</td>';
     $ptmp_out .= '<td width="50%" align="center">';
     $ptmp_out .= '<font face="tahoma,arial,sans-serif" size="1" color="' . $y_textcolor . '"><b>' . $y_text . '</b></font>:<br>';
     $ptmp_out .= '<span class="ux-form"><input type="text" size="8" maxlength="255" value="" onBlur="try { eval( \'\' + SmartJS_Base64.decode(\'' . base64_encode("try { var SmartCaptchaChecksum = SmartJS_BrowserUtils.getCookie('" . Smart::escape_js(self::chkcookiename($y_form_name)) . "'); if(SmartCaptchaChecksum == '') { SmartCaptchaChecksum = 'invalid-captcha'; alert('The Captcha session expired ..." . '\\n' . "Click on Captcha image to get a new one and try to re-enter the new code." . '\\n' . "If the problem persist please contact the admin !'); } var smartCaptchaTimerCookie = new Date(); var smartCaptchaCookie = SmartJS_Archiver_LZS.compressToBase64(SmartJS_CryptoBlowfish.encrypt(SmartJS_Base64.encode(smartCaptchaTimerCookie.getTime() + '!' + this.value.toUpperCase() + '!SmartFramework'), SmartJS_CoreUtils.stringTrim(SmartCaptchaChecksum))); SmartJS_BrowserUtils.setCookie('" . Smart::escape_js($js_cookie_name) . "', smartCaptchaCookie, false, '/'); } catch(err) { alert('Captcha ERROR: (2) ' + err); } this.value = '';") . '\')); } catch(error){ alert(\'Captcha ERROR: (2) :: Invalid Captcha Script \'); }"></span>';
     $ptmp_out .= '</td>';
     $ptmp_out .= '</tr>';
     $ptmp_out .= '</table>';
     $ptmp_out .= '</div>';
     //--
     return $ptmp_out;
     //--
 }
 /**
  * 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 print_log_modules($title, $modules_log)
 {
     //--
     $log = '';
     //--
     $log .= '<div class="smartframework_debugbar_status smartframework_debugbar_status_head"><font size="4"><b>' . Smart::escape_html($title) . ' :: MODULE Log</b></font></div>';
     //--
     $max = Smart::array_size($modules_log);
     if (is_array($modules_log) and $max > 0) {
         //--
         $log .= '<div class="smartframework_debugbar_status smartframework_debugbar_status_highlight" style="width:450px;">Total Entries: <b>' . Smart::escape_html($max) . '</b></div>';
         //--
         for ($i = 0; $i < $max; $i++) {
             //--
             $tmp_arr = (array) $modules_log[$i];
             //--
             $log .= '<div class="smartframework_debugbar_inforow" style="font-size:11px; color:#000000;">';
             $log .= '<b>' . Smart::escape_html((string) $tmp_arr['title']) . '</b><br>';
             $log .= '<pre style="font-size:11px; color:#000000;">' . Smart::escape_html(str_replace(array("\r\n", "\r", "\t"), array("\n", "\n", ' '), trim((string) $tmp_arr['data']))) . '</pre>';
             $log .= '</div>';
             //--
         }
         //end for
         //--
     } else {
         //--
         $log .= '<div class="smartframework_debugbar_status smartframework_debugbar_status_warn" style="width: 100px; text-align: center;"><font size="2"><b>N/A</b></font></div>';
         //--
     }
     //end if
     //--
     return $log;
     //--
 }
    public static function test_fs()
    {
        //--
        if (SMART_FRAMEWORK_TESTUNIT_ALLOW_FS_TESTS !== true) {
            return SmartComponents::operation_notice('Test Unit File System Tests are DISABLED ...');
        }
        //end if
        //--
        //--
        $time = microtime(true);
        //--
        //--
        $err = '';
        $tests = array();
        //--
        //--
        if ((string) DIRECTORY_SEPARATOR != '\\') {
            // broken links do not work on Windows !
            $tests[] = '##### FileSystem OPERATIONS / TESTS - ALL: #####';
        } else {
            $tests[] = '##### FileSystem OPERATIONS / TESTS *** PARTIAL SUPPORT ONLY (BY PLATFORM) ***: #####';
        }
        //end if else
        //--
        //--
        $test_string = '#START#' . "\n" . 'グッド' . "\n" . 'SmartFramework/Test/FileSystem' . "\n" . time() . "\n" . SMART_FRAMEWORK_HTACCESS_NOINDEXING . SMART_FRAMEWORK_HTACCESS_FORBIDDEN . SMART_FRAMEWORK_HTACCESS_NOEXECUTION . "\n" . '#END#';
        $test_str_cksum = SmartHashCrypto::sha512($test_string);
        $long_prefixed = SmartFileSysUtils::prefixed_sha1_path(sha1(time()));
        $short_prefixed = SmartFileSysUtils::prefixed_uuid10_dir(Smart::uuid_10_seq());
        //--
        $the_base_folder = 'tmp/tests/';
        $the_sufx_folder = 'Folder1';
        $the_base_file = 'NORMAL-Write_123_@#.txt';
        //--
        $the_folder = $the_base_folder . $the_sufx_folder . '/';
        $the_copy_folder = $the_base_folder . 'folder2';
        $the_move_folder = $the_base_folder . 'FOLDER3';
        $the_extra_folder = $the_folder . 'extra/';
        $the_file = $the_folder . $the_base_file;
        //--
        $get_folder = SmartFileSysUtils::add_dir_last_slash(SmartFileSysUtils::get_dir_from_path($the_folder));
        $get_file = SmartFileSysUtils::get_file_name_from_path($the_file);
        $get_xfile = SmartFileSysUtils::get_noext_file_name_from_path($the_file);
        $get_ext = SmartFileSysUtils::get_file_extension_from_path($the_file);
        //--
        $the_copy_file = $the_file . '.copy.txt';
        $the_move_file = $the_extra_folder . $the_base_file . '.copy.moved.txt';
        $the_broken_link = $the_extra_folder . 'a-broken-link';
        $the_broken_dir_link = $the_extra_folder . 'a-broken-dir-link';
        $the_good_link = $the_extra_folder . 'a-good-link';
        $the_good_dir_link = $the_extra_folder . 'a-good-dir-link';
        //--
        //--
        $tests[] = 'INITIAL-FOLDER: ' . $get_folder;
        $tests[] = 'NEW-FOLDER: ' . $the_folder;
        $tests[] = 'NEW-FILE: ' . $the_file;
        //--
        //--
        if ((string) $err == '') {
            $the_test = 'CHECK TEST SAFE PATH NAME: DIR / FILE ...';
            $tests[] = $the_test;
            if ((string) Smart::safe_pathname((string) $get_folder) !== (string) $get_folder or (string) Smart::safe_pathname((string) $the_copy_file) !== (string) $the_copy_file) {
                $err = 'ERROR: SAFE PATH NAME TEST ... FAILED !!!';
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'CHECK TEST ABSOLUTE / BACKWARD PATHS ...';
            $tests[] = $the_test;
            if (!SmartFileSysUtils::check_file_or_dir_name('/this/is/absolute', 'no') or SmartFileSysUtils::check_file_or_dir_name('/this/is/absolute') or SmartFileSysUtils::check_file_or_dir_name('/this/is/../backward/path')) {
                $err = 'ERROR: CHECK TEST ABSOLUTE / BACKWARD PATHS ... FAILED !!!';
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'CHECK EXTRACT FOLDER FROM PATH ...';
            $tests[] = $the_test;
            if ((string) $get_folder != SmartFileSysUtils::add_dir_last_slash(Smart::dir_name($the_folder))) {
                $err = 'ERROR: Path Extraction FAILED: Dir=' . $get_folder . ' ; DirName=' . SmartFileSysUtils::add_dir_last_slash(Smart::dir_name($the_folder));
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'CHECK EXTRACT FILE AND EXTENSION FROM PATH (1) ...';
            $tests[] = $the_test;
            if ((string) $get_folder . SmartFileSysUtils::add_dir_last_slash($the_sufx_folder) . $get_file != $the_file) {
                $err = 'ERROR :: Path Extraction FAILED: Re-Composed-File=' . $get_folder . SmartFileSysUtils::add_dir_last_slash($the_sufx_folder) . $get_file . ' ; File=' . $the_file;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'CHECK EXTRACT FILE AND EXTENSION FROM PATH (2) ...';
            $tests[] = $the_test;
            if ((string) $get_file != $get_xfile . '.' . $get_ext) {
                $err = 'ERROR :: Path Extraction FAILED: File=' . $get_file . ' ; XFile=' . $get_xfile . ' ; Ext=' . $get_ext;
            }
            //end if
        }
        //end if
        //--
        SmartFileSysUtils::raise_error_if_unsafe_path($the_folder);
        if ((string) $err == '') {
            $the_test = 'CHECK PATH NAME DIR: check_file_or_dir_name() : ' . $the_folder;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSysUtils::check_file_or_dir_name($the_folder);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        SmartFileSysUtils::raise_error_if_unsafe_path($the_file);
        if ((string) $err == '') {
            $the_test = 'CHECK PATH NAME FILE: check_file_or_dir_name() : ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSysUtils::check_file_or_dir_name($the_file);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        //--
        if ((string) $err == '') {
            $parent_folder = SmartFileSysUtils::add_dir_last_slash('');
            $the_test = 'Check Add Dir Last (trailing) Slash: Empty Folder Name';
            $tests[] = $the_test;
            if ((string) $parent_folder != './') {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $parent_folder = SmartFileSysUtils::add_dir_last_slash('.');
            $the_test = 'Check Add Dir Last (trailing) Slash: Dot Folder Name: ' . $parent_folder;
            $tests[] = $the_test;
            if ((string) $parent_folder != './') {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $parent_folder = SmartFileSysUtils::add_dir_last_slash('./');
            $the_test = 'Check Add Dir Last (trailing) Slash: DotSlash Folder Name: ' . $parent_folder;
            $tests[] = $the_test;
            if ((string) $parent_folder != './') {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $parent_folder = SmartFileSysUtils::add_dir_last_slash(Smart::dir_name($the_base_folder));
            $the_test = 'Check Parent Dir Name with Add Dir Last (trailing) Slash: ' . $parent_folder . ' # from: ' . $the_base_folder;
            $tests[] = $the_test;
            if ((string) $parent_folder != 'tmp/') {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        //--
        if ((string) $err == '') {
            if (is_dir($get_folder)) {
                $the_test = 'DIR DELETE - INIT CLEANUP: dir_delete() + recursive: ' . $get_folder;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::dir_delete($the_base_folder, true);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            } else {
                $tests[] = 'DIR DELETE - INIT CLEANUP: Test Not Run (folder does not exists): ' . $get_folder;
            }
            //end if else
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'DIR CREATE RECURSIVE: dir_recursive_create() : ' . $the_folder . $long_prefixed . $short_prefixed;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::dir_recursive_create($the_folder . $long_prefixed . $short_prefixed);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'DIR CREATE NON-RECURSIVE: dir_create() : extra/ in : ' . $the_extra_folder;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::dir_recursive_create($the_extra_folder);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        if ((string) DIRECTORY_SEPARATOR != '\\') {
            // broken links do not work on Windows !
            if ((string) $err == '') {
                $the_test = 'CREATE BROKEN FILE LINK FOR DELETION (1): link_create() : as : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::link_create('tmp/cache', $the_broken_link);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'DELETE BROKEN FILE LINK (1): delete() : as : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::delete($the_broken_link);
                if ($result !== 1 || is_link($the_broken_link)) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'CREATE BROKEN FILE LINK FOR DELETION (2): link_create() : as : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::link_create('tmp/index.html', $the_broken_link);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'DELETE BROKEN FILE LINK (2): dir_delete() : as : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::dir_delete($the_broken_link);
                if ($result !== 1 || is_link($the_broken_link)) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'CREATE BROKEN FILE LINK: link_create() : as : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::link_create('tmp/index.html', $the_broken_link);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'CREATE BROKEN DIR LINK: link_create() : as : ' . $the_broken_dir_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::link_create('tmp/', $the_broken_dir_link);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'CREATE A FILE LINK: link_create() : as : ' . $the_good_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::link_create(Smart::real_path('tmp/index.html'), $the_good_link);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'CREATE A DIR LINK: link_create() : as : ' . $the_good_dir_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::link_create(Smart::real_path('tmp/'), $the_good_dir_link);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'FILE WRITE with empty content: write() : ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::write($the_file, '');
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'FILE WRITE: write() / before append : ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::write($the_file, $test_string);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'FILE WRITE: write() +append : ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::write($the_file, $test_string, 'a');
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'FILE READ / Append: read() Full Size: ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::read($the_file);
            if ((string) SmartHashCrypto::sha512($result) != (string) SmartHashCrypto::sha512($test_string . $test_string)) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'FILE WRITE: re-write() : ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::write($the_file, $test_string);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        if ((string) DIRECTORY_SEPARATOR != '\\') {
            // broken links do not work on Windows !
            if ((string) $err == '') {
                $the_test = 'FILE WRITE TO A BROKEN LINK: write() : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::write($the_broken_link, $test_string);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'DELETE THE BROKEN LINK AFTER write() and RE-CREATE IT : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::delete($the_broken_link);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'RE-CREATE BROKEN FILE LINK [AFTER WRITE]: link_create() : as : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::link_create('tmp/index.html', $the_broken_link);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'FILE WRITE: write_if_not_exists() with Content Compare to a broken link : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::write_if_not_exists($the_broken_link, $test_string, 'yes');
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'DELETE THE BROKEN LINK AFTER write_if_not_exists() and RE-CREATE IT : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::delete($the_broken_link);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
            if ((string) $err == '') {
                $the_test = 'RE-CREATE BROKEN FILE LINK [AFTER WRITE-IF-NOT-EXISTS]: link_create() : as : ' . $the_broken_link;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::link_create('tmp/index.html', $the_broken_link);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'FILE WRITE: write_if_not_exists() without Content Compare : ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::write_if_not_exists($the_file, $test_string, 'no');
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'FILE READ: read() Full Size: ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::read($the_file);
            if ((string) SmartHashCrypto::sha512($result) != (string) $test_str_cksum) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'FILE READ: read() Partial Size, First 10 bytes: ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::read($the_file, 10);
            if ((string) sha1($result) != (string) sha1(substr($test_string, 0, 10))) {
                // here we read bytes so substr() not SmartUnicode::sub_str() should be used
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'FILE STATIC-READ: staticread() Full Size: ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::staticread($the_file);
            if ((string) SmartHashCrypto::sha512($result) != (string) $test_str_cksum) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'FILE STATIC-READ: staticread() Partial Size, First 10 bytes: ' . $the_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::staticread($the_file, 10);
            if ((string) sha1($result) != (string) sha1(substr($test_string, 0, 10))) {
                // here we read bytes so substr() not SmartUnicode::sub_str() should be used
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'FILE COPY: copy() : ' . $the_file . ' to: ' . $the_copy_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::copy($the_file, $the_copy_file);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'FILE COPY with OVERWRITE: copy() : ' . $the_file . ' to: ' . $the_copy_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::copy($the_file, $the_copy_file, true);
            // overwrite destination file(s)
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'FILE RE-COPY (test should re-write the destination): copy() : ' . $the_file . ' to: ' . $the_move_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::copy($the_file, $the_move_file);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            } else {
                $the_test = 'FILE DELETE: delete() : ' . $the_move_file;
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::delete($the_move_file);
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'FILE RENAME/MOVE: rename() : ' . $the_copy_file . ' to: ' . $the_move_file;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::rename($the_copy_file, $the_move_file);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            if (is_dir('__development/')) {
                //--
                $the_test = 'RECURSIVE COPY (CLONE) DIR [DEVELOPMENT]: dir_copy() : ' . '__development/' . ' to: ' . $the_folder . '__development';
                $tests[] = $the_test;
                $result = 0;
                $result = SmartFileSystem::dir_copy('__development/', $the_folder . '__development');
                if ($result !== 1) {
                    $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
                }
                //end if
                //--
                if ((string) $err == '') {
                    $the_test = 'DIR COMPARE THE [DEVELOPMENT] SOURCE WITH [DEVELOPMENT] DESTINATION AFTER DIR COPY AND DIR MOVE:' . "\n" . 'compare_folders() : ' . '__development/' . ' with: ' . $the_folder . '__development/';
                    $tests[] = $the_test;
                    $arr_diff = array();
                    $arr_diff = SmartFileSystem::compare_folders('__development', $the_folder . '__development', true, true);
                    if (Smart::array_size($arr_diff) > 0) {
                        $err = 'ERROR :: ' . $the_test . ' #DIFFERENCES=' . print_r($arr_diff, 1);
                    }
                    //end if
                }
                //end if
                //--
            } else {
                $tests[] = 'RECURSIVE COPY (CLONE) DIR [DEVELOPMENT]: Test Not Run (Development environment not detected) ...';
            }
            //end if else
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'RECURSIVE COPY (CLONE) DIR: dir_copy() : ' . $the_folder . ' to: ' . $the_copy_folder;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::dir_copy($the_folder, $the_copy_folder);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'MOVE/RENAME DIR: dir_rename() : ' . $the_copy_folder . ' to: ' . $the_move_folder;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::dir_rename($the_copy_folder, $the_move_folder);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'DIR COMPARE THE SOURCE WITH DESTINATION AFTER DIR COPY AND DIR MOVE: ' . $the_folder . ' with: ' . $the_move_folder;
            $tests[] = $the_test;
            $arr_diff = array();
            $arr_diff = SmartFileSystem::compare_folders($the_folder, $the_move_folder, true, true);
            if (Smart::array_size($arr_diff) > 0) {
                $err = 'ERROR :: ' . $the_test . ' #DIFFERENCES=' . print_r($arr_diff, 1);
            }
            //end if
        }
        //end if
        //--
        if ((string) $err == '') {
            $the_test = 'DIR DELETE - SIMPLE: dir_delete() non-recursive: ' . $the_extra_folder;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::dir_delete($the_extra_folder, false);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        if ((string) $err == '') {
            $the_test = 'DIR DELETE - LAST CLEANUP: dir_delete() + recursive: ' . $get_folder;
            $tests[] = $the_test;
            $result = 0;
            $result = SmartFileSystem::dir_delete($the_base_folder, true);
            if ($result !== 1) {
                $err = 'ERROR :: ' . $the_test . ' #RESULT=' . $result;
            }
            //end if
        }
        //end if
        //--
        //--
        $time = 'TOTAL TIME was: ' . (microtime(true) - $time);
        //--
        //--
        $end_tests = '##### END TESTS ... ' . $time . ' sec. #####';
        //--
        //--
        if ((string) $err == '') {
            $img_sign = 'lib/core/img/sign_info.png';
            $img_check = 'lib/core/img/q_completed.png';
            $text_main = Smart::escape_js('<span style="color:#83B953;">Good ... Perfect &nbsp;&nbsp;&nbsp; :: &nbsp;&nbsp;&nbsp; グッド ... パーフェクト</span>');
            $text_info = Smart::escape_js('<h2><span style="color:#83B953;">All</span> the SmartFramework FS Operations <span style="color:#83B953;">Tests PASSED on PHP</span><hr></h2><span style="font-size:14px;">' . Smart::nl_2_br(Smart::escape_html(implode("\n" . '* ', $tests) . "\n" . $end_tests)) . '</span>');
        } else {
            $img_sign = 'lib/core/img/sign_error.png';
            $img_check = 'lib/core/img/q_warning.png';
            $text_main = Smart::escape_js('<span style="color:#FF5500;">An ERROR occured ... &nbsp;&nbsp;&nbsp; :: &nbsp;&nbsp;&nbsp; エラーが発生しました ...</span>');
            $text_info = Smart::escape_js('<h2><span style="color:#FF5500;">A test FAILED</span> when testing FS Operations.<span style="color:#FF5500;"><hr>FAILED Test Details</span>:</h2><br><h3>' . Smart::escape_html($tests[Smart::array_size($tests) - 1]) . '</h3><br><span style="font-size:14px;"><pre>' . Smart::escape_html($err) . '</pre></span>');
        }
        //end if else
        //--
        //--
        $html = <<<HTML
<h1>SmartFramework LibFileSystem Tests: DONE ... [ Time: {$time} sec. ]</h1>
<script type="text/javascript">
\tSmartJS_BrowserUtils.alert_Dialog(
\t\t'<img src="{$img_sign}" align="right"><h1>{$text_main}</h1><hr><span style="color:#333333;"><img src="{$img_check}" align="right">{$text_info}<br>',
\t\t'',
\t\t'FileSystem Operations Test Suite for SmartFramework: PHP',
\t\t'920',
\t\t'480'
\t);
</script>
HTML;
        //--
        //--
        return $html;
        //--
    }
 /**
  * Function: Draw Powered Info
  *
  * @access 		private
  * @internal
  *
  */
 public static function draw_powered_info($y_show_versions, $y_software_name = '', $y_software_powered_logo = '')
 {
     //--
     global $configs;
     //--
     $os_pict = self::get_os_pict(SmartUtils::get_server_os(), 'Server Powered by ');
     //--
     if ((string) $y_software_name == '' or (string) $y_software_powered_logo == '') {
         $y_software_name = 'Smart.Framework';
         $y_software_powered_logo = 'lib/framework/img/powered_by_smart_framework.png';
     }
     //end if
     //--
     $tmp_arr_web_server = SmartUtils::get_webserver_version();
     $name_webserver = Smart::escape_html($tmp_arr_web_server['name']);
     //--
     if ((string) $y_show_versions == 'yes') {
         // expose versions (not recommended in web area, except for auth admins)
         //--
         $y_software_name .= ' :: ' . SMART_SOFTWARE_APP_NAME;
         //--
         $version_webserver = ' :: ' . Smart::escape_html($tmp_arr_web_server['version']);
         $version_php = ' :: ' . Smart::escape_html(PHP_VERSION);
         //--
     } else {
         // avoid expose versions
         //--
         $version_webserver = '';
         $version_php = '';
         //--
     }
     //end if else
     //--
     if (trim(strtolower($name_webserver)) == 'apache') {
         $name_webserver = 'Apache';
         $icon_webserver_powered = 'lib/framework/img/powered_by_apache.png';
         $icon_webserver_logo = 'lib/framework/img/apache_logo_small_trans.png';
     } else {
         $icon_webserver_powered = 'lib/framework/img/powered_by_nginx.png';
         $icon_webserver_logo = 'lib/framework/img/nginx_logo_small_trans.png';
     }
     //end if else
     //--
     $version_dbserver = '';
     if (is_array($configs['pgsql'])) {
         if (defined('SMART_FRAMEWORK_DB_VERSION_PostgreSQL') and (string) $y_show_versions == 'yes') {
             $version_dbserver = ' :: ' . Smart::escape_html(SMART_FRAMEWORK_DB_VERSION_PostgreSQL);
         }
         //end if
         $name_dbserver = 'PostgreSQL';
         $icon_dbserver_powered = '<img src="lib/core/img/db/powered_by_postgresql.png">';
         $icon_dbserver_logo = '<img src="lib/core/img/db/postgresql_logo_small_trans.png">';
     } else {
         $name_dbserver = '';
         $icon_dbserver_powered = '';
         $icon_dbserver_logo = '';
     }
     //end if else
     //--
     if (is_array($configs['redis'])) {
         $name_cacheserver = 'Redis';
         $icon_cacheserver_powered = '<img src="lib/core/img/db/powered_by_redis.png">';
         $icon_cacheserver_logo = '<img src="lib/core/img/db/redis_logo_small_trans.png">';
     } else {
         $name_cacheserver = '';
         $icon_cacheserver_powered = '';
         $icon_cacheserver_logo = '';
     }
     //end if
     //--
     $name_dblite = 'SQLite';
     $icon_dblite_powered = 'lib/core/img/db/powered_by_sqlite.png';
     $icon_dblite_logo = 'lib/core/img/db/sqlite_logo_small.png';
     //--
     return (string) SmartMarkersTemplating::render_file_template('lib/core/templates/powered-info.inc.htm', ['OS-LOGO' => $os_pict, 'WEB-SERVER-POWERED-VERSION' => $name_webserver . $version_webserver, 'WEB-SERVER-POWERED-ICON' => $icon_webserver_powered, 'WEB-SERVER-VERSION' => $name_webserver . ' Web Server', 'WEB-SERVER-ICON' => $icon_webserver_logo, 'PHP-VERSION' => $version_php, 'DBSERVER-NAME' => $name_dbserver, 'DBSERVER-VERSION' => $version_dbserver, 'DBSERVER-POWERED-ICON' => $icon_dbserver_powered, 'DBSERVER-POWERED-LOGO' => $icon_dbserver_logo, 'CACHESERVER-NAME' => $name_cacheserver, 'CACHESERVER-POWERED-ICON' => $icon_cacheserver_powered, 'CACHESERVER-POWERED-LOGO' => $icon_cacheserver_logo, 'DBLITE-NAME' => $name_dblite, 'DBLITE-POWERED-ICON' => $icon_dblite_powered, 'DBLITE-POWERED-LOGO' => $icon_dblite_logo, 'SOFTWARE-NAME' => Smart::escape_html($y_software_name), 'SOFTWARE-POWERED-LOGO' => Smart::escape_html($y_software_powered_logo)]);
     //--
 }
 /**
  * Generate the ODS Document on the fly from an array of data
  *
  * @param STRING $y_table_name					:: The Table Name
  * @param STRING $y_arr_fields					:: Array of Header Fields
  * @param STRING $y_arr_data 					:: Array of Data
  *
  * @returns STRING 								:: The ODS Document Contents
  *
  */
 public function ODS_SpreadSheet($y_table_name, $y_arr_fields, $y_arr_data, $y_arr_process = array(), $y_arr_totals = array(), $y_arr_finals = array(), $y_arr_widths = array(), $y_arr_highlights = array())
 {
     // font-weight="bold"
     // fo:font-style="italic"
     // style:text-underline-type="single"
     //-- header
     $header = '' . '<?xml version="1.0" encoding="UTF-8"?' . '>' . "\n" . '<office:document-content ' . $this->open_document_ns . 'office:version="1.0">' . "\n" . $this->open_document_styles . '<office:body>' . "\n" . '<office:spreadsheet>' . "\n";
     //--
     //-- footer
     $footer = "\n" . '</office:spreadsheet>' . "\n" . '</office:body>' . "\n" . '</office:document-content>';
     //--
     //-- data
     $data = '';
     $data .= '<table:table table:style-name="ta1" table:print="true" table:name="' . Smart::escape_html($y_table_name) . '">' . "\n";
     //--
     //-- table headings
     $num_cols = Smart::array_size($y_arr_fields);
     $num_data = Smart::array_size($y_arr_data);
     //--
     $data .= '<table:table-row table:style-name="ro1">' . "\n";
     //--
     for ($i = 0; $i < $num_cols; $i++) {
         //--
         $data .= '<table:table-cell table:style-name="he1" office:value-type="string">';
         $data .= '<text:p>' . Smart::escape_html($y_arr_fields[$i]) . '</text:p>';
         $data .= '</table:table-cell>' . "\n";
         //--
     }
     //end for
     //--
     $data .= '</table:table-row>' . "\n";
     //--
     for ($n = 0; $n < $num_data; $n++) {
         //--
         $data .= '<table:table-row table:style-name="ro1">' . "\n";
         //--
         for ($i = 0; $i < $num_cols; $i++) {
             //--
             $kk = $i + $n;
             //--
             if ($i % $num_cols == 0 or $i % $num_cols == $num_cols - 1) {
                 $tmp_style = 'ce1';
                 // highlight first and last column
             } elseif ($i % 2) {
                 $tmp_style = 'ce3';
             } else {
                 $tmp_style = 'ce2';
             }
             //end if else
             //--
             if ((string) $y_arr_process[$i] == 'number' or (string) $y_arr_process[$i] == 'decimal2' or (string) $y_arr_process[$i] == 'decimal4') {
                 //--
                 if ((string) $y_arr_process[$i] == 'decimal2') {
                     $y_arr_data[$kk] = (string) Smart::format_number_dec($y_arr_data[$kk], 2, '.', '');
                 } elseif ((string) $y_arr_process[$i] == 'decimal4') {
                     $y_arr_data[$kk] = (string) Smart::format_number_dec($y_arr_data[$kk], 4, '.', '');
                 } else {
                     $y_arr_data[$kk] = (string) $y_arr_data[$kk];
                 }
                 //end if
                 //--
                 //$data .= '<table:table-cell table:style-name="'.$tmp_style.'" office:value-type="float" office:value="'.Smart::escape_html($y_arr_data[$kk]).'">';
                 $data .= '<table:table-cell table:style-name="' . $tmp_style . '" office:value-type="string">';
                 // preserve number as they are, force type string !!!
                 $data .= '<text:p>' . Smart::escape_html($y_arr_data[$kk]) . '</text:p>';
                 $data .= '</table:table-cell>' . "\n";
                 //--
             } else {
                 //--
                 $data .= '<table:table-cell table:style-name="' . $tmp_style . '" office:value-type="string">';
                 $data .= '<text:p>' . Smart::escape_html($y_arr_data[$kk]) . '</text:p>';
                 $data .= '</table:table-cell>' . "\n";
                 //--
             }
             //end if else
             //--
         }
         //end for
         //--
         $data .= '</table:table-row>' . "\n";
         //--
         $n += $num_cols - 1;
         // salt
         //--
     }
     //end for
     //--
     //-- totals row
     if (Smart::array_size($y_arr_totals) > 0) {
         //--
         $data .= '<table:table-row table:style-name="ro1">' . "\n";
         //--
         for ($i = 0; $i < $num_cols; $i++) {
             //--
             $data .= '<table:table-cell table:style-name="he2" office:value-type="string">';
             $data .= '<text:p>' . $y_arr_totals[$i] . '</text:p>';
             $data .= '</table:table-cell>' . "\n";
             //--
         }
         //end for
         //--
         $data .= '</table:table-row>' . "\n";
         //--
     }
     //end if
     //--
     //-- final row
     if (Smart::array_size($y_arr_finals) > 0) {
         //--
         $data .= '<table:table-row table:style-name="ro1">' . "\n";
         //--
         for ($i = 0; $i < $num_cols; $i++) {
             //--
             $data .= '<table:table-cell table:style-name="he3" office:value-type="string">';
             $data .= '<text:p>' . $y_arr_finals[$i] . '</text:p>';
             $data .= '</table:table-cell>' . "\n";
             //--
         }
         //end for
         //--
         $data .= '</table:table-row>' . "\n";
         //--
     }
     //end if
     //--
     //--
     $data .= '</table:table>' . "\n";
     //--
     //--
     return (string) $this->OpenDocument_Template((string) $this->mime_ods, $header . "\n" . $data . "\n" . $footer);
     //--
 }
示例#20
0
 private static function display_calendar($y_mode, $y_sel_date, $y_width, $y_highlight_selected, $y_events_arr)
 {
     //--
     global $configs;
     //--
     if ($configs['regional']['calendar-week-start'] == 1) {
         $the_first_day = 1;
         // Calendar Start on Monday
     } else {
         $the_first_day = 0;
         // Calendar Start on Sunday
     }
     //end if else
     //--
     if ((string) $y_sel_date == '') {
         $y_sel_date = date('Y-m-d');
     }
     //end if
     //--
     $translator_core_calendar = SmartTextTranslations::getTranslator('@core', 'calendar');
     //--
     $calendar = new SmartHTMLCalendar(date('Y-m-d', @strtotime($y_sel_date)), $y_highlight_selected, $y_width, (string) $y_mode);
     //-- set months
     $calendar->setMonthNames(array('01' => $translator_core_calendar->text('m_01'), '02' => $translator_core_calendar->text('m_02'), '03' => $translator_core_calendar->text('m_03'), '04' => $translator_core_calendar->text('m_04'), '05' => $translator_core_calendar->text('m_05'), '06' => $translator_core_calendar->text('m_06'), '07' => $translator_core_calendar->text('m_07'), '08' => $translator_core_calendar->text('m_08'), '09' => $translator_core_calendar->text('m_09'), '10' => $translator_core_calendar->text('m_10'), '11' => $translator_core_calendar->text('m_11'), '12' => $translator_core_calendar->text('m_12')));
     //-- set days
     if ((string) $y_mode == 'small') {
         $calendar->setDayNames(array(0 => SmartUnicode::sub_str($translator_core_calendar->text('w_1'), 0, 2), 1 => SmartUnicode::sub_str($translator_core_calendar->text('w_2'), 0, 2), 2 => SmartUnicode::sub_str($translator_core_calendar->text('w_3'), 0, 2), 3 => SmartUnicode::sub_str($translator_core_calendar->text('w_4'), 0, 2), 4 => SmartUnicode::sub_str($translator_core_calendar->text('w_5'), 0, 2), 5 => SmartUnicode::sub_str($translator_core_calendar->text('w_6'), 0, 2), 6 => SmartUnicode::sub_str($translator_core_calendar->text('w_7'), 0, 2)));
     } else {
         $calendar->setDayNames(array(0 => $translator_core_calendar->text('w_1'), 1 => $translator_core_calendar->text('w_2'), 2 => $translator_core_calendar->text('w_3'), 3 => $translator_core_calendar->text('w_4'), 4 => $translator_core_calendar->text('w_5'), 5 => $translator_core_calendar->text('w_6'), 6 => $translator_core_calendar->text('w_7')));
     }
     //end if else
     //-- set start on
     $calendar->setStartOfWeek($the_first_day);
     //--
     if (Smart::array_size($y_events_arr) > 0) {
         for ($i = 0; $i < count($y_events_arr); $i++) {
             if ($y_events_arr[$i]['date-end'] === false) {
                 $calendar->addDayEvent((string) $y_events_arr[$i]['event-html'], date('Y-m-d', @strtotime((string) $y_events_arr[$i]['date-start'])), false);
             } else {
                 $calendar->addDayEvent((string) $y_events_arr[$i]['event-html'], date('Y-m-d', @strtotime((string) $y_events_arr[$i]['date-start'])), date('Y-m-d', @strtotime((string) $y_events_arr[$i]['date-end'])));
             }
             //end if else
         }
         //end for
     }
     //end if
     //-- draw
     return '<div title="' . Smart::escape_html(date('Y-m', @strtotime((string) $y_sel_date))) . '">' . $calendar->draw() . '</div>';
     //--
 }
示例#21
0
 public function Run()
 {
     //-- sample page variable from Request (GET/POST)
     $some_var_from_request = $this->RequestVarGet('extra_text', 'default', 'string');
     //--
     //--
     $module_area = $this->ControllerGetParam('module-area');
     $the_lang = (string) $this->ConfigParamGet('regional.language-id');
     $the_xlang = (string) $this->ConfigParamGet('regional.language-id');
     // repeat this to check if caching works
     //--
     if ($this->IfDebug()) {
         $this->SetDebugData('Module Area', $module_area);
         $this->SetDebugData('Module Path', $this->ControllerGetParam('module-path'));
         $this->SetDebugData('Module Name', $this->ControllerGetParam('module-name'));
         $this->SetDebugData('URL Script', $this->ControllerGetParam('url-script'));
         $this->SetDebugData('URL Path', $this->ControllerGetParam('url-path'));
         $this->SetDebugData('URL Address', $this->ControllerGetParam('url-addr'));
         $this->SetDebugData('URL Page', $this->ControllerGetParam('url-page'));
         $this->SetDebugData('Config / Language ID', $the_lang);
     }
     //end if
     //--
     //--
     if ($this->PageCacheisActive()) {
         //-- because the Request can modify the content, also the unique key must take in account variables that will vary the page config or page content vars
         $the_page_cache_key = 'samples-toolkit-' . $module_area . '__' . SmartHashCrypto::sha384((string) $some_var_from_request);
         //--
     }
     //end if
     //--
     //--
     if ($this->PageCacheisActive()) {
         //--
         $test_cache = $this->PageGetFromCache('cached-samples', $the_page_cache_key);
         //--
         if (Smart::array_size($test_cache) > 0) {
             if (is_array($test_cache['configs']) && is_array($test_cache['vars'])) {
                 // if valid cache (test as we exported both arrays ... so they must be the 2 arrays again)
                 $this->PageViewSetCfgs((array) $test_cache['configs']);
                 $this->PageViewSetVars((array) $test_cache['vars']);
                 $this->PageViewAppendVar('main', "\n" . '<!-- Redis Cached Content Key: ' . Smart::escape_html($the_page_cache_key) . ' -->' . "\n");
                 // add a markup to the HTML to know was served from cache ...
                 if ($this->IfDebug()) {
                     $this->SetDebugData('Page Cache Info', 'Serving page from Persistent Cache: Redis (override PHP Execution). Page key is: ' . $the_page_cache_key);
                 }
                 // end if
                 return;
                 // the page was served from Cache (stop here)
             }
             //end if
         }
         //end if
         //--
     }
     //end if
     //--
     //=== if no cached, execute the code below ...
     //--
     $this->PageViewSetCfg('template-path', 'default');
     // set the template path (must be inside etc/templates/)
     $this->PageViewSetCfg('template-file', 'template.htm');
     // set the template file
     //--
     //--
     $fcontent = SmartFileSystem::staticread('lib/framework/css/ux-toolkit-samples.html');
     $arr_data = explode('<body>', $fcontent);
     $fcontent = (string) $arr_data[1];
     $arr_data = explode('</body>', $fcontent);
     $fcontent = (string) $arr_data[0];
     //--
     //-- building a semantic URL
     $url_test_unit = Smart::url_add_params($this->ControllerGetParam('url-script'), array('page' => 'samples.testunit', 'tab' => 0));
     // will generate: index.php?page=samples.testunit OR admin.php?page=samples.testunit
     $url_test_unit = Smart::url_make_semantic($url_test_unit);
     // convert the above to a pretty URL as: ?/page/samples.testunit (in this case index.php is ignored) OR admin.php?/page/samples.testunit
     //--
     //-- building a regular URL
     $url_benchmark = Smart::url_add_params($this->ControllerGetParam('url-script'), array('page' => 'samples.benchmark.html'));
     $url_benchmark = Smart::url_make_semantic($url_benchmark);
     //--
     //--
     $translator_core = SmartTextTranslations::getTranslator('@core', 'messages');
     //--
     $translator_mod_samples = SmartTextTranslations::getTranslator('mod-samples', 'samples');
     $txt_hello_world = $translator_mod_samples->text('hello-world');
     unset($translator_mod_samples);
     // this is just an internal test, normally the translator should not be unset ...
     $translator_mod_samples = SmartTextTranslations::getTranslator('mod-samples', 'samples');
     $txt_this_is_sf = $translator_mod_samples->text('this-is-smart-framework');
     //--
     //--
     $this->PageViewSetVars(['title' => 'Toolkit Samples', 'main' => '<h1>This text should not be displayed, it was RESET !!!</h1>']);
     $this->PageViewResetVar('main');
     // test reset
     $this->PageViewSetVar('main', SmartMarkersTemplating::render_template('<h1>' . '[####TXT-HELLO-WORLD####]</h1><div align="right"><b>[####DATE-TIME|html####] [[####TXT-OK####]]' . "\n" . '</b></div><br><a class="ux-button ux-button-special" href="http://sourceforge.net/projects/warp-cms/files/smart-framework/" target="_blank"><i class="fa fa-cloud-download"></i> &nbsp; Download Smart.Framework (latest stable releases)</a> &nbsp;&nbsp;&nbsp; <a class="ux-button ux-button-highlight" href="http://demo.unix-world.org/smart-framework.docs/" target="_blank"><i class="fa fa-book"></i> &nbsp; Documentation for the Smart.Framework</a><br>' . "\n" . '<br><a class="ux-button ux-button-primary" href="[####URL-TESTUNIT|html####]"><i class="fa fa-object-group"></i> &nbsp; Go to the Smart.Framework PHP/Javascript Test &amp; Demo Suite</a> &nbsp;&nbsp;&nbsp; <a class="ux-button ux-button-secondary" href="[####URL-BENCHMARK|html####]"><i class="fa fa-line-chart"></i> &nbsp; Benchmark URL for Smart.Framework</a><br><br>', ['DATE-TIME' => date('Y-m-d H:i:s O'), 'TXT-OK' => $translator_core->text('ok'), 'TXT-HELLO-WORLD' => '<span title="LanguageID: ' . Smart::escape_html($the_xlang) . '" style="cursor:help;">' . '[' . Smart::escape_html($the_lang) . ']' . '</span>' . ' ' . $txt_hello_world . ', ' . $txt_this_is_sf . ' - a modern PHP / Javascript framework featuring MVC + Middlewares', 'URL-TESTUNIT' => $url_test_unit, 'URL-BENCHMARK' => $url_benchmark]));
     $this->PageViewAppendVar('main', '<hr><div style="color:#DDDDDD">' . Smart::escape_html('Unicode@String :: Smart スマート // Cloud Application Platform クラウドアプリケーションプラットフォーム :: áâãäåāăąÁÂÃÄÅĀĂĄ ćĉčçĆĈČÇ ďĎ èéêëēĕėěęÈÉÊËĒĔĖĚĘ ĝģĜĢ ĥħĤĦ ìíîïĩīĭȉȋįÌÍÎÏĨĪĬȈȊĮ ijĵIJĴ ķĶ ĺļľłĹĻĽŁ ñńņňÑŃŅŇ óôõöōŏőøœÒÓÔÕÖŌŎŐØŒ ŕŗřŔŖŘ șşšśŝßȘŞŠŚŜ țţťȚŢŤ ùúûüũūŭůűųÙÚÛÜŨŪŬŮŰŲ ŵŴ ẏỳŷÿýẎỲŶŸÝ źżžŹŻŽ') . '</div><hr><div align="right">[' . Smart::escape_html($some_var_from_request) . ']</div>');
     $this->PageViewAppendVar('main', trim($fcontent));
     //--
     //== cache page (if redis - persistent cache is set in config)
     //-- if Redis is active this will cache the page for 1 hour ...
     if ($this->PageCacheisActive()) {
         //--
         $this->PageSetInCache('cached-samples', $the_page_cache_key, array('configs' => $this->PageViewGetCfgs(), 'vars' => $this->PageViewGetVars()), 3600);
         //--
         if ($this->IfDebug()) {
             $this->SetDebugData('Page Cache Info', 'Setting page in Persistent Cache: Redis (after PHP Execution). Page key is: ' . $the_page_cache_key);
         }
         //end if
         //--
     } else {
         //--
         if ($this->IfDebug()) {
             $this->SetDebugData('Page Cache Info', 'Persistent Cache (Redis) is not active. Serving Page from PHP Execution.');
         }
         //end if
         //--
     }
     //end if else
     //--
 }
    public static function Redirection_Monitor()
    {
        //--
        if (!defined('SMART_FRAMEWORK_VERSION')) {
            die('Smart Runtime // Redirection Monitor :: Requires SmartFramework to be loaded ...');
        }
        //end if
        //--
        if (self::$RedirectionMonitorStarted !== false) {
            return;
            // avoid run after it was used by runtime
        }
        //end if
        self::$RedirectionMonitorStarted = true;
        //--
        $url_redirect = '';
        //--
        $the_current_url = SmartUtils::get_server_current_url();
        $the_current_script = SmartUtils::get_server_current_script();
        //--
        if (SMART_SOFTWARE_FRONTEND_ENABLED === false and SMART_SOFTWARE_BACKEND_ENABLED === false) {
            // both frontend and backend are disabled
            die('FATAL ERROR: The FRONTEND but also the BACKEND of this application are DISABLED ! ...');
        }
        //end if
        if (SMART_SOFTWARE_FRONTEND_ENABLED === false and (string) $the_current_script == 'index.php') {
            $url_redirect = $the_current_url . 'admin.php';
        }
        //end if
        if (SMART_SOFTWARE_BACKEND_ENABLED === false and (string) $the_current_script == 'admin.php') {
            $url_redirect = $the_current_url . 'index.php';
        }
        //end if
        //--
        if ((string) $url_redirect == '' and isset($_SERVER['PATH_INFO'])) {
            //--
            if (strlen($_SERVER['PATH_INFO']) > 0) {
                //--
                if ((string) $the_current_script == 'index.php') {
                    $the_current_script = '';
                }
                //end if
                $url_redirect = $the_current_url . $the_current_script . '?' . $_SERVER['PATH_INFO'];
                //--
            }
            //end if
            //--
        }
        //end if
        //--
        $gopage = '
		<!DOCTYPE html>
		<!-- template :: RUNTIME REDIRECTION / PATH SUFFIX -->
		<html>
			<head>
				<meta charset="UTF-8">
				<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
				<meta http-equiv="refresh" content="3;URL=' . Smart::escape_html($url_redirect) . '">
			</head>
			<body>
				<h1>Redirecting to a valid URL ... wait ...</h1><br>
				<script type="text/javascript">setTimeout("self.location=\'' . Smart::escape_js($url_redirect) . '\'",1500);</script>
			</body>
		</html>
	';
        //--
        if (strlen($url_redirect) > 0) {
            @header('Location: ' . $url_redirect);
            die($gopage);
        }
        //end if
        //--
    }
 public function text($y_textkey)
 {
     //--
     if ((string) $y_textkey == '') {
         Smart::log_warning('Empty Key for Text Context Translator - Area: ' . $this->area . ' ; SubArea: ' . $this->subarea);
         return '{Empty Translation Key}';
     }
     //end if
     //--
     $text = (string) SmartTextTranslations::getTranslationByKey($this->area, $this->subarea, $y_textkey);
     //--
     if ((string) $text == '') {
         Smart::log_warning('Undefined Key: [' . $y_textkey . '] for Text Context Translator - Area: ' . $this->area . ' ; SubArea: ' . $this->subarea);
         return '{Undefined Translation Key: ' . Smart::escape_html($y_textkey) . '}';
     }
     //end if
     //--
     return (string) $text;
     //--
 }