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
0d013e59
Commit
0d013e59
authored
Jul 19, 2023
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload video ready!
parent
0f6a4251
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
122 additions
and
46 deletions
+122
-46
class-post_types.php
includes/class-post_types.php
+15
-1
class-query.php
includes/class-query.php
+1
-1
class-shortcodes.php
includes/class-shortcodes.php
+1
-0
class-video-upload.php
includes/class-video-upload.php
+5
-8
class-video.php
includes/class-video.php
+1
-1
class-woocommerce-support.php
includes/class-woocommerce-support.php
+22
-5
functions-forms-save.php
includes/functions-forms-save.php
+43
-20
metabox_video.php
templates/admin/metabox_video.php
+1
-0
new_video.php
templates/new_video.php
+33
-10
No files found.
includes/class-post_types.php
View file @
0d013e59
...
...
@@ -65,6 +65,7 @@ if(!class_exists('SH_PostTypes')) {
// Devo pero' verificare le varie taxonomy e attributi della pagina, vedere come creare un prodotto in wordpress
// per ogni pagina sexhack_video che credo, sincronizzare prodotti e video pagine, gestire prodotti con lo stesso nome
// ( credo si possa fare dandogli differenti slugs )
register_post_type
(
'sexhack_video'
,
array
(
'labels'
=>
array
(
'name'
=>
'Videos'
,
...
...
@@ -95,7 +96,20 @@ if(!class_exists('SH_PostTypes')) {
'taxonomies'
=>
array
(),
//'category','post_tag'), // TODO Shouldn't we have a "video_type" taxonomy for VR or flat?
));
$statuses
=
array
(
'creating'
,
'uploading'
,
'queue'
,
'processing'
,
'ready'
,
'published'
,
'error'
);
foreach
(
$statuses
as
$status
)
{
register_post_status
(
$status
,
array
(
'label'
=>
$status
,
'public'
=>
true
,
'label_count'
=>
_n_noop
(
$status
.
' <span class="count">(%s)</span>'
,
$status
.
' <span class="count">(%s)</span>'
,
'sexhackme-domain'
),
'post_type'
=>
array
(
'sexhack_video'
),
// Define one or more post types the status can be applied to.
'show_in_admin_all_list'
=>
true
,
'show_in_admin_status_list'
=>
true
,
'show_in_metabox_dropdown'
=>
true
,
'show_in_inline_dropdown'
=>
true
,
'dashicon'
=>
'dashicons-businessman'
,
));
}
$rules
=
$wp_rewrite
->
wp_rewrite_rules
();
$DEFAULTSLUG
=
get_option
(
'sexhack_gallery_slug'
,
'v'
);
...
...
includes/class-query.php
View file @
0d013e59
...
...
@@ -359,7 +359,7 @@ if(!class_exists('SH_Query')) {
foreach
(
$dbres
as
$ures
)
{
$udata
=
get_userdata
(
$ures
->
user_id
);
if
(
$udata
)
$guests
[
$uid
]
=
$udata
;
if
(
$udata
)
$guests
[
$u
res
->
user_
id
]
=
$udata
;
}
}
if
(
count
(
$guests
)
>
0
)
return
$guests
;
...
...
includes/class-shortcodes.php
View file @
0d013e59
...
...
@@ -178,6 +178,7 @@ if(!class_exists('SH_Shortcodes')) {
"page"
=>
''
,
'level'
=>
'public'
,
),
$attr
));
if
(
!
array_key_exists
(
'level'
,
$attr
))
$attr
[
'level'
]
=
'public'
;
if
((
$attr
[
'level'
]
==
'guestonly'
&&
!
is_user_logged_in
())
||
(
$attr
[
'level'
]
==
'public'
or
!
$attr
[
'level'
])
||
(
is_user_logged_in
()
&&
(
$attr
[
'level'
]
==
'members'
||
(
$attr
[
'level'
]
==
'premium'
&&
user_is_premium
()))))
{
$ipost
=
get_post
(
$attr
[
'page'
]);
...
...
includes/class-video-upload.php
View file @
0d013e59
...
...
@@ -48,11 +48,11 @@ if(!class_exists('SH_VideoUpload')) {
$config
=
new
\Flow\Config
();
$config
->
setTempDir
(
"/tmp"
);
$request
=
new
\Flow\Request
();
if
(
isset
(
$_POST
[
'uniqid'
]))
$uniqid
=
$_POST
[
'uniqid'
]
;
if
(
isset
(
$_POST
[
'uniqid'
]))
$uniqid
=
sanitize_text_field
(
$_POST
[
'uniqid'
])
;
else
$uniqid
=
uniqid
();
$uploadFolder
=
get_option
(
'sexhack_video_tmp_path'
,
'/tmp'
);
$uploadFileName
=
$uniqid
.
"_"
.
$request
->
getFileName
(
);
$uploadFileName
=
$uniqid
.
"_"
.
sanitize_text_field
(
$request
->
getFileName
()
);
$uploadPath
=
$uploadFolder
.
"/"
.
$uploadFileName
;
if
(
\Flow\Basic
::
save
(
$uploadPath
,
$config
,
$request
))
{
...
...
@@ -72,13 +72,10 @@ if(!class_exists('SH_VideoUpload')) {
public
function
edit_video_callback
()
{
sexhack_log
(
"PORCODIOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
);
sexhack_log
(
$_POST
);
sexhack_log
(
$_GET
);
// XXX Sanitize $_POST['title']
//sexhack_log($_POST);
//sexhack_log($_GET);
if
(
!
isset
(
$_POST
[
'title'
]))
return
;
$title
=
$_POST
[
'title'
]
;
$title
=
sanitize_text_field
(
$_POST
[
'title'
])
;
$post_id
=
wp_insert_post
(
array
(
'post_type'
=>
'sexhack_video'
,
...
...
includes/class-video.php
View file @
0d013e59
...
...
@@ -216,7 +216,7 @@ if(!class_exists('SH_Video')) {
if
(
$guests
)
{
foreach
(
$guests
as
$guest
)
$this
->
attributes
[
'guests'
][
$guest
->
ID
]
=
$
ca
t
;
$this
->
attributes
[
'guests'
][
$guest
->
ID
]
=
$
gues
t
;
}
}
...
...
includes/class-woocommerce-support.php
View file @
0d013e59
...
...
@@ -142,11 +142,19 @@ if(!class_exists("SH_VideoProducts")) {
$prod
->
set_downloads
(
$wcdowns
);
// Categories. If not configured try to search
// for a category named "Video", if not present
// just take the last one in list, if no categories
// exists just don't set anything and will remain in
// Uncategorized.
// Categories.
// XXX We don't access categories of products, so, just put them in "videos"
/*
$catsids = array();
if(count($video->get_categories(false)) > 0)
{
$cats = array();
foreach($video->get_categories(false) as $cat) {
$cats[$cat->id] = $cat->category;
}
wp_set_object_terms($prod->get_id(),$cats, 'product_cat');
}
*/
$cat_id
=
get_option
(
'sexhack_wcpms-prodcat'
,
false
);
if
(
$cat_id
)
$prod
->
set_category_ids
(
array
(
$cat_id
));
else
{
...
...
@@ -158,7 +166,16 @@ if(!class_exists("SH_VideoProducts")) {
if
(
$cat
)
$prod
->
set_category_ids
(
array
(
$cat
->
term_id
));
}
// Sync tags with Video
if
(
count
(
$video
->
get_tags
(
false
))
>
0
)
{
$tags
=
array
();
foreach
(
$video
->
get_tags
(
false
)
as
$tag
)
{
$tags
[
$tag
->
id
]
=
$tag
->
tag
;
}
wp_set_object_terms
(
$prod
->
get_id
(),
$tags
,
'product_tag'
);
}
// Save the product
$prod
->
save
();
$video
->
product_id
=
$prod
->
get_id
();
...
...
includes/functions-forms-save.php
View file @
0d013e59
...
...
@@ -120,7 +120,7 @@ function save_sexhack_video_forms( $post_id )
$video
->
thumbnail
=
false
;
}
else
{
// Shoudn't we move it somewhere?
if
(
isset
(
$_POST
[
'
filename_thumb'
]))
$video
->
thumbnail
=
sanitize_text_field
(
$_POST
[
'filename
_thumb'
]);
if
(
isset
(
$_POST
[
'
video_thumb'
]))
$video
->
thumbnail
=
get_option
(
'sexhack_video_tmp_path'
,
'/tmp'
)
.
"/"
.
sanitize_text_field
(
$_POST
[
'video
_thumb'
]);
else
$video
->
thumbnail
=
false
;
}
...
...
@@ -128,6 +128,7 @@ function save_sexhack_video_forms( $post_id )
$validstatuses
=
array
(
'creating'
,
'uploading'
,
'queue'
,
'processing'
,
'ready'
,
'published'
,
'error'
);
if
(
array_key_exists
(
'video_status'
,
$_POST
)
&&
in_array
(
sanitize_text_field
(
$_POST
[
'video_status'
]),
$validstatuses
))
$video
->
status
=
sanitize_text_field
(
$_POST
[
'video_status'
]);
else
if
(
!
$admin
)
$video
->
status
=
get_post_status
(
$post_id
);
// Video private
if
(
array_key_exists
(
'video_private'
,
$_POST
)
&&
in_array
(
$_POST
[
'video_private'
],
array
(
'Y'
,
'N'
)))
...
...
@@ -150,53 +151,73 @@ function save_sexhack_video_forms( $post_id )
if
(
array_key_exists
(
'video_vr_projection'
,
$_POST
)
&&
in_array
(
$_POST
[
'video_vr_projection'
],
array
(
'VR180_LR'
,
'VR360_LR'
)))
$video
->
vr_projection
=
$_POST
[
'video_vr_projection'
];
// XXX Arrivato qui
// Preview video
if
(
array_key_exists
(
'video_preview'
,
$_POST
)
&&
check_url_or_path
(
sanitize_text_field
(
$_POST
[
'video_preview'
])))
if
(
$admin
&&
array_key_exists
(
'video_preview'
,
$_POST
)
&&
check_url_or_path
(
sanitize_text_field
(
$_POST
[
'video_preview'
])))
$video
->
preview
=
sanitize_text_field
(
$_POST
[
'video_preview'
]);
elseif
(
!
$admin
&&
array_key_exists
(
'video_preview'
,
$_POST
)
&&
sanitize_text_field
(
$_POST
[
'video_preview'
]))
$video
->
preview
=
sanitize_text_field
(
get_option
(
'sexhack_video_tmp_path'
,
'/tmp'
)
.
"/"
.
$_POST
[
'video_preview'
]);
else
$video
->
preview
=
false
;
// Animated gif path
if
(
array_key_exists
(
'video_gif'
,
$_POST
)
&&
check_url_or_path
(
sanitize_text_field
(
$_POST
[
'video_gif'
])))
if
(
$admin
&&
array_key_exists
(
'video_gif'
,
$_POST
)
&&
check_url_or_path
(
sanitize_text_field
(
$_POST
[
'video_gif'
])))
$video
->
gif
=
sanitize_text_field
(
$_POST
[
'video_gif'
]);
elseif
(
!
$admin
&&
array_key_exists
(
'video_gif'
,
$_POST
)
&&
sanitize_text_field
(
$_POST
[
'video_gif'
]))
$video
->
gif
=
sanitize_text_field
(
get_option
(
'sexhack_video_tmp_path'
,
'/tmp'
)
.
"/"
.
$_POST
[
'video_gif'
]);
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'
])))
if
(
$admin
&&
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'
]);
elseif
(
!
$admin
&&
array_key_exists
(
'video_gif_small'
,
$_POST
)
&&
sanitize_text_field
(
$_POST
[
'video_gif_small'
]))
$video
->
gif_small
=
sanitize_text_field
(
get_option
(
'sexhack_video_tmp_path'
,
'/tmp'
)
.
"/"
.
$_POST
[
'video_gif_small'
]);
else
$video
->
gif_small
=
false
;
// Differenciated content for access levels
foreach
(
array
(
'public'
,
'members'
,
'premium'
)
as
$vt
)
{
{
// HLS playlist
if
(
array_key_exists
(
'video_hls_'
.
$vt
,
$_POST
)
&&
if
(
$admin
&&
array_key_exists
(
'video_hls_'
.
$vt
,
$_POST
)
&&
check_url_or_path
(
sanitize_text_field
(
$_POST
[
'video_hls_'
.
$vt
]))
&&
(
strncasecmp
(
strrev
(
sanitize_text_field
(
$_POST
[
'video_hls_'
.
$vt
])),
'8u3m'
,
4
)
===
0
))
{
$video
->
__set
(
'hls_'
.
$vt
,
sanitize_text_field
(
$_POST
[
'video_hls_'
.
$vt
]));
}
else
$video
->
__set
(
'hls_'
.
$vt
,
false
);
}
else
if
(
!
$admin
&&
array_key_exists
(
'video_'
.
$vt
,
$_POST
)
&&
sanitize_text_field
(
$_POST
[
'video_'
.
$vt
]))
{
$video
->
__set
(
'hls_'
.
$vt
,
get_option
(
'sexhack_video_tmp_path'
,
'/tmp'
)
.
"/"
.
sanitize_text_field
(
$_POST
[
'video_'
.
$vt
]));
}
else
$video
->
__set
(
'hls_'
.
$vt
,
false
);
// Download
if
(
array_key_exists
(
'video_download_'
.
$vt
,
$_POST
)
&&
if
(
$admin
&&
array_key_exists
(
'video_download_'
.
$vt
,
$_POST
)
&&
check_url_or_path
(
sanitize_text_field
(
$_POST
[
'video_download_'
.
$vt
])))
{
$video
->
__set
(
'download_'
.
$vt
,
sanitize_text_field
(
$_POST
[
'video_download_'
.
$vt
]));
}
else
$video
->
__set
(
'download_'
.
$vt
,
false
);
}
else
if
(
!
$admin
&&
array_key_exists
(
$vt
.
'_isdownload'
,
$_POST
)
&&
in_array
(
$_POST
[
$vt
.
'_isdownload'
],
array
(
'Y'
,
'N'
))
&&
array_key_exists
(
'video_'
.
$vt
,
$_POST
)
&&
sanitize_text_field
(
$_POST
[
'video_'
.
$vt
]))
$video
->
__set
(
'download_'
.
$vt
,
get_option
(
'sexhack_video_tmp_path'
,
'/tmp'
)
.
"/"
.
sanitize_text_field
(
$_POST
[
'video_'
.
$vt
]));
else
$video
->
__set
(
'download_'
.
$vt
,
false
);
// Text only data
foreach
(
array
(
'size'
,
'format'
,
'codec'
,
'acodec'
,
'duration'
,
'resolution'
)
as
$key
)
{
if
(
array_key_exists
(
'video_'
.
$key
.
'_'
.
$vt
,
$_POST
)
&&
sanitize_text_field
(
$_POST
[
'video_'
.
$key
.
'_'
.
$vt
]))
{
$video
->
__set
(
$key
.
'_'
.
$vt
,
sanitize_text_field
(
$_POST
[
'video_'
.
$key
.
'_'
.
$vt
]));
}
else
$video
->
__set
(
$key
.
'_'
.
$vt
,
false
);
if
(
$admin
)
{
foreach
(
array
(
'size'
,
'format'
,
'codec'
,
'acodec'
,
'duration'
,
'resolution'
)
as
$key
)
{
if
(
array_key_exists
(
'video_'
.
$key
.
'_'
.
$vt
,
$_POST
)
&&
sanitize_text_field
(
$_POST
[
'video_'
.
$key
.
'_'
.
$vt
]))
{
$video
->
__set
(
$key
.
'_'
.
$vt
,
sanitize_text_field
(
$_POST
[
'video_'
.
$key
.
'_'
.
$vt
]));
}
else
$video
->
__set
(
$key
.
'_'
.
$vt
,
false
);
}
}
}
...
...
@@ -208,8 +229,10 @@ function save_sexhack_video_forms( $post_id )
{
if
(
is_numeric
(
$guest_id
)
&&
intval
(
$guest_id
)
>
0
)
{
$guest
=
get_userdata
(
intval
(
$guest_id
));
if
(
$guest
)
$video
->
add_guest
(
$guest
);
if
(
$admin
||
(
!
$admin
&&
intval
(
$guest_id
)
!=
get_current_user_id
()))
{
$guest
=
get_userdata
(
intval
(
$guest_id
));
if
(
$guest
)
$video
->
add_guest
(
$guest
);
}
}
}
}
...
...
templates/admin/metabox_video.php
View file @
0d013e59
...
...
@@ -46,6 +46,7 @@ if($video->product_id > 0)
<select
name=
'video_status'
>
<option
value=
'creating'
<?php
if
(
$video
->
status
==
'creating'
)
echo
"selected"
;
?>
>
Creating
</option>
<option
value=
'uploading'
<?php
if
(
$video
->
status
==
'uploading'
)
echo
"selected"
;
?>
>
Uploading
</option>
<option
value=
'queue'
<?php
if
(
$video
->
status
==
'queue'
)
echo
"selected"
;
?>
>
Queue
</option>
<option
value=
'processing'
<?php
if
(
$video
->
status
==
'processing'
)
echo
"selected"
;
?>
>
Processing
</option>
<option
value=
'ready'
<?php
if
(
$video
->
status
==
'ready'
)
echo
"selected"
;
?>
>
Ready
</option>
<option
value=
'published'
<?php
if
(
$video
->
status
==
'published'
)
echo
"selected"
;
?>
>
Published
</option>
...
...
templates/new_video.php
View file @
0d013e59
...
...
@@ -330,7 +330,10 @@ jQuery(function($) {
});
$
(
'#send'
).
on
(
'click'
,
function
()
{
console
.
log
(
'uhmm'
);
console
.
log
(
'sending...'
);
document
.
getElementById
(
'send'
).
disabled
=
true
;
document
.
getElementById
(
'send'
).
value
=
'Sending...'
;
formdata
=
new
FormData
();
formdata
.
append
(
'action'
,
'sh_editvideo'
);
formdata
.
append
(
'uniqid'
,
'
<?php
echo
$uniqid
?>
'
);
...
...
@@ -342,17 +345,35 @@ jQuery(function($) {
formdata
.
append
(
'video_type'
,
$
(
'input[name="video_type"]:checked'
).
val
());
formdata
.
append
(
'video_vr_projection'
,
$
(
'#video_vr_projection'
).
find
(
":selected"
).
val
());
formdata
.
append
(
'video_price'
,
$
(
'input[name="video_price"]'
).
val
());
formdata
.
append
(
'public_isdownload'
,
$
(
'input[name="video_isdownload_public"]'
).
val
());
formdata
.
append
(
'members_isdownload'
,
$
(
'input[name="video_isdownload_members"]'
).
val
());
formdata
.
append
(
'premium_isdownload'
,
$
(
'input[name="video_isdownload_premium"]'
).
val
());
formdata
.
append
(
'categories'
,
$
(
"#catstable input:checkbox:checked"
).
map
(
function
(){
return
$
(
this
).
val
();}).
get
());
formdata
.
append
(
'public_isdownload'
,
$
(
'input[name="video_isdownload_public"]:checked'
).
val
());
formdata
.
append
(
'members_isdownload'
,
$
(
'input[name="video_isdownload_members"]:checked'
).
val
());
formdata
.
append
(
'premium_isdownload'
,
$
(
'input[name="video_isdownload_premium"]:checked'
).
val
());
//formdata.append('vcategory', $("#catstable input:checkbox:checked").map(function(){ return $(this).val();}).get());
var
vcats
=
$
(
"#catstable input:checkbox:checked"
).
map
(
function
(){
return
$
(
this
).
val
();}).
get
();
for
(
var
i
=
0
;
i
<
vcats
.
length
;
i
++
)
{
formdata
.
append
(
'vcategory[]'
,
vcats
[
i
]);
}
var
guestar
=
$
(
'.guest_list p select[name="vguests[]"]'
).
find
(
':selected'
).
map
(
function
()
{
if
(
$
(
this
).
val
()
>
0
)
return
$
(
this
).
val
()}).
get
();
formdata
.
append
(
'guests'
,
guestar
.
filter
((
item
,
index
)
=>
guestar
.
indexOf
(
item
)
===
index
));
formdata
.
append
(
'tags'
,
$
(
'input[name="video_tags[]"]'
).
map
(
function
(){
return
$
(
this
).
val
()}).
get
());
var
gaf
=
guestar
.
filter
((
item
,
index
)
=>
guestar
.
indexOf
(
item
)
===
index
);
for
(
var
i
=
0
;
i
<
gaf
.
length
;
i
++
)
{
formdata
.
append
(
'vguests[]'
,
gaf
[
i
]);
}
//formdata.append('vguests', guestar.filter((item, index) => guestar.indexOf(item) === index));
///formdata.append('video_tags', $('input[name="video_tags[]"]').map(function(){ return $(this).val()}).get());
var
vtags
=
$
(
'input[name="video_tags[]"]'
).
map
(
function
(){
return
$
(
this
).
val
()});
for
(
var
i
=
0
;
i
<
vtags
.
length
;
i
++
)
{
formdata
.
append
(
'video_tags[]'
,
vtags
[
i
]);
}
formdata
.
append
(
'post_type'
,
'sexhack_video'
);
<?php
foreach
(
array
(
'public'
,
'members'
,
'premium'
,
'preview'
,
'thumb'
,
'gif'
,
'gif_small'
)
as
$level
)
{
?>
formdata
.
append
(
'
filename
_
<?php
echo
$level
;
?>
'
,
$
(
'input[name="filename_
<?php
echo
$level
;
?>
"]'
).
val
());
formdata
.
append
(
'
video
_
<?php
echo
$level
;
?>
'
,
$
(
'input[name="filename_
<?php
echo
$level
;
?>
"]'
).
val
());
<?php
}
?>
$
.
ajax
({
url
:
'
<?php
echo
admin_url
(
'admin-ajax.php'
);
?>
'
,
...
...
@@ -361,7 +382,8 @@ jQuery(function($) {
processData
:
false
,
data
:
formdata
,
success
:
function
(
response
)
{
alert
(
'saved'
);
document
.
getElementById
(
'send'
).
value
=
'Success!'
;
window
.
location
=
window
.
location
.
pathname
;
}
});
});
...
...
@@ -436,8 +458,9 @@ jQuery(function($) {
if
(
flowuploads
)
flowuploads
--
;
console
.
log
(
'CI SIAMO'
);
ppid
=
fileslot
.
parentElement
.
parentElement
.
id
;
if
(
ppid
==
'newvideo_members_list'
||
ppid
==
'newvideo_public_list'
||
ppid
==
'newvideo_premium_list'
)
needsupload
++
;
$
(
'#'
+
ppid
).
parent
().
find
(
'input[type="hidden"]'
).
val
(
'
<?php
echo
$uniqid
.
"_"
;
?>
'
+
file
.
name
);
if
(
ppid
==
'newvideo_members_list'
||
ppid
==
'newvideo_public_list'
||
ppid
==
'newvideo_premium_list'
)
needsupload
++
;
if
(
flowuploads
)
flowuploads
--
;
canbesaved
();
});
...
...
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