-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.php
93 lines (72 loc) · 2.21 KB
/
list.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
<html>
<head>
<meta charset="utf-8">
<title>Maison des éditions — in-quarto</title>
<meta name="description" content="list sources">
</head>
<body>
<div id="container">
<?php
require_once("utils/simple_html_dom.php");
require_once("utils/rglob.php");
function is_image($file) {
$size = getimagesize($file);
if(!$size) {
return 0;
}
$valid_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP);
if(in_array($size[2], $valid_types)) {
return 1;
} else {
return 0;
}
}
$txt = rglob('*.html', './_txt');
$txt = glob('./_txt/*.html');
$cam = glob('./_cam/*.png');
//$img = rglob('*.jpg', './_img/uploads/web');
$img = glob("{./_img/uploads/dessins/*.png,./_img/uploads/dessinsmarie/*.png,./_img/uploads/web/*.jpg}",GLOB_BRACE);
$papier = rglob('*.JPG', './_img/uploads/papier');
shuffle($txt);
shuffle($cam);
shuffle($img);
shuffle($papier);
$txt = array_slice($txt ,0 ,50);
$cam = array_slice($cam ,0 ,20);
$img = array_slice($img ,0 ,80);
$papier = array_slice($papier ,0 ,20);
$sources = array_merge ($txt, $img, $papier);
shuffle($sources);
$sources = array_slice($sources, 0, 25);
foreach ($sources as $file) {
if (is_image($file)){
$imagesourcedir = substr($file, 2, 4);
$image = substr($file, 7);
// CRAPPY
if($imagesourcedir == '_cam'){
$content = '<div class="img"><img src="' . $file . '" width="200"></div>';
} else {
$content = '<div class="img"><img src="_img/cache/grey/400x400/' . $image . '"></div>';
}
} else {
$html = file_get_html($file);
$titre = $html->find('h1', 0)->innertext;
if($titre == ''){
$text = $html->plaintext;
$dot = stripos ($text, '.'); //find first dot position
$titre = substr($text, 0, $dot+1);
}
if (strlen($titre) < 50) {
$content = "<h1 class='nord'>$titre</h1>";
} else if (strlen($titre) > 150) {
$content = "<p>$titre</p>";
} else {
$content = "<h1>$titre</h1>";
}
}
echo '<div class="item" data-source="'. substr($file,2) .'">' . $content . '</div>';
}
?>
</div>
</body>
</html>