1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<?php
/**
* Copyright: 2022 (c)Franco (nextime) Lanza <franco@nexlab.it>
* License: GNU/GPL version 3.0
*
* This file is part of SexHackMe Wordpress Plugin.
*
* SexHackMe Wordpress Plugin is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* SexHackMe Wordpress Plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SexHackMe Wordpress Plugin. If not, see <https://www.gnu.org/licenses/>.
*/
namespace wp_SexHackMe;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
$sh_video = get_query_var('sh_video', false);
if(!$sh_video) {
wp_redirect(get_permalink(get_option('sexhack_video404_page', '0')));
exit ;
}
$video = sh_get_video_from_slug($sh_video);
if(!$video)
{
wp_redirect(get_permalink(get_option('sexhack_video404_page', '0')));
exit ;
}
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<header class="page-header">
<?php
//the_archive_title( '<h1 class="page-title">', '</h1>' );
//the_archive_description( '<div class="taxonomy-description">', '</div>' ); // XXX Check it? what it does
?>
</header><!-- .page-header -->
<?php
do_action( 'storefront_loop_before' );
//print_r($sexhack_pms->plans);
while ( have_posts() ) :
the_post();
echo do_shortcode("[sexadv adv=".get_option('sexadv_video_top')."]");
$htmltags = '<span><b>TAGS: </b></span>';
$tags = $video->get_tags();
if ( ! empty( $tags ) && ! is_wp_error( $tags ) )
{
foreach($tags as $tag) {
$htmltags.="<span>#".$tag->tag . '</span> ';
}
}
$videoslug = get_option('sexhack_gallery_slug', 'v');
$vurl = "/".$videoslug."/".$sh_video."/";
$prod = $video->get_product();
$hls_public = $video->hls_public;
$hls_members = $video->hls_members;
$hls_premium = $video->hls_premium;
$video_preview = $video->preview;
$gif_preview = $video->gif_small;
$gif = $video->gif;
$premium_is_ppv = false;
if($video->premium_is_ppv=='Y') $premium_is_ppv=true;
$categories = $video->get_categories(true);
if(($hls_public) AND starts_with('/', $hls_public)) $hls_public = site_url().$hls_public;
if(($hls_members) AND starts_with('/', $hls_members)) $hls_members = site_url().$hls_members;
if(($hls_premium) AND starts_with('/', $hls_premium)) $hls_premium = site_url().$hls_premium;
if(($video_preview) AND starts_with('/', $video_preview)) $video_preview = site_url().$video_preview;
$t = $video->thumbnail;
if(is_numeric($t) )
$thumb = wp_get_attachment_url($video->thumbnail);
else
$thumb = $t;
$avail = array();
$tabtext = array('subscribers' => 'Subscribers',
'members' => 'Members',
'public' => 'Public');
if($premium_is_ppv) $tabtext['subscribers'] = 'PPV';
if($hls_public || $video_preview ) $avail[] = 'public';
if($hls_members) $avail[] = 'members';
if($hls_premium) $avail[] = 'subscribers';
$videoaccess = get_query_var('videoaccess', false);
if($videoaccess && in_array($videoaccess, $avail))
{
$tab = $videoaccess;
}
else
{
if(user_has_premium_access() || $video->user_bought_video()) {
if($hls_premium && ((!$premium_is_ppv) || $video->user_bought_video() )) $tab = 'subscribers';
elseif($hls_members) $tab = 'members';
else $tab = 'public';
}
elseif(user_has_member_access()) // free membership
{
if($hls_members) $tab = 'members';
else $tab = 'public';
}
else // public
{
$tab = 'public';
}
}
?>
<article id="post-<?php echo get_the_ID();?>" class="post-<?php echo get_the_ID();?> product type-product">
<div class="sexhack-video-container">
<?php
$filterurl=false;
if(get_option('sexhack_shmdown', false)) $filterurl=get_option('sexhack_shmdown_uri', false);
if(in_array($tab, $avail))
{
switch($tab)
{
case "members":
if(user_has_member_access() || $video->user_bought_video())
{
if($filterurl && $hls_members && $video->video_type=="VR" )
echo do_shortcode( "[sexvideo url=\"".wp_nonce_url($filterurl.$sh_video."/members/".basename($hls_members), 'shm_members_video-'.$video->id)."\" posters=\"".$thumb."\"]" );
else if($hls_members && $video->video_type=="VR" )
echo do_shortcode( "[sexvideo url=\"".$hls_members."\" posters=\"".$thumb."\"]" );
else if($filterurl && $hls_members)
echo do_shortcode( "[sexhls url=\"".wp_nonce_url($filterurl.$sh_video."/members/".basename($hls_members), 'shm_members_video-'.$video->id)."\" posters=\"".$thumb."\"]" );
else if($hls_members)
echo do_shortcode( "[sexhls url=\"".$hls_members."\" posters=\"".$thumb."\"]" );
else echo "<h3 class='sexhack-videonotify'>SOMETHING WENT BADLY WRONG. I CAN'T FIND THE VIDEO</h3>";
}
else
{
if($gif_preview) echo '<img class="sexhack_videopreview" src="'.$gif_preview.'" loading="lazy"></img>';
else echo '<img class="sexhack_videopreview" src="'.$thumb.'" loading="lazy"></img>';
}
break;
case "subscribers":
if((user_has_premium_access() && !$premium_is_ppv) || $video->user_bought_video())
{
if($filterurl && $hls_premium && $video->video_type=="VR")
echo do_shortcode( "[sexvideo url=\"".wp_nonce_url($filterurl.$sh_video."/premium/".basename($hls_premium), 'shm_premium_video-'.$video->id)."\" posters=\"".$thumb."\"]" );
else if($hls_premium && $video->video_type=="VR")
echo do_shortcode( "[sexvideo url=\"".$hls_premium."\" posters=\"".$thumb."\"]" );
else if($filterurl && $hls_premium)
echo do_shortcode( "[sexhls url=\"".wp_nonce_url($filterurl.$sh_video."/premium/".basename($hls_premium), 'shm_premium_video-'.$video->id)."\" posters=\"".$thumb."\"]" );
else if($hls_premium)
echo do_shortcode( "[sexhls url=\"".$hls_premium."\" posters=\"".$thumb."\"]" );
else echo "<h3 class='sexhack-videonotify'>SOMETHING WENT BADLY WRONG. I CAN'T FIND THE VIDEO</h3>";
}
else
{
if($gif_preview) echo '<img class="sexhack_videopreview" src="'.$gif_preview.'" loading="lazy"></img>';
else echo '<img class="sexhack_videopreview" src="'.$thumb.'" loading="lazy"></img>';
}
break;
default: // public too!
if($filterurl && $hls_public && $video->video_type=='VR')
echo do_shortcode( "[sexvideo url=\"".wp_nonce_url($filterurl.$sh_video."/public/".basename($hls_public), 'shm_public_video-'.$video->id)."\" posters=\"".$thumb."\"]" );
else if($hls_public && $video->video_type=='VR')
echo do_shortcode( "[sexvideo url=\"".$hls_public."\" posters=\"".$thumb."\"]" );
else if($filterurl && $hls_public)
echo do_shortcode( "[sexhls url=\"".wp_nonce_url($filterurl.$sh_video."/public/".basename($hls_public), 'shm_public_video-'.$video->id)."\" posters=\"".$thumb."\"]" );
else if($hls_public)
echo do_shortcode( "[sexhls url=\"".$hls_public."\" posters=\"".$thumb."\"]" );
else if($video_preview) {
//echo do_shortcode( "[sexvideo url=\"".$video_preview."\" posters=\"".$thumb."\"]" );
// XXX BUG: sexvideo doesn't like google.drive.com/uc? videos for cross-site problems?
echo '<video src='."'$video_preview'".' controls autoplay muted playsinline loop></video></div></div>';
header("Access-Control-Allow-Origin: *");
}
else if($gif_preview) echo '<img class="sexhack_videopreview" src="'.$gif_preview.'" loading="lazy"></img>';
else echo '<img class="sexhack_videopreview" src="'.$thumb.'" loading="lazy"></img>';
}
}
else // if(in_array($tab, $avail))
{
if($video_preview) echo '<video src='."'$video_preview'".' controls autoplay muted playsinline loop poster="'.$thumb.'"></video>';
else if($gif_preview) echo '<img class="sexhack_videopreview" src="'.$gif_preview.'" loading="lazy"></img>';
else echo '<img class="sexhack_videopreview" src="'.$thumb.'" loading="lazy"></img>';
?>
<h2 class='sexhack-videonotify' style="padding:5%;"><b>PUBLIC VIDEO NOT AVAILABLE</b></h2>
<?php
}
?>
</div> <!-- video container -->
<div class="sexhack-tabs">
<?php
foreach($avail as $vaval)
{
if(!(in_array('vrpub', $avail) && ($vaval == 'public'))) {
$hrefurl = $vurl.'/'.$vaval.'/';
$bclass = '';
if(isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $hrefurl .= '?'.$_SERVER['QUERY_STRING'];
if($vaval == $tab) $bclass='sexhack_toggled_button';
?>
<a class="sexhack_tab_a" href="<?php echo $hrefurl; ?>">
<button name="<?php echo $vaval; ?>" class="sexhack_tab_button <?php echo $bclass; ?>">
<?php echo $tabtext[$vaval]; ?>
</button>
</a>
<?php
}
}
?>
</div>
<header class="entry-header">
<h2 class="sexhack_video_title">
<?php echo $video->get_title(); echo " (".$tabtext[$tab]." version)"; ?>
</h2>
</header><!-- .entry-header -->
<p><?php echo do_shortcode($video->description); ?></p>
<?php
$pcontent = do_shortcode(get_post()->post_content);
if($pcontent!='') { ?>
<p><?php echo $pcontent; ?></p>
<?php } ?>
<hr>
<?php
echo $htmltags;
?>
<?php if(!$video->user_bought_video() && $hls_premium && ($premium_is_ppv && user_is_premium() || !user_is_premium())) { ?>
<h3><a href="<?php echo \wc_get_checkout_url()."?add-to-cart=".strval($video->product_id)."&shm_direct_checkout=".strval($video->product_id); ?>"><button>Buy unlimited access to this video</button></a></h3>
<?php } ?>
<?php if(!$video->user_bought_video() && $hls_premium && !$premium_is_ppv && !user_is_premium() && user_is_member()) { ?>
<h3><a href="/product-category/subscriptions/"><button>Upgrade to access premium versions</button></a></h3>
<?php } ?>
<?php if($video->has_downloads()) { // XXX IS already bought this should redirect to the video ?>
<?php if(!$video->user_bought_video()) { ?>
<h3><a href="<?php echo \wc_get_checkout_url()."?add-to-cart=".strval($video->product_id)."&shm_direct_checkout=".strval($video->product_id); ?>"><button>Download full version</button></a></h3>
<?php } else { ?>
<h3><a href="<?php echo get_permalink($video->product_id);?>"><button>Download</button></a></h3>
<?php } ?>
<?php } ?>
<?php if(!user_has_member_access()) { ?>
<div class='sexhack-videonotify' style="padding:1px; margin: 0 auto; margin-left: 10%;">
<a href="/register/">
<img src="<?php echo plugin_dir_url(__FILE__)."/img/cropped-sexhack_members-300x99.jpg";?>" alt="Register for free and watch members version!" />
</a>
</div>
<?php } ?>
<?php
if(!is_user_logged_in())
echo "<div class='shm_video_login' style='max-width: 300px; width: 80%; margin-left: 10%;' ><h4>Already a member? Login:</h4></div>";
echo "<div class='shm_video_login' style='max-width: 300px; width: 80%; margin-left: 10%;' >".do_shortcode('[pms-login redirect_url="/account" ]')."</div>";
?>
<hr>
<?php
echo do_shortcode("[sexadv adv=".get_option('sexadv_video_bot')."]");
endwhile;
/**
* Functions hooked in to storefront_paging_nav action
*
* @hooked storefront_paging_nav - 10
*/
do_action( 'storefront_loop_after' );
else :
get_template_part( 'content', 'none' );
endif;
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
do_action( 'storefront_sidebar' );
get_footer();