a452063929b266a72bc06780ff84162689eddab1
4 * SquirrelMail NewMail plugin
6 * Script loads user's media file.
8 * @copyright © 2001-2007 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
16 * Path for SquirrelMail required files.
19 require('../../include/init.php');
20 /** Load plugin functions */
21 include_once(SM_PATH
. 'plugins/newmail/functions.php');
23 sqgetGlobalVar('username',$username,SQ_SESSION
);
26 $media = getPref($data_dir,$username,'newmail_media', '(none)');
28 $newmail_userfile_type=getPref($data_dir,$username,'newmail_userfile_type',false);
30 $newmail_userfile_location=getHashedFile($username, $data_dir, $username . '.sound');
32 if ($newmail_uploadsounds && $newmail_userfile_type!=false && file_exists($newmail_userfile_location)) {
34 $newmail_userfile_handle = fopen($newmail_userfile_location,'rb');
35 if ($newmail_userfile_handle) {
36 $newmail_userfile_filesize = filesize($newmail_userfile_location);
37 $newmail_userfile_contents = fread($newmail_userfile_handle,$newmail_userfile_filesize);
38 fclose ($newmail_userfile_handle);
40 // user prefs use only integer values to store file type
41 switch($newmail_userfile_type) {
42 case SM_NEWMAIL_FILETYPE_WAV
:
44 $newmail_userfile_contenttype='audio/x-wav';
46 case SM_NEWMAIL_FILETYPE_MP3
:
48 $newmail_userfile_contenttype='audio/mpeg';
50 case SM_NEWMAIL_FILETYPE_OGG
:
52 $newmail_userfile_contenttype='application/ogg';
54 case SM_NEWMAIL_FILETYPE_SWF
:
56 $newmail_userfile_contenttype='application/x-shockwave-flash';
58 case SM_NEWMAIL_FILETYPE_SVG
:
60 $newmail_userfile_contenttype='image/svg+xml';
64 $newmail_userfile_contenttype='unknown';
67 // make sure that media file is in correct format
68 $newmail_userfile_extension=newmail_detect_filetype($newmail_userfile_contents,$newmail_userfile_contenttype);
70 // last check before sending file contents to browser.
71 if ($newmail_userfile_extension!=false) {
72 $newmail_send_filename='mediafile.' . $newmail_userfile_extension;
73 header ('Content-Disposition: inline; filename="' . $newmail_send_filename . '"');
74 header('Content-Type: "' . $newmail_userfile_contenttype .'"; ' .
75 'name="' . $newmail_send_filename . '"');
76 header('Content-Length: ' . $newmail_userfile_filesize );
77 echo $newmail_userfile_contents;
79 } // file type detection failed
80 } // failed to open userfile
81 } // userfile is missing or preferences don't store file type.
82 // maybe we should send some error code