function he_wall_pages_photo_upload($pages_id) { global $user, $misc, $setting; $max_filesize = 8 * 1024 * 1024; $file_exts = array('jpg', 'jpeg', 'gif', 'png'); $file_types = array('image/jpeg', 'image/jpg', 'image/jpe', 'image/pjpeg', 'image/pjpg', 'image/x-jpeg', 'x-jpg', 'image/gif', 'image/x-gif', 'image/png', 'image/x-png'); $width = 500; //TODO $height = 500; $thumb_width = 70; $thumb_height = 70; $new_upload = new se_upload(); $he_upload = new he_upload($user->user_info['user_id'], 'pages_photo'); $new_upload->new_upload('wall_photo', $max_filesize, $file_exts, $file_types); if ($new_upload->is_error) { $result = array('result' => 0, 'error' => SE_Language::get($new_upload->is_error)); } else { $upload_id = $he_upload->new_upload($pages_id); $file_name = "{$he_upload->instance_type}_{$upload_id}.{$new_upload->file_ext}"; $file_thumb = "{$he_upload->instance_type}_{$upload_id}_thumb.{$new_upload->file_ext}"; $file_thumb_path = "./uploads_pages/{$file_thumb}"; $new_upload->upload_photo($file_thumb_path, $thumb_width, $thumb_height); $new_upload->upload_photo("./uploads_pages/{$file_name}", $width, $height); $media_width = $misc->photo_size($file_thumb_path, $thumb_width, $thumb_height, "w"); $media_height = $misc->photo_size($file_thumb_path, $thumb_width, $thumb_height, "h"); if ($new_upload->is_error) { $he_upload->delete_upload($upload_id); $result = array('result' => 0, 'error' => SE_Language::get($new_upload->is_error)); } else { $he_upload->save_upload($upload_id, $file_name); $result = array('result' => 1, 'media_path' => $file_thumb_path, 'media_width' => $media_width, 'media_height' => $media_height); } } return $result; }