function wp_lightbox_secure_s3_file_download_display($name, $bucket, $source)
{
    global $wp_lightbox_config;
    //Do some error checking on the name and bucket parameters
    if (preg_match("/http/", $name)) {
        return '<div class="wp_lightbox_error_message">Looks like you have entered a URL in the "name" field for your Protected S3 Video shortcode. You should only use the name of the video file in this field (Not the full URL of the file).</div>';
    }
    if (preg_match("/http/", $bucket)) {
        return '<div class="wp_lightbox_error_message">Looks like you have entered a URL in the "bucket" field for your Protected S3 Video shortcode. You should only use the name of the bucket in this field (Not the full URL).</div>';
    }
    $access_key = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_access_key');
    $secret_key = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_secret_key');
    $link_duration = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_link_duration');
    if (empty($access_key) || empty($secret_key)) {
        return '<div class="wp_lightbox_error_message">You must fill in a value in both the "AWS Access Key ID" and the "AWS Secret Access Key" fields in the settings menu!</div>';
    }
    if (empty($link_duration) && $link_duration != '0') {
        $link_duration = '300';
    }
    $objS3 = new wp_lightbox_ultimate_amazon_s3("{$access_key}", "{$secret_key}");
    $link = $objS3->getAuthenticatedURL($bucket, $name, $link_duration);
    $wp_lightbox_output = <<<EOT

\t<div class="lightbox_ultimate_anchor lightbox_ultimate_image_anchor">

\t<a href="{$link}"><img src="{$source}" alt="" /></a>

\t</div>

EOT;
    return $wp_lightbox_output;
}
 /**
  * Get a list of CloudFront distributions
  *
  * @return array
  */
 public static function listDistributions()
 {
     self::$useSSL = true;
     // CloudFront requires SSL
     $rest = new wp_lightbox_ultimate_request_s3('GET', '', '2008-06-30/distribution', 'cloudfront.amazonaws.com');
     $rest = self::__getCloudFrontResponse($rest);
     if ($rest->error === false && $rest->code !== 200) {
         $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
     }
     if ($rest->error !== false) {
         trigger_error(sprintf("S3::listDistributions(): [%s] %s", $rest->error['code'], $rest->error['message']), E_USER_WARNING);
         return false;
     } elseif ($rest->body instanceof SimpleXMLElement && isset($rest->body->DistributionSummary)) {
         $list = array();
         if (isset($rest->body->Marker, $rest->body->MaxItems, $rest->body->IsTruncated)) {
             //$info['marker'] = (string)$rest->body->Marker;
             //$info['maxItems'] = (int)$rest->body->MaxItems;
             //$info['isTruncated'] = (string)$rest->body->IsTruncated == 'true' ? true : false;
         }
         foreach ($rest->body->DistributionSummary as $summary) {
             $list[(string) $summary->Id] = self::__parseCloudFrontDistributionConfig($summary);
         }
         return $list;
     }
     return array();
 }
function wp_lightbox_html5_protected_s3_video_display($name, $bucket, $poster, $width, $height, $source)
{
    global $wp_lightbox_config;
    //Do some error checking on the name and bucket parameters
    if (preg_match("/http/", $name)) {
        return '<div class="wp_lightbox_error_message">Looks like you have entered a URL in the "name" field for your Protected S3 Video shortcode. You should only use the name of the video file in this field (Not the full URL of the file).</div>';
    }
    if (preg_match("/http/", $bucket)) {
        return '<div class="wp_lightbox_error_message">Looks like you have entered a URL in the "bucket" field for your Protected S3 Video shortcode. You should only use the name of the bucket in this field (Not the full URL).</div>';
    }
    $access_key = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_access_key');
    $secret_key = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_secret_key');
    $link_duration = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_link_duration');
    if (empty($access_key) || empty($secret_key)) {
        return '<div class="wp_lightbox_error_message">You must fill in a value in both the "AWS Access Key ID" and the "AWS Secret Access Key" fields in the settings menu!</div>';
    }
    if (empty($link_duration) && $link_duration != '0') {
        $link_duration = '300';
    }
    $objS3 = new wp_lightbox_ultimate_amazon_s3("{$access_key}", "{$secret_key}");
    $link = $objS3->getAuthenticatedURL($bucket, $name, $link_duration);
    //$link = urlencode($link);
    $unique_video_overlay_id = wp_lightbox_generate_unique_id();
    $unique_player_id = wp_lightbox_generate_unique_id();
    $poster_url = '';
    if (!empty($poster)) {
        $poster_url = <<<EOT

\t\tposter="{$poster}"

EOT;
    }
    if (empty($width) || empty($height)) {
        $width = $wp_lightbox_config->getValue('wp_lightbox_width');
        $height = $wp_lightbox_config->getValue('wp_lightbox_height');
    }
    $flash_player_url = WP_LIGHTBOX_LIB_URL . '/mediaelement/flashmediaelement.swf';
    $wp_lightbox_output = <<<EOT

\t<div class="lightbox_ultimate_anchor lightbox_ultimate_image_anchor">

\t<a href="#{$unique_player_id}" class="wp_lightbox_html5_trigger" rel="#{$unique_video_overlay_id}"><img src="{$source}" alt="" /></a>

  \t<div id="{$unique_video_overlay_id}" class="lightbox_ultimate_fp_overlay" style="width:{$width}px;">

\t\t<video id="{$unique_player_id}" width="{$width}" height="{$height}" {$poster_url} controls="control" preload="none"> 

\t\t\t\t\t\t\t<source src="{$link}" type="video/mp4" /> 

\t\t\t\t\t\t\t<object width="{$width}" height="{$height}" type="application/x-shockwave-flash" data="{$flash_player_url}"> 

\t\t\t\t\t\t\t\t<param name="movie" value="{$flash_player_url}" /> 

\t\t\t\t\t\t\t\t<param name="flashvars" value="controls=true&amp;file={$link}" /> \t\t\t\t\t\t\t\t 

\t\t\t\t\t\t\t</object> 

\t\t</video>

  </div>

  </div>

  

EOT;
    return $wp_lightbox_output;
}
function wp_lightbox_flowplayer_protected_s3_video_display($name, $bucket, $width, $height, $source)
{
    global $wp_lightbox_config;
    //Do some error checking on the name and bucket parameters
    if (preg_match("/http/", $name)) {
        return '<div class="wp_lightbox_error_message">Looks like you have entered a URL in the "name" field for your Protected S3 Video shortcode. You should only use the name of the video file in this field (Not the full URL of the file).</div>';
    }
    if (preg_match("/http/", $bucket)) {
        return '<div class="wp_lightbox_error_message">Looks like you have entered a URL in the "bucket" field for your Protected S3 Video shortcode. You should only use the name of the bucket in this field (Not the full URL).</div>';
    }
    $access_key = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_access_key');
    $secret_key = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_secret_key');
    $link_duration = $wp_lightbox_config->getValue('wp_lightbox_amazon_s3_link_duration');
    if (empty($access_key) || empty($secret_key)) {
        return '<div class="wp_lightbox_error_message">You must fill in a value in both the "AWS Access Key ID" and the "AWS Secret Access Key" fields in the settings menu!</div>';
    }
    if (empty($link_duration) && $link_duration != '0') {
        $link_duration = '300';
    }
    if (empty($width) || empty($height)) {
        $width = $wp_lightbox_config->getValue('wp_lightbox_width');
        $height = $wp_lightbox_config->getValue('wp_lightbox_height');
    }
    $objS3 = new wp_lightbox_ultimate_amazon_s3("{$access_key}", "{$secret_key}");
    $file = $objS3->getAuthenticatedURL($bucket, $name, $link_duration);
    $file = urlencode($file);
    $unique_video_overlay_id = wp_lightbox_generate_unique_id();
    $wp_lightbox_output = <<<EOT

\t<div class="lightbox_ultimate_anchor lightbox_ultimate_image_anchor">

\t<a href="#" class="wp_lightbox_fp_trigger" rel="#{$unique_video_overlay_id}"><img src="{$source}" alt="" /></a>

\t<div id="{$unique_video_overlay_id}" class="lightbox_ultimate_fp_overlay" style="width:{$width}px;">\t

\t<a class="player" href="{$file}" style="display:block;width:{$width}px;height:{$height}px;"></a>

\t</div>

\t</div>

EOT;
    return $wp_lightbox_output;
}