forked from DMeloni/shaarlo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
archive.php
134 lines (123 loc) · 4.34 KB
/
archive.php
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
require_once 'config.php';
require_once 'fct/fct_rss.php';
require_once 'fct/fct_cache.php';
require_once 'fct/fct_file.php';
require_once 'fct/fct_sort.php';
require_once 'fct/fct_valid.php';
error_reporting(0);
header('Content-Type: text/html; charset=utf-8');
global $DATA_DIR, $CACHE_DIR_NAME, $ARCHIVE_DIR_NAME, $ARCHIVE_FILE_NAME, $CALENDAR_SORTING;
$indexFile = sprintf('%s/%s/%s', $DATA_DIR, $CACHE_DIR_NAME, 'index.html');
// Autoredirect on boot.php
if(!checkInstall() && !is_file($indexFile)){
header('Location: boot.php');
return;
}
$archiveFile = sprintf('%s/%s/%s', $DATA_DIR, $CACHE_DIR_NAME, $ARCHIVE_FILE_NAME);
$expire = time() - 1000 ;
if(file_exists($archiveFile) && filemtime($archiveFile) > $expire) {
echo file_get_contents($archiveFile);
}else{
$archiveDir = sprintf('%s/%s', $DATA_DIR, $ARCHIVE_DIR_NAME);
$rssFileList = array();
// $actualTime = time() ;
// for($i = 0; $i < 8000; $i++){
// $actualTime = $actualTime - (24 * 3600);
// // echo $archiveDir . 'rss_' . date('Ymd', $actualTime) . '.xml';
// file_put_contents($archiveDir . 'rss_' . date('Ymd', $actualTime) . '.xml', 'bonjour');
// }
if ($handle = opendir($archiveDir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
sscanf($file, 'rss_%4s%2s%2s.xml', $years, $months, $days);
$rssFileList[$years]["$months"]["$days"] = $days;
}
}
closedir($handle);
}
// rsort($rssFileList);
// $rssFileList = array_unique($rssFileList);
$assocMonth = array('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Décembre');
ob_start();
?><!DOCTYPE html>
<html lang="fr">
<head>
<title>Shaarlo</title>
<meta charset="utf-8"/>
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="viewport" content="width=device-width, user-scalable=yes" />
<link rel="apple-touch-icon" href="favicon.png" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>
<link rel="alternate" type="application/rss+xml" href="http://shaarli.fr/rss" title="Shaarlo Feed" />
</head>
<body>
<div id="header">
<a href="index.php">Accueil</a>
<a href="admin.php">Administration</a>
<a href="random.php">Aléatoire</a>
<a href="my.php">My</a>
<a href="opml.php?mod=opml">OPML</a>
<h1 id="top"><a href="./archive.php">Archives des discussions de Shaarli</a></h1>
</div>
<div id="content">
<?php
krsort($rssFileList);
foreach($rssFileList as $year => $rssMonth){
ksort($rssMonth);
?>
<div class="article shaarli-youm-org">
<h2 class="article-title ">Archives de l'année <?php echo $year;?></h2>
<?php
foreach($rssMonth as $month => $rssDay){
?>
<div style="float:left;">
<h3 class="article-title "><?php echo $assocMonth[(int)$month - 1];?></h3>
<div class="article-content">
<table border="1">
<?php
if('desc' === $CALENDAR_SORTING){
arsort($rssDay);
}
else {
asort($rssDay);
}
$rssCollumnsDay = array_chunk($rssDay, 7, true);
foreach($rssCollumnsDay as $rowDays){?>
<tr>
<?php foreach($rowDays as $day){?>
<td><a href="index.php?from=<?php echo $year.$month.$day;?>" ><?php echo (int)$day;?></a></td>
<?php }
for($j = 0; $j < (int)(7 - count($rowDays)) ; $j++){
?>
<td></td>
<?php
}
?>
</tr>
<?php } ?>
</table>
</div>
</div>
<?php
}
?>
</div>
<?php
}
?>
</div>
<div id="footer"> <p>Please contact <a href="mailto:[email protected]">me</a> for any comments - <a href="https://github.com/DMeloni/shaarlo">sources on github</a></p></div>
</body>
</html><?php
$page = ob_get_contents();
ob_end_clean();
$page = sanitize_output($page);
$index = sanitize_output($page);
file_put_contents($archiveFile, $page);
echo $page;
}