php自动获取目录下的模板的代码

yipeiwu_com6年前PHP代码库
目录下必须有default.gif(此图为模板缩略图)的才为合法的模板
复制代码 代码如下:

function get_template ()
{
$template = array ();
$dir = CMS_ROOT.'/tpl/';
$n = 0;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file =='.' or $file == '..' or $file == '.svn')
{
continue;
}
if (is_dir ($dir.$file))
{
if (file_exists ($dir.$file.'/default.gif'))
{
$template[$n]['dir'] = $file;
$template[$n]['pic'] ='/tpl/'.$file.'/default.gif';
}
}
$n++;
}
closedir($dh);
}
}
return $template;
}

相关文章

PHP简单计算两个时间差的方法示例

本文实例讲述了PHP简单计算两个时间差的方法。分享给大家供大家参考,具体如下: <?php //PHP计算两个时间差的方法 $startdate="2010-12-1...

php join函数应用

复制代码 代码如下: $key = array(); $val = array(); foreach ($_POST as $k=>$v) { $key[] = '`'.strip...

php实现网站顶踩功能的完整前端代码

许多网站都支持顶、踩功能,以便于显示用户对当前网页内容的满意度反馈。下面我们给出本站使用的顶、踩功能的完整前台实现代码,以便于用户参考。 完整的前端代码包括html、css、js各部分的...

php使用crypt()函数进行加密

php使用crypt()函数进行加密

一、代码 <?php $str = '应用crypt()函数进行单向加密!'; //声明字符串变量$str echo '加密前$str的值为:'.$s...

php生成短域名函数

php生成短域名函数 public function createRandCode($string) { $code = ''; $hex_code = '1qaz2...