Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
WordPress_SexHackMe_Plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SexHackMe
WordPress_SexHackMe_Plugin
Commits
4d3cd6ec
Commit
4d3cd6ec
authored
Jul 22, 2022
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
google drive support complete!
parent
4fce81ab
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
219 additions
and
22 deletions
+219
-22
class-integrate-google-drive.php
includes/class-integrate-google-drive.php
+85
-1
class-query.php
includes/class-query.php
+32
-11
class-video.php
includes/class-video.php
+20
-6
class-woocommerce-support.php
includes/class-woocommerce-support.php
+26
-0
functions-forms-save.php
includes/functions-forms-save.php
+29
-2
functions-utils.php
includes/functions-utils.php
+2
-0
functions-video.php
includes/functions-video.php
+13
-1
sexhackme.php
sexhackme.php
+2
-1
metabox_video.php
templates/admin/metabox_video.php
+4
-0
metabox_videotags.php
templates/admin/metabox_videotags.php
+6
-0
No files found.
includes/class-integrate-google-drive.php
View file @
4d3cd6ec
...
...
@@ -32,10 +32,94 @@ if(!class_exists('SH_GDrive')) {
function
__construct
()
{
add_filter
(
'sh_download_url_filter'
,
array
(
$this
,
'get_download_url'
));
{
}
function
get_download_url
(
$file
)
{
if
(
function_exists
(
'igd_fs'
)
)
{
// Integrate Google Drive Plugin is installed and active, so, filter it!
if
((
strlen
(
$file
)
>
9
)
&&
(
strncmp
(
$file
,
"gdrive://"
,
9
)
===
0
))
{
$gpath
=
substr
(
$file
,
9
);
if
(
strncmp
(
$gpath
,
'/'
,
1
)
===
0
)
$gpath
=
substr
(
$file
,
10
);
$gparts
=
explode
(
'/'
,
$gpath
);
if
(
count
(
$gparts
)
>
0
)
{
$parent
=
false
;
$gfile
=
false
;
$success
=
false
;
$igd
=
\IGD\App
::
instance
();
// Try root first
foreach
(
$gparts
as
$k
=>
$part
)
{
if
(
$k
==
0
)
{
$gdo
=
$igd
->
get_files
(
array
(
'q'
=>
"
{
$part
}
in name"
),
'root'
,
false
);
}
else
{
$gdo
=
$igd
->
get_files
(
array
(
'q'
=>
"name='
{
$part
}
"
),
$parent
,
false
);
}
if
(
!
is_array
(
$gdo
)
||
(
count
(
$gdo
)
<
1
)
||
array_key_exists
(
'error'
,
$gdo
))
break
;
$parent
=
false
;
foreach
(
$gdo
as
$g
)
{
if
(
$g
[
'name'
]
==
$part
)
{
$parent
=
$g
[
'id'
];
$gf
=
$g
;
}
}
if
(
!
$parent
)
break
;
if
(
count
(
$gparts
)
-
1
==
$k
)
$success
=
true
;
}
// Then try on the shared with me folder
if
(
!
$success
)
{
foreach
(
$gparts
as
$k
=>
$part
)
{
if
(
$k
==
0
)
{
$gdo
=
$igd
->
get_files
(
array
(
'q'
=>
"parents='' and sharedWithMe=true and '
{
$part
}
' in name"
),
'shared'
,
false
);
}
else
{
$gdo
=
$igd
->
get_files
(
array
(
'q'
=>
"name='
{
$part
}
"
),
$parent
,
false
);
}
sexhack_log
(
$gdo
);
if
(
!
is_array
(
$gdo
)
||
(
count
(
$gdo
)
<
1
)
||
array_key_exists
(
'error'
,
$gdo
))
break
;
$parent
=
false
;
foreach
(
$gdo
as
$g
)
{
if
(
$g
[
'name'
]
==
$part
)
{
$parent
=
$g
[
'id'
];
$gf
=
$g
;
}
}
}
}
if
(
count
(
$gparts
)
-
1
==
$k
)
$success
=
true
;
if
(
$success
)
$gfile
=
$gf
;
if
(
$gfile
&&
(
$gfile
[
'type'
]
!=
'application/vnd.google-apps.folder'
))
{
$file
=
"https://drive.google.com/open?action=igd-wc-download&id="
.
$gfile
[
'id'
];
}
}
}
}
return
$file
;
}
}
...
...
includes/class-query.php
View file @
4d3cd6ec
...
...
@@ -52,7 +52,7 @@ if(!class_exists('SH_Query')) {
if
(
is_object
(
$video
))
{
sexhack_log
(
$video
);
//
sexhack_log($video);
$fieldsarrayraw
=
$video
->
get_sql_array
();
$fieldsarray
=
array
();
$fields
=
""
;
...
...
@@ -110,9 +110,12 @@ if(!class_exists('SH_Query')) {
$updateid
=
true
;
}
do_action
(
"sh_save_video_before_query"
,
$video
);
$wpdb
->
query
(
$sql
);
if
(
$updateid
)
$video
->
id
=
$wpdb
->
insert_id
;
sexhack_log
(
$sql
);
//
sexhack_log($sql);
foreach
(
$video
->
get_categories
()
as
$cat
)
{
...
...
@@ -122,24 +125,26 @@ if(!class_exists('SH_Query')) {
(
{
$cat
->
id
}
,
{
$video
->
id
}
);
\n
"
;
}
foreach
(
$video
->
get_tags_names
()
as
$tagname
)
{
{
$tagname
=
$wpdb
->
_real_escape
(
$tagname
);
$
q
=
"INSERT IGNORE INTO
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videotags
(tag) VALUES ('
{
$tagname
}
');"
;
$wpdb
->
query
(
$q
);
$sqlarr
[]
=
"INSERT INTO
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videotags_assoc
$
tag
=
sh_get_tag_by_name
(
$tagname
,
true
);
if
(
$tag
)
{
$sqlarr
[]
=
"INSERT INTO
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videotags_assoc
(tag_id, video_id)
VALUES
((SELET id FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videotags WHERE tag='
{
$tagname
}
'),
{
$video
->
id
}
);"
;
('
{
$tag
->
id
}
', '
{
$video
->
id
}
');"
;
}
}
foreach
(
$sqlarr
as
$sql
)
{
sexhack_log
(
$sql
);
//
sexhack_log($sql);
if
(
$sql
)
$wpdb
->
query
(
$sql
);
}
do_action
(
"sh_save_video_after_query"
,
$video
);
return
$video
;
...
...
@@ -245,11 +250,27 @@ if(!class_exists('SH_Query')) {
if
(
!
$id
)
return
$dbres
;
if
(
is_array
(
$dbres
)
&&
count
(
$dbres
)
>
0
)
return
$dbres
[
0
];
}
public
static
function
get_Tag_By_Name
(
$name
,
$create
=
false
)
{
global
$wpdb
;
$sql
=
"SELECT * FROM
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videotags WHERE tag='
{
$name
}
'"
;
$res
=
$wpdb
->
get_results
(
$sql
);
if
(
is_array
(
$res
))
{
if
(
count
(
$res
)
>
0
)
return
$res
[
0
];
if
(
count
(
$res
)
==
0
&&
$create
)
{
$sql
=
"INSERT IGNORE INTO
{
$wpdb
->
prefix
}
"
.
SH_PREFIX
.
"videotags (tag) VALUES ('
{
$name
}
')"
;
$wpdb
->
query
(
$sql
);
return
SH_Query
::
get_Tag_By_Name
(
$name
);
}
}
return
false
;
}
public
static
function
get_Video_Categories
(
$vid
)
{
global
$wpdb
;
...
...
includes/class-video.php
View file @
4d3cd6ec
...
...
@@ -53,6 +53,7 @@ if(!class_exists('SH_Video')) {
'hls_premium'
=>
false
,
'thumbnail'
=>
false
,
'gif'
=>
false
,
'gif_small'
=>
false
,
'download_public'
=>
false
,
'download_members'
=>
false
,
'download_premium'
=>
false
,
...
...
@@ -128,17 +129,20 @@ if(!class_exists('SH_Video')) {
return
isset
(
$this
->
attributes
[
'key'
]);
}
public
function
get_tags
()
public
function
get_tags
(
$usedb
=
true
)
{
if
(
isset
(
$this
->
attributes
[
'tags'
]))
return
$this
->
tags
;
$tags
=
sh_get_video_tags
(
$this
->
id
);
$this
->
attributes
[
'tags'
]
=
array
();
$this
->
attributes
[
'tagsnames'
]
=
array
();
if
(
$
tags
)
if
(
$
usedb
)
{
foreach
(
$tags
as
$tag
)
{
$this
->
attributes
[
'tags'
][
$tag
->
id
]
=
$tag
;
$this
->
attributes
[
'tagsnames'
][]
=
$tag
->
tag
;
$tags
=
sh_get_video_tags
(
$this
->
id
);
if
(
$tags
)
{
foreach
(
$tags
as
$tag
)
{
$this
->
attributes
[
'tags'
][
$tag
->
id
]
=
$tag
;
$this
->
attributes
[
'tagsnames'
][]
=
$tag
->
tag
;
}
}
}
return
$this
->
tags
;
...
...
@@ -160,6 +164,16 @@ if(!class_exists('SH_Video')) {
}
public
function
add_tag
(
$tag
)
{
if
(
!
is_object
(
$tag
))
return
false
;
if
(
!
isset
(
$this
->
attributes
[
'tags'
]))
$this
->
attributes
[
'tags'
]
=
array
();
if
(
!
isset
(
$this
->
attributes
[
'tagsnames'
]))
$this
->
attributes
[
'tagsnames'
]
=
array
();
$this
->
attributes
[
'tags'
][
$tag
->
id
]
=
$tag
;
$this
->
attributes
[
'tagsnames'
][]
=
$tag
->
tag
;
return
true
;
}
public
function
get_categories
(
$usedb
=
true
)
{
if
(
isset
(
$this
->
attributes
[
'categories'
]))
return
$this
->
categories
;
...
...
includes/class-woocommerce-support.php
View file @
4d3cd6ec
...
...
@@ -24,6 +24,31 @@ namespace wp_SexHackMe;
// Exit if accessed directly
if
(
!
defined
(
'ABSPATH'
)
)
exit
;
/* Sync Video Pages and Products */
if
(
!
class_exists
(
"SH_VideoProducts"
))
{
class
SH_VideoProducts
{
public
function
__construct
()
{
add_action
(
'sh_save_video_after_query'
,
array
(
$this
,
'sync_product_from_video'
),
1
,
10
);
}
public
function
sync_product_from_video
(
$video
)
{
sexhack_log
(
"PRODUUUUUUCT"
);
sexhack_log
(
$video
);
$download
=
apply_filters
(
'sh_download_url_filter'
,
$video
->
download_public
);
sexhack_log
(
$download
);
}
}
new
SH_VideoProducts
;
}
/* Class to add Video to product page instead of image */
if
(
!
class_exists
(
'SexhackWoocommerceProductVideos'
))
{
...
...
@@ -33,6 +58,7 @@ if(!class_exists('SexhackWoocommerceProductVideos')) {
{
add_action
(
'woocommerce_before_single_product'
,
array
(
$this
,
'video_remove_default_woocommerce_image'
));
add_filter
(
'query_vars'
,
array
(
$this
,
'themeslug_query_vars'
));
}
public
function
themeslug_query_vars
(
$qvars
)
{
...
...
includes/functions-forms-save.php
View file @
4d3cd6ec
...
...
@@ -82,8 +82,8 @@ function save_sexhack_video_meta_box_data( $post_id )
sexhack_log
(
$_POST
);
// Model
if
(
array_key_exists
(
'video_model'
,
$_POST
)
&&
is_
integer
(
$_POST
[
'video_model'
])
&&
intval
(
$_POST
[
'video_model'
])
>
0
)
$video
->
model
=
intval
(
$_POST
[
'video_model'
]);
if
(
array_key_exists
(
'video_model'
,
$_POST
)
&&
is_
numeric
(
$_POST
[
'video_model'
])
&&
intval
(
$_POST
[
'video_model'
])
>
0
)
$video
->
user_id
=
intval
(
$_POST
[
'video_model'
]);
// Video description
$video
->
description
=
sanitize_text_field
(
$_POST
[
'video_description'
]
);
...
...
@@ -138,6 +138,13 @@ function save_sexhack_video_meta_box_data( $post_id )
else
$video
->
gif
=
false
;
// Small Animated gif path
if
(
array_key_exists
(
'video_gif_small'
,
$_POST
)
&&
check_url_or_path
(
sanitize_text_field
(
$_POST
[
'video_gif_small'
])))
$video
->
gif_small
=
sanitize_text_field
(
$_POST
[
'video_gif_small'
]);
else
$video
->
gif_small
=
false
;
// Differenciated content for access levels
foreach
(
array
(
'public'
,
'members'
,
'premium'
)
as
$vt
)
{
...
...
@@ -183,6 +190,26 @@ function save_sexhack_video_meta_box_data( $post_id )
// Make sure the categories array is initialized
$video
->
get_categories
(
false
);
// Video Tags
if
(
array_key_exists
(
'video_tags'
,
$_POST
)
&&
is_array
(
$_POST
[
'video_tags'
]))
{
foreach
(
$_POST
[
'video_tags'
]
as
$tag_name
)
{
$vtags
=
$video
->
get_tags
(
false
);
if
(
sanitize_text_field
(
strtolower
(
$tag_name
)))
{
$tag_name
=
sanitize_text_field
(
strtolower
(
$tag_name
));
$tag
=
sh_get_tag_by_name
(
$tag_name
,
true
);
if
(
$tag
)
$video
->
add_tag
(
$tag
);
}
}
}
// Make sure the tags array is initialized
$video
->
get_tags
(
false
);
// Save the video data in the database.
sh_save_video
(
$video
);
...
...
includes/functions-utils.php
View file @
4d3cd6ec
...
...
@@ -249,6 +249,8 @@ function check_url_or_path($url)
{
if
(
strncmp
(
$url
,
"/"
,
1
)
===
0
)
return
'path'
;
else
if
(
strncmp
(
$url
,
'gdrive://'
,
9
)
===
0
)
return
'gdrive'
;
else
if
(
filter_var
(
$url
,
FILTER_VALIDATE_URL
))
return
'uri'
;
...
...
includes/functions-video.php
View file @
4d3cd6ec
...
...
@@ -26,7 +26,14 @@ if ( ! defined( 'ABSPATH' ) ) exit;
function
sh_save_video
(
$video
)
{
return
SH_Query
::
save_Video
(
$video
);
if
(
is_object
(
$video
))
{
// Initialize categories and tags is they are not.
// Get from database active if not cached already.
$video
->
get_categories
(
true
);
$video
->
get_tags
(
true
);
return
SH_Query
::
save_Video
(
$video
);
}
return
false
;
}
function
sh_delete_video
(
$v
)
...
...
@@ -94,6 +101,11 @@ function sh_get_video_tags($v)
return
false
;
}
function
sh_get_tag_by_name
(
$name
,
$create
=
false
)
{
return
SH_Query
::
get_Tag_By_Name
(
$name
,
$create
);
}
function
sh_delete_tags_from_video
(
$v
)
{
if
(
is_numeric
(
$v
)
and
$v
>
0
)
return
SH_Query
::
delete_Tags_assoc
(
$v
,
'video_id'
);
...
...
sexhackme.php
View file @
4d3cd6ec
...
...
@@ -185,7 +185,8 @@ if(!class_exists('SexHackMe_Plugin')) {
hls_members varchar(1024) DEFAULT NULL,
hls_premium varchar(1024) DEFAULT NULL,
thumbnail varchar(1024) DEFAULT NULL,
gif varchar(1024) DEFAULT NULL,
gif varchar(256) DEFAULT NULL,
gif_small varchar(256) DEFAULT NULL,
download_public varchar(1024) DEFAULT NULL,
download_members varchar(1024) DEFAULT NULL,
download_premium varchar(1024) DEFAULT NULL,
...
...
templates/admin/metabox_video.php
View file @
4d3cd6ec
...
...
@@ -64,6 +64,10 @@ echo '<style>div#visibility.misc-pub-section.misc-pub-visibility{display:none}</
<label>
* Animated GIF (URI or PATH):
</label>
<input
type=
'text'
name=
"video_gif"
value=
'
<?php
echo
esc_attr
(
$video
->
gif
);
?>
'
/>
</p>
<p>
<label>
* small preview GIF (URI or PATH):
</label>
<input
type=
'text'
name=
"video_gif_small"
value=
'
<?php
echo
esc_attr
(
$video
->
gif_small
);
?>
'
/>
</p>
<p>
<label>
* Video preview/teaser (max 1 min)
</label>
<input
type=
'text'
name=
"video_preview"
value=
'
<?php
echo
esc_attr
(
$video
->
preview
);
?>
'
/>
...
...
templates/admin/metabox_videotags.php
View file @
4d3cd6ec
...
...
@@ -40,6 +40,12 @@ foreach($video->get_tags() as $tag)
</div>
</p>
<div
id=
"vtagsdata"
></div>
<?php
foreach
(
$video
->
get_tags
()
as
$tag
)
{
echo
" <input type='hidden' name='video_tags[]' data='"
.
$tag
->
tag
.
"' value='"
.
$tag
->
tag
.
"' />
\n
"
;
}
?>
<!--
<p class="hide-if-no-js"><button type="button" class="button-link tagcloud-link" id="link-video_tags" aria-expanded="false">Choose from the most used tags</button></p>
-->
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment