/*
$connectArgs = array();
$connectArgs['getID'] = $getID;
$connectArgs['blockChain'] = 'polygonscan';
$connectArgs['polygonKey'] = $polygonKey;
$connectArgs['action'] = 'balance';
$encodeArgs = json_encode($connectArgs);
error_log('allbre_curl $connectArgs from transactions.php: Update MATIC ' . $encodeArgs);
$connectArgs['polygonAddress'] = $polygonAddress;
$connectArgs['message'] = 'Updates MATIC balance at this time for post_meta';
###################
### allbre_curl ###
# updates MATIC balance for transaction meta
$connectArgs['caller'] = 'update_5';
$connectArgs['debug'] = $debug;
$response = apply_filters( 'allbre_curl',$connectArgs);
###################
$maticBalance = $response;
*/
/*
$args = array(
'fields' => 'ids',
'post_type' => 'transaction',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'ID',
'order' => 'DESC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'symbol',
'value' => '',
'compare' => '='
),
array(
'key' => 'profit_loss',
'value' => '',
'compare' => '='
),
array(
'key' => 'gas_fee',
'value' => '',
'compare' => '='
),
)
);
*/
/*
# View error logs in page
if ($tempID == 753) {
$filename = ini_get('error_log');
$handle = fopen($filename, 'r+');
while (($data = fgets($handle, 1000)) !== FALSE) {
# $logData .= preg_replace("/\[[^)]+\]/","",$data);
$logData[] = $data;
}
fclose($handle);
var_dump($logData); exit;
echo apply_filters( 'allbre_var_dump',array($data,'$data')); exit;
$logData = str_replace('Done with the_content!','',$logData);
$logData = str_replace('--------------','',$logData);
echo '
';
echo trim(substr($logData,-1000));
echo '
';
}
*/
/*
$tempGet = file_get_contents($tempString);
$tempArray = json_decode($tempGet,true);
$daiBalance = $tempArray['result'];
*/
/*
$daiBalance = get_option( 'dai_balance');
$oldDai = get_option( 'dai_balance');
if (empty($oldDai)) {
$oldDai = $daiBalance;
}
update_option('dai_balance',$daiBalance);
*/
/*
if ($getID == 1970){
echo '$key: ' . $key . '
';
echo '$tempGstamp: ' . $tempGstamp . ' >= ' . $getTime . '
';
echo 'not empty $isGains: ' . $isGains . '
';
echo 'empty $getPloss: ' . $getPloss . '
';
echo 'not empty $isClose: ' . $isClose . '
';
}
*/
# Polygonscan API proc_close
# get DAI balance for account at block number or time
$blockno = 27468778;
$tempString = 'https://api.polygonscan.com/api?module=account&action=tokenbalancehistory&contractaddress=' . $tempContract . '&address=' . $tempAddress . '&blockno=' . $blockno . '&apikey=' . $tempApiKey;
# echo 'LOOK: ' . $tempNonce . ' < $tempNonce : ' . $tempInput . ' : ' . $isGains;
foreach($myGains as $key => $value) {
$tempGkey = $key;
$tempGdate = $value['date'];
$tempGdate = substr($tempGdate,0,16);
$tempGpair = $value['pair'];
$tempGaction = $value['action'];
$tempGbuy = $value['buy'];
$tempGpair = '';
$tempSymbol = '';
$tempBuy = '';
$tempAction = '';
}
/*
if ($tempDate >= $tempGdate && !empty($isGains)) {
$prevKey = $key - 1;
echo apply_filters( 'allbre_var_dump',array($key,'$key'));
echo apply_filters( 'allbre_var_dump',array($value,'$value'));
echo 'This one ^
';
$tempGpair = $myGains[$prevKey]['pair'];
$tempGpair = strtok($tempGpair, '/');
$tempSymbol = $tempGpair;
if (empty($tempSymbol)) {
echo 'waiting for Gains';
}
$tempBuy = $myGains[$prevKey]['buy'];
$tempAction = $myGains[$prevKey]['action'];
break;
}
*/
/*
$tempString = __DIR__ . '/trading-history-24h.json';
$tempString = file_get_contents($tempInfo);
*/
/*
# Update DAI
$connectArgs['getID'] = $id;
$connectArgs['contractAddress'] = $daiContract;
$connectArgs['blockChain'] = 'polygon-dai';
$connectArgs['polygonAddress'] = $polygonAddress;
$connectArgs['polygonKey'] = $polygonKey;
echo apply_filters( 'allbre_var_dump',array($connectArgs,'$connectArgs'));
$encodeArgs = json_encode($connectArgs);
error_log('allbre_curl $connectArgs from transactions.php: Update DAI ' . $encodeArgs);
###################
### allbre_curl ###
# gets my DAI balance from Polygon
$response = apply_filters( 'allbre_curl',$connectArgs);
###################
$tempMonitor .= $response;
*/
/*
case 'polygon-dai';
#echo apply_filters( 'allbre_var_dump',array($tempData,'$tempData')); exit;
# gets my DAI balance from Polygon
$tempData = $tempArray -> result;
/*
$tempDai = get_transient('polygon_dai_price');
error_log('Previous DAI: polygon_dai_price: ' . $tempDai);
error_log('New DAI: $tempData: ' . $tempData);
*/
# echo apply_filters( 'allbre_var_dump',array($tempData,'$tempData'));
$tempGains = 0;
if (!empty($getID)) {
$tempInput = get_post_meta($getID,'input_string',true);
if (stristr($tempInput,'0x9aa7c0e5') == true ) {
$tempGains = 1;
}
if ($tempData < $tempDai && !empty($tempGains)) {
$tempUpdate = $tempDai;
} else {
$tempUpdate = $tempData;
}
error_log('DAI update post: $tempUpdate: ' . $tempUpdate);
update_post_meta($getID,'dai_balance',$tempUpdate);
} elseif ($tempData > $tempDai) {
set_transient('polygon_dai_price', $tempData, 7 * DAY_IN_SECONDS );
error_log('Updated polygon_dai_price transient.');
}
break;
/*
case 'polygon-dai';
# gets my DAI balance from Polygon
$tempAddress = $args['polygonAddress'];
$tempApiKey = $args['polygonKey'];
$tempContract = $args['contractAddress'];
$tempString = 'https://api.polygonscan.com/api?module=account&action=tokenbalance&contractaddress=' . $tempContract . '&address=' . $tempAddress . '&tag=latest&apikey=' . $tempApiKey;
# echo apply_filters( 'allbre_var_dump',array($tempString,'$tempString'));
error_log('polygon-dai string: ' . $tempString);
$cURLConnection = curl_init();
break;
*/
# 2022-04-02T17:17:01.000Z
foreach($myGains as $key => $value) {
$tempGkey = $key;
$tempGdate = $value['date'];
$tempGdate = substr($tempGdate,0,16);
$tempGpair = $value['pair'];
echo apply_filters( 'allbre_var_dump',array($key,'$key'));
echo apply_filters( 'allbre_var_dump',array($value,'$value'));
if ($tempDate >= $tempGdate) {
$thisGains = $tempGkey;
$tempGpair = strtok($tempGpair, '/');
break;
}
}
$thisGains = $myGains[$thisGains];
$connectArgs['symbol'] = $tempGpair;
echo apply_filters( 'allbre_var_dump',array($debug,'$debug'));
echo apply_filters( 'allbre_var_dump',array($tempDate,'$tempDate'));
echo apply_filters( 'allbre_var_dump',array($connectArgs,'$connectArgs'));
*/
/*
add_action('wp_ajax_newbid', 'newbid_ajax');
function newbid_ajax() {
$post_id = $_POST['id'];
$mybid = get_post_meta($post_id, 'start_price', true);
$mybid = $mybid + 100;
update_post_meta($post_id,'start_price',$mybid);
die($mybid);
}
add_action('wp_head','my_ajaxurl');
function my_ajaxurl() {
$html = '';
echo $html;
}
*/
/* register session */
/*
add_action('init', 'register_my_session');
function register_my_session() {
if (!session_id()) {
session_start();
}
}
*/