Changeset 686 for trunk/app/controllers
- Timestamp:
- 08/01/08 23:57:18 (4 months ago)
- Location:
- trunk/app/controllers
- Files:
-
- 2 modified
-
images_controller.php (modified) (2 diffs)
-
users_controller.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/images_controller.php
r591 r686 90 90 91 91 /** Security: checks to see if file is an image, if not do not allow upload ==*/ 92 93 if ( $type != "image/jpeg" && $type != "image/pjpeg" && $type != "image/png" && $type != "image/gif"): 94 /** is this a valid file? */ 95 $error = "Error. The file $imgfile_name is not valid.Only .jpg, .gif or .png files. Current type file: " . $type . "\n"; 96 92 $types = array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif'); 93 94 if ( !in_array($type, $types) ): 95 $error = "Error. The file $imgfile_name is not valid. Only .jpg, .gif or .png files. Current type file: ".$type ."\n"; 97 96 /** delete uploaded file */ 98 97 unlink($imgfile); … … 103 102 if ( $imgfile_size > $maxfilesize): 104 103 $error = "Error. The image is bigger than 2.0 MB. Current size: " . $imgfile_size; 105 106 104 /** delete uploaded file */ 107 105 unlink($imgfile); -
trunk/app/controllers/users_controller.php
r674 r686 435 435 /** Security: checks to see if file is an image, if not do not allow upload ==*/ 436 436 437 if ( $type != "image/jpeg" && $type != "image/pjpeg" && $type != "image/png" && $type != "image/gif") 438 {/** is this a valid file? */437 if ( $type != "image/jpeg" && $type != "image/pjpeg" && $type != "image/png" && $type != "image/gif"): 438 /** is this a valid file? */ 439 439 $ErrMsg = "<h1>ERROR</h1> the file $imgfile_name $imgfile is not valid.<br>"; 440 440 $ErrMsg .= "<p>Only .jpg, .gif or .png files<br><br>"; … … 444 444 unlink($imgfile); 445 445 die($this->flash($ErrMsg, '/admin/users/edit/') ); 446 } 447 448 if ( $imgfile_size > $maxfilesize) 449 { 446 endif; 447 448 if ( $imgfile_size > $maxfilesize): 450 449 $error = "Error. The image is too big. Bigger than 2.0 MB Current size: " . $imgfile_size ."\n"; 451 450 … … 454 453 $this->flash($error,'/users/edit/'); 455 454 return false; 456 }455 endif; 457 456 458 457 //check size 459 if ($width > 100 || $height > 100) 460 { 461 $error = " The image is too large. "; 462 $error .= "Width or height is larger than 100 pixels. Current size: width ". $width ."px height ". $height ."px\n"; 458 if ($width > 100 || $height > 100): 459 $error = 'Error '. __('The image is too large', true); 460 $error .= "Width or height is larger than 100 pixels. Current size: width ". $width ."px height ". $height ."px\n"; 463 461 464 /** delete uploaded file */465 unlink($imgfile);466 $this->flash($error,'/users/edit/');467 return false;468 }462 /** delete uploaded file */ 463 unlink($imgfile); 464 $this->flash($error,'/users/edit/'); 465 return false; 466 endif; 469 467 470 468 $extension = $this->Adds->get_extension($type); … … 479 477 480 478 /** do extra security check to prevent malicious abuse */ 481 if (is_uploaded_file($imgfile)) 482 { 479 if (is_uploaded_file($imgfile)): 483 480 /** move file to proper directory ==*/ 484 if (!copy($imgfile, $newfile)) 485 { 486 /** if an error occurs the file could not be written, read or possibly does not exist */ 481 if (!copy($imgfile, $newfile)): 487 482 die($this->flash('Error Uploading File.', '/users/edit/')); 488 }489 }483 endif; 484 endif; 490 485 491 486 /** delete the temporary uploaded file **/ … … 496 491 $this->data['User']['avatar'] = $final_filename; 497 492 498 if ($this->User->save($this->data ['User'])):493 if ($this->User->save($this->data)): 499 494 $this->msgFlash('Image update', '/users/edit/'); 500 495 else: 501 496 die('Error saving'); 502 497 endif; 503 498 504 499 } 505 500 } … … 524 519 //die( debug($this->data['User']) ); 525 520 if ($this->User->save($this->data['User'])): 526 $this->msgFlash(__(' User has been updated', true), '/admin/users/edit/');521 $this->msgFlash(__('Data saved', true), '/admin/users/edit/'); 527 522 endif; 528 523 endif; … … 532 527 { 533 528 $this->layout = 'admin'; 534 535 $conditions = null; //array("Entry.user_id"=>$this->Auth->user('id')); 536 537 if ($order === null) 538 { 529 530 $conditions = null; 531 532 if ($order === null): 539 533 $order = "User.id"; 540 }534 endif; 541 535 542 536 if ($group_id != null && intval($group_id) ): … … 594 588 595 589 if ( $this->data['User']['file']['error'] != 0 ): 596 $this->flash('Something where wrong, please push Back button', '/admin/users/edit/');597 return false;590 $this->flash('Something where wrong, please push Back button', '/admin/users/edit/'); 591 return false; 598 592 endif; 599 593
