forked from renbaoshuo/Shortlink
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8a7082
commit 7a9c2fa
Showing
6 changed files
with
128 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Options -Indexes | ||
order deny,allow | ||
|
||
<Files ~ "^.(htaccess|htpasswd)$"> | ||
deny from all | ||
</Files> | ||
|
||
<Files ~ "^database.db"> | ||
deny from all | ||
</Files> | ||
|
||
RewriteEngine On | ||
RewriteCond $1 !^(api|asset) | ||
RewriteRule ^(\d+|\w+)$ index.php?id=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
# Shortlink | ||
短链接生成网站源码 | ||
# ShortLink | ||
|
||
代码基于 [CRZ.im](https://github.com/Caringor/CRZ.im) 开发,感谢原作者的辛勤劳动。 | ||
|
||
--- | ||
|
||
> 一个支持域名缩短网站的源代码 | ||
## 概述 | ||
|
||
这是一个网址缩短服务的网站的源代码。 | ||
|
||
## 安装 | ||
|
||
本项目基于 `PHP` 、 `SQLite` 进行开发,您只需要修改 `config.php` 的相关配置并把 inc 目录权限设置为可读写即可。对于 `Nginx` 用户,则还需把 `nginx.txt` 里面的内容添加到 `Nginx` 的配置文件里。 | ||
|
||
## 本项目相比原项目有了什么变化? | ||
|
||
本项目增加了 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
global $config; | ||
$config = []; | ||
|
||
// 程序安装路径 | ||
$config['path'] = '/'; | ||
// ID 长度 | ||
$config['length'] = 8; | ||
// 网站标题 | ||
$config['title'] = '短链生成'; | ||
// 网站简介 | ||
$config['description'] = '在线网址缩短服务'; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
// 引入类 | ||
require_once('inc/require.php'); | ||
|
||
// 重定向 | ||
if(isset($_GET['id'])) { | ||
$url_c = new url(); | ||
// 获取目标网址 | ||
$url = $url_c->get_url($_GET['id']); | ||
// 重定向至目标网址 | ||
if($url) { | ||
header('Location: ' . $url); | ||
exit; | ||
} | ||
} | ||
?> | ||
|
||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<!--标题--> | ||
<title><?php echo get_title() . ' - ' . get_description(); ?></title> | ||
<!--介绍、关键词的放置处(SEO优化)--> | ||
<meta name="description" content="ShortLink 短链接服务"> | ||
<meta name="keyword" content="短链接,ShortLink,Link,链接缩短,短网址"> | ||
<!--引入 CSS 文件--> | ||
<link type="text/css" rel="stylesheet" href="asset/css/main.css"> | ||
</head> | ||
<body> | ||
<div class="wrap"> | ||
<!--网页显示标题--> | ||
<div class="meta"> | ||
<h2 class="title"><?php echo get_title(); ?></h2> | ||
<h3 class="description"><?php echo get_description(); ?></h3> | ||
</div> | ||
<br><br> | ||
<!--链接显示区--> | ||
<div class="link-area"> | ||
<input id="url" type="text" placeholder="源网址" /> | ||
<input id="submit" type="button" value="生成" onclick="APP.fn.setUrl(this)" /> | ||
<br><br> | ||
<input id="shorturl" type="text" placeholder="短网址" readonly/> | ||
<input id="shorturlcopy" type="button" value="复制" onclick="copyText()" /> | ||
</div> | ||
<div class="footer"> | ||
Copyright © <a href="https://www.baoshuo.ren/">宝硕小站</a> | <a href="https://github.com/Caringor/CRZ.im/" title="源码" target="_blank">Github</a> | ||
</div> | ||
</div> | ||
<!--嵌入 JS 代码--> | ||
<script> | ||
document.body.oncopy = function() { | ||
Swal.fire({ | ||
allowOutsideClick:false, | ||
type:'success', | ||
title: '复制成功!', | ||
showConfirmButton: false, | ||
timer: 3000 | ||
}); | ||
}; | ||
</script> | ||
<!--引入 JS 文件--> | ||
<script type="text/javascript" src="asset/js/app.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# REWRITE START | ||
location / { | ||
try_files $uri $uri/ =404; | ||
} | ||
location ~ /inc/ { | ||
return 404; | ||
} | ||
location ~* ^/(?![asset|api]) { | ||
rewrite (\d+|\w+)$ /index.php?id=$1; | ||
} | ||
# REWRITE END |