Browse Source

新增直链开关

pull/90/head
川南吴彦祖 2 years ago
parent
commit
47b10a61bc
  1. 2
      config.simple.php
  2. 2
      controller/api.php
  3. 33
      controller/index.php
  4. 7
      templates/admin/setting/site.php
  5. 2
      templates/default/index.php

2
config.simple.php

@ -28,6 +28,8 @@ $site_setting['logo'] = 'OneNav';
$site_setting['keywords'] = 'OneNav,OneNav导航,OneNav书签,开源导航,开源书签,简洁导航,云链接,个人导航,个人书签'; $site_setting['keywords'] = 'OneNav,OneNav导航,OneNav书签,开源导航,开源书签,简洁导航,云链接,个人导航,个人书签';
//站点描述 //站点描述
$site_setting['description'] = 'OneNav是一款使用PHP + SQLite3开发的简约导航/书签管理器,免费开源。'; $site_setting['description'] = 'OneNav是一款使用PHP + SQLite3开发的简约导航/书签管理器,免费开源。';
//直链
$site_setting['straight'] = '';
//这两项不要修改 //这两项不要修改
$site_setting['user'] = USER; $site_setting['user'] = USER;

2
controller/api.php

@ -295,6 +295,8 @@ function set_site($api) {
$data['subtitle'] = htmlspecialchars($_POST['subtitle']); $data['subtitle'] = htmlspecialchars($_POST['subtitle']);
//获取关键词 //获取关键词
$data['keywords'] = htmlspecialchars($_POST['keywords']); $data['keywords'] = htmlspecialchars($_POST['keywords']);
//获取是否直链
$data['straight'] = htmlspecialchars($_POST['straight']);
//获取描述 //获取描述
$data['description'] = htmlspecialchars($_POST['description']); $data['description'] = htmlspecialchars($_POST['description']);
//获取自定义header //获取自定义header

33
controller/index.php

@ -48,7 +48,7 @@ if( is_login() ){
'fid' => $fid, 'fid' => $fid,
'ORDER' => ["weight" => "DESC"] 'ORDER' => ["weight" => "DESC"]
]); ]);
return $links; return handle_link($links);
} }
//右键菜单标识 //右键菜单标识
$onenav['right_menu'] = 'admin_menu();'; $onenav['right_menu'] = 'admin_menu();';
@ -100,12 +100,39 @@ else{
'property' => 0, 'property' => 0,
'ORDER' => ["weight" => "DESC"] 'ORDER' => ["weight" => "DESC"]
]); ]);
return $links; return handle_link($links);
} }
//右键菜单标识 //右键菜单标识
$onenav['right_menu'] = 'user_menu();'; $onenav['right_menu'] = 'user_menu();';
} }
//处理得到的转换链接数据
function handle_link($data)
{
if (empty($data)) {
return $data;
}
global $db;
$site = $db->get('on_options', 'value', ['key' => "s_site"]);
$site = unserialize($site);
$type = 1; //模式1 原链接
if (! empty($site['straight']) && $site['straight'] == "open") {
//有且只有开关的时候 才处理
$type = 2; //模式2 新链接
}
$hrefLink = "";
foreach ($data as &$value) {
switch ($type) {
case "1":
$hrefLink = "/index.php?c=click&id=" . $value['id'];
break;
case "2":
$hrefLink = $value['url'];
break;
}
$value['href_link'] = $hrefLink;
}
return $data;
}
//获取版本号 //获取版本号
function get_version(){ function get_version(){
if( file_exists('version.txt') ) { if( file_exists('version.txt') ) {

7
templates/admin/setting/site.php

@ -50,7 +50,12 @@
<textarea placeholder="网站描述,一般不超过200字符" name = "description" class="layui-textarea"><?php echo $site['description']; ?></textarea> <textarea placeholder="网站描述,一般不超过200字符" name = "description" class="layui-textarea"><?php echo $site['description']; ?></textarea>
</div> </div>
</div> </div>
<div class="layui-form-item" pane="">
<label class="layui-form-label">是否直链</label>
<div class="layui-input-block">
<input type="checkbox" <?php if($site['straight']=="open"){echo 'checked=""';} ?> name="straight" value="open" lay-skin="switch" lay-filter="switchTest" title="开关">
</div>
</div>
<div class="layui-form-item layui-form-text"> <div class="layui-form-item layui-form-text">
<label class="layui-form-label">自定义header</label> <label class="layui-form-label">自定义header</label>
<div class="layui-input-block"> <div class="layui-input-block">

2
templates/default/index.php

@ -207,7 +207,7 @@
$id = $link['id']; $id = $link['id'];
//var_dump($link); //var_dump($link);
?> ?>
<a href="/index.php?c=click&id=<?php echo $link['id']; ?>" target="_blank" title = "<?php echo $link['description']; ?>"> <a href="<?php echo $link['href_link']; ?>" target="_blank" title = "<?php echo $link['description']; ?>">
<div class="mdui-col-lg-2 mdui-col-md-3 mdui-col-sm-4 mdui-col-xs-6 link-space" id = "id_<?php echo $link['id']; ?>" link-title = "<?php echo $link['title']; ?>" link-url = "<?php echo $link['url']; ?>"> <div class="mdui-col-lg-2 mdui-col-md-3 mdui-col-sm-4 mdui-col-xs-6 link-space" id = "id_<?php echo $link['id']; ?>" link-title = "<?php echo $link['title']; ?>" link-url = "<?php echo $link['url']; ?>">
<!-- 用来搜索匹配使用 --> <!-- 用来搜索匹配使用 -->
<span style = "display:none;"><?php echo $link['url']; ?></span> <span style = "display:none;"><?php echo $link['url']; ?></span>

Loading…
Cancel
Save