Skip to content

Commit

Permalink
Merge pull request #171 from TheCraigHewitt/release/1.16.4
Browse files Browse the repository at this point in the history
Release/1.16.4
  • Loading branch information
jonathanbossenger authored Jun 21, 2017
2 parents 9d41aa3 + 8f10184 commit 8b7e385
Show file tree
Hide file tree
Showing 9 changed files with 382 additions and 369 deletions.
2 changes: 1 addition & 1 deletion assets/js/fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jQuery(document).ready(function($) {
$('#upload_audio_file').siblings('span.description').html('Your media file has been successfully uploaded.');
$('.peek-a-bar').fadeOut(5000);
}else {
var notification_message = 'An error occurred, please try again.' + close_anchor;
var notification_message = 'An error occurred, please try again. ' + close_anchor;
if ( result.message !== ''){
notification_message = result.message + close_anchor;
}
Expand Down
2 changes: 1 addition & 1 deletion assets/js/fileupload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions includes/class-podmotor-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private function init_podmotor_client() {
$this->podmotor_bucket = $response['bucket'];
$this->podmotor_show_slug = $response['show_slug'];
$this->podmotor_client = S3Client::factory( $this->podmotor_config );

}

/**
Expand Down Expand Up @@ -185,10 +186,8 @@ public function upload_file_from_external_source( $remote_file = '' ) {
if ( empty( $remote_file ) ) {
$this->update_response( 'message', 'The remote file url is empty' );
}
ssp_debug( 'Download remote file ' . $remote_file );
$downloaded_file = ssp_download_remote_file( $remote_file );
if ( $downloaded_file ) {
ssp_debug( 'Uploading downloaded file to S3 ' . $downloaded_file );
$podmotor_response = $this->upload_file_to_podmotor_storage( $downloaded_file );
if ( 'success' === $podmotor_response['status'] ) {
$this->update_response( 'status', 'success' );
Expand All @@ -197,7 +196,6 @@ public function upload_file_from_external_source( $remote_file = '' ) {
} else {
$this->update_response( 'message', 'An error occurred uploading the file to Seriously Simple Hosting' );
}
ssp_debug( 'Clearing local download file ' . $downloaded_file );
@unlink( $downloaded_file );
} else {
$this->update_response( 'message', 'An error occurred downloading the remote file' );
Expand All @@ -222,13 +220,13 @@ public function upload_file_to_podmotor_storage( $file, $podcast_id = 0 ) {
$file_info = pathinfo( $file );
$base_file_name = $file_info['basename'];
try {
$result = $this->podmotor_client->putObject( [
$result = $this->podmotor_client->putObject( array(
'Bucket' => $this->podmotor_bucket,
'Key' => $this->podmotor_show_slug . '/' . sanitize_file_name( $base_file_name ),
'Body' => fopen( $file, 'r' ),
'ACL' => 'public-read',
'StorageClass' => 'REDUCED_REDUNDANCY',
] );
) );
$podmotor_uploaded_file = $result['ObjectURL'];
if ( ! empty( $podmotor_uploaded_file ) ) {
$this->update_response( 'status', 'success' );
Expand All @@ -243,6 +241,7 @@ public function upload_file_to_podmotor_storage( $file, $podcast_id = 0 ) {
update_post_meta( $podcast_id, 'duration', $duration );
}
}
$this->clear_local_podmotor_file( $file );
} else {
$this->update_response( 'message', 'An error occured uploading the file to Seriously Simple Hosting' );
}
Expand Down Expand Up @@ -290,7 +289,6 @@ public function upload_podmotor_storage_file_data_to_podmotor( $podmotor_file_pa
$this->update_response( 'file_id', $responseObject->file_id );
$this->update_response( 'file_path', $responseObject->file_path );
} else {
ssp_debug( $responseObject );
$this->update_response( 'message', 'An error occurred uploading the file data to Seriously Simple Hosting' );
}
} else {
Expand All @@ -310,7 +308,8 @@ public function upload_podmotor_storage_file_data_to_podmotor( $podmotor_file_pa
*/
public function clear_local_podmotor_file( $podmotor_file_path = '' ) {
$file_info = pathinfo( $podmotor_file_path );
$file_to_be_deleted = SSP_UPLOADS_DIR . $file_info['basename'];
$file_to_be_deleted = ssp_get_upload_directory() . $file_info['basename'];
ssp_debug( $file_to_be_deleted );
if ( is_file( $file_to_be_deleted ) ) {
unlink( $file_to_be_deleted );
}
Expand Down Expand Up @@ -445,7 +444,11 @@ public function podmotor_decrypt_config( $encrypted_string, $unique_key ) {
list( $original_string, $encrypted_string, $encoding_iv ) = $regs;
$encoding_method = 'AES-128-CTR';
$encoding_key = crypt( $unique_key, sha1( $unique_key ) );
$decrypted_token = openssl_decrypt( $encrypted_string, $encoding_method, $encoding_key, 0, hex2bin( $encoding_iv ) );
if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
$decrypted_token = openssl_decrypt( $encrypted_string, $encoding_method, $encoding_key, 0, pack( 'H*', $encoding_iv ) );
} else {
$decrypted_token = openssl_decrypt( $encrypted_string, $encoding_method, $encoding_key, 0, hex2bin( $encoding_iv ) );
}
$config = unserialize( $decrypted_token );
return $config;
} else {
Expand Down
Loading

0 comments on commit 8b7e385

Please sign in to comment.