Example #1
0
$sessionpermissions = $aw->get_user_permissions($session->get_id());
if ($sessionpermissions[2] == '1' || Session::is_group_user('Audiowalls Admin')) {
    $ownerid = DigiplayDB::select("user_id FROM aw_sets_owner WHERE set_id = '" . $aw->get_id() . "'");
    if (isset($ownerid)) {
        $user = Users::get_by_id($ownerid);
        $username = $user->get_display_name();
    } else {
        $username = "";
    }
    require_once 'pre.php';
    Output::add_script("../aw.js");
    Output::set_title("Audiowall Users");
    MainTemplate::set_subtitle("<span style=\"margin-right:20px;\">Set: " . $aw->get_name() . "</span><span style=\"margin-right:20px;\">Owner: " . $username . "</span><span id=\"editor_edit_buttons\"><a href=\"#\" class=\"btn btn-success\">Add Viewer</a></span>");
    echo "<style type=\"text/css\">\n\ttable { font-size:1.2em; }\n\tthead { display:none; }\n\t.description { font-size:0.8em; font-style:italic; }\n\t.hover-info { display:none; }\n\t.table tbody tr.success td { background-color: #DFF0D8; }\n\t</style>";
    echo "<table class=\"table table-striped\" cellspacing=\"0\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th></th>\n\t\t\t\t\t\t<th style=\"width:65px\"></th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead><tbody>";
    $aw_set = AudiowallSets::get_by_id($_REQUEST['setid']);
    $users = $aw_set->get_users_with_permissions();
    if (!is_null($users) && count($users) > 1) {
        foreach ($users as $user) {
            $userclass = Users::get_by_id($user->get_id());
            $username = $userclass->get_username();
            $permissions = $aw_set->get_user_permissions($user->get_id());
            if ($permissions[0] == "1" && $permissions[1] == '0') {
                echo "<tr><td><strong>" . $username . "</strong></td>";
                echo "<td class=\"delete-aw-btn\" style=\"width:65px\"><a href=\"#\" class=\"btn btn-danger\">Delete</a></td>";
                echo "</td></tr>";
            }
        }
    }
    if (!is_null($users) && count($users) == 1) {
        $userclass = Users::get_by_id($users->get_id());
<?php

if (Session::is_user()) {
    $a = AudiowallSets::get_by_id(pg_escape_string($_REQUEST['setid']));
    if ($a->user_can_delete() || Session::is_group_user('Audiowalls Admin')) {
        $user = Users::get_by_username(pg_escape_string($_REQUEST['username']));
        if (!is_null($user)) {
            $query = "permissions FROM aw_sets_permissions WHERE set_id = :set_id AND user_id = :user_id";
            $data = array('set_id' => $a->get_id(), 'user_id' => $user->get_id());
            $current = DigiplayDB::select($query, NULL, false, $data);
            if (!is_null($current)) {
                if ($_REQUEST['val'] == 'editor') {
                    if ($current[2] == '1') {
                        $new = '111';
                    } else {
                        $new = '110';
                    }
                } elseif ($_REQUEST['val'] == 'viewer') {
                    if ($current[2] == '1') {
                        $new = '111';
                    } else {
                        if ($current[1] == '1') {
                            $new = '110';
                        } else {
                            $new = '100';
                        }
                    }
                } elseif ($_REQUEST['val'] == 'admin') {
                    $new = '111';
                }
                $data = array('permissions' => $new);
Example #3
0
<?php

require_once 'pre.php';
Output::set_title("Audiowalls");
$sets = AudiowallSets::get_all();
$active = DigiplayDB::select("\"val\" FROM \"public\".\"usersconfigs\" WHERE \"userid\" = '" . Session::get_id() . "' AND \"configid\" = '1'");
?>
<style type="text/css">
table { font-size:1.2em; }
thead { display:none; }
.description { font-size:0.8em; font-style:italic; }
.hover-info { display:none; }
.table tbody tr.success td { background-color: #DFF0D8; }
</style>
<?php 
echo "\t<div class=\"row\"><div class=\"col-md-3\"><div class=\"well\"><p><a href=\"#\" class=\"btn btn-success\" id=\"create\">Create New Audiowall</a></p><p>An Audiowall is a 3x4 grid of buttons in Digiplay which play audio when pressed. They are displayed on the right hand side of the touchscreen in the studio. The top audiowall is set for everyone and contains core station imaging, promos and beds. The bottom audiowall can be set on this page, and may contain jingles and other audio specific to your show.</p></div></div><div class=\"col-md-9\">\t<table class=\"table table-striped\" cellspacing=\"0\">\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th></th>\n\t\t\t\t\t<th>Name</th>\n\t\t\t\t\t<th style=\"width:65px\"></th>\n\t\t\t\t\t<th style=\"width:185px\"></th>\n\t\t\t\t</tr>\n\t\t\t</thead><tbody>";
foreach ($sets as $set) {
    if (!$set->user_can_view() && !Session::is_group_user('Audiowalls Admin')) {
        continue;
    }
    echo "<tr" . ($set->get_id() == $active ? ' class="success"' : '') . "><td class=\"wall-info\" >";
    if ($set->user_can_delete()) {
        echo "<a href=\"users/users-viewers.php?setid=" . $set->get_id() . "\">" . Bootstrap::glyphicon("info-sign") . "</a>";
    }
    echo "</td><td><strong>" . $set->get_name() . "</strong><br /><span class=\"description\">" . $set->get_description() . "</span></td>";
    $station_aw = DigiplayDB::select("val FROM configuration WHERE parameter = 'station_aw_set' AND location = '1'");
    if (!($set->get_id() == (int) $station_aw)) {
        if ($set->user_can_delete() || Session::is_group_user('Audiowalls Admin')) {
            echo "<td class=\"delete-aw-btn\" data-aw-name=\"" . $set->get_name() . "\" data-dps-set-id=\"" . $set->get_id() . "\" style=\"width:65px\"><a href=\"#\" class=\"btn btn-danger\">Delete</a></td>";
        } else {
            echo "<td style=\"width:65px\"></td>";
<?php

if (Session::is_user()) {
    $a = AudiowallSets::get_by_id((int) $_REQUEST['setid']);
    if ($a->user_can_edit()) {
        $walls = $a->get_walls();
        $w = 0;
        foreach ($walls as $wall) {
            $w++;
        }
        if ($_REQUEST['name'] == "") {
            $name = "New Page";
        } else {
            $name = $_REQUEST['name'];
        }
        if ($_REQUEST['desc'] == "") {
            $desc = "New Page";
        } else {
            $desc = $_REQUEST['desc'];
        }
        $table = "aw_walls";
        $data = array('id' => NULL, 'name' => pg_escape_string($name), 'set_id' => $_REQUEST['setid'], 'page' => $w, 'description' => pg_escape_string($desc));
        DigiplayDB::insert($table, $data);
        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' => $a->get_id())));
        }
    } else {
Example #5
0
<?php

Output::set_title("Administration");
MainTemplate::set_subtitle("Control every aspect of the Digiplay system");
$trash = Files::get_by_id(3, "dir");
echo "\n<div class=\"row\">\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "admin/music\">\n\t\t\t<div class=\"panel panel-info\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("volume-up icon-huge") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . Tracks::get_total_tracks() . "</h2>\n\t\t\t\t\t\t\t<h4>tracks</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "admin/users\">\n\t\t\t<div class=\"panel panel-success\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("user icon-huge") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . Users::count() . "</h2>\n\t\t\t\t\t\t\t<h4>users</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "showplans\">\n\t\t\t<div class=\"panel panel-default\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("tasks icon-huge") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . Showplans::count() . "</h2>\n\t\t\t\t\t\t\t<h4>showplans</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n</div>\n<div class=\"row\">\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "audiowalls\">\n\t\t\t<div class=\"panel panel-default\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("th icon-huge\" style=\"margin-top: -4px;") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . AudiowallSets::count() . "</h2>\n\t\t\t\t\t\t\t<h4>audiowalls</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "email\">\n\t\t\t<div class=\"panel panel-warning\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("envelope icon-huge") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . Emails::count_unread() . "</h2>\n\t\t\t\t\t\t\t<h4>e-mails</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n\t<div class=\"col-sm-4\">\n\t\t<a href=\"" . LINK_ABS . "admin/trash\">\n\t\t\t<div class=\"panel panel-danger\">\n\t\t\t\t<div class=\"panel-heading\">\n\t\t\t\t\t<div class=\"row dashboard-stamp\">\n\t\t\t\t\t\t<div class=\"col-xs-5\">\n\t\t\t\t\t\t\t" . Bootstrap::glyphicon("trash icon-huge") . "\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"col-xs-7\">\n\t\t\t\t\t\t\t<h2>" . $trash->count() . "</h2>\n\t\t\t\t\t\t\t<h4>in trash</h4>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</a>\n\t</div>\n</div>";
Example #6
0
<?php

if (Session::is_user()) {
    $set = AudiowallSets::get((int) $_REQUEST['id']);
    if ($set->user_can_edit()) {
        $set->set_name($_REQUEST['name']);
        $set->set_description($_REQUEST['description']);
        foreach ($_REQUEST['walls'] as $walldata) {
            $wall = new Audiowall();
            $wall->set_id($walldata[id]);
            $wall->set_name($walldata[name]);
            $wall->set_description($walldata[name]);
            $wall->set_page($walldata[page]);
            foreach ($walldata[items] as $itemdata) {
                $item = new AudiowallItem();
                $item->set_audio_id($itemdata[audio_id]);
                $item->set_style_id($itemdata[style_id]);
                $item->set_item($itemdata[item]);
                $item->set_text(str_replace("<br>", "\n", $itemdata[text]));
                //print_r($item);
                $wall->add_item($item);
            }
            $set->add_wall($wall);
        }
        $set->save();
    } else {
        http_response_code(403);
        exit(json_encode(array('error' => 'Permission denied.')));
    }
} else {
    http_response_code(403);
<?php

if (Session::is_user()) {
    $a = Audiowalls::get_by_id($_REQUEST['wallid']);
    $set = AudiowallSets::get_by_id($a->get_set_id());
    if ($set->user_can_edit()) {
        $a->delete();
        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)));
        }
    } else {
        http_response_code(403);
        exit(json_encode(array('error' => 'Permission denied.')));
    }
} else {
    http_response_code(403);
    exit(json_encode(array('error' => 'Permission denied.')));
}
Example #8
0
if (isset($_REQUEST["key"])) {
    $location = Locations::get_by_key($_REQUEST["key"]);
    $key = $_REQUEST["key"];
} else {
    if (isset($_REQUEST["location"])) {
        $location = Locations::get_by_id($_REQUEST["location"]);
        $key = $location->get_key();
    } else {
        exit("No location specified!");
    }
}
echo "\r\n\t\t<script>\r\n\t\t\tvar key = 'key=" . $key . "&';\r\n\t\t\tvar timers = [];\r\n\t\t\tvar connect_timeout;\r\n\t\t\tvar websocket;\r\n\t\t\tvar connection = false;\r\n\r\n\t\t\tfunction startWebsocket() {\r\n\t\t\t\tconsole.log('Starting websocket...');\r\n\t\t\t\twebsocket = new WebSocket('" . Configs::get_system_param("websocket_uri") . "');\r\n\t\t\t\twebsocket.onopen = function(e) { onOpen(e) };\r\n\t\t\t\twebsocket.onclose = function(e) { onClose(e) };\r\n\t\t\t\twebsocket.onmessage = function(e) { onMessage(e) };\r\n\t\t\t\twebsocket.onerror = function(e) { onError(e) };\r\n\t\t\t}\r\n\r\n\t\t\tfunction onOpen(e) {\r\n\t\t\t\tconnection = true;\r\n\t\t\t\tconsole.log('Websocket connection established.');\r\n\t\t\t\twebsocket.send(JSON.stringify({'ident':'" . $key . "'}));\r\n\t\t\t\tclearTimeout(connect_timeout);\r\n\t\t\t\t\$.each(timers, function(i, v) { clearInterval(v); });\r\n\t\t\t\ttimers = [];\r\n\t\t\t}\r\n\r\n\t\t\tfunction onClose(e) {\r\n\t\t\t\tconnection = false;\r\n\t\t\t\tconsole.log('Websocket connection lost.');\r\n\t\t\t\tconnect_timeout = setTimeout('setIntervals()', 5000);\r\n\t\t\t\tsetTimeout('startWebsocket()',5000);\r\n\t\t\t}\r\n\r\n\t\t\tfunction onMessage(e) {\r\n\t\t\t\tdata = JSON.parse(e.data);\r\n\t\t\t\tswitch(data.channel) {\r\n\t\t\t\t\tcase 't_audiowall':\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tfunction onError(e) {\r\n\t\t\t\tconsole.log(e);\r\n\t\t\t}\r\n\r\n\t\t\tfunction setIntervals() {\r\n\t\t\t\tif(timers.length == 0) {\r\n\t\t\t\t\tconsole.log('Setting manual refresh intervals.');\r\n\t\t\t\t\ttimers.push(setInterval('reloadAudiowall()', 30000));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t\$(function() {\r\n\t\t\t\tconnect_timeout = setTimeout('setIntervals()', 5000);\r\n\t\t\t\tstartWebsocket();\r\n\t\t\t\twindow.oncontextmenu = function(event) {\r\n  \t\t\t\t\tevent.preventDefault();\r\n    \t\t\t\tevent.stopPropagation();\r\n    \t\t\t\treturn false;\r\n\t\t\t\t};\r\n\r\n\t\t\t\t\$(document).keydown(function(e) {\r\n\t\t\t\t\tif((111 < e.which) && (e.which < 123)) e.preventDefault();\r\n\t\t\t\t});\r\n\t\t\t});\r\n\r\n\t\t</script>\r\n";
if (isset($_GET["id"])) {
    $set = AudiowallSets::get_by_id($_GET["id"]);
} else {
    $set = AudiowallSets::get_by_id($location->get_config("station_aw_set")->get_val());
}
if (isset($_GET["page"])) {
    $wall = $set->get_walls()[$_GET["page"] - 1];
} else {
    $wall = $set->get_walls()[0];
}
$items = $wall->get_items();
echo "<div class=\"row\">";
for ($i = 0; $i < 12; $i++) {
    echo "\r\n\t\t<div class=\"col-xs-4\">";
    if (isset($items[$i])) {
        $item = $items[$i];
        $style = $item->get_style();
        $audio = $item->get_audio();
        echo "\r\n\t\t\t<div class=\"btn btn-block disabled\" data-item-id=\"" . $item->get_id() . "\" style=\"color: " . $style->get_foreground_rgb() . "; background: " . $style->get_background_rgb() . "; border-color: " . $style->get_accent_rgb() . "\">\r\n\t\t\t\t<div class=\"buffer\"></div>\r\n\t\t\t\t<div class=\"progress\"></div>\r\n\t\t\t\t" . $item->get_text() . "<br />" . $audio->get_length_formatted() . "\r\n\t\t\t\t<script>\r\n\t\t\t\t\$(function() {\r\n\t\t\t\t\t\$('[data-item-id=" . $item->get_id() . "]').find('.disabled').show();\r\n\t\t\t\t\titem" . $item->get_id() . " = new Audio('" . LINK_ABS . "audio/get/" . $audio->get_id() . ".wav');\r\n\t\t\t\t\titem" . $item->get_id() . ".buffercheck = setInterval(function() { \r\n\t\t\t\t\t\tif(item" . $item->get_id() . ".buffered.length == 1) {\r\n\t\t\t\t\t\t\tbuffered = (item" . $item->get_id() . ".buffered.end(0) / item" . $item->get_id() . ".duration).toFixed(3) * 100;\r\n\t\t\t\t\t\t \t\$('[data-item-id=" . $item->get_id() . "]').find('.buffer').css('width', (100-buffered)+'%');\r\n\r\n\t\t\t\t\t\t \tif(buffered == 100) { clearInterval(item" . $item->get_id() . ".buffercheck) }\r\n\t\t\t\t\t\t} \r\n\t\t\t\t\t}, 50);\r\n\r\n\t\t\t\t\t\$('[data-item-id=" . $item->get_id() . "]').bind('click', function() {\r\n\t\t\t\t\t\tif(\$('[data-item-id=" . $item->get_id() . "]').hasClass('disabled')) return false;\r\n\t\t\t\t\t\tif(item" . $item->get_id() . ".paused == true || item" . $item->get_id() . ".currentTime == 0) {\r\n\t\t\t\t\t\t\titem" . $item->get_id() . ".play();\r\n\t\t\t\t\t\t\titem" . $item->get_id() . ".progressupdate = setInterval(function() { \r\n\t\t\t\t\t\t\t\tprogress = (item" . $item->get_id() . ".currentTime / item" . $item->get_id() . ".duration).toFixed(3) * 100;\r\n\t\t\t\t\t \t\t\t\$('[data-item-id=" . $item->get_id() . "]').find('.progress').css('width', progress+'%');\r\n\t\t\t\t\t\t}, 50);\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\titem" . $item->get_id() . ".pause();\r\n\t\t\t\t\t\t\titem" . $item->get_id() . ".currentTime = 0;\r\n\t\t\t\t\t\t\tclearInterval(item" . $item->get_id() . ".progressupdate);\r\n\t\t\t\t\t\t\t\$('[data-item-id=" . $item->get_id() . "]').find('.progress').css('width', 0);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\titem" . $item->get_id() . ".onended = function() { \r\n\t\t\t\t\t\tclearInterval(item" . $item->get_id() . ".progressupdate);\r\n\t\t\t\t\t\t\$('[data-item-id=" . $item->get_id() . "]').find('.progress').css('width', 0); \r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\titem" . $item->get_id() . ".oncanplay = function() { \$('[data-item-id=" . $item->get_id() . "]').removeClass('disabled'); }\r\n\t\t\t\t});\r\n\t\t\t\t</script>\r\n\r\n\t\t\t</div>";
<?php

if (Session::is_user()) {
    // Require a description for all audiowalls
    // Makes it easier for audiowall admins to manage
    if ($_REQUEST["awdescription"] == "") {
        http_response_code(400);
        exit(json_encode(array("error" => "Audiowall description missing", "detail" => "You must provide a description for the audiowall")));
        Errors::clear();
    }
    // Query number of audiowalls that the user currently has
    // If an audiowall already exists for that user, deny creation
    $numberOfAudiowalls = AudiowallSets::count_by_user();
    if ($numberOfAudiowalls > 0 && !Session::is_group_user('Audiowalls Admin')) {
        http_response_code(400);
        exit(json_encode(array("error" => "Audiowall limit exceeded", "detail" => "You are limited to a single audiowall")));
        Errors::clear();
    }
    $aw_set = new AudiowallSet();
    $aw_set->set_name(pg_escape_string($_REQUEST["awname"]));
    $aw_set->set_description(pg_escape_string($_REQUEST["awdescription"]));
    $aw_set->save();
    // Add audiowall owner to the database
    $data = array('user_id' => Session::get_id(), 'set_id' => $aw_set->get_id());
    DigiplayDB::insert("aw_sets_owner", $data);
    // Add audiowall permissions to current user
    // The bitmask is as follows (view, edit, delete) where a value of 1 grants the permission
    // INSERT INTO aw_sets_permissions (user_id, set_id, permissions) VALUES (Session::get_id(), $aw_set->get_id(), '111');
    $data = array('user_id' => Session::get_id(), 'set_id' => $aw_set->get_id(), 'permissions' => '111');
    DigiplayDB::insert("aw_sets_permissions", $data);
    if (Errors::occured()) {