אשכול: עזרה עם xml
View Single Post
ישן 17-12-07, 15:20   # 3
AlmogBaku
חבר וותיק
 
AlmogBaku's Avatar
 
מיני פרופיל
תאריך הצטרפות: Nov 2007
מיקום: מודיעין
הודעות: 1,022

AlmogBaku לא מחובר  

אני לא ממש זוכר איך עשיתי את זה אבל הנה קוד שבניתי לפני כמה שנים[בערך 3], תנסה להבין, לשנות ולהתאים
PHP קוד:
 <?php
if(empty($_GET['ip'])) {
    
$settings['ip'] = "84.95.240.244"// Your radio server's ip
} else{
    
$settings['ip'] = $_GET['ip'];
}
if(empty(
$_GET['port'])) {
    
$settings['port'] = 1234// Your radio server's port
} else {
        
$settings['port'] = $_GET['port'];
}

function 
servinfo($ip$port) {
    
$fp fsockopen($ip$port$errno$errstr30);
    if (!
$fp) {
       echo 
"$errstr ($errno)<br />\n";
    } else {
       
$out "GET /7.html HTTP/1.1\r\n";
       
$out .= "User-Agent: Mozilla/4.0 (compatible; MSIE 4.0; Windows NT 5.0)\r\n";
       
$out .= "Host: $ip:$port\r\n";
       
$out .= "Connection: Close\r\n\r\n";
       
       
fputs($fp$out);
       while (!
feof($fp)) {
           
$read fread($fp500);
       }
       
fclose($fp);
       
$rtxt substr($readstrpos($read"\r\n\r\n") + 4);
       return 
$rtxt;
    }
}
function 
replacetags($msg$ip$port) {
    
$explode explode(","servinfo($ip$port));
    
$ex_listeners explode("<body>"$explode[0]);
    
$listeners $ex_listeners[1];
    
$ex_song explode("</body></html>"$explode[6]);
    
$song $ex_song[0];
    
    function 
stats($num) {
        if(
$num == 1) {
            return 
"Run";
        } elseif(
$num == 0) {
            return 
"Down";
        }
    }
    
    
$rules[0] = "{!Listeners}";
    
$rules[1] = "{!Status}";
    
$rules[2] = "{!Peak}";
    
$rules[3] = "{!Max}";
    
$rules[4] = "{!Bitrate}";
    
$rules[5] = "{!Song}";
    
$rules[6] = "{!Ip}";
    
$rules[7] = "{!Port}";
    
$rules[8] = "{!Server}";
    
    
$replaces[0] = $listeners;
    
$replaces[1] = stats($explode[1]);
    
$replaces[2] = $explode[2];
    
$replaces[3] = $explode[3];
    
$replaces[4] = $explode[5];
    
$replaces[5] = $song;
    
$replaces[6] = $ip;
    
$replaces[7] = $port;
    
$replaces[8] = $ip ":" $port;
    
    echo 
str_replace($rules$replaces$msg);
}
if(empty(
$_GET['txt'])) {
    
$text "
    server: {!Ip}:{!Port}<BR>
    listeners: {!Listeners}<BR>
    Song: {!Song}<BR>
    Peak: {!Peak}<BR>
    Bitrate: {!Bitrate}<BR>
    Stats: {!Status}
    "
;
} else {
    
$text $_GET[txt];
}
replacetags($text$settings['ip'], $settings['port']);
?>
  Reply With Quote