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 / keys.php

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

183 lines 5.9 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 function wpstream_live_streaming_generate_key($streamname){
18
19 $current_user = wp_get_current_user();
20 $stream_key = esc_html($streamname);
21 $stream_key_array = explode('-', $stream_key);
22 $real_stream_key = $stream_key_array[0];
23 $server_ip = '';
24
25 if ($server_ip=='' || false === ( $server_ip = get_transient( $server_ip.'_serverip' ) ) ) {
26 $server_ip = wpstream_get_live_stream_server($current_user,$streamname);
27 set_transient( $server_ip.'_serverip', $server_ip, 600 );
28 }
29
30 if ( false === ( $get_key = get_transient( $server_ip.'_carnatus1x' ) ) ) {
31 $get_key = wpstream_get_encryption_key_local($stream_key,$server_ip);
32 set_transient( $server_ip.'$server_ip', $get_key, 30 );
33 }
34 print $get_key;
35 }
36
37
38
39 function wpstream_live_streaming_generate_key_old($streamname){
40
41 $current_user = wp_get_current_user();
42 $stream_key = esc_html($streamname);
43 $stream_key_array = explode('-', $stream_key);
44 $real_stream_key = $stream_key_array[0];
45
46 $args_free = array(
47 'posts_per_page' => -1,
48 'post_type' => 'wpstream_product',
49 'post_status' => 'publish',
50 'meta_query' => array(
51 array(
52 'key' => 'live_event_stream_name',
53 'value' => $real_stream_key,
54 'compare' => '=',
55 )
56 ),
57
58
59 );
60 $event_list_free = new WP_Query($args_free);
61
62
63 if ($event_list_free->have_posts() ){
64 $event_list_free->the_post();
65 $the_id = get_the_ID();
66 $event_data = get_post_meta($the_id,'live_event_uri',true);
67 $ip = get_post_meta($the_id,'ip',true);
68
69 $show_id = $the_id;
70
71
72 if ( false === ( $get_key = get_transient( $show_id.'_carnatus1x' ) ) ) {
73 $get_key = wpstream_get_encryption_key_local($stream_key,$ip);
74 set_transient( $show_id.'_carnatus1x', $get_key, 30 );
75 }
76 print $get_key;
77 }else{
78
79
80
81 // this is for paid products
82 if ( is_user_logged_in() && intval($current_user->ID)!=0 ) {
83
84 $args = array(
85 'posts_per_page' => -1,
86 'post_type' => 'product',
87 'post_status' => 'publish',
88 'meta_query' => array(
89 array(
90 'key' => 'live_event_stream_name',
91 'value' => $real_stream_key,
92 'compare' => '=',
93 ),
94 ),
95 'tax_query' => array(
96 'relation' => 'AND',
97 array(
98 'taxonomy' => 'product_type',
99 'field' => 'slug',
100 'terms' => array('live_stream','subscription')
101 )
102 ),
103 );
104
105
106 $event_list = new WP_Query($args);
107
108 if ($event_list->have_posts() ){
109 while ( $event_list->have_posts() ):
110 $event_list->the_post();
111 $the_id = get_the_ID();
112 $event_data = get_post_meta($the_id,'live_event_uri',true);
113 $ip = get_post_meta($the_id,'ip',true);
114 $show_id = $the_id;
115
116 endwhile;
117
118 $is_valid_subscription=0;
119 if(class_exists ('WC_Subscription')){
120 $is_valid_subscription = wcs_user_has_subscription( $current_user->ID, $show_id ,'active');
121 }
122
123
124 if(function_exists('wpstream_check_global_subscription_model')){
125 if( wpstream_check_global_subscription_model() ){
126 $is_valid_subscription=1;// this is global subscription
127 }
128 }
129
130
131 if( wc_customer_bought_product( $current_user->email, $current_user->ID, $show_id) || $is_valid_subscription==1 ){
132
133 if ( false === ( $get_key = get_transient( $show_id.'_carnatus1x' ) ) ) {
134 $get_key = wpstream_get_encryption_key_local($stream_key,$ip);
135 set_transient( $show_id.'_carnatus1x', $get_key, 30 );
136 }
137
138 print $get_key;
139 die();
140
141 }else{
142 exit('no ticket ');
143 }
144
145 } else{
146 exit('not query x13');
147 }
148
149 }else{
150 exit('not log');
151 }
152 }
153 }
154
155
156
157
158
159 function wpstream_get_encryption_key_local($stream_key,$server_ip){
160
161 $url= 'http://'.$server_ip.':80/keys/'.$stream_key;
162 $get= wp_remote_get( $url );
163
164 if(is_array($get)){
165 $body = $get['body'];
166 return($body);
167 }else{
168 return 'cucc'.wpstream_generateRandomString_keys(32);
169 }
170 }
171
172
173 function wpstream_generateRandomString_keys($length = 10) {
174 $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
175 $charactersLength = strlen($characters);
176 $randomString = '';
177 for ($i = 0; $i < $length; $i++) {
178 $randomString .= $characters[rand(0, $charactersLength - 1)];
179 }
180 return $randomString;
181 }
182
183