RadioDJ - Free Radio Automation Software Forum

Ajutor live_stat.php (php+ mysql)

Offline ThP

  • ***
  • 102
Ajutor live_stat.php (php+ mysql)
« on: September 14, 2013, 09:26:24 PM »
Am o rugaminte catre cei care cunosc php + mysql si care sunt dispusi sa ma ajute.
Doresc sa fac 2 modificari fisierului live_stat.php dupa cum urmeaza:

1. Sa inversez NOW PLAYING cu SOON ON RADIO DJ (NOW PLAYING sa fie afisat deasupra SOON ...). Partea cu RECENTLY nu ma intereseaaz deloc.

2. Sa modific in asa fel incat daca RDJ are in emisie un internet stream (song_type=5) sa NU imi mai afiseze deloc SOON ...

Eu am modificat linia care imi afisaza melodia curenta in asa fel incat sa imi afiseze SI internet stream (song_type=5) pe pagina, la NOW PLAYING.

Code: [Select]
<?php
$query 
"SELECT `ID`, `date_played`, `artist`, `title`, `duration` FROM `history` WHERE (`song_type` = 0 OR `song_type` = 5) ORDER BY `date_played` DESC LIMIT 0," . ($resLimit+1);
?>

Aici m-am impotmolit ...

Trebuie intercalat acolo ceva in genul

Code: [Select]
<?php
if (song_type 0) { echo "NOW PLAYING & SOON ..."; }

if (
song_type 5) { echo "only NOW PLAYING without SOON ..."; }
?>

Postez mai jos fisierul live_stat.php din care am scos tot ce tine de style/format pentru a simplifica lucrurile.

Code: [Select]
<?php
/* ============================================================================= */
// EDIT BELOW
/* ============================================================================= */
$pageTitle "Now Playing";

$nextLimit 5; // How many upcoming tracks to display?
$shufleUpcoming False; // Don't show the correct order of upcoming tracks

//$resLimit = 5; // How many history tracks to display?

/* ============================================================================= */
// END EDIT
/* ============================================================================= */

require_once('serv_inc.php');
//require_once('header.php');

function 
convertTime($seconds) {
$sec $seconds;
    
// Time conversion
    
$hours intval(intval($sec) / 3600);
    
$padHours True;
    
$hms = ($padHours)
        ? 
str_pad($hours2"0"STR_PAD_LEFT). ':'
        
$hours':';
    
$minutes intval(($sec 60) % 60);
    
$hms .= str_pad($minutes2"0"STR_PAD_LEFT). ':';
    
$seconds intval($sec 60);
    
$hms .= str_pad($seconds2"0"STR_PAD_LEFT);

return $hms;
}
db_conn();

$shuffleQuery null;

If (
$shufleUpcoming == True) {
$shuffleQuery " ORDER BY RAND()";
}

$nextquery "SELECT songs.ID, songs.artist, songs.title, queuelist.songID FROM songs, queuelist WHERE songs.song_type=0 AND songs.ID=queuelist.songID" $shuffleQuery " LIMIT 0," $nextLimit;
$resultx mysql_query($nextquery);

if (!
$resultx) {
echo mysql_error();
exit;
}

if (
mysql_num_rows($resultx) > 0) {

// If there tracks in the playlist, we show them
$inc 0;
echo "<hr />";
echo "SOON ON RADIODJ<br />";

while($rowx mysql_fetch_array($resultx)) {
echo "" htmlspecialchars($rowx['artist'], ENT_QUOTES) . " - " htmlspecialchars($rowx['title'], ENT_QUOTES) . "";

//if the current track is not the last, we put a separator
if ($inc < (mysql_num_rows($resultx) -1)) {
echo "<br />";
}

$inc += 1;
}




$query "SELECT `ID`, `date_played`, `artist`, `title`, `duration` FROM `history` WHERE (`song_type` = 0 OR `song_type` = 5) ORDER BY `date_played` DESC LIMIT 0," . ($resLimit+1);

$result mysql_query($query);

if (!
$result) {
echo mysql_error();
exit;
}

if (
mysql_num_rows($result) == 0) {
exit;
}

$inc 0;

while(
$row mysql_fetch_assoc($result)) {
if ($inc == 0) {
echo "<hr />";
echo "NOW PLAYING<br />";
echo "" htmlspecialchars($row['artist'], ENT_QUOTES) . " - " htmlspecialchars($row['title'], ENT_QUOTES) . "";


if ($resLimit 0) {

/*Nu ma intereseaza RECENT
echo "<hr />";
echo "RECENTLY PLAYED SONGS<br />";*/
}

} else {

/*Nu ma intereseaza RECENT
if ($resLimit > 0) {
echo "" . date('H:i:s', strtotime($row['date_played'])) . " - " . htmlspecialchars($row['artist'], ENT_QUOTES) . " - " . htmlspecialchars($row['title'], ENT_QUOTES) . "111111<br />";
}*/
}
$inc += 1;
}

@
mysql_free_result($result);
db_close($opened_db);
//require_once('footer.php');
?>

Va multumesc anticipat.

Offline Marius

  • *****
  • 5622
    • Radio DJ
Re: Ajutor live_stat.php (php+ mysql)
« Reply #1 on: September 14, 2013, 09:39:57 PM »
Salut, vezi ca datele sunt in doua tabele diferite.
Din "history" poti sa scoti numai piesa curenta si ce a fost.
Ca sa scoti ce va urma, trebuie sa folosesti si tabela "queuelist".

Daca nu te descurci posteaza aici si voi incerca sa te ajut.
DOWNLOADS PAGE

HOW TO FIX RADIODJ DATABASE
----------------
Please don't PM me for support requests. Use the forums instead.

Offline ThP

  • ***
  • 102
Re: Ajutor live_stat.php (php+ mysql)
« Reply #2 on: September 14, 2013, 10:12:39 PM »
Cred ca nu am explicat cum trebuie.

1. Vreau sa inversez pozitia in pagina a celor 2 (NOW .... si SOON ...). Exemplu.

2. La noi DJ emit intrun shoutcast (privat). RDJ preia acel shoutcast ca internet stream. In momentul in care RDJ preia acel shoutcast (internet stream), nu vreau sa imi afiseze partea cu SOON. Exemplu.

Va multumesc anticipat.

Offline ThP

  • ***
  • 102
Re: Ajutor live_stat.php (php+ mysql)
« Reply #3 on: September 17, 2013, 03:03:56 PM »
Am rezolvat.