public static function deleteFromServer($image) { if (JO_Registry::get('enable_amazon')) { $s3 = new JO_Api_Amazon(JO_Registry::get('awsAccessKey'), JO_Registry::get('awsSecretKey')); $s3->putBucket(JO_Registry::get('bucklet'), JO_Api_Amazon::ACL_PUBLIC_READ); if ($s3->getBucketLogging(JO_Registry::get('bucklet'))) { $s3->deleteObject(JO_Registry::get('bucklet'), $image); } } }
public static function uploadEventImage1($avatar, $user_id = 0) { try { $added_date = time(); if (is_array($user_info = Model_Users::getUser($user_id))) { $added_date = $user_info['date_added']; } $date_added = WM_Date::format($added_date, 'yy-mm-dd H:i:s'); $s3 = new JO_Api_Amazon(JO_Registry::get('awsAccessKey'), JO_Registry::get('awsSecretKey')); $s3->putBucket(JO_Registry::get('bucklet'), JO_Api_Amazon::ACL_PUBLIC_READ); if ($s3->getBucketLogging(JO_Registry::get('bucklet'))) { if (($imageinfo = @getimagesize($avatar)) !== false) { $ext = strtolower(strrchr($avatar, ".")); $name = $user_id . $ext; $image_path = 'events/' . WM_Date::format($date_added, 'yy/mm/'); if (!file_exists(BASE_PATH . '/uploads/cache_events/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_events/' . $image_path)) { @mkdir(BASE_PATH . '/uploads/cache_events/' . $image_path, 0777, true); } @copy($avatar, BASE_PATH . '/uploads/cache_events/' . $image_path . $name); if (self::uploatToServer(BASE_PATH . '/uploads/cache_events/' . $image_path . $name, $image_path . $name)) { $model_images = new Helper_Images(); $temp_width = 0; $temp_height = 0; $sizes = self::userThumbSizes(); if ($sizes) { foreach ($sizes as $size => $prefix) { $sizes = explode('x', $size); $width = (int) isset($sizes[0]) ? $sizes[0] : 0; $height = (int) isset($sizes[1]) ? $sizes[1] : 0; $name_pref = basename($name, $ext) . $prefix . $ext; if ($width && $height) { $thumb_a = $model_images->resize('/cache_events/' . $image_path . $name, $width, $height, true); } else { if ($width && !$height) { $thumb_a = $model_images->resizeWidth('/cache_events/' . $image_path . $name, $width); } else { if ($height && !$width) { $thumb_a = $model_images->resizeHeight('/cache_events/' . $image_path . $name, $height); } } } if ($prefix == '_B') { $temp_width = $model_images->getSizes('width'); $temp_height = $model_images->getSizes('height'); } $thumb_a1 = explode('/uploads/', $thumb_a); if ($thumb_a1 && isset($thumb_a1[1])) { if (!self::uploatToServer(BASE_PATH . '/uploads/' . $thumb_a1[1], $image_path . $name_pref)) { } } } } //$model_images->deleteImages('/cache_events/' . $image_path . $name); if ($temp_width) { return array('store' => 'amazons3', 'image' => $image_path . $name, 'width' => $temp_width, 'height' => $temp_height); } else { return false; } } else { return false; } } else { return false; } } } catch (JO_Exception $e) { return false; } return false; }