Add base template for gdrive

parent d1bb18dd
<?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;
if(!class_exists('SH_GDrive')) {
class SH_GDrive
{
function __construct()
{
add_filter('sh_download_url_filter', array($this, 'get_download_url'));
{
function get_download_url($file)
{
return $file;
}
}
new SH_Gdrive;
}
?>
...@@ -51,6 +51,8 @@ if(!class_exists('SH_Query')) { ...@@ -51,6 +51,8 @@ if(!class_exists('SH_Query')) {
if(is_object($video)) if(is_object($video))
{ {
sexhack_log($video);
$fieldsarrayraw = $video->get_sql_array(); $fieldsarrayraw = $video->get_sql_array();
$fieldsarray = array(); $fieldsarray = array();
$fields = ""; $fields = "";
...@@ -240,7 +242,11 @@ if(!class_exists('SH_Query')) { ...@@ -240,7 +242,11 @@ if(!class_exists('SH_Query')) {
if($id && is_numeric($id)) if($id && is_numeric($id))
$sql .= " WHERE id='".intval($id)."'"; $sql .= " WHERE id='".intval($id)."'";
$dbres = $wpdb->get_results( $sql ); $dbres = $wpdb->get_results( $sql );
return $dbres;
if(!$id) return $dbres;
if(is_array($dbres) && count($dbres) > 0) return $dbres[0];
} }
......
...@@ -132,18 +132,14 @@ if(!class_exists('SH_Video')) { ...@@ -132,18 +132,14 @@ if(!class_exists('SH_Video')) {
{ {
if(isset($this->attributes['tags'])) return $this->tags; if(isset($this->attributes['tags'])) return $this->tags;
$tags = sh_get_video_tags($this->id); $tags = sh_get_video_tags($this->id);
$this->tags = array(); $this->attributes['tags'] = array();
$this->tagsnames = array(); $this->attributes['tagsnames'] = array();
$tags_indexed = array();
$tagsnames = array();
if($tags) if($tags)
{ {
foreach($tags as $tag) { foreach($tags as $tag) {
$tags_indexed[$tag->id] = $tag; $this->attributes['tags'][$tag->id] = $tag;
$tagsnames[] = $tag->tag; $this->attributes['tagsnames'][] = $tag->tag;
} }
$this->tags = $tags_indexed;
$this->tagsnames = $tagsnames;
} }
return $this->tags; return $this->tags;
} }
...@@ -155,17 +151,27 @@ if(!class_exists('SH_Video')) { ...@@ -155,17 +151,27 @@ if(!class_exists('SH_Video')) {
return $this->tagsnames; return $this->tagsnames;
} }
public function get_categories() public function add_category($cat)
{
if(!is_object($cat)) return false;
if(!isset($this->attributes['categories'])) $this->attributes['categories'] = array();
$this->attributes['categories'][$cat->id] = $cat;
return true;
}
public function get_categories($usedb=true)
{ {
if(isset($this->attributes['categories'])) return $this->categories; if(isset($this->attributes['categories'])) return $this->categories;
$cats = sh_get_video_categories($this->id); $this->attributes['categories'] = array();
$this->categories = array(); if($usedb)
$cats_indexed = array();
if($cats)
{ {
foreach($cats as $cat) $cats = sh_get_video_categories($this->id);
$cats_indexed[$cat->id] = $cat; if($cats)
$this->categories = $cats_indexed; {
foreach($cats as $cat)
$this->attributes['categories'][$cat->id] = $cat;
}
} }
return $this->categories; return $this->categories;
} }
...@@ -218,7 +224,9 @@ if(!class_exists('SH_Video')) { ...@@ -218,7 +224,9 @@ if(!class_exists('SH_Video')) {
$r = array(); $r = array();
foreach($this->attributes as $k => $v) foreach($this->attributes as $k => $v)
{ {
if(($v) && !in_array($k, array('id', 'post', 'product', 'tags','categories', 'tagsnames')) ) $r[$k] = $v; if(($v!==false) && !in_array($k, array('id','post','product','tags',
'categories','tagsnames','created','updated','sells',
'views_public','views_members','views_premium')) ) $r[$k] = $v;
} }
return $r; return $r;
} }
......
...@@ -86,8 +86,7 @@ function save_sexhack_video_meta_box_data( $post_id ) ...@@ -86,8 +86,7 @@ function save_sexhack_video_meta_box_data( $post_id )
$video->model = intval($_POST['video_model']); $video->model = intval($_POST['video_model']);
// Video description // Video description
if(array_key_exists('video_description', $_POST) && sanitize_text_field($_POST['video_description'])) $video->description = sanitize_text_field( $_POST['video_description'] );
$video->description = sanitize_text_field( $_POST['video_description'] );
// Video thumbnail // Video thumbnail
if(array_key_exists('video_thumbnail', $_POST) && sanitize_text_field($_POST['video_thumbnail'])) if(array_key_exists('video_thumbnail', $_POST) && sanitize_text_field($_POST['video_thumbnail']))
...@@ -112,11 +111,12 @@ function save_sexhack_video_meta_box_data( $post_id ) ...@@ -112,11 +111,12 @@ function save_sexhack_video_meta_box_data( $post_id )
// Video visible // Video visible
if(array_key_exists('video_visible', $_POST) && in_array($_POST['video_visible'], array('Y','N'))) if(array_key_exists('video_visible', $_POST) && in_array($_POST['video_visible'], array('Y','N')))
$video->private = $_POST['video_visible']; $video->visible = $_POST['video_visible'];
// Video price // Video price
if(array_key_exists('video_price', $_POST) && is_numeric($_POST['video_price']) && (floatval($_POST['video_price']) > 0)) if(array_key_exists('video_price', $_POST) && is_numeric($_POST['video_price']) && (floatval($_POST['video_price']) >= 0))
$video->price = floatval($_POST['video_price']); $video->price = floatval($_POST['video_price']);
else $video->price = 0;
// Video type // Video type
if(array_key_exists('video_type', $_POST) && in_array($_POST['video_type'], array('VR', 'FLAT'))) if(array_key_exists('video_type', $_POST) && in_array($_POST['video_type'], array('VR', 'FLAT')))
...@@ -128,11 +128,15 @@ function save_sexhack_video_meta_box_data( $post_id ) ...@@ -128,11 +128,15 @@ function save_sexhack_video_meta_box_data( $post_id )
// Preview video // Preview video
if(array_key_exists('video_preview', $_POST) && check_url_or_path(sanitize_text_field($_POST['video_preview']))) if(array_key_exists('video_preview', $_POST) && check_url_or_path(sanitize_text_field($_POST['video_preview'])))
$video->preview = sanitize_text_field($_POST['video_preview']); $video->preview = sanitize_text_field($_POST['video_preview']);
else
$video->preview = false;
// Animated gif path // Animated gif path
if(array_key_exists('video_gif', $_POST) && check_url_or_path(sanitize_text_field($_POST['video_gif']))) if(array_key_exists('video_gif', $_POST) && check_url_or_path(sanitize_text_field($_POST['video_gif'])))
$video->gif = sanitize_text_field($_POST['video_gif']); $video->gif = sanitize_text_field($_POST['video_gif']);
else
$video->gif = false;
// Differenciated content for access levels // Differenciated content for access levels
foreach(array('public','members','premium') as $vt) foreach(array('public','members','premium') as $vt)
...@@ -143,14 +147,14 @@ function save_sexhack_video_meta_box_data( $post_id ) ...@@ -143,14 +147,14 @@ function save_sexhack_video_meta_box_data( $post_id )
(strncasecmp(strrev(sanitize_text_field($_POST['video_hls_'.$vt])), '8u3m', 4) === 0)) (strncasecmp(strrev(sanitize_text_field($_POST['video_hls_'.$vt])), '8u3m', 4) === 0))
{ {
$video->__set('hls_'.$vt, sanitize_text_field($_POST['video_hls_'.$vt])); $video->__set('hls_'.$vt, sanitize_text_field($_POST['video_hls_'.$vt]));
} } else $video->__set('hls_'.$vt, false);
// Download // Download
if(array_key_exists('video_download_'.$vt, $_POST) && if(array_key_exists('video_download_'.$vt, $_POST) &&
check_url_or_path(sanitize_text_field($_POST['video_download_'.$vt]))) check_url_or_path(sanitize_text_field($_POST['video_download_'.$vt])))
{ {
$video->__set('download_'.$vt, sanitize_text_field($_POST['video_download_'.$vt])); $video->__set('download_'.$vt, sanitize_text_field($_POST['video_download_'.$vt]));
} } else $video->__set('download_'.$vt, false);
// Text only data // Text only data
foreach(array('size','format','codec','acodec','duration','resolution') as $key) foreach(array('size','format','codec','acodec','duration','resolution') as $key)
...@@ -159,11 +163,26 @@ function save_sexhack_video_meta_box_data( $post_id ) ...@@ -159,11 +163,26 @@ function save_sexhack_video_meta_box_data( $post_id )
sanitize_text_field($_POST['video_'.$key.'_'.$vt])) sanitize_text_field($_POST['video_'.$key.'_'.$vt]))
{ {
$video->__set($key.'_'.$vt, sanitize_text_field($_POST['video_'.$key.'_'.$vt])); $video->__set($key.'_'.$vt, sanitize_text_field($_POST['video_'.$key.'_'.$vt]));
} } else $video->__set($key.'_'.$vt, false);
} }
} }
// Video Categories
if(array_key_exists('vcategory', $_POST) && is_array($_POST['vcategory']))
{
foreach($_POST['vcategory'] as $cat_id)
{
if(is_numeric($cat_id) && intval($cat_id) > 0)
{
$cat = sh_get_categories(intval($cat_id));
if($cat) $video->add_category($cat);
}
}
}
// Make sure the categories array is initialized
$video->get_categories(false);
// Save the video data in the database. // Save the video data in the database.
sh_save_video($video); sh_save_video($video);
......
...@@ -394,6 +394,9 @@ if(!class_exists('SexHackMe_Plugin')) { ...@@ -394,6 +394,9 @@ if(!class_exists('SexHackMe_Plugin')) {
/* Unlock integration class */ /* Unlock integration class */
$this->file_include('includes/class-unlock-support.php'); $this->file_include('includes/class-unlock-support.php');
/* integrate google drive plugin database support */
$this->file_include('includes/class-integrate-google-drive.php');
/* Video */ /* Video */
$this->file_include('includes/class-video.php'); $this->file_include('includes/class-video.php');
$this->file_include('includes/functions-video.php'); $this->file_include('includes/functions-video.php');
......
...@@ -58,15 +58,15 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</ ...@@ -58,15 +58,15 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</
<h4>Preview</h4> <h4>Preview</h4>
<p> <p>
<label> * Thumbnail (URI,PATH or thumbail ID):</label> <label> * Thumbnail (URI,PATH or thumbail ID):</label>
<input type='text' nane="video_thumbnail" value='<?php echo esc_attr( $video->thumbnail ); ?>' > (Override featured image)</input> <input type='text' name="video_thumbnail" value='<?php echo esc_attr( $video->thumbnail ); ?>' > (Override featured image)</input>
</p> </p>
<p> <p>
<label> * Animated GIF (URI or PATH):</label> <label> * Animated GIF (URI or PATH):</label>
<input type='text' nane="video_gif" value='<?php echo esc_attr( $video->gif ); ?>' /> <input type='text' name="video_gif" value='<?php echo esc_attr( $video->gif ); ?>' />
</p> </p>
<p> <p>
<label> * Video preview/teaser (max 1 min)</label> <label> * Video preview/teaser (max 1 min)</label>
<input type='text' nane="video_preview" value='<?php echo esc_attr( $video->preview ); ?>' /> <input type='text' name="video_preview" value='<?php echo esc_attr( $video->preview ); ?>' />
<p> <p>
</p> </p>
...@@ -80,8 +80,8 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</ ...@@ -80,8 +80,8 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</
<p> <p>
<label> * VR Projection</label> <label> * VR Projection</label>
<select name='video_vr_projection'> <select name='video_vr_projection'>
<option value='VR180_LR' <?php if($video->video_vr_projection=='VR180_LR') echo "selected"; ?>>Equirectangular 180 LR</option> <option value='VR180_LR' <?php if($video->vr_projection=='VR180_LR') echo "selected"; ?>>Equirectangular 180 LR</option>
<option value='VR360_LR' <?php if($video->video_vr_projection=='VR360_LR') echo "selected"; ?>>Equirectangular 360 LR</option> <option value='VR360_LR' <?php if($video->vr_projection=='VR360_LR') echo "selected"; ?>>Equirectangular 360 LR</option>
</select> </select>
<label>(ignored for non VR videos)</option> <label>(ignored for non VR videos)</option>
</p> </p>
...@@ -89,7 +89,7 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</ ...@@ -89,7 +89,7 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</
<p> <p>
<h4>Price:</h4> <h4>Price:</h4>
<label>USD:</label> <label>USD:</label>
<input type='text' nane="video_price" value='<?php echo esc_attr( $video->price ); ?>' /> <input type='text' name="video_price" value='<?php echo esc_attr( $video->price ); ?>' />
</p> </p>
<p> <p>
<?php <?php
...@@ -119,35 +119,35 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</ ...@@ -119,35 +119,35 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</
<h4> <?php echo ucfirst($vt); ?> files</h4> <h4> <?php echo ucfirst($vt); ?> files</h4>
<p> <p>
<label> * Download (URI or PATH):</label> <label> * Download (URI or PATH):</label>
<input type='text' nane="video_download_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtdown) ); ?>' /> <input type='text' name="video_download_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtdown) ); ?>' />
</p> </p>
</p> </p>
<label> * HLS playlist (URI or PATH):</label> <label> * HLS playlist (URI or PATH):</label>
<input type='text' nane="video_hls_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vthls ) ); ?>' /> <input type='text' name="video_hls_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vthls ) ); ?>' />
</p> </p>
</p> </p>
<label> * Duration:</label> <label> * Duration:</label>
<input type='text' nane="video_duration_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtduration ) ); ?>' /> <input type='text' name="video_duration_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtduration ) ); ?>' />
</p> </p>
</p> </p>
<label> * File size:</label> <label> * File size:</label>
<input type='text' nane="video_size_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtsize ) ); ?>' /> <input type='text' name="video_size_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtsize ) ); ?>' />
</p> </p>
</p> </p>
<label> * Resolution:</label> <label> * Resolution:</label>
<input type='text' nane="video_resolution_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtresolution ) ); ?>' /> <input type='text' name="video_resolution_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtresolution ) ); ?>' />
</p> </p>
</p> </p>
<label> * Format:</label> <label> * Format:</label>
<input type='text' nane="video_format_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtformat ) ); ?>' /> <input type='text' name="video_format_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtformat ) ); ?>' />
</p> </p>
</p> </p>
<label> * Codec:</label> <label> * Codec:</label>
<input type='text' nane="video_codec_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtcodec ) ); ?>' /> <input type='text' name="video_codec_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtcodec ) ); ?>' />
</p> </p>
</p> </p>
<label> * Audio codec:</label> <label> * Audio codec:</label>
<input type='text' nane="video_acodec_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtacodec ) ); ?>' /> <input type='text' name="video_acodec_<?php echo $vt;?>" value='<?php echo esc_attr( $video->__get($vtacodec ) ); ?>' />
</p> </p>
</div> </div>
......
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