public function Run()
 {
     //--
     $title = 'Extended Markers Template Test';
     //--
     $test_switch_arr = ['a', 'b', 'c', 'd'];
     $this->PageViewSetVars(['title' => $title, 'main' => SmartMarkersTemplating::render_file_template($this->ControllerGetParam('module-path') . 'views/templating-test.htm', ['TITLE' => $title, 'TEST-COMPARE' => 'a', 'TESTURL' => 'a"b\'c', 'DATA' => ['This is a sample table', ['id' => 1, 'slug' => 'a', 'name' => 'Letter A', 'is_vowel' => true], ['id' => 2, 'slug' => 'b', 'name' => 'Letter B', 'is_vowel' => false], ['id' => 3, 'slug' => 'c', 'name' => 'Letter C', 'is_vowel' => false], ['id' => 4, 'slug' => 'd', 'name' => 'Letter D', 'is_vowel' => false], ['id' => 5, 'slug' => 'e', 'name' => 'Letter E', 'is_vowel' => true], ['id' => 6, 'slug' => 'f', 'name' => 'Letter F', 'is_vowel' => false], ['id' => 7, 'slug' => 'g', 'name' => 'Letter G', 'is_vowel' => false], ['id' => 8, 'slug' => 'h', 'name' => 'Letter H', 'is_vowel' => false], ['id' => 9, 'slug' => 'i', 'name' => 'Letter I', 'is_vowel' => true], ['id' => 10, 'slug' => 'j', 'name' => 'Letter J', 'is_vowel' => false], ['id' => 11, 'slug' => 'k', 'name' => 'Letter K', 'is_vowel' => false], ['id' => 12, 'slug' => 'l', 'name' => 'Letter L', 'is_vowel' => false], ['id' => 13, 'slug' => 'm', 'name' => 'Letter M', 'is_vowel' => false], ['id' => 14, 'slug' => 'n', 'name' => 'Letter N', 'is_vowel' => false], ['id' => 15, 'slug' => 'o', 'name' => 'Letter O', 'is_vowel' => true]], 'DAT2' => ['key1' => ['id' => 'val1', 'name' => 'Value 1'], 'key2' => 'val2', 'key3' => 'val3', 'key4' => 'val4'], 'TEST1' => 3, 'TEST2' => Smart::random_number(2, 3), 'TEST3' => 3, 'STATUS' => (string) $test_switch_arr[Smart::random_number(0, 3)]])]);
     //--
 }
 public function Run()
 {
     //-- Session will be started also by set
     SmartSession::set('Samples_Benchmark_WithSession (just for admin)', true);
     //--
     //--
     $this->PageViewSetCfg('template-path', '@');
     // set template path to this module
     $this->PageViewSetCfg('template-file', 'template-benchmark.htm');
     // the default template
     //--
     //--
     $this->PageViewSetVar('title', 'Benchmark with Session Test URL');
     //--
     $this->PageViewSetVar('main', SmartMarkersTemplating::render_file_template($this->ControllerGetParam('module-path') . 'views/benchmark.htm', ['BENCHMARK-TITLE' => '[ Benchmark Test URL with PHP Session ]<br>use this URL to run a benchmark of this PHP framework with the PHP Session started ...']));
     //--
 }
예제 #3
0
 public function Run()
 {
     //--
     $this->PageViewSetCfg('template-path', '@');
     // set template path to this module
     $this->PageViewSetCfg('template-file', 'template-benchmark.htm');
     // the default template
     //--
     //--
     $this->PageViewSetVar('title', 'Benchmark Test URL');
     //--
     $this->PageViewSetVars(['head-meta' => '<meta name="author" content="Smart.Framework by Unix-World, https://github.com/unix-world/Smart.Framework">', 'main' => SmartMarkersTemplating::render_file_template($this->ControllerGetParam('module-view-path') . 'benchmark.htm', ['BENCHMARK-TITLE' => '[ Benchmark Test URL ' . date('Y-m-d H:i:s O') . ' ]<br>use this URL to run a benchmark of this PHP framework ...'], 'no')]);
     //--
     //--
     return 200;
     // HTTP 200 OK
     //--
 }
 /**
  * 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)]);
     //--
 }
 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 static function test_crypto()
 {
     //--
     $time = microtime(true);
     //--
     //--
     $unicode_text = "Unicode String [ " . time() . " ]: @ Smart スマート // Cloud Application Platform クラウドアプリケーションプラットフォーム '" . implode('', array_keys(SmartUnicode::accented_chars())) . " \" <p></p>\n\t? & * ^ \$ @ ! ` ~ % () [] {} | \\ / + - _ : ; , . #'" . microtime() . '#';
     //--
     //--
     $b64enc = base64_encode($unicode_text);
     $b64dec = base64_decode($b64enc);
     //--
     //--
     $bin2hex = strtoupper(bin2hex((string) $unicode_text));
     $hex2bin = hex2bin(strtolower(trim((string) $bin2hex)));
     //--
     //--
     $hkey = 'TestUnit // This is a test key for Crypto Cipher ...' . time() . $unicode_text;
     //--
     $he_enc = SmartUtils::crypto_encrypt($unicode_text, $hkey);
     $he_dec = SmartUtils::crypto_decrypt($he_enc, $hkey);
     //--
     if ((string) $he_dec != (string) $unicode_text or sha1($he_dec) != sha1($unicode_text)) {
         Smart::raise_error('TestUnit FAILED in ' . __FUNCTION__ . '() :: Crypto Cipher test', 'TestUnit: Crypto Cipher test failed ...');
         return;
     }
     //end if
     //--
     //--
     $bf_key = SmartHashCrypto::sha512('TestUnit // This is a test key for Blowfish ...' . time() . $unicode_text);
     $bf_enc = SmartUtils::crypto_blowfish_encrypt($unicode_text, $bf_key);
     $bf_dec = SmartUtils::crypto_blowfish_decrypt($bf_enc, $bf_key);
     if ((string) $bf_dec != (string) $unicode_text or sha1($bf_dec) != sha1($unicode_text)) {
         Smart::raise_error('TestUnit FAILED in ' . __FUNCTION__ . '() :: Crypto Blowfish test', 'TestUnit: Blowfish test failed ...');
         return;
     }
     //end if
     //--
     //--
     $arch_lzs = SmartArchiverLZS::compressToBase64($unicode_text);
     $unarch_lzs = SmartArchiverLZS::decompressFromBase64($arch_lzs);
     if ((string) $unarch_lzs != (string) $unicode_text or sha1($unarch_lzs) != sha1($unicode_text)) {
         Smart::raise_error('TestUnit FAILED in ' . __FUNCTION__ . '() :: Crypto Arch-LZS test', 'TestUnit: Arch-LZS test failed ...');
         return;
     }
     //end if
     //--
     //--
     $arch_bf_lzs = SmartArchiverLZS::compressToBase64($bf_enc);
     $unarch_bf_lzs = SmartArchiverLZS::decompressFromBase64($arch_bf_lzs);
     if ((string) $unarch_bf_lzs != (string) $bf_enc or sha1($unarch_bf_lzs) != sha1($bf_enc)) {
         Smart::raise_error('TestUnit FAILED in ' . __FUNCTION__ . '() :: Crypto Blowfish-Arch-LZS test', 'TestUnit: Blowfish-Arch-LZS test failed ...');
         return;
     }
     //end if
     //--
     //--
     $time = 'TOTAL TIME was: ' . (microtime(true) - $time);
     //--
     //--
     return SmartMarkersTemplating::render_file_template('lib/core/templates/testunit/crypto-test.inc.htm', array('EXE-TIME' => Smart::escape_html($time), 'UNICODE-TEXT' => Smart::escape_html($unicode_text), 'JS-ESCAPED' => $unicode_text, 'HASH-SHA512' => Smart::escape_html(SmartHashCrypto::sha512($unicode_text)), 'HASH-SHA1' => Smart::escape_html(sha1($unicode_text)), 'HASH-MD5' => Smart::escape_html(md5($unicode_text)), 'BASE64-ENCODED' => Smart::escape_html($b64enc), 'BASE64-DECODED' => Smart::escape_html($b64dec), 'BIN2HEX-ENCODED' => Smart::escape_html($bin2hex), 'HEX2BIN-DECODED' => Smart::escape_html($hex2bin), 'LZS-ARCHIVED' => Smart::escape_html($arch_lzs), 'LZS-UNARCHIVED' => Smart::escape_html($unarch_lzs), 'BLOWFISH-ENCRYPTED' => Smart::escape_html($bf_enc), 'BLOWFISH-LZS-ENCRYPTED' => Smart::escape_html($arch_bf_lzs), 'BLOWFISH-DECRYPTED' => Smart::escape_html($bf_dec), 'BLOWFISH-KEY' => Smart::escape_html($bf_key), 'BLOWFISH-OPTIONS' => Smart::escape_html(SmartCipherCrypto::crypto_options('blowfish')), 'HASHCRYPT-ENC' => Smart::escape_html($he_enc), 'HASHCRYPT-DEC' => Smart::escape_html($he_dec), 'HASHCRYPT-OPTIONS' => Smart::escape_html(SmartCipherCrypto::crypto_options('custom'))));
     //--
 }
 /**
  * CallBack Mapping for HTML (wysiwyg) Editor - FileBrowser Integration
  *
  * @param STRING $yurl					The Callback URL
  * @param BOOLEAN $is_popup 			Set to True if Popup (incl. Modal)
  *
  * @return STRING						[JS Code]
  */
 public static function js_callback_html_area($yurl, $is_popup = false)
 {
     //--
     return str_replace(array("\r\n", "\r", "\n", "\t"), array(' ', ' ', ' ', ' '), (string) \SmartMarkersTemplating::render_file_template('modules/mod-js-components/libs/templates/html-editor-callback.inc.htm', array('IS_POPUP' => (int) $is_popup, 'URL' => (string) $yurl), 'yes'));
     //--
 }