コード例 #1
0
ファイル: HandlingImage.php プロジェクト: egorlost/mysite
 public static function LoadImage($photo, $company_id)
 {
     $photo = trim($photo);
     $temp_path = "./cp/{$company_id}/temp_img/";
     $p1_p_title = $company_id;
     $p2_p_title = rand(1, 99999);
     $p3_p_title = time();
     $p_title = $p1_p_title . '_' . $p2_p_title . '_' . $p3_p_title . '.jpg';
     if (preg_match('/^http\\:\\/\\//', $photo)) {
         $Image = new HandlingImage();
         if ($Image->load($photo)) {
             if ($Image->getHeight() > $Image->getWidth()) {
                 $Image->resizeToWidth(800);
             } else {
                 $Image->resizeToHeight(800);
             }
             $Image->save($temp_path . $p_title);
             return $p_title;
         } else {
             return false;
         }
     } else {
         $photo = UsersLib::SeoTranslit($photo, 150);
         if (file_exists($temp_path . $photo . ".jpg")) {
             if (rename($temp_path . $photo . ".jpg", $temp_path . $p_title)) {
                 return $p_title;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
 }