PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 2.06
WpStream – Live Streaming, Video on Demand, Pay Per View v2.06
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.06, at libs/plugin-admin.php

531 lines 23.8 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 delete_transient( 'wpstream_token_request');
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 or Email',
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>'.__('WpStream Credentials','wpstream').'</h1>';
72
73 if( wpstream_client_check_api_status() ){
74 echo '<div class="api_conected">'.__('Conected to WpStream.net!','wpstream').'</div>';
75 }else{
76 echo '<div class="api_not_conected">'.__('No Connection to WpStream.net Use your WpStream credentials to connect below or go ','wpstream').'<a href="https://wpstream.net/my-account" target="_blank">here</a>'.__(' to create an account.','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
94
95 print '</div>';
96 print '</form>';
97
98 print '<div class="theme_options_tab_wpstream" style="display:block;" >';
99 $link_new = admin_url('admin.php?page=wpstream_new_general_set');
100 $link_new_paid = admin_url('post-new.php?post_type=product');
101 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
102
103
104 print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create new free channel','wpstream').'</a>';
105 print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Create pay-per-view channel','wpstream').'</a>';
106 print '<a href="'.esc_url($link_new).'" class="wpstream_no_chanel_add_channel">'.esc_html('My Channels','wpstream').'</a>';
107 print '</div>';
108
109
110 }
111 function wpstream_new_general_set() {
112
113
114
115 $no_channel=1;
116
117 if(class_exists ('WC_Subscription')){
118
119 }
120
121 //event_passed
122 $args = array(
123 'posts_per_page' => -1,
124 'post_type' => 'product',
125 'post_status' => 'publish',
126 'meta_query' => array(
127 array(
128 'key' => 'event_passed',
129 'value' => 1,
130 'compare' => '!=',
131 )
132 ),
133
134 'tax_query' => array(
135 'relation' => 'AND',
136 array(
137 'taxonomy' => 'product_type',
138 'field' => 'slug',
139 'terms' => array('live_stream','subscription')
140 )
141 ),
142 );
143
144
145
146 $event_list = new WP_Query($args);
147 global $live_event_for_user;
148
149 $live_event_for_user = wpstream_get_live_event_for_user();
150
151
152
153 $pack_details = wpstream_get_pack_details_user();
154
155 if( isset($pack_details['band']) && isset( $pack_details['storage']) ){
156 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>';
157 print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">';
158 print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">';
159
160 }
161
162
163
164
165 if( $event_list->have_posts()){
166 print '<div class="pack_details_wrapper_transparent">
167 <h3>'.__('Your Pay-Per-View Channel List','wpstream').'</h3>';
168
169 $link_new = admin_url('post-new.php?post_type=product');
170 print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new pay-per-view channel.','wpstream').'</a>';
171 print '</div>';
172
173 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
174
175 while ($event_list->have_posts()): $event_list->the_post();
176
177 $the_id = get_the_ID();
178 $is_subscription_live_event = esc_html(get_post_meta($the_id,'_subscript_live_event',true));
179 $term_list = wp_get_post_terms($the_id, 'product_type');
180
181 if( $term_list[0]->name=='subscription' && $is_subscription_live_event=='no'){
182 continue;
183 }
184
185 wpstream_live_stream_unit($the_id);
186
187 endwhile;
188
189 print'</div>';
190 $no_channel=1;
191 }else{
192 $no_channel=0;
193 }
194
195
196 $ajax_nonce = wp_create_nonce( "wpstream_start_event_nonce" );
197 print '<input type="hidden" id="wpstream_start_event_nonce" value="'.$ajax_nonce.'">';
198 $current_user = wp_get_current_user();
199 $allowded_html = array();
200 $userID = $current_user->ID;
201 $user_live_streams = get_user_meta($userID,'live_shows');
202
203
204 wp_reset_postdata();
205
206
207
208
209
210
211
212
213 // free
214
215 $args_free = array(
216 'posts_per_page' => -1,
217 'post_type' => 'wpstream_product',
218 'post_status' => 'publish',
219 'meta_query' => array(
220 'relation' => 'AND',
221 array(
222 'key' => 'wpstream_product_type',
223 'value' => 1,
224 'compare' => '==',
225 ),
226
227 ),
228
229
230 );
231 $event_list_free = new WP_Query($args_free);
232
233
234 if( $event_list_free->have_posts()){
235 print '<div class="pack_details_wrapper_transparent">
236 <h3>'.__('Your Free Channel List','wpestate').'</h3>';
237
238 $link_new = admin_url('post-new.php?post_type=wpstream_product');
239 print '<a href="'.esc_url($link_new).'" class="wpstream_create_new_product_link">'.esc_html__('Create new free channel.','wpstream').'</a>';
240 print '</div>';
241 print '<div style="clear: both;"></div><div class="event_list_wrapper">';
242
243 while ($event_list_free->have_posts()): $event_list_free->the_post();
244
245
246 $the_id = get_the_ID();
247
248 if( get_post_meta ($the_id,'event_passed',true)!=1){
249 wpstream_live_stream_unit($the_id);
250 }
251
252 endwhile;
253
254 print'</div>';
255 $no_channel=1;
256 }else{
257 $no_channel=0;
258 }
259
260
261
262 if($no_channel==0){
263 $link_new_paid = admin_url('post-new.php?post_type=product');
264 $link_new_free = admin_url('post-new.php?post_type=wpstream_product');
265 print '<div class="no_events_warning"> '.__('* You don\'t have any live channels!','wpstream');
266
267 print '<a href="'.esc_url($link_new_free).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new free channel ','wpstream').'</a>';
268 print '<a href="'.esc_url($link_new_paid).'" class="wpstream_no_chanel_add_channel">'.esc_html__('Add new pay-per-view channel ','wpstream').'</a>';
269
270 print '</div>';
271 }
272
273
274
275
276 }
277 // end wpstream_new_general_set
278
279
280
281
282
283
284
285 function wpstream_live_stream_unit($the_id){
286 global $live_event_for_user;
287
288 $live_class='';
289 if(isset($live_event_for_user[$the_id])) {
290 $live_class=" wpstream_show_started";
291 }
292
293
294 print '<div class="event_list_unit '.$live_class.' ">';
295 $ip= get_post_meta($the_id,'ip',true);
296
297
298 if(has_post_thumbnail($the_id)){
299 $thumb = get_the_post_thumbnail_url($the_id,'thumbnail');
300 }else{
301 $thumb= plugin_dir_url( dirname( __FILE__ ) ). 'img/default_150.jpg';
302 }
303
304
305 print '<div class="event_thumb_wrapper"><img class="event_thumb" src="'.$thumb.'" alt="show_imagge"></div>';
306 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> ';
307
308 $live_event_stream_name = get_post_meta($the_id,'live_event_stream_name',true);
309 $live_event_array = get_post_meta($the_id,'live_event_uri',true);
310 $live_event_uri = '';
311
312
313 $pending_streaming_class = '';
314 $wpstream_ready_to_stream_class = '';
315 $external_software_streaming_class = '';
316 $wpstream_no_stream_class = '';
317 $carnat_key1 = '';
318 $carnat_key2 = '';
319 $uri = '';
320 $webcaster_url = '';
321 $rtmp_ip_uri = '';
322 $uri_ip = '';
323
324 if(is_array($live_event_for_user) && isset($live_event_for_user[$the_id])) {
325
326 $pending_streaming_class = 'show_stream_data pending_trigger';
327 $wpstream_ready_to_stream_class = 'hide_stream_data';
328 $external_software_streaming_class = 'show_stream_data';
329 $wpstream_no_stream_class = 'hide_stream_data';
330 if(isset($live_event_for_user[$the_id]['live_uri'])){
331 $explode = explode('wpstream.net/', $live_event_for_user[$the_id]['live_uri']);
332 $uri = $explode[0].'wpstream.net/wpstream/';
333 $stream_name = get_post_meta($the_id,'live_event_stream_name',true);
334 $carnat_key1 = $live_event_for_user[$the_id]['carnat1'];
335 $carnat_key2 = $live_event_for_user[$the_id]['carnat2'];
336 $webcaster_url = 'https://'.$live_event_for_user[$the_id]['subdomain_key'].'.live.streamer.wpstream.net:8443/'.$live_event_for_user[$the_id]['carnat2'];
337
338 $rtmp_ip_uri = 'http://'.$live_event_for_user[$the_id]['ip'].':8444';
339 $uri_ip= 'rtmp://'.$live_event_for_user[$the_id]['ip'].'/wpstream/';
340 }
341
342 }else{
343
344 $pending_streaming_class = 'hide_stream_data';
345 $wpstream_ready_to_stream_class = 'hide_stream_data';
346 $external_software_streaming_class = 'hide_stream_data';
347 $wpstream_no_stream_class = 'show_stream_data';
348 }
349
350
351
352
353 print' <div class="pending_streaming '.$pending_streaming_class.' " data-server-id="'.$the_id.'" data-server-url="'.$rtmp_ip_uri.'">';
354 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').' ';
355 print '<img class="server_loading_new" src="'.plugin_dir_url( dirname( __FILE__ ) ).'img/loading.gif" alt="loading" /></div>';
356 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>';
357 print '</div>';
358
359
360 print '<div class="wpstream_ready_to_stream '.$wpstream_ready_to_stream_class.'">';
361 print '<div class="wpstream_channel_status"><span class="dashicons dashicons-yes"></span>'.esc_html__('Ready To Stream !','wpstream').'</div>';
362 print '<div class="start_webcaster wpstream_button" data-webcaster-url="'.$webcaster_url.'" >'.esc_html__('Start Browser Broadcast','wpstream').'</div>';
363 print '<div class="start_external wpstream_button" >'.esc_html__('Broascast With 3rd Party Software','wpstream').'</div>';
364 print '</div>';
365
366
367
368 print '<div class="external_software_streaming '. $external_software_streaming_class.' ">';
369 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>';
370 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>';
371 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>';
372 print ' <img class="how_to" src="'.plugin_dir_url( dirname( __FILE__ ) ).'img/how_to_obs.jpg" alt="show_imagge">';
373 print'</div>';
374 print'</div>';
375
376
377
378
379 print '<div class="wpstream_no_stream '.$wpstream_no_stream_class.' ">';
380 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>';
381 print '<div class="record_wrapper">Record ? <input type="checkbox" name="record_event" class="record_event"/>Yes</div>';
382 print '<input class="start_event wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Broadcast To Channel','wpstream').'">';
383 print '<input class="close_event wpstream_button" type="button" data-show-id="'.$the_id.'" value="'.esc_html__('Delete Channel','wpstream').'">';
384 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>';
385 print '</div>';
386
387
388 print '</div>';
389 }
390
391
392
393
394
395 function wpstream_convert_band($megabits){
396 $gigabit = $megabits * 0.001;
397 $gigabit = number_format($gigabit,2);
398 return $gigabit;
399 }
400
401
402
403
404 function wpstream_check_open_port($host){
405
406 $host= str_replace("rtmp://", "",$host);
407 $host= str_replace("/", "",$host);
408
409 $port='1935';
410 $connection = fsockopen($host, $port);
411 if (is_resource($connection)){
412 print '<div class="server_ready_live">'.__('Ready for Live Streaming','wpstream').'</div>';
413 fclose($connection);
414 }else{
415 print '<div class="server_not_ready_live">'.__('Not Ready Yet!','wpstream').'</div>';
416 }
417
418 }
419
420
421 function wpstream_media_management(){
422 $pack_details = wpstream_get_pack_details_user();
423
424 if( isset($pack_details['band']) && isset( $pack_details['storage']) ){
425 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>';
426 print'<input type="hidden" id="wpstream_band" value="'.$pack_details['band'].'">';
427 print'<input type="hidden" id="wpstream_storage" value="'.$pack_details['storage'].'">';
428 }
429
430 print '<div id="wpstream_media_upload"><h3>'.__('Media Upload','wpstream').'</h3>'.wpstream_present_media_upload().'</div>';
431
432 print '<div id="wpstream_file_management"><h3 id="video_management_title">'.__('Video Management','wpstream').'</h3>'.wpstream_present_file_management().'</div>';
433
434 }
435
436
437
438 function wpstream_present_media_upload(){
439 $to_return='';
440 $formInputs=wpstream_get_signed_form_upload_data();
441
442 if($formInputs === 'notenough'){
443 $to_return.='<div class="wpstream_upload_alert">'.esc_html__('You do not have enough bandwidth or storage to upload a video!','wpstream').'</div>';
444 return $to_return;
445 }
446
447
448 $to_return.='<div class="wpstream_upload_container">';
449 $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>';
450 $to_return.='<form action="https://wpstream-videos.s3.amazonaws.com/"
451 method="POST"
452 enctype="multipart/form-data"
453 class="direct-upload">';
454
455 $to_return.='<input id="wpstream_upload" type="file" class="inputfile inputfile-1" value="Pick a video file" name="file" multiple>';
456 $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>';
457
458
459 $to_return.='<div class="wpstream_file_drop_color">';
460 $to_return.='<div class="wpstream_form_ex">'.esc_html__('Drop a video file here!','wpstream').'</div>';
461 $to_return.='<div class="wpstream_form_ex_details">'.esc_html__('The Video File must be encoded with the following settings:
462
463 Container: MP4,
464 Video codec: H264,
465 Audio codec: AAC. Media will fail to play back if it does not follow the above settings.
466 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>';
467 if(is_array($formInputs)){
468 foreach ($formInputs as $name => $value) {
469 $to_return.='<input type="hidden" name="'. $name.'" value="'.$value.'">';
470 }
471 }
472
473 $to_return.='
474 <div class="progress-bar-area"></div></div>
475 </form>';
476
477 $to_return.='</div>';
478 return $to_return;
479
480 }
481
482
483
484
485
486
487
488
489
490
491
492
493
494 function wpstream_present_file_management(){
495 $video_list_raw = wpstream_get_videos_from_storage_raw_data();
496
497
498
499
500
501 $to_return='';
502 if(is_array($video_list_raw)){
503 foreach ($video_list_raw as $key =>$video){
504 $to_return.='<div class="wpstream_video_wrapper">';
505
506 $to_return.='<div class="wpstream_video_title">';
507
508 $to_return.='<div class="wpstream_video_notice"></div></div>';
509
510 $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>';
511
512
513
514
515 $to_return.=' <div class="wpstream_delete_media" ';
516
517 $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>';
518
519
520 $to_return.='<div class="wpstream_get_download_link" data-filename="'.$video['video_name_storage'].'">'.esc_html__('get download link','wpstream').'</div>';
521
522 $to_return.='<a href="" class="wpstream_download_link">'.esc_html__('Click to download! The url will work for the next 20 minutes!','wpstream').'</a>';
523
524 $to_return.='</div>';
525
526 }
527 } else {
528 $to_return.= '<div class="wpstream_video_wrapper">'.esc_html__('You don\'t have any videos.','wpstream').'</div>';
529 }
530 return $to_return;
531 }