setLogin ($login); $this->setPassword ($password); } function getCurrencyRates () { $field_delimiter = '~'; $line_delimiter = '|'; $http_client = new Zend_Http_Client ($this->getWebapiServer ('/webapi/currency.php')); $http_client->setParameterGet ('delim', $field_delimiter); $http_client->setParameterGet ('linebreak', $line_delimiter); $http_client->setParameterGet ('login', $this->getLogin ()); $http_client->setParameterGet ('webapipassword', $this->getPassword ()); $response = $http_client->request (); if ($response->getStatus () == 200) if (strpos ($response->getBody (), $field_delimiter) !== false) if (strpos ($response->getBody (), $line_delimiter) !== false) { $result = array (); foreach (explode ($line_delimiter, $response->getBody ()) as $line) { $item = explode ($field_delimiter, $line); if (count ($item) == 3) { $result [$item [0]] = array ( 'name' => $item [1], 'rate' => $item [2], ); } } return $result; } } protected function getWebapiServer ($path = null) { $result = 'http://api.templatemonster.com'; if (Kohana::config ('core.api-server')) { $result = Kohana::config ('core.api-server'); } if (isset ($path)) { $result .= $path; } return $result; } function setPassword ($password) { $this->password = $password; } function getPassword () { return $this->password; } function setLogin ($login) { $this->login = $login; } function getLogin () { return $this->login; } }