PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 2.03
WpStream – Live Streaming, Video on Demand, Pay Per View v2.03
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 / keys.php

keys.php in WpStream – Live Streaming, Video on Demand, Pay Per View 2.03, at libs/keys.php

154 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function wpstream_live_streaming_key(){
4
5 if( isset( $_REQUEST[ 'keys' ]) && $_REQUEST[ 'keys' ]!='' ) {
6 wpstream_live_streaming_generate_key(esc_html($_REQUEST[ 'keys' ]));
7 die();
8 }else{
9 return;
10 }
11
12 }
13
14 add_action('init','wpstream_live_streaming_key');
15
16
17
18
19
20 function wpstream_live_streaming_generate_key($streamname){
21
22 $current_user = wp_get_current_user();
23 $stream_key = esc_html($streamname);
24 $stream_key_array = explode('-', $stream_key);
25 $real_stream_key = $stream_key_array[0];
26
27 $args_free = array(
28 'posts_per_page' => -1,
29 'post_type' => 'wpstream_product',
30 'post_status' => 'publish',
31 'meta_query' => array(
32 array(
33 'key' => 'live_event_stream_name',
34 'value' => $real_stream_key,
35 'compare' => '=',
36 )
37 ),
38
39
40 );
41 $event_list_free = new WP_Query($args_free);
42
43
44 if ($event_list_free->have_posts() ){
45 $event_list_free->the_post();
46 $the_id = get_the_ID();
47 $event_data = get_post_meta($the_id,'live_event_uri',true);
48 $ip = get_post_meta($the_id,'ip',true);
49
50 $show_id = $the_id;
51
52
53 if ( false === ( $get_key = get_transient( $show_id.'_carnatus1x' ) ) ) {
54 $get_key = wpstream_get_encryption_key_local($stream_key,$ip);
55 set_transient( $show_id.'_carnatus1x', $get_key, 30 );
56 }
57 print $get_key;
58 }else{
59
60
61
62 // this is for paid products
63 if ( is_user_logged_in() && intval($current_user->ID)!=0 ) {
64
65 $args = array(
66 'posts_per_page' => -1,
67 'post_type' => 'product',
68 'post_status' => 'publish',
69 'meta_query' => array(
70 array(
71 'key' => 'live_event_stream_name',
72 'value' => $real_stream_key,
73 'compare' => '=',
74 ),
75 ),
76 'tax_query' => array(
77 'relation' => 'AND',
78 array(
79 'taxonomy' => 'product_type',
80 'field' => 'slug',
81 'terms' => array('live_stream','subscription')
82 )
83 ),
84 );
85
86
87 $event_list = new WP_Query($args);
88
89 if ($event_list->have_posts() ){
90 while ( $event_list->have_posts() ):
91 $event_list->the_post();
92 $the_id = get_the_ID();
93 $event_data = get_post_meta($the_id,'live_event_uri',true);
94 $ip = get_post_meta($the_id,'ip',true);
95 $show_id = $the_id;
96
97 endwhile;
98
99 $is_valid_subscription=0;
100 if(class_exists ('WC_Subscription')){
101 $is_valid_subscription = wcs_user_has_subscription( $current_user->ID, $show_id ,'active');
102 }
103
104
105 if(function_exists('wpstream_check_global_subscription_model')){
106 if( wpstream_check_global_subscription_model() ){
107 $is_valid_subscription=1;// this is global subscription
108 }
109 }
110
111
112 if( wc_customer_bought_product( $current_user->email, $current_user->ID, $show_id) || $is_valid_subscription==1 ){
113
114 if ( false === ( $get_key = get_transient( $show_id.'_carnatus1x' ) ) ) {
115 $get_key = wpstream_get_encryption_key_local($stream_key,$ip);
116 set_transient( $show_id.'_carnatus1x', $get_key, 30 );
117 }
118
119 print $get_key;
120 die();
121
122 }else{
123 exit('no ticket ');
124 }
125
126 } else{
127 exit('not query x1');
128 }
129
130 }else{
131 exit('not log');
132 }
133 }
134 }
135
136
137
138
139
140 function wpstream_get_encryption_key_local($stream_key,$server_ip){
141
142 $url= 'http://'.$server_ip.':80/keys/'.$stream_key;
143 $get= wp_remote_get( $url );
144
145 if(is_array($get)){
146 $body = $get['body'];
147 return($body);
148 }else{
149 return 'cucc'.wpstream_generateRandomString(32);
150 }
151 }
152
153
154