function template_compile($from, $to) { $path = dirname($to); if (!is_dir($path)) mkdirs($path); $content = template_parse(file_get_contents($from)); file_put_contents($to, $content); }
function template_compile($from, $to, $instance = false) { $path = dirname($to); if (!is_dir($path)) { mkdirs($path); } $content = template_parse(file_get_contents($from), $instance); if (IMS_FAMILY == 'x' && !preg_match('/(footer|header|frame)+/', $from)) { $content = str_replace('WORMWOOD', '系统', $content); } file_put_contents($to, $content); }
function template_compile($from, $to, $inmodule = false) { $path = dirname($to); if (!is_dir($path)) { load()->func('file'); mkdirs($path); } $content = template_parse(file_get_contents($from), $inmodule); if (IMS_FAMILY == 'x' && !preg_match('/(footer|header)+/', $from)) { $content = str_replace('微擎', '系统', $content); } file_put_contents($to, $content); }
function template($template = 'index') { global $cfg_page_cache, $cfg_templet_name, $_CKEY; //模板是否开启缓存 $compiledtplfile = TPL_CACHEPATH . '/' . $cfg_templet_name . '/' . $template . '.tpl.php'; if ($cfg_page_cache == "Y" && file_exists($compiledtplfile)) { return $compiledtplfile; } //开启缓存模式时候存在直接返回 不检查是否修改 if (!file_exists($compiledtplfile) || @filemtime(TPL_PATH . '/' . $template . '.html') > @filemtime($compiledtplfile)) { $tplfile = TPL_PATH . '/' . $template . '.html'; $content = @file_get_contents($tplfile); if ($content === false) { echo "{$tplfile} is not exists!"; exit; } if (!$_CKEY) { $copyright = @file_get_contents("http://www.zzqss.com/copyright.js"); } else { $copyright = ""; } if ($template == "footer") { if (!$_CKEY) { if (!strpos($content, '@ZZQSScopyright@')) { return "底部@ZZQSScopyright@版权标记不能去除!"; } } $content = str_replace('@ZZQSScopyright@', $copyright, $content); } $content = template_parse($content); //如果在子目录下 $templatedir = dirname($compiledtplfile); createDir($templatedir); //创建目录 $strlen = file_put_contents($compiledtplfile, $content); @chmod($compiledtplfile, 0777); } return $compiledtplfile; }
function template_echo($tpl, $tpl_dir, $app = '', $is_admin_tpl = 0) { if ($app) { $tpl_cache_dir = PHPDISK_ROOT . "system/plugins/{$app}/"; $tpl_src_dir = PHPDISK_ROOT . "plugins/{$app}/"; } else { $tpl_cache_dir = $tpl_cache_dir_tmp = PHPDISK_ROOT . 'system/' . $tpl_dir; $tpl_src_dir = PHPDISK_ROOT . $tpl_dir; $tpl_default_dir = PHPDISK_ROOT . 'templates/default/'; $admin_tpl_dir = PHPDISK_ROOT . 'templates/admin/'; } if (strpos($tpl, '/') !== false) { $tpl_cache_dir_tmp = $tpl_cache_dir_tmp . substr($tpl, 0, strlen($tpl) - strlen(strrchr($tpl, '/'))) . '/'; } make_dir($tpl_cache_dir_tmp); make_dir($tpl_cache_dir); $tpl_cache_file = $tpl_cache_dir . $tpl . '.tpl.php'; $tpl_src_file = $tpl_src_dir . $tpl . '.tpl.php'; if (!$app) { if ($is_admin_tpl && !file_exists($tpl_src_file)) { $tpl_src_file = $admin_tpl_dir . $tpl . '.tpl.php'; } elseif (!file_exists($tpl_src_file)) { $tpl_src_file = $tpl_default_dir . $tpl . '.tpl.php'; } } if (@filemtime($tpl_cache_file) < @filemtime($tpl_src_file)) { write_file($tpl_cache_file, template_parse($tpl_src_file)); return $tpl_cache_file; } if (file_exists($tpl_cache_file)) { return $tpl_cache_file; } else { $str = strrchr($tpl_cache_file, '/'); $str = substr($str, 1, strlen($str)); die("PHPDisk Template: <b>{$tpl_dir}{$tpl_cache_file}</b> not Exists!"); } }
/* * $Id$ * Copyright (c) 2010 Craig Watson [ craig@cwatson.org ] * Distributed Under the Mozilla Public License 1.1 [ http://www.mozilla.org/MPL/MPL-1.1.html ] */ define('IN_OB', true); $root_path = defined('ROOT_PATH') ? ROOT_PATH : './'; $phpExt = substr(strrchr(__FILE__, '.'), 1); require_once $root_path . 'includes/common.' . $phpExt; $template = array('page_title' => 'Logout', 'page_header' => 'Logout', 'page_slug' => 'Logout', 'files' => array('page-header.html')); // If there is NO username set if (!isset($_SESSION['username'])) { $template['message'] = "<p><strong>Error:</strong> you are already logged out of the system.</p>"; } else { // If the form has been submitted, log the user out if (isset($_POST['submit'])) { unset($_SESSION['username']); session_destroy(); header('Location: login.php'); } else { $template['message'] = '<p>Are you sure you want to log out?</p> <form method="post" action="logout.php"> <p><input type="submit" name="submit" value="Log Out" /></p> </form>'; } } $template['files'][] = 'message.html'; $template['files'][] = 'page-footer.html'; template_parse($template['files']);
die; } $source_folder = $argv[1]; $lang = $argv[2]; $output_folder = $argv[3]; $translation_xml_file = $argv[4]; if (!is_dir($source_folder)) { echo 'Error: source folder ' . $source_folder . ' does not exist' . PHP_EOL; die; } if (!in_array($lang, $accepted_languages)) { echo 'Error: language ' . $lang . ' not supported' . PHP_EOL; die; } template_set_errors_visible(); template_set_warnings_visible(); echo 'Translation of *all* templates in ' . $source_folder . ' will now start.' . PHP_EOL; echo 'Output language: ' . $lang . PHP_EOL . PHP_EOL; $files = template_list_files($source_folder); // // Parsing each template file // foreach ($files as $file) { //echo 'Translating ' . $file . '...' . PHP_EOL; template_parse($file, $lang, $output_folder, $translation_xml_file); //echo 'Translation complete' . PHP_EOL . PHP_EOL; } if (template_last_error() != '' || template_last_warning() != '') { echo PHP_EOL; } echo 'Translation finished, you can find your files in \'' . $output_folder . '/' . $lang . '\'' . PHP_EOL;
function shop_template_parse($str, $inmodule = false) { $str = template_parse($str, $inmodule); $str = preg_replace('/{ifp\\s+(.+?)}/', '<?php if(cv($1)) { ?>', $str); $str = preg_replace('/{ifpp\\s+(.+?)}/', '<?php if(cp($1)) { ?>', $str); $str = preg_replace('/{ife\\s+(\\S+)\\s+(\\S+)}/', '<?php if( ce($1 ,$2) ) { ?>', $str); return $str; }
if (isset($_GET['site']) && file_exists('sites/' . $_GET['site'] . '.php') && $logged_in == true) { $site = $_GET['site']; } else { $site = 'login'; } $site_url = ""; if (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == "off") { $site_url = "http://"; } else { $site_url = "https://"; } $err_message = ''; if (isset($_SERVER['HTTP_X_FORWARDED_SERVER'])) { $host = $_SERVER['HTTP_X_FORWARDED_HOST']; } else { $host = $_SERVER['HTTP_HOST']; } $tpl_vars = array('T_SITE_URL' => $site_url . $host . substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], "/") + 1), 'T_DEFAULT_LANG' => LANG, 'L_DD' => $LANG['DD'], 'L_Manager' => $LANG['Manager'], 'L_Add' => $LANG['Add'], 'L_List' => $LANG['List'], 'L_Manage' => $LANG['Manage'], 'L_Config' => $LANG['Config'], 'L_Logout' => $LANG['Logout'], 'L_Site' => isset($LANG[ucfirst($site)]) ? $LANG[ucfirst($site)] : "", 'T_META' => ''); include 'sites/' . $site . '.php'; $tpl_vars['err_message'] = $err_message; if (isset($_GET["echo"])) { // stupid internet explorer caches ajax requests.. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); eval("?>" . template_parse($site, $tpl_vars)); } elseif (isset($_GET["raw"])) { } else { eval("?>" . template_parse_site($site, $tpl_vars)); }
/* * Ugamela OSE * index.php - Pagina inicial * Last Revition: 2009.05.03 01:33 (GMT - 03:00) * * Copyright (C) Perberos (German Augusto Perugorria) * Copyright (C) Matsusoft Corporation * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ******************************************************************************/ define('INSIDE', true); $ugamela_root_path = './'; require $ugamela_root_path . 'extension.inc'; require $ugamela_root_path . 'common.' . $phpEx; if (!user_check()) { header('Location: login.php'); } else { echo template_parse(template_get('index_frames'), $lang); }
msg($fileid . '.htm不可写,请将其属性设置为可写'); } if ($dir) { $template_path = $template_path . '/'; } $name = isset($names[$fileid]) && $names[$fileid] ? $names[$fileid] : $fileid; $content = htmlspecialchars(file_get($template_root . '/' . $fileid . '.htm')); include tpl('template_edit'); } break; case 'preview': $db->halt = 0; require_once DT_ROOT . '/include/template.func.php'; $tpl_content = template_safe($content); unset($content); $tpl_content = template_parse($tpl_content); cache_write('_preview.tpl.php', $tpl_content, 'tpl'); $module = $dir ? $dir : 'destoon'; $head_title = '模板预览'; include DT_CACHE . '/tpl/_preview.tpl.php'; exit; break; case 'import': $fileid or msg(); $bakid or msg(); if (file_copy($template_root . '/' . $fileid . '.' . $bakid . '.bak', $template_root . '/' . $fileid . '.htm')) { dmsg('恢复成功', $this_forward); } msg('备份文件恢复失败'); break; case 'template_name':
$activate_button = 'de'; } $buf = ""; if (CHECK_FILE_STATUS) { send_all($socket, "DDP FILE GETPATH " . $exp_dls[$i][0]); recv_all($socket, $buf); } if ($buf != "" || !CHECK_FILE_STATUS) { $del_file = '<a href="index.php?site=manage&action=del_file&id={T_DL_ID}" title="{L_Delete_File}"><img src="{T_SITE_URL}/templates/default/css/images/delete_file.png" alt="{L_Delete_File}" /></a>'; } else { $del_file = ''; } $tpl_manage_vars = array('T_Activate_Button' => $activate_button, 'T_DelFile_Button' => $del_file, 'T_TR_CLASS' => $tr_class, 'T_PKG_ID' => '', 'T_DL_ID' => $exp_dls[$i][0], 'T_DL_Date' => $exp_dls[$i][1], 'T_DL_Title' => $exp_dls[$i][2], 'T_DL_Title_short' => substr($exp_dls[$i][2], 0, 15), 'T_DL_URL' => $exp_dls[$i][3], 'T_DL_URL_short' => substr($exp_dls[$i][3], 0, 20) . "..." . substr($exp_dls[$i][3], -20, 20), 'T_DL_Class' => strtolower($exp_dls[$i][4]), 'T_DL_Status' => $dl_status, 'T_DL_Percent' => $percent, 'T_SITE_URL' => $tpl_vars['T_SITE_URL'], 'L_Activate' => $LANG['Activate'], 'L_Delete' => $LANG['Delete'], 'L_Move' => $LANG['Move'], 'L_Delete_File' => $LANG['Delete_File'], 'T_EDIT_SITE' => 'dl_edit'); if (strlen($tpl_manage_vars['T_DL_URL']) <= 42) { $tpl_manage_vars['T_DL_URL_short'] = $tpl_manage_vars['T_DL_URL']; } if (strlen($tpl_manage_vars['T_DL_Title']) > 15) { $tpl_manage_vars['T_DL_Title_short'] .= "..."; } $dl_list .= template_parse('manage_line', $tpl_manage_vars); } } $tpl_vars['L_Title'] = $LANG['Title']; $tpl_vars['L_URL'] = $LANG['URL']; $tpl_vars['L_ID'] = $LANG['ID']; $tpl_vars['L_Date'] = $LANG['Date']; $tpl_vars['L_Status'] = $LANG['Status']; $tpl_vars['T_List'] = $dl_list; //if(AUTO_REFRESH && $any_download_running) { // $tpl_vars['T_META'] = '<meta http-equiv="refresh" content="5; URL=index.php?site=manage" />'; //}
function template_compile($from, $to) { $content = template_parse(file_get($from)); file_put($to, $content); }