PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 2.02
WpStream – Live Streaming, Video on Demand, Pay Per View v2.02
4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 4.5.12 All 180 releases
wpstream / libs / plugin-admin.php

plugin-admin.php in WpStream – Live Streaming, Video on Demand, Pay Per View 2.02, at libs/plugin-admin.php

502 lines 22.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 function wpstream_set_wpstream_credentials(){
3
4 if($_SERVER['REQUEST_METHOD'] === 'POST'){
5 $allowed_html = array();
6 $exclude_array = array();
7 $allowed_html = array();
8
9 foreach($_POST as $variable=>$value){
10
11 if ($variable!='submit'){
12 if (!in_array($variable, $exclude_array) ){
13 update_option( sanitize_key('wpstream_'.$variable), wp_kses ($value,$allowed_html) );
14 }
15 }
16 }
17
18
19 update_option('wp_estate_token_expire',0);
20 update_option('wp_estate_curent_token',' ');
21
22
23
24 }
25
26
27 $allowed_html = array();
28 $api_key = esc_html( get_option('wpstream_api_key','') );
29
30
31 $wpstream_options_array =array(
32 2 => array(
33 'label' => 'WpStream.net Username',
34 'name' => 'api_username',
35 'type' => 'text',
36 ),
37 3 => array(
38 'label' => 'WpStream.net Password',
39 'name' => 'api_password',
40 'type' => 'password',
41 ),
42 0 => array(
43 'label' => 'API Key',
44 'name' => 'api_key',
45 'type' => 'text',
46 ),
47 1 => array(
48 'label' => 'API Secret Key',
49 'name' => 'api_secret_key',
50 'type' => 'text',
51 ),
52
53 );
54
55
56 $token = wpstream_rcapi_retrive_token();
57
58 $pack_details = wpstream_get_pack_details_user();
59
60 if( isset($pack_details['band']) && isset( $pack_details['storage']) ){
61 print '<div class="pack_details_wrapper"><strong>'.__('Your account information: ','wpstream').'</strong> '.__('You have','wpstream').'<strong> '.wpstream_convert_band($pack_details['band']).' Gb</strong> '.__('available streaming bandwidth and','wpstream').' <strong>'.wpstream_convert_band($pack_details['storage']).' Gb</strong> '.__('available media storage','wpstream').'.</div>';
62 print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">';
63 print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">';
64
65 }
66
67
68
69 print '<form method="post" action="" >';
70 print '<div class="theme_options_tab_wpstream" style="display:block;" >
71 <h1>'.__('Connection Settings','wpstream').'</h1>';
72
73 if( wpstream_client_check_api_status() ){
74 echo '<div class="api_conected">'.__('Conected to WpStream.net API!','wpstream').'</div>';
75 }else{
76 echo '<div class="api_not_conected">'.__('No Connection to WpStream.net API. Go ','wpstream').'<a href="https://wpstream.net/my-account" target="_blank">here</a>'.__(' to get your API credentials','wpstream').'</div>';
77 }
78 print '<div class="wpstream_option_wrapper">';
79 foreach ($wpstream_options_array as $key=>$option){
80 print '<div class="wpstream_option">';
81
82 $options_value = esc_html( get_option('wpstream_'.$option['name'],'') );
83 print '<label for="'.$option['name'].'">'.$option['label'].'</label>';
84 print '<input id="'.$option['name'].'" type="'.$option['type'].'" size="36" name="'.$option['name'].'" value="'.esc_html($options_value).'" />';
85
86 print '</div>';
87 }
88 print '</div>';
89
90
91 print '<input type="submit" name="submit" class="wpstream_button" value="'.__('Save Changes','wpstream').'" />';
92
93 print '</div>';
94 print '</form>';
95
96
97 }
98 function wpstream_new_general_set() {
99
100
101
102 $no_channel=1;
103
104 if(class_exists ('WC_Subscription')){
105
106 }
107
108 //event_passed
109 $args = array(
110 'posts_per_page' => -1,
111 'post_type' => 'product',
112 'post_status' => 'publish',
113 'meta_query' => array(
114 array(
115 'key' => 'event_passed',
116 'value' => 1,
117 'compare' => '!=',
118 )
119 ),
120
121 'tax_query' => array(
122 'relation' => 'AND',
123 array(
124 'taxonomy' => 'product_type',
125 'field' => 'slug',
126 'terms' => array('live_stream','subscription')
127 )
128 ),
129 );
130
131
132
133 $event_list = new WP_Query($args);
134 global $live_event_for_user;
135
136 $live_event_for_user = wpstream_get_live_event_for_user();
137
138
139
140 $pack_details = wpstream_get_pack_details_user();
141
142 if( isset($pack_details['band']) && isset( $pack_details['storage']) ){
143 print '<div class="pack_details_wrapper"><strong>'.__('Your account information: ','wpstream').'</strong> '.__('You have','wpstream').'<strong> '.wpstream_convert_band($pack_details['band']).' Gb</strong> '.__('available streaming bandwidth and','wpstream').' <strong>'.wpstream_convert_band($pack_details['storage']).' Gb</strong> '.__('available media storage','wpstream').'.</div>';
144 print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">';
145 print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">';
146
147 }
148
149
150
151
152 if($event_list->have_posts()){
153 print '<div class="pack_details_wrapper_transparent">
154 <h3>'.__('Your Paid Channel List','wpestate').'</h3>
155 </div>';
156
157 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
158
159 while ($event_list->have_posts()): $event_list->the_post();
160
161 $the_id = get_the_ID();
162 $is_subscription_live_event = esc_html(get_post_meta($the_id,'_subscript_live_event',true));
163 $term_list = wp_get_post_terms($the_id, 'product_type');
164
165 if( $term_list[0]->name=='subscription' && $is_subscription_live_event=='no'){
166 continue;
167 }
168
169 wpstream_live_stream_unit($the_id);
170
171 endwhile;
172
173 print'</div>';
174 $no_channel=1;
175 }else{
176 $no_channel=0;
177 }
178
179
180 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
181 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
182 $current_user = wp_get_current_user();
183 $allowded_html = array();
184 $userID = $current_user->ID;
185 $user_live_streams = get_user_meta($userID,'live_shows');
186
187
188 wp_reset_postdata();
189
190
191
192
193
194
195
196
197 // free
198
199 $args_free = array(
200 'posts_per_page' => -1,
201 'post_type' => 'wpstream_product',
202 'post_status' => 'publish',
203 'meta_query' => array(
204 'relation' => 'AND',
205 array(
206 'key' => 'wpstream_product_type',
207 'value' => 1,
208 'compare' => '==',
209 ),
210
211 ),
212
213
214 );
215 $event_list_free = new WP_Query($args_free);
216 // array(
217 // 'key' => 'event_passed',
218 // 'value' => 1,
219 // 'compare' => '!=',
220 // )
221
222 if($event_list_free->have_posts()){
223 print '<div class="pack_details_wrapper_transparent">
224 <h3>'.__('Your Free Channel List','wpestate').'</h3>
225 </div>';
226
227 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
228
229 while ($event_list_free->have_posts()): $event_list_free->the_post();
230
231
232 $the_id = get_the_ID();
233
234 if( get_post_meta ($the_id,'event_passed',true)!=1){
235 wpstream_live_stream_unit($the_id);
236 }
237
238 endwhile;
239
240 print'</div>';
241 $no_channel=1;
242 }else{
243 $no_channel=0;
244 }
245
246
247
248 if($no_channel==0){
249 print '<div class="no_events_warning"> '.__('* You don\'t have any live channels. Please add one in your Free Products / Woocomerce Products menu!','wpstream').'</div>';
250 }
251
252
253
254
255 }
256 // end wpstream_new_general_set
257
258
259
260
261
262
263
264 function wpstream_live_stream_unit($the_id){
265 global $live_event_for_user;
266
267 $live_class='';
268 if(isset($live_event_for_user[$the_id])) {
269 $live_class=" wpstream_show_started";
270 }
271
272
273 print '<div class="event_list_unit '.$live_class.' ">';
274 $ip= get_post_meta($the_id,'ip',true);
275 $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
276 print '<div class="event_thumb_wrapper"><img class="event_thumb" src="'.$thumb.'" alt="show_imagge"></div>';
277 print '<h3 data-prodid="'.$the_id.'">'.get_the_title($the_id).' - '.esc_html__('Id','wpstream').': '.$the_id.'<a class="view_channel" href="'.get_permalink($the_id).'" target="_blank">'.esc_html__('View Channel','wprentals').'</a></h3> ';
278
279 $live_event_stream_name = get_post_meta($the_id,'live_event_stream_name',true);
280 $live_event_array = get_post_meta($the_id,'live_event_uri',true);
281 $live_event_uri = '';
282
283
284 $pending_streaming_class = '';
285 $wpstream_ready_to_stream_class = '';
286 $external_software_streaming_class = '';
287 $wpstream_no_stream_class = '';
288 $carnat_key1 = '';
289 $carnat_key2 = '';
290 $uri = '';
291 $webcaster_url = '';
292 $rtmp_ip_uri = '';
293 $uri_ip = '';
294
295 if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
296
297 $pending_streaming_class = 'show_stream_data pending_trigger';
298 $wpstream_ready_to_stream_class = 'hide_stream_data';
299 $external_software_streaming_class = 'show_stream_data';
300 $wpstream_no_stream_class = 'hide_stream_data';
301 if(isset($live_event_for_user[$the_id]['live_uri'])){
302 $explode = explode('wpstream.net/', $live_event_for_user[$the_id]['live_uri']);
303 $uri = $explode[0].'wpstream.net/wpstream/';
304 $stream_name = get_post_meta($the_id,'live_event_stream_name',true);
305 $carnat_key1 = $live_event_for_user[$the_id]['carnat1'];
306 $carnat_key2 = $live_event_for_user[$the_id]['carnat2'];
307 $webcaster_url = 'https://'.$live_event_for_user[$the_id]['subdomain_key'].'.live.streamer.wpstream.net:8443/'.$live_event_for_user[$the_id]['carnat2'];
308
309 $rtmp_ip_uri = 'http://'.$live_event_for_user[$the_id]['ip'].':8444';
310 $uri_ip= 'rtmp://'.$live_event_for_user[$the_id]['ip'].'/wpstream/';
311 }
312
313 }else{
314
315 $pending_streaming_class = 'hide_stream_data';
316 $wpstream_ready_to_stream_class = 'hide_stream_data';
317 $external_software_streaming_class = 'hide_stream_data';
318 $wpstream_no_stream_class = 'show_stream_data';
319 }
320
321
322
323
324 print' <div class="pending_streaming '.$pending_streaming_class.' " data-server-id="'.$the_id.'" data-server-url="'.$rtmp_ip_uri.'">';
325 print'<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>'.esc_html__('Getting ready to stream. Please wait...','wprentals').' ';
326 print '<img class="server_loading_new" src="'.plugin_dir_url( dirname( __FILE__ ) ).'img/loading.gif" alt="loading" /></div>';
327 print '<div class="multiple_warning_events"> '.esc_html__('* You can run multiple live events on a single channel. **Once deleted, you can no longer broadcast to it.','wpstream').'</div>';
328 print '</div>';
329
330
331 print '<div class="wpstream_ready_to_stream '.$wpstream_ready_to_stream_class.'">';
332 print '<div class="wpstream_channel_status"><span class="dashicons dashicons-yes"></span>'.esc_html__('Ready To Stream !','wpstream').'</div>';
333 print '<div class="start_webcaster wpstream_button" data-webcaster-url="'.$webcaster_url.'" >'.esc_html__('Start Browser Broadcast','wpstream').'</div>';
334 print '<div class="start_external wpstream_button" >'.esc_html__('Broascast With 3rd Party Software','wpstream').'</div>';
335 print '</div>';
336
337
338
339 print '<div class="external_software_streaming '. $external_software_streaming_class.' ">';
340 print '<div class="event_list_unit_notificationx"><strong>'.__('URL:').' </strong> <div class="wpstream_live_uri_text">' . $uri_ip.'</div><div class="copy_live_uri">'.__('copy to clipboard','wpstream').'</div>';
341 print '<div class="event_list_stream_key_wrap"><strong>'.__('Stream key:').' </strong><div class="wpstream_live_key_text">'. $carnat_key1.'?auth='.$carnat_key2.'</div><div class="copy_live_key">'.__('copy to clipboard','wpstream').'</div></div>';
342 print '<div class="warning_stream">'.sprintf(esc_html__('For professional results use %s with above credentials. You may also use the "RTMP Camera" app on Android phones and tablets or the "Broadcast Me" app on iPhone and iPad.','wpstream'),'<a href="https://obsproject.com/download" target="_blank">OBS Studio software</a>').'</div>';
343 print ' <img class="how_to" src="'.plugin_dir_url( dirname( __FILE__ ) ).'img/how_to_obs.jpg" alt="show_imagge">';
344 print'</div>';
345 print'</div>';
346
347
348
349
350 print '<div class="wpstream_no_stream '.$wpstream_no_stream_class.' ">';
351 print '<div class="event_list_unit_notificationx"><span class="server_notification">'.__('Channel is inactive.','wpestream').' <img class="server_loading" src="'.plugins_url().'/wpstream/img/loading.gif" alt="loading" /></span></div>';
352 print '<div class="record_wrapper">Record ? <input type="checkbox" name="record_event" class="record_event"/>Yes</div>';
353 print '<input class="start_event wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Broadcast To Channel','wpstream').'">';
354 print '<input class="close_event wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Delete Channel','wpstream').'">';
355 print '<div class="multiple_warning_events"> '.esc_html__('* You can run multiple live events on a single channel. **Once deleted, you can no longer broadcast to it.','wpstream').'</div>';
356 print '</div>';
357
358
359 print '</div>';
360 }
361
362
363
364
365
366 function wpstream_convert_band($megabits){
367 $gigabit = $megabits * 0.001;
368 $gigabit = number_format($gigabit,2);
369 return $gigabit;
370 }
371
372
373
374
375 function wpstream_check_open_port($host){
376
377 $host= str_replace("rtmp://", "",$host);
378 $host= str_replace("/", "",$host);
379
380 $port='1935';
381 $connection = fsockopen($host, $port);
382 if (is_resource($connection)){
383 print '<div class="server_ready_live">'.__('Ready for Live Streaming','wpstream').'</div>';
384 fclose($connection);
385 }else{
386 print '<div class="server_not_ready_live">'.__('Not Ready Yet!','wpstream').'</div>';
387 }
388
389 }
390
391
392 function wpstream_media_management(){
393 $pack_details = wpstream_get_pack_details_user();
394
395 if( isset($pack_details['band']) && isset( $pack_details['storage']) ){
396 print '<div class="pack_details_wrapper"><strong>'.__('Your account information: ','wpstream').'</strong> '.__('You have','wpstream').'<strong> '.wpstream_convert_band($pack_details['band']).' Gb </strong> '.__('available streaming bandwidth and','wpstream').' <strong>'.wpstream_convert_band($pack_details['storage']).' Gb </strong> '.__('available media storage','wpstream').'.</div>';
397 print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">';
398 print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">';
399 }
400
401 print '<div id="wpstream_media_upload"><h3>'.__('Media Upload','wpstream').'</h3>'.wpstream_present_media_upload().'</div>';
402
403 print '<div id="wpstream_file_management"><h3 id="video_management_title">'.__('Video Management','wpstream').'</h3>'.wpstream_present_file_management().'</div>';
404
405 }
406
407
408
409 function wpstream_present_media_upload(){
410 $to_return='';
411 $formInputs=wpstream_get_signed_form_upload_data();
412
413 if($formInputs === 'notenough'){
414 $to_return.='<div class="wpstream_upload_alert">'.esc_html__('You do not have enough bandwidth or storage to upload a video!','wpstream').'</div>';
415 return $to_return;
416 }
417
418
419 $to_return.='<div class="wpstream_upload_container">';
420 $to_return.='<div id="wpstream_uploaded_mes">'.esc_html__('Please select or drop a video file. Do not close this window during the upload!','wpstream').'</div>';
421 $to_return.='<form action="https://wpstream-videos.s3.amazonaws.com/"
422 method="POST"
423 enctype="multipart/form-data"
424 class="direct-upload">';
425
426 $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>';
427 $to_return.='<label for="wpstream_upload"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"/></svg> <span id="wpstream_label_action">Choose a file&hellip;</span></label>';
428
429
430 $to_return.='<div class="wpstream_file_drop_color">';
431 $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>';
432 $to_return.='<div class="wpstream_form_ex_details">'.esc_html__('The Video File must be encoded with the following settings:
433
434 Container: MP4,
435 Video codec: H264,
436 Audio codec: AAC. Media will fail to play back if it does not follow the above settings.
437 You may use a tool like MediaInfo to verify your file. Also you may convert it with specialized software like HandBrake.','wpstream').'<strong>'.esc_html__('Accepted file extensions: .mp4, .mov .','wpstream').'</strong></div>';
438 if(is_array($formInputs)){
439 foreach ($formInputs as $name => $value) {
440 $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">';
441 }
442 }
443
444 $to_return.='
445 <div class="progress-bar-area"></div></div>
446 </form>';
447
448 $to_return.='</div>';
449 return $to_return;
450
451 }
452
453
454
455
456
457
458
459
460
461
462
463
464
465 function wpstream_present_file_management(){
466 $video_list_raw = wpstream_get_videos_from_storage_raw_data();
467
468
469
470
471
472 $to_return='';
473 if(is_array($video_list_raw)){
474 foreach ($video_list_raw as $key =>$video){
475 $to_return.='<div class="wpstream_video_wrapper">';
476
477 $to_return.='<div class="wpstream_video_title">';
478
479 $to_return.='<div class="wpstream_video_notice"></div></div>';
480
481 $to_return.='<div class="wpstream_video_title"><strong class="storage_file_name">'.esc_html__('File Name :','wpstream').'</strong>'.'<span class="storage_file_name_real">'.$video['video_name_storage'].'</span></div>';
482
483
484
485
486 $to_return.=' <div class="wpstream_delete_media" ';
487
488 $to_return.=' onclick="return confirm(\' Are you sure you wish to delete '.$video['video_name_storage'].'?\')" data-filename="'.$video['video_name_storage'].'">'.esc_html__('delete file','wpstream').'</div>';
489
490
491 $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video['video_name_storage'].'">'.esc_html__('get download link','wpstream').'</div>';
492
493 $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>';
494
495 $to_return.='</div>';
496
497 }
498 } else {
499 $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
500 }
501 return $to_return;
502 }