function compress_template($file_path) { $temp = new mb_template($file_path, array('temp_dir' => ROOT_PATH, 'compile_dir' => ROOT_PATH . '_cache', 'force_compression' => true, 'compressHTML' => true, 'output_template' => true), null); $output = $temp->output_string(); $file_dir = get_dir_of_path($file_path); make_dir($file_dir, ROOT_PATH); write_file(rtrim(OUTPUT_DIR, '\\/\\') . $file_path, $output); $output = null; }
$data_file = DATA_DIR . 'global.json'; if (file_exists($data_file)) { $data_content = file_get_contents($data_file); $global_data = $json->decode($data_content); } $data_file = DATA_DIR . wipe_ext($template_file) . '.json'; if (file_exists($data_file)) { $data_content = file_get_contents($data_file); $data = $json->decode($data_content); if ($data) { $data = array_merge($global_data, $data); } } $data['path'] = $_SERVER['REQUEST_URI']; $data['web_host'] = 'http://' . $_SERVER['HTTP_HOST']; $data['www_root'] = $data['web_host'] . WEB_PATH; $data['time'] = time(); $data['page_list'] = array(); if ($fp = @opendir(PAGE_DIR)) { while (false !== ($file = readdir($fp))) { $file_path = PAGE_DIR . $file; if (!is_dir($file_path) && preg_match('/\\.html$/i', $file) && $file !== '404.html' && $file !== 'index.html') { $data['page_list'][] = $file; } } } $temp->tmp_var = $data; $output = $temp->output_string(); //$output = htmlspecialchars($output ); die($output); }