コード例 #1
0
 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)]])]);
     //--
 }
コード例 #2
0
 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
     //--
 }
コード例 #4
0
 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";
     //--
 }
コード例 #5
0
 /**
  * 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)]);
     //--
 }
コード例 #6
0
 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');
     //--
 }
コード例 #7
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
     //--
 }
コード例 #8
0
 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'))));
     //--
 }
コード例 #9
0
 /**
  * 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'));
     //--
 }