-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.php
More file actions
53 lines (38 loc) · 1.23 KB
/
utils.php
File metadata and controls
53 lines (38 loc) · 1.23 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
<?php
function getListPosts(){
$directorio = 'posts';
$ficheros = array_diff(scandir($directorio), array('..', '.'));
$resultado = "<ul>\n";
foreach ($ficheros as $fichero){
$resultado .= "<li>";
$resultado .= '<a href="ver.php?nombre='.urlencode($fichero).'">'.$fichero.'</a>';
$resultado .= '<a href="borrar.php?nombre='.urlencode($fichero).'"> Borrar</a>';
$resultado .= '<a href="editar.php?nombre='.urlencode($fichero).'"> Editar</a>';
$resultado .= "</li>\n";
}
$resultado .= "</ul>\n";
return $resultado;
}
function getPostHTML(){
$fichero = $_GET['nombre'];
$ruta = "posts/$fichero";
$contenido = file_get_contents($ruta);
return $contenido;
}
function getPostContent($fichero){
$ruta = "posts/$fichero";
$contenido = file_get_contents($ruta);
return $contenido;
}
function getRecentPosts(){
$listado = `ls -t posts`;
$elementos = explode("\n",$listado);
$resultado = "<div>\n";
$resultado .= substr(getPostContent($elementos[0]), 0, 9);
$resultado .= "</div>\n";
$resultado .= "<div>\n";
$resultado .= substr(getPostContent($elementos[1]), 0, 9);
$resultado .= "</div>\n";
return $resultado;
}
?>