<?php
/**
* @ 2016 J!Life
* @ http://joomlalife.com
* @ GNU/GPL licence
*
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
class plgContentjlife_gold extends JPlugin
{
public function onContentPrepare($context, &$row, &$params, $page = 0) {
$row->text = preg_replace('|{gold}|e', '$this->insertgold()', $row->text);
return true;
}
function insertgold(){
require_once 'simple_html_dom.php';
$html = file_get_html('http://www.forexpf.ru/chart/gold/');
// Золото
foreach($html->find('.stat tr[4] td[1]') as $a){
$gold = str_replace(",",".",$a->plaintext);
}
// Курсы
$gold_999 = round($gold * 0.97,0);
$gold_375 = round(($gold_999/100)*37.5,0);
$gold_585 = round(($gold_999/100)*58.5,0);
$gold_750 = round(($gold_999/100)*75,0);
$gold_850 = round(($gold_999/100)*85,0);
$gold_900 = round(($gold_999/100)*90,0);
$gold_916 = round(($gold_999/100)*91.6,0);
return $text;
}
}