4 * SquirrelMail NewMail plugin
6 * Script loads user's media file.
8 * @copyright © 2001-2006 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
19 define('SM_PATH','../../');
21 /** Load squirrelmail functions */
22 include_once(SM_PATH
. 'include/validate.php');
23 /** Load plugin functions */
24 include_once(SM_PATH
. 'plugins/newmail/functions.php');
26 sqgetGlobalVar('username',$username,SQ_SESSION
);
29 $media = getPref($data_dir,$username,'newmail_media', '(none)');
31 $newmail_userfile_type=getPref($data_dir,$username,'newmail_userfile_type',false);
33 $newmail_userfile_location=getHashedFile($username, $data_dir, $username . '.sound');
35 if ($newmail_uploadsounds && $newmail_userfile_type!=false && file_exists($newmail_userfile_location)) {
37 $newmail_userfile_handle = fopen($newmail_userfile_location,'rb');
38 if ($newmail_userfile_handle) {
39 $newmail_userfile_filesize = filesize($newmail_userfile_location);
40 $newmail_userfile_contents = fread($newmail_userfile_handle,$newmail_userfile_filesize);
41 fclose ($newmail_userfile_handle);
43 // user prefs use only integer values to store file type
44 switch($newmail_userfile_type) {
45 case SM_NEWMAIL_FILETYPE_WAV
:
47 $newmail_userfile_contenttype='audio/x-wav';
49 case SM_NEWMAIL_FILETYPE_MP3
:
51 $newmail_userfile_contenttype='audio/mpeg';
53 case SM_NEWMAIL_FILETYPE_OGG
:
55 $newmail_userfile_contenttype='application/ogg';
57 case SM_NEWMAIL_FILETYPE_SWF
:
59 $newmail_userfile_contenttype='application/x-shockwave-flash';
61 case SM_NEWMAIL_FILETYPE_SVG
:
63 $newmail_userfile_contenttype='image/svg+xml';
67 $newmail_userfile_contenttype='unknown';
70 // make sure that media file is in correct format
71 $newmail_userfile_extension=newmail_detect_filetype($newmail_userfile_contents,$newmail_userfile_contenttype);
73 // last check before sending file contents to browser.
74 if ($newmail_userfile_extension!=false) {
75 $newmail_send_filename='mediafile.' . $newmail_userfile_extension;
76 header ('Content-Disposition: inline; filename="' . $newmail_send_filename . '"');
77 header('Content-Type: "' . $newmail_userfile_contenttype .'"; ' .
78 'name="' . $newmail_send_filename . '"');
79 header('Content-Length: ' . $newmail_userfile_filesize );
80 echo $newmail_userfile_contents;
82 } // file type detection failed
83 } // failed to open userfile
84 } // userfile is missing or preferences don't store file type.
85 // maybe we should send some error code