<?php
namespace Think\Template\TagLib;
use Think\Template\TagLib;

class Klmz extends TagLib
{
	protected $tags = array(
		"qqlist" => array("attr" => "row,limit,where,order", "close" => 1)
		);

	public function _qqlist($attr, $content)
	{
		$sid = $_COOKIE["xiha_sid"];
		if ($sid && ($user = m("users")->field("uid")->where("sid='$sid'")->find())) {
		}
		else {
			@header("HTTP/1.1 301 Moved Permanently");
			@header("Location:/");
		}

		$where = ($attr["where"] ? "uid='{$user['uid']}' and " . $attr["where"] : "uid='{$user['uid']}'");
		$order = ($attr["order"] ? $attr["order"] : null);
		$comment = $attr["comment"];

		if ($attr["limit"]) {
			$limit = $attr["limit"];
		}

		$str = "<?php ";
		$str .= "\$_rows=M(\"qqs\")->field(\"*\")->where(\"" . $where . "\")->limit(\"" . $limit . "\")->order(\"" . $order . "\")->select();";
		$str .= "foreach (\$_rows as \$_row):";
		$str .= "extract(\$_row);?>";
		$str .= $content;
		$str .= "<?php endforeach ?>";
		return $str;
	}
}


?>
