MySQL Error
Message: MySQL Query Error
SQL: SELECT * FROM gxwk_task AS a JOIN gxwk_field AS b ON a.tid=b.tid WHERE 1 ORDER BY tid DESC LIMIT 0,20
Error: Column 'tid' in order clause is ambiguous
Errno.: 1052
文件的代码:
<?php
/*
广西威客 2009.8.11
*/
if(!defined('IN_UCHOME') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
//权限
$managetaskmanage = checkperm('managetaskmanage');
$noprivilege = !$managetaskmanage;
if($noprivilege) {
cpmessage('no_authority_management_operation');
}
$ac=$_GET[ac];
$op=$_GET[op];
get_isid($_GET[tid], "admincp.php?ac=$ac");
//批量删除任务
if(submitcheck('deletesubmit')) {
if(count($_POST['ids'])=="0"){
showmessage('请至少正确选择一个要删除的任务!', "admincp.php?ac=$ac");
}else{
//同时删除附件
$task_file = array();
$query = $_SGLOBAL['db']->query("SELECT * FROM gxwk_file WHERE tid IN (".simplode($_POST['ids']).") ");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
$task_file[] = $value;
unlink('../task/'.$value[file]);
}
$_SGLOBAL['db']->query("DELETE FROM gxwk_file WHERE tid IN (".simplode($_POST['ids']).")");
//同时删除任务下的稿件 **********************
//删除稿件附件
$draft_file = array();
$query = $_SGLOBAL['db']->query("SELECT * FROM gxwk_draft AS a LEFT JOIN gxwk_draftfile AS p ON a.did=p.did WHERE a.tid IN (".simplode($_POST['ids']).") ");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
$draft_file[] = $value;
unlink('../task/'.$value[file]);
}
//删除稿件所有字段
$_SGLOBAL['db']->query("DELETE gxwk_draft,gxwk_comment,gxwk_draftfile FROM gxwk_draft LEFT JOIN gxwk_comment ON gxwk_draft.did=gxwk_comment.did LEFT JOIN gxwk_draftfile ON gxwk_draft.did=gxwk_draftfile.did WHERE gxwk_draft.tid IN (".simplode($_POST['ids']).")");
//稿件删除完成 *****************************
//同时删除任务内容
$_SGLOBAL['db']->query("DELETE FROM gxwk_field WHERE tid IN (".simplode($_POST['ids']).")");
//同时删除任务留言
$_SGLOBAL['db']->query("DELETE FROM gxwk_guestbook WHERE tid IN (".simplode($_POST['ids']).")");
//同时删除任务报名
$_SGLOBAL['db']->query("DELETE FROM gxwk_join WHERE tid IN (".simplode($_POST['ids']).")");
//同时删除任务招标
$_SGLOBAL['db']->query("DELETE FROM gxwk_tender WHERE tid IN (".simplode($_POST['ids']).")");
//最后删除任务
$_SGLOBAL['db']->query("DELETE FROM gxwk_task WHERE tid IN (".simplode($_POST['ids']).")");
showmessage('删除任务成功!', "admincp.php?ac=$ac");
}
}
//修改内容
if($op=='edit'){
$tid=$_GET[tid];
$query = $_SGLOBAL['db']->query("SELECT message FROM ".wk('field')." WHERE tid='$tid' ");
$value = $_SGLOBAL['db']->fetch_array($query);
$content=stripslashes(nl2br($value[message])); //输出换行
if(submitcheck('contentsubmit')) {
$tid=$_POST[tid];
$contents=getstr($_POST[content], 0, 0, 1, 1, 0,1);
if(strlen($contents)<="6"){
showmessage('任务内容不能小于6个字节!', "admincp.php?ac=task_manage&op=edit&tid=$tid");
}
$query = $_SGLOBAL['db']->query("update ".wk('field')." set message='$contents' where tid='$tid' ");
showmessage('任务内容修改成功!', "admincp.php?ac=$ac");
}
}
//批注
if($op=='note'){
$tid=$_GET[tid];
$query = $_SGLOBAL['db']->query("SELECT note FROM ".wk('field')." WHERE tid='$tid' ");
$value = $_SGLOBAL['db']->fetch_array($query);
$notes=$value[note];
if(submitcheck('notesubmit')) {
$tid=$_POST[tid];
if(strlen($_POST[note])<="6"){
showmessage('批注内容不能小于6个字节!', "admincp.php?ac=task_manage&op=note&tid=$tid");
}
$note=overhtml($_POST[note]);
$query = $_SGLOBAL['db']->query("update ".wk('field')." set note='$note' where tid='$tid' ");
showmessage('批注任务成功!', "admincp.php?ac=$ac");
}
}
//延期
if($op=='delay'){
if(submitcheck('delaysubmit')) {
$tid=$_POST[tid];
if(!ereg("^[0-9]*$",$_POST[delay])) {
showmessage('延期天数只能为数字!', "admincp.php?ac=task_manage&op=delay&tid=$tid");
}
$query = $_SGLOBAL['db']->query("SELECT endtime FROM ".wk('task')." WHERE tid='$tid' ");
$value = $_SGLOBAL['db']->fetch_array($query);
$oldtime=$value[endtime];
$delay=$_POST[delay];
$taskend=$oldtime+(86400*$delay); // 计算任务结束时间
$query = $_SGLOBAL['db']->query("update ".wk('task')." set endtime='$taskend' where tid='$tid' ");
showmessage('延期任务成功!', "admincp.php?ac=$ac");
}
}
//批量审核任务
if(submitcheck('gradesubmit')) {
if(count($_POST['ids'])=="0"){
showmessage('请至少正确选择一个要审核的任务!', "admincp.php?ac=$ac");
}else{
$_SGLOBAL['db']->query("UPDATE gxwk_task SET grade='1' WHERE tid IN (".simplode($_POST['ids']).") ");
showmessage('审核任务成功!', "admincp.php?ac=$ac");
}
}
//批量作弊任务
if(submitcheck('fraudsubmit')) {
if(count($_POST['ids'])=="0"){
showmessage('请至少正确选择一个要设置作弊的任务!', "admincp.php?ac=$ac");
}else{
$endtime=mktime();
$_SGLOBAL['db']->query("UPDATE gxwk_task SET taskset='1',endtime='$endtime',draftpay='1' WHERE tid IN (".simplode($_POST['ids']).") ");
showmessage('设置作弊任务成功!', "admincp.php?ac=$ac");
}
}
//确认支付
if($op=='paydraft'){
$tid=$_GET[tid];
$accept_time=mktime();
//结束任务记录稿件支付
$_SGLOBAL['db']->query("update ".wk('task')." set endtime='$accept_time',draftpay='1' where tid=".$tid." ");
//查询任务信息
$query = $_SGLOBAL['db']->query("SELECT * FROM ".wk('task')." WHERE tid=$tid ");
$task = $_SGLOBAL['db']->fetch_array($query);
$taskuid=$task['uid'];
$taskusername=$task['username'];
$taskmode=$task['taskmode'];
$taskmoney=$task['money'];
$subject=$task['subject'];
//入围
$query = $_SGLOBAL['db']->query("SELECT uid AS uidok FROM ".wk('draft')." WHERE tid='$tid' AND successful=1 ");
$draftok = $_SGLOBAL['db']->fetch_array($query);
$uidok=$draftok['uidok'];
$finalistarr=array();
$query = $_SGLOBAL['db']->query("SELECT * FROM ".wk('draft')." WHERE tid='$tid' AND vote>=$config[finalistvotes] AND successful=0 AND uid!='$uidok' GROUP BY uid ORDER BY vote DESC
LIMIT 0 , ".$config[taskfinalistnum]." ");
while ($finalists = $_SGLOBAL['db']->fetch_array($query)){
$finalistarr[]=$finalists;
}
$finalist_money=$taskmoney*$config[taskfinalistmoney];
foreach($finalistarr AS $finalist){
if($finalist_money>='0.01'){
$query = $_SGLOBAL['db']->query("SELECT money AS finalist_usermoney,uid AS finalist_uid,username AS finalist_username FROM ".wk('member')." where uid='$finalist[uid]' ");
$fvalue = $_SGLOBAL['db']->fetch_array($query);
$finalist_usermoney=$fvalue[finalist_usermoney];
//修改入围者当前金额
$nowfinalist_usermoney=$finalist_usermoney+$finalist_money;
//加入个人财富
task_wealth($finalist[uid],$finalist_money);
$_SGLOBAL['db']->query("update ".wk('member')." set money='$nowfinalist_usermoney' where uid='$finalist[uid]' ");
//插入交易记录
$moneydesc="$finalist[username] 的稿件在<a href=\"$config[siteurl]/award\/draft.php\?tid=$tid\">$tid 号任务中入围获得 $finalist_money 元.<\/a> ";
moneydeal($tid,$finalist[uid],$finalist[username],'15',$moneydesc,$finalist_money,'2');
banks($tid,$finalist_money,'2');
$moneydesc="$config[payname] 支付 $tid 号任务入围费 $finalist_money 元给 $finalist[username]";
moneydeal($tid,'0',$config[payname],'16',$moneydesc,$finalist_money,'1');
task_feed($config[siteurl],$finalist[uid],$finalist[username],$tid,$subject,13);
$_SGLOBAL['db']->query("update ".wk('draft')." set accept_time='$accept_time',finalist='1' where did='$finalist[did]' ");
//通知入围者
$pmnote="您的稿件在<a href=\"$config[siteurl]/award\/draft.php\?tid=$tid\">$tid 号任务中入围获得 $finalist_money 元, 积分 + $config[taskpointfinalist] 请注意查收!";
tasknote($finalist[uid],$taskuid,$taskname,$accept_time,$pmnote);
//入围者加入积分
task_addpoint($finalist[uid],$config[taskpointfinalist]);
}else{
task_feed($config[siteurl],$finalist[uid],$finalist[username],$tid,$subject,13);
$_SGLOBAL['db']->query("update ".wk('draft')." set accept_time='$accept_time',finalist='1' where did='$finalist[did]' ");
//通知入围者
$pmnote="您的稿件在<a href=\"$config[siteurl]/award\/draft.php\?tid=$tid\">$tid 号任务中入围了因入围赏金不足 0.01 元系统不作支付处理, 积分 + $config[taskpointfinalist] 请注意查收!";
tasknote($finalist[uid],$taskuid,$taskname,$accept_time,$pmnote);
//入围者加入积分
task_addpoint($finalist[uid],$config[taskpointfinalist]);
}
//推广者入围收益
$query = $_SGLOBAL['db']->query("SELECT rid AS unionfuid FROM ".wk('member')." where uid='$finalist[uid]'");
$value = $_SGLOBAL['db']->fetch_array($query);
$unionfuid=$value['unionfuid'];
//是否有推广者
if($unionfuid){
$uniontask_fmoney=$taskmoney*$config[uniontaskfinalist];
if($uniontask_fmoney>='0.01'){
$query = $_SGLOBAL['db']->query("SELECT money AS union_usermoney,uid AS union_uid,username AS union_username FROM ".wk('member')." where uid='$unionfuid' ");
$value = $_SGLOBAL['db']->fetch_array($query);
$union_usermoney=$value['union_usermoney'];
$union_uid=$value['union_uid'];
$union_username=$value['union_username'];
//修改推广者当前金额
$nowunion_usermoney=$union_usermoney+$uniontask_fmoney;
//加入个人财富
task_wealth($unionfuid,$uniontask_fmoney);
$_SGLOBAL['db']->query("update ".wk('member')." set money='$nowunion_usermoney' where uid='$unionfuid' ");
//插入交易记录
$moneydesc="$finalist[username] 的稿件在<a href=\"$config[siteurl]/award\/show.php\?tid=$tid\">$tid 号任务中入围 $union_username 获得推广费 $uniontask_fmoney 元.<\/a> ";
moneydeal($tid,$union_uid,$union_username,'17',$moneydesc,$uniontask_fmoney,'2');
banks($tid,$uniontask_fmoney,'2');
$moneydesc="$config[payname] 支付 $tid 号任务入围推广费 $uniontask_fmoney 元给 $union_username";
moneydeal($tid,'0',$config[payname],'18',$moneydesc,$uniontask_fmoney,'1');
//通知推广者 ;
$pmnote="$tid 号任务稿件入围,您获得推广费 $uniontask_fmoney 元, 积分 + $config[unionpointfinalist] 请注意查收!";
tasknote($union_uid,$taskuid,$taskname,$accept_time,$pmnote);
//推广者加入积分
task_addpoint($union_uid,$config[unionpointfinalist]);
}else{
//通知推广者
$pmnote="$tid 号任务稿件中标,因推广入围赏金不足 0.01 元系统不作支付处理, 积分 + $config[unionpointfinalist] 请注意查收!";
tasknote($union_uid,$taskuid,$taskname,$accept_time,$pmnote);
//推广者加入积分
task_addpoint($union_uid,$config[unionpointfinalist]);
}
}
}
if($taskmode==1){
$money=round(($taskmoney-$taskmoney*$config[taskmoney]),2);
//查询中标稿件ID
$query = $_SGLOBAL['db']->query("SELECT did,uid FROM ".wk('draft')." WHERE tid=$tid AND successful=1 ");
$draftid = $_SGLOBAL['db']->fetch_array($query);
$did=$draftid['did'];
$draftuid=$draftid['uid'];
//中标稿件生成缩略图110px *110 px
$query = $_SGLOBAL['db']->query("SELECT a.did,p.file AS filepath,filename FROM ".wk('draft')." AS a JOIN ".wk('draftfile')." AS p ON a.did=p.did WHERE a.tid='$tid' AND successful=1 ");
$successful_draft = $_SGLOBAL['db']->fetch_array($query);
$fileurl= substr($successful_draft['filepath'],-3); //处理扩展名
if($fileurl=='jpg' || $fileurl=='gif' || $fileurl=='png'){
$filepaththumb=$successful_draft['filepath'];
$didthumb=$successful_draft['did'];
$thumbfilename=$successful_draft['filename'];
$newfilepaththumb='../'.$filepaththumb;
//生成新的文件名
$filepath= substr($filepaththumb,0,-4); //处理扩展名
$filenames=explode('/',$filepath);
$savepath='../'.$filenames[0].'/'.$filenames[1].'/'.$filenames[2].'/'.$filenames[3].'_thumb.jpg';
$savefile=$filenames[0].'/'.$filenames[1].'/'.$filenames[2].'/'.$filenames[3].'_thumb.jpg';
photothumb($newfilepaththumb,$config[casepicwidth],$config[casepicheight],$config[blackwatermark],$savepath);
}
$query = $_SGLOBAL['db']->query("INSERT INTO gxwk_case (tid,casename,photoname,photothumb) VALUES ('$tid','$subject','$thumbfilename','$savefile')");
//稿件状态
$_SGLOBAL['db']->query("update ".wk('draft')." set accept='1',successful='1',accept_time='$accept_time' where did=".$did." ");
}else{
$money= round(($taskmoney-$taskmoney*$config[tendermoney]),2);
//查询中标稿件ID
$query = $_SGLOBAL['db']->query("SELECT zid,uid FROM ".wk('tender')." WHERE tid=$tid AND successful=1 ");
$draftid = $_SGLOBAL['db']->fetch_array($query);
$did=$draftid['zid'];
$draftuid=$draftid['uid'];
//稿件状态
$_SGLOBAL['db']->query("update ".wk('tender')." set accept='1',successful='1',accept_time='$accept_time' where zid=".$did." ");
}
// 插入采纳通知
$pmnote="任务秘书代任务主已向您的 $did 号稿件支付!请注意查收!";
tasknote($draftuid,$taskuid,$taskname,$accept_time,$pmnote);
//插入交易记录 *************
$moneydesc="<a href=\"$config[siteurl]/award\/show.php\?tid=$tid\">$tid 号任务 $did 号稿件中标<\/a> ";
moneydeal($tid,$draftuid,$draftname,'2',$moneydesc,$money,'2');
banks($tid,$money,'2');
$moneydesc="$config[payname] 支付 $tid 号任务中标 $did 号稿件托管金额 $money 元";
moneydeal($tid,'0',$config[payname],'4',$moneydesc,$money,'1');
//*********************
//修改中标威客当前金额
$query = $_SGLOBAL['db']->query("SELECT * FROM ".wk('member')." where uid=".$draftuid." ");
$value = $_SGLOBAL['db']->fetch_array($query);
$nowmoney=$value[money]+$money;
//加入个人财富
task_wealth($draftuid,$money);
$_SGLOBAL['db']->query("update ".wk('member')." set money='$nowmoney' where uid=".$draftuid." ");
$_SGLOBAL['db']->query("update ".wk('task')." set acdraft='0' where tid=".$tid." ");
if($taskmode==1 || $taskmode==4 || $taskmode==5){
//中标推广者收益
$query = $_SGLOBAL['db']->query("SELECT rid AS unionfuid FROM ".wk('member')." where uid='$draftuid'");
$value = $_SGLOBAL['db']->fetch_array($query);
$unionfuid=$value['unionfuid'];
//是否有推广者
if($unionfuid){
$query = $_SGLOBAL['db']->query("SELECT money AS taskmoney FROM ".wk('task')." where tid='$tid' ");
$value = $_SGLOBAL['db']->fetch_array($query);
$taskmoney=$value['taskmoney'];
$uniontask_money=$taskmoney*$config[uniontaskok];
if($uniontask_money>='0.01'){
$query = $_SGLOBAL['db']->query("SELECT money AS union_usermoney,uid AS union_uid,username AS union_username FROM ".wk('member')." where uid='$unionfuid' ");
$value = $_SGLOBAL['db']->fetch_array($query);
$union_usermoney=$value['union_usermoney'];
$union_uid=$value['union_uid'];
$union_username=$value['union_username'];
//修改推广者当前金额
$nowunion_usermoney=$union_usermoney+$uniontask_money;
$_SGLOBAL['db']->query("update ".wk('member')." set money='$nowunion_usermoney' where uid='$unionfuid' ");
//插入交易记录
$moneydesc="$union_username 的稿件在<a href=\"$config[siteurl]/award\/show.php\?tid=$tid\">$tid 号任务中中标 $union_username 获得推广费 $uniontask_money 元.<\/a> ";
moneydeal($tid,$union_uid,$union_username,'13',$moneydesc,$uniontask_money,'2');
banks($tid,$uniontask_money,'2');
$moneydesc="$config[payname] 支付 $tid 号任务中标推广费 $uniontask_money 元给 $union_username";
moneydeal($tid,'0',$config[payname],'14',$moneydesc,$uniontask_money,'1');
//通知推广者
$pay_time=mktime();
$pmnote="$tid 号任务稿件中标,您获得推广费 $uniontask_money 元, 积分 + $config[unionpointok] 请注意查收!";
tasknote($union_uid,$taskuid,$taskname,$pay_time,$pmnote);
//加入个人财富
task_wealth($union_uid,$uniontask_money);
//推广者加入积分
task_addpoint($union_uid,$config[unionpointok]);
}else{
//通知推广者
$pay_time=mktime();
$pmnote="$tid 号任务稿件中标,因推广中标赏金不足 0.01 元系统不作支付处理, 积分 + $config[unionpointok] 请注意查收!";
tasknote($union_uid,$taskuid,$taskname,$pay_time,$pmnote);
//推广者加入积分
task_addpoint($union_uid,$config[unionpointok]);
}
}
}
//插入UCHOME动态
task_feed($config[siteurl],$taskuid,$taskname,$tid,$subject,3);
//增加积分
task_addpoint($taskuid,$config[taskpointpay]);
showmessage('支付任务成功!', "admincp.php?ac=$ac");
}
$mpurl = 'admincp.php?ac=task_manage';
//处理搜索条件 a 表
$intkeys = array('uid','tid');
$strkeys = array('username');
$likekeys = array('subject');
$randkeys = array(array('sstrtotime','dateline'), array('intval','views'));
$results = task_getwheres($intkeys,$strkeys,$likekeys,$randkeys, 'a.');
$wherearr = $results['wherearr'];
$mpurl .= '&'.implode('&', $results['urls']);
//处理搜索条件b表
$intkeys = array();
$strkeys = array();
$likekeys = array('message');
$results = task_getwheres($intkeys,$strkeys,$likekeys, 'b.');
$wherearr2 = $results['wherearr'];
$mpurl .= '&'.implode('&', $results['urls']);
$wheresql = empty($wherearr)?'1':implode(' AND ', $wherearr); //empty判断是否为空后 三元运算
$wheresql2 = empty($wherearr2)?'':implode(' AND ', $wherearr2); //empty判断是否为空后 三元运算
//排序
$orders = task_getorders(array('dateline', 'endtime', 'views'), 'tid', 'a.');
$ordersql = $orders['sql'];
if($orders['urls']) $mpurl .= '&'.implode('&', $orders['urls']);
$orderby = array($_GET['orderby']=>' selected');
$ordersc = array($_GET['ordersc']=>' selected');
//搜索查询任务分页
$perpage = empty($_GET['perpage'])?0:intval($_GET['perpage']);
if(!in_array($perpage, array(20,50,100,1000))) $perpage = 20;//默认分类数
$page = empty($_GET['page'])?1:intval($_GET['page']);
if($page<1) $page=1;
$start = ($page-1)*$perpage;
//检查开始数
ckstart($start, $perpage);
// 基础链接
// 数据总数
if($wheresql2){
$count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM gxwk_task AS a JOIN gxwk_field AS b ON a.tid=b.tid WHERE $wheresql and $wheresql2"),0);
}else{
$count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM gxwk_task AS a JOIN gxwk_field AS b ON a.tid=b.tid WHERE $wheresql"),0);
}
if($count) {
$task_list = array();
if($wheresql2){
$query = $_SGLOBAL['db']->query("SELECT * FROM gxwk_task AS a JOIN gxwk_field AS b ON a.tid=b.tid WHERE $wheresql and $wheresql2 LIMIT $start,$perpage");
}else{
$query = $_SGLOBAL['db']->query("SELECT * FROM gxwk_task AS a JOIN gxwk_field AS b ON a.tid=b.tid WHERE $wheresql $ordersql LIMIT $start,$perpage");
}
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
$task_list[]=$value;
}
}
$mpurl .= '&perpage='.$perpage;
$multi = multi($count, $perpage, $page, $mpurl);
?> |