Exemple #1
0
function playlist_editor($plid, $prev, $sort = 0)
{
    global $runinit, $cfg;
    $kpd = new kpdesign();
    $kpd->top(false, get_lang(59));
    $radiocolor = array(0 => '#7FFFD4', 1 => '#FFBF00');
    $radioseq = array();
    $kppl = new kp_playlist($plid);
    if ($kppl->isloaded() && $kppl->anyaccess()) {
        if ($kppl->soleaccess()) {
            $access = 1;
        } else {
            if ($kppl->writeaccess()) {
                $access = 2;
            } else {
                $access = 3;
            }
        }
        $scrolly = frm_get('scrolly', 1, 0);
        if (ALLOWDOWNLOAD && db_guinfo('u_allowdownload') && $cfg['archivemode'] && db_guinfo('allowarchive')) {
            $dlbutton = true;
        } else {
            $dlbutton = false;
        }
        $result = db_execquery('SELECT * FROM ' . TBL_PLAYLIST_LIST . ' WHERE listid = ' . $plid . ' ORDER BY seq ASC');
        if ($result) {
            $cnt = db_num_rows($result);
        } else {
            $cnt = 0;
        }
        if (UNAUTHORIZEDSTREAMS) {
            $extra = '<a class="bbox" href="' . PHPSELF . '?streamplaylist=' . $plid . '&amp;extm3u=true">i</a> &nbsp;';
        } else {
            $extra = '';
        }
        echo blackboxpart(get_lang(46, $kppl->getname(), $cnt), 1, $extra);
        if (WINDOWPLAYER) {
            $kpwjs = new kpwinjs();
            $playcode = '<input type="button" value="' . get_lang(42) . '" class="fatbuttom" onclick="javascript: ' . $kpwjs->playlist($plid) . '"/>';
        } else {
            $playcode = '<input type="submit" name="playplaylist" value="' . get_lang(42) . '" class="fatbuttom"/>';
        }
        ?>
		<form style="margin:0;padding:0" action="<?php 
        echo PHPSELF;
        ?>
" method="post">
		<input type="hidden" name="action" value="playlisteditor"/>
		<input type="hidden" name="sel_playlist" value="<?php 
        echo $plid;
        ?>
"/>
		<input type="hidden" name="previous" value="<?php 
        echo $prev;
        ?>
"/>
		<input type="hidden" name="drive" value="<?php 
        echo $runinit['drive'];
        ?>
"/>

		<table width="700" cellspacing="2" border="0" cellpadding="2">
		<tr class="wtext">
			<td><?php 
        echo get_lang(92);
        ?>
</td>
			<td><?php 
        echo get_lang(54);
        ?>
</td>
			<td><?php 
        echo get_lang(44);
        ?>
</td>
			<td><?php 
        echo get_lang(125);
        ?>
</td>
			<td></td>
		</tr>
		<tr>
			<td>				
				<?php 
        echo '<input type="button" value="' . get_lang(34) . '" class="fatbuttom" onclick="javascript: chhttp(\'' . PHPSELF . '?pwd=' . $prev . '&amp;d=' . $runinit['drive'] . '\');"/>' . '&nbsp; ';
        echo $playcode . '&nbsp; ';
        if ($access == 1) {
            echo '<input type="submit" name="deleteplaylist" onclick="javascript: if (!confirm(\'' . get_lang(169) . '\')) return false;" value="' . get_lang(43) . '" class="fatbuttom"/>' . '&nbsp; ';
        }
        if ($dlbutton) {
            echo '<input type="button" name="pdlall" value="' . get_lang(117) . '" onclick="javascript: newwin(\'dlplaylist\', \'' . PHPSELF . '?action=dlplaylist&amp;pid=' . $plid . '\', 130, 450);" class="fatbuttom"/>';
        }
        ?>
			</td>
			<?php 
        echo '<td>';
        if ($access == 1) {
            echo '<input type="text" name="playlistname" value="' . checkchs($kppl->getname()) . '" size="25" class="fatbuttom"/>';
        } else {
            echo checkchs($kppl->getname());
        }
        echo '</td><td>';
        if ($access == 1) {
            echo '<select name="public" class="fatbuttom" style="width:100px">' . $kppl->selectaccess() . '</select>';
        } else {
            echo '<select name="public" class="fatbuttom" disabled="disabled" style="width:100px">' . $kppl->selectaccess() . '</select>';
        }
        echo '</td><td>';
        if ($access == 1) {
            echo '<input type="checkbox" name="shuffle" value="1" ' . checked($kppl->getstatus()) . '/>';
        } else {
            echo '<input disabled="disabled" type="checkbox" name="shuffle" value="1" ' . checked($kppl->getstatus()) . '/>';
        }
        echo '</td><td>';
        if ($access == 1) {
            echo '<input type="submit" class="fatbuttom" name="saveplaylist" value="' . get_lang(45) . '"/>';
        }
        echo '&nbsp; <input type="submit" class="fatbuttom" name="refresh" value="' . get_lang(107) . '"/>';
        ?>
			</td>
		</tr>
		<tr>
			<td colspan="2">
			<?php 
        if ($access == 1 || $access == 2) {
            echo '<input type="button" name="upload" onclick="' . jswin('upload', '?action=playlistupload&amp;plid=' . $plid, 220, 520) . '" value="' . get_lang(234) . '" class="fatbuttom"/>&nbsp; ';
            echo '<select name="sort" class="fatbuttom">';
            $sorts = array(0 => get_lang(170), 1 => get_lang(171), 2 => get_lang(173), 3 => get_lang(180));
            echo selectoptions($sorts, $sort);
            echo '</select> &nbsp;';
            echo '<input type="submit" name="sortplaylist" value="' . get_lang(172) . '" class="fatbuttom"/>';
        }
        ?>
			</td>
		</tr>
		<?php 
        $min = time() - 1800;
        $res = db_execquery('SELECT * FROM ' . TBL_ICERADIO . ' WHERE lactive > ' . $min . ' AND playlistid = ' . $plid);
        if (db_num_rows($res) > 0 && ($access == 1 || $access == 2)) {
            echo '<tr><td>' . get_lang(369) . '</td></tr>';
            echo '<tr><td colspan="5">';
            $colorc = 0;
            while ($row = db_fetch_assoc($res)) {
                $kpr = new kpradio($row['stationid']);
                if ($kpr) {
                    if (!isset($radiocolor[$colorc])) {
                        $radiocolor[] = '#CCCCCC';
                    }
                    if (!isset($radioseq[$kpr->getcurseq()])) {
                        $radioseq[$kpr->getcurseq()] = $radiocolor[$colorc];
                    }
                    echo '<input class="fatbuttom" title="' . $kpr->getname() . '" style="background-color:' . $radiocolor[$colorc] . '" size="6" type="text" name="nextradioseq_' . $row['stationid'] . '" value="' . lzero($kpr->getnextseq()) . '"/> &nbsp;';
                    $colorc++;
                }
            }
            echo ' &nbsp;<input type="submit" class="fatbuttom" name="saveradiosequence" value="' . get_lang(45) . '"/>';
            echo '</td></tr>';
        }
        ?>
		</table>
		</form>
		<?php 
        echo blackboxpart(get_lang(46), 2);
        echo '<br/>';
        echo '<form onsubmit="javascript: savescrolly();" style="margin:0;padding:0" name="psongs" action="' . PHPSELF . '" method="post">';
        echo '<input type="hidden" name="previous" value="' . $prev . '"/>';
        echo '<input type="hidden" name="drive" value="' . $runinit['drive'] . '"/>';
        echo '<input type="hidden" name="sort" value="0"/>';
        echo '<input type="hidden" name="sel_playlist" value="' . $plid . '"/>';
        echo '<input type="hidden" id="scrolly" name="scrolly" value="0"/>';
        echo '<input type="hidden" name="action" value="playlisteditor"/>';
        if ($access == 1 || $access == 2) {
            echo blackboxpart(get_lang(47), 1);
        } else {
            echo blackboxpart(get_lang(48), 1);
        }
        if ($cnt > 0) {
            echo '<table width="700" cellspacing="0" border="0" cellpadding="0">';
            ?>
			<tr>
				<td width="70" class="wtext"><?php 
            echo get_lang(49);
            ?>
</td>
				<td width="70" class="wtext"><?php 
            echo get_lang(50);
            ?>
</td>
				<td width="110" class="wtext"><?php 
            echo get_lang(52);
            ?>
</td>
				<td width="95" class="wtext"><?php 
            if ($access == 1 || $access == 2) {
                echo get_lang(53);
            }
            ?>
</td>
				<td width="355" class="wtext"><?php 
            echo get_lang(141);
            ?>
</td>
			</tr>
			<?php 
            echo '<tr><td height="8"></td></tr>';
            echo '<tr bgcolor="#BCBCBC"><td colspan="5" height="1"></td></tr>';
            echo '<tr><td height="6"></td></tr>';
            $totalsec = $count = $countfails = 0;
            while ($row = db_fetch_assoc($result)) {
                $count++;
                $id = $row['id'];
                $f2 = new file2($row['sid'], true);
                if ($f2) {
                    $id3 = $f2->getid3();
                    if (is_numeric($id3['lengths'])) {
                        $totalsec += $id3['lengths'];
                    }
                    $seq = (int) $row['seq'];
                    if (isset($radioseq[$seq])) {
                        echo '<tr bgcolor="' . $radioseq[$seq] . '">';
                    } else {
                        if ($count % 2 == 0) {
                            echo '<tr class="row2nd">';
                        } else {
                            echo '<tr>';
                        }
                    }
                    echo '<td align="center">';
                    echo '<input type="checkbox" class="wtext" name="selected[]" value="' . $id . '"/>';
                    echo '</td>';
                    echo '<td>';
                    if ($access == 1 || $access == 2) {
                        echo '<input class="smalltext" type="text" name="seq[]" value="' . lzero($seq) . '" size="4"/>';
                    } else {
                        echo lzero($row['seq']);
                    }
                    echo '</td>';
                    echo '<td>';
                    if (is_numeric($id3['bitrate']) && $id3['bitrate'] != 0 && strlen($id3['length']) != 0) {
                        echo $id3['bitrate'] . 'kb - ' . $id3['length'];
                    }
                    echo '</td>';
                    echo '<td>';
                    if ($access == 1 || $access == 2) {
                        echo '<input title="' . get_lang(60) . '" class="fatbuttom" type="submit" name="singledel_' . $id . '" value="' . get_lang(43) . '"/>';
                    }
                    echo '</td>';
                    echo '<td><a ' . $f2->mkalink() . '>' . checkchs($f2->gentitle(array('title', 'artist'), 60)) . '</a></td>';
                    echo '</tr>';
                }
            }
            echo '<tr><td height="8"></td></tr>';
            echo '<tr bgcolor="#BCBCBC"><td colspan="5" height="1"></td></tr>';
            echo '<tr><td height="6"></td></tr>';
            $secs = $totalsec;
            $days = floor($secs / 86400);
            $secs = $secs % 86400;
            $hours = floor($secs / 3600);
            $secs = $secs % 3600;
            $min = floor($secs / 60);
            $secs = $secs % 60;
            $totshow = get_lang(187, $days, $hours, $min, $secs);
            echo '<tr><td colspan="2" class="wtext" align="center"><b>' . get_lang(55) . '</b></td><td>' . $totshow . '</td></tr>';
            echo '<tr><td height="12"></td></tr>';
            echo '<tr><td align="left" class="file" colspan="5">';
            echo '&nbsp;&nbsp;' . get_lang(73) . '&nbsp;&nbsp;<input type="button" value="+" class="fatbuttom" onclick="javascript: selectall();"/>&nbsp;&nbsp;';
            echo '<input type="button" value="-" class="fatbuttom" onclick="javascript: disselectall();"/>&nbsp;&nbsp;';
            echo get_lang(57) . '&nbsp;&nbsp;<input type="submit" class="fatbuttom" onclick="javascript: if (!anyselected()) { alert(\'' . get_lang(159) . '\'); return false; }" name="playselected" value="' . get_lang(42) . '"/>&nbsp;&nbsp;';
            if ($access == 1 || $access == 2) {
                echo '<input type="submit" class="fatbuttom" onclick="javascript: if (!anyselected()) { alert(\'' . get_lang(159) . '\'); return false; } else if (!confirm(\'' . get_lang(210) . '\')) return false;" name="delselected" value="' . get_lang(43) . '"/>&nbsp;&nbsp;';
                echo get_lang(58) . '&nbsp;&nbsp;<input type="submit" class="fatbuttom" name="saveseq" value="' . get_lang(45) . '"/>';
            }
            echo '</td></tr>';
            echo '<tr><td height="12"></td></tr>';
            echo '</table>';
        } else {
            echo get_lang(302);
        }
        if ($access == 1 || $access == 2) {
            echo blackboxpart(get_lang(47), 2);
        } else {
            echo blackboxpart(get_lang(48), 2);
        }
        echo '</form>';
        ?>
		<script type="text/javascript">
		<!--
			window.scrollTo(0, <?php 
        echo $scrolly;
        ?>
);
		-->
		</script>
		<?php 
    }
    $kpd->bottom();
}