开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 1 Fork 0

程江科技/TxtShortURL

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
main
分支 (1)
main
main
分支 (1)
main
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
main
分支 (1)
main
TxtShortURL
/
src
/
admin
/
index.php
TxtShortURL
/
src
/
admin
/
index.php
index.php 8.79 KB
一键复制 编辑 原始数据 按行查看 历史
Jackson 提交于 2025年09月22日 15:36 +08:00 . 正式命名为:TxtShortURL
<?php
include_once '../includes/common.php';
include_once '../includes/admin.php';
function time13()
{
list($s1, $s2) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
}
$runtime = time13();
// 查找文件,建立索引
function file_indexes($path)
{
$data = array();
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && $file != '.DS_Store') {
if (is_dir($path . '/' . $file)) {
// file_list($path.'/'.$file);
} else {
array_push($data, str_replace('.txt', '', $file));
}
}
}
return $data;
}
}
function filetime($path)
{
return date('Y-m-d H:i:s', filectime($path));
}
function dellink($id)
{
if (file_exists(ROOT_PATH . '/data/txt/' . $id . '.txt')) {
unlink(ROOT_PATH . '/data/txt/' . $id . '.txt');
// 写入新索引
wdata(ROOT_PATH . '/data/indexes.php', file_indexes(ROOT_PATH . '/data/txt/'));
}
}
if (isset($_REQUEST['act'])) {
if ($_REQUEST['act'] == 'del') {
// 删除记录
if (@strlen($_POST['id']) == 8) {
dellink($_POST['id']);
echo 1;
exit;
}
} else if ($_REQUEST['act'] == 'indexes') {
// 更新索引
wdata(ROOT_PATH . '/data/indexes.php', file_indexes(ROOT_PATH . '/data/txt/'));
}
// $path = dirname(dirname(__FILE__)) . '/data/txt'; // 上级目录
// $path = ROOT_PATH . '/data/txt/';
// die($path);
// echo "<pre>";print_r(file_indexes($path));die;
// wdata(ROOT_PATH . '/data/indexes.php', file_indexes(ROOT_PATH . '/data/txt/'));
// unset($data);
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="renderer" content="webkit" />
<meta name="force-rendering" content="webkit" />
<meta name="robots" content="none, nofollow, noarchive, nocache">
<meta name="referrer" content="never" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="TxtShortURL" />
<meta name="keywords" content="<?php echo $config['site_keywords']; ?>" />
<meta name="description" content="<?php echo $config['site_description']; ?>" />
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" mce_href="favicon.ico">
<title><?php echo $config['site_title']; ?> - 管理后台</title>
<link type="text/css" href="../assets/css/admin.css" rel="stylesheet" />
</head>
<body>
<div class="header">
<h1>TxtShortURL</h1>
</div>
<div class="nav">
<div style="float: left;">
<a class="btn" href="<?php echo $site_url; ?>" title="站点首页" target="_blank">站点首页</a>
<a class="btn" href="<?php echo $site_url; ?>/admin/" title="后台首页">链接管理</a>
<a class="btn" href="<?php echo $site_url; ?>/admin/?act=indexes" title="更新索引">更新索引</a>
<a class="btn" href="<?php echo $site_url; ?>/admin/settings.php" title="系统设置">系统设置</a>
</div>
<div style="float: right;margin-left: 10px;">
<span class="btn" onclick="unlogin()">退出登录</span>
</div>
<div style="float: right;">
<input type="text" value="" id="sdel" class="form-input" /><input type="button" value="删除指定" class="form-input-btn" onclick="dellinks()" />
</div>
</div>
<div class="content">
<table>
<thead>
<tr>
<th width="100">序号</th>
<th>编号</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php
// 后台链接管理
$indexes = rdata(ROOT_PATH . "/data/indexes.php");
$arr = array_reverse($indexes);
unset($indexes);
$articlelenght = count($arr);
$listlenght = ceil($articlelenght / 10);
$p = isset($_REQUEST['p']) ? (int)$_REQUEST['p'] : 1;
if ($p < 0 or $p > $listlenght) {
$p = 1;
}
$page = $p * 10;
$page = $page > $articlelenght ? $articlelenght : $page;
$pages = $page - 10 < 0 ? 0 : $page - 10;
$pgs = $p - 1;
$pgs = $pgs <= 0 ? 1 : $pgs;
$pgx = $p + 1;
$pgx = $pgx > $listlenght ? $listlenght : $pgx;
// echo $pgs."|".$pgx."|".$listlenght."|".$pages."|".$page;die;
$str = "";
for ($i = $pages; $i < $page; $i++) {
$str .= '<tr>' .
'<td data-label="序号">' . $i . '</td>' .
'<td data-label="编号"><a href="' . $site_url . '/s.php?u=' . $arr[$i] . '" target="_blank">' . $arr[$i] . '</a></td>' .
'<td data-label="创建时间">' . filetime(ROOT_PATH . "/data/txt/" . $arr[$i] . ".txt") . '</td>' .
'<td data-label="操作">
<a class="del" href="' . $site_url . '/s.php?u=' . $arr[$i] . '" target="_blank">查看</a>
<a class="del" href="' . $site_url . '/ss.php?u=' . $arr[$i] . '" target="_blank">演示</a>
<a class="del" href="' . $site_url . '/txt.php?u=' . $arr[$i] . '" target="_blank">文本</a>
<a class="del" href="' . $site_url . '/run.php?u=' . $arr[$i] . '" target="_blank">运行</a>
<a class="del" href="javascript:(0);" onclick="dellink(\'' . $arr[$i] . '\')">删除</a>
</td>' .
'</tr>';
}
echo $str;
unset($arr, $str);
?>
<tr>
<td colspan="4" style="width:100%;text-align:center;">
<span class="btn avr"><?php echo $p; ?>页/共<?php echo $listlenght; ?><?php echo $articlelenght; ?></span>
<a href="/admin/?p=1" title="首页" class="btn">首页</a>
<a href="/admin/?p=<?php echo $pgs; ?>" title="上一页" class="btn">上一页</a>
<span title="当前页" class="btn avr"><?php echo $p; ?></span>
<a href="/admin/?p=<?php echo $pgx; ?>" title="下一页" class="btn">下一页</a>
<a href="/admin/?p=<?php echo $listlenght; ?>" title="尾页" class="btn">尾页</a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="footer">
<p>Copyright © <?php echo date('Y'); ?> TxtShortURL All Rights Reserved.</p>
<p><a href="https://github.com/Crogram/TxtShortURL" target="_blank">Github</a> <a href="https://gitee.com/crogram/TxtShortURL" target="_blank">Gitee</a></p>
<p>Powered by <a href="https://crogram.org" target="_blank">Crogram</a></p>
</div>
<script>
function d_post(url, data) {
var httpRequest = new XMLHttpRequest();
httpRequest.open('POST', url, true);
httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
httpRequest.send(data);
httpRequest.onreadystatechange = function() {
if (httpRequest.status == 200) {
if (httpRequest.responseText == 1) {
location.reload();
}
}
};
}
function p_post(url, data) {
var httpRequest = new XMLHttpRequest();
httpRequest.open('POST', url, true);
httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
httpRequest.send(data);
httpRequest.onreadystatechange = function() {
if (httpRequest.status == 200) {
console.log(httpRequest.responseText);
}
};
}
function dellink(id) {
d_post("/admin/?act=del", "id=" + id);
}
function dellinks() {
var id = document.getElementById("sdel").value;
if (id) {
d_post("/admin/?act=del", "id=" + id);
}
}
function unlogin() {
document.cookie = "username=";
document.cookie = "token=";
location.href = "<?php echo $site_url; ?>/admin";
}
</script>
</body>
</html><!--<?php echo time13() - $runtime; ?>ms-->
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

TxtShortURL - 程江短链接系统
暂无标签
MIT
使用 MIT 开源许可协议
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/crogram/TxtShortURL.git
git@gitee.com:crogram/TxtShortURL.git
crogram
TxtShortURL
TxtShortURL
main
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /