Example #1
0
<?php

if (Session::is_group_user("Music Admin")) {
    $tracks = Tracks::get_deleted();
    foreach ($tracks as $track) {
        $id = $track->get_id();
        $md5 = $track->get_md5();
        $archive = $track->get_archive();
        $dir = $archive->get_localpath();
        $folder = $md5[0];
        $files = array(0 => '.flac', 1 => '.xml');
        $tables = array(0 => 'audioartists', 1 => 'audiocomments', 2 => 'audiodir', 3 => 'audiogroups', 4 => 'audiojinglepkgs', 5 => 'audiokeywords', 6 => 'audioplaylists', 7 => 'audiousers');
        $wherepre = "audioid = " . $id;
        $where = pg_escape_string($wherepre);
        $track_id_escaped = pg_escape_string($id);
        DigiplayDB::delete('audio', "id = " . $track_id_escaped);
        foreach ($tables as $table) {
            DigiplayDB::delete($table, $where);
        }
        foreach ($files as $file) {
            $path = $dir . "/" . $folder . "/" . $md5 . $file;
            $cmd = "rm " . $path;
            shell_exec($cmd);
        }
    }
    if (Errors::occured()) {
        http_response_code(400);
        exit(json_encode(array("error" => "Something went wrong. You may have discovered a bug!", "detail" => Errors::report("array"))));
        Errors::clear();
    } else {
        exit(json_encode(array('response' => 'success', 'id' => 1)));
Example #2
0
<?php

Output::set_title("Trash");
$index = isset($_REQUEST["i"]) ? explode(",", $_REQUEST["i"]) : array("title", "artist", "album");
$limit = isset($_GET["n"]) && is_numeric($_REQUEST["n"]) ? $_GET["n"] : 10;
$page = isset($_REQUEST["p"]) && is_numeric($_REQUEST["p"]) ? $_REQUEST["p"] : 1;
MainTemplate::set_subtitle("Find a track in the database, edit track details");
$tracks = Tracks::get_deleted($limit, ($page - 1) * $limit);
if ($tracks) {
    $pages = new Paginator();
    $pages->items_per_page = $limit;
    $pages->index = implode(",", $index);
    $pages->mid_range = 5;
    $pages->items_total = Tracks::count_deleted();
    $pages->paginate();
    $low = ($page - 1) * $limit + 1;
    $high = $low + $limit - 1 > Tracks::count_deleted() ? Tracks::count_deleted() : $low + $limit - 1;
    echo "<script>\n\t\t\$(function () {\n\t\t\t\$('.track-info').popover({\n\t\t\t\t'html': true, \n\t\t\t\t'trigger': 'hover',\n\t\t\t\t'title': function() { \n\t\t\t\t\treturn(\$(this).parent().parent().find('.title').html())\n\t\t\t\t},\n\t\t\t\t'content': function() {\n\t\t\t\t\treturn(\$(this).parent().find('.hover-info').html());\n\t\t\t\t}\n\t\t\t});\n" . (Session::is_group_user("Playlist Admin") ? "\n\t\tvar item;\n\t\t\$('.playlist-add').click(function() {\n\t\t\titem = \$(this).parent().parent();\n\t\t\tplaylists = \$(this).attr('data-playlists-in').split(',');\n\t\t\t\$('.playlist-select').parent().removeClass('active');\n\t\t\t\$('.playlist-select').find('span').removeClass('glyphicon-minus').addClass('glyphicon-plus');\n\t\t\t\$('.playlist-select').each(function() {\n\t\t\t\tif(\$.inArray(\$(this).attr('data-playlist-id'),playlists) > -1) {\n\t\t\t\t\t\$(this).find('span').removeClass('icon-plus').addClass('glyphicon-minus');\n\t\t\t\t\t\$(this).parent().addClass('active');\n\t\t\t\t}\n\t\t\t})\n\t\t});\n\n\t\t\$('.playlist-select').click(function() {\n\t\t\tobj = \$(this);\n\t\t\tif(\$(this).parent().hasClass('active')) {\n\t\t\t\t\$(this).find('span').removeClass('glyphicon-minus').addClass('glyphicon-refresh');\n\t\t\t\t\$.ajax({\n\t\t\t\t\turl: '" . LINK_ABS . "ajax/track-playlist-update.php',\n\t\t\t\t\tdata: 'trackid='+item.attr('id')+'&playlistid='+obj.attr('data-playlist-id')+'&action=del',\n\t\t\t\t\ttype: 'POST',\n\t\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-minus');\n\t\t\t\t\t\talert(value.error);\n\t\t\t\t\t},\n\t\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\t\tvalues = \$.parseJSON(data);\n\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-plus');\n\t\t\t\t\t\tobj.parent().removeClass('active');\n\t\t\t\t\t\titem.find('.playlist-add').attr('data-playlists-in',values.playlists.join(','));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t\$(this).find('span').removeClass('glyphicon-plus').addClass('glyphicon-refresh');\n\t\t\t\t\$.ajax({\n\t\t\t\t\turl: '" . LINK_ABS . "ajax/track-playlist-update.php',\n\t\t\t\t\tdata: 'trackid='+item.attr('id')+'&playlistid='+obj.attr('data-playlist-id')+'&action=add',\n\t\t\t\t\ttype: 'POST',\n\t\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-plus');\n\t\t\t\t\t\talert(value.error);\n\t\t\t\t\t},\n\t\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\t\tvalues = \$.parseJSON(data);\n\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-minus');\n\t\t\t\t\t\tobj.parent().addClass('active');\n\t\t\t\t\t\titem.find('.playlist-add').attr('data-playlists-in',values.playlists.join(','));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t\$(this).parent().addClass('active');\n\t\t\t\t\$(this).find('span').removeClass('glyphicon-plus').addClass('glyphicon-minus');\n\t\t\t}\n\t\t});\t\t\n" : "") . (Session::is_group_user("Music Admin") ? "\n\t\tvar trackid;\n\t\t\$('.track-delete').click(function() {\n\t\t\t\$('.delete-track-title').html(\$(this).parent().parent().find('.title').html());\n\t\t\ttrackid = \$(this).attr('data-dps-id');\n\t\t});\n\n\t\t\$('.yes-definitely-delete').click(function() {\n\t\t\t\$.ajax({\n\t\t\t\turl: '" . LINK_ABS . "ajax/remove-track.php',\n\t\t\t\tdata: { id: trackid },\n\t\t\t\ttype: 'POST',\n\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\talert(value.error);\n\t\t\t\t},\n\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\twindow.location.reload(true); \n\t\t\t\t}\n\t\t\t});\n\t\t});\n" : "") . "\t\t});\n\t</script>";
    echo "<a href=\"#\" id=\"flag\" data-toggle=\"modal\" data-target=\"#empty-modal\" class=\"btn btn-danger btn-block\">" . Bootstrap::glyphicon("warning-sign") . " Empty Trash</a>";
    echo "<p></p>";
    echo "<h3>" . Tracks::count_deleted() . " results for deleted items.</small></h3>";
    echo "<div class=\"row\"><div class=\"col-lg-5\"><h5>Showing results " . $low . " to " . $high . "</h5></div><div class=\"pull-right\">" . $pages->display_jump_menu() . $pages->display_items_per_page() . "</div></div>";
    echo "<table class=\"table table-striped\" cellspacing=\"0\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th class=\"icon\"> </th>\n\t\t\t<th class=\"artist\">Artist</th>\n\t\t\t<th class=\"title\">Title</th>\n\t\t\t<th class=\"album\">Album</th>\n\t\t\t<th class=\"length nowrap\">Length</th> \n\t\t\t" . (Session::is_group_user("Playlist Admin") ? "<th class=\"icon\"></th>" : "") . "\n\t\t\t" . (Session::is_group_user("Music Admin") ? "<th class=\"icon\"></th>" : "") . "\n\t\t</tr>\n\t</thead>";
    foreach ($tracks as $track) {
        echo "\n\t\t<tr id=\"" . $track->get_id() . "\">\n\t\t\t<td class=\"icon\">\n\t\t\t\t<a href=\"" . LINK_ABS . "music/detail/" . $track->get_id() . "\" class=\"track-info\">\n\t\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\n\t\t\t\t</a>\n\t\t\t\t<div class=\"hover-info\">\n\t\t\t\t\t<strong>Artist:</strong> " . $track->get_artists_str() . "<br />\n\t\t\t\t\t<strong>Album:</strong> " . $track->get_album()->get_name() . "<br />\n\t\t\t\t\t<strong>Year:</strong> " . $track->get_year() . "<br />\n\t\t\t\t\t<strong>Length:</strong> " . Time::format_succinct($track->get_length()) . "<br />\n\t\t\t\t\t<strong>Origin:</strong> " . $track->get_origin() . "<br />\n\t\t\t\t\t" . ($track->get_reclibid() ? "<strong>Reclib ID:</strong> " . $track->get_reclibid() . "<br />" : "") . "\n\t\t\t\t\t<strong>Censored:</strong> " . ($track->is_censored() ? "Yes" : "No") . "<br /> \n\t\t\t\t</div>\n\t\t\t</td>\n\t\t\t<td class=\"artist\">" . $track->get_artists_str() . "</td>\n\t\t\t<td class=\"title\">" . $track->get_title() . "</td>\n\t\t\t<td class=\"album\">" . $track->get_album()->get_name() . "</td>\n\t\t\t<td class=\"length nowrap\">" . Time::format_succinct($track->get_length()) . "</td>";
        if (Session::is_group_user("Playlist Admin")) {
            $playlists = array();
            foreach ($track->get_playlists_in() as $playlist) {
                $playlists[] = $playlist->get_id();
            }
            echo "<td class=\"icon\"><a href=\"#\" data-toggle=\"modal\" data-target=\"#playlist-modal\" data-backdrop=\"true\" data-keyboard=\"true\" data-dps-id=\"" . $track->get_id() . "\" data-playlists-in=\"" . implode(",", $playlists) . "\" class=\"playlist-add\" title=\"Add to playlist\" rel=\"twipsy\">" . Bootstrap::glyphicon("plus-sign") . "</a></td>";