我的网络托管公司最近升级到 Apache 2.2.22 和 PHP 5.3.13,从那以后一段脚本将无法正常工作。该网页是一个无线电流媒体,现在从文本文件更新曲目信息的部分根本不显示。流媒体工作正常,其他第三方小部件也是如此。
这是显示专辑封面的脚本的一部分:
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
不确定这是否相关。任何帮助,将不胜感激。谢谢