Exemple #1
0
 public function put($id, $update, $before = null, $after = null, $put_style = 'default')
 {
     $loginApi = new KUser_loginApi();
     $uid = $loginApi->iGetLoginUid();
     if (!$uid || $uid != $id) {
         throw new Exception('修改密码失败', 1);
     }
     switch ($put_style) {
         case 'passwd':
             if (!preg_match('/^[_0-9a-z]{4,16}$/i', $update['newpasswd'])) {
                 throw new Exception('登录密码只能使用字母,数字和下划线,4-16个字符', 2);
             }
             if (false === $loginApi->bChangePassword($uid, $update['oldpasswd'], $update['newpasswd'], $errno)) {
                 throw new Exception('旧密码输入错误', 3);
             }
             break;
         case 'profile':
             if ('' == $update['nickname']) {
                 throw new Exception('请输入昵称', 4);
             }
             $baseinfoApi = new KUser_baseinfoApi();
             $baseinfoApi->bUpdateNickname($uid, $update['nickname']);
             break;
     }
     return array('key' => $id);
 }
Exemple #2
0
 public function post($update, $after = null)
 {
     $api = new KStorage_Api();
     $content = $api->sRead($update['fileid']);
     if ('' === $content) {
         throw new Exception('获取原文件失败', 1);
     }
     if (false === ($info = Ko_Tool_Image::VInfo($content, Ko_Tool_Image::FLAG_SRC_BLOB))) {
         throw new Exception('获取原文件信息失败', 2);
     }
     $zoom = $info['width'] / $update['width'];
     $aOption = array('srcx' => $zoom * $update['left'], 'srcy' => $zoom * $update['top'], 'srcw' => $zoom * $update['w'], 'srch' => $zoom * $update['h'], 'quality' => 98, 'strip' => true);
     if (false === ($dst = Ko_Tool_Image::VCrop($content, '1.' . $info['type'], $update['w'], $update['h'], Ko_Tool_Image::FLAG_SRC_BLOB | Ko_Tool_Image::FLAG_DST_BLOB, $aOption))) {
         throw new Exception('文件转换失败', 3);
     }
     if (!$api->bContent2Storage($dst, $logoid)) {
         throw new Exception('文件保存失败', 3);
     }
     $loginApi = new KUser_loginApi();
     $baseinfoApi = new KUser_baseinfoApi();
     $baseinfoApi->bUpdateLogo($loginApi->iGetLoginUid(), $logoid);
     return array('key' => $logoid);
 }