somehow i can not run AJAX localmachine with Apache... anyone can help me with this problem ?
this source i use:
it did work on the webserver..
index.php
<?php
session_start();
function isin($word, $string) {
$length = strlen($word);
for($a=0;$a<$length;$a++){
$output = substr($word,$a,strlen($string));
if ($string == $output) { return true; }
}
}
#include "../config/db.php";
#include "../config/ip.php";
?>
<script type="text/javascript">
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") {
http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
http = new XMLHttpRequest();
}
function retrievewr(url) {
alert(url);
http.abort();
http.open("POST", "radio/winamp/waradios.php?&channel=" + url, true);
http.onreadystatechange=function() {
if(http.readyState == 4 && http.status == 200) {
document.getElementById('RRadios').innerHTML = http.responseText;
}
if(http.readyState == 4 && http.status != 200) {
setTimeout("retrievewr(url)", 1);
}
}
http.send(null);
}
</script>
<style>
td.Cchatters {
width: 90px;
font-size: 8pt;
font: ARIAL;
}
</style>
<table border=1 width=20%>
<tr>
<td valign=top class="Cchatters" width=30%>
<img src="../../chat2/design/optionfield-RoomsChatters.gif" onmouseover="javascript:display('rooms_show');nodisplay('chatters_show');validaterooms();">
<div id=Crooms style="position:relative;z-index: 7;margin-top: -30px; padding-top: 5px; color: black; text-align: center; width: 100px;"><b>Winamp's<b></div>
</td>
<td valign=top class="Cchatters" width=30%>
<img src="../../chat2/design/optionfield-RoomsChatters.gif" onmouseover="javascript:nodisplay('rooms_show');display('chatters_show');">
<div id=Crooms style="position:relative;z-index: 7;margin-top: -30px; padding-top: 5px; color: black; text-align: center; width: 100px;"><b>Radio Stations<b></div>
</td>
<td valign=top class="Cchatters" width=30%>
<img src="../../chat2/design/optionfield-RoomsChatters.gif" onmouseover="javascript:nodisplay('rooms_show');display('chatters_show');">
<div id=Crooms style="position:relative;z-index: 7;margin-top: -30px; padding-top: 5px; color: black; text-align: center; width: 100px;"><b>Site DJ's<b></div>
</td>
</tr>
<tr>
<td colspan=3 width=100%>
<?php include "cathegorys.php"; ?>
<?php include "waradios.php"; ?>
</td>
</tr>
</table>
cathegorys.php
<style>
#RMenu {
display: block;
position:absolute;
width: 400px;
height: 200px;
overflow: scroll;
font-size: 8pt;
font: ARIAL;
scrollbar-face-color: #0D2623;
scrollbar-shadow-color: #0B5D51;
scrollbar-highlight-color: #004C49;
scrollbar-3dlight-color: #27847A;
scrollbar-darkshadow-color: #004C49;
scrollbar-track-color: #05372B;
scrollbar-arrow-color: #28887D;
scrollbar-base-color: #0D2623
border: 1px solid black;
}
</style>
<?php
## Scan Radio Menu.
$divname = "RMenu";
$menu = "href=\"/media/radio/";
$url = "http://www.winamp.com/media/radio/";
## Scan Radio Classes.
$filehandle = fopen($url, "r");
$total = "0";
echo "<div id=".$divname." style=\"position:relative;\">";
while (!feof($filehandle)) {
$line = fgets($filehandle, 4096);
$line = str_replace("class=\"selected\" ", "", $line);
$line = str_replace(" class=\"odd\"", "", $line);
$line = str_replace("»", "", $line);
$line = str_replace(" ", "", $line);
$line = str_replace("title=\"Listen\">", "", $line);
$line = str_replace("<img align=\"absmiddle\" hspace=\"5\" src=\"http://media.winamp.com/main/images/buttons/listen.gif\" border=\"0\" alt=\"Listen\">", "", $line);
$line = str_replace(" ", " ", $line);
if (isin($line, $menu) == "true") {
$total++;
$cathegory = preg_replace('/\<li\>\<a href=\"(.*)\">(.*)/', '$2', $line );
$cathegory = str_replace(" ", "", $cathegory);
$cathegory = str_replace("</a></li>", "", $cathegory);
if ($cathegory == "Top50") echo '<a href="javascript:retrievewr(\'/\');">';
if ($cathegory != "Top50") echo '<a href="javascript:retrievewr(\'/'.$cathegory.'\');">';
echo $cathegory;
echo '</a><br>';
}
}
fclose($filehandle);
echo "</div>";
?>
waradios.php
<style>
#RRadios {
display: block;
position:absolute;
width: 400px;
height: 200px;
overflow: scroll;
font-size: 8pt;
font: ARIAL;
scrollbar-face-color: #0D2623;
scrollbar-shadow-color: #0B5D51;
scrollbar-highlight-color: #004C49;
scrollbar-3dlight-color: #27847A;
scrollbar-darkshadow-color: #004C49;
scrollbar-track-color: #05372B;
scrollbar-arrow-color: #28887D;
scrollbar-base-color: #0D2623
border: 1px solid black;
}
</style>
<?php
function isinn($word, $string) {
$length = strlen($word);
for($a=0;$a<$length;$a++){
$output = substr($word,$a,strlen($string));
if ($string == $output) { return true; }
}
}
## Scan Radio Menu.
$divname = "RRadios";
$menu = "href=\"/media/radio/";
$url = "http://www.winamp.com/media/radio";
$url .= $_REQUEST['channel'];
## Scan Radio Classes.
$radio = "tunein-station.pls?id=";
$filehandle = fopen($url, "r");
$total = "0";
echo "<div id=".$divname." style=\"position:relative;\">";
while (!feof($filehandle)) {
$line = fgets($filehandle, 4096);
$line = str_replace("class=\"selected\" ", "", $line);
$line = str_replace(" class=\"odd\"", "", $line);
$line = str_replace("»", "", $line);
$line = str_replace(" ", "", $line);
$line = str_replace("title=\"Listen\">", "", $line);
$line = str_replace("<img align=\"absmiddle\" hspace=\"5\" src=\"http://media.winamp.com/main/images/buttons/listen.gif\" border=\"0\" alt=\"Listen\">", "", $line);
$line = str_replace(" ", " ", $line);
if (isinn($line, $radio) == "true") {
$line = preg_replace('/\<li\>\<a href=\"(.*)\"(.*)\<\/a\>/U', '$2', $line );
$line = preg_replace('/ \<strong\>\<a href=\"(.*)\" title=\"(.*)\">(.*)\<\/a\>\<\/strong\>/U', '<a href=$1>$3</a>', $line );
echo $line;
echo '<br>';
}
}
fclose($filehandle);
echo "</div>";
?>
Regards.