⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resource.db.php

📁 在综合英文版XOOPS 2.09, 2.091, 2.092 的基础上正式发布XOOPS 2.09中文版 XOOPS 2.09x 版主要是PHP5升级、bug修正和安全补正: 1 全面兼容PHP 5.
💻 PHP
字号:
<?php
/*
 * Smarty plugin
 * ------------------------------------------------------------- 
 * File:     resource.db.php
 * Type:     resource
 * Name:     db
 * Purpose:  Fetches templates from a database
 * -------------------------------------------------------------
 */
function smarty_resource_db_source($tpl_name, &$tpl_source, &$smarty)
{
    $tplfile_handler =& xoops_gethandler('tplfile');
	$tplobj =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], null, null, null, $tpl_name, true);
	if (count($tplobj) > 0) {
		if (false != $smarty->xoops_canUpdateFromFile()) {
			$conf_theme = isset($GLOBALS['xoopsConfig']['theme_set']) ? $GLOBALS['xoopsConfig']['theme_set'] : 'default';
			if ($conf_theme != 'default') {
				switch ($tplobj[0]->getVar('tpl_type')) {
					case 'module':
						$filepath = XOOPS_THEME_PATH.'/'.$conf_theme.'/templates/'.$tplobj[0]->getVar('tpl_module').'/'.$tpl_name;
						break;
					case 'block':
						$filepath = XOOPS_THEME_PATH.'/'.$conf_theme.'/templates/'.$tplobj[0]->getVar('tpl_module').'/blocks/'.$tpl_name;
						break;
					default:
						$filepath = "";
						break;
				}
			} else {
				switch ($tplobj[0]->getVar('tpl_type')) {
					case 'module':
						$filepath = XOOPS_ROOT_PATH.'/modules/'.$tplobj[0]->getVar('tpl_module').'/templates/'.$tpl_name;
						break;
					case 'block':
						$filepath = XOOPS_ROOT_PATH.'/modules/'.$tplobj[0]->getVar('tpl_module').'/templates/blocks/'.$tpl_name;
						break;
					default:
						$filepath = "";
						break;
				}
			}
			if ($filepath != "" && file_exists($filepath)) {
				$file_modified = filemtime($filepath);
				if ($file_modified > $tplobj[0]->getVar('tpl_lastmodified')) {
					if (false != $fp = fopen($filepath, 'r')) {
						$filesource = fread($fp, filesize($filepath));
    					fclose($fp);
						$tplobj[0]->setVar('tpl_source', $filesource, true);
						$tplobj[0]->setVar('tpl_lastmodified', time());
						$tplobj[0]->setVar('tpl_lastimported', time());
    					$tplfile_handler->forceUpdate($tplobj[0]);
						$tpl_source = $filesource;
        				return true;
					}
				}
			}
		}
        $tpl_source = $tplobj[0]->getVar('tpl_source');
        return true;
    } else {
		return false;
	}
}

function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, &$smarty)
{
    $tplfile_handler =& xoops_gethandler('tplfile');
    $tplobj =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], null, null, null, $tpl_name, false);
	if (count($tplobj) > 0) {
		if (false != $smarty->xoops_canUpdateFromFile()) {
			$conf_theme = isset($GLOBALS['xoopsConfig']['theme_set']) ? $GLOBALS['xoopsConfig']['theme_set'] : 'default';
			if ($conf_theme != 'default') {
				switch ($tplobj[0]->getVar('tpl_type')) {
					case 'module':
						$filepath = XOOPS_THEME_PATH.'/'.$conf_theme.'/templates/'.$tplobj[0]->getVar('tpl_module').'/'.$tpl_name;
						break;
					case 'block':
						$filepath = XOOPS_THEME_PATH.'/'.$conf_theme.'/templates/'.$tplobj[0]->getVar('tpl_module').'/blocks/'.$tpl_name;
						break;
					default:
						$filepath = "";
						break;
				}
			} else {
				switch ($tplobj[0]->getVar('tpl_type')) {
					case 'module':
						$filepath = XOOPS_ROOT_PATH.'/modules/'.$tplobj[0]->getVar('tpl_module').'/templates/'.$tpl_name;
						break;
					case 'block':
						$filepath = XOOPS_ROOT_PATH.'/modules/'.$tplobj[0]->getVar('tpl_module').'/templates/blocks/'.$tpl_name;
						break;
					default:
						$filepath = "";
						break;
				}
			}
			if ($filepath != "" && file_exists($filepath)) {
				$file_modified = filemtime($filepath);
				if ($file_modified > $tplobj[0]->getVar('tpl_lastmodified')) {
					$tpl_timestamp = $file_modified;
					return true;
				}
			}
		}
        $tpl_timestamp = $tplobj[0]->getVar('tpl_lastmodified');
        return true;
    } else {
		return false;
	}
}

function smarty_resource_db_secure($tpl_name, &$smarty)
{
    // assume all templates are secure
    return true;
}

function smarty_resource_db_trusted($tpl_name, &$smarty)
{
    // not used for templates
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -