2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
14 define('AT_INCLUDE_PATH', 'include/');
16 header("Content-Encoding: none");
18 $_user_location = 'public';
19 $nophoto_flag = false; //true if no profile photo exists
21 require(AT_INCLUDE_PATH . 'vitals.inc.php');
22 require(AT_INCLUDE_PATH . 'lib/mime.inc.php');
24 $id = intval($_GET['id']);
25 if (isset($_GET['size']) && $_GET['size'] == 'o') {
26 $size = 'originals'; //t (thumbnail) or o (original)
27 } elseif (isset($_GET['size']) && $_GET['size'] == 'p') {
28 $size = 'profile'; //p (profile)
33 $file = AT_CONTENT_DIR . 'profile_pictures/' . $size .'/'. $id .'.';
34 $extensions = array('gif', 'jpg', 'png');
36 foreach ($extensions as $extension) {
37 if (file_exists($file.$extension)) {
42 //if file does not exist, quit.
43 if (!file_exists($file)){
44 $file = AT_INCLUDE_PATH.'../images/nophoto.gif';
48 $pathinfo = pathinfo($file);
50 $ext = $pathinfo['extension'];
52 $ext = 'application/octet-stream';
54 $ext = $mime[$ext][0];
57 $real = realpath($file);
59 if ($nophoto_flag || (file_exists($real) && (substr($real, 0, strlen(AT_CONTENT_DIR)) == AT_CONTENT_DIR))) {
60 header('Content-Disposition: filename="'.$size.$id.'.'.$pathinfo['extension'].'"');
62 * although we can check if mod_xsendfile is installed in apache2
63 * we can't actually check if it's enabled. also, we can't check if
64 * it's enabled and installed in lighty, so instead we send the
65 * header anyway, if it works then the line after it will not
66 * execute. if it doesn't work, then the line after it will replace
67 * it so that the full server path is not exposed.
69 * x-sendfile is supported in apache2 and lighttpd 1.5+ (previously
70 * named x-send-file in lighttpd 1.4)
72 header('x-Sendfile: '.$real);
73 header('x-Sendfile: ', TRUE); // if we get here then it didn't work
75 header('Content-Type: '.$ext);
81 header('HTTP/1.1 404 Not Found', TRUE);