-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfunction.php
More file actions
89 lines (77 loc) · 2.05 KB
/
function.php
File metadata and controls
89 lines (77 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?
/**
* Krunk.cn KBlog - 极简博客
*
* Project Link: https://kblog.krunk.cn
* GitHub: https://github.com/KrunkZhou/KBlog
*
* @author Krunk Zhou
* @copyright 2019 Krunk Zhou (https://krunk.cn)
*/
include('config.php');
include('Parsedown.php');
include($data_folder.'/custom_function.php');
$html_start="<html>";
$html_end="</html>";
$post_start="<div class='post'>";
$post_end="</div>";
$postCard_start="<div class='postCardDiv'>";
function notfoundfile(){
global $theme_folder;
$html = @file_get_contents($theme_folder.'/notfound.md');
$Parsedown = new Parsedown();
return $Parsedown->text($html);
}
function get_File_Id(){
global $blog_folder;
$fileList=glob($blog_folder."/*.md");
$mdList=array();
foreach ($fileList as $type) {
$t=substr($type,0,strpos($type,"."));
array_push($mdList, substr($t,strlen($blog_folder)+1,strpos($type,".")));
}
return($mdList);
}
function get_post_title($id){
global $blog_folder;
$html = @file_get_contents($blog_folder.'/'.$id.'.md');
$html_arr = explode("\n", $html, 2);
$title = $html_arr[0];
return $title;
}
function get_post_date($id){
global $blog_folder;
$html = @file_get_contents($blog_folder.'/'.$id.'.md');
$html_arr = explode("\n", $html, 2);
$title = $html_arr[0];
$html = strstr($html, "\n");
$html = ltrim($html, "\n");
$html_arr = explode("\n", $html, 2);
$time = $html_arr[0];
return $time;
}
function cmp($a,$b){
return strcmp(get_post_date($b),get_post_date($a));
}
function get_orgnized_file_id(){
$id_array=get_File_Id();
//var_dump($id_array) ;
$new_array=$id_array;
usort($new_array, "cmp");
//var_dump($new_array) ;
return $new_array;
}
function nav_active($id){
return '<script>document.getElementById("'.$id.'").classList.add("active");</script>';
}
function cleanInput($input) {
$search = array(
'@<script[^>]*?>.*?</script>@si', // javascript
'@<[\/\!]*?[^<>]*?>@si', // HTML tags
'@<style[^>]*?>.*?</style>@siU', // style tags
'@<![\s\S]*?--[ \t\n\r]*>@' // multi-line
);
$output = preg_replace($search, '', $input);
return $output;
}
?>