1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-06 03:49:56 +02:00

Fix other scrutinizer issues

This commit is contained in:
Afterster 2014-05-26 01:05:53 +02:00
parent fee1e70ffa
commit 76e8d4b3e4
8 changed files with 28 additions and 15 deletions

View file

@ -934,11 +934,11 @@ class Art extends database_object
} // foreach } // foreach
// Rudimentary image type detection, only JPG and GIF allowed. // Rudimentary image type detection, only JPG and GIF allowed.
if (substr($result[$key], -4 == '.jpg')) { if (substr($result[$key], -4) == '.jpg') {
$mime = "image/jpeg"; $mime = "image/jpeg";
} elseif (substr($result[$key], -4 == '.gif')) { } elseif (substr($result[$key], -4) == '.gif') {
$mime = "image/gif"; $mime = "image/gif";
} elseif (substr($result[$key], -4 == '.png')) { } elseif (substr($result[$key], -4) == '.png') {
$mime = "image/png"; $mime = "image/png";
} else { } else {
/* Just go to the next result */ /* Just go to the next result */

View file

@ -93,6 +93,7 @@ class Plex_Api
$createSession = false; $createSession = false;
Session::gc(); Session::gc();
$username = "";
$email = Session::read((string) $myplex_token); $email = Session::read((string) $myplex_token);
if (empty($email)) { if (empty($email)) {
$createSession = true; $createSession = true;
@ -120,7 +121,7 @@ class Plex_Api
self::createError(401); self::createError(401);
} }
if (empty($email) && isset($username)) { if (empty($email)) {
$xml = self::get_users_account(); $xml = self::get_users_account();
if ((string) $xml->username == $username) { if ((string) $xml->username == $username) {
$email = (string) $xml->email; $email = (string) $xml->email;
@ -140,14 +141,15 @@ class Plex_Api
if (!isset($user) || !$user->id) { if (!isset($user) || !$user->id) {
debug_event('Access Denied', 'Unable to get an Ampache user match for email ' . $email, '3'); debug_event('Access Denied', 'Unable to get an Ampache user match for email ' . $email, '3');
self::createError(401); self::createError(401);
} else {
$username = $user->username;
if (!Access::check_network('init-api', $username, 5)) {
debug_event('Access Denied', 'Unauthorized access attempt to Plex [' . $_SERVER['REMOTE_ADDR'] . ']', '3');
self::createError(401);
} else {
$GLOBALS['user'] = $user;
}
} }
$username = $user->username;
if (!Access::check_network('init-api', $username, 5)) {
debug_event('Access Denied', 'Unauthorized access attempt to Plex [' . $_SERVER['REMOTE_ADDR'] . ']', '3');
self::createError(401);
}
$GLOBALS['user'] = $user;
} else { } else {
$email = $username; $email = $username;
$username = null; $username = null;
@ -443,7 +445,9 @@ class Plex_Api
$res['raw'] = $r; $res['raw'] = $r;
try { try {
$res['xml'] = simplexml_load_string($r); $res['xml'] = simplexml_load_string($r);
} catch (Exception $e) { } } catch (Exception $e) {
// If exception, wrong data returned (Plex API changes?)
}
return $res; return $res;
} }

View file

@ -498,7 +498,7 @@ if ($start > 0) {
// If this is a democratic playlist remove the entry. // If this is a democratic playlist remove the entry.
// We do this regardless of play amount. // We do this regardless of play amount.
if ($demo_id) { $democratic->delete_from_oid($oid,'song'); } if ($demo_id && isset($democratic)) { $democratic->delete_from_oid($oid,'song'); }
if ($transcode && isset($transcoder)) { if ($transcode && isset($transcoder)) {
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {

View file

@ -91,6 +91,7 @@ switch ($_REQUEST['action']) {
case 'set_track_numbers': case 'set_track_numbers':
debug_event('playlist', 'Set track numbers called.', '5'); debug_event('playlist', 'Set track numbers called.', '5');
$playlist = new Playlist($_REQUEST['playlist_id']);
/* Make sure they have permission */ /* Make sure they have permission */
if (!$playlist->has_access()) { if (!$playlist->has_access()) {
UI::access_denied(); UI::access_denied();
@ -103,7 +104,6 @@ switch ($_REQUEST['action']) {
debug_event('playlist', $key.'='.$_GET[$key], '5'); debug_event('playlist', $key.'='.$_GET[$key], '5');
} }
$playlist = new Playlist($_REQUEST['playlist_id']);
if (isset($_GET['order'])) { if (isset($_GET['order'])) {
$songs = explode(";", $_GET['order']); $songs = explode(";", $_GET['order']);
$track = 1; $track = 1;

View file

@ -23,6 +23,7 @@
/* Check and see if their remember me is the same or lower then local /* Check and see if their remember me is the same or lower then local
* if so disable the checkbox * if so disable the checkbox
*/ */
$remember_disabled = '';
if (AmpConfig::get('session_length') >= AmpConfig::get('remember_length')) { if (AmpConfig::get('session_length') >= AmpConfig::get('remember_length')) {
$remember_disabled = 'disabled="disabled"'; $remember_disabled = 'disabled="disabled"';
} }

View file

@ -46,6 +46,8 @@ foreach ($data as $row) {
$agent = ''; $agent = '';
$time_string = '-'; $time_string = '-';
$has_allowed_agent = true;
$has_allowed_time = true;
$is_allowed = Access::check('interface', '100') || $GLOBALS['user']->id == $row_user->id; $is_allowed = Access::check('interface', '100') || $GLOBALS['user']->id == $row_user->id;
if (!$is_allowed) { if (!$is_allowed) {
$has_allowed_time = Preference::get_by_user($row_user->id, 'allow_personal_info_time'); $has_allowed_time = Preference::get_by_user($row_user->id, 'allow_personal_info_time');

View file

@ -22,7 +22,12 @@
?> ?>
<ul class="sb2" id="sb_localplay"> <ul class="sb2" id="sb_localplay">
<?php if ($server_allow = AmpConfig::get('allow_localplay_playback') AND $controller = AmpConfig::get('localplay_controller') AND $access_check = Access::check('localplay','5')) { ?> <?php
$server_allow = AmpConfig::get('allow_localplay_playback');
$controller = AmpConfig::get('localplay_controller');
$access_check = Access::check('localplay','5');
if ($server_allow && $controller && $access_check) {
?>
<?php <?php
// Little bit of work to be done here // Little bit of work to be done here
$localplay = new Localplay(AmpConfig::get('localplay_controller')); $localplay = new Localplay(AmpConfig::get('localplay_controller'));

View file

@ -29,6 +29,7 @@
<ul class="subnavside"> <ul class="subnavside">
<?php <?php
foreach ($items as $item) { foreach ($items as $item) {
$li_class = '';
if ($item['url'] == $item['active']) { if ($item['url'] == $item['active']) {
$li_class = "class=\"activesubmenu\""; $li_class = "class=\"activesubmenu\"";
} }