function secure_html5_video_player_get_media_server_address($client_ip, $video_filename) { $has_media_server = secure_html5_video_player_has_media_server(); if ($has_media_server) { $server_list = secure_html5_video_player_media_server_address_list(); $chksum = crc32($client_ip); if ($chksum < 0) { $chksum = -1 * $chksum; } if ($video_filename) { $server_filelist = secure_html5_video_player_filelist(true); $server_list_with_file = $server_filelist[$video_filename]; if (!empty($server_list_with_file)) { $server_list = $server_list_with_file; } } $num_servers = count($server_list); $selected_server = $chksum % $num_servers; if ($selected_server < $num_servers && isset($server_list[$selected_server]) && $server_list[$selected_server]) { return $server_list[$selected_server]; } } $plugin_url = plugins_url('secure-html5-video-player'); return $plugin_url; }
$filename = substr($filename, $last_slash_pos + 1); $filepath = $secure_html5_video_player_video_dir . '/' . $filename; $filename_no_ext = secure_html5_video_player_filename_no_ext($filename); } if (is_dir($filedir)) { $dh = opendir($filedir); while (false !== ($curr_video_file = readdir($dh))) { if (secure_html5_video_player_startsWith($curr_video_file, '.')) { continue; } $ext = secure_html5_video_player_filename_get_ext($curr_video_file); $normalized_ext = secure_html5_video_player_filename_get_normalized_ext($ext); $start_check = $filename_no_ext . '.'; if (secure_html5_video_player_startsWith($curr_video_file, $start_check)) { print $normalized_ext . '=' . secure_html5_video_player_media_url($secure_html5_video_player_video_dir, $plugin_dir, $access_key, $original_filename_no_ext, $ext) . "\n"; $found = true; } } } if (!$found) { print '0'; } } else { if ($info == 'list') { $video_files = secure_html5_video_player_filelist(false); foreach ($video_files as $curr_video_file => $server_addr) { print $curr_video_file; print "\n"; } } }
function secure_html5_video_player_inner_custom_box($post) { wp_nonce_field(plugin_basename(__FILE__), 'secure_html5_video_player_noncename'); $secure_html5_video_player_video_shortcode = get_option('secure_html5_video_player_video_shortcode', 'video'); $defaults = array('width' => get_option('secure_html5_video_player_default_width'), 'height' => get_option('secure_html5_video_player_default_height'), 'preload' => get_option('secure_html5_video_player_default_preload'), 'autoplay' => get_option('secure_html5_video_player_default_autoplay'), 'loop' => get_option('secure_html5_video_player_default_loop')); $instance = array('video' => get_post_meta($post->ID, 'sh5vp-video', true), 'youtube_video_id' => get_post_meta($post->ID, 'sh5vp-youtube_video_id', true), 'vimeo_video_id' => get_post_meta($post->ID, 'sh5vp-vimeo_video_id', true), 'width' => get_post_meta($post->ID, 'sh5vp-width', true), 'height' => get_post_meta($post->ID, 'sh5vp-height', true), 'preload' => get_post_meta($post->ID, 'sh5vp-preload', true), 'autoplay' => get_post_meta($post->ID, 'sh5vp-autoplay', true), 'loop' => get_post_meta($post->ID, 'sh5vp-loop', true)); foreach ($defaults as $key => $value) { if (!$instance[$key]) { $instance[$key] = $value; } } ?> <table> <tr> <td><label for="sh5vp-video"><?php _e('Video', 'secure-html5-video-player'); ?> :</label></td> <td> <?php $video_files = secure_html5_video_player_filelist(true); if (!empty($video_files)) { $preview_key = secure_html5_video_player_accessKey('preview-iframe'); ?> <select id="sh5vp-video" name="sh5vp-video" > <option value=""></option> <?php foreach ($video_files as $curr_video_file => $server_addr) { ?> <option data-key="<?php print $preview_key; ?> " value="<?php print $curr_video_file; ?> " <?php if ($instance['video'] == $curr_video_file) { ?> selected="selected" <?php } ?> ><?php print $curr_video_file; //if (count($server_addr) > 0) { // print ' (' . implode(', ', $server_addr) . ')'; //} ?> </option><?php } ?> </select><?php } else { ?> <input type="text" id="sh5vp-video" name="sh5vp-video" value="<?php print $instance['video']; ?> " /><?php } ?> </td> </tr> <tr> <td><label for="sh5vp-youtube_video_id"><?php _e('Youtube video ID', 'secure-html5-video-player'); ?> :</label></td> <td><input type="text" id="sh5vp-youtube_video_id" name="sh5vp-youtube_video_id" value="<?php print $instance['youtube_video_id']; ?> " /></td> </tr> <tr> <td><label for="sh5vp-vimeo_video_id"><?php _e('Vimeo video ID', 'secure-html5-video-player'); ?> :</label></td> <td><input type="text" id="sh5vp-vimeo_video_id" name="sh5vp-vimeo_video_id" value="<?php print $instance['vimeo_video_id']; ?> " /></td> </tr> <tr> <td><label for="sh5vp-width"><?php _e('Width', 'secure-html5-video-player'); ?> :</label></td> <td><input type="text" id="sh5vp-width" name="sh5vp-width" value="<?php print $instance['width']; ?> " size="5" /> px</td> </tr> <tr> <td><label for="sh5vp-height"><?php _e('Height', 'secure-html5-video-player'); ?> :</label></td> <td><input type="text" id="sh5vp-height" name="sh5vp-height" value="<?php print $instance['height']; ?> " size="5" /> px</td> </tr> <tr> <td></td> <td> <input type="checkbox" id="sh5vp-preload" name="sh5vp-preload" value="yes" <?php if ($instance['preload'] == 'yes') { ?> checked="checked" <?php } ?> /> <label for="sh5vp-preload"><?php _e('Preload', 'secure-html5-video-player'); ?> </label> </td> </tr> <tr> <td></td> <td> <input type="checkbox" id="sh5vp-autoplay" name="sh5vp-autoplay" value="yes" <?php if ($instance['autoplay'] == 'yes') { ?> checked="checked" <?php } ?> /> <label for="sh5vp-autoplay"><?php _e('Autoplay', 'secure-html5-video-player'); ?> </label> </td> </tr> <tr> <td></td> <td> <input type="checkbox" id="sh5vp-loop" name="sh5vp-loop" value="yes" <?php if ($instance['loop'] == 'yes') { ?> checked="checked" <?php } ?> /> <label for="sh5vp-loop"><?php _e('Loop', 'secure-html5-video-player'); ?> </label> </td> </tr> <tr> <td colspan="2"> <input type="button" class="button-secondary" value="<?php _e('Insert Into Post', 'secure-html5-video-player'); ?> " onclick="sh5vp_insertIntoPost();"/> <input type="button" class="button-secondary" value="<?php _e('Preview Video', 'secure-html5-video-player'); ?> " onclick="sh5vp_previewVideo();"/> </td> </tr> </table> <div class="sh5vp-video-modal" id="sh5vp-video-modal" data-video-shortcode="<?php echo $secure_html5_video_player_video_shortcode; ?> " data-youtube_override_type="<?php echo get_option('secure_html5_video_player_youtube_override_type'); ?> " data-plugin_dir="<?php echo plugins_url('secure-html5-video-player'); ?> " <?php foreach ($defaults as $key => $value) { echo " data-default-{$key}=\"{$value}\""; } ?> > <div class="sh5vp-modal-bg"></div> <div class="sh5vp-modal-inner"> <div class="sh5vp-modal-close"></div> <h1 class="sh5vp-modal-title">Secure HTML5 Video Preview</h1> <iframe class="sh5vp-modal-iframe" width="560" height="315" src="" frameborder="0" allowfullscreen scrolling="no"></iframe> <div> <table> <tr><td class="sh5vp-preview-label">Video:</td><td class="sh5vp-preview-selected-video"></td></tr> <tr><td class="sh5vp-preview-label">Youtube:</td><td class="sh5vp-preview-selected-youtube"></td></tr> <tr><td class="sh5vp-preview-label">Vimeo:</td><td class="sh5vp-preview-selected-vimeo"></td></tr> </table> </div> </div> </div> <p><?php _e('To use the video in your template, call the function: <code>get_sh5vp_featured_video($post_id, $width, $height)</code>, which returns the appropriate video tag. Or call: <code>sh5vp_featured_video($post_id, $width, $height)</code> which prints the appropriate video tag. The arguments: <code>$width</code> and <code>$height</code> are optional, and taken from the settings above if not specified.', 'secure-html5-video-player'); ?> </p> <p><?php _e('Alternatively, you may insert the video into the post as a shortcode by placing the text cursor into the editor and pressing the <em>Insert Into Post</em> button, above.', 'secure-html5-video-player'); ?> </p> <?php }
function form($instance) { $defaults = array('title' => '', 'video' => '', 'youtube_video_id' => '', 'vimeo_video_id' => '', 'width' => get_option('secure_html5_video_player_default_width'), 'height' => get_option('secure_html5_video_player_default_height'), 'preload' => get_option('secure_html5_video_player_default_preload'), 'autoplay' => get_option('secure_html5_video_player_default_autoplay'), 'loop' => get_option('secure_html5_video_player_default_loop'), 'caption' => ''); $instance = wp_parse_args((array) $instance, $defaults); ?> <table> <tr> <td colspan="2"><label for="<?php print $this->get_field_id('title'); ?> "><?php _e('Title', 'secure-html5-video-player'); ?> :</label></td> </tr> <tr> <td colspan="2"><input type="text" id="<?php print $this->get_field_id('title'); ?> " name="<?php print $this->get_field_name('title'); ?> " value="<?php print $instance['title']; ?> " style="width:400px;"/></td> </tr> <tr> <td colspan="2"><label for="<?php print $this->get_field_id('video'); ?> "><?php _e('Video', 'secure-html5-video-player'); ?> :</label></td></tr> <tr> <td colspan="2"><?php $video_files = secure_html5_video_player_filelist(true); if (!empty($video_files)) { ?> <select id="<?php print $this->get_field_id('video'); ?> " name="<?php print $this->get_field_name('video'); ?> " style="width:400px;"> <option value=""></option> <?php $preview_key = secure_html5_video_player_accessKey('preview-iframe'); foreach ($video_files as $curr_video_file => $server_addr) { ?> <option data-key="<?php print $preview_key; ?> " value="<?php print $curr_video_file; ?> " <?php if ($instance['video'] == $curr_video_file) { ?> selected="selected" <?php } ?> ><?php print $curr_video_file; //if (count($server_addr) > 0) { // print ' (' . implode(', ', $server_addr) . ')'; //} ?> </option><?php } ?> </select><?php } else { ?> <input type="text" id="<?php print $this->get_field_id('video'); ?> " name="<?php print $this->get_field_name('video'); ?> " value="<?php print $instance['video']; ?> " style="width:400px;"/><?php } ?> </td> </tr> <tr> <td colspan="2"><label for="<?php print $this->get_field_id('youtube_video_id'); ?> "><?php _e('Youtube video ID', 'secure-html5-video-player'); ?> :</label></td> </tr> <tr> <td colspan="2"><input type="text" id="<?php print $this->get_field_id('youtube_video_id'); ?> " name="<?php print $this->get_field_name('youtube_video_id'); ?> " value="<?php print $instance['youtube_video_id']; ?> " style="width:400px;"/></td> </tr> <tr> <td colspan="2"><label for="<?php print $this->get_field_id('vimeo_video_id'); ?> "><?php _e('Vimeo video ID', 'secure-html5-video-player'); ?> :</label></td> </tr> <tr> <td colspan="2"><input type="text" id="<?php print $this->get_field_id('vimeo_video_id'); ?> " name="<?php print $this->get_field_name('vimeo_video_id'); ?> " value="<?php print $instance['vimeo_video_id']; ?> " style="width:400px;"/></td> </tr> <tr> <td><label for="<?php print $this->get_field_id('width'); ?> "><?php _e('Width', 'secure-html5-video-player'); ?> :</label></td> <td style="width:100%;"><input type="text" id="<?php print $this->get_field_id('width'); ?> " name="<?php print $this->get_field_name('width'); ?> " value="<?php print $instance['width']; ?> " size="5" /> px</td> </tr> <tr> <td><label for="<?php print $this->get_field_id('height'); ?> "><?php _e('Height', 'secure-html5-video-player'); ?> :</label></td> <td><input type="text" id="<?php print $this->get_field_id('height'); ?> " name="<?php print $this->get_field_name('height'); ?> " value="<?php print $instance['height']; ?> " size="5" /> px</td> </tr> <tr> <td colspan="2"> <input type="checkbox" id="<?php print $this->get_field_id('preload'); ?> " name="<?php print $this->get_field_name('preload'); ?> " value="yes" <?php if ($instance['preload'] == 'yes') { ?> checked="checked" <?php } ?> /> <label for="<?php print $this->get_field_id('preload'); ?> "><?php _e('Preload', 'secure-html5-video-player'); ?> </label> </td> </tr> <tr> <td colspan="2"> <input type="checkbox" id="<?php print $this->get_field_id('autoplay'); ?> " name="<?php print $this->get_field_name('autoplay'); ?> " value="yes" <?php if ($instance['autoplay'] == 'yes') { ?> checked="checked" <?php } ?> /> <label for="<?php print $this->get_field_id('autoplay'); ?> "><?php _e('Autoplay', 'secure-html5-video-player'); ?> </label> </td> </tr> <tr> <td colspan="2"> <input type="checkbox" id="<?php print $this->get_field_id('loop'); ?> " name="<?php print $this->get_field_name('loop'); ?> " value="yes" <?php if ($instance['loop'] == 'yes') { ?> checked="checked" <?php } ?> /> <label for="<?php print $this->get_field_id('loop'); ?> "><?php _e('Loop', 'secure-html5-video-player'); ?> </label> </td> </tr> <tr><td colspan="2"><label for="<?php print $this->get_field_id('caption'); ?> "><?php _e('Caption (Text or HTML)', 'secure-html5-video-player'); ?> :</label></td></tr> <tr><td colspan="2"><textarea id="<?php print $this->get_field_id('caption'); ?> " name="<?php print $this->get_field_name('caption'); ?> " rows="5" cols="29" class="widefat" ><?php print $instance['caption']; ?> </textarea></td></tr> <tr><td colspan="2" class="sh5vp-widget-preview"><input type="button" class="button-secondary" value="<?php _e('Preview Video', 'secure-html5-video-player'); ?> " onclick="sh5vp_previewVideo({ video: '<?php print $this->get_field_id('video'); ?> ', youtube: '<?php print $this->get_field_id('youtube_video_id'); ?> ', vimeo: '<?php print $this->get_field_id('vimeo_video_id'); ?> ', width: '<?php print $this->get_field_id('width'); ?> ', height: '<?php print $this->get_field_id('height'); ?> ', preload: '<?php print $this->get_field_id('preload'); ?> ', autoplay: '<?php print $this->get_field_id('autoplay'); ?> ', loop: '<?php print $this->get_field_id('loop'); ?> ', modal: '<?php print $this->get_field_id('modal'); ?> ' });"/></td></tr> </table> <div class="sh5vp-video-modal" id="<?php print $this->get_field_id('modal'); ?> " data-video-shortcode="<?php echo get_option('secure_html5_video_player_video_shortcode', 'video'); ?> " data-youtube_override_type="<?php echo get_option('secure_html5_video_player_youtube_override_type'); ?> " data-plugin_dir="<?php echo plugins_url('secure-html5-video-player'); ?> " <?php foreach ($defaults as $key => $value) { echo " data-default-{$key}=\"{$value}\""; } ?> > <div class="sh5vp-modal-bg"></div> <div class="sh5vp-modal-inner"> <div class="sh5vp-modal-close"></div> <h1 class="sh5vp-modal-title">Secure HTML5 Video Preview</h1> <iframe class="sh5vp-modal-iframe" width="560" height="315" src="" frameborder="0" allowfullscreen scrolling="no"></iframe> <div> <table> <tr><td class="sh5vp-preview-label">Video:</td><td class="sh5vp-preview-selected-video"></td></tr> <tr><td class="sh5vp-preview-label">Youtube:</td><td class="sh5vp-preview-selected-youtube"></td></tr> <tr><td class="sh5vp-preview-label">Vimeo:</td><td class="sh5vp-preview-selected-vimeo"></td></tr> </table> </div> </div> </div> <?php }