<?php

/**
 *      
 */


if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}
$do=$_GET['do']?$_GET['do']:'systhame';
$navtitle=dzzlang('thame/template','theme');

if($do=='systhame'){
//获取用户选择的主题信息
	
	$page = empty($_GET['page'])?1:intval($_GET['page']);
	$thames=array();
	$perpage = 12;
			//$perpage = mob_perpage($perpage);
	$start = ($page-1)*$perpage;
	$count=DB::result_first("SELECT COUNT(*) FROM ".DB::table('dzz_thame')." where 1 ");
	if($count){
		$query=DB::query("SELECT * FROM ".DB::table('dzz_thame')."  where 1 ORDER BY disp  LIMIT $start,$perpage" );
		while($value=DB::fetch($query)){
			if(!$value['backimg']) $value['backimg']='dzz/styles/thame/'.$value['folder'].'/back.jpg';
			$thames[$value['folder']]=$value;
		}
	}
	$thamejson=json_encode($thames);
	$multi = multi($count, $perpage, $page, DZZSCRIPT."?mod=thame");
	
}elseif($do=='color'){
	
	//获取所有颜色
	$page = empty($_GET['page'])?1:intval($_GET['page']);
	$thames=array();
	$perpage = 12;
			//$perpage = mob_perpage($perpage);
	$start = ($page-1)*$perpage;
	$count=DB::result_first("SELECT COUNT(*) FROM ".DB::table('dzz_wallpaper')." where type='color'");
	if($count){
		$query=DB::query("SELECT * FROM ".DB::table('dzz_wallpaper')."  where type='color' ORDER BY disp LIMIT $start,$perpage" );
		while($value=DB::fetch($query)){
			
			$thames[]=$value;
		}
	}
	$multi = multi($count, $perpage, $page, DZZSCRIPT."?mod=thame&do=$do");
}elseif($do=='repeat' || $do=='scale'){
	$page = empty($_GET['page'])?1:intval($_GET['page']);
	$thames=array();
	$classid=intval($_GET['classid']);
	$class=array();
	$query=DB::query("select * from ".DB::table('dzz_wallpaper_class')." where type='{$do}' order by disp DESC");
	while($value=DB::fetch($query)){
		$class[]=$value;
	}
	$perpage = 12;
	$wheresql="where type='{$do}'";
	if($classid) $wheresql.=" and  classid='{$classid}'";
			//$perpage = mob_perpage($perpage);
	$start = ($page-1)*$perpage;
	$count=DB::result_first("SELECT COUNT(*) FROM ".DB::table('dzz_wallpaper')." $wheresql");
	if($count){
		$query=DB::query("SELECT * FROM ".DB::table('dzz_wallpaper')." $wheresql ORDER BY disp DESC LIMIT $start,$perpage" );
		while($value=DB::fetch($query)){
			if($value['thumb']) $value['thumbpic']=$value['val'].'.thumb.jpg';
			else $value['thumbpic']=$value['val'];
			$thames[]=$value;
		}
	}
	$multi = multi($count, $perpage, $page, DZZSCRIPT."?mod=thame&do=$do&classid=$classid");
}elseif($do=='url'){
	$page = empty($_GET['page'])?1:intval($_GET['page']);
	$thames=array();
	$classid=intval($_GET['classid']);
	$class=array();
	$query=DB::query("select * from ".DB::table('dzz_wallpaper_class')." where type='{$do}' order by disp DESC");
	while($value=DB::fetch($query)){
		$class[]=$value;
	}
	$perpage = 12;
	$wheresql="where type='{$do}'";
	if($classid) $wheresql.=" and  classid='{$classid}'";
			//$perpage = mob_perpage($perpage);
	$start = ($page-1)*$perpage;
	$count=DB::result_first("SELECT COUNT(*) FROM ".DB::table('dzz_wallpaper')." $wheresql");
	if($count){
		$query=DB::query("SELECT * FROM ".DB::table('dzz_wallpaper')." $wheresql ORDER BY disp DESC LIMIT $start,$perpage" );
		while($value=DB::fetch($query)){
			if($value['thumb']) $value['thumbpic']=$value['img'].'.thumb.jpg';
			else $value['thumbpic']=$value['img'];
			$thames[]=$value;
		}
	}
	$multi = multi($count, $perpage, $page, DZZSCRIPT."?mod=thame&do=$do&classid=$classid");
}elseif($do=='dock' || $do=='topbar'|| $do=='window'|| $do=='browser'|| $do=='filemanage'){
	 $list=array();
	 $page = empty($_GET['page'])?1:intval($_GET['page']);
	 $perpage = 16;
	 $start = ($page-1)*$perpage;
	 $count=DB::result_first("SELECT COUNT(*) FROM ".DB::table('dzz_thameitem')." where idtype='{$do}'");
	 if($count){
		 $query=DB::query("select * from ".DB::table('dzz_thameitem')." where idtype='{$do}' ORDER BY disp LIMIT $start,$perpage");
		 while($value=DB::fetch($query)){
				$value['thumb']='dzz/styles/'.($do=='topbar'?'navbar':$do).'/'.$value['folder'].'/thumb.jpg';
				$list[]=$value;
		 }
	 }
	$multi = multi($count, $perpage, $page, DZZSCRIPT."?mod=thame&do=$do");
}
include dzztemplate('thame/thame_thame');

?>