<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty {fetch} plugin
 *
 * Type:     function<br>
 * Name:     fetch<br>
 * Purpose:  fetch file, web or ftp data and display results
 * @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}
 *       (Smarty online manual)
 * @author Monte Ohrt <monte at ohrt dot com>
 * @param array
 * @param Smarty
 * @return string|null if the assign parameter is passed, Smarty assigns the
 *                     result to a template variable
 */

function smarty_function_getlink($params, &$smarty){
 extract($params); 
 $isindex = isset($params['isindex']) ? $params['isindex'] : 0;     
 $isimg = isset($params['isimg']) ? $params['isimg'] : 0;
 if(is_null($isindex) || is_null($isimg)){
 return '传入数据不正确';
 	 	}
 	$str = ''; 	
	$msql = "select * from limao_link where lm_action='".cinput($isimg)."' and lm_select='".cinput($isindex)."'";
	$mrs = mysql_query($msql) or die('传入的参数错误');
	while($mdata=mysql_fetch_object($mrs)){
switch($mdata->lm_action){		
	case 0:
	$tmp = "<span><a href='".rinput($mdata->lm_url)."' target='_blank'>".rinput($mdata->lm_title)."</a></span>&nbsp;";	
  break;
  case 1:
 	$tmp = "<div style='display:inline-block;float:left;'><a href='".rinput($mdata->lm_url)."' target='_blank'><img src='".rinput($mdata->lm_imgurl)."' width='120px' height='60px' /></a></div>&nbsp;";	
  break;
 }
  $str .= $tmp;  
}
   return $str;
    
    }  

/* vim: set expandtab: */

?>
