1 |
<?php |
2 |
/** |
3 |
* hugs.mageia.org - a place where to send the grumpy ones. |
4 |
* |
5 |
* Got an argument (or approaching) with someone on IRC or by email? |
6 |
* Things get tense? Be cool! And be the first to give this virtual hug! |
7 |
* |
8 |
* PHP version 5 |
9 |
* |
10 |
* @category Mageia_Web_Sites |
11 |
* @package Hugs.mageia.org |
12 |
* @author Romain d'Alverny <rda@mageia.org> |
13 |
* @copyright 2011 Romain d'Alverny |
14 |
* @license MIT License, see LICENSE.txt |
15 |
* @link http://svnweb.mageia.org/svn/web/hugs/ |
16 |
*/ |
17 |
|
18 |
header('Content-Type: text/html; charset=utf-8'); |
19 |
|
20 |
$app_root = realpath(dirname(__FILE__)); |
21 |
$images = glob(sprintf('%s/var/hugs/*.jpg', $app_root)); |
22 |
|
23 |
if (count($images) > 0) { |
24 |
|
25 |
$img_tmpl = '<img id="hi" src="%s" alt="Free Hugs!" title="Come get a hug!">'; |
26 |
$img = $images[array_rand($images)]; |
27 |
$out = sprintf($img_tmpl, |
28 |
str_replace($app_root, '', $img)); |
29 |
|
30 |
if (function_exists('exif_read_data')) { |
31 |
// TIP use jhead -ce photo.jpg to edit photo COMMENT field |
32 |
$exif = exif_read_data($img, null, true); |
33 |
if (!is_null($exif) |
34 |
&& isset($exif['COMMENT'])) { |
35 |
|
36 |
$out .= sprintf('<figcaption id="hicomment">%s</figcaption>', |
37 |
nl2br(preg_replace('`((?:https?|ftp)://\S+[[:alnum:]]/?)`si', |
38 |
'<a href="$1" rel="nofollow">$1</a>', |
39 |
trim($exif['COMMENT'][0])))); |
40 |
} |
41 |
} |
42 |
$out = sprintf('<figure>%s</figure>', $out); |
43 |
|
44 |
} else { |
45 |
header($_SERVER['SERVER_PROTOCOL'] . ': 404 Not Found'); |
46 |
header('Status: 404 Not Found'); |
47 |
$out = '<div id="hi"><p>404 Hug Not Found :(</p></div>'; |
48 |
} |
49 |
|
50 |
ob_start(); |
51 |
|
52 |
?><!DOCTYPE html> |
53 |
<html lang="en" dir="ltr"> |
54 |
<head> |
55 |
<meta charset="utf-8"> |
56 |
<title>Free Hugs! @ Mageia</title> |
57 |
<meta name="description" content="Be kind. Enough with bugs. Hug someone!"> |
58 |
<meta name="keywords" content="mageia, community, fun, friendly, happy, |
59 |
hugs, free hugs, no bug, calins, collaboration, free software, linux"> |
60 |
<meta name="robots" content="noindex, follow"> |
61 |
<link rel="canonical" href="http://hugs.mageia.org/"> |
62 |
<link rel="icon" type="image/png" href="/static/favicon.png"> |
63 |
<meta name="google-site-verification" content="upEZjJeSjjjVNCMOM2xZNi5PmRgMOY9SCtW3xmGY6nQ"> |
64 |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Pacifico"> |
65 |
<style><?php include 'source-min.css'; ?></style> |
66 |
</head> |
67 |
<body> |
68 |
<article> |
69 |
<section><?php echo $out; ?></section> |
70 |
<aside> |
71 |
<h1>Need a hug?</h1> |
72 |
<p>Maybe you wanted to visit <a href="http://bugs.mageia.org/" |
73 |
rel="nofollow">bugs.mageia.org</a> (with a b!) actually?</p> |
74 |
<p>Or to check our <a href="mageia.org/en/about/code-of-conduct/" |
75 |
rel="nofollow">code of conduct</a>; just some advice to help collaboration within our project.</p> |
76 |
<p>Or to learn more about <a href="mageia.org/">Mageia</a>! |
77 |
We are nice fellows <!-- <a href="http://bonjourmageia.fr/" |
78 |
rel="nofollow"></a>--> |
79 |
and we gather to build a Linux-based operating system. |
80 |
It's fun, it's great, <a href="http://mageia.org/">have a look</a> and join us!</p> |
81 |
<p style="text-align: center;"><a href="http://mageia.org/"> |
82 |
<img src="static/mageia-logo-small.png" style="width: 200px;" alt="Mageia"></a></p> |
83 |
<h2>Free hugs?</h2> |
84 |
<p>Yes! A hug definitely will make you feel better. |
85 |
It's free and it's great!</p> |
86 |
<p>Check the <a href="http://www.freehugscampaign.org/">Free |
87 |
Hugs Campaign</a> out, and save the date: next International |
88 |
Free Hugs Day is on <time datetime="2011-07-02">July, |
89 |
2<sup>nd</sup> 2011</time>.</p> |
90 |
</aside> |
91 |
</article> |
92 |
<div class="clear"></div> |
93 |
<footer> |
94 |
<p class="sign">♡ May 2011 by <a href="https://wiki.mageia.org/en/Atelier_team">mageia.org atelier team</a> – Copying is an act of love. <a href="http://svnweb.mageia.org/web/hugs/">Please copy and share</a> (or send patches) |
95 |
– Want to <a href="/post-your-own/" rel="nofollow">post your own photo</a> here?</p> |
96 |
</footer> |
97 |
</body> |
98 |
</html> |
99 |
<?php |
100 |
|
101 |
$s = ob_get_clean(); |
102 |
$s = str_replace(array(">\n", ">\n\t", "\t", ' ', ";\n"), array('>', '>', '', '', ';'), $s); |
103 |
echo $s; |