Ejemplo n.º 1
0
 /**
  * 根據文件Id获取文件数据
  */
 public function getLink($fileId, $linkType, $shareKey)
 {
     $data = array();
     $file = MiniFile::getInstance()->getById($fileId);
     $data["name"] = $file["file_name"];
     $data["bytes"] = intval($file["file_size"] + "");
     $fileType = $file["file_type"];
     if ($fileType == 0) {
         $data["icon"] = MiniHttp::getIcon4File($file["file_name"]);
         if (!MiniUtil::isMixCloudVersion()) {
             $data["icon"] = MiniHttp::getMiniHost() . "statics/static/mini-box/images/link/" . $data["icon"];
         } else {
             $data["icon"] = "http://static.miniyun.cn/static/mini-box/images/link/" . $data["icon"];
         }
     }
     $ext = MiniUtil::getFileExtension($file["file_name"]);
     $path = MiniUtil::getRelativePath($file["file_path"]);
     if ($ext == "jpg" || $ext == "jpeg" || $ext == "png" || $ext == "gif") {
         $data["thumbnail_link"] = MiniHttp::createAnonymousUrl("linkAccess/thumbnail?key=" . $shareKey . "&size=256x256&path=" . urlencode($path));
     } else {
         $data["thumbnail_link"] = "";
     }
     if ($linkType == MiniLink::$PREVIEW_LINK) {
         $data["link"] = MiniHttp::createUrl("link/access/key/" . $shareKey);
     } else {
         $data["link"] = MiniHttp::createAnonymousUrl("linkAccess/download?key=" . $shareKey . "&path=" . urlencode($path));
     }
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * 设置迷你云默认地址,迷你文档服务器下载文件内容需要获得这个地址
  */
 private function setDefault()
 {
     //判断是否在网页启动数据库生成,在command模式下无法获得$_SERVER的值
     if (array_key_exists("SERVER_PORT", $_SERVER)) {
         $host = MiniHttp::getMiniHost();
         MiniOption::getInstance()->setOptionValue("miniyun_host", $host);
     }
 }
Ejemplo n.º 3
0
 /**
  * 设置站点基本信息
  */
 public function settingSiteInfo()
 {
     $site['siteTitle'] = MiniHttp::getParam('siteTitle', 'miniyun');
     $site['siteName'] = MiniHttp::getParam('siteName', '迷你云');
     $site['siteDefaultSpace'] = MiniHttp::getParam('siteDefaultSpace', '1024');
     $site['siteCompany'] = MiniHttp::getParam('siteCompany', '');
     $site['userRegisterEnabled'] = MiniHttp::getParam('userRegisterEnabled', '1');
     $site['fileStorePath'] = MiniHttp::getParam('fileStorePath', '');
     $site['miniyun_host'] = MiniHttp::getParam('miniyun_host', MiniHttp::getMiniHost());
     $model = new SystemManageBiz();
     $result = $model->settingSiteInfo($site);
     if ($result['success'] == false) {
         setcookie("settingMsg", $result['msg'], time() + 3600, "/");
     } else {
         setcookie("settingMsg", '', time() + 3600, "/");
     }
     return $result;
 }
Ejemplo n.º 4
0
 /**
  * 合法性检查
  */
 private function valid()
 {
     $file = $this->file;
     $data = array();
     $data["success"] = true;
     //判断文件是否正确
     if (empty($file)) {
         throw new MiniException(1100);
     }
     //判断用户是否有访问该文件的权限
     //        if($this->user["id"]!=$file["user_id"]){
     //当前判断的是用户是否文件拥有者进行判断
     //            throw new MiniException(1101);
     //        }
     //本域自身使用无限制
     $currentHost = MiniHttp::getMiniHost();
     if (strpos($currentHost, $this->originDomain) === false) {
         $model = new MiniChooserForm();
         if ($model->validKey($this->originDomain, $this->appKey) !== true) {
             throw new MiniException(1102);
         }
     }
     return $data;
 }
Ejemplo n.º 5
0
 /**
  * 创建默认站点
  */
 public function createDefault()
 {
     $nodes = $this->getNodeList();
     if (count($nodes) > 2) {
         return true;
     }
     if (count($nodes) == 1) {
         $node = StoreNode::model()->find("id=:id", array("id" => $nodes[0]["id"]));
     } else {
         $node = new StoreNode();
         $node->saved_file_count = 0;
         $node->downloaded_file_count = 0;
         $node->safe_code = "uBEEAcKM2D7sxpJD7QQEapsxiCmzPCyS";
         $node->name = "store1";
     }
     $host = MiniHttp::getMiniHost();
     $miniHostInfo = parse_url($host);
     $node->host = $miniHostInfo["scheme"] . "://" . $miniHostInfo["host"] . ":6081" . $miniHostInfo["path"];
     $node->status = 1;
     $node->save();
 }
Ejemplo n.º 6
0
 /**
  * 加载资源
  */
 public function load()
 {
     date_default_timezone_set("PRC");
     @ini_set('display_errors', '1');
     $this->appInfo = new SiteAppInfo();
     //默认业务主路径
     $this->cloudFolderName = "mini-box";
     $language = $this->getCookie("language");
     if (empty($language)) {
         $language = "zh_cn";
     }
     $this->language = $language;
     $v = $this->getCookie("cloudVersion");
     if (empty($v)) {
         $v = "1.0";
     }
     //$this->version = $v;
     $this->version = time();
     $header = "";
     //生产状态,将会把js/css文件进行合并处理,提高加载效率
     $header .= "<script id='miniBox' static-server-host='" . $this->staticServerHost . "' host='" . MiniHttp::getMiniHost() . "' version='" . $v . "' type=\"text/javascript\"  src='" . $this->staticServerHost . "miniLoad.php?t=js&c=box&a=index&v=" . $v . "&l=" . $this->language . "' charset=\"utf-8\"></script>";
     $header .= "<link rel=\"stylesheet\" type=\"text/css\"  href='" . $this->staticServerHost . "miniLoad.php?t=css&c=box&a=index&v=" . $v . "&l=" . $this->language . "'/>";
     $this->loadHtml($header);
 }
Ejemplo n.º 7
0
 /**
  * 秒传接口
  * @param array $params
  */
 function fileSec($params)
 {
     $signature = $params["signature"];
     $data['success'] = false;
     $data['store_type'] = "miniStore";
     //查询断点文件表
     $node = null;
     $breakFile = PluginMiniBreakFile::getInstance()->getBySignature($signature);
     if (!empty($breakFile)) {
         $node = PluginMiniStoreNode::getInstance()->getNodeById($breakFile["store_node_id"]);
     }
     //如果断点文件不存在或无效则重新分配一个存储节点
     if (empty($node) || $node["status"] === -1) {
         $node = PluginMiniStoreNode::getInstance()->getUploadNode();
         //更新断点表该文件的状态
         PluginMiniBreakFile::getInstance()->create($signature, $node["id"]);
     }
     //回调地址
     $callbackUrl = MiniHttp::getMiniHost() . "api.php?node_id=" . base64_encode($node["id"]);
     foreach ($params as $key => $value) {
         $callbackUrl .= "&" . $key . "=" . base64_encode(urlencode($value));
     }
     $callbackUrl .= "&encode=base64";
     $siteId = MiniSiteUtils::getSiteID();
     $data['callback'] = $callbackUrl;
     //兼容127.0.0.1
     $urlInfo = parse_url($node["host"]);
     if ($urlInfo["host"] == "127.0.0.1") {
         //说明迷你存储在本机,直接把127.0.0.1替换为迷你存储端口
         $defaultHost = MiniHttp::getMiniHost();
         $miniHostInfo = parse_url($defaultHost);
         $node['host'] = $miniHostInfo["scheme"] . "://" . $miniHostInfo["host"] . ":" . $urlInfo["port"] . $miniHostInfo["path"];
     }
     $data['url'] = $node["host"] . "/api.php";
     echo json_encode($data);
     exit;
 }
Ejemplo n.º 8
0
 /**
  * 获得迷你云站点安装的插件列表
  * @return array
  */
 public function getAllPlugin()
 {
     $suffix = 'Module.php';
     $path = Yii::getPathOfAlias('application.plugins') . DIRECTORY_SEPARATOR;
     $handle = opendir($path);
     $plugins = array();
     $tmpPlugins = array();
     while ($file = readdir($handle)) {
         if ($file == '..' || $file == '.') {
             continue;
         }
         if (is_file($path . $file) == true) {
             continue;
         }
         $pluginFile = $path . $file . DIRECTORY_SEPARATOR . ucfirst($file) . $suffix;
         if (!file_exists($pluginFile) || is_file($pluginFile) == false) {
             continue;
         }
         $pluginMeta = $this->getPluginMeta($pluginFile);
         $pluginMeta["logo"] = "";
         //设置插件的logo.png
         $logoPath = $path . $file . DIRECTORY_SEPARATOR . "logo.png";
         if (file_exists($logoPath)) {
             $aimPath = $path . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "plugin" . DIRECTORY_SEPARATOR;
             if (!file_exists($aimPath)) {
                 mkdir($aimPath);
             }
             $pluginLogoPath = $aimPath . $file . ".png";
             if (copy($logoPath, $pluginLogoPath)) {
                 $pluginMeta["logo"] = MiniHttp::getMiniHost() . "assets/plugin/" . $file . ".png";
             }
         }
         // 屏蔽插件
         if ($pluginMeta['hidden']) {
             continue;
         }
         //获得插件时间,然后进行排序
         array_push($tmpPlugins, array("file" => $file, "time" => filemtime($pluginFile), "data" => $pluginMeta));
     }
     $timeList = array();
     $fileList = array();
     $dataList = array();
     foreach ($tmpPlugins as $key => $row) {
         $timeList[$key] = $row['time'];
         $fileList[$key] = $row['file'];
         $dataList[$key] = $row['data'];
     }
     array_multisort($timeList, SORT_DESC, $fileList, SORT_ASC, $tmpPlugins);
     //判断插件是否启用
     $activePlugins = array();
     $value = MiniOption::getInstance()->getOptionValue("active_plugins");
     if ($value !== NULL) {
         $activePlugins = (array) unserialize($value);
     }
     foreach ($tmpPlugins as $row) {
         $meta = $row['data'];
         $enabled = false;
         foreach ($activePlugins as $id => $item) {
             if ($id === $row['file']) {
                 $enabled = true;
                 break;
             }
         }
         $meta["enabled"] = $enabled;
         $plugins[] = $meta;
     }
     //把迷你云主系统加入到列表中
     // $plugins[] = array(
     //     "id"=>"miniyun",
     //     "type"=>"miniyun",
     //     "name"=>NAME_ZH,
     //     "url"=>"http://www.miniyun.cn",
     //     "description"=>Yii::t("common", "plugin_miniyun_description", array("{app_name}"=>NAME_ZH)),
     //     "version"=>APP_VERSION,
     //     "logo"=>"http://static.miniyun.cn/static/mini-box/images/logo.png",
     //     "enabled"=>true,
     // );
     return $plugins;
 }
Ejemplo n.º 9
0
 /**
  *
  * 检查文件data和 meta是否存在
  * @param string $hash      文件sha1
  * @param string $fileName  文件名
  * @return bool|void
  */
 protected function handleCheckFileVersion($hash, $fileName)
 {
     $version = MiniVersion::getInstance()->getBySignature($hash);
     if (!$this->isNewVersion) {
         //data源处理对象
         if ($version == null) {
             return $this->handleAssign();
         }
         // 检查文件是否存在
         $dataObj = Yii::app()->data;
         $storePath = MiniUtil::getPathBySplitStr($hash);
         if ($dataObj->exists($storePath) == false) {
             return $this->handleAssign();
         }
         $this->version_id = $version['id'];
         $this->size = $version['file_size'];
         return true;
     } else {
         //返回断点文件信息
         $data = array();
         if (empty($version)) {
             $miniStoreInfo = MiniUtil::getPluginMiniStoreData();
             if (empty($miniStoreInfo)) {
                 //普通文件上传
                 $data['success'] = false;
                 $data['url'] = MiniHttp::getMiniHost() . "api.php";
                 $storePath = MiniUtil::getPathBySplitStr($hash);
                 $filePath = BASE . "upload_block/cache/" . $storePath;
                 if (file_exists($filePath)) {
                     $data['offset'] = filesize($filePath);
                     //如文件大小相同而且Hash值相同,说明流数据文件已经存在,直接生成元数据即可
                     $size = MiniHttp::getParam("size", "");
                     if ($data['offset'] == $size) {
                         //生成version记录,为使用老逻辑代码,这里处理得很羞涩
                         //理想的逻辑是在这里直接返回相关结果
                         $mimeType = MiniUtil::getMimeType($fileName);
                         $version = MiniVersion::getInstance()->create($hash, $size, $mimeType);
                         $this->version_id = $version['id'];
                         $this->size = $version['file_size'];
                         return true;
                     }
                 } else {
                     $data['offset'] = 0;
                 }
                 echo json_encode($data);
                 exit;
             } else {
                 //迷你存储与第3方存储秒传接口
                 apply_filters("file_sec", array("route" => "module/miniStore/report", "sign" => MiniHttp::getParam("sign", ""), "access_token" => MiniHttp::getParam("access_token", ""), "signature" => $hash, "size" => MiniHttp::getParam("size", ""), "path" => MiniHttp::getParam("path", "")));
             }
         } else {
             //上传文件到其它目录下,支持秒传
             $this->version_id = $version['id'];
             $this->size = $version['file_size'];
             return true;
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * 获得拥有权限的用户列表
  */
 public function getPrivilegeList($filePath)
 {
     //获得绝对路径
     $privileges = MiniUserPrivilege::getInstance()->getPrivilegeList($filePath);
     $groupPrivileges = MiniGroupPrivilege::getInstance()->getPrivilegeList($filePath);
     $data = array();
     foreach ($privileges as $item) {
         $user = MiniUser::getInstance()->getUser($item['user_id']);
         $privilege = array();
         $privilege['id'] = $user['user_id'];
         $privilege['name'] = $user['user_name'];
         $privilege['nick'] = $user['nick'];
         $privilege['avatar'] = $user['avatar'];
         $privilege['user_status'] = $user['user_status'];
         $permission = $item['permission'];
         $readValue = substr($permission, 0, 1);
         $modifyValue = substr($permission, 1);
         $dirCreateValue = substr($permission, 1, 1);
         $dirRenameValue = substr($permission, 2, 1);
         $dirDelValue = substr($permission, 3, 1);
         $fileUploadValue = substr($permission, 4, 1);
         $contentValue = substr($permission, 5, 1);
         $fileRenameValue = substr($permission, 6, 1);
         $fileDelValue = substr($permission, 7, 1);
         $previewValue = substr($permission, 8, 1);
         if ($readValue == '1') {
             //read权限 与js格式转化为一致
             $privilege['view'] = true;
         } else {
             $privilege['view'] = false;
         }
         if ($dirCreateValue == '1') {
             //dir_create权限 与js格式转化为一致
             $privilege['dir_create'] = true;
         } else {
             $privilege['dir_create'] = false;
         }
         if ($dirRenameValue == '1') {
             //dir_rename权限 与js格式转化为一致
             $privilege['dir_rename'] = true;
         } else {
             $privilege['dir_rename'] = false;
         }
         if ($dirDelValue == '1') {
             //dir_del权限 与js格式转化为一致
             $privilege['dir_delete'] = true;
         } else {
             $privilege['dir_delete'] = false;
         }
         if ($fileUploadValue == '1') {
             //file_upload权限 与js格式转化为一致
             $privilege['file_upload'] = true;
         } else {
             $privilege['file_upload'] = false;
         }
         if ($fileRenameValue == '1') {
             //file_rename权限 与js格式转化为一致
             $privilege['file_rename'] = true;
         } else {
             $privilege['file_rename'] = false;
         }
         if ($contentValue == '1') {
             //content权限 与js格式转化为一致
             $privilege['file_edit'] = true;
         } else {
             $privilege['file_edit'] = false;
         }
         if ($fileDelValue == '1') {
             //file_del权限 与js格式转化为一致
             $privilege['file_delete'] = true;
         } else {
             $privilege['file_delete'] = false;
         }
         if ($previewValue == '1') {
             //preview权限 与js格式转化为一致
             $privilege['download'] = true;
         } else {
             $privilege['download'] = false;
         }
         if ($modifyValue == '11111111') {
             $privilege['modified'] = true;
         } else {
             $privilege['modified'] = false;
         }
         $privilege['type'] = "0";
         array_push($data, $privilege);
     }
     foreach ($groupPrivileges as $item) {
         $group = MiniGroup::getInstance()->getById($item['group_id']);
         $privilege = array();
         $privilege['id'] = $item['group_id'];
         $privilege['name'] = $group['group_name'];
         $privilege['nick'] = $group['group_name'];
         $privilege['avatar'] = MiniHttp::getMiniHost() . "static/images/icon_group.png";
         $permission = $item['permission'];
         $readValue = substr($permission, 0, 1);
         $modifyValue = substr($permission, 1);
         $dirCreateValue = substr($permission, 1, 1);
         $dirRenameValue = substr($permission, 2, 1);
         $dirDelValue = substr($permission, 3, 1);
         $fileUploadValue = substr($permission, 4, 1);
         $contentValue = substr($permission, 5, 1);
         $fileRenameValue = substr($permission, 6, 1);
         $fileDelValue = substr($permission, 7, 1);
         $previewValue = substr($permission, 8, 1);
         if ($readValue == '1') {
             //read权限 与js格式转化为一致
             $privilege['view'] = true;
         } else {
             $privilege['view'] = false;
         }
         if ($dirCreateValue == '1') {
             //dir_create权限 与js格式转化为一致
             $privilege['dir_create'] = true;
         } else {
             $privilege['dir_create'] = false;
         }
         if ($dirRenameValue == '1') {
             //dir_rename权限 与js格式转化为一致
             $privilege['dir_rename'] = true;
         } else {
             $privilege['dir_rename'] = false;
         }
         if ($dirDelValue == '1') {
             //dir_del权限 与js格式转化为一致
             $privilege['dir_delete'] = true;
         } else {
             $privilege['dir_delete'] = false;
         }
         if ($fileUploadValue == '1') {
             //file_upload权限 与js格式转化为一致
             $privilege['file_upload'] = true;
         } else {
             $privilege['file_upload'] = false;
         }
         if ($fileRenameValue == '1') {
             //file_rename权限 与js格式转化为一致
             $privilege['file_rename'] = true;
         } else {
             $privilege['file_rename'] = false;
         }
         if ($contentValue == '1') {
             //content权限 与js格式转化为一致
             $privilege['file_edit'] = true;
         } else {
             $privilege['file_edit'] = false;
         }
         if ($fileDelValue == '1') {
             //file_del权限 与js格式转化为一致
             $privilege['file_delete'] = true;
         } else {
             $privilege['file_delete'] = false;
         }
         if ($previewValue == '1') {
             //preview权限 与js格式转化为一致
             $privilege['download'] = true;
         } else {
             $privilege['download'] = false;
         }
         if ($modifyValue == '11111111') {
             $privilege['modified'] = true;
         } else {
             $privilege['modified'] = false;
         }
         $privilege['type'] = "1";
         array_push($data, $privilege);
     }
     return $data;
 }
Ejemplo n.º 11
0
 /**
  * 把db对象转换为array
  * @param object $item
  * @return array|null
  */
 private function db2Item($item)
 {
     if (isset($item)) {
         $user = array();
         $user["id"] = $item->id;
         $user["user_id"] = $item->id;
         $user["user_uuid"] = $item->user_uuid;
         $user["user_name"] = $item->user_name;
         $user["user_pass"] = $item->user_pass;
         $user["user_status"] = $item->user_status == 0 ? false : true;
         $user["user_pass"] = $item->user_pass;
         $user["user_status"] = $item->user_status;
         $user["salt"] = $item->salt;
         $user["created_at"] = $item->created_at;
         $user["updated_at"] = $item->updated_at;
         //查询用户Meta信息
         $avatar = Yii::app()->params["defaultAvatar"];
         if (!MiniHttp::isConsole()) {
             $avatar = MiniHttp::getMiniHost() . $avatar;
         }
         $user["avatar"] = $avatar;
         $user["nick"] = $user["user_name"];
         $user["phone"] = "";
         $user["email"] = "";
         $user["space"] = MUtils::defaultTotalSize();
         $user["is_admin"] = false;
         $metas = MiniUserMeta::getInstance()->getUserMetas($user["id"]);
         foreach ($metas as $key => $value) {
             if ($key === "nick") {
                 $user["nick"] = $value;
             }
             if ($key === "phone") {
                 $user["phone"] = $value;
             }
             if ($key === "email") {
                 $user["email"] = $value;
             }
             if ($key === "space") {
                 $user["space"] = $value;
             }
             if ($key === "is_admin") {
                 $user["is_admin"] = $value === "1" ? true : false;
             }
             if ($key === 'file_sort_type') {
                 $user["file_sort_type"] = $value;
             }
             if ($key === 'file_sort_order') {
                 $user["file_sort_order"] = $value;
             }
         }
         //获得用户头像,如本地没有图片,则重新下载原始图片
         if (array_key_exists("avatar", $metas)) {
             $value = $metas["avatar"];
             if (strpos($value, "http") === 0) {
                 $user["avatar"] = $value;
             } else {
                 $savePath = THUMBNAIL_TEMP . "avatar";
                 $path = $savePath . '/' . $value;
                 if (!file_exists($path)) {
                     if (!file_exists($savePath)) {
                         mkdir($savePath);
                     }
                     $url = $metas["avatar_url"];
                     file_put_contents($path, file_get_contents($url));
                 }
                 $user["avatar"] = MiniHttp::getMiniHost() . "assets/thumbnails/avatar/" . $value;
             }
         }
         return $user;
     }
     return NULL;
 }
Ejemplo n.º 12
0
 /**
  * delete头像
  * @param
  * @return string
  */
 public function deleteAvatar($avatar)
 {
     $userId = $this->user['id'];
     $file = MiniHttp::getMiniHost() . "static/thumbnails/avatar/" . $avatar;
     MUtils::RemoveFile($file);
     $result = MiniUserMeta::getInstance()->deleteAvatar($userId, $avatar);
     return array(success => $result);
 }
Ejemplo n.º 13
0
 /**
  *商业般主题插件参数设置
  * @param $companyName 公司名称
  * @param $productName 产品名称
  * @param $companyEnglishName 公司英文名称
  * @param $helpUrl 帮助链接地址
  * @param $helpName 帮助名称
  */
 public function setParams($companyName, $productName, $companyEnglishName, $helpUrl, $helpName)
 {
     $host = MiniHttp::getMiniHost();
     $key = "plugin_" . "businessTheme";
     $value = array();
     if (empty($companyName)) {
         echo '公司名不能为空';
         exit;
     }
     if (empty($productName)) {
         echo '产品名不能为空';
         exit;
     }
     $businessThemeData = MiniOption::getInstance()->getOptionValue($key);
     if (!empty($businessThemeData)) {
         $value = unserialize($businessThemeData);
     }
     $value['companyName'] = $companyName;
     $value['productName'] = $productName;
     $value['companyEnglishName'] = $companyEnglishName;
     $value['helpUrl'] = $helpUrl;
     $value['helpName'] = $helpName;
     $iconFile = $_FILES['icon'];
     $carouselPictures = $_FILES['carousel_pictures'];
     if (!empty($iconFile['name'])) {
         $iconFilePath = BASE . '../static/images/plugins/pluginTheme/icon.png';
         if ($iconFile['error'] == 0) {
             list($width, $height, $type, $attr) = getimagesize($iconFile['tmp_name']);
             if ($width != 256 || $height != 256) {
                 echo 'Logo文件大小不合法!';
                 echo "<script type='text/javascript'> setTimeout(function(){window.parent.location = '" . $host . "index.php/consolePlugin/businessTheme'},1000);</script>";
                 exit;
             }
             move_uploaded_file($iconFile['tmp_name'], $iconFilePath);
         }
         $value['logo'] = $host . 'static/images/plugins/pluginTheme/icon.png';
     } else {
         $value['logo'] = '';
     }
     if (!empty($carouselPictures['name'])) {
         $total = count($carouselPictures['name']) - 1;
         $carouselImagesUrl = array();
         for ($i = 0; $i <= $total; $i++) {
             if ($carouselPictures['error'][$i] == 0) {
                 list($width, $height, $type, $attr) = getimagesize($carouselPictures['tmp_name'][$i]);
                 if ($width != 1055 || $height != 575) {
                     echo '轮播图片文件大小不合法!';
                     echo "<script type='text/javascript'> setTimeout(function(){window.parent.location = '" . $host . "index.php/consolePlugin/businessTheme'},1000);</script>";
                     exit;
                 }
                 $saveFilePath = BASE . '../static/images/plugins/pluginTheme/p' . $i . '.png';
                 move_uploaded_file($carouselPictures['tmp_name'][$i], $saveFilePath);
                 array_push($carouselImagesUrl, $host . 'static/images/plugins/pluginTheme/p' . $i . '.png');
             }
         }
         $value['carouselImagesUrl'] = $carouselImagesUrl;
     } else {
         $value['carouselImagesUrl'] = '';
     }
     MiniOption::getInstance()->setOptionValue($key, serialize($value));
     echo '提交成功!';
     echo "<script type='text/javascript'> setTimeout(function(){window.parent.location = '" . $host . "index.php/consolePlugin/businessTheme'},1000);</script>";
     exit;
 }
Ejemplo n.º 14
0
 /**
  * 在线浏览文件获得内容
  * @param string $path 文件当前路径
  * @param string $type 文件类型,可选择pdf/png
  * @throws
  * @return NULL
  */
 public function previewContent($path, $type)
 {
     $file = MiniFile::getInstance()->getByPath($path);
     // 权限处理
     if (empty($file)) {
         return array('success' => false, 'msg' => 'file not existed');
     }
     $fileBiz = new FileBiz();
     $canRead = $fileBiz->privilege($path);
     if (!$canRead) {
         throw new MFileopsException(Yii::t('api', 'no permission'), MConst::HTTP_CODE_409);
     }
     //获得文件当前版本对应的version
     $version = PluginMiniDocVersion::getInstance()->getVersion($file["version_id"]);
     $signature = $version["file_signature"];
     $localPath = PluginMiniDocOption::getInstance()->getMiniDocCachePath() . $signature . "/" . $signature . "." . $type;
     if (!file_exists($localPath)) {
         //文档还在转换中
         $node = PluginMiniDocNode::getInstance()->getConvertNode($signature);
         if (empty($node)) {
             throw new MFileopsException(Yii::t('api', 'convert error'), MConst::HTTP_CODE_412);
         }
         //根据情况判断是否需要向迷你文档拉取内容
         $parentPath = dirname($localPath);
         //如果缓存目录不存在,则需要创建
         if (!file_exists($parentPath)) {
             MUtils::MkDirsLocal($parentPath);
         }
         //文件不存在,则需要从迷你文档拉取文件内容
         $url = PluginMiniDocNode::getInstance()->getDownloadUrl($node["id"], $version, $type);
         $http = new HttpClient();
         $http->get($url);
         $status = $http->get_status();
         if ($status == "200") {
             $content = $http->get_body();
             //把文件内容存储到本地硬盘
             file_put_contents($localPath, $content);
             Yii::log($signature . " get " . $type . " success", CLogger::LEVEL_INFO, "doc.convert");
         } else {
             if (!($version["doc_convert_status"] == -1)) {
                 //如迷你文档服务器不存在该文档,说明迷你文档服务器发生了变动
                 //这个时候自动启动负载均衡机制,把文档重新转换
                 PluginMiniDocVersion::getInstance()->pushConvertSignature($signature, "");
                 Yii::log($signature . " get " . $type . " error", CLogger::LEVEL_ERROR, "doc.convert");
             }
         }
     }
     if (file_exists($localPath)) {
         if ($type === "png") {
             $contentType = "image/png";
         }
         if ($type === "pdf") {
             $contentType = "Content-type: application/pdf";
         }
         //Firefox+混合云模式下直接输出内容
         //其它浏览器使用sendfile模式输出内容
         $isSendFile = true;
         if (MiniUtil::isMixCloudVersion()) {
             $ua = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : NULL;
             if (strpos($ua, "Firefox") > 0 || strpos($ua, "Safari") > 0) {
                 $isSendFile = false;
             }
         }
         if ($isSendFile) {
             header('Location: ' . MiniHttp::getMiniHost() . "assets/minidoc/" . $signature . "/" . $signature . "." . $type);
         } else {
             Header("Content-type: " . $contentType);
             echo file_get_contents($localPath);
             exit;
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * 获取站点的基本信息
  */
 public function getSiteInfo()
 {
     $data = array();
     $data['siteTitle'] = MiniOption::getInstance()->getOptionValue('site_title');
     $data['siteName'] = MiniOption::getInstance()->getOptionValue('site_name');
     $data['siteDefaultSpace'] = MiniOption::getInstance()->getOptionValue('site_default_space');
     $data['siteCompany'] = MiniOption::getInstance()->getOptionValue('site_company');
     $data['userRegisterEnabled'] = MiniOption::getInstance()->getOptionValue('user_register_enabled');
     $miniHost = MiniOption::getInstance()->getOptionValue('miniyun_host');
     if (empty($miniHost)) {
         $miniHost = MiniHttp::getMiniHost();
         MiniOption::getInstance()->setOptionValue('miniyun_host', $miniHost);
     }
     $data['miniyun_host'] = $miniHost;
     $data['fileStorePath'] = BASE;
     return $data;
 }
Ejemplo n.º 16
0
 /**
  * 验证chooser是否有效
  */
 public function chooserValid()
 {
     $valid = false;
     $url = MiniHttp::getParam("key", "");
     $params = explode('/', $url);
     if (count($params) > 9) {
         $originDomain = $params[3];
         $appKey = $params[9];
         //本域自身使用无限制
         $currentHost = MiniHttp::getMiniHost();
         if (strpos($currentHost, $originDomain) !== false) {
             $valid = true;
         } else {
             $model = new MiniChooserForm();
             if ($model->validKey($originDomain, $appKey) === true) {
                 $valid = true;
             }
         }
     }
     if ($valid === false) {
         throw new MiniException(1301);
     }
     return array('success' => true);
 }
Ejemplo n.º 17
0
 /**
  * 创建对象
  */
 public function create()
 {
     // 查询文件信息
     $path = MiniUtil::getAbsolutePath($this->user_id, $this->path);
     $file = MiniFile::getInstance()->getByPath($path);
     if (empty($file)) {
         throw new MException(Yii::t('api', MConst::PATH_ERROR), MConst::HTTP_CODE_404);
     }
     $fileName = $file["file_name"];
     $fileSize = $file["file_size"];
     $versionId = $file["version_id"];
     // 检查是否支持缩略图
     $this->checkExistThumbnail($fileName, $fileSize);
     // 获取文件版本
     $version = MFileVersions::queryFileVersionByID($versionId);
     if (count($version) == 0) {
         throw new MException(Yii::t('api', MConst::PATH_ERROR), MConst::HTTP_CODE_404);
     }
     // 获取文件存储路径
     $isTmp = false;
     $signature = $_REQUEST["signature"];
     if (empty($signature) || $signature === "undefined") {
         $signature = $version[0]["file_signature"];
     }
     // 缩略图大小
     $sizeInfo = self::$sizes[$this->size];
     if ($sizeInfo === NULL) {
         $sizeStr = strtolower($this->size);
         $sizeList = explode("x", $sizeStr);
         $sizeInfo = array("w" => $sizeList[0], "h" => $sizeList[1]);
     }
     $this->width = $sizeInfo["w"];
     $this->height = $sizeInfo["h"];
     // 检查缩略图是否存在
     $thumbnail = THUMBNAIL_TEMP . MiniUtil::getPathBySplitStr($signature);
     $thumbnail .= "_{$this->width}_{$this->height}.{$this->format}";
     if (file_exists($thumbnail) == true) {
         //直接跳转,避免重复生成缩略图
         $url = MiniHttp::getMiniHost() . "assets/thumbnails/" . MiniUtil::getPathBySplitStr($signature);
         $url .= "_{$this->width}_{$this->height}.{$this->format}";
         header('Location: ' . $url);
         exit;
     }
     //判断文件是否在迷你存储中,兼容非迷你存储的文件
     $version = MiniVersion::getInstance()->getBySignature($signature);
     $meta = MiniVersionMeta::getInstance()->getMeta($version["id"], "store_id");
     $thumbnailData = array();
     if (!empty($meta)) {
         //为迷你存储缩略图添加hook
         $thumbnailData["signature"] = $signature;
         $storePath = apply_filters("image_path", $thumbnailData);
     }
     if (empty($storePath) || $storePath === $thumbnailData) {
         //data源处理对象
         $dataObj = Yii::app()->data;
         $signaturePath = MiniUtil::getPathBySplitStr($signature);
         if ($dataObj->isExistLocal()) {
             $storePath = $dataObj->documentStorePath($signaturePath) . $signaturePath;
         }
     }
     if (file_exists($storePath) == false) {
         throw new MException(Yii::t('api', "The file path was not found."), MConst::HTTP_CODE_404);
     }
     $pathInfo = MUtils::pathinfo_utf($fileName);
     $extension = $pathInfo["extension"];
     $tmpPath = DOCUMENT_TEMP . $signature . ".{$extension}";
     // 缩略图对象
     $this->handler = NULL;
     $this->image = $tmpPath;
     $this->resize = true;
     // 创建缩略图片父目录
     if (file_exists(dirname($thumbnail)) == false) {
         if (MUtils::MkDirsLocal(dirname($thumbnail)) == false) {
             throw new MException(Yii::t('api', "The file path was not found."), MConst::HTTP_CODE_404);
         }
     }
     // 临时文件父目录
     if (file_exists(dirname($tmpPath)) == false) {
         if (MUtils::MkDirsLocal(dirname($tmpPath)) == false) {
             throw new MException(Yii::t('api', "The file path was not found."), MConst::HTTP_CODE_404);
         }
     }
     // 拷贝文件到临时目录
     if (file_exists($tmpPath) == false) {
         if (copy($storePath, $tmpPath) == false) {
             throw new MException(Yii::t('api', "The file path was not found."), MConst::HTTP_CODE_404);
         }
     }
     // 如果图片格式与后缀不一致,转换为一致的
     if ($this->format != strtolower($extension)) {
         $fm = new Image($tmpPath);
         $format_path = DOCUMENT_TEMP . $signature . ".{$this->format}";
         $fm->save($format_path);
         // 转换成功删除临时文件
         unlink($tmpPath);
         $this->image = $format_path;
     }
     if ($isTmp) {
         unlink($storePath);
     }
     // 初始化图像对象
     try {
         $this->handler = new Image($this->image, isset($this->config) ? $this->config : NULL);
     } catch (MException $e) {
         Yii::log("Exception : {$e->getTraceAsString()}");
         throw new MException(Yii::t('api', "The image is invalid and cannot be thumbnailed."), MConst::HTTP_CODE_415);
     }
     // 生成缩略图
     if ($this->resize == true) {
         $this->handler->resize($this->width, $this->height)->rotate(0)->quality(75)->sharpen(20);
         $chmod = 0644;
         $keep_actions = true;
         try {
             $this->handler->save($thumbnail, $chmod, $keep_actions);
             $this->handler->setImageFile($thumbnail);
             $this->image = $thumbnail;
             @unlink($format_path);
         } catch (MException $e) {
             Yii::trace("Exception : {$e}", "miniyun.api");
             throw new MException(Yii::t('api', "The image is invalid and cannot be thumbnailed."), MConst::HTTP_CODE_415);
         }
     }
 }
Ejemplo n.º 18
0
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php 
echo NAME_ZH;
?>
 &rsaquo; <?php 
echo Yii::t("front_common", "install_title");
?>
</title>
<link rel="shortcut icon" href="<?php 
echo Yii::app()->params['app']['host'] . Yii::app()->params['app']['logoSmall'];
?>
" />
<link rel="stylesheet" href="<?php 
echo MiniHttp::getMiniHost();
?>
static/css/install.css?v=<?php 
echo APP_VERSION;
?>
" type="text/css" />
<style>
.errorSummary {
	border: 2px solid #C00;
	padding: 7px 7px 12px 7px;
	margin: 0 0 20px 0;
	background: #FEE;
	font-size: 0.9em;
}
.errorMessage {color: red;font-size: 0.9em;}
.errorSummary p {margin: 0;padding: 5px;}
 /**
  * 设置默认参数
  */
 public static function getDefaultParams()
 {
     $host = MiniHttp::getMiniHost();
     $data = array('companyName' => '让文件管理更简单', 'companyEnglishName' => 'make document management easier', 'productName' => '迷你云', 'logo' => $host . 'static/images/logo.png', 'carouselImagesUrl' => array($host . 'static/images/plugins/pluginTheme/default.png'), 'helpName' => '帮助', 'helpUrl' => 'http://bbs.miniyun.cn');
     return $data;
 }