public function delete() { $query = "DELETE FROM aw_items WHERE wall_id = '" . $this->id . "'"; $result = DigiplayDB::query($query); $query = "DELETE FROM aw_walls WHERE id = '" . $this->id . "'"; $result = DigiplayDB::query($query); $wallsInSet = DigiplayDB::select("* FROM aw_walls WHERE set_id = " . $this->get_set_id() . " ORDER BY page ASC", "Audiowall", true); foreach ($wallsInSet as $aw) { if ($aw->get_page() > $this->page) { $newValue = $aw->get_page() - 1; $newPage = array("page" => $newValue); DigiplayDB::update("aw_walls", $newPage, "set_id = " . $aw->get_set_id() . " AND id =" . $aw->get_id()); } } }
$result = DigiplayDB::query($query, $parameters); if ($result->rowCount() != 1) { echo Bootstrap::alert_message_basic("danger", "Couldn't find track ID in the digiplay audio DB."); } else { $track = $result->fetch(); $query = "SELECT * FROM sustschedule order by id asc limit 1"; $result = DigiplayDB::query($query); $scheduleslot = $result->fetch(); if ($track['id'] != $scheduleslot['audioid']) { $query = "UPDATE sustschedule SET audioid=:trackid, trim_start_smpl=0, trim_end_smpl = :tracklength, fade_in = 0, fade_out = :tracklength WHERE id = :scheduleslot"; $parameters = array(':trackid' => $track['id'], ':tracklength' => $track['length_smpl'], ':scheduleslot' => $scheduleslot['id']); DigiplayDB::query($query, $parameters); $query = "INSERT INTO sustlog (audioid,userid,timestamp) VALUES (:audioid,:userid,:timestamp)"; date_default_timezone_set("Europe/London"); $parameters = array(':audioid' => $track['id'], ':userid' => Session::get_id(), ':timestamp' => time()); DigiplayDB::query($query, $parameters); echo Bootstrap::alert_message_basic("info", "Track Scheduled."); } else { echo Bootstrap::alert_message_basic("warning", "This track is already at the top of the queue."); } } } $currentQueue = Sustainer::get_queue(); $i = 0; echo "<h3>Current queue:</h3>"; if (!is_null($currentQueue)) { if (array_key_exists('id', $currentQueue)) { $currentQueueTemp = array(0 => $currentQueue); $currentQueue = $currentQueueTemp; } echo "<table class=\"table table-striped table-bordered\">\r\n\t\t<thead>\r\n\t\t<tr>\r\n\t\t<th></th>\r\n\t\t<th>Title</th>\r\n\t\t<th>Artist</th>\r\n\t\t<th>Album</th>\r\n\t\t</tr>\r\n\t\t</thead>\r\n\t\t<tbody>";
public function save() { $query = "INSERT INTO aw_items (audio_id, style_id, item, wall_id, text) VALUES ('" . $this->audio_id . "', '" . $this->style_id . "', '" . $this->item . "', '" . $this->wall_id . "', '" . pg_escape_string($this->text) . "')"; $result = DigiplayDB::query($query); }
public static function login($username, $password) { if (Configs::get_system_param("auth_method") != "LDAP") { $local_user = DigiplayDB::select("* FROM users WHERE username = '******' AND password = '******';", "User"); if ($local_user) { self::$data["user"] = true; self::$user_object = $local_user; } else { return false; } } else { $ldap_instance = new LDAP(); if (!$ldap_instance->login($username, $password)) { return false; } if (is_object($ldap_instance) && get_class($ldap_instance) == "LDAP") { if ($ldap_instance->login_status()) { self::$data = $ldap_instance->userdetails(); self::$data["user"] = true; # Get the user's info, or insert them as a new user if there isn't any self::$user_object = Users::get_by_username(self::$data["username"]); if (!self::$user_object) { $id = DigiplayDB::insert("users", array("username" => self::$data["username"], "password" => NULL), "id"); self::$user_object = Users::get_by_id($id); } } else { return false; } } } if (self::$user_object) { $result = self::$user_object->get_config_var("user_curlogin"); if ($result) { self::$data["lastlogin"] = $result; DigiplayDB::query("UPDATE usersconfigs SET val = '" . time() . "' WHERE userid = " . self::$user_object->get_id() . " AND configid = 3;"); } else { DigiplayDB::query("INSERT INTO usersconfigs (userid,configid,val) VALUES (" . self::$user_object->get_id() . ",3,'" . time() . "');"); DigiplayDB::query("INSERT INTO usersconfigs (userid,configid,val) VALUES (" . self::$user_object->get_id() . ",1,'');"); } return true; } else { return false; } }
<?php if (Session::is_user()) { $id = (int) $_REQUEST['itemid']; $item = AudiowallItems::get_by_id($id); if (!$item) { http_response_code(400); exit(json_encode(array("error" => "Invalid audiowall item", "detail" => "Audiowall item does not exist"))); Errors::clear(); } $wall = Audiowalls::get_by_id($item->get_wall_id()); $set = AudiowallSets::get_by_id($wall->get_set_id()); if ($set->user_can_edit()) { $query = "DELETE FROM \"aw_items\" WHERE \"id\" = " . $id; DigiplayDB::query($query); 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.'))); }