update distributed encoding system

parent 8ec403d5
......@@ -30,6 +30,10 @@
.woocommerce-form-row--last + div + p {
display: none;
}
label.wc-stripe-label-payment-type {
color: #939191 !important;
}
/*.col-full{ */
/* max-width:66%; */
/* margin-left: 0;
......
......@@ -153,7 +153,7 @@ ul.products li.sexhack_thumbli {
width:90%;
}
.sexhack_thumb_cont .sexhack_thumb_hover {
width: 90%;
width: 100%;
}
}
......
......@@ -88,10 +88,18 @@ if(!class_exists('SH_Admin')) {
register_setting('sexhackme-gallery-settings', 'sexhack_video_flat_path');
register_setting('sexhackme-gallery-settings', 'sexhack_video_vr_path');
register_setting('sexhackme-gallery-settings', 'sexhack_video_hls_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_video_hls_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_video_video_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_video_video_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_video_photo_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_video_photo_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_video_gif_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_video_gif_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_video_vr_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_video_vr_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_thumbnail_storage');
register_setting('sexhackme-gallery-settings', 'sexhack_thumbnail_uri');
register_setting('sexhackme-gallery-settings', 'sexhack_socialpost_storage');
add_action('update_option', '\wp_SexHackMe\SH_Admin::update_gallery_slug', 10, 3);
//register_setting('sexhackme-gallery-settings', 'sexhack_gallery_slug');
}
......
......@@ -50,7 +50,7 @@ if(!class_exists('SH_PostType_Video')) {
if(!is_object($post) || ($post->post_type!='sexhack_video'))
return;
//sexhack_log("STATUS CHANGE: post ".$post->ID." changed from $old to $new");
sexhack_log("STATUS CHANGE: post ".$post->ID." changed from $old to $new");
if($old===$new) return;
$video = sh_get_video_from_post($post);
......@@ -59,10 +59,10 @@ if(!class_exists('SH_PostType_Video')) {
$vold = $video->status;
if($new=='publish' && $video->status == 'ready') $video->status = 'published';
else if($new!='publish' && $video->status == 'published') $video->status = 'ready';
sexhack_log(" * video ".$video->id." is ".$video->status." (was $vold)");
//sexhack_log(" * video ".$video->id." is ".$video->status." (was $vold)");
if($vold!=$video->status) sh_save_video($video);
if($vold!=$video->status) sh_save_video($video, 'POST_TYPE');
}
}
......
......@@ -45,14 +45,15 @@ if(!class_exists('SH_Query')) {
}
public static function save_Video($video)
public static function save_Video($video, $source=false)
{
global $wpdb;
if($source) sexhack_log("save_Video called from $source");
if(is_object($video))
{
$video = apply_filters('video_before_save', $video);
//sexhack_log($video);
$fieldsarrayraw = $video->get_sql_array();
......@@ -120,7 +121,8 @@ if(!class_exists('SH_Query')) {
$wpdb->query( $sql );
if($updateid) $video->id = $wpdb->insert_id;
//sexhack_log($sql);
if($source) sexhack_log("QUERY FOR save_Video called from $source");
sexhack_log($sql);
foreach($video->get_categories() as $cat)
{
......@@ -275,7 +277,7 @@ if(!class_exists('SH_Query')) {
public static function get_VideosCat($vcat=false)
public static function get_VideosCat($vcat=false, $filtering=false)
{
global $wpdb;
......@@ -302,14 +304,21 @@ if(!class_exists('SH_Query')) {
$results = array();
//$sql = $wpdb->prepare("SELECT * from {$wpdb->prefix}{$prefix}videos");
$sql = "SELECT * FROM {$wpdb->prefix}".SH_PREFIX."videos";
if($filter) $sql .= " WHERE ".$filter."!=''";
if($filter && $filtering) $sql .= " AND ";
else if(!$filter && $filtering) $sql .= " WHERE ";
if($filtering) $sql .= " ".$filtering." ";
$dbres = $wpdb->get_results( $sql, ARRAY_A );
sexhack_log($dbres);
//sexhack_log($dbres);
foreach($dbres as $row)
{
$results[] = new SH_Video($row);
}
sexhack_log($results);
//sexhack_log($results);
return $results;
......
......@@ -127,15 +127,19 @@ if(!class_exists('SH_Shortcodes')) {
$html = "<div class='sexhack_gallery'>"; //<h3>SexHack VideoGallery</h3>";
if(isset($_GET['SHDEV'])) $html .= '<h3>DEVELOPEMENT MODE</h3>';
$html .= '<ul class="products columns-4">';
$videos = $sh_videogallery->get_videos_by_cat();
$videos = $sh_videogallery->get_videos_by_cat(filtering: "status='published' ORDER BY created DESC");
$sep=1;
foreach($videos as $video)
{
if($video->status == 'published')
{
//if($video->status == 'published')
//{
$post = $video->get_post();
if($post) setup_postdata($post);
$html .= $sh_videogallery->get_video_thumb($video);
}
if($sep==4) $html .= '<li class="product type-product sexhack_thumbli" style="width:100% !important; margin-bottom: 1px !important;"> </li>';
$sep=$sep+1;
if($sep==5) $sep=1;
//}
}
wp_reset_postdata();
$html .= "</ul></div>";
......
......@@ -46,6 +46,11 @@ if(!class_exists('SH_StoreFront')) {
// add footer disclaimer
//add_action('storefront_footer', 'wp_SexHackMe\sh_get_disclaimer')); // XXX I don't like positioning this way. Fix in CSS or sobstitute footer theme file?
// add footer navigation menu
register_nav_menu('shm-footer-menu',__( 'Sexhackme Footer Menu' ));
add_action( 'storefront_footer', 'wp_SexHackMe\SH_StoreFront::footer_menu', 15);
// Re add the cart in the right position
add_action( 'storefront_header', 'storefront_header_cart', 40);
......@@ -68,6 +73,13 @@ if(!class_exists('SH_StoreFront')) {
}
}
public static function footer_menu()
{
echo '<nav class=\'secondary-navigation\' role=\'navigation\' aria-label=\'Secondary Navigation\' >';
wp_nav_menu(array('theme_location' => 'shm-footer-menu'));
echo '</nav>';
}
public static function credits($cred)
{
return '';
......
......@@ -78,7 +78,8 @@ if(!class_exists('SH_Video')) {
'views_public' => 0,
'views_members' => 0,
'views_premium' => 0,
'sales' => 0
'sales' => 0,
'socialpost' => 0
);
public function __construct($attr=false)
{
......@@ -267,6 +268,20 @@ if(!class_exists('SH_Video')) {
}
public function user_bought_video($uid=False)
{
if(!isset($this->attributes['product_id'])) return false;
if(!$uid && get_current_user_id())
{
if(wc_customer_bought_product( '', get_current_user_id(), $this->attributes['product_id'])) return true;
}
else if($uid && intval($uid))
{
if(wc_customer_bought_product( '', $uid, $this->attributes['product_id'])) return true;
}
return false;
}
// Repopulate the object from $post or $post->ID
public function update_video_from_post($p)
{
......
......@@ -85,11 +85,11 @@ if(!class_exists('SH_VideoGallery')) {
}
}
public function get_videos_by_cat($vcat=false) {
public function get_videos_by_cat($vcat=false, $filtering=false) {
// XXX TODO Only published videos!
if(!$this->videolist && !$vcat) $this->videolist = sh_get_videos_by_cat();
else if($vcat) return sh_get_videos_by_cat($vcat);
if(!$this->videolist && !$vcat) $this->videolist = sh_get_videos_by_cat(filtering:$filtering);
else if($vcat) return sh_get_videos_by_cat($vcat, filtering:$filtering);
return $this->videolist;
......@@ -117,7 +117,7 @@ if(!class_exists('SH_VideoGallery')) {
$video_preview = $video->preview;
$gif_preview = $video->gif_small;
sexhack_log($video);
//sexhack_log($video);
$categories = $video->get_categories(true);
......
......@@ -38,6 +38,27 @@ if(!class_exists("SH_VideoProducts")) {
// fired when deleting a video
add_action('sh_delete_video', array($this, 'delete_video_product'), 9, 1);
// Add filter for download product uri fix
add_filter('woocommerce_download_product_filepath', array($this, 'fix_download_uri'));
}
public function fix_download_uri($path)
{
$vr_storage = get_option('sexhack_video_vr_storage', false);
$vr_uri = get_option('sexhack_video_vr_uri', '/VR/');
$video_storage = get_option('sexhack_video_video_storage', false);
$video_uri = get_option('sexhack_video_video_uri', '/Videos/');
$gif_storage = get_option('sexhack_video_gif_storage', false);
$gif_uri = get_option('sexhack_video_gif_uri', '/GIF/');
$photo_storage = get_option('sexhack_video_photo_storage', false);
$photo_uri = get_option('sexhack_video_photo_uri', '/Photos/');
if($vr_storage && starts_with($vr_storage, $path)) return str_replace($vr_storage, $vr_uri, $path);
if($gif_storage && starts_with($gif_storage, $path)) return str_replace($gif_storage, $gif_uri, $path);
if($video_storage && starts_with($video_storage, $path)) return str_replace($video_storage, $video_uri, $path);
if($photo_storage && starts_with($photo_storage, $path)) return str_replace($photo_storage, $photo_uri, $path);
return $path;
}
public function delete_video_product($video)
......@@ -503,4 +524,6 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) {
new SH_WooCommerce_Registration_Integration;
}
?>
......@@ -24,7 +24,7 @@ namespace wp_SexHackMe;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
function save_sexhack_video_forms( $post_id )
function save_sexhack_video_forms( $post_id)
{
// Verify that the nonce is set and valid.
......@@ -43,6 +43,10 @@ function save_sexhack_video_forms( $post_id )
// ... ant it's set to sexhack_video
if($_POST['post_type']!='sexhack_video') return;
// ... what if we are saving the wrong post?
if(get_post_type($post_id) != 'sexhack_video') return;
// Make sure we don't get caught in any loop
if($admin) unset($_POST['sh_video_description_nonce']);
if(!$admin) unset($_POST['sh_editvideo_nonce']);
......@@ -73,7 +77,11 @@ function save_sexhack_video_forms( $post_id )
}
// Get $video object
$setslug = false;
$video = sh_get_video_from_post($post_id);
if(!$video) sexhack_log("Video object not initialized, new video?? (form passed \"$post_id\" \$post_id");
if(!$video) sexhack_log($video);
if(!$video) $setslug = true;
if(!$video) $video = new SH_Video();
......@@ -87,7 +95,8 @@ function save_sexhack_video_forms( $post_id )
//
// Title and slug
$video->title = $post->post_title;
$video->slug = uniqidReal()."-".$post->post_name;
if(!$video->slug || $setslug) $video->slug = uniqidReal()."-".$post->post_name;
// TODO Remove debug
//sexhack_log("SAVE post object:");
......@@ -120,7 +129,8 @@ function save_sexhack_video_forms( $post_id )
$video->thumbnail = false;
} else {
// Shoudn't we move it somewhere?
if(isset($_POST['video_thumb'])) $video->thumbnail = get_option('sexhack_video_tmp_path', '/tmp')."/".sanitize_text_field($_POST['video_thumb']);
if(isset($_POST['video_thumb'])
&& !empty($_POST['video_thumb'])) $video->thumbnail = get_option('sexhack_video_tmp_path', '/tmp')."/".sanitize_text_field($_POST['video_thumb']);
else $video->thumbnail = false;
}
......@@ -261,6 +271,7 @@ function save_sexhack_video_forms( $post_id )
{
foreach($_POST['video_tags'] as $tag_name)
{
$tag_name = str_replace("#", "", $tag_name);
$vtags = $video->get_tags(false);
if(sanitize_text_field(strtolower($tag_name)))
{
......@@ -276,7 +287,9 @@ function save_sexhack_video_forms( $post_id )
// Save the video data in the database.
sh_save_video($video);
//sexhack_log("SAVING VIDEO FROM FORM");
//sexhack_log($video);
sh_save_video($video, 'FORM');
}
......
......@@ -81,7 +81,7 @@ function debug_rewrite_rules($matchonly=false)
}
function starts_with ($startString, $string)
function starts_with($startString, $string)
{
$len = strlen($startString);
return (substr($string, 0, $len) === $startString);
......@@ -394,4 +394,11 @@ function sh_mime_type($filename) {
}
}
function convert_filesize($bytes, $decimals = 2){
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
}
?>
......@@ -30,7 +30,7 @@ function sh_get_my_videos()
return SH_Query::get_Videos(get_current_user_id(), 'user');
}
function sh_save_video($video)
function sh_save_video($video, $source=false)
{
if(is_object($video)) {
// Initialize categories and tags is they are not.
......@@ -38,7 +38,7 @@ function sh_save_video($video)
$video->get_categories(true);
$video->get_tags(true);
$video->get_guests(true);
return SH_Query::save_Video($video);
return SH_Query::save_Video($video, $source);
}
return false;
}
......@@ -65,9 +65,21 @@ function sh_delete_video_from_product($p)
}
function sh_get_videos_by_cat($vcat=false)
function sh_get_videos_by_status($status="published")
{
return SH_Query::get_VideosCat($vcat);
if(!in_array($status, array('published', 'queue', 'creating','uploading','processing','ready','error'))) $status='published';
return sh_get_videos_by_cat(filtering: "status='$status'");
}
function sh_get_videos_by_socialpost($socialpost=0)
{
if(!is_numeric($socialpost)) return 'KO';
return sh_get_videos_by_cat(filtering: "socialpost='$socialpost' AND status='published'");
}
function sh_get_videos_by_cat($vcat=false, $filtering=false)
{
return SH_Query::get_VideosCat($vcat, $filtering);
}
function sh_get_video($id)
......
......@@ -32,7 +32,7 @@ function SexHLSPlayer(url, vuid){
hls.autoLevelEnabled = true;
//hls.loadLevel = 4;
hls.startLoad();
//vtag.play(); // XXX Autoplay doesn't work apparently atm
vtag.play(); // XXX Autoplay doesn't work apparently atm
});
//document.title = url
}
......
......@@ -19,9 +19,11 @@
*/
function SexVideoPlayer(vuid){
var vtag = videojs(vuid);
var vtag = videojs(vuid, {autoplay: true});
vtag.ready(function() {
myPlayer.volume(0.5);
vtag.play();
vtag.volume(0.5);
});
return vtag;
}
......
......@@ -212,6 +212,7 @@ if(!class_exists('SexHackMe_Plugin')) {
views_members bigint(32) NOT NULL DEFAULT '0',
views_premium bigint(32) NOT NULL DEFAULT '0',
sales bigint(32) NOT NULL DEFAULT '0',
socialpost bigint(32) NOT NULL DEFAULT '0',
PRIMARY KEY (id),
KEY user_id (user_id),
KEY post_id (post_id),
......
......@@ -106,30 +106,72 @@ if ( ! defined( 'ABSPATH' ) ) exit;
<label>Video Storage HLS</label>
<input type='text' name='sexhack_video_hls_storage' value='<?php echo get_option('sexhack_video_hls_storage', ABSPATH.'HLS'); ?>'>
</td>
<td>
<label>Video URI HLS</label>
<input type='text' name='sexhack_video_hls_uri' value='<?php echo get_option('sexhack_video_hls_uri', '/HLS/'); ?>'>
</td>
</tr>
<tr>
<td>
<label>Video Storage Video</label>
<input type='text' name='sexhack_video_video_storage' value='<?php echo get_option('sexhack_video_video_storage', ABSPATH.'Videos'); ?>'>
</td>
<td>
<label>Video URI Video</label>
<input type='text' name='sexhack_video_video_uri' value='<?php echo get_option('sexhack_video_video_uri', '/Videos/'); ?>'>
</td>
</tr>
<tr>
<td>
<label>Video Storage Photo</label>
<input type='text' name='sexhack_video_photo_storage' value='<?php echo get_option('sexhack_video_photo_storage', ABSPATH.'Photos'); ?>'>
</td>
<td>
<label>Video URI Photo</label>
<input type='text' name='sexhack_video_photo_uri' value='<?php echo get_option('sexhack_video_photo_uri', '/Photos/'); ?>'>
</td>
</tr>
<tr>
<td>
<label>Video Storage GIF</label>
<input type='text' name='sexhack_video_gif_storage' value='<?php echo get_option('sexhack_video_gif_storage', ABSPATH.'GIF'); ?>'>
</td>
<td>
<label>Video URI GIF</label>
<input type='text' name='sexhack_video_gif_uri' value='<?php echo get_option('sexhack_video_gif_uri', '/GIF/'); ?>'>
</td>
</tr>
<tr>
<td>
<label>Video Storage VR</label>
<input type='text' name='sexhack_video_vr_storage' value='<?php echo get_option('sexhack_video_vr_storage', ABSPATH.'VR'); ?>'>
</td>
<td>
<label>Video URI VR</label>
<input type='text' name='sexhack_video_vr_uri' value='<?php echo get_option('sexhack_video_vr_uri', '/VR/'); ?>'>
</td>
</tr>
<tr>
<td>
<label>Thumbnail Storage</label>
<input type='text' name='sexhack_thumbnail_storage' value='<?php echo get_option('sexhack_thumbnail_storage', ABSPATH.'Thumbs'); ?>'>
</td>
<td>
<label>Thumbnail URI</label>
<input type='text' name='sexhack_thumbnail_uri' value='<?php echo get_option('sexhack_thumbnail_uri', '/Thumbs/'); ?>'>
</td>
</tr>
<tr>
<td>
<label>Social Post Storage</label>
<input type='text' name='sexhack_socialpost_storage' value='<?php echo get_option('sexhack_socialpost_storage', ABSPATH.'SOCIALPOSTS'); ?>'>
</td>
</tr>
......
......@@ -117,7 +117,7 @@ foreach(array('public','members','premium') as $level) { ?>
<p>
<label> Include in Download?</label>
<input type='radio' name='video_isdownload_<?php echo $level; ?>' value='Y' <?php if($video->has_downloads($level)) echo "checked"; ?>>Yes</input>
<input type='radio' name='video_isdownload <?php echo $level; ?>' value='N' <?php if(!$video->has_downloads($level)) echo "checked"; ?>>No</input>
<input type='radio' name='video_isdownload_<?php echo $level; ?>' value='N' <?php if(!$video->has_downloads($level)) echo "checked"; ?>>No</input>
</p>
</p>
<?php
......@@ -393,8 +393,9 @@ jQuery(function($) {
foreach(array('public','members','premium','preview','thumb','gif','gif_small') as $level) { ?>
var flow_<?php echo $level; ?> = new Flow({
target: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
chunkSize: 1024*1024, // 1MB
chunkSize: 1024*1024*8, // 8MB
uploadMethod:'POST',
simultaneousUploads: 4,
testChunks:false,
query:{action:'file_upload', uniqid:'<?php echo $uniqid ?>', security:'<?php echo wp_create_nonce( 'sh_video_upload');?>', level:'<?php echo $level; ?>'},
singleFile: true
......
......@@ -119,7 +119,7 @@ get_header(); ?>
}
else
{
if(user_has_premium_access()) {
if(user_has_premium_access() || $video->user_bought_video()) {
if($hls_premium) $tab = 'subscribers';
elseif($hls_members) $tab = 'members';
else $tab = 'public';
......@@ -151,7 +151,7 @@ get_header(); ?>
{
case "members":
if(user_has_member_access())
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."\"]" );
......@@ -167,13 +167,13 @@ get_header(); ?>
{
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>';
echo "<h3 class='sexhack-videonotify'><a href='/login'>YOU NEED TO LOGIN TO ACCESS THIS VIDEO</a></h3>";
echo "<h3 class='sexhack-videonotify'><a href='/login'>YOU NEED FREE MEMBER, PREMUM LOGIN or BUY DOWLOAD TO ACCESS THIS VIDEO</a></h3>";
echo "<div style='width: 80%; margin-left: 10%;' >".do_shortcode('[pms-login redirect_url="/account" ]')."</div>";
}
break;
case "subscribers":
if(user_has_premium_access())
if(user_has_premium_access() || $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."\"]" );
......@@ -190,7 +190,7 @@ get_header(); ?>
{
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>';
echo "<h3 class='sexhack-videonotify'><a href='/product-category/subscriptions/'>YOU NEED A SUBSCRIPTION TO ACCESS THIS VIDEO</a></h3>";
echo "<h3 class='sexhack-videonotify'><a href='/product-category/subscriptions/'>YOU NEED A SUBSCRIPTION OR BUY DOWNLOAD TO ACCESS THIS VIDEO</a></h3>";
}
break;
......@@ -221,6 +221,19 @@ get_header(); ?>
?>
<h2 class='sexhack-videonotify'><b>PUBLIC VIDEO NOT AVAILABLE</b></h2>
<?php
/*
if($hls_members) {
?>
<h3><a href="">members version here!</a></h3>
<?php
}
if($hls_premium) {
?>
<h3><a href="">Premium users version here!</a></h3>
<?php
}
*/
}
?>
</div> <!-- video container -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment