Thread: Profile Enhancements - vBStatus - Facebook Style Status Display (v4)
View Single Post
  #447  
Old 07-14-2009, 03:46 AM
Majidm Majidm is offline
 
Join Date: Aug 2005
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi, nice mod.

Why are these functions in att_include.php?

Code:
 class AttilitusImage{
    
function vbimghost_imgtype ($val){
    
    $types = array(
       1 => '.GIF',
       2 => '.JPG',
       3 => '.PNG',
       4 => '.SWF',
       5 => '.PSD',
       6 => '.BMP',
       7 => '.TIFF',
       8 => '.TIFF',
       9 => '.JPC',
       10 => '.JP2',
       11 => '.JPX',
       12 => '.JB2',
       13 => '.SWC',
       14 => '.IFF',
       15 => '.WBMP',
       16 => '.XBM'
   );
   if ($val > 16 )
           return  false;
   else
           return strtolower($types[$val]);
}

function resize($filename,$imagew,$imageh){
$filepath="$directory/$filename";
$filepath=$filename;
                if(!$dime = getimagesize($filepath)){
                    eval(standard_error("Not an Image"));
                }
                $fileext=$this->vbimghost_imgtype($dime[2]);  
            
         switch ($fileext){
             case (".gif"):
                     $srcImg = imagecreatefromgif($filepath);
                     $colortrans = imagecolortransparent($srcImg);
                     $thumbImg = imagecreate($imagew, $imageh);
                     imagepalettecopy($thumbImg,$srcImg);
                     imagefill($thumbImg,0,0,$colortrans);
                     imagecolortransparent($thumbImg,$colortrans);
                     imagecopyresized($thumbImg,$srcImg,0,0,0,0,$imagew,$imageh,$dime[0],$dime[1]);
                     imagegif($thumbImg,$filepath);
                 break;
             case (".jpg"):
             case (".jpeg"):
                     $srcImg = imagecreatefromjpeg($filepath);
                     if (function_exists('imagecreatetruecolor')){
                         $thumbImg = imagecreatetruecolor($imagew,$imageh);
                         imagecopyresampled($thumbImg,$srcImg,0,0,0,0,$imagew,$imageh,$dime[0],$dime[1]);
                     }else{
                         $thumbImg = imagecreate($imagew,$imageh);
                         imagecopyresized($thumbImg,$srcImg,0,0,0,0,$imagew,$imageh,$dime[0],$dime[1]);
                     }
                     imagejpeg($thumbImg,$filepath,75);
                 break;
             case (".png"):
                     $srcImg = imagecreatefrompng($filepath);
                     if (function_exists('imagecreatetruecolor')){
                         $thumbImg = imagecreatetruecolor($imagew,$imageh);
                         imagecopyresampled($thumbImg,$srcImg,0,0,0,0,$imagew,$imageh,$dime[0],$dime[1]);
                     }else{
                         $thumbImg = imagecreate($imagew,$imageh);
                         imagecopyresized($thumbImg,$srcImg,0,0,0,0,$imagew,$imageh,$dime[0],$dime[1]);
                     }
                     imagepng($thumbImg,$filepath);
                     
                 break;
                default:
                     return false;
                     break;
         }
     imagedestroy($srcImg);
     imagedestroy($thumbImg);
     return true;
}

function upload($file,$filename,$directory,$maxw,$maxh){
            $AllowedExtensions=".jpg|.gif|.jpeg|.png";
            $AllowedExtensions=explode("|",strtolower($AllowedExtensions));
            
            $upfilename = str_replace("'","",$file['name']); 
            $upfilesize = ($file['size']/1024); 
            $upfiletype = $file['type']; 
            $upfiletname = $file['tmp_name']; 
            $upfileerro = $file['error']; 
            $fileext =trim(strtolower(strrchr($upfilename, '.')));
            //fix for getimagesize errors 
            $tmpname = "tmp_".uniqid($userid).$fileext;
            if(move_uploaded_file($upfiletname, $directory."/".$tmpname)){
                $upfiletname = $directory."/".$tmpname;
            }
            
            if ($upfilename!="")
            {
                
                if(!$dime = getimagesize($upfiletname)){
                    eval(standard_error("Not an Image"));
                }
                
                if (!$dime){
                    eval(standard_error("Error image size not defined"));    
                }
                
                $fileext = $this->vbimghost_imgtype($dime[2]);
				$this->Uploaded_EXT=$fileext;
                if(! in_array($fileext,$AllowedExtensions)){
                    eval(standard_error("Image extension is not allowed."));    
                }
                           
                //If Width or Height are off resize.
                if($dime[0] > $maxw)
                {
                    $ResizeRatio=($maxw/$dime[0]);
                    $NewWidth=$ResizeRatio*$dime[0];
                    $NewHeight=$ResizeRatio*$dime[1];
                    
                    $this->resize($upfiletname,$NewWidth,$NewHeight);
                }else if($dime[1] > $maxh){
                    $ResizeRatio=($maxh/$dime[1]);
                    $NewWidth=$ResizeRatio*$dime[0];
                    $NewHeight=$ResizeRatio*$dime[1];
                    
                    $this->resize($upfiletname,$NewWidth,$NewHeight);    
                    
                }
            
                @copy($upfiletname, $directory."/".$filename.$fileext);
                //remove temp file
                unlink($upfiletname);  
                }
            }

}
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01032 seconds
  • Memory Usage 1,799KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete