Blame view

application/function.php 3.42 KB
8d65d0ce   andryeyev   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  <?php
  function Redirect($path){
   header('location:' . $path);
  }
  
  function translitIt($str) 
  {
      $tr = array(
          "À"=>"a","Á"=>"b","Â"=>"v","Ã"=>"g",
          "Ä"=>"d","Å"=>"e","Æ"=>"j","Ç"=>"z","È"=>"i",
          "É"=>"y","Ê"=>"k","Ë"=>"l","Ì"=>"m","Í"=>"n",
          "Î"=>"o","Ï"=>"p","Ð"=>"r","Ñ"=>"s","Ò"=>"t",
          "Ó"=>"u","Ô"=>"f","Õ"=>"h","Ö"=>"ts","×"=>"ch",
          "Ø"=>"sh","Ù"=>"sch","Ú"=>"","Û"=>"yi","Ü"=>"",
          "Ý"=>"e","Þ"=>"yu","ß"=>"ya","à"=>"a","á"=>"b",
          "â"=>"v","ã"=>"g","ä"=>"d","å"=>"e","æ"=>"j",
          "ç"=>"z","è"=>"i","é"=>"y","ê"=>"k","ë"=>"l",
          "ì"=>"m","í"=>"n","î"=>"o","ï"=>"p","ð"=>"r",
          "ñ"=>"s","ò"=>"t","ó"=>"u","ô"=>"f","õ"=>"h",
          "ö"=>"ts","÷"=>"ch","ø"=>"sh","ù"=>"sch","ú"=>"y",
          "û"=>"yi","ü"=>"","ý"=>"e","þ"=>"yu","ÿ"=>"ya","¿"=>"i", "¯"=>"Yi", "º"=>"ie", "ª"=>"Ye", 
          " "=> "_", "."=> "", "/"=> "_","%"=>'vidsotkiv',
      );
      
  
  		return strtolower(strtr($str,$tr));
  
  }
  
  function upload_ImageResize($upload,$option){
  
  	// *** 1) Initialise / load image
  	$resizeObj = new resize($upload);
  
  	// *** 2) Resize image (options: exact, portrait, landscape, auto, crop)
  	$options = isset($option['crop']) ? 'crop' : 'auto';
  	$resizeObj -> resizeImage($option["width"], $option["height"], $options);
  
  	// *** 3) Save image
  	$type = substr(strrchr($upload['name'],"."),1);
      $nameFile = mktime() . "_" . rand(1,10000) . "." . $type;
      $save_image = $option["upload_path"] . $nameFile;
  	$resizeObj -> saveImage($save_image, 100);
  
  
  	
  
  return $nameFile;
  }
  
          function upload_ImageResize2($upload,$option){
  
     $type = substr(strrchr($upload['name'],"."),1);
     $newWidth = $option["width"];
     $newHeight = $option["height"];
     $nameFile = mktime() . "_" . rand(1,10000) . "." . $type;
     $save_image = $option["upload_path"] . $nameFile;
     $img = $upload["tmp_name"];
  
  switch($type){
  case "jpg":
     $function_image_create = "ImageCreateFromJpeg";
     $function_image_new = "ImageJpeg";
  case "jpeg":
     $function_image_create = "ImageCreateFromJpeg";
     $function_image_new = "ImageJpeg";
  break;
  case "png":
     $function_image_create = "ImageCreateFromPng";
     $function_image_new = "ImagePNG";
  break;
  case "gif":
     $function_image_create = "ImageCreateFromGif";
     $function_image_new = "ImageGif";
  break;
  default:
     $function_image_create = "ImageCreateFromJpeg";
     $function_image_new = "ImageJpeg";
  break;
  }
  
  
     $srcImage = @$function_image_create($img);
  
     $srcWidth  = ImageSX($srcImage);
     $srcHeight = ImageSY($srcImage);
  
  
    if ( ($newWidth < $srcWidth) || ($newHeight < $srcHeight) ) {
     if( $srcWidth < $srcHeight ){
         $destWidth  = $newWidth * $srcWidth/$srcHeight;
         $destHeight = $newHeight;
     }else{
         $destWidth  = $newWidth;
         $destHeight = $newHeight * $srcHeight/$srcWidth;
     }
    }else{ $destWidth = $srcWidth;$destHeight = $srcHeight;}
  
  
  
     $destImage = imagecreatetruecolor($destWidth, $destHeight);
  
     ImageCopyResampled( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight );
             /*
     if(isset($option['str']) && strlen($option['str'])>0){
      $colorGrey=imagecolorallocate($destImage, 192, 192, 192);
      $height_str = $destHeight-7;
      imagettftext($destImage,15,0,7,$height_str,$colorGrey,"{$_SERVER['DOCUMENT_ROOT']}/libs/fonts/ds_zombi.ttf",$option['str']);
     }   */
    @$function_image_new($destImage,$save_image,100);
  
  
     ImageDestroy( $srcImage  );
     ImageDestroy( $destImage );
  
  return $nameFile;
  }
  
  ?>