PluginProbe
VdoCipher: Secure Video Player and Hosting / 1.28
VdoCipher: Secure Video Player and Hosting v1.28
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 | include/options.php +208 -57 1.141.28 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2 if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) {
3 3 header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
4 - exit("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n<html><head>\r\n<title>404 Not Found</title>\r\n".
4 + 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".
5 5 "</head><body>\r\n<h1>Not Found</h1>\r\n<p>The requested URL " . $_SERVER['SCRIPT_NAME'] . " was not found on ".
6 6 "this server.</p>\r\n</body></html>");
7 7 }
8 8 ?>
@@ -9,98 +9,249 @@
9 9
10 10 <div class="wrap">
11 11 <h2>VdoCipher Options</h2>
12 12
13 -<form method="post" action="options.php">
13 +<form name="vdoOptionForm" method="post" action="options.php">
14 14 <?php
15 15 settings_fields('vdo_option-group');
16 16 do_settings_sections('vdo_option-group');
17 17 ?>
18 - <div class="updated">
19 - <p><strong>Status : </strong> Ready to use. You can now embed your videos inside posts and pages.</p>
20 - </div>
18 + <?php
19 + $existingKey = get_option('vdo_client_key');
20 + $keyIsValid = $existingKey && strlen($existingKey) == 64;
21 + $keyDescriptionDisplay = $keyIsValid ? 'none' : 'block';
22 + $restElementDisplay = $keyIsValid ? 'table-row-group' : 'none';
23 + ?>
21 24 <table class="form-table">
25 + <tbody>
22 26 <tr valign="top">
23 - <th scope="row">Client Secret Key</th>
24 - <td><input type="text" name="vdo_client_key"
25 - value="<?php echo esc_attr(get_option('vdo_client_key')); ?>"
26 - max-length="64" style="width: 640px" id="vdo_client_key" /></td>
27 + <th scope="row"><label for="vdo_client_key">API Secret Key</label></th>
28 + <td>
29 + <div style="display: inline-flex;">
30 + <input id="vdo_client_key" name="vdo_client_key" style="width: 640px"
31 + type="password" required minlength="64" maxlength="64"
32 + value="<?php echo esc_attr(get_option('vdo_client_key')); ?>"/>
33 + <button id="toggle_API_visibility" data-protected="On" class="button" type="button">Show API Secret Key</button>
34 + </div>
35 + <p class="description" style="display: <?= $keyDescriptionDisplay ?>">
36 + API Key is a shared secret between your website servers and vdocipher dashboard. To generate this,
37 + login to vdocipher dashboard, go to "Config" > "API Keys". Generate a new key and copy-paste it here.
38 + </p>
39 + </td>
27 40 </tr>
41 + </tbody>
28 42
43 + <tbody style="display: <?= $restElementDisplay ?>">
29 44 <tr valign="top">
30 - <th scope="row">Default Width</th>
31 - <td><input type="text" name="vdo_default_width"
32 - value="<?php echo esc_attr(get_option('vdo_default_width')); ?>"
45 + <th scope="row"><label for="vdo_default_width">Default Width</label></th>
46 + <td>
47 + <input id="vdo_default_width" name="vdo_default_width"
48 + type="number" required
49 + value="<?php echo esc_attr(get_option('vdo_default_width')); ?>"
33 50 /></td>
34 51 </tr>
35 52
36 53 <tr valign="top">
37 - <th scope="row">Default Height</th>
38 - <td><input type="text" name="vdo_default_height"
39 - value="<?php echo esc_attr(get_option('vdo_default_height')); ?>"
40 - /></td>
54 + <th scope="row"><label for="vdo_default_height">Default Height</label></th>
55 + <td>
56 + <input type="text" id="vdo_default_height" name="vdo_default_height"
57 + required pattern="^auto|\d+$"
58 + value="<?php echo esc_attr(get_option('vdo_default_height')); ?>"/>
59 + <p class="description">Can be either "auto" or a number. Set to "auto" height and max width for responsive layout.</p>
60 + </td>
41 61 </tr>
42 62
63 + <tr>
64 + <th scope="row"><label for="vdo_player_speed">Playback speed</label></th>
65 + <td>
66 + <input type="text" id="vdo_player_speed" name="vdo_player_speed"
67 + pattern="^\d.\d{1,2}(,\d.\d{1,2})+$"
68 + value="<?php echo esc_attr(get_option('vdo_player_speed')); ?>"
69 + />
70 + <p class="description">Speed can be defined as comma separated decimal values e.g. 0.75,1.0,1.25,1.5,1.75,2.0</p>
71 + <p class="description">With player v2, there is an option to set this as part of custom player configuration. This setting will override any options set as part of custom player.</p>
72 + </td>
73 + </tr>
74 +
43 75 <!-- Version Number -->
44 - <?php
45 - if (empty(get_option('vdo_embed_version'))) {
46 - update_option('vdo_embed_version', '0.5');
76 + <?php
77 + $existingVersion = get_option('vdo_embed_version');
78 + $embedVersionDisplay = 'none';
79 + if ($existingVersion !== false && $existingVersion !== VDOCIPHER_PLAYER_VERSION) {
80 + $embedVersionDisplay = 'table-row';
81 + } ?>
82 + <tr valign="top">
83 + <?php
84 + function vdo_selected($match) {
85 + $existingEmbedVersion = get_option('vdo_embed_version');
86 + // global $existingEmbedVersion;
87 + // return $GLOBALS['existingEmbedVersion'] ;
88 + return $existingEmbedVersion === $match ? 'selected="selected"' : '';
47 89 }
48 - ?>
49 - <tr valign="top">
50 - <th scope="row">Player Version</th>
51 - <td>
52 - <?php $vdo_embed_version_vars = array('0.5', '1.0.0', '1.1.0'); ?>
53 - <select name="vdo_embed_version" id="vdo_embed_version">
54 - <?php
55 - $vdo_embed_version_str = get_option('vdo_embed_version');
56 - ?>
57 - <?php
58 - foreach($vdo_embed_version_vars as $vdo_embed_version_var) {
59 - if ($vdo_embed_version_str == $vdo_embed_version_var) {
60 - $selected = 'selected="selected"'; }
61 - else { $selected = ''; }
62 -
63 - if($vdo_embed_version_var === '0.5') {
64 - $version_old_new = ' (old player)' ; }
65 - else {
66 - $version_old_new = ' (new player)' ; }
67 - ?>
68 - <option value="<?php echo $vdo_embed_version_var; ?>" <?php echo $selected; ?> >
69 - <?php echo $vdo_embed_version_var . $version_old_new ; ?>
70 - </option>
71 - <?php } ?>
72 - </select>
73 - </td>
90 + ?>
91 + <th scope="row"><label for="vdo_embed_version">Player Version</label></th>
92 + <td>
93 + <div style="display: inline-flex">
94 + <select name="vdo_embed_version" id="vdo_embed_version" onchange="" autocomplete="off">
95 + <option value="1.6.10" <?= vdo_selected('1.6.10') ?>>v1</option>
96 + <option value="v2" <?= vdo_selected('v2') ?>>v2 (Recommended)</option>
97 + </select>
98 + </div>
99 + <?php include( 'player-versions-doc.php' ) ?>
100 + </td>
74 101 </tr>
75 102
76 103 <!-- Player Theme Options -->
77 104 <?php
78 - if (empty(get_option('vdo_player_theme'))) {
79 - update_option('vdo_player_theme','9ae8bbe8dd964ddc9bdb932cca1cb59a');
80 - }
105 + /**
106 + * if the player is v1 and non-standard theme, then only allow disabling non-standard themes
107 + * if the player is v1 and standard theme, do not show anything
108 + * if the player is v2, allow adding player IDs. But validate the length of id
109 + *
110 + * This can be implemented in both PHP and JS. But if the JS is essential, then we can skip
111 + * writing in PHP and run the JS function after page load.
112 + */
113 + $existingTheme = get_option('vdo_player_theme');
81 114 ?>
82 - <tr valign="top">
83 - <th scope="row">Player Theme</th>
115 + <tr valign="top" id="vdo_theme_editing_row" >
116 + <th scope="row"><label for="vdo_player_theme">Player ID</label></th>
84 117 <td>
85 - <input type="text" name="vdo_player_theme"
86 - value="<?php echo esc_attr(get_option('vdo_player_theme')); ?>" max-length = "32" style="width: 320px"
87 - />
88 - <p class="description">Player theme is not available for old player version(0.5). The default theme will be applied for old player.</p>
118 + <div style="display:inline-flex; margin-bottom:10px;">
119 + <input
120 + type="text"
121 + name="vdo_player_theme"
122 + id="vdo_player_theme"
123 + value="<?php echo $existingTheme; ?>"
124 + maxlength="32"
125 + style="width: 320px"
126 + />
127 + <p class="vdo_saveChangeMessage" style="display: none; font-style: italic">Click on "save changes" below to confirm</p>
128 + <button id="vdo_setDefaultThemeBtn" style="display: none" class="button" type="button">Revert to default theme</button><br/>
129 + <script>
130 + (function () {
131 + const themeInputRow = document.querySelector('#vdo_theme_editing_row');
132 + const themeInputField = themeInputRow.querySelector('input');
133 + const playerVersionField = document.querySelector('[name=vdo_embed_version]');
134 + const setDefaultButton = document.querySelector('#vdo_setDefaultThemeBtn');
135 + playerVersionField.addEventListener('change', updateThemeInput);
136 + const defaultV1Theme = '9ae8bbe8dd964ddc9bdb932cca1cb59a';
137 + const originalTheme = "<?= get_option('vdo_player_theme') ?>";
138 + let resetV2Theme, resetV1Theme;
139 + function updateThemeInput() {
140 + if (playerVersionField.value === 'v2') {
141 + themeInputRow.style.display = '';
142 + if (themeInputField.value.match(/^\w{32}$/)) resetV1Theme = themeInputField.value;
143 + if (resetV2Theme) themeInputField.value = resetV2Theme;
144 + // if the input is not valid for v2, clear the field
145 + if (!themeInputField.value.match(/^\w{16}$/)) themeInputField.value = '';
146 + // set the max and min length for v2 players
147 + themeInputField.setAttribute('maxlength', '16');
148 + themeInputField.setAttribute('minlength', '16');
149 + setDefaultButton.style.display = 'none';
150 + } else {
151 + // if input valid for v2, save in reset variable
152 + if (themeInputField.value.match(/^\w{16}$/)) resetV2Theme = themeInputField.value;
153 + if (resetV1Theme) themeInputField.value = resetV1Theme;
154 + // if input is not valid for v1, reset to default theme
155 + if (!themeInputField.value.match(/^\w{32}$/)) themeInputField.value = defaultV1Theme;
156 + themeInputField.setAttribute('maxlength', '32');
157 + themeInputField.setAttribute('minlength', '32');
158 + // if original theme was some custom v1 theme, hide the entire row
159 + // else, show reset button
160 + if (originalTheme.length !== 32 || originalTheme === defaultV1Theme) {
161 + themeInputRow.style.display = 'none';
162 + } else {
163 + setDefaultButton.style.display = '';
164 + setDefaultButton.addEventListener('click', (e) => {
165 + e.preventDefault();
166 + themeInputField.value = '9ae8bbe8dd964ddc9bdb932cca1cb59a'
167 + e.target.style.display = 'none';
168 + e.target.parentElement.querySelector('.vdo_saveChangeMessage').style.display = '';
169 + });
170 + }
171 + }
172 + }
173 + setTimeout(() => {
174 + updateThemeInput();
175 + }, 0);
176 + })()
177 + </script>
178 + </div>
179 + <?php include('player-id-doc.html'); ?>
89 180 </td>
90 181 </tr>
182 + <!-- Player Theme Options end-->
91 183
92 184 <tr valign="top">
93 - <th scope="row">Annotation Statement</th>
185 + <th scope="row"><label for="vdo_watermarkjson">Annotation Statement</label></th>
94 186 <td>
95 - <textarea name="vdo_annotate_code" type="textarea" rows="5" cols="60"><?php
187 + <div style="display: inline-flex;">
188 + <textarea name="vdo_annotate_code" id="vdo_watermarkjson" rows="6" cols="55" style="font-family: monospace"
189 + ><?php
96 190 if (get_option('vdo_annotate_code') != "") {
97 191 echo get_option('vdo_annotate_code');
192 + $vdo_annotation_code = get_option('vdo_annotate_code');
98 193 }
99 194 ?></textarea>
100 - <p class="description">Leave this text blank in case you do not need watermark over all Videos. For details on writing the annotation code <a href="https://www.vdocipher.com/blog/2014/12/add-text-to-videos-with-watermark/" target="_blank">check this out</a></p>
195 + <p class="description" style="margin-left:20px; position: relative">
196 + <span style="color:purple"><b>Sample Code for Dynamic Watermark</b></span><br/>
197 + [{'type':'rtext', 'text':' {name}', 'alpha':'0.60', 'color':'0xFF0000','size':'15','interval':'5000'}] <br/>
198 + <span style="color:purple"><b>Sample Code for Static Watermark</b></span><br/>
199 + [{'type':'text', 'text':'{ip}', 'alpha':'0.5' , 'x':'10', 'y':'100', 'color':'0xFF0000', 'size':'12'}] <br/>
200 + </p>
201 + </div>
202 + <p class="description" id="vdojsonvalidator"></p>
203 + <p class="description">
204 + Leave this text blank in case you do not need watermark over all
205 + videos. For details on writing the annotation code
206 + <a href="https://www.vdocipher.com/blog/2014/12/add-text-to-videos-with-watermark/" target="_blank">
207 + check this out
208 + </a>
209 + </p>
101 210 </td>
102 211 </tr>
212 +
213 + <!-- Advanced Options -->
214 +
215 + <tr valign="top">
216 + <th scope="row"></th>
217 + <td>
218 + <details>
219 + <summary style="cursor: pointer">Advanced Options</summary>
220 + <div style="margin: 20px 0">
221 + <div style="display: inline-flex;">
222 + <div style="width: 300px;">
223 + <label for="vdo_show_plugin_in_sidebar"><strong>Show VdoCipher in sidebar</strong></label>
224 + </div>
225 + <div>
226 + <input type="checkbox" name="vdo_show_plugin_in_sidebar" id="vdo_show_plugin_in_sidebar"
227 + value="true" <?php echo esc_attr(get_option('vdo_show_plugin_in_sidebar')) == 'true' ? 'checked' : ''; ?>/>
228 + </div>
229 + </div>
230 + <p class="description">
231 + Not recommended to be changed. Mark this option unchecked if you like to hide the VdoCipher settings page from the sidebar.<br/>
232 + Once changed, you will need to access this page from inside the Wordpress Settings / Plugins page.
233 + </p>
234 + </div>
235 + </details>
236 +
237 + </td>
238 + </tr>
239 +
240 + <!-- Footer -->
241 + <tr style="display:none;">
242 + <td>Plugin version no.: </td>
243 + <td><input
244 + id="vdo_plugin_version" name="vdo_plugin_version" type="hidden"
245 + value="<?php echo esc_attr(get_option('vdo_plugin_version')); ?>" readonly>
246 + </td>
247 + </tr>
248 +
249 + </tbody>
103 250 </table>
251 + <?php
252 + wp_enqueue_script('vdo_validate_watermark', plugin_dir_url(__FILE__).'js/validatewatermark.js');
253 + wp_enqueue_script('vdo_hide_key', plugin_dir_url(__FILE__).'js/showkey.js');
254 + ?>
104 255 <?php submit_button(); ?>
105 256 </form>
106 257 </div>