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 +167 -37 1.231.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.23
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
@@ -118,8 +171,9 @@
118 171 }
119 172 if (get_option('vdo_annotate_code') != "") {
120 173 $current_user = wp_get_current_user();
121 174 $vdo_annotate_code = get_option('vdo_annotate_code');
175 + $vdo_annotate_code = apply_filters('vdocipher_annotate_preprocess', $vdo_annotate_code);
122 176 if (is_user_logged_in()) {
123 177 $vdo_annotate_code = str_replace('{name}', $current_user->display_name, $vdo_annotate_code);
124 178 $vdo_annotate_code = str_replace('{email}', $current_user->user_email, $vdo_annotate_code);
125 179 $vdo_annotate_code = str_replace('{username}', $current_user->user_login, $vdo_annotate_code);
@@ -126,9 +180,11 @@
126 180 $vdo_annotate_code = str_replace('{id}', $current_user->ID, $vdo_annotate_code);
127 181 }
128 182 $vdo_annotate_code = str_replace('{ip}', $_SERVER['REMOTE_ADDR'], $vdo_annotate_code);
129 183 $vdo_annotate_code = preg_replace_callback('/\{date\.([^\}]+)\}/', "eval_date", $vdo_annotate_code);
130 - // Add annotate code to $otp_post_array, which will be converted to Json and then sent as POST body to API endpoint
184 + $vdo_annotate_code = apply_filters('vdocipher_annotate_postprocess', $vdo_annotate_code);
185 + // Add annotate code to $otp_post_array, which will be
186 + // converted to Json and then sent as POST body to API endpoint
131 187 if (!$no_annotate) {
132 188 $otp_post_array["annotate"] = $vdo_annotate_code;
133 189 }
134 190 }
@@ -137,9 +193,8 @@
137 193 $OTP = $OTP_Response->otp;
138 194 $playbackInfo = $OTP_Response->playbackInfo;
139 195
140 196 if (is_null($OTP)) {
141 -
142 197 $output = "<span id='vdo$OTP' style='background:#555555;color:#FFFFFF'><h4>Video not found</h4></span>";
143 198 return $output;
144 199 }
145 200
@@ -148,22 +203,25 @@
148 203 if (isset($atts['version'])) {
149 204 $version = $atts['version'];
150 205 }
151 206
152 - // Video Embed version is updated
207 + // Video Embed version is retrieved from options table or from shortcode attribute
153 208 if ((get_option('vdo_embed_version')) == false) {
154 - update_option('vdo_embed_version', '1.6.4');
209 + update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
155 210 }
156 - $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 + }
157 216
158 217 // Video Player theme, update and as shortcode attribute
159 218 if ((get_option('vdo_player_theme')) == false) {
160 219 update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a');
161 220 }
162 - if(!$vdo_theme){
221 + if (!$vdo_theme) {
163 222 $vdo_player_theme = get_option('vdo_player_theme');
164 - }
165 - else {
223 + } else {
166 224 $vdo_player_theme = $vdo_theme;
167 225 }
168 226
169 227 // tech override custom names
@@ -206,9 +264,9 @@
206 264 if (get_option('vdo_watermark_flash_html') === 'flash') {
207 265 $player_tech = "*,-dash";
208 266 }
209 267 }
210 - $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>";
211 269 $output .= "<script>(function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){".
212 270 "(v[o].d=v[o].d||[]).push(a);};";
213 271 $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];";
214 272 $output .= "a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}";
@@ -218,8 +276,18 @@
218 276 $output .= "vdo.add({";
219 277 $output .= "otp: '$OTP',";
220 278 $output .= "playbackInfo: '$playbackInfo',";
221 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 .= "}],";
222 290 if ($player_tech !== '') {
223 291 $output .= "techoverride: [" ;
224 292 $techarray = explode(',', $player_tech);
225 293 for ($i = 0; $i < sizeof($techarray); $i++) {
@@ -257,9 +325,10 @@
257 325 add_action('admin_menu', 'vdo_menu');
258 326 } else {
259 327 // non-admin enqueues, actions, and filters
260 328 }
261 -function vdo_menu() {
329 +function vdo_menu()
330 +{
262 331 add_menu_page(
263 332 'VdoCipher Options',
264 333 'VdoCipher',
265 334 'manage_options',
@@ -276,9 +345,10 @@
276 345 'themesvdo'
277 346 );
278 347 }
279 348
280 -function themesvdo() {
349 +function themesvdo()
350 +{
281 351 include('include/player_themes.php');
282 352 }
283 353
284 354 function vdo_options()
@@ -308,8 +378,9 @@
308 378 register_setting('vdo_option-group', 'vdo_annotate_code');
309 379 register_setting('vdo_option-group', 'vdo_embed_version');
310 380 register_setting('vdo_option-group', 'vdo_player_theme');
311 381 register_setting('vdo_option-group', 'vdo_watermark_flash_html');
382 + register_setting('vdo_option-group', 'vdo_plugin_version');
312 383 register_setting('vdo_custom_theme', 'vdo_player_theme_options');
313 384 }
314 385 // add the menu item and register settings (3 functions), ends
315 386
@@ -329,9 +400,9 @@
329 400 update_option('vdo_default_width', '1280');
330 401 }
331 402 //https://stackoverflow.com/a/2173318/5022684
332 403 if ((get_option('vdo_embed_version')) == false) {
333 - update_option('vdo_embed_version', '1.6.4');
404 + update_option('vdo_embed_version', VDOCIPHER_PLAYER_VERSION);
334 405 }
335 406 if ((get_option('vdo_player_theme')) == false) {
336 407 update_option('vdo_player_theme', '9ae8bbe8dd964ddc9bdb932cca1cb59a');
337 408 }
@@ -337,11 +408,69 @@
337 408 }
338 409 if ((get_option('vdo_watermark_flash_html')) == false) {
339 410 update_option('vdo_watermark_flash_html', 'html5');
340 411 }
412 + if ((get_option('vdo_plugin_version')) == false) {
413 + update_option('vdo_plugin_version', VDOCIPHER_PLUGIN_VERSION);
414 + }
341 415 }
342 416 register_activation_hook(__FILE__, 'vdo_activate');
343 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 +
344 473 // Deactivation Hook starts
345 474 function vdo_deactivate()
346 475 {
347 476 delete_option('vdo_client_key');
@@ -351,8 +480,9 @@
351 480 delete_option('vdo_embed_version');
352 481 delete_option('vdo_player_theme');
353 482 delete_option('vdo_watermark_flash_html');
354 483 delete_option('vdo_player_theme_options');
484 + delete_option('vdo_plugin_version');
355 485 }
356 486 register_deactivation_hook(__FILE__, 'vdo_deactivate');
357 487
358 488 // Admin notice to configure plugin for new installs, starts