2012-06-27 99 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。谢谢。

相关问题