-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
62 lines (54 loc) · 1.65 KB
/
index.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
<!DOCTYPE html>
<html lang="pt-PT">
<head>
<meta charset="UTF-8" />
<title>Hack PT</title>
<link href="css/normalize.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet" />
</head>
<body>
<h1 id="header">
Hackers PT
</h1>
<div id="news">
<?
$news = json_decode(file_get_contents('http://pipes.yahoo.com/pipes/pipe.run?_id=0af0ddb7e7ce4bbcba3e8c3bb3a19ade&_render=json'));
foreach($news->value->items as $item){
echo "<a class='item' target='_blank' title='".strip_tags($item->description)."' href='".$item->link."'>";
echo ' <span class="author">'.$item->author.'</span>';
echo ' <span class="title">'.$item->title.'</span>';
echo ' <span class ="time">há '.ago(strtotime($item->pubDate))."</span>";
echo "</a>";
}
?>
</div>
<div id="footer">
<div class="sugestion"> Sugere blogs a adicionar para [email protected]</div>
<iframe class="fork" src="http://ghbtns.com/github-btn.html?user=markdotto&repo=github-buttons&type=fork"
allowtransparency="true" frameborder="0" scrolling="0" width="53" height="20"></iframe>
</div>
<?
// TIME AGO FUNCITON
function ago($time)
{
$periods = array("segundo", "minuto", "hora", "dia", "semana", "mês", "ano", "decada");
$lengths = array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $time;
$tense = "ago";
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference != 1) {
if($j == 5){
$periods[$j] = "meses";
}else{
$periods[$j].= "s";
}
}
return "$difference $periods[$j]";
}
?>
</body>
</html>