<?php
defined('IN_YUNYECMSAdmin') or exit('No permission.');
core::load_admin_class('admin');
class content extends YUNYE_admin
{
	private $curmodel;  //当前模型
	private $curcat;   //当前栏目
	private $rootcat;  //当前根栏目
	private $lang;  //当前根栏目
	private $has_sub;  //是否包含子类
	function __construct()
	{
		parent::__construct();
		$this->db = core::load_model('content_model');
		if (!getroot('info', 'view')) {
			messagebox(Lan('no_permission_infoview'), 'back', "warn");
		}
		$this->lang = getlangid();
		if (!empty($_REQUEST['catid'])) {
			$catid = trim($_REQUEST['catid']);
			if (!is_numeric($catid)) {
				messagebox("错误的参数", "back", 'warn');
			}
			$catid = usafestr($catid);
			$this->curcat = $this->db->find("select * from `#yunyecms_category` where id={$catid} ");
			if (empty($this->curcat)) {
				messagebox("栏目不存在或参数错误", $_SERVER['HTTP_REFERER']);
			} else {
				$parentid = getparentid($catid);
				$subcatid = getsubcatid($catid);
				if (empty($subcatid) || $parentid) {
					$this->has_sub = false;
				} else {
					$this->has_sub = true;
				}
				$modelid = $this->curcat['modelid'];
				if (empty($modelid)) {
					messagebox('您选择的栏目有误，请重新选择!', $_SERVER['HTTP_REFERER'], "warn");
				} else {
					$this->curmodel = $this->db->find("select * from `#yunyecms_model` where modelid={$modelid} ");
				}
			}
			if (empty($this->curmodel)) {
				messagebox('该分类所在的数据模型不存在，请重新选择!', $_SERVER['HTTP_REFERER'], "warn");
			}
			$ppid = getppid($catid);
			if (!empty($ppid)) {
				$this->rootcat = $this->db->find("select * from `#yunyecms_category` where id={$ppid} ");
			}
		} else {
			messagebox("栏目不存在或参数错误", $_SERVER['HTTP_REFERER']);
		}
	}
	//加载首页
	public function lists()
	{
		$aa = getroot('info', 'view');
		if (!getroot('info', 'view')) {
			messagebox(Lan('no_permission_infoview'), 'back', "warn");
		} else {
			//取得栏目权限
			$catpower = fetch_cat_power();
			if (!empty($catpower)) {
				//取得拥有查看权限的分类ID
				$catpwerid = get_power_catid($catpower);
			}
		}
		$tablename = "m_" . $this->curmodel['tablename'];
		$modelfields = $this->db->select("select * from `#yunyecms_modelfields`  where modelid={$this->curmodel['modelid']} and language=1 and issys=0 and issearch=1 and isadd=1 order by ordernum ");
		$parnav = '<li class=\"breadcrumb-item\"><a href=\"' . url_admin('init', "category") . '\" target=\"maincontent\">内容</a></li><li class=\"breadcrumb-item\"><a href=\"' . url_admin('lists', 'content', array("catid" => $this->curcat['id'])) . '\" target=\"maincontent\">' . $this->rootcat['title'] . '</a></li><li class=\"breadcrumb-item active\">' . $this->curcat['title'] . '</li>';
		$pagesize = 20;
		$sqlquery = "select * from `#yunyecms_{$tablename}`  ";
		$where = " where 1=1 and lang={$this->lang} ";
		$sqlcnt = " select count(*) from `#yunyecms_{$tablename}` ";
		$order = " order by `addtime` desc ";
		if (isset($_REQUEST)) {
			if (!empty($_REQUEST["searchkey"])) {
				$searchkey = usafestr(trim($_REQUEST["searchkey"]));
				$where = $where . " and ( `title`  like '%{$searchkey}%'  )";
			}
			foreach ($modelfields as $key => $var) {
				$formctrl = $var[formctrl];
				$fdname = $var[fdname];
				if ($formctrl == 'checkbox' || $formctrl == 'radio') {
					$postfdname = usafestr(trim($_REQUEST[$fdname]));
					if (!empty($postfdname)) {
						$where = $where . "and FIND_IN_SET($postfdname,$fdname) ";
					}
				} else {
					$postfdname = usafestr(trim($_REQUEST[$fdname]));
					if (!empty($postfdname)) {
						$where = $where . " and $fdname ='$postfdname' ";
					}
				}
			}
			$catid = trim($_REQUEST['catid']);
			if (!is_numeric($catid)) {
				messagebox("错误的参数", "back", 'warn');
			}
			$catid = usafestr($catid);
			if (!empty($catid)) {
				$subcat = get_cat_child($catid);
				$catidstr = implode(',', $subcat);
				$newcat = array_intersect($subcat, $catpwerid);
				$messagetip = "暂时没有{$this->curcat["title"]}信息";
				if (!empty($catpwerid)) {
					if (empty($newcat)) {
						messagebox("您没有管理{$this->curcat["title"]}信息的权限", 'back', "warn");
					} else {
						$catidstr = implode(',', $newcat);
						$where = $where . " and catid in($catidstr)";
					}
				} else {
					$where = $where . " and catid in($catidstr)  ";
				}
				$where = $where . "or FIND_IN_SET($catid,catids) ";
			}
			if (getroot('info', 'self')) {
				$where = $where . " and admin_userid ={$this->admuser["userid"]}";
			}
		}
		$pagearr = $this->db->pagelist($sqlcnt, $sqlquery, $where, $order, $pagesize);
		if ($pagearr["count"] != 0) {
			$list = $pagearr["query"];
			foreach ($list as $key => $var) {
				$modelarr = $this->db->find("select modelid  from `#yunyecms_category` where `id`= {$var['catid']}");
				if ($modelarr) {
					$list[$key]["modelid"] = $modelarr["modelid"];
					$list[$key]['pic'] = dopic($var['pic']);
				}
			}
			$pages = $pagearr["page"];
		}
		require tpl_adm('infolist');
	}

	public function infolist_add()
	{
		$tablename = "m_" . $this->curmodel['tablename'];
		$modelfields = $this->db->select("select * from `#yunyecms_modelfields`  where modelid={$this->curmodel['modelid']} and language=1 and issys=0 and isadd=1 order by ordernum ");
		$morepicfield = $this->db->find("select * from `#yunyecms_modelfields`  where modelid={$this->curmodel['modelid']} and  issys=1 and fdname='morepic'");
		$membergroup = $this->db->select("select * from `#yunyecms_membergroup` order by ordernum asc");
		$modelfields_all = $this->db->select("select * from `#yunyecms_modelfields`  where modelid={$this->curmodel['modelid']}  and issys=0 ");
		$lang_list = getalllang();
		$langid = $this->lang;
		$langid = intval($langid);
		$nums = count($lang_list);
		foreach ($lang_list as $kk => $vv) {
			$lang_list[$kk]['lang_icon'] = dopic($vv['lang_icon']);
		}
		if (!empty($_REQUEST["id"])) {
			$parnav = '<li class=\"breadcrumb-item\"><a href=\"' . url_admin('init', "category") . '\" target=\"maincontent\">内容</a></li><li class=\"breadcrumb-item\"><a href=\"' . url_admin('lists', 'content', array("catid" => $this->curcat['id'])) . '\" target=\"maincontent\">' . $this->rootcat['title'] . '</a></li><li class=\"breadcrumb-item active\">' . $this->curcat['title'] . '</li>';
			$id = trim($_REQUEST["id"]);
			if (!is_numeric($id)) {
				messagebox("参数必须为数字，谢谢!", $_SERVER['HTTP_REFERER']);
			}
			$id = usafestr($id);
			$catid = $this->curcat['id'];
			$rsinfo = $this->db->find("select * from `#yunyecms_{$tablename}` where `id`= {$id}");
			$catids = $rsinfo["catids"];
			if ($catids) $catids = explode(",", $catids);
			if (empty($rsinfo)) {
				messagebox("该信息不存在，谢谢!", $_SERVER['HTTP_REFERER']);
			} else {
				$syn = $rsinfo['syn'];
			}
			if ($rsinfo['pic']) $rsinfo['pic'] = dopic($rsinfo['pic']);
			//处理自定义字段数据开始
			foreach ($lang_list as $kk => $vv) {
				$lid = $vv['id'];
				$ldef = $vv['isdefault'];
				if ($syn) {
					$rs_shadow[$lid] = $this->db->find("select * from `#yunyecms_{$tablename}` where `syn`= {$syn} and lang={$lid}");
				} else {
					$rs_shadow[$lid] = $this->db->find("select * from `#yunyecms_{$tablename}` where `syn`= {$id} and lang={$lid}");
				}
				if ($rs_shadow[$lid]['pic']) $rs_shadow[$lid]['pic'] = dopic($rs_shadow[$lid]['pic']);
				foreach ($modelfields_all as $key => $var) {
					$ofdname = $var['fdname'];
					$fdname = $var['fdname'] . "_{$lid}";
					$formctrl = $var['formctrl'];
					if ($ldef) {
						if (isset($rsinfo[$ofdname])) {
							if ($formctrl == 'editor') {
								if (!empty($rsinfo[$ofdname])) {
									$rsinfo[$ofdname] = doimgs($rsinfo[$ofdname]);
								} else {
									$rsinfo[$ofdname] = "";
								}
							} elseif ($formctrl == 'img' && !empty($rsinfo[$ofdname])) {
								$rsinfo[$ofdname] = usafepic(dopic($rsinfo[$ofdname]));
							} elseif ($formctrl == 'file' && !empty($rsinfo[$ofdname])) {
								$rsinfo[$ofdname] = usafepic(dopic($rsinfo[$ofdname]));
							} else {
								$rsinfo[$ofdname] = uhtmlspecialchars_decode($rsinfo[$ofdname]);
							}
						}
					}
					if (isset($rs_shadow[$lid][$ofdname])) {
						if ($formctrl == 'editor') {
							if (!empty($rs_shadow[$lid][$ofdname])) {
								$rs_shadow[$lid][$ofdname] = doimgs($rs_shadow[$lid][$ofdname]);
							} else {
								$rs_shadow[$lid][$ofdname] = "";
							}
						} elseif ($formctrl == 'img' && !empty($rs_shadow[$lid][$ofdname])) {
							$rs_shadow[$lid][$ofdname] = usafepic(dopic($rs_shadow[$lid][$ofdname]));
						} elseif ($formctrl == 'file' && !empty($rs_shadow[$lid][$ofdname])) {
							$rs_shadow[$lid][$ofdname] = usafepic(dopic($rs_shadow[$lid][$ofdname]));
						} else {
							$rs_shadow[$lid][$ofdname] = uhtmlspecialchars_decode($rs_shadow[$lid][$ofdname]);
						}
					}
				}
			}
			//处理自定义字段数据结束
			$morepic = $rsinfo["morepic"];
			if (!empty($morepic)) {
				$morepicarr = unserialize($morepic);
				foreach ($morepicarr as $k => $var) {
					$morepicarr[$k] = dopic($var);
				}
				$morepicstr = implode(",", $morepicarr);
			}
			$yyact = "edit";
		} else {
			$yyact = yyact_get("add");
			$parnav = '<li class=\"breadcrumb-item\"><a href=\"' . url_admin('init', "category") . '\" target=\"maincontent\">内容</a></li><li class=\"breadcrumb-item\"><a href=\"' . url_admin('lists', 'content', array("catid" => $this->curcat['id'])) . '\" target=\"maincontent\">' . $this->rootcat['title'] . '</a></li><li class=\"breadcrumb-item active\">' . $this->curcat['title'] . '</li>';
			$catid = $this->curcat['id'];
			if (!getroot('info', 'add')) {
				messagebox(Lan('no_permission_infoadd'), 'back', "warn");
			} else {
				if (!get_cat_power($catid, "add")) {
					messagebox("您没有添加{$this->curcat["title"]}信息的权限", 'back', "warn");
				}
			}
			$strmaxarray = $this->db->find("select max(ordernum) as maxorder  from `#yunyecms_{$tablename}` where `catid`= {$this->curcat['id']}");
			$strmax = $strmaxarray["maxorder"] + 1;
		}

		if (isset($_POST["yyact"])) {
			$catpower = fetch_cat_power();
			$_POST = ustripslashes($_POST);
			if (!empty($_POST['morepic'])) {
				$morepic = $_POST['morepic'];
				$morepicstr = explode(",", $morepic);
				foreach ($morepicstr as $k => $var) {
					$morepicstr[$k] = usafepic(revpic($var));
				}
				$morepicstr = serialize($morepicstr);
				$data["morepic"] = $morepicstr;
			} else {
				$data["morepic"] = "";
			}
			$data["ispower"] = usafestr(trim($_POST["ispower"]));
			$data["catid"] = usafestr(trim($_POST["catid"]));
			if ($_POST["catids"]) {
				$catids_array = TrimArray($_POST["catids"]);
				if ($catids_array) {
					$data["catids"] = implode(",", $catids_array);
				}
			}
			$data["catid"] = usafestr(trim($_POST["catid"]));
			$data["isgood"] = empty($_POST["isgood"]) ? 0 : usafestr(trim($_POST["isgood"]));
			$data["ishead"] = empty($_POST["ishead"]) ? 0 : usafestr(trim($_POST["ishead"]));
			$data["istop"] = empty($_POST["istop"]) ? 0 : usafestr(trim($_POST["istop"]));
			$data["pic"] = usafepic(revpic(trim($_POST["pic"])));
			$data["ordernum"] = usafestr(trim($_POST["ordernum"]));
			$data["status"] = 1;
			foreach ($lang_list as $kk => $vv) {
				$lid = $vv['id'];
				$ldef = $vv['isdefault'];
				if ($ldef == 1) {
					$data["title"] = usafestr(trim($_POST["title_{$lid}"]));
					$data['exlink'] = uhtmlspecialchars(trim($_POST["exlink_{$lid}"]));
					if (uhtmlspecialchars(trim($_POST["picfile_{$lid}"]))) $data["picfile"] = uhtmlspecialchars(trim($_POST["picfile_{$lid}"]));
					$data['seotitle'] = uhtmlspecialchars(trim($_POST["seotitle_{$lid}"]));
					$data['seokeywords'] = uhtmlspecialchars(trim($_POST["seokeywords_{$lid}"]));
					$data['seodesc'] = uhtmlspecialchars(trim($_POST["seodesc_{$lid}"]));
					$data['lang'] = $lid;
					foreach ($modelfields_all as $key => $var) {
						$ofdname = $var['fdname'];
						$fdname = $var['fdname'] . "_{$lid}";
						$formctrl = $var['formctrl'];
						$fdtitle = $var['fdtitle'];
						$isunique = $var['isunique'];
						if (isset($_POST[$fdname])) {
							if ($formctrl == 'editor') {
								if (!empty($_POST[$fdname])) {
									$data[$ofdname] = revimgs($_POST[$fdname]);
								} else {
									$data[$ofdname] = "";
								}
							} elseif ($formctrl == 'img' && !empty($_POST[$fdname])) {
								$data[$ofdname] = usafepic(revpic($_POST[$fdname]));
							} elseif ($formctrl == 'file' && !empty($_POST[$fdname])) {
								$data[$ofdname] = usafepic(revpic($_POST[$fdname]));
							} elseif ($formctrl == 'checkbox') {
								$postfdname = $_POST[$fdname];
								if (!empty($postfdname)) {
									$postfdname = implode(",", $postfdname);
									$data[$ofdname] = $postfdname;
								}
							} else {
								$data[$ofdname] = uhtmlspecialchars($_POST[$fdname]);
							}
						}
					}
				} else {
					//$data_shadow[$lid]["catid"];
					$postcatid = usafestr(trim($_POST["catid"]));
					$psyn = $this->db->getfield('syn', $postcatid, 'category');
					if ($psyn) {
						$catecheck = $this->db->find("select * from `#yunyecms_category` where `syn`= {$psyn} and lang={$lid}");
						if ($catecheck) {
							$data_shadow[$lid]['catid'] = $catecheck["id"];
						} else {
							messagebox("{$vv['title']}栏目不能为空，请先添加栏目!", $_SERVER['HTTP_REFERER']);
						}
					} else {
						messagebox("栏目参数错误，请重新选择!", $_SERVER['HTTP_REFERER']);
					}
					//同步多语言版的关联栏目
					if ($_POST["catids"]) {
						$post_catids = TrimArray($_POST["catids"]);
						foreach ($post_catids as $v) {
							$psyn_item = $this->db->getfield('syn', $v, 'category');
							if ($psyn_item) {
								$catids_item = $this->db->find("select * from `#yunyecms_category` where `syn`= {$psyn_item} and lang={$lid}");
								if ($catids_item) {
									$catids_syn[] = $catids_item["id"];
								} else {
									messagebox("{$vv['title']}关联栏目不能为空，请先添加栏目!", $_SERVER['HTTP_REFERER']);
								}
							}
						}
						if ($catids_syn)  $data_shadow[$lid]['catids'] = implode(",", $catids_syn);
					}
					$data_shadow[$lid]['title'] = uhtmlspecialchars(trim($_POST["title_{$lid}"]));
					$data_shadow[$lid]['exlink'] = uhtmlspecialchars(trim($_POST["exlink_{$lid}"]));
					if (uhtmlspecialchars(trim($_POST["picfile_{$lid}"]))) $data_shadow[$lid]["picfile"] = uhtmlspecialchars(trim($_POST["picfile_{$lid}"]));
					$data_shadow[$lid]['seotitle'] = uhtmlspecialchars(trim($_POST["seotitle_{$lid}"]));
					$data_shadow[$lid]['seokeywords'] = uhtmlspecialchars(trim($_POST["seokeywords_{$lid}"]));
					$data_shadow[$lid]['seodesc'] = uhtmlspecialchars(trim($_POST["seodesc_{$lid}"]));
					$data_shadow[$lid]['lang'] = $lid;
					$data_shadow[$lid]['isgood'] = $data["isgood"];
					$data_shadow[$lid]['ishead'] = $data["ishead"];
					$data_shadow[$lid]['istop'] = $data["istop"];
					$data_shadow[$lid]['pic'] = $data["pic"];
					$data_shadow[$lid]['morepic'] = $data["morepic"];
					$data_shadow[$lid]['ordernum'] = $data["ordernum"];
					$data_shadow[$lid]['status'] = 1;
					$data_shadow[$lid]['ispower'] = $data["ispower"];
					foreach ($modelfields_all as $key => $var) {
						$ofdname = $var['fdname'];
						$fdname = $var['fdname'] . "_{$lid}";
						$formctrl = $var['formctrl'];
						$fdtitle = $var['fdtitle'];
						$isunique = $var['isunique'];
						if (isset($_POST[$fdname])) {
							if ($formctrl == 'editor' && !empty($_POST[$fdname])) {
								if (!empty($_POST[$fdname])) {
									$data_shadow[$lid][$ofdname] = revimgs($_POST[$fdname]);
								} else {
									$data_shadow[$lid][$ofdname] = "";
								}
							} elseif ($formctrl == 'img' && !empty($_POST[$fdname])) {
								$data_shadow[$lid][$ofdname] = usafepic(revpic($_POST[$fdname]));
							} elseif ($formctrl == 'file' && !empty($_POST[$fdname])) {
								$data_shadow[$lid][$ofdname] = usafepic(revpic($_POST[$fdname]));
							} elseif ($formctrl == 'checkbox') {
								$postfdname = $_POST[$fdname];
								if (!empty($postfdname)) {
									$postfdname = implode(",", $postfdname);
									$data_shadow[$lid][$ofdname] = $postfdname;
								}
							} else {
								$data_shadow[$lid][$ofdname] = uhtmlspecialchars($_POST[$fdname]);
							}
						}
					}
				}
			}

			if (empty($data["title"])) {
				messagebox("标题不能为空，谢谢!", $_SERVER['HTTP_REFERER']);
			}
			if (empty($data["catid"])) {
				messagebox("栏目不能为空，请重新选择!", $_SERVER['HTTP_REFERER']);
			}
			if (!is_numeric($data["catid"])) {
				messagebox("栏目参数错误，请重新选择!", $_SERVER['HTTP_REFERER']);
			}
			$catid = $data["catid"];
			if ($_POST["yyact"] == "add") {
				$data["addtime"] = time();
				$data["status"] = 1;
				$data["admin_userid"] = $this->admuser["userid"];
				//计算记录编号  
				$data["number"] = create_number($tablename, $this->lang);
				//$this->db->Autocommit_start();
				$insertid = $this->db->insert($data, $tablename, true);
				if ($insertid) {
					//同步新增其他语言版记录
					$syndata['syn'] = $insertid;
					$retsyn = $this->db->update($syndata, array('id' => $insertid), $tablename);
					if ($retsyn) {
						foreach ($lang_list as $kk => $vv) {
							$lid = $vv['id'];
							$ldef = $vv['isdefault'];
							$data_shadow[$lid]['syn'] = $insertid;
							$data_shadow[$lid]["addtime"] = time();
							$data_shadow[$lid]["admin_userid"] = $this->admuser["userid"];
							$data_shadow[$lid]["number"] = $data["number"];;
							if ($ldef != 1) {
								$retsynadd[$lid] = $this->db->insert($data_shadow[$lid], $tablename);
							}
						}
						//$this->db->Autocommit_commit(); 
					} else {
						$this->db->Autocommit_rollback();
					}
					$doing = "添加{$this->curcat['title']}信息—" . $data["title"];
					$yyact = "addinfolist";
					insert_admlogs($doing, $yyact);
					messagebox("添加{$this->curcat['title']}信息成功！", url_admin('lists', 'content', array('catid' => $catid)), "success");
				} else {
					messagebox("添加{$this->curcat['title']}信息失败！", url_admin('lists', 'content', array('catid' => $catid)), "error");
				}
			}
			if ($_POST["yyact"] == "edit") {
				if (!getroot('info', 'edit')) {
					messagebox(Lan('no_permission_infoedit'), 'back', "warn");
				} else {
					if (!get_cat_power($data["catid"], "edit")) {
						messagebox("您没有编辑{$this->curcat["title"]}信息的权限", 'back', "warn");
					}
				}
				$id = $_POST["id"];
				$data["addtime"] = strtotime(trim($_POST["addtime"]));
				if (!$this->check_exist($id)) {
					messagebox("该内容不存在！", url_admin('init'), "warn");
				}
				$crow = $this->db->find("select * from `#yunyecms_{$tablename}`  where `id`= {$id}");

				$retres = $this->db->update($data, "id={$id}", $tablename);
				if ($retres) {
					//同步更新其他语言版
					foreach ($lang_list as $kk => $vv) {
						$lid = $vv['id'];
						$ldef = $vv['isdefault'];
						$rs_check = $this->db->GetCount("select count(*) from `#yunyecms_{$tablename}` where `syn`= {$crow['syn']} and lang={$lid}");
						if ($rs_check) {
							$data_shadow[$lid]["addtime"] = $data["addtime"];
							$retsynadd[$lid] = $this->db->update($data_shadow[$lid], array("syn" => $id, "lang" => $lid), $tablename);
						} else {
							$data_shadow[$lid]['syn'] = $crow['syn'];
							$data_shadow[$lid]['number'] = create_number($tablename, $this->lang);
							$data_shadow[$lid]["addtime"] = $crow['addtime'];
							$data_shadow[$lid]["updatetime"] = $crow['updatetime'];
							$data_shadow[$lid]["admin_userid"] = $this->admuser["userid"];
							$retsynadd[$lid] = $this->db->insert($data_shadow[$lid], $tablename, true);
						}
					}

					$doing = "更新{$this->curcat['title']}信息—" . $data["title"];
					$yyact = "updateinfolist";
					insert_admlogs($doing, $yyact);
					messagebox("更新{$this->curcat['title']}信息成功！", url_admin('lists', 'content', array('catid' => $catid)), "success");
				} else {
					messagebox("更新{$this->curcat['title']}信息失败！", url_admin('lists', 'content', array('catid' => $catid)), "error");
				}
			}
		}
		require tpl_adm('infolist_add');
	}

	//复制信息2020-10-06	
	public function infolist_copy()
	{
		$tablename = "m_" . $this->curmodel['tablename'];
		$lang_list = getalllang();
		$langid = $this->lang;
		$langid = intval($langid);
		if (!empty($_REQUEST["id"])) {
			$id = trim($_REQUEST["id"]);
			if (!is_numeric($id)) {
				messagebox("参数必须为数字，谢谢!", $_SERVER['HTTP_REFERER']);
			}
			$id = usafestr($id);
			$catid = $this->curcat['id'];
			$rsinfo = $this->db->find("select * from `#yunyecms_{$tablename}` where `id`= {$id}");
			if (empty($rsinfo)) {
				messagebox("该信息不存在，谢谢!", $_SERVER['HTTP_REFERER']);
			} else {
				$syn = $rsinfo['syn'];
			}
			$synid = 0;
			$retids = array();
			foreach ($lang_list as $kk => $vv) {
				$lid = $vv['id'];
				if ($syn) {
					$rs_shadow[$lid] = $this->db->find("select * from `#yunyecms_{$tablename}` where `syn`= {$syn} and lang={$lid}");
				} else {
					$rs_shadow[$lid] = $this->db->find("select * from `#yunyecms_{$tablename}` where `syn`= {$id} and lang={$lid}");
				}
				unset($rs_shadow[$lid]['id']);
				$retids[$lid] = $this->db->insert($rs_shadow[$lid], $tablename, true);
				if ($vv['isdefault']) {
					$synid = $retids[$lid];
				}
			}
			if ($retids) {
				$curtime = time();
				foreach ($retids as $key => $var) {
					$rsinfo = $this->db->find("select * from `#yunyecms_{$tablename}` where `id`= '{$var}' and lang='{$key}'");
					$data[$key]['number'] = create_number($tablename, $this->lang);
					//$data[$key]['title']=$rsinfo['title'].'_'.$data[$key]['number'];
					//$data[$key]['seotitle']=$rsinfo['seotitle'].'_'.$data[$key]['number'];
					$data[$key]['addtime'] = $curtime;
					$data[$key]['updatetime'] = $curtime;
					$data[$key]['syn'] = $synid;
					$retsynadd[$key] = $this->db->update($data[$key], array("id" => $var, "lang" => $key), $tablename);
				}
				if ($retsynadd) {
					messagebox("复制{$this->curcat['title']}信息成功！", url_admin('lists', 'content', array('catid' => $catid)), "success");
				} else {
					messagebox("复制{$this->curcat['title']}信息失败！", url_admin('lists', 'content', array('catid' => $catid)), "error");
				}
			} else {
				messagebox("复制{$this->curcat['title']}信息失败！", url_admin('lists', 'content', array('catid' => $catid)), "error");
			}
		}
	}

	public function singlepage()
	{
		if (!empty($_REQUEST["id"]) || !empty($_REQUEST["catid"])) {
			$tablename = "m_" . $this->curmodel['tablename'];
			$modelfields = $this->db->select("select * from `#yunyecms_modelfields`  where modelid={$this->curmodel['modelid']}  and issys=0 ");
			$lang_list = getalllang();
			foreach ($lang_list as $kk => $vv) {
				$lang_list[$kk]['lang_icon'] = dopic($vv['lang_icon']);
			}
			$langid = intval($this->lang);
			$nums = count($lang_list);
			$parnav = '<li class=\"breadcrumb-item\"><a href=\"' . url_admin('init', "category") . '\" target=\"maincontent\">内容</a></li><li class=\"breadcrumb-item\"><a href=\"' . url_admin('lists', 'content', array("catid" => $this->curcat['id'])) . '\" target=\"maincontent\">' . $this->rootcat['title'] . '</a></li><li class=\"breadcrumb-item active\">' . $this->curcat['title'] . '</li>';
			$catid = $_REQUEST['catid'];
			$id = trim($catid);
			if (!is_numeric($id)) {
				messagebox("参数必须为数字！");
			}
			$id = usafestr(trim($id));
			$catid = usafestr(trim($catid));
			$rscat = $this->db->find("select * from `#yunyecms_category` where `id`= {$id}");
			if (empty($rscat)) {
				messagebox("栏目不存在！");
			} else {
				$syn = $rscat['syn'];
			}
			foreach ($lang_list as $kk => $vv) {
				$lid = $vv['id'];
				$ldef = $vv['isdefault'];
				$psyn = $this->curcat['syn'];
				if ($psyn) {
					$catecheck = $this->db->find("select * from `#yunyecms_category` where `syn`= {$psyn} and lang={$lid}");
					if ($catecheck) {
						$data_up[$lid]['catid'] = $catecheck["id"];
					} else {
						messagebox("{$vv['title']}栏目不能为空，请先添加栏目!", 'back');
					}
				} else {
					messagebox("栏目参数错误，请重新选择!", $_SERVER['HTTP_REFERER'], 'info');
				}
				$check = $this->db->GetCount("select count(*) from `#yunyecms_{$tablename}`  where syn={$this->curcat['syn']}  and lang=$lid");
				if ($check <= 0) {
					$data_up[$lid]['id'] = $catecheck["id"];
					$data_up[$lid]['title'] = $catecheck['title'];
					$data_up[$lid]['seotitle'] = $catecheck['title'];
					$data_up[$lid]['seokeywords'] = $catecheck['keywords'];
					$data_up[$lid]['seodesc'] = $catecheck['description'];
					$data_up[$lid]['syn'] = $this->curcat['syn'];
					$data_up[$lid]['lang'] = $lid;
					$retres = $this->db->insert($data_up[$lid], $tablename);
				}
				if ($syn) {
					$rs_shadow[$lid] = $this->db->find("select * from `#yunyecms_{$tablename}` where `syn`= {$syn} and lang={$lid}");
				} else {
					$rs_shadow[$lid] = $this->db->find("select * from `#yunyecms_{$tablename}` where `syn`= {$id} and lang={$lid}");
				}
				$rs_shadow[$lid]['content'] = doimgs($rs_shadow[$lid]['content']);
				$rs_shadow[$lid]['pic'] = dopic($rs_shadow[$lid]['pic']);
			}
			$rsinfo = $rs_shadow[$langid];

			if (!getroot('info', 'view')) {
				messagebox(Lan('no_permission_infoview'), 'back', "warn");
			} else {
				if (!get_cat_power($catid, "view")) {
					messagebox("您没有管理{$this->curcat["title"]}信息的权限", 'back', "warn");
				}
			}


			$yyact = "edit";
		} else {
			messagebox("栏目参数错误，请重新选择!");
		}

		if (isset($_POST["yyact"])) {
			$modelfields_all = $this->db->select("select * from `#yunyecms_modelfields`  where modelid={$this->curmodel['modelid']}  and issys=0 ");
			$_POST = ustripslashes($_POST);
			$data["catid"] = usafestr(trim($_POST["catid"]));
			$data["pic"] = usafepic(revpic(trim($_POST["pic"])));
			foreach ($lang_list as $kk => $vv) {
				$lid = $vv['id'];
				$ldef = $vv['isdefault'];
				if ($ldef == 1) {
					$data["title"] = usafestr(trim($_POST["title_{$lid}"]));
					$data['summary'] = uhtmlspecialchars(trim($_POST["summary_{$lid}"]));
					$data['seotitle'] = uhtmlspecialchars(trim($_POST["seotitle_{$lid}"]));
					$data['seokeywords'] = uhtmlspecialchars(trim($_POST["seokeywords_{$lid}"]));
					$data['seodesc'] = uhtmlspecialchars(trim($_POST["seodesc_{$lid}"]));
					$data['lang'] = $lid;
					if (isset($_POST["content_{$lid}"])) {
						$data["content"] = revimgs(trim($_POST["content_{$lid}"]));
					}
					foreach ($modelfields_all as $key => $var) {
						$ofdname = $var['fdname'];
						$fdname = $var['fdname'] . "_{$lid}";
						$formctrl = $var['formctrl'];
						$fdtitle = $var['fdtitle'];
						$isunique = $var['isunique'];
						if (isset($_POST[$fdname]) && !empty($_POST[$fdname])) {
							$data[$ofdname] = uhtmlspecialchars($_POST[$fdname]);
						}
						if ($formctrl == 'checkbox') {
							$postfdname = $_POST[$fdname];
							if (!empty($postfdname)) {
								$postfdname = implode(",", $postfdname);
								$data[$ofdname] = $postfdname;
							}
						}
					}
				} else {
					$postcatid = usafestr(trim($_POST["catid"]));
					$psyn = $this->db->getfield('syn', $postcatid, 'category');
					if ($psyn) {
						$catecheck = $this->db->find("select * from `#yunyecms_category` where `syn`= {$psyn} and lang={$lid}");
						if ($catecheck) {
							$data_shadow[$lid]['catid'] = $catecheck["id"];
						} else {
							messagebox("{$vv['title']}栏目不能为空，请先添加栏目!", $_SERVER['HTTP_REFERER']);
						}
					} else {
						messagebox("栏目参数错误，请重新选择!", $_SERVER['HTTP_REFERER']);
					}
					$data_shadow[$lid]['title'] = uhtmlspecialchars(trim($_POST["title_{$lid}"]));
					$data_shadow[$lid]['summary'] = uhtmlspecialchars(trim($_POST["summary_{$lid}"]));
					$data_shadow[$lid]['seotitle'] = uhtmlspecialchars(trim($_POST["seotitle_{$lid}"]));
					$data_shadow[$lid]['seokeywords'] = uhtmlspecialchars(trim($_POST["seokeywords_{$lid}"]));
					$data_shadow[$lid]['seodesc'] = uhtmlspecialchars(trim($_POST["seodesc_{$lid}"]));
					$data_shadow[$lid]['lang'] = $lid;
					$data_shadow[$lid]['pic'] = $data["pic"];
					if (isset($_POST["content_{$lid}"])) {
						$data_shadow[$lid]["content"] = revimgs(trim($_POST["content_{$lid}"]));
					}
					foreach ($modelfields_all as $key => $var) {
						$ofdname = $var['fdname'];
						$fdname = $var['fdname'] . "_{$lid}";
						$formctrl = $var['formctrl'];
						$fdtitle = $var['fdtitle'];
						$isunique = $var['isunique'];
						if (isset($_POST[$fdname]) && !empty($_POST[$fdname])) {
							$data_shadow[$lid][$ofdname] = uhtmlspecialchars($_POST[$fdname]);
						}
						if ($formctrl == 'checkbox') {
							$postfdname = $_POST[$fdname];
							if (!empty($postfdname)) {
								$postfdname = implode(",", $postfdname);
								$data_shadow[$lid][$ofdname] = $postfdname;
							}
						}
					}
				}
			}

			if (empty($data["title"])) {
				messagebox("标题不能为空，谢谢!", $_SERVER['HTTP_REFERER']);
			}
			if (empty($data["catid"])) {
				messagebox("栏目不能为空，请重新选择!", $_SERVER['HTTP_REFERER']);
			}
			if (!is_numeric($data["catid"])) {
				messagebox("栏目参数错误，请重新选择!", $_SERVER['HTTP_REFERER']);
			}
			$catid = $data["catid"];
			if (!getroot('info', 'edit')) {
				messagebox(Lan('no_permission_infoedit'), 'back', "warn");
			} else {
				if (!get_cat_power($catid, "edit")) {
					messagebox("您没有编辑{$this->curcat["title"]}信息的权限", 'back', "warn");
				}
			}
			if ($_POST["yyact"] == "edit") {
				$id = $_POST["id"];
				if (!$this->check_exist($id)) {
					messagebox("该内容不存在！");
				}
				$retres = $this->db->update($data, "id={$id}", $tablename);
				$crow = $this->db->find("select * from `#yunyecms_{$tablename}`  where `id`= {$id}");
				if ($retres) {
					//同步更新其他语言版
					foreach ($lang_list as $kk => $vv) {
						$lid = $vv['id'];
						$ldef = $vv['isdefault'];
						$rs_check = $this->db->GetCount("select count(*) from `#yunyecms_{$tablename}` where `syn`= {$crow['syn']} and lang={$lid}");
						if ($rs_check) {
							$data_shadow[$lid]["addtime"] = time();
							$data_shadow[$lid]['number'] = create_number($tablename, $this->lang);
							$retsynadd[$lid] = $this->db->update($data_shadow[$lid], array("syn" => $crow['syn'], "lang" => $lid), $tablename);
						} else {
							$data_shadow[$lid]['syn'] = $crow['syn'];
							$data_shadow[$lid]['number'] = create_number($tablename, $this->lang);
							$data_shadow[$lid]["addtime"] = $crow['addtime'];
							$retsynadd[$lid] = $this->db->insert($data_shadow[$lid], $tablename, true);
						}
					}

					$doing = "更新{$this->curcat['title']}信息—" . $data["title"];
					$yyact = "updatesinglepage";
					insert_admlogs($doing, $yyact);
					messagebox("更新{$this->curcat['title']}信息成功！", url_admin('singlepage', 'content', array('catid' => $catid)), "success");
				} else {
					messagebox("更新{$this->curcat['title']}信息失败！", url_admin('singlepage', 'content', array('catid' => $catid)), "error");
				}
			}
		}

		require tpl_adm('singlepage');
	}

	//加载首页
	public function customform()
	{
		if (!getroot('info', 'view')) {
			messagebox(Lan('no_permission_infoview'), 'back', "warn");
		} else {
			$catpower = fetch_cat_power();
			if (!empty($catpower)) {
				$catpwerid = get_power_catid($catpower);
			}
		}
		$tablename = "m_" . $this->curmodel['tablename'];
		$parnav = '<li class=\"breadcrumb-item\"><a href=\"' . url_admin('init', "category") . '\" target=\"maincontent\">内容</a></li><li class=\"breadcrumb-item\"><a href=\"' . url_admin('lists', 'content', array("catid" => $this->curcat['id'])) . '\" target=\"maincontent\">' . $this->rootcat['title'] . '</a></li><li class=\"breadcrumb-item active\">' . $this->curcat['title'] . '</li>';
		if (!getroot('users', 'logs')) {
			messagebox(Lan('no_permission'), 'back', "warn");
		}
		$modelfields = $this->db->select("select * from `#yunyecms_modelfields`  where modelid={$this->curmodel['modelid']}  and isdisplay=1 ");
		$pagesize = 20;
		$sqlquery = "select * from `#yunyecms_{$tablename}`  ";
		$where = " where 1=1  ";
		$sqlcnt = " select count(*) from `#yunyecms_{$tablename}` ";
		$order = " order by `addtime` desc ";
		if (isset($_REQUEST)) {
			if (!empty($_REQUEST["searchkey"])) {
				$searchkey = usafestr(trim($_REQUEST["searchkey"]));
				$where = $where . " and ( `title`  like '%{$searchkey}%'  )";
			}
		}
		if (!empty($_REQUEST['catid'])) {
			$catid = trim($_REQUEST['catid']);
			if (!is_numeric($catid)) {
				messagebox("错误的参数", "back", 'warn');
			}
			$catid = usafestr($catid);
			$subcat = get_cat_child($catid);
			$catidstr = implode(',', $subcat);
			$newcat = array_intersect($subcat, $catpwerid);
			$messagetip = "暂时没有{$this->curcat["title"]}信息";
			if (!empty($catpwerid)) {
				if (empty($newcat)) {
					messagebox("您没有管理{$this->curcat["title"]}信息的权限", 'back', "warn");
				} else {
					$catidstr = implode(',', $newcat);
					$where = $where . " and catid in($catidstr)";
				}
			} else {
				$where = $where . " and catid in($catidstr)";
			}
		}

		$pagearr = $this->db->pagelist($sqlcnt, $sqlquery, $where, $order, $pagesize);
		if ($pagearr["count"] != 0) {
			$list = $pagearr["query"];
			foreach ($list as $key => $var) {
				$modelarr = $this->db->find("select modelid  from `#yunyecms_category` where `id`= {$var['catid']}");
				if ($modelarr) {
					$list[$key]["modelid"] = $modelarr["modelid"];
					if (!empty($var["userid"])) {
						$list[$key]["user"] = $this->db->getbyid($var["userid"], "member");
					}
				}
			}
			$pages = $pagearr["page"];
		}
		require tpl_adm('customform');
	}


	public function customform_add()
	{
		$tablename = "m_" . $this->curmodel['tablename'];
		$modelfields = $this->db->select("select * from `#yunyecms_modelfields`  where modelid={$this->curmodel['modelid']}  and isadd=1 ");
		if (!empty($_REQUEST["id"])) {
			$parnav = '<li class=\"breadcrumb-item\"><a href=\"' . url_admin('init', "category") . '\" target=\"maincontent\">内容</a></li><li class=\"breadcrumb-item\"><a href=\"' . url_admin('lists', 'content') . '\" target=\"maincontent\">' . $this->rootcat['title'] . '</a></li><li class=\"breadcrumb-item active\">' . $this->curcat['title'] . '</li>';
			$id = trim($_REQUEST["id"]);
			if (!is_numeric($id)) {
				messagebox("参数必须为数字，谢谢!", $_SERVER['HTTP_REFERER']);
			}
			$id = usafestr(trim($id));
			$rsinfo = $this->db->find("select * from `#yunyecms_{$tablename}` where `id`= {$id}");
			if (empty($rsinfo)) {
				messagebox("栏目不存在", $_SERVER['HTTP_REFERER']);
			}
			$catid = $this->curcat['id'];
			$yyact = "edit";
		} else {
			$yyact = yyact_get("add");
			$parnav = '<li class=\"breadcrumb-item\"><a href=\"' . url_admin('init', "category") . '\" target=\"maincontent\">内容</a></li><li class=\"breadcrumb-item\"><a href=\"' . url_admin('lists', 'content') . '\" target=\"maincontent\">' . $this->rootcat['title'] . '</a></li><li class=\"breadcrumb-item active\">' . $this->curcat['title'] . '</li>';

			$catid = $this->curcat['id'];

			if (!getroot('info', 'add')) {
				messagebox(Lan('no_permission_infoadd'), 'back', "warn");
			} else {
				if (!get_cat_power($catid, "add")) {
					messagebox("您没有添加{$this->curcat["title"]}信息的权限", 'back', "warn");
				}
			}
		}

		if (isset($_POST["yyact"])) {
			$_POST = ustripslashes($_POST);
			$data["catid"] = usafestr(trim($_POST["catid"]));
			$data["addtime"] = time();
			$data["status"] = 1;
			foreach ($modelfields as $key => $var) {
				$fdname = $var['fdname'];
				if (isset($_POST[$fdname])) {
					$data[$fdname] = uhtmlspecialchars(trim($_POST[$fdname]));
				}
			}
			if (empty($data["title"])) {
				messagebox("标题不能为空，谢谢!");
			}
			if (empty($data["catid"])) {
				messagebox("栏目不能为空，请重新选择!");
			}
			if (!is_numeric($data["catid"])) {
				messagebox("栏目参数错误，请重新选择!");
			}
			$catid = $data["catid"];
			if ($_POST["yyact"] == "add") {
				$data["admin_userid"] = $this->admuser["userid"];
				$retres = $this->db->insert($data, $tablename);
				if ($retres) {
					$doing = "添加{$this->curcat['title']}信息——" . $data["title"];
					$yyact = "addcustomform";
					insert_admlogs($doing, $yyact);
					messagebox("添加{$this->curcat['title']}信息成功！", url_admin('customform', 'content', array('catid' => $catid)), "success");
				} else {
					messagebox("添加{$this->curcat['title']}信息失败！", url_admin('customform', 'content', array('catid' => $catid)), "error");
				}
			}
			if ($_POST["yyact"] == "edit") {

				if (!getroot('info', 'edit')) {
					messagebox(Lan('no_permission_infoedit'), 'back', "warn");
				} else {
					if (!get_cat_power($catid, "edit")) {
						messagebox("您没有编辑{$this->curcat["title"]}信息的权限", 'back', "warn");
					}
				}

				$id = $_POST["id"];
				if (!$this->check_exist($id)) {
					messagebox("该内容不存在！", 'back', "warn");
				}
				$retres = $this->db->update($data, "id={$id}", $tablename);
				if ($retres) {
					$doing = "更新{$this->curcat['title']}信息——" . $data["title"];
					$yyact = "updatecustomform";
					insert_admlogs($doing, $yyact);
					messagebox("更新{$this->curcat['title']}信息成功！", url_admin('customform', 'content', array('catid' => $catid)), "success");
				} else {
					messagebox("更新{$this->curcat['title']}信息失败！", url_admin('customform', 'content', array('catid' => $catid)), "error");
				}
			}
		}
		require tpl_adm('customform_add');
	}


	public function customform_view()
	{
		$tablename = "m_" . $this->curmodel['tablename'];
		$modelfields = $this->db->select("select * from `#yunyecms_modelfields`  where modelid={$this->curmodel['modelid']}  and isadd=1 ");
		if (!empty($_REQUEST["id"])) {
			$parnav = '<li class=\"breadcrumb-item\"><a href=\"' . url_admin('init', "category") . '\" target=\"maincontent\">内容</a></li><li class=\"breadcrumb-item\"><a href=\"' . url_admin('lists', 'content') . '\" target=\"maincontent\">' . $this->rootcat['title'] . '</a></li><li class=\"breadcrumb-item active\">' . $this->curcat['title'] . '</li>';
			$id = trim($_REQUEST["id"]);
			if (!is_numeric($id)) {
				messagebox("参数必须为数字，谢谢!", $_SERVER['HTTP_REFERER']);
			}
			$id = usafestr($id);
			$rsinfo = $this->db->find("select * from `#yunyecms_{$tablename}` where `id`= {$id}");
			if (empty($rsinfo)) {
				messagebox("栏目不存在", $_SERVER['HTTP_REFERER']);
			} else {
				$strsql = "update `#yunyecms_{$tablename}` set isview=1 where id=" . $id . "";
				$this->db->query($strsql);
			}
			$catid = $this->curcat['id'];
			if (!getroot('info', 'view')) {
				messagebox(Lan('no_permission_infoview'), 'back', "warn");
			} else {
				if (!get_cat_power($catid, "view")) {
					messagebox("您没有查看{$this->curcat["title"]}信息的权限", 'back', "warn");
				}
			}
		}
		require tpl_adm('customform_view');
	}

	public function finaldelete()
	{
		$tablename = "m_" . $this->curmodel['tablename'];
		$catid = $this->curcat["id"];
		if (!getroot('info', 'del')) {
			messagebox(Lan('no_permission_infodel'), 'back', "warn");
		} else {
			if (!get_cat_power($catid, "del")) {
				messagebox("您没有删除{$this->curcat["title"]}信息的权限", 'back', "warn");
			}
		}
		$id = $_REQUEST["id"];
		if (!is_array($id)) {
			$id = compact('id');
		}
		$idarray = $id;
		foreach ($idarray as $key => $var) {
			if (!is_numeric($var)) {
				messagebox("错误的参数！", 'back', "warn");
			}
			$var = usafestr($var);
			$curmodelnr = $this->db->find("select * from `#yunyecms_{$tablename}` where `id`= {$var}");
			$syn = $curmodelnr["syn"];
			if ($curmodelnr) {
				$thumb = $curmodelnr["pic"];
				if (!empty($curmodelnr["content"])) {
					$ct_content = uhtmlspecialchars_decode($curmodelnr["content"]);
					$ct_content_img = getcontentimg($ct_content);
					if (!empty($thumb)) {
						file_delete($thumb);
					}
					foreach ($ct_content_img as $key3 => $var3) {
						file_delete($var3);
					}
				}
			}
			$retres = $this->db->delete("syn = $syn", $tablename);
		}
		if (isset($idarray)) {
			if ($retres !== false) {
				$yyact = "infolistdel";
				$logcontent['tablename'] = $this->curmodel['tablename'];
				$logcontent['action'] = $yyact;
				$logcontent['ids'] = serialize($id);
				$logcontent = serialize($logcontent);
				$doing = "删除{$this->curcat['title']}信息：{$idarray} ";
				insert_admlogs($doing, $yyact, $logcontent);
				messagebox(Lan('admin_delete_success'), $_SERVER['HTTP_REFERER'], "success");
			} else {
				messagebox(Lan('admin_delete_error'), $_SERVER['HTTP_REFERER'], "warn");
			}
		} else {
			messagebox(Lan('admin_delete_error'), $_SERVER['HTTP_REFERER'], "warn");
		}
	}


	public function customformdelete()
	{
		$tablename = "m_" . $this->curmodel['tablename'];

		$catid = $this->curcat["id"];
		if (!getroot('info', 'del')) {
			messagebox(Lan('no_permission_infodel'), 'back', "warn");
		} else {
			if (!get_cat_power($catid, "del")) {
				messagebox("您没有删除{$this->curcat["title"]}信息的权限", 'back', "warn");
			}
		}

		$id = $_REQUEST["id"];
		if (!is_array($id)) {
			$id = compact('id');
		}
		$idarray = $id;
		if (isset($idarray)) {
			foreach ($idarray as $key => $var) {
				if (!is_numeric($var)) {
					messagebox("错误的参数！", 'back', "warn");
				}
				$idarray[$key] = usafestr($var);
			}
			$idarray = implode(",", $idarray);
			$retres = $this->db->delete("id in ({$idarray})", $tablename);
			if ($retres !== false) {
				$yyact = "customformdel";
				$logcontent['tablename'] = $this->curmodel['tablename'];
				$logcontent['action'] = $yyact;
				$logcontent['ids'] = serialize($id);
				$logcontent = serialize($logcontent);
				$doing = "删除{$this->curcat['title']}信息：{$idarray} ";
				insert_admlogs($doing, $yyact, $logcontent);
				messagebox(Lan('admin_delete_success'), $_SERVER['HTTP_REFERER'], "success");
			} else {
				messagebox(Lan('admin_delete_error'), $_SERVER['HTTP_REFERER'], "warn");
			}
		} else {
			messagebox(Lan('admin_delete_error'), $_SERVER['HTTP_REFERER'], "warn");
		}
	}


	public function check()
	{
		if (!getroot('info', 'verify')) {
			messagebox(Lan('no_permission_infoverify'), 'back', "warn");
		}
		$tablename = "m_" . $this->curmodel['tablename'];
		parent::infocheck($tablename, $this->db);
	}

	public function nocheck()
	{
		if (!getroot('info', 'verify')) {
			messagebox(Lan('no_permission_infoverify'), 'back', "warn");
		}
		$tablename = "m_" . $this->curmodel['tablename'];
		parent::infonocheck($tablename, $this->db);
	}

	private function check_exist($id)
	{
		$tablename = "m_" . $this->curmodel['tablename'];
		$id = trim($id);
		if (empty($id)) {
			return false;
		} else {
			if (!is_numeric($id)) {
				return false;
			}
			if ($this->db->find("select count(*) as cnt from `#yunyecms_{$tablename}` where `id`= {$id}")) {
				return true;
			}
		}
	}
}
