⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 special.class.php

📁 Phpcms2008 是一款基于 PHP+Mysql 架构的网站内容管理系统
💻 PHP
字号:
<?php
class special
{
	var $db;
	var $pages;
	var $number;
	var $table;
    var $contentpages;

    function __construct()
    {
		global $db,$M;
		$this->db = &$db;
		$this->table = DB_PRE.'special';
        $this->table_content = DB_PRE.'content';
        $this->table_special_content = DB_PRE.'special_content';
		$this->M = $M;
		$this->url = load('url.class.php', 'special', 'include');
    }

	function special()
	{
		$this->__construct();
	}

	function get($specialid)
	{
		$specialid = intval($specialid);
		if($specialid < 1) return false;
		return $this->db->get_one("SELECT * FROM $this->table WHERE specialid=$specialid");
	}

	function add($info)
	{
		global $_userid,$_username;
		if(!is_array($info) || empty($info['title'])) return false;
		$info['url'] = $this->M['url'].$this->url->show($specialid, $info['filename'], $info['typeid']);
        $info['createtime'] = TIME;
        $info['userid'] = $_userid;
        $info['username'] = $_username;
		$this->db->insert($this->table, $info);
		$specialid = $this->db->insert_id();
		return $specialid;
	}

	function edit($specialid, $info)
	{
		if(!$specialid || !is_array($info) || empty($info['title'])) return false;
		$info['url'] = $this->M['url'].$this->url->show($specialid, $info['filename'], $info['typeid']);
		return $this->db->update($this->table, $info, "specialid=$specialid");
	}

	function delete($specialid)
	{
		$specialid = intval($specialid);
		return $this->db->query("DELETE FROM $this->table WHERE specialid=$specialid");
	}

	function listinfo($where = '', $order = '', $page = 1, $pagesize = 50)
	{
		if($where) $where = " WHERE $where";
		if($order) $order = " ORDER BY $order";
		$page = max(intval($page), 1);
        $offset = $pagesize*($page-1);
        $limit = " LIMIT $offset, $pagesize";
		$r = $this->db->get_one("SELECT count(*) as number FROM $this->table $where");
        $number = $r['number'];
        $this->pages = pages($number, $page, $pagesize);
		$array = array();
		$result = $this->db->query("SELECT * FROM $this->table $where $order $limit");
		while($r = $this->db->fetch_array($result))
		{
			$array[] = $r;
		}
		$this->number = $this->db->num_rows($result);
        $this->db->free_result($result);
		return $array;
	}

    function select_content($contentid, $specialid)
    {
        $specialid = intval($specialid);
        if(is_array($contentid))
		{
			$contentid = array_map('intval', $contentid);
			foreach($contentid AS $id)
			{
				$this->db->query("INSERT INTO `$this->table_special_content` (`specialid`, `contentid`) VALUES($specialid, $id)");
			}
		}
		else
		{
			$this->db->query("INSERT INTO `$this->table_special_content` (`specialid`, `contentid`) VALUES($specialid, $contentid)");
		}
        return true;
    }

    function list_content($specialid, $page = 1, $pagesize = 50)
	{
		$page = max(intval($page), 1);
        $offset = $pagesize*($page-1);
        $limit = " LIMIT $offset, $pagesize";
		$r = $this->db->get_one("SELECT count(*) as number FROM `$this->table_special_content` AS a ,`$this->table_content` AS b WHERE a.contentid = b.contentid AND specialid = $specialid");
        $number = $r['number'];
        $this->contentpages = pages($number, $page, $pagesize);
		return $this->db->select("SELECT * FROM `$this->table_special_content` AS a ,`$this->table_content` AS b WHERE a.contentid=b.contentid AND a.specialid=$specialid ORDER BY a.contentid $limit");
	}

    function del_content($specialid, $contentid)
	{
		$specialid = intval($specialid);
        if(is_array($contentid)) $contentid = array_map('intval', $contentid);
        $contentids = implodeids($contentid);
		return $this->db->query("DELETE FROM `$this->table_special_content` WHERE specialid=$specialid AND `contentid` IN($contentids)");
	}

	function exists_content($specialid, $contentid)
	{
		$specialid = intval($specialid);
		$contentid = intval($contentid);
		return $this->db->get_one("SELECT `specialid` FROM `$this->table_special_content` WHERE `specialid`=$specialid AND `contentid`=$contentid");
	}

	function listorder($info)
	{
		if(!is_array($info)) return false;
		foreach($info as $id=>$listorder)
		{
			$id = intval($id);
			$listorder = intval($listorder);
			$this->db->query("UPDATE $this->table SET listorder=$listorder WHERE `specialid`=$id");
		}
		return true;
	}

	function elite($specialid, $value)
	{
		$specialid = intval($specialid);
		$value = $value == 1 ? 1: 0;
		return $this->db->query("UPDATE `$this->table` SET `elite`='$value' WHERE `specialid`=$specialid");
	}

	function disable($specialid, $value)
	{
		$specialid = intval($specialid);
		$value = $value == 1 ? 1: 0;
		return $this->db->query("UPDATE `$this->table` SET `disabled`='$value' WHERE `specialid`=$specialid");
	}
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -