= 0 && $transparency < $palletsize) { $transparent_color = imagecolorsforindex($image, $transparency); $transparency = imagecolorallocate($image_resized, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); imagefill($image_resized, 0, 0, $transparency); imagecolortransparent($image_resized, $transparency); } elseif ($info[2] == IMAGETYPE_PNG) { imagealphablending($image_resized, false); $color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127); imagefill($image_resized, 0, 0, $color); imagesavealpha($image_resized, true); } } imagecopyresampled($image_resized, $image, 0, 0, $cropWidth, $cropHeight, $final_width, $final_height, $width_old - 2 * $cropWidth, $height_old - 2 * $cropHeight); # Taking care of original, if needed if ( $delete_original ) { if ( $use_linux_commands ) exec('rm '.$file); else @unlink($file); } # Preparing a method of providing result switch ( strtolower($output) ) { case 'browser': $mime = image_type_to_mime_type($info[2]); header("Content-type: $mime"); $output = NULL; break; case 'file': $output = $file; break; case 'return': return $image_resized; break; default: break; } # Writing image according to type to the output destination and image quality switch ( $info[2] ) { case IMAGETYPE_GIF: imagegif($image_resized, $output); break; case IMAGETYPE_JPEG: imagejpeg($image_resized, $output, $quality); break; case IMAGETYPE_PNG: $quality = 9 - (int)((0.9*$quality)/10.0); imagepng($image_resized, $output, $quality); break; default: return false; } return true; } function exec_ogp_module() { global $db; if( isset($_POST['home_id']) and isset($_POST['mod_id']) and isset($_POST['map']) and isset($_POST['extension']) ) { $home_id = $_POST['home_id']; $mod_id = $_POST['mod_id']; $map = $_POST['map']; $extension = $_POST['extension']; $home_info = $db->getGameHome($home_id); $mods = $home_info['mods']; $current_mod_info = $mods[$mod_id]; $mod_name = $current_mod_info['mod_name']; $mod_key = $current_mod_info['mod_key']; if ( strtolower($mod_name) == "none") $mod = $mod_key; else $mod = $mod_name; $server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']); if ($server_xml->protocol == "gameq") $query_name = $server_xml->gameq_query_name; elseif ($server_xml->protocol == "lgsl") $query_name = $server_xml->lgsl_query_name; else $query_name = $mod; // If query name does not exist use mod key instead. $dest_path = "protocol". DIRECTORY_SEPARATOR ."lgsl". DIRECTORY_SEPARATOR ."maps". DIRECTORY_SEPARATOR ."$query_name". DIRECTORY_SEPARATOR ."$mod"; $dest_file = $dest_path . DIRECTORY_SEPARATOR . "$map.$extension"; if( $_FILES['map-image']['error'] == 0 ) { if( !file_exists($dest_path)) { if(!@mkdir($dest_path, 0700, true)) { echo get_lang_f('cant_create_folder',$dest_path); return; } } if(@move_uploaded_file( $_FILES["map-image"]["tmp_name"], $dest_file )) { print_lang('uploaded_successfully'); smart_resize_image($dest_file, null, 160, 120, true); } else { echo get_lang_f('cant_write_file',$dest_file); } } else { switch ($_FILES['map-image']['error']) { case UPLOAD_ERR_INI_SIZE: echo get_lang_f('exceeded_php_directive','upload_max_filesize='.ini_get('upload_max_filesize')); case UPLOAD_ERR_FORM_SIZE: echo get_lang_f('exceeded_php_directive','post_max_size='.ini_get('post_max_size')); default: print_lang('unknown_errors'); } } } } ?>