Changeset 2501
- Timestamp:
- Sep 5, 2008, 12:45:27 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_functions.inc.php
r2496 r2501 940 940 list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4); 941 941 942 // upload directory hierarchy 942 943 $upload_dir = sprintf( 943 944 PHPWG_ROOT_PATH.'upload/%s/%s/%s', … … 949 950 //fwrite($fh_log, $upload_dir."\n"); 950 951 952 // create the upload directory tree if not exists 951 953 if (!is_dir($upload_dir)) { 952 954 umask(0000); … … 955 957 } 956 958 959 // compute file path 957 960 $date_string = preg_replace('/[^\d]/', '', $dbnow); 958 961 $random_string = substr($params['file_sum'], 0, 8); 959 960 962 $filename_wo_ext = $date_string.'-'.$random_string; 961 962 963 $file_path = $upload_dir.'/'.$filename_wo_ext.'.jpg'; 964 965 // dump the photo file 963 966 $fh_file = fopen($file_path, 'w'); 964 967 fwrite($fh_file, base64_decode($params['file_content'])); 965 968 fclose($fh_file); 966 969 967 // check dumped file md5sum with expected md5sum 968 970 // check dumped file md5sum against expected md5sum 971 $dumped_md5 = md5_file($file_path); 972 if ($dumped_md5 != $params['file_sum']) { 973 return new PwgError(500, 'file transfert failed'); 974 } 975 976 // thumbnail directory is a subdirectory of the photo file, hard coded 977 // "thumbnail" 969 978 $thumbnail_dir = $upload_dir.'/thumbnail'; 970 979 if (!is_dir($thumbnail_dir)) { … … 973 982 } 974 983 984 // thumbnail path, the filename may use a prefix and the extension is 985 // always "jpg" (no matter what the real file format is) 975 986 $thumbnail_path = sprintf( 976 987 '%s/%s%s.%s', … … 980 991 'jpg' 981 992 ); 993 994 // dump the thumbnail 982 995 $fh_thumbnail = fopen($thumbnail_path, 'w'); 983 996 fwrite($fh_thumbnail, base64_decode($params['thumbnail_content'])); … … 985 998 986 999 // check dumped thumbnail md5 1000 $dumped_md5 = md5_file($thumbnail_path); 1001 if ($dumped_md5 != $params['thumbnail_sum']) { 1002 return new PwgError(500, 'thumbnail transfert failed'); 1003 } 987 1004 988 1005 // fwrite($fh_log, 'output: '.md5_file($file_path)."\n"); … … 1016 1033 array($insert) 1017 1034 ); 1035 1036 invalidate_user_cache(); 1018 1037 1019 1038 // fclose($fh_log);
Note: See TracChangeset
for help on using the changeset viewer.