public static function print_debug_info($y_area, $y_debug_token)
 {
     global $configs;
     //-- {{{SYNC-DEBUG-DATA}}}
     if ((string) SMART_FRAMEWORK_DEBUG_MODE != 'yes') {
         return '';
     }
     //end if
     //--
     if ((string) $y_area != 'idx' and (string) $y_area != 'adm') {
         return '';
     }
     //end if
     //--
     $y_debug_token = trim((string) $y_debug_token);
     if ((string) $y_debug_token == '') {
         return '';
     }
     //end if
     //--
     $the_dir = 'tmp/logs/' . Smart::safe_filename($y_area) . '/' . date('Y-m-d@H') . '-debug-data/' . Smart::safe_filename($y_debug_token) . '/';
     //-- #END# SYNC
     //--
     $storage = (new SmartGetFileSystem(true))->get_storage($the_dir, true, false);
     $arr = array();
     if (is_array($storage['list-files'])) {
         $storage['list-files'] = Smart::array_sort($storage['list-files'], 'natsort');
         for ($i = 0; $i < Smart::array_size($storage['list-files']); $i++) {
             $arr[] = Smart::unseryalize(SmartFileSystem::read($storage['list-files'][$i]));
         }
         //end if
     }
     //end if
     $storage = array();
     //--
     //--
     $debug_response = '';
     $debug_resources = '';
     $debug_environment = '';
     $debug_session = '';
     $debug_auth = '';
     $debug_mail = '';
     $debug_dbqueries = '';
     $debug_optimizations = '';
     $debug_extra = '';
     $debug_modules = '';
     $tmp_decode_arr = array();
     //--
     $start_marker = '<div class="smartframework_debugbar_status smartframework_debugbar_status_title"><font size="5"><b># DEBUG Data :: ALL REQUESTS #</b></font></div>';
     $end_marker = '<div class="smartframework_debugbar_status smartframework_debugbar_status_title"><font size="3"><b># DEBUG # END #</b></font></div>';
     //--
     for ($i = 0; $i < Smart::array_size($arr); $i++) {
         //--
         if ($arr[$i]['is-request-main'] === true) {
             $txt_main = '<div class="smartframework_debugbar_status smartframework_debugbar_status_title"><font size="5"><b># DEBUG Data :: MAIN REQUEST #</b></font></div>';
         } else {
             $txt_main = '<div class="smartframework_debugbar_status smartframework_debugbar_status_title"><font size="3"><b># DEBUG Data :: SUB-REQUEST #</b></font></div>';
         }
         //end if else
         $txt_token = '<div class="smartframework_debugbar_status smartframework_debugbar_status_token" style="width: 400px; text-align: center;"><font size="2"><b>Debug Token: ' . Smart::escape_html($arr[$i]['debug-token']) . '</b></font></div>';
         $txt_url = '<div class="smartframework_debugbar_status smartframework_debugbar_status_url"><font size="2">URL: ' . Smart::escape_html($arr[$i]['request-uri']) . '</font></div>';
         //--
         $debug_response .= $txt_main . $txt_url . $txt_token . self::print_log_headers($arr[$i]['response-code'], Smart::unseryalize(base64_decode($arr[$i]['response-headers'])), Smart::unseryalize(base64_decode($arr[$i]['request-headers']))) . '<hr>';
         //--
         $debug_resources .= $txt_main . $txt_url . $txt_token . self::print_log_resources($arr[$i]['resources-time'], $arr[$i]['resources-memory']);
         //--
         $debug_environment .= $txt_main . $txt_url . $txt_token . self::print_log_environment(Smart::unseryalize(base64_decode($arr[$i]['env-req-filtered'])), Smart::unseryalize(base64_decode($arr[$i]['env-cookies'])), Smart::unseryalize(base64_decode($arr[$i]['env-get'])), Smart::unseryalize(base64_decode($arr[$i]['env-post'])), Smart::unseryalize(base64_decode($arr[$i]['env-server']))) . '<hr>';
         //--
         $debug_session .= $txt_main . $txt_url . $txt_token . self::print_log_session(Smart::unseryalize(base64_decode($arr[$i]['php-session']))) . '<hr>';
         //--
         $debug_auth .= $txt_main . $txt_url . $txt_token . self::print_log_auth($arr[$i]['auth-data']) . '<hr>';
         //--
         if (is_array($arr[$i]['log-optimizations'])) {
             $debug_optimizations .= $txt_main . $txt_url . $txt_token;
             foreach ($arr[$i]['log-optimizations'] as $key => $val) {
                 $debug_optimizations .= self::print_log_optimizations(strtoupper((string) $key), Smart::unseryalize(base64_decode($val))) . '<hr>';
             }
             //end foreach
         }
         //end if
         //--
         if (is_array($arr[$i]['log-mail'])) {
             $debug_mail .= $txt_main . $txt_url . $txt_token . self::print_log_mail(Smart::unseryalize(base64_decode($arr[$i]['log-mail']))) . '<hr>';
         }
         //end if
         //--
         if (is_array($arr[$i]['log-db'])) {
             $debug_dbqueries .= $txt_main . $txt_url . $txt_token;
             foreach ($arr[$i]['log-db'] as $key => $val) {
                 $debug_dbqueries .= self::print_log_database(strtoupper((string) $key), Smart::unseryalize(base64_decode($val))) . '<hr>';
             }
             //end foreach
         }
         //end if
         //--
         if (is_array($arr[$i]['log-extra'])) {
             $debug_extra .= $txt_main . $txt_url . $txt_token;
             foreach ($arr[$i]['log-extra'] as $key => $val) {
                 $debug_extra .= self::print_log_extra(strtoupper((string) $key), Smart::unseryalize(base64_decode($val))) . '<hr>';
             }
             //end foreach
         }
         //end if
         //--
         if (is_array($arr[$i]['log-modules'])) {
             $debug_modules .= $txt_main . $txt_url . $txt_token;
             foreach ($arr[$i]['log-modules'] as $key => $val) {
                 $debug_modules .= self::print_log_modules(strtoupper((string) $key), Smart::unseryalize(base64_decode($val))) . '<hr>';
             }
             //end foreach
         }
         //end if
         //--
     }
     //end for
     //--
     if ((string) $debug_optimizations == '') {
         $debug_optimizations = '<div class="smartframework_debugbar_status smartframework_debugbar_status_nodata"><font size="5"><b>Optimization Hints: N/A</b></font></div>';
     } else {
         $debug_optimizations .= $end_marker;
     }
     //end if else
     //--
     if ((string) $debug_mail == '') {
         $debug_mail = '<div class="smartframework_debugbar_status smartframework_debugbar_status_nodata"><font size="5"><b>Mail Debug: No data</b></font></div>';
     } else {
         $debug_mail .= $end_marker;
     }
     //end if else
     //--
     if ((string) $debug_dbqueries == '') {
         $debug_dbqueries = '<div class="smartframework_debugbar_status smartframework_debugbar_status_nodata"><font size="5"><b>Database Debug: No Queries found</b></font></div>';
     } else {
         $debug_dbqueries .= $end_marker;
     }
     //end if else
     //--
     if ((string) $debug_extra == '') {
         $debug_extra = '<div class="smartframework_debugbar_status smartframework_debugbar_status_nodata"><font size="5"><b>Extra Debug: No data</b></font></div>';
     } else {
         $debug_extra .= $end_marker;
     }
     //end if else
     //--
     if ((string) $debug_modules == '') {
         $debug_modules = '<div class="smartframework_debugbar_status smartframework_debugbar_status_nodata"><font size="5"><b>Modules Debug: No data</b></font></div>';
     } else {
         $debug_modules .= $end_marker;
     }
     //end if else
     //--
     //--
     return SmartMarkersTemplating::render_file_template('lib/core/templates/debug-profiler-footer.inc.htm', array('DEBUG-TIME' => date('Y-m-d H:i:s O'), 'DEBUG-RUNTIME' => $start_marker . self::print_log_runtime() . $end_marker, 'DEBUG-CONFIGS' => $start_marker . self::print_log_configs() . $end_marker, 'DEBUG-RESOURCES' => $debug_resources . $end_marker, 'DEBUG-HEADERS' => $debug_response . $end_marker, 'DEBUG-ENVIRONMENT' => $debug_environment . $end_marker, 'DEBUG-SESSION' => $debug_session . $end_marker, 'DEBUG-AUTH' => $debug_auth . $end_marker, 'DEBUG-OPTIMIZATIONS' => $debug_optimizations, 'DEBUG-MAIL' => $debug_mail, 'DEBUG-DATABASE' => $debug_dbqueries, 'DEBUG-EXTRA' => $debug_extra, 'DEBUG-MODULES' => $debug_modules), 'no');
     //--
 }
 /**
  * [PUBLIC] Draw an Image Gallery
  *
  * @param STRING $y_title									:: a title for the gallery
  * @param STRING $y_dir										:: path to scan
  * @param *OPTIONAL[yes/no] $y_process_previews_and_images	:: If = 'yes', will create previews for images and videos (movies) and will create conformed images
  * @param *OPTIONAL[yes/no] $y_remove_originals				:: If = 'yes', will remove original (images) after creating previews [$y_process_previews_and_images must be yes]
  * @param *OPTIONAL[>=0]	$y_display_limit				:: Items limit to display
  */
 public function draw($y_title, $y_dir, $y_process_previews_and_images = 'no', $y_remove_originals = 'no', $y_display_limit = '0')
 {
     //--
     $y_title = (string) $y_title;
     //--
     $y_dir = (string) $y_dir;
     //--
     $y_process_previews_and_images = (string) $y_process_previews_and_images;
     if ((string) $y_process_previews_and_images != 'yes') {
         $y_process_previews_and_images = 'no';
     }
     //end if
     //--
     $y_display_limit = Smart::format_number_int($y_display_limit, '+');
     //--
     //--
     if ((string) $this->use_secure_links == 'yes') {
         if ((string) $this->secure_download_link == '' or (string) $this->secure_download_ctrl_key == '') {
             return '<h1>WARNING: Media Gallery / Secure Links Mode is turned ON but at least one of the: download link or the controller was NOT provided ...</h1>';
         }
         //end if
     }
     //end if
     //--
     //--
     if (!SmartFileSysUtils::check_file_or_dir_name($y_dir)) {
         return '<h1>ERROR: Invalid Folder for Media Gallery ...</h1>';
     }
     //end if
     //--
     $y_dir = SmartFileSysUtils::add_dir_last_slash($y_dir);
     SmartFileSysUtils::raise_error_if_unsafe_path($y_dir);
     //--
     if (!is_dir($y_dir)) {
         return '<h1>WARNING: The Folder for Media Gallery does not exists ...</h1>';
     }
     //end if
     //--
     //--
     $this->gallery_items = 0;
     //--
     //-- constraint of params
     if ((string) $y_process_previews_and_images != 'yes') {
         $y_remove_originals = 'no';
     }
     //end if
     //--
     if (strlen($this->preview_formvar) > 0) {
         // avoid processing if it is displayed in a form
         $y_process_previews_and_images = 'no';
         $y_remove_originals = 'no';
     }
     //end if
     //--
     //-- some inits ...
     $out = '';
     $arr_files = array();
     $processed = 0;
     //--
     //--
     $arr_storage = (array) (new SmartGetFileSystem(true))->get_storage($y_dir, false, false);
     $all_mg_files = (array) $arr_storage['list-files'];
     //--
     //--
     for ($i = 0; $i < Smart::array_size($all_mg_files); $i++) {
         //--
         $file = (string) $all_mg_files[$i];
         $ext = strtolower(SmartFileSysUtils::get_file_extension_from_path($file));
         //--
         if (substr($file, 0, 1) != '.' and strpos($file, '.#') === false and strpos($file, '#.') === false) {
             //--
             if (is_file($y_dir . $file) and ((string) $ext == 'jpeg' or (string) $ext == 'jpg' or (string) $ext == 'gif' or (string) $ext == 'png')) {
                 //--
                 if (SmartFileSysUtils::version_check($file, 'mg-preview')) {
                     //-- it is an image preview file
                     if (!is_file($y_dir . SmartFileSysUtils::version_add($file, 'mg-image'))) {
                         SmartFileSystem::delete($y_dir . $file);
                         // remove preview if orphan
                     }
                     //end if
                     //--
                 } elseif (SmartFileSysUtils::version_check($file, 'mg-image')) {
                     //-- it is an image file
                     if ((string) $y_process_previews_and_images == 'yes') {
                         //--
                         $tmp_file = $y_dir . SmartFileSysUtils::version_add($file, 'mg-preview');
                         //--
                         if (!is_file($tmp_file)) {
                             //--
                             $out .= $this->img_preview_create($y_dir . $file, $tmp_file) . '<br>';
                             $processed += 1;
                             //--
                         }
                         //end if
                         //--
                     }
                     //end if
                     //--
                     $arr_files[] = $file;
                     $this->gallery_items += 1;
                     //--
                 } elseif (SmartFileSysUtils::version_check($file, 'mg-vpreview')) {
                     //-- it is a movie preview file
                     if (stripos($file, '.#tmp-preview#.jpg') === false) {
                         //--
                         $tmp_linkback_file = SmartFileSysUtils::get_noext_file_name_from_path(SmartFileSysUtils::version_remove($file));
                         //--
                         if (!is_file($y_dir . $tmp_linkback_file)) {
                             SmartFileSystem::delete($y_dir . $file);
                             // remove if orphan
                         }
                         //end if
                         //--
                     }
                     //end if
                     //--
                 } else {
                     // unprocessed image
                     //--
                     if ((string) $y_process_previews_and_images == 'yes') {
                         //--
                         $tmp_file = $y_dir . SmartFileSysUtils::version_add($file, 'mg-image');
                         //--
                         if (!is_file($tmp_file)) {
                             //--
                             if ((string) $y_dir . $file != (string) $y_dir . strtolower($file)) {
                                 SmartFileSystem::rename($y_dir . $file, $y_dir . strtolower($file));
                                 // make sure is lowercase, to be ok for back-check since versioned is lowercase
                             }
                             //end if
                             //--
                             $out .= $this->img_conform_create($y_dir . $file, $tmp_file) . '<br>';
                             $processed += 1;
                             //--
                         } else {
                             //--
                             if ((string) $y_remove_originals == 'yes') {
                                 //--
                                 SmartFileSystem::delete($y_dir . $file);
                                 $out .= '<table width="550" bgcolor="#FF3300"><tr><td>removing original image: \'' . Smart::escape_html($file) . '\'</td></tr></table><br>';
                                 $processed += 1;
                                 //--
                             }
                             //end if
                             //--
                         }
                         //end if else
                         //--
                     }
                     //end if
                     //--
                 }
                 //end if else
                 //--
             } elseif (is_file($y_dir . $file) and ((string) $ext == 'webm' or (string) $ext == 'ogv' or (string) $ext == 'mp4' or (string) $ext == 'mov' or (string) $ext == 'flv')) {
                 // WEBM, OGV, MP4, MOV, FLV
                 //-- process preview FLV / MOV ...
                 if ((string) $y_process_previews_and_images == 'yes') {
                     //--
                     $tmp_file = $y_dir . SmartFileSysUtils::version_add($file, 'mg-vpreview') . '.jpg';
                     //--
                     if (!is_file($tmp_file)) {
                         //--
                         if ((string) $y_dir . $file != (string) $y_dir . strtolower($file)) {
                             SmartFileSystem::rename($y_dir . $file, $y_dir . strtolower($file));
                             // make sure is lowercase, to be ok for back-check since versioned is lowercase
                         }
                         //end if
                         //--
                         $out .= $this->mov_preview_create($y_dir . strtolower($file), $tmp_file) . '<br>';
                         $processed += 1;
                         //--
                     }
                     //end if
                     //--
                 }
                 //end if
                 //--
                 $arr_files[] = $file;
                 $this->gallery_items += 1;
                 //--
             }
             //end if else
             //--
         }
         //end if
         //--
     }
     //end for
     //--
     //--
     $out .= '<!-- START MEDIA GALLERY -->' . "\n";
     //--
     if ((string) $this->use_styles == 'yes') {
         $out .= '<div id="mediagallery_box">' . "\n";
     }
     //end if
     //--
     //--
     $out_arr = array();
     //--
     if ($processed <= 0) {
         //--
         $arr_files = Smart::array_sort($arr_files, 'natsort');
         //--
         $max_loops = Smart::array_size($arr_files);
         if ($y_display_limit > 0) {
             if ($y_display_limit < $max_loops) {
                 $max_loops = $y_display_limit;
             }
             //end if
         }
         //end if
         //--
         for ($i = 0; $i < $max_loops; $i++) {
             //--
             $tmp_the_ext = strtolower(SmartFileSysUtils::get_file_extension_from_path($arr_files[$i]));
             // [OK]
             //--
             if ((string) $tmp_the_ext == 'webm' or (string) $tmp_the_ext == 'ogv' or (string) $tmp_the_ext == 'mp4' or (string) $tmp_the_ext == 'mov' or (string) $tmp_the_ext == 'flv') {
                 $out_arr[] = $this->mov_draw_box($y_dir, $arr_files[$i], $tmp_the_ext);
             } else {
                 $out_arr[] = $this->img_draw_box($y_dir, $arr_files[$i]);
             }
             //end if
             //--
         }
         //end for
         //--
         $out .= '<div title="' . Smart::escape_html($this->gallery_show_counter) . '">' . "\n";
         //--
         if ((string) $y_title != '') {
             $out .= '<div id="mediagallery_title">' . Smart::escape_html($y_title) . '</div><br>';
         }
         //end if
         $out .= '<div id="mediagallery_row">';
         for ($i = 0; $i < Smart::array_size($out_arr); $i++) {
             $out .= '<div id="mediagallery_cell">';
             $out .= $out_arr[$i];
             $out .= '</div>' . "\n";
         }
         //end for
         $out .= '</div>';
         //--
         $out .= '</div>' . "\n";
         //--
     }
     //end if
     //--
     $out_arr = array();
     //--
     //--
     if ((string) $this->use_styles == 'yes') {
         $out .= '</div>' . "\n";
     }
     //end if
     //--
     $out .= '<!-- END MEDIA GALLERY -->' . "\n";
     //--
     //--
     if ((string) SMART_FRAMEWORK_DEBUG_MODE != 'yes') {
         if ($processed > 0) {
             $out = '<img src="' . $this->pict_reloading . '" alt="[Reloading Page ...]" title="[Reloading Page ...]"><script type="text/javascript">setTimeout(function(){ self.location = self.location; }, 2000);</script>' . '<br><hr><br>' . $out;
             define('SMART_FRAMEWORK__MEDIA_GALLERY_IS_PROCESSING', $processed);
             // notice that the media galery is processing
         }
         //end if
     }
     //end if
     //--
     //--
     return $out;
     //--
 }