/** * 根据cookie中的accessToken获得用户信息 */ private function getUserByAccessToken() { //当accessToken在session中的时候,他的优先级最高,然后cookie里面的accessToken //这里解决新版客户端网页加载的问题 $accessToken = Yii::app()->session["accessToken"]; if (empty($accessToken)) { //PC客户端从Post参数获得access_token if (MiniHttp::isPCClient()) { $accessToken = MiniHttp::getParam("access_token", ""); } else { if (!array_key_exists("accessToken", $_COOKIE)) { $accessToken = MiniHttp::getParam("access_token", ""); if (empty($accessToken)) { return NULL; } } else { $accessToken = $_COOKIE['accessToken']; } } } if (empty($accessToken)) { return NULL; } $accessInfo = MiniToken2::getInstance()->getAccessInfo2($accessToken); if (!isset($accessInfo)) { return NULL; } $user = MUserManager::getInstance()->getUserOauth2($accessInfo["device_id"]); //获取用户的信息 return $user; }
/** * 根据OpenId获得accessToken */ public function bind() { $appKey = MiniHttp::getParam('app_key', ""); $openId = MiniHttp::getParam('open_id', ""); $biz = new SiteBiz(); return $biz->bindOpenId($appKey, $openId); }
public function saveSortType() { $type = MiniHttp::getParam("type", ""); $sortOrder = MiniHttp::getParam("sortOrder", ""); $biz = new UserBiz(); return $biz->saveSortType($type, $sortOrder); }
public function search() { $fileName = MiniHttp::getParam("file_name", ""); $arr = new RecycleBiz(); $data = $arr->search($fileName); return $data; }
/** * download file */ public function getList() { $pageSize = MiniHttp::getParam("pageSize", ""); $page = MiniHttp::getParam("page", ""); $biz = new AlbumBiz(); $list = $biz->getPage($page, $pageSize); return $list; }
/** * 恢复版本 */ public function recover() { $signature = MiniHttp::getParam("signature", "-1"); $path = MiniHttp::getParam("file_path", ""); $history = new HistoryBiz(); $result = $history->recover($signature, $path); return array('success' => $result); }
/** * 获取在线用户列表 */ public function getList() { $pageSize = MiniHttp::getParam('page_size', 10); $currentPage = MiniHttp::getParam('current_page', 1); $model = new OnlineListBiz(); $data = $model->getOnlineUsers($pageSize, $currentPage); return $data; }
public function miniyun() { $sharedPath = MiniHttp::getParam('shared_path', ''); $urlManager = new MUrlManager(); $urlArray = $urlManager->parseActionFromUrl(); $metadataController = new MMetadataController(); $metadataController->invoke($urlArray["uri"], $sharedPath); }
/** * 根据用户名或设备名查找设备信息 */ public function searchDevicesByName() { $pageSize = MiniHttp::getParam('page_size', 10); $currentPage = MiniHttp::getParam('current_page', 1); $key = MiniHttp::getParam('key', ''); $model = new DeviceManageBiz(); $data = $model->searchDevicesByName($key, $pageSize, $currentPage); return $data; }
/** * 修改迷你搜索节点的状态 */ public function nodeStatus() { $name = MiniHttp::getParam("name", ""); $status = MiniHttp::getParam("status", "0"); if (empty($name)) { throw new MiniException(100302); } $biz = new PluginMiniSearchBiz(); return $biz->modifyNodeStatus($name, $status); }
/** * 商业版主题参数设置接口 */ public function setParams() { $companyName = MiniHttp::getParam('company_name', ""); $productName = MiniHttp::getParam('product_name', ""); $companyEnglishName = MiniHttp::getParam('company_english_name', ""); $helpUrl = MiniHttp::getParam('help_url', ""); $helpName = MiniHttp::getParam('help_name', ""); $biz = new PluginBusinessThemeBiz(); $biz->setParams($companyName, $productName, $companyEnglishName, $helpUrl, $helpName); }
/** * 选择器名字的列表 */ public function getList() { $pageSize = MiniHttp::getParam('page_size', 10); $currentPage = MiniHttp::getParam('current_page', 1); $type = MiniHttp::getParam('type', 'web'); $items = MiniChooser::getInstance()->getPageList($pageSize, $currentPage, $type); $total = MiniChooser::getInstance()->getTotal($type); $value['items'] = $items; $value['total'] = $total; return $value; }
/** * 修改editor */ public function updateEditor() { $selectExtend = MiniHttp::getParam('select_extend', ""); $extend = MiniHttp::getParam('extend', ""); $firstMethod = MiniHttp::getParam('first_method', ""); $secondMethod = MiniHttp::getParam('second_method', ""); $editorTip = MiniHttp::getParam('editor_tip', ""); $model = new EditorManageBiz(); $data = $model->updateEditor($selectExtend, $extend, $firstMethod, $secondMethod, $editorTip); return array('success' => $data); }
public function getList() { $path = MiniHttp::getParam('path', ''); $time = MiniHttp::getParam("time", "-1"); $deviceUuid = MiniHttp::getParam('device_uuid', '-1'); $currentPage = MiniHttp::getParam('current_page', '1'); $pageSize = MiniHttp::getParam('page_size', '20'); $model = new EventBiz(); $data = $model->getList($path, $time, $deviceUuid, $pageSize, $currentPage); return $data; }
public function getStatusList() { $pageSize = MiniHttp::getParam('pageSize', ''); $page = MiniHttp::getParam('page', ''); $pageSet = ($page - 1) * $pageSize; $sessionUser = $this->user; $userId = $sessionUser["id"]; $value = MiniMessage::getInstance()->getMessageStatus($pageSize, $pageSet, $userId); $list["list"] = $this->createArray($value); $list["total"] = MiniMessage::getInstance()->getMessageStatusCount($userId); return $list; }
/** * 存储AD信息 */ public function setAdInfo() { $adInfo = array(); $adInfo['ad_ldap_host'] = MiniHttp::getParam('ad_ldap_host', ""); $adInfo['ad_ldap_port'] = MiniHttp::getParam('ad_ldap_port', ""); $adInfo['ad_ldap_base_cn'] = MiniHttp::getParam('ad_ldap_base_cn', ""); $adInfo['ad_coding'] = MiniHttp::getParam('ad_coding', ""); $adInfo['ad_white_list_open'] = MiniHttp::getParam('ad_white_list_open', ""); $adInfo['ad_sync_department'] = MiniHttp::getParam('ad_sync_department', ""); $adInfo['ad_test_user_name'] = MiniHttp::getParam('user_name', ""); $adInfo['ad_test_password'] = MiniHttp::getParam('password', ""); $model = new PluginAdBiz(); return $model->setAdInfo($adInfo); }
/** * 存储LDAP信息 */ public function setLdapInfo() { $ldapInfo = array(); $ldapInfo['ldap_host'] = MiniHttp::getParam('ldap_host', ""); $ldapInfo['ldap_port'] = MiniHttp::getParam('ldap_port', ""); $ldapInfo['ldap_base_cn'] = MiniHttp::getParam('ldap_base_cn', ""); $ldapInfo['ldap_primary_key'] = strtolower(MiniHttp::getParam('ldap_primary_key', "")); $ldapInfo['ldap_nick'] = strtolower(MiniHttp::getParam('ldap_nick', "")); $ldapInfo['ldap_department_name'] = strtolower(MiniHttp::getParam('ldap_department_name', "")); $ldapInfo['ldap_coding'] = MiniHttp::getParam('ldap_coding', ""); $ldapInfo['ldap_white_list_open'] = MiniHttp::getParam('ldap_white_list_open', ""); $ldapInfo['ldap_sync_department'] = MiniHttp::getParam('ldap_sync_department', ""); $ldapInfo['ldap_test_user_name'] = MiniHttp::getParam('user_name', ""); $ldapInfo['ldap_test_password'] = MiniHttp::getParam('password', ""); $model = new PluginLdapBiz(); return $model->setLdapInfo($ldapInfo); }
public function invoke() { $route = MiniHttp::getParam("route", ""); if (!empty($route)) { //1.7调用方式 //插件的接口访问形式如下 //{http://t.miniyun.cn/api.php?route=module/miniDoc/list&page_size=16&page=1&mime_type=application/msword} //执行该类的方式是PluginMiniDocService.download方法 if ($this->isPluginSendRequest()) { //查询是否是来自插件的请求 $info = explode("/", $route); $pluginName = $info[1]; $className = "Plugin" . ucfirst($pluginName) . "Service"; $service = new $className(); $result = $service->invoke($info[2]); echo json_encode($result); exit; } else { $info = explode("/", $route); $module = $info[0]; $class = ucfirst($module) . "Service"; $service = new $class(); $result = $service->invoke($info[1]); echo json_encode($result); exit; } } else { //1.5调用方式 $uri = $this->getFilterUrl(); $info = explode("/", $uri); $module = $info[3]; $whiteList = $this->getWhiteList(); foreach ($whiteList as $item) { if ($module === $item) { $newUri = "/" . implode("/", array_slice($info, 3)); $class = ucfirst($module) . "Service"; $service = new $class(); $result = $service->invoke($newUri); echo json_encode($result); exit; } } } }
/** * 用户与群组解绑 */ public function unbind() { $userId = MiniHttp::getParam("user_id", ""); $groupId = MiniHttp::getParam("group_id", ""); $biz = new GroupBiz(); return $biz->unbind($userId, $groupId); }
/** * 获取文件的相关信息 */ public function info() { $path = MiniHttp::getParam("path", ""); $biz = new FileBiz(); $data = $biz->info($path); return $data; }
/** * 检查密码 * @return mixed */ public function checkPassword() { $key = MiniHttp::getParam("key", ""); $password = MiniHttp::getParam("password", ""); $result = MiniLink::getInstance()->checkPassword($key, $password); return $result; }
/** * 控制器执行主逻辑函数 */ public function invoke($uri = null) { $this->setAction(MConst::CREATE_FILE); // 调用父类初始化函数,注册自定义的异常和错误处理逻辑 parent::init(); $urlManager = new MUrlManager(); $root = $urlManager->parseRootFromUrl($uri); if ($root == false) { //支持参数模式传递上传路径 $path = MiniHttp::getParam("path", ""); if (empty($path)) { throw new MFilesException(Yii::t('api', MConst::PATH_ERROR), MConst::HTTP_CODE_411); } } // 初始化创建文件公共类句柄 $createFileHandler = MFilesCommon::initMFilesCommon(); if (count($_FILES) == 0) { throw new MFilesException(Yii::t('api', MConst::PARAMS_ERROR . "5"), MConst::HTTP_CODE_400); } $keys = array_keys($_FILES); if (count($keys) != 1) { throw new MFilesException(Yii::t('api', MConst::PARAMS_ERROR . "6"), MConst::HTTP_CODE_400); } $key = $keys[0]; // 检查请求参数$_FILES if (isset($_FILES[$key]) === false) { throw new MFilesException(Yii::t('api', MConst::PARAMS_ERROR . "7"), MConst::HTTP_CODE_400); } // 检查文件上传过程是否有错 if ($_FILES[$key]["error"] != 0) { throw new MFilesException(Yii::t('api', MConst::PARAMS_ERROR . "8"), MConst::HTTP_CODE_400); } $fileName = $_FILES[$key]["name"]; $type = MiniUtil::getMimeType($fileName); $size = $_FILES[$key]["size"]; $tmpName = $_FILES[$key]["tmp_name"]; // 验证文件是否已经上传成功 if (file_exists($tmpName) === false) { throw new MFilesException(Yii::t('api', MConst::INTERNAL_SERVER_ERROR), MConst::HTTP_CODE_500); } // 检查文件上传错误 if (filesize($tmpName) != $size) { throw new MFilesException(Yii::t('api', "The file upload error!"), MConst::HTTP_CODE_400); } //断点文件上传 if ($this->isBreakpointUpload()) { $filesController = new MFilePutController(); $filesController->invoke($uri); } else { //完整文件上传 $signature = MiniUtil::getFileHash($tmpName); // 解析路径 $path = MiniHttp::getParam("path", ""); $path = MiniUtil::specialWordReplace($path); $parentPath = dirname($path); $user = MUserManager::getInstance()->getCurrentUser(); $parentFile = MiniFile::getInstance()->getByPath($parentPath); //如果目录存在,且该目录is_delete=1,则把目录状态删除状态修改为0 if (!empty($parentFile) && $parentFile['is_deleted'] == 1) { $values = array(); $values['is_deleted'] = false; MiniFile::getInstance()->updateByPath($parentPath, $values); } else { //如果是根目录,则不用新建目录 //否则会创建文件名名称的文件夹出来,而且目标文件位于该文件夹的下面 if (!MiniUtil::isRootPath($parentPath, $user["id"])) { MiniFile::getInstance()->createFolder($parentPath, $user['id']); } } $createFileHandler->size = $size; $createFileHandler->parent_path = MUtils::convertStandardPath($parentPath); $createFileHandler->file_name = MiniUtil::specialWordReplace($fileName); $createFileHandler->root = $root; $createFileHandler->path = MUtils::convertStandardPath($path); $createFileHandler->type = $type; // 文件不存在,保存文件 $createFileHandler->saveFile($tmpName, $signature, $size); // 保存文件meta $createFileHandler->saveFileMeta(); // 处理不同端,不同返回值 if (MUserManager::getInstance()->isWeb() === true) { $createFileHandler->buildWebResponse(); return; } $createFileHandler->buildResult(); } }
/** * 用户登录 * @return array|bool * @throws */ public function oauth2() { $isExtend = apply_filters("license_expired"); if ($isExtend === 1) { $userName = MiniHttp::getParam("username", ""); if ($userName !== "admin") { throw new MiniException(440); } } $oauth = new PDOOAuth2(); $token = $oauth->grantAccessToken(); #添加登陆日志 $deviceId = $oauth->getVariable("device_id"); MiniLog::getInstance()->createLogin($deviceId); #返回site_id,便于与cloud.miniyun.cn通信 $token["site_id"] = MiniSiteUtils::getSiteID(); return $token; }
public function mateCode() { $mateArr = MiniHttp::getParam('mateArr', ''); $model = new SystemManageBiz(); $data = $model->mateCodeData($mateArr); return $data; }
/** * 设置公共目录权限 */ public function setPrivilege() { $filePath = MiniHttp::getParam('file_path', ""); $privilege = MiniHttp::getParam('privilege', ""); $model = new FileManageBiz(); return $model->setPrivilege($filePath, $privilege); }
/** * 下载配置文件 */ public function downloadConfigFile() { $model = new MiniChooserForm(); $id = MiniHttp::getParam('id', ''); $model->downloadConfig($id); }
/** *修改用户绑定的用户组 */ public function modifyBind() { $userId = MiniHttp::getParam('user_id', ''); $groupId = MiniHttp::getParam('new_group_id', ''); $biz = new DepartmentBiz(); $result = $biz->modifyBind($userId, $groupId); return $result; }
date_default_timezone_set("PRC"); defined('YII_DEBUG') or define('YII_DEBUG', false); @ini_set('display_errors', '1'); error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); // change the following paths if necessary $config = dirname(__FILE__) . '/protected/config/main.php'; $yii = dirname(__FILE__) . '/yii/framework/yii.php'; // specify how many levels of call stack should be shown in each log message defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 8); // 客户端请求 defined('CLIENT_REQUEST_API') or define('CLIENT_REQUEST_API', TRUE); require_once $yii; Yii::createWebApplication($config); header('Access-Control-Allow-Origin: http://static.miniyun.cn'); header('Access-Control-Allow-Methods: POST'); header('Access-Control-Allow-Methods: GET'); MiniAppParam::getInstance()->load(); //初始化APP静态数据 MiniPlugin::getInstance()->load(); //加载插件 $routePath = MiniHttp::getParam("route", ""); if (empty($routePath)) { //老接口 $meta = new MAPIController(); //通过meta的控制器进行跳转处理逻辑 $meta->invoke(); } else { //新接口 $api = new APIController(); $api->invoke(); }
public function delete() { $filePath = MiniHttp::getParam('file_path', ''); LockBiz::getInstance()->delete($filePath); return array('success' => true); }
/** * 设置分享链接 * @return mixed */ public function setLinkAccessPolicy() { $originDomain = MiniHttp::getParam("origin_domain", ""); $chooserAppKey = MiniHttp::getParam("chooser_app_key", ""); $session = MiniHttp::getParam("session", ""); $key = MiniHttp::getParam("key", ""); $shareKey = MiniHttp::getParam("shareKey", ""); $password = MiniHttp::getParam("password", ""); $time = MiniHttp::getParam("time", ""); $link = new LinkCreateBiz($this->path, $originDomain, $chooserAppKey, $session); $result = $link->setAccessPolicy($key, $shareKey, $password, $time); return $result; }