📄 down.php
字号:
<?php
/*
*######################################
* PHPCMS v3.0.0 - 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);
///URL参数
$referer = $referer ? $referer : $_SERVER["HTTP_REFERER"];
$action = $action ? $action : 'manage';
//后台管理菜单
$menus=array(
array("<font color='red'>添加下载</font>", "?mod=".$mod."&file=".$file."&action=add&channelid=".$channelid),
array("审核下载", "?mod=".$mod."&file=".$file."&action=check&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)
);
$downmenu = adminmenu('下载管理',$menus);
//跳转菜单
$tree = new tree;
$script="onchange=\"if(this.options[this.selectedIndex].value!=''){location='?mod=".$mod."&file=".$mod."&action=".$action."&catid=".$catid."&channelid=".$channelid."&catid='+this.options[this.selectedIndex].value;}\"";
$cat_jump = cat_select('catid','请选择栏目进行管理',$catid,$script);
$cat_pos = cat_pos($catid);
//栏目参数
$cats_num = count($_CAT);
//查询条件
$condtion='';
$cat_serach = cat_select('catid','请选择栏目',$catid);
//======================================== 置顶
if($ontop==1)
{
$condtion.=" and ontop=1 ";
$iftop=0;
$topinfo='取消置顶';
}
elseif($ontop==0)
{
$iftop=1;
$topinfo='置顶';
}
$topurl = changeurl("ontop",$iftop);
$topcheckded = ($ontop==1) ? ' checked="checked" ' : '';
//======================================== 置顶
//======================================== 推荐
if($elite==1)
{
$condtion.=" and elite=1 ";
$ifelite=0;
$eliteinfo="取消推荐";
}
elseif($elite==0)
{
$ifelite=1;
$eliteinfo="推荐";
}
$eliteurl = changeurl("elite",$ifelite);
$elitecheckded=($elite==1) ? ' checked="checked" ' : '';
//======================================== 推荐
$fieldtypes=array('title','introduce','username','checker','editor');
$ordertypes=array('addtime desc','addtime asc','edittime desc','edittime asc','hits desc','hits asc');
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("您没有权限!");
$ontop=$elite=$recycle=$error=$errortimes=0;
$groupview =is_array($groupid_box) ? implode(',',$groupid_box) : $groupid_box;
//提交字段判断
if(!$catid) showmessage('请选择栏目!请返回!');
if(!$_CAT[$catid]['enableadd']) showmessage('指定栏目不允许添加下载!请返回!');
if(!$title) showmessage('请填写标题!请返回!');
if(!$introduce) showmessage('请填写内容!请返回!');
if(!$downurls) showmessage('下载地址不能为空!请返回!');
//更新关键字
if($addkeywords && !empty($keywords))
{
$keywords_input = explode(",", $keywords);
foreach($keywords_input 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);
}
$db->query("insert into ".TABLE_DOWN."(channelid,catid,specialid,title,titlefontcolor,titlefonttype,keywords,author,copyfromname,copyfromurl,username,addtime,checker,checktime,editor,edittime,introduce,status,thumb,filesize,downurls,skinid,templateid,ontop,elite,stars,readpoint,groupview) values('$channelid','$catid','$specialid','$title','$titlefontcolor','$titlefonttype','$keywords','$author','$copyfromname','$copyfromurl','$_username','$timestamp','','','','$timestamp','$introduce','$status','$thumb','$filesize','$downurls','$skinid','$templateid','$ontop','$elite','$stars','$readpoint','$groupview')");
$downid = $db->insert_id();
field_update($channelid,"downid=$downid");
if($status==3)
{
credit_add($_username,$_CAT[$catid]['creditget']);
if($_CHA['htmlcreatetype'])
{
include_once PHPCMS_ROOT."/include/cmd.php";
cmd_send(PHPCMS_PATH.$_CHA['channeldir']."/cmd.php","down2html",$referer,"downid=".$downid);
}
}
showmessage('操作成功!',$referer);
}
else
{
$headtitle='添加'.$_CHA['channelname'];
foreach( $_CAT as $key=>$val)
{
$cats.="arr[".$key."]=".$val['defaultpoint'].";\n";
}
//关键字,作者,来源
$keyword_select = keyword_select($channelid);
$author_select = author_select($channelid,'author_sel','onchange="author.value=this.value;"');
$copyfrom_select = copyfrom_select($channelid);
$cat_select = cat_select('catid','请选择栏目',$catid,"onchange=\"setff(this.value)\"");
$special_select = special_select($channelid,'specialid','不属于任何专题',$specialid);
$skin_select = showskin('skinid',$skinid);
$tpl_select = showtpl($mod,'content','templateid',$templateid);
$fontcolor_select=color_select('titlefontcolor','颜色',$titlefontcolor);
$fonttype_select =fonttype_select('titlefonttype','字形',$titlefonttype);
$fields = field_input($channelid,"tablerow");
$upfile_size= intval($_CHA['maxfilesize']/1024);
$group_box=showgroup('checkbox','groupid_box[]');
include admintpl('down_add');
}
break;
//编辑下载
case 'edit':
$headtitle='编辑'.$_CHA['channelname'];
if($submit)
{
if($_grade==4 && $status==3) showmessage("您没有权限!");
$groupview =is_array($groupid_box) ? implode(',',$groupid_box) : $groupid_box;
//提交字段判断
if(!$catid) showmessage('请选择栏目!请返回!');
if(!$_CAT[$catid]['enableadd']) showmessage('指定栏目不允许添加下载!请返回!');
if(!$title) showmessage('请填写标题!请返回!');
if(!$introduce) showmessage('请填写内容!请返回!');
if(!$downurls) showmessage('下载地址不能为空!请返回!');
//更新关键字
if($addkeywords && !empty($keywords))
{
$keywords_input = explode(",", $keywords);
foreach($keywords_input 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);
}
$db->query("update ".TABLE_DOWN." set catid='$catid',specialid='$specialid',title='$title',titlefontcolor='$titlefontcolor',titlefonttype='$titlefonttype',keywords='$keywords',author='$author',copyfromname='$copyfromname',copyfromurl='$copyfromurl',editor='$_username',edittime='$timestamp',introduce='$introduce',status='$status',thumb='$thumb',filesize='$filesize',downurls='$downurls',skinid='$skinid',templateid='$templateid',ontop='$ontop',elite='$elite',stars='$stars',readpoint='$readpoint',groupview='$groupview' where downid='$downid' limit 1");
field_update($channelid,"downid=$downid");
if($status==3)
{
tohtml("down");
}
showmessage('操作成功!',$referer);
}
else
{
if($_grade>3 && $status==3) showmessage("您没有权限!");
if(!$downid) showmessage("参数错误!");
$upfile_size= intval($_CHA['maxfilesize']/1024);
$r = $db->get_one("select * from ".TABLE_DOWN." where downid='$downid'");
if(!$r['downid']) showmessage("参数错误!");
@extract($r);
//实现自动添加点数
foreach( $_CAT as $key=>$val)
{
$cats.="arr[".$key."]=".$val['defaultpoint'].";\n";
}
$cat_select = cat_select('catid','请选择栏目',$catid,"onchange=\"setff(this.value)\"");
$special_select = special_select($channelid,'specialid','不属于任何专题',$specialid);
$skin_select = showskin('skinid',$skinid);
$tpl_select = showtpl($mod,'content','templateid',$templateid);
$fontcolor_select=color_select('titlefontcolor','颜色',$titlefontcolor);
$fonttype_select=fonttype_select('titlefonttype','字形',$titlefonttype);
$group_box = showgroup('checkbox','groupid_box[]',$groupview);
//关键字,作者,来源
$keyword_select = keyword_select($channelid);
$author_select = author_select($channelid,'author_sel','onchange="author.value=this.value;"');
$copyfrom_select = copyfrom_select($channelid);
$fields = field_input($channelid,"tablerow");
$downurls = explode("\n",$downurls);
$downurls = array_map("trim",$downurls);
include admintpl('down_edit');
}
break;
case 'checktitle':
if(empty($title)) $error_msg='标题不能为空!请返回!';
$result=$db->query("SELECT downid,title,addtime FROM ".TABLE_DOWN." WHERE status=3 AND recycle=0 AND channelid=$channelid AND title LIKE '%$title%' ORDER BY downid");
while($r=$db->fetch_array($result))
{
$r[url] = $p->get_itemurl($r[downid],$r[addtime]);
$r[adddate]=date("m-d",$r[addtime]);
$downs[]=$r;
}
include admintpl('down_checktitle');
break;
//从数据库删除
case 'delete':
if(empty($downid)) showmessage('非法参数!请返回!');
$downids = is_array($downid) ? implode(',',$downid) : $downid;
$result = $db->query("SELECT downid,addtime,downurls FROM ".TABLE_DOWN." WHERE downid IN ($downids) AND channelid='$channelid'");
while($r = $db->fetch_array($result))
{
attach_del($downurls);
if($_CHA['htmlcreatetype'])
{
$p->set_type("path");
$filename = $p->get_itemurl($r[downid],$r[addtime]);
@$f->unlink($filename);
}
}
$db->query("DELETE FROM ".TABLE_DOWN." WHERE downid IN ($downids) AND channelid='$channelid'");
if($db->affected_rows()>0)
{
showmessage('操作成功!',$referer);
}
else
{
showmessage('操作失败!请返回!');
}
break;
//清空回收站
case 'deleteall':
$result = $db->query("SELECT downid,addtime,downurls FROM ".TABLE_DOWN." WHERE recycle='1' AND channelid='$channelid'");
while($r = $db->fetch_array($result))
{
attach_del($downurls);
if($_CHA['htmlcreatetype'])
{
$p->set_type("path");
$filename = $p->get_itemurl($r[downid],$r[addtime]);
@$f->unlink($filename);
}
}
$db->query("delete from ".TABLE_DOWN." where recycle='1' and channelid='$channelid'");
if($db->affected_rows()>0)
{
showmessage('清空回收站操作成功!',$referer);
}
else
{
showmessage('操作失败,请返回!');
}
break;
//置顶
case 'ontop':
$value=$value?intval($value):0;
$downids=is_array($downid) ? implode(",",$downid) : $downid;
if(empty($downids))
{
showmessage('请选择要操作的项目!');
}
if(!ereg('^[0-1]+$',$value))
{
showmessage('非法参数,请返回!');
}
$db->query("update ".TABLE_DOWN." set ontop='$value' where downid in ($downids)");
$msg = $value==1 ? '置顶操作成功!' : '取消置顶操作成功!';
if($db->affected_rows()>0)
{
showmessage($msg,$referer);
}
else
{
showmessage('操作失败,请返回!');
}
break;
//推荐
case 'elite':
$value=$value?intval($value):0;
$downids=is_array($downid) ? implode(",",$downid) : $downid;
if(empty($downids))
{
showmessage('请选择要操作的项目!');
}
if(!ereg('^[0-1]+$',$value))
{
showmessage('非法参数,请返回!');
}
$sql="update ".TABLE_DOWN." set elite='$value' where downid in ($downids)";
$query=$db->query($sql);
$msg=($value==1) ? '推荐操作成功!' : '取消推荐操作成功!';
if($query)
{
showmessage($msg,$referer);
}
else
{
showmessage('操作失败,请返回!');
}
break;
case 'specialout':
if(empty($downid)) showmessage('非法参数!请返回!');
$downids=is_array($downid) ? implode(',',$downid) : $downid;
$db->query("UPDATE ".TABLE_DOWN." SET specialid=0 WHERE downid IN ($downids) AND channelid='$channelid'");
if($db->affected_rows()>0)
{
showmessage('操作成功!',$referer);
}
else
{
showmessage('操作失败!请返回!');
}
break;
//投稿
case 'send':
if(empty($downid))
{
showmessage('非法参数,请返回!');
}
$db->query("update ".TABLE_DOWN." set status='1' where downid='$downid' and (status='0' or status='2') and channelid='$channelid'");
if($db->affected_rows()>0)
showmessage('投稿成功!',$referer);
else
showmessage('信息不存在,请返回!',$referer);
break;
//退稿
case 'sendback':
$headtitle=$_CHA['channelname']."退稿";
if($submit)
{
if(empty($downid))
{
showmessage('请选择要操作的项目!');
}
if($ifpm)
{
if(empty($title))
{
showmessage('对不起,标题不能为空!请返回!');
}
if(empty($content))
{
showmessage('对不起,内容不能为空!请返回!');
}
sendpm($username,$title,$content);
}
if($ifemail)
{
sendusermail($username,$title,$content);
}
$sql="update ".TABLE_DOWN." set status='2',elite=0,ontop=0 where downid='$downid' and channelid='$channelid'";
$query=$db->query($sql);
if($query)
{
showmessage('退稿成功!',$referer);
}
else
{
showmessage('操作失败,请返回!');
}
}
else
{
if(empty($downid))
{
showmessage('非法参数!请返回!');
}
$result=$db->query("select title,catid,username,status from ".TABLE_DOWN." where downid='$downid' and status='1' and channelid='$channelid'");
if($db->num_rows($result)>0)
{
$down=$db->fetch_array($result);
}
else
{
showmessage('信息不存在!请返回!');
}
include admintpl('down_sendback');
}
break;
//删除或者还原到回收站
case 'torecycle':
$downids=is_array($downid) ? implode(",",$downid) : $downid;
if(empty($downids))
{
showmessage('请选择要删除的项目!');
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -