Example #1
0
function savePhoto($uid)
{
    $x1 = MooGetGPC('x1', 'integer');
    $y1 = MooGetGPC('y1', 'integer');
    $x2 = MooGetGPC('x2', 'integer');
    $y2 = MooGetGPC('y2', 'integer');
    $width = MooGetGPC('width', 'integer');
    $height = MooGetGPC('height', 'integer');
    $photoimage = MooGetGPC('photoimage', 'string');
    $first_dir = substr($uid, -1, 1);
    $secend_dir = substr($uid, -2, 1);
    $third_dir = substr($uid, -3, 1);
    $forth_dir = substr($uid, -4, 1);
    $userpath = "../data/upload/userimg/" . $first_dir . "/" . $secend_dir . "/" . $third_dir . "/" . $forth_dir . "/";
    //$userpath="../data/upload/userimg/5/2/3/4/";
    //echo $userpath;
    if (!is_dir($userpath)) {
        $array = explode('/', $userpath);
        $count = count($array);
        for ($i = 0; $i < $count; $i++) {
            $msg .= $array[$i];
            if (!file_exists($msg)) {
                mkdir($msg, 0777);
            }
            $msg .= '/';
        }
    }
    //$newimages=resizeImage($photoimage,$width,$height,$x1,$y1,$uid);
    $sizearray = array(0 => array('width' => 320, 'height' => 400), 1 => array('width' => 171, 'height' => 212), 2 => array('width' => 100, 'height' => 125), 3 => array('width' => 60, 'height' => 75), 4 => array('width' => 50, 'height' => 63), 5 => array('width' => 110, 'height' => 138), 6 => array('width' => 100, 'height' => 125));
    $namearray = array(0 => 'big', 1 => 'mid', 2 => 'medium', 3 => 'small', 4 => 'page', 5 => 'com', 6 => 'index');
    $newimages = changesize($photoimage, $userpath, $x1, $y1, $width, $height, $uid, $sizearray, $namearray);
    //生成另外三种形象照
    /*$bigphoto=MooGetphotoAdmin($uid,'big');
    
    	$thuid=$uid*3;
    	//$userpath="../data/upload/userimg/";
    	$arr=explode('.',$bigphoto);
    	$jpg=$arr[count($arr)-1];
    	$index_name=$thuid.'_'.'index.'.$jpg;
    	$com_name  =$thuid.'_'.'com.'.$jpg;
    	$page_name =$thuid.'_'.'page.'.$jpg;
    	list($width,$height)=getimagesize($bigphoto);
    	$d=$width/$height;
    	$c=100/125;//100*125
    	if($d>$c){
    		$g1_width=100;
    		$b=$width/$g1_width;
    		$g1_height=$height/$b;
    	}else{
    		$g1_height=125;
    		$b=$height/$g1_height;
    		$g1_width=$width/$b;
    	}
    	ImagickResizeImage($bigphoto,$userpath.$index_name,$g1_width,$g1_height);
    	$c=50/63;//100*125
    	if($d>$c){
    		$g2_width=50;
    		$b=$width/$g2_width;
    		$g2_height=$height/$b;
    	}else{
    		$g2_height=63;
    		$b=$height/$g2_height;
    		$g2_width=$width/$b;
    	}
    	ImagickResizeImage($bigphoto,$userpath.$page_name,$g2_width,$g2_height);
    	$c=110/138;//100*125
    	if($d>$c){
    		$g3_width=110;
    		$b=$width/$g3_width;
    		$g3_height=$height/$b;
    	}else{
    		$g3_height=138;
    		$b=$height/$g3_height;
    		$g3_width=$width/$b;
    	}
    	ImagickResizeImage($bigphoto,$userpath.$com_name,$g3_width,$g3_height);	*/
    $sql = "UPDATE {$GLOBALS['dbTablePre']}members SET `images_ischeck`=1 WHERE `uid`='{$uid}'";
    $GLOBALS['_MooClass']['MooMySQL']->query($sql);
    if (MOOPHP_ALLOW_FASTDB) {
        $value['images_ischeck'] = 1;
        MooFastdbUpdate("members", 'uid', $uid, $value);
    }
    $image_type_arr = array('mid', 'medium');
    /*foreach($image_type_arr as $image_type){
    		$image_file=substr(MooGetphotoAdmin($uid,$image_type),3);		
    		@file_get_contents("http://control.wjmax.com/cdn/services/rsPushService/addRefreshUrl?userName=zikou&password=L0ciFer&hasEncrypt=false&pushUrl=http://www.7651.com/".$image_file);
    	}*/
    sendusermessage($uid, "您的形象照已经通过红娘的审核", "形象照审核");
    serverlog(3, $dbTablePre . "members", $GLOBALS['username'] . "审核会员" . $uid . "的形象照成功", $GLOBALS['adminid'], $uid);
}
Example #2
0
function savePhoto($uid,$photoimage){
    $x1=128;
    $y1=0;
    $x2=494;
    $y2=457;
    $width=366;
    $height=457;
    $photoimage= '/wwwroot/zays/'.$photoimage;
    $first_dir=substr($uid,-1,1);
    $secend_dir=substr($uid,-2,1);
    $third_dir=substr($uid,-3,1);
    $forth_dir=substr($uid,-4,1);
    $userpath="/wwwroot/zays/data/upload/userimg/".$first_dir."/".$secend_dir."/".$third_dir."/".$forth_dir."/";

    
    if(!is_dir($userpath)){
		mkdir($userpath,0777,true);
        /* $array = explode('/', $userpath);
        $count = count($array);
        for($i = 0; $i < $count; $i++) {
			$msg .= $array[$i];
			if(!file_exists($msg)) {
				mkdir($msg, 0777);
			}
			$msg .= '/';
		} */
    }

    $sizearray=array(0=>array('width'=>320,'height'=>400),
                     1=>array('width'=>171,'height'=>212),
                     2=>array('width'=>100,'height'=>125),
                     3=>array('width'=>60,'height'=>75),
                     4=>array('width'=>50,'height'=>63),
                     5=>array('width'=>110,'height'=>138),
                     6=>array('width'=>100,'height'=>125)
                    );
    $namearray=array(0=>'big',1=>'mid',2=>'medium',3=>'small',4=>'page',5=>'com',6=>'index');
    
    $newimages=changesize($photoimage,$userpath,$x1,$y1,$width,$height,$uid,$sizearray,$namearray);//生成另外三种形象照
   
    //$sql = "UPDATE web_members_search SET `images_ischeck`=1  WHERE `uid`='$uid'";
    //$GLOBALS['_MooClass']['MooMySQL']->query($sql);
    //searchApi('members_man members_women') -> updateAttr(array('images_ischeck'),array($uid=>array(1)));
     //更新索引数据的属性值
    //if(MOOPHP_ALLOW_FASTDB) {       
    //    $value['images_ischeck']= 1;
    //    MooFastdbUpdate("members_search",'uid',$uid,$value);
    //}

}
Example #3
0
function site_story_edit()
{
    global $story_sweet_process, $_MooClass, $dbTablePre, $memcached;
    $ispost = MooGetGPC('ispost', 'integer', 'P');
    $imgpost = MooGetGPC('imgpost', 'integer', 'P');
    //$MooImage = MooAutoLoad('MooImage');
    if ($imgpost == '1') {
        $story_picname = MooGetGPC('imgUrl', 'string', 'P');
        $sid = MooGetGPC('sid', 'integer', 'P');
        $mid = MooGetGPC('mid', 'integer', 'P');
        //重新生成小图 覆盖原来的首页照
        $src = IMG_ROOT . $story_picname;
        $sidmd5 = $sid * 3;
        $size = getimagesize($src, $info);
        $width = $size['0'];
        $height = $size['1'];
        $sizearray = array(0 => array('width' => 280, 'height' => 168), 1 => array('width' => 252, 'height' => 151), 2 => array('width' => 150, 'height' => 90));
        $namearray = array(0 => 'big', 1 => 'medium', 2 => 'small');
        $newimages = changesize($src, '../data/upload/story', 0, 0, $width, $height, $sid, $sizearray, $namearray);
        $sql = "UPDATE {$GLOBALS['dbTablePre']}story SET is_index='{$mid}' WHERE sid='{$sid}'";
        $res = $GLOBALS['_MooClass']['MooMySQL']->query($sql);
        if ($res) {
            echo 1;
        }
        exit;
    }
    if ($ispost == '1') {
        $sid = trim(MooGetGPC('sid', 'integer', 'P'));
        $title = htmlspecialchars(trim(MooGetGPC('title', 'string', 'P')));
        $content = htmlspecialchars(trim(MooGetGPC('content', 'string', 'P')));
        $confirmtime = htmlspecialchars(MooGetGPC('confirmtime', 'string', 'P'));
        $story_date = '';
        if ($confirmtime) {
            $story_date1 = htmlspecialchars(MooGetGPC('confirmtime', 'string', 'P'));
            $story_date = strtotime($story_date1);
        } else {
            $story_date1 = trim(MooGetGPC('date', 'string', 'P'));
            $story_date = strtotime($story_date1);
        }
        $name1 = trim(MooGetGPC('name1', 'string', 'P'));
        $name1 = htmlspecialchars($name1);
        $name2 = trim(MooGetGPC('name2', 'string', 'P'));
        $name2 = htmlspecialchars($name2);
        $state = trim(MooGetGPC('state', 'integer', 'P'));
        $syscheck = trim(MooGetGPC('pass', 'integer', 'P'));
        $recommand = trim(MooGetGPC('recommand', 'integer', 'P'));
        $hot = trim(MooGetGPC('clicknum', 'integer', 'P'));
        date_default_timezone_set('Asia/Shanghai');
        $submit_date = time();
        $imgtitle = trim(MooGetGPC('imgtitle', 'string', 'P'));
        $imgtitle = htmlspecialchars($imgtitle);
        //note 上传新图片
        //note 判断上传的文件类型
        $flag = '';
        $images = array('jpg', 'jpeg', 'gif', 'png', 'bmp');
        $maxfilesize = 1024 * 1024;
        $filesize = $_FILES['img']['size'];
        if (!empty($filesize)) {
            foreach ($images as $v) {
                if (strpos($_FILES['img']['type'], $v) == true) {
                    $flag = 1;
                }
            }
            if ($flag != 1) {
                $notice = "照片必须为BMP,JPG,PNG或GIF格式";
                MooMessageAdmin($notice, 'index.php?action=site_story&h=edit&id=' . $sid, 0);
                exit;
            }
            if ($filesize > $maxfilesize) {
                $notice = "上传图片大小不得超过1M";
                MooMessageAdmin($notice, 'index.php?action=site_story&h=edit&id=' . $sid, 0);
                exit;
            }
            //note 上传到指定目录,并且获得上传后的文件描述
            global $upload;
            $upload = MooAutoLoad('MooUpload');
            $upload->config(array('targetDir' => IMG_ROOT, 'saveType' => '0'));
            $files = $upload->saveFiles('img');
            $story_picname = $files[0]['name'] . "." . $files[0]['extension'];
            $filetype = explode('.', $story_picname);
            $filetype = array_pop($filetype);
            //生成小图
            /*
            $src = IMG_ROOT.$story_picname;
            $sidmd5=$sid*3;
            $size = getimagesize($src,$info);
            $width = $size['0'];
            $height = $size['1'];
            $sizearray=array(0=>array('width'=>280,'height'=>168),1=>array('width'=>252,'height'=>151),2=>array('width'=>150,'height'=>90));
            $namearray=array(0=>'big',1=>'medium',2=>'small');
            $newimages=changesize($src,'../data/upload/story',0,0,$width,$height,$sid,$sizearray,$namearray);
            */
            $res_in_pic = '';
            if ($story_picname) {
                //note 插入story_pic表
                $sql_in_spic = "INSERT INTO {$GLOBALS['dbTablePre']}story_pic SET sid='{$sid}',img='{$story_picname}',title='{$imgtitle}',submit_date='{$submit_date}',syscheck='{$syscheck}'";
                $res_in_pic = $GLOBALS['_MooClass']['MooMySQL']->query($sql_in_spic);
            }
        }
        $sql = "UPDATE {$GLOBALS['dbTablePre']}story SET title='{$title}',content='{$content}',story_date='{$story_date}',name1='{$name1}',name2='{$name2}',state='{$state}',syscheck='{$syscheck}',recommand='{$recommand}',hot='{$hot}' WHERE sid='{$sid}' ";
        $sql_up_pic = "UPDATE {$GLOBALS['dbTablePre']}story_pic SET syscheck='{$syscheck}' WHERE sid='{$sid}'";
        $res = $GLOBALS['_MooClass']['MooMySQL']->query($sql);
        $res_up_pic = $GLOBALS['_MooClass']['MooMySQL']->query($sql_up_pic);
        //note 更新缓存
        $param = "type=query/name=story/sql=select s.sid,s.uid,s.title,s.content,s.name1,s.name2,s.story_date,sp.img from `{$dbTablePre}story` as s left join  `{$dbTablePre}story_pic` as sp on s.is_index=sp.mid where sp.syscheck=1 and s.syscheck=1 and s.recommand= '1' order by s.story_date desc,sp.img desc limit 6/cachetime=86400";
        $cachekey = md5($param);
        // 		$file = MOOPHP_DATA_DIR.'/block/story_'.$cachekey.'.data';
        if ($memcached->get('story_' . $cachekey)) {
            $memcached->delete('story_' . $cachekey);
        }
        $_MooClass['MooCache']->getBlock($param);
        $story = $GLOBALS['_MooBlock']['story'];
        //note 插入日志
        serverlog(1, $GLOBALS['dbTablePre'] . 'story', '编辑成功故事', $GLOBALS['adminid']);
        salert("编辑成功", "index.php?action=site_story&h=edit&id=" . $sid);
        exit;
    }
    //note 编辑图片页面
    $sid = MooGetGPC('id', 'integer', 'G');
    $sid = intval($sid);
    $sql = "SELECT * FROM {$GLOBALS['dbTablePre']}story WHERE `sid` = '{$sid}'";
    $sql_pic = "SELECT * FROM {$GLOBALS['dbTablePre']}story_pic WHERE `sid` = '{$sid}'";
    $editStory = $GLOBALS['_MooClass']['MooMySQL']->getOne($sql);
    $editPic = $GLOBALS['_MooClass']['MooMySQL']->getAll($sql_pic);
    require adminTemplate('site_story_edit');
}