<?php
defined('IN_TS') or die('Access Denied.');  
class zhuti{

	var $db;

	function zhuti($dbhandle){
		$this->db = $dbhandle;
	}
	
	function themesimg($goodid)
	{
	
			if($goodid){
				$Onegood = $this->db->once_fetch_assoc("select goods_id,oldimg,img from ".dbprefix."share_goods where goods_id in (".$goodid.")");
				
				$simgurl= $Onegood['img'];
				
				if(!is_file($simgurl)){
					$uptime = time();
			        $fold = date('Ymd',$uptime);
			        $random = random(14);
			        $dir = "cache/thumb/index/".$fold;
			        !is_dir($dir)?mkdir($dir,0777):'';
			        $imgurl="cache/thumb/index/".$fold."/".$random."w210.jpg";
					require_once 'letutao/class.image.php';
					$oldimgarr = explode('|',$Onegood['oldimg']);
				    $resizeimage = new tsImg($oldimgarr[0], "210", "", "0", "$imgurl" );
					$this->db->query("update ".dbprefix."share_goods set `img`='$imgurl' where goods_id='".$Onegood['goods_id']."'");
					$simgurl = $imgurl;
				}
				
				return $simgurl;
			}else{
				
				return '';
				
			}
			
			
		}
	

}
