check for no data during transload
git-svn-id: file:///home/shish/svn/shimmie2/trunk@363 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
		
							parent
							
								
									e06a63c955
								
							
						
					
					
						commit
						101bbeecee
					
				| @ -119,11 +119,12 @@ class Upload extends Extension { | |||||||
| 		// PHP falls back to system default if /tmp fails, can't we just
 | 		// PHP falls back to system default if /tmp fails, can't we just
 | ||||||
| 		// use the system default to start with? :-/
 | 		// use the system default to start with? :-/
 | ||||||
| 		$tmp_filename = tempnam("/tmp", "shimmie_transload"); | 		$tmp_filename = tempnam("/tmp", "shimmie_transload"); | ||||||
|  | 		$filename = basename($url); | ||||||
| 
 | 
 | ||||||
| 		if($config->get_string("transload_engine") == "fopen") { | 		if($config->get_string("transload_engine") == "fopen") { | ||||||
| 			$fp = fopen($url, "r"); | 			$fp = fopen($url, "r"); | ||||||
| 			if(!$fp) { | 			if(!$fp) { | ||||||
| 				$this->theme->display_upload_error($page, "Error with ".html_escape(basename($url)), | 				$this->theme->display_upload_error($page, "Error with ".html_escape($filename), | ||||||
| 					"Error reading from ".html_escape($url)); | 					"Error reading from ".html_escape($url)); | ||||||
| 				return false; | 				return false; | ||||||
| 			} | 			} | ||||||
| @ -152,13 +153,17 @@ class Upload extends Extension { | |||||||
| 			fclose($fp); | 			fclose($fp); | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		if(filesize($tmp_filename) > $config->get_int('upload_size')) { | 		if(filesize($tmp_filename) == 0) { | ||||||
| 			$this->theme->display_upload_error($page, "Error with ".html_escape($file['name']), | 			$this->theme->display_upload_error($page, "Error with ".html_escape($filename), | ||||||
|  | 				"No data found -- perhaps the site has hotlink protection?"); | ||||||
|  | 		} | ||||||
|  | 		else if(filesize($tmp_filename) > $config->get_int('upload_size')) { | ||||||
|  | 			$this->theme->display_upload_error($page, "Error with ".html_escape($filename), | ||||||
| 				"File too large (".filesize($tmp_filename)." > ". | 				"File too large (".filesize($tmp_filename)." > ". | ||||||
| 				($config->get_int('upload_size')).")"); | 				($config->get_int('upload_size')).")"); | ||||||
| 		} | 		} | ||||||
| 		else if(!($info = getimagesize($tmp_filename))) { | 		else if(!($info = getimagesize($tmp_filename))) { | ||||||
| 			$this->theme->display_upload_error($page, "Error with ".html_escape(basename($url)), | 			$this->theme->display_upload_error($page, "Error with ".html_escape($filename), | ||||||
| 				"PHP doesn't recognise this as an image file"); | 				"PHP doesn't recognise this as an image file"); | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| @ -169,12 +174,12 @@ class Upload extends Extension { | |||||||
| 				send_event($event); | 				send_event($event); | ||||||
| 				$ok = !$event->vetoed; | 				$ok = !$event->vetoed; | ||||||
| 				if(!$ok) { | 				if(!$ok) { | ||||||
| 					$this->theme->display_upload_error($page, "Error with ".html_escape(basename($url)), | 					$this->theme->display_upload_error($page, "Error with ".html_escape($filename), | ||||||
| 						$event->veto_reason); | 						$event->veto_reason); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			else { | 			else { | ||||||
| 				$this->theme->display_upload_error($page, "Error with ".html_escape(basename($url)), | 				$this->theme->display_upload_error($page, "Error with ".html_escape($filename), | ||||||
| 					"Something is not right!"); | 					"Something is not right!"); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user