<?PHP
/*******************************************
Avatar Class
Version 1.0
Author: duketang
Msn:
tangxl@gi310.com QQ: 8339544
Date: 2005/12/22
********************************************/
class xshow_class
{
var $db;
var $conf;
var $user_path;
var $temp_path;
var $user_id;
var $default_layer;
var $out_suit_layer;
var $default_boy_module;
var $default_girl_module;
function xshow_class()
{
global $db,$conf;
$this->db = $db;
$this->conf = $conf;
$this->user_id = phone_user_id();
$this->user_path = "/test_system/test.cn/data/xshow/user_profile/".ceil($this->user_id/3000)."/".$this->user_id."/";
$this->temp_path = "/test_system/test.cn/data/xshow/user_temp/";
//必选层
$this->default_layer = array(5,6,7,8,10,11,13);
//套装互斥层
$this->out_suit_layer = array(3,6,7,9,10,11);
//默认结构
$this->default_boy_module = array(
5 => array(7,0,11,'N',12,''),
6 => array(1,0,0,'N',1,''),
7 => array(2,0,0,'N',3,''),
8 => array(3,0,0,'Y',5,''),
10 => array(4,0,0,'N',7,''),
11 => array(5,0,0,'N',9,''),
13 => array(6,0,12,'N',11,'')
);
$this->default_girl_module = array(
5 => array(7,0,13,'N',14,''),
6 => array(1,0,0,'N',2,''),
7 => array(2,0,0,'N',4,''),
8 => array(3,0,0,'Y',6,''),
10 => array(4,0,0,'N',8,''),
11 => array(5,0,0,'N',10,''),
13 => array(6,0,14,'N',13,'')
);
}
/**
* 检测性别
*/
function check_sex($show_user_id)
{
$user_path = "/test_system/test.cn/data/xshow/user_profile/".ceil($show_user_id/3000)."/".$show_user_id."/";
if(!file_exists($this->user_path."main.xml") and $_GET['code'] != "new_xshow")
{
$wml_data .= "<card id='my_space' title='我的空间'>";
$wml_data .= "<p align='left'>n";
$wml_data .= "请确定你的性别(注意:本次选定以后将不能再做修改!)<br/>";
$wml_data .= "<select name='sex'><option value='1'>男</option><option value='2'>女</option></select><br/>";
if($_GET['action']=="camer" and $_GET['camer_id'] != "")
{
$wml_data .= "<anchor title='Click'>进入我的形象<go href='./page.php?action=xshow&code=new_xshow&testSESSID=".$_GET['testSESSID']."&up_url=".urlencode("/page.php?action=".$_GET['action']."&code=".$_GET['code']."&camer_id=".$_GET['camer_id'])."' method='post'><postfield name='sex' value='$(sex)'/></go></anchor><br/>";
}else{
$wml_data .= "<anchor title='Click'>进入我的形象<go href='./page.php?action=xshow&code=new_xshow&testSESSID=".$_GET['testSESSID']."' method='post'><postfield name='sex' value='$(sex)'/></go></anchor><br/>";
}
$wml_data .= "--------------<br/>";
$wml_data .= "<a href='index2.wml'>回门户首页</a></p>n";
$this->wml_data = $wml_data;
$this->out_page();
include_once($this->conf['WAP_INCLUDE_PATH']."/foot.inc.php");
exit();
}
}
/**
* 生成主形象
*
* @param int $show_user_id 用户ID
* @param char $xml_file 所使用数据名
* @param char $res_file 生成文件名
* @param int $start_layer 所使用层集合
*/
function xshow_process($show_user_id,$xml_file="main",$res_file="main",$layer_array="")
{
$show_user_path = "/test_system/test.cn/data/xshow/user_profile/".ceil($show_user_id/3000)."/".$show_user_id."/";
$xml_data = new XMLParser($show_user_path.$xml_file.".xml");
$main_data = $xml_data->result->profile_data;
$ani = false;
$for_i = 1;
$last_layer = "";
$layer_count = sizeof($main_data->layer);
$s_img_path = "/test_system/test.cn/data/xshow/";
if($layer_array==""){
for ($i=1;$i<=100;$i++){
$layer_array[] = $i;
}
}
//print_r($layer_array);
foreach ($main_data->layer as $layer_data)
{
if(in_array($layer_data->ln,$layer_array))
{
if($layer_data->ani == "Y") $ani = true;
//echo $for_i."<br>";
if($for_i == 1) $last_layer = $layer_data;
if(!$ani and $for_i == 1)
{
copy($s_img_path.$last_layer->ln."/".$last_layer->type."/".$last_layer->img.".gif",$this->temp_path.$show_user_id."_user.gif");
}elseif($ani and $for_i == 1){
for ($ani_for_i = 0;$ani_for_i<4;$ani_for_i++)
{
copy($s_img_path.$last_layer->ln."/".$last_layer->type."/".$last_layer->img."_f_0".$ani_for_i.".gif",$this->temp_path.$show_user_id."_user_f_0".$ani_for_i.".gif");
}
}
if(!$ani)
{
if($for_i > 1)
{
$last_img =imagecreatefromgif($this->temp_path.$show_user_id."_user".".gif");
$last_img_size=getimagesize($this->temp_path.$show_user_id."_user".".gif",$last_img_info);
$layer_img =imagecreatefromgif($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif");
$layer_img_size = getimagesize($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif");
imagecopy ($last_img,$layer_img,0,0,0,0,$layer_img_size[0],$layer_img_size[1]);
imagedestroy($layer_img);
imagegif($last_img, $this->temp_path.$show_user_id."_user.gif");
imagedestroy($last_img);
}
}else{
if($for_i > 1)
{
if(!file_exists($this->temp_path.$show_user_id."_user_f_00.gif"))
{
copy($this->temp_path.$show_user_id."_user.gif",$this->temp_path.$show_user_id."_user_f_00.gif");
copy($this->temp_path.$show_user_id."_user.gif",$this->temp_path.$show_user_id."_user_f_01.gif");
copy($this->temp_path.$show_user_id."_user.gif",$this->temp_path.$show_user_id."_user_f_02.gif");
copy($this->temp_path.$show_user_id."_user.gif",$this->temp_path.$show_user_id."_user_f_03.gif");
}
if($layer_data->ani == "Y")
{
for ($ani_for_i=0;$ani_for_i<4;$ani_for_i++)
{
//echo $this->temp_path.$this->user_id."_user_f_0".$ani_for_i.".gif"."<br/>";
//echo $s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif"."<br/>";
$last_img =imagecreatefromgif($this->temp_path.$show_user_id."_user_f_0".$ani_for_i.".gif");
$last_img_size=getimagesize($this->temp_path.$show_user_id."_user_f_0".$ani_for_i.".gif",$last_img_info);
$layer_img =imagecreatefromgif($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img."_f_0".$ani_for_i.".gif");
$layer_img_size = getimagesize($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img."_f_0".$ani_for_i.".gif");
imagecopy ($last_img,$layer_img,0,0,0,0,$layer_img_size[0],$layer_img_size[1]);
imagedestroy($layer_img);
imagegif($last_img, $this->temp_path.$show_user_id."_user_f_0".$ani_for_i.".gif");
imagedestroy($last_img);
}
}else{
for ($ani_for_i=0;$ani_for_i<4;$ani_for_i++)
{
//echo $this->temp_path.$this->user_id."_user_f_0".$ani_for_i.".gif"."<br/>";
//echo $s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif"."<br/>";
$last_img =imagecreatefromgif($this->temp_path.$show_user_id."_user_f_0".$ani_for_i.".gif");
$last_img_size=getimagesize($this->temp_path.$show_user_id."_user_f_0".$ani_for_i.".gif",$last_img_info);
$layer_img =imagecreatefromgif($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif");
$layer_img_size = getimagesize($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif");
imagecopy ($last_img,$layer_img,0,0,0,0,$layer_img_size[0],$layer_img_size[1]);
imagedestroy($layer_img);
imagegif($last_img, $this->temp_path.$show_user_id."_user_f_0".$ani_for_i.".gif");
imagedestroy($last_img);
}
}
}
}
$for_i++;
}
}
//system("/usr/local/imagemagick/bin/convert -compress LZW".$this->temp_path.$show_user_id."_user_f_00.gif");
//system("/usr/local/imagemagick/bin/convert -compress LZW".$this->temp_path.$show_user_id."_user_f_01.gif");
//system("/usr/local/imagemagick/bin/convert -compress LZW".$this->temp_path.$show_user_id."_user_f_02.gif");
//system("/usr/local/imagemagick/bin/convert -compress LZW".$this->temp_path.$show_user_id."_user_f_03.gif");
system("/usr/local/imagemagick/bin/convert -loop 1000 -delay 30 ".$this->temp_path.$show_user_id."_user_f_0*.gif ".$show_user_path.$res_file.".gif");
@unlink($this->temp_path.$show_user_id."_user.gif");
@unlink($this->temp_path.$show_user_id."_user_f_00.gif");
@unlink($this->temp_path.$show_user_id."_user_f_01.gif");
@unlink($this->temp_path.$show_user_id."_user_f_02.gif");
@unlink($this->temp_path.$show_user_id."_user_f_03.gif");
}
/**
* 试用产品
*
* @param unknown_type $show_user_id
* @param unknown_type $product_id
*/
function test_product($show_user_id,$product_id,$xml_file,$product_uid='',$mode='+')
{
$this->create_xml_data($show_user_id,$product_id,$xml_file,$product_uid,$mode);
$this->xshow_process($show_user_id,$xml_file,$xml_file);
return $xml_file;
}
/**
* 清除临时文件
*
* @param unknown_type $show_user_id
* @param unknown_type $file_name
*/
function clear_tmp_data($show_user_id,$file_name)
{
@unlink($this->user_path.$file_name.".xml");
@unlink($this->user_path.$file_name.".gif");
}
/**
* 生成配置文件
*/
function create_xml_data($show_user_id,$product_id,$xml_file,$product_uid='',$mode='+')
{
$user_sex = $this->db->get_var("select sex from test_user where id=".$show_user_id);
$show_user_path = "/test_system/test.cn/data/xshow/user_profile/".ceil($show_user_id/3000)."/".$show_user_id."/";
$xml_data = new XMLParser($show_user_path."main.xml");
$main_data = $xml_data->result->profile_data;
$product_data = $this->db->get_row("SELECT product . * , type.layer_id FROM test_xshow_img_list AS product, test_xshow_img_type AS type WHERE product.img_id =".$product_id." AND product.img_type = type.type_id");
$temp_array[$product_data->layer_id] = array($product_data->layer_id,$product_data->img_type,time()+$product_data->img_expire,$product_data->img_link,$product_data->img_ani,$product_data->img_id,$product_uid);
if($product_data->img_link != 0)
{
$product_link = true;
$product_link_data = $this->db->get_row("SELECT product . * , type.layer_id FROM test_xshow_img_list AS product, test_xshow_img_type AS type WHERE product.img_id =".$product_data->img_link." AND product.img_type = type.type_id");
$temp_array[$product_link_data->layer_id] = array($product_link_data->layer_id,$product_link_data->img_type,time()+$product_link_data->img_expire,$product_link_data->img_link,$product_link_data->img_ani,$product_link_data->img_id);
}else{ $product_link = false; }
if($product_data->img_suit == "Y") $product_suit = true; else $product_suit=false;
foreach ($main_data->layer as $layer_data)
{
if($layer_data->ln != $product_data->layer_id)
{
if(($product_link && $layer_data->ln != $product_link_data->layer_id) || !$product_link)
{
$temp_array[$layer_data->ln] = array($layer_data->ln,$layer_data->type,$layer_data->expr,$layer_data->link,$layer_data->ani,$layer_data->img,$layer_data->pid);
}
}
}
if($mode == "-")
{
unset($temp_array[$product_data->layer_id]);
if($product_link) {unset($temp_array[$product_link_data->layer_id]);}
}
if($product_suit)
{
foreach ($temp_array as $layer_data)
{
if(in_array($layer_data[0],$this->out_suit_layer))
{
if($layer_data[3] != 0) unset($temp_array[$layer_data[0]]);
unset($temp_array[$layer_data[0]]);
}
}
}
if($user_sex==1) $must_array = $this->default_boy_module; else $must_array = $this->default_girl_module;
if(!$product_suit || $mode=='-')
{
while (list($id,$key) = each($must_array)) {
if(!is_array($temp_array[$id])){
$temp_array[$id] = array($id,$must_array[$id][0],$must_array[$id][1],$must_array[$id][2],$must_array[$id][3],$must_array[$id][4],$must_array[$id][5]);
}
}
}
if(in_array($product_data->layer_id, $this->out_suit_layer)){
unset($temp_array[12]);
}
ksort($temp_array);
$main_xml_data = "<?xml version='1.0' encoding='GB2312'?>n";
$main_xml_data .= "<profile_data>n";
foreach ($temp_array as $layer_data)
{
$main_xml_data .= "<layer ln='".$layer_data[0]."' type='".$layer_data[1]."' expr='".$layer_data[2]."' link='".$layer_data[3]."' ani='".$layer_data[4]."' img='".$layer_data[5]."' pid='".$layer_data[6]."'/>n";
#echo "layer_id:".$layer_data[0]." img_type:".$layer_data[1]." img_expr:".$layer_data[2]." img_link:".$layer_data[3]." img_ani:".$layer_data[4]." img_id:".$layer_data[5]."<br/>";
}
$main_xml_data .= "</profile_data>";
$write_file = fopen($show_user_path.$xml_file.".xml","wb");
fwrite($write_file,$main_xml_data);
fclose($write_file);
}
/**
* Enter description here...
*
* @param unknown_type $用户ID
* @param unknown_type $物品ID
* @param unknown_type $物品是一次使用还是多次使用 value=1使用一次 value=0使用多次
* @return unknown
*/
function buy_product_process($show_user_id,$product_id,$go_in=0,$rec_user="")
{
if($rec_user == "") $rec_user = $show_user_id;
$user_level_data = user_level($show_user_id);
$user_level_data = explode("|",$user_level_data);
$user_money=$this->db->get_row("select moneyp,moneyb from test_user where id=".$show_user_id);
$product_data = $this->db->get_row("select product.*,type.layer_id,type.type_name from test_xshow_img_list as product,test_xshow_img_type as type where product.img_type = type.type_id and product.img_status ='Y' and product.img_id=".$product_id);
if(($product_data->img_price_type=="B" and $product_data->img_price <= $user_money->moneyb) || ($product_data->img_price_type=="P" and $product_data->img_price <= $user_money->moneyp) and $product_data->img_level <= $user_level_data[0])
{
if($product_data->img_price_type=="B")
{ $m_query = "update test_user set moneyb = moneyb - $product_data->img_price where id=".$show_user_id;}
else
{ $m_query = "update test_user set moneyp = moneyp - $product_data->img_price where id=".$show_user_id;}
$this->db->query($m_query);
$this->db->query("insert into test_xshow_buy_log values($show_user_id,".time().",$product_data->layer_id,$product_data->img_type,$product_data->img_id)");
if($go_in == 0)
{
$this->db->query("insert into test_xshow_user values('',$rec_user,$product_id,$product_data->layer_id,$product_data->img_type,".(time()+$product_data->img_expire).",'N',".time().")");
}
$last_insert_id = $this->db->get_var("SELECT LAST_INSERT_ID()");
return $last_insert_id;
}else{
if(($product_data->img_price_type=="B" and $product_data->img_price > $user_money->moneyb) || ($product_data->img_price_type=="P" and $product_data->img_price > $user_money->moneyp))
{
return "money";
}elseif($product_data->img_level > $user_level_data[0])
{
return "level";
}
}
}
/**
* 刷新主形象
*
* @param unknown_type $show_user_id $用户ID
*
*/
function ref_main($show_user_id)
{
$show_user_path = "/test_system/test.cn/data/xshow/user_profile/".ceil($show_user_id/3000)."/".$show_user_id."/";
$xml_data = new XMLParser($show_user_path."main.xml");
$main_data = $xml_data->result->profile_data;
foreach ($main_data->layer as $layer_data)
{
if($layer_data->pid != "")
{
$tmp_array[] = $layer_data->pid;
}
}
if(sizeof($tmp_array)>0)
{
$q_array = $this->csql_type($tmp_array);
$this->db->query("update test_xshow_user set use_status='N' where id not in (".$q_array.")");
$this->db->query("update test_xshow_user set use_status='Y' where id in (".$q_array.")");
}
$show_type = $this->db->get_var("select user_status from test_xshow_user_status where user_id=".$show_user_id);
if($show_type == 'S') $this->mirror_show($show_user_id,"main");
}
/**
* 重置用户物品状态
*
* @param unknown_type $show_user_id
* @param unknown_type $user_product_id
*/
function set_product_status($show_user_id,$user_product_id)
{
}
/**
* Enter description here...
*
* @param unknown_type $show_user_id
* @param unknown_type $show_file
*/
function mirror_show($show_user_id,$show_file)
{
copy("/test_system/test.cn/data/xshow/user_profile/".ceil($this->user_id/3000)."/".$this->user_id."/".$show_file.".gif","/test_system/test.cn/data/xshow/user_profile/".ceil($this->user_id/3000)."/".$this->user_id."/"."show.gif");
}
function copy_photo($show_user_id,$source_file,$target_file)
{
copy("/test_system/test.cn/data/xshow/user_profile/".ceil($this->user_id/3000)."/".$this->user_id."/".$source_file.".gif","/test_system/test.cn/data/xshow/user_profile/".ceil($this->user_id/3000)."/".$this->user_id."/photo/".$target_file.".gif");
}
function photo_show($show_user_id,$show_file)
{
$photo_author = $this->db->get_var("select user_id from test_xshow_user_photo where id=".$show_file);
if($photo_author == $this->user_id)
{
copy("/test_system/test.cn/data/xshow/user_profile/".ceil($this->user_id/3000)."/".$this->user_id."/photo/".$show_file.".gif","/test_system/test.cn/data/xshow/user_profile/".ceil($this->user_id/3000)."/".$this->user_id."/"."show.gif");
$this->db->query("update test_xshow_user_status set user_status ='P' where user_id=".$this->user_id);
}
}
/**
* 转换数组
*
* @param unknown_type $type_array
* @return unknown
*/
function csql_type($type_array)
{
$csql="";
for ($i=0;$i<=sizeof($type_array);$i++){
if ($i>0 and $i<sizeof($type_array)) {$csql .= ",";}
$csql .= $type_array[$i];
}
return $csql;
}
function check_m_camer_user($camer_id,$camer_user,$mode)
{
$camer_data = $this->db->get_row("select * from test_xshow_camer_log where camer_id=".$camer_id);
$camer_user_array [] = $camer_data->u1;
$camer_user_array [] = $camer_data->u2;
$camer_user_array [] = $camer_data->u3;
$camer_user_array [] = $camer_data->u4;
$camer_user_count = 0;
while (list($key,$user_id) = each($camer_user_array)) {
if($user_id != "")
{
$tmp_user_id = explode(":",$user_id);
if($camer_user == $tmp_user_id[0])
{
if($tmp_user_id[2] == "N")
{
if($mode == "agree"){
$this->db->query("update test_xshow_camer_log set u".($key+1)."='".$camer_user.":Y:Y' where camer_id=".$camer_id);
$camer_nick = $this->db->get_var("select nick from test_user where id=".$camer_user);
insert_msg($camer_data->user_id,1006,$camer_nick."(".$camer_user.")同意了你发起的多人合照!<br
/>");
$camer_user_array[$key] = $camer_user.":Y:Y";
}elseif($mode=="reject"){
$this->db->query("update test_test_xshow_camer_log set u".($key+1)."='".$camer_user.":N:Y' where camer_id=".$camer_id);
$camer_nick = $this->db->get_var("select nick from test_user where id=".$camer_user);
insert_msg($camer_data->user_id,1006,$camer_nick."(&q
uot;.$camer_user.")拒绝了你发起的多人合照!<br/>");
$camer_user_array[$key] = $camer_user.":N:Y";
}
}
}
$camer_user_count ++;
}
}
reset($camer_user_array);
$true_user = 0;
while (list($id,$user_id) = each($camer_user_array)) {
if(substr($user_id,-4) == ":Y:Y"){
$true_user ++;
}
}
if($true_user == $camer_user_count)
{
$this->db->query("update test_xshow_camer_log set status='Y' where camer_id=".$camer_id);
$this->do_m_camer_process($camer_id);
}
}
function do_m_camer_process($camer_id)
{
$camer_data = $this->db->get_row("select * from test_xshow_camer_log where camer_id=".$camer_id." and status = 'Y'");
{
$camer_user = array();
$camer_user[] = $camer_data->user_id;
if($camer_data->u1!="") $camer_user[] = $camer_data->u1;
if($camer_data->u2!="") $camer_user[] = $camer_data->u2;
if($camer_data->u3!="") $camer_user[] = $camer_data->u3;
if($camer_data->u4!="") $camer_user[] = $camer_data->u4;
$camer_user_id = array();
$s_img_path = "/test_system/test.cn/data/xshow/";
$layer_array = array(2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
$file_fix = "camer_".$camer_id."_".$camer_data->user_id."_";
$camer_user_count = sizeof($camer_user);
if(sizeof($camer_user_count) > 0)
{
while(list($key,$user_data) = each($camer_user))
{
unset($main_data);
unset($xml_data);
unset($layer_data);
$user_data = explode(":",$user_data);
$show_user_id = $user_data[0];
$camer_user_id[] = $user_data[0];
$xml_file = "main";
$show_user_path = "/test_system/test.cn/data/xshow/user_profile/".ceil($show_user_id/3000)."/".$show_user_id."/";
$xml_data = new XMLParser($show_user_path.$xml_file.".xml");
$main_data = $xml_data->result->profile_data;
$ani = false;
$for_i = 1;
$last_layer = "";
$layer_count = sizeof($main_data->layer);
foreach ($main_data->layer as $layer_data)
{
if(in_array($layer_data->ln,$layer_array))
{
if($layer_data->ani == "Y") $ani = true;
//echo $for_i."<br>";
if($for_i == 1) $last_layer = $layer_data;
if(!$ani and $for_i == 1)
{
copy($s_img_path.$last_layer->ln."/".$last_layer->type."/".$last_layer->img.".gif",$this->temp_path.$file_fix.$show_user_id."_user.gif");
}elseif($ani and $for_i == 1){
for ($ani_for_i = 0;$ani_for_i<4;$ani_for_i++)
{
copy($s_img_path.$last_layer->ln."/".$last_layer->type."/".$last_layer->img."_f_0".$ani_for_i.".gif",$this->temp_path.$file_fix.$show_user_id."_user_f_0".$ani_for_i.".gif");
}
}
if(!$ani)
{
if($for_i > 1)
{
$last_img =imagecreatefromgif($this->temp_path.$file_fix.$show_user_id."_user".".gif");
$last_img_size=getimagesize($this->temp_path.$file_fix.$show_user_id."_user".".gif",$last_img_info);
$layer_img =imagecreatefromgif($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif");
$layer_img_size = getimagesize($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif");
imagecopy ($last_img,$layer_img,0,0,0,0,$layer_img_size[0],$layer_img_size[1]);
imagedestroy($layer_img);
imagegif($last_img, $this->temp_path.$file_fix.$show_user_id."_user.gif");
imagedestroy($last_img);
}
}else{
if($for_i > 1)
{
if(!file_exists($this->temp_path.$file_fix.$show_user_id."_user_f_00.gif"))
{
copy($this->temp_path.$file_fix.$show_user_id."_user.gif",$this->temp_path.$file_fix.$show_user_id."_user_f_00.gif");
copy($this->temp_path.$file_fix.$show_user_id."_user.gif",$this->temp_path.$file_fix.$show_user_id."_user_f_01.gif");
copy($this->temp_path.$file_fix.$show_user_id."_user.gif",$this->temp_path.$file_fix.$show_user_id."_user_f_02.gif");
copy($this->temp_path.$file_fix.$show_user_id."_user.gif",$this->temp_path.$file_fix.$show_user_id."_user_f_03.gif");
}
if($layer_data->ani == "Y")
{
for ($ani_for_i=0;$ani_for_i<4;$ani_for_i++)
{
//echo $this->temp_path.$file_fix.$show_user_id."_user_f_0".$ani_for_i.".gif"."<br/>";
//echo $s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif"."<br/>";
$last_img =imagecreatefromgif($this->temp_path.$file_fix.$show_user_id."_user_f_0".$ani_for_i.".gif");
$last_img_size=getimagesize($this->temp_path.$file_fix.$show_user_id."_user_f_0".$ani_for_i.".gif");
$layer_img =imagecreatefromgif($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img."_f_0".$ani_for_i.".gif");
$layer_img_size = getimagesize($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img."_f_0".$ani_for_i.".gif");
imagecopy ($last_img,$layer_img,0,0,0,0,$layer_img_size[0],$layer_img_size[1]);
imagedestroy($layer_img);
imagegif($last_img, $this->temp_path.$file_fix.$show_user_id."_user_f_0".$ani_for_i.".gif");
imagedestroy($last_img);
}
}else{
for ($ani_for_i=0;$ani_for_i<4;$ani_for_i++)
{
//echo $this->temp_path.$this->user_id."_user_f_0".$ani_for_i.".gif"."<br/>";
//echo $s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif"."<br/>";
$last_img =imagecreatefromgif($this->temp_path.$file_fix.$show_user_id."_user_f_0".$ani_for_i.".gif");
$last_img_size=getimagesize($this->temp_path.$file_fix.$show_user_id."_user_f_0".$ani_for_i.".gif");
$layer_img =imagecreatefromgif($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif");
$layer_img_size = getimagesize($s_img_path.$layer_data->ln."/".$layer_data->type."/".$layer_data->img.".gif");
imagecopy ($last_img,$layer_img,0,0,0,0,$layer_img_size[0],$layer_img_size[1]);
imagedestroy($layer_img);
imagegif($last_img, $this->temp_path.$file_fix.$show_user_id."_user_f_0".$ani_for_i.".gif");
imagedestroy($last_img);
}
}
}
}
$for_i++;
}
}
//system("/usr/local/imagemagick/bin/convert -loop 1000 -delay 30 ".$this->temp_path.$show_user_id."_user_f_0*.gif ".$show_user_path.$res_file.".gif");
//@unlink($this->temp_path.$show_user_id."_user.gif");
//@unlink($this->temp_path.$show_user_id."_user_f_00.gif");
//@unlink($this->temp_path.$show_user_id."_user_f_01.gif");
//@unlink($this->temp_path.$show_user_id."_user_f_02.gif");
//@unlink($this->temp_path.$show_user_id."_user_f_03.gif");
}
}
$user_sex = $this->db->get_results("select sex,id from test_user where id in(".$this->csql_type($camer_user_id).") order by id desc");
if($camer_user_count == 2){
if(($user_sex[0]->sex == $user_sex[1]->sex) and ($user_sex[0]->sex == 1 or $user_sex[0]->sex == 2))
{
$user_place[0] = array(19,0,0,0,91,150);
$user_place[1] = array(18,0,0,0,91,150);
//$user_place[0] = array(35,0,0,0,91,150);
//$user_place[1] = array(0,0,0,0,91,150);
}elseif($user_sex[0]->sex == 1 and $user_sex[1]->sex == 2){
$user_place[0] = array(19,5,0,0,91,145);
$user_place[1] = array(18,0,0,0,91,150);
}elseif($user_sex[0]->sex == 2 and $user_sex[1]->sex == 1){
$user_place[0] = array(18,0,0,0,91,150);
$user_place[1] = array(19,-4,0,0,91,150);
}
}elseif($camer_user_count == 3){
$user_place[0] = array(27,0,0,0,91,150);
$user_place[1] = array(0,0,0,0,91,150);
$user_place[2] = array(30,0,0,0,91,150);
}elseif($camer_user_count == 4){
$user_place[0] = array(10,0,0,0,91,150);
$user_place[1] = array(35,0,0,0,91,150);
$user_place[2] = array(0,40,35,0,91,150);
$user_place[3] = array(10,40,0,0,91,150);
}elseif($camer_user_count == 5){
$user_place[0] = array(20,5,0,0,91,150);
$user_place[1] = array(25,0,0,5,91,150);
$user_place[2] = array(0,40,35,0,91,150);
$user_place[3] = array(0,40,0,0,91,150);
$user_place[4] = array(35,40,0,0,91,150);
}
$user_key=0;
foreach ($user_sex as $camer_user_data)
{
if($user_key == 0)
{
for ($gif_i = 0;$gif_i < 4;$gif_i++)
{
$last_img =imagecreatefromgif($this->temp_path.$file_fix.$camer_user_data->id."_user_f_0".$gif_i.".gif");
$next_img =imagecreatefromgif($this->temp_path."default_camer.gif");
imagecopy ($next_img,$last_img,$user_place[$user_key][2],$user_place[$user_key][3],$user_place[$user_key][0],$user_place[$user_key][1],$user_place[$user_key][4],$user_place[$user_key][5]);
imagedestroy($last_img);
imagegif($next_img,$this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_f_0".$gif_i.".gif");
imagedestroy($next_img);
}
}else{
for ($gif_i = 0;$gif_i < 4;$gif_i++)
{
$last_img =imagecreatefromgif($this->temp_path.$file_fix.$camer_user_data->id."_user_f_0".$gif_i.".gif");
$next_img =imagecreatefromgif($this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_f_0".$gif_i.".gif");
imagecopy ($next_img,$last_img,$user_place[$user_key][0],$user_place[$user_key][1],$user_place[$user_key][2],$user_place[$user_key][3],$user_place[$user_key][4],$user_place[$user_key][5]);
imagedestroy($last_img);
imagegif($next_img, $this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_f_0".$gif_i.".gif");
imagedestroy($next_img);
}
}
$user_key ++;
}
$bk_data = $this->db->get_row("SELECT type.layer_id, img.img_type FROM test_xshow_img_list AS img, test_xshow_img_type AS type WHERE img.img_type = type.type_id AND img.img_id =".$camer_data->bk_id);
for ($gif_i = 0;$gif_i < 4;$gif_i++)
{
$last_img =imagecreatefromgif($this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_f_0".$gif_i.".gif");
$next_img =imagecreatefromgif($s_img_path.$bk_data->layer_id."/".$bk_data->img_type."/".$camer_data->bk_id.".gif");
imagecopy ($next_img,$last_img,0,0,0,0,126,150);
imagedestroy($last_img);
imagegif($next_img, $this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_f_0".$gif_i.".gif");
imagedestroy($next_img);
}
//echo "/usr/local/imagemagick/bin/convert -loop 1000 -delay 30 ".$this->temp_path.$show_user_id."_user_f_0*.gif /test_system/test.cn/data/xshow/user_profile/".ceil($camer_data->user_id/3000)."/".$camer_data->user_id."/photo/".$camer_data->camer_id.".gif";
$this->db->query("insert into test_xshow_user_photo values('',$camer_data->user_id,'".$camer_data->camer_title."',".time().",0,'Y')");
$master_photo_id = $this->db->get_var("SELECT LAST_INSERT_ID()");
system("/usr/local/imagemagick/bin/convert -loop 1000 -delay 30 ".$this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_f_0*.gif /test_system/test.cn/data/xshow/user_profile/".ceil($camer_data->user_id/3000)."/".$camer_data->user_id."/photo/".$master_photo_id.".gif");
@unlink($this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_f_00.gif");
@unlink($this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_f_01.gif");
@unlink($this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_f_02.gif");
@unlink($this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_f_03.gif");
reset($camer_user);
while (list($key,$cmuser_id) = each($camer_user_id)) {
if($cmuser_id != $camer_data->user_id)
{
$this->db->query("insert into test_xshow_user_photo values('',$cmuser_id,'".$camer_data->camer_title."',".time().",0,'Y')");
$photo_id = $this->db->get_var("SELECT LAST_INSERT_ID()");
copy("/test_system/test.cn/data/xshow/user_profile/".ceil($camer_data->user_id/3000)."/".$camer_data->user_id."/photo/".$master_photo_id.".gif","/test_system/test.cn/data/xshow/user_profile/".ceil($cmuser_id/3000)."/".$cmuser_id."/photo/".$photo_id.".gif");
}
@unlink($this->temp_path."camer_".$camer_id."_".$camer_data->user_id."_".$cmuser_id."_user.gif");
@unlink($this->temp_path.$file_fix.$cmuser_id."_user_f_00.gif");
@unlink($this->temp_path.$file_fix.$cmuser_id."_user_f_01.gif");
@unlink($this->temp_path.$file_fix.$cmuser_id."_user_f_02.gif");
@unlink($this->temp_path.$file_fix.$cmuser_id."_user_f_03.gif");
}
$this->db->query("update test_xshow_camer_log set status='O' where camer_id=".$camer_data->camer_id);
}
}
}
?>