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

AlmogBaku לא מחובר  

תשחק קצת עם הקוד, מאוד פשוט..
[php]
<?php
תשחק קצת עם הקוד, מאוד פשוט..
PHP קוד:
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 
status($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] = status($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); 

$text "server: {!Ip}:{!Port}<br />\n"
    
."listeners: {!Listeners}<br />\n"
    
."Song: {!Song}<br />\n"
    
."Peak: {!Peak}<br />\n"
    
."Bitrate: {!Bitrate}<br />\n"
    
."Stats: {!Status}\n";

replacetags($textlocalhost7000); 
?> 
נסה את זה.. זה יותר פשוט. תנסה להבין..
בעקרון מה שעשיתי פה אם אני זוכר נכון - התחברתי לדף של הshoutcast ושאבתי מידע מהעמוד הראשי-HTML.
זה די מסורבל כי זו עבודה ממש ישנה, ואני בכלל לא בטוח אם ז העדיין תקף- אבל אין סיבה שלא.

Last edited by AlmogBaku; 17-12-07 at 17:54..
  Reply With Quote