PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.3
WpStream – Live Streaming, Video on Demand, Pay Per View v3.3
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.3, at public/class-wpstream-public.php

976 lines 34.2 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 <office@wpstream.net>
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 wp_enqueue_style('wpstream-style', plugin_dir_url( __FILE__ ) .'/css/wpstream_style.css',array(), WPSTREAM_PLUGIN_VERSION, 'all' );
74 wp_enqueue_style('video-js.min', plugin_dir_url( __FILE__ ).'/css/video-js.min.css', array(), WPSTREAM_PLUGIN_VERSION, 'all');
75
76 }
77
78 /**
79 * Register the JavaScript for the public-facing side of the site.
80 *
81 * @since 3.0.1
82 */
83 public function enqueue_scripts() {
84
85
86 wp_enqueue_script('video.min', plugin_dir_url( __FILE__ ).'js/video.min.js',array('jquery'), WPSTREAM_PLUGIN_VERSION, false);
87 wp_enqueue_script('youtube.min', plugin_dir_url( __FILE__ ).'js/youtube.min.js',array('video.min'), WPSTREAM_PLUGIN_VERSION, false);
88 wp_enqueue_script('videojs-vimeo.min', plugin_dir_url( __FILE__ ).'js/videojs-vimeo.min.js',array('video.min'), WPSTREAM_PLUGIN_VERSION, false);
89 wp_enqueue_script('wpstream-player', plugin_dir_url( __FILE__ ).'js/wpstream-player.js',array('video.min'), WPSTREAM_PLUGIN_VERSION, false);
90
91 wp_localize_script('wpstream-player', 'wpstream_player_vars',
92 array(
93 'admin_url' => get_admin_url(),
94 )
95 );
96
97 wp_enqueue_script( 'jquery-ui-autocomplete' );
98 wp_enqueue_script( "jquery-effects-core");
99
100 wp_register_script( 'sockjs-0.3.min', plugin_dir_url( __FILE__ ) . '/chat_lib/sockjs-0.3.min.js', array('jquery'), true );
101 wp_register_script( 'emojione.min.js',plugin_dir_url( __FILE__ ). '/chat_lib/emojione.min.js', array('jquery'), true );
102
103 wp_register_script( 'jquery.linkify.min.js', plugin_dir_url( __FILE__ ). '/chat_lib/jquery.linkify.min.js', array('jquery'), true );
104 wp_register_script( 'ripples.min.js',plugin_dir_url( __FILE__ ). '/chat_lib/ripples.min.js', array('jquery'), true );
105 wp_register_script( 'material.min.js"', plugin_dir_url( __FILE__ ). '/chat_lib/material.min.js', array('jquery'), true );
106 wp_register_script( 'chat.js', plugin_dir_url( __FILE__ ). '/chat_lib/chat.js', array('jquery'), true );
107
108
109
110 wp_register_style( 'chat.css',plugin_dir_url( __FILE__ ).'/chat_lib/css/chat.css', array(), '1.0', 'all');
111 wp_register_style( 'ripples.css',plugin_dir_url( __FILE__ ).'/chat_lib/css/ripples.css', array(), '1.0', 'all');
112 wp_register_style( 'emojione.min.css',plugin_dir_url( __FILE__ ).'/chat_lib/css/emojione.min.css', array(), '1.0', 'all');
113
114
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 add_shortcode('wpstream_chat', array($this,'wpstream_chat_function') );
220
221
222 // register shortcodes for visual composer
223 if( function_exists('vc_map') ):
224 vc_map(
225 array(
226 "name" => esc_html__( "WpStream Chat - Beta Version","wpestate"),
227 "base" => "wpstream_chat",
228 "class" => "",
229 "category" => esc_html__( 'WpStream','wpestate'),
230 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
231 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
232 'weight'=>100,
233 'icon' =>'',
234 'description'=>esc_html__( 'Insert WpStream Chat','wpestate'),
235 "params" => array(
236 array(
237 "type" => "textfield",
238 "holder" => "div",
239 "class" => "",
240 "heading" => esc_html__( "Live Stream Id","wpestate"),
241 "param_name" => "id",
242 "value" => "0",
243 "description" => esc_html__( "Add here the live stream id","wpestate")
244 ),
245
246 )
247 )
248 );
249
250
251
252 vc_map(
253 array(
254 "name" => esc_html__( "WpStream Player","wpestate"),
255 "base" => "wpstream_player",
256 "class" => "",
257 "category" => esc_html__( 'WpStream','wpestate'),
258 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
259 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
260 'weight'=>100,
261 'icon' =>'',
262 'description'=>esc_html__( 'Insert WpStream Player','wpestate'),
263 "params" => array(
264 array(
265 "type" => "textfield",
266 "holder" => "div",
267 "class" => "",
268 "heading" => esc_html__( "Product/Free Product Id","wpestate"),
269 "param_name" => "id",
270 "value" => "0",
271 "description" => esc_html__( "Add here the live stream id or the video id","wpestate")
272 ),
273
274 )
275 )
276 );
277
278
279
280 $product_type=array(
281 '1' => __('Free Live Channel','wpstream'),
282 '2' => __('Free Video','wpstream')
283 );
284
285 vc_map(
286 array(
287 "name" => esc_html__( "WpStream Products List","wpestate"),
288 "base" => "wpstream_list_products",
289 "class" => "",
290 "category" => esc_html__( 'WpStream','wpestate'),
291 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
292 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
293 'weight'=>100,
294 'icon' =>'',
295 'description'=>esc_html__( ' List wpstream products','wpestate'),
296 "params" => array(
297 array(
298 "type" => "textfield",
299 "holder" => "div",
300 "class" => "",
301 "heading" => esc_html__( "Media number","wpestate"),
302 "param_name" => "media_number",
303 "value" => "",
304 "description" => esc_html__( "No of media ","wpestate")
305 ),
306
307 array(
308 "type" => "dropdown",
309 "holder" => "div",
310 "class" => "",
311 "heading" => esc_html__( "Product type","wpestate"),
312 "param_name" => "product_type",
313 "value" => $product_type,
314 "description" => esc_html__( "What type of products ","wpestate")
315 ),
316
317 )
318 )
319 );
320 endif;
321
322
323 // add shorcotes to editor interface
324 if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
325 return;
326 }
327
328 if (get_user_option('rich_editing') == 'true') {
329 add_filter('mce_external_plugins', array( $this,'wpstream_add_plugin') );
330 add_filter('mce_buttons_2', array($this,'wpstream_register_button') );
331 }
332 }
333
334
335 /**
336 * shortocode player
337 *
338 * @since 3.0.1
339 *
340 */
341 public function wpstream_chat_function($attributes, $content = null){
342 $product_id = '';
343 $return_string = '';
344 $attributes = shortcode_atts(
345 array(
346 'id' => 0,
347 ), $attributes) ;
348
349
350 if ( isset($attributes['id']) ){
351 $product_id=$attributes['id'];
352 }
353
354
355 $return_string.= '<div class="wpstream_plugin_chat_wrapper">';
356 ob_start();
357 $this->main->wpstream_player->wpstream_chat_wrapper($product_id);
358 $return_string.= ob_get_contents();
359 ob_end_clean();
360 $return_string.='</div>';
361 $this->main->wpstream_player->wpstream_connect_to_chat($product_id);
362
363 return $return_string;
364 }
365
366
367
368
369 /**
370 * shortocode player
371 *
372 * @since 3.0.1
373 *
374 */
375
376
377 public function wpstream_insert_player_inpage_local($attributes, $content = null){
378 $product_id = '';
379 $return_string = '';
380 $attributes = shortcode_atts(
381 array(
382 'id' => 0,
383 ), $attributes) ;
384
385
386 if ( isset($attributes['id']) ){
387 $product_id=$attributes['id'];
388 }
389
390 ob_start();
391 $this->main->wpstream_player->wpstream_video_player_shortcode($product_id);
392 $return_string= ob_get_contents();
393 ob_end_clean();
394
395 return $return_string;
396 }
397
398
399
400
401 /**
402 * list products - shortcode function
403 *
404 * @since 3.0.1
405 *
406 */
407
408 public function wpstream_list_products_function($atts, $content=null){
409
410 $media_number = "";
411 $product_type = "";
412 $attributes = shortcode_atts(
413 array(
414 'media_number' => '4',
415 'product_type' => __('Free Live Channel','wpstream'),
416
417 ), $atts);
418
419 if ( isset($attributes['media_number']) ){
420 $media_number=$attributes['media_number'];
421 }
422
423 if ( isset($attributes['product_type']) ){
424 $product_type=$attributes['product_type'];
425 }
426
427 if($product_type== __('Free Live Channel','wpstream') ){
428 $product_type=1;
429 }else{
430 $product_type=2;
431 }
432
433 $return_string="";
434
435
436
437 $args = array(
438 'post_type' => 'wpstream_product',
439 'post_status' => 'publish',
440 'meta_query' =>array(
441 array(
442 'key' => 'wpstream_product_type',
443 'value' => $product_type,
444 'compare' => '=',
445 ),
446 ),
447 'posts_per_page' =>$media_number,
448 'page' => 1
449 );
450
451
452 $media_list= new WP_Query($args);
453
454 if($product_type==1){
455 $see_product= __('See Free Live Chanel','wpstream');
456 }else{
457 $see_product =_('See Free Video','wpstream');
458 }
459
460
461
462 while($media_list->have_posts()):$media_list->the_post();
463 $return_string.='<div class="wpstream_product_unit">'
464 .'<div class="product_image" style="background-image:url('.wp_get_attachment_thumb_url(get_post_thumbnail_id()).')"></div>'
465 .'<a href="'.get_permalink().'" class="product_title" >'.get_the_title().'</a>'
466 .'<a href="'.get_permalink().'"class="see_product">'.$see_product.'</a>'
467 .'</div>';
468 endwhile;
469
470 wp_reset_postdata();
471 wp_reset_query();
472
473
474 return '<div class="shortcode_list_wrapper">'.$return_string.'</div>';
475
476 }
477
478
479
480 /**
481 * register shortcodes - add buttons in js
482 *
483 * @since 3.0.1
484 *
485 */
486
487 public function wpstream_add_plugin($plugin_array) {
488 $plugin_array['wpstream_player'] = plugin_dir_url( __FILE__ ). '/js/shortcodes.js';
489 $plugin_array['wpstream_list_products'] = plugin_dir_url( __FILE__ ). '/js/shortcodes.js';
490 return $plugin_array;
491 }
492
493 /**
494 * register shortcodes - add buttons
495 *
496 * @since 3.0.1
497 *
498 */
499 public function wpstream_register_button($buttons) {
500 array_push($buttons, "|", "wpstream_player");
501 array_push($buttons, "|", "wpstream_list_products");
502 return $buttons;
503 }
504
505
506
507 /**
508 * wpstream cors
509 *
510 * @since 3.0.1
511 *
512 */
513
514 public function wpstream_cors_check_and_response(){
515 if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
516 header('Access-Control-Allow-Methods: POST, GET');
517 header('Access-Control-Allow-Headers: Authorization');
518 header('Access-Control-Max-Age: 1'); //1728000
519 header("Content-Length: 0");
520 header("Content-Type: text/plain charset=UTF-8");
521 exit(0);
522 }
523 }
524
525 /**
526 * set user cookie
527 *
528 * @since 3.0.1
529 *
530 */
531
532 public function wpstream_set_cookies(){
533 if( !isset( $_REQUEST[ 'keys' ]) && !isset( $_REQUEST[ 'keys2' ]) ) {
534 $cookie=uniqid ();
535 setcookie("WpstreamNonLogCookie3", $cookie);
536 }
537 }
538
539 /**
540 * get key for live stream
541 *
542 * @since 3.0.1
543 *
544 */
545
546
547 public function wpstream_live_streaming_key(){
548
549 if( isset( $_REQUEST[ 'keys' ]) && $_REQUEST[ 'keys' ]!='' ) {
550
551 $streamname_received = esc_html($_REQUEST[ 'keys' ]);
552 $stream_key_array = explode('-', $streamname_received);
553
554 $streamname = $stream_key_array[0];
555 $current_user = wp_get_current_user();
556
557
558 $args_free = array(
559 'posts_per_page' => -1,
560 'post_type' => 'wpstream_product',
561 'post_status' => 'publish',
562 'meta_query' => array(
563 array(
564 'key' => 'streamName',
565 'value' => $streamname,
566 'compare' => '=',
567 )
568 ),
569
570
571 );
572 $event_list_free = new WP_Query($args_free);
573
574
575 if ($event_list_free->have_posts() ){
576 ////////////////////////////////////////////////////////////
577 // when we have a free event
578 ////////////////////////////////////////////////////////////
579
580 $event_list_free->the_post();
581 $the_id = get_the_ID();
582 $show_id = $the_id;
583 $get_key = $this->wpstream_get_encryption_key_remonting($show_id,$streamname_received);
584 print $get_key;
585 die();
586
587
588 }else{
589 ////////////////////////////////////////////////////////////
590 // this is for paid products
591 ////////////////////////////////////////////////////////////
592
593 if ( is_user_logged_in() && intval($current_user->ID)!=0 ) {
594
595 $args = array(
596 'posts_per_page' => -1,
597 'post_type' => 'product',
598 'post_status' => 'publish',
599 'meta_query' => array(
600 array(
601 'key' => 'streamName',
602 'value' => $streamname,
603 'compare' => '=',
604 ),
605 ),
606 'tax_query' => array(
607 'relation' => 'AND',
608 array(
609 'taxonomy' => 'product_type',
610 'field' => 'slug',
611 'terms' => array('live_stream','subscription')
612 )
613 ),
614 );
615
616
617 $event_list = new WP_Query($args);
618
619 if ($event_list->have_posts() ){
620 while ( $event_list->have_posts() ):
621 $event_list->the_post();
622 $the_id = get_the_ID();
623 $show_id = $the_id;
624
625 endwhile;
626
627 $is_valid_subscription=0;
628 if(class_exists ('WC_Subscription')){
629 $is_valid_subscription = wcs_user_has_subscription( $current_user->ID, $show_id ,'active');
630 }
631
632
633 if(function_exists('wpstream_check_global_subscription_model')){
634 if( wpstream_check_global_subscription_model() ){
635 $is_valid_subscription=1;// this is global subscription
636 }
637 }
638
639
640 if( wc_customer_bought_product( $current_user->email, $current_user->ID, $show_id) || $is_valid_subscription==1 ){
641 $get_key = $this->wpstream_get_encryption_key_remonting($show_id,$streamname_received);
642 print $get_key;
643 die();
644
645 }else{
646 exit('live - no ticket ');
647 }
648
649 } else{
650 exit('live - no event');
651 }
652
653 }else{
654 exit('live - user not log or awserr');
655 }
656
657 }
658 exit('no free or paid event');
659
660 }else{
661 return;
662 }
663
664 }
665
666
667
668
669 /**
670 * get remote key for live
671 *
672 * @since 3.0.1
673 *
674 */
675
676 public function wpstream_get_encryption_key_remonting ($show_id,$streamname_received){
677
678 if ( false === ( $get_key = get_transient( $show_id.'_api20_streamName' ) ) ) {
679
680 $url = get_post_meta($show_id,'hlsKeyRetrievalUrl',true).'/'.$streamname_received;
681
682 $get= wp_remote_get( $url );
683
684 if(is_array($get)){
685 $get_key = $get['body'];
686 }else{
687 $get_key='';
688 }
689
690 set_transient( $show_id.'_api20_streamName', $get_key, 30 );
691 }
692 return $get_key;
693 }
694
695
696
697 /**
698 * get key for 3rdparty
699 *
700 * @since 3.0.1
701 *
702 */
703
704
705 public function wpstream_live_streaming_key_for_3rdparty(){
706
707 if( isset( $_REQUEST[ 'thirdkeys' ]) && $_REQUEST[ 'thirdkeys' ]!='' ) {
708
709 $thirdkeys = esc_html($_REQUEST[ 'thirdkeys' ]);
710
711 //live_event_carnat2
712
713 $args = array(
714 'post_type' => array('product','wpstream_product'),
715 'post_status' => 'publish',
716 'meta_query' =>array(
717 array(
718 'key' => 'live_event_carnat2',
719 'value' => $thirdkeys,
720 'compare' => '=',
721 ),
722 ),
723
724
725 );
726
727
728 $media_list= new WP_Query($args);
729 if($media_list->have_posts()){
730 while($media_list->have_posts()):$media_list->the_post();
731
732 $media_id = get_the_ID();
733 $replay_array = array(
734 // '', // fb will be here
735 stripslashes( get_post_meta($media_id,'wpstream_youtube_rtmp',true )),
736 stripslashes( get_post_meta($media_id,'wpstream_twich_rtmp',true) ),
737 );
738
739 $reply_final=array('rtmp_urls'=>$replay_array);
740 header('Content-Type: application/json;charset=utf-8');
741 print json_encode($reply_final,JSON_UNESCAPED_SLASHES);
742 die();
743
744
745 endwhile;
746 }else{
747 print'{}';
748 die('');
749 }
750
751 }
752
753 }
754
755
756
757 /**
758 * get key for vod
759 *
760 * @since 3.0.1
761 *
762 */
763
764
765 public function wpstream_live_streaming_key_vod(){
766
767 if( isset( $_REQUEST[ 'keys2' ]) && $_REQUEST[ 'keys2' ]!='' ) {
768 global $wp_query;
769 $current_user = wp_get_current_user();
770
771
772 $keys2 = esc_html($_REQUEST[ 'keys2' ]);
773
774
775 $keys2= ltrim($keys2,"/");
776 $keys2= rtrim($keys2,"/");
777 $keys2_array=explode('/',$keys2);
778
779
780 $folder=$keys2_array[0];
781 $movie=$keys2_array[1];
782
783
784 $free_args = array(
785 'posts_per_page' => -1,
786 'post_type' => 'wpstream_product',
787 'meta_query' => array(
788 array(
789 'key' => 'wpstream_free_video',
790 'value' => $movie,
791 'compare' => '=',
792 ),
793 )
794 );
795
796
797 $free_video_list = new WP_Query($free_args);
798
799 if ($free_video_list->have_posts() ){
800 $get_key = $this->wpstream_get_vod_key($folder.'/'.$movie);
801 echo ($get_key);
802 die();
803 }else{
804 if ( is_user_logged_in() && intval($current_user->ID)!=0 ) {
805
806 $args = array(
807 'posts_per_page' => -1,
808 'post_type' => 'product',
809 'meta_query' => array(
810 array(
811 'key' => '_movie_url',
812 'value' => $movie,
813 'compare' => '=',
814 ),
815 ),
816 'tax_query' => array(
817 'relation' => 'AND',
818 array(
819 'taxonomy' => 'product_type',
820 'field' => 'slug',
821 'terms' => array('video_on_demand','subscription')
822 )
823 ),
824
825 );
826
827
828 $video_list = new WP_Query($args);
829
830 $video_id =0;
831 $ticket_flag=0;
832 if ($video_list->have_posts() ){
833 while ( $video_list->have_posts() ):
834 $video_list->the_post();
835 $video_id = get_the_ID();
836
837 $show_id='';
838 $is_valid_subscription=0;
839 if(class_exists ('WC_Subscription')){
840
841 $is_valid_subscription = wcs_user_has_subscription( $current_user->ID, $show_id ,'active');
842 }
843
844 if(function_exists('wpstream_check_global_subscription_model')){
845 if( wpstream_check_global_subscription_model() ){
846 $is_valid_subscription=1;// this is global subscription
847 }
848 }
849
850
851 if( wc_customer_bought_product( $current_user->email, $current_user->ID, $video_id) ||
852 $is_valid_subscription==1 ){
853
854 $get_key = $this->wpstream_get_vod_key($folder.'/'.$movie);
855 echo ($get_key);
856 exit();
857 }else{
858 $ticket_flag=1;
859 exit('no ticket loop'.$current_user->ID.'/'.$video_id.'/'.$is_valid_subscription );
860 }
861 endwhile;
862
863 if($ticket_flag==0){
864 exit($current_user->email.'no ticket ukpt'.$current_user->ID.'.'.$video_id);
865 }
866
867 }else{
868 exit('no video found :'.$movie);
869 }
870
871 }else{
872 exit('user not log');
873 }
874
875 }
876
877 }
878
879 }
880
881
882
883 /**
884 * request key for vod from wpstream
885 *
886 * @since 3.0.1
887 *
888 */
889
890
891 public function wpstream_get_vod_key($filename){
892 global $wpstream_plugin;
893 $vod_key = get_transient("vod_key".$filename);
894 if(false===$vod_key){
895 $token = $wpstream_plugin->wpstream_live_connection->wpstream_get_token();
896 $domain = parse_url ( get_site_url() );
897
898 $values_array=array(
899 "filename" => $filename,
900 );
901 $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/uservodkey/get/?access_token=".$token;
902
903
904 $arguments = array(
905 'method' => 'GET',
906 'timeout' => 45,
907 'redirection' => 5,
908 'httpversion' => '1.0',
909 'blocking' => true,
910 'headers' => array(),
911 'body' => $values_array,
912 'cookies' => array()
913 );
914 $response = wp_remote_post($url,$arguments);
915 $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
916
917
918 if( isset($response['response']['code']) && $response['response']['code']=='200'){
919 set_transient("vod_key".$filename,$received_data,120);
920 return ($received_data);
921 }else{
922 return 'failed connection';
923 }
924 }else{
925 return $vod_key;
926 }
927
928 }
929
930
931
932
933
934
935
936
937
938 /**
939 * wrapper start around woo
940 *
941 * @since 3.0.1
942 *
943 */
944
945
946 public function wpstream_non_image_content_wrapper_start() {
947 if ( is_user_logged_in() ) {
948 global $product;
949 $current_user = wp_get_current_user();
950 $product = wc_get_product();
951
952 if($product){
953 $product_id = $product->get_id();
954 if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ){
955 echo '<div id="wpstream_product_wrap">';
956 }else{
957 echo '<div id="wpstream_product_wrap_no_buy">';
958 }
959 }
960 }
961
962 }
963
964 /**
965 * wrapper end around woo
966 *
967 * @since 3.0.1
968 *
969 */
970
971
972 function wpstream_non_image_content_wrapper_end() {
973 // echo '</div>';
974 }
975 }
976