v2.0.12-20230417

This commit is contained in:
MI15\Win
2023-04-17 16:26:10 +08:00
parent 0ef96aba23
commit fa292ba2ab
22 changed files with 506 additions and 126 deletions

28
system/MySQL/20230417.php Normal file
View File

@@ -0,0 +1,28 @@
<?php if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}
$sql ="
ALTER DATABASE {$GLOBALS['db_config']['name']} DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE global_config CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE global_user CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE purview_list CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE regcode_list CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE updatadb_logs CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE user_apply CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE user_categorys CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE user_config CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE user_count CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE user_group CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE user_links CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE user_log CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE user_login_info CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE user_pwd_group CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE user_share CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
('link_extend', '链接扩展', '允许使用链接扩展字段'),
('theme_in', '主题设置', '后台显示主题设置菜单'),
('theme_set', '主题配置', '允许自定义主题配置');
";
if(exe_sql($sql)){
insert_db('updatadb_logs',['file_name'=>$file_name,'update_time'=>time(),'status'=>'TRUE','extra'=>'']);
}else{
msg(-1,'数据库更新失败');
}

View File

@@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS `global_config` (
`v` text NOT NULL COMMENT '',
`d` varchar(32) DEFAULT '' COMMENT '描述',
UNIQUE KEY `k` (`k`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 用户配置
DROP TABLE IF EXISTS `user_config`;
@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS `user_config` (
`t` varchar(32) NOT NULL COMMENT '类型',
`d` varchar(32) DEFAULT '' COMMENT '描述',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
-- 统计
@@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS `user_count` (
`k` varchar(32) NOT NULL COMMENT '',
`v` bigint(10) UNSIGNED DEFAULT '0' COMMENT '',
`t` varchar(32) NOT NULL COMMENT '类型'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 数据库升级记录
@@ -40,8 +40,9 @@ CREATE TABLE IF NOT EXISTS `updatadb_logs` (
`extra` varchar(512) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `file_name` (`file_name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
INSERT INTO "updatadb_logs" ("id", "file_name", "update_time", "status", "extra") VALUES ('1', '20230417.php', '1681719049', 'TRUE', '');
-- 创建用户表
DROP TABLE IF EXISTS `global_user`;
@@ -64,7 +65,7 @@ CREATE TABLE IF NOT EXISTS `global_user` (
PRIMARY KEY (`ID`),
UNIQUE KEY `User` (`User`),
UNIQUE KEY `Email` (`Email`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
-- 用户分类表
DROP TABLE IF EXISTS `user_categorys`;
@@ -85,7 +86,7 @@ CREATE TABLE IF NOT EXISTS `user_categorys` (
`icon` text NOT NULL DEFAULT '' COMMENT '个性图标',
`extend` text NOT NULL COMMENT '扩展',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='用户分类';
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='用户分类';
INSERT INTO `user_categorys` (`id`, `cid`, `fid`, `uid`, `pid`, `status`, `property`, `name`, `add_time`, `up_time`, `weight`, `description`, `font_icon`, `icon`, `extend`) VALUES
(1, 1, 0, 0, 0, 1, 0, '默认分类', 1672502400, 1672502400, 0, 'TwoNav默认分类', 'fa fa-book', '', '');
@@ -112,7 +113,7 @@ CREATE TABLE IF NOT EXISTS `user_links` (
`up_time` int(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '修改时间',
`extend` text NOT NULL COMMENT '扩展',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='用户链接';
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='用户链接';
INSERT INTO `user_links` (`id`, `lid`, `uid`, `fid`, `pid`, `status`, `property`, `title`, `url`, `url_standby`, `weight`, `description`, `icon`, `click`, `add_time`, `up_time`, `extend`) VALUES
@@ -134,7 +135,7 @@ CREATE TABLE IF NOT EXISTS `user_login_info` (
`expire_time` int(10) UNSIGNED NOT NULL COMMENT '过期时间',
`cookie_key` varchar(32) NOT NULL COMMENT 'cookie_key',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
-- 日志表
DROP TABLE IF EXISTS `user_log`;
@@ -148,7 +149,7 @@ CREATE TABLE IF NOT EXISTS `user_log` (
`content` text NOT NULL COMMENT '请求内容',
`description` varchar(128) NOT NULL COMMENT '描述',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='日志';
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='日志';
-- 用户组
DROP TABLE IF EXISTS `user_group`;
@@ -162,7 +163,7 @@ CREATE TABLE IF NOT EXISTS `user_group` (
`codes` text NOT NULL COMMENT '允许代号',
PRIMARY KEY (`id`),
UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 权限列表
DROP TABLE IF EXISTS `purview_list`;
@@ -172,7 +173,7 @@ CREATE TABLE IF NOT EXISTS `purview_list` (
`name` varchar(64) NOT NULL COMMENT '名称',
`description` varchar(128) NOT NULL COMMENT '描述',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
('Upload_icon', '上传图标', '允许上传分类和链接图标'),
@@ -185,7 +186,10 @@ INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
('link', '链接管理', '允许添加/编辑/删除链接(未勾选时只读)'),
('apply', '收录管理', '允许使用收录功能'),
('link_pwd', '加密管理', '允许使用加密管理(未勾选时只读)'),
('guestbook', '留言板', '允许使用留言板功能');
('guestbook', '留言板', '允许使用留言板功能'),
('link_extend', '链接扩展', '允许使用链接扩展字段'),
('theme_in', '主题设置', '后台显示主题设置菜单'),
('theme_set', '主题配置', '允许自定义主题配置');
-- 注册码列表
DROP TABLE IF EXISTS `regcode_list`;
@@ -199,7 +203,7 @@ CREATE TABLE IF NOT EXISTS `regcode_list` (
`use_time` int(10) UNSIGNED NOT NULL COMMENT '使用时间',
PRIMARY KEY (`id`),
UNIQUE KEY `regcode` (`regcode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 加密分组
DROP TABLE IF EXISTS `user_pwd_group`;
@@ -212,7 +216,7 @@ CREATE TABLE IF NOT EXISTS `user_pwd_group` (
`description` varchar(128) NOT NULL DEFAULT '' COMMENT '描述',
`display` int(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT '主页显示',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 收录申请
DROP TABLE IF EXISTS `user_apply`;
@@ -231,7 +235,7 @@ CREATE TABLE IF NOT EXISTS `user_apply` (
`category_name` varchar(512) NOT NULL DEFAULT '' COMMENT '分类名',
`description` varchar(512) NOT NULL DEFAULT '' COMMENT '描述',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 书签分享
DROP TABLE IF EXISTS `user_share`;
@@ -250,5 +254,5 @@ CREATE TABLE IF NOT EXISTS `user_share` (
`data` text NOT NULL COMMENT '数据',
`pv` int(1) NOT NULL COMMENT '私有可见',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@@ -0,0 +1,12 @@
<?php if(!defined('DIR')){header('HTTP/1.1 404 Not Found');header("status: 404 Not Found");exit;}
$sql =<<<EOF
INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
('link_extend', '链接扩展', '允许使用链接扩展字段'),
('theme_in', '主题设置', '后台显示主题设置菜单'),
('theme_set', '主题配置', '允许自定义主题配置');
EOF;
if(exe_sql($sql)){
insert_db('updatadb_logs',['file_name'=>$file_name,'update_time'=>time(),'status'=>'TRUE','extra'=>'']);
}else{
msg(-1,'数据库更新失败');
}

View File

@@ -35,6 +35,7 @@ CREATE TABLE IF NOT EXISTS "updatadb_logs" (
"extra" TEXT(512) NOT NULL DEFAULT "",
CONSTRAINT "file_name" UNIQUE ("file_name" ASC)
);
INSERT INTO "updatadb_logs" ("id", "file_name", "update_time", "status", "extra") VALUES ('1', '20230417.php', '1681719049', 'TRUE', '');
-- 创建用户表
CREATE TABLE IF NOT EXISTS "global_user" (
@@ -158,7 +159,10 @@ INSERT INTO `purview_list` (`code`, `name`, `description`) VALUES
('link', '链接管理', '允许添加/编辑/删除链接(未勾选时只读)'),
('apply', '收录管理', '允许使用收录功能'),
('link_pwd', '加密管理', '允许使用加密管理(未勾选时只读)'),
('guestbook', '留言板', '允许使用留言板功能');
('guestbook', '留言板', '允许使用留言板功能'),
('link_extend', '链接扩展', '允许使用链接扩展字段'),
('theme_in', '主题设置', '后台显示主题设置菜单'),
('theme_set', '主题配置', '允许自定义主题配置');
-- 注册码列表
CREATE TABLE IF NOT EXISTS "regcode_list" (

View File

@@ -197,9 +197,14 @@ if( $page == 'theme_home' || $page == 'theme_login' || $page == 'theme_transit'
//菜单接口
if ($page == 'menu') {
$menu = array(
['title'=>'站点设置','href'=>'SiteSetting','icon'=>'fa fa-cog'],
['title'=>'主题设置','href'=>'theme_home','icon'=>'fa fa-magic'],
$menu = [];
if(check_purview('site_info',1)){
array_push($menu,['title'=>'站点设置','href'=>'SiteSetting','icon'=>'fa fa-cog']);
}
if(check_purview('theme_in',1)){
array_push($menu,['title'=>'主题设置','href'=>'theme_home','icon'=>'fa fa-magic']);
}
array_push($menu,
['title'=>'分类管理','href'=>'category_list','icon'=>'fa fa-list-ul'],
['title'=>'加密管理','href'=>'pwd_group','icon'=>'fa fa-lock'],
['title'=>'链接管理','icon'=>'fa fa-folder-open-o','href'=>'','child'=>

View File

@@ -282,6 +282,18 @@ function write_category(){
//读链接列表
function read_link_list(){
if($_GET['type'] == 'extend_list'){
if($GLOBALS['global_config']['link_extend'] != 1 || !check_purview('link_extend',1)){
msgA(['code'=>1,'msg'=>'无权限','count'=>0,'data'=>[]]);
}
$list = get_db("user_config","v",["k"=>"s_extend_list","uid"=>UID]);
if(empty($list)){
msgA(['code'=>1,'msg'=>'无数据','count'=>0,'data'=>[]]);
}
$list = unserialize($list);
msgA(['code'=>1,'msg'=>'获取成功','count'=>count($list),'data'=>$list]);
}
$query = $_POST['query'];
$fid = intval(@$_POST['fid']); //获取分类ID
$page = empty(intval($_REQUEST['page'])) ? 1 : intval($_REQUEST['page']);
@@ -541,6 +553,22 @@ function write_link(){
'icon' => $icon
];
//扩展字段
if($GLOBALS['global_config']['link_extend'] == 1 && check_purview('link_extend',1)){
$list = get_db("user_config","v",["k"=>"s_extend_list","uid"=>UID]);
if(!empty($list)){
$list = unserialize($list);
$extend = [];
foreach($list as $field){
$name = "_{$field['name']}";
if(isset($_POST[$name])){
$data['extend'][$name] = $_POST[$name];
}
}
}
}
//非必须参数,未传递参数时
if(isset($_POST['icon'])){
//指定本地图标时检测是否存在
@@ -641,12 +669,86 @@ function write_link(){
if(empty($fid)){msg(-1,'分类ID错误');}
//加一个查找分类是否存在
update_db('user_links',['fid'=>$fid],['uid'=>UID ,"lid" => json_decode($_POST['lid']) ],[1,'设置成功']);
//图标拉取(不完善,未开放使用)
}elseif($_GET['type'] === 'icon_pull'){
$link = get_db('user_links','url',['uid'=>UID,'lid'=>$_POST['id']]);
if(empty($link)){
msg(-1,'请求的链接id不存在');
}
$s_site = unserialize(get_db("user_config","v",["k"=>"s_site","uid"=>UID]));
if(empty($s_site['link_icon']) || $s_site['link_icon'] == 0){
msg(-1,'站点设置链接图标不能是离线图标!请先修改配置!');
}
$icon = $s_site['link_icon'];
if($icon ==2){
function base64($url){
$urls = parse_url($url);
$scheme = empty( $urls['scheme'] ) ? 'http://' : $urls['scheme'].'://'; //获取请求协议
$host = $urls['host']; //获取主机名
$port = empty( $urls['port'] ) ? '' : ':'.$urls['port']; //获取端口
$new_url = $scheme.$host.$port;
return base64_encode($new_url);
}
$api = 'https://favicon.rss.ink/v1/'.base64($link);
}elseif($icon ==4){
$api = 'https://api.15777.cn/get.php?url='.$link;
}elseif($icon ==5){
$api = 'https://favicon.cccyun.cc/'.$link;
}elseif($icon ==6){
$api = 'https://api.iowen.cn/favicon/'.parse_url($link)['host'].'.png';
}elseif($icon ==7){
$api = 'https://toolb.cn/favicon/'.parse_url($link)['host'];
}
if(downFile($api,$_POST['id'].'.ico',DIR ."/data/user/".U."/favicon/")){
update_db('user_links',['icon'=>"./data/user/".U.'/favicon/'.$_POST['id'].'.ico'],['uid'=>UID ,"lid" => $_POST['id'] ],[1,'获取成功']);
}
msg(-1,'获取失败');
}elseif($_GET['type'] == 'extend_list'){
if($GLOBALS['global_config']['link_extend'] != 1 ||!check_purview('link_extend',1)){
msg(-1,'无权限');
}
$lists = json_decode($_POST['list'],true);
$weight = [];
foreach ($lists as $data ){
if(empty($data['weight']) || !preg_match('/^\d$/', $data['weight'])){
msgA( ['code' => -1,'msg' => '序号错误,请输入正整数'] );
}
if(empty($data['title']) || check_xss($data['title'])){
msgA( ['code' => -1,'msg' => '标题不能为空'] );
}
if(empty($data['name']) || check_xss($data['name']) || !preg_match('/^[A-Za-z0-9]{3,18}$/',$data['name'])){
msgA( ['code' => -1,'msg' => '字段名错误,请输入长度3-18的字母/数字'] );
}
if(!in_array($data['type'],['text','textarea'])){
msgA( ['code' => -1,'msg' => '类型错误'] );
}
}
if(is_Duplicated($lists,'weight')){
msg(-1,'序号不能重复');
}elseif(is_Duplicated($lists,'title')){
msg(-1,'标题不能重复');
}elseif(is_Duplicated($lists,'name')){
msg(-1,'字段名不能重复');
}
$datas = [];
foreach ($lists as $key => $data ){
array_push($datas,['title'=>$data['title'],'name'=>$data['name'],'weight'=>$data['weight'],'type'=>$data['type'],'default'=> "{$data['default']}"]);
}
//根据序号排序
usort($datas, function($a, $b) {
return $a['weight'] - $b['weight'];
});
write_user_config('s_extend_list',$datas,'config','链接扩展字段');
msgA( ['code' => 1,'msg' => '保存成功','datas'=>$datas] );
}
msg(-1,'操作类型错误');
}
//写安全设置
function write_security_setting(){
global $USER_DB;
@@ -844,7 +946,7 @@ function write_site_setting(){
'keywords'=>['empty'=>true],
'description'=>['empty'=>true],
'link_model'=>['v'=>['direct','Privacy','Privacy_js','Privacy_meta','301','302','Transition'],'msg'=>'链接模式参数错误'],
'link_icon'=>['int'=>true,'min'=>0,'max'=>6,'msg'=>'链接图标参数错误'],
'link_icon'=>['int'=>true,'min'=>0,'max'=>10,'msg'=>'链接图标参数错误'],
'site_icon'=>['empty'=>true],
'top_link'=>['int'=>true,'min'=>0,'max'=>20,'msg'=>'热门链接参数错误'],
'new_link'=>['int'=>true,'min'=>0,'max'=>20,'msg'=>'最新链接参数错误'],
@@ -1123,6 +1225,9 @@ function write_theme(){
//配置主题信息
}elseif($_GET['type'] == 'config'){
if(!check_purview('theme_set',1)){
msg(-1,"无权限!");
}
if(empty($_POST)){
msg(-1,"POST请求数据不能为空");
}

View File

@@ -505,6 +505,7 @@ function write_sys_settings(){
//扩展功能-(全局开关)
'apply'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'收录管理参数错误'],
'guestbook'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'留言管理参数错误'],
'link_extend'=>['int'=>true,'min'=>0,'max'=>1,'msg'=>'链接扩展参数错误'],
];
$o_config = [];
foreach ($datas as $key => $data){

View File

@@ -18,7 +18,7 @@ if(empty($link)){
//站点设置和站点图标
$site = unserialize(get_db('user_config','v',['uid'=>UID,'k'=>'s_site']));
$favicon = ( !empty($site['site_icon_file'])) ? $site['site_icon'] : './favicon.ico';
$site['Title'] = $site['title'].(empty($site['subtitle'])?'':' - '.$site['subtitle']);
//取登录状态
$is_login = is_login();
@@ -111,10 +111,6 @@ if(!is_file($transit_path)){
$copyright = empty($global_config['copyright'])?'<a target="_blank" href="https://gitee.com/tznb/twonav">Copyright © TwoNav</a>':$global_config['copyright'];
$ICP = empty($global_config['ICP'])?'':'<a target="_blank" href="https://beian.miit.gov.cn">'.$global_config['ICP'].'</a>';
//读取站点配置
$s_site = unserialize(get_db("user_config","v",["k"=>"s_site","uid"=>UID]));
//var_dump($link,$transit_path,$category_parent,$category_ancestor,$s_site);
//统计点击数
write_user_count(date('Ym'),'click_Ym');
@@ -124,19 +120,21 @@ update_db("user_links", ["click[+]"=>1],['uid'=>UID,'lid'=>$id]);
//读取过渡页设置
$transition_page = unserialize(get_db("user_config","v",["t"=>"config","k"=>"s_transition_page","uid"=>UID]));
//载入站点设置
$site = unserialize(get_db('user_config','v',['uid'=>UID,'k'=>'s_site']));
//读取用户主题配置
$theme_config_db = unserialize(get_db('user_config','v',['t'=>'theme','k'=>$s_templates['transit'],'uid'=>UID]));
//读取默认主题配置
$theme_info = json_decode(@file_get_contents($dir_path.'/info.json'),true);
$theme_config = empty($theme_info['config']) ? []:$theme_info['config'];
$theme_ver = !Debug?$theme_info['version']:$theme_info['version'].'.'.time();
//合并配置数据
$theme_config = empty($theme_config_db) ? $theme_config : array_merge ($theme_config??[],$theme_config_db??[]);
//如果主题信息声明支持扩展字段
if($global_config['link_extend'] == 1 && check_purview('link_extend',1) && in_array($theme_info['support']['link_extend'],["true","1"])){
$extend = empty($link['extend']) ? [] : unserialize($link['extend']);
}
//如果存在备用链接,则强制载入过渡页
if(!empty($link['url_standby'])) {

View File

@@ -69,7 +69,7 @@ $fid_s = array_column($fid_s,null,'cid');
//根据分类ID查询二级分类
function get_category_sub($id) {
global $site,$share,$data;
global $share,$data;
//禁止搜索非数字
if(intval($id) == 0){
return;
@@ -264,77 +264,4 @@ if(empty($_GET['share']) && !$site['ex_theme']){
write_user_count(date('Ym'),'index_Ym');
write_user_count(date('Ymd'),'index_Ymd');
//载入模板
require($index_path);
//取分类图标(六零系主题在用)
function get_category($content){
if(empty($content)){
return '';
}
if(substr($content, 0,4) == '<svg'){
return 'data:image/svg+xml;base64,'.base64_encode($content);
}else{
return $content;
}
}
//获取公开分类(返回数组cid)
function get_open_category(){
$where['uid'] = UID;
$where['fid'] = 0;
$where['status'] = 1;
$where['property'] = 0;
$categorys = select_db('user_categorys','cid',$where);
$where['fid'] = $categorys;
$categorys = array_merge ($categorys,select_db('user_categorys','cid',$where));
return $categorys;
}
//获取图标URL
function geticourl($icon,$link){
if( !empty( $link['icon']) ){
if(substr($link['icon'], 0,4) == '<svg'){
return('data:image/svg+xml;base64,'.base64_encode($link['icon']));
}else{
return($link['icon']);
}
}
if ($site['link_icon'] == 'default'){
return($GLOBALS['libs'].'/Other/default.ico');
}elseif ($icon ==1){
return('./favicon/index2.php?url='.$link['real_url']);
}elseif($icon ==2){
return('//favicon.rss.ink/v1/'.base64($link['real_url']));
}elseif($icon ==4){
return('//api.15777.cn/get.php?url='.$link['real_url']);
}elseif($icon ==5){
return('//favicon.cccyun.cc/'.$link['real_url']);
}elseif($icon ==6){
return('//api.iowen.cn/favicon/'.parse_url($link['real_url'])['host'].'.png');
}elseif($icon ==0){
return('./system/ico.php?text='.mb_strtoupper(mb_substr($link['title'], 0, 1)));
}else{
return('./favicon/index2.php?url='.$link['real_url']);
}//如果参数错误则使用本地服务器
}
//将URL转换为base64编码
function base64($url){
$urls = parse_url($url);
$scheme = empty( $urls['scheme'] ) ? 'http://' : $urls['scheme'].'://'; //获取请求协议
$host = $urls['host']; //获取主机名
$port = empty( $urls['port'] ) ? '' : ':'.$urls['port']; //获取端口
$new_url = $scheme.$host.$port;
return base64_encode($new_url);
}
//是否启用收录
function is_apply(){
global $global_config;
$apply_user = unserialize( get_db("user_config", "v", ["k" => "apply","uid"=>UID]));
return ($global_config['apply'] == 1 && $apply_user['apply'] == 1);
}
//是否启用留言
function is_guestbook(){
global $global_config;
$guestbook_user = unserialize( get_db("user_config", "v", ["k" => "guestbook","uid"=>UID]) );
return ($global_config['guestbook'] == 1 && $guestbook_user['allow'] == 1);
}
require($index_path);

View File

@@ -582,7 +582,18 @@ function getindexurl(){
$HOST = $http_type.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
return($HOST);
}
//检查数组指定字段是否有重复值
function is_Duplicated($array, $field){
$values = [];
foreach($array as $item){
if(in_array($item[$field], $values)){
return true;
}else{
$values[] = $item[$field];
}
}
return false;
}
//检查权限(有权限返回true 没有权限时根传递参数1是返回false 2是直接返回错误信息)
function check_purview($name,$return_type){
global $USER_DB;

View File

@@ -12,3 +12,84 @@ if(empty($s_templates)){
$s_templates = $global_templates;
insert_db("user_config", ["uid" => UID,"k"=>"s_templates","v"=>$global_templates,"t"=>"config","d" => '默认模板']);
}
//载入辅助函数
if(empty($c) || in_array($c,['index','click'])){
//将URL转换为base64编码
function base64($url){
$urls = parse_url($url);
$scheme = empty( $urls['scheme'] ) ? 'http://' : $urls['scheme'].'://'; //获取请求协议
$host = $urls['host']; //获取主机名
$port = empty( $urls['port'] ) ? '' : ':'.$urls['port']; //获取端口
$new_url = $scheme.$host.$port;
return base64_encode($new_url);
}
//是否启用收录
function is_apply(){
global $global_config;
$apply_user = unserialize( get_db("user_config", "v", ["k" => "apply","uid"=>UID]));
return ($global_config['apply'] == 1 && $apply_user['apply'] == 1);
}
//是否启用留言
function is_guestbook(){
global $global_config;
$guestbook_user = unserialize( get_db("user_config", "v", ["k" => "guestbook","uid"=>UID]) );
return ($global_config['guestbook'] == 1 && $guestbook_user['allow'] == 1);
}
//获取图标URL
function geticourl($icon,$link){
if( !empty( $link['icon']) ){
if(substr($link['icon'], 0,4) == '<svg'){
return('data:image/svg+xml;base64,'.base64_encode($link['icon']));
}else{
return($link['icon']);
}
}
if ($site['link_icon'] == 'default'){
return($GLOBALS['libs'].'/Other/default.ico');
}elseif ($icon ==1){
return('./favicon/index2.php?url='.$link['real_url']);
}elseif($icon ==2){
return('//favicon.rss.ink/v1/'.base64($link['real_url']));
}elseif($icon ==4){
return('//api.15777.cn/get.php?url='.$link['real_url']);
}elseif($icon ==5){
return('//favicon.cccyun.cc/'.$link['real_url']);
}elseif($icon ==6){
return('//api.iowen.cn/favicon/'.parse_url($link['real_url'])['host'].'.png');
}elseif($icon ==7){
return('https://toolb.cn/favicon/'.parse_url($link['real_url'])['host']);
}elseif($icon ==8){
return('https://apis.jxcxin.cn/api/Favicon?url='.$link['real_url']);
}elseif($icon ==0){
return('./system/ico.php?text='.mb_strtoupper(mb_substr($link['title'], 0, 1)));
}else{
return('./favicon/index2.php?url='.$link['real_url']);
}//如果参数错误则使用本地服务器
}
//取分类图标(六零系主题在用)
function get_category($content){
if(empty($content)){
return '';
}
if(substr($content, 0,4) == '<svg'){
return 'data:image/svg+xml;base64,'.base64_encode($content);
}else{
return $content;
}
}
//获取公开分类(返回数组cid)
function get_open_category(){
$where['uid'] = UID;
$where['fid'] = 0;
$where['status'] = 1;
$where['property'] = 0;
$categorys = select_db('user_categorys','cid',$where);
$where['fid'] = $categorys;
$categorys = array_merge ($categorys,select_db('user_categorys','cid',$where));
return $categorys;
}
}

View File

@@ -1 +1 @@
v2.0.11-20230414
v2.0.12-20230417