diff --git a/crmeb/README.md b/crmeb/README.md index c82cb7bb..0270f094 100644 --- a/crmeb/README.md +++ b/crmeb/README.md @@ -1,4 +1,4 @@ -CRMEB v4.5 后端程序目录 +CRMEB v5 后端程序目录 =============== > 运行环境要求PHP7.1-7.4。 @@ -8,12 +8,10 @@ CRMEB v4.5 后端程序目录 ## 一键安装 上传你的代码,站点入口目录设置/public 在浏览器中输入你的域名或IP(例如:www.yourdomain.com), -安装程序会自动执行安装。期间系统会提醒你输入数据库信息以完成安装,安装完成后建议删除install目录下index.php文件或将其改名。 +安装程序会自动执行安装。期间系统会提醒你输入数据库信息以完成安装,安装完成后建议删除install目录。 后台访问地址: 1.域名/admin -2.域名/index.php/admin -3.域名/index.php?s=/admin 公众号和H5首页访问地址: 1.域名/ @@ -37,32 +35,39 @@ DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 #数据库连接地址 +HOSTPORT = 3306 #数据库端口 DATABASE = test #数据库名称 USERNAME = username #数据库登录账号 PASSWORD = password #数据库登录密码 -HOSTPORT = 3306 #数据库端口 -CHARSET = utf8 +PREFIX = eb_ +CHARSET = utf8mb4 DEBUG = true [LANG] default_lang = zh-cn +[CACHE] +DRIVER = file #缓存类型,redis/file +CACHE_PREFIX = cache_xxxx: #缓存前缀 +CACHE_TAG_PREFIX = cache_tag_xxxx: #缓存类型前缀 + [REDIS] -REDIS_HOSTNAME = 127.0.0.1 # redis链接地址 +REDIS_HOSTNAME = 127.0.0.1 #redis链接地址 PORT = 6379 #端口号 REDIS_PASSWORD = 123456 #密码 SELECT = 0 #数据库 + +[QUEUE] +QUEUE_NAME = xxxx #队列前缀 ~~~ 3.修改目录权限(linux系统)777 -/public -/runtime +/crmeb +/template + 4.后台登录: http://域名/admin 默认账号:admin 密码:crmeb.com -## 消息队列 -```sh -php think queue:listen --queue -``` + ## 消息队列 ```sh diff --git a/crmeb/app/services/agent/DivisionAgentApplyServices.php b/crmeb/app/services/agent/DivisionAgentApplyServices.php index 6a1b587a..9a56d1ff 100644 --- a/crmeb/app/services/agent/DivisionAgentApplyServices.php +++ b/crmeb/app/services/agent/DivisionAgentApplyServices.php @@ -16,6 +16,7 @@ use crmeb\services\FormBuilder as Form; use app\services\other\UploadService; use think\facade\Log; use think\facade\Route; +use think\facade\Config; class DivisionAgentApplyServices extends BaseServices { @@ -245,6 +246,18 @@ class DivisionAgentApplyServices extends BaseServices public function downloadImage($url = '', $name = '', $type = 0, $timeout = 30, $w = 0, $h = 0) { if (!strlen(trim($url))) return ''; + if (!strlen(trim($name))) { + //TODO 获取要下载的文件名称 + $downloadImageInfo = $this->getImageExtname($url); + $ext = $downloadImageInfo['ext_name']; + $name = $downloadImageInfo['file_name']; + if (!strlen(trim($name))) return ''; + } else { + $ext = $this->getImageExtname($name)['ext_name']; + } + if (!in_array($ext, Config::get('upload.fileExt'))) { + throw new AdminException(400558); + } //TODO 获取远程文件所采用的方法 if ($type) { $ch = curl_init(); @@ -283,4 +296,25 @@ class DivisionAgentApplyServices extends BaseServices $data['is_exists'] = false; return $data; } + + /** + * 获取即将要下载的图片扩展名 + * @param string $url + * @param string $ex + * @return array|string[] + */ + public function getImageExtname($url = '', $ex = 'jpg') + { + $_empty = ['file_name' => '', 'ext_name' => $ex]; + if (!$url) return $_empty; + if (strpos($url, '?')) { + $_tarr = explode('?', $url); + $url = trim($_tarr[0]); + } + $arr = explode('.', $url); + if (!is_array($arr) || count($arr) <= 1) return $_empty; + $ext_name = trim($arr[count($arr) - 1]); + $ext_name = !$ext_name ? $ex : $ext_name; + return ['file_name' => md5($url) . '.' . $ext_name, 'ext_name' => $ext_name]; + } } diff --git a/crmeb/app/services/product/product/CopyTaobaoServices.php b/crmeb/app/services/product/product/CopyTaobaoServices.php index 12924228..bcbbec93 100644 --- a/crmeb/app/services/product/product/CopyTaobaoServices.php +++ b/crmeb/app/services/product/product/CopyTaobaoServices.php @@ -18,6 +18,7 @@ use app\services\system\attachment\SystemAttachmentCategoryServices; use app\services\system\attachment\SystemAttachmentServices; use crmeb\exceptions\AdminException; use app\services\other\UploadService; +use think\facade\Config; /** * @@ -288,7 +289,7 @@ class CopyTaobaoServices extends BaseServices } else { $ext = $this->getImageExtname($name)['ext_name']; } - if (!in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'JPG', 'JPEG', 'PNG', 'GIF'])) { + if (!in_array($ext, Config::get('upload.fileExt'))) { throw new AdminException(400558); } //TODO 获取远程文件所采用的方法 diff --git a/crmeb/app/services/wechat/WechatQrcodeServices.php b/crmeb/app/services/wechat/WechatQrcodeServices.php index 4a80dfad..c7dcdc61 100644 --- a/crmeb/app/services/wechat/WechatQrcodeServices.php +++ b/crmeb/app/services/wechat/WechatQrcodeServices.php @@ -14,6 +14,7 @@ use app\services\user\UserServices; use crmeb\exceptions\AdminException; use app\services\other\UploadService; use crmeb\services\app\WechatService; +use think\facade\Config; /** * Class WechatQrcodeServices @@ -172,6 +173,18 @@ class WechatQrcodeServices extends BaseServices public function downloadImage($url = '', $name = '', $type = 0, $timeout = 30, $w = 0, $h = 0) { if (!strlen(trim($url))) return ''; + if (!strlen(trim($name))) { + //TODO 获取要下载的文件名称 + $downloadImageInfo = $this->getImageExtname($url); + $ext = $downloadImageInfo['ext_name']; + $name = $downloadImageInfo['file_name']; + if (!strlen(trim($name))) return ''; + } else { + $ext = $this->getImageExtname($name)['ext_name']; + } + if (!in_array($ext, Config::get('upload.fileExt'))) { + throw new AdminException(400558); + } //TODO 获取远程文件所采用的方法 if ($type) { $ch = curl_init(); @@ -211,6 +224,27 @@ class WechatQrcodeServices extends BaseServices return $data; } + /** + * 获取即将要下载的图片扩展名 + * @param string $url + * @param string $ex + * @return array|string[] + */ + public function getImageExtname($url = '', $ex = 'jpg') + { + $_empty = ['file_name' => '', 'ext_name' => $ex]; + if (!$url) return $_empty; + if (strpos($url, '?')) { + $_tarr = explode('?', $url); + $url = trim($_tarr[0]); + } + $arr = explode('.', $url); + if (!is_array($arr) || count($arr) <= 1) return $_empty; + $ext_name = trim($arr[count($arr) - 1]); + $ext_name = !$ext_name ? $ex : $ext_name; + return ['file_name' => md5($url) . '.' . $ext_name, 'ext_name' => $ext_name]; + } + /** * 扫码完成后方法 * @param $qrcodeInfo diff --git a/crmeb/crmeb/utils/DownloadImage.php b/crmeb/crmeb/utils/DownloadImage.php index e9ef303a..17816acf 100644 --- a/crmeb/crmeb/utils/DownloadImage.php +++ b/crmeb/crmeb/utils/DownloadImage.php @@ -15,6 +15,7 @@ namespace crmeb\utils; use app\services\other\UploadService; use crmeb\exceptions\AdminException; use think\Image; +use think\facade\Config; /** * 下载图片到本地 @@ -80,7 +81,7 @@ class DownloadImage } else { $ext = $this->getImageExtname($name)['ext_name']; } - if (!in_array($ext, ['jpg', 'jpeg', 'png', 'gif', 'JPG', 'JPEG', 'PNG', 'GIF'])) { + if (!in_array($ext, Config::get('upload.fileExt'))) { throw new AdminException(400558); } if (strstr($url, 'http://') === false && strstr($url, 'https://') === false) {