<?php 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') {
cw_load('files', 'image', 'user'); $file_upload_data =& cw_session_register('file_upload_data', array()); $service_fields = array("file_path", "source", "image_x", "image_y", "image_size", "image_type", "dir_upload", "id", "type", "date", "filename"); if (!isset($available_images[$type]) || empty($type)) { cw_close_window(); } $userfiles_dir = cw_user_get_files_location() . DIRECTORY_SEPARATOR; if ($REQUEST_METHOD == "POST") { $data = array(); $userfiles = $_FILES['userfiles']; if (is_array($userfiles)) { foreach ($userfiles['tmp_name'] as $index => $userfile) { if (zerolen($userfile)) { break; } if (cw_is_image_userfile($userfile, $userfiles['size'][$index], $userfiles['type'][$index])) { $tmp = array(); $tmp['is_copied'] = true; $tmp['filename'] = strtolower($userfiles['name'][$index]); $tmp['file_path'] = cw_move_uploaded_file('userfiles', '', $index); $tmp['source'] = 'S'; $data[] = $tmp; } } } if (is_array($filenames)) { foreach ($filenames as $ind => $filename) { $filename = trim($filename); if (!zerolen($filename)) { $tmp = array(); $tmp['file_path'] = $userfiles_dir . $file_paths[$ind];