优化 输出

This commit is contained in:
LyLme 2022-05-21 20:03:09 +08:00
parent ba37539337
commit 341d3ff7e8
4 changed files with 54 additions and 11 deletions

View File

@ -43,13 +43,18 @@ if (!empty($q)) {
else{ echo '<body>';}?> else{ echo '<body>';}?>
<div id="menu"><i></i></div> <div id="menu"><i></i></div>
<div class="list closed"> <div class="list closed">
<?php <?php
session_start(); //设置session
$groups = $DB->query("SELECT * FROM `lylme_groups` ORDER BY `group_order` ASC"); $groups = $DB->query("SELECT * FROM `lylme_groups` ORDER BY `group_order` ASC");
// 获取分类 // 获取分类
$i = 0; $i = 0;
while ($group = $DB->fetch($groups)) { while ($group = $DB->fetch($groups)) {
//循环所有分组 //循环所有分组
if($group["group_status"]=='0'){continue;}
if(!in_array($group['group_pwd'],$_SESSION['list'])&&!empty($group['group_pwd'])){
//如果 分组加密未在认证列表 并且分组设置了密码(不显示分组)
continue;
}
$sql = "SELECT * FROM `lylme_links` WHERE `group_id` = " . $group['group_id']." ORDER BY `link_order` ASC;"; $sql = "SELECT * FROM `lylme_links` WHERE `group_id` = " . $group['group_id']." ORDER BY `link_order` ASC;";
$group_links = $DB->query($sql); $group_links = $DB->query($sql);
$link_num = $DB->num_rows($group_links); $link_num = $DB->num_rows($group_links);
@ -64,9 +69,18 @@ while ($group = $DB->fetch($groups)) {
while ($link = $DB->fetch($group_links)) { while ($link = $DB->fetch($group_links)) {
// 循环每个链接 // 循环每个链接
// 返回指定分组下的所有字段 // 返回指定分组下的所有字段
$lpwd = true;
if ($link_num > $i) { if ($link_num > $i) {
$i = $i + 1; $i = $i + 1;
if($link["link_status"]!="0"){ if(!empty($group['group_pwd'])&&!empty($link['link_pwd'])){
//分组和链接同时加密
//忽略链接加密正常显示分组
}
else if(!in_array($link['link_pwd'],$_SESSION['list'])&&!empty($link['link_pwd'])){
//当前链接加密
$lpwd = false;
}
if($link["link_status"]!="0" && $lpwd ){
echo "\n" . '<li class="col-3 col-sm-3 col-md-3 col-lg-1"><a rel="nofollow" href="' . $link["url"] . '" target="_blank">'; echo "\n" . '<li class="col-3 col-sm-3 col-md-3 col-lg-1"><a rel="nofollow" href="' . $link["url"] . '" target="_blank">';
if ($link["icon"] == '') { if ($link["icon"] == '') {
echo '<img src="/assets/img/default-icon.png" alt="默认' . $link["name"] . '" />'; echo '<img src="/assets/img/default-icon.png" alt="默认' . $link["name"] . '" />';

View File

@ -15,6 +15,7 @@ $groups = $DB->query("SELECT * FROM `lylme_groups` ORDER BY `group_order` ASC");
$i = 0; //设置起始 $i = 0; //设置起始
while ($group = $DB->fetch($groups)) { while ($group = $DB->fetch($groups)) {
//循环所有分组 //循环所有分组
if($group["group_status"]=='0'){continue;}
if(!in_array($group['group_pwd'],$_SESSION['list'])&&!empty($group['group_pwd'])){ if(!in_array($group['group_pwd'],$_SESSION['list'])&&!empty($group['group_pwd'])){
//如果 分组加密未在认证列表 并且分组设置了密码(不显示分组) //如果 分组加密未在认证列表 并且分组设置了密码(不显示分组)
continue; continue;

View File

@ -10,10 +10,15 @@
// | date: 2022-3-12 | // | date: 2022-3-12 |
// +----------------------------------------------------------+ // +----------------------------------------------------------+
session_start(); //设置session
$groups = $DB->query("SELECT * FROM `lylme_groups` ORDER BY `group_order` ASC"); // 获取分类 $groups = $DB->query("SELECT * FROM `lylme_groups` ORDER BY `group_order` ASC"); // 获取分类
$i = 0; $i = 0; //设置起始
while ($group = $DB->fetch($groups)) { //循环所有分组 while ($group = $DB->fetch($groups)) { //循环所有分组
if($group["group_status"]=='0'){continue;}
if(!in_array($group['group_pwd'],$_SESSION['list'])&&!empty($group['group_pwd'])){
//如果 分组加密未在认证列表 并且分组设置了密码(不显示分组)
continue;
}
$sql = "SELECT * FROM `lylme_links` WHERE `group_id` = " . $group['group_id']." ORDER BY `link_order` ASC;"; $sql = "SELECT * FROM `lylme_links` WHERE `group_id` = " . $group['group_id']." ORDER BY `link_order` ASC;";
$group_links = $DB->query($sql); $group_links = $DB->query($sql);
$link_num = $DB->num_rows($group_links); // 获取返回字段条目数量 $link_num = $DB->num_rows($group_links); // 获取返回字段条目数量
@ -23,11 +28,21 @@ while ($group = $DB->fetch($groups)) { //循环所有分组
$i = 0; $i = 0;
continue; continue;
} }
while ($link = $DB->fetch($group_links)) { // 循环每个链接 while ($link = $DB->fetch($group_links)) {
// 循环每个链接
// 返回指定分组下的所有字段 // 返回指定分组下的所有字段
$lpwd = true;
if ($link_num > $i) { if ($link_num > $i) {
$i = $i + 1; $i = $i + 1;
if($link["link_status"]!="0"){ if(!empty($group['group_pwd'])&&!empty($link['link_pwd'])){
//分组和链接同时加密
//忽略链接加密正常显示分组
}
else if(!in_array($link['link_pwd'],$_SESSION['list'])&&!empty($link['link_pwd'])){
//当前链接加密
$lpwd = false;
}
if($link["link_status"]!="0" && $lpwd ){
echo "\n" . '<li class="col-3 col-sm-3 col-md-3 col-lg-1"><a rel="nofollow" href="' . $link["url"] . '" target="_blank">'; echo "\n" . '<li class="col-3 col-sm-3 col-md-3 col-lg-1"><a rel="nofollow" href="' . $link["url"] . '" target="_blank">';
if ($link["icon"] == '') { if ($link["icon"] == '') {
echo '<img src="/assets/img/default-icon.png" alt="默认' . $link["name"] . '" />'; echo '<img src="/assets/img/default-icon.png" alt="默认' . $link["name"] . '" />';

View File

@ -10,11 +10,15 @@
// | date: 2022-3-12 | // | date: 2022-3-12 |
// +----------------------------------------------------------+ // +----------------------------------------------------------+
session_start(); //设置session
$links = $DB->query("SELECT * FROM `lylme_links`"); // 获取网站
$groups = $DB->query("SELECT * FROM `lylme_groups` ORDER BY `group_order` ASC"); // 获取分类 $groups = $DB->query("SELECT * FROM `lylme_groups` ORDER BY `group_order` ASC"); // 获取分类
$i = 0; $i = 0;
while ($group = $DB->fetch($groups)) { //循环所有分组 while ($group = $DB->fetch($groups)) { //循环所有分组
if($group["group_status"]=='0'){continue;}
if(!in_array($group['group_pwd'],$_SESSION['list'])&&!empty($group['group_pwd'])){
//如果 分组加密未在认证列表 并且分组设置了密码(不显示分组)
continue;
}
$sql = "SELECT * FROM `lylme_links` WHERE `group_id` = " . $group['group_id']." ORDER BY `link_order` ASC;"; $sql = "SELECT * FROM `lylme_links` WHERE `group_id` = " . $group['group_id']." ORDER BY `link_order` ASC;";
$group_links = $DB->query($sql); $group_links = $DB->query($sql);
$link_num = $DB->num_rows($group_links); // 获取返回字段条目数量 $link_num = $DB->num_rows($group_links); // 获取返回字段条目数量
@ -26,9 +30,18 @@ while ($group = $DB->fetch($groups)) { //循环所有分组
} }
while ($link = $DB->fetch($group_links)) { // 循环每个链接 while ($link = $DB->fetch($group_links)) { // 循环每个链接
// 返回指定分组下的所有字段 // 返回指定分组下的所有字段
$lpwd = true;
if ($link_num > $i) { if ($link_num > $i) {
$i = $i + 1; $i = $i + 1;
if($link["link_status"]!="0"){ if(!empty($group['group_pwd'])&&!empty($link['link_pwd'])){
//分组和链接同时加密
//忽略链接加密正常显示分组
}
else if(!in_array($link['link_pwd'],$_SESSION['list'])&&!empty($link['link_pwd'])){
//当前链接加密
$lpwd = false;
}
if($link["link_status"]!="0" && $lpwd ){
echo "\n" . '<li class="lylme-3"><a rel="nofollow" href="' . $link["url"] . '" target="_blank">'; echo "\n" . '<li class="lylme-3"><a rel="nofollow" href="' . $link["url"] . '" target="_blank">';
if ($link["icon"] == '') { if ($link["icon"] == '') {
echo '<img src="/assets/img/default-icon.png" alt="默认' . $link["name"] . '" />'; echo '<img src="/assets/img/default-icon.png" alt="默认' . $link["name"] . '" />';