Пример #1
0
										$html = 'Failed to create temporary upload folder: '.$targetPath;
									}
								}
				
								if ($html == '') {			
									if (!copy($upload_file,$targetFile)) {
										$html .= "FAILED: Could not move ".$upload_file." to ".$targetFile;
									} else {
										
										unlink($upload_file);
										unlink(dirname($upload_file).'/thumbnail/'.$upload_filename);
				
										// resize to a various sizes
										$thumbnail_size = ($value = get_option(WPS_OPTIONS_PREFIX."_gallery_thumbnail_size")) ? $value : '75';
										include_once('../../'.WPS_DIR.'/SimpleImage.php');
									   	$image = new __wps__SimpleImage();
									   	$image->load($targetFile);
									   	$image->resizeToWidth(800);
									   	$image->save($fullsize_targetFile);
									   	$image->resizeToWidth($thumbnail_size);
									   	$image->save($thumbnail_targetFile);
				
									   	// Record filename of uploaded image to database
										// NB. show and thumbnail are prefixes to filename
			        		      		$wpdb->query( $wpdb->prepare( "
			     						INSERT INTO ".$wpdb->base_prefix."symposium_gallery_items
					     				( 	gid,
			     							name,
			     							owner,
					     					created,
			     							cover,
					@unlink($directory.'/'.$image);
				}
			}
		}
						
		// Check that extension is allowed
		$ext = explode('.', strtolower($filename));
		if (strpos(get_option(WPS_OPTIONS_PREFIX.'_image_ext').','.get_option(WPS_OPTIONS_PREFIX.'_video_ext').','.get_option(WPS_OPTIONS_PREFIX.'_doc_ext'), $ext[sizeof($ext)-1]) > 0) {
		
			if (!move_uploaded_file($tempFile,$targetFile)) {
				$html .= "FAILED: Could not move ".$tempFile." to ".$targetFile;
			} else {

				// resize to a decent size
				include_once(dirname(__FILE__).'/../SimpleImage.php');
			   	$image = new __wps__SimpleImage();
			   	$image->load($targetFile);
			   	$image->resizeToWidth(640);
			   	$image->save($targetFile);
			   					
				$html = $filename;

				echo $html;
				exit;
			
			}
		} else {
			// Invalid extension, just remove uploaded file
			$html .= __('Invalid file extension, the following are permitted:', WPS_TEXT_DOMAIN).' '.get_option(WPS_OPTIONS_PREFIX.'_image_ext').','.get_option(WPS_OPTIONS_PREFIX.'_video_ext').','.get_option(WPS_OPTIONS_PREFIX.'_doc_ext');
		}