Fitness Sports Junkie is an online sports community web platform where people can stay connected & fit forever in and around their community.

Product List

Uncategorized

© 2020 Ernest Pest Control | All Rights Reserved | Powered by GoViral Australia




Providing commercial and domestic pest control services since 2000

0425 305 626 I SYDNEY

Fitness in the Park

Fitness in the Park

function get_price_metal($metal,$currency) { global $wpdb; $metal_name=$metal.'_rate'; $sql="select $metal_name from gol_metalrate where id=1"; $result=$wpdb->get_results($wpdb->prepare($sql)); $sql_currency="select $currency from gol_currency where id=1"; $result_currency=$wpdb->get_results($wpdb->prepare($sql_currency)); return $result[0]->$metal_name; } //Call CURL and pass URL and API KEY function httpGet($url,$apiKey) { $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_HEADER, false); // curl_setopt($ch, CURLOPT_HTTPHEADER, array( // 'X-API-KEY: ' . $apiKey // )); $output=curl_exec($ch); curl_close($ch); return $output; } function save_goldrate(){ $api_key='https://api.metals.live/v1/spot'; $URL=strtolower($api_key); $json=httpGet($URL,''); $descode_arr=json_decode($json,true); //print_r($descode_arr); //$currency_rate='1.293109'; global $wpdb; // if($_24karat_rate!=0) // { // echo "UPDATE gol_metalrate SET gold_rate='".$descode_arr[0]['gold']."' where 1"; // if($descode_arr[0]['gold']!='0.00' && $descode_arr[2]['silver']!='0.00' && $descode_arr[1]['platinum']!='0.00' && $descode_arr[3]['palladium']!='0.00') // { $html = file_get_contents('https://www.abcbullion.com.au/'); $doc = new DOMDocument(); $doc->loadHTML($html); $liList = $doc->getElementsByTagName('li'); $liValues = array(); foreach ($liList as $li) { $liValues[] = $li->nodeValue; } $gold_p=$liValues[0]; $new_gold_p=str_replace('BUY GOLD','',$gold_p); $silver_p=$liValues[1]; $new_silver=str_replace('BUY SILVER','',$silver_p); $sql = "UPDATE gol_metalrate SET gold_rate='".$new_gold_p."',silver_rate='".$new_silver."' where 1"; $wpdb->query($wpdb->prepare($sql)); //} //} // endif; } function save_currencyrate(){ $api_key='https://openexchangerates.org/api/latest.json?app_id=ff67f7970687420f94ed293aa505eac2&base=USD'; $URL=strtolower($api_key); $json=httpGet($URL,''); $descode_arr=json_decode($json,true); $aud=$descode_arr['rates']['AUD']; $usd=$descode_arr['rates']['USD']; $hkd=$descode_arr['rates']['HKD']; $cny=$descode_arr['rates']['CNY']; //$currency_rate='1.293109'; global $wpdb; // if($_24karat_rate!=0) // { // echo "UPDATE gol_metalrate SET gold_rate='".$descode_arr[0]['gold']."' where 1"; echo $sql = "UPDATE gol_currency SET AUD='$aud',USD='$usd',HKD='$hkd',CNY='$cny' where 1"; $wpdb->query($wpdb->prepare($sql)); //} // endif; } //add_action('parse_query', 'save_currencyrate'); add_action( 'savecurrency_oneminute_event', 'save_currencyrate' ); //add_action('parse_query', 'save_goldrate'); add_action( 'savegoldprice_oneminute_event', 'save_goldrate' ); function save_goldrate_caret(){ $currency_code="AUD"; //You can change it to the currency of your chouce $unit_type="gram"; $currency_code = strtolower($currency_code); $unit_type = strtolower($unit_type); $result_data= (array) display_gold_rates()[0]; $api_key=$result_data['url']; $xmlfile = file_get_contents($api_key); $ob= simplexml_load_string($xmlfile); $json = json_encode($ob); $result = json_decode($json, true); $spot_price=str_replace('AUD', '', trim($result['div'][1])); //echo $result['ul']['li'][0]; $_9karat_rate= str_replace(' Per Gram', '', str_replace('9k : $', '', $result['ul']['li'][0])); $_10karat_rate= str_replace(' Per Gram', '', str_replace('10k : $', '', $result['ul']['li'][1])); $_14karat_rate= str_replace(' Per Gram', '', str_replace('14k : $', '', $result['ul']['li'][2])); $_18karat_rate= str_replace(' Per Gram', '', str_replace('18k : $', '', $result['ul']['li'][3])); $_21karat_rate= str_replace(' Per Gram', '', str_replace('21k : $', '', $result['ul']['li'][4])); $_22karat_rate= str_replace(' Per Gram', '', str_replace('22k : $', '', $result['ul']['li'][5])); $_24karat_rate= str_replace(' Per Gram', '', str_replace('24k : $', '', $result['ul']['li'][6])); $gmt_datetime_gold_updated='0000-00-00 00:00:00'; $gmt_datetime_currency_updated='0000-00-00 00:00:00'; //$currency_rate='1.293109'; global $wpdb; if($_24karat_rate!=0) { $sql = "UPDATE gol_goldrate SET gold_rate='".$_24karat_rate."', gmt_datetime_gold_updated='".$gmt_datetime_gold_updated."', gmt_datetime_currency_updated='".$gmt_datetime_currency_updated."', 24karat_rate ='".$_24karat_rate."', 22karat_rate ='". $_22karat_rate ."', 21karat_rate ='". $_21karat_rate."', 18karat_rate ='". $_18karat_rate ."', 14karat_rate ='". $_14karat_rate."', 10karat_rate ='". $_10karat_rate."', 9karat_rate ='". $_9karat_rate."', spot_price ='". $spot_price ."', serilized_result ='' WHERE currency_code = 'AUD'"; $wpdb->query($wpdb->prepare($sql)); } // endif; } add_action( 'savegoldprice_event', 'save_goldrate_caret' ); function create_notification() { $args = array( $args_1, $args_2 ); if (! wp_next_scheduled ( 'savegoldprice_oneminute_event', $args )) { wp_schedule_event( time(), '5min', 'savegoldprice_oneminute_event', $args ); } $args = array( $args_1, $args_2 ); if (! wp_next_scheduled ( 'savecurrency_oneminute_event', $args )) { wp_schedule_event( time(), 'daily', 'savecurrency_oneminute_event', $args ); } $args = array( $args_1, $args_2 ); if (! wp_next_scheduled ( 'savegoldprice_event', $args )) { // wp_schedule_event( time(), '30min', 'savegoldprice_event', $args ); } } add_action('init', 'create_notification'); // function display_gold_rates() // { // global $wpdb; // $sql="select * from gol_goldrate where id=1"; // $result=$wpdb->get_results($wpdb->prepare($sql)); // return $result; // } // function get_price_metal($metal,$currency) // { // global $wpdb; // $metal_name=$metal.'_rate'; // $sql="select $metal_name from gol_metalrate where id=1"; // $result=$wpdb->get_results($wpdb->prepare($sql)); // $sql_currency="select $currency from gol_currency where id=1"; // $result_currency=$wpdb->get_results($wpdb->prepare($sql_currency)); // return $result[0]->$metal_name; // } function my_cron_schedules($schedules){ if(!isset($schedules["5min"])){ $schedules["5min"] = array( 'interval' => 5*60, 'display' => __('Once every 5 minutes')); } if(!isset($schedules["1min"])){ $schedules["1min"] = array( 'interval' => 1*60, 'display' => __('Once every 1 minutes')); } if(!isset($schedules["1sec"])){ $schedules["1sec"] = array( 'interval' => 1, 'display' => __('Once every 1 seconds')); } if(!isset($schedules["30min"])){ $schedules["30min"] = array( 'interval' => 30*60, 'display' => __('Once every 30 minutes')); } return $schedules; } add_filter('cron_schedules','my_cron_schedules'); function CCAjax() { global $wpdb; $currency=$_POST['currency']; $gold=get_price_metal('gold',$currency); $silver=get_price_metal('silver',$currency); $platinum=get_price_metal('platinum',$currency); $paladium=get_price_metal('paladium',$currency); //get_template_part( 'gold', 'rate' ); $sql_currency="select $currency from gol_currency where id=1"; $result_currency=$wpdb->get_results($wpdb->prepare($sql_currency)); //print_r($result_currency); $currency_p=$result_currency[0]->$currency; $c_i=number_format((float)$currency_p,'2','.',''); $json=array('gold_price'=>$gold,'silver_price'=>$silver,'platinum_price'=>$platinum,'paladium_price'=>$paladium,'c_i'=>$c_i); echo json_encode($json); wp_die(); } // creating Ajax call for WordPress add_action('wp_ajax_nopriv_CCAjax', 'CCAjax'); add_action('wp_ajax_CCAjax', 'CCAjax'); function CCAjaxtime() { echo gmdate("i:s", sh_get_next_cron_time('savegoldprice_oneminute_event')); exit(); } // creating Ajax call for WordPress add_action('wp_ajax_nopriv_CCAjaxtime', 'CCAjaxtime'); add_action('wp_ajax_CCAjaxtime', 'CCAjaxtime'); function sh_get_next_cron_time( $cron_name ){ foreach( _get_cron_array() as $timestamp => $crons ){ if( in_array( $cron_name, array_keys( $crons ) ) ){ return $timestamp - time(); } } return false; } function display_gold_rates() { global $wpdb; $sql="select * from gol_goldrate where id=1"; $result=$wpdb->get_results($wpdb->prepare($sql)); return $result; }