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

Fix scrutinizer code style

This commit is contained in:
Afterster 2014-05-26 00:48:43 +02:00
parent 1757d8c6f5
commit fee1e70ffa
14 changed files with 37 additions and 12 deletions

View file

@ -180,6 +180,7 @@ class Api
if ($client) { if ($client) {
// Create the session // Create the session
$data = array();
$data['username'] = $client->username; $data['username'] = $client->username;
$data['type'] = 'api'; $data['type'] = 'api';
$data['value'] = $timestamp; $data['value'] = $timestamp;
@ -654,6 +655,7 @@ class Api
*/ */
public static function search_songs($input) public static function search_songs($input)
{ {
$array = array();
$array['type'] = 'song'; $array['type'] = 'song';
$array['rule_1'] = 'anywhere'; $array['rule_1'] = 'anywhere';
$array['rule_1_input'] = $input['filter']; $array['rule_1_input'] = $input['filter'];

View file

@ -743,6 +743,7 @@ class Art extends database_object
// that displays cover art. // that displays cover art.
// I'm leaving in the releaseuri info for the moment, though // I'm leaving in the releaseuri info for the moment, though
// it's not going to be used. // it's not going to be used.
$coverartsites = array();
$coverartsites[] = array( $coverartsites[] = array(
'name' => "CD Baby", 'name' => "CD Baby",
'domain' => "cdbaby.com", 'domain' => "cdbaby.com",

View file

@ -379,12 +379,13 @@ class Artist extends database_object
$sql = 'SELECT `id`, `mbid` FROM `artist` WHERE `name` LIKE ?'; $sql = 'SELECT `id`, `mbid` FROM `artist` WHERE `name` LIKE ?';
$db_results = Dba::read($sql, array($name)); $db_results = Dba::read($sql, array($name));
$id_array = array();
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {
$key = $row['mbid'] ?: 'null'; $key = $row['mbid'] ?: 'null';
$id_array[$key] = $row['id']; $id_array[$key] = $row['id'];
} }
if (isset($id_array)) { if (count($id_array)) {
if ($mbid) { if ($mbid) {
if (isset($id_array['null']) && !$readonly) { if (isset($id_array['null']) && !$readonly) {
$sql = 'UPDATE `artist` SET `mbid` = ? WHERE `id` = ?'; $sql = 'UPDATE `artist` SET `mbid` = ? WHERE `id` = ?';

View file

@ -66,6 +66,7 @@ class Auth
xoutput_headers(); xoutput_headers();
$results = array();
$results['rfc3514'] = '<script type="text/javascript">reloadRedirect("' . $target . '")</script>'; $results['rfc3514'] = '<script type="text/javascript">reloadRedirect("' . $target . '")</script>';
echo xoutput_from_array($results); echo xoutput_from_array($results);
} else { } else {
@ -134,6 +135,7 @@ class Auth
// variations of the password. Increases collision chances, but // variations of the password. Increases collision chances, but
// doesn't break things. // doesn't break things.
// FIXME: Break things in the future. // FIXME: Break things in the future.
$hashed_password = array();
$hashed_password[] = hash('sha256', $password); $hashed_password[] = hash('sha256', $password);
$hashed_password[] = hash('sha256', $hashed_password[] = hash('sha256',
Dba::escape(stripslashes(htmlspecialchars(strip_tags($password))))); Dba::escape(stripslashes(htmlspecialchars(strip_tags($password)))));
@ -169,6 +171,7 @@ class Auth
*/ */
private static function pam_auth($username, $password) private static function pam_auth($username, $password)
{ {
$results = array();
if (!function_exists('pam_auth')) { if (!function_exists('pam_auth')) {
$results['success'] = false; $results['success'] = false;
$results['error'] = 'The PAM PHP module is not installed'; $results['error'] = 'The PAM PHP module is not installed';
@ -274,6 +277,7 @@ class Auth
//This is the ldap objectclass (required) //This is the ldap objectclass (required)
$ldap_class = AmpConfig::get('ldap_objectclass'); $ldap_class = AmpConfig::get('ldap_objectclass');
$results = array();
if (!($ldap_dn && $ldap_url && $ldap_filter && $ldap_class)) { if (!($ldap_dn && $ldap_url && $ldap_filter && $ldap_class)) {
debug_event('ldap_auth', 'Required config value missing', 1); debug_event('ldap_auth', 'Required config value missing', 1);
$results['success'] = false; $results['success'] = false;
@ -367,6 +371,7 @@ class Auth
*/ */
private static function http_auth($username, $password) private static function http_auth($username, $password)
{ {
$results = array();
if (($_SERVER['REMOTE_USER'] == $username) || if (($_SERVER['REMOTE_USER'] == $username) ||
($_SERVER['HTTP_REMOTE_USER'] == $username)) { ($_SERVER['HTTP_REMOTE_USER'] == $username)) {
$results['success'] = true; $results['success'] = true;

View file

@ -506,6 +506,7 @@ abstract class Catalog extends database_object
$data = Dba::fetch_row($db_results); $data = Dba::fetch_row($db_results);
$artists = $data[0]; $artists = $data[0];
$results = array();
$results['songs'] = $songs; $results['songs'] = $songs;
$results['albums'] = $albums; $results['albums'] = $albums;
$results['artists'] = $artists; $results['artists'] = $artists;

View file

@ -120,7 +120,7 @@ class Plex_Api
self::createError(401); self::createError(401);
} }
if (empty($email)) { if (empty($email) && isset($username)) {
$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;
@ -137,7 +137,7 @@ class Plex_Api
if (!empty($email)) { if (!empty($email)) {
$user = User::get_from_email($email); $user = User::get_from_email($email);
} }
if (!$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);
} }
@ -202,7 +202,7 @@ class Plex_Api
} }
$ach = $reqheaders['Access-Control-Request-Headers']; $ach = $reqheaders['Access-Control-Request-Headers'];
if ($ach) { if ($ach) {
$headers = self::getPlexHeaders(true, $acl); $headers = self::getPlexHeaders(true, $ach);
$headerkeys = array(); $headerkeys = array();
foreach ($headers as $key => $value) { foreach ($headers as $key => $value) {
$headerkeys[] = strtolower($key); $headerkeys[] = strtolower($key);
@ -652,14 +652,14 @@ class Plex_Api
$art = new Art($id, "artist"); $art = new Art($id, "artist");
} else if (Plex_XML_Data::isAlbum($key)) { } else if (Plex_XML_Data::isAlbum($key)) {
$art = new Art($id, "album"); $art = new Art($id, "album");
} else if (Plex_XML_Data::isSong($key)) { } else if (Plex_XML_Data::isTrack($key)) {
$art = new Art($id, "song"); $art = new Art($id, "song");
} }
if ($art != null) { if ($art != null) {
$art->get_db(); $art->get_db();
if (!$size) { if (!isset($size)) {
self::setHeader($art->raw_mime); self::setHeader($art->raw_mime);
echo $art->raw; echo $art->raw;
} else { } else {
@ -942,6 +942,7 @@ class Plex_Api
$rating = $_REQUEST['rating']; $rating = $_REQUEST['rating'];
if ($identifier == 'com.plexapp.plugins.library') { if ($identifier == 'com.plexapp.plugins.library') {
$robj = null;
if (Plex_XML_Data::isArtist($id)) { if (Plex_XML_Data::isArtist($id)) {
$robj = new Rating(Plex_XML_Data::getAmpacheId($id), "artist"); $robj = new Rating(Plex_XML_Data::getAmpacheId($id), "artist");
} else if (Plex_XML_Data::isAlbum($id)) { } else if (Plex_XML_Data::isAlbum($id)) {

View file

@ -76,6 +76,7 @@ class scrobbler
*/ */
public function handshake() public function handshake()
{ {
$data = array();
$as_socket = fsockopen($this->scrobble_host, 80, $errno, $errstr, 2); $as_socket = fsockopen($this->scrobble_host, 80, $errno, $errstr, 2);
if (!$as_socket) { if (!$as_socket) {
$this->error_msg = $errstr; $this->error_msg = $errstr;

View file

@ -73,8 +73,11 @@ class Stream_Playlist
$sql = 'INSERT INTO `stream_playlist` '; $sql = 'INSERT INTO `stream_playlist` ';
$fields = array();
$fields[] = '`sid`'; $fields[] = '`sid`';
$values = array();
$values[] = $this->id; $values[] = $this->id;
$holders = array();
$holders[] = '?'; $holders[] = '?';
foreach ($url->properties as $field) { foreach ($url->properties as $field) {

View file

@ -91,6 +91,7 @@ class User extends database_object
$sql = 'SELECT COUNT(`id`) FROM `user`'; $sql = 'SELECT COUNT(`id`) FROM `user`';
$db_results = Dba::read($sql); $db_results = Dba::read($sql);
$data = Dba::fetch_row($db_results); $data = Dba::fetch_row($db_results);
$results = array();
$results['users'] = $data[0]; $results['users'] = $data[0];
$time = time(); $time = time();
@ -116,6 +117,7 @@ class User extends database_object
return parent::get_from_cache('user',$id); return parent::get_from_cache('user',$id);
} }
$data = array();
// If the ID is -1 then // If the ID is -1 then
if ($id == '-1') { if ($id == '-1') {
$data['username'] = 'System'; $data['username'] = 'System';
@ -294,6 +296,7 @@ class User extends database_object
$db_results = Dba::read($sql); $db_results = Dba::read($sql);
$results = array(); $results = array();
$type_array = array();
/* Ok this is crapy, need to clean this up or improve the code FIXME */ /* Ok this is crapy, need to clean this up or improve the code FIXME */
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$type = $r['catagory']; $type = $r['catagory'];
@ -354,7 +357,7 @@ class User extends database_object
/* If its an artist */ /* If its an artist */
elseif ($type == 'artist') { elseif ($type == 'artist') {
$data = new Artist($r['object_id']); $data = new Artist($r['object_id']);
$data->count = $r['count']; //$data->count = $r['count'];
$data->format(); $data->format();
$data->f_name = $data->f_link; $data->f_name = $data->f_link;
$items[] = $data; $items[] = $data;
@ -388,7 +391,7 @@ class User extends database_object
// Incase they only have one user // Incase they only have one user
$users = array(); $users = array();
$ratings = array();
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
/* Store the fact that you rated this */ /* Store the fact that you rated this */
$key = $r['object_id']; $key = $r['object_id'];
@ -933,6 +936,7 @@ class User extends database_object
"WHERE `user_preference`.`preference` = `preference`.`id` AND `user_preference`.`user`='-1' AND `preference`.`catagory` !='system'"; "WHERE `user_preference`.`preference` = `preference`.`id` AND `user_preference`.`user`='-1' AND `preference`.`catagory` !='system'";
$db_results = Dba::read($sql); $db_results = Dba::read($sql);
/* While through our base stuff */ /* While through our base stuff */
$zero_results = array();
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$key = $r['preference']; $key = $r['preference'];
$zero_results[$key] = $r['value']; $zero_results[$key] = $r['value'];
@ -1177,6 +1181,7 @@ class User extends database_object
public function upload_avatar() public function upload_avatar()
{ {
$upload = array();
if (!empty($_FILES['avatar']['tmp_name'])) { if (!empty($_FILES['avatar']['tmp_name'])) {
$path_info = pathinfo($_FILES['avatar']['name']); $path_info = pathinfo($_FILES['avatar']['name']);
$upload['file'] = $_FILES['avatar']['tmp_name']; $upload['file'] = $_FILES['avatar']['tmp_name'];

View file

@ -90,7 +90,7 @@ class vainfo
try { try {
$this->_raw = $this->_getID3->analyze(Core::conv_lc_file($file)); $this->_raw = $this->_getID3->analyze(Core::conv_lc_file($file));
} catch (Exception $error) { } catch (Exception $error) {
debug_event('getID3', "Broken file detected: $file: " . $error->message, 1); debug_event('getID3', "Broken file detected: $file: " . $error->getMessage(), 1);
$this->_broken = true; $this->_broken = true;
return false; return false;
} }
@ -228,6 +228,7 @@ class vainfo
$order = (array) AmpConfig::get($config_key); $order = (array) AmpConfig::get($config_key);
// Iterate through the defined key order adding them to an ordered array. // Iterate through the defined key order adding them to an ordered array.
$returned_keys = array();
foreach ($order as $key) { foreach ($order as $key) {
if ($results[$key]) { if ($results[$key]) {
$returned_keys[] = $key; $returned_keys[] = $key;
@ -851,6 +852,8 @@ class vainfo
$key = array_shift($order); $key = array_shift($order);
$broken = array();
$broken[$key] = array();
$broken[$key]['title'] = '**BROKEN** ' . $this->filename; $broken[$key]['title'] = '**BROKEN** ' . $this->filename;
$broken[$key]['album'] = 'Unknown (Broken)'; $broken[$key]['album'] = 'Unknown (Broken)';
$broken[$key]['artist'] = 'Unknown (Broken)'; $broken[$key]['artist'] = 'Unknown (Broken)';

View file

@ -168,6 +168,7 @@ class Waveform
$handle = fopen($filename, "r"); $handle = fopen($filename, "r");
// wav file header retrieval // wav file header retrieval
$heading = array();
$heading[] = fread($handle, 4); $heading[] = fread($handle, 4);
$heading[] = bin2hex(fread($handle, 4)); $heading[] = bin2hex(fread($handle, 4));
$heading[] = fread($handle, 4); $heading[] = fread($handle, 4);

View file

@ -224,6 +224,7 @@ function install_insert_db($db_user = null, $db_pass = null, $create_db = true,
$sql_file = AmpConfig::get('prefix') . '/sql/ampache.sql'; $sql_file = AmpConfig::get('prefix') . '/sql/ampache.sql';
$query = fread(fopen($sql_file, 'r'), filesize($sql_file)); $query = fread(fopen($sql_file, 'r'), filesize($sql_file));
$pieces = split_sql($query); $pieces = split_sql($query);
$errors = array();
for ($i=0; $i<count($pieces); $i++) { for ($i=0; $i<count($pieces); $i++) {
$pieces[$i] = trim($pieces[$i]); $pieces[$i] = trim($pieces[$i]);
if (!empty($pieces[$i]) && $pieces[$i] != '#') { if (!empty($pieces[$i]) && $pieces[$i] != '#') {

View file

@ -262,7 +262,7 @@ if (!$media->file || !Core::is_readable(Core::conv_lc_file($media->file))) {
} }
// FIXME: why are these separate? // FIXME: why are these separate?
// Remove the song votes if this is a democratic song // Remove the song votes if this is a democratic song
if ($demo_id) { $democratic->delete_from_oid($oid, 'song'); } if ($demo_id && isset($democratic)) { $democratic->delete_from_oid($oid, 'song'); }
debug_event('play', "Song $media->file ($media->title) does not have a valid filename specified", 2); debug_event('play', "Song $media->file ($media->title) does not have a valid filename specified", 2);
header('HTTP/1.1 404 Invalid song, file not found or file unreadable'); header('HTTP/1.1 404 Invalid song, file not found or file unreadable');

View file

@ -49,8 +49,8 @@ switch ($_REQUEST['action']) {
$playlist_name = scrub_in($_REQUEST['playlist_name']); $playlist_name = scrub_in($_REQUEST['playlist_name']);
$playlist_type = scrub_in($_REQUEST['type']); $playlist_type = scrub_in($_REQUEST['type']);
Playlist::create($playlist_name, $playlist_type); $playlist_id = Playlist::create($playlist_name, $playlist_type);
$_SESSION['data']['playlist_id'] = $playlist->id; $_SESSION['data']['playlist_id'] = $playlist_id;
show_confirmation(T_('Playlist Created'), sprintf(T_('%1$s (%2$s) has been created'), $playlist_name, $playlist_type), 'playlist.php'); show_confirmation(T_('Playlist Created'), sprintf(T_('%1$s (%2$s) has been created'), $playlist_name, $playlist_type), 'playlist.php');
break; break;
case 'delete_playlist': case 'delete_playlist':