הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   עזרה עם xml (https://hosts.co.il/forums/showthread.php?t=57978)

AmStAf 16-12-07 20:03

עזרה עם xml
 
שלום.
אני מנסה לעשות קוד לרדיו אשר יציג את מספר המאזינים;
הגעתי לדבר פשוט שמציג את שם השיר.
עכשיו אני מעונין לעשות לכמות מאזינים וכן האלה...
הנה הצגת שם השיר:
http://ip:port/title.html
למישהו יש רעיון / יודע איך לעשות לכמות מאיזינים?
תודה. :-D

daMn 16-12-07 22:23

לא יצא לי להתעסק עם שרתי רדיו ומספר מאזינים, אבל אם יש לך פאנל של shoutcast אז אני זוכר שזה מראה את המאזינים ותוכל לקחת בpreg מדף רחוק בפעולה די פשוטה.

AlmogBaku 17-12-07 15:20

אני לא ממש זוכר איך עשיתי את זה אבל הנה קוד שבניתי לפני כמה שנים[בערך 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']);
?>


AmStAf 17-12-07 16:29

אמ חחח
זה לא ממש מובן לי..
אם תוכל להסביר אולי בפשטות
מה אני אמור להדביק בדף אינטרנט?
תודה.

AlmogBaku 17-12-07 16:45

תשחק קצת עם הקוד, מאוד פשוט..
[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.
זה די מסורבל כי זו עבודה ממש ישנה, ואני בכלל לא בטוח אם ז העדיין תקף- אבל אין סיבה שלא.


כל הזמנים הם GMT +2. הזמן כעת הוא 22:25.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ