
<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: forum_attachment.php 23252 2011-06-28 09:34:48Z monkey $
 */

if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
	exit('Access Denied');
}
$refer=dreferer();
dzz_cpheader();
$identifier=str_replace('plugin:','',$action);
$do=$_GET['do'];
if($operation=='delete'){
	$ids=$_POST['ids'];
	if($ids){
		foreach($ids as $value){
			list($uid,$idtype,$typeid)=explode('_',$value);
			 DB::delete('dzz_music_playlist',"idtype='{$idtype}' and uid='{$uid}' and typeid='{$typeid}'");
		}
	}
	cpmsg($lang['do_success'],$_G['siteurl'].$_POST['refer'],'succeed');
	
}else{
	if(!$plugin=DB::fetch_first("select * from ".DB::table('dzz_plugin')." where identifier='{$identifier}'")){
		showmessage('plugin_nonexistence');
	}
	if($plugin['available']<1){
		exit(dzzlang('message','plugin_closed'));
	}
	define('PLUGIN_ROOT','dzz/plugin/'.$plugin['directory']);
	dzz_shownav($lang['menu_plugin'],$plugin['name']);
	$page = empty($_GET['page'])?1:intval($_GET['page']);
		$uid=intval($_GET['uid']);
		$username=trim($_GET['username']);
		$songname=trim($_GET['songname']);
		$perpage = 20;
		$start = ($page-1)*$perpage;
		$gets = array(
				'action'=>$action,
				'uid'=>$uid,
				'username'=>$username,
				'songname'=>$songname,
			);
	$theurl = ADMINSCRIPT."?".url_implode($gets);
	$wheresql="1";
	if($username) $wheresql.=" and username='{$username}'";
	if($uid) $wheresql.=" and uid='{$uid}'";
	if($songname){
				$wheresql.=" and playlist LIKE '%".$songname."%'";
			}
	$list=array();
	$count=DB::result_first("SELECT COUNT(*) FROM ".DB::table('dzz_music_playlist')." where $wheresql  ");
	if($count){
		$query=DB::query("select * from ".DB::table('dzz_music_playlist')." where $wheresql order by dateline DESC");
		while($value=DB::fetch($query)){
			$value['playlist']=dstripslashes(unserialize(stripslashes($value['playlist'])));
			$value['dateline']=dgmdate($value['dateline']);
			$list[]=$value;
		}
	}

	$multi = multi($count, $perpage, $page, $theurl);
	
	include dzztemplate($identifier.':admin');
}
dzzfooter();
?>