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
9df169e9
Commit
9df169e9
authored
May 11, 2024
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add woocommerce Chaturbate tokens payment gateway
parent
e110388b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
268 additions
and
22 deletions
+268
-22
chaturbate_ico.png
img/chaturbate_ico.png
+0
-0
class-shortcodes.php
includes/class-shortcodes.php
+11
-2
class-video-players.php
includes/class-video-players.php
+2
-2
class-woocommerce-support.php
includes/class-woocommerce-support.php
+243
-12
functions-core.php
includes/functions-core.php
+5
-3
sexhls.js
js/sexhls.js
+6
-2
cropped-sexhack_members-300x99.jpg
templates/img/cropped-sexhack_members-300x99.jpg
+0
-0
hls.php
templates/videoplayer/hls.php
+1
-1
No files found.
img/chaturbate_ico.png
0 → 100644
View file @
9df169e9
8.15 KB
includes/class-shortcodes.php
View file @
9df169e9
...
...
@@ -70,8 +70,13 @@ if(!class_exists('SH_Shortcodes')) {
extract
(
shortcode_atts
(
array
(
"url"
=>
''
,
"posters"
=>
''
,
"autoplay"
=>
false
),
$attr
));
return
"<div class='sexhls_video'>"
.
sh_hls_player
(
$url
,
$posters
)
.
"</div>"
;
ob_start
();
sh_hls_player
(
$url
,
$posters
,
$autoplay
);
$player
=
ob_get_contents
();
ob_end_clean
();
return
"<div class='sexhls_video'>"
.
$player
.
"</div>"
;
}
public
static
function
video_xr
(
$attr
,
$cont
)
...
...
@@ -80,7 +85,11 @@ if(!class_exists('SH_Shortcodes')) {
"url"
=>
''
,
"posters"
=>
''
,
),
$attr
));
return
"<div class='sexvideo_videojs'>"
.
sh_xr_player
(
$url
,
$posters
)
.
"</div>"
;
ob_start
();
sh_xr_player
(
$url
,
$posters
);
$player
=
ob_get_contents
();
ob_end_clean
();
return
"<div class='sexvideo_videojs'>"
.
$player
.
"</div>"
;
}
public
static
function
xframe_bypass
(
$attr
,
$cont
)
...
...
includes/class-video-players.php
View file @
9df169e9
...
...
@@ -29,13 +29,13 @@ if(!class_exists('SH_VideoPlayer')) {
class
SH_VideoPlayer
{
public
static
function
addPlayer
(
$player_type
=
'hls'
,
$vurl
=
''
,
$posters
=
""
,
$projection
=
'180_LR'
)
public
static
function
addPlayer
(
$player_type
=
'hls'
,
$vurl
=
''
,
$posters
=
""
,
$projection
=
'180_LR'
,
$autoplay
=
false
)
{
$html
=
false
;
switch
(
$player_type
)
{
case
'hls'
:
$html
=
sh_get_template
(
"videoplayer/hls.php"
,
array
(
'vurl'
=>
$vurl
,
'posters'
=>
$posters
));
$html
=
sh_get_template
(
"videoplayer/hls.php"
,
array
(
'vurl'
=>
$vurl
,
'posters'
=>
$posters
,
'autoplay'
=>
strval
(
$autoplay
)
));
break
;
case
'xr'
:
...
...
includes/class-woocommerce-support.php
View file @
9df169e9
...
...
@@ -220,6 +220,7 @@ if(!class_exists('SexhackWoocommerceCheckout')) {
//add_action( 'woocommerce_before_checkout_form', array($this, 'empty_cart'), 1);
add_action
(
'woocommerce_add_to_cart_validation'
,
array
(
$this
,
'empty_cart'
),
1
);
add_filter
(
'woocommerce_add_to_cart_redirect'
,
array
(
$this
,
'redirect_checkout_add_cart'
));
add_action
(
'woocommerce_simple_add_to_cart'
,
array
(
$this
,
'oneclick_checkout'
));
add_action
(
'woocommerce_after_shop_loop_item'
,
array
(
$this
,
'product_loop_oneclick'
),
9
);
...
...
@@ -235,9 +236,16 @@ if(!class_exists('SexhackWoocommerceCheckout')) {
$woocommerce
->
cart
->
empty_cart
();
//WC()->session->set('cart', array());
$woocommerce
->
cart
->
add_to_cart
(
intval
(
$_GET
[
'shm_direct_checkout'
]),
1
);
}
else
{
//$woocommerce->cart->empty_cart();
return
true
;
}
}
public
function
redirect_checkout_add_cart
()
{
return
wc_get_checkout_url
();
}
public
function
header_buffer_start
()
{
ob_start
(
array
(
$this
,
"header_buffer_callback"
));
}
public
function
header_buffer_stop
()
{
ob_end_flush
();
}
...
...
@@ -250,12 +258,14 @@ if(!class_exists('SexhackWoocommerceCheckout')) {
public
function
product_loop_oneclick
()
{
global
$product
;
echo
'<div class="custom-add-to-cart">'
;
remove_action
(
'woocommerce_after_shop_loop_item'
,
'woocommerce_template_loop_add_to_cart'
);
if
(
!
$product
->
is_type
(
'variable'
))
{
echo
'<div class="custom-add-to-cart">'
;
//woocommerce_template_loop_add_to_cart();
echo
'<a class="button" href="'
.
wc_get_checkout_url
()
.
"?add-to-cart="
.
$product
->
get_id
()
.
"&shm_direct_checkout="
.
$product
->
get_id
()
.
'">Buy now!</a>'
;
echo
'</div>'
;
}
}
public
function
oneclick_checkout
()
{
global
$product
;
...
...
@@ -402,9 +412,10 @@ if(!class_exists('WoocommerceEmailCheckout')) {
foreach
(
WC
()
->
cart
->
get_cart
()
as
$cart_item_key
=>
$cart_item
)
{
// Check if there are non-virtual products
if
(
!
$cart_item
[
'data'
]
->
is_virtual
(
)
)
$only_virtual
=
false
;
if
(
(
!
$cart_item
[
'data'
]
->
is_virtual
())
&&
(
$cart_item
[
'data'
]
->
get_attribute
(
'virtual'
)
!=
'y'
)
)
$only_virtual
=
false
;
}
if
(
$only_virtual
)
{
unset
(
$fields
[
'billing'
][
'billing_company'
]);
unset
(
$fields
[
'billing'
][
'billing_address_1'
]);
...
...
@@ -586,4 +597,224 @@ if(!class_exists('SH_WooCommerce_Registration_Integration')) {
}
if
(
!
class_exists
(
'SH_WooCommerce_Chaturbate_Payments'
))
{
add_filter
(
'woocommerce_payment_gateways'
,
'wp_SexHackMe\sh_add_payment_gateway_class'
);
function
sh_add_payment_gateway_class
(
$gateways
)
{
$gateways
[]
=
'wp_SexHackMe\SH_WooCommerce_Chaturbate_Payments'
;
// your class name is here
return
$gateways
;
}
add_action
(
'plugins_loaded'
,
'wp_SexHackMe\chaturbate_payment_init'
);
function
chaturbate_payment_init
()
{
class
SH_WooCommerce_Chaturbate_Payments
extends
\WC_Payment_Gateway
{
// Constructor for initializing the payment gateway
public
function
__construct
()
{
$this
->
id
=
'shchaturbate'
;
$this
->
method_title
=
'Chaturbate Payment Gateway (SexHackMe)'
;
$this
->
method_description
=
'Receive payments in chaturbate.com tokens'
;
$this
->
icon
=
SH_PLUGIN_DIR_URL
.
'/img/chaturbate_ico.png'
;
// URL to the icon
$this
->
has_fields
=
true
;
$this
->
init_form_fields
();
$this
->
init_settings
();
$this
->
supports
=
array
(
'products'
);
$this
->
enabled
=
$this
->
get_option
(
'enabled'
);
$this
->
title
=
$this
->
get_option
(
'title'
);
$this
->
description
=
$this
->
get_option
(
'description'
);
$this
->
uuid_prefix
=
$this
->
get_option
(
'uuid_prefix'
);
$this
->
cb_model
=
$this
->
get_option
(
'cb_model'
);
$this
->
cb_change
=
$this
->
get_option
(
'cb_change'
);
$this
->
instructions
=
$this
->
get_option
(
'instructions'
);
$this
->
api_passkey
=
$this
->
get_option
(
'api_passkey'
);
add_action
(
'woocommerce_update_options_payment_gateways_'
.
$this
->
id
,
array
(
$this
,
'process_admin_options'
));
add_action
(
'woocommerce_api_shchaturbate'
,
array
(
$this
,
'webhook_cb'
)
);
//add_action( 'woocommerce_before_thankyou', array( $this, 'thankyou_page' ));
add_filter
(
'woocommerce_thankyou_order_received_text'
,
array
(
$this
,
'thankyou_page'
),
90
,
2
);
// Customer Emails.
add_action
(
'woocommerce_email_before_order_table'
,
array
(
$this
,
'email_instructions'
),
10
,
3
);
}
public
function
webhook
()
{
if
(
$_GET
[
'key'
]
==
$this
->
api_passkey
)
{
$msg
=
$_GET
[
'msg'
];
$tkns
=
intval
(
$_GET
[
'tkns'
]);
if
(
str_starts_with
(
$msg
,
$this
->
uuid_prefix
))
{
$order_id
=
intval
(
str_replace
(
$this
->
uuid_prefix
,
''
,
$msg
));
$order
=
wc_get_order
(
$order_id
);
$tktotal
=
$order
->
get_total
()
/
$this
->
cb_change
;
if
(
$tkns
>=
$tktotal
)
{
$order
->
payment_complete
();
}
}
}
//$order->reduce_order_stock();
}
// Initialize settings fields
public
function
init_form_fields
()
{
$this
->
form_fields
=
array
(
'enabled'
=>
array
(
'title'
=>
'Enable/Disable'
,
'label'
=>
'Enable Chaturbate Gateway'
,
'type'
=>
'checkbox'
,
'description'
=>
''
,
'default'
=>
'no'
),
'title'
=>
array
(
'title'
=>
__
(
'Title'
,
'woocommerce'
),
'type'
=>
'text'
,
'description'
=>
__
(
'This controls the title displayed during checkout.'
,
'woocommerce'
),
'default'
=>
__
(
'Chaturbate Tokens'
,
'woocommerce'
),
'desc_tip'
=>
true
,
),
'description'
=>
array
(
'title'
=>
__
(
'Description'
,
'woocommerce'
),
'type'
=>
'textarea'
,
'description'
=>
__
(
'This controls the description displayed during checkout.'
,
'woocommerce'
),
'default'
=>
__
(
'Pay using Chaturbate tokens'
,
'woocommerce'
),
'desc_tip'
=>
true
,
),
'cb_change'
=>
array
(
'title'
=>
'CB Tokens USD conversion'
,
'type'
=>
'number'
,
'custom_attributes'
=>
array
(
'step'
=>
'any'
,
'min'
=>
'0'
),
'description'
=>
'Value of 1 chaturbate token in USD'
,
'desc_tip'
=>
true
,
'default'
=>
0.05
,
),
'instructions'
=>
array
(
'title'
=>
__
(
'Instructions'
,
'woocommerce'
),
'type'
=>
'textarea'
,
'description'
=>
__
(
'Instructions that will be added to the thank you page and emails.'
,
'woocommerce'
),
'default'
=>
'Send {TOTAL} chaturbate tokens to https://chaturbate.com/{CB_MODEL} with the message {ORDER_UUID}'
,
'desc_tip'
=>
true
,
),
'uuid_prefix'
=>
array
(
'title'
=>
'Order ID Prefix'
,
'type'
=>
'text'
,
'description'
=>
'order ID prefix for messages included in tokens sent'
,
'desc_tip'
=>
true
,
'default'
=>
'SHMPAY-'
,
),
'cb_model'
=>
array
(
'title'
=>
'Model name'
,
'type'
=>
'text'
,
'description'
=>
'Model name on chaturbate that will receive tokens'
,
'desc_tip'
=>
true
,
'default'
=>
'sexhackme'
,
),
'api_passkey'
=>
array
(
'title'
=>
'API Passkey'
,
'type'
=>
'text'
,
'description'
=>
'API Key password for chaturbate bot API'
,
'desc_tip'
=>
true
,
'default'
=>
'sexhackme_key_changeme'
,
),
);
}
private
function
print_instructions
(
$order_id
,
$totalusd
=-
1
)
{
$instr
=
str_replace
(
'{CB_MODEL}'
,
$this
->
cb_model
,
$this
->
instructions
);
$instr
=
str_replace
(
'{ORDER_UUID}'
,
$this
->
uuid_prefix
.
strval
(
$order_id
),
$instr
);
if
(
$totalusd
<
0
)
{
$order
=
wc_get_order
(
$order_id
);
$totalusd
=
$order
->
get_total
();
}
$instr
=
str_replace
(
'{TOTAL}'
,
intval
(
$totalusd
/
$this
->
cb_change
),
$instr
);
return
$instr
;
}
//public function thankyou_page($order_id) {
public
function
thankyou_page
(
$msg
,
$order
)
{
$order_id
=
$order
->
get_id
();
if
(
$this
->
instructions
)
{
//$order = wc_get_order( $order_id );
if
(
$order
->
get_payment_method
()
==
'shchaturbate'
)
return
wp_kses_post
(
wpautop
(
wptexturize
(
$this
->
print_instructions
(
$order_id
,
$order
->
get_total
())
)
)
);
//echo wp_kses_post( wpautop( wptexturize( $this->print_instructions($order_id, $order->get_total()) ) ) );
}
return
$msg
;
}
public
function
email_instructions
(
$order
,
$sent_to_admin
,
$plain_text
=
false
)
{
if
(
$this
->
instructions
&&
!
$sent_to_admin
&&
'shchaturbate'
===
$order
->
get_payment_method
()
&&
$order
->
has_status
(
apply_filters
(
'woocommerce_shchaturbate_email_instructions_order_status'
,
'on-hold'
,
$order
)
)
)
{
echo
wp_kses_post
(
wpautop
(
wptexturize
(
$this
->
print_instructions
(
$order
->
get_id
(),
$order
->
get_total
())
)
)
.
PHP_EOL
);
}
}
// Process payment
public
function
process_payment
(
$order_id
)
{
$order
=
wc_get_order
(
$order_id
);
$total
=
$order
->
get_total
();
//
/*
if ( $total > 0 ) {
// Mark as on-hold (we're awaiting the shchaturbate).
$order->update_status(
apply_filters( 'woocommerce_shchaturbate_process_payment_order_status', 'on-hold', $order ),
'Waiting for '.intval($total/$this->cb_change).' tokens to https://chaturbate.com/'.$this->cb_model.' with message '.$this->uuid_prefix.$order_id
);
} else {
$order->payment_complete();
}
*/
if
(
$total
<-
0
)
$order
->
payment_complete
();
//$order->update_status('on-hold', __( 'Pay by sending '.intval($total/0.05).' tokens to https://chaturbate.com/sexhackme', 'woocommerce' ));
/*
$order->add_order_note(
'Please go on https://chaturbate.com/sexhackme and tip '.intval($total/0.05).' tokens with the message SHM-'.strval($order_id),
true );
*/
// Empty cart
WC
()
->
cart
->
empty_cart
();
return
array
(
'result'
=>
'success'
,
'redirect'
=>
$this
->
get_return_url
(
$order
),
);
}
/*
// XXX We don't use anything special here.
// Display payment fields during checkout
public function payment_fields() {
// Display payment fields such as credit card info or other required info
// ...
}
// Validate payment fields
public function validate_fields() {
// Validate payment fields submitted by the customer
// ...
} */
}
}
}
?>
includes/functions-core.php
View file @
9df169e9
...
...
@@ -28,7 +28,9 @@ function sh_get_template($tmpl, $args=array())
{
foreach
(
$args
as
$var
=>
$data
)
$$var
=
$data
;
if
(
file_exists
(
SH_PLUGIN_DIR_PATH
.
'templates/'
.
$tmpl
))
return
include_once
SH_PLUGIN_DIR_PATH
.
'templates/'
.
$tmpl
;
{
return
include
SH_PLUGIN_DIR_PATH
.
'templates/'
.
$tmpl
;
}
return
false
;
}
...
...
@@ -75,9 +77,9 @@ function sh_genpass_register_form()
}
function
sh_hls_player
(
$video_url
,
$posters
=
''
)
function
sh_hls_player
(
$video_url
,
$posters
=
''
,
$autoplay
=
false
)
{
SH_VideoPlayer
::
addPlayer
(
'hls'
,
$video_url
,
$posters
);
SH_VideoPlayer
::
addPlayer
(
'hls'
,
$video_url
,
$posters
,
''
,
$autoplay
);
}
function
sh_xr_player
(
$video_url
,
$posters
=
''
,
$projection
=
'180_LR'
)
...
...
js/sexhls.js
View file @
9df169e9
...
...
@@ -20,7 +20,7 @@
//var vtag = document.getElementById('vtag');
function
SexHLSPlayer
(
url
,
vuid
){
function
SexHLSPlayer
(
url
,
vuid
,
autoplay
=
false
){
var
vtag
=
document
.
getElementById
(
vuid
);
if
(
Hls
.
isSupported
())
{
vtag
.
volume
=
0.3
;
...
...
@@ -28,10 +28,14 @@ function SexHLSPlayer(url, vuid){
var
m3u8Url
=
decodeURIComponent
(
url
)
hls
.
loadSource
(
m3u8Url
);
hls
.
attachMedia
(
vtag
);
hls
.
on
(
Hls
.
Events
.
MANIFEST_PARSED
,
function
()
{
hls
.
on
(
Hls
.
Events
.
MANIFEST_PARSED
,
function
(
autoplay
)
{
hls
.
autoLevelEnabled
=
true
;
//hls.loadLevel = 4;
hls
.
startLoad
();
if
(
autoplay
==
true
)
{
vtag
.
mute
=
true
;
}
vtag
.
play
();
// XXX Autoplay doesn't work apparently atm
});
//document.title = url
...
...
templates/img/cropped-sexhack_members-300x99.jpg
0 → 100644
View file @
9df169e9
8.49 KB
templates/videoplayer/hls.php
View file @
9df169e9
...
...
@@ -27,7 +27,7 @@ $uid = uniqid('sexhls_');
<video
id=
"
<?php
echo
$uid
;
?>
"
style=
"width: 100%; height: 100%;"
controls
poster=
"
<?php
echo
$posters
;
?>
"
></video>
<script
language=
"javascript"
>
$
(
window
).
on
(
'load'
,
function
()
{
SexHLSPlayer
(
'
<?php
echo
$vurl
;
?>
'
,
'
<?php
echo
$uid
;
?>
'
);
SexHLSPlayer
(
'
<?php
echo
$vurl
;
?>
'
,
'
<?php
echo
$uid
;
?>
'
,
<?php
echo
$autoplay
;
?>
);
$
(
'#
<?php
echo
$uid
;
?>
'
).
on
(
'click'
,
function
(){
this
.
paused
?
this
.
play
():
this
.
pause
();});
Mousetrap
(
document
.
getElementById
(
'
<?php
echo
$uid
;
?>
'
)).
bind
(
'space'
,
function
(
e
,
combo
)
{
SexHLSplayPause
(
'
<?php
echo
$uid
;
?>
'
);
});
Mousetrap
(
document
.
getElementById
(
'
<?php
echo
$uid
;
?>
'
)).
bind
(
'up'
,
function
(
e
,
combo
)
{
SexHLSvolumeUp
(
'
<?php
echo
$uid
;
?>
'
);
});
...
...
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