Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $date_now = date('Y-m-d');
- $result = $db->query("SELECT * FROM curr WHERE date = '$date_now'");
- if($result->num_rows) {
- while($row = $result->fetch_array(MYSQLI_ASSOC)) {
- $xml = $row['xml'];
- }
- }
- else {
- $xml = file_get_contents('http://www.nationalbank.kz/rss/rates_all.xml');
- $db->query("INSERT INTO curr (date, xml) VALUES ('$date_now', '$xml')");
- }
- if(count($expltext) > 2) {
- $expltext[1] = strtoupper($expltext[1]);
- $expltext[2] = strtoupper($expltext[2]);
- $curr1 = preg_replace('/.+?<title>' . $expltext[1] . '<\/title><pubDate>.+?<\/pubDate><description>(.+?)<\/description>.+/', '$1', $xml);
- $curr2 = preg_replace('/.+?<title>' . $expltext[2] . '<\/title><pubDate>.+?<\/pubDate><description>(.+?)<\/description>.+/', '$1', $xml);
- $curr1 = ($expltext[1] == 'KZT') ? 1 : $curr1;
- $curr2 = ($expltext[2] == 'KZT') ? 1 : $curr2;
- $response = '1' . $expltext[1] . ' = ' . ($curr2 / $curr1) . $expltext[2];
- }
- else {
- $response = '/lazy';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement