2022-02-19 23:38:30 +08:00
|
|
|
|
<?php
|
|
|
|
|
$title='链接管理';
|
|
|
|
|
include './head.php';
|
2022-02-22 03:03:09 +08:00
|
|
|
|
$grouplists =mysqli_query($con,"SELECT * FROM `lylme_groups`");
|
2022-02-19 23:38:30 +08:00
|
|
|
|
?>
|
2022-02-22 03:03:09 +08:00
|
|
|
|
<main class="lyear-layout-content">
|
|
|
|
|
|
|
|
|
|
<div class="container-fluid">
|
|
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
|
<div class="col-lg-12">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="card-body">
|
2022-02-19 23:38:30 +08:00
|
|
|
|
<?php
|
2022-02-22 03:03:09 +08:00
|
|
|
|
|
2022-02-19 23:38:30 +08:00
|
|
|
|
$set=isset($_GET['set'])?$_GET['set']:null;
|
|
|
|
|
|
|
|
|
|
if($set=='add')
|
|
|
|
|
{
|
2022-02-22 03:03:09 +08:00
|
|
|
|
echo '<h4>新增链接</h4>
|
|
|
|
|
<div class="panel-body">
|
|
|
|
|
<form action="./link.php?set=add_submit" method="POST">
|
2022-02-19 23:38:30 +08:00
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>*名称:</label><br>
|
|
|
|
|
<input type="text" class="form-control" name="name" value="" required>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>*URL链接地址:</label><br>
|
|
|
|
|
<input type="text" class="form-control" name="url" value="" required>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>链接图标:</label><br>
|
2022-02-22 03:03:09 +08:00
|
|
|
|
<textarea type="text" class="form-control" name="icon"></textarea>
|
|
|
|
|
<small class="help-block">方式1:填写图标的<code>URL</code>地址,如<code>/img/logo.png</code>或<code>http://www.xxx.com/img/logo.png</code><br>
|
|
|
|
|
方式2:粘贴图标的<code>SVG</code>代码,<a href="/admin/help.php?doc=icon" target="_blank">查看教程</a><br>方式3:留空使用默认图标</small>
|
2022-02-19 23:38:30 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
2022-02-22 03:03:09 +08:00
|
|
|
|
<label>*分组:</label><br>
|
|
|
|
|
<select class="form-control" name="group_id">';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
|
2022-02-22 03:03:09 +08:00
|
|
|
|
while($grouplist = mysqli_fetch_assoc($grouplists)) {
|
|
|
|
|
if($grouplist["group_id"]==$row['group_id']){$select='selected="selected"';}else {$select='';}
|
|
|
|
|
echo '<option value="'.$grouplist["group_id"].'">'.$grouplist["group_id"].' - '.$grouplist["group_name"].'</option>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
}
|
2022-02-22 03:03:09 +08:00
|
|
|
|
echo '</select></div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<input type="submit" class="btn btn-primary btn-block" value="确定添加"></form>
|
|
|
|
|
</div>
|
|
|
|
|
<br/><a href="./link.php"><<返回链接列表</a>
|
|
|
|
|
</div></div>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
}
|
|
|
|
|
elseif($set=='edit')
|
|
|
|
|
{
|
|
|
|
|
$id=$_GET['id'];
|
2022-02-22 03:03:09 +08:00
|
|
|
|
$row2 = mysqli_query($con,"select * from lylme_links where id='$id' limit 1");
|
|
|
|
|
$row=mysqli_fetch_assoc($row2);
|
|
|
|
|
echo '<h4>修改链接信息</h4>
|
|
|
|
|
<div class="panel-body">
|
|
|
|
|
<form action="./link.php?set=edit_submit&id='.$id.'" method="POST">
|
2022-02-19 23:38:30 +08:00
|
|
|
|
<div class="form-group">
|
2022-02-22 03:03:09 +08:00
|
|
|
|
<label>*名称:</label><br>
|
2022-02-19 23:38:30 +08:00
|
|
|
|
<input type="text" class="form-control" name="name" value="'.$row['name'].'" required>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
2022-02-22 03:03:09 +08:00
|
|
|
|
<label>*URL链接地址:</label><br>
|
2022-02-19 23:38:30 +08:00
|
|
|
|
<input type="text" class="form-control" name="url" value="'.$row['url'].'" required>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
2022-02-22 03:03:09 +08:00
|
|
|
|
<label>链接图标:</label><br>
|
|
|
|
|
<textarea type="text" class="form-control" name="icon" >'.$row['icon'].'</textarea>
|
|
|
|
|
<small class="help-block">方式1:填写图标的<code>URL</code>地址,如<code>/img/logo.png</code>或<code>http://www.xxx.com/img/logo.png</code><br>
|
|
|
|
|
方式2:粘贴图标的<code>SVG</code>代码,<a href="/admin/help.php?doc=icon" target="_blank">查看教程</a><br>方式3:留空使用默认图标<br>方式3:留空使用默认图标</small>
|
2022-02-19 23:38:30 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
2022-02-22 03:03:09 +08:00
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>*分组:</label><br>
|
|
|
|
|
<select class="form-control" name="group_id">';
|
|
|
|
|
while($grouplist = mysqli_fetch_assoc($grouplists)) {
|
|
|
|
|
if($grouplist["group_id"]==$row['group_id']){$select='selected="selected"';}else {$select='';}
|
|
|
|
|
echo '<option value="'.$grouplist["group_id"].'" '.$select.'>'.$grouplist["group_id"].' - '.$grouplist["group_name"].'</option>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
}
|
2022-02-22 03:03:09 +08:00
|
|
|
|
echo '</select>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<input type="submit" class="btn btn-primary btn-block" value="确定修改"></form>
|
|
|
|
|
</div>
|
|
|
|
|
<br/><a href="./link.php"><<返回链接列表</a>
|
|
|
|
|
</div></div>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
}
|
|
|
|
|
elseif($set=='add_submit')
|
|
|
|
|
{
|
|
|
|
|
$name=$_POST['name'];
|
|
|
|
|
$url=$_POST['url'];
|
2022-02-22 03:03:09 +08:00
|
|
|
|
$icon=$_POST['icon'];
|
|
|
|
|
$group_id=$_POST['group_id'];
|
2022-02-23 21:20:04 +08:00
|
|
|
|
$link_order = $linksrows+1;
|
2022-02-19 23:38:30 +08:00
|
|
|
|
if($name==NULL or $url==NULL){
|
2022-02-22 03:03:09 +08:00
|
|
|
|
echo '<script>alert("保存错误,请确保带星号的都不为空!");history.go(-1);</script>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
} else {
|
2022-02-23 21:34:29 +08:00
|
|
|
|
$sql="INSERT INTO `lylme_links` (`id`, `name`, `group_id`, `url`, `icon`, `PS`,`link_order`) VALUES (NULL, '".$name."', '".$group_id."', '".$url."', '".$icon."', '".$name."', '".$link_order."');";
|
2022-02-22 03:03:09 +08:00
|
|
|
|
|
|
|
|
|
if(mysqli_query($con,$sql)){
|
|
|
|
|
echo '<script>alert("添加链接 '.$name.' 成功!");window.location.href="/admin/link.php";</script>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
}else
|
2022-02-22 03:03:09 +08:00
|
|
|
|
echo '<script>alert("添加链接失败");history.go(-1);</script>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
elseif($set=='edit_submit')
|
|
|
|
|
{
|
|
|
|
|
$id=$_GET['id'];
|
2022-02-22 03:03:09 +08:00
|
|
|
|
$rows2 = mysqli_query($con,"select * from lylme_links where id='$id' limit 1");
|
|
|
|
|
$rows=mysqli_fetch_assoc($rows2);
|
2022-02-19 23:38:30 +08:00
|
|
|
|
if(!$rows)
|
2022-02-22 03:03:09 +08:00
|
|
|
|
echo '<script>alert("当前记录不存在!");history.go(-1);</script>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
$name=$_POST['name'];
|
|
|
|
|
$url=$_POST['url'];
|
2022-02-22 03:03:09 +08:00
|
|
|
|
$icon=$_POST['icon'];
|
|
|
|
|
$group_id=$_POST['group_id'];
|
2022-02-19 23:38:30 +08:00
|
|
|
|
if($name==NULL or $url==NULL){
|
2022-02-22 03:03:09 +08:00
|
|
|
|
echo '<script>alert("保存错误,请确保带星号的都不为空!");history.go(-1);</script>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
} else {
|
2022-02-22 03:03:09 +08:00
|
|
|
|
|
|
|
|
|
$sql = "UPDATE `lylme_links` SET `name` = '".$name."', `url` = '".$url."', `icon` = '".$icon."', `group_id` = '".$group_id."' WHERE `lylme_links`.`id` = '".$id."';";
|
|
|
|
|
if(mysqli_query($con,$sql))
|
|
|
|
|
echo '<script>alert("修改链接 '.$name.' 成功!");window.location.href="/admin/link.php";</script>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
else
|
2022-02-23 21:20:04 +08:00
|
|
|
|
echo '<script>alert("修改链接失败!");history.go(-1);</script>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
elseif($set=='delete')
|
|
|
|
|
{
|
|
|
|
|
$id=$_GET['id'];
|
|
|
|
|
$sql="DELETE FROM lylme_links WHERE id='$id'";
|
|
|
|
|
if(mysqli_query($con,$sql))
|
2022-02-22 03:03:09 +08:00
|
|
|
|
echo '<script>alert("删除成功!");window.location.href="/admin/link.php";</script>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
else
|
2022-02-23 21:20:04 +08:00
|
|
|
|
echo '<script>alert("删除失败!");history.go(-1);</script>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$sql=" 1";
|
2022-02-22 03:03:09 +08:00
|
|
|
|
$cons='系统共有 <b>'.$linksrows.'</b> 个链接<br/><a href="./link.php?set=add" class="btn btn-primary">新增链接</a>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
|
|
|
|
|
echo '<div class="alert alert-info">';
|
2022-02-22 03:03:09 +08:00
|
|
|
|
echo $cons;
|
2022-02-19 23:38:30 +08:00
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
<div class="table-responsive">
|
|
|
|
|
<table class="table table-striped">
|
2022-02-22 03:03:09 +08:00
|
|
|
|
<thead><tr><th>ID</th><th>名称</th><th>链接</th><th>分组ID</th><th>操作</th></tr></thead>
|
2022-02-19 23:38:30 +08:00
|
|
|
|
<tbody>
|
|
|
|
|
<?php
|
|
|
|
|
$pagesize=30;
|
2022-02-22 05:31:25 +08:00
|
|
|
|
$pages=intval($linksrows/$pagesize);
|
|
|
|
|
if ($linksrows%$pagesize)
|
2022-02-19 23:38:30 +08:00
|
|
|
|
{
|
|
|
|
|
$pages++;
|
|
|
|
|
}
|
|
|
|
|
if (isset($_GET['page'])){
|
|
|
|
|
$page=intval($_GET['page']);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
$page=1;
|
|
|
|
|
}
|
|
|
|
|
$offset=$pagesize*($page - 1);
|
|
|
|
|
|
2022-02-22 03:03:09 +08:00
|
|
|
|
$rs=mysqli_query($con,"SELECT * FROM lylme_links WHERE{$sql} order by id asc");
|
2022-02-19 23:38:30 +08:00
|
|
|
|
while($res = mysqli_fetch_array($rs))
|
|
|
|
|
{
|
2022-02-22 03:03:09 +08:00
|
|
|
|
echo '<tr><td><b>'.$res['id'].'</b></td><td>'.$res['name'].'</td><td>'.$res['url'].'</td><td>'.$res['group_id'].'</td><td><a href="./link.php?set=edit&id='.$res['id'].'" class="btn btn-info btn-xs">编辑</a> <a href="./link.php?set=delete&id='.$res['id'].'" class="btn btn-xs btn-danger" onclick="return confirm(\'你确实要删除 '.$res['name'].' 吗?\');">删除</a></td></tr>';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
2022-02-22 03:03:09 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
2022-02-19 23:38:30 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
2022-02-22 03:03:09 +08:00
|
|
|
|
</main>
|
2022-02-19 23:38:30 +08:00
|
|
|
|
<?php
|
2022-02-22 03:03:09 +08:00
|
|
|
|
|
2022-02-19 23:38:30 +08:00
|
|
|
|
}
|
2022-02-22 03:03:09 +08:00
|
|
|
|
|
|
|
|
|
include './footer.php';
|
2022-02-19 23:38:30 +08:00
|
|
|
|
?>
|