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

📄 picture.php

📁 phpcms网站管理系统  很不错的 有需要的就下载看看八 
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php
/*
*######################################
* PHPCMS v3.00 - Advanced Content Manage System.
* Copyright (c) 2004-2005 phpcms.cn
*
* For further information go to http://www.phpcms.cn/
* This copyright notice MUST stay intact for use.
*######################################
*/
defined('IN_PHPCMS') or exit('Access Denied');

$channelid = intval($channelid);
if(!$channelid) showmessage('非法参数!请返回!',$referer);

$submenu=array(
	array('<font color="red">添加图片</font>','?mod='.$mod.'&file='.$file.'&action=add&channelid='.$channelid),
	array('审核图片','?mod='.$mod.'&file='.$file.'&action=check&status=1&channelid='.$channelid),
	array('<font color="red">管理图片</font>','?mod='.$mod.'&file='.$file.'&action=manage&channelid='.$channelid),
	array('我添加的图片','?mod='.$mod.'&file='.$file.'&action=myitem&channelid='.$channelid),
	array('<font color="red">管理专题图片</font>','?mod='.$mod.'&file='.$file.'&action=special&channelid='.$channelid),
	array('批量移动图片','?mod='.$mod.'&file='.$file.'&action=move&channelid='.$channelid),
	array('回收站管理','?mod='.$mod.'&file='.$file.'&action=recycle&channelid='.$channelid)
);
$menu=adminmenu('图片管理',$submenu);

$referer = $referer ? $referer : $PHP_REFERER;

$pagesize=$_PHPCMS['pagesize'];

$tree = new tree;

$cat_option = cat_option($catid);

$script="onchange=\"if(this.options[this.selectedIndex].value!=''){location='?mod=".$mod."&file=".$mod."&action=".
$action."&value=".$value."&channelid=".$channelid."&catid='+this.options[this.selectedIndex].value;}\"";
$cat_jump = cat_select('catid','请选择栏目进行管理',$catid,$script);

$cat_pos = cat_pos($catid);

$referer=$referer ? $referer : $PHP_REFERER;

$action=$action ? $action : 'manage';

//搜索
if(!empty($keywords))
{
	$keyword=str_replace(' ','%',$keywords);
	$keyword=str_replace('*','%',$keyword);
	switch($srchtype)
	{
		case '0':
			$addquery=" AND title LIKE '%$keyword%' ";
	break;
		case '1':
			$addquery=" AND content LIKE '%$keyword%' ";
	break;
		case '2':
			$addquery=" AND author LIKE '%$keyword%' ";
	break;
		case '3':
			$addquery=" AND username LIKE '%$keyword%' ";
	break;
		default :
			$addquery=" AND title LIKE '%$keyword%' ";
	}
}

if($catid)
{
	$addquery.=" AND catid=$catid ";
}
elseif($_grade==5)
{
	$catids = is_array($_purview_category) ? implode(",",$_purview_category) : "";
	$addquery .= $catids ? " AND catid IN($catids) " : "";
}

$addquery .= $elite ? " AND elite=1 " : "";
$addquery .= $ontop ? " AND ontop=1 " : "";
switch($ordertype)
{
	case 1:
		$dordertype=" pictureid DESC ";
break;
	case 2:
		$dordertype=" pictureid ";
break;
	case 3:
		$dordertype=" hits DESC ";
break;
	case 4:
		$dordertype=" hits ";
break;
	default :
		$dordertype=" pictureid DESC ";
}

purview_category($catid,$action);

switch($action){

case 'add':
	if(!is_array($_CAT)) showmessage("请先添加栏目!","?mod=phpcms&file=category&action=add&channelid=".$channelid);

	if($submit)
	{
		if($_grade==4 && $status==3) showmessage("您没有权限!");

		if(!$catid)	showmessage('对不起,请选择所属栏目!请返回!');
		if($_CAT[$catid][child] && !$_CAT[$catid][enableadd]) showmessage('指定栏目不允许添加图片!请返回!');
		if(empty($title)) showmessage('对不起,标题不能为空!请返回!');
		if(!$pictureurls) showmessage('图片地址不能为空!','goback');

		$groupview = is_array($groupview) ? implode(',',$groupview) : $groupview;

		$addtime = preg_match('/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/i', $addtime) ? strtotime($addtime.' '.date('H:i:s',$timestamp)) : $timestamp;

		if($addkeywords && !empty($keywords))
		{
			$keywords_in = explode(",", $keywords);
			foreach($keywords_in as $keyword)
			{
				update_keyword($keyword,$channelid);
			}
		}
		if($addauthors && !empty($author))
		{
			update_author($author,$channelid,$catid,$face=0,$introduction='',$elite);
		}
		if($addcopyfroms && !empty($copyfromname))
		{
			update_copyfrom($copyfromname,$copyfromurl,$channelid);
		}

		$status = $status ? $status : 1;
		
		$db->query("INSERT INTO ".TABLE_PICTURE."(channelid,catid,specialid,title,thumb,titlefontcolor,titlefonttype,author,copyfromname,copyfromurl,username,addtime,keywords,content,pictureurls,ontop,elite,status,checker,checktime,stars,skinid,templateid,readpoint,groupview) VALUES('$channelid','$catid','$specialid','$title','$thumb','$titlefontcolor','$titlefonttype','$author','$copyfromname','$copyfromurl','$_username','$addtime','$keywords','$content','$pictureurls','$ontop','$elite','$status','$_username','$addtime','$stars','$skinid','$templateid','$readpoint','$groupview')");
		$pictureid=$db->insert_id();
		field_update($channelid,"pictureid=$pictureid");
		if($status==3)
		{
			tohtml("picture");
		}
	    $referer="?mod=picture&file=picture&action=".$action."&channelid=".$channelid."&catid=".$catid."&status=".$status;
		showmessage('操作成功!',$referer); 
	}
	else
	{
		//实现自动添加点数
		foreach( $_CAT as $key=>$val)
		{
			$cats.="arr[".$key."]=".$val['defaultpoint'].";\n";
		}
		$cat_select = cat_select('catid','请选择栏目',$catid,"onchange='setff(this.value)'");
		//自定义字段
		$fields = field_input($channelid,"tablerow");
		$special_select = special_select($channelid,'specialid','不属于任何专题',$specialid);
		$titlefontcolor=color_select('titlefontcolor','颜色',$colorcode);
		$fonttype=fonttype_select('titlefonttype','字形',$defaultfont);
		$showskin = showskin($name='skinid',$skinid);
		$showtpl = showtpl($module='picture',$typename='content',$name='templateid',$templateid);
		$keyword_select = keyword_select($channelid);
		$author_select = author_select($channelid);
		$copyfrom_select = copyfrom_select($channelid);
		$showgroup = showgroup('checkbox','groupview[]');

		$today=date("Y-m-d",$timestamp);
		include admintpl('picture_add');
	}

break;

case 'edit':
	if(!$pictureid) showmessage('非法参数!请返回!');

	if($submit)
	{
		if($_grade==4 && $status==3) showmessage("您没有权限!");

		if(!$catid)	showmessage('对不起,请选择所属栏目!请返回!');
		if($_CAT[$catid][child] && !$_CAT[$catid][enableadd]) showmessage('指定栏目不允许添加图片!请返回!');
		if(empty($title)) showmessage('对不起,标题不能为空!请返回!');
		if(!$pictureurls) showmessage('图片地址不能为空!','goback');

		$groupview = is_array($groupview) ? implode(',',$groupview) : $groupview;

		//$addtime = preg_match('/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/i', $addtime) ? strtotime($addtime.' '.date('H:i:s',$timestamp)) : $timestamp;

		if($addkeywords && !empty($keywords))
		{
			$keywords_in = explode(",", $keywords);
			foreach($keywords_in as $keyword)
			{
				update_keyword($keyword,$channelid);
			}
		}
		if($addauthors && !empty($author))
		{
			update_author($author,$channelid);
		}
		if($addcopyfroms && !empty($copyfromname))
		{
			update_copyfrom($copyfromname,$copyfromurl,$channelid);
		}

		$db->query("UPDATE ".TABLE_PICTURE." SET catid='$catid',specialid='$specialid',title='$title',thumb='$thumb',titlefontcolor='$titlefontcolor',titlefonttype='$titlefonttype',author='$author',copyfromname='$copyfromname',copyfromurl='$copyfromurl',keywords='$keywords',content='$content',pictureurls='$pictureurls',ontop='$ontop',elite='$elite',status='$status',editor='$_username',edittime='$timestamp',stars='$stars',skinid='$skinid',templateid='$templateid',readpoint='$readpoint',groupview='$groupview' WHERE pictureid='$pictureid' AND channelid='$channelid'");
		if ($db->affected_rows()>0)
		{
		    field_update($channelid,"pictureid=$pictureid");
			if($status==3)
			{
				tohtml("picture");
			}
			showmessage('操作成功!',$referer);
		}
		else
		{
			showmessage('操作失败!');
		}
	}
	else
	{
		if(empty($pictureid))
		{
			showmessage('非法参数!请返回!');
		}
		if($_grade>3 && $status==3) showmessage("您没有权限!");

		$picture = $db->get_one("SELECT * FROM ".TABLE_PICTURE." WHERE pictureid='$pictureid' AND channelid='$channelid'");
		$picture[content]=htmlspecialchars(stripslashes($picture[content]));
		$picture[addtime]=date("Y-m-d",$picture[addtime]);
		//实现自动添加点数
		foreach( $_CAT as $key=>$val)
		{
			$cats.="arr[".$key."]=".$val['defaultpoint'].";\n";
		}
        $titlefontcolor = color_select('titlefontcolor','颜色',$picture[titlefontcolor]);
        $fonttype = fonttype_select('titlefonttype','字形',$picture[titlefonttype]);
		$cat_select = cat_select('catid','请选择栏目',$catid);
		$special_select = special_select($channelid,'specialid','不属于任何专题',$specialid);
		$keyword_select = keyword_select($channelid);
		$author_select = author_select($channelid);
		$copyfrom_select = copyfrom_select($channelid);
		$today=date("Y-m-d",$timestamp);
		$showskin = showskin('skinid',$picture[skinid]);
		$showtpl = showtpl('picture','content','templateid',$picture[templateid]);
		$showgroup = showgroup('checkbox','groupview[]',$picture[groupview]);

        $pictureurls = trim($picture[pictureurls]);
		$pictureurls = explode("\n",$pictureurls);
		$pictureurls = array_map("trim",$pictureurls);

		$referer=urlencode('?mod=picture&file=picture&action=manage&channelid='.$channelid);
		include admintpl('picture_edit');
	}
break;

//检查图片名称是否相同
case 'checktitle':
	if(empty($title))
	{
		$error_msg='图片名称不能为空!请返回!';
	}
	$query="SELECT title,addtime FROM ".TABLE_PICTURE." WHERE status<>2 AND recycle=0 AND channelid='$channelid' AND title LIKE '%$title%' ORDER BY pictureid DESC";
	$result=$db->query($query);
	if($db->num_rows($result)>0)
	{
		while($r=$db->fetch_array($result))
		{
			$r[adddate]=date("m-d",$r[addtime]);
			$r[addtime]=date("Y/md",$r[addtime]);
			$pictures[]=$r;
		}
	}
	include admintpl('picture_checktitle');
break;

//管理图片
case 'manage':

	$status=isset($status) ? $status : 3;
	$referer=urlencode("?mod=picture&file=picture&action=manage&channelid=".$channelid."&catid=".$catid."&status=".$status."&keyword=".$keyword."&ontop=".$ontop."&elite=".$elite."&ordertype=".$ordertype."&srchtype=".$srchtype."&page=".$page);
	
	if(!$page)
	{
		$page=1;
		$offset=0;
	}
	else
	{
		$offset=($page-1)*$pagesize;
	}

	$query="SELECT COUNT(*) AS num FROM ".TABLE_PICTURE." WHERE status='$status' AND recycle=0 AND channelid='$channelid' $addquery";
	$result=$db->query($query);
	$r=$db->fetch_array($result);
	$number=$r["num"];
	$url="?mod=picture&file=picture&action=manage&channelid=".$channelid."&catid=".$catid."&status=".$status."&keyword=".$keyword."&ontop=".$ontop."&elite=".$elite."&ordertype=".$ordertype."&srchtype=".$srchtype."&page=".$page."&submit=1";

⌨️ 快捷键说明

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