laimas,
https://pp.userapi.com/c840427/v8404...-HKT_Q-TXA.jpg https://pp.userapi.com/c840427/v8404...qWb0Jgc4mg.jpg Верно? А тут адрес моего второго сайта? header('Access-Control-Allow-Origin: http://domain_2'); |
Цитата:
|
А тут адрес моего второго сайта?
header('Access-Control-Allow-Origin: http://domain_2'); а то уже скоро 0:00 |
laimas,
уже 23:45 верно всё? |
|
Что не так то?
страница моего первого сайта где будет курс <style> /*общие правила для элементов отображающих курс*/ span[class|=rate] { display: block; text-align: center; padding: 3px 0; color: #000; font-weight: bold; } /*правила для знака доллара*/ span[class|=rate]:before { margin-right: 10px; content: "$"; } /*общие правила для стрелок*/ span[class|=rate]:after { margin-left: 10px; } /*правила для стрелки вверх*/ .rate-1:after { content: "▲"; color: #BC0101; } /*правила для стрелки вниз*/ .rate-0:after { content: "▼"; color: #089301; } </style> <div id="usd" class=""> <span id="current" class="rate-0"></span> <span id="previous" class="rate-0"></span> </div> <script> $.getJSON("http://h116641.s08.test-hf.su/", function(data) { $.each(data, function(k, o) { $('#'+k).text(o.value).attr('class', function() { return this.className.replace(/\d/, o.rate) }) }) }); </script> index.php <? header('Access-Control-Allow-Origin: адрес сайта где выводить курс.ру'); header('Vary: Origin'); header('Access-Control-Allow-Methods: GET'); header('Content-type: application/json; charset=utf-8'); exit(file_get_contents('current/current.json')); ?> .htaccess <Files *> Deny from all </Files> current.json {"current":{"date":"8.2.2018","value":56.95,"rate" :"▼"},"previous":{"date":"7.2.2018","value":57.2 2,"rate":"▲"}} current.php <? $dir = dirname(__FILE__); chdir($dir); libxml_use_internal_errors(); if($xml = simplexml_load_file('http://www.cbr.ru/scripts/XML_dynamic.asp?date_req1='.date('d/m/Y', strtotime('-2 day')).'&date_req2='.date('d/m/Y').'&VAL_NM_RQ=R01235')) { $last = round((float)str_replace(',', '.', current($xml->Record[0]->Value)), 2); $usd_prev = round((float)str_replace(',', '.', current($xml->Record[1]->Value)), 2); $usd_curr = round((float)str_replace(',', '.', current($xml->Record[2]->Value)), 2); chmod($dir, 0777); //уточнить у хостера file_put_contents('current.json', json_encode([ 'current' => [ 'date' => date('j.n.Y'), 'value' => $usd_curr, 'rate' => intval($usd_curr > $usd_prev) ], 'previous' => [ 'date' => date('j.n.Y', strtotime('-1 day')), 'value' => $usd_prev, 'rate' => intval($usd_prev > $last) ] ], JSON_UNESCAPED_UNICODE) ); chmod($dir, 0644); //уточнить у хостера } ?> |
В этом файле current.json данные не изменились
|
когда в файле index.php прописано
exit(file_get_contents('current/current.json')); то отображается его содержимое. А когда в index.php прописан полный путь exit(file_get_contents('http://h116641.s08.test-hf.su/current/current.json')); то в этом файле ничего не видно пусто |
Цитата:
|
Цитата:
|
Часовой пояс GMT +3, время: 05:59. |