<?php
set_time_limit(3);
error_reporting(E_ALL);
//var_dump("smarty_block_qkweb");
function smarty_block_qkweb($params, $content, &$smarty, &$repeat) {
	//$item['name'] = 'qkweb';
		$t = count($smarty->_tag_stack);
		//var_dump();
		//if(!isset($GLOBALS['blocksdata'])){$GLOBALS['blocksdata'] = array();}
		//$param_count = count($smarty->_tag_stack);
		$dataindex = md5(__FUNCTION__ . md5(serialize($params)));
		$dataindex = substr($dataindex,0,16);
		//echo $dataindex."<br>";
		if(!isset($GLOBALS['blocksdata'][$dataindex])){//echo"aaa".$dataindex;
			$a= array(array("name"=>"qkweb"),array("name"=>"qkwessb"));
				$GLOBALS['blocksdata'][$dataindex]=$a;//exit;
				//print_r($a);
				//echo $dataindex;
				//echo($GLOBALS['blocksdata']);
				//exit;
		}
		//echo $param_count;exit;
		//print_r($GLOBALS['blocksdata']);
		//exit;
		//if(!$GLOBALS['blocksdata'][$dataindex]){$repeat = false;return '';}
		//reset($data[$dataindex]);
		//print_r($data[$dataindex]);exit;
		//$data[$dataindex]=array();
//$data=array();

	if(is_array($GLOBALS['blocksdata'][$dataindex])){

		$item = array_shift($GLOBALS['blocksdata'][$dataindex]);
		$smarty->assign($params['name'], $item);
		if(count($GLOBALS['blocksdata'][$dataindex])==0){
			$GLOBALS['blocksdata'][$dataindex] = false;
		}
		$repeat= true;
	}else{
		$repeat = false;
	}
	/*
		if(list($key, $item) = each($GLOBALS['blocksdata'])){
			$smarty->assign($params['name'],$item);
			//print_r($item);
			$repeat = true;
		}else{
			//echo"abc";
			$repeat = false;
		}
		*/
		//print_r($item);
		//$repeat=false;
		//exit;
		//if(!$item){
		//	reset($data);
		//$repeat = false;}
		//print $content;
		echo $content;
/*
	if(list($key, $item) = each($content)) {
		$repeat = true;
		$item['name'] = "abc";
		$smarty->assign($params['name'], $item);
		print_r($item);
		if($i==2)exit;
		$i++;
	}
	else {
		$repeat = false;
		reset($content);
	}
	if(!$repeat) $content = array();
	*/
	/*
	$repeat = true;
	$item = array("name"=>"qkweb");
	//echo $params['name'];exit;
	$smarty->assign($params['name'], $item);
	$repeat=false;
	
	//return array(array("name"=>"qkweb"));
	//return $content;
	//$smarty->assign($params['name'], "aaaa");
	if(!$repeat){
		//return "aaaa";
	}*/
//$smarty->assign($params['name'], $item);
}
?>