* @copyright 2011 Romain d'Alverny * @license MIT License, see LICENSE.txt * @link http://gitweb.mageia.org/web/hugs/ */ header('Content-Type: text/html; charset=utf-8'); $app_root = realpath(dirname(__FILE__)); $images = glob(sprintf('%s/var/hugs/*.jpg', $app_root)); if (count($images) > 0) { $img_tmpl = 'Free Hugs!'; $img = $images[array_rand($images)]; $out = sprintf($img_tmpl, str_replace($app_root, '', $img)); if (function_exists('exif_read_data')) { // TIP use jhead -ce photo.jpg to edit photo COMMENT field $exif = exif_read_data($img, null, true); if (!is_null($exif) && isset($exif['COMMENT'])) { $out .= sprintf('
%s
', nl2br(preg_replace('`((?:https?|ftp)://\S+[[:alnum:]]/?)`si', '$1', trim($exif['COMMENT'][0])))); } } $out = sprintf('
%s
', $out); } else { header($_SERVER['SERVER_PROTOCOL'] . ': 404 Not Found'); header('Status: 404 Not Found'); $out = '

404 Hug Not Found :(

'; } ob_start(); ?> Free Hugs! @ Mageia
\n", ">\n\t", "\t", ' ', ";\n"), array('>', '>', '', '', ';'), $s); echo $s;