?? picture.php
字號:
<?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('圖片地址不能為空!請返回!');
$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('圖片地址不能為空!請返回!');
$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 + -