PluginProbe
VdoCipher: Secure Video Player and Hosting / 1.26
VdoCipher: Secure Video Player and Hosting v1.26
trunk 1.10 1.11 1.12 1.13 1.14 1.15 1.17 1.18 1.19 1.20 1.21 1.22 1.23 1.24 1.25 1.26 1.27 1.28 1.29 1.3 1.30 1.4 1.5 1.6 All 28 releases
← All changes | vdocipher.php +101 -78 1.271.26 View file →
@@ -1,10 +1,10 @@
1 1 <?php
2 2 /**
3 3 * Plugin Name: VdoCipher
4 4 * Plugin URI: https://www.vdocipher.com
5 - * Description: Secured video hosting for WordPress
6 - * Version: 1.27
5 + * Description: Secured video hosting for wordpress
6 + * Version: 1.26
7 7 * Author: VdoCipher
8 8 * Author URI: https://www.vdocipher.com
9 9 * License: GPL2
10 10 */
@@ -10,15 +10,15 @@
10 10 */
11 11
12 12 if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) {
13 13 header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
14 - exit("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n<html lang='en'><head>\r\n<title>404 Not Found</title>\r\n".
14 + exit("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n<html><head>\r\n<title>404 Not Found</title>\r\n".
15 15 "</head><body>\r\n<h1>Not Found</h1>\r\n<p>The requested URL " . $_SERVER['SCRIPT_NAME'] . " was not found on ".
16 16 "this server.</p>\r\n</body></html>");
17 17 }
18 18
19 19 if (!defined('VDOCIPHER_PLUGIN_VERSION')) {
20 - define('VDOCIPHER_PLUGIN_VERSION', '1.27');
20 + define('VDOCIPHER_PLUGIN_VERSION', '1.25');
21 21 }
22 22
23 23 if (!defined('VDOCIPHER_PLAYER_VERSION')) {
24 24 define('VDOCIPHER_PLAYER_VERSION', '1.6.10');
@@ -23,15 +23,11 @@
23 23 if (!defined('VDOCIPHER_PLAYER_VERSION')) {
24 24 define('VDOCIPHER_PLAYER_VERSION', '1.6.10');
25 25 }
26 26
27 -if (!defined('VDOCIPHER_DEFAULT_THEME')) {
28 - define('VDOCIPHER_DEFAULT_THEME', '9ae8bbe8dd964ddc9bdb932cca1cb59a');
29 -}
30 -
31 27 function vdo_plugin_check_version()
32 28 {
33 - // This applies only for installs 1.24 and below
29 +// This applies only for installs 1.24 and below
34 30 if (!get_option('vdo_plugin_version')) {
35 31 if (preg_match('/^1\.[0123456]\.[0-9]{1,2}$/', get_option('vdo_embed_version'))) {
36 32 update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
37 33 }
@@ -40,15 +36,17 @@
40 36 }
41 37 update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION);
42 38 return ;
43 39 }
44 - // This applies for all new installations after 1.25
40 + // This applies for all new installs after 1.25
45 41 if (VDOCIPHER_PLUGIN_VERSION !== get_option('vdo_plugin_version')) {
46 42 if (preg_match('/^1\.[0-9]{1,2}\.[0-9]{1,2}$/', get_option('vdo_embed_version'))) {
47 43 update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
48 44 }
49 45 update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION);
46 + return ;
50 47 }
48 + return ;
51 49 }
52 50
53 51 add_action('plugins_loaded', 'vdo_plugin_check_version');
54 52
@@ -77,9 +75,10 @@
77 75 $video_json_response = $response['body'];
78 76 $video_list_object = json_decode($video_json_response);
79 77 $video_list = $video_list_object->rows;
80 78 $video_object = $video_list[0];
81 - return $video_object->id;
79 + $video_id = $video_object->id;
80 + return $video_id;
82 81 }
83 82 // Function called to retrieve id for when title given, ends
84 83
85 84 // Function called to get OTP, starts
@@ -123,8 +122,9 @@
123 122 'width' => get_option('vdo_default_width'),
124 123 'height' => get_option('vdo_default_height'),
125 124 'id' => 'id',
126 125 'no_annotate'=> false,
126 + 'version'=> 0,
127 127 'vdo_theme'=> false,
128 128 'vdo_version'=> false,
129 129 'player_tech'=> ''
130 130 ),
@@ -134,8 +134,9 @@
134 134 $width = $vdo_args['width'];
135 135 $height = $vdo_args['height'];
136 136 $id = $vdo_args['id'];
137 137 $no_annotate = $vdo_args['no_annotate'];
138 + $version = $vdo_args['version'];
138 139 $vdo_theme = $vdo_args['vdo_theme'];
139 140 $vdo_version = $vdo_args['vdo_version'];
140 141 $player_tech = $vdo_args['player_tech'];
141 142
@@ -178,9 +179,9 @@
178 179 $vdo_annotate_code = str_replace('{username}', $current_user->user_login, $vdo_annotate_code);
179 180 $vdo_annotate_code = str_replace('{id}', $current_user->ID, $vdo_annotate_code);
180 181 }
181 182 $vdo_annotate_code = str_replace('{ip}', $_SERVER['REMOTE_ADDR'], $vdo_annotate_code);
182 - $vdo_annotate_code = preg_replace_callback('/{date\.([^}]+)}/', "eval_date", $vdo_annotate_code);
183 + $vdo_annotate_code = preg_replace_callback('/\{date\.([^\}]+)\}/', "eval_date", $vdo_annotate_code);
183 184 $vdo_annotate_code = apply_filters('vdocipher_annotate_postprocess', $vdo_annotate_code);
184 185 // Add annotate code to $otp_post_array, which will be
185 186 // converted to Json and then sent as POST body to API endpoint
186 187 if (!$no_annotate) {
@@ -192,9 +193,10 @@
192 193 $OTP = $OTP_Response->otp;
193 194 $playbackInfo = $OTP_Response->playbackInfo;
194 195
195 196 if (is_null($OTP)) {
196 - return "<span id='vdo$OTP' style='background:#555555;color:#FFFFFF'><h4>Video not found</h4></span>";
197 + $output = "<span id='vdo$OTP' style='background:#555555;color:#FFFFFF'><h4>Video not found</h4></span>";
198 + return $output;
197 199 }
198 200
199 201 // Version, legacy, for flash only
200 202 $version = 0;
@@ -202,8 +204,11 @@
202 204 $version = $atts['version'];
203 205 }
204 206
205 207 // Video Embed version is retrieved from options table or from shortcode attribute
208 + if ((get_option('vdo_embed_version')) == false) {
209 + update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
210 + }
206 211 if (!$vdo_version) {
207 212 $vdo_embed_version_str = get_option('vdo_embed_version');
208 213 } else {
209 214 $vdo_embed_version_str = $vdo_version;
@@ -209,8 +214,11 @@
209 214 $vdo_embed_version_str = $vdo_version;
210 215 }
211 216
212 217 // Video Player theme, update and as shortcode attribute
218 + if ((get_option('vdo_player_theme')) == false) {
219 + update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a');
220 + }
213 221 if (!$vdo_theme) {
214 222 $vdo_player_theme = get_option('vdo_player_theme');
215 223 } else {
216 224 $vdo_player_theme = $vdo_theme;
@@ -218,8 +226,10 @@
218 226
219 227 // tech override custom names
220 228 switch ($player_tech) {
221 229 case "flash":
230 + $player_tech = "*,-dash";
231 + break;
222 232 case "nohtml5":
223 233 $player_tech = "*,-dash";
224 234 break;
225 235 case "noflash":
@@ -254,67 +264,44 @@
254 264 if (get_option('vdo_watermark_flash_html') === 'flash') {
255 265 $player_tech = "*,-dash";
256 266 }
257 267 }
258 - $techOverrideProperty = '';
268 + $output = "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>";
269 + $output .= "<script>(function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){".
270 + "(v[o].d=v[o].d||[]).push(a);};";
271 + $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];";
272 + $output .= "a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}";
273 + $output .= "})(window,document,'script','https://d1z78r8i505acl.cloudfront.net/playerAssets/";
274 + $output .= "$vdo_embed_version_str";
275 + $output .= "/vdo.js','vdo');";
276 + $output .= "vdo.add({";
277 + $output .= "otp: '$OTP',";
278 + $output .= "playbackInfo: '$playbackInfo',";
279 + $output .= "theme: '$vdo_player_theme',";
280 + $output .= "plugins: [{";
281 + $output .= "name: 'keyboard',";
282 + $output .= "options: {";
283 + $output .= "preset: 'default',";
284 + $output .= "bindings: {";
285 + $output .= "'Left' : (player) => player.seek(player.currentTime - 15),";
286 + $output .= "'Right' : (player) => player.seek(player.currentTime + 15),";
287 + $output .= "},";
288 + $output .= "}";
289 + $output .= "}],";
259 290 if ($player_tech !== '') {
260 - $techOverrideProperty = "techoverride: [" ;
261 - $techArray = explode(',', $player_tech);
262 - for ($i = 0; $i < sizeof($techArray); $i++) {
263 - $techStr = $techArray[$i];
264 - $techOverrideProperty .= "'$techStr'";
265 - if ($i !== sizeof($techArray)-1) {
266 - $techOverrideProperty .= ", ";
291 + $output .= "techoverride: [" ;
292 + $techarray = explode(',', $player_tech);
293 + for ($i = 0; $i < sizeof($techarray); $i++) {
294 + $techStr = $techarray[$i];
295 + $output .= "'$techStr'";
296 + if ($i !== sizeof($techarray)-1) {
297 + $output .= ", ";
267 298 }
268 299 }
269 - $techOverrideProperty .= "],";
300 + $output .= "],";
270 301 }
271 - $output = <<<END
272 - <div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>
273 - <script>(function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){
274 - (v[o].d=v[o].d||[]).push(a);};
275 - if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];
276 - a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}
277 - })(window,document,'script','https://d1z78r8i505acl.cloudfront.net/playerAssets/$vdo_embed_version_str/vdo.js','vdo');
278 - vdo.add({
279 - otp: '$OTP',
280 - playbackInfo: '$playbackInfo',
281 - theme: '$vdo_player_theme',
282 - plugins: [{
283 - name: 'keyboard',
284 - options: {
285 - preset: 'default',
286 - bindings: {
287 - 'Left' : (player) => player.seek(player.currentTime - 15),
288 - 'Right' : (player) => player.seek(player.currentTime + 15),
289 - },
290 - }
291 - }],
292 - container: document.querySelector('#vdo$OTP'),
293 - $techOverrideProperty
294 - })
295 - </script>
296 -END;
297 - $speedOptions = esc_attr(get_option('vdo_player_speed'));
298 - $speedPattern = '/^\d.\d{1,2}(,\d.\d{1,2})+$/';
299 - if ($speedOptions !== false && preg_match($speedPattern, $speedOptions)) {
300 - $output .= <<<END
301 - <script>
302 - (function () {
303 - var originalReadyFunction = window.onVdoCipherAPIReady;
304 - // private API; do not use anywhere else; might change without notice
305 - var index = vdo.d.length - 1;
306 - window.onVdoCipherAPIReady = () => {
307 - if (originalReadyFunction) originalReadyFunction();
308 - var v_ = vdo.getObjects()[index];
309 - v_.addEventListener('load', () => {
310 - v_.availablePlaybackRates = [$speedOptions]
311 - });
312 - }
313 - })()
314 - </script>
315 -END;
316 - }
302 + $output .= "container: document.querySelector('#vdo$OTP'),});";
303 + $output .= "</script>";
317 304 }
318 305 return $output;
319 306 }
320 307 add_shortcode('vdo', 'vdo_shortcode');
@@ -335,8 +322,10 @@
335 322 // add the menu item and register settings (3 functions), starts
336 323 if (is_admin()) { // admin actions
337 324 add_action('admin_init', 'register_vdo_settings');
338 325 add_action('admin_menu', 'vdo_menu');
326 +} else {
327 + // non-admin enqueues, actions, and filters
339 328 }
340 329 function vdo_menu()
341 330 {
342 331 add_menu_page(
@@ -346,10 +335,23 @@
346 335 'vdocipher',
347 336 'vdo_options',
348 337 plugin_dir_url(__FILE__).'images/logo.png'
349 338 );
339 + add_submenu_page(
340 + null,
341 + 'Video Player Themes',
342 + 'CustomPlayer',
343 + 'manage_options',
344 + 'themesvdo',
345 + 'themesvdo'
346 + );
350 347 }
351 348
349 +function themesvdo()
350 +{
351 + include('include/player_themes.php');
352 +}
353 +
352 354 function vdo_options()
353 355 {
354 356 if (!get_option('vdo_default_height')) {
355 357 update_option('vdo_default_height', 'auto');
@@ -356,15 +358,18 @@
356 358 }
357 359 if (!get_option('vdo_default_width')) {
358 360 update_option('vdo_default_width', '1280');
359 361 }
362 + $vdo_client_key = get_option('vdo_client_key');
363 + if (!$vdo_client_key && strlen($vdo_client_key) != 64) {
364 + vdo_show_form_client_key();
365 + return "";
366 + }
360 367 if (!current_user_can('manage_options')) {
361 - wp_die(__('You do not have sufficient permissions to access this page.'));
368 + wp_die(__('You do not have sufficient permissions to access this page.'));
362 369 }
363 370 include('include/options.php');
364 - return "";
365 371 }
366 -
367 372 function register_vdo_settings()
368 373 {
369 374 // whitelist options
370 375 register_setting('vdo_option-group', 'vdo_client_key');
@@ -374,21 +379,40 @@
374 379 register_setting('vdo_option-group', 'vdo_embed_version');
375 380 register_setting('vdo_option-group', 'vdo_player_theme');
376 381 register_setting('vdo_option-group', 'vdo_watermark_flash_html');
377 382 register_setting('vdo_option-group', 'vdo_plugin_version');
378 - register_setting('vdo_option-group', 'vdo_player_speed');
379 383 register_setting('vdo_custom_theme', 'vdo_player_theme_options');
380 384 }
381 385 // add the menu item and register settings (3 functions), ends
382 386
387 +// section for client key for new users
388 +function vdo_show_form_client_key()
389 +{
390 + include('include/setting_form.php');
391 +}
392 +
383 393 // Activation Hook starts
384 394 function vdo_activate()
385 395 {
386 - add_option('vdo_default_height', 'auto');
387 - add_option('vdo_default_width', 1280);
388 - add_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
389 - add_option('vdo_player_theme', VDOCIPHER_DEFAULT_THEME);
390 - add_option('vdo_watermark_flash_html', 'html5');
396 + if ((get_option('vdo_default_height')) == false) {
397 + update_option('vdo_default_height', 'auto');
398 + }
399 + if ((get_option('vdo_default_width')) == false) {
400 + update_option('vdo_default_width', '1280');
401 + }
402 + //https://stackoverflow.com/a/2173318/5022684
403 + if ((get_option('vdo_embed_version')) == false) {
404 + update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
405 + }
406 + if ((get_option('vdo_player_theme')) == false) {
407 + update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a');
408 + }
409 + if ((get_option('vdo_watermark_flash_html')) == false) {
410 + update_option('vdo_watermark_flash_html', 'html5');
411 + }
412 + if ((get_option('vdo_plugin_version')) == false) {
413 + update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION);
414 + }
391 415 }
392 416 register_activation_hook(__FILE__, 'vdo_activate');
393 417
394 418 // Registering and specifying Gutenberg block
@@ -457,9 +481,8 @@
457 481 delete_option('vdo_player_theme');
458 482 delete_option('vdo_watermark_flash_html');
459 483 delete_option('vdo_player_theme_options');
460 484 delete_option('vdo_plugin_version');
461 - delete_option('vdo_player_speed');
462 485 }
463 486 register_deactivation_hook(__FILE__, 'vdo_deactivate');
464 487
465 488 // Admin notice to configure plugin for new installs, starts