Changeset 686 for trunk/app/controllers

Show
Ignore:
Timestamp:
08/01/08 23:57:18 (4 months ago)
Author:
aarkerio
Message:

Test JS

Location:
trunk/app/controllers
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/images_controller.php

    r591 r686  
    9090     
    9191    /** 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"; 
    9796      /** delete uploaded file  */ 
    9897      unlink($imgfile); 
     
    103102    if ( $imgfile_size > $maxfilesize): 
    104103      $error  = "Error. The image is bigger than 2.0 MB. Current size: " . $imgfile_size; 
    105          
    106104      /** delete uploaded file */ 
    107105      unlink($imgfile); 
  • trunk/app/controllers/users_controller.php

    r674 r686  
    435435    /** Security: checks to see if file is an image, if not do not allow upload ==*/ 
    436436     
    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? */ 
    439439        $ErrMsg   = "<h1>ERROR</h1> the file $imgfile_name $imgfile is not valid.<br>"; 
    440440        $ErrMsg  .= "<p>Only .jpg, .gif or .png files<br><br>"; 
     
    444444        unlink($imgfile); 
    445445        die($this->flash($ErrMsg, '/admin/users/edit/') ); 
    446     } 
    447      
    448     if ( $imgfile_size > $maxfilesize)  
    449     { 
     446    endif; 
     447     
     448    if ( $imgfile_size > $maxfilesize): 
    450449      $error  = "Error. The image is too big. Bigger than 2.0 MB  Current size: " . $imgfile_size ."\n"; 
    451450              
     
    454453      $this->flash($error,'/users/edit/'); 
    455454      return false; 
    456     } 
     455    endif; 
    457456   
    458457    //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"; 
    463461              
    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; 
    469467   
    470468    $extension   = $this->Adds->get_extension($type); 
     
    479477     
    480478    /** do extra security check to prevent malicious abuse */ 
    481     if (is_uploaded_file($imgfile)) 
    482     { 
     479    if (is_uploaded_file($imgfile)): 
    483480       /** 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)): 
    487482          die($this->flash('Error Uploading File.', '/users/edit/')); 
    488        } 
    489    } 
     483       endif; 
     484    endif; 
    490485    
    491486  /** delete the temporary uploaded file **/ 
     
    496491  $this->data['User']['avatar'] = $final_filename; 
    497492    
    498   if ($this->User->save($this->data['User'])): 
     493  if ($this->User->save($this->data)): 
    499494           $this->msgFlash('Image update', '/users/edit/'); 
    500495  else: 
    501496           die('Error saving');    
    502497  endif; 
    503     
     498 
    504499 } 
    505500 
     
    524519       //die( debug($this->data['User']) ); 
    525520       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/'); 
    527522       endif; 
    528523    endif; 
     
    532527 { 
    533528    $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): 
    539533         $order = "User.id"; 
    540     } 
     534    endif; 
    541535        
    542536    if ($group_id != null && intval($group_id) ): 
     
    594588 
    595589    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; 
    598592    endif; 
    599593