3 * SquirrelMail NewMail plugin
5 * Script loads user's media file.
12 define('SM_PATH','../../');
14 /** Load squirrelmail functions */
15 include_once(SM_PATH
. 'include/validate.php');
16 /** Load plugin functions */
17 include_once(SM_PATH
. 'plugins/newmail/functions.php');
19 sqgetGlobalVar('username',$username,SQ_SESSION
);
22 $media = getPref($data_dir,$username,'newmail_media', '(none)');
24 $newmail_userfile_type=getPref($data_dir,$username,'newmail_userfile_type',false);
26 $newmail_userfile_location=getHashedFile($username, $data_dir, $username . '.sound');
28 if ($newmail_userfile_type!=false && file_exists($newmail_userfile_location)) {
30 $newmail_userfile_handle = fopen($newmail_userfile_location,'rb');
31 if ($newmail_userfile_handle) {
32 $newmail_userfile_filesize = filesize($newmail_userfile_location);
33 $newmail_userfile_contents = fread($newmail_userfile_handle,$newmail_userfile_filesize);
34 fclose ($newmail_userfile_handle);
36 // user prefs use only integer values to store file type
37 switch($newmail_userfile_type) {
38 case SM_NEWMAIL_FILETYPE_WAV
:
40 $newmail_userfile_contenttype='audio/x-wav';
42 case SM_NEWMAIL_FILETYPE_MP3
:
44 $newmail_userfile_contenttype='audio/mpeg';
46 case SM_NEWMAIL_FILETYPE_OGG
:
48 $newmail_userfile_contenttype='application/ogg';
50 case SM_NEWMAIL_FILETYPE_SWF
:
52 $newmail_userfile_contenttype='application/x-shockwave-flash';
54 case SM_NEWMAIL_FILETYPE_SVG
:
56 $newmail_userfile_contenttype='image/svg+xml';
60 $newmail_userfile_contenttype='unknown';
63 // make sure that media file is in correct format
64 $newmail_userfile_extension=newmail_detect_filetype($newmail_userfile_contents,$newmail_userfile_contenttype);
66 // last check before sending file contents to browser.
67 if ($newmail_userfile_extension!=false) {
68 $newmail_send_filename='mediafile.' . $newmail_userfile_extension;
69 header ('Content-Disposition: inline; filename="' . $newmail_send_filename . '"');
70 header('Content-Type: "' . $newmail_userfile_contenttype .'"; ' .
71 'name="' . $newmail_send_filename . '"');
72 header('Content-Length: ' . $newmail_userfile_filesize );
73 echo $newmail_userfile_contents;
75 } // file type detection failed
76 } // failed to open userfile
77 } // userfile is missing or preferences don't store file type.
78 // maybe we should send some error code