Changeset 2463 for trunk/include/ws_functions.inc.php
- Timestamp:
- Jul 30, 2008, 11:53:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_functions.inc.php
r2451 r2463 914 914 } 915 915 return $affected_rows; 916 } 917 918 function ws_images_add($params, &$service) 919 { 920 global $conf; 921 922 // name 923 // category_id 924 // file_content 925 // file_sum 926 // thumbnail_content 927 // thumbnail_sum 928 929 // $fh_log = fopen('/tmp/php.log', 'w'); 930 // fwrite($fh_log, time()."\n"); 931 // fwrite($fh_log, 'input: '.$params['file_sum']."\n"); 932 // fwrite($fh_log, 'input: '.$params['thumbnail_sum']."\n"); 933 934 // current date 935 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); 936 list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4); 937 938 $upload_dir = sprintf( 939 PHPWG_ROOT_PATH.'upload/%s/%s/%s', 940 $year, 941 $month, 942 $day 943 ); 944 945 fwrite($fh_log, $upload_dir."\n"); 946 947 if (!is_dir($upload_dir)) { 948 umask(0000); 949 $recursive = true; 950 mkdir($upload_dir, 0777, $recursive); 951 } 952 953 $date_string = preg_replace('/[^\d]/', '', $dbnow); 954 $random_string = substr($params['file_sum'], 0, 8); 955 956 $filename_wo_ext = $date_string.'-'.$random_string; 957 958 $file_path = $upload_dir.'/'.$filename_wo_ext.'.jpg'; 959 $fh_file = fopen($file_path, 'w'); 960 fwrite($fh_file, base64_decode($params['file_content'])); 961 fclose($fh_file); 962 963 // check dumped file md5sum with expected md5sum 964 965 $thumbnail_dir = $upload_dir.'/thumbnail'; 966 if (!is_dir($thumbnail_dir)) { 967 umask(0000); 968 mkdir($thumbnail_dir, 0777); 969 } 970 971 $thumbnail_path = sprintf( 972 '%s/%s%s.%s', 973 $thumbnail_dir, 974 $conf['prefix_thumbnail'], 975 $filename_wo_ext, 976 'jpg' 977 ); 978 $fh_thumbnail = fopen($thumbnail_path, 'w'); 979 fwrite($fh_thumbnail, base64_decode($params['thumbnail_content'])); 980 fclose($fh_thumbnail); 981 982 // check dumped thumbnail md5 983 984 // fwrite($fh_log, 'output: '.md5_file($file_path)."\n"); 985 // fwrite($fh_log, 'output: '.md5_file($thumbnail_path)."\n"); 986 987 // database registration 988 $insert = array( 989 'file' => $filename_wo_ext.'.jpg', 990 'date_available' => $dbnow, 991 'tn_ext' => 'jpg', 992 'name' => $params['name'], 993 'path' => $file_path, 994 ); 995 996 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 997 mass_inserts( 998 IMAGES_TABLE, 999 array_keys($insert), 1000 array($insert) 1001 ); 1002 1003 $image_id = mysql_insert_id(); 1004 1005 $insert = array( 1006 'category_id' => $params['category_id'], 1007 'image_id'=> $image_id, 1008 ); 1009 mass_inserts( 1010 IMAGE_CATEGORY_TABLE, 1011 array_keys($insert), 1012 array($insert) 1013 ); 1014 1015 // fclose($fh_log); 916 1016 } 917 1017
Note: See TracChangeset
for help on using the changeset viewer.