PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.1.8
WpStream – Live Streaming, Video on Demand, Pay Per View v3.1.8
4.14.1 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 All 181 releases
wpstream / public / class-wpstream-public.php

class-wpstream-public.php in WpStream – Live Streaming, Video on Demand, Pay Per View 3.1.8, at public/class-wpstream-public.php

1,000 lines 33.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The public-facing functionality of the plugin.
5 *
6 * @link http://wpstream.net
7 * @since 3.0.1
8 *
9 * @package Wpstream
10 * @subpackage Wpstream/public
11 */
12
13 /**
14 * The public-facing functionality of the plugin.
15 *
16 * Defines the plugin name, version, and two examples hooks for how to
17 * enqueue the public-facing stylesheet and JavaScript.
18 *
19 * @package Wpstream
20 * @subpackage Wpstream/public
21 * @author wpstream <[email protected]>
22 */
23 class Wpstream_Public {
24
25
26
27 /**
28 * Store plugin main class to allow public access.
29 *
30 * @since 20180622
31 * @var object The main class.
32 */
33 public $main;
34 /**
35 * The ID of this plugin.
36 *
37 * @since 3.0.1
38 * @access private
39 * @var string $plugin_name The ID of this plugin.
40 */
41 private $plugin_name;
42
43 /**
44 * The version of this plugin.
45 *
46 * @since 3.0.1
47 * @access private
48 * @var string $version The current version of this plugin.
49 */
50 private $version;
51
52 /**
53 * Initialize the class and set its properties.
54 *
55 * @since 3.0.1
56 * @param string $plugin_name The name of the plugin.
57 * @param string $version The version of this plugin.
58 */
59 public function __construct( $plugin_name, $version ,$plugin_main) {
60 $this->main = $plugin_main;
61 $this->plugin_name = $plugin_name;
62 $this->version = $version;
63
64 }
65
66 /**
67 * Register the stylesheets for the public-facing side of the site.
68 *
69 * @since 3.0.1
70 */
71 public function enqueue_styles() {
72
73 /**
74 * This function is provided for demonstration purposes only.
75 *
76 * An instance of this class should be passed to the run() function
77 * defined in Wpstream_Loader as all of the hooks are defined
78 * in that particular class.
79 *
80 * The Wpstream_Loader will then create the relationship
81 * between the defined hooks and the functions defined in this
82 * class.
83 */
84
85 wp_enqueue_style('wpstream-style', plugin_dir_url( __FILE__ ) .'/css/wpstream_style.css' );
86 wp_enqueue_style('video-js.min', plugin_dir_url( __FILE__ ).'/css/video-js.min.css', array(), '1.0', 'all');
87
88 }
89
90 /**
91 * Register the JavaScript for the public-facing side of the site.
92 *
93 * @since 3.0.1
94 */
95 public function enqueue_scripts() {
96
97 /**
98 * This function is provided for demonstration purposes only.
99 *
100 * An instance of this class should be passed to the run() function
101 * defined in Wpstream_Loader as all of the hooks are defined
102 * in that particular class.
103 *
104 * The Wpstream_Loader will then create the relationship
105 * between the defined hooks and the functions defined in this
106 * class.
107 */
108
109
110
111 wp_enqueue_script('video.min', plugin_dir_url( __FILE__ ).'js/video.min.js',array('jquery'), '1.0', false);
112 wp_enqueue_script('youtube.min', plugin_dir_url( __FILE__ ).'js/youtube.min.js',array('video.min'), '1.0', false);
113 wp_enqueue_script('videojs-vimeo.min', plugin_dir_url( __FILE__ ).'js/videojs-vimeo.min.js',array('video.min'), '1.0', false);
114 wp_enqueue_script('wpstream-player', plugin_dir_url( __FILE__ ).'js/wpstream-player.js',array('video.min'), '1.0', false);
115
116
117 }
118
119
120
121 /**
122 * add custom end points for woocomerce
123 *
124 * @since 3.0.1
125 * @return nothing
126 */
127 public function wpstream_my_custom_endpoints() {
128 add_rewrite_endpoint( 'video-list', EP_ROOT | EP_PAGES );
129 add_rewrite_endpoint( 'event-list', EP_ROOT | EP_PAGES );
130 }
131
132 /**
133 * add custom query vars
134 *
135 * @since 3.0.1
136 * @return nothing
137 */
138 public function wpstream_my_custom_query_vars( $vars ) {
139 $vars[] = 'video-list';
140 $vars[] = 'event-list';
141 return $vars;
142 }
143
144
145 /**
146 * Hust flush rewrite rules
147 *
148 * @since 3.0.1
149 *
150 */
151 public function wpstream_custom_flush_rewrite_rules() {
152 flush_rewrite_rules();
153 }
154
155
156 /**
157 * Add new sections in woocomerce account
158 *
159 * @since 3.0.1
160 */
161 public function wpstream_custom_my_account_menu_items( $items ) {
162 if(function_exists('wpstream_is_global_subscription') && wpstream_is_global_subscription()){
163 $items = array(
164 'dashboard' => __( 'Dashboard', 'woocommerce' ),
165 'orders' => __( 'Orders', 'woocommerce' ),
166 'edit-address' => __( 'Addresses', 'woocommerce' ),
167 'edit-account' => __( 'Edit Account', 'woocommerce' ),
168 'customer-logout' => __( 'Logout', 'woocommerce' ),
169 );
170 }else{
171 $items = array(
172 'dashboard' => __( 'Dashboard', 'woocommerce' ),
173 'orders' => __( 'Orders', 'woocommerce' ),
174 'edit-address' => __( 'Addresses', 'woocommerce' ),
175 'edit-account' => __( 'Edit Account', 'woocommerce' ),
176 'event-list' => __( 'Events', 'wpstream' ),
177 'video-list' => __( 'Videos', 'wpstream' ),
178 'customer-logout' => __( 'Logout', 'woocommerce' ),
179 );
180 }
181 return $items;
182 }
183
184
185
186 /**
187 * Add new endpoint
188 *
189 * @since 3.0.1
190 */
191 public function wpstream_custom_endpoint_content_event_list() {
192 include plugin_dir_path( __DIR__ ).'woocommerce/myaccount/event_list.php';
193 }
194
195
196 /**
197 * Add new endpoint
198 *
199 * @since 3.0.1
200 */
201 public function wpstream_custom_endpoint_video_list() {
202 include plugin_dir_path( __DIR__ ).'woocommerce/myaccount/video_list.php';
203 }
204
205
206
207
208
209
210 /**
211 * register shortcodes
212 *
213 * @since 3.0.1
214 *
215 */
216 public function wpstream_shortcodes(){
217 add_shortcode('wpstream_player', array($this,'wpstream_insert_player_inpage_local') );
218 add_shortcode('wpstream_list_products', array($this,'wpstream_list_products_function') );
219
220
221 // register shortcodes for visual composer
222 if( function_exists('vc_map') ):
223 vc_map(
224 array(
225 "name" => esc_html__( "WpStream Player","wpestate"),
226 "base" => "wpstream_player",
227 "class" => "",
228 "category" => esc_html__( 'WpStream','wpestate'),
229 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
230 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
231 'weight'=>100,
232 'icon' =>'',
233 'description'=>esc_html__( 'Insert WpStream Player','wpestate'),
234 "params" => array(
235 array(
236 "type" => "textfield",
237 "holder" => "div",
238 "class" => "",
239 "heading" => esc_html__( "Product/Free Product Id","wpestate"),
240 "param_name" => "id",
241 "value" => "0",
242 "description" => esc_html__( "Add here the live stream id or the video id","wpestate")
243 ),
244
245 )
246 )
247 );
248
249
250
251 $product_type=array(
252 '1' => __('Free Live Channel','wpstream'),
253 '2' => __('Free Video','wpstream')
254 );
255
256 vc_map(
257 array(
258 "name" => esc_html__( "WpStream Products List","wpestate"),
259 "base" => "wpstream_list_products",
260 "class" => "",
261 "category" => esc_html__( 'WpStream','wpestate'),
262 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
263 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
264 'weight'=>100,
265 'icon' =>'',
266 'description'=>esc_html__( ' List wpstream products','wpestate'),
267 "params" => array(
268 array(
269 "type" => "textfield",
270 "holder" => "div",
271 "class" => "",
272 "heading" => esc_html__( "Media number","wpestate"),
273 "param_name" => "media_number",
274 "value" => "",
275 "description" => esc_html__( "No of media ","wpestate")
276 ),
277
278 array(
279 "type" => "dropdown",
280 "holder" => "div",
281 "class" => "",
282 "heading" => esc_html__( "Product type","wpestate"),
283 "param_name" => "product_type",
284 "value" => $product_type,
285 "description" => esc_html__( "What type of products ","wpestate")
286 ),
287
288 )
289 )
290 );
291 endif;
292
293
294 // add shorcotes to editor interface
295 if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
296 return;
297 }
298
299 if (get_user_option('rich_editing') == 'true') {
300 add_filter('mce_external_plugins', array( $this,'wpstream_add_plugin') );
301 add_filter('mce_buttons_2', array($this,'wpstream_register_button') );
302 }
303 }
304
305
306
307 /**
308 * register shortcodes - add buttons in js
309 *
310 * @since 3.0.1
311 *
312 */
313
314
315 public function wpstream_insert_player_inpage_local($attributes, $content = null){
316 $product_id = '';
317 $return_string = '';
318 $attributes = shortcode_atts(
319 array(
320 'id' => 0,
321 ), $attributes) ;
322
323
324 if ( isset($attributes['id']) ){
325 $product_id=$attributes['id'];
326 }
327
328 ob_start();
329 $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
330 $return_string= ob_get_contents();
331 ob_end_clean();
332
333 return $return_string;
334 }
335
336
337
338
339 /**
340 * list products - shortcode function
341 *
342 * @since 3.0.1
343 *
344 */
345
346 public function wpstream_list_products_function($atts, $content=null){
347
348 $media_number = "";
349 $product_type = "";
350 $attributes = shortcode_atts(
351 array(
352 'media_number' => '4',
353 'product_type' => __('Free Live Channel','wpstream'),
354
355 ), $atts);
356
357 if ( isset($attributes['media_number']) ){
358 $media_number=$attributes['media_number'];
359 }
360
361 if ( isset($attributes['product_type']) ){
362 $product_type=$attributes['product_type'];
363 }
364
365 if($product_type== __('Free Live Channel','wpstream') ){
366 $product_type=1;
367 }else{
368 $product_type=2;
369 }
370
371 $return_string="";
372
373
374
375 $args = array(
376 'post_type' => 'wpstream_product',
377 'post_status' => 'publish',
378 'meta_query' =>array(
379 array(
380 'key' => 'wpstream_product_type',
381 'value' => $product_type,
382 'compare' => '=',
383 ),
384 ),
385 'posts_per_page' =>$media_number,
386 'page' => 1
387 );
388
389
390 $media_list= new WP_Query($args);
391
392 if($product_type==1){
393 $see_product= __('See Free Live Chanel','wpstream');
394 }else{
395 $see_product =_('See Free Video','wpstream');
396 }
397
398
399
400 while($media_list->have_posts()):$media_list->the_post();
401 $return_string.='<div class="wpstream_product_unit">'
402 .'<div class="product_image" style="background-image:url('.wp_get_attachment_thumb_url(get_post_thumbnail_id()).')"></div>'
403 .'<a href="'.get_permalink().'" class="product_title" >'.get_the_title().'</a>'
404 .'<a href="'.get_permalink().'"class="see_product">'.$see_product.'</a>'
405 .'</div>';
406 endwhile;
407
408 wp_reset_postdata();
409 wp_reset_query();
410
411
412 return '<div class="shortcode_list_wrapper">'.$return_string.'</div>';
413
414 }
415
416
417
418 /**
419 * register shortcodes - add buttons in js
420 *
421 * @since 3.0.1
422 *
423 */
424
425 public function wpstream_add_plugin($plugin_array) {
426 $plugin_array['wpstream_player'] = plugin_dir_url( __FILE__ ). '/js/shortcodes.js';
427 $plugin_array['wpstream_list_products'] = plugin_dir_url( __FILE__ ). '/js/shortcodes.js';
428 return $plugin_array;
429 }
430
431 /**
432 * register shortcodes - add buttons
433 *
434 * @since 3.0.1
435 *
436 */
437 public function wpstream_register_button($buttons) {
438 array_push($buttons, "|", "wpstream_player");
439 array_push($buttons, "|", "wpstream_list_products");
440 return $buttons;
441 }
442
443 /**
444 * add rewrite tags
445 *
446 * @since 3.0.1
447 *
448 */
449 // public function wpstream_custom_rewrite_tag() {
450 // add_rewrite_tag('%streamname%', '([^&]+)');
451 // add_rewrite_tag('%streamname2%', '([^&]+)');
452 // add_rewrite_tag('%variety%', '([^&]+)');
453 // add_rewrite_tag('%userkey%', '([^&]+)');
454 // add_rewrite_tag('%streamvod%', '([^&]+)');
455 // }
456 //
457 //
458 // /**
459 // * add rewrite rules
460 // *
461 // * @since 3.0.1
462 // *
463 // */
464 // public function wpstream_custom_rewrite_rule() {
465 // $page = get_page_by_title( 'WpStream' );
466 // $page_user_key = get_page_by_title( 'Userkey' );
467 // $page_vod_key = get_page_by_title( 'Vodkey' );
468 //
469 //
470 //
471 //
472 // if( isset($page_vod_key->ID) ){ // is wod-key=page-template
473 // add_rewrite_rule('^keys1/([^/]*)/([^/]*)/?','index.php?page_id='.$page_vod_key->ID.'&streamname=$matches[1]&streamname2=$matches[2]','top');
474 // }
475 //
476 //
477 //
478 // flush_rewrite_rules();
479 // }
480 //
481
482
483 //
484 // /**
485 // * user key page temaplte
486 // *
487 // * @since 3.0.1
488 // *
489 // */
490 //
491 // public function wpstream_userkey_page_template( $page_template ){
492 // if ( is_page( 'Userkey' ) ) {
493 // $page_template = dirname( __FILE__ ) . '/user-key-page-template.php';
494 // }
495 // return $page_template;
496 // }
497 //
498 // /**
499 // * wpstream wod key page temaplate
500 // *
501 // * @since 3.0.1
502 // *
503 // */
504 // public function wpstream_vodkey_page_template( $page_template ){
505 // if ( is_page( 'vodkey' ) ) {
506 // $page_template = dirname( __FILE__ ) . '/vod-key-page-template.php';
507 // }
508 // return $page_template;
509 // }
510 //
511
512 /**
513 * wpstream cors
514 *
515 * @since 3.0.1
516 *
517 */
518
519 public function wpstream_cors_check_and_response(){
520 if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
521 header('Access-Control-Allow-Methods: POST, GET');
522 header('Access-Control-Allow-Headers: Authorization');
523 header('Access-Control-Max-Age: 1'); //1728000
524 header("Content-Length: 0");
525 header("Content-Type: text/plain charset=UTF-8");
526 exit(0);
527 }
528 }
529
530 /**
531 * set user cookie
532 *
533 * @since 3.0.1
534 *
535 */
536
537 public function wpstream_set_cookies(){
538 if( !isset( $_REQUEST[ 'keys' ]) && !isset( $_REQUEST[ 'keys2' ]) ) {
539 $cookie=uniqid ();
540 setcookie("WpstreamNonLogCookie3", $cookie);
541 }
542 }
543
544 /**
545 * get key for live stream
546 *
547 * @since 3.0.1
548 *
549 */
550
551
552 public function wpstream_live_streaming_key(){
553
554 if( isset( $_REQUEST[ 'keys' ]) && $_REQUEST[ 'keys' ]!='' ) {
555
556 $streamname = esc_html($_REQUEST[ 'keys' ]);
557 $current_user = wp_get_current_user();
558 $stream_key = esc_html($streamname);
559 $stream_key_array = explode('-', $stream_key);
560 $real_stream_key = $stream_key_array[0];
561 $server_ip = '';
562
563 if ($server_ip=='' || false === ( $server_ip = get_transient( $server_ip.'_serverip' ) ) ) {
564 $server_ip = $this->main->wpstream_live_connection->wpstream_get_live_stream_server($current_user,$streamname);
565 set_transient( $server_ip.'_serverip', $server_ip, 600 );
566 }
567
568 $args_free = array(
569 'posts_per_page' => -1,
570 'post_type' => 'wpstream_product',
571 'post_status' => 'publish',
572 'meta_query' => array(
573 array(
574 'key' => 'live_event_stream_name',
575 'value' => $real_stream_key,
576 'compare' => '=',
577 )
578 ),
579
580
581 );
582 $event_list_free = new WP_Query($args_free);
583
584
585 if ($event_list_free->have_posts() ){
586 $event_list_free->the_post();
587 $the_id = get_the_ID();
588 $event_data = get_post_meta($the_id,'live_event_uri',true);
589 $ip = get_post_meta($the_id,'ip',true);
590
591 $show_id = $the_id;
592
593
594 //if( isset( $_COOKIE['WpstreamNonLogCookie3'] ) ){
595
596 if ( false === ( $get_key = get_transient( $show_id.'_carnatus1x' ) ) ) {
597 $get_key = $this->wpstream_get_encryption_key_remonting($stream_key,$server_ip);
598 set_transient( $show_id.'_carnatus1x', $get_key, 30 );
599 }
600 print $get_key;
601 die();
602
603 // }
604 //
605 // die('cookie not present');
606
607 }else{
608 // this is for paid products
609 if ( is_user_logged_in() && intval($current_user->ID)!=0 ) {
610
611 $args = array(
612 'posts_per_page' => -1,
613 'post_type' => 'product',
614 'post_status' => 'publish',
615 'meta_query' => array(
616 array(
617 'key' => 'live_event_stream_name',
618 'value' => $real_stream_key,
619 'compare' => '=',
620 ),
621 ),
622 'tax_query' => array(
623 'relation' => 'AND',
624 array(
625 'taxonomy' => 'product_type',
626 'field' => 'slug',
627 'terms' => array('live_stream','subscription')
628 )
629 ),
630 );
631
632
633 $event_list = new WP_Query($args);
634
635 if ($event_list->have_posts() ){
636 while ( $event_list->have_posts() ):
637 $event_list->the_post();
638 $the_id = get_the_ID();
639 $event_data = get_post_meta($the_id,'live_event_uri',true);
640 $ip = get_post_meta($the_id,'ip',true);
641 $show_id = $the_id;
642
643 endwhile;
644
645 $is_valid_subscription=0;
646 if(class_exists ('WC_Subscription')){
647 $is_valid_subscription = wcs_user_has_subscription( $current_user->ID, $show_id ,'active');
648 }
649
650
651 if(function_exists('wpstream_check_global_subscription_model')){
652 if( wpstream_check_global_subscription_model() ){
653 $is_valid_subscription=1;// this is global subscription
654 }
655 }
656
657
658 if( wc_customer_bought_product( $current_user->email, $current_user->ID, $show_id) || $is_valid_subscription==1 ){
659
660
661 $get_key = $this->wpstream_get_encryption_key_remonting($stream_key,$server_ip);
662
663
664 print $get_key;
665 die();
666
667 }else{
668 exit('live - no ticket ');
669 }
670
671 } else{
672 exit('live -no event');
673 }
674
675 }else{
676 exit('live- user not log or awserr');
677 }
678
679 }
680 exit('no free or paid event');
681
682
683
684 }else{
685 return;
686 }
687
688 }
689
690
691
692
693 /**
694 * get remote key for live
695 *
696 * @since 3.0.1
697 *
698 */
699
700 public function wpstream_get_encryption_key_remonting ($stream_key,$server_ip){
701
702 if ( false === ( $get_key = get_transient( $server_ip.'_carnatus1x' ) ) ) {
703 $url= 'http://'.$server_ip.':80/keys/'.$stream_key;
704 $get= wp_remote_get( $url );
705
706 if(is_array($get)){
707 $get_key = $get['body'];
708 }else{
709 $get_key='';
710 }
711
712 set_transient( $server_ip.'_carnatus1x', $get_key, 30 );
713 }
714 return $get_key;
715 }
716
717
718
719 /**
720 * get key for 3rdparty
721 *
722 * @since 3.0.1
723 *
724 */
725
726
727 public function wpstream_live_streaming_key_for_3rdparty(){
728
729 if( isset( $_REQUEST[ 'thirdkeys' ]) && $_REQUEST[ 'thirdkeys' ]!='' ) {
730
731 $thirdkeys = esc_html($_REQUEST[ 'thirdkeys' ]);
732
733 //live_event_carnat2
734
735 $args = array(
736 'post_type' => array('product','wpstream_product'),
737 'post_status' => 'publish',
738 'meta_query' =>array(
739 array(
740 'key' => 'live_event_carnat2',
741 'value' => $thirdkeys,
742 'compare' => '=',
743 ),
744 ),
745
746
747 );
748
749
750 $media_list= new WP_Query($args);
751 if($media_list->have_posts()){
752 while($media_list->have_posts()):$media_list->the_post();
753
754 $media_id = get_the_ID();
755 $replay_array = array(
756 // '', // fb will be here
757 stripslashes( get_post_meta($media_id,'wpstream_youtube_rtmp',true )),
758 stripslashes( get_post_meta($media_id,'wpstream_twich_rtmp',true) ),
759 );
760
761 $reply_final=array('rtmp_urls'=>$replay_array);
762 header('Content-Type: application/json;charset=utf-8');
763 print json_encode($reply_final,JSON_UNESCAPED_SLASHES);
764 die();
765
766
767 endwhile;
768 }else{
769 print'{}';
770 die('');
771 }
772
773 }
774
775 }
776
777
778
779 /**
780 * get key for vod
781 *
782 * @since 3.0.1
783 *
784 */
785
786
787 public function wpstream_live_streaming_key_vod(){
788
789 if( isset( $_REQUEST[ 'keys2' ]) && $_REQUEST[ 'keys2' ]!='' ) {
790 global $wp_query;
791 $current_user = wp_get_current_user();
792
793
794 $keys2 = esc_html($_REQUEST[ 'keys2' ]);
795
796
797 $keys2= ltrim($keys2,"/");
798 $keys2= rtrim($keys2,"/");
799 $keys2_array=explode('/',$keys2);
800
801
802 $folder=$keys2_array[0];
803 $movie=$keys2_array[1];
804
805 // $folder = sanitize_text_field( $wp_query->query_vars['streamname'] );
806 // $movie = sanitize_text_field ( $wp_query->query_vars['streamname2'] );
807
808 $free_args = array(
809 'posts_per_page' => -1,
810 'post_type' => 'wpstream_product',
811 'meta_query' => array(
812 array(
813 'key' => 'wpstream_free_video',
814 'value' => $movie,
815 'compare' => '=',
816 ),
817 )
818 );
819
820
821 $free_video_list = new WP_Query($free_args);
822
823 if ($free_video_list->have_posts() ){
824 //if( isset( $_COOKIE['WpstreamNonLogCookie3'] ) ){
825 $get_key = $this->wpstream_get_vod_key($folder.'/'.$movie);
826 echo ($get_key);
827
828 //}
829 die();
830 }else{
831 if ( is_user_logged_in() && intval($current_user->ID)!=0 ) {
832
833 $args = array(
834 'posts_per_page' => -1,
835 'post_type' => 'product',
836 'meta_query' => array(
837 array(
838 'key' => '_movie_url',
839 'value' => $movie,
840 'compare' => '=',
841 ),
842 ),
843 'tax_query' => array(
844 'relation' => 'AND',
845 array(
846 'taxonomy' => 'product_type',
847 'field' => 'slug',
848 'terms' => array('video_on_demand','subscription')
849 )
850 ),
851
852 );
853
854
855 $video_list = new WP_Query($args);
856
857 $video_id =0;
858 $ticket_flag=0;
859 if ($video_list->have_posts() ){
860 while ( $video_list->have_posts() ):
861 $video_list->the_post();
862 $video_id = get_the_ID();
863
864 $show_id='';
865 $is_valid_subscription=0;
866 if(class_exists ('WC_Subscription')){
867
868 $is_valid_subscription = wcs_user_has_subscription( $current_user->ID, $show_id ,'active');
869 }
870
871 if(function_exists('wpstream_check_global_subscription_model')){
872 if( wpstream_check_global_subscription_model() ){
873 $is_valid_subscription=1;// this is global subscription
874 }
875 }
876
877
878 if( wc_customer_bought_product( $current_user->email, $current_user->ID, $video_id) ||
879 $is_valid_subscription==1 ){
880
881 $get_key = $this->wpstream_get_vod_key($folder.'/'.$movie);
882 echo ($get_key);
883 exit();
884 }else{
885 $ticket_flag=1;
886 exit('no ticket loop'.$current_user->ID.'/'.$video_id.'/'.$is_valid_subscription );
887 }
888 endwhile;
889
890 if($ticket_flag==0){
891 exit($current_user->email.'no ticket ukpt'.$current_user->ID.'.'.$video_id);
892 }
893
894 }else{
895 exit('no video found :'.$movie);
896 }
897
898 }else{
899 exit('user not log');
900 }
901
902 }
903
904 }
905
906 }
907
908
909
910 /**
911 * request key for vod from wpstream
912 *
913 * @since 3.0.1
914 *
915 */
916
917
918 public function wpstream_get_vod_key($filename){
919 global $wpstream_plugin;
920 $vod_key = get_transient("vod_key".$filename);
921 if(false===$vod_key){
922 $token = $wpstream_plugin->wpstream_live_connection->wpstream_get_token();
923 $domain = parse_url ( get_site_url() );
924
925 $values_array=array(
926 "filename" => $filename,
927 );
928 $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/uservodkey/get/?access_token=".$token;
929
930
931 $arguments = array(
932 'method' => 'GET',
933 'timeout' => 45,
934 'redirection' => 5,
935 'httpversion' => '1.0',
936 'blocking' => true,
937 'headers' => array(),
938 'body' => $values_array,
939 'cookies' => array()
940 );
941 $response = wp_remote_post($url,$arguments);
942 $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
943
944
945 if( isset($response['response']['code']) && $response['response']['code']=='200'){
946 set_transient("vod_key".$filename,$received_data,120);
947 return ($received_data);
948 }else{
949 return 'failed connection';
950 }
951 }else{
952 return $vod_key;
953 }
954
955 }
956
957
958
959
960
961
962
963
964
965 /**
966 * wrapper start around woo
967 *
968 * @since 3.0.1
969 *
970 */
971
972
973 public function wpstream_non_image_content_wrapper_start() {
974 if ( is_user_logged_in() ) {
975 global $product;
976 $current_user = wp_get_current_user();
977 $product_id = wc_get_product()->get_id();
978
979 if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ){
980 echo '<div id="wpstream_product_wrap">';
981 }else{
982 echo '<div id="wpstream_product_wrap_no_buy">';
983 }
984 }
985
986 }
987
988 /**
989 * wrapper end around woo
990 *
991 * @since 3.0.1
992 *
993 */
994
995
996 function wpstream_non_image_content_wrapper_end() {
997 // echo '</div>';
998 }
999 }
1000