mirror of
https://github.com/LyLme/lylme_spage.git
synced 2024-11-17 14:34:08 +08:00
增加 模板输出
This commit is contained in:
parent
546f7677d1
commit
2977c8aac6
@ -17,6 +17,7 @@ include_once(SYSTEM_ROOT."db.class.php");
|
||||
$DB=new DB($dbconfig['host'],$dbconfig['user'],$dbconfig['pwd'],$dbconfig['dbname'],$dbconfig['port']);
|
||||
$rs= $DB->query("SELECT * FROM `lylme_config`");
|
||||
while($row = $DB->fetch($rs)) $conf[$row['k']]=$row['v'];
|
||||
include_once(SYSTEM_ROOT."lists.php");
|
||||
include_once(SYSTEM_ROOT."function.php");
|
||||
include_once(SYSTEM_ROOT."member.php");
|
||||
include_once(SYSTEM_ROOT."tj.php");
|
||||
|
@ -168,4 +168,34 @@ function get_real_ip() {
|
||||
//客户端IP 或 (最后一个)代理服务器 IP
|
||||
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
function yan(){
|
||||
$filename = ROOT.'/assets/data/data.dat'; //随机一言文件路径
|
||||
if (file_exists($filename)) {
|
||||
$data = explode(PHP_EOL, file_get_contents($filename));
|
||||
$result = str_replace(array(
|
||||
"\r",
|
||||
"\n",
|
||||
"\r\n"
|
||||
) , '', $data[array_rand($data) ]);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
function rearr($data,$arr){
|
||||
$arr = str_replace('{group_id}', $data['group_id'],$arr);
|
||||
$arr = str_replace('{group_name}', $data['group_name'],$arr);
|
||||
$arr = str_replace('{group_icon}', $data['group_icon'],$arr);
|
||||
$arr = str_replace('{link_id}', $data['id'],$arr);
|
||||
$arr = str_replace('{link_name}', $data['name'],$arr);
|
||||
$arr = str_replace('{link_url}', $data['url'],$arr);
|
||||
if (empty($data["icon"])) {
|
||||
$icon = '<img src="/assets/img/default-icon.png" alt="' . $data["name"] . '" />';
|
||||
} else if (!preg_match("/^<svg*/", $data["icon"])) {
|
||||
$icon = '<img src="' . $data["icon"] . '" alt="' . $data["name"] . '" />';
|
||||
} else {
|
||||
$icon = $data["icon"];
|
||||
}
|
||||
$arr = str_replace('{link_icon}', $icon,$arr);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
?>
|
@ -1,4 +1,9 @@
|
||||
<?php
|
||||
if(!empty($_GET['url'])){
|
||||
$url = $_GET['url'];
|
||||
header("Location:$url");
|
||||
exit();
|
||||
}
|
||||
include("common.php");
|
||||
session_start(); //设置session
|
||||
if($_POST['exit']=='exit'){
|
||||
|
69
include/lists.php
Normal file
69
include/lists.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------+
|
||||
// | LyLme Spage |
|
||||
// +----------------------------------------------------------+
|
||||
// | Copyright (c) 2022 LyLme |
|
||||
// +----------------------------------------------------------+
|
||||
// | File: lists.php |
|
||||
// +----------------------------------------------------------+
|
||||
// | Authors: LyLme <admin@lylme.com> |
|
||||
// | date: 2022-06-10 |
|
||||
// +----------------------------------------------------------+
|
||||
function lists($htmls) {
|
||||
global $DB;
|
||||
$groups = $DB->query("SELECT * FROM `lylme_groups` ORDER BY `group_order` ASC");
|
||||
// 获取分类
|
||||
$i = 0;
|
||||
//初始化循环次数
|
||||
while ($group = $DB->fetch($groups)) {
|
||||
//循环所有分组
|
||||
$html = rearr($group,$htmls);
|
||||
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;";
|
||||
$group_links = $DB->query($sql);
|
||||
$link_num = $DB->num_rows($group_links);
|
||||
// 获取返回字段条目数量
|
||||
echo $html['g1'].$html['g2'];
|
||||
//输出分组图标和标题
|
||||
if ($link_num == 0) {
|
||||
echo $html['g3'] . "\n\n";
|
||||
$i = 0;
|
||||
continue;
|
||||
}
|
||||
while ($link = $DB->fetch($group_links)) {
|
||||
// 循环每个链接
|
||||
$html = rearr($link,$htmls);
|
||||
// 返回指定分组下的所有字段
|
||||
$lpwd = true;
|
||||
if ($link_num > $i) {
|
||||
$i = $i + 1;
|
||||
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'] && $lpwd ) {
|
||||
echo "\n" .$html['l1'].$html['l2'].$html['l3'];
|
||||
}
|
||||
//输出图标和链接
|
||||
}
|
||||
if ($link_num == $i) {
|
||||
//判断当前分组链接循环完毕
|
||||
echo $html['g3'] . "\n\n";
|
||||
//输出分类结束标签
|
||||
$i = 0;
|
||||
break;
|
||||
//重置$i为0跳出当前循环
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user