Example #1
0
 /**
  * 静态方法, 单例统一访问入口
  * @return object  返回对象的唯一实例
  */
 public static function getInstance()
 {
     if (is_null(self::$_instance) || !isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #2
0
 /**
  * web端入口,从session中获取用户
  */
 public function getUserFromSession()
 {
     $user = Yii::app()->session["user"];
     $deviceId = Yii::app()->session["deviceId"];
     if (empty($user) || empty($deviceId)) {
         return false;
     }
     // 获取web端设备id
     $device = MiniUserDevice2::getInstance()->getUserDevice2($deviceId);
     if ($device === NULL) {
         return false;
     }
     $userId = $user['id'];
     $userInfo = MiniUser2::getInstance()->getUser2($userId);
     $userInfo["appId"] = 1;
     $this->_current_user = $userInfo;
     $this->_current_device = $device;
     return $user;
 }
Example #3
0
 /**
  * 
  * 获取用户空间信息
  */
 public function handleSpace()
 {
     $user = MiniUser2::getInstance()->getUser2($this->_userId);
     $this->totalSpace = $user["space"];
     $this->usedSpace = $user["usedSpace"];
     if ($this->totalSpace <= $this->usedSpace) {
         $this->result["msg"] = "空间不足";
         $this->result["message"] = "空间不足";
         throw new ApiException("File name is NULL.");
     }
 }
Example #4
0
 /**
  * web返回值处理
  */
 public function buildWebResponse()
 {
     if (!isset($this->success) || $this->success != true) {
         throw new MFilesException(Yii::t('api', MConst::INTERNAL_SERVER_ERROR), MConst::HTTP_CODE_500);
     }
     // 查询数据库,找出对应id
     $fileDetail = UserFile::model()->find(array('condition' => 'file_path=:file_path', 'params' => array(':file_path' => "/" . $this->user_id . $this->path)));
     if (empty($fileDetail)) {
         throw new MFileopsException(Yii::t('api', 'Can not find the folder.'), MConst::HTTP_CODE_404);
     }
     $pathInfo = MUtils::pathinfo_utf($this->share_filter->src_path);
     $user = MiniUser2::getInstance()->getUser2($this->user_id);
     $total = $user["space"];
     $usedSpace = $user["usedSpace"];
     $uploadSizeRemain = $total - $usedSpace;
     $cid = isset($_REQUEST['cid']) ? $_REQUEST['cid'] : 0;
     $data = array();
     $data["rev"] = $this->version_id;
     $data["is_user"] = 1;
     $data["user_id"] = $this->user_id;
     $data["group_id"] = 0;
     $data["aid"] = 0;
     $data["user_ip"] = "0.0.0.0";
     $data["upload_type"] = 1;
     //
     // dataserver 修改需要的返回值 文件path
     // by Kindac
     // since 2013/06/25
     //
     $data["temp_file_path"] = $this->file_path;
     $data["temp_file_name"] = $this->file_name;
     $data["temp_file_sha1"] = $this->file_hash;
     $data["is_share"] = 0;
     $data["file_ext"] = $pathInfo["extension"];
     $data["file_name_sort"] = strlen($this->file_name);
     $data["file_size"] = $this->size;
     $data["file_description"] = "";
     $data["pick_time"] = "";
     $data["is_collect"] = 0;
     $data["file_status"] = 1;
     $data["file_ptime"] = time();
     $data["file_id"] = $fileDetail->id;
     $data["ico"] = $pathInfo["extension"];
     $data["area_id"] = $cid;
     $data["category_id"] = $cid;
     $data["upload_size_remain"] = $uploadSizeRemain;
     $ret = array();
     $ret["state"] = true;
     $ret["data"] = $data;
     echo json_encode($ret);
 }
Example #5
0
 /**
  * 验证自有系统中是否存在此用户
  * @param string $userName
  * @param string $password
  * @return bool $use
  */
 public function validUserSelf($userName, $password)
 {
     $user = MiniUser2::getInstance()->getUserByName2($userName);
     if ($user === NULL) {
         //用户名不存在
         $this->errorCode = MConst::ERROR_USERNAME_INVALID;
         return false;
     }
     $signPassword = MSecret::passSign($password, $user["salt"]);
     if ($user["user_pass"] == $signPassword) {
         //密码正确的情况下再验证用户是否被冻结
         if (!$user['user_status']) {
             //返回用户被冻结错误码
             CUserValid::$userDisabled = true;
             $this->errorCode = MConst::ERROR_USER_DISABLED;
             return false;
         }
         return $user;
     }
     //返回密码不正确 代码
     $this->errorCode = MConst::ERROR_PASSWORD_INVALID;
     return false;
 }