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
vdocipher / include / options.php

options.php in VdoCipher: Secure Video Player and Hosting 1.28, at include/options.php

258 lines 12.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) {
3 header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
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 "</head><body>\r\n<h1>Not Found</h1>\r\n<p>The requested URL " . $_SERVER['SCRIPT_NAME'] . " was not found on ".
6 "this server.</p>\r\n</body></html>");
7 }
8 ?>
9
10 <div class="wrap">
11 <h2>VdoCipher Options</h2>
12
13 <form name="vdoOptionForm" method="post" action="options.php">
14 <?php
15 settings_fields('vdo_option-group');
16 do_settings_sections('vdo_option-group');
17 ?>
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 ?>
24 <table class="form-table">
25 <tbody>
26 <tr valign="top">
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>
40 </tr>
41 </tbody>
42
43 <tbody style="display: <?= $restElementDisplay ?>">
44 <tr valign="top">
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')); ?>"
50 /></td>
51 </tr>
52
53 <tr valign="top">
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>
61 </tr>
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
75 <!-- Version Number -->
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"' : '';
89 }
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>
101 </tr>
102
103 <!-- Player Theme Options -->
104 <?php
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');
114 ?>
115 <tr valign="top" id="vdo_theme_editing_row" >
116 <th scope="row"><label for="vdo_player_theme">Player ID</label></th>
117 <td>
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'); ?>
180 </td>
181 </tr>
182 <!-- Player Theme Options end-->
183
184 <tr valign="top">
185 <th scope="row"><label for="vdo_watermarkjson">Annotation Statement</label></th>
186 <td>
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
190 if (get_option('vdo_annotate_code') != "") {
191 echo get_option('vdo_annotate_code');
192 $vdo_annotation_code = get_option('vdo_annotate_code');
193 }
194 ?></textarea>
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>
210 </td>
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>
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 ?>
255 <?php submit_button(); ?>
256 </form>
257 </div>
258