<?php
function module_pic_lists()
{
	global $smarty;
	$list_public = get_file_list('images');
	$smarty->assign('list_public',$list_public);
	$list_goods = get_folder_list('images/goods');
	$smarty->assign('list_goods',$list_goods);
	$list_editor = get_folder_list('images/editor');
	$smarty->assign('list_editor',$list_editor);
	
	$smarty->assign('host',$_SERVER['HTTP_HOST']);
}
function get_file_list($val)
{
	$arr = array();
	$i = 0;
	$list = scandir($val);
	foreach($list as $file)
	{
		if($file != '.' && $file != '..' && !is_dir($val.'/'.$file))
		{
			$arr[$i]['id'] = sel_file($val.'/'.$file);
			$arr[$i]['name'] = $file;
			$i ++;
		}
	}
	return $arr;
}
function get_folder_list($val)
{
	$arr = array();
	$i = 0;
	if(file_exists($val))
	{
		$list = scandir($val);
		foreach($list as $file)
		{
			if($file != '.' && $file != '..' && is_dir($val.'/'.$file))
			{
				$arr[$i]['name'] = $file;
				$arr[$i]['path_str'] = rawurlencode($val.'/'.$file);
				$i ++;
			}
		}
	}
	return $arr;
}
function sel_file($val)
{
	$return = get_id('goods','goo_img',$val);
	if(!$return)
	{
		$return = get_id('goods','goo_x_img',$val);
	}
	if(!$return)
	{
		$return = get_id('picture','pic_path',$val);
	}
	return $return;
}
//红头船
?>