<?php

/**
 * Recent pages, topics in forums, users, comments
 *
 * @package recentitems
 * @version 0.7.0
 * @author Cotonti Team
 * @copyright Copyright (c) Cotonti Team 2008-2012
 * @license BSD
 */
defined('COT_CODE') or die("Wrong URL.");

class Piyasalar {

	var $temp_xml;

	function __construct(){
	
		$this->url = 'http://realtime.paragaranti.com/asp/xml/icpiyasa.asp';
	
	}
	
	function get_data(){
	
		$data = @file_get_contents($this->url);
		$this->temp_xml = $data;
	
	}
	
	function parse_data($node = ''){
	
		if(strlen($this->temp_xml) < 10) {
			$this->get_data();
		}

		$nodes = explode('>', $node);

		$node_count = count($nodes);
		$data = $this->temp_xml;


		for($i=0; $i < $node_count; $i++) {
		$sme="";
			if(strpos($nodes[$i], "[") > 1) {
					$a = strpos($nodes[$i], "[");
					$nodex = substr($nodes[$i], 0, strlen($nodes[$i]) - ($a-2));

					$sme = substr($nodes[$i], $a+1, 1);

			} else {
			
					$nodex = $nodes[$i];
					
			}

			$data = explode('<'.$nodex.'>',$data);

			if($sme != "") {

				$data = explode('</'.$nodex.'>',$data[$sme]);
				
			} else {
			
				$data = explode('</'.$nodex.'>',$data[1]);
			}
					
			$data = $data[0];

		}
		
		return $data;
	
	}

}

?>