/**
* 保存图片时响应
*/
function onrectavatar() {
@header ( "Expires: 0" );
@header ( "Cache-Control: private, post-check=0, pre-check=0, max-age=0", FALSE );
@header ( "
ragma: no-cache" );
header ( "Content-type: application/xml; charset=utf-8" );
$arr = array ();
parse_str ( $_GET ['input'], $arr );
$uid = intval ( $arr ['uid'] );
if (empty ( $uid )) {
return '<root><message type="error" value="-1" /></root>';
}
$home = $this->get_home ( $uid );
if (! is_dir ( $this->systempath . $this->avatarpath . $home )) {
$this->set_home ( $uid, $this->systempath . $this->avatarpath );
}
$bigavatarfile = $this->systempath . $this->avatarpath . $this->get_avatar ( $uid, 'big' );
$middleavatarfile = $this->systempath . $this->avatarpath . $this->get_avatar ( $uid, 'middle' );
$smallavatarfile = $this->systempath . $this->avatarpath . $this->get_avatar ( $uid, 'small' );
$array_pic_url=array('bigavatarfile'=>$bigavatarfile,'middleavatarfile'=>$middleavatarfile,'smallavatarfile'=>$smallavatarfile);
@$this->insert_imgurl($array_pic_url);
$bigavatar = $this->flashdata_decode ( $_POST ['avatar1'] );
$middleavatar = $this->flashdata_decode ( $_POST ['avatar2'] );
$smallavatar = $this->flashdata_decode ( $_POST ['avatar3'] );
if (! $bigavatar || ! $middleavatar || ! $smallavatar) {
return '<root><message type="error" value="-2" /></root>';
}
$success = 1;
$fp = @fopen ( $bigavatarfile, 'wb' );
@fwrite ( $fp, $bigavatar );
@fclose ( $fp );
$fp = @fopen ( $middleavatarfile, 'wb' );
@fwrite ( $fp, $middleavatar );
@fclose ( $fp );
$fp = @fopen ( $smallavatarfile, 'wb' );
@fwrite ( $fp, $smallavatar );
@fclose ( $fp );
$biginfo = @getimagesize ( $bigavatarfile );
$middleinfo = @getimagesize ( $middleavatarfile );
$smallinfo = @getimagesize ( $smallavatarfile );
if (! $biginfo || ! $middleinfo || ! $smallinfo || $biginfo [2] == 4 || $middleinfo [2] == 4 || $smallinfo [2] == 4) {
file_exists ( $bigavatarfile ) && unlink ( $bigavatarfile );
file_exists ( $middleavatarfile ) && unlink ( $middleavatarfile );
file_exists ( $smallavatarfile ) && unlink ( $smallavatarfile );
$success = 0;
}
$filetype = '.jpg';
@unlink ( $this->systempath . $this->tmppath . 'useravatar' . $uid . $filetype );
//print_r($array_pic_url);
if ($success) {
return '
<?xml version
="1.0" ?><root><face success="1"/></root>';//return $array_pic_url;
}
return '
<?xml version
="1.0" ?><root><face success="0"/></root>';//return $array_pic_url;
}
function insert_imgurl($array_pic_url){
$ci = & get_instance ();
$data=array('url'=>$array_pic_url['smallavatarfile']);
$ci->db->insert('img_url',$data);
}