if (!$addons['Salesman']) { cw_header_location('index.php'); } cw_load('files'); if ($userfile_type != "application/x-shockwave-flash" && substr($userfile_name, -4) == '.swf') { $userfile_type = "application/x-shockwave-flash"; } if ($action == 'close') { $banner_type = ''; $mode = 'close'; $banner_id = ''; } elseif ($action == "upload" && cw_is_image_userfile($userfile, $userfile_size, $userfile_type)) { $userfile = cw_move_uploaded_file("userfile"); list($img_size, $img_width, $img_height) = cw_get_image_size($userfile); $image = addslashes(cw_file_get($userfile, true)); if (!is_numeric($image_width) || !is_numeric($image_height) || $image_width < 1 || $image_height < 1) { if ($img_width && $img_height) { $image_width = $img_width; $image_height = $img_height; } elseif ($width && $height) { $image_width = $width; $image_height = $height; } } db_query("INSERT INTO {$tables['salesman_banners_elements']} (data, data_type, data_x, data_y) VALUES ('{$image}', '{$userfile_type}', '{$image_width}', '{$image_height}')"); @unlink($userfile); $banner_type = "M"; } elseif ($action == 'add' && $add && $add['banner']) { if ($add['banner_type'] == 'G') { $userfile = cw_move_uploaded_file("userfile");
function cw_image_store_fs($image_data, $type) { $dest_dir = cw_image_dir($type); if (isset($image_data['file_path'])) { $image_data['id'] = false; $image_data['image_id'] = false; $image_data['image'] = cw_file_get($image_data['file_path'], true); } $file_name = cw_image_gen_unique_filename($image_data['filename'], $type, $image_data['image_type'], $image_data['id'], $image_data['image_id']); if ($file_name === false) { return false; } $file = $dest_dir . '/' . $file_name; $fd = cw_fopen($file, "wb", true); if ($fd === false) { return false; } $image = fwrite($fd, $image_data['image']); fclose($fd); @chmod($file, 0666); if (!empty($image_data['is_copied'])) { unlink(cw_realpath($image_data['file_path'])); } return $file; }