2012-06-27 156 views
0

我的網絡託管公司最近升級到Apache 2.2.22和PHP 5.3.13,此後一段腳本無法正常工作。該網頁是無線電流媒體,現在從文本文件更新曲目信息的部分根本不顯示。流光工作正常,其他第三方小工具也是如此。Web主機升級後AJAX/PHP無法正常工作

這裏是腳本中顯示唱片封面的一部分:

updateNowPlayingInfo = function() { 
var d = new Date(); 
$.ajax('/php_proxy_simple.php?url=playingnow.txt&_=' + d.getTime(), { 
    complete: function(jqXHR, textStatus) { console.log('RMX Player XHR completed: ' +textStatus); }, 
    error: function(jqXHR, textStatus, errorThrown) { console.log('RMX Player XHR error:' + textStatus + ':' + errorThrown); }, 
    xhr: (window.ActiveXObject) ? 
    function() { 
      try { 
       return new window.ActiveXObject("Microsoft.XMLHTTP"); 
      } catch(e) {} 
     } : 
     function() { 
      return new window.XMLHttpRequest(); 
     }, 
    cache: true, 
    type: 'GET', 
    crossDomain: true, 
    dataType: 'text', 
    global: false, // @note was using false 
    ifModified: true, 
    success: function(data, textStatus, jqXHR) { 

     //alert(playingData); 
     playingData = data.split("\n"); 

     if (playingData[2] && ! playingData[2].match(/no-image-no-ciu/)) { 
      //playingData[2] = playingData[2].replace('SS110', 'AA280'); // swap small image for medium 
      //console.log(playingData[2]); 
      playingData[2] = playingData[2].replace('_SL160_', '_SX200_'); // swap small image for large 
      $("#nowplaying_album_cover img").attr("src" , playingData[2]); 
      $("#nowplaying_album_cover").show(); 
      } 
     else $("#nowplaying_album_cover").attr("src" , playingData[2]); 
     $("#nowplaying_album_cover").show(); 
     }, 
    failure: function() { alert('failed to get play data') ; } 
}); 

而且PHP代碼:

<?php 
// PHP Proxy example for Yahoo! Web services. 
// Responds to both HTTP GET and POST requests 

// Allowed hostname 
define ('HOSTNAME', 'http://www.mysite.co/'); 

// Get the REST call path from the AJAX application 
// Is it a POST or a GET? 
ini_set('error_reporting', 0); 
$path = ($_POST['url']) ? $_POST['url'] : $_GET['url']; 
$url = HOSTNAME.$path.'?timestamp=' . time(); 

// Open the Curl session 
$session = curl_init($url); 

// If it's a POST, put the POST data in the body 
if ($_POST['url']) { 
    $postvars = ''; 
    while ($element = current($_POST)) { 
     $postvars .= urlencode(key($_POST)).'='.urlencode($element).'&'; 
     next($_POST); 
    } 
    curl_setopt ($session, CURLOPT_POST, true); 
    curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars); 
} 

// Don't return HTTP headers. Do return the contents of the call 
curl_setopt($session, CURLOPT_HEADER, false); 
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); 

// Make the call 
$response = curl_exec($session); 

// possibly include expires header to bust aggresive caching -expires=>’+1s’ 
header('Content-Type: text/html;charset=utf-8'); 

echo $response; 
curl_close($session); 

?> 

我抓住這個從原始日誌文件:

「GET /playingnow.txt HTTP/1.1「304

不確定這是否相關。任何幫助,將不勝感激。謝謝

+2

304意味着沒有修改 –

+0

那麼,它在做什麼?你怎麼知道它不工作? –

+2

狀態304未被修改。快速猜測 - 您的Apache配置現在正在緩存* .txt文件。告訴Apache停止這樣做,或者不要使用* .txt作爲你的URL。尋找'ExpiresByType text/plain'或類似的。 –

回答

1

修復它,PHP文件的文件權限需要在0644。謝謝。

相關問題