<?php

/* 

 * 用户添加删除黑名单接口 

 * ==============================================================

 * @param tag (强制string) | 标示符 1=加入黑名单 0=取消黑名单

 * @param uid              | 对方用户uid(不是本人uid)

 * @param auth             | 用户auth

 * @author                 | zhangxin 

 * ==============================================================

 */

if(!defined('IN_DISCUZ')) {

	exit('Access Denied');

}



$tag  = $_GET['tag'];

$bid  = $_GET['uid'];



if(empty($_G['uid'])){

        odz_error('auth error');

}

if(empty($bid)){

        odz_error('uid not exits');

}

if(!in_array($tag,array('0','1'),true)){

        odz_error('tag error');

}



$checkbid = DB::fetch_first(' SELECT * FROM '.DB::table('mocuz_blackfriend')." WHERE uid = '".$_G['uid']."' AND bid='".$bid."'");



//取消黑名单

if($checkbid && $tag==='0'){

    

        DB::delete('mocuz_blackfriend', array('uid'=>$_G['uid'],'bid'=>$bid))?odz_success('operation_done'):odz_error('mysql error');

}

//加入黑名单

if(empty($checkbid) && $tag ==='1'){

    

        DB::insert('mocuz_blackfriend', array('uid'=>$_G['uid'],'bid'=>$bid,'dateline'=>time()))?odz_success('operation_done'):odz_error('mysql error');

}

odz_error('operation error');



?>