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 +165 -37 1.241.26 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * Plugin Name: VdoCipher
4 4 * Plugin URI: https://www.vdocipher.com
5 5 * Description: Secured video hosting for wordpress
6 - * Version: 1.24
6 + * Version: 1.26
7 7 * Author: VdoCipher
8 8 * Author URI: https://www.vdocipher.com
9 9 * License: GPL2
10 10 */
@@ -15,10 +15,45 @@
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 +if (!defined('VDOCIPHER_PLUGIN_VERSION')) {
20 + define('VDOCIPHER_PLUGIN_VERSION', '1.25');
21 +}
22 +
23 +if (!defined('VDOCIPHER_PLAYER_VERSION')) {
24 + define('VDOCIPHER_PLAYER_VERSION', '1.6.10');
25 +}
26 +
27 +function vdo_plugin_check_version()
28 +{
29 +// This applies only for installs 1.24 and below
30 + if (!get_option('vdo_plugin_version')) {
31 + if (preg_match('/^1\.[0123456]\.[0-9]{1,2}$/', get_option('vdo_embed_version'))) {
32 + update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
33 + }
34 + if (preg_match('/^1\.[01234]\.[0-9]{1,2}$/', get_option('vdo_embed_version'))) {
35 + update_option('vdo_default_height', 'auto');
36 + }
37 + update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION);
38 + return ;
39 + }
40 + // This applies for all new installs after 1.25
41 + if (VDOCIPHER_PLUGIN_VERSION !== get_option('vdo_plugin_version')) {
42 + if (preg_match('/^1\.[0-9]{1,2}\.[0-9]{1,2}$/', get_option('vdo_embed_version'))) {
43 + update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
44 + }
45 + update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION);
46 + return ;
47 + }
48 + return ;
49 +}
50 +
51 +add_action('plugins_loaded', 'vdo_plugin_check_version');
52 +
19 53 // Function called to retrieve id for when title given, starts
20 -function vdo_retrieve_id($title) {
54 +function vdo_retrieve_id($title)
55 +{
21 56 $client_key = get_option('vdo_client_key');
22 57 if ($client_key == false || $client_key == "") {
23 58 return "Plugin not configured. Please set the API key to embed videos.";
24 59 }
@@ -46,9 +81,10 @@
46 81 }
47 82 // Function called to retrieve id for when title given, ends
48 83
49 84 // Function called to get OTP, starts
50 -function vdo_otp($video, $otp_post_array = array()) {
85 +function vdo_otp($video, $otp_post_array = array())
86 +{
51 87 $client_key = get_option('vdo_client_key');
52 88 if ($client_key == false || $client_key == "") {
53 89 return "Plugin not configured. Please set the API key to embed videos.";
54 90 }
@@ -58,13 +94,16 @@
58 94 'Content-Type'=>'application/json',
59 95 'Accept'=>'application/json'
60 96 );
61 97 $otp_post_json = json_encode($otp_post_array);
62 - $response = wp_remote_post($url, array(
63 - 'method' => 'POST',
64 - 'headers' => $headers,
65 - 'body' => $otp_post_json
66 - ));
98 + $response = wp_remote_post(
99 + $url,
100 + array(
101 + 'method' => 'POST',
102 + 'headers' => $headers,
103 + 'body' => $otp_post_json
104 + )
105 + );
67 106 if (is_wp_error($response)) {
68 107 $error_message = $response->get_error_message();
69 108 echo "VdoCipher: Something went wrong: $error_message";
70 109 return "";
@@ -76,36 +115,50 @@
76 115
77 116 // VdoCipher Shortcode starts
78 117 function vdo_shortcode($atts)
79 118 {
80 - extract(shortcode_atts(
119 + $vdo_args = shortcode_atts(
81 120 array(
82 - 'title' => 'TITLE_OF_VIDEO',
83 - 'width' => get_option('vdo_default_width') . "px",
84 - 'height' => get_option('vdo_default_height') . "px",
85 - 'id' => 'id',
86 - 'no_annotate'=> false,
87 - 'version'=> 0,
88 - 'vdo_theme'=> false,
89 - 'player_tech'=> ''
90 - ),
121 + 'title' => 'TITLE_OF_VIDEO',
122 + 'width' => get_option('vdo_default_width'),
123 + 'height' => get_option('vdo_default_height'),
124 + 'id' => 'id',
125 + 'no_annotate'=> false,
126 + 'version'=> 0,
127 + 'vdo_theme'=> false,
128 + 'vdo_version'=> false,
129 + 'player_tech'=> ''
130 + ),
91 131 $atts
92 - ));
93 - if ((get_option('vdo_default_height')) == 'auto') {
94 - $height = 'auto';
132 + );
133 + $title = $vdo_args['title'];
134 + $width = $vdo_args['width'];
135 + $height = $vdo_args['height'];
136 + $id = $vdo_args['id'];
137 + $no_annotate = $vdo_args['no_annotate'];
138 + $version = $vdo_args['version'];
139 + $vdo_theme = $vdo_args['vdo_theme'];
140 + $vdo_version = $vdo_args['vdo_version'];
141 + $player_tech = $vdo_args['player_tech'];
142 +
143 + if (!preg_match('/.*px$/', $width)) {
144 + $width = $width."px";
95 145 }
146 + if (!preg_match('/.*px$/', $height)) {
147 + if ($height != 'auto') {
148 + $height = $height."px";
149 + }
150 + }
96 151 if (!$atts['id']) {
97 152 if (!$atts['title']) {
98 153 return "Required argument id for embedded video not found.";
99 - }
100 - else {
154 + } else {
101 155 $video = vdo_retrieve_id($title);
102 156 if ($video == null) {
103 157 return "404. Video not found.";
104 158 }
105 159 }
106 - }
107 - else {
160 + } else {
108 161 $video = $id;
109 162 }
110 163
111 164 // Initialize $otp_post_array, to be sent as part of OTP request, as for time-to-live 300
@@ -128,9 +181,10 @@
128 181 }
129 182 $vdo_annotate_code = str_replace('{ip}', $_SERVER['REMOTE_ADDR'], $vdo_annotate_code);
130 183 $vdo_annotate_code = preg_replace_callback('/\{date\.([^\}]+)\}/', "eval_date", $vdo_annotate_code);
131 184 $vdo_annotate_code = apply_filters('vdocipher_annotate_postprocess', $vdo_annotate_code);
132 - // Add annotate code to $otp_post_array, which will be converted to Json and then sent as POST body to API endpoint
185 + // Add annotate code to $otp_post_array, which will be
186 + // converted to Json and then sent as POST body to API endpoint
133 187 if (!$no_annotate) {
134 188 $otp_post_array["annotate"] = $vdo_annotate_code;
135 189 }
136 190 }
@@ -139,9 +193,8 @@
139 193 $OTP = $OTP_Response->otp;
140 194 $playbackInfo = $OTP_Response->playbackInfo;
141 195
142 196 if (is_null($OTP)) {
143 -
144 197 $output = "<span id='vdo$OTP' style='background:#555555;color:#FFFFFF'><h4>Video not found</h4></span>";
145 198 return $output;
146 199 }
147 200
@@ -150,22 +203,25 @@
150 203 if (isset($atts['version'])) {
151 204 $version = $atts['version'];
152 205 }
153 206
154 - // Video Embed version is updated
207 + // Video Embed version is retrieved from options table or from shortcode attribute
155 208 if ((get_option('vdo_embed_version')) == false) {
156 - update_option('vdo_embed_version', '1.6.4');
209 + update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
157 210 }
158 - $vdo_embed_version_str = get_option('vdo_embed_version');
211 + if (!$vdo_version) {
212 + $vdo_embed_version_str = get_option('vdo_embed_version');
213 + } else {
214 + $vdo_embed_version_str = $vdo_version;
215 + }
159 216
160 217 // Video Player theme, update and as shortcode attribute
161 218 if ((get_option('vdo_player_theme')) == false) {
162 219 update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a');
163 220 }
164 - if(!$vdo_theme){
221 + if (!$vdo_theme) {
165 222 $vdo_player_theme = get_option('vdo_player_theme');
166 - }
167 - else {
223 + } else {
168 224 $vdo_player_theme = $vdo_theme;
169 225 }
170 226
171 227 // tech override custom names
@@ -208,9 +264,9 @@
208 264 if (get_option('vdo_watermark_flash_html') === 'flash') {
209 265 $player_tech = "*,-dash";
210 266 }
211 267 }
212 - $output .= "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>";
268 + $output = "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>";
213 269 $output .= "<script>(function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){".
214 270 "(v[o].d=v[o].d||[]).push(a);};";
215 271 $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];";
216 272 $output .= "a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}";
@@ -220,8 +276,18 @@
220 276 $output .= "vdo.add({";
221 277 $output .= "otp: '$OTP',";
222 278 $output .= "playbackInfo: '$playbackInfo',";
223 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 .= "}],";
224 290 if ($player_tech !== '') {
225 291 $output .= "techoverride: [" ;
226 292 $techarray = explode(',', $player_tech);
227 293 for ($i = 0; $i < sizeof($techarray); $i++) {
@@ -259,9 +325,10 @@
259 325 add_action('admin_menu', 'vdo_menu');
260 326 } else {
261 327 // non-admin enqueues, actions, and filters
262 328 }
263 -function vdo_menu() {
329 +function vdo_menu()
330 +{
264 331 add_menu_page(
265 332 'VdoCipher Options',
266 333 'VdoCipher',
267 334 'manage_options',
@@ -278,9 +345,10 @@
278 345 'themesvdo'
279 346 );
280 347 }
281 348
282 -function themesvdo() {
349 +function themesvdo()
350 +{
283 351 include('include/player_themes.php');
284 352 }
285 353
286 354 function vdo_options()
@@ -310,8 +378,9 @@
310 378 register_setting('vdo_option-group', 'vdo_annotate_code');
311 379 register_setting('vdo_option-group', 'vdo_embed_version');
312 380 register_setting('vdo_option-group', 'vdo_player_theme');
313 381 register_setting('vdo_option-group', 'vdo_watermark_flash_html');
382 + register_setting('vdo_option-group', 'vdo_plugin_version');
314 383 register_setting('vdo_custom_theme', 'vdo_player_theme_options');
315 384 }
316 385 // add the menu item and register settings (3 functions), ends
317 386
@@ -331,9 +400,9 @@
331 400 update_option('vdo_default_width', '1280');
332 401 }
333 402 //https://stackoverflow.com/a/2173318/5022684
334 403 if ((get_option('vdo_embed_version')) == false) {
335 - update_option('vdo_embed_version', '1.6.4');
404 + update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
336 405 }
337 406 if ((get_option('vdo_player_theme')) == false) {
338 407 update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a');
339 408 }
@@ -339,11 +408,69 @@
339 408 }
340 409 if ((get_option('vdo_watermark_flash_html')) == false) {
341 410 update_option('vdo_watermark_flash_html', 'html5');
342 411 }
412 + if ((get_option('vdo_plugin_version')) == false) {
413 + update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION);
414 + }
343 415 }
344 416 register_activation_hook(__FILE__, 'vdo_activate');
345 417
418 +// Registering and specifying Gutenberg block
419 +function vdo_register_block()
420 +{
421 + if (!function_exists('register_block_type')) {
422 + return ;
423 + }
424 + wp_register_script(
425 + 'vdo-block-script',
426 + plugins_url('/include/block/dist/blocks.build.js', __FILE__),
427 + array('wp-blocks', 'wp-element', 'wp-editor', 'wp-i18n')
428 + );
429 + wp_register_style(
430 + 'vdo-block-base-style',
431 + plugins_url('/include/block/dist/blocks.style.build.css', __FILE__),
432 + array('wp-blocks')
433 + );
434 + wp_register_style(
435 + 'vdo-block-editor-style',
436 + plugins_url('/include/block/dist/blocks.editor.build.css', __FILE__),
437 + array('wp-edit-blocks')
438 + );
439 + register_block_type(
440 + 'vdo/block',
441 + array(
442 + 'editor_script'=>'vdo-block-script',
443 + 'editor_style'=>'vdo-block-editor-style',
444 + 'style'=>'vdo-block-base-style',
445 + 'attributes'=>array(
446 + 'id'=>array(
447 + 'type'=>'string',
448 + ),
449 + 'width'=>array(
450 + 'type'=>'string',
451 + 'default'=>get_option('vdo_default_width')
452 + ),
453 + 'height'=>array(
454 + 'type'=>'string',
455 + 'default'=>get_option('vdo_default_height')
456 + ),
457 + 'vdo_theme'=>array(
458 + 'type'=>'string',
459 + 'default'=>get_option('vdo_player_theme')
460 + ),
461 + 'vdo_version'=>array(
462 + 'type'=>'string',
463 + 'default'=>get_option('vdo_embed_version')
464 + ),
465 + ),
466 + 'render_callback'=>'vdo_shortcode'
467 + )
468 + );
469 +}
470 +
471 +add_action('init', 'vdo_register_block');
472 +
346 473 // Deactivation Hook starts
347 474 function vdo_deactivate()
348 475 {
349 476 delete_option('vdo_client_key');
@@ -353,8 +480,9 @@
353 480 delete_option('vdo_embed_version');
354 481 delete_option('vdo_player_theme');
355 482 delete_option('vdo_watermark_flash_html');
356 483 delete_option('vdo_player_theme_options');
484 + delete_option('vdo_plugin_version');
357 485 }
358 486 register_deactivation_hook(__FILE__, 'vdo_deactivate');
359 487
360 488 // Admin notice to configure plugin for new installs, starts