Browse Source

wc-mmo creation

Shane
Felty 2 years ago
parent
commit
64bb83e5f8
15 changed files with 1126 additions and 0 deletions
  1. +27
    -0
      vidyen-wc-mmo/README.md
  2. +5
    -0
      vidyen-wc-mmo/includes/functions/core/index.php
  3. +26
    -0
      vidyen-wc-mmo/includes/functions/core/vyps_adgate_pro_func.php
  4. +113
    -0
      vidyen-wc-mmo/includes/functions/core/vyps_woowallet_currency.php
  5. +5
    -0
      vidyen-wc-mmo/includes/functions/index.php
  6. +5
    -0
      vidyen-wc-mmo/includes/images/index.php
  7. BIN
      vidyen-wc-mmo/includes/images/logo.png
  8. BIN
      vidyen-wc-mmo/includes/images/powered_by_vyps.png
  9. +5
    -0
      vidyen-wc-mmo/includes/index.php
  10. +57
    -0
      vidyen-wc-mmo/includes/menus/adgate-menu.php
  11. +5
    -0
      vidyen-wc-mmo/includes/menus/index.php
  12. +5
    -0
      vidyen-wc-mmo/includes/shortcodes/index.php
  13. +704
    -0
      vidyen-wc-mmo/includes/shortcodes/vyps-point-exchange.php
  14. +5
    -0
      vidyen-wc-mmo/index.php
  15. +164
    -0
      vidyen-wc-mmo/vidyen-wc-mmo.php

+ 27
- 0
vidyen-wc-mmo/README.md View File

@ -0,0 +1,27 @@
# vyps-pro-adgate
Code for the pro version
## Commentary
You maybe wondering why I'm putting the pro version on GitHub... Well... Since VYPS is all open source, you can just comment a few lines and remove the logos yourself, but I suppose it would be helpful if you wanted to help out VidYen, LLC continue the progress towards making this easier for everyone.
# Donations
First and formost you can just use our Adgate referral code.
[https://panel.adgatemedia.com/r/62694](https://panel.adgatemedia.com/r/62694)
Donate to our XMR Wallet:
8BpC2QJfjvoiXd8RZv3DhRWetG7ybGwD8eqG9MZoZyv7aHRhPzvrRF43UY1JbPdZHnEckPyR4dAoSSZazf5AY5SS9jrFAdb
Or if you have USD to throw around...
[Patreon](https://www.patreon.com/vidyen)
And I should get a BTC wallet setup.
## Fork of Blank Slate
Due to the nature of Adgate Postback I had to find a quick way to reduce as much information as possible for the Adgate return.
I have modifications to that and integrate with less of the WP script hooks. Their license remains the same. See the blankslateREADME.md for their credits.

+ 5
- 0
vidyen-wc-mmo/includes/functions/core/index.php View File

@ -0,0 +1,5 @@
<?php
// Silence is golden, but gold has no intrinsic value.
// At least it's easy to trade digital currencies.
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

+ 26
- 0
vidyen-wc-mmo/includes/functions/core/vyps_adgate_pro_func.php View File

@ -0,0 +1,26 @@
<?php
//adgate pro_check feature. This actually allows post back
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
function vyps_adgate_pro_check_func()
{
//If you bought the $30 pro version it will do it.
if (function_exists('vyps_flag_pro_2019'))
{
//OK it does exist so lets run it.
$pro_result = intval(vyps_flag_pro_2019());
return $pro_result; //It should be a 1 or a 0
}
//Otherwise, we just need the referral option.
//This is just proving you have a referral code
if (function_exists('vyps_flag_pro_adgate'))
{
//OK it does exist so lets run it.
$pro_result = intval(vyps_flag_pro_adgate());
return $pro_result; //It should be a 1 or a 0
}
}
//no Need for pro check shortcode... That was debugging

+ 113
- 0
vidyen-wc-mmo/includes/functions/core/vyps_woowallet_currency.php View File

@ -0,0 +1,113 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
//I needed a way to add my own currency in WooCommerce. I'm going to just use copper for the first. -Felty
//I needed a way to add my own currency in WooCommerce. I'm going to just use copper for the first. -Felty
/**
* Custom currency and currency symbol
*
* Copper
* Silver
* Gold
* Gems
* VidYen
*
*/
/*** Copper ***/
add_filter( 'woocommerce_currencies', 'add_vyps_copper_currency' );
function add_vyps_copper_currency( $currencies )
{
$currencies['COPPER'] = __( 'Copper Pieces', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_vyps_copper_currency_symbol', 10, 2);
function add_vyps_copper_currency_symbol( $currency_symbol, $currency )
{
switch( $currency ) {
case 'COPPER': $currency_symbol = 'Copper'; break;
}
return $currency_symbol;
}
/*** Silver ***/
add_filter( 'woocommerce_currencies', 'add_vyps_silver_currency' );
function add_vyps_silver_currency( $currencies )
{
$currencies['SILVER'] = __( 'Silver Pieces', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_vyps_silver_currency_symbol', 10, 2);
function add_vyps_silver_currency_symbol( $currency_symbol, $currency )
{
switch( $currency ) {
case 'SILVER': $currency_symbol = 'Silver'; break;
}
return $currency_symbol;
}
/*** Gold ***/
add_filter( 'woocommerce_currencies', 'add_vyps_gold_currency' );
function add_vyps_gold_currency( $currencies )
{
$currencies['GOLD'] = __( 'Gold Pieces', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_vyps_gold_currency_symbol', 10, 2);
function add_vyps_gold_currency_symbol( $currency_symbol, $currency )
{
switch( $currency ) {
case 'GOLD': $currency_symbol = 'Gold'; break;
}
return $currency_symbol;
}
/*** Gems ***/
add_filter( 'woocommerce_currencies', 'add_vyps_gems_currency' );
function add_vyps_gems_currency( $currencies )
{
$currencies['GEMS'] = __( 'Gems', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_vyps_gems_currency_symbol', 10, 2);
function add_vyps_gems_currency_symbol( $currency_symbol, $currency )
{
switch( $currency ) {
case 'GEMS': $currency_symbol = 'Gems'; break;
}
return $currency_symbol;
}
/*** VidYen ***/
add_filter( 'woocommerce_currencies', 'add_vyps_vidyen_currency' );
function add_vyps_vidyen_currency( $currencies )
{
$currencies['VIDYEN'] = __( 'VidYen', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_vyps_vidyen_currency_symbol', 10, 2);
function add_vyps_vidyen_currency_symbol( $currency_symbol, $currency )
{
switch( $currency ) {
case 'VIDYEN': $currency_symbol = 'V¥'; break;
}
return $currency_symbol;
}

+ 5
- 0
vidyen-wc-mmo/includes/functions/index.php View File

@ -0,0 +1,5 @@
<?php
// Silence is golden, but gold has no intrinsic value.
// At least it's easy to trade digital currencies.
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

+ 5
- 0
vidyen-wc-mmo/includes/images/index.php View File

@ -0,0 +1,5 @@
<?php
// Silence is golden, but gold has no intrinsic value.
// At least it's easy to trade digital currencies.
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

BIN
vidyen-wc-mmo/includes/images/logo.png View File

Before After
Width: 173  |  Height: 42  |  Size: 1.3 KiB

BIN
vidyen-wc-mmo/includes/images/powered_by_vyps.png View File

Before After
Width: 65  |  Height: 16  |  Size: 1.1 KiB

+ 5
- 0
vidyen-wc-mmo/includes/index.php View File

@ -0,0 +1,5 @@
<?php
// Silence is golden, but gold has no intrinsic value.
// At least it's easy to trade digital currencies.
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

+ 57
- 0
vidyen-wc-mmo/includes/menus/adgate-menu.php View File

@ -0,0 +1,57 @@
<?php
//AdGate menu
add_action('admin_menu', 'vyps_adgate_submenu', 450 ); //Last VYPS was 440
/* Creates the AdGate submenu on the main VYPS plugin */
//Copied and pasted from Adscend and updated for post packs.
function vyps_adgate_submenu()
{
$parent_menu_slug = 'vyps_points';
$page_title = "VYPS AdGate Shortcodes";
$menu_title = 'AdGate Shortcodes';
$capability = 'manage_options';
$menu_slug = 'vyps_adgate_page';
$function = 'vyps_adgate_sub_menu_page';
add_submenu_page($parent_menu_slug, $page_title, $menu_title, $capability, $menu_slug, $function);
}
/* Below is the functions for the shortcode */
function vyps_adgate_sub_menu_page()
{
//Image URLS
//NOTE It took me a while to realize, I needed the dirname()
$VYPS_logo_url = plugins_url( 'images/logo.png', dirname(__FILE__) );
echo '<br><br><img src="' . $VYPS_logo_url . '" > ';
//Originally, this was includes to other files but don't need that much de-integration
echo '<br><br><h1>AdGate User Tracking API Shortcodes</h1>
<p>This plugin needs a <a href="https://adgatemedia.com/" target="_blank">AdGate Media</a> account to function. The intention is to allow a quick and easy way for you to award user points for Adscend Activity.</p>
<p>The intention of this plugin was to make it easier for a WordPress admin to talk with the Adscend API without actually having to program curl calls in PHP manually and automate the recognition of the monetization activity by your end users.</p>
<h1>Shortcodes and Syntax</h1>
<p><b>[vyps-adgate code=(found on AdGate site)]</b></p>
<p>ex: <b>[vyps-adgate code=nqaaqg]</b></p>
<p>This is pretty much it. Just need to grab your AdGate code off the AdGate <a href="https://panel.adgatemedia.com/affiliate/vc-walls" target="_blank">rewards page</a> to shortcode.<p>
<h1>Post Back Instructions</h1>
<p>1. Create a WordPress standalone page for the post back.</p>
<p>2. Add the shortcode: <b>[vyps-adgate-postback outputid=(point id) secret=(your AdGate secret key)]</b> (ex: [vyps-adgate-postback outputid=7])</p>
<p>3. Make sure no other text or shortcode is in page body. It will cause errors on the AdGate report if you do.</p>
<p>4. On Edit Page -> Page Attributes (right-hand side on classic editor), set the template to AdGate Post Back Template and update. This will remove all the extra WordPress HTML that would cause the AdGate API to error out on the post back attempt.</p>
<p><b>Note:</b> VYPS will do a 1-for-1 and round to the closest whole number based on the AdGate settings on their site. Simply set your AdGate Data to more than 100 per US$1 and set their system to currency round.</p>
<p>TThere are optional shortcodes. By default, the AdGate post back whitelist IPs are 104.130.7.162 and 52.42.57.125, but if they are different, use ip1=, ip2=, and ip3= to set your specific addresses.</p>
<p>Also, <b>reason="My Own Reason"</b> will set a specific reason for the log system. By default, it is "AdGate", Aalthough I use the Global Postback: <b>https://vidyen.com/fabius/adgate-postback/?tx_id={transaction_id}&user_id={s1}&point_value={points}&usd_value={payout}&offer_title={vc_titlpoe}&point_value={points}&status={status}</b> you may wish to edit your own, but the following are required: <b>{user_id}</b>, <b>{tx_id}</b>, <b>{point_value}</b>, <b>{status}</b></p>
<h2>API Security</h2>
<p>Due to the only security built into AdGate, I added a manual api system. Add <b>apikey=(your random number)</b> to the shortcode.</p>
<p>Then on the post back page of AdGate add the &api= key as such:</p>
<p>https://vidyen.com/fabius/adgate-postback/?tx_id={transaction_id}&user_id={s1}&point_value={points}&usd_value={payout}&offer_title={vc_titlpoe}&point_value={points}&status={status}&api=(your random number again)</p>
<h2>Referral</h2>
<p>lease help out VidYen when you sign up to Adscend by using our <a href="https://panel.adgatemedia.com/r/62694" target="_blank">referral link</a> on our webpage</p>
<p>We will also put some tips on getting accepted on that page as well.</p>
';
}

+ 5
- 0
vidyen-wc-mmo/includes/menus/index.php View File

@ -0,0 +1,5 @@
<?php
// Silence is golden, but gold has no intrinsic value.
// At least it's easy to trade digital currencies.
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

+ 5
- 0
vidyen-wc-mmo/includes/shortcodes/index.php View File

@ -0,0 +1,5 @@
<?php
// Silence is golden, but gold has no intrinsic value.
// At least it's easy to trade digital currencies.
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

+ 704
- 0
vidyen-wc-mmo/includes/shortcodes/vyps-point-exchange.php View File

@ -0,0 +1,704 @@
<?php
//VIDYEN Points Exchange Shortcode
//Advanced version with timer
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/* Added prepare() to all SQL SELECT calls 7.1.2018 */
//Oh. Maybe I should put this elsewhere but I have foudn this nifty code off https://stackoverflow.com/questions/8273804/convert-seconds-into-days-hours-minutes-and-seconds
//So I'm putting it here as a function. Will use elsewhere mayhaps. If so will fix later.
//NOTE: This is the time converstion
function vyps_secondsToTime($seconds) {
$dtF = new \DateTime('@0');
$dtT = new \DateTime("@$seconds");
return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes, and %s seconds');
}
function vyps_point_exchange_func( $atts ) {
//The shortcode attributes need to come before the button as they determine the button value
$atts = shortcode_atts(
array(
'firstid' => '0',
'secondid' => '0',
'outputid' => '0',
'firstamount' => '0',
'secondamount' => '0',
'outputamount' => '0',
'refer' => 0,
'days' => '0',
'hours' => '0',
'minutes' => '0',
'symbol' => '',
'amount' => 0,
'from_user_id' => 0,
'to_user_id' => 0,
'fee' => 0,
'comment' => '',
'skip_confirm' => true,
'mobile' => TRUE,
'woowallet' => false,
'mycred' => false,
'mycred_reason' => 'VYPS Transfer',
'gamipress' => false,
'gamipress_reason' => 'VYPS Transfer',
'transfer' => false,
'vyps_meta_id' => '',
'reason' => 'Point Exchange',
'auto' => FALSE,
), $atts, 'vyps-pe' );
//Check if user is logged in and stop the code.
//NOTE:I moved this here. I realized, its more likely that 10,000 users are bashing site mem while the admin is almost always logged in.
if ( is_user_logged_in() )
{
//I probaly don't have to have this part of the if
}
else
{
return; //You get nothing. Use the LG code.
}
/* Save this for later
$sourcePointID = $atts['spid'];
$destinationPointID = $atts['dpid'];
$pt_sAmount = $atts['samount'];
$pt_dAmount = $atts['damount'];
*/
$current_user_id = get_current_user_id(); //This needs to go here as we are checking the time way before then.
$user_id = $current_user_id;
$firstPointID = $atts['firstid'];
$secondPointID = $atts['secondid'];
$destinationPointID = $atts['outputid'];
$pt_fAmount = $atts['firstamount']; //I'm going to be the first to say, I'm am not proud of my naming conventions. Gods know if I ever get amnesia and have to fix my own code, I will be highly displeased. -Felty
$pt_sAmount = $atts['secondamount']; //f = first and s = second, notice how i reused some of the old variables for new. Not really intentional nor well executed.
$pt_dAmount = $atts['outputamount']; //desintation amount.
$vyps_reason = $atts['reason']; //PE reason TODO fix later
$refer_rate = intval($atts['refer']); //Yeah I intvaled it immediatly. No wire decimals!
$user_transfer_state = $atts['transfer']; //NOTE: I was going to rewrite whole system to do user to user tranfer and it occurred to me could just put it here
//Time variables
$time_days = $atts['days'];
$time_hours = $atts['hours'];
$time_minutes = $atts['minutes'];
//Now to get the raw seconds. This is important. 24 * 60 * 60 = 86400, 3600 seconds in an hour etc. We are not doing months unless you want to do my 28 day suggestion with 13 months.
$time_left_seconds = 0; //Just in case there was no transfer inbound to have this variable set.
$time_seconds = ($time_days * 86400) + ($time_hours * 3600) + ($time_minutes * 60);
//NOTE: Here are the dashed slug stuff. Let's get everything that needs to be checked.
$ds_symbol = $atts['symbol']; //We dod check for this because, if we know its set they are trying to use it.
$ds_amount = $atts['amount']; //Need the amount obviously.
$ds_bank_user = $atts['from_user_id']; //Bank user has to be set obviousl. Though the desintation will always be current user
//Fees and comments don't really have to be set.
//Mobile view variable pass
$mobile_view = $atts['mobile'];
//Automode check
$auto_mode = $atts['auto'];
//WooWallet Check
$woowallet_mode = $atts['woowallet'];
//MyCred Check
$mycred_mode = $atts['mycred'];
$mycred_reason = $atts['mycred_reason'];
//Gamipress Check
$gamipress_mode = $atts['gamipress'];
$gamipress_reason = $atts['gamipress_reason'];
$gamipress_point_type = $atts['outputid'];
$gamipress_point_amount = $atts['outputamount'];
//Normal Check. Order of operations issue. Just need to check if any of the 3rd party stuff is on.
if ( $mycred_mode == TRUE OR $woowallet_mode == TRUE OR $gamipress_mode == TRUE ) {
//Definatley not normal mode
$vyps_pe_normal_mode = FALSE;
} else {
//In normal mode... Save DS... Which is kind of normal or no?
$vyps_pe_normal_mode = TRUE;
}
//Just some Dash slug logic checks. To make sure if they are setting a symbol that it has an amount and a bank user.
if ( $ds_symbol != '' AND $ds_amount == 0 ) {
return "You are attempting to use the Dash Slug attributes without setting an amount!";
} elseif ( $ds_symbol != '' AND $ds_bank_user == 0 ) {
return "You are attempting to use the Dash Slug attributes without setting a bank user!";
}
//The usual suspects check to see if admin has set their short codes right.
//Ok I'm lazy here, but the admins should know which of the three they did not set.
if ( $pt_dAmount == 0) {
return "Admin Error: Output amount set to 0. Please set.";
}
//Oh yeah. Checking to see if source pid was set
//NOTE: I have a realization, this might not be valid, but who knows.
if ( $firstPointID == 0 OR ( $destinationPointID == 0 AND $woowallet_mode != TRUE AND $mycred_mode != TRUE AND $gamipress_mode != TRUE )) {
return "Admin Error: A required id was set to 0! Please set all ids.";
} elseif ( $firstPointID == 0 ) {
//In case we have $woowallet_mode == true
return "Admin Error: A required id was set to 0! First point id.";
}
if ($time_seconds < 0 ) {
//I feel like this should be not needed but I feel that it would blow up one of my ifs down below catastrophically
return "Admin Error: You have a negative time somewhere.";
}
//Not seeing comma number seperators annoys me
$format_pt_fAmount = number_format($pt_fAmount);
$format_pt_sAmount = number_format($pt_sAmount);
//NOTE Ok. Some assumption code. By default if you set a ds amount, that you intend to use a decimal so no number formatting.
//If they put in an amount for the ds then we assume they don't want it formatted.
//The logic with the OR neded to be implicit with an AND. As if there is a DS amount you can't use woowallet. Sooo... May the gods save me from my users.
//NOTE: As we are moving up in the world. We need to check to see if any of these are true. Then ds amount will be not invoked.
if ( $ds_amount == 0 AND $woowallet_mode != TRUE ){
$format_pt_dAmount = number_format($pt_dAmount);
//OK this needed go go here. Because the post just was not happening
$vyps_meta_id = $firstPointID . $secondPointID . $destinationPointID . $pt_fAmount . $pt_sAmount . $pt_dAmount;
} elseif ($woowallet_mode == true ) {
//We can assume (most likely incorrectly) that if a user has woowallet to true that they want decimals but not the dashed slug part below
$format_pt_dAmount = '$' . money_format('%i', $pt_dAmount); //Where we are going we are formating for $
//Almost forgot, we need a button without the out put as may be decimals
$vyps_meta_id = $firstPointID . $pt_fAmount . 'ww' . $mobile_view; //I am going to assume that you only have one button of each. I could be wrong. Yes. I was. I was testing with mobile and non mobile on same page, but.... That doesn't work.
} else {
//This is Dashed slug checking
//Need to have it but not formatted!
$format_pt_dAmount = $pt_dAmount;
//Also good place to do this since we know we have a $ds_amount
$ds_bal_check = vyps_dashed_slug_bal_check_func($atts); //This should return a 1 or a zero.
//Ok some herpy derpy here as I realized that the btn did not like decimals so we threw all that out.
//And set some nondecimal and text stuff. Should be unique enough.
$vyps_meta_id = $firstPointID . $secondPointID . $destinationPointID . $pt_fAmount . $pt_sAmount . $ds_symbol;
}
//Array hook for the add
$atts['vyps_meta_id'] = $vyps_meta_id; //Seems like I can pull this in reverse? Just a guess
//I am going to redo the process but just use all the variables.
//I don't know if this is some lazy coding but I am going to just return out if they haven't pressed the button
// Side note: And this is important. The button value should be dynamic to not interfer with other buttons on page
//I tried avoiding calling this before the press, but had to get point names
global $wpdb;
$table_name_points = $wpdb->prefix . 'vyps_points';
$table_name_log = $wpdb->prefix . 'vyps_points_log';
//NOTE: I'm replacing these SQL calls with functions that also do SQL calls
//First source point name and Icon
$f_sourceName = vyps_point_name_func($firstPointID); //I'm 80% sure that the $atts will be the same. From vyps_point_func.php
$f_sourceIcon = vyps_point_icon_func($firstPointID); //I'm 80% sure that the $atts will be the same. From vyps_point_func.php
//NOTE: Second source point. Perhaps I should write something more to differentiate.
//Only does the the WPDB if the the secondPointID actually exists. I thought but perhaps greater than 0 is best to rule out negative numbers
if ($secondPointID > 0){
//Second source point name and Icon
$s_sourceName = vyps_point_name_func($secondPointID); //I'm 80% sure that the $atts will be the same. From vyps_point_func.php
$s_sourceIcon = vyps_point_icon_func($secondPointID); //I'm 80% sure that the $atts will be the same. From vyps_point_func.php
}
//NOTE: Output point
//LOGIC: As long as the $woowallet_mode is not turned on it will do this.
if ($vyps_pe_normal_mode == TRUE ) {
//Destination source point name and Icon
$destName = vyps_point_name_func($destinationPointID); //I'm 80% sure that the $atts will be the same. From vyps_point_func.php
$destIcon = vyps_point_icon_func($destinationPointID); //I'm 80% sure that the $atts will be the same. From vyps_point_func.p
} elseif($woowallet_mode == TRUE ) {
//WooWallet mode must be true then. Or 1.
$destName = 'My Wallet';
//So we know WooWallet mod is true so we know it can do this:
//<span class=\"woo-wallet-icon-wallet\"></span>
$destIcon = '<span class=\"woo-wallet-icon-wallet\"></span>'; //Huh the '' vs "" came in handy.
} elseif ($mycred_mode == TRUE ) {
//Mycred on.... honestly... I know I have a 2nd or 3rd conciousness but didn't really think that would be a 3rd possiblity here... Oh well.
$destName = 'myCred Points';
//Mycred wallet icon. ERE WE GO!
$destIcon = '<span class="dashicons dashicons-star-filled static"></span>';
} elseif ($gamipress_mode == TRUE ) {
//Mycred on.... honestly... I know I have a 2nd or 3rd conciousness but didn't really think that would be a 3rd possiblity here... Oh well.
$destName = 'GamiPress Points';
//Mycred wallet icon. ERE WE GO!
$destIcon = '<span class="dashicons dashicons-star-filled static"></span>';
}
//NOTE: I will have two inputs on two different row and the output and transfer button will be spread accross
//As my coding skills have improved greatly in the past 2 months I am redoing this next bit to be more modernized
//But I am still strapped for time, so I'm not going back to apply the updates to the old exchanged
//NOTE: Time check.
//I'm putting this here as you might want to know you still have time before you can click the button before you click the button
//Should only check if we have a time check in 'teh' short codes
//No miliseconds. I'm not sorry.
if ($time_seconds > 0 ){
$last_transfer_query = "SELECT max(id) FROM ". $table_name_log . " WHERE user_id = %d AND vyps_meta_id = %s"; //In theory we should check for the pid as well, but it the btn should make it unique
$last_transfer_query_prepared = $wpdb->prepare( $last_transfer_query, $current_user_id, $vyps_meta_id );
$last_transfer = $wpdb->get_var( $last_transfer_query_prepared ); //Now we know the last id. NOTE: It is possible that there was not a previous transaction.
//return $last_transfer; //DEBUG I think there is something going on here that I'm not aware of.
if ($last_transfer == ''){
//Well nothing should happen. There was no prior entry. Go ahead and check entries
} else {
//We now know the id exists so an entry exists so we need ot check its timed
$last_posted_time_query = "SELECT time FROM ". $table_name_log . " WHERE id = %d";
$last_posted_time_query_prepared = $wpdb->prepare($last_posted_time_query, $last_transfer ); //The ids should all be unique. In theory and in practice.
$last_posted_time = $wpdb->get_var( $last_posted_time_query_prepared ); //Now we know time of the last transaction
//return $last_posted_time; //DEBUG seeing what the time is.
$last_posted_time = strtotime($last_posted_time); //Note sure why the 'new' but it was how PHP man suggested to do it
//return $last_posted_time;
$current_time = date('Y-m-d H:i:s');
$current_time = strtotime($current_time);
$time_passed = $current_time - $last_posted_time; //I'm just making a big guess here that this will work.
$time_left_seconds = $time_seconds - $time_passed; //NOTE: if this number is positive it means they still need to wait.
$display_time = vyps_secondsToTime($time_left_seconds); //This converts the seconds left into something more human readable. Master race machines and replicants need not use.
}
}
$results_message = "Press button to transfer.";
if ( $time_left_seconds > 0 ) {
$results_message = "You have $display_time before another transfer.";
}
if (isset($_POST[ $vyps_meta_id ]) OR $auto_mode == TRUE ) //I'm 90% sure that this will work with automode. As the idea was that we needed to know which button to press, but if its auto it means it loads every time the page is loaded.
{
//Code check.
//First things first. Make sure they have enough damn points to transfer.
$table_name_log = $wpdb->prefix . 'vyps_points_log';
$current_user_id = get_current_user_id();
//Check the first input
$balance_points_query = "SELECT sum(points_amount) FROM ". $table_name_log . " WHERE user_id = %d AND point_id = %d";
$balance_points_query_prepared = $wpdb->prepare( $balance_points_query, $current_user_id, $firstPointID );
$f_balance_points = $wpdb->get_var( $balance_points_query_prepared );
/* I do not ever see the need for a non-formatted need point */
$f_need_points = number_format($pt_fAmount - $f_balance_points);
//Check the second inputs
if ($secondPointID > 0){
$balance_points_query = "SELECT sum(points_amount) FROM ". $table_name_log . " WHERE user_id = %d AND point_id = %d";
$balance_points_query_prepared = $wpdb->prepare( $balance_points_query, $current_user_id, $secondPointID );
$s_balance_points = $wpdb->get_var( $balance_points_query_prepared );
/* I do not ever see the need for a non-formatted need point */
$s_need_points = number_format($pt_sAmount - $s_balance_points);
} else {
$s_balance_points = 0; //Need to zero this out if there was no second point
$s_need_points = 0; //And this as well. Methinks mayhaps I should have thought this through better
}
//Four possible scenarios, both are enough, both are not enough, first is not enough, second is not enough
//NOTE: Now we are adding the other scenario that the time is not enough, but that check will be run above.
if ( $pt_fAmount > $f_balance_points AND $pt_sAmount > $s_balance_points AND $pt_fAmount != 0 ) {
$results_message = "You need $f_need_points $f_sourceName and $s_need_points $s_sourceName more to transfer!";
} elseif ( $pt_fAmount > $f_balance_points AND $pt_fAmount != 0 ) {
$results_message = "Not enough $f_sourceName! You need $f_need_points more.";
} elseif ( $pt_sAmount > $s_balance_points AND $pt_sAmount != 0 ) {
$results_message = "Not enough $s_sourceName! You need $s_need_points more.";
} elseif ( $time_left_seconds > 0 ) {
//This means the timer has not go on long enough
//Need some message.
$results_message = "You have $display_time before another transfer.";
} elseif( $ds_symbol != '' AND $ds_bal_check == 0) {
//Good news everyone. I bothered to have an if chain. That checks if there is a symbol it checks to make sure there is enough balance in it to do transaction.
//$results_message = "Warning. The site does not have enough crypto in its wallet to do a payout. Contact the site admin!";
return "The site wallet does not have enough crypto for a payout. Contact your administrator.";
} else {
//NOTE: OK. We can run the transfer
$table_log = $wpdb->prefix . 'vyps_points_log'; //Not sure if needed
//Reason set for $atts
$atts['reason'] = 'Point Exchange';
//In case the ds symbol is set to something.
//I believe the transfer reason should be considered something else
//As it's basically no longer on the system and not really created a new point amount like the WW transfer.
if ( $ds_symbol != ''){
//Reason set for $atts
$atts['reason'] = 'Point to Crypto Transfer';
}
//NOTE: Going to guess here witht the deduct
$deduct_result= vyps_deduct_func( $atts );
//NOTE: OK we are putting in the DS call. Good luck! You'll need it!
//Also we already checked to see if it had enough balance and the function should do it again anyways.
if( $ds_amount > 0 ) {
//Wasn't that nice we made a function for it!
$dash_move_result = vyps_dashed_slug_move_func($atts);
//I'm making this more informative to me as something is not right.
if ($dash_move_result == 1){
//Doing balance update check.
vyps_balance_func( $atts );
//Results message output for dashed result transfer.
$add_result = 1;
$results_message = "Success. Crypto payout at: ". date('Y-m-d H:i:s'); //NOTE I need to fix this later down the page. I don't have time today and not really that needed.
//NOTE: Was requested that we do a refer for crypto payouts but its doing to be the original
//Refer transfer below.
if ($refer_rate > 0 AND vyps_current_refer_func($current_user_id) != 0 ){
//Note this is a referral... So its an add. Deal with later
$PointType = $firstPointID; //I believe this should work? A refer with crypto payout should do it.
$reason = "Point Transfer Referral"; //It feels like this reason is legnth... But I shows that it was a refer rather than someone on your account transferring you points away
$amount = doubleval($pt_fAmount); //Why do I do a doubleval here again? I think it was something with Wordfence.
$amount = intval($amount * ( $refer_rate / 100 )); //Yeah we make a decimal of the $refer_rate and then smash it into the $amount and cram it back into an int. To hell with your rounding.
$refer_user_id = vyps_current_refer_func($current_user_id); //Ho ho! See the functions for what this does. It checks their meta and see if this have a valid refer code.
//Inserting VY256 hashes AS points! To referral user. NOTE: The meta_ud for 'refer' and meta_subid1 for the ud of the person who referred them
$data = [
'reason' => $reason,
'point_id' => $PointType,
'points_amount' => $amount,
'user_id' => $refer_user_id,
'vyps_meta_id' => 'refer',
'vyps_meta_subid1' => $user_id,
'time' => date('Y-m-d H:i:s')
];
$wpdb->insert($table_log, $data);
//NOTE: I am not too concerned with showing the user they are giving out points to their referral person. They can always check the logs.
$add_result = 1;
}
} else {
$results_message = "Transfer error.";
$add_result = 0;
}
} elseif( $woowallet_mode == true ){
//This catch is if its not DS but is a woowallet output which has no VYPS destination
//I'm going to hope the WW dev didn't mess up his tables.
//I am assuming (WCCW) that the it checked for input points way before now.
$woowallet_result = vyps_woowallet_credit_func( $atts );
if ($woowallet_result == 0){
$results_message = "WooWallet transfer error."; //Not sure if it will do any good, but may help me troubleshoot down the road.
$add_result = 0;
} else {
//If WooWallet works lets say it does.
$results_message = "Success. Exchanged at: ". date('Y-m-d H:i:s');
}
} elseif( $mycred_mode == TRUE ){
//NOTE: mycred stuff goes here
//Developer note... Look at the woowallet stuff above... I seem to have lucked out with my subconcious Developement
//Note WW had its own functions but mycred had a bit better api
$mycred_result = mycred_add( $mycred_reason, $user_id, $pt_dAmount, $vyps_reason );
//Then it must have worked in practice
$results_message = "Success. Exchanged at: ". date('Y-m-d H:i:s');
} elseif( $gamipress_mode == TRUE ){
//Gamipress function call. Doing the output to gamipress
$gamipress_result = gamipress_award_points_to_user( $user_id, $gamipress_point_amount, $gamipress_point_type, array( 'reason' => $gamipress_reason ) );
//Then it must have worked in practice
$results_message = "Success. Exchanged at: ". date('Y-m-d H:i:s');
} else {
//NOTE: Below is the adds for everything after the checks for non-vyps
//AKA this is pure VYPS to VYPS exchanges.
///NOTE NOTE: I added reason into the $atts option as a way to simply have it in the shortcode itself rather than Hardcoded
//My instince is to hard code it, but as my users are my children I should let them be free.
//In theory I just now have to run the add and it all works! In theory...
$add_result = vyps_add_func($atts);
}
//Note $add_result may not matter... I'm just seeing if its defined change the result message... otherwise... It's not that bad.
if ( isset( $add_result )){
if ( $add_result == 1 ) {
//Then it must have worked in practice
$results_message = "Success. Exchanged at: ". date('Y-m-d H:i:s');
} else {
$results_message = "Uknown Error: " . $add_result; //Yeah I would have no clue. Maybe $add_result could tell us.
}
} //End of if defined
} //End of the if for proceeding with transfer. Line 360
} else {
//This is what shows if button has yet to be pressed
}
//Down here is where the end result goes in the returned
//It really didn't matter where this went so going here.
//Here is the destination icon code. As it was become a problem to change every 4 possiblities now * 2 for woo_wallet_transactions
//I decided to just make the destination icon a mini operation variables
if ($woowallet_mode != true ) {
//I am 99.99996% sure that this same for all 4 versions mobile and not.
//With the wonders of ctrl+f I confirmed it is.
$destIcon_output = $destIcon;
} elseif($mycred_mode == TRUE) {
//We do the mycred icon TODO I need to fix this as in two places has to update
$destIcon_output = "<span class=\"dashicons dashicons-star-filled static\"></span>";
} else {
//We do the woowallet mode icon
$destIcon_output = "<span class=\"woo-wallet-icon-wallet\"></span>";
}
//Classic view.
if ($mobile_view == false ) {
//NOTE: Doing a if then, to have two different versions for 1 or 2 inputs
if ($secondPointID == 0){
//Well we know we have only point input as no PID 0
$table_result_ouput = "<table id=\"$vyps_meta_id\">
<tr><!-- First input -->
<td><div align=\"center\">Spend</div></td>
<td><div align=\"center\">$f_sourceIcon $format_pt_fAmount</div></td>
<td>
<div align=\"center\">
<b><form method=\"post\">
<input type=\"hidden\" value=\"\" name=\"$vyps_meta_id\"/>
<input type=\"submit\" class=\"button-secondary\" value=\"Transfer\" onclick=\"return confirm('You are about to transfer $format_pt_fAmount $f_sourceName for $format_pt_dAmount $destName. Are you sure?');\" />
</form></b>
</div>
</td>
<td><div align=\"center\">$destIcon_output $format_pt_dAmount</div></td>
<td><div align=\"center\">Receive</div></td>
</tr>
";
} else {
//Output for when there is two points.
$table_result_ouput = "<table id=\"$vyps_meta_id\">
<tr><!-- First input -->
<td rowspan=\"2\"><div align=\"center\">Spend</div></td>
<td><div align=\"center\">$f_sourceIcon $format_pt_fAmount</div></td>
<td rowspan=\"2\">
<div align=\"center\">
<b><form method=\"post\">
<input type=\"hidden\" value=\"\" name=\"$vyps_meta_id\"/>
<input type=\"submit\" class=\"button-secondary\" value=\"Transfer\" onclick=\"return confirm('You are about to transfer $format_pt_fAmount $f_sourceName and $format_pt_sAmount $s_sourceName for $format_pt_fAmount $destName. Are you sure?');\" />
</form></b>
</div>
</td>
<td rowspan=\"2\"><div align=\"center\">$destIcon_output $format_pt_dAmount</div></td>
<td rowspan=\"2\"><div align=\"center\">Receive</div></td>
</tr>
<tr><!-- Second input -->
<td><div align=\"center\">$s_sourceIcon $format_pt_sAmount</div></td>
</tr>";
} //End of the non mobile view
} else {
//NOTE: Repeat of the final 2 of the 4 possiblities if mobile view
if ($secondPointID == 0){
//Well we know we have only point input as no PID 0
$table_result_ouput = "<table id=\"$vyps_meta_id\">
<tr><!-- First row -->
<td><div align=\"center\">Spend</div></td>
<td><div align=\"center\">$f_sourceIcon $format_pt_fAmount</div></td>
</tr>
<tr><!-- Second row -->
<td><div align=\"center\">Receive</div></td>
<td><div align=\"center\">$destIcon_output $format_pt_dAmount</div></td>
</tr>
<tr><!-- Button row -->
<td colspan = 2>
<div align=\"center\">
<b><form method=\"post\">
<input type=\"hidden\" value=\"\" name=\"$vyps_meta_id\"/>
<input type=\"submit\" class=\"button-secondary\" value=\"Transfer\" onclick=\"return confirm('You are about to transfer $format_pt_fAmount $f_sourceName for $format_pt_dAmount $destName. Are you sure?');\" />
</form></b>
</div>
</td>
</tr>
";
} else {
//Output for when there is two points. NOTE: No need for row/column spans
$table_result_ouput = "<table id=\"$vyps_meta_id\">
<tr><!-- First input -->
<td><div align=\"center\">Spend</div></td>
<td><div align=\"center\">$f_sourceIcon $format_pt_fAmount</div></td>
<tr>
<tr><!-- Second input -->
<td><div align=\"center\">Spend</div></td>
<td><div align=\"center\">$s_sourceIcon $format_pt_sAmount</div></td>
</tr>
<tr> <!-- Output -->
<td><div align=\"center\">Receive</div></td>
<td><div align=\"center\">$destIcon_output $format_pt_dAmount</div></td>
</tr>
<tr><!-- Button-->
<td colspan = 2>
<div align=\"center\">
<b><form method=\"post\">
<input type=\"hidden\" value=\"\" name=\"$vyps_meta_id\"/>
<input type=\"submit\" class=\"button-secondary\" value=\"Transfer\" onclick=\"return confirm('You are about to transfer $format_pt_fAmount $f_sourceName and $format_pt_sAmount $s_sourceName for $format_pt_dAmount $destName. Are you sure?');\" />
</form></b>
</div>
</td>
</tr>
";
} //End of double input
} //End of the mobile view table. I do not believe the other parts need working.
//NOTE: I'm ending the table here and the next is ends
//The only thing that really changes is the last row message. Ergo I can save a lot of code editing by just modifying the below and keeping the above a template.
//I just have to remember to close the damn table or it all blows up.
//Need to check if we are in mobile view and put the span at two.
if ($mobile_view == false ) {
$table_close_output = "
<tr>
<td colspan = 5><div align=\"center\"><b>$results_message</b></div></td>
</tr>
</table>";
//<br><br>$vyps_meta_id"; //Debug: I'm curious what it looks like.
} else {
$table_close_output = "
<tr>
<td colspan = 2><div align=\"center\"><b>$results_message</b></div></td>
</tr>
</table>";
} //End of mobile view check.
//Lets see if it works:
return $table_result_ouput . $table_close_output;
}
/* Telling WP to use function for shortcode */
add_shortcode( 'vyps-pe', 'vyps_point_exchange_func');
/* Ok after much deliberation, I decided I want the WW plugin to go into the pt since it has become the exchange */
/* If you don't have WW, it won't kill anything if you don't call it */
/* WW shortcode was here but moved it out */

+ 5
- 0
vidyen-wc-mmo/index.php View File

@ -0,0 +1,5 @@
<?php
// Silence is golden, but gold has no intrinsic value.
// At least it's easy to trade digital currencies.
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

+ 164
- 0
vidyen-wc-mmo/vidyen-wc-mmo.php View File

@ -0,0 +1,164 @@
<?php
/*
Plugin Name: VYPS Adgate Module
Plugin URI: https://wordpress.org/plugins/vidyen-point-system-vyps/
Description: Installing this plugin allows Adgate Post Backs
Version: 1.0.0
Author: VidYen, LLC
Author URI: https://vidyen.com/
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
/*
* This program 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, version 2 of the License
*
* This program 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.
*
* See <http://www.gnu.org/licenses/>.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
//NOTE: Literally just lets you know function exists.
function vyps_flag_pro_adgate()
{
return 1;
}
//From: https://github.com/wpexplorer/page-templater
/*** Page Templator ***/
class AdGatePageTemplater {
/**
* A reference to an instance of this class.
*/
private static $instance;
/**
* The array of templates that this plugin tracks.
*/
protected $templates;
/**
* Returns an instance of this class.
*/
public static function get_instance() {
if ( null == self::$instance ) {
self::$instance = new AdGatePageTemplater();
}
return self::$instance;
}
/**
* Initializes the plugin by setting filters and administration functions.
*/
private function __construct() {
$this->templates = array();
// Add a filter to the attributes metabox to inject template into the cache.
if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.7', '<' ) ) {
// 4.6 and older
add_filter(
'page_attributes_dropdown_pages_args',
array( $this, 'register_project_templates' )
);
} else {
// Add a filter to the wp 4.7 version attributes metabox
add_filter(
'theme_page_templates', array( $this, 'add_new_template' )
);
}
// Add a filter to the save post to inject out template into the page cache
add_filter(
'wp_insert_post_data',
array( $this, 'register_project_templates' )
);
// Add a filter to the template include to determine if the page has our
// template assigned and return it's path
add_filter(
'template_include',
array( $this, 'view_project_template')
);
// Add your templates to this array.
$this->templates = array(
'adgate-postback-template.php' => 'Adgate Post Back Template',
);
}
/**
* Adds our template to the page dropdown for v4.7+
*
*/
public function add_new_template( $posts_templates ) {
$posts_templates = array_merge( $posts_templates, $this->templates );
return $posts_templates;
}
/**
* Adds our template to the pages cache in order to trick WordPress
* into thinking the template file exists where it doens't really exist.
*/
public function register_project_templates( $atts ) {
// Create the key used for the themes cache
$cache_key = 'page_templates-' . md5( get_theme_root() . '/' . get_stylesheet() );
// Retrieve the cache list.
// If it doesn't exist, or it's empty prepare an array
$templates = wp_get_theme()->get_page_templates();
if ( empty( $templates ) ) {
$templates = array();
}
// New cache, therefore remove the old one
wp_cache_delete( $cache_key , 'themes');
// Now add our template to the list of templates by merging our templates
// with the existing templates array from the cache.
$templates = array_merge( $templates, $this->templates );
// Add the modified cache to allow WordPress to pick it up for listing
// available templates
wp_cache_add( $cache_key, $templates, 'themes', 1800 );
return $atts;
}
/**
* Checks if the template is assigned to the page
*/
public function view_project_template( $template ) {
// Return the search template if we're searching (instead of the template for the first result)
if ( is_search() ) {
return $template;
}
// Get global post
global $post;
// Return template if post is empty
if ( ! $post ) {
return $template;
}
// Return default template if we don't have a custom one defined
if ( ! isset( $this->templates[get_post_meta(
$post->ID, '_wp_page_template', true
)] ) ) {
return $template;
}
// Allows filtering of file path
$filepath = apply_filters( 'page_templater_plugin_dir_path', plugin_dir_path( __FILE__ ) );
$file = $filepath . get_post_meta(
$post->ID, '_wp_page_template', true
);
// Just to be safe, we check if the file exist first
if ( file_exists( $file ) ) {
return $file;
} else {
echo $file;
}
// Return template
return $template;
}
}
add_action( 'plugins_loaded', array( 'AdGatePageTemplater', 'get_instance' ) );
/*** Includes ***/
include( plugin_dir_path( __FILE__ ) . 'includes/shortcodes/vyps-adgate.php'); //Adding AdGate support. Not the naming convention change.
include( plugin_dir_path( __FILE__ ) . 'includes/shortcodes/vyps-adgate-postback.php'); //AdGate post back
include( plugin_dir_path( __FILE__ ) . 'includes/functions/core/vyps_adgate_pro_func.php'); //Adgate Pro checking.
/*** Menu Includes ***/
include( plugin_dir_path( __FILE__ ) . 'includes/menus/adgate-menu.php'); //Order 450 (residual from the extraction for core VYPS)

Loading…
Cancel
Save