This commit is contained in:
2025-12-17 10:18:58 +08:00
commit ad4cb058fc
4112 changed files with 750772 additions and 0 deletions

21
.env Normal file
View File

@@ -0,0 +1,21 @@
# 项目配置, 请根据实际情况修改
PROJECT_NAME=PHP_OFFICIA_WEB
APP_ENV=dev
# PHP/PHP-FPM 配置
PHP_VERSION=7.4
PHP_FPM_VERSION=7.4-fpm
PHP_FPM_PORT=9108
# 数据库配置
MYSQL_ROOT_HOST=%
MYSQL_DATABASE=eyoucms
MYSQL_USER=eyoucms
MYSQL_PASSWORD=eyoucms
MYSQL_PORT=3326
# Nginx 暴漏端口
NGINX_PORT=8070
NGINX_SSL_PORT=8072

73
.gitignore vendored Normal file
View File

@@ -0,0 +1,73 @@
# Composer
composer.phar
composer.lock
# IDE
/.idea/
/.vscode/
nbproject
Thumbs.db
# System
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Logs
*.log
# Runtime data
/data/runtime/
/data/cache/
/data/temp/
# Backup data
/data/backup/
# Environment variables
# .env
# .env.local
# .env.*.local
# Build artifacts
/node_modules
/build
/dist
# Database
# *.sql
# *.sqlite
# Temporary files
*.tmp
*.temp
# Uploads directory exceptions (if needed)
!/uploads/.gitkeep
# Ignore config files that might contain sensitive information
# /application/database.php
# /config/database.php
# Ignore user specific files
*.swp
*.swo
# PHP specific
*.php~
.php_cs.cache
.php_cs.dist
.phpunit.result.cache
# OS generated files
**/*.DS_Store
**/*.swp
**/*~
# Editor files
*.sublime-project
*.sublime-workspace

108
docker-compose.yml Normal file
View File

@@ -0,0 +1,108 @@
x-shared-env: &shared-api-env
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpassword}
MYSQL_ROOT_HOST: ${MYSQL_ROOT_HOST:-'%'} # 允许root从任何主机连接
MYSQL_DATABASE: ${MYSQL_DATABASE:-eyoucms}
MYSQL_USER: ${MYSQL_USER:-eyoucms}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-eyoucms}
# 将服务归类到目录 A 中
services:
php-fpm:
build:
context: ./docker/php
dockerfile: Dockerfile
container_name: ${PROJECT_NAME}_${APP_ENV}_php
restart: always
extra_hosts:
- "host.docker.internal:host-gateway" # 支持主机名解析
environment:
PHP_ENV: ${PHP_ENV:-dev}
APP_ENV: ${APP_ENV:-dev}
APP_DEBUG: ${APP_DEBUG:-true}
ports:
- "${PHP_FPM_PORT:-9000}:9000" # PHP-FPM
volumes:
- ./src:/var/www/html
# 更新下载源列表以加速apt-get
- ./docker/debian/sources.list:/etc/apt/sources.list:ro
- ./docker/php/php.ini:/usr/local/etc/php/php.ini:ro
depends_on:
- db
healthcheck:
test: ["CMD", "bash", "-c", "curl -f http://localhost:9000/status"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
networks:
- net-php-ooficial-website
labels:
- "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}"
nginx:
build:
context: ./docker/nginx
dockerfile: Dockerfile
container_name: ${PROJECT_NAME}_${APP_ENV}_nginx
restart: always
ports:
- "${NGINX_PORT:-80}:80"
- "${NGINX_SSL_PORT:-443}:443"
volumes:
# 挂载项目代码到 Nginx 容器中
- ./src:/var/www/html:rw
# 更新下载源列表以加速apt-get
- ./docker/debian/sources.list:/etc/apt/sources.list:ro
# 创建临时目录
- /var/www/server/nginx/proxy_temp_dir
- /var/www/server/nginx/proxy_cache_dir
depends_on:
- php-fpm
networks:
- net-php-ooficial-website
labels:
- "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}"
db:
image: mysql:5.7.44
container_name: ${PROJECT_NAME}_${APP_ENV}_mysql
environment:
<<: *shared-api-env
volumes:
- mysql_db:/var/lib/mysql
- ./docker/mysql/init:/docker-entrypoint-initdb.d
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/custom.cnf
ports:
- ${MYSQL_PORT:-3306}:3306
networks:
- net-php-ooficial-website
restart: unless-stopped
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --innodb_buffer_pool_size=256M
labels:
- "com.docker.compose.project.working_dir=${PROJECT_NAME}_${APP_ENV}"
volumes:
mysql_db:
name: ${PROJECT_NAME}_${APP_ENV}_mysql_db
driver: local
driver_opts:
type: none
o: bind
device: ./docker-volumes/mysql/${APP_ENV}
redis_data:
name: ${PROJECT_NAME}_${APP_ENV}_redis_data
driver: local
driver_opts:
type: none
o: bind
device: ./docker-volumes/redis/${APP_ENV}
networks:
net-php-ooficial-website:
name: ${PROJECT_NAME}_${APP_ENV}_net
driver: bridge
external: true

0
docker-volumes/.gitkeep Normal file
View File

View File

@@ -0,0 +1,6 @@
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z bullseye main
deb https://mirrors.aliyun.com/debian/ bullseye main
# deb http://snapshot.debian.org/archive/debian-security/20221114T000000Z bullseye-security main
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z bullseye-updates main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main

11121
docker/mysql/init/init.sql Normal file

File diff suppressed because one or more lines are too long

26
docker/mysql/my.cnf Normal file
View File

@@ -0,0 +1,26 @@
[mysqld]
# 字符集设置
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
# 连接设置
max_connections=100
wait_timeout=28800
interactive_timeout=28800
# 缓冲区设置
innodb_buffer_pool_size=256M
key_buffer_size=64M
# 日志设置
slow_query_log=1
slow_query_log_file=/var/lib/mysql/slow.log
long_query_time=2
# 其他设置
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
default-character-set=utf8mb4

View File

@@ -0,0 +1,6 @@
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z bullseye main
deb https://mirrors.aliyun.com/debian/ bullseye main
# deb http://snapshot.debian.org/archive/debian-security/20221114T000000Z bullseye-security main
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z bullseye-updates main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main

29
docker/nginx/Dockerfile Normal file
View File

@@ -0,0 +1,29 @@
FROM nginx:alpine
# 删除默认配置
RUN rm /etc/nginx/conf.d/default.conf
#
# - ./.docker/nginx/conf.c:/etc/nginx/conf.c:ro
# - ./.docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
# - ./.docker/nginx/sites-enabled:/etc/nginx/sites-enabled:ro
# 将本地 nginx 配置复制到镜像中并设置为只读
COPY ./conf.c /etc/nginx/conf.c
COPY ./default.conf /etc/nginx/conf.d/default.conf
COPY ./sites-enabled /etc/nginx/sites-enabled
# 设置只读权限(文件 0444目录及其内容 0555
RUN chmod 0444 /etc/nginx/conf.c \
&& chmod 0444 /etc/nginx/conf.d/default.conf \
&& chmod -R 0555 /etc/nginx/sites-enabled
# 设置工作目录
WORKDIR /var/www/html
# 创建日志目录
RUN mkdir -p /var/log/nginx
# 暴露端口
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -0,0 +1,3 @@
# 开发环境显示错误
fastcgi_param PHP_VALUE "display_errors=On";
fastcgi_param PHP_VALUE "error_reporting=E_ALL";

View File

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-52.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-53.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-54.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-55.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-56.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-70.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-71.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-72.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-73.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,10 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
# fastcgi_pass unix:/tmp/php-cgi-74.sock;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
include conf.c/debug.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-80.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-81.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-82.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,8 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-83.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,10 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-84.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,10 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-90.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,10 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-91.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
include conf.c/pathinfo.conf;
}

View File

@@ -0,0 +1,7 @@
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi-56.sock;
fastcgi_index index.php;
include conf.c/fastcgi.conf;
}

View File

@@ -0,0 +1,26 @@
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

View File

@@ -0,0 +1,26 @@
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

View File

@@ -0,0 +1,25 @@
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

View File

@@ -0,0 +1,25 @@
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

109
docker/nginx/conf.c/koi-utf Normal file
View File

@@ -0,0 +1,109 @@
# This map is not a full koi8-r <> utf8 map: it does not contain
# box-drawing and some other characters. Besides this map contains
# several koi8-u and Byelorussian letters which are not in koi8-r.
# If you need a full and standard map, use contrib/unicode2nginx/koi-utf
# map instead.
charset_map koi8-r utf-8 {
80 E282AC ; # euro
95 E280A2 ; # bullet
9A C2A0 ; # &nbsp;
9E C2B7 ; # &middot;
A3 D191 ; # small yo
A4 D194 ; # small Ukrainian ye
A6 D196 ; # small Ukrainian i
A7 D197 ; # small Ukrainian yi
AD D291 ; # small Ukrainian soft g
AE D19E ; # small Byelorussian short u
B0 C2B0 ; # &deg;
B3 D081 ; # capital YO
B4 D084 ; # capital Ukrainian YE
B6 D086 ; # capital Ukrainian I
B7 D087 ; # capital Ukrainian YI
B9 E28496 ; # numero sign
BD D290 ; # capital Ukrainian soft G
BE D18E ; # capital Byelorussian short U
BF C2A9 ; # (C)
C0 D18E ; # small yu
C1 D0B0 ; # small a
C2 D0B1 ; # small b
C3 D186 ; # small ts
C4 D0B4 ; # small d
C5 D0B5 ; # small ye
C6 D184 ; # small f
C7 D0B3 ; # small g
C8 D185 ; # small kh
C9 D0B8 ; # small i
CA D0B9 ; # small j
CB D0BA ; # small k
CC D0BB ; # small l
CD D0BC ; # small m
CE D0BD ; # small n
CF D0BE ; # small o
D0 D0BF ; # small p
D1 D18F ; # small ya
D2 D180 ; # small r
D3 D181 ; # small s
D4 D182 ; # small t
D5 D183 ; # small u
D6 D0B6 ; # small zh
D7 D0B2 ; # small v
D8 D18C ; # small soft sign
D9 D18B ; # small y
DA D0B7 ; # small z
DB D188 ; # small sh
DC D18D ; # small e
DD D189 ; # small shch
DE D187 ; # small ch
DF D18A ; # small hard sign
E0 D0AE ; # capital YU
E1 D090 ; # capital A
E2 D091 ; # capital B
E3 D0A6 ; # capital TS
E4 D094 ; # capital D
E5 D095 ; # capital YE
E6 D0A4 ; # capital F
E7 D093 ; # capital G
E8 D0A5 ; # capital KH
E9 D098 ; # capital I
EA D099 ; # capital J
EB D09A ; # capital K
EC D09B ; # capital L
ED D09C ; # capital M
EE D09D ; # capital N
EF D09E ; # capital O
F0 D09F ; # capital P
F1 D0AF ; # capital YA
F2 D0A0 ; # capital R
F3 D0A1 ; # capital S
F4 D0A2 ; # capital T
F5 D0A3 ; # capital U
F6 D096 ; # capital ZH
F7 D092 ; # capital V
F8 D0AC ; # capital soft sign
F9 D0AB ; # capital Y
FA D097 ; # capital Z
FB D0A8 ; # capital SH
FC D0AD ; # capital E
FD D0A9 ; # capital SHCH
FE D0A7 ; # capital CH
FF D0AA ; # capital hard sign
}

103
docker/nginx/conf.c/koi-win Normal file
View File

@@ -0,0 +1,103 @@
charset_map koi8-r windows-1251 {
80 88 ; # euro
95 95 ; # bullet
9A A0 ; # &nbsp;
9E B7 ; # &middot;
A3 B8 ; # small yo
A4 BA ; # small Ukrainian ye
A6 B3 ; # small Ukrainian i
A7 BF ; # small Ukrainian yi
AD B4 ; # small Ukrainian soft g
AE A2 ; # small Byelorussian short u
B0 B0 ; # &deg;
B3 A8 ; # capital YO
B4 AA ; # capital Ukrainian YE
B6 B2 ; # capital Ukrainian I
B7 AF ; # capital Ukrainian YI
B9 B9 ; # numero sign
BD A5 ; # capital Ukrainian soft G
BE A1 ; # capital Byelorussian short U
BF A9 ; # (C)
C0 FE ; # small yu
C1 E0 ; # small a
C2 E1 ; # small b
C3 F6 ; # small ts
C4 E4 ; # small d
C5 E5 ; # small ye
C6 F4 ; # small f
C7 E3 ; # small g
C8 F5 ; # small kh
C9 E8 ; # small i
CA E9 ; # small j
CB EA ; # small k
CC EB ; # small l
CD EC ; # small m
CE ED ; # small n
CF EE ; # small o
D0 EF ; # small p
D1 FF ; # small ya
D2 F0 ; # small r
D3 F1 ; # small s
D4 F2 ; # small t
D5 F3 ; # small u
D6 E6 ; # small zh
D7 E2 ; # small v
D8 FC ; # small soft sign
D9 FB ; # small y
DA E7 ; # small z
DB F8 ; # small sh
DC FD ; # small e
DD F9 ; # small shch
DE F7 ; # small ch
DF FA ; # small hard sign
E0 DE ; # capital YU
E1 C0 ; # capital A
E2 C1 ; # capital B
E3 D6 ; # capital TS
E4 C4 ; # capital D
E5 C5 ; # capital YE
E6 D4 ; # capital F
E7 C3 ; # capital G
E8 D5 ; # capital KH
E9 C8 ; # capital I
EA C9 ; # capital J
EB CA ; # capital K
EC CB ; # capital L
ED CC ; # capital M
EE CD ; # capital N
EF CE ; # capital O
F0 CF ; # capital P
F1 DF ; # capital YA
F2 D0 ; # capital R
F3 D1 ; # capital S
F4 D2 ; # capital T
F5 D3 ; # capital U
F6 C6 ; # capital ZH
F7 C2 ; # capital V
F8 DC ; # capital soft sign
F9 DB ; # capital Y
FA C7 ; # capital Z
FB D8 ; # capital SH
FC DD ; # capital E
FD D9 ; # capital SHCH
FE D7 ; # capital CH
FF DA ; # capital hard sign
}

View File

@@ -0,0 +1,4 @@
lua_shared_dict limit 10m;
lua_package_path "/www/server/nginx/waf/?.lua";
init_by_lua_file /www/server/nginx/waf/init.lua;
access_by_lua_file /www/server/nginx/waf/waf.lua;

View File

@@ -0,0 +1,97 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/svg+xml svg svgz;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/webp webp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
font/woff woff;
font/woff2 woff2;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.oasis.opendocument.graphics odg;
application/vnd.oasis.opendocument.presentation odp;
application/vnd.oasis.opendocument.spreadsheet ods;
application/vnd.oasis.opendocument.text odt;
application/vnd.openxmlformats-officedocument.presentationml.presentation
pptx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xlsx;
application/vnd.openxmlformats-officedocument.wordprocessingml.document
docx;
application/vnd.wap.wmlc wmlc;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}

View File

@@ -0,0 +1,97 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/svg+xml svg svgz;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/webp webp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
font/woff woff;
font/woff2 woff2;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.oasis.opendocument.graphics odg;
application/vnd.oasis.opendocument.presentation odp;
application/vnd.oasis.opendocument.spreadsheet ods;
application/vnd.oasis.opendocument.text odt;
application/vnd.openxmlformats-officedocument.presentationml.presentation
pptx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xlsx;
application/vnd.openxmlformats-officedocument.wordprocessingml.document
docx;
application/vnd.wap.wmlc wmlc;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}

View File

@@ -0,0 +1,92 @@
user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
#include luawaf.conf;
include proxy.conf;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
server_tokens off;
access_log off;
server
{
listen 888;
server_name phpmyadmin;
index index.html index.htm index.php;
root /www/server/phpmyadmin;
location ~ /tmp/ {
return 403;
}
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log /www/wwwlogs/access.log;
}
include /www/server/panel/vhost/nginx/*.conf;
}

View File

@@ -0,0 +1,117 @@
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}

View File

@@ -0,0 +1,9 @@
set $real_script_name $fastcgi_script_name;
set $path_info "";
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;

View File

@@ -0,0 +1,35 @@
# 代理临时文件目录,用于存放尚未完全发送/接收的请求体或响应体片段
proxy_temp_path /var/www/server/nginx/proxy_temp_dir;
# 定义代理缓存存放路径、目录层级、缓存区名称与大小、失效时间和最大占用空间
proxy_cache_path /var/www/server/nginx/proxy_cache_dir levels=1:2 keys_zone=cache_one:20m inactive=1d max_size=5g;
# 客户端请求体缓冲区大小超过此大小的请求体会写入临时文件单位字节可用k、m
client_body_buffer_size 512k;
# 与上游服务器建立连接的超时时间(秒)
proxy_connect_timeout 60;
# 从上游服务器读取响应的超时时间(秒)
proxy_read_timeout 60;
# 向上游服务器发送请求时的超时时间(秒)
proxy_send_timeout 60;
# 用于读取上游响应头的缓冲区大小
proxy_buffer_size 32k;
# 用于读取上游响应体的缓冲区数量与每个缓冲区大小(数量 大小)
proxy_buffers 4 64k;
# 当缓冲区正在被发送到客户端时允许占用的缓冲区总大小
proxy_busy_buffers_size 128k;
# 向临时文件写入时每次写入的最大字节数
proxy_temp_file_write_size 128k;
# 指定在何种情况下将请求转发到下一个上游错误、超时、无效头以及特定HTTP状态码
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
# 在当前上下文启用名为 cache_one 的缓存区用于响应缓存(与上面的 keys_zone 名称对应)
proxy_cache cache_one;

View File

@@ -0,0 +1,17 @@
scgi_param REQUEST_METHOD $request_method;
scgi_param REQUEST_URI $request_uri;
scgi_param QUERY_STRING $query_string;
scgi_param CONTENT_TYPE $content_type;
scgi_param DOCUMENT_URI $document_uri;
scgi_param DOCUMENT_ROOT $document_root;
scgi_param SCGI 1;
scgi_param SERVER_PROTOCOL $server_protocol;
scgi_param REQUEST_SCHEME $scheme;
scgi_param HTTPS $https if_not_empty;
scgi_param REMOTE_ADDR $remote_addr;
scgi_param REMOTE_PORT $remote_port;
scgi_param SERVER_PORT $server_port;
scgi_param SERVER_NAME $server_name;

View File

@@ -0,0 +1,17 @@
scgi_param REQUEST_METHOD $request_method;
scgi_param REQUEST_URI $request_uri;
scgi_param QUERY_STRING $query_string;
scgi_param CONTENT_TYPE $content_type;
scgi_param DOCUMENT_URI $document_uri;
scgi_param DOCUMENT_ROOT $document_root;
scgi_param SCGI 1;
scgi_param SERVER_PROTOCOL $server_protocol;
scgi_param REQUEST_SCHEME $scheme;
scgi_param HTTPS $https if_not_empty;
scgi_param REMOTE_ADDR $remote_addr;
scgi_param REMOTE_PORT $remote_port;
scgi_param SERVER_PORT $server_port;
scgi_param SERVER_NAME $server_name;

View File

@@ -0,0 +1,17 @@
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REQUEST_SCHEME $scheme;
uwsgi_param HTTPS $https if_not_empty;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;

View File

@@ -0,0 +1,17 @@
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REQUEST_SCHEME $scheme;
uwsgi_param HTTPS $https if_not_empty;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;

126
docker/nginx/conf.c/win-utf Normal file
View File

@@ -0,0 +1,126 @@
# This map is not a full windows-1251 <> utf8 map: it does not
# contain Serbian and Macedonian letters. If you need a full map,
# use contrib/unicode2nginx/win-utf map instead.
charset_map windows-1251 utf-8 {
82 E2809A ; # single low-9 quotation mark
84 E2809E ; # double low-9 quotation mark
85 E280A6 ; # ellipsis
86 E280A0 ; # dagger
87 E280A1 ; # double dagger
88 E282AC ; # euro
89 E280B0 ; # per mille
91 E28098 ; # left single quotation mark
92 E28099 ; # right single quotation mark
93 E2809C ; # left double quotation mark
94 E2809D ; # right double quotation mark
95 E280A2 ; # bullet
96 E28093 ; # en dash
97 E28094 ; # em dash
99 E284A2 ; # trade mark sign
A0 C2A0 ; # &nbsp;
A1 D18E ; # capital Byelorussian short U
A2 D19E ; # small Byelorussian short u
A4 C2A4 ; # currency sign
A5 D290 ; # capital Ukrainian soft G
A6 C2A6 ; # borken bar
A7 C2A7 ; # section sign
A8 D081 ; # capital YO
A9 C2A9 ; # (C)
AA D084 ; # capital Ukrainian YE
AB C2AB ; # left-pointing double angle quotation mark
AC C2AC ; # not sign
AD C2AD ; # soft hypen
AE C2AE ; # (R)
AF D087 ; # capital Ukrainian YI
B0 C2B0 ; # &deg;
B1 C2B1 ; # plus-minus sign
B2 D086 ; # capital Ukrainian I
B3 D196 ; # small Ukrainian i
B4 D291 ; # small Ukrainian soft g
B5 C2B5 ; # micro sign
B6 C2B6 ; # pilcrow sign
B7 C2B7 ; # &middot;
B8 D191 ; # small yo
B9 E28496 ; # numero sign
BA D194 ; # small Ukrainian ye
BB C2BB ; # right-pointing double angle quotation mark
BF D197 ; # small Ukrainian yi
C0 D090 ; # capital A
C1 D091 ; # capital B
C2 D092 ; # capital V
C3 D093 ; # capital G
C4 D094 ; # capital D
C5 D095 ; # capital YE
C6 D096 ; # capital ZH
C7 D097 ; # capital Z
C8 D098 ; # capital I
C9 D099 ; # capital J
CA D09A ; # capital K
CB D09B ; # capital L
CC D09C ; # capital M
CD D09D ; # capital N
CE D09E ; # capital O
CF D09F ; # capital P
D0 D0A0 ; # capital R
D1 D0A1 ; # capital S
D2 D0A2 ; # capital T
D3 D0A3 ; # capital U
D4 D0A4 ; # capital F
D5 D0A5 ; # capital KH
D6 D0A6 ; # capital TS
D7 D0A7 ; # capital CH
D8 D0A8 ; # capital SH
D9 D0A9 ; # capital SHCH
DA D0AA ; # capital hard sign
DB D0AB ; # capital Y
DC D0AC ; # capital soft sign
DD D0AD ; # capital E
DE D0AE ; # capital YU
DF D0AF ; # capital YA
E0 D0B0 ; # small a
E1 D0B1 ; # small b
E2 D0B2 ; # small v
E3 D0B3 ; # small g
E4 D0B4 ; # small d
E5 D0B5 ; # small ye
E6 D0B6 ; # small zh
E7 D0B7 ; # small z
E8 D0B8 ; # small i
E9 D0B9 ; # small j
EA D0BA ; # small k
EB D0BB ; # small l
EC D0BC ; # small m
ED D0BD ; # small n
EE D0BE ; # small o
EF D0BF ; # small p
F0 D180 ; # small r
F1 D181 ; # small s
F2 D182 ; # small t
F3 D183 ; # small u
F4 D184 ; # small f
F5 D185 ; # small kh
F6 D186 ; # small ts
F7 D187 ; # small ch
F8 D188 ; # small sh
F9 D189 ; # small shch
FA D18A ; # small hard sign
FB D18B ; # small y
FC D18C ; # small soft sign
FD D18D ; # small e
FE D18E ; # small yu
FF D18F ; # small ya
}

41
docker/nginx/default.conf Normal file
View File

@@ -0,0 +1,41 @@
#include luawaf.conf; # 可选Lua防火墙配置当前被注释
include conf.c/proxy.conf; # 引入反向代理或公共设置
# server_names_hash_bucket_size 512; # server_name哈希桶大小影响域名匹配性能
# client_header_buffer_size 32k; # 单个请求头的缓冲区大小
# large_client_header_buffers 4 32k; # 用于大请求头的缓冲区数量与大小
# client_max_body_size 50m; # 客户端请求体最大尺寸(上传限制)
# sendfile on; # 启用高效文件传输sendfile
# tcp_nopush on; # 优化TCP以减少分片与sendfile配合
# keepalive_timeout 60; # keep-alive连接超时时间
# tcp_nodelay on; # 关闭Nagle算法以减少小包延迟
# fastcgi_connect_timeout 300; # FastCGI连接超时
# fastcgi_send_timeout 300; # 发送给FastCGI的超时
# fastcgi_read_timeout 300; # 从FastCGI读取响应的超时
# fastcgi_buffer_size 64k; # FastCGI响应头缓冲区大小
# fastcgi_buffers 4 64k; # FastCGI响应的缓冲区数量和单个大小
# fastcgi_busy_buffers_size 128k; # FastCGI忙时缓冲区总大小避免磁盘写入
# fastcgi_temp_file_write_size 256k; # 写入临时文件前允许的阈值大小
# fastcgi_intercept_errors on; # 由nginx处理后端返回的错误页面
# gzip on; # 启用gzip压缩响应
# gzip_min_length 1k; # 小于该长度的响应不做压缩
# gzip_buffers 4 16k; # gzip压缩时使用的缓冲区数量与大小
# gzip_http_version 1.1; # 最低支持的HTTP版本以启用gzip
# gzip_comp_level 2; # gzip压缩级别1-9数值越大CPU越高
# gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; # 要压缩的内容类型
# gzip_vary on; # 添加Vary: Accept-Encoding头以支持缓存代理
# gzip_proxied expired no-cache no-store private auth; # 在代理情况下是否对响应进行gzip
# gzip_disable "MSIE [1-6]\."; # 对老旧IE浏览器禁用gzip
# limit_conn_zone $binary_remote_addr zone=perip:10m; # 基于客户端IP的连接数限制共享内存区
# limit_conn_zone $server_name zone=perserver:10m; # 基于server_name虚拟主机的连接数限制共享内存区
# server_tokens off; # 禁止在响应和错误页中显示nginx版本
# access_log off; # 关闭访问日志(可根据需求启用)
include sites-enabled/*.conf; # 引入启用的站点(虚拟主机)配置

View File

@@ -0,0 +1,75 @@
# /etc/nginx/nginx.conf
# Nginx 的主配置文件(通常是 /etc/nginx/nginx.conf变更的修改
############################################
# user nginx;
# worker_processes auto;
# events {
# worker_connections 1024;
# }
# http {
# include /etc/nginx/conf.d/*.conf; # 加载其他配置
# }
#############################################
user www www; # 运行nginx的用户和组
worker_processes auto; # 自动设置工作进程数量建议等于CPU核数
error_log /www/wwwlogs/nginx_error.log crit; # 错误日志路径及最低记录级别
pid /tmp/nginx.pid; # 主进程PID文件位置
worker_rlimit_nofile 51200; # 提高工作进程可打开的最大文件描述符数
events { # 事件模块开始
use epoll; # 指定事件驱动模型Linux上推荐epoll
worker_connections 51200; # 每个工作进程允许的最大连接数
multi_accept on; # 允许一次接收多个新连接
} # 事件模块结束
http { # HTTP 主配置块开始
include mime.types; # 引入MIME类型映射文件
#include luawaf.conf; # 可选Lua防火墙配置当前被注释
include conf.c/proxy.conf; # 引入反向代理或公共设置
default_type application/octet-stream; # 默认MIME类型
server_names_hash_bucket_size 512; # server_name哈希桶大小影响域名匹配性能
client_header_buffer_size 32k; # 单个请求头的缓冲区大小
large_client_header_buffers 4 32k; # 用于大请求头的缓冲区数量与大小
client_max_body_size 50m; # 客户端请求体最大尺寸(上传限制)
sendfile on; # 启用高效文件传输sendfile
tcp_nopush on; # 优化TCP以减少分片与sendfile配合
keepalive_timeout 60; # keep-alive连接超时时间
tcp_nodelay on; # 关闭Nagle算法以减少小包延迟
fastcgi_connect_timeout 300; # FastCGI连接超时
fastcgi_send_timeout 300; # 发送给FastCGI的超时
fastcgi_read_timeout 300; # 从FastCGI读取响应的超时
fastcgi_buffer_size 64k; # FastCGI响应头缓冲区大小
fastcgi_buffers 4 64k; # FastCGI响应的缓冲区数量和单个大小
fastcgi_busy_buffers_size 128k; # FastCGI忙时缓冲区总大小避免磁盘写入
fastcgi_temp_file_write_size 256k; # 写入临时文件前允许的阈值大小
fastcgi_intercept_errors on; # 由nginx处理后端返回的错误页面
gzip on; # 启用gzip压缩响应
gzip_min_length 1k; # 小于该长度的响应不做压缩
gzip_buffers 4 16k; # gzip压缩时使用的缓冲区数量与大小
gzip_http_version 1.1; # 最低支持的HTTP版本以启用gzip
gzip_comp_level 2; # gzip压缩级别1-9数值越大CPU越高
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; # 要压缩的内容类型
gzip_vary on; # 添加Vary: Accept-Encoding头以支持缓存代理
gzip_proxied expired no-cache no-store private auth; # 在代理情况下是否对响应进行gzip
gzip_disable "MSIE [1-6]\."; # 对老旧IE浏览器禁用gzip
limit_conn_zone $binary_remote_addr zone=perip:10m; # 基于客户端IP的连接数限制共享内存区
limit_conn_zone $server_name zone=perserver:10m; # 基于server_name虚拟主机的连接数限制共享内存区
server_tokens off; # 禁止在响应和错误页中显示nginx版本
access_log off; # 关闭访问日志(可根据需求启用)
include sites-enabled/*.conf; # 引入启用的站点(虚拟主机)配置
} # HTTP 主配置块结束

View File

@@ -0,0 +1,68 @@
server
{
listen 80;
listen 443 ssl http2 ;
server_name xcx30.5g-quickapp.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/myweb/newshop;
#SSL-START SSL相关配置请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
ssl_certificate /www/server/panel/vhost/cert/xcx30.5g-quickapp.com/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/xcx30.5g-quickapp.com/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
error_page 497 https://$host$request_uri;
#SSL-END
#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START PHP引用配置可以注释或修改
include enable-php-74.conf;
#PHP-INFO-END
#REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
# include /www/server/panel/vhost/rewrite/xcx30.5g-quickapp.com.conf; # 等于下面的内容
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
}
#REWRITE-END
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log /dev/null;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log /dev/null;
access_log /dev/null;
}
access_log /www/wwwlogs/xcx30.5g-quickapp.com.log;
error_log /www/wwwlogs/xcx30.5g-quickapp.com.error.log;
}

View File

@@ -0,0 +1,66 @@
server {
listen 80;
# listen 443 ssl http2; # Enable HTTP/2
server_name localhost;
root /var/www/html;
index index.php index.html index.htm default.php default.htm default.html;
# --- SSL configuration start ---
# ssl_certificate /etc/nginx/ssl/nginx.crt;
# ssl_certificate_key /etc/nginx/ssl/nginx.key;
# ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
# ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
# ssl_prefer_server_ciphers on;
# ssl_session_cache shared:SSL:10m;
# ssl_session_timeout 10m;
# add_header Strict-Transport-Security "max-age=31536000";
# error_page 497 https://$host$request_uri;
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# --- SSL configuration end ---
#PHP-INFO-START PHP引用配置可以注释或修改
include conf.c/enable-php-74.conf;
#PHP-INFO-END
# --- REWRITE-START --- URL重写规则引用,修改后将导致面板设置的伪静态规则失效
# include /www/server/panel/vhost/rewrite/xcx30.5g-quickapp.com.conf; # 等于下面的内容
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
}
}
# --- REWRITE-END ---
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
location ~* \.(png|jpg|jpeg|gif|svg|ico|woff|woff2)$ {
expires 30d;
error_log /dev/null;
access_log /dev/null;
}
location ~ .*\.(js|css)?$
{
expires 12h;
error_log /dev/null;
access_log /dev/null;
}
location ~ /\.
{
deny all;
}
# 日志配置
access_log /var/log/nginx/thinkphp_access.log;
error_log /var/log/nginx/thinkphp_error.log;
}

View File

@@ -0,0 +1,6 @@
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z bullseye main
deb https://mirrors.aliyun.com/debian/ bullseye main
# deb http://snapshot.debian.org/archive/debian-security/20221114T000000Z bullseye-security main
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z bullseye-updates main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main

5
docker/php/.env Normal file
View File

@@ -0,0 +1,5 @@
MYSQL_ROOT_PASSWORD=rootpassword
# 可选:你也可以在这里定义 MYSQL_DATABASE / MYSQL_USER / MYSQL_PASSWORD
MYSQL_DATABASE=shop_mallnew
MYSQL_USER=shop_mallnew
MYSQL_PASSWORD=shop_mallnew

87
docker/php/Dockerfile Normal file
View File

@@ -0,0 +1,87 @@
# 使用官方PHP镜像
FROM php:7.4.33-fpm
# 设置工作目录
WORKDIR /var/www/html
# 拷贝本地的 sources.list 文件以加速 apt-get
COPY ./sources.list /etc/apt/sources.list
# 复制Supervisor配置
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# 安装系统依赖
RUN apt-get update && apt-get install -y \
supervisor \
git \
curl \
vim \
libpng-dev \
libonig-dev \
libxml2-dev \
libssl-dev \
zip \
unzip \
libzip-dev \
default-mysql-client \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
iputils-ping \
&& rm -rf /var/lib/apt/lists/*
# 安装 PHP 扩展
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \
pdo_mysql \
mysqli \
mbstring \
exif \
pcntl \
bcmath \
gd \
zip \
sockets
# 安装 Redis 扩展
RUN pecl install redis-5.3.7 && docker-php-ext-enable redis
# 安装Composer
COPY --from=composer:2.2.25 /usr/bin/composer /usr/bin/composer
# 验证安装
RUN composer --version
# 修改 PHP 配置
RUN echo "memory_limit=256M" > /usr/local/etc/php/conf.d/memory-limit.ini \
&& echo "upload_max_filesize=50M" >> /usr/local/etc/php/conf.d/uploads.ini \
&& echo "post_max_size=50M" >> /usr/local/etc/php/conf.d/uploads.ini
# # 使用Composer安装项目依赖可选根据需要启用, 更多的时候,会出错,要在容器中执行操作)
# RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
# RUN composer install --no-dev --optimize-autoloader --working-dir=/var/www/html
# 暴露端口
EXPOSE 9000
############ 查看 cron 进程
## 查看 cron 进程
# ps aux | grep "think cron:schedule"
# # 精确查找
# pgrep -f "think cron:schedule"
# # 查看进程树
# pstree -p | grep -i cron
## 启动 cron 任务
# 守护进程模式
# nohup php think cron:schedule > /dev/null 2>&1 &
#######################################
# 启动Supervisor
# 添加在Dockerfile末尾CMD命令之前
COPY ./entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# 修改CMD命令
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

113
docker/php/entrypoint.sh Normal file
View File

@@ -0,0 +1,113 @@
#!/bin/bash
set -e
echo "=== ThinkPHP Docker权限初始化 ==="
# 定义应用根目录
APP_ROOT="/var/www/html"
# 获取正确的用户和组
if [ -n "$USER_ID" ] && [ -n "$GROUP_ID" ]; then
# 如果指定了用户ID修改www-data
usermod -u $USER_ID www-data
groupmod -g $GROUP_ID www-data
fi
echo "当前用户: $(whoami)"
echo "UID: $(id -u), GID: $(id -g)"
# 修复目录所有权和权限
fix_directory_permissions() {
local dir=$1
echo "修复PHP目录权限: $dir"
# 确保目录存在
mkdir -p "$dir"
# 设置所有权
chown -R www-data:www-data "$dir"
# 设置权限
chmod -R 775 "$dir"
# 设置setgid权限
chmod g+s "$dir"
# 尝试设置ACL如果支持
if command -v setfacl >/dev/null 2>&1; then
setfacl -dR -m u:www-data:rwx "$dir"
fi
find "$dir" -type d -exec chmod 775 {} \;
find "$dir" -type f -exec chmod 775 {} \;
find "$dir" -type d -exec chmod g+s {} \;
find "$dir" -type f -exec chmod g+s {} \;
# 设置umask
umask 0002
echo "$dir 权限设置完成, 目录权限: $(stat -c '%a %n' "$dir"), setgid权限: $(stat -c '%a %n' "$dir" | grep 's')"
}
# 处理所有需要权限的目录
directories=("runtime" "upload" "runtime/log" "runtime/cache" "runtime/temp")
for dir in "${directories[@]}"; do
fix_directory_permissions "$APP_ROOT/$dir"
done
# 验证权限
echo "=== 权限验证 ==="
echo "当前用户: $(whoami)"
echo "当前UID: $(id -u), GID: $(id -g)"
echo "当前umask: $(umask)"
# 验证www-data用户是否可以在runtime和upload目录下新建子目录
# 方法1使用sudo
if command -v sudo >/dev/null 2>&1; then
echo "使用sudo测试..."
if sudo -u www-data mkdir -p $APP_ROOT/runtime/log/test_dir 2>/dev/null; then
echo "✅ sudo: runtime目录创建子目录成功 [使用www-data用户]"
rm -rf $APP_ROOT/runtime/log/test_dir
else
echo "❌ sudo: runtime目录创建子目录失败 [使用www-data用户]"
fi
fi
# 方法2使用su
echo "使用su测试..."
if su -s /bin/sh -c "mkdir -p $APP_ROOT/runtime/log/test_dir" www-data 2>/dev/null; then
echo "✅ su: runtime目录创建子目录成功 [使用www-data用户]"
rm -rf $APP_ROOT/runtime/log/test_dir
else
echo "❌ su: runtime目录创建子目录失败 [使用www-data用户]"
fi
# 方法3使用runuser
if command -v runuser >/dev/null 2>&1; then
echo "使用runuser测试..."
if runuser -u www-data -- mkdir -p $APP_ROOT/runtime/log/test_dir 2>/dev/null; then
echo "✅ runuser: runtime目录创建子目录成功 [使用www-data用户]"
rm -rf $APP_ROOT/runtime/log/test_dir
else
echo "❌ runuser: runtime目录创建子目录失败 [使用www-data用户]"
fi
fi
# 检查www-data用户和组
echo "检查www-data用户..."
id www-data
groups www-data
# 检查目录的实际权限
echo "检查目录权限..."
ls -ld $APP_ROOT/runtime/log
ls -ld $APP_ROOT/runtime/cache
ls -ld $APP_ROOT/runtime/temp
ls -ld $APP_ROOT/upload
echo "=== 启动应用 ==="
# 执行原有的启动命令
exec "$@"

6
docker/php/php.ini Normal file
View File

@@ -0,0 +1,6 @@
display_errors = On
error_reporting = E_ALL
memory_limit = 512M
upload_max_filesize = 50M
post_max_size = 50M
opcache.enable=0 # 开发环境关闭opcache

6
docker/php/sources.list Normal file
View File

@@ -0,0 +1,6 @@
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z bullseye main
deb https://mirrors.aliyun.com/debian/ bullseye main
# deb http://snapshot.debian.org/archive/debian-security/20221114T000000Z bullseye-security main
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
# deb http://snapshot.debian.org/archive/debian/20221114T000000Z bullseye-updates main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main

View File

@@ -0,0 +1,45 @@
[supervisord]
nodaemon=true
logfile=/var/log/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/var/run/supervisord.pid
[program:chmod]
command=/bin/bash -c "while true; do chmod -R 775 /var/www/html/runtime/ /var/www/html/upload/ 2>/dev/null || true; sleep 30; done"
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
[program:php-fpm]
command=php-fpm
autostart=true
autorestart=true
startretries=3
startsecs=1
stopasgroup=true
killasgroup=true
stdout_logfile=/var/log/supervisor/php-fpm.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/php-fpm-error.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=10
[program:think-cron]
command=php /var/www/html/think cron:schedule
process_name=%(program_name)s_%(process_num)02d
numprocs=1
autostart=true
autorestart=true
startretries=3
stdout_logfile=/var/log/supervisor/think-cron.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=10
stderr_logfile=/var/log/supervisor/think-cron-error.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=10
startsecs=3
stopwaitsecs=10

23
docker/php/xdebug.ini Normal file
View File

@@ -0,0 +1,23 @@
; Xdebug 配置
zend_extension=xdebug.so
; 基本配置
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.discover_client_host=false
; 远程调试配置
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
xdebug.idekey=VSCODE
; 日志配置(调试时开启)
xdebug.log=/tmp/xdebug.log
xdebug.log_level=7
; 性能分析(可选)
; xdebug.mode=profile
; xdebug.output_dir=/tmp/profiler
; 路径映射(在 VSCode 中配置更灵活)
xdebug.remote_connect_back=0

48
docker/redis/redis.conf Normal file
View File

@@ -0,0 +1,48 @@
# Redis 配置文件
# 绑定地址(允许所有连接)
bind 0.0.0.0
# 端口
port 6379
# 密码认证
requirepass luckyshop123!@#
# 持久化设置
save 900 1
save 300 10
save 60 10000
# 数据存储目录
dir /data
# 日志级别
loglevel notice
# 日志文件
logfile ""
# 数据库数量
databases 16
# 最大内存限制
maxmemory 256mb
maxmemory-policy allkeys-lru
# 连接超时
timeout 0
# TCP keepalive
tcp-keepalive 300
# 保护模式Docker 中关闭)
protected-mode no
# 后台运行
daemonize no
# 客户端输出缓冲区限制
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

73
src/.gitignore vendored Normal file
View File

@@ -0,0 +1,73 @@
# Composer
composer.phar
composer.lock
# IDE
/.idea/
/.vscode/
nbproject
Thumbs.db
# System
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Logs
*.log
# Runtime data
/data/runtime/
/data/cache/
/data/temp/
# Backup data
/data/backup/
# Environment variables
# .env
# .env.local
# .env.*.local
# Build artifacts
/node_modules
/build
/dist
# Database
# *.sql
# *.sqlite
# Temporary files
*.tmp
*.temp
# Uploads directory exceptions (if needed)
!/uploads/.gitkeep
# Ignore config files that might contain sensitive information
# /application/database.php
# /config/database.php
# Ignore user specific files
*.swp
*.swo
# PHP specific
*.php~
.php_cs.cache
.php_cs.dist
.phpunit.result.cache
# OS generated files
**/*.DS_Store
**/*.swp
**/*~
# Editor files
*.sublime-project
*.sublime-workspace

21
src/.htaccess Normal file
View File

@@ -0,0 +1,21 @@
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
#http跳转到https
#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^(.*)$ https://www.xxxxx.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
#RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
#RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
#禁止指定脚本的运行
RewriteCond % !^$
RewriteRule data/(.*).(php|php3|php4|php5|php6|php7|pht|phtml|asp|aspx|jsp|exe|js|sql|perl|cgi|asa)$ [F]
RewriteRule template/(.*).(php|php3|php4|php5|php6|php7|pht|phtml|asp|aspx|jsp|exe|perl|cgi|asa)$ [F]
RewriteRule uploads/(.*).(php|php3|php4|php5|php6|php7|pht|phtml|asp|aspx|jsp|exe|js|perl|cgi|asa)$ [F]
</IfModule>

1
src/.user.ini Normal file
View File

@@ -0,0 +1 @@
open_basedir=/www/wwwroot/www.zgshortvideo.org.cn/:/tmp/

View File

@@ -0,0 +1 @@
deny from all

View File

@@ -0,0 +1,142 @@
<?php
namespace app\admin\behavior;
/**
* 系统行为扩展:新增/更新/删除之后的后置操作
*/
load_trait('controller/Jump');
class ActionBeginBehavior {
use \traits\controller\Jump;
protected static $actionName;
protected static $controllerName;
protected static $moduleName;
protected static $method;
/**
* 构造方法
* @param Request $request Request对象
* @access public
*/
public function __construct()
{
}
// 行为扩展的执行入口必须是run
public function run(&$params){
self::$actionName = request()->action();
self::$controllerName = request()->controller();
self::$moduleName = request()->module();
self::$method = request()->method();
$this->_initialize();
}
private function _initialize() {
if ('POST' == self::$method) {
$this->checkRepeatTitle();
$this->clearWeapp();
$this->instyes();
} else {
$this->verifyfile();
}
}
private function verifyfile()
{
$tmp1 = 'cGhwLnBocF9zZXJ2aW'.'NlaW5mbw==';
$tmp1 = base64_decode($tmp1);
$data = tpCache($tmp1);
$data = mchStrCode($data, 'DECODE');
$data = json_decode($data, true);
if (empty($data['pid']) || 2 > $data['pid']) return true;
$file = "./data/conf/{$data['code']}.txt";
$tmp2 = 'cGhwX3NlcnZpY2VtZWFs';
$tmp2 = base64_decode($tmp2);
if (!file_exists($file)) {
/*多语言*/
if (is_language()) {
$langRow = \think\Db::name('language')->order('id asc')->select();
foreach ($langRow as $key => $val) {
tpCache('php', [$tmp2=>1], $val['mark']);
}
} else { // 单语言
tpCache('php', [$tmp2=>1]);
}
/*--end*/
} else {
/*多语言*/
if (is_language()) {
$langRow = \think\Db::name('language')->order('id asc')->select();
foreach ($langRow as $key => $val) {
tpCache('php', [$tmp2=>$data['pid']], $val['mark']);
}
} else { // 单语言
tpCache('php', [$tmp2=>$data['pid']]);
}
/*--end*/
}
}
/**
* 插件每次post提交都清除插件相关缓存
* @access private
*/
private function clearWeapp()
{
/*只有相应的控制器和操作名才执行,以便提高性能*/
$ctlActArr = array(
'Weapp@*',
);
$ctlActStr = self::$controllerName.'@*';
if (in_array($ctlActStr, $ctlActArr)) {
\think\Cache::clear('hooks');
}
/*--end*/
}
/**
* 发布或编辑时,检测文档标题的重复性
* @access private
*/
private function checkRepeatTitle()
{
/*只有相应的控制器和操作名才执行,以便提高性能*/
$ctlArr = \think\Db::name('channeltype')->field('id,ctl_name,is_repeat_title')
->where('nid','NOT IN', ['guestbook','single'])
->getAllWithIndex('ctl_name');
$actArr = ['add','edit'];
if (!empty($ctlArr[self::$controllerName]) && in_array(self::$actionName, $actArr)) {
/*模型否开启文档重复标题的检测*/
if (empty($ctlArr[self::$controllerName]['is_repeat_title'])) {
$map = array(
'title' => $_POST['title'],
);
if ('edit' == self::$actionName) {
$map['aid'] = ['NEQ', $_POST['aid']];
}
$count = \think\Db::name('archives')->where($map)->count('aid');
if(!empty($count)){
$this->error('该标题已存在,请更改');
}
}
/*--end*/
}
/*--end*/
}
/**
* @access private
*/
private function instyes()
{
$ca = md5(self::$actionName.'@'.self::$controllerName);
if ('0e3e00da04fcf78cd9fd7dc763d956fc' == $ca) {
$s = '5a6J'.'6KOF'.'5oiQ5'.'Yqf';
if (1605110400 < getTime()) {
sleep(5);
$this->success(base64_decode($s));
}
}
}
}

View File

@@ -0,0 +1,110 @@
<?php
namespace app\admin\behavior;
/**
* 系统行为扩展:
*/
class AppEndBehavior {
protected static $actionName;
protected static $controllerName;
protected static $moduleName;
protected static $method;
/**
* 构造方法
* @param Request $request Request对象
* @access public
*/
public function __construct()
{
}
// 行为扩展的执行入口必须是run
public function run(&$params){
self::$actionName = request()->action();
self::$controllerName = request()->controller();
self::$moduleName = request()->module();
self::$method = request()->method();
// file_put_contents ( DATA_PATH."log.txt", date ( "Y-m-d H:i:s" ) . " " . var_export('admin_CoreProgramBehavior',true) . "\r\n", FILE_APPEND );
$this->_initialize();
}
private function _initialize() {
$this->resetAuthor(); // 临时处理授权问题
$this->clearHtmlCache(); // 变动数据之后,清除页面缓存和数据
// $this->sitemap(); // 自动生成sitemap
}
/**
* 自动生成sitemap
* @access public
*/
// private function sitemap()
// {
// /*只有相应的控制器和操作名才执行,以便提高性能*/
// if ('POST' == self::$method) {
// $channeltype_row = \think\Cache::get("extra_global_channeltype");
// if (empty($channeltype_row)) {
// $ctlArr = \think\Db::name('channeltype')
// ->where('id','NOTIN', [6,8])
// ->column('ctl_name');
// } else {
// $ctlArr = array();
// foreach($channeltype_row as $key => $val){
// if (!in_array($val['id'], [6,8])) {
// $ctlArr[] = $val['ctl_name'];
// }
// }
// }
// $systemCtl= ['Arctype'];
// $ctlArr = array_merge($systemCtl, $ctlArr);
// $actArr = ['add','edit'];
// if (in_array(self::$controllerName, $ctlArr) && in_array(self::$actionName, $actArr)) {
// sitemap_auto();
// }
// }
// /*--end*/
// }
/**
* 临时处理授权问题
*/
private function resetAuthor()
{
/*在以下相应的控制器和操作名里执行,以便提高性能*/
$ctlActArr = array(
'Index@index',
);
$ctlActStr = self::$controllerName.'@'.self::$actionName;
if (in_array($ctlActStr, $ctlActArr) && 'GET' == self::$method) {
if(!empty($_SESSION['isset_resetAuthor']))
return true;
$_SESSION['isset_resetAuthor'] = 1;
session('isset_author', null);
}
/*--end*/
}
/**
* 数据变动之后,清理页面和数据缓存
*/
private function clearHtmlCache()
{
/*在以下相应的控制器和操作名里执行,以便提高性能*/
$actArr = ['add','edit','del','recovery','changeTableVal'];
if ('POST' == self::$method) {
foreach ($actArr as $key => $val) {
if (preg_match('/^((.*)_)?('.$val.')$/i', self::$actionName)) {
foreach ([HTML_ROOT,CACHE_PATH] as $k2 => $v2) {
delFile($v2);
}
break;
}
}
}
}
}

View File

@@ -0,0 +1,275 @@
<?php
namespace app\admin\behavior;
/**
* 管理员权限控制
*/
load_trait('controller/Jump');
class AuthRoleBehavior
{
use \traits\controller\Jump;
protected static $actionName;
protected static $controllerName;
protected static $moduleName;
protected static $method;
protected static $admin_info;
/**
* 构造方法
* @param Request $request Request对象
* @access public
*/
public function __construct()
{
!isset(self::$moduleName) && self::$moduleName = request()->module();
!isset(self::$controllerName) && self::$controllerName = request()->controller();
!isset(self::$actionName) && self::$actionName = request()->action();
!isset(self::$method) && self::$method = request()->method();
!isset(self::$admin_info) && self::$admin_info = session('admin_info');
}
/**
* 模块初始化
* @param array $params 传入参数
* @access public
*/
public function moduleInit(&$params)
{
}
/**
* 操作开始执行
* @param array $params 传入参数
* @access public
*/
public function actionBegin(&$params)
{
if (0 < intval(self::$admin_info['role_id'])) {
// 检测全局的增、改、删的权限——优先级最高
$this->cud_access();
// 检测每个小插件的权限
$this->weapp_access();
// 检测栏目管理的每个栏目权限
$this->arctype_access();
// 检测内容管理每个栏目对应的内容里列表等权限
$this->archives_access();
}
}
/**
* 视图内容过滤
* @param array $params 传入参数
* @access public
*/
public function viewFilter(&$params)
{
}
/**
* 应用结束
* @param array $params 传入参数
* @access public
*/
public function appEnd(&$params)
{
}
/**
* 检测全局的增、改、删的权限
* @access private
*/
private function cud_access()
{
/*只有相应的控制器和操作名才执行,以便提高性能*/
$ctl = strtolower(self::$controllerName);
$act = strtolower(self::$actionName);
$actArr = ['add','edit','del'];
if ('weapp' == $ctl && 'execute' == $act) {
$sa = input('param.sa/s');
foreach ($actArr as $key => $cud) {
$sa = preg_replace('/^(.*)_('.$cud.')$/i', '$2', $sa); // 同名add 或者以_add类似结尾都符合
if ($sa == $cud) {
$admin_info = self::$admin_info;
$auth_role_info = !empty($admin_info['auth_role_info']) ? $admin_info['auth_role_info'] : [];
$cudArr = !empty($auth_role_info['cud']) ? $auth_role_info['cud'] : [];
if (!in_array($sa, $cudArr)) {
$this->error('您没有操作权限,请联系超级管理员分配权限');
}
break;
}
}
} else {
$post = input('post.');
array_push($actArr, 'changetableval'); // 审核信息
foreach ($actArr as $key => $cud) {
$act = preg_replace('/^(.*)_('.$cud.')$/i', '$2', $act); // 同名add 或者以_add类似结尾都符合
if ($act == $cud) {
$admin_info = self::$admin_info;
$auth_role_info = !empty($admin_info['auth_role_info']) ? $admin_info['auth_role_info'] : [];
$cudArr = !empty($auth_role_info['cud']) ? $auth_role_info['cud'] : [];
if (!in_array($act, $cudArr)) {
if ('changetableval' == $act) {
// 审核信息
if ('archives' == $post['table'] && 'arcrank' == $post['field']) {
$this->error('您没有操作权限,请联系超级管理员分配权限', null, '', 2);
}
} else {
$this->error('您没有操作权限,请联系超级管理员分配权限');
}
} else {
if (!in_array('changetableval', $cudArr)) {
// 审核信息
if (IS_POST && 'edit' == $act) {
$archivesInfo = M('archives')->field('arcrank,admin_id')->find($post['aid']);
if (-1 == $archivesInfo['arcrank'] && $archivesInfo['arcrank'] != $post['arcrank']) {
$this->error('您没有操作权限,请联系超级管理员分配权限', url('Archives/edit', ['id'=>$post['aid']]), '', 3);
}
}
}
}
break;
}
}
}
/*--end*/
}
/**
* 检测每个小插件的权限
* @access private
*/
private function weapp_access()
{
/*只有相应的控制器和操作名才执行,以便提高性能*/
$ctl = strtolower(self::$controllerName);
$act = strtolower(self::$actionName);
if ('weapp' == $ctl && 'execute' == $act) {
$sc = input('param.sc/s');
$sm = input('param.sm/s');
$sa = input('param.sa/s');
$admin_info = self::$admin_info;
$auth_role_info = !empty($admin_info['auth_role_info']) ? $admin_info['auth_role_info'] : [];
$plugins = !empty($auth_role_info['permission']['plugins']) ? $auth_role_info['permission']['plugins'] : [];
// 插件本身设置的权限列表
$config = include WEAPP_PATH.$sc.DS.'config.php';
$plugins_permission = !empty($config['permission']) ? array_keys($config['permission']) : [];
// 管理员拥有的插件具体权限
$admin_permission = !empty($plugins[$sc]['child']) ? $plugins[$sc]['child'] : [];
// 没有赋给管理员的插件具体权限
$diff_plugins_perm = array_diff($plugins_permission, $admin_permission);
// 检测插件权限
$bool = true;
if (empty($plugins_permission) && !isset($plugins[$sc])) {
$bool = false;
} else if (!empty($plugins_permission)) {
foreach ($diff_plugins_perm as $key => $val) {
if (strtolower($sm.'@'.$sa) == strtolower($val)) {
$bool = false;
break;
}
}
}
if (!$bool) {
$this->error('您没有操作权限,请联系超级管理员分配权限');
}
}
/*--end*/
}
/**
* 检测栏目管理的每个栏目权限
* @access private
*/
private function arctype_access()
{
/*只有相应的控制器和操作名才执行,以便提高性能*/
$ctl_all = strtolower(self::$controllerName.'@*');
$ctlArr = ['arctype@*'];
if (in_array($ctl_all, $ctlArr)) {
$typeids = [];
if (in_array(strtolower(self::$actionName), ['edit','del'])) {
$typeids[] = input('id/d', 0);
} else if (in_array(strtolower(self::$actionName), ['add'])) {
$typeids[] = input('parent_id/d', 0);
}
if (!$this->is_check_arctype($typeids)) {
$this->error('您没有操作权限,请联系超级管理员分配权限');
}
}
/*--end*/
}
/**
* 检测内容管理每个栏目对应的内容里列表等权限
* @access private
*/
private function archives_access()
{
/*只有相应的控制器和操作名才执行,以便提高性能*/
$ctl = strtolower(self::$controllerName);
$act = strtolower(self::$actionName);
$ctl_act = $ctl.'@'.$act;
$ctl_all = $ctl.'@*';
$ctlArr= ['arctype@single','archives@*'];
$row = \think\Db::name('channeltype')
->where('nid','NOTIN', ['single'])
->column('ctl_name');
foreach ($row as $key => $val) {
array_push($ctlArr, strtolower($val).'@*');
}
if (in_array($ctl_act, $ctlArr) || in_array($ctl_all, $ctlArr)) {
$typeids = [];
if (in_array($act, ['add','edit','del'])) {
$aids = [];
switch ($act) {
case 'edit':
$aids = input('id/a', []);
break;
case 'del':
$aids = input('del_id/a', []);
break;
default:
# code...
break;
}
if (!empty($aids)) {
$typeids = M('archives')->where('aid','IN',$aids)->column('typeid');
}
} else {
$typeids[] = input('typeid/d', 0);
}
if (!$this->is_check_arctype($typeids)) {
$this->error('您没有操作权限,请联系超级管理员分配权限');
}
}
/*--end*/
}
/**
* 检测栏目是否有权限
*/
private function is_check_arctype($typeids = []) {
$bool_flag = true;
$admin_info = self::$admin_info;
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
$permission = $auth_role_info['permission'];
foreach ($typeids as $key => $tid) {
if (0 < intval($tid) && !in_array($tid, $permission['arctype'])) {
$bool_flag = false;
break;
}
}
}
return $bool_flag;
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace app\admin\behavior;
/**
* 系统行为扩展:
*/
class ModuleInitBehavior {
protected static $actionName;
protected static $controllerName;
protected static $moduleName;
protected static $method;
/**
* 构造方法
* @param Request $request Request对象
* @access public
*/
public function __construct()
{
}
// 行为扩展的执行入口必须是run
public function run(&$params){
self::$actionName = request()->action();
self::$controllerName = request()->controller();
self::$moduleName = request()->module();
self::$method = request()->method();
$this->_initialize();
}
private function _initialize() {
// $this->setChanneltypeStatus();
}
/**
* 根据前端模板自动开启系统模型
*/
// private function setChanneltypeStatus()
// {
// /*不在以下相应的控制器和操作名里不往下执行,以便提高性能*/
// $ctlActArr = array(
// 'Index@index',
// 'System@clear_cache',
// );
// $ctlActStr = self::$controllerName.'@'.self::$actionName;
// if (!in_array($ctlActStr, $ctlActArr) || 'GET' != self::$method) {
// return true;
// }
// /*--end*/
// // 根据前端模板自动开启系统模型
// model('Channeltype')->setChanneltypeStatus();
// }
}

View File

@@ -0,0 +1,144 @@
<?php
namespace app\admin\behavior;
use think\Db;
/**
* 系统行为扩展:
*/
class ViewFilterBehavior {
protected static $actionName;
protected static $controllerName;
protected static $moduleName;
protected static $method;
/**
* 构造方法
* @param Request $request Request对象
* @access public
*/
public function __construct()
{
}
// 行为扩展的执行入口必须是run
public function run(&$params){
self::$actionName = request()->action();
self::$controllerName = request()->controller();
self::$moduleName = request()->module();
self::$method = request()->method();
$this->_initialize($params);
}
private function _initialize(&$params) {
$this->weappUpgrade($params);
}
/**
* 每个插件主入口index页面进行更新包检测
*/
private function weappUpgrade(&$params)
{
$ca = self::$controllerName.'&'.self::$actionName;
if ('Weapp&execute' == $ca && 'GET' == self::$method) {
$code = input('param.sm/s');
if (!empty($code)) {
$url1 = url('Weapp/ajax_check_upgrade');
$url2 = url('Weapp/OneKeyUpgrade');
$url3 = url('Weapp/ajax_cancel_upgrade');
$replace = <<<EOF
<script type="text/javascript">
$(function(){
weapp_upgrade_1599613252();
// 检测升级
function weapp_upgrade_1599613252()
{
var code = '{$code}';
$.ajax({
type : "GET",
url : "{$url1}",
data : {code:code , _ajax:1},
dataType: 'json',
success: function(res) {
if (res.code == 1 && res.data.upgrade && res.data.upgrade.code == 2) {
var upgrade_str = res.data.upgrade.msg.upgrade;
var intro_str = res.data.upgrade.msg.intro;
var notice_str = res.data.upgrade.msg.notice;
intro_str += '<style type="text/css">.layui-layer-content{height:270px!important;text-align:left!important;}</style>';
upgrade_str = notice_str + intro_str + '<br/>' + upgrade_str;
//询问框
layer.confirm(upgrade_str, {
title: false,//'检测插件更新',
area: ['580px','400px'],
btn: ['立即升级','不再提醒'] //按钮
}, function(){
layer.closeAll();
setTimeout(function(){
upgrade_1599613252(code); // 请求后台
},200);
}, function(){
setTimeout(function(){
cancel_upgrade_1599613252(code);
},200);
});
}
}
});
}
// 执行升级
function upgrade_1599613252(code){
layer_loading('升级中');
$.ajax({
type : "GET",
url : "{$url2}",
timeout : 360000, //超时时间设置,单位毫秒 设置了 1小时
data : {code:code, _ajax:1},
error: function(request) {
layer.closeAll();
layer.alert("升级失败,请第一时间联系技术协助!", {icon: 2, closeBtn: false, title:false}, function(){
window.location.reload();
});
},
success: function(res) {
layer.closeAll();
if(1 == res.code){
layer.alert('已升级最新版本!', {icon: 1, closeBtn: false, title:false}, function(){
window.location.reload();
});
}
else{
layer.alert(res.msg, {icon: 2, closeBtn: false, title:false}, function(){
window.location.reload();
});
}
}
});
}
// 不再提醒
function cancel_upgrade_1599613252(code){
$.ajax({
type : "GET",
url : "{$url3}",
data : {code:code, _ajax:1},
success: function(res) {
}
});
}
});
</script>
</body>
EOF;
$params = str_ireplace('</body>', $replace, $params);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,287 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
/**
* 权限属性说明
* array
* id 主键ID
* menu_id 一级模块ID
* menu_id2 二级模块ID
* name 权限名称
* is_modules 是否显示在分组下
* sort_order 排序号
* auths 权限列表(格式:控制器@*,控制器@操作名 --多个权限以逗号隔开)
*/
return [
[
'id' => 1,
'menu_id' => 1001,
'menu_id2' => 0,
'name' => '栏目管理',
'is_modules' => 1,
'sort_order' => 100,
'auths' => 'Arctype@index,Arctype@add,Arctype@edit,Arctype@del,Arctype@pseudo_del',
],
[
'id' => 2,
'menu_id' => 1002,
'menu_id2' => 0,
'name' => '内容管理',
'is_modules' => 1,
'sort_order' => 100,
'auths' => 'Archives@*,Arctype@single_edit',
],
[
'id' => 3, // 广告管理
'menu_id' => 1003,
'menu_id2' => 0,
'name' => '允许操作',
'is_modules' => 1,
'sort_order' => 100,
'auths' => 'Other@*,AdPosition@*',
],
[
'id' => 4,
'menu_id' => 2001,
'menu_id2' => 2001001,
'name' => '网站设置',
'is_modules' => 1,
'sort_order' => 10,
'auths' => 'System@web,System@customvar_index,System@customvar_save,System@customvar_del',
],
[
'id' => 5,
'menu_id' => 2001,
'menu_id2' => 2001002,
'name' => '核心设置',
'is_modules' => 1,
'sort_order' => 20,
'auths' => 'System@web2',
],
[
'id' => 6,
'menu_id' => 2001,
'menu_id2' => 2001003,
'name' => '附件设置',
'is_modules' => 1,
'sort_order' => 30,
'auths' => 'System@basic',
],
[
'id' => 7,
'menu_id' => 2004,
'menu_id2' => 2004009,
'name' => '水印配置',
'is_modules' => 1,
'sort_order' => 20,
'auths' => 'System@water',
],
[
'id' => 8,
'menu_id' => 2003,
'menu_id2' => 2003001,
'name' => 'URL配置',
'is_modules' => 1,
'sort_order' => 10,
'auths' => 'Seo@*',
],
[
'id' => 9,
'menu_id' => 2003,
'menu_id2' => 2003003,
'name' => '友情链接',
'is_modules' => 1,
'sort_order' => 30,
'auths' => 'Links@*',
],
[
'id' => 10,
'menu_id' => 2004,
'menu_id2' => 2004001,
'name' => '管理员',
'is_modules' => 1,
'sort_order' => 50,
'auths' => 'Admin@admin_pwd',
],
[
'id' => 11,
'menu_id' => 2004,
'menu_id2' => 2004002,
'name' => '备份还原',
'is_modules' => 1,
'sort_order' => 70,
'auths' => 'Tools@*',
],
[
'id' => 12,
'menu_id' => 2004,
'menu_id2' => 2004003,
'name' => '模板管理',
'is_modules' => 1,
'sort_order' => 100,
'auths' => 'Filemanager@*',
],
[
'id' => 13,
'menu_id' => 2001,
'menu_id2' => 2001005,
'name' => '接口配置',
'is_modules' => 1,
'sort_order' => 100,
'auths' => 'System@api_conf,Member@wechat_set,Member@alipay_set,System@smtp,System@smtp_tpl,System@smtp_tpl_edit,System@sms,System@sms_tpl,System@microsite,PayApi@*',
],
// [
// 'id' => 14,
// 'menu_id' => 2004,
// 'menu_id2' => 2004005,
// 'name' => '清除缓存',
// 'is_modules' => 1,
// 'sort_order' => 100,
// 'auths' => 'System@clear_cache',
// ],
[
'id' => 15,
'menu_id' => 2005,
'menu_id2' => 0,
'name' => '插件应用',
'is_modules' => 1,
'sort_order' => 100,
'auths' => 'Weapp@index,Weapp@create,Weapp@pack,Weapp@upload,Weapp@disable,Weapp@install,Weapp@enable,Weapp@execute',
],
[
'id' => 16,
'menu_id' => 2002,
'menu_id2' => 0,
'name' => '允许操作',
'is_modules' => 1,
'sort_order' => 100,
'auths' => 'Uiset@*',
],
[
'id' => 17,
'menu_id' => 2005,
'menu_id2' => 0,
'name' => '插件卸载',
'is_modules' => 0,
'sort_order' => 100,
'auths' => 'Weapp@uninstall',
],
[
'id' => 18,
'menu_id' => 2004,
'menu_id2' => 2004001,
'name' => '权限组',
'is_modules' => 0,
'sort_order' => 100,
'auths' => 'Admin@admin_add,Admin@admin_del,AuthRole@*',
],
[
'id' => 19,
'menu_id' => 2004,
'menu_id2' => 2004006,
'name' => '回收站',
'is_modules' => 1,
'sort_order' => 60,
'auths' => 'RecycleBin@*',
],
[
'id' => 20,
'menu_id' => 2004,
'menu_id2' => 2004007,
'name' => '频道模型',
'is_modules' => 1,
'sort_order' => 80,
'auths' => 'Channeltype@*,Field@*',
],
[
'id' => 21,
'menu_id' => 2006,
'menu_id2' => 0,
'name' => '允许操作',
'is_modules' => 1,
'sort_order' => 100,
'auths' => 'Member@*',
],
[
'id' => 22,
'menu_id' => 2004,
'menu_id2' => 2004004,
'name' => '栏目字段',
'is_modules' => 1,
'sort_order' => 90,
'auths' => 'Field@arctype_index,Field@arctype_add,Field@arctype_edit,Field@arctype_del',
],
[
'id' => 23,
'menu_id' => 2008,
'menu_id2' => 0,
'name' => '允许操作',
'is_modules' => 1,
'sort_order' => 100,
'auths' => 'Statistics@*,Shop@*,ShopProduct@*,Member@*',
],
[
'id' => 24,
'menu_id' => 2009,
'menu_id2' => 0,
'name' => '允许操作',
'is_modules' => 1,
'sort_order' => 100,
'auths' => 'Diyminipro@*',
],
[
'id' => 25,
'menu_id' => 2003,
'menu_id2' => 2003002,
'name' => 'Sitemap',
'is_modules' => 1,
'sort_order' => 20,
'auths' => 'Sitemap@*',
],
[
'id' => 26,
'menu_id' => 2004,
'menu_id2' => 2004008,
'name' => '文档属性',
'is_modules' => 1,
'sort_order' => 10,
'auths' => 'ArchivesFlag@*',
],
[
'id' => 27,
'menu_id' => 2004,
'menu_id2' => 2004010,
'name' => '缩略图配置',
'is_modules' => 1,
'sort_order' => 30,
'auths' => 'System@thumb',
],
[
'id' => 28,
'menu_id' => 2004,
'menu_id2' => 2004011,
'name' => 'TAG管理',
'is_modules' => 1,
'sort_order' => 40,
'auths' => 'Tags@*',
],
[
'id' => 29,
'menu_id' => 2004,
'menu_id2' => 2004012,
'name' => '模块开关',
'is_modules' => 1,
'sort_order' => 1,
'auths' => 'Index@switch_map',
],
];

View File

@@ -0,0 +1,3 @@
<?php
define('INSTALL_DATE',1684043912);
define('SERIALNUMBER','20230514015832urBSc5');

View File

@@ -0,0 +1,7 @@
<?php
/**
* 配置常量
*/
return array(
);

View File

View File

@@ -0,0 +1,785 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
$main_lang= get_main_lang();
$admin_lang = get_admin_lang();
$domain = request()->domain();
/*PC端可视编辑URl*/
$uiset_pc_arr = [];
if (file_exists(ROOT_PATH.'template/'.TPL_THEME.'pc/uiset.txt')) {
$uiset_pc_arr = array(
'url' => url('Uiset/pc', array(), true, $domain),
'is_menu' => 1,
);
}
/*--end*/
/*手机端可视编辑URl*/
$uiset_mobile_arr = [];
if (file_exists(ROOT_PATH.'template/'.TPL_THEME.'mobile/uiset.txt')) {
$uiset_mobile_arr = array(
'url' => url('Uiset/mobile', array(), true, $domain),
'is_menu' => 1,
);
}
/*--end*/
/*清理数据URl*/
$uiset_data_url = '';
if (!empty($uiset_pc_arr) || !empty($uiset_mobile_arr)) {
$uiset_data_url = url('Uiset/ui_index', array(), true, $domain);
}
/*--end*/
/*可视编辑URL*/
$uiset_index_arr = array();
if (!empty($uiset_pc_arr) || !empty($uiset_mobile_arr)) {
$uiset_index_arr = array(
'url' => url('Uiset/index', array(), true, $domain),
'is_menu' => 1,
);
}
/*--end*/
/*基本信息*/
$ctlactArr = [
'System@web',
'System@web2',
'System@basic',
'System@water',
'System@api_conf',
'PayApi@pay_api_index',
];
$system_index_arr = array();
foreach ($ctlactArr as $key => $val) {
if (is_check_access($val)) {
$arr = explode('@', $val);
$system_index_arr = array(
'controller' => !empty($arr[0]) ? $arr[0] : '',
'action' => !empty($arr[1]) ? $arr[1] : '',
);
break;
}
}
/*--end*/
/*SEO优化URl*/
$seo_index_arr = array();
if ($main_lang != $admin_lang) {
$seo_index_arr = array(
'controller' => 'Links',
'action' => 'index',
);
} else {
$ctlactArr = [
'Seo@seo',
'Sitemap@index',
'Links@index',
];
foreach ($ctlactArr as $key => $val) {
if (is_check_access($val)) {
$arr = explode('@', $val);
$seo_index_arr = array(
'controller' => !empty($arr[0]) ? $arr[0] : '',
'action' => !empty($arr[1]) ? $arr[1] : '',
);
break;
}
}
}
/*--end*/
/*备份还原URl*/
$tools_index_arr = array();
if ($main_lang == $admin_lang) {
$tools_index_arr = array(
'is_menu' => 1,
);
}
/*--end*/
/*频道模型URl*/
$channeltype_index_arr = array();
if ($main_lang == $admin_lang) {
$channeltype_index_arr = array(
'is_menu' => 1,
);
}
/*--end*/
/*回收站URl*/
$recyclebin_index_arr = array();
if ($main_lang == $admin_lang) {
$recyclebin_index_arr = array(
'is_menu' => 1,
);
}
/*--end*/
/*插件应用URl*/
$weapp_index_arr = array();
if (1 == tpCache('web.web_weapp_switch') && file_exists(ROOT_PATH.'weapp')) {
//功能限制
$auth_function = true;
if (function_exists('checkAuthRule')) {
$auth_function = checkAuthRule(2005);
}
//2005 菜单id
if ($auth_function){
$weapp_index_arr = array(
'is_menu' => 1,
);
}else{
$weapp_index_arr = array(
'is_menu' => 0,
);
}
}
/*--end*/
/*会员中心URl*/
$users_index_arr = array();
if (1 == tpCache('web.web_users_switch') && $main_lang == $admin_lang) {
$users_index_arr = array(
'is_menu' => 1,
'is_modules' => 1,
);
}
/*--end*/
/*商城中心URl*/
$shop_index_arr = array();
$shopServicemeal = array_join_string(array('cGhwLnBocF9zZXJ2aWNlbWVhbA=='));
if (1 == tpCache('web.web_users_switch') && 1 == getUsersConfigData('shop.shop_open') && $main_lang == $admin_lang && 1.5 <= tpCache($shopServicemeal)) {
$shop_index_arr = array(
'is_menu' => 1,
'is_modules' => 1,
);
}
/*--end*/
/*小程序*/
$diyminipro_index_arr = array();
if (is_dir('./weapp/Diyminipro/') && 1 == tpCache('web.web_diyminipro_switch') && $main_lang == $admin_lang) {
$diyminipro_index_arr = array(
'is_modules' => 1,
);
}
/*--end*/
/*更多功能*/
$index_switch_map_arr = array();
if ($main_lang == $admin_lang) {
$index_switch_map_arr = array(
'is_menu' => 1,
'is_modules' => 1,
);
}
/*--end*/
/**
* 权限模块属性说明
* array
* id 主键ID
* parent_id 父ID
* name 模块名称
* controller 控制器
* action 操作名
* url 跳转链接(控制器与操作名为空时才使用url)
* target 打开窗口方式
* icon 菜单图标
* grade 层级
* is_menu 是否显示菜单
* is_modules 是否显示权限模块分组
* is_subshowmenu 子模块是否有显示的模块
* child 子模块
*/
return array(
'1000'=>array(
'id'=>1000,
'parent_id'=>0,
'name'=>'',
'controller'=>'',
'action'=>'',
'url'=>'',
'target'=>'workspace',
'grade'=>0,
'is_menu'=>1,
'is_modules'=>1,
'is_subshowmenu'=>1,
'child'=>array(
'1001' => array(
'id'=>1001,
'parent_id'=>1000,
'name' => '栏目管理',
'controller'=>'Arctype',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-bars',
'grade'=>1,
'is_menu'=>1,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'1002' => array(
'id'=>1002,
'parent_id'=>1000,
'name' => '内容管理',
'controller'=>'Archives',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-file-o',
'grade'=>1,
'is_menu'=>1,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'1003' => array(
'id'=>1003,
'parent_id'=>1000,
'name' => '广告管理',
'controller'=>'AdPosition',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-file-image-o',
'grade'=>1,
'is_menu'=>1,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
),
),
'2000'=>array(
'id'=>2000,
'parent_id'=>0,
'name'=>'设置',
'controller'=>'',
'action'=>'',
'url'=>'',
'target'=>'workspace',
'grade'=>0,
'is_menu'=>1,
'is_modules'=>1,
'is_subshowmenu'=>1,
'child'=>array(
'2001' => array(
'id'=>2001,
'parent_id'=>2000,
'name' => '基本信息',
'controller'=>isset($system_index_arr['controller']) ? $system_index_arr['controller'] : 'System',
'action'=>isset($system_index_arr['action']) ? $system_index_arr['action'] : 'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-cog',
'grade'=>1,
'is_menu'=>1,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(
'2001001' => array(
'id'=>2001001,
'parent_id'=>2001,
'name' => '网站设置',
'controller'=>'System',
'action'=>'web',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-undo',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'2001002' => array(
'id'=>2001002,
'parent_id'=>2001,
'name' => '核心设置',
'controller'=>'System',
'action'=>'web2',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-undo',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'2001003' => array(
'id'=>2001003,
'parent_id'=>2001,
'name' => '附件设置',
'controller'=>'System',
'action'=>'basic',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-undo',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'2001005' => array(
'id'=>2001005,
'parent_id'=>2001,
'name' => '接口配置',
'controller'=>'System',
'action'=>'api_conf',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-undo',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
),
),
'2002' => array(
'id'=>2002,
'parent_id'=>2000,
'name' => '可视编辑',
'controller'=>'Uiset',
'action'=>'index',
'url'=>isset($uiset_index_arr['url']) ? $uiset_index_arr['url'] : '',
'target'=>'workspace',
'icon'=>'fa fa-tachometer',
'grade'=>1,
'is_menu'=>isset($uiset_index_arr['is_menu']) ? $uiset_index_arr['is_menu'] : 0,
'is_modules'=>1,
'is_subshowmenu'=>1,
'child'=>array(
'2002001' => array(
'id'=>2002001,
'parent_id'=>2002,
'name' => '电脑版',
'controller'=>'Uiset',
'action'=>'pc',
'url'=>isset($uiset_pc_arr['url']) ? $uiset_pc_arr['url'] : '',
'target'=>'_blank',
'icon'=>'fa fa-desktop',
'grade'=>2,
'is_menu'=>isset($uiset_pc_arr['is_menu']) ? $uiset_pc_arr['is_menu'] : 0,
'is_modules'=>0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2002002' => array(
'id'=>2002002,
'parent_id'=>2002,
'name' => '手机版',
'controller'=>'Uiset',
'action'=>'mobile',
'url'=>isset($uiset_mobile_arr['url']) ? $uiset_mobile_arr['url'] : '',
'target'=>'_blank',
'icon'=>'fa fa-mobile',
'grade'=>2,
'is_menu'=>isset($uiset_mobile_arr['is_menu']) ? $uiset_mobile_arr['is_menu'] : 0,
'is_modules'=>0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2002003' => array(
'id'=>2002003,
'parent_id'=>2002,
'name' => '数据清理',
'controller'=>'Uiset',
'action'=>'ui_index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-undo',
'grade'=>2,
'is_menu'=>1,
'is_modules'=>0,
'is_subshowmenu'=>0,
'child' => array(),
),
),
),
'2003' => array(
'id'=>2003,
'parent_id'=>2000,
'name' => 'SEO设置',
'controller'=>isset($seo_index_arr['controller']) ? $seo_index_arr['controller'] : 'Seo',
'action'=>isset($seo_index_arr['action']) ? $seo_index_arr['action'] : 'seo',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-paper-plane',
'grade'=>1,
'is_menu'=>1,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child'=>array(
'2003001' => array(
'id'=>2003001,
'parent_id'=>2003,
'name' => 'URL配置',
'controller'=>'Seo',
'action'=>'seo',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-newspaper-o',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'2003002' => array(
'id'=>2003002,
'parent_id'=>2003,
'name' => 'Sitemap',
'controller'=>'Sitemap',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-newspaper-o',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'2003003' => array(
'id'=>2003003,
'parent_id'=>2003,
'name' => '友情链接',
'controller'=>'Links',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-link',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
),
),
'2004' => array(
'id'=>2004,
'parent_id'=>2000,
'name' => '更多功能',
'controller'=>'Index',
'action'=>'switch_map',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-th-large',
'grade'=>1,
'is_menu'=>isset($index_switch_map_arr['is_menu']) ? $index_switch_map_arr['is_menu'] : 0,
'is_modules'=>isset($index_switch_map_arr['is_modules']) ? $index_switch_map_arr['is_modules'] : 0,
'is_subshowmenu'=>0,
'child' => array(
'2004001' => array(
'id'=>2004001,
'parent_id'=>2004,
'name' => '管理员',
'controller'=>'Admin',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-user',
'grade'=>2,
'is_menu'=>1,
'is_modules'=>0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2004002' => array(
'id'=>2004002,
'parent_id'=>2004,
'name' => '备份还原',
'controller'=>'Tools',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-database',
'grade'=>2,
'is_menu'=>isset($tools_index_arr['is_menu']) ? $tools_index_arr['is_menu'] : 0,
'is_modules'=>0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2004003' => array(
'id'=>2004003,
'parent_id'=>2004,
'name' => '模板管理',
'controller'=>'Filemanager',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-folder-open',
'grade'=>2,
'is_menu'=>1,
'is_modules'=>0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2004004' => array(
'id'=>2004004,
'parent_id'=>2004,
'name' => '栏目字段',
'controller'=>'Field',
'action'=>'arctype_add',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-cogs',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>0,
'is_subshowmenu'=>0,
'child' => array(),
),
// '2004005' => array(
// 'id'=>2004005,
// 'parent_id'=>2004,
// 'name' => '清除缓存',
// 'controller'=>'System',
// 'action'=>'clear_cache',
// 'url'=>'',
// 'target'=>'workspace',
// 'icon'=>'fa fa-undo',
// 'grade'=>2,
// 'is_menu'=>1,
// 'is_modules'=>0,
// 'is_subshowmenu'=>0,
// 'child' => array(),
// ),
'2004006' => array(
'id'=>2004006,
'parent_id'=>2004,
'name' => '回收站',
'controller'=>'RecycleBin',
'action'=>'archives_index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-recycle',
'grade'=>2,
'is_menu'=>isset($recyclebin_index_arr['is_menu']) ? $recyclebin_index_arr['is_menu'] : 0,
'is_modules'=>0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2004007' => array(
'id'=>2004007,
'parent_id'=>2004,
'name' => '频道模型',
'controller'=>'Channeltype',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-cube',
'grade'=>2,
'is_menu'=>isset($channeltype_index_arr['is_menu']) ? $channeltype_index_arr['is_menu'] : 0,
'is_modules'=>0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2004008' => array(
'id'=>2004008,
'parent_id'=>2004,
'name' => '文档属性',
'controller'=>'ArchivesFlag',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-undo',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'2004009' => array(
'id'=>2004009,
'parent_id'=>2004,
'name' => '水印配置',
'controller'=>'System',
'action'=>'water',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-undo',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'2004010' => array(
'id'=>2004010,
'parent_id'=>2004,
'name' => '缩略图配置',
'controller'=>'System',
'action'=>'thumb',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-undo',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'2004011' => array(
'id'=>2004011,
'parent_id'=>2004,
'name' => 'TAG管理',
'controller'=>'Tags',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-undo',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
'2004012' => array(
'id'=>2004012,
'parent_id'=>2004,
'name' => '模块开关',
'controller'=>'Index',
'action'=>'switch_map',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-undo',
'grade'=>2,
'is_menu'=>0,
'is_modules'=>1,
'is_subshowmenu'=>0,
'child' => array(),
),
),
),
'2005' => array(
'id'=>2005,
'parent_id'=>2000,
'name' => '插件应用',
'controller'=>'Weapp',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-futbol-o',
'grade'=>1,
'is_menu'=>isset($weapp_index_arr['is_menu']) ? $weapp_index_arr['is_menu'] : 0,
'is_modules'=>0,
'is_subshowmenu'=>0,
'child'=>array(),
),
'2006' => array(
'id'=>2006,
'parent_id'=>2000,
'name' => '会员中心',
'controller'=>'Member',
'action'=>'users_index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-user',
'grade'=>1,
'is_menu'=>isset($users_index_arr['is_menu']) ? $users_index_arr['is_menu'] : 0,
'is_modules'=>isset($users_index_arr['is_modules']) ? $users_index_arr['is_modules'] : 0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2010' => array(
'id'=>2006,
'parent_id'=>2000,
'name' => '项目/服务商',
'controller'=>'Project',
'action'=>'users_index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-user',
'grade'=>1,
'is_menu'=>isset($users_index_arr['is_menu']) ? $users_index_arr['is_menu'] : 0,
'is_modules'=>isset($users_index_arr['is_modules']) ? $users_index_arr['is_modules'] : 0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2011' => array(
'id'=>2006,
'parent_id'=>2000,
'name' => '案例列表',
'controller'=>'Casevideo',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-user',
'grade'=>1,
'is_menu'=>isset($users_index_arr['is_menu']) ? $users_index_arr['is_menu'] : 0,
'is_modules'=>isset($users_index_arr['is_modules']) ? $users_index_arr['is_modules'] : 0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2012' => array(
'id'=>2006,
'parent_id'=>2000,
'name' => '主流平台',
'controller'=>'platform',
'action'=>'index',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-user',
'grade'=>1,
'is_menu'=>isset($users_index_arr['is_menu']) ? $users_index_arr['is_menu'] : 0,
'is_modules'=>isset($users_index_arr['is_modules']) ? $users_index_arr['is_modules'] : 0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2008' => array(
'id'=>2008,
'parent_id'=>2000,
'name' => '商城中心',
'controller'=>'Shop',
'action'=>'home',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-shopping-cart',
'grade'=>1,
'is_menu'=>isset($shop_index_arr['is_menu']) ? $shop_index_arr['is_menu'] : 0,
'is_modules'=>isset($shop_index_arr['is_modules']) ? $shop_index_arr['is_modules'] : 0,
'is_subshowmenu'=>0,
'child' => array(),
),
'2009' => array(
'id'=>2009,
'parent_id'=>2000,
'name' => '可视化小程序',
'controller'=>'Diyminipro',
'action'=>'page_edit',
'url'=>'',
'target'=>'workspace',
'icon'=>'fa fa-code',
'grade'=>1,
'is_menu'=>0,
'is_modules'=>isset($diyminipro_index_arr['is_modules']) ? $diyminipro_index_arr['is_modules'] : 0,
'is_subshowmenu'=>0,
'child' => array(),
),
),
),
);

View File

@@ -0,0 +1,5 @@
<?php
$session_1600593464 = json_encode(array (
'expire' => '3600',
));
define('EY_SESSION_CONF', $session_1600593464);

View File

@@ -0,0 +1,92 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
$admin_ey_config = [
'seo_pseudo' => 1, // 默认纯动态URL模式兼容不支持pathinfo环境
'seo_dynamic_format' => 1, // 1=兼容模式的URL2=伪动态
'seo_rewrite_format' => config('ey_config.seo_rewrite_format'),
'system_sql_mode' => config('ey_config.system_sql_mode'), // 数据库模式
'seo_inlet' => config('ey_config.seo_inlet'), // 0=保留入口文件1=隐藏入口文件
];
$ey_config = array_merge(config('ey_config'), $admin_ey_config);
// 分页数
$system_paginate_pagesize = config('tpcache.system_paginate_pagesize');
$system_paginate_pagesize = !empty($system_paginate_pagesize) ? intval($system_paginate_pagesize) : 20;
$admin_config = array(
'ey_config' => $ey_config,
//分页配置
'paginate' => array(
'list_rows' => $system_paginate_pagesize,
),
// 默认全局过滤方法 用逗号分隔多个
'default_filter' => 'htmlspecialchars', // htmlspecialchars
// 登录有效期
'login_expire' => 3600,
// 登录错误最大次数
'login_errtotal' => 8,
// 登录错误超过次数之后,锁定用户名有效时间 15 分钟
'login_errexpire' => 900,
// +----------------------------------------------------------------------
// | 模板设置
// +----------------------------------------------------------------------
// 默认成功跳转对应的模板文件
'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
// 默认错误跳转对应的模板文件
'dispatch_error_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
// +----------------------------------------------------------------------
// | 异常及错误设置
// +----------------------------------------------------------------------
// 异常页面的模板文件
//'exception_tmpl' => ROOT_PATH.'public/static/errpage/404.html',
// errorpage 错误页面
//'error_tmpl' => ROOT_PATH.'public/static/errpage/404.html',
/**假设这个访问地址是 www.xxxxx.dev/home/goods/goodsInfo/id/1.html
*就保存名字为 home_goods_goodsinfo_1.html
*配置成这样, 指定 模块 控制器 方法名 参数名
*/
'HTML_CACHE_STATUS' => false,
// 控制器与操作名之间的连接符
'POWER_OPERATOR' => '@',
// 数据管理
'DATA_BACKUP_PATH' => '/data/sqldata', //数据库备份根路径
'DATA_BACKUP_PART_SIZE' => 524288000, //数据库备份卷大小 50M
'DATA_BACKUP_COMPRESS' => 0, //数据库备份文件是否启用压缩
'DATA_BACKUP_COMPRESS_LEVEL' => 9, //数据库备份文件压缩级别
// 过滤不需要登录的操作
'filter_login_action' => array(
'Admin@login', // 登录
'Admin@logout', // 退出
'Admin@vertify', // 验证码
),
// 无需验证权限的操作
'uneed_check_action' => array(
'Base@*', // 基类
'Index@*', // 后台首页
'Ajax@*', // 所有ajax操作
'Ueditor@*', // 编辑器上传
'Uploadify@*', // 图片上传
),
);
$html_config = include_once 'html.php';
return array_merge($admin_config, $html_config);
?>

View File

@@ -0,0 +1,755 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Page;
use think\Db;
class AdPosition extends Base
{
private $ad_position_system_id = array(); // 系统默认位置ID不可删除
public function _initialize() {
parent::_initialize();
}
public function index()
{
$list = array();
$get = input('get.');
$keywords = input('keywords/s');
$condition = [];
// 应用搜索条件
foreach (['keywords', 'type'] as $key) {
if (isset($get[$key]) && $get[$key] !== '') {
if ($key == 'keywords') {
$condition['a.title'] = array('LIKE', "%{$get[$key]}%");
} else {
$tmp_key = 'a.'.$key;
$condition[$tmp_key] = array('eq', $get[$key]);
}
}
}
// 多语言
$condition['a.lang'] = array('eq', $this->admin_lang);
$adPositionM = M('ad_position');
$count = $adPositionM->alias('a')->where($condition)->count();// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = $adPositionM->alias('a')->where($condition)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->getAllWithIndex('id');
// 每组获取三张图片
$pids = get_arr_column($list, 'id');
$ad = M('ad')->where(['pid' => ['IN', $pids], 'lang' => $this->admin_lang])->order('pid asc, id asc')->select();
foreach ($list as $k => $v) {
if (1 == $v['type']) {
// 图片封面图片
$v['ad'] = [];
foreach ($ad as $m => $n) {
if ($v['id'] == $n['pid']) {
$n['litpic'] = get_default_pic($n['litpic']); // 支持子目录
$v['ad'][] = $n;
unset($ad[$m]);
} else {
continue;
}
}
// 若没有内容则显示默认图片
if (empty($v['ad'])) {
$v['ad_count'] = 0;
$v['ad'][]['litpic'] = ROOT_DIR . '/public/static/common/images/not_adv.jpg';
} else {
$v['ad_count'] = count($v['ad']);
}
// 广告类型
$v['type_name'] = '图片';
} else if (2 == $v['type']) {
// 多媒体封面图片
$v['ad'][]['litpic'] = ROOT_DIR . '/public/static/admin/images/ad_type_media.png';
// 广告类型
$v['type_name'] = '多媒体';
} else if (3 == $v['type']) {
// HTML代码封面图片
$v['ad'][]['litpic'] = ROOT_DIR . '/public/static/admin/images/ad_type_html.png';
// 广告类型
$v['type_name'] = 'HTML代码';
}
$list[$k] = $v;
}
$show = $Page->show();// 分页显示输出
$this->assign('page',$show);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->assign('pager',$Page);// 赋值分页对象
return $this->fetch();
}
/**
* 新增
*/
public function add()
{
//防止php超时
function_exists('set_time_limit') && set_time_limit(0);
$this->language_access(); // 多语言功能操作权限
if (IS_POST) {
$post = input('post.');
$map = array(
'title' => trim($post['title']),
'lang' => $this->admin_lang,
);
if(M('ad_position')->where($map)->count() > 0){
$this->error('该广告名称已存在,请检查', url('AdPosition/index'));
}
// 添加广告位置表信息
$data = array(
'title' => trim($post['title']),
'type' => $post['type'],
'intro' => $post['intro'],
'admin_id' => session('admin_id'),
'lang' => $this->admin_lang,
'add_time' => getTime(),
'update_time' => getTime(),
);
$insertID = M('ad_position')->insertGetId($data);
if (!empty($insertID)) {
// 同步广告位置ID到多语言的模板变量里添加多语言广告位
$this->syn_add_language_attribute($insertID);
// 读取组合广告位的图片及信息
$AdData = [];
if (1 == $post['type'] && !empty($post['img_litpic'])) { // 图片类型
$i = 1;
foreach ($post['img_litpic'] as $key => $value) {
if (!empty($value)) {
// 去掉http:
$value = str_replace("http:", "", $value);
// 去掉https:
$value = str_replace("https:", "", $value);
// 主要参数
$AdData['litpic'] = $value;
$AdData['pid'] = $insertID;
$AdData['title'] = trim($post['img_title'][$key]);
$AdData['links'] = $post['img_links'][$key];
$AdData['intro'] = $post['img_intro'][$key];
$target = !empty($post['img_target'][$key]) ? 1 : 0;
$AdData['target'] = $target;
// 其他参数
$AdData['media_type'] = 1;
$AdData['admin_id'] = session('admin_id');
$AdData['lang'] = $this->admin_lang;
$AdData['sort_order'] = $i++;
$AdData['add_time'] = getTime();
$AdData['update_time'] = getTime();
// 添加到广告图表
$ad_id = Db::name('ad')->add($AdData);
// 同步多语言
$this->syn_add_ad_language_attribute($ad_id);
}
}
} else if (2 == $post['type'] && !empty($post['video_litpic'])) { // 媒体类型
// 去掉http:
$video_litpic = str_replace("http:", "", $post['video_litpic']);
// 去掉https:
$video_litpic = str_replace("https:", "", $post['video_litpic']);
// 主要参数
$AdData['litpic'] = $video_litpic;
$AdData['pid'] = $insertID;
$AdData['title'] = trim($post['title']);
// 其他参数
$AdData['intro'] = '';
$AdData['links'] = '';
$AdData['target'] = 0;
$AdData['media_type'] = 2;
$AdData['admin_id'] = session('admin_id');
$AdData['lang'] = $this->admin_lang;
$AdData['sort_order'] = 1;
$AdData['add_time'] = getTime();
$AdData['update_time'] = getTime();
// 添加到广告图表
$ad_id = Db::name('ad')->add($AdData);
// 同步多语言
$this->syn_add_ad_language_attribute($ad_id);
} else if (3 == $post['type'] && !empty($post['html_intro'])) { // HTML代码
// 主要参数
$AdData['pid'] = $insertID;
$AdData['title'] = trim($post['title']);
$AdData['intro'] = $post['html_intro'];
// 其他参数
$AdData['litpic'] = '';
$AdData['links'] = '';
$AdData['target'] = 0;
$AdData['media_type'] = 3;
$AdData['admin_id'] = session('admin_id');
$AdData['lang'] = $this->admin_lang;
$AdData['sort_order'] = 1;
$AdData['add_time'] = getTime();
$AdData['update_time'] = getTime();
// 添加到广告图表
$ad_id = Db::name('ad')->add($AdData);
// 同步多语言
$this->syn_add_ad_language_attribute($ad_id);
}
adminLog('新增广告:'.$post['title']);
$this->success("操作成功", url('AdPosition/index'));
} else {
$this->error("操作失败", url('AdPosition/index'));
}
}
// 上传通道
$WeappConfig = Db::name('weapp')->field('code, status')->where('code', 'IN', ['Qiniuyun', 'AliyunOss', 'Cos'])->select();
$WeappOpen = [];
foreach ($WeappConfig as $value) {
if ('Qiniuyun' == $value['code']) {
$WeappOpen['qny_open'] = $value['status'];
} else if ('AliyunOss' == $value['code']) {
$WeappOpen['oss_open'] = $value['status'];
} else if ('Cos' == $value['code']) {
$WeappOpen['cos_open'] = $value['status'];
}
}
$this->assign('WeappOpen', $WeappOpen);
// 系统最大上传视频的大小
$upload_max_filesize = upload_max_filesize();
$this->assign('upload_max_filesize', $upload_max_filesize);
// 视频类型
$media_type = tpCache('basic.media_type');
$media_type = !empty($media_type) ? $media_type : config('global.media_ext');
$media_type = str_replace(",", "|", $media_type);
$this->assign('media_type', $media_type);
return $this->fetch();
}
/**
* 编辑
*/
public function edit()
{
if (IS_POST) {
$post = input('post.');
if (!empty($post['id'])) {
if (array_key_exists($post['id'], $this->ad_position_system_id)) {
$this->error("不可更改系统预定义位置", url('AdPosition/edit',array('id'=>$post['id'])));
}
/* 判断除自身外是否还有相同广告名称已存在 */
$map = array(
'id' => array('NEQ', $post['id']),
'title' => trim($post['title']),
'lang' => $this->admin_lang,
);
if (Db::name('ad_position')->where($map)->count() > 0) $this->error('该广告名称已存在,请检查');
/* END */
/* 判断广告是否切换广告类型 */
// $where = [
// 'id' => $post['id'],
// 'type' => $post['type'],
// 'lang' => $this->admin_lang
// ];
// if (Db::name('ad_position')->where($where)->count() == 0) {
// // 已切换广告类型,清除广告中的广告内容
// $where = [
// 'pid' => $post['id'],
// 'lang' => $this->admin_lang
// ];
// Db::name('ad')->where($where)->delete();
// }
/* END */
/* 修改广告主体信息 */
$data = array(
'id' => $post['id'],
'title' => trim($post['title']),
'type' => $post['type'],
'intro' => $post['intro'],
'update_time' => getTime(),
);
$resultID = Db::name('ad_position')->update($data);
/* END */
}
if (!empty($resultID)) {
$ad_db = Db::name('ad');
if (1 == $post['type'] && !empty($post['img_litpic'])) { // 图片类型
// 读取组合广告位的图片及信息
$i = 1;
foreach ($post['img_litpic'] as $key => $value) {
if (!empty($value)) {
// 去掉http:
$value = str_replace("http:", "", $value);
// 去掉https:
$value = str_replace("https:", "", $value);
// 是否新窗口打开
$target = !empty($post['img_target'][$key]) ? 1 : 0;
// 广告位ID为空则表示添加
$ad_id = $post['img_id'][$key];
if (!empty($ad_id)) {
// 查询更新条件
$where = [
'id' => $ad_id,
'lang' => $this->admin_lang,
];
if ($ad_db->where($where)->count() > 0) {
// 主要参数
$AdData['litpic'] = $value;
$AdData['title'] = $post['img_title'][$key];
$AdData['links'] = $post['img_links'][$key];
$AdData['intro'] = $post['img_intro'][$key];
$AdData['target'] = $target;
// 其他参数
$AdData['sort_order'] = $i++;
$AdData['update_time'] = getTime();
// 更新,不需要同步多语言
$ad_db->where($where)->update($AdData);
} else {
// 主要参数
$AdData['litpic'] = $value;
$AdData['pid'] = $post['id'];
$AdData['title'] = $post['img_title'][$key];
$AdData['links'] = $post['img_links'][$key];
$AdData['intro'] = $post['img_intro'][$key];
$AdData['target'] = $target;
// 其他参数
$AdData['media_type'] = 1;
$AdData['admin_id'] = session('admin_id');
$AdData['lang'] = $this->admin_lang;
$AdData['sort_order'] = $i++;
$AdData['add_time'] = getTime();
$AdData['update_time'] = getTime();
$ad_id = $ad_db->add($AdData);
// 同步多语言
$this->syn_add_ad_language_attribute($ad_id);
}
} else {
// 主要参数
$AdData['litpic'] = $value;
$AdData['pid'] = $post['id'];
$AdData['title'] = $post['img_title'][$key];
$AdData['links'] = $post['img_links'][$key];
$AdData['intro'] = $post['img_intro'][$key];
$AdData['target'] = $target;
// 其他参数
$AdData['media_type'] = 1;
$AdData['admin_id'] = session('admin_id');
$AdData['lang'] = $this->admin_lang;
$AdData['sort_order'] = $i++;
$AdData['add_time'] = getTime();
$AdData['update_time'] = getTime();
$ad_id = $ad_db->add($AdData);
// 同步多语言
$this->syn_add_ad_language_attribute($ad_id);
}
}
}
} else if (2 == $post['type'] && !empty($post['video_litpic'])) { // 媒体类型
// 去掉http:
$video_litpic = str_replace("http:", "", $post['video_litpic']);
// 去掉https:
$video_litpic = str_replace("https:", "", $post['video_litpic']);
if (!empty($post['video_id'])) {
// 更新广告内容
$AdData['litpic'] = $video_litpic;
$AdData['title'] = trim($post['title']);
$AdData['media_type'] = 2;
$AdData['update_time'] = getTime();
$ad_db->where('id', $post['video_id'])->update($AdData);
} else {
// 新增广告内容
$AdData['litpic'] = $video_litpic;
$AdData['pid'] = $post['id'];
$AdData['title'] = trim($post['title']);
$AdData['links'] = '';
$AdData['intro'] = '';
$AdData['target'] = 0;
$AdData['media_type'] = 2;
$AdData['admin_id'] = session('admin_id');
$AdData['lang'] = $this->admin_lang;
$AdData['sort_order'] = 1;
$AdData['add_time'] = getTime();
$AdData['update_time'] = getTime();
$ad_id = $ad_db->add($AdData);
// 同步多语言
$this->syn_add_ad_language_attribute($ad_id);
}
} else if (3 == $post['type'] && !empty($post['html_intro'])) { // HTML代码
if (!empty($post['html_id'])) {
// 更新广告内容
$AdData['title'] = trim($post['title']);
$AdData['intro'] = $post['html_intro'];
$AdData['media_type'] = 3;
$AdData['update_time'] = getTime();
$ad_db->where('id', $post['html_id'])->update($AdData);
} else {
// 新增广告内容
$AdData['litpic'] = '';
$AdData['pid'] = $post['id'];
$AdData['title'] = trim($post['title']);
$AdData['intro'] = $post['html_intro'];
$AdData['links'] = '';
$AdData['target'] = 0;
$AdData['media_type'] = 3;
$AdData['admin_id'] = session('admin_id');
$AdData['lang'] = $this->admin_lang;
$AdData['sort_order'] = 1;
$AdData['add_time'] = getTime();
$AdData['update_time'] = getTime();
$ad_id = $ad_db->add($AdData);
// 同步多语言
$this->syn_add_ad_language_attribute($ad_id);
}
}
adminLog('编辑广告:'.$post['title']);
$this->success("操作成功", url('AdPosition/index'));
} else {
$this->error("操作失败");
}
}
$assign_data = array();
$id = input('id/d');
$field = M('ad_position')->field('a.*')->alias('a')->where(array('a.id'=>$id))->find();
if (empty($field)) $this->error('广告不存在,请联系管理员!');
switch ($field['type']) {
case '1':
$field['type_name'] = '图片';
break;
case '2':
$field['type_name'] = '多媒体';
break;
case '3':
$field['type_name'] = 'HTML代码';
break;
}
$assign_data['field'] = $field;
// 广告
$ad_data = Db::name('ad')->where(array('pid'=>$field['id']))->order('sort_order asc')->select();
foreach ($ad_data as $key => $val) {
if (1 == $val['type']) {
$ad_data[$key]['litpic'] = get_default_pic($val['litpic']); // 支持子目录
}
}
$assign_data['ad_data'] = $ad_data;
// 上传通道
$WeappConfig = Db::name('weapp')->field('code, status')->where('code', 'IN', ['Qiniuyun', 'AliyunOss', 'Cos'])->select();
$WeappOpen = [];
foreach ($WeappConfig as $value) {
if ('Qiniuyun' == $value['code']) {
$WeappOpen['qny_open'] = $value['status'];
} else if ('AliyunOss' == $value['code']) {
$WeappOpen['oss_open'] = $value['status'];
} else if ('Cos' == $value['code']) {
$WeappOpen['cos_open'] = $value['status'];
}
}
$this->assign('WeappOpen', $WeappOpen);
// 系统最大上传视频的大小
$file_size = tpCache('basic.file_size');
$postsize = @ini_get('file_uploads') ? ini_get('post_max_size') : -1;
$fileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : -1;
$min_size = strval($file_size) < strval($postsize) ? $file_size : $postsize;
$min_size = strval($min_size) < strval($fileupload) ? $min_size : $fileupload;
$upload_max_filesize = intval($min_size) * 1024 * 1024;
$assign_data['upload_max_filesize'] = $upload_max_filesize;
// 视频类型
$media_type = tpCache('basic.media_type');
$media_type = !empty($media_type) ? $media_type : config('global.media_ext');
$media_type = str_replace(",", "|", $media_type);
$assign_data['media_type'] = $media_type;
$this->assign($assign_data);
return $this->fetch();
}
/**
* 删除广告图片
*/
public function del_imgupload()
{
$this->language_access(); // 多语言功能操作权限
$id_arr = input('del_id/a');
$id_arr = eyIntval($id_arr);
if(IS_POST && !empty($id_arr)){
/*多语言*/
$attr_name_arr = [];
foreach ($id_arr as $key => $val) {
$attr_name_arr[] = 'ad'.$val;
}
if (is_language()) {
$new_id_arr = Db::name('language_attr')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad',
])->column('attr_value');
!empty($new_id_arr) && $id_arr = $new_id_arr;
}
/*--end*/
$r = Db::name('ad')->where([
'id' => ['IN', $id_arr],
])
->cache(true,null,'ad')
->delete();
if ($r) {
/*多语言*/
if (!empty($attr_name_arr)) {
Db::name('language_attr')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad',
])->delete();
Db::name('language_attribute')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad',
])->delete();
}
/*--end*/
adminLog('删除广告-id'.implode(',', $id_arr));
}
}
}
/**
* 删除
*/
public function del()
{
$this->language_access(); // 多语言功能操作权限
$id_arr = input('del_id/a');
$id_arr = eyIntval($id_arr);
if(IS_POST && !empty($id_arr)){
foreach ($id_arr as $key => $val) {
if(array_key_exists($val, $this->ad_position_system_id)){
$this->error('系统预定义,不能删除');
}
}
/*多语言*/
$attr_name_arr = [];
foreach ($id_arr as $key => $val) {
$attr_name_arr[] = 'adp'.$val;
}
if (is_language()) {
$new_id_arr = Db::name('language_attr')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad_position',
])->column('attr_value');
!empty($new_id_arr) && $id_arr = $new_id_arr;
}
/*--end*/
$r = M('ad_position')->where('id','IN',$id_arr)->delete();
if ($r) {
/*多语言*/
if (!empty($attr_name_arr)) {
M('language_attr')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad_position',
])->delete();
M('language_attribute')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad_position',
])->delete();
}
/*--end*/
M('ad')->where('pid','IN',$id_arr)->delete();
adminLog('删除广告-id'.implode(',', $id_arr));
$this->success('删除成功');
} else {
$this->error('删除失败');
}
}else{
$this->error('参数有误');
}
}
/**
* 打开预览视频
*/
public function open_preview_video()
{
$post = input('post.');
$video_litpic = $post['video_litpic'];
if (!is_http_url($video_litpic)) {
$video_litpic = request()->domain() . handle_subdir_pic($video_litpic, 'media');
}
$this->success('执行成功', $video_litpic);
}
/**
* 检测广告名称是否存在重复
*/
public function detection_title_repeat()
{
if (IS_AJAX_POST) {
$post = input('post.');
$where = [
'id' => ['NEQ', $post['id']],
'title' => trim($post['title']),
'lang' => $this->admin_lang,
];
$count = Db::name('ad_position')->where($where)->count();
if (empty($count)) {
$this->success('检测通过');
} else {
$this->error('该广告名称已存在,请检查');
}
}
}
/**
* 同步新增广告位置ID到多语言的模板变量里
*/
private function syn_add_language_attribute($adp_id)
{
/*单语言情况下不执行多语言代码*/
if (!is_language()) {
return true;
}
/*--end*/
$attr_group = 'ad_position';
$admin_lang = $this->admin_lang;
$main_lang = $this->main_lang;
$languageRow = Db::name('language')->field('mark')->order('id asc')->select();
if (!empty($languageRow) && $admin_lang == $main_lang) { // 当前语言是主体语言,即语言列表最早新增的语言
$ad_position_db = Db::name('ad_position');
$result = $ad_position_db->find($adp_id);
$attr_name = 'adp'.$adp_id;
$r = Db::name('language_attribute')->save([
'attr_title' => $result['title'],
'attr_name' => $attr_name,
'attr_group' => $attr_group,
'add_time' => getTime(),
'update_time' => getTime(),
]);
if (false !== $r) {
$data = [];
foreach ($languageRow as $key => $val) {
/*同步新广告位置到其他语言广告位置列表*/
if ($val['mark'] != $admin_lang) {
$addsaveData = $result;
$addsaveData['lang'] = $val['mark'];
$addsaveData['title'] = $val['mark'].$addsaveData['title'];
unset($addsaveData['id']);
$adp_id = $ad_position_db->insertGetId($addsaveData);
}
/*--end*/
/*所有语言绑定在主语言的ID容器里*/
$data[] = [
'attr_name' => $attr_name,
'attr_value' => $adp_id,
'lang' => $val['mark'],
'attr_group' => $attr_group,
'add_time' => getTime(),
'update_time' => getTime(),
];
/*--end*/
}
if (!empty($data)) {
model('LanguageAttr')->saveAll($data);
}
}
}
}
/**
* 同步新增广告ID到多语言的模板变量里
*/
private function syn_add_ad_language_attribute($ad_id)
{
/*单语言情况下不执行多语言代码*/
if (!is_language()) {
return true;
}
/*--end*/
$attr_group = 'ad';
$admin_lang = $this->admin_lang;
$main_lang = get_main_lang();
$languageRow = Db::name('language')->field('mark')->order('id asc')->select();
if (!empty($languageRow) && $admin_lang == $main_lang) { // 当前语言是主体语言,即语言列表最早新增的语言
$ad_db = Db::name('ad');
$result = $ad_db->find($ad_id);
$attr_name = 'ad'.$ad_id;
$r = Db::name('language_attribute')->save([
'attr_title' => $result['title'],
'attr_name' => $attr_name,
'attr_group' => $attr_group,
'add_time' => getTime(),
'update_time' => getTime(),
]);
if (false !== $r) {
$data = [];
foreach ($languageRow as $key => $val) {
/*同步新广告到其他语言广告列表*/
if ($val['mark'] != $admin_lang) {
$addsaveData = $result;
$addsaveData['lang'] = $val['mark'];
$newPid = Db::name('language_attr')->where([
'attr_name' => 'adp'.$result['pid'],
'attr_group' => 'ad_position',
'lang' => $val['mark'],
])->getField('attr_value');
$addsaveData['pid'] = $newPid;
$addsaveData['title'] = $val['mark'].$addsaveData['title'];
unset($addsaveData['id']);
$ad_id = $ad_db->insertGetId($addsaveData);
}
/*--end*/
/*所有语言绑定在主语言的ID容器里*/
$data[] = [
'attr_name' => $attr_name,
'attr_value' => $ad_id,
'lang' => $val['mark'],
'attr_group' => $attr_group,
'add_time' => getTime(),
'update_time' => getTime(),
];
/*--end*/
}
if (!empty($data)) {
model('LanguageAttr')->saveAll($data);
}
}
}
}
}

View File

@@ -0,0 +1,827 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Page;
use think\Verify;
use think\Db;
use think\db\Query;
use think\Session;
use app\admin\model\AuthRole;
use app\admin\logic\AjaxLogic;
class Admin extends Base {
public function index()
{
$list = array();
$keywords = input('keywords/s');
$condition = array();
if (!empty($keywords)) {
$condition['a.user_name|a.true_name'] = array('LIKE', "%{$keywords}%");
}
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$condition['a.admin_id|a.parent_id'] = $admin_info['admin_id'];
} else {
if (!empty($admin_info['parent_id'])) {
$condition['a.admin_id|a.parent_id'] = $admin_info['admin_id'];
}
}
/*--end*/
/**
* 数据查询
*/
$count = DB::name('admin')->alias('a')->where($condition)->count();// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = DB::name('admin')->field('a.*, b.name AS role_name')
->alias('a')
->join('__AUTH_ROLE__ b', 'a.role_id = b.id', 'LEFT')
->where($condition)
->order('a.admin_id asc')
->limit($Page->firstRow.','.$Page->listRows)
->select();
foreach ($list as $key => $val) {
if (0 >= intval($val['role_id'])) {
$val['role_name'] = !empty($val['parent_id']) ? '超级管理员' : '创始人';
}
$list[$key] = $val;
}
$show = $Page->show();// 分页显示输出
$this->assign('page',$show);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->assign('pager',$Page);// 赋值分页集
/*第一次同步CMS用户的栏目ID到权限组里*/
$this->syn_built_auth_role();
/*--end*/
return $this->fetch();
}
/*
* 管理员登陆
*/
public function login()
{
if (session('?admin_id') && session('admin_id') > 0) {
$web_adminbasefile = tpCache('web.web_adminbasefile');
$web_adminbasefile = !empty($web_adminbasefile) ? $web_adminbasefile : '/login.php';
$this->success("您已登录", $web_adminbasefile);
}
// $gb_funcs = get_extension_funcs('gd');
$is_vertify = 1; // 默认开启验证码
$admin_login_captcha = config('captcha.admin_login');
if (!function_exists('imagettftext') || empty($admin_login_captcha['is_on'])) {
$is_vertify = 0; // 函数不存在,不符合开启的条件
}
$this->assign('is_vertify', $is_vertify);
if (IS_POST) {
$post = input('post.');
if (!function_exists('session_start')) {
$this->error('请联系空间商开启php的session扩展');
}
if (!testWriteAble(ROOT_PATH.config('session.path').'/')) {
$this->error('请仔细检查以下问题:<br/>1、磁盘空间大小是否100%<br/>2、站点目录权限是否为755<br/>3、站点所有目录的权限禁止用root:root <br/>4、如还没解决请点击<a href="http://www.eyoucms.com/wenda/6958.html" target="_blank">查看教程</a>');
}
if (1 == $is_vertify) {
$verify = new Verify();
if (!$verify->check(input('post.vertify'), "admin_login")) {
$this->error('验证码错误');
}
}
$is_clicap = 0; // 默认关闭文字验证码
if (is_dir('./weapp/Clicap/')) {
$ClicapRow = model('Weapp')->getWeappList('Clicap');
if (!empty($ClicapRow['status']) && 1 == $ClicapRow['status']) {
if (!empty($ClicapRow['data']) && $ClicapRow['data']['captcha']['admin_login']['is_on'] == 1) {
$clicaptcha_info = input('post.clicaptcha-submit-info');
$clicaptcha = new \weapp\Clicap\vendor\Clicaptcha;
if (empty($clicaptcha_info) || !$clicaptcha->check($clicaptcha_info, false)) {
$this->error('文字点击验证错误!');
}
}
}
}
$user_name = input('post.user_name/s');
$password = input('post.password/s');
/*登录错误次数的限制*/
/* $ststem_login_errnum_key = 'system_'.md5('login_errnum_'.$user_name);
$ststem_login_errtime_key = 'system_'.md5('login_errtime_'.$user_name);
$loginErrtotal = config('login_errtotal'); // 限定最大的登录错误次数
$loginErrexpire = config('login_errexpire'); // 限定登录错误锁定有效时间
$loginErrnum = tpCache('system.'.$ststem_login_errnum_key); // 登录错误次数
$loginErrtime = tpCache('system.'.$ststem_login_errtime_key); // 最后一次登录错误时间
if (intval($loginErrnum) >= intval($loginErrtotal)) {
if (getTime() < $loginErrtime + $loginErrexpire) {
adminLog('登录失败(已被锁定)');
$this->error("登录错误次数超限用户名被锁定15分钟");
} else {
// 重置登录错误次数
$loginErrnum = 0;
$loginErrtime = 0;
tpCache('system', [$ststem_login_errnum_key => $loginErrnum]);
tpCache('system', [$ststem_login_errtime_key => $loginErrtime]);
}
}*/
/*end*/
$condition['user_name'] = $user_name;
$condition['password'] = $password;
if (!empty($condition['user_name']) && !empty($condition['password'])) {
$condition['password'] = func_encrypt($condition['password']);
$admin_info = M('admin')->where($condition)->find();
if (empty($admin_info)) {
adminLog('登录失败(用户名/密码错误)');
/*记录登录错误次数*/
/*$login_num = intval($loginErrtotal) - intval($loginErrnum);
$ststem_login_errnum = $loginErrnum + 1;
tpCache('system', [$ststem_login_errnum_key=>$ststem_login_errnum]);
tpCache('system', [$ststem_login_errtime_key=>getTime()]);
$this->error("用户名或密码错误,您还可以尝试[{$login_num}]次!");*/
$this->error("用户名或密码错误!");
/*end*/
} else {
if ($admin_info['status'] == 0) {
adminLog('登录失败(用户名被禁用)');
$this->error('用户名被禁用!');
}
$role_id = !empty($admin_info['role_id']) ? $admin_info['role_id'] : -1;
$auth_role_info = array();
if (!empty($admin_info['parent_id'])) {
$role_name = '超级管理员';
$isFounder = 0;
} else {
$role_name = '创始人';
$isFounder = 1;
}
if (0 < intval($role_id)) {
$auth_role_info = M('auth_role')
->field("a.*, a.name AS role_name")
->alias('a')
->where('a.id','eq', $role_id)
->find();
if (!empty($auth_role_info)) {
$auth_role_info['language'] = unserialize($auth_role_info['language']);
$auth_role_info['cud'] = unserialize($auth_role_info['cud']);
$auth_role_info['permission'] = unserialize($auth_role_info['permission']);
$role_name = $auth_role_info['name'];
}
}
$admin_info['auth_role_info'] = $auth_role_info;
$admin_info['role_name'] = $role_name;
$last_login_time = getTime();
$last_login_ip = clientIP();
$login_cnt = $admin_info['login_cnt'] + 1;
M('admin')->where("admin_id = ".$admin_info['admin_id'])->save(array('last_login'=>$last_login_time, 'last_ip'=>$last_login_ip, 'login_cnt'=>$login_cnt, 'session_id'=>$this->session_id));
$admin_info['last_login'] = $last_login_time;
$admin_info['last_ip'] = $last_login_ip;
// 头像
empty($admin_info['head_pic']) && $admin_info['head_pic'] = get_head_pic($admin_info['head_pic'], true);
$admin_info_new = $admin_info;
/*过滤存储在session文件的敏感信息*/
foreach (['user_name','true_name','password'] as $key => $val) {
unset($admin_info_new[$val]);
}
/*--end*/
session('admin_id',$admin_info['admin_id']);
session('admin_info', $admin_info_new);
session('admin_login_expire', getTime()); // 登录有效期
/*检查密码复杂度*/
$admin_login_pwdlevel = checkPasswordLevel($password);
session('admin_login_pwdlevel', $admin_login_pwdlevel);
/*end*/
// 重置登录错误次数
/*tpCache('system', [$ststem_login_errnum_key=>0]);
tpCache('system', [$ststem_login_errtime_key=>0]);*/
adminLog('后台登录');
$url = session('from_url') ? session('from_url') : $this->request->baseFile();
session('isset_author', null); // 内置勿动
/*同步追加一个后台管理员到会员用户表*/
$this->syn_users_login($admin_info, $isFounder);
/* END */
$this->success('登录成功', $url);
}
} else {
$this->error('请填写用户名/密码');
}
}
$ajaxLogic = new AjaxLogic;
$ajaxLogic->login_handle();
session('admin_info', null);
return $this->fetch();
}
/**
* 验证码获取
*/
public function vertify()
{
/*验证码插件开关*/
$admin_login_captcha = config('captcha.admin_login');
$config = (!empty($admin_login_captcha['is_on']) && !empty($admin_login_captcha['config'])) ? $admin_login_captcha['config'] : config('captcha.default');
/*--end*/
ob_clean(); // 清空缓存,才能显示验证码
$Verify = new Verify($config);
$Verify->entry('admin_login');
exit();
}
/**
* 修改管理员密码
* @return \think\mixed
*/
public function admin_pwd()
{
$admin_id = input('admin_id/d',0);
$oldPwd = input('old_pw/s');
$newPwd = input('new_pw/s');
$new2Pwd = input('new_pw2/s');
if(!$admin_id){
$admin_id = session('admin_id');
}
$info = M('admin')->where("admin_id", $admin_id)->find();
$info['password'] = "";
$this->assign('info',$info);
if(IS_POST){
//修改密码
$enOldPwd = func_encrypt($oldPwd);
$enNewPwd = func_encrypt($newPwd);
$admin = M('admin')->where('admin_id' , $admin_id)->find();
if(!$admin || $admin['password'] != $enOldPwd){
exit(json_encode(array('status'=>-1,'msg'=>'旧密码不正确')));
}else if($newPwd != $new2Pwd){
exit(json_encode(array('status'=>-1,'msg'=>'两次密码不一致')));
}else{
$data = array(
'update_time' => getTime(),
'password' => $enNewPwd,
);
$row = M('admin')->where('admin_id' , $admin_id)->save($data);
if($row){
/*检查密码复杂度*/
$admin_login_pwdlevel = checkPasswordLevel($newPwd);
session('admin_login_pwdlevel', $admin_login_pwdlevel);
/*end*/
adminLog('修改管理员密码');
exit(json_encode(array('status'=>1,'msg'=>'操作成功')));
}else{
exit(json_encode(array('status'=>-1,'msg'=>'操作失败')));
}
}
}
if (IS_AJAX) {
return $this->fetch('admin/admin_pwd_ajax');
} else {
return $this->fetch('admin/admin_pwd');
}
}
/**
* 退出登陆
*/
public function logout()
{
adminLog('安全退出');
session_unset();
// session_destroy();
session::clear();
cookie('admin-treeClicked', null); // 清除并恢复栏目列表的展开方式
$this->success("安全退出", request()->baseFile());
}
/**
* 新增管理员时,检测用户名是否与前台用户名相同
*/
public function ajax_add_user_name()
{
if (IS_AJAX_POST) {
$user_name = input('post.user_name/s');
if (M('admin')->where("user_name", $user_name)->count()) {
$this->error("此用户名已被注册,请更换!");
}
$row = Db::name('users')->field('users_id')->where([
'username' => $user_name,
'lang' => $this->admin_lang,
])->find();
if (!empty($row)) {
$this->error('已有相同会员名,将其转为系统账号?');
} else {
$this->success('会员名不存在,无需提示!');
}
}
}
/**
* 新增管理员
*/
public function admin_add()
{
$this->language_access(); // 多语言功能操作权限
if (IS_POST) {
$data = input('post.');
if (0 < intval(session('admin_info.role_id'))) {
$this->error("超级管理员才能操作!");
}
if (empty($data['password'])) {
$this->error("密码不能为空!");
}
$data['user_name'] = trim($data['user_name']);
$data['password'] = func_encrypt($data['password']);
$data['role_id'] = intval($data['role_id']);
$data['parent_id'] = session('admin_info.admin_id');
$data['add_time'] = getTime();
if (empty($data['pen_name'])) {
$data['pen_name'] = $data['user_name'];
}
if (M('admin')->where("user_name", $data['user_name'])->count()) {
$this->error("此用户名已被注册,请更换",url('Admin/admin_add'));
} else {
$admin_id = M('admin')->insertGetId($data);
if ($admin_id) {
adminLog('新增管理员:'.$data['user_name']);
/*同步追加一个后台管理员到会员用户表*/
try {
$usersInfo = Db::name('users')->field('users_id')->where([
'username' => $data['user_name'],
'lang' => $this->admin_lang,
])->find();
if (!empty($usersInfo)) {
$r = Db::name('users')->where(['users_id'=>$usersInfo['users_id']])->update([
'nickname' => $data['user_name'],
'admin_id' => $admin_id,
'is_activation' => 1,
'is_lock' => 0,
'is_del' => 0,
'update_time' => getTime(),
]);
!empty($r) && $users_id = $usersInfo['users_id'];
} else {
// 获取要添加的用户名
$username = $this->GetUserName($data['user_name']);
$AddData = [
'username' => $username,
'nickname' => $username,
'password' => func_encrypt(getTime()),
'level' => 1,
'lang' => $this->admin_lang,
'reg_time' => getTime(),
'add_time' => getTime(),
'head_pic' => ROOT_DIR . '/public/static/common/images/dfboy.png',
'register_place' => 1,
'admin_id' => $admin_id,
];
$users_id = Db::name('users')->insertGetId($AddData);
}
if (!empty($users_id)) {
Db::name('admin')->where(['admin_id'=>$admin_id])->update([
'syn_users_id' => $users_id,
'update_time' => getTime(),
]);
}
} catch (\Exception $e) {}
/* END */
$this->success("操作成功", url('Admin/index'));
} else {
$this->error("操作失败");
}
}
}
// 权限组
$admin_role_list = model('AuthRole')->getRoleAll();
$this->assign('admin_role_list', $admin_role_list);
// 模块组
$modules = getAllMenu();
$this->assign('modules', $modules);
// 权限集
$auth_rules = get_auth_rule(['is_modules'=>1]);
$auth_rule_list = group_same_key($auth_rules, 'menu_id');
foreach ($auth_rule_list as $key => $val) {
if (is_array($val)) {
$sort_order = [];
foreach ($val as $_k => $_v) {
$sort_order[$_k] = $_v['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $val);
$auth_rule_list[$key] = $val;
}
}
$this->assign('auth_rule_list', $auth_rule_list);
// 栏目
$arctype_data = $arctype_array = array();
$arctype = M('arctype')->select();
if(! empty($arctype)){
foreach ($arctype as $item){
if($item['parent_id'] <= 0){
$arctype_data[] = $item;
}
$arctype_array[$item['parent_id']][] = $item;
}
}
$this->assign('arctypes', $arctype_data);
$this->assign('arctype_array', $arctype_array);
// 插件
$plugins = model('Weapp')->getList(['status'=>1]);
$this->assign('plugins', $plugins);
return $this->fetch();
}
/**
* 编辑管理员
*/
public function admin_edit()
{
if (IS_POST) {
$data = input('post.');
$id = $data['admin_id'];
if ($id == session('admin_info.admin_id')) {
unset($data['role_id']); // 不能修改自己的权限组
} else if (0 < intval(session('admin_info.role_id')) && session('admin_info.admin_id') != $id) {
$this->error('禁止更改别人的信息!');
}
$password = $data['password'];
$user_name = $data['user_name'];
if(empty($password)){
unset($data['password']);
}else{
$data['password'] = func_encrypt($password);
}
unset($data['user_name']);
if (empty($data['pen_name'])) {
$data['pen_name'] = $user_name;
}
/*不允许修改自己的权限组*/
if (isset($data['role_id'])) {
if (0 < intval(session('admin_info.role_id')) && intval($data['role_id']) != session('admin_info.role_id')) {
$data['role_id'] = session('admin_info.role_id');
}
}
/*--end*/
$data['update_time'] = getTime();
$r = M('admin')->where('admin_id', $id)->save($data);
if ($r) {
/*检查密码复杂度*/
if ($id == session('admin_info.admin_id')) {
$admin_login_pwdlevel = checkPasswordLevel($password);
session('admin_login_pwdlevel', $admin_login_pwdlevel);
}
/*end*/
/*过滤存储在session文件的敏感信息*/
if ($id == session('admin_info.admin_id')) {
$admin_info = session('admin_info');
$admin_info = array_merge($admin_info, $data);
foreach (['user_name','true_name','password'] as $key => $val) {
unset($admin_info[$val]);
}
session('admin_info', $admin_info);
}
/*--end*/
/*同步相同数据到会员表对应的会员*/
$syn_users_id = Db::name('admin')->where(['admin_id'=>$data['admin_id']])->getField('syn_users_id');
if (!empty($syn_users_id)) {
$updateData = [
'nickname' => $data['pen_name'],
'head_pic' => $data['head_pic'],
'update_time' => getTime(),
];
Db::name('users')->where(['users_id'=>$syn_users_id])->update($updateData);
}
/*end*/
adminLog('编辑管理员:'.$user_name);
$this->success("操作成功",url('Admin/index'));
} else {
$this->error("操作失败");
}
}
$id = input('get.id/d', 0);
$info = M('admin')->field('a.*')
->alias('a')
->where("a.admin_id", $id)->find();
$info['password'] = "";
$this->assign('info',$info);
// 当前角色信息
$admin_role_model = model('AuthRole');
$role_info = $admin_role_model->getRole(array('id' => $info['role_id']));
$this->assign('role_info', $role_info);
// 权限组
$admin_role_list = $admin_role_model->getRoleAll();
$this->assign('admin_role_list', $admin_role_list);
// 模块组
$modules = getAllMenu();
$this->assign('modules', $modules);
// 权限集
$auth_rules = get_auth_rule(['is_modules'=>1]);
$auth_rule_list = group_same_key($auth_rules, 'menu_id');
foreach ($auth_rule_list as $key => $val) {
if (is_array($val)) {
$sort_order = [];
foreach ($val as $_k => $_v) {
$sort_order[$_k] = $_v['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $val);
$auth_rule_list[$key] = $val;
}
}
$this->assign('auth_rule_list', $auth_rule_list);
// 栏目
$arctype_data = $arctype_array = array();
$arctype = M('arctype')->select();
if(! empty($arctype)){
foreach ($arctype as $item){
if($item['parent_id'] <= 0){
$arctype_data[] = $item;
}
$arctype_array[$item['parent_id']][] = $item;
}
}
$this->assign('arctypes', $arctype_data);
$this->assign('arctype_array', $arctype_array);
// 插件
$plugins = model('Weapp')->getList(['status'=>1]);
$this->assign('plugins', $plugins);
return $this->fetch();
}
/**
* 删除管理员
*/
public function admin_del()
{
$this->language_access(); // 多语言功能操作权限
if (IS_POST) {
$id_arr = input('del_id/a');
$id_arr = eyIntval($id_arr);
if (in_array(session('admin_id'), $id_arr)) {
$this->error('禁止删除自己');
}
if (!empty($id_arr)) {
if (0 < intval(session('admin_info.role_id')) || !empty($parent_id) ) {
$count = M('admin')->where("admin_id in (".implode(',', $id_arr).") AND role_id = -1")
->count();
if (!empty($count)) {
$this->error('禁止删除超级管理员');
}
}
$result = M('admin')->field('user_name')->where("admin_id",'IN',$id_arr)->select();
$user_names = get_arr_column($result, 'user_name');
$r = M('admin')->where("admin_id",'IN',$id_arr)->delete();
if($r){
adminLog('删除管理员:'.implode(',', $user_names));
/*同步删除管理员关联的前台会员*/
Db::name('users')->where(['admin_id'=>['IN', $id_arr],'lang'=>$this->admin_lang])->delete();
/*end*/
$this->success('删除成功');
}else{
$this->error('删除失败');
}
}else{
$this->error('参数有误');
}
}
$this->error('非法操作');
}
/*
* 第一次同步CMS用户的栏目ID到权限组里
* 默认赋予内置权限所有的内容栏目权限
*/
private function syn_built_auth_role()
{
$authRole = new AuthRole;
$roleRow = $authRole->getRoleAll(['built_in'=>1,'update_time'=>['elt',0]]);
if (!empty($roleRow)) {
$saveData = [];
foreach ($roleRow as $key => $val) {
$permission = $val['permission'];
$arctype = M('arctype')->where('status',1)->column('id');
if (!empty($arctype)) {
$permission['arctype'] = $arctype;
} else {
unset($permission['arctype']);
}
$saveData[] = array(
'id' => $val['id'],
'permission' => $permission,
'update_time' => getTime(),
);
}
$authRole->saveAll($saveData);
}
}
/*
* 设置admin表数据
*/
public function ajax_setfield()
{
if (IS_POST) {
$admin_id = session('admin_id');
$field = input('field'); // 修改哪个字段
$value = input('value', '', null); // 修改字段值
if (!empty($admin_id)) {
$r = M('admin')->where('admin_id',intval($admin_id))->save([
$field=>$value,
'update_time'=>getTime(),
]); // 根据条件保存修改的数据
if ($r) {
/*更新存储在session里的信息*/
$admin_info = session('admin_info');
$admin_info[$field] = $value;
session('admin_info', $admin_info);
/*--end*/
$this->success('操作成功');
}
}
}
$this->error('操作失败');
}
/*
* 检测密码的复杂程度
*/
public function ajax_checkPasswordLevel()
{
$password = input('post.password/s');
if (IS_AJAX_POST && !empty($password)) {
$pwdLevel = checkPasswordLevel($password);
if (3 >= $pwdLevel) {
$this->success("<font color='red'>当前密码复杂度为 {$pwdLevel} ,建议复杂度在 4~7 范围内,避免容易被暴力破解!</font>", null, ['pwdLevel'=>$pwdLevel]);
} else {
$this->success("<font color='green'>当前密码复杂度为 {$pwdLevel} ,在系统设定 4~7 安全范围内!</font>", null, ['pwdLevel'=>$pwdLevel]);
}
}
$this->error('操作失败');
}
// 确保用户名唯一
private function GetUserName($username = null)
{
$count = Db::name('users')->where('username',$username)->count();
if (!empty($count)) {
$username_new = $username.rand(1000,9999);
$username = $this->GetUserName($username_new);
}
return $username;
}
/**
* 同步追加一个后台管理员到会员用户表,并同步前台登录
*/
private function syn_users_login($admin_info = [], $isFounder = 0)
{
$where_new = [
'admin_id' => $admin_info['admin_id'],
'lang' => $this->admin_lang,
];
$users_id = Db::name('users')->where($where_new)->getField('users_id');
try {
if (empty($users_id) && empty($admin_info['syn_users_id'])) {
$usersInfo = [];
if (1 == $isFounder) {
// 如果是创始人,强制将与会员名相同的改为管理员前台用户名
$usersInfo = Db::name('users')->field('users_id')->where([
'username' => $admin_info['user_name'],
'lang' => $this->admin_lang,
])->find();
}
if (!empty($usersInfo)) {
$r = Db::name('users')->where(['users_id'=>$usersInfo['users_id']])->update([
'nickname' => $admin_info['user_name'],
'admin_id' => $admin_info['admin_id'],
'is_activation' => 1,
'is_lock' => 0,
'is_del' => 0,
'update_time' => getTime(),
'last_login' => getTime(),
]);
!empty($r) && $users_id = $usersInfo['users_id'];
} else {
// 获取要添加的用户名
$username = $this->GetUserName($admin_info['user_name']);
$AddData = [
'username' => $username,
'nickname' => $username,
'password' => func_encrypt(getTime()),
'level' => 1,
'lang' => $this->admin_lang,
'reg_time' => getTime(),
'head_pic' => ROOT_DIR . '/public/static/common/images/dfboy.png',
'add_time' => getTime(),
'last_login' => getTime(),
'register_place' => 1,
'admin_id' => $admin_info['admin_id'],
];
$users_id = Db::name('users')->insertGetId($AddData);
}
if (!empty($users_id)) {
Db::name('admin')->where(['admin_id'=>$admin_info['admin_id']])->update([
'syn_users_id' => $users_id,
'update_time' => getTime(),
]);
$admin_info['syn_users_id'] = $users_id;
session('admin_info', $admin_info);
}
} else if (!empty($users_id) && empty($admin_info['syn_users_id'])) {
Db::name('admin')->where(['admin_id'=>$admin_info['admin_id']])->update([
'syn_users_id' => $users_id,
'update_time' => getTime(),
]);
$admin_info['syn_users_id'] = $users_id;
session('admin_info', $admin_info);
}
} catch (\Exception $e) {}
// 加载前台session
if (!empty($users_id)) {
$users = M('users')->field('a.*,b.level_name,b.level_value,b.discount as level_discount')
->alias('a')
->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
->where([
'a.users_id' => $users_id,
'a.lang' => $this->admin_lang,
'a.is_activation' => 1,
])->find();
if (!empty($users)) {
Db::name('users')->where(['users_id'=>$users_id])->update([
'update_time' => getTime(),
'last_login' => getTime(),
]);
GetUsersLatestData($users_id);
}
}
}
}

View File

@@ -0,0 +1,124 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Db;
use think\Session;
use think\Config;
use app\admin\logic\AjaxLogic;
/**
* 所有ajax请求或者不经过权限验证的方法全放在这里
*/
class Ajax extends Base {
private $ajaxLogic;
public function _initialize() {
parent::_initialize();
$this->ajaxLogic = new AjaxLogic;
}
/**
* 进入欢迎页面需要异步处理的业务
*/
public function welcome_handle()
{
\think\Session::pause(); // 暂停session防止session阻塞机制
$this->ajaxLogic->welcome_handle();
}
/**
* 隐藏后台欢迎页的系统提示
*/
public function explanation_welcome()
{
\think\Session::pause(); // 暂停session防止session阻塞机制
$type = input('param.type/d', 0);
$tpCacheKey = 'system_explanation_welcome';
if (1 < $type) {
$tpCacheKey .= '_'.$type;
}
/*多语言*/
if (is_language()) {
$langRow = \think\Db::name('language')->field('mark')->order('id asc')->select();
foreach ($langRow as $key => $val) {
tpCache('system', [$tpCacheKey=>1], $val['mark']);
}
} else { // 单语言
tpCache('system', [$tpCacheKey=>1]);
}
/*--end*/
}
/**
* 版本检测更新弹窗
*/
public function check_upgrade_version()
{
\think\Session::pause(); // 暂停session防止session阻塞机制
$upgradeLogic = new \app\admin\logic\UpgradeLogic;
$security_patch = tpSetting('upgrade.upgrade_security_patch');
if (!empty($security_patch) && 1 == $security_patch) {
$upgradeMsg = $upgradeLogic->checkSecurityVersion(); // 安全补丁包消息
} else {
$upgradeMsg = $upgradeLogic->checkVersion(); // 升级包消息
}
$this->success('检测成功', null, $upgradeMsg);
}
/**
* 更新stiemap.xml地图
*/
public function update_sitemap($controller, $action)
{
if (IS_AJAX_POST) {
\think\Session::pause(); // 暂停session防止session阻塞机制
$channeltype_row = \think\Cache::get("extra_global_channeltype");
if (empty($channeltype_row)) {
$ctlArr = \think\Db::name('channeltype')
->where('id','NOTIN', [6,8])
->column('ctl_name');
} else {
$ctlArr = array();
foreach($channeltype_row as $key => $val){
if (!in_array($val['id'], [6,8])) {
$ctlArr[] = $val['ctl_name'];
}
}
}
$systemCtl= ['Arctype'];
$ctlArr = array_merge($systemCtl, $ctlArr);
$actArr = ['add','edit'];
if (in_array($controller, $ctlArr) && in_array($action, $actArr)) {
Session::pause(); // 暂停session防止session阻塞机制
sitemap_auto();
$this->success('更新sitemap成功');
}
}
$this->error('更新sitemap失败');
}
// 开启\关闭余额支付
public function BalancePayOpen()
{
if (IS_AJAX_POST) {
$open_value = input('post.open_value/d');
getUsersConfigData('pay', ['pay_balance_open' => $open_value]);
$this->success('操作成功');
}
}
}

View File

@@ -0,0 +1,921 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Db;
use think\Page;
use app\common\logic\ArctypeLogic;
class Archives extends Base
{
// 允许发布文档的模型ID
public $allowReleaseChannel = array();
public function _initialize() {
parent::_initialize();
$this->allowReleaseChannel = config('global.allow_release_channel');
}
/**
* 内容管理
*/
public function index()
{
$arctype_list = array();
// 目录列表
$arctypeLogic = new ArctypeLogic();
$where['is_del'] = '0'; // 回收站功能
$where['current_channel'] = ['neq',51]; // 问答模型
$where['weapp_code'] = '';
$arctype_list = $arctypeLogic->arctype_list(0, 0, false, 0, $where, false);
$zNodes = "[";
foreach ($arctype_list as $key => $val) {
if ($val['current_channel'] == 5 && 1.5 > $this->php_servicemeal) {
continue;
}
$current_channel = $val['current_channel'];
if (!empty($val['weapp_code'])) {
// 插件栏目
$typeurl = weapp_url($val['weapp_code'].'/'.$val['weapp_code'].'/index');
} else {
if (6 == $current_channel) {
$gourl = url('Arctype/single_edit', array('typeid'=>$val['id']));
$typeurl = url("Arctype/single_edit", array('typeid'=>$val['id'],'gourl'=>$gourl));
} else if (8 == $current_channel) {
$typeurl = url("Guestbook/index", array('typeid'=>$val['id'], 'archives'=>1));
} else {
$typeurl = url('Archives/index_archives', array('typeid'=>$val['id']));
}
}
$typename = $val['typename'];
$zNodes .= "{"."id:{$val['id']}, pId:{$val['parent_id']}, name:\"{$typename}\", url:'{$typeurl}',target:'content_body'";
/*默认展开一级栏目*/
if (empty($val['parent_id'])) {
$zNodes .= ",open:true";
}
/*--end*/
/*栏目有下级栏目时,显示图标*/
if (1 == $val['has_children']) {
$zNodes .= ",isParent:true";
} else {
$zNodes .= ",isParent:false";
}
/*--end*/
$zNodes .= "},";
}
$zNodes .= "]";
$this->assign('zNodes', $zNodes);
return $this->fetch();
}
/**
* 内容管理 - 所有文档列表风格只针对ey_archives表排除单页记录
*/
public function index_archives()
{
$assign_data = array();
$condition = array();
// 获取到所有URL参数
$param = input('param.');
$flag = input('flag/s');
$typeid = input('typeid/d', 0);
/*跳转到指定栏目的文档列表*/
if (0 < intval($typeid)) {
$row = Db::name('arctype')
->alias('a')
->field('b.ctl_name,b.id')
->join('__CHANNELTYPE__ b', 'a.current_channel = b.id', 'LEFT')
->where('a.id', 'eq', $typeid)
->find();
$ctl_name = $row['ctl_name'];
$current_channel = $row['id'];
if (6 == $current_channel) {
$gourl = url('Arctype/single_edit', array('typeid'=>$typeid));
$gourl = url("Arctype/single_edit", array('typeid'=>$typeid,'gourl'=>$gourl));
$this->redirect($gourl);
} else if (8 == $current_channel) {
$gourl = url("Guestbook/index", array('typeid'=>$typeid));
$this->redirect($gourl);
}
}
/*--end*/
// 应用搜索条件
foreach (['keywords','typeid','flag','is_release'] as $key) {
if (isset($param[$key]) && $param[$key] !== '') {
if ($key == 'keywords') {
$condition['a.title'] = array('LIKE', "%{$param[$key]}%");
} else if ($key == 'typeid') {
$typeid = $param[$key];
$hasRow = model('Arctype')->getHasChildren($typeid);
$typeids = get_arr_column($hasRow, 'id');
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
if(isset($auth_role_info['only_oneself']) && 1 == $auth_role_info['only_oneself']){
$condition['a.admin_id'] = $admin_info['admin_id'];
}
if(! empty($auth_role_info['permission']['arctype'])){
if (!empty($typeid)) {
$typeids = array_intersect($typeids, $auth_role_info['permission']['arctype']);
}
}
}
}
/*--end*/
$condition['a.typeid'] = array('IN', $typeids);
} else if ($key == 'flag') {
if ('is_release' == $param[$key]) {
$condition['a.users_id'] = array('gt', 0);
} else {
$condition['a.'.$param[$key]] = array('eq', 1);
}
// } else if ($key == 'is_release') {
// if (0 < intval($param[$key])) {
// $condition['a.users_id'] = array('gt', intval($param[$key]));
// }
} else {
$condition['a.'.$key] = array('eq', $param[$key]);
}
}
}
/*权限控制 by 小虎哥*/
if (empty($typeid)) {
$typeids = [];
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
if(isset($auth_role_info['only_oneself']) && 1 == $auth_role_info['only_oneself']){
$condition['a.admin_id'] = $admin_info['admin_id'];
}
if(! empty($auth_role_info['permission']['arctype'])){
$typeids = $auth_role_info['permission']['arctype'];
}
}
}
if (!empty($typeids)) {
$condition['a.typeid'] = array('IN', $typeids);
}
}
/*--end*/
if (empty($typeid)) {
$id_tmp = [6,8];
// 只显示允许发布文档的模型,且是开启状态
$channelIds = Db::name('channeltype')->where('status',0)
->whereOr('id','IN',$id_tmp)->column('id');
$condition['a.channel'] = array('NOT IN', $channelIds);
} else {
// 只显示当前栏目对应模型下的文档
$current_channel = Db::name('arctype')->where('id',$typeid)->getField('current_channel');
$condition['a.channel'] = array('eq', $current_channel);
}
/*多语言*/
$condition['a.lang'] = array('eq', $this->admin_lang);
/*--end*/
/*回收站数据不显示*/
$condition['a.is_del'] = array('eq', 0);
/*--end*/
/*自定义排序*/
$orderby = input('param.orderby/s');
$orderway = input('param.orderway/s');
if (!empty($orderby)) {
$orderby = "a.{$orderby} {$orderway}";
$orderby .= ", a.aid desc";
} else {
$orderby = "a.aid desc";
}
/*end*/
/**
* 数据查询搜索出主键ID的值
*/
$count = Db::name('archives')->alias('a')->where($condition)->count('aid');// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = Db::name('archives')
->field("a.aid,a.channel")
->alias('a')
->where($condition)
->order($orderby)
->limit($Page->firstRow.','.$Page->listRows)
->getAllWithIndex('aid');
/**
* 完善数据集信息
* 在数据量大的情况下经过优化的搜索逻辑先搜索出主键ID再通过ID将其他信息补充完整
*/
if ($list) {
$aids = array_keys($list);
$fields = "b.*, a.*, a.aid as aid";
$row = Db::name('archives')
->field($fields)
->alias('a')
->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
->where('a.aid', 'in', $aids)
->getAllWithIndex('aid');
/*获取当页文档的所有模型*/
$channelIds = get_arr_column($list, 'channel');
$channelRow = Db::name('channeltype')->field('id, ctl_name, ifsystem')
->where('id','IN',$channelIds)
->getAllWithIndex('id');
$assign_data['channelRow'] = $channelRow;
/*--end*/
$aids_channel2 = []; // 产品模型的文档ID
foreach ($list as $key => $val) {
if (2 == $val['channel']) {
array_push($aids_channel2, $val['aid']);
}
$row[$val['aid']]['arcurl'] = get_arcurl($row[$val['aid']]);
$row[$val['aid']]['litpic'] = handle_subdir_pic($row[$val['aid']]['litpic']); // 支持子目录
$list[$key] = $row[$val['aid']];
}
// 产品参数
$product_attr_row = [];
if (!empty($aids_channel2)) {
$product_attr_row = Db::name('product_attr')->field('count(product_attr_id) as num, aid')->where(['aid'=>['IN', $aids_channel2]])->group('aid')->getAllWithIndex('aid');
}
$assign_data['product_attr_row'] = $product_attr_row;
}
$show = $Page->show(); // 分页显示输出
$assign_data['page'] = $show; // 赋值分页输出
$assign_data['list'] = $list; // 赋值数据集
$assign_data['pager'] = $Page; // 赋值分页对象
// 栏目ID
$assign_data['typeid'] = $typeid; // 栏目ID
/*当前栏目信息*/
$arctype_info = array();
if ($typeid > 0) {
$arctype_info = M('arctype')->field('typename,current_channel')->find($typeid);
}
$assign_data['arctype_info'] = $arctype_info;
/*--end*/
/*允许发布文档列表的栏目*/
$assign_data['arctype_html'] = allow_release_arctype($typeid, array());
/*--end*/
/*前台URL模式*/
$assign_data['seo_pseudo'] = tpCache('seo.seo_pseudo');
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
// 商城开关
$assign_data['shop_open'] = getUsersConfigData('shop.shop_open');
/*是否存在栏目*/
$assign_data['is_arctype'] = Db::name('arctype')->where([
'is_del' => 0,
'lang' => get_current_lang(),
])->count();
/*end*/
$this->assign($assign_data);
return $this->fetch('index_archives');
}
/**
* 内容管理 - 栏目展开风格
*/
private function index_arctype() {
$arctype_list = array();
// 目录列表
$arctypeLogic = new ArctypeLogic();
$arctype_list = $arctypeLogic->arctype_list(0, 0, false, 0, array(), false);
$this->assign('arctype_list', $arctype_list);
// 模型列表
$channeltype_list = getChanneltypeList();
$this->assign('channeltype_list', $channeltype_list);
// 栏目最多级别
$arctype_max_level = intval(config('global.arctype_max_level'));
$this->assign('arctype_max_level', $arctype_max_level);
// 允许发布文档的模型
$this->assign('allow_release_channel', $this->allowReleaseChannel);
return $this->fetch('index_arctype');
}
/**
* 发布文档
*/
public function add()
{
$typeid = input('param.typeid/d', 0);
if (!empty($typeid)) {
$row = Db::name('arctype')
->alias('a')
->field('b.ctl_name,b.id,b.ifsystem')
->join('__CHANNELTYPE__ b', 'a.current_channel = b.id', 'LEFT')
->where('a.id', 'eq', $typeid)
->find();
$data = [
'typeid' => $typeid,
];
if (empty($row['ifsystem'])) {
$ctl_name = 'Custom';
$data['channel'] = $row['id'];
} else {
$ctl_name = $row['ctl_name'];
}
$gourl = url('Archives/index_archives', array('typeid'=>$typeid));
$data['gourl'] = $gourl;
$jumpUrl = url("{$ctl_name}/add", $data);
} else {
$jumpUrl = url("Archives/release");
}
$this->redirect($jumpUrl);
}
/**
* 编辑文档
*/
public function edit()
{
$id = input('param.id/d', 0);
$typeid = input('param.typeid/d', 0);
$row = Db::name('archives')
->alias('a')
->field('a.channel,b.ctl_name,b.id,b.ifsystem')
->join('__CHANNELTYPE__ b', 'a.channel = b.id', 'LEFT')
->where('a.aid', 'eq', $id)
->find();
if (empty($row['channel'])) {
$channelRow = Db::name('channeltype')->field('id as channel, ctl_name')
->where('nid','article')
->find();
$row = array_merge($row, $channelRow);
}
$data = [
'id' => $id,
];
if (empty($row['ifsystem'])) {
$ctl_name = 'Custom';
$data['channel'] = $row['id'];
} else {
$ctl_name = $row['ctl_name'];
}
$arcurl = input('param.arcurl/s');
$data['arcurl'] = $arcurl;
$jumpUrl = url("{$ctl_name}/edit", $data);
$this->redirect($jumpUrl);
}
/**
* 删除文档
*/
public function del()
{
if (IS_POST) {
$del_id = input('del_id/a');
$thorough = input('thorough/d', 0);
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$archivesLogic->del($del_id, $thorough);
}
}
/**
* 审核文档
*/
public function check()
{
if (IS_POST) {
$aids = input('ids/a');
$aids = !empty($aids) ? eyIntval($aids) : '';
if (!empty($aids)){
$info = [
'arcrank' => 0,
'update_time'=>getTime(),
];
$r = Db::name('archives')->where('aid','IN',$aids)->cache(true,null,'archives')->save($info);
if ($r !== false) {
adminLog('审核文档-id'.implode(',', $aids));
$this->success('操作成功!');
} else {
$this->error('操作失败!');
}
}
}
}
/**
* 取消审核文档
*/
public function uncheck()
{
if (IS_POST) {
$aids = input('ids/a');
$aids = !empty($aids) ? eyIntval($aids) : '';
if (!empty($aids)){
$info = [
'arcrank' => -1,
'update_time'=>getTime(),
];
$r = Db::name('archives')->where('aid','IN',$aids)->cache(true,null,'archives')->save($info);
if ($r !== false) {
adminLog('取消审核-id'.implode(',', $aids));
$this->success('操作成功!');
} else {
$this->error('操作失败!');
}
}
}
}
/**
* 移动
*/
public function move()
{
if (IS_POST) {
$post = input('post.');
$typeid = !empty($post['typeid']) ? eyIntval($post['typeid']) : '';
$aids = !empty($post['aids']) ? eyIntval($post['aids']) : '';
if (empty($typeid) || empty($aids)) {
$this->error('参数有误,请联系技术支持');
}
// 获取移动栏目的模型ID
$current_channel = Db::name('arctype')->where([
'id' => $typeid,
'lang' => $this->admin_lang,
])->getField('current_channel');
// 抽取相符合模型ID的文档aid
$aids = Db::name('archives')->where([
'aid' => ['IN', $aids],
'channel' => $current_channel,
'lang' => $this->admin_lang,
])->column('aid');
// 移动文档处理
$update_data = array(
'typeid' => $typeid,
'update_time' => getTime(),
);
$r = M('archives')->where([
'aid' => ['IN', $aids],
])->update($update_data);
if($r){
adminLog('移动文档-id'.$aids);
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
$typeid = input('param.typeid/d', 0);
/*允许发布文档列表的栏目*/
$allowReleaseChannel = [];
if (!empty($typeid)) {
$channelId = Db::name('arctype')->where('id',$typeid)->getField('current_channel');
$allowReleaseChannel[] = $channelId;
}
$arctype_html = allow_release_arctype($typeid, $allowReleaseChannel);
$this->assign('arctype_html', $arctype_html);
/*--end*/
/*不允许发布文档的模型ID用于JS判断*/
// $js_allow_channel_arr = '[]';
// if (!empty($allowReleaseChannel)) {
// $js_allow_channel_arr = '[';
// foreach ($allowReleaseChannel as $key => $val) {
// if ($key > 0) {
// $js_allow_channel_arr .= ',';
// }
// $js_allow_channel_arr .= $val;
// }
// $js_allow_channel_arr = $js_allow_channel_arr.']';
// }
// $this->assign('js_allow_channel_arr', $js_allow_channel_arr);
/*--end*/
/*表单提交URL*/
$form_action = url('Archives/move');
$this->assign('form_action', $form_action);
/*--end*/
return $this->fetch();
}
/**
* 发布内容
*/
public function release()
{
$typeid = input('param.typeid/d', 0);
if (0 < $typeid) {
$param = input('param.');
$row = Db::name('arctype')
->field('b.ctl_name,b.id,b.ifsystem')
->alias('a')
->join('__CHANNELTYPE__ b', 'a.current_channel = b.id', 'LEFT')
->where('a.id', 'eq', $typeid)
->find();
/*针对不支持发布文档的模型*/
if (!in_array($row['id'], $this->allowReleaseChannel)) {
$this->error('该栏目不支持发布文档!', url('Archives/release'));
exit;
}
/*-----end*/
$data = [
'typeid' => $typeid,
];
if (empty($row['ifsystem'])) {
$ctl_name = 'Custom';
$data['channel'] = $row['id'];
} else {
$ctl_name = $row['ctl_name'];
}
$gourl = url('Archives/index_archives', array('typeid'=>$typeid), true, true);
$data['gourl'] = $gourl;
$jumpUrl = url("{$ctl_name}/add", $data, true, true);
header('Location: '.$jumpUrl);
exit;
}
$iframe = input('param.iframe/d',0);
/*允许发布文档列表的栏目*/
$select_html = allow_release_arctype();
$this->assign('select_html',$select_html);
/*--end*/
/*不允许发布文档的模型ID用于JS判断*/
$js_allow_channel_arr = '[';
foreach ($this->allowReleaseChannel as $key => $val) {
if ($key > 0) {
$js_allow_channel_arr .= ',';
}
$js_allow_channel_arr .= $val;
}
$js_allow_channel_arr = $js_allow_channel_arr.']';
$this->assign('js_allow_channel_arr', $js_allow_channel_arr);
/*--end*/
if (!empty($iframe)) {
$template = 'release_iframe';
$attribute_row = Db::name('product_attribute')->field('typeid, count(attr_id) as num')
->where([
'is_del' => 0,
'lang' => $this->admin_lang,
])
->group('typeid')
->getAllWithIndex('typeid');
$this->assign('attribute_row', $attribute_row);
} else {
$template = 'release';
}
$this->assign('iframe', $iframe);
return $this->fetch($template);
}
public function ajax_get_arctype()
{
$pid = input('pid/d');
$html = '';
$status = 0;
if (0 < $pid) {
$map = array(
'current_channel' => array('IN', $this->allowReleaseChannel),
'parent_id' => $pid,
);
$row = model('Arctype')->getAll('id,typename', $map, 'id');
if (!empty($row)) {
$status = 1;
$html = '<option value="0">请选择栏目…</option>';
foreach ($row as $key => $val) {
$html .= '<option value="'.$val['id'].'">'.$val['typename'].'</option>';
}
}
}
respose(array(
'status' => $status,
'msg' => $html,
));
}
/**
* 复制
*/
public function batch_copy()
{
if (IS_AJAX_POST) {
$typeid = input('post.typeid/d');
$aids = input('post.aids/s');
$num = input('post.num/d');
if (empty($typeid) || empty($aids)) {
$this->error('复制失败!');
} else if (empty($num)) {
$this->error('复制数量至少一篇!');
}
// 获取复制栏目的模型ID
$current_channel = Db::name('arctype')->where([
'id' => $typeid,
])->getField('current_channel');
// 抽取相符合模型ID的文档aid
$aids = Db::name('archives')->where([
'aid' => ['IN', $aids],
'channel' => $current_channel,
])->column('aid');
// 复制文档处理
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$r = $archivesLogic->batch_copy($aids, $typeid, $current_channel, $num);
if($r){
adminLog('复制文档-id'.$aids);
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
$typeid = input('param.typeid/d', 0);
/*允许发布文档列表的栏目*/
$allowReleaseChannel = [];
if (!empty($typeid)) {
$channelId = Db::name('arctype')->where('id',$typeid)->getField('current_channel');
$allowReleaseChannel[] = $channelId;
}
$arctype_html = allow_release_arctype($typeid, $allowReleaseChannel);
$this->assign('arctype_html', $arctype_html);
/*--end*/
/*表单提交URL*/
$form_action = url('Archives/batch_copy');
$this->assign('form_action', $form_action);
/*--end*/
return $this->fetch();
}
/**
* 批量属性操作
*/
public function batch_attr()
{
if (IS_AJAX_POST) {
$opt = input('post.opt/s');
$aids = input('post.aids/s');
$attrType = input('post.attrType/s');
if (empty($opt)) {
$this->error('操作失败!');
} else if (empty($attrType)) {
$this->error('请勾选属性!');
} else if (empty($aids)) {
$this->error('文档ID不能为空');
}
$value = ($opt == 'add') ? 1 : 0;
$aids = str_replace('', ',', $aids);
$r = Db::name('archives')->where([
'aid' => ['IN', explode(',', $aids)],
'lang' => $this->admin_lang,
])->update([
$attrType => $value,
'update_time' => getTime(),
]);
if($r !== false){
adminLog('批量处理属性-id'.$aids);
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
$this->assign($assign_data);
return $this->fetch();
}
/**
* 远程图片本地化
*
* @access public
* @return string
*/
public function ajax_remote_to_local()
{
if (IS_AJAX_POST) {
$body = input('post.body/s', '', null);
$body = remote_to_local($body);
$this->success('本地化成功!', null, ['body'=>$body]);
}
$this->error('本地化失败!');
}
/**
* 清除非站内链接
*
* @access public
* @return string
*/
public function ajax_replace_links()
{
if (IS_AJAX_POST) {
$body = input('post.body/s', '', null);
$body = replace_links($body);
$this->success('清除成功!', null, ['body'=>$body]);
}
$this->error('清除失败!');
}
/**
* 自定义字段
*/
public function ajax_get_addonextitem()
{
$aid = input('param.aid/d', 0);
$typeid = input('param.typeid/d', 0);
$channeltype = input('param.channeltype/d', 0);
if (!empty($typeid) && !empty($channeltype)) {
// 存在aid则执行查询文档数据
$info = !empty($aid) ? model('Archives')->UnifiedGetInfo($aid, null, false) : [];
// 查询对应的自定义字段
$addonFieldExtList = model('Field')->getChannelFieldList($channeltype, 0, $aid, $info);
$field_id_row = Db::name('channelfield_bind')->where([
'field_id' => ['IN', get_arr_column($addonFieldExtList, 'id')],
])->column('field_id');
// 匹配显示的自定义字段
$htmltextField = []; // 富文本的字段名
if (!empty($field_id_row)) {
// 查询绑定的自定义字段
$channelfieldBindRow = Db::name('channelfield_bind')->where([
'typeid' => ['IN', [0, $typeid]],
])->column('field_id');
foreach ($addonFieldExtList as $key => $val) {
if (in_array($val['id'], $field_id_row) && !in_array($val['id'], $channelfieldBindRow)) {
unset($addonFieldExtList[$key]);
continue;
}
if ($val['dtype'] == 'htmltext') {
array_push($htmltextField, $val['name']);
}
}
}
$assign_data['addonFieldExtList'] = $addonFieldExtList;
// 加载模板
$assign_data['params'] = input('param.');
$assign_data['field'] = $info;
$this->assign($assign_data);
// 渲染模板
$controller_name = input('param.controller_name/s');
if (!empty($controller_name) && 'Custom' == $controller_name) {
$html = $this->fetch('field/modelfield');
} else {
$html = $this->fetch('field/addonextitem');
}
$this->success('请求成功', null, ['html'=>$html, 'htmltextField'=>$htmltextField]);
}
}
/**
* 新建模板文件
*/
public function ajax_newtpl()
{
if (IS_POST) {
$post = input('post.', '', null);
$content = input('post.content', '', null);
$view_suffix = config('template.view_suffix');
if (!empty($post['filename'])) {
if (!preg_match("/^[\w\-\_]{1,}$/u", $post['filename'])) {
$this->error('文件名称只允许字母、数字、下划线、连接符的任意组合!');
}
$filename = "{$post['type']}_{$post['nid']}_{$post['filename']}.{$view_suffix}";
} else {
$filename = "{$post['type']}_{$post['nid']}.{$view_suffix}";
}
$content = !empty($content) ? $content : '';
$tpldirpath = !empty($post['tpldir']) ? '/template/'.TPL_THEME.trim($post['tpldir']) : '/template/'.TPL_THEME.'pc';
if (file_exists(ROOT_PATH.ltrim($tpldirpath, '/').'/'.$filename)) {
$this->error('文件名称已经存在,请重新命名!', null, ['focus'=>'filename']);
}
$nosubmit = input('param.nosubmit/d');
if (1 == $nosubmit) {
$this->success('检测通过');
}
$filemanagerLogic = new \app\admin\logic\FilemanagerLogic;
$r = $filemanagerLogic->editFile($filename, $tpldirpath, $content);
if ($r === true) {
$this->success('操作成功', null, ['filename'=>$filename,'type'=>$post['type']]);
} else {
$this->error($r);
}
}
$type = input('param.type/s');
$nid = input('param.nid/s');
$tpldirList = glob('template/'.TPL_THEME.'*');
$tpl_theme = str_replace('/', '\\/', TPL_THEME);
foreach ($tpldirList as $key => $val) {
if (!preg_match('/template\/'.$tpl_theme.'(pc|mobile)$/i', $val)) {
unset($tpldirList[$key]);
} else {
$tpldirList[$key] = preg_replace('/^(.*)template\/'.$tpl_theme.'(pc|mobile)$/i', '$2', $val);
}
}
!empty($tpldirList) && arsort($tpldirList);
$this->assign('tpldirList', $tpldirList);
$content = '';
if ('special' == $nid) {
$fileContent = @file_get_contents('./data/model/template/pc/view_custommodel.htm');
if (!empty($fileContent)) {
$content = $fileContent;
$replace = <<<EOF
<section class="article-list">
{eyou:specnode code="default1" id="field"}
<article>
{eyou:notempty name="\$field.is_litpic"}
<a href="{\$field.arcurl}" target="_blank" title="{\$field.title}" style="float: left; margin-right: 10px"> <img src="{\$field.litpic}" alt="{\$field.title}" height="100" /> </a>
{/eyou:notempty}
<h2><a href="{\$field.arcurl}" target="_blank">{\$field.title}</a><span>{\$field.click}°C</span></h2>
<div class="excerpt">
<p>{\$field.seo_description}</p>
</div>
<div class="meta">
<span class="item"><time>{\$field.add_time|MyDate='Y-m-d',###}</time></span>
<span class="item"><a href="{\$field.typeurl}" target="_blank">{\$field.typename}</a></span>
</div>
</article>
{/eyou:specnode}
</section>
EOF;
$content = str_replace("<!-- #special# -->", $replace, $content);
}
}
$this->assign('content', $content);
$this->assign('type', $type);
$this->assign('nid', $nid);
$this->assign('tpl_theme', TPL_THEME);
return $this->fetch();
}
/**
* 检测自定义文件名是否存在
*/
public function ajax_check_htmlfilename()
{
$htmlfilename = input('post.htmlfilename/s');
$htmlfilename = trim($htmlfilename);
if (!empty($htmlfilename)) {
$aid = input('post.aid/d');
$htmlfilename = preg_replace("/[^a-zA-Z0-9_-]+/", "-", $htmlfilename);
$htmlfilename = strtolower($htmlfilename);
$map = array(
'htmlfilename' => $htmlfilename,
'lang' => $this->admin_lang,
);
if ($aid > 0) {
$map['aid'] = array('neq', $aid);
}
$result = Db::name('archives')->where($map)->find();
if (!empty($result)) {
$this->error('自定义文件名已存在,请更改!');
}
}
$this->success('自定义文件名可用!');
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Db;
use think\Page;
use think\Cache;
class ArchivesFlag extends Base
{
public function index()
{
$list = array();
$keywords = input('keywords/s');
$condition = array();
if (!empty($keywords)) {
$condition['flag_name'] = array('LIKE', "%{$keywords}%");
}
$archivesflagM = M('archives_flag');
$count = $archivesflagM->where($condition)->count('id');// 查询满足要求的总记录数
$Page = $pager = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = $archivesflagM->where($condition)->order('sort_order asc, id asc')->limit($Page->firstRow.','.$Page->listRows)->select();
$show = $Page->show();// 分页显示输出
$this->assign('page',$show);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->assign('pager',$pager);// 赋值分页对象
return $this->fetch();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,646 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Page;
use think\Db;
use think\Config;
class Article extends Base
{
// 模型标识
public $nid = 'article';
// 模型ID
public $channeltype = '';
public function _initialize()
{
parent::_initialize();
$channeltype_list = config('global.channeltype_list');
$this->channeltype = $channeltype_list[$this->nid];
empty($this->channeltype) && $this->channeltype = 1;
$this->assign('nid', $this->nid);
$this->assign('channeltype', $this->channeltype);
}
/**
* 文章列表
*/
public function index()
{
$assign_data = array();
$condition = array();
// 获取到所有GET参数
$param = input('param.');
$flag = input('flag/s');
$typeid = input('typeid/d', 0);
$begin = strtotime(input('add_time_begin'));
$end = strtotime(input('add_time_end'));
// 应用搜索条件
foreach (['keywords','typeid','flag','is_release'] as $key) {
if (isset($param[$key]) && $param[$key] !== '') {
if ($key == 'keywords') {
$condition['a.title'] = array('LIKE', "%{$param[$key]}%");
} else if ($key == 'typeid') {
$typeid = $param[$key];
$hasRow = model('Arctype')->getHasChildren($typeid);
$typeids = get_arr_column($hasRow, 'id');
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
if(! empty($auth_role_info['permission']['arctype'])){
if (!empty($typeid)) {
$typeids = array_intersect($typeids, $auth_role_info['permission']['arctype']);
}
}
}
}
/*--end*/
$condition['a.typeid'] = array('IN', $typeids);
} else if ($key == 'flag') {
if ('is_release' == $param[$key]) {
$condition['a.users_id'] = array('gt', 0);
} else {
$condition['a.'.$param[$key]] = array('eq', 1);
}
// } else if ($key == 'is_release') {
// if (0 < intval($param[$key])) {
// $condition['a.users_id'] = array('gt', intval($param[$key]));
// }
} else {
$condition['a.'.$key] = array('eq', $param[$key]);
}
}
}
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
if(isset($auth_role_info['only_oneself']) && 1 == $auth_role_info['only_oneself']){
$condition['a.admin_id'] = $admin_info['admin_id'];
}
}
}
/*--end*/
// 时间检索
if ($begin > 0 && $end > 0) {
$condition['a.add_time'] = array('between',"$begin,$end");
} else if ($begin > 0) {
$condition['a.add_time'] = array('egt', $begin);
} else if ($end > 0) {
$condition['a.add_time'] = array('elt', $end);
}
// 模型ID
$condition['a.channel'] = array('eq', $this->channeltype);
// 多语言
$condition['a.lang'] = array('eq', $this->admin_lang);
// 回收站
$condition['a.is_del'] = array('eq', 0);
/*自定义排序*/
$orderby = input('param.orderby/s');
$orderway = input('param.orderway/s');
if (!empty($orderby)) {
$orderby = "a.{$orderby} {$orderway}";
$orderby .= ", a.aid desc";
} else {
$orderby = "a.aid desc";
}
/*end*/
/**
* 数据查询搜索出主键ID的值
*/
$count = DB::name('archives')->alias('a')->where($condition)->count('aid');// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = DB::name('archives')
->field("a.aid")
->alias('a')
->where($condition)
->order($orderby)
->limit($Page->firstRow.','.$Page->listRows)
->getAllWithIndex('aid');
/**
* 完善数据集信息
* 在数据量大的情况下经过优化的搜索逻辑先搜索出主键ID再通过ID将其他信息补充完整
*/
if ($list) {
$aids = array_keys($list);
$fields = "b.*, a.*, a.aid as aid";
$row = DB::name('archives')
->field($fields)
->alias('a')
->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
->where('a.aid', 'in', $aids)
->getAllWithIndex('aid');
foreach ($list as $key => $val) {
$row[$val['aid']]['arcurl'] = get_arcurl($row[$val['aid']]);
$row[$val['aid']]['litpic'] = handle_subdir_pic($row[$val['aid']]['litpic']); // 支持子目录
$list[$key] = $row[$val['aid']];
}
}
$show = $Page->show(); // 分页显示输出
$assign_data['page'] = $show; // 赋值分页输出
$assign_data['list'] = $list; // 赋值数据集
$assign_data['pager'] = $Page; // 赋值分页对象
// 栏目ID
$assign_data['typeid'] = $typeid; // 栏目ID
/*当前栏目信息*/
$arctype_info = array();
if ($typeid > 0) {
$arctype_info = M('arctype')->field('typename')->find($typeid);
}
$assign_data['arctype_info'] = $arctype_info;
/*--end*/
/*选项卡*/
$tab = input('param.tab/d', 3);
$assign_data['tab'] = $tab;
/*--end*/
/*前台URL模式*/
$assign_data['seo_pseudo'] = tpCache('seo.seo_pseudo');
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
$this->assign($assign_data);
return $this->fetch();
}
/**
* 添加
*/
public function add()
{
$admin_info = session('admin_info');
$auth_role_info = $admin_info['auth_role_info'];
$this->assign('auth_role_info', $auth_role_info);
$this->assign('admin_info', $admin_info);
if (IS_POST) {
$post = input('post.');
/* 处理TAG标签 */
if (!empty($post['tags_new'])) {
$post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
unset($post['tags_new']);
}
$post['tags'] = explode(',', $post['tags']);
$post['tags'] = array_unique($post['tags']);
$post['tags'] = implode(',', $post['tags']);
/* END */
$content = input('post.addonFieldExt.content', '', null);
// 根据标题自动提取相关的关键字
$seo_keywords = $post['seo_keywords'];
if (!empty($seo_keywords)) {
$seo_keywords = str_replace('', ',', $seo_keywords);
} else {
// $seo_keywords = get_split_word($post['title'], $content);
}
// 自动获取内容第一张图片作为封面图
$is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
$litpic = '';
if ($is_remote == 1) {
$litpic = $post['litpic_remote'];
} else {
$litpic = $post['litpic_local'];
}
if (empty($litpic)) {
$litpic = get_html_first_imgurl($content);
}
$post['litpic'] = $litpic;
/*是否有封面图*/
if (empty($post['litpic'])) {
$is_litpic = 0; // 无封面图
} else {
$is_litpic = 1; // 有封面图
}
// SEO描述
$seo_description = '';
if (empty($post['seo_description']) && !empty($content)) {
$seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
} else {
$seo_description = $post['seo_description'];
}
// 外部链接跳转
$jumplinks = '';
$is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
if (intval($is_jump) > 0) {
$jumplinks = $post['jumplinks'];
}
// 模板文件,如果文档模板名与栏目指定的一致,默认就为空。让它跟随栏目的指定而变
if ($post['type_tempview'] == $post['tempview']) {
unset($post['type_tempview']);
unset($post['tempview']);
}
//处理自定义文件名,仅由字母数字下划线和短横杆组成,大写强制转换为小写
$htmlfilename = trim($post['htmlfilename']);
if (!empty($htmlfilename)) {
$htmlfilename = preg_replace("/[^a-zA-Z0-9_-]+/", "-", $htmlfilename);
$htmlfilename = strtolower($htmlfilename);
//判断是否存在相同的自定义文件名
$filenameCount = Db::name('archives')->where([
'htmlfilename' => $htmlfilename,
'lang' => $this->admin_lang,
])->count();
if (!empty($filenameCount)) {
$this->error("自定义文件名已存在,请重新设置!");
}
}
$post['htmlfilename'] = $htmlfilename;
//做自动通过审核判断
if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
$post['arcrank'] = -1;
}
// --存储数据
$newData = array(
'typeid'=> empty($post['typeid']) ? 0 : $post['typeid'],
'channel' => $this->channeltype,
'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
'is_jump' => $is_jump,
'is_litpic' => $is_litpic,
'jumplinks' => $jumplinks,
'seo_keywords' => $seo_keywords,
'seo_description' => $seo_description,
'admin_id' => session('admin_info.admin_id'),
'lang' => $this->admin_lang,
'sort_order' => 100,
'add_time' => strtotime($post['add_time']),
'update_time' => strtotime($post['add_time']),
);
$data = array_merge($post, $newData);
$aid = Db::name('archives')->insertGetId($data);
$_POST['aid'] = $aid;
if ($aid) {
// ---------后置操作
model('Article')->afterSave($aid, $data, 'add');
// ---------end
adminLog('新增文章:'.$data['title']);
// 生成静态页面代码
$successData = [
'aid' => $aid,
'tid' => $post['typeid'],
];
$this->success("操作成功!", null, $successData);
exit;
}
$this->error("操作失败!");
exit;
}
$typeid = input('param.typeid/d', 0);
$assign_data['typeid'] = $typeid; // 栏目ID
// 栏目信息
$arctypeInfo = Db::name('arctype')->find($typeid);
/*允许发布文档列表的栏目*/
$arctype_html = allow_release_arctype($typeid, array($this->channeltype));
$assign_data['arctype_html'] = $arctype_html;
/*--end*/
/*自定义字段*/
// $addonFieldExtList = model('Field')->getChannelFieldList($this->channeltype);
// $channelfieldBindRow = Db::name('channelfield_bind')->where([
// 'typeid' => ['IN', [0, $typeid]],
// ])->column('field_id');
// if (!empty($channelfieldBindRow)) {
// foreach ($addonFieldExtList as $key => $val) {
// if (!in_array($val['id'], $channelfieldBindRow)) {
// unset($addonFieldExtList[$key]);
// }
// }
// }
// $assign_data['addonFieldExtList'] = $addonFieldExtList;
// $assign_data['aid'] = 0;
/*--end*/
// 阅读权限
$arcrank_list = get_arcrank_list();
$assign_data['arcrank_list'] = $arcrank_list;
/*模板列表*/
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$templateList = $archivesLogic->getTemplateList($this->nid);
$this->assign('templateList', $templateList);
/*--end*/
/*默认模板文件*/
$tempview = 'view_'.$this->nid.'.'.config('template.view_suffix');
!empty($arctypeInfo['tempview']) && $tempview = $arctypeInfo['tempview'];
$this->assign('tempview', $tempview);
/*--end*/
// 文档默认浏览量
$other_config = tpCache('other');
if (isset($other_config['other_arcclick']) && 0 <= $other_config['other_arcclick']) {
$arcclick_arr = explode("|", $other_config['other_arcclick']);
if (count($arcclick_arr) > 1) {
$assign_data['rand_arcclick'] = mt_rand($arcclick_arr[0], $arcclick_arr[1]);
} else {
$assign_data['rand_arcclick'] = intval($arcclick_arr[0]);
}
}else{
$arcclick_config['other_arcclick'] = '500|1000';
tpCache('other', $arcclick_config);
$assign_data['rand_arcclick'] = mt_rand(500, 1000);
}
// URL模式
$tpcache = config('tpcache');
$assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
$this->assign($assign_data);
return $this->fetch();
}
/**
* 编辑
*/
public function edit()
{
$admin_info = session('admin_info');
$auth_role_info = $admin_info['auth_role_info'];
$this->assign('auth_role_info', $auth_role_info);
$this->assign('admin_info', $admin_info);
if (IS_POST) {
$post = input('post.');
/* 处理TAG标签 */
if (!empty($post['tags_new'])) {
$post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
unset($post['tags_new']);
}
$post['tags'] = explode(',', $post['tags']);
$post['tags'] = array_unique($post['tags']);
$post['tags'] = implode(',', $post['tags']);
/* END */
$typeid = input('post.typeid/d', 0);
$content = input('post.addonFieldExt.content', '', null);
// 根据标题自动提取相关的关键字
$seo_keywords = $post['seo_keywords'];
if (!empty($seo_keywords)) {
$seo_keywords = str_replace('', ',', $seo_keywords);
} else {
// $seo_keywords = get_split_word($post['title'], $content);
}
// 自动获取内容第一张图片作为封面图
$is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
$litpic = '';
if ($is_remote == 1) {
$litpic = $post['litpic_remote'];
} else {
$litpic = $post['litpic_local'];
}
if (empty($litpic)) {
$litpic = get_html_first_imgurl($content);
}
$post['litpic'] = $litpic;
/*是否有封面图*/
if (empty($post['litpic'])) {
$is_litpic = 0; // 无封面图
} else {
$is_litpic = !empty($post['is_litpic']) ? $post['is_litpic'] : 0; // 有封面图
}
// SEO描述
$seo_description = '';
if (empty($post['seo_description']) && !empty($content)) {
$seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
} else {
$seo_description = $post['seo_description'];
}
// --外部链接
$jumplinks = '';
$is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
if (intval($is_jump) > 0) {
$jumplinks = $post['jumplinks'];
}
// 模板文件,如果文档模板名与栏目指定的一致,默认就为空。让它跟随栏目的指定而变
if ($post['type_tempview'] == $post['tempview']) {
unset($post['type_tempview']);
unset($post['tempview']);
}
// 同步栏目切换模型之后的文档模型
$channel = Db::name('arctype')->where(['id'=>$typeid])->getField('current_channel');
//处理自定义文件名,仅由字母数字下划线和短横杆组成,大写强制转换为小写
$htmlfilename = trim($post['htmlfilename']);
if (!empty($htmlfilename)) {
$htmlfilename = preg_replace("/[^a-zA-Z0-9_-]+/", "-", $htmlfilename);
$htmlfilename = strtolower($htmlfilename);
//判断是否存在相同的自定义文件名
$filenameCount = Db::name('archives')->where([
'aid' => ['NEQ', $post['aid']],
'htmlfilename' => $htmlfilename,
'lang' => $this->admin_lang,
])->count();
if (!empty($filenameCount)) {
$this->error("自定义文件名已存在,请重新设置!");
}
}
$post['htmlfilename'] = $htmlfilename;
//做未通过审核文档不允许修改文档状态操作
if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
$old_archives_arcrank = Db::name('archives')->where(['aid' => $post['aid']])->getField("arcrank");
if ($old_archives_arcrank < 0) {
unset($post['arcrank']);
}
}
// --存储数据
$newData = array(
'typeid'=> $typeid,
'channel' => $channel,
'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
'is_jump' => $is_jump,
'is_litpic' => $is_litpic,
'jumplinks' => $jumplinks,
'seo_keywords' => $seo_keywords,
'seo_description' => $seo_description,
'add_time' => strtotime($post['add_time']),
'update_time' => getTime(),
);
$data = array_merge($post, $newData);
$r = Db::name('archives')->where([
'aid' => $data['aid'],
'lang' => $this->admin_lang,
])->update($data);
if ($r) {
// ---------后置操作
model('Article')->afterSave($data['aid'], $data, 'edit');
// ---------end
adminLog('编辑文章:'.$data['title']);
// 生成静态页面代码
$successData = [
'aid' => $data['aid'],
'tid' => $typeid,
];
$this->success("操作成功!", null, $successData);
exit;
}
$this->error("操作失败!");
exit;
}
$assign_data = array();
$id = input('id/d');
$info = model('Article')->getInfo($id, null, false);
if (empty($info)) {
$this->error('数据不存在,请联系管理员!');
exit;
}
/*兼容采集没有归属栏目的文档*/
if (empty($info['channel'])) {
$channelRow = Db::name('channeltype')->field('id as channel')
->where('id',$this->channeltype)
->find();
$info = array_merge($info, $channelRow);
}
/*--end*/
$typeid = $info['typeid'];
$assign_data['typeid'] = $typeid;
// 栏目信息
$arctypeInfo = Db::name('arctype')->find($typeid);
$info['channel'] = $arctypeInfo['current_channel'];
if (is_http_url($info['litpic'])) {
$info['is_remote'] = 1;
$info['litpic_remote'] = handle_subdir_pic($info['litpic']);
} else {
$info['is_remote'] = 0;
$info['litpic_local'] = handle_subdir_pic($info['litpic']);
}
// SEO描述
if (!empty($info['seo_description'])) {
$info['seo_description'] = @msubstr(checkStrHtml($info['seo_description']), 0, config('global.arc_seo_description_length'), false);
}
$assign_data['field'] = $info;
/*允许发布文档列表的栏目,文档所在模型以栏目所在模型为主,兼容切换模型之后的数据编辑*/
$arctype_html = allow_release_arctype($typeid, array($info['channel']));
$assign_data['arctype_html'] = $arctype_html;
/*--end*/
/*自定义字段*/
// $addonFieldExtList = model('Field')->getChannelFieldList($info['channel'], 0, $id, $info);
// $channelfieldBindRow = Db::name('channelfield_bind')->where([
// 'typeid' => ['IN', [0,$typeid]],
// ])->column('field_id');
// if (!empty($channelfieldBindRow)) {
// foreach ($addonFieldExtList as $key => $val) {
// if (!in_array($val['id'], $channelfieldBindRow)) {
// unset($addonFieldExtList[$key]);
// }
// }
// }
// $assign_data['addonFieldExtList'] = $addonFieldExtList;
// $assign_data['aid'] = $id;
/*--end*/
// 阅读权限
$arcrank_list = get_arcrank_list();
$assign_data['arcrank_list'] = $arcrank_list;
/*模板列表*/
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$templateList = $archivesLogic->getTemplateList($this->nid);
$this->assign('templateList', $templateList);
/*--end*/
/*默认模板文件*/
$tempview = $info['tempview'];
empty($tempview) && $tempview = $arctypeInfo['tempview'];
$this->assign('tempview', $tempview);
/*--end*/
// URL模式
$tpcache = config('tpcache');
$assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
$this->assign($assign_data);
return $this->fetch();
}
/**
* 删除
*/
public function del()
{
if (IS_POST) {
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$archivesLogic->del();
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,271 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Page;
use think\Db;
use think\Validate;
class AuthRole extends Base {
public function _initialize() {
parent::_initialize();
$this->language_access(); // 多语言功能操作权限
}
/**
* 权限组管理
*/
public function index()
{
$map = array();
$pid = input('pid/d');
$keywords = input('keywords/s');
if (!empty($keywords)) {
$map['c.name'] = array('LIKE', "%{$keywords}%");
}
$AuthRole = M('auth_role');
$count = $AuthRole->alias('c')->where($map)->count();// 查询满足要求的总记录数
$Page = new Page($count, 10);// 实例化分页类 传入总记录数和每页显示的记录数
$fields = "c.*,s.name AS pname";
$list = DB::name('auth_role')
->field($fields)
->alias('c')
->join('__AUTH_ROLE__ s','s.id = c.pid','LEFT')
->where($map)
->order('c.id asc')
->limit($Page->firstRow.','.$Page->listRows)
->select();
$show = $Page->show();// 分页显示输出
$this->assign('page',$show);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->assign('pager',$Page);// 赋值分页集
return $this->fetch();
}
/**
* 新增权限组
*/
public function add()
{
if (IS_POST) {
$rule = array(
'name' => 'require',
);
$msg = array(
'name.require' => '权限组名称不能为空!',
);
$data = array(
'name' => trim(input('name/s')),
);
$validate = new Validate($rule, $msg);
$result = $validate->check($data);
if(!$result){
$this->error($validate->getError());
}
$model = model('AuthRole');
$count = $model->where('name', $data['name'])->count();
if(! empty($count)){
$this->error('该权限组名称已存在,请检查');
}
$role_id = $model->saveAuthRole(input());
if($role_id){
adminLog('新增权限组:'.$data['name']);
$admin_role_list = model('AuthRole')->getRoleAll();
$this->success('操作成功', url('AuthRole/index'), ['role_id'=>$role_id,'role_name'=>$data['name'],'admin_role_list'=>json_encode($admin_role_list)]);
}else{
$this->error('操作失败');
}
}
// 权限组
$admin_role_list = model('AuthRole')->getRoleAll();
$this->assign('admin_role_list', $admin_role_list);
// 模块组
$modules = getAllMenu();
$this->assign('modules', $modules);
// 权限集
// $singleArr = array_multi2single($modules, 'child'); // 多维数组转为一维
$auth_rules = get_auth_rule(['is_modules'=>1]);
$auth_rule_list = group_same_key($auth_rules, 'menu_id');
foreach ($auth_rule_list as $key => $val) {
if (is_array($val)) {
$sort_order = [];
foreach ($val as $_k => $_v) {
$sort_order[$_k] = $_v['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $val);
$auth_rule_list[$key] = $val;
}
}
$this->assign('auth_rule_list', $auth_rule_list);
// 栏目
$arctype_data = $arctype_array = array();
$arctype = M('arctype')->select();
if(! empty($arctype)){
foreach ($arctype as $item){
if($item['parent_id'] <= 0){
$arctype_data[] = $item;
}
$arctype_array[$item['parent_id']][] = $item;
}
}
$this->assign('arctypes', $arctype_data);
$this->assign('arctype_array', $arctype_array);
// 插件
$plugins = false;
$web_weapp_switch = tpCache('web.web_weapp_switch');
if (1 == $web_weapp_switch) {
$plugins = model('Weapp')->getList(['status'=>1]);
}
$this->assign('plugins', $plugins);
return $this->fetch();
}
public function edit()
{
$id = input('id/d', 0);
if($id <= 0){
$this->error('非法访问');
}
if (IS_POST) {
$rule = array(
'name' => 'require',
);
$msg = array(
'name.require' => '权限组名称不能为空!',
);
$data = array(
'name' => trim(input('name/s')),
);
$validate = new Validate($rule, $msg);
$result = $validate->check($data);
if(!$result){
$this->error($validate->getError());
}
$model = model('AuthRole');
$count = $model->where('name', $data['name'])
->where('id', '<>', $id)
->count();
if(! empty($count)){
$this->error('该权限组名称已存在,请检查');
}
$role_id = $model->saveAuthRole(input(), true);
if($role_id){
adminLog('编辑权限组:'.$data['name']);
$this->success('操作成功', url('AuthRole/index'), ['role_id'=>$role_id,'role_name'=>$data['name']]);
}else{
$this->error('操作失败');
}
}
$model = model('AuthRole');
$info = $model->getRole(array('id' => $id));
if(empty($info)){
$this->error('数据不存在,请联系管理员!');
}
$this->assign('info', $info);
// 权限组
$admin_role_list = model('AuthRole')->getRoleAll();
$this->assign('admin_role_list', $admin_role_list);
// 模块组
$modules = getAllMenu();
$this->assign('modules', $modules);
// 权限集
$auth_rules = get_auth_rule(['is_modules'=>1]);
$auth_rule_list = group_same_key($auth_rules, 'menu_id');
foreach ($auth_rule_list as $key => $val) {
if (is_array($val)) {
$sort_order = [];
foreach ($val as $_k => $_v) {
$sort_order[$_k] = $_v['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $val);
$auth_rule_list[$key] = $val;
}
}
$this->assign('auth_rule_list', $auth_rule_list);
// 栏目
$arctype_data = $arctype_array = array();
$arctype = M('arctype')->select();
if(! empty($arctype)){
foreach ($arctype as $item){
if($item['parent_id'] <= 0){
$arctype_data[] = $item;
}
$arctype_array[$item['parent_id']][] = $item;
}
}
$this->assign('arctypes', $arctype_data);
$this->assign('arctype_array', $arctype_array);
// 插件
$plugins = false;
$web_weapp_switch = tpCache('web.web_weapp_switch');
if (1 == $web_weapp_switch) {
$plugins = model('Weapp')->getList(['status'=>1]);
}
$this->assign('plugins', $plugins);
return $this->fetch();
}
public function del()
{
$id_arr = input('del_id/a');
$id_arr = eyIntval($id_arr);
if (!empty($id_arr)) {
$count = M('auth_role')->where(['built_in'=>1,'id'=>['IN',$id_arr]])->count();
if (!empty($count)) {
$this->error('系统内置不允许删除!');
}
$role = M('auth_role')->where("pid",'IN',$id_arr)->select();
if ($role) {
$this->error('请先清空该权限组下的子权限组');
}
$role_admin = M('admin')->where("role_id",'IN',$id_arr)->select();
if ($role_admin) {
$this->error('请先清空所属该权限组的管理员');
} else {
$r = M('auth_role')->where("id",'IN',$id_arr)->delete();
if($r){
adminLog('删除权限组');
$this->success('删除成功');
}else{
$this->error('删除失败');
}
}
} else {
$this->error('参数有误');
}
}
}

View File

@@ -0,0 +1,167 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use app\admin\logic\UpgradeLogic;
use think\Controller;
use think\Db;
use think\response\Json;
use think\Session;
class Base extends Controller {
public $session_id;
public $php_servicemeal = 0;
/**
* 析构函数
*/
function __construct()
{
if (!session_id()) {
Session::start();
}
header("Cache-control: private"); // history.back返回后输入框值丢失问题
parent::__construct();
$this->global_assign();
}
/*
* 初始化操作
*/
public function _initialize()
{
$this->session_id = session_id(); // 当前的 session_id
!defined('SESSION_ID') && define('SESSION_ID', $this->session_id); //将当前的session_id保存为常量供其它方法调用
parent::_initialize();
/*及时更新cookie中的admin_id用于前台的可视化权限验证*/
// $auth_role_info = model('AuthRole')->getRole(array('id' => session('admin_info.role_id')));
// session('admin_info.auth_role_info', $auth_role_info);
/*--end*/
//过滤不需要登陆的行为
$ctl_act = CONTROLLER_NAME.'@'.ACTION_NAME;
$ctl_all = CONTROLLER_NAME.'@*';
$filter_login_action = config('filter_login_action');
if (in_array($ctl_act, $filter_login_action) || in_array($ctl_all, $filter_login_action)) {
//return;
}else{
$web_login_expiretime = tpCache('web.web_login_expiretime');
empty($web_login_expiretime) && $web_login_expiretime = config('login_expire');
$admin_login_expire = session('admin_login_expire'); // 登录有效期web_login_expiretime
if (session('?admin_id') && getTime() - intval($admin_login_expire) < $web_login_expiretime) {
session('admin_login_expire', getTime()); // 登录有效期
$this->check_priv();//检查管理员菜单操作权限
}else{
/*自动退出*/
adminLog('访问后台');
session_unset();
session::clear();
cookie('admin-treeClicked', null); // 清除并恢复栏目列表的展开方式
/*--end*/
if (IS_AJAX) {
$this->error('登录超时!');
} else {
$url = request()->baseFile().'?s=Admin/login';
$this->redirect($url);
}
}
}
/* 增、改的跳转提示页,只限制于发布文档的模型和自定义模型 */
$channeltype_list = config('global.channeltype_list');
$controller_name = $this->request->controller();
$this->assign('controller_name', $controller_name);
if (isset($channeltype_list[strtolower($controller_name)]) || 'Custom' == $controller_name) {
if (in_array($this->request->action(), ['add','edit'])) {
\think\Config::set('dispatch_success_tmpl', 'public/dispatch_jump');
$id = input('param.id/d', input('param.aid/d'));
('GET' == $this->request->method()) && cookie('ENV_IS_UPHTML', 0);
} else if (in_array($this->request->action(), ['index'])) {
cookie('ENV_GOBACK_URL', $this->request->url());
cookie('ENV_LIST_URL', request()->baseFile()."?m=admin&c={$controller_name}&a=index&lang=".$this->admin_lang);
}
}
if ('Archives' == $controller_name && in_array($this->request->action(), ['index_archives'])) {
cookie('ENV_GOBACK_URL', $this->request->url());
cookie('ENV_LIST_URL', request()->baseFile()."?m=admin&c=Archives&a=index_archives&lang=".$this->admin_lang);
}
/* end */
}
public function check_priv()
{
$ctl = CONTROLLER_NAME;
$act = ACTION_NAME;
$ctl_act = $ctl.'@'.$act;
$ctl_all = $ctl.'@*';
//无需验证的操作
$uneed_check_action = config('uneed_check_action');
if (0 >= intval(session('admin_info.role_id'))) {
//超级管理员无需验证
return true;
} else {
$bool = false;
/*检测是否有该权限*/
if (is_check_access($ctl_act)) {
$bool = true;
}
/*--end*/
/*在列表中的操作不需要验证权限*/
if (IS_AJAX || strpos($act,'ajax') !== false || in_array($ctl_act, $uneed_check_action) || in_array($ctl_all, $uneed_check_action)) {
$bool = true;
}
/*--end*/
//检查是否拥有此操作权限
if (!$bool) {
$this->error('您没有操作权限,请联系超级管理员分配权限');
}
}
}
/**
* 保存系统设置
*/
public function global_assign()
{
/*随时更新每页记录数*/
$pagesize = input('get.pagesize/d');
if (!empty($pagesize)) {
$system_paginate_pagesize = config('tpcache.system_paginate_pagesize');
if ($pagesize != intval($system_paginate_pagesize)) {
tpCache('system', ['system_paginate_pagesize'=>$pagesize]);
}
}
/*end*/
$globalConf = tpCache('global');
$this->php_servicemeal = $globalConf['php_servicemeal'];
$this->assign('global', $globalConf);
}
/**
* 多语言功能操作权限
*/
public function language_access()
{
if (is_language() && $this->main_lang != $this->admin_lang) {
$lang_title = model('Language')->where('mark',$this->main_lang)->value('title');
$this->error('当前语言没有此功能,请切换到【'.$lang_title.'】语言');
}
}
}

View File

@@ -0,0 +1,275 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Page;
use think\Db;
class Case extends Base
{
private $ad_position_system_id = array(); // 系统默认位置ID不可删除
public function _initialize() {
parent::_initialize();
}
public function index()
{
$list = array();
$get = input('get.');
$keywords = input('keywords/s');
$condition = [];
// 应用搜索条件
foreach (['keywords', 'type'] as $key) {
if (isset($get[$key]) && $get[$key] !== '') {
if ($key == 'keywords') {
$condition['a.title'] = array('LIKE', "%{$get[$key]}%");
} else {
$tmp_key = 'a.'.$key;
$condition[$tmp_key] = array('eq', $get[$key]);
}
}
}
// 多语言
// $condition['a.lang'] = array('eq', $this->admin_lang);
$adPositionM = M('platform');
$count = $adPositionM->alias('a')->where($condition)->count();// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = $adPositionM->alias('a')->where($condition)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->getAllWithIndex('id');
// 每组获取三张图片
$pids = get_arr_column($list, 'id');
$ad = M('ad')->where(['pid' => ['IN', $pids], 'lang' => $this->admin_lang])->order('pid asc, id asc')->select();
foreach ($list as $k => $v) {
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']); // 支持子目录
$list[$k] = $v;
}
$show = $Page->show();// 分页显示输出
$this->assign('page',$show);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->assign('pager',$Page);// 赋值分页对象
return $this->fetch();
}
/**
* 新增
*/
public function add()
{
//防止php超时
function_exists('set_time_limit') && set_time_limit(0);
$this->language_access(); // 多语言功能操作权限
if (IS_POST) {
$post = input('post.');
// 添加广告位置表信息
$data = array(
'title' => trim($post['title']),
'desc' => $post['intro'],
'logo'=>$post['img_litpic'][0],
// 'intro' => $post['intro'],
'admin_id' => session('admin_id'),
// 'lang' => $this->admin_lang,
'createtime' => getTime(),
);
$insertID = M('platform')->insertGetId($data);
if (!empty($insertID)) {
adminLog('新增平台:'.$post['title']);
$this->success("操作成功", url('platform/index'));
} else {
$this->error("操作失败", url('platform/index'));
}
}
// 上传通道
$WeappConfig = Db::name('weapp')->field('code, status')->where('code', 'IN', ['Qiniuyun', 'AliyunOss', 'Cos'])->select();
$WeappOpen = [];
foreach ($WeappConfig as $value) {
if ('Qiniuyun' == $value['code']) {
$WeappOpen['qny_open'] = $value['status'];
} else if ('AliyunOss' == $value['code']) {
$WeappOpen['oss_open'] = $value['status'];
} else if ('Cos' == $value['code']) {
$WeappOpen['cos_open'] = $value['status'];
}
}
$this->assign('WeappOpen', $WeappOpen);
// 系统最大上传视频的大小
$upload_max_filesize = upload_max_filesize();
$this->assign('upload_max_filesize', $upload_max_filesize);
// 视频类型
$media_type = tpCache('basic.media_type');
$media_type = !empty($media_type) ? $media_type : config('global.media_ext');
$media_type = str_replace(",", "|", $media_type);
$this->assign('media_type', $media_type);
return $this->fetch();
}
/**
* 编辑
*/
public function edit()
{
if (IS_POST) {
$post = input('post.');
if (!empty($post['id'])) {
// if (array_key_exists($post['id'], $this->ad_position_system_id)) {
// $this->error("不可更改系统预定义位置", url('Platform/edit',array('id'=>$post['id'])));
// }
$data = array(
'id' => $post['id'],
'desc' => $post['intro'],
'logo'=>$post['img_litpic'][0],
'createtime' => getTime(),
);
$resultID = Db::name('platform')->update($data);
/* END */
}
if (!empty($resultID)) {
adminLog('编辑广告:'.$post['title']);
$this->success("操作成功", url('Platform/index'));
} else {
$this->error("操作失败");
}
}
$assign_data = array();
$id = input('id/d');
$field = M('platform')->field('a.*')->alias('a')->where(array('a.id'=>$id))->find();
if (empty($field)) $this->error('广告不存在,请联系管理员!');
$assign_data['field'] = $field;
/*
// 广告
$ad_data = Db::name('ad')->where(array('pid'=>$field['id']))->order('sort_order asc')->select();
foreach ($ad_data as $key => $val) {
if (1 == $val['type']) {
$ad_data[$key]['litpic'] = get_default_pic($val['litpic']); // 支持子目录
}
}
$assign_data['ad_data'] = $ad_data;
// 上传通道
$WeappConfig = Db::name('weapp')->field('code, status')->where('code', 'IN', ['Qiniuyun', 'AliyunOss', 'Cos'])->select();
$WeappOpen = [];
foreach ($WeappConfig as $value) {
if ('Qiniuyun' == $value['code']) {
$WeappOpen['qny_open'] = $value['status'];
} else if ('AliyunOss' == $value['code']) {
$WeappOpen['oss_open'] = $value['status'];
} else if ('Cos' == $value['code']) {
$WeappOpen['cos_open'] = $value['status'];
}
}
$this->assign('WeappOpen', $WeappOpen);
// 系统最大上传视频的大小
$file_size = tpCache('basic.file_size');
$postsize = @ini_get('file_uploads') ? ini_get('post_max_size') : -1;
$fileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : -1;
$min_size = strval($file_size) < strval($postsize) ? $file_size : $postsize;
$min_size = strval($min_size) < strval($fileupload) ? $min_size : $fileupload;
$upload_max_filesize = intval($min_size) * 1024 * 1024;
$assign_data['upload_max_filesize'] = $upload_max_filesize;
// 视频类型
$media_type = tpCache('basic.media_type');
$media_type = !empty($media_type) ? $media_type : config('global.media_ext');
$media_type = str_replace(",", "|", $media_type);
$assign_data['media_type'] = $media_type;*/
$this->assign($assign_data);
return $this->fetch();
}
/**
* 删除广告图片
*/
public function del_imgupload()
{
$this->language_access(); // 多语言功能操作权限
$id_arr = input('del_id/a');
$id_arr = eyIntval($id_arr);
if(IS_POST && !empty($id_arr)){
/*多语言*/
$attr_name_arr = [];
foreach ($id_arr as $key => $val) {
$attr_name_arr[] = 'ad'.$val;
}
if (is_language()) {
$new_id_arr = Db::name('language_attr')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad',
])->column('attr_value');
!empty($new_id_arr) && $id_arr = $new_id_arr;
}
/*--end*/
$r = Db::name('ad')->where([
'id' => ['IN', $id_arr],
])
->cache(true,null,'ad')
->delete();
if ($r) {
/*多语言*/
if (!empty($attr_name_arr)) {
Db::name('language_attr')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad',
])->delete();
Db::name('language_attribute')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad',
])->delete();
}
/*--end*/
adminLog('删除广告-id'.implode(',', $id_arr));
}
}
}
/**
* 删除
*/
public function del()
{
$this->language_access(); // 多语言功能操作权限
$id_arr = input('del_id/a');
$id_arr = eyIntval($id_arr);
if(IS_POST && !empty($id_arr)){
$r = M('platform')->where('id','IN',$id_arr)->delete();
if ($r) {
adminLog('删除广告-id'.implode(',', $id_arr));
$this->success('删除成功');
} else {
$this->error('删除失败');
}
}else{
$this->error('参数有误');
}
}
}

View File

@@ -0,0 +1,273 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Page;
use think\Db;
class Casevideo extends Base
{
private $ad_position_system_id = array(); // 系统默认位置ID不可删除
public function _initialize() {
parent::_initialize();
}
public function index()
{
$list = array();
$get = input('get.');
$keywords = input('keywords/s');
$condition = [];
// 应用搜索条件
foreach (['keywords', 'type'] as $key) {
if (isset($get[$key]) && $get[$key] !== '') {
if ($key == 'keywords') {
$condition['a.title'] = array('LIKE', "%{$get[$key]}%");
} else {
$tmp_key = 'a.'.$key;
$condition[$tmp_key] = array('eq', $get[$key]);
}
}
}
// 多语言
// $condition['a.lang'] = array('eq', $this->admin_lang);
$adPositionM = M('casevideo');
$count = $adPositionM->alias('a')->where($condition)->count();// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = $adPositionM->alias('a')->where($condition)->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->getAllWithIndex('id');
// 每组获取三张图片
$pids = get_arr_column($list, 'id');
$ad = M('ad')->where(['pid' => ['IN', $pids], 'lang' => $this->admin_lang])->order('pid asc, id asc')->select();
foreach ($list as $k => $v) {
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']); // 支持子目录
$v['litpic'] = ROOT_DIR . '/public/static/admin/images/ad_type_media.png';
$list[$k] = $v;
}
$show = $Page->show();// 分页显示输出
$this->assign('page',$show);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->assign('pager',$Page);// 赋值分页对象
return $this->fetch();
}
/**
* 新增
*/
public function add()
{
//防止php超时
function_exists('set_time_limit') && set_time_limit(0);
$this->language_access(); // 多语言功能操作权限
if (IS_POST) {
$post = input('post.');
// 添加广告位置表信息
$data = array(
'title' => trim($post['title']),
'video'=>$post['video_litpic'],
'admin_id' => session('admin_id'),
'createtime' => getTime(),
);
$insertID = M('casevideo')->insertGetId($data);
if (!empty($insertID)) {
adminLog('新增平台:'.$post['title']);
$this->success("操作成功", url('casevideo/index'));
} else {
$this->error("操作失败", url('casevideo/index'));
}
}
// 上传通道
$WeappConfig = Db::name('weapp')->field('code, status')->where('code', 'IN', ['Qiniuyun', 'AliyunOss', 'Cos'])->select();
$WeappOpen = [];
foreach ($WeappConfig as $value) {
if ('Qiniuyun' == $value['code']) {
$WeappOpen['qny_open'] = $value['status'];
} else if ('AliyunOss' == $value['code']) {
$WeappOpen['oss_open'] = $value['status'];
} else if ('Cos' == $value['code']) {
$WeappOpen['cos_open'] = $value['status'];
}
}
$this->assign('WeappOpen', $WeappOpen);
// 系统最大上传视频的大小
$upload_max_filesize = upload_max_filesize();
$this->assign('upload_max_filesize', $upload_max_filesize);
// 视频类型
$media_type = tpCache('basic.media_type');
$media_type = !empty($media_type) ? $media_type : config('global.media_ext');
$media_type = str_replace(",", "|", $media_type);
$this->assign('media_type', $media_type);
return $this->fetch();
}
/**
* 编辑
*/
public function edit()
{
if (IS_POST) {
$post = input('post.');
if (!empty($post['id'])) {
// if (array_key_exists($post['id'], $this->ad_position_system_id)) {
// $this->error("不可更改系统预定义位置", url('Platform/edit',array('id'=>$post['id'])));
// }
$data = array(
'id' => $post['id'],
'title' => trim($post['title']),
'video'=>$post['video_litpic'],
'createtime' => getTime(),
);
$resultID = Db::name('casevideo')->update($data);
/* END */
}
if (!empty($resultID)) {
adminLog('编辑广告:'.$post['title']);
$this->success("操作成功", url('casevideo/index'));
} else {
$this->error("操作失败");
}
}
$assign_data = array();
$id = input('id/d');
$field = M('casevideo')->field('a.*')->alias('a')->where(array('a.id'=>$id))->find();
if (empty($field)) $this->error('广告不存在,请联系管理员!');
$assign_data['field'] = $field;
/*
// 广告
$ad_data = Db::name('ad')->where(array('pid'=>$field['id']))->order('sort_order asc')->select();
foreach ($ad_data as $key => $val) {
if (1 == $val['type']) {
$ad_data[$key]['litpic'] = get_default_pic($val['litpic']); // 支持子目录
}
}
$assign_data['ad_data'] = $ad_data;*/
// 上传通道
$WeappConfig = Db::name('weapp')->field('code, status')->where('code', 'IN', ['Qiniuyun', 'AliyunOss', 'Cos'])->select();
$WeappOpen = [];
foreach ($WeappConfig as $value) {
if ('Qiniuyun' == $value['code']) {
$WeappOpen['qny_open'] = $value['status'];
} else if ('AliyunOss' == $value['code']) {
$WeappOpen['oss_open'] = $value['status'];
} else if ('Cos' == $value['code']) {
$WeappOpen['cos_open'] = $value['status'];
}
}
$this->assign('WeappOpen', $WeappOpen);
// 系统最大上传视频的大小
$file_size = tpCache('basic.file_size');
$postsize = @ini_get('file_uploads') ? ini_get('post_max_size') : -1;
$fileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : -1;
$min_size = strval($file_size) < strval($postsize) ? $file_size : $postsize;
$min_size = strval($min_size) < strval($fileupload) ? $min_size : $fileupload;
$upload_max_filesize = intval($min_size) * 1024 * 1024;
$assign_data['upload_max_filesize'] = $upload_max_filesize;
// 视频类型
$media_type = tpCache('basic.media_type');
$media_type = !empty($media_type) ? $media_type : config('global.media_ext');
$media_type = str_replace(",", "|", $media_type);
$assign_data['media_type'] = $media_type;
$this->assign($assign_data);
return $this->fetch();
}
/**
* 删除广告图片
*/
public function del_imgupload()
{
$this->language_access(); // 多语言功能操作权限
$id_arr = input('del_id/a');
$id_arr = eyIntval($id_arr);
if(IS_POST && !empty($id_arr)){
/*多语言*/
$attr_name_arr = [];
foreach ($id_arr as $key => $val) {
$attr_name_arr[] = 'ad'.$val;
}
if (is_language()) {
$new_id_arr = Db::name('language_attr')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad',
])->column('attr_value');
!empty($new_id_arr) && $id_arr = $new_id_arr;
}
/*--end*/
$r = Db::name('ad')->where([
'id' => ['IN', $id_arr],
])
->cache(true,null,'ad')
->delete();
if ($r) {
/*多语言*/
if (!empty($attr_name_arr)) {
Db::name('language_attr')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad',
])->delete();
Db::name('language_attribute')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'ad',
])->delete();
}
/*--end*/
adminLog('删除广告-id'.implode(',', $id_arr));
}
}
}
/**
* 删除
*/
public function del()
{
$this->language_access(); // 多语言功能操作权限
$id_arr = input('del_id/a');
$id_arr = eyIntval($id_arr);
if(IS_POST && !empty($id_arr)){
$r = M('casevideo')->where('id','IN',$id_arr)->delete();
if ($r) {
adminLog('删除广告-id'.implode(',', $id_arr));
$this->success('删除成功');
} else {
$this->error('删除1失败');
}
}else{
$this->error('参数有误');
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,678 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 陈风任 <491085389@qq.com>
* Date: 2019-1-7
*/
namespace app\admin\controller;
use think\Page;
use think\Db;
class Custom extends Base
{
// 模型标识
public $nid = '';
// 模型ID
public $channeltype = 0;
// 模型附加表
public $table = '';
/*
* 初始化操作
*/
public function _initialize()
{
parent::_initialize();
$this->archives_db = Db::name('archives');
$this->channeltype = input('param.channel/d', 0);
$channeltypeRow = Db::name('channeltype')->field('nid,table')->where(['id'=>['eq',$this->channeltype]])->find();
if (empty($this->channeltype) || empty($channeltypeRow)) {
$this->error('自定义模型ID丢失打开失败');
}
$this->nid = $channeltypeRow['nid'];
$this->assign('nid', $this->nid);
$this->assign('channeltype', $this->channeltype);
}
/**
* 列表
*/
public function index()
{
$assign_data = array();
$condition = array();
// 获取到所有GET参数
$param = input('param.');
$flag = input('flag/s');
$typeid = input('typeid/d', 0);
$begin = strtotime(input('add_time_begin'));
$end = strtotime(input('add_time_end'));
// 应用搜索条件
foreach (['keywords','typeid','flag','is_release'] as $key) {
if (isset($param[$key]) && $param[$key] !== '') {
if ($key == 'keywords') {
$condition['a.title'] = array('LIKE', "%{$param[$key]}%");
} else if ($key == 'typeid') {
$typeid = $param[$key];
$hasRow = model('Arctype')->getHasChildren($typeid);
$typeids = get_arr_column($hasRow, 'id');
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
if(! empty($auth_role_info['permission']['arctype'])){
if (!empty($typeid)) {
$typeids = array_intersect($typeids, $auth_role_info['permission']['arctype']);
}
}
}
}
/*--end*/
$condition['a.typeid'] = array('IN', $typeids);
} else if ($key == 'flag') {
if ('is_release' == $param[$key]) {
$condition['a.users_id'] = array('gt', 0);
} else {
$condition['a.'.$param[$key]] = array('eq', 1);
}
// } else if ($key == 'is_release') {
// if (0 < intval($param[$key])) {
// $condition['a.users_id'] = array('gt', intval($param[$key]));
// }
} else {
$condition['a.'.$key] = array('eq', $param[$key]);
}
}
}
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
if(isset($auth_role_info['only_oneself']) && 1 == $auth_role_info['only_oneself']){
$condition['a.admin_id'] = $admin_info['admin_id'];
}
}
}
/*--end*/
// 时间检索
if ($begin > 0 && $end > 0) {
$condition['a.add_time'] = array('between',"$begin,$end");
} else if ($begin > 0) {
$condition['a.add_time'] = array('egt', $begin);
} else if ($end > 0) {
$condition['a.add_time'] = array('elt', $end);
}
// 模型ID
$condition['a.channel'] = array('eq', $this->channeltype);
// 多语言
$condition['a.lang'] = array('eq', $this->admin_lang);
// 回收站
$condition['a.is_del'] = array('eq', 0);
/*自定义排序*/
$orderby = input('param.orderby/s');
$orderway = input('param.orderway/s');
if (!empty($orderby)) {
$orderby = "a.{$orderby} {$orderway}";
$orderby .= ", a.aid desc";
} else {
$orderby = "a.aid desc";
}
/*end*/
/**
* 数据查询搜索出主键ID的值
*/
$count = $this->archives_db->alias('a')->where($condition)->count('aid');// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = $this->archives_db
->field("a.aid")
->alias('a')
->where($condition)
->order($orderby)
->limit($Page->firstRow.','.$Page->listRows)
->getAllWithIndex('aid');
/**
* 完善数据集信息
* 在数据量大的情况下经过优化的搜索逻辑先搜索出主键ID再通过ID将其他信息补充完整
*/
if ($list) {
$aids = array_keys($list);
$fields = "b.*, a.*, a.aid as aid";
$row = $this->archives_db
->field($fields)
->alias('a')
->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
->where('a.aid', 'in', $aids)
->getAllWithIndex('aid');
foreach ($list as $key => $val) {
$row[$val['aid']]['arcurl'] = get_arcurl($row[$val['aid']]);
$row[$val['aid']]['litpic'] = handle_subdir_pic($row[$val['aid']]['litpic']); // 支持子目录
$list[$key] = $row[$val['aid']];
}
}
$show = $Page->show(); // 分页显示输出
$assign_data['page'] = $show; // 赋值分页输出
$assign_data['list'] = $list; // 赋值数据集
$assign_data['pager'] = $Page; // 赋值分页对象
// 栏目ID
$assign_data['typeid'] = $typeid; // 栏目ID
/*当前栏目信息*/
$arctype_info = array();
if ($typeid > 0) {
$arctype_info = M('arctype')->field('typename')->find($typeid);
}
$assign_data['arctype_info'] = $arctype_info;
/*--end*/
/*选项卡*/
$tab = input('param.tab/d', 3);
$assign_data['tab'] = $tab;
/*--end*/
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
$this->assign($assign_data);
return $this->fetch();
}
/**
* 添加
*/
public function add()
{
$admin_info = session('admin_info');
$auth_role_info = $admin_info['auth_role_info'];
$this->assign('auth_role_info', $auth_role_info);
$this->assign('admin_info', $admin_info);
if (IS_POST) {
$post = input('post.');
/* 处理TAG标签 */
if (!empty($post['tags_new'])) {
$post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
unset($post['tags_new']);
}
$post['tags'] = explode(',', $post['tags']);
$post['tags'] = array_unique($post['tags']);
$post['tags'] = implode(',', $post['tags']);
/* END */
/*获取第一个html类型的内容作为文档的内容来截取SEO描述*/
$contentField = Db::name('channelfield')->where([
'channel_id' => $this->channeltype,
'dtype' => 'htmltext',
])->getField('name');
$content = input('post.addonFieldExt.'.$contentField, '', null);
/*--end*/
// 根据标题自动提取相关的关键字
$seo_keywords = $post['seo_keywords'];
if (!empty($seo_keywords)) {
$seo_keywords = str_replace('', ',', $seo_keywords);
} else {
// $seo_keywords = get_split_word($post['title'], $content);
}
// 自动获取内容第一张图片作为封面图
$is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
$litpic = '';
if ($is_remote == 1) {
$litpic = $post['litpic_remote'];
} else {
$litpic = $post['litpic_local'];
}
if (empty($litpic)) {
$litpic = get_html_first_imgurl($content);
}
$post['litpic'] = $litpic;
/*是否有封面图*/
if (empty($post['litpic'])) {
$is_litpic = 0; // 无封面图
} else {
$is_litpic = 1; // 有封面图
}
// SEO描述
$seo_description = '';
if (empty($post['seo_description']) && !empty($content)) {
$seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
} else {
$seo_description = $post['seo_description'];
}
// 外部链接跳转
$jumplinks = '';
$is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
if (intval($is_jump) > 0) {
$jumplinks = $post['jumplinks'];
}
// 模板文件,如果文档模板名与栏目指定的一致,默认就为空。让它跟随栏目的指定而变
if ($post['type_tempview'] == $post['tempview']) {
unset($post['type_tempview']);
unset($post['tempview']);
}
//处理自定义文件名,仅由字母数字下划线和短横杆组成,大写强制转换为小写
$htmlfilename = trim($post['htmlfilename']);
if (!empty($htmlfilename)) {
$htmlfilename = preg_replace("/[^a-zA-Z0-9_-]+/", "-", $htmlfilename);
$htmlfilename = strtolower($htmlfilename);
//判断是否存在相同的自定义文件名
$filenameCount = Db::name('archives')->where([
'htmlfilename' => $htmlfilename,
'lang' => $this->admin_lang,
])->count();
if (!empty($filenameCount)) {
$this->error("自定义文件名已存在,请重新设置!");
}
}
$post['htmlfilename'] = $htmlfilename;
//做自动通过审核判断
if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
$post['arcrank'] = -1;
}
// --存储数据
$newData = array(
'typeid'=> empty($post['typeid']) ? 0 : $post['typeid'],
'channel' => $this->channeltype,
'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
'is_jump' => $is_jump,
'is_litpic' => $is_litpic,
'jumplinks' => $jumplinks,
'seo_keywords' => $seo_keywords,
'seo_description' => $seo_description,
'admin_id' => session('admin_info.admin_id'),
'lang' => $this->admin_lang,
'sort_order' => 100,
'add_time' => strtotime($post['add_time']),
'update_time' => strtotime($post['add_time']),
);
$data = array_merge($post, $newData);
$aid = $this->archives_db->insertGetId($data);
$_POST['aid'] = $aid;
if ($aid) {
// ---------后置操作
model('Custom')->afterSave($aid, $data, 'add');
// ---------end
adminLog('新增数据:'.$data['title']);
// 生成静态页面代码
$successData = [
'aid' => $aid,
'tid' => $post['typeid'],
];
$this->success("操作成功!", null, $successData);
exit;
}
$this->error("操作失败!");
exit;
}
$typeid = input('param.typeid/d', 0);
$assign_data['typeid'] = $typeid; // 栏目ID
// 栏目信息
$arctypeInfo = Db::name('arctype')->find($typeid);
/*允许发布文档列表的栏目*/
$arctype_html = allow_release_arctype($typeid, array($this->channeltype));
$assign_data['arctype_html'] = $arctype_html;
/*--end*/
/*自定义字段*/
// $addonFieldExtList = model('Field')->getChannelFieldList($this->channeltype);
// $channelfieldBindRow = Db::name('channelfield_bind')->where([
// 'typeid' => ['IN', [0,$typeid]],
// ])->column('field_id');
// if (!empty($channelfieldBindRow)) {
// foreach ($addonFieldExtList as $key => $val) {
// if (!in_array($val['id'], $channelfieldBindRow)) {
// unset($addonFieldExtList[$key]);
// }
// }
// }
// $assign_data['addonFieldExtList'] = $addonFieldExtList;
// $assign_data['aid'] = 0;
/*--end*/
// 阅读权限
$arcrank_list = get_arcrank_list();
$assign_data['arcrank_list'] = $arcrank_list;
/*获取可显示的系统字段*/
$condition['ifcontrol'] = 0;
$condition['channel_id'] = $this->channeltype;
$channelfield_row = Db::name('channelfield')->where($condition)->field('name,ifeditable')->getAllWithIndex('name');
$assign_data['channelfield_row'] = $channelfield_row;
/*--end*/
/*模板列表*/
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$templateList = $archivesLogic->getTemplateList($this->nid);
$this->assign('templateList', $templateList);
/*--end*/
/*默认模板文件*/
$tempview = 'view_'.$this->nid.'.'.config('template.view_suffix');
!empty($arctypeInfo['tempview']) && $tempview = $arctypeInfo['tempview'];
$this->assign('tempview', $tempview);
/*--end*/
// 文档默认浏览量
$other_config = tpCache('other');
if (isset($other_config['other_arcclick']) && 0 <= $other_config['other_arcclick']) {
$arcclick_arr = explode("|", $other_config['other_arcclick']);
if (count($arcclick_arr) > 1) {
$assign_data['rand_arcclick'] = mt_rand($arcclick_arr[0], $arcclick_arr[1]);
} else {
$assign_data['rand_arcclick'] = intval($arcclick_arr[0]);
}
}else{
$arcclick_config['other_arcclick'] = '500|1000';
tpCache('other', $arcclick_config);
$assign_data['rand_arcclick'] = mt_rand(500, 1000);
}
// URL模式
$tpcache = config('tpcache');
$assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
$this->assign($assign_data);
return $this->fetch();
}
/**
* 编辑
*/
public function edit()
{
$admin_info = session('admin_info');
$auth_role_info = $admin_info['auth_role_info'];
$this->assign('auth_role_info', $auth_role_info);
$this->assign('admin_info', $admin_info);
if (IS_POST) {
$post = input('post.');
$typeid = input('post.typeid/d', 0);
/* 处理TAG标签 */
if (!empty($post['tags_new'])) {
$post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
unset($post['tags_new']);
}
$post['tags'] = explode(',', $post['tags']);
$post['tags'] = array_unique($post['tags']);
$post['tags'] = implode(',', $post['tags']);
/* END */
/*获取第一个html类型的内容作为文档的内容来截取SEO描述*/
$contentField = Db::name('channelfield')->where([
'channel_id' => $this->channeltype,
'dtype' => 'htmltext',
])->getField('name');
$content = input('post.addonFieldExt.'.$contentField, '', null);
/*--end*/
// 根据标题自动提取相关的关键字
$seo_keywords = $post['seo_keywords'];
if (!empty($seo_keywords)) {
$seo_keywords = str_replace('', ',', $seo_keywords);
} else {
// $seo_keywords = get_split_word($post['title'], $content);
}
// 自动获取内容第一张图片作为封面图
$is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
$litpic = '';
if ($is_remote == 1) {
$litpic = $post['litpic_remote'];
} else {
$litpic = $post['litpic_local'];
}
if (empty($litpic)) {
$litpic = get_html_first_imgurl($content);
}
$post['litpic'] = $litpic;
/*是否有封面图*/
if (empty($post['litpic'])) {
$is_litpic = 0; // 无封面图
} else {
$is_litpic = !empty($post['is_litpic']) ? $post['is_litpic'] : 0; // 有封面图
}
// SEO描述
$seo_description = '';
if (empty($post['seo_description']) && !empty($content)) {
$seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
} else {
$seo_description = $post['seo_description'];
}
// --外部链接
$jumplinks = '';
$is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
if (intval($is_jump) > 0) {
$jumplinks = $post['jumplinks'];
}
// 模板文件,如果文档模板名与栏目指定的一致,默认就为空。让它跟随栏目的指定而变
if ($post['type_tempview'] == $post['tempview']) {
unset($post['type_tempview']);
unset($post['tempview']);
}
// 同步栏目切换模型之后的文档模型
$channel = Db::name('arctype')->where(['id'=>$typeid])->getField('current_channel');
//做未通过审核文档不允许修改文档状态操作
if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
$old_archives_arcrank = Db::name('archives')->where(['aid' => $post['aid']])->getField("arcrank");
if ($old_archives_arcrank < 0) {
unset($post['arcrank']);
}
}
//处理自定义文件名,仅由字母数字下划线和短横杆组成,大写强制转换为小写
$htmlfilename = trim($post['htmlfilename']);
if (!empty($htmlfilename)) {
$htmlfilename = preg_replace("/[^a-zA-Z0-9_-]+/", "-", $htmlfilename);
$htmlfilename = strtolower($htmlfilename);
//判断是否存在相同的自定义文件名
$filenameCount = Db::name('archives')->where([
'aid' => ['NEQ', $post['aid']],
'htmlfilename' => $htmlfilename,
'lang' => $this->admin_lang,
])->count();
if (!empty($filenameCount)) {
$this->error("自定义文件名已存在,请重新设置!");
}
}
$post['htmlfilename'] = $htmlfilename;
// --存储数据
$newData = array(
'typeid'=> $typeid,
'channel' => $channel,
'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
'is_jump' => $is_jump,
'is_litpic' => $is_litpic,
'jumplinks' => $jumplinks,
'seo_keywords' => $seo_keywords,
'seo_description' => $seo_description,
'add_time' => strtotime($post['add_time']),
'update_time' => getTime(),
);
$data = array_merge($post, $newData);
$r = M('archives')->where([
'aid' => $data['aid'],
'lang' => $this->admin_lang,
])->update($data);
if ($r) {
// ---------后置操作
model('Custom')->afterSave($data['aid'], $data, 'edit');
// ---------end
adminLog('编辑文章:'.$data['title']);
// 生成静态页面代码
$successData = [
'aid' => $data['aid'],
'tid' => $typeid,
];
$this->success("操作成功!", null, $successData);
exit;
}
$this->error("操作失败!");
exit;
}
$assign_data = array();
$id = input('id/d');
$info = model('Custom')->getInfo($id, null, false);
if (empty($info)) {
$this->error('数据不存在,请联系管理员!');
exit;
}
/*兼容采集没有归属栏目的文档*/
if (empty($info['channel'])) {
$channelRow = Db::name('channeltype')->field('id as channel')
->where('id',$this->channeltype)
->find();
$info = array_merge($info, $channelRow);
}
/*--end*/
$typeid = $info['typeid'];
$assign_data['typeid'] = $typeid;
// 栏目信息
$arctypeInfo = Db::name('arctype')->find($typeid);
$info['channel'] = $arctypeInfo['current_channel'];
if (is_http_url($info['litpic'])) {
$info['is_remote'] = 1;
$info['litpic_remote'] = handle_subdir_pic($info['litpic']);
} else {
$info['is_remote'] = 0;
$info['litpic_local'] = handle_subdir_pic($info['litpic']);
}
// SEO描述
if (!empty($info['seo_description'])) {
$info['seo_description'] = @msubstr(checkStrHtml($info['seo_description']), 0, config('global.arc_seo_description_length'), false);
}
$assign_data['field'] = $info;
/*允许发布文档列表的栏目,文档所在模型以栏目所在模型为主,兼容切换模型之后的数据编辑*/
$arctype_html = allow_release_arctype($typeid, array($info['channel']));
$assign_data['arctype_html'] = $arctype_html;
/*--end*/
/*自定义字段*/
// $addonFieldExtList = model('Field')->getChannelFieldList($info['channel'], 0, $id, $info);
// $channelfieldBindRow = Db::name('channelfield_bind')->where([
// 'typeid' => ['IN', [0,$typeid]],
// ])->column('field_id');
// if (!empty($channelfieldBindRow)) {
// foreach ($addonFieldExtList as $key => $val) {
// if (!in_array($val['id'], $channelfieldBindRow)) {
// unset($addonFieldExtList[$key]);
// }
// }
// }
// $assign_data['addonFieldExtList'] = $addonFieldExtList;
// $assign_data['aid'] = $id;
/*--end*/
/*获取可显示的系统字段*/
$condition['ifcontrol'] = 0;
$condition['channel_id'] = $this->channeltype;
$channelfield_row = Db::name('channelfield')->where($condition)->field('name,ifeditable')->getAllWithIndex('name');
$assign_data['channelfield_row'] = $channelfield_row;
/*--end*/
// 阅读权限
$arcrank_list = get_arcrank_list();
$assign_data['arcrank_list'] = $arcrank_list;
/*模板列表*/
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$templateList = $archivesLogic->getTemplateList($this->nid);
$this->assign('templateList', $templateList);
/*--end*/
/*默认模板文件*/
$tempview = $info['tempview'];
empty($tempview) && $tempview = $arctypeInfo['tempview'];
$this->assign('tempview', $tempview);
/*--end*/
// URL模式
$tpcache = config('tpcache');
$assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
$this->assign($assign_data);
return $this->fetch();
}
/**
* 删除
*/
public function del()
{
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$archivesLogic->del();
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Db;
use think\Page;
/**
* 用户自定义扩展php文件
*/
class DiyExtend extends Base {
public function _initialize() {
parent::_initialize();
}
}

View File

@@ -0,0 +1,930 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Page;
use think\Db;
class Download extends Base
{
// 模型标识
public $nid = 'download';
// 模型ID
public $channeltype = '';
public function _initialize()
{
parent::_initialize();
$channeltype_list = config('global.channeltype_list');
$this->channeltype = $channeltype_list[$this->nid];
empty($this->channeltype) && $this->channeltype = 4;
$this->assign('nid', $this->nid);
$this->assign('channeltype', $this->channeltype);
}
/**
* 列表
*/
public function index()
{
$assign_data = array();
$condition = array();
// 获取到所有GET参数
$param = input('param.');
$flag = input('flag/s');
$typeid = input('typeid/d', 0);
$begin = strtotime(input('add_time_begin'));
$end = strtotime(input('add_time_end'));
// 应用搜索条件
foreach (['keywords','typeid','flag','is_release'] as $key) {
if (isset($param[$key]) && $param[$key] !== '') {
if ($key == 'keywords') {
$condition['a.title'] = array('LIKE', "%{$param[$key]}%");
} else if ($key == 'typeid') {
$typeid = $param[$key];
$hasRow = model('Arctype')->getHasChildren($typeid);
$typeids = get_arr_column($hasRow, 'id');
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
if(! empty($auth_role_info['permission']['arctype'])){
if (!empty($typeid)) {
$typeids = array_intersect($typeids, $auth_role_info['permission']['arctype']);
}
}
}
}
/*--end*/
$condition['a.typeid'] = array('IN', $typeids);
} else if ($key == 'flag') {
if ('is_release' == $param[$key]) {
$condition['a.users_id'] = array('gt', 0);
} else {
$condition['a.'.$param[$key]] = array('eq', 1);
}
// } else if ($key == 'is_release') {
// if (0 < intval($param[$key])) {
// $condition['a.users_id'] = array('gt', intval($param[$key]));
// }
} else {
$condition['a.'.$key] = array('eq', $param[$key]);
}
}
}
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
if(isset($auth_role_info['only_oneself']) && 1 == $auth_role_info['only_oneself']){
$condition['a.admin_id'] = $admin_info['admin_id'];
}
}
}
/*--end*/
// 时间检索
if ($begin > 0 && $end > 0) {
$condition['a.add_time'] = array('between',"$begin,$end");
} else if ($begin > 0) {
$condition['a.add_time'] = array('egt', $begin);
} else if ($end > 0) {
$condition['a.add_time'] = array('elt', $end);
}
// 模型ID
$condition['a.channel'] = array('eq', $this->channeltype);
// 多语言
$condition['a.lang'] = array('eq', $this->admin_lang);
// 回收站
$condition['a.is_del'] = array('eq', 0);
/*自定义排序*/
$orderby = input('param.orderby/s');
$orderway = input('param.orderway/s');
if (!empty($orderby)) {
$orderby = "a.{$orderby} {$orderway}";
$orderby .= ", a.aid desc";
} else {
$orderby = "a.aid desc";
}
/*end*/
/**
* 数据查询搜索出主键ID的值
*/
$count = DB::name('archives')->alias('a')->where($condition)->count('aid');// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$fields = "b.*, a.*, a.aid as aid";
$list = DB::name('archives')
->field($fields)
->alias('a')
->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
->where($condition)
->order($orderby)
->limit($Page->firstRow.','.$Page->listRows)
->getAllWithIndex('aid');
foreach ($list as $key => $val) {
$val['arcurl'] = get_arcurl($val);
$val['litpic'] = handle_subdir_pic($val['litpic']); // 支持子目录
$list[$key] = $val;
}
$show = $Page->show(); // 分页显示输出
$assign_data['page'] = $show; // 赋值分页输出
$assign_data['list'] = $list; // 赋值数据集
$assign_data['pager'] = $Page; // 赋值分页对象
// 栏目ID
$assign_data['typeid'] = $typeid; // 栏目ID
/*当前栏目信息*/
$arctype_info = array();
if ($typeid > 0) {
$arctype_info = M('arctype')->field('typename')->find($typeid);
}
$assign_data['arctype_info'] = $arctype_info;
/*--end*/
/*选项卡*/
$tab = input('param.tab/d', 3);
$assign_data['tab'] = $tab;
/*--end*/
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
$this->assign($assign_data);
return $this->fetch();
}
/**
* 添加
*/
public function add()
{
$admin_info = session('admin_info');
$auth_role_info = $admin_info['auth_role_info'];
$this->assign('auth_role_info', $auth_role_info);
$this->assign('admin_info', $admin_info);
if (IS_POST) {
$post = input('post.');
/* 处理TAG标签 */
if (!empty($post['tags_new'])) {
$post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
unset($post['tags_new']);
}
$post['tags'] = explode(',', $post['tags']);
$post['tags'] = array_unique($post['tags']);
$post['tags'] = implode(',', $post['tags']);
/* END */
$content = input('post.addonFieldExt.content', '', null);
if (!empty($post['fileupload'])){
foreach ($post['fileupload']['file_url'] as $k => $v){
if (is_http_url($v)){
$post['fileupload']['uhash'][$k] = md5($v);
}
}
}
// 根据标题自动提取相关的关键字
$seo_keywords = $post['seo_keywords'];
if (!empty($seo_keywords)) {
$seo_keywords = str_replace('', ',', $seo_keywords);
} else {
// $seo_keywords = get_split_word($post['title'], $content);
}
// 自动获取内容第一张图片作为封面图
$is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
$litpic = '';
if ($is_remote == 1) {
$litpic = $post['litpic_remote'];
} else {
$litpic = $post['litpic_local'];
}
if (empty($litpic)) {
$litpic = get_html_first_imgurl($content);
}
$post['litpic'] = $litpic;
/*是否有封面图*/
if (empty($post['litpic'])) {
$is_litpic = 0; // 无封面图
} else {
$is_litpic = 1; // 有封面图
}
// SEO描述
$seo_description = '';
if (empty($post['seo_description']) && !empty($content)) {
$seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
} else {
$seo_description = $post['seo_description'];
}
// 外部链接跳转
$jumplinks = '';
$is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
if (intval($is_jump) > 0) {
$jumplinks = $post['jumplinks'];
}
// 模板文件,如果文档模板名与栏目指定的一致,默认就为空。让它跟随栏目的指定而变
if ($post['type_tempview'] == $post['tempview']) {
unset($post['type_tempview']);
unset($post['tempview']);
}
//处理自定义文件名,仅由字母数字下划线和短横杆组成,大写强制转换为小写
$htmlfilename = trim($post['htmlfilename']);
if (!empty($htmlfilename)) {
$htmlfilename = preg_replace("/[^a-zA-Z0-9_-]+/", "-", $htmlfilename);
$htmlfilename = strtolower($htmlfilename);
//判断是否存在相同的自定义文件名
$filenameCount = Db::name('archives')->where([
'htmlfilename' => $htmlfilename,
'lang' => $this->admin_lang,
])->count();
if (!empty($filenameCount)) {
$this->error("自定义文件名已存在,请重新设置!");
}
}
$post['htmlfilename'] = $htmlfilename;
//做自动通过审核判断
if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
$post['arcrank'] = -1;
}
// --存储数据
$newData = array(
'typeid'=> empty($post['typeid']) ? 0 : $post['typeid'],
'channel' => $this->channeltype,
'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
'is_jump' => $is_jump,
'is_litpic' => $is_litpic,
'jumplinks' => $jumplinks,
'seo_keywords' => $seo_keywords,
'seo_description' => $seo_description,
'admin_id' => session('admin_info.admin_id'),
'lang' => $this->admin_lang,
'sort_order' => 100,
'add_time' => strtotime($post['add_time']),
'update_time' => strtotime($post['add_time']),
);
$data = array_merge($post, $newData);
$aid = Db::name('archives')->insertGetId($data);
$_POST['aid'] = $aid;
if ($aid) {
// ---------后置操作
model('Download')->afterSave($aid, $data, 'add');
// ---------end
adminLog('新增下载:'.$data['title']);
// 生成静态页面代码
$successData = [
'aid' => $aid,
'tid' => $post['typeid'],
];
$this->success("操作成功!", null, $successData);
exit;
}
$this->error("操作失败!");
exit;
}
$typeid = input('param.typeid/d', 0);
$assign_data['typeid'] = $typeid; // 栏目ID
// 栏目信息
$arctypeInfo = Db::name('arctype')->find($typeid);
//第三方存储空间 七牛云/oss开关信息
$assign_data['qiniu_open'] = 0;
$assign_data['oss_open'] = 0;
$assign_data['cos_open'] = 0;
$channelRow = Db::name('channeltype')->where('id', $this->channeltype)->find();
if(!empty($channelRow)){
$channelRow['data'] = json_decode($channelRow['data'], true);
$assign_data['qiniu_open'] = !empty($channelRow['data']['qiniuyun_open']) ? $channelRow['data']['qiniuyun_open'] : 0;
$assign_data['oss_open'] = !empty($channelRow['data']['oss_open']) ? $channelRow['data']['oss_open'] : 0;
$assign_data['cos_open'] = !empty($channelRow['data']['cos_open']) ? $channelRow['data']['cos_open'] : 0;
}
/*允许发布文档列表的栏目*/
$arctype_html = allow_release_arctype($typeid, array($this->channeltype));
$assign_data['arctype_html'] = $arctype_html;
/*--end*/
/*自定义字段*/
// $addonFieldExtList = model('Field')->getChannelFieldList($this->channeltype);
// $channelfieldBindRow = Db::name('channelfield_bind')->where([
// 'typeid' => ['IN', [0,$typeid]],
// ])->column('field_id');
// if (!empty($channelfieldBindRow)) {
// foreach ($addonFieldExtList as $key => $val) {
// if (!in_array($val['id'], $channelfieldBindRow)) {
// unset($addonFieldExtList[$key]);
// }
// }
// }
// $assign_data['addonFieldExtList'] = $addonFieldExtList;
// $assign_data['aid'] = 0;
/*--end*/
// 阅读权限
$arcrank_list = get_arcrank_list();
$assign_data['arcrank_list'] = $arcrank_list;
/*模板列表*/
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$templateList = $archivesLogic->getTemplateList($this->nid);
$this->assign('templateList', $templateList);
/*--end*/
/*默认模板文件*/
$tempview = 'view_'.$this->nid.'.'.config('template.view_suffix');
!empty($arctypeInfo['tempview']) && $tempview = $arctypeInfo['tempview'];
$this->assign('tempview', $tempview);
/*--end*/
/*会员等级信息*/
$assign_data['users_level'] = DB::name('users_level')->field('level_id,level_name')->where('lang',$this->admin_lang)->select();
/*--end*/
/*下载模型自定义属性字段*/
$attr_field = Db::name('download_attr_field')->select();
$servername_use = 0;
if ($attr_field) {
$servername_info = [];
for ($i = 0; $i < count($attr_field); $i++) {
if ($attr_field[$i]['field_name'] == 'server_name') {
if ($attr_field[$i]['field_use'] == 1) {
$servername_use = 1;
}
$servername_info = $attr_field[$i];
break;
}
}
$assign_data['servername_info'] = $servername_info;
}
$assign_data['attr_field'] = $attr_field;
$assign_data['servername_use'] = $servername_use;
$servername_arr = unserialize(tpCache('download.download_select_servername'));
$assign_data['default_servername'] = $servername_arr?$servername_arr[0]:'立即下载';
/*--end*/
// 文档默认浏览量 / 软件默认下载量
$other_config = tpCache('other');
if (isset($other_config['other_arcclick']) && 0 <= $other_config['other_arcclick']) {
$arcclick_arr = explode("|", $other_config['other_arcclick']);
if (count($arcclick_arr) > 1) {
$assign_data['rand_arcclick'] = mt_rand($arcclick_arr[0], $arcclick_arr[1]);
} else {
$assign_data['rand_arcclick'] = intval($arcclick_arr[0]);
}
}else{
$arcclick_config['other_arcclick'] = '500|1000';
tpCache('other', $arcclick_config);
$assign_data['rand_arcclick'] = mt_rand(500, 1000);
}
if (isset($other_config['other_arcdownload']) && 0 <= $other_config['other_arcdownload']) {
$arcdownload_arr = explode("|", $other_config['other_arcdownload']);
if (count($arcdownload_arr) > 1) {
$assign_data['rand_arcdownload'] = mt_rand($arcdownload_arr[0], $arcdownload_arr[1]);
} else {
$assign_data['rand_arcdownload'] = intval($arcdownload_arr[0]);
}
}else{
$arcdownload_config['other_arcdownload'] = '100|500';
tpCache('other', $arcdownload_config);
$assign_data['rand_arcdownload'] = mt_rand(100, 500);
}
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
// URL模式
$tpcache = config('tpcache');
$assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
// 系统最大上传视频的大小 限制类型
$file_size = tpCache('basic.file_size');
$postsize = @ini_get('file_uploads') ? ini_get('post_max_size') : -1;
$fileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : -1;
$min_size = strval($file_size) < strval($postsize) ? $file_size : $postsize;
$min_size = strval($min_size) < strval($fileupload) ? $min_size : $fileupload;
$basic['file_size'] = intval($min_size) * 1024 * 1024;
$file_type = tpCache('basic.file_type');
$basic['file_type'] = !empty($file_type) ? $file_type : "zip|gz|rar|iso|doc|xls|ppt|wps";
$assign_data['basic'] = $basic;
$this->assign($assign_data);
return $this->fetch();
}
/**
* 编辑
*/
public function edit()
{
$admin_info = session('admin_info');
$auth_role_info = $admin_info['auth_role_info'];
$this->assign('auth_role_info', $auth_role_info);
$this->assign('admin_info', $admin_info);
if (IS_POST) {
$post = input('post.');
/* 处理TAG标签 */
if (!empty($post['tags_new'])) {
$post['tags'] = !empty($post['tags']) ? $post['tags'] . ',' . $post['tags_new'] : $post['tags_new'];
unset($post['tags_new']);
}
$post['tags'] = explode(',', $post['tags']);
$post['tags'] = array_unique($post['tags']);
$post['tags'] = implode(',', $post['tags']);
/* END */
$typeid = input('post.typeid/d', 0);
$content = input('post.addonFieldExt.content', '', null);
if (!empty($post['fileupload'])){
foreach ($post['fileupload']['file_url'] as $k => $v){
if (is_http_url($v)){
$post['fileupload']['uhash'][$k] = md5($v);
}
}
}
// 根据标题自动提取相关的关键字
$seo_keywords = $post['seo_keywords'];
if (!empty($seo_keywords)) {
$seo_keywords = str_replace('', ',', $seo_keywords);
} else {
// $seo_keywords = get_split_word($post['title'], $content);
}
// 自动获取内容第一张图片作为封面图
$is_remote = !empty($post['is_remote']) ? $post['is_remote'] : 0;
$litpic = '';
if ($is_remote == 1) {
$litpic = $post['litpic_remote'];
} else {
$litpic = $post['litpic_local'];
}
if (empty($litpic)) {
$litpic = get_html_first_imgurl($content);
}
$post['litpic'] = $litpic;
/*是否有封面图*/
if (empty($post['litpic'])) {
$is_litpic = 0; // 无封面图
} else {
$is_litpic = !empty($post['is_litpic']) ? $post['is_litpic'] : 0; // 有封面图
}
// SEO描述
$seo_description = '';
if (empty($post['seo_description']) && !empty($content)) {
$seo_description = @msubstr(checkStrHtml($content), 0, config('global.arc_seo_description_length'), false);
} else {
$seo_description = $post['seo_description'];
}
// --外部链接
$jumplinks = '';
$is_jump = isset($post['is_jump']) ? $post['is_jump'] : 0;
if (intval($is_jump) > 0) {
$jumplinks = $post['jumplinks'];
}
// 模板文件,如果文档模板名与栏目指定的一致,默认就为空。让它跟随栏目的指定而变
if ($post['type_tempview'] == $post['tempview']) {
unset($post['type_tempview']);
unset($post['tempview']);
}
//处理自定义文件名,仅由字母数字下划线和短横杆组成,大写强制转换为小写
$htmlfilename = trim($post['htmlfilename']);
if (!empty($htmlfilename)) {
$htmlfilename = preg_replace("/[^a-zA-Z0-9_-]+/", "-", $htmlfilename);
$htmlfilename = strtolower($htmlfilename);
//判断是否存在相同的自定义文件名
$filenameCount = Db::name('archives')->where([
'aid' => ['NEQ', $post['aid']],
'htmlfilename' => $htmlfilename,
'lang' => $this->admin_lang,
])->count();
if (!empty($filenameCount)) {
$this->error("自定义文件名已存在,请重新设置!");
}
}
$post['htmlfilename'] = $htmlfilename;
// 同步栏目切换模型之后的文档模型
$channel = Db::name('arctype')->where(['id'=>$typeid])->getField('current_channel');
//做未通过审核文档不允许修改文档状态操作
if ($admin_info['role_id'] > 0 && $auth_role_info['check_oneself'] < 1) {
$old_archives_arcrank = Db::name('archives')->where(['aid' => $post['aid']])->getField("arcrank");
if ($old_archives_arcrank < 0) {
unset($post['arcrank']);
}
}
// --存储数据
$newData = array(
'typeid'=> $typeid,
'channel' => $channel,
'is_b' => empty($post['is_b']) ? 0 : $post['is_b'],
'is_head' => empty($post['is_head']) ? 0 : $post['is_head'],
'is_special' => empty($post['is_special']) ? 0 : $post['is_special'],
'is_recom' => empty($post['is_recom']) ? 0 : $post['is_recom'],
'is_roll' => empty($post['is_roll']) ? 0 : $post['is_roll'],
'is_slide' => empty($post['is_slide']) ? 0 : $post['is_slide'],
'is_diyattr' => empty($post['is_diyattr']) ? 0 : $post['is_diyattr'],
'is_jump' => $is_jump,
'is_litpic' => $is_litpic,
'jumplinks' => $jumplinks,
'seo_keywords' => $seo_keywords,
'seo_description' => $seo_description,
'add_time' => strtotime($post['add_time']),
'update_time' => getTime(),
);
$data = array_merge($post, $newData);
$r = Db::name('archives')->where([
'aid' => $data['aid'],
'lang' => $this->admin_lang,
])->update($data);
if ($r) {
// ---------后置操作
model('Download')->afterSave($data['aid'], $data, 'edit');
// ---------end
adminLog('编辑下载:'.$data['title']);
// 生成静态页面代码
$successData = [
'aid' => $data['aid'],
'tid' => $typeid,
];
$this->success("操作成功!", null, $successData);
exit;
}
$this->error("操作失败!");
exit;
}
$assign_data = array();
$id = input('id/d');
$info = model('Download')->getInfo($id);
if (empty($info)) {
$this->error('数据不存在,请联系管理员!');
exit;
}
/*兼容采集没有归属栏目的文档*/
if (empty($info['channel'])) {
$channelRow = Db::name('channeltype')->field('id as channel')
->where('id',$this->channeltype)
->find();
$info = array_merge($info, $channelRow);
}
/*--end*/
$typeid = $info['typeid'];
$assign_data['typeid'] = $typeid;
// 栏目信息
$arctypeInfo = Db::name('arctype')->find($typeid);
//第三方存储空间 七牛云/oss开关信息
$assign_data['qiniu_open'] = 0;
$assign_data['oss_open'] = 0;
$assign_data['oss_open'] = 0;
$channelRow = Db::name('channeltype')->where('id', $this->channeltype)->find();
if(!empty($channelRow)){
$channelRow['data'] = json_decode($channelRow['data'], true);
$assign_data['qiniu_open'] = !empty($channelRow['data']['qiniuyun_open']) ? $channelRow['data']['qiniuyun_open'] : 0;
$assign_data['oss_open'] = !empty($channelRow['data']['oss_open']) ? $channelRow['data']['oss_open'] : 0;
$assign_data['cos_open'] = !empty($channelRow['data']['cos_open']) ? $channelRow['data']['cos_open'] : 0;
}
$info['channel'] = $arctypeInfo['current_channel'];
if (is_http_url($info['litpic'])) {
$info['is_remote'] = 1;
$info['litpic_remote'] = handle_subdir_pic($info['litpic']);
} else {
$info['is_remote'] = 0;
$info['litpic_local'] = handle_subdir_pic($info['litpic']);
}
// SEO描述
if (!empty($info['seo_description'])) {
$info['seo_description'] = @msubstr(checkStrHtml($info['seo_description']), 0, config('global.arc_seo_description_length'), false);
}
$assign_data['field'] = $info;
// 下载文件
$downfile_list = model('DownloadFile')->getDownFile($id);
$assign_data['downfile_list'] = $downfile_list;
// 下载文件中是否存在远程链接
$is_remote_file = 0;
foreach ($downfile_list as $key => $value) {
if (1 == $value['is_remote']) {
$is_remote_file = 1;
break;
}
}
$assign_data['is_remote_file'] = $is_remote_file;
/*允许发布文档列表的栏目,文档所在模型以栏目所在模型为主,兼容切换模型之后的数据编辑*/
$arctype_html = allow_release_arctype($typeid, array($info['channel']));
$assign_data['arctype_html'] = $arctype_html;
/*--end*/
/*自定义字段*/
// $addonFieldExtList = model('Field')->getChannelFieldList($info['channel'], 0, $id, $info);
// $channelfieldBindRow = Db::name('channelfield_bind')->where([
// 'typeid' => ['IN', [0,$typeid]],
// ])->column('field_id');
// if (!empty($channelfieldBindRow)) {
// foreach ($addonFieldExtList as $key => $val) {
// if (!in_array($val['id'], $channelfieldBindRow)) {
// unset($addonFieldExtList[$key]);
// }
// }
// }
// $assign_data['addonFieldExtList'] = $addonFieldExtList;
// $assign_data['aid'] = $id;
/*--end*/
// 阅读权限
$arcrank_list = get_arcrank_list();
$assign_data['arcrank_list'] = $arcrank_list;
/*模板列表*/
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$templateList = $archivesLogic->getTemplateList($this->nid);
$this->assign('templateList', $templateList);
/*--end*/
/*默认模板文件*/
$tempview = $info['tempview'];
empty($tempview) && $tempview = $arctypeInfo['tempview'];
$this->assign('tempview', $tempview);
/*--end*/
/*会员等级信息*/
$assign_data['users_level'] = DB::name('users_level')->field('level_id,level_name')->where('lang',$this->admin_lang)->select();
/*--end*/
/*下载模型自定义属性字段*/
$attr_field = Db::name('download_attr_field')->select();
$servername_use = 0;
if ($attr_field) {
$servername_info = [];
for ($i = 0; $i < count($attr_field); $i++) {
if ($attr_field[$i]['field_name'] == 'server_name') {
if ($attr_field[$i]['field_use'] == 1) {
$servername_use = 1;
}
$servername_info = $attr_field[$i];
break;
}
}
$assign_data['servername_info'] = $servername_info;
}
$assign_data['attr_field'] = $attr_field;
$assign_data['servername_use'] = $servername_use;
$servername_arr = unserialize(tpCache('download.download_select_servername'));
$assign_data['default_servername'] = $servername_arr?$servername_arr[0]:'立即下载';
/*--end*/
// URL模式
$tpcache = config('tpcache');
$assign_data['seo_pseudo'] = !empty($tpcache['seo_pseudo']) ? $tpcache['seo_pseudo'] : 1;
/*文档属性*/
$assign_data['archives_flags'] = model('ArchivesFlag')->getList();
// 系统最大上传视频的大小 限制类型
$file_size = tpCache('basic.file_size');
$postsize = @ini_get('file_uploads') ? ini_get('post_max_size') : -1;
$fileupload = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : -1;
$min_size = strval($file_size) < strval($postsize) ? $file_size : $postsize;
$min_size = strval($min_size) < strval($fileupload) ? $min_size : $fileupload;
$basic['file_size'] = intval($min_size) * 1024 * 1024;
$file_type = tpCache('basic.file_type');
$basic['file_type'] = !empty($file_type) ? $file_type : "zip|gz|rar|iso|doc|xls|ppt|wps";
$assign_data['basic'] = $basic;
$this->assign($assign_data);
return $this->fetch();
}
/**
* 删除
*/
public function del()
{
if (IS_POST) {
$archivesLogic = new \app\admin\logic\ArchivesLogic;
$archivesLogic->del();
}
}
public function template_set()
{
if (IS_AJAX_POST) {
$post = input('post.');
// 修改是否使用
if (!empty($post) && isset($post['field_use'])) {
$data['field_use'] = $post['field_use'];
$data['update_time'] = getTime();
Db::name('download_attr_field')->where('field_id',$post['field_id'])->update($data);
$this->success("更新成功!");
}
// 修改标题
if (!empty($post) && isset($post['field_title'])) {
$data['field_title'] = $post['field_title'];
$data['update_time'] = getTime();
Db::name('download_attr_field')->where('field_id',$post['field_id'])->update($data);
$this->success("更新成功!");
}
}
$list = Db::name('download_attr_field')->select();
$assign_data['list'] = $list;
$this->assign($assign_data);
return $this->fetch();
}
public function select_servername()
{
$servername_arr = unserialize(tpCache('download.download_select_servername'));
$param = input('param.');
$assign_data['select_servername'] = $servername_arr;
$assign_data['file_key'] = $param['file_key'];
$assign_data['sn_type'] = $param['sn_type'];
$assign_data['sn_name_sub'] = $param['sn_name_sub'];
$this->assign($assign_data);
return $this->fetch();
}
public function set_servername()
{
if (IS_AJAX_POST) {
$post = input('param.');
$servernames = htmlspecialchars($post['servername']);
$servernames = str_replace("\r\n", "\n", trim($servernames));
$servernames = explode("\n", $servernames);
$servernames_new = array_unique($servernames);
$servernames_new = serialize($servernames_new);
$param = ['download_select_servername'=>$servernames_new];
/*多语言*/
if (is_language()) {
$langRow = \think\Db::name('language')->order('id asc')
->cache(true, EYOUCMS_CACHE_TIME, 'language')
->select();
foreach ($langRow as $key => $val) {
tpCache('download', $param, $val['mark']);
}
} else {
tpCache('download', $param);
}
/*--end*/
$this->success("更新成功!");
}
$servername_arr = unserialize(tpCache('download.download_select_servername'));
$servername_arr = implode("\n",$servername_arr);
$assign_data['servernames'] = $servername_arr;
$this->assign($assign_data);
return $this->fetch();
}
public function search_servername()
{
if (IS_AJAX_POST) {
$post = input('param.');
$keyword = $post['keyword'];
$servernames = tpCache('download.download_select_servername');
$servernames = unserialize($servernames);
$search_data = $servernames;
if (!empty($keyword)) {
$search_data = [];
if ($servernames) {
foreach ($servernames as $k => $v) {
if (preg_match("/$keyword/s", $v)) $search_data[] = $v;
}
}
}
$this->success("获取成功",null,$search_data);
}
}
public function get_template()
{
if (IS_AJAX_POST) {
//$list = Db::name('download_attr_field')->where('field_use',1)->select();
$list = Db::name('download_attr_field')->select();
$this->success("查询成功!", null, $list);
}
}
/**
* 获取七牛云token
*/
/* public function qiniu_upload()
{
if (IS_AJAX_POST) {
$weappInfo = Db::name('weapp')->where('code','Qiniuyun')->field('id,status,data')->find();
if (empty($weappInfo)) {
$this->error('请先安装配置【七牛云图片加速】插件!', null, ['code'=>-1]);
} else if (1 != $weappInfo['status']) {
$this->error('请先启用【七牛云图片加速】插件!', null, ['code'=>-2,'id'=>$weappInfo['id']]);
} else {
$Qiniuyun = json_decode($weappInfo['data'], true);
if (empty($Qiniuyun)) {
$this->error('请先配置【七牛云图片加速】插件!', null, ['code'=>-3]);
} else if (empty($Qiniuyun['domain'])) {
$this->error('请先配置【七牛云图片加速】插件中的域名!', null, ['code'=>-3]);
}
}
//引入七牛云的相关文件
weapp_vendor('Qiniu.src.Qiniu.Auth', 'Qiniuyun');
weapp_vendor('Qiniu.src.Qiniu.Storage.UploadManager', 'Qiniuyun');
require_once ROOT_PATH.'weapp/Qiniuyun/vendor/Qiniu/autoload.php';
// 配置信息
$accessKey = $Qiniuyun['access_key'];
$secretKey = $Qiniuyun['secret_key'];
$bucket = $Qiniuyun['bucket'];
$domain = '//'.$Qiniuyun['domain'];
// 区域对应的上传URl
$config = new \Qiniu\Config(null);
$uphost = $config->getUpHost($accessKey, $bucket);
$uphost = str_replace('http://', '//', $uphost);
// 生成上传Token
$auth = new \Qiniu\Auth($accessKey, $secretKey);
$token = $auth->uploadToken($bucket);
if ($token) {
$filePath = UPLOAD_PATH.'soft/';
// $filePath = UPLOAD_PATH.'soft/' . date('Ymd/') . session('admin_id') . '-' . dd2char(date("ymdHis") . mt_rand(100, 999));
$data = [
'token' => $token,
'domain' => $domain,
'uphost' => $uphost,
'filePath' => $filePath,
];
$this->success('获取token成功!', null, $data);
} else {
$this->error('获取token失败!');
}
}
}*/
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,266 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use app\admin\controller\Base;
use think\Controller;
use think\Db;
use app\admin\logic\FilemanagerLogic;
class Filemanager extends Base
{
public $filemanagerLogic;
public $baseDir = '';
public $maxDir = '';
public $globalTpCache = array();
public function _initialize() {
parent::_initialize();
$this->filemanagerLogic = new FilemanagerLogic();
$this->globalTpCache = $this->filemanagerLogic->globalTpCache;
$this->baseDir = $this->filemanagerLogic->baseDir; // 服务器站点根目录绝对路径
$this->maxDir = $this->filemanagerLogic->maxDir; // 默认文件管理的最大级别目录
}
public function index()
{
// 获取到所有GET参数
$param = input('param.', '', null);
$activepath = input('param.activepath', '', null);
$activepath = $this->filemanagerLogic->replace_path($activepath, ':', true);
/*当前目录路径*/
$activepath = !empty($activepath) ? $activepath : $this->maxDir;
$tmp_max_dir = preg_replace("#\/#i", "\/", $this->maxDir);
if (!preg_match("#^".$tmp_max_dir."#i", $activepath)) {
$activepath = $this->maxDir;
}
/*--end*/
$inpath = "";
$activepath = str_replace("..", "", $activepath);
$activepath = preg_replace("#^\/{1,}#", "/", $activepath); // 多个斜杆替换为单个斜杆
if($activepath == "/") $activepath = "";
if(empty($activepath)) {
$inpath = $this->baseDir.$this->maxDir;
} else {
$inpath = $this->baseDir.$activepath;
}
$list = $this->filemanagerLogic->getDirFile($inpath, $activepath);
$assign_data['list'] = $list;
/*文件操作*/
$assign_data['replaceImgOpArr'] = $this->filemanagerLogic->replaceImgOpArr;
$assign_data['editOpArr'] = $this->filemanagerLogic->editOpArr;
$assign_data['renameOpArr'] = $this->filemanagerLogic->renameOpArr;
$assign_data['delOpArr'] = $this->filemanagerLogic->delOpArr;
$assign_data['moveOpArr'] = $this->filemanagerLogic->moveOpArr;
/*--end*/
$assign_data['activepath'] = $activepath;
$this->assign($assign_data);
return $this->fetch();
}
/**
* 替换图片
*/
public function replace_img()
{
if (IS_POST) {
$post = input('post.', '', null);
$activepath = !empty($post['activepath']) ? trim($post['activepath']) : '';
if (empty($activepath)) {
$this->error('参数有误');
exit;
}
$file = request()->file('upfile');
if (empty($file)) {
$this->error('请选择上传图片!');
exit;
} else {
$image_type = tpCache('basic.image_type');
$fileExt = !empty($image_type) ? str_replace('|', ',', $image_type) : config('global.image_ext');
$image_upload_limit_size = intval(tpCache('basic.file_size') * 1024 * 1024);
$result = $this->validate(
['file' => $file],
['file'=>'image|fileSize:'.$image_upload_limit_size.'|fileExt:'.$fileExt],
['file.image' => '上传文件必须为图片','file.fileSize' => '上传文件过大','file.fileExt'=>'上传文件后缀名必须为'.$fileExt]
);
if (true !== $result || empty($file)) {
$this->error($result);
exit;
}
}
$res = $this->filemanagerLogic->upload('upfile', $activepath, $post['filename'], 'image');
if ($res['code'] == 1) {
$this->success('操作成功!', url('Filemanager/index', array('activepath'=>$this->filemanagerLogic->replace_path($activepath, ':', false))));
} else {
$this->error($res['msg'], url('Filemanager/index', array('activepath'=>$this->filemanagerLogic->replace_path($activepath, ':', false))));
}
}
$filename = input('param.filename/s', '', null);
$activepath = input('param.activepath/s', '', null);
$activepath = $this->filemanagerLogic->replace_path($activepath, ':', true);
if ($activepath == "") $activepathname = "根目录";
else $activepathname = $activepath;
$info = array(
'activepath' => $activepath,
'activepathname' => $activepathname,
'filename' => $filename,
);
$this->assign('info', $info);
return $this->fetch();
}
/**
* 编辑
*/
public function edit()
{
if (IS_POST) {
$post = input('post.', '', null);
$content = input('post.content', '', null);
$filename = !empty($post['filename']) ? trim($post['filename']) : '';
$content = !empty($content) ? $content : '';
$activepath = !empty($post['activepath']) ? trim($post['activepath']) : '';
if (empty($filename) || empty($activepath)) {
$this->error('参数有误');
exit;
}
$r = $this->filemanagerLogic->editFile($filename, $activepath, $content);
if ($r === true) {
$this->success('操作成功!', url('Filemanager/index', array('activepath'=>$this->filemanagerLogic->replace_path($activepath, ':', false))));
exit;
} else {
$this->error($r, null, [], 8);
exit;
}
}
$activepath = input('param.activepath/s', '', null);
$activepath = $this->filemanagerLogic->replace_path($activepath, ':', true);
$filename = input('param.filename/s', '', null);
$activepath = str_replace("..", "", $activepath);
$filename = str_replace("..", "", $filename);
$path_parts = pathinfo($filename);
$path_parts['extension'] = strtolower($path_parts['extension']);
/*不允许越过指定最大级目录的文件编辑*/
$tmp_max_dir = preg_replace("#\/#i", "\/", $this->filemanagerLogic->maxDir);
if (!preg_match("#^".$tmp_max_dir."#i", $activepath)) {
$this->error('没有操作权限!');
exit;
}
/*--end*/
/*允许编辑的文件类型*/
if (!in_array($path_parts['extension'], $this->filemanagerLogic->editExt)) {
$this->error('只允许操作文件类型如下:'.implode('|', $this->filemanagerLogic->editExt));
exit;
}
/*--end*/
/*读取文件内容*/
$file = $this->baseDir."$activepath/$filename";
$content = "";
if(is_file($file))
{
$filesize = filesize($file);
if (0 < $filesize) {
$fp = fopen($file, "r");
$content = fread($fp, $filesize);
fclose($fp);
if ('htm' == $path_parts['extension']) {
$content = htmlspecialchars($content, ENT_QUOTES);
foreach ($this->filemanagerLogic->disableFuns as $key => $val) {
$val_new = msubstr($val, 0, 1).'-'.msubstr($val, 1);
$content = preg_replace("/(@)?".$val."(\s*)\(/i", "{$val_new}(", $content);
}
}
}
}
/*--end*/
if($path_parts['extension'] == 'js'){
$extension = 'text/javascript';
} else if($path_parts['extension'] == 'css'){
$extension = 'text/css';
} else {
$extension = 'text/html';
}
$info = array(
'filename' => $filename,
'activepath'=> $activepath,
'extension' => $extension,
'content' => $content,
);
$this->assign('info', $info);
return $this->fetch();
}
/**
* 新建文件
*/
public function newfile()
{
if (IS_POST) {
$post = input('post.', '', null);
$content = input('post.content', '', null);
$filename = !empty($post['filename']) ? trim($post['filename']) : '';
$content = !empty($content) ? $content : '';
$activepath = !empty($post['activepath']) ? trim($post['activepath']) : '';
if (empty($filename) || empty($activepath)) {
$this->error('参数有误');
exit;
}
$r = $this->filemanagerLogic->editFile($filename, $activepath, $content);
if ($r === true) {
$this->success('操作成功!', url('Filemanager/index', array('activepath'=>$this->filemanagerLogic->replace_path($activepath, ':', false))));
exit;
} else {
$this->error($r, null, [], 8);
exit;
}
}
$activepath = input('param.activepath/s', '', null);
$activepath = $this->filemanagerLogic->replace_path($activepath, ':', true);
$filename = 'newfile.htm';
$content = "";
$info = array(
'filename' => $filename,
'activepath'=> $activepath,
'content' => $content,
'extension' => 'text/html',
);
$this->assign('info', $info);
return $this->fetch();
}
}

View File

@@ -0,0 +1,780 @@
<?php
/**
* 易优CMS
* ============================================================================
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
* 网站地址: http://www.eyoucms.com
* ----------------------------------------------------------------------------
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\admin\controller;
use think\Page;
use think\Db;
use app\common\logic\ArctypeLogic;
class Guestbook extends Base
{
// 模型标识
public $nid = 'guestbook';
// 模型ID
public $channeltype = '';
// 表单类型
public $attrInputTypeArr = array();
public function _initialize()
{
parent::_initialize();
$channeltype_list = config('global.channeltype_list');
$this->channeltype = $channeltype_list[$this->nid];
$this->attrInputTypeArr = config('global.guestbook_attr_input_type');
}
/**
* 留言列表
*/
public function index()
{
$assign_data = array();
$condition = array();
// 获取到所有GET参数
$get = input('get.');
$typeid = input('typeid/d');
$begin = strtotime(input('param.add_time_begin/s'));
$end = input('param.add_time_end/s');
!empty($end) && $end .= ' 23:59:59';
$end = strtotime($end);
// 应用搜索条件
foreach (['keywords', 'typeid'] as $key) {
if (isset($get[$key]) && $get[$key] !== '') {
if ($key == 'keywords') {
$attr_row = Db::name('guestbook_attr')->field('aid')->where(array('attr_value' => array('LIKE', "%{$get[$key]}%")))->group('aid')->getAllWithIndex('aid');
$aids = array_keys($attr_row);
$condition['a.aid'] = array('IN', $aids);
} else if ($key == 'typeid') {
$condition['a.typeid'] = array('eq', $get[$key]);
} else {
$condition['a.' . $key] = array('eq', $get[$key]);
}
}
}
// 时间检索
if ($begin > 0 && $end > 0) {
$condition['a.add_time'] = array('between',"$begin,$end");
} else if ($begin > 0) {
$condition['a.add_time'] = array('egt', $begin);
} else if ($end > 0) {
$condition['a.add_time'] = array('elt', $end);
}
if (empty($typeid)) {
/*权限控制 by 小虎哥*/
$admin_info = session('admin_info');
if (0 < intval($admin_info['role_id'])) {
$auth_role_info = $admin_info['auth_role_info'];
if(! empty($auth_role_info)){
$is_notaccess = false;
$permission_arctype = !empty($auth_role_info['permission']['arctype']) ? $auth_role_info['permission']['arctype'] : [];
if(! empty($permission_arctype)){
$typeids_tmp = Db::name('arctype')->where(['current_channel'=>8,'lang'=>$this->admin_lang])->cache(true, EYOUCMS_CACHE_TIME, 'arctype')->column('id');
$typeids_tmp = !empty($typeids_tmp) ? $typeids_tmp : [];
$typeids_tmp2 = array_intersect($typeids_tmp, $auth_role_info['permission']['arctype']);
if (!empty($typeids_tmp2)) {
$condition['a.typeid'] = ['IN', $typeids_tmp2];
$is_notaccess = true;
}
}
if (false === $is_notaccess) {
$this->error('您没有操作权限,请联系超级管理员分配权限');
}
}
}
/*--end*/
}
// 多语言
$condition['a.lang'] = array('eq', $this->admin_lang);
/**
* 数据查询搜索出主键ID的值
*/
$count = DB::name('guestbook')->alias('a')->where($condition)->count('aid');// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = DB::name('guestbook')
->field("b.*, a.*")
->alias('a')
->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
->where($condition)
->order('a.add_time desc')
->limit($Page->firstRow . ',' . $Page->listRows)
->getAllWithIndex('aid');
/**
* 完善数据集信息
* 在数据量大的情况下经过优化的搜索逻辑先搜索出主键ID再通过ID将其他信息补充完整
*/
if ($list) {
$where = [
'b.aid' => ['IN', array_keys($list)],
'a.is_showlist' => 1,
'a.lang' => $this->admin_lang,
'a.is_del' => 0,
];
$row = DB::name('guestbook_attribute')
->field('a.attr_name, b.attr_value, b.aid, b.attr_id,a.attr_input_type')
->alias('a')
->join('__GUESTBOOK_ATTR__ b', 'b.attr_id = a.attr_id', 'LEFT')
->where($where)
->order('b.aid desc, a.sort_order asc, a.attr_id asc')
->getAllWithIndex();
$attr_list = array();
foreach ($row as $key => $val) {
if (9 == $val['attr_input_type']){
//如果是区域类型,转换名称
$val['attr_value'] = Db::name('region')->where('id','in',$val['attr_value'])->column('name');
$val['attr_value'] = implode('',$val['attr_value']);
}
if (preg_match('/(\.(jpg|gif|png|bmp|jpeg|ico|webp))$/i', $val['attr_value'])) {
if (!stristr($val['attr_value'], '|')) {
$val['attr_value'] = handle_subdir_pic($val['attr_value']);
$val['attr_value'] = "<img src='{$val['attr_value']}' width='60' height='60' style='float: unset;cursor: pointer;' onclick=\"Images('{$val['attr_value']}', 650, 350);\" />";
}
} else {
$val['attr_value'] = str_replace(PHP_EOL, ' | ', $val['attr_value']);
}
$attr_list[$val['aid']][] = $val;
}
foreach ($list as $key => $val) {
$list[$key]['attr_list'] = isset($attr_list[$val['aid']]) ? $attr_list[$val['aid']] : array();
}
}
$assign_data['tab_list'] = Db::name('guestbook_attribute')->where([
'typeid' => $typeid,
'is_showlist' => 1,
'lang' => $this->admin_lang,
'is_del' => 0,
])->order('sort_order asc, attr_id asc')->select();
$show = $Page->show(); // 分页显示输出
$assign_data['page'] = $show; // 赋值分页输出
$assign_data['list'] = $list; // 赋值数据集
$assign_data['pager'] = $Page; // 赋值分页对象
// 栏目ID
$assign_data['typeid'] = $typeid; // 栏目ID
/*当前栏目信息*/
$arctype_info = array();
if ($typeid > 0) {
$arctype_info = Db::name('arctype')->field('typename')->find($typeid);
}
$assign_data['arctype_info'] = $arctype_info;
/*--end*/
/*选项卡*/
$tab = input('param.tab/d', 3);
$assign_data['tab'] = $tab;
/*--end*/
$this->assign($assign_data);
return $this->fetch();
}
/**
* 删除
*/
public function del()
{
$id_arr = input('del_id/a');
$id_arr = eyIntval($id_arr);
if (!empty($id_arr)) {
$r = Db::name('guestbook')->where([
'aid' => ['IN', $id_arr],
'lang' => $this->admin_lang,
])->delete();
if ($r) {
// ---------后置操作
model('Guestbook')->afterDel($id_arr);
// ---------end
adminLog('删除留言-id' . implode(',', $id_arr));
$this->success('删除成功');
} else {
$this->error('删除失败');
}
} else {
$this->error('参数有误');
}
}
/**
* 留言表单表单列表
*/
public function attribute_index()
{
$assign_data = array();
$condition = array();
// 获取到所有GET参数
$get = input('get.');
$typeid = input('typeid/d');
// 应用搜索条件
foreach (['keywords','typeid'] as $key) {
if (isset($get[$key]) && $get[$key] !== '') {
if ($key == 'keywords') {
$condition['a.attr_name'] = array('LIKE', "%{$get[$key]}%");
} else if ($key == 'typeid') {
$typeids = model('Arctype')->getHasChildren($get[$key]);
$condition['a.typeid'] = array('IN', array_keys($typeids));
} else {
$condition['a.'.$key] = array('eq', $get[$key]);
}
}
}
$condition['b.id'] = ['gt', 0];
$condition['a.is_del'] = 0;
// 多语言
$condition['a.lang'] = $this->admin_lang;
/**
* 数据查询搜索出主键ID的值
*/
$count = DB::name('guestbook_attribute')->alias('a')
->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
->where($condition)
->count();// 查询满足要求的总记录数
$Page = new Page($count, config('paginate.list_rows'));// 实例化分页类 传入总记录数和每页显示的记录数
$list = DB::name('guestbook_attribute')
->field("a.attr_id")
->alias('a')
->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
->where($condition)
->order('a.typeid desc, a.sort_order asc, a.attr_id asc')
->limit($Page->firstRow.','.$Page->listRows)
->getAllWithIndex('attr_id');
/**
* 完善数据集信息
* 在数据量大的情况下经过优化的搜索逻辑先搜索出主键ID再通过ID将其他信息补充完整
*/
if ($list) {
$attr_ida = array_keys($list);
$fields = "b.*, a.*";
$row = DB::name('guestbook_attribute')
->field($fields)
->alias('a')
->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
->where('a.attr_id', 'in', $attr_ida)
->getAllWithIndex('attr_id');
/*获取多语言关联绑定的值*/
$row = model('LanguageAttr')->getBindValue($row, 'guestbook_attribute', $this->main_lang); // 多语言
/*--end*/
foreach ($row as $key => $val) {
$val['fieldname'] = 'attr_'.$val['attr_id'];
$row[$key] = $val;
}
foreach ($list as $key => $val) {
$list[$key] = $row[$val['attr_id']];
}
}
$show = $Page->show(); // 分页显示输出
$assign_data['page'] = $show; // 赋值分页输出
$assign_data['list'] = $list; // 赋值数据集
$assign_data['pager'] = $Page; // 赋值分页对象
/*获取当前模型栏目*/
$select_html = allow_release_arctype($typeid, array($this->channeltype));
$typeidNum = substr_count($select_html, '</option>');
$this->assign('select_html',$select_html);
$this->assign('typeidNum',$typeidNum);
/*--end*/
// 栏目ID
$assign_data['typeid'] = $typeid; // 栏目ID
/*当前栏目信息*/
$arctype_info = array();
if ($typeid > 0) {
$arctype_info = Db::name('arctype')->field('typename')->find($typeid);
}
$assign_data['arctype_info'] = $arctype_info;
/*--end*/
/*选项卡*/
$tab = input('param.tab/d', 3);
$assign_data['tab'] = $tab;
/*--end*/
$assign_data['attrInputTypeArr'] = $this->attrInputTypeArr; // 表单类型
$this->assign($assign_data);
return $this->fetch();
}
/**
* 新增留言表单
*/
public function attribute_add()
{
//防止php超时
function_exists('set_time_limit') && set_time_limit(0);
$this->language_access(); // 多语言功能操作权限
if(IS_AJAX && IS_POST)//ajax提交验证
{
$model = model('GuestbookAttribute');
$attr_values = str_replace('_', '', input('attr_values')); // 替换特殊字符
$attr_values = str_replace('@', '', $attr_values); // 替换特殊字符
$attr_values = trim($attr_values);
/*过滤重复值*/
$attr_values_arr = explode(PHP_EOL, $attr_values);
foreach ($attr_values_arr as $key => $val) {
$tmp_val = trim($val);
if (empty($tmp_val)) {
unset($attr_values_arr[$key]);
continue;
}
$attr_values_arr[$key] = $tmp_val;
}
$attr_values_arr = array_unique($attr_values_arr);
$attr_values = implode(PHP_EOL, $attr_values_arr);
/*end*/
$post_data = input('post.');
$post_data['attr_values'] = $attr_values;
$attr_input_type = isset($post_data['attr_input_type']) ? $post_data['attr_input_type'] : 0;
/*前台输入是否JS验证*/
$validate_type = 0;
$validate_type_list = config("global.validate_type_list"); // 前台输入验证类型
if (!empty($validate_type_list[$attr_input_type])) {
$validate_type = $attr_input_type;
}
/*end*/
if (9 == $post_data['attr_input_type']) {
if (!empty($post_data['region_data'])) {
$post_data['attr_values'] = serialize($post_data['region_data']);
} else {
$this->error("请选择区域范围!");
}
}
$savedata = array(
'attr_name' => $post_data['attr_name'],
'typeid' => $post_data['typeid'],
'attr_input_type' => $attr_input_type,
'attr_values' => isset($post_data['attr_values']) ? $post_data['attr_values'] : '',
'is_showlist' => $post_data['is_showlist'],
'required' => $post_data['required'],
'validate_type' => $validate_type,
'sort_order' => 100,
'lang' => $this->admin_lang,
'add_time' => getTime(),
'update_time' => getTime(),
);
// 数据验证
$validate = \think\Loader::validate('GuestbookAttribute');
if(!$validate->batch()->check($savedata))
{
$error = $validate->getError();
$error_msg = array_values($error);
$return_arr = array(
'status' => -1,
'msg' => $error_msg[0],
'data' => $error,
);
respose($return_arr);
} else {
$model->data($savedata,true); // 收集数据
$model->save(); // 写入数据到数据库
$insertId = $model->getLastInsID();
/*同步留言属性ID到多语言的模板变量里*/
model('GuestbookAttribute')->syn_add_language_attribute($insertId);
/*--end*/
$return_arr = array(
'status' => 1,
'msg' => '操作成功',
'data' => array('url'=>url('Guestbook/attribute_index', array('typeid'=>$post_data['typeid']))),
);
adminLog('新增留言表单:'.$savedata['attr_name']);
respose($return_arr);
}
}
$typeid = input('param.typeid/d', 0);
if ($typeid > 0) {
$select_html = Db::name('arctype')->where('id', $typeid)->getField('typename');
$select_html = !empty($select_html) ? $select_html : '该栏目不存在';
} else {
$arctypeLogic = new ArctypeLogic();
$map = array(
'channeltype' => $this->channeltype,
);
$arctype_max_level = intval(config('global.arctype_max_level'));
$select_html = $arctypeLogic->arctype_list(0, $typeid, true, $arctype_max_level, $map);
}
$assign_data['select_html'] = $select_html; //
$assign_data['typeid'] = $typeid; // 栏目ID
$assign_data['attrInputTypeArr'] = $this->attrInputTypeArr; // 表单类型
//区域
$China[] = [
'id' => 0,
'name' => '全国',
];
$Province = get_province_list();
$assign_data['Province'] = array_merge($China, $Province);
$this->assign($assign_data);
return $this->fetch();
}
/**
* 编辑留言表单
*/
public function attribute_edit()
{
if(IS_AJAX && IS_POST)//ajax提交验证
{
$model = model('GuestbookAttribute');
$attr_values = str_replace('_', '', input('attr_values')); // 替换特殊字符
$attr_values = str_replace('@', '', $attr_values); // 替换特殊字符
$attr_values = trim($attr_values);
/*过滤重复值*/
$attr_values_arr = explode(PHP_EOL, $attr_values);
foreach ($attr_values_arr as $key => $val) {
$tmp_val = trim($val);
if (empty($tmp_val)) {
unset($attr_values_arr[$key]);
continue;
}
$attr_values_arr[$key] = $tmp_val;
}
$attr_values_arr = array_unique($attr_values_arr);
$attr_values = implode(PHP_EOL, $attr_values_arr);
/*end*/
$post_data = input('post.');
$post_data['attr_values'] = $attr_values;
$attr_input_type = isset($post_data['attr_input_type']) ? $post_data['attr_input_type'] : 0;
/*前台输入是否JS验证*/
$validate_type = 0;
$validate_type_list = config("global.validate_type_list"); // 前台输入验证类型
if (!empty($validate_type_list[$attr_input_type])) {
$validate_type = $attr_input_type;
}
/*end*/
if (9 == $post_data['attr_input_type']) {
if (!empty($post_data['region_data'])) {
$post_data['attr_values'] = serialize($post_data['region_data']);
} else {
$this->error("请选择区域范围!");
}
}
$savedata = array(
'attr_id' => $post_data['attr_id'],
'attr_name' => $post_data['attr_name'],
'typeid' => $post_data['typeid'],
'attr_input_type' => $attr_input_type,
'attr_values' => isset($post_data['attr_values']) ? $post_data['attr_values'] : '',
'is_showlist' => $post_data['is_showlist'],
'required' => $post_data['required'],
'validate_type' => $validate_type,
'sort_order' => 100,
'update_time' => getTime(),
);
// 数据验证
$validate = \think\Loader::validate('GuestbookAttribute');
if(!$validate->batch()->check($savedata))
{
$error = $validate->getError();
$error_msg = array_values($error);
$return_arr = array(
'status' => -1,
'msg' => $error_msg[0],
'data' => $error,
);
respose($return_arr);
} else {
$model->data($savedata, true); // 收集数据
$model->isUpdate(true, [
'attr_id' => $post_data['attr_id'],
'lang' => $this->admin_lang,
])->save(); // 写入数据到数据库
$return_arr = array(
'status' => 1,
'msg' => '操作成功',
'data' => array('url' => url('Guestbook/attribute_index', array('typeid' => $post_data['typeid']))),
);
adminLog('编辑留言表单:' . $savedata['attr_name']);
respose($return_arr);
}
}
$assign_data = array();
$id = input('id/d');
/*获取多语言关联绑定的值*/
$new_id = model('LanguageAttr')->getBindValue($id, 'guestbook_attribute'); // 多语言
!empty($new_id) && $id = $new_id;
/*--end*/
$info = Db::name('GuestbookAttribute')->where([
'attr_id' => $id,
'lang' => $this->admin_lang,
])->find();
if (empty($info)) {
$this->error('数据不存在,请联系管理员!');
exit;
}
$assign_data['field'] = $info;
// 所在栏目
$select_html = Db::name('arctype')->where('id', $info['typeid'])->getField('typename');
$select_html = !empty($select_html) ? $select_html : '该栏目不存在';
$assign_data['select_html'] = $select_html;
$assign_data['attrInputTypeArr'] = $this->attrInputTypeArr; // 表单类型
/*区域字段处理*/
// 初始化参数
$assign_data['region'] = [
'parent_id' => '-1',
'region_id' => '-1',
'region_names' => '',
'region_ids' => '',
];
// 定义全国参数
$China[] = [
'id' => 0,
'name' => '全国',
];
// 查询省份信息并且拼装上$China数组
$Province = get_province_list();
$assign_data['Province'] = array_merge($China, $Province);
// 区域选择时,指定不出现下级地区列表
$assign_data['parent_array'] = "[]";
// 如果是区域类型则执行
if (9 == $info['attr_input_type']) {
// 反序列化默认值参数
$dfvalue = unserialize($info['attr_values']);
if (0 == $dfvalue['region_id']) {
$parent_id = $dfvalue['region_id'];
} else {
// 查询当前选中的区域父级ID
$parent_id = Db::name('region')->where("id", $dfvalue['region_id'])->getField('parent_id');
if (0 == $parent_id) {
$parent_id = $dfvalue['region_id'];
}
}
// 查询市\区\县信息
$assign_data['City'] = Db::name('region')->where("parent_id", $parent_id)->select();
// 加载数据到模板
$assign_data['region'] = [
'parent_id' => $parent_id,
'region_id' => $dfvalue['region_id'],
'region_names' => $dfvalue['region_names'],
'region_ids' => $dfvalue['region_ids'],
];
// 删除默认值,防止切换其他类型时使用到
unset($info['attr_values']);
// 区域选择时,指定不出现下级地区列表
$assign_data['parent_array'] = convert_js_array(config('global.field_region_all_type'));
}
/*区域字段处理结束*/
$this->assign($assign_data);
return $this->fetch();
}
/**
* 删除留言表单
*/
public function attribute_del()
{
$this->language_access(); // 多语言功能操作权限
$id_arr = input('del_id/a');
$id_arr = eyIntval($id_arr);
if (!empty($id_arr)) {
/*多语言*/
if (is_language()) {
$attr_name_arr = [];
foreach ($id_arr as $key => $val) {
$attr_name_arr[] = 'attr_' . $val;
}
$new_id_arr = Db::name('language_attr')->where([
'attr_name' => ['IN', $attr_name_arr],
'attr_group' => 'guestbook_attribute',
])->column('attr_value');
!empty($new_id_arr) && $id_arr = $new_id_arr;
}
/*--end*/
$r = Db::name('GuestbookAttribute')->where([
'attr_id' => ['IN', $id_arr],
])->update([
'is_del' => 1,
'update_time' => getTime(),
]);
if($r){
adminLog('删除留言表单-id'.implode(',', $id_arr));
$this->success('删除成功');
}else{
$this->error('删除失败');
}
}else{
$this->error('参数有误');
}
}
/**
* 查看详情
*/
public function details()
{
$aid = input('param.aid/d');
// 标记为已读和IP地区
$row = Db::name('guestbook')->find($aid);
$city = "";
$city_arr = getCityLocation($row['ip']);
if (!empty($city_arr)) {
!empty($city_arr['location']) && $city .= $city_arr['location'];
}
$row['city'] = $city;
$this->assign('row', $row);
// 留言属性
$condition['a.aid'] = $aid;
$condition['a.lang'] = $this->admin_lang;
$attr_list = Db::name('guestbook_attr')
->field("b.*, a.*")
->alias('a')
->join('__GUESTBOOK_ATTRIBUTE__ b', 'a.attr_id = b.attr_id', 'LEFT')
->where($condition)
->order('a.attr_id asc')
->select();
foreach ($attr_list as $key => &$val) {
if ($val['attr_input_type'] == 9) {
$val['attr_value'] = Db::name('region')->where('id','in',$val['attr_value'])->column('name');
$val['attr_value'] = implode('',$val['attr_value']);
} else if ($val['attr_input_type'] == 4) {
$val['attr_value'] = filter_line_return($val['attr_value'], '、');
} else {
if (preg_match('/(\.(jpg|gif|png|bmp|jpeg|ico|webp))$/i', $val['attr_value'])) {
if (!stristr($val['attr_value'], '|')) {
$val['attr_value'] = handle_subdir_pic($val['attr_value']);
$val['attr_value'] = "<a href='{$val['attr_value']}' target='_blank'><img src='{$val['attr_value']}' width='60' height='60' style='float: unset;cursor: pointer;' /></a>";
}
}elseif (preg_match('/(\.('.tpCache('basic.file_type').'))$/i', $val['attr_value'])){
if (!stristr($val['attr_value'], '|')) {
$val['attr_value'] = handle_subdir_pic($val['attr_value']);
$val['attr_value'] = "<a href='{$val['attr_value']}' download='".time()."'><img src=\"".ROOT_DIR."/public/static/common/images/file.png\" alt=\"\" style=\"width: 16px;height: 16px;\">点击下载</a>";
}
}
}
}
$this->assign('attr_list', $attr_list);
// 标记为已读
Db::name('guestbook')->where(['aid'=>$aid, 'lang'=>$this->admin_lang])->update([
'is_read' => 1,
'update_time' => getTime(),
]);
return $this->fetch();
}
/**
* excel导出
*/
public function excel_export()
{
$id_arr = input('aid/s');
if (!empty($id_arr)) {
$id_arr = explode(',', $id_arr);
$id_arr = eyIntval($id_arr);
}
$typeid = input('typeid/d');
$start_time = input('start_time/s');
$end_time = input('end_time/s');
$strTable = '<table width="500" border="1">';
$where = [];
$where['typeid'] = $typeid;
$where['lang'] = $this->admin_lang;
$order = 'add_time asc';
//没有指定ID就导出全部
if (!empty($id_arr)) {
$where['aid'] = ['IN', $id_arr];
}
//根据日期导出
if (!empty($start_time) && !empty($end_time)) {
$start_time = strtotime($start_time);
$end_time = strtotime("+1 day", strtotime($end_time)) - 1;
$where['add_time'] = ['between', [$start_time, $end_time]];
} elseif (!empty($start_time) && empty($end_time)) {
$start_time = strtotime($start_time);
$where['add_time'] = ['>=', $start_time];
} elseif (empty($start_time) && !empty($end_time)) {
$end_time = strtotime("+1 day", strtotime($end_time)) - 1;
$where['add_time'] = ['<=', $end_time];
}
$row = Db::name('guestbook')->where($where)->order($order)->select();
$title = Db::name('guestbook_attribute')->where([
'typeid' => $typeid,
'lang' => $this->admin_lang,
'is_del' => 0,
])->order('sort_order asc, attr_id asc')->select();
if ($row && $title) {
$strTable .= '<tr>';
$strTable .= '<td style="text-align:center;font-size:12px;" width="*">ID</td>';
foreach ($title as &$key) {
$strTable .= '<td style="text-align:center;font-size:12px;" width="*">' . $key['attr_name'] . '</td>';
}
$strTable .= '<td style="text-align:center;font-size:12px;" width="*">新增时间</td>';
$strTable .= '<td style="text-align:center;font-size:12px;" width="*">更新时间</td>';
$strTable .= '</tr>';
foreach ($row as &$val) {
$attr_value = Db::name('guestbook_attr')
->alias('a')
->field('a.*,b.attr_input_type')
->where(['a.aid' => $val['aid'], 'a.lang' => $this->admin_lang])
->join('guestbook_attribute b','a.attr_id = b.attr_id')
->getAllWithIndex('attr_id');
foreach ($attr_value as $k => $v){
if ($v['attr_input_type'] == 9){
$v['attr_value'] = Db::name('region')->where('id','in',$v['attr_value'])->column('name');
$attr_value[$k]['attr_value'] = implode('',$v['attr_value']);
}
}
$strTable .= '<tr>';
$strTable .= '<td style="text-align:center;font-size:12px;">' . $val['aid'] . '</td>';
foreach ($title as &$key) {
$strTable .= '<td style="text-align:center;font-size:12px;" style=\'vnd.ms-excel.numberformat:@\' width="*">' . $attr_value[$key['attr_id']]['attr_value'] . '</td>';
}
$strTable .= '<td style="text-align:left;font-size:12px;">' . date('Y-m-d H:i:s', $val['add_time']) . '</td>';
$strTable .= '<td style="text-align:left;font-size:12px;">' . date('Y-m-d H:i:s', $val['update_time']) . '</td>';
$strTable .= '</tr>';
}
}
$strTable .= '</table>';
downloadExcel($strTable, 'guestbook');
exit();
}
}

Some files were not shown because too many files have changed in this diff Show More