1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-04 10:19:25 +02:00

Replaced almost every dba::query to dba::read or dba::write.

This commit is contained in:
dipsol 2009-12-14 08:06:20 +00:00
parent 9b3232ba29
commit a7838e2a13
20 changed files with 2463 additions and 2463 deletions

View file

@ -58,7 +58,7 @@ if ($where) $where = "($where) AND catalog_type='local'";
else $where = "catalog_type='local'"; else $where = "catalog_type='local'";
$sql = "SELECT id FROM catalog"; $sql = "SELECT id FROM catalog";
if ($where) $sql .= " WHERE $where"; if ($where) $sql .= " WHERE $where";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
ob_start("ob_html_strip",'4096',true); ob_start("ob_html_strip",'4096',true);

View file

@ -38,7 +38,7 @@ if ($debug) { echo _("DEBUG ENABLED WILL NOT DELETE FILES!"); echo "\n"; }
/* Get a list of filenames */ /* Get a list of filenames */
$sql = "SELECT `id`,`file` FROM song WHERE enabled='0'"; $sql = "SELECT `id`,`file` FROM song WHERE enabled='0'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {
if ($debug) { if ($debug) {
@ -50,7 +50,7 @@ while ($row = Dba::fetch_assoc($db_results)) {
echo "\n"; echo "\n";
unlink($row['file']); unlink($row['file']);
$sql = "DELETE FROM `song` WHERE `id`='" . Dba::escape($row['id']) . "'"; $sql = "DELETE FROM `song` WHERE `id`='" . Dba::escape($row['id']) . "'";
$del_results = Dba::query($sql); $del_results = Dba::write($sql);
} }
} // end while } // end while

View file

@ -63,7 +63,7 @@ printf (_('Using %s as source character set'), $source_encoding);
echo "\n"; echo "\n";
$sql = "SELECT * FROM `catalog` WHERE `catalog_type`='local'"; $sql = "SELECT * FROM `catalog` WHERE `catalog_type`='local'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {

View file

@ -56,7 +56,7 @@ print "\n";
/* Attempt to figure out what catalog it comes from */ /* Attempt to figure out what catalog it comes from */
$sql = "SELECT `catalog`.`id` FROM `song` INNER JOIN `catalog` ON `song`.`catalog`=`catalog`.`id` WHERE `song`.`file` LIKE '%" . Dba::escape($filename) . "'"; $sql = "SELECT `catalog`.`id` FROM `song` INNER JOIN `catalog` ON `song`.`catalog`=`catalog`.`id` WHERE `song`.`file` LIKE '%" . Dba::escape($filename) . "'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results); $results = Dba::fetch_assoc($db_results);
$catalog = new Catalog($results['id']); $catalog = new Catalog($results['id']);

View file

@ -47,7 +47,7 @@ ob_end_clean();
/* First Clean the catalog to we don't try to write anything we shouldn't */ /* First Clean the catalog to we don't try to write anything we shouldn't */
$sql = "SELECT `id` FROM `catalog` WHERE `catalog_type`='local'"; $sql = "SELECT `id` FROM `catalog` WHERE `catalog_type`='local'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$catalogs = array(); $catalogs = array();
@ -295,7 +295,7 @@ function sort_move_file($song,$fullname) {
/* Update the catalog */ /* Update the catalog */
$sql = "UPDATE song SET file='" . Dba::escape($fullname) . "' WHERE id='" . Dba::escape($song->id) . "'"; $sql = "UPDATE song SET file='" . Dba::escape($fullname) . "' WHERE id='" . Dba::escape($song->id) . "'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
} // end else } // end else

View file

@ -64,7 +64,7 @@ class AmpacheMail {
break; break;
} // end filter switch } // end filter switch
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$results = array(); $results = array();

View file

@ -48,7 +48,7 @@ abstract class database_object {
} }
$sql = "SELECT * FROM `$table_name` WHERE `id`='$id'"; $sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
if (!$db_results) { return array(); } if (!$db_results) { return array(); }

View file

@ -1,21 +1,21 @@
<?php <?php
/* /*
Copyright (c) Ampache.org Copyright (c) Ampache.org
All rights reserved. All rights reserved.
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2 modify it under the terms of the GNU General Public License v2
as published by the Free Software Foundation. as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/* Make sure they aren't directly accessing it */ /* Make sure they aren't directly accessing it */
@ -252,7 +252,7 @@ class Dba {
if (Config::get('sql_profiling')) { if (Config::get('sql_profiling')) {
print '<br/>Profiling data: <br/>'; print '<br/>Profiling data: <br/>';
$res = Dba::query('show profiles'); $res = Dba::read('show profiles');
print '<table>'; print '<table>';
while ($r = Dba::fetch_row($res)) { while ($r = Dba::fetch_row($res)) {
print '<tr><td>' . implode('</td><td>', $r) . '</td></tr>'; print '<tr><td>' . implode('</td><td>', $r) . '</td></tr>';
@ -407,25 +407,25 @@ class Dba {
// Alter the charset for the entire database // Alter the charset for the entire database
$sql = "ALTER DATABASE `" . Config::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; $sql = "ALTER DATABASE `" . Config::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "SHOW TABLES"; $sql = "SHOW TABLES";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
// Go through the tables! // Go through the tables!
while ($row = Dba::fetch_row($db_results)) { while ($row = Dba::fetch_row($db_results)) {
$sql = "DESCRIBE `" . $row['0'] . "`"; $sql = "DESCRIBE `" . $row['0'] . "`";
$describe_results = Dba::query($sql); $describe_results = Dba::read($sql);
// Change the tables default charset and colliation // Change the tables default charset and colliation
$sql = "ALTER TABLE `" . $row['0'] . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; $sql = "ALTER TABLE `" . $row['0'] . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation";
$alter_table = Dba::query($sql); $alter_table = Dba::write($sql);
// Itterate through the columns of the table // Itterate through the columns of the table
while ($table = Dba::fetch_assoc($describe_results)) { while ($table = Dba::fetch_assoc($describe_results)) {
if (strstr($table['Type'],'varchar') OR strstr($table['Type'],'enum') OR strstr($table['Table'],'text')) { if (strstr($table['Type'],'varchar') OR strstr($table['Type'],'enum') OR strstr($table['Table'],'text')) {
$sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset; $sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset;
$charset_results = Dba::query($sql); $charset_results = Dba::write($sql);
if (!$charset_results) { if (!$charset_results) {
debug_event('CHARSET','Unable to update the charset of ' . $table['Field'] . '.' . $table['Type'] . ' to ' . $target_charset,'3'); debug_event('CHARSET','Unable to update the charset of ' . $table['Field'] . '.' . $table['Type'] . ' to ' . $target_charset,'3');
} // if it fails } // if it fails

View file

@ -550,7 +550,7 @@ class Query {
// First we need to get the SQL statement we are going to run // First we need to get the SQL statement we are going to run
// This has to run against any possible filters (dependent on type) // This has to run against any possible filters (dependent on type)
$sql = self::get_sql(); $sql = self::get_sql();
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$results = array(); $results = array();
while ($data = Dba::fetch_assoc($db_results)) { while ($data = Dba::fetch_assoc($db_results)) {

View file

@ -466,11 +466,11 @@ class Update {
// Alter the user table so that you can't have an ID beyond the // Alter the user table so that you can't have an ID beyond the
// range of the other tables which have to allow for -1 // range of the other tables which have to allow for -1
$sql = "ALTER TABLE `user` CHANGE `id` `id` INT ( 11 ) NOT NULL AUTO_INCREMENT"; $sql = "ALTER TABLE `user` CHANGE `id` `id` INT ( 11 ) NOT NULL AUTO_INCREMENT";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Now pull the access list users, alter table and then re-insert // Now pull the access list users, alter table and then re-insert
$sql = "SELECT DISTINCT(`user`) FROM `access_list`"; $sql = "SELECT DISTINCT(`user`) FROM `access_list`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
// Build the new SQL // Build the new SQL
@ -479,17 +479,17 @@ class Update {
$username = Dba::escape($username); $username = Dba::escape($username);
$sql = "UPDATE `access_list` SET `user`='$user_id' WHERE `user`='$username'"; $sql = "UPDATE `access_list` SET `user`='$user_id' WHERE `user`='$username'";
$update_results = Dba::query($sql); $update_results = Dba::write($sql);
} // end while access_list } // end while access_list
// Alter the table // Alter the table
$sql = "ALTER TABLE `access_list` CHANGE `user` `user` INT ( 11 ) NOT NULL"; $sql = "ALTER TABLE `access_list` CHANGE `user` `user` INT ( 11 ) NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Now pull flagged users, update and alter // Now pull flagged users, update and alter
$sql = "SELECT DISTINCT(`user`) FROM `flagged`"; $sql = "SELECT DISTINCT(`user`) FROM `flagged`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$username = $r['user']; $username = $r['user'];
@ -497,18 +497,18 @@ class Update {
$username = Dba::escape($username); $username = Dba::escape($username);
$sql = "UPDATE `flagged` SET `user`='$user_id' WHERE `user`='$username'"; $sql = "UPDATE `flagged` SET `user`='$user_id' WHERE `user`='$username'";
$update_results = Dba::query($sql); $update_results = Dba::write($sql);
} // end while } // end while
// Alter the table // Alter the table
$sql = "ALTER TABLE `flagged` CHANGE `user` `user` INT ( 11 ) NOT NULL"; $sql = "ALTER TABLE `flagged` CHANGE `user` `user` INT ( 11 ) NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Now fix up the ip history // Now fix up the ip history
$sql = "SELECT DISTINCT(`user`) FROM `ip_history`"; $sql = "SELECT DISTINCT(`user`) FROM `ip_history`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$username = $r['user']; $username = $r['user'];
@ -516,17 +516,17 @@ class Update {
$username = Dba::escape($username); $username = Dba::escape($username);
$sql = "UPDATE `ip_history` SET `user`='$user_id' WHERE `user`='$username'"; $sql = "UPDATE `ip_history` SET `user`='$user_id' WHERE `user`='$username'";
$update_results = Dba::query($sql); $update_results = Dba::write($sql);
} // end while } // end while
// Alter the table // Alter the table
$sql = "ALTER TABLE `ip_history` CHANGE `user` `user` INT ( 11 ) NOT NULL"; $sql = "ALTER TABLE `ip_history` CHANGE `user` `user` INT ( 11 ) NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Now fix now playing // Now fix now playing
$sql = "SELECT DISTINCT(`user`) FROM `now_playing`"; $sql = "SELECT DISTINCT(`user`) FROM `now_playing`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$username = $r['user']; $username = $r['user'];
@ -534,17 +534,17 @@ class Update {
$username = Dba::escape($username); $username = Dba::escape($username);
$sql = "UPDATE `now_playing` SET `user`='$user_id' WHERE `user`='$username'"; $sql = "UPDATE `now_playing` SET `user`='$user_id' WHERE `user`='$username'";
$update_results = Dba::query($sql); $update_results = Dba::write($sql);
} // end while } // end while
// Alter the table // Alter the table
$sql = "ALTER TABLE `now_playing` CHANGE `user` `user` INT ( 11 ) NOT NULL"; $sql = "ALTER TABLE `now_playing` CHANGE `user` `user` INT ( 11 ) NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Now fix the playlist table // Now fix the playlist table
$sql = "SELECT DISTINCT(`user`) FROM `playlist`"; $sql = "SELECT DISTINCT(`user`) FROM `playlist`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$username = $r['user']; $username = $r['user'];
@ -552,21 +552,21 @@ class Update {
$username = Dba::escape($username); $username = Dba::escape($username);
$sql = "UPDATE `playlist` SET `user`='$user_id' WHERE `user`='$username'"; $sql = "UPDATE `playlist` SET `user`='$user_id' WHERE `user`='$username'";
$update_results = Dba::query($sql); $update_results = Dba::write($sql);
} // end while } // end while
// Alter the table // Alter the table
$sql = "ALTER TABLE `playlist` CHANGE `user` `user` INT ( 11 ) NOT NULL"; $sql = "ALTER TABLE `playlist` CHANGE `user` `user` INT ( 11 ) NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Drop unused table // Drop unused table
$sql = "DROP TABLE `playlist_permission`"; $sql = "DROP TABLE `playlist_permission`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Now fix the ratings table // Now fix the ratings table
$sql = "SELECT DISTINCT(`user`) FROM `ratings`"; $sql = "SELECT DISTINCT(`user`) FROM `ratings`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$username = $r['user']; $username = $r['user'];
@ -574,20 +574,20 @@ class Update {
$username = Dba::escape($username); $username = Dba::escape($username);
$sql = "UPDATE `ratings` SET `user`='$user_id' WHERE `user`='$username'"; $sql = "UPDATE `ratings` SET `user`='$user_id' WHERE `user`='$username'";
$update_results = Dba::query($sql); $update_results = Dba::write($sql);
} // end while } // end while
$sql = "ALTER TABLE `ratings` CHANGE `user` `user` INT ( 11 ) NOT NULL"; $sql = "ALTER TABLE `ratings` CHANGE `user` `user` INT ( 11 ) NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Now work on the tag_map // Now work on the tag_map
$sql = "ALTER TABLE `tag_map` CHANGE `user_id` `user` INT ( 11 ) NOT NULL"; $sql = "ALTER TABLE `tag_map` CHANGE `user_id` `user` INT ( 11 ) NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Now fix user preferences // Now fix user preferences
$sql = "SELECT DISTINCT(`user`) FROM `user_preference`"; $sql = "SELECT DISTINCT(`user`) FROM `user_preference`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$username = $r['user']; $username = $r['user'];
@ -595,64 +595,64 @@ class Update {
$username = Dba::escape($username); $username = Dba::escape($username);
$sql = "UPDATE `user_preference` SET `user`='$user_id' WHERE `user`='$username'"; $sql = "UPDATE `user_preference` SET `user`='$user_id' WHERE `user`='$username'";
$update_results = Dba::query($sql); $update_results = Dba::write($sql);
} // end while } // end while
// Alter the table // Alter the table
$sql = "ALTER TABLE `user_preference` CHANGE `user` `user` INT ( 11 ) NOT NULL"; $sql = "ALTER TABLE `user_preference` CHANGE `user` `user` INT ( 11 ) NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Add a date to the user_vote // Add a date to the user_vote
$sql = "ALTER TABLE `user_vote` ADD `date` INT( 11 ) UNSIGNED NOT NULL"; $sql = "ALTER TABLE `user_vote` ADD `date` INT( 11 ) UNSIGNED NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Add the index for said field // Add the index for said field
$sql = "ALTER TABLE `user_vote` ADD INDEX(`date`)"; $sql = "ALTER TABLE `user_vote` ADD INDEX(`date`)";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Add the thumb fields to album // Add the thumb fields to album
$sql = "ALTER TABLE `album` ADD `thumb` TINYBLOB NULL ,ADD `thumb_mime` VARCHAR( 128 ) NULL"; $sql = "ALTER TABLE `album` ADD `thumb` TINYBLOB NULL ,ADD `thumb_mime` VARCHAR( 128 ) NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Now add in the min_object_count preference and the random_method // Now add in the min_object_count preference and the random_method
$sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES('min_object_count','1','Min Element Count','5','integer','interface')"; "VALUES('min_object_count','1','Min Element Count','5','integer','interface')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES('random_method','default','Random Method','5','string','interface')"; "VALUES('random_method','default','Random Method','5','string','interface')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Delete old preference // Delete old preference
$sql = "DELETE FROM `preferences` WHERE `name`='min_album_size'"; $sql = "DELETE FROM `preferences` WHERE `name`='min_album_size'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Make Hash a non-required field and smaller // Make Hash a non-required field and smaller
$sql = "ALTER TABLE `song` CHANGE `hash` `hash` VARCHAR ( 64 ) NULL"; $sql = "ALTER TABLE `song` CHANGE `hash` `hash` VARCHAR ( 64 ) NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Make user access an int, nothing else // Make user access an int, nothing else
$sql = "UPDATE `user` SET `access`='100' WHERE `access`='admin'"; $sql = "UPDATE `user` SET `access`='100' WHERE `access`='admin'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "UPDATE `user` SET `access`='25' WHERE `access`='user'"; $sql = "UPDATE `user` SET `access`='25' WHERE `access`='user'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "UPDATE `user` SET `access`='5' WHERE `access`='guest'"; $sql = "UPDATE `user` SET `access`='5' WHERE `access`='guest'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Alter the table // Alter the table
$sql = "ALTER TABLE `user` CHANGE `access` `access` TINYINT ( 4 ) UNSIGNED NOT NULL"; $sql = "ALTER TABLE `user` CHANGE `access` `access` TINYINT ( 4 ) UNSIGNED NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Add in Label and Catalog # and language // Add in Label and Catalog # and language
$sql = "ALTER TABLE `song_ext_data` ADD `label` VARCHAR ( 128 ) NULL, ADD `catalog_number` VARCHAR ( 128 ) NULL, ADD `language` VARCHAR ( 128 ) NULL"; $sql = "ALTER TABLE `song_ext_data` ADD `label` VARCHAR ( 128 ) NULL, ADD `catalog_number` VARCHAR ( 128 ) NULL, ADD `language` VARCHAR ( 128 ) NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
/* Fix every users preferences */ /* Fix every users preferences */
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
User::fix_preferences('-1'); User::fix_preferences('-1');
@ -676,7 +676,7 @@ class Update {
/* Add the offset_limit preference and remove it from the user table */ /* Add the offset_limit preference and remove it from the user table */
$sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . $sql = "INSERT INTO `preferences` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('offset_limit','50','Offset Limit','5','integer','interface')"; "VALUES ('offset_limit','50','Offset Limit','5','integer','interface')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
self::set_version('db_version','340002'); self::set_version('db_version','340002');
@ -694,22 +694,22 @@ class Update {
public static function update_340003() { public static function update_340003() {
$sql = "ALTER TABLE `song` CHANGE `mode` `mode` ENUM( 'abr', 'vbr', 'cbr' ) NULL DEFAULT 'cbr'"; $sql = "ALTER TABLE `song` CHANGE `mode` `mode` ENUM( 'abr', 'vbr', 'cbr' ) NULL DEFAULT 'cbr'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `song` CHANGE `time` `time` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0'"; $sql = "ALTER TABLE `song` CHANGE `time` `time` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `song` CHANGE `rate` `rate` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'"; $sql = "ALTER TABLE `song` CHANGE `rate` `rate` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `song` CHANGE `bitrate` `bitrate` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'"; $sql = "ALTER TABLE `song` CHANGE `bitrate` `bitrate` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `song` CHANGE `track` `track` SMALLINT( 5 ) UNSIGNED NULL DEFAULT NULL "; $sql = "ALTER TABLE `song` CHANGE `track` `track` SMALLINT( 5 ) UNSIGNED NULL DEFAULT NULL ";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `user` CHANGE `disabled` `disabled` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'"; $sql = "ALTER TABLE `user` CHANGE `disabled` `disabled` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "CREATE TABLE `album_data` (" . $sql = "CREATE TABLE `album_data` (" .
"`album_id` INT( 11 ) UNSIGNED NOT NULL , " . "`album_id` INT( 11 ) UNSIGNED NOT NULL , " .
@ -719,11 +719,11 @@ class Update {
"`thumb_mime` VARCHAR( 64 ) NULL , " . "`thumb_mime` VARCHAR( 64 ) NULL , " .
"UNIQUE ( `album_id` )" . "UNIQUE ( `album_id` )" .
") ENGINE = MYISAM"; ") ENGINE = MYISAM";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
/* Foreach the Albums and move the data into the new album_data table */ /* Foreach the Albums and move the data into the new album_data table */
$sql = "SELECT * FROM album"; $sql = "SELECT * FROM album";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
while ($data = Dba::fetch_assoc($db_results)) { while ($data = Dba::fetch_assoc($db_results)) {
$id = $data['id']; $id = $data['id'];
@ -733,48 +733,48 @@ class Update {
$thumb_mime = Dba::escape($data['thumb_mime']); $thumb_mime = Dba::escape($data['thumb_mime']);
$sql = "INSERT INTO `album_data` (`album_id`,`art`,`art_mime`,`thumb`,`thumb_mime`)" . $sql = "INSERT INTO `album_data` (`album_id`,`art`,`art_mime`,`thumb`,`thumb_mime`)" .
" VALUES ('$id','$art','$art_mime','$thumb','$thumb_mime')"; " VALUES ('$id','$art','$art_mime','$thumb','$thumb_mime')";
$insert_results = Dba::query($sql); $insert_results = Dba::write($sql);
} // end while } // end while
$sql = "RENAME TABLE `song_ext_data` TO `song_data`"; $sql = "RENAME TABLE `song_ext_data` TO `song_data`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "RENAME TABLE `preferences` TO `preference`"; $sql = "RENAME TABLE `preferences` TO `preference`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "RENAME TABLE `ratings` TO `rating`"; $sql = "RENAME TABLE `ratings` TO `rating`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Go ahead and drop the art/thumb stuff // Go ahead and drop the art/thumb stuff
$sql = "ALTER TABLE `album` DROP `art`, DROP `art_mime`, DROP `thumb`, DROP `thumb_mime`"; $sql = "ALTER TABLE `album` DROP `art`, DROP `art_mime`, DROP `thumb`, DROP `thumb_mime`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// We need to fix the user_vote table // We need to fix the user_vote table
$sql = "ALTER TABLE `user_vote` CHANGE `user` `user` INT( 11 ) UNSIGNED NOT NULL"; $sql = "ALTER TABLE `user_vote` CHANGE `user` `user` INT( 11 ) UNSIGNED NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Remove offset limit from the user // Remove offset limit from the user
$sql = "ALTER TABLE `user` DROP `offset_limit`"; $sql = "ALTER TABLE `user` DROP `offset_limit`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `rating` CHANGE `user_rating` `rating` ENUM( '-1', '0', '1', '2', '3', '4', '5' ) NOT NULL DEFAULT '0'"; $sql = "ALTER TABLE `rating` CHANGE `user_rating` `rating` ENUM( '-1', '0', '1', '2', '3', '4', '5' ) NOT NULL DEFAULT '0'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
/* Add the rate_limit preference */ /* Add the rate_limit preference */
$sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('rate_limit','8192','Rate Limit','100','integer','streaming')"; "VALUES ('rate_limit','8192','Rate Limit','100','integer','streaming')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
/* Add the playlist_method preference and remove it from the user table */ /* Add the playlist_method preference and remove it from the user table */
$sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('playlist_method','normal','Playlist Method','5','string','streaming')"; "VALUES ('playlist_method','normal','Playlist Method','5','string','streaming')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `update_info` ADD UNIQUE (`key`)"; $sql = "ALTER TABLE `update_info` ADD UNIQUE (`key`)";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
User::fix_preferences('-1'); User::fix_preferences('-1');
@ -797,21 +797,21 @@ class Update {
/* Alter the session.id so that it's 64 */ /* Alter the session.id so that it's 64 */
$sql = "ALTER TABLE `session` CHANGE `id` `id` VARCHAR( 64 ) NOT NULL"; $sql = "ALTER TABLE `session` CHANGE `id` `id` VARCHAR( 64 ) NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
/* Add Playlist Related Preferences */ /* Add Playlist Related Preferences */
$sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('playlist_add','append','Add Behavior','5','string','playlist')"; "VALUES ('playlist_add','append','Add Behavior','5','string','playlist')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Switch the existing preferences over to this new catagory // Switch the existing preferences over to this new catagory
$sql = "UPDATE `preference` SET `catagory`='playlist' WHERE `name`='playlist_method' " . $sql = "UPDATE `preference` SET `catagory`='playlist' WHERE `name`='playlist_method' " .
" OR `name`='playlist_type'"; " OR `name`='playlist_type'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Change the default value for playlist_method // Change the default value for playlist_method
$sql = "UPDATE `preference` SET `value`='normal' WHERE `name`='playlist_method'"; $sql = "UPDATE `preference` SET `value`='normal' WHERE `name`='playlist_method'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Add in the shoutbox // Add in the shoutbox
$sql = "CREATE TABLE `user_shout` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , " . $sql = "CREATE TABLE `user_shout` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , " .
@ -822,25 +822,25 @@ class Update {
"`object_id` INT( 11 ) UNSIGNED NOT NULL , " . "`object_id` INT( 11 ) UNSIGNED NOT NULL , " .
"`object_type` VARCHAR( 32 ) NOT NULL " . "`object_type` VARCHAR( 32 ) NOT NULL " .
") ENGINE = MYISAM"; ") ENGINE = MYISAM";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `user_shout` ADD INDEX ( `sticky` )"; $sql = "ALTER TABLE `user_shout` ADD INDEX ( `sticky` )";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `user_shout` ADD INDEX ( `date` )"; $sql = "ALTER TABLE `user_shout` ADD INDEX ( `date` )";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `user_shout` ADD INDEX ( `user` )"; $sql = "ALTER TABLE `user_shout` ADD INDEX ( `user` )";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `now_playing` CHANGE `start_time` `expire` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0'"; $sql = "ALTER TABLE `now_playing` CHANGE `start_time` `expire` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "OPTIMIZE TABLE `album`"; $sql = "OPTIMIZE TABLE `album`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
User::fix_preferences('-1'); User::fix_preferences('-1');
@ -863,31 +863,31 @@ class Update {
// Turn user_rating into a tinyint and call it score // Turn user_rating into a tinyint and call it score
$sql = "ALTER TABLE `rating` CHANGE `user_rating` `score` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'"; $sql = "ALTER TABLE `rating` CHANGE `user_rating` `score` TINYINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "UPDATE `preference` SET `catagory`='playlist' WHERE `name`='random_method'"; $sql = "UPDATE `preference` SET `catagory`='playlist' WHERE `name`='random_method'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('transcode','default','Transcoding','25','string','streaming')"; "VALUES ('transcode','default','Transcoding','25','string','streaming')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
/* We need to check for playlist_method here because I fubar'd an earlier update */ /* We need to check for playlist_method here because I fubar'd an earlier update */
$sql = "SELECT * FROM `preference` WHERE `name`='playlist_method'"; $sql = "SELECT * FROM `preference` WHERE `name`='playlist_method'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
if (!Dba::num_rows($db_results)) { if (!Dba::num_rows($db_results)) {
/* Add the playlist_method preference and remove it from the user table */ /* Add the playlist_method preference and remove it from the user table */
$sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " . $sql = "INSERT INTO `preference` (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
"VALUES ('playlist_method','default','Playlist Method','5','string','playlist')"; "VALUES ('playlist_method','default','Playlist Method','5','string','playlist')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
} }
// Add in the object_type to the tmpplaylist data table so that we can have non-songs in there // Add in the object_type to the tmpplaylist data table so that we can have non-songs in there
$sql = "ALTER TABLE `tmp_playlist_data` ADD `object_type` VARCHAR( 32 ) NULL AFTER `tmp_playlist`"; $sql = "ALTER TABLE `tmp_playlist_data` ADD `object_type` VARCHAR( 32 ) NULL AFTER `tmp_playlist`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
User::fix_preferences('-1'); User::fix_preferences('-1');
@ -909,7 +909,7 @@ class Update {
public static function update_340006() { public static function update_340006() {
$sql = "DESCRIBE `album_data`"; $sql = "DESCRIBE `album_data`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {
if ($row['Field'] == 'art' AND $row['Type'] == 'blob') { if ($row['Field'] == 'art' AND $row['Type'] == 'blob') {
@ -918,15 +918,15 @@ class Update {
} // end while } // end while
if ($blob_needed) { if ($blob_needed) {
$sql = "ALTER TABLE `album_data` CHANGE `art` `art` MEDIUMBLOB NULL DEFAULT NULL"; $sql = "ALTER TABLE `album_data` CHANGE `art` `art` MEDIUMBLOB NULL DEFAULT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
} }
// No matter what remove that random method preference // No matter what remove that random method preference
$sql = "DELETE FROM `preference` WHERE `name`='random_method'"; $sql = "DELETE FROM `preference` WHERE `name`='random_method'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
User::fix_preferences('-1'); User::fix_preferences('-1');
@ -950,7 +950,7 @@ class Update {
// Tweak the session table to handle larger session vars for my page-a-nation hotness // Tweak the session table to handle larger session vars for my page-a-nation hotness
$sql = "ALTER TABLE `session` CHANGE `value` `value` LONGTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; $sql = "ALTER TABLE `session` CHANGE `value` `value` LONGTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Create the new stream table where we will store stream SIDs // Create the new stream table where we will store stream SIDs
$sql = "CREATE TABLE `session_stream` ( " . $sql = "CREATE TABLE `session_stream` ( " .
@ -961,15 +961,15 @@ class Update {
"`ip` INT( 11 ) UNSIGNED NULL , " . "`ip` INT( 11 ) UNSIGNED NULL , " .
"PRIMARY KEY ( `id` ) " . "PRIMARY KEY ( `id` ) " .
") ENGINE = MYISAM"; ") ENGINE = MYISAM";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Change the now playing to use stream session ids for its ID // Change the now playing to use stream session ids for its ID
$sql = "ALTER TABLE `now_playing` CHANGE `id` `id` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; $sql = "ALTER TABLE `now_playing` CHANGE `id` `id` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Now longer needed because of the new hotness // Now longer needed because of the new hotness
$sql = "ALTER TABLE `now_playing` DROP `session`"; $sql = "ALTER TABLE `now_playing` DROP `session`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
self::set_version('db_version','340007'); self::set_version('db_version','340007');
@ -985,36 +985,36 @@ class Update {
public static function update_340008() { public static function update_340008() {
$sql = "ALTER TABLE `playlist_data` CHANGE `song` `object_id` INT( 11 ) UNSIGNED NULL DEFAULT NULL"; $sql = "ALTER TABLE `playlist_data` CHANGE `song` `object_id` INT( 11 ) UNSIGNED NULL DEFAULT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `playlist_data` CHANGE `dyn_song` `dynamic_song` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL"; $sql = "ALTER TABLE `playlist_data` CHANGE `dyn_song` `dynamic_song` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `playlist_data` ADD `object_type` VARCHAR( 32 ) NOT NULL DEFAULT 'song' AFTER `object_id`"; $sql = "ALTER TABLE `playlist_data` ADD `object_type` VARCHAR( 32 ) NOT NULL DEFAULT 'song' AFTER `object_id`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `playlist` ADD `genre` INT( 11 ) UNSIGNED NOT NULL AFTER `type`"; $sql = "ALTER TABLE `playlist` ADD `genre` INT( 11 ) UNSIGNED NOT NULL AFTER `type`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "DELETE FROM `preference` WHERE `name`='allow_downsample_playback'"; $sql = "DELETE FROM `preference` WHERE `name`='allow_downsample_playback'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "UPDATE `preference` SET `description`='Transcode Bitrate' WHERE `name`='sample_rate'"; $sql = "UPDATE `preference` SET `description`='Transcode Bitrate' WHERE `name`='sample_rate'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Check for old tables and drop if found, seems like there was a glitch that caused them // Check for old tables and drop if found, seems like there was a glitch that caused them
// not to get droped.. *shrug* // not to get droped.. *shrug*
$sql = "DROP TABLE IF EXISTS `preferences`"; $sql = "DROP TABLE IF EXISTS `preferences`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "DROP TABLE IF EXISTS `song_ext_data`"; $sql = "DROP TABLE IF EXISTS `song_ext_data`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "DROP TABLE IF EXISTS `ratings`"; $sql = "DROP TABLE IF EXISTS `ratings`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
User::fix_preferences('-1'); User::fix_preferences('-1');
@ -1035,13 +1035,13 @@ class Update {
public static function update_340009() { public static function update_340009() {
$sql = "ALTER TABLE `album` ADD `disk` smallint(5) UNSIGNED DEFAULT NULL"; $sql = "ALTER TABLE `album` ADD `disk` smallint(5) UNSIGNED DEFAULT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `album` ADD INDEX (`disk`)"; $sql = "ALTER TABLE `album` ADD INDEX (`disk`)";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `access_list` ADD `dns` VARCHAR( 255 ) NOT NULL AFTER `end`"; $sql = "ALTER TABLE `access_list` ADD `dns` VARCHAR( 255 ) NOT NULL AFTER `end`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "CREATE TABLE `artist_data` (" . $sql = "CREATE TABLE `artist_data` (" .
"`artist_id` INT( 11 ) UNSIGNED NOT NULL ," . "`artist_id` INT( 11 ) UNSIGNED NOT NULL ," .
@ -1051,7 +1051,7 @@ class Update {
"`thumb_mime` VARCHAR( 32 ) NOT NULL ," . "`thumb_mime` VARCHAR( 32 ) NOT NULL ," .
"`bio` TEXT NOT NULL , " . "`bio` TEXT NOT NULL , " .
"UNIQUE (`artist_id`) ) ENGINE = MYISAM"; "UNIQUE (`artist_id`) ) ENGINE = MYISAM";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
self::set_version('db_version','340009'); self::set_version('db_version','340009');
@ -1066,23 +1066,23 @@ class Update {
public static function update_340010() { public static function update_340010() {
$sql = "UPDATE `preference` SET `catagory`='options' WHERE `name` LIKE 'localplay_%'"; $sql = "UPDATE `preference` SET `catagory`='options' WHERE `name` LIKE 'localplay_%'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "DELETE FROM `preference` WHERE `name`='playlist_add'"; $sql = "DELETE FROM `preference` WHERE `name`='playlist_add'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "UPDATE `preference` SET `catagory`='plugins' WHERE (`name` LIKE 'mystrands_%' OR `name` LIKE 'lastfm_%') AND `catagory`='options'"; $sql = "UPDATE `preference` SET `catagory`='plugins' WHERE (`name` LIKE 'mystrands_%' OR `name` LIKE 'lastfm_%') AND `catagory`='options'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "UPDATE `preference` SET `value`='default' WHERE `name`='playlist_method'"; $sql = "UPDATE `preference` SET `value`='default' WHERE `name`='playlist_method'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "UPDATE `preference` SET `description`='Localplay Config' WHERE `name`='localplay_level'"; $sql = "UPDATE `preference` SET `description`='Localplay Config' WHERE `name`='localplay_level'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
/* Fix every users preferences */ /* Fix every users preferences */
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
User::fix_preferences('-1'); User::fix_preferences('-1');
@ -1114,7 +1114,7 @@ class Update {
"`ip` INT( 11 ) UNSIGNED NULL , " . "`ip` INT( 11 ) UNSIGNED NULL , " .
"PRIMARY KEY ( `id` ) " . "PRIMARY KEY ( `id` ) " .
") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
self::set_version('db_version','340011'); self::set_version('db_version','340011');
@ -1130,7 +1130,7 @@ class Update {
public static function update_340012() { public static function update_340012() {
$sql = "ALTER TABLE `catalog` ADD `add_path` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER `path`"; $sql = "ALTER TABLE `catalog` ADD `add_path` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER `path`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "CREATE TABLE `democratic` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," . $sql = "CREATE TABLE `democratic` (`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ," .
"`name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ," . "`name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ," .
@ -1139,13 +1139,13 @@ class Update {
"`user` INT( 11 ) NOT NULL ," . "`user` INT( 11 ) NOT NULL ," .
"`primary` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'" . "`primary` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'" .
") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `democratic` ADD INDEX (`primary`)"; $sql = "ALTER TABLE `democratic` ADD INDEX (`primary`)";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `democratic` ADD INDEX (`level`)"; $sql = "ALTER TABLE `democratic` ADD INDEX (`level`)";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
self::set_version('db_version','340012'); self::set_version('db_version','340012');
@ -1162,16 +1162,16 @@ class Update {
$sql = "DELETE FROM `preference` WHERE `name`='localplay_mpd_hostname' OR `name`='localplay_mpd_port' " . $sql = "DELETE FROM `preference` WHERE `name`='localplay_mpd_hostname' OR `name`='localplay_mpd_port' " .
"OR `name`='direct_link' OR `name`='localplay_mpd_password' OR `name`='catalog_echo_count'"; "OR `name`='direct_link' OR `name`='localplay_mpd_password' OR `name`='catalog_echo_count'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "UPDATE `preference` SET `description`='Localplay Access' WHERE `name`='localplay_level'"; $sql = "UPDATE `preference` SET `description`='Localplay Access' WHERE `name`='localplay_level'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "UPDATE `access_list` SET `type`='rpc' WHERE `type`='xml-rpc'"; $sql = "UPDATE `access_list` SET `type`='rpc' WHERE `type`='xml-rpc'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
User::fix_preferences('-1'); User::fix_preferences('-1');
@ -1195,16 +1195,16 @@ class Update {
public static function update_340014() { public static function update_340014() {
$sql = "DROP TABLE `session_api`"; $sql = "DROP TABLE `session_api`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `session` CHANGE `type` `type` ENUM ('mysql','ldap','http','api','xml-rpc') NOT NULL"; $sql = "ALTER TABLE `session` CHANGE `type` `type` ENUM ('mysql','ldap','http','api','xml-rpc') NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `session` ADD `agent` VARCHAR ( 255 ) NOT NULL AFTER `type`"; $sql = "ALTER TABLE `session` ADD `agent` VARCHAR ( 255 ) NOT NULL AFTER `type`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `session` ADD INDEX (`type`)"; $sql = "ALTER TABLE `session` ADD INDEX (`type`)";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
self::set_version('db_version','340014'); self::set_version('db_version','340014');
@ -1221,14 +1221,14 @@ class Update {
public static function update_340015() { public static function update_340015() {
$sql = "ALTER TABLE `playlist` DROP `date`"; $sql = "ALTER TABLE `playlist` DROP `date`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `playlist` ADD `date` INT ( 11 ) UNSIGNED NOT NULL"; $sql = "ALTER TABLE `playlist` ADD `date` INT ( 11 ) UNSIGNED NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Pull all of the rating information // Pull all of the rating information
$sql = "SELECT `id`,`rating` FROM `rating`"; $sql = "SELECT `id`,`rating` FROM `rating`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$results = array(); $results = array();
@ -1237,16 +1237,16 @@ class Update {
} }
$sql = "ALTER TABLE `rating` DROP `rating`"; $sql = "ALTER TABLE `rating` DROP `rating`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `rating` ADD `rating` TINYINT ( 4 ) NOT NULL"; $sql = "ALTER TABLE `rating` ADD `rating` TINYINT ( 4 ) NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
foreach ($results as $row) { foreach ($results as $row) {
$rating = Dba::escape($row['rating']); $rating = Dba::escape($row['rating']);
$id = Dba::escape($row['id']); $id = Dba::escape($row['id']);
$sql = "UPDATE `rating` SET `rating`='$rating' WHERE `id`='$id'"; $sql = "UPDATE `rating` SET `rating`='$rating' WHERE `id`='$id'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
} }
self::set_version('db_version','340015'); self::set_version('db_version','340015');
@ -1263,7 +1263,7 @@ class Update {
public static function update_340016() { public static function update_340016() {
$sql = "ALTER TABLE `democratic` ADD `base_playlist` INT ( 11 ) UNSIGNED NOT NULL"; $sql = "ALTER TABLE `democratic` ADD `base_playlist` INT ( 11 ) UNSIGNED NOT NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
self::set_version('db_version','340016'); self::set_version('db_version','340016');
@ -1279,16 +1279,16 @@ class Update {
public static function update_340017() { public static function update_340017() {
$sql = "ALTER TABLE `democratic` ADD `base_playlist` INT( 11 ) UNSIGNED NOT NULL AFTER `name`"; $sql = "ALTER TABLE `democratic` ADD `base_playlist` INT( 11 ) UNSIGNED NOT NULL AFTER `name`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `tmp_playlist` DROP `base_playlist`"; $sql = "ALTER TABLE `tmp_playlist` DROP `base_playlist`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "DELETE FROM `tmp_playlist` WHERE `session`='-1'"; $sql = "DELETE FROM `tmp_playlist` WHERE `session`='-1'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "TRUNCATE `democratic`"; $sql = "TRUNCATE `democratic`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
self::set_version('db_version','340017'); self::set_version('db_version','340017');
@ -1350,25 +1350,25 @@ class Update {
// Alter the charset for the entire database // Alter the charset for the entire database
$sql = "ALTER DATABASE `" . Config::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; $sql = "ALTER DATABASE `" . Config::get('database_name') . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "SHOW TABLES"; $sql = "SHOW TABLES";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
// Go through the tables! // Go through the tables!
while ($row = Dba::fetch_row($db_results)) { while ($row = Dba::fetch_row($db_results)) {
$sql = "DESCRIBE `" . $row['0'] . "`"; $sql = "DESCRIBE `" . $row['0'] . "`";
$describe_results = Dba::query($sql); $describe_results = Dba::read($sql);
// Change the tables default charset and colliation // Change the tables default charset and colliation
$sql = "ALTER TABLE `" . $row['0'] . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation"; $sql = "ALTER TABLE `" . $row['0'] . "` DEFAULT CHARACTER SET $target_charset COLLATE $target_collation";
$alter_table = Dba::query($sql); $alter_table = Dba::write($sql);
// Itterate through the columns of the table // Itterate through the columns of the table
while ($table = Dba::fetch_assoc($describe_results)) { while ($table = Dba::fetch_assoc($describe_results)) {
if (strstr($table['Type'],'varchar') OR strstr($table['Type'],'enum') OR strstr($table['Table'],'text')) { if (strstr($table['Type'],'varchar') OR strstr($table['Type'],'enum') OR strstr($table['Table'],'text')) {
$sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset; $sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset;
$charset_results = Dba::query($sql); $charset_results = Dba::write($sql);
if (!$charset_results) { if (!$charset_results) {
debug_event('CHARSET','Unable to update the charset of ' . $table['Field'] . '.' . $table['Type'] . ' to ' . $target_charset,'3'); debug_event('CHARSET','Unable to update the charset of ' . $table['Field'] . '.' . $table['Type'] . ' to ' . $target_charset,'3');
} // if it fails } // if it fails
@ -1391,19 +1391,19 @@ class Update {
public static function update_350001() { public static function update_350001() {
$sql = "ALTER TABLE `tag_map` ADD `tag_id` INT ( 11 ) UNSIGNED NOT NULL AFTER `id`"; $sql = "ALTER TABLE `tag_map` ADD `tag_id` INT ( 11 ) UNSIGNED NOT NULL AFTER `id`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "RENAME TABLE `tags` TO `tag`"; $sql = "RENAME TABLE `tags` TO `tag`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `tag` CHANGE `map_id` `id` INT ( 11 ) UNSIGNED NOT NULL auto_increment"; $sql = "ALTER TABLE `tag` CHANGE `map_id` `id` INT ( 11 ) UNSIGNED NOT NULL auto_increment";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `album` CHANGE `prefix` `prefix` VARCHAR ( 32 ) NULL"; $sql = "ALTER TABLE `album` CHANGE `prefix` `prefix` VARCHAR ( 32 ) NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
$sql = "ALTER TABLE `artist` CHANGE `prefix` `prefix` VARCHAR ( 32 ) NULL"; $sql = "ALTER TABLE `artist` CHANGE `prefix` `prefix` VARCHAR ( 32 ) NULL";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
self::set_version('db_version','350001'); self::set_version('db_version','350001');
@ -1633,7 +1633,7 @@ class Update {
$db_results = Dba::write($sql); $db_results = Dba::write($sql);
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
User::fix_preferences('-1'); User::fix_preferences('-1');
@ -1785,7 +1785,7 @@ class Update {
$db_results = Dba::write($sql); $db_results = Dba::write($sql);
$sql = "SELECT `id` FROM `user`"; $sql = "SELECT `id` FROM `user`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
User::fix_preferences('-1'); User::fix_preferences('-1');

View file

@ -834,7 +834,7 @@ class User extends database_object {
/* Get All Preferences for the current user */ /* Get All Preferences for the current user */
$sql = "SELECT * FROM `user_preference` WHERE `user`='$user_id'"; $sql = "SELECT * FROM `user_preference` WHERE `user`='$user_id'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$results = array(); $results = array();
@ -871,7 +871,7 @@ class User extends database_object {
if ($user_id != '-1') { if ($user_id != '-1') {
$sql .= " WHERE catagory !='system'"; $sql .= " WHERE catagory !='system'";
} }
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {

View file

@ -97,7 +97,7 @@ class vauth {
$expire = isset($_COOKIE[Config::get('session_name') . '_remember']) ? time() + Config::get('remember_length') : time() + Config::get('session_length'); $expire = isset($_COOKIE[Config::get('session_name') . '_remember']) ? time() + Config::get('remember_length') : time() + Config::get('session_length');
$sql = "UPDATE `session` SET `value`='$value', `expire`='$expire' WHERE `id`='$key'"; $sql = "UPDATE `session` SET `value`='$value', `expire`='$expire' WHERE `id`='$key'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
debug_event('SESSION','Writing to ' . $key . ' with expire ' . $expire . ' ' . Dba::error(),'6'); debug_event('SESSION','Writing to ' . $key . ' with expire ' . $expire . ' ' . Dba::error(),'6');
@ -117,7 +117,7 @@ class vauth {
// Remove anything and EVERYTHING // Remove anything and EVERYTHING
$sql = "DELETE FROM `session` WHERE `id`='$key'"; $sql = "DELETE FROM `session` WHERE `id`='$key'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
debug_event('SESSION','Deleting Session with key:' . $key,'6'); debug_event('SESSION','Deleting Session with key:' . $key,'6');
@ -198,7 +198,7 @@ class vauth {
$key = Dba::escape($key); $key = Dba::escape($key);
$sql = "SELECT * FROM `session` WHERE `id`='$key' AND `expire` > '" . time() . "'"; $sql = "SELECT * FROM `session` WHERE `id`='$key' AND `expire` > '" . time() . "'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results); $results = Dba::fetch_assoc($db_results);
@ -285,7 +285,7 @@ class vauth {
/* Insert the row */ /* Insert the row */
$sql = "INSERT INTO `session` (`id`,`username`,`ip`,`type`,`agent`,`value`,`expire`) " . $sql = "INSERT INTO `session` (`id`,`username`,`ip`,`type`,`agent`,`value`,`expire`) " .
" VALUES ('$key','$username','$ip','$type','$agent','$value','$expire')"; " VALUES ('$key','$username','$ip','$type','$agent','$value','$expire')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
if (!$db_results) { if (!$db_results) {
debug_event('SESSION',"Session Creation Failed with Query: $sql and " . Dba::error(),'1'); debug_event('SESSION',"Session Creation Failed with Query: $sql and " . Dba::error(),'1');
@ -370,7 +370,7 @@ class vauth {
$ip = Dba::escape(inet_pton($data['ip'])); $ip = Dba::escape(inet_pton($data['ip']));
$agent = Dba::escape($data['agent']); $agent = Dba::escape($data['agent']);
$sql = "SELECT * FROM `session_stream` WHERE `id`='$key' AND `expire` > '$time' AND `ip`='$ip' AND `agent`='$agent'"; $sql = "SELECT * FROM `session_stream` WHERE `id`='$key' AND `expire` > '$time' AND `ip`='$ip' AND `agent`='$agent'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
if (Dba::num_rows($db_results)) { if (Dba::num_rows($db_results)) {
return true; return true;
@ -398,7 +398,7 @@ class vauth {
$expire = isset($_COOKIE[Config::get('session_name') . '_remember']) ? time() + Config::get('remember_length') : time() + Config::get('session_length'); $expire = isset($_COOKIE[Config::get('session_name') . '_remember']) ? time() + Config::get('remember_length') : time() + Config::get('session_length');
$sql = "UPDATE `session` SET `expire`='$expire' WHERE `id`='$sid'"; $sql = "UPDATE `session` SET `expire`='$expire' WHERE `id`='$sid'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
debug_event('SESSION','Session:' . $sid . ' Has been Extended to ' . $expire,'6'); debug_event('SESSION','Session:' . $sid . ' Has been Extended to ' . $expire,'6');
@ -526,11 +526,11 @@ class vauth {
// This has to still be here because lots of people use old_password in their config file // This has to still be here because lots of people use old_password in their config file
$sql = "SELECT `password` FROM `user` WHERE `username`='$username'"; $sql = "SELECT `password` FROM `user` WHERE `username`='$username'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results); $row = Dba::fetch_assoc($db_results);
$sql = "SELECT version()"; $sql = "SELECT version()";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$version = Dba::fetch_row($db_results); $version = Dba::fetch_row($db_results);
$mysql_version = substr(preg_replace("/(\d+)\.(\d+)\.(\d+).*/","$1$2$3",$version[0]),0,3); $mysql_version = substr(preg_replace("/(\d+)\.(\d+)\.(\d+).*/","$1$2$3",$version[0]),0,3);
@ -539,7 +539,7 @@ class vauth {
} }
$sql = "SELECT `username`,`id` FROM `user` WHERE `username`='$username' AND `password`=$password_check_sql"; $sql = "SELECT `username`,`id` FROM `user` WHERE `username`='$username' AND `password`=$password_check_sql";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results); $results = Dba::fetch_assoc($db_results);

View file

@ -52,7 +52,7 @@ class xmlRpcServer {
$sql = "SELECT `catalog`.`name`,COUNT(`song`.`id`) AS `count`,`catalog`.`id` AS `catalog_id` FROM `catalog` ". $sql = "SELECT `catalog`.`name`,COUNT(`song`.`id`) AS `count`,`catalog`.`id` AS `catalog_id` FROM `catalog` ".
"LEFT JOIN `song` ON `catalog`.`id`=`song`.`catalog` WHERE `catalog`.`catalog_type`='local' " . "LEFT JOIN `song` ON `catalog`.`id`=`song`.`catalog` WHERE `catalog`.`catalog_type`='local' " .
"GROUP BY `catalog`.`id`"; "GROUP BY `catalog`.`id`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row; $results[] = $row;
@ -97,7 +97,7 @@ class xmlRpcServer {
// Get Catalogs first // Get Catalogs first
$sql = "SELECT `catalog`.`id` FROM `catalog` WHERE `catalog`.`catalog_type`='local'"; $sql = "SELECT `catalog`.`id` FROM `catalog` WHERE `catalog`.`catalog_type`='local'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {
$where_sql .= "`song`.`catalog`='" . $row['id'] . "' OR"; $where_sql .= "`song`.`catalog`='" . $row['id'] . "' OR";
@ -106,7 +106,7 @@ class xmlRpcServer {
$where_sql = rtrim($where_sql,'OR'); $where_sql = rtrim($where_sql,'OR');
$sql = "SELECT `song`.`id` FROM `song` WHERE `song`.`enabled`='1' AND ($where_sql) LIMIT $start,$end"; $sql = "SELECT `song`.`id` FROM `song` WHERE `song`.`enabled`='1' AND ($where_sql) LIMIT $start,$end";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {
$song = new Song($row['id']); $song = new Song($row['id']);
@ -146,7 +146,7 @@ class xmlRpcServer {
// Get Albums first // Get Albums first
$sql = "SELECT `album`.`id` FROM `album` "; $sql = "SELECT `album`.`id` FROM `album` ";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {
// Load the current album // Load the current album
@ -245,7 +245,7 @@ class xmlRpcServer {
// Run the query and return the key's for ACLs of type RPC that would match this IP // Run the query and return the key's for ACLs of type RPC that would match this IP
$sql = "SELECT * FROM `access_list` WHERE `type`='rpc' AND `start` <= '$ip' AND `end` >= '$ip'"; $sql = "SELECT * FROM `access_list` WHERE `type`='rpc' AND `start` <= '$ip' AND `end` >= '$ip'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {

View file

@ -54,7 +54,7 @@ function check_database($host,$username,$pass) {
function check_database_inserted($dbh,$db_name) { function check_database_inserted($dbh,$db_name) {
$sql = "DESCRIBE session"; $sql = "DESCRIBE session";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
if (!$db_results) { if (!$db_results) {
return false; return false;

View file

@ -29,7 +29,7 @@ function session_exists($sid,$xml_rpc=0) {
$found = true; $found = true;
$sql = "SELECT * FROM `session` WHERE `id` = '$sid'"; $sql = "SELECT * FROM `session` WHERE `id` = '$sid'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
if (!Dba::num_rows($db_results)) { if (!Dba::num_rows($db_results)) {
$found = false; $found = false;
@ -81,7 +81,7 @@ function extend_session($sid) {
if ($_COOKIE['amp_longsess'] == '1') { $new_time = time() + 86400*364; } if ($_COOKIE['amp_longsess'] == '1') { $new_time = time() + 86400*364; }
$sql = "UPDATE `session` SET `expire`='$new_time' WHERE `id`='$sid'"; $sql = "UPDATE `session` SET `expire`='$new_time' WHERE `id`='$sid'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
} // extend_session } // extend_session

View file

@ -35,7 +35,7 @@ function update_preferences($pref_id=0) {
/* If it isn't the System Account's preferences */ /* If it isn't the System Account's preferences */
if ($pref_id != '-1') { $sql .= " WHERE `catagory` != 'system'"; } if ($pref_id != '-1') { $sql .= " WHERE `catagory` != 'system'"; }
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
// Collect the current possible keys // Collect the current possible keys
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
@ -105,7 +105,7 @@ function update_preference($user_id,$name,$pref_id,$value) {
/* Else make sure that the current users has the right to do this */ /* Else make sure that the current users has the right to do this */
if (Preference::has_access($name)) { if (Preference::has_access($name)) {
$sql = "UPDATE `user_preference` SET `value`='$value' WHERE `preference`='$pref_id' AND `user`='$user_id'"; $sql = "UPDATE `user_preference` SET `value`='$value' WHERE `preference`='$pref_id' AND `user`='$user_id'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
return true; return true;
} }

View file

@ -447,7 +447,7 @@ function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0) {
echo "<select name=\"$name\" id=\"$key\">\n"; echo "<select name=\"$name\" id=\"$key\">\n";
$sql = "SELECT `id`, `name`, `prefix` FROM `album` ORDER BY `name`"; $sql = "SELECT `id`, `name`, `prefix` FROM `album` ORDER BY `name`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$selected = ''; $selected = '';
@ -485,7 +485,7 @@ function show_artist_select($name='artist', $artist_id=0, $allow_add=0, $song_id
echo "<select name=\"$name\" id=\"$key\">\n"; echo "<select name=\"$name\" id=\"$key\">\n";
$sql = "SELECT `id`, `name`, `prefix` FROM `artist` ORDER BY `name`"; $sql = "SELECT `id`, `name`, `prefix` FROM `artist` ORDER BY `name`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$selected = ''; $selected = '';
@ -516,7 +516,7 @@ function show_catalog_select($name='catalog',$catalog_id=0,$style='') {
echo "<select name=\"$name\" style=\"$style\">\n"; echo "<select name=\"$name\" style=\"$style\">\n";
$sql = "SELECT `id`, `name` FROM `catalog` ORDER BY `name`"; $sql = "SELECT `id`, `name` FROM `catalog` ORDER BY `name`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$selected = ''; $selected = '';
@ -543,7 +543,7 @@ function show_user_select($name,$selected='',$style='') {
echo "\t<option value=\"\">" . _('All') . "</option>\n"; echo "\t<option value=\"\">" . _('All') . "</option>\n";
$sql = "SELECT `id`,`username`,`fullname` FROM `user` ORDER BY `fullname`"; $sql = "SELECT `id`,`username`,`fullname` FROM `user` ORDER BY `fullname`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {
$select_txt = ''; $select_txt = '';
@ -571,7 +571,7 @@ function show_playlist_select($name,$selected='',$style='') {
echo "\t<option value=\"\">" . _('None') . "</option>\n"; echo "\t<option value=\"\">" . _('None') . "</option>\n";
$sql = "SELECT `id`,`name` FROM `playlist` ORDER BY `name`"; $sql = "SELECT `id`,`name` FROM `playlist` ORDER BY `name`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {
$select_txt = ''; $select_txt = '';

View file

@ -73,7 +73,7 @@ class AmpacheHttpq extends localplay_controller {
public function is_installed() { public function is_installed() {
$sql = "DESCRIBE `localplay_httpq`"; $sql = "DESCRIBE `localplay_httpq`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
return Dba::num_rows($db_results); return Dba::num_rows($db_results);
@ -94,7 +94,7 @@ class AmpacheHttpq extends localplay_controller {
"`password` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL , " . "`password` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL , " .
"`access` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'" . "`access` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'" .
") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Add an internal preference for the users current active instance // Add an internal preference for the users current active instance
Preference::insert('httpq_active','HTTPQ Active Instance','0','25','integer','internal'); Preference::insert('httpq_active','HTTPQ Active Instance','0','25','integer','internal');
@ -111,7 +111,7 @@ class AmpacheHttpq extends localplay_controller {
public function uninstall() { public function uninstall() {
$sql = "DROP TABLE `localplay_httpq`"; $sql = "DROP TABLE `localplay_httpq`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Remove the pref we added for this // Remove the pref we added for this
Preference::delete('httpq_active'); Preference::delete('httpq_active');
@ -145,7 +145,7 @@ class AmpacheHttpq extends localplay_controller {
$sql = "INSERT INTO `localplay_httpq` (`name`,`host`,`port`,`password`,`owner`) " . $sql = "INSERT INTO `localplay_httpq` (`name`,`host`,`port`,`password`,`owner`) " .
"VALUES ('$name','$host','$port','$password','$user_id')"; "VALUES ('$name','$host','$port','$password','$user_id')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
return $db_results; return $db_results;
@ -161,7 +161,7 @@ class AmpacheHttpq extends localplay_controller {
$uid = Dba::escape($uid); $uid = Dba::escape($uid);
$sql = "DELETE FROM `localplay_httpq` WHERE `id`='$uid'"; $sql = "DELETE FROM `localplay_httpq` WHERE `id`='$uid'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
return true; return true;
@ -175,7 +175,7 @@ class AmpacheHttpq extends localplay_controller {
public function get_instances() { public function get_instances() {
$sql = "SELECT * FROM `localplay_httpq` ORDER BY `name`"; $sql = "SELECT * FROM `localplay_httpq` ORDER BY `name`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$results = array(); $results = array();
@ -200,7 +200,7 @@ class AmpacheHttpq extends localplay_controller {
$pass = Dba::escape($data['password']); $pass = Dba::escape($data['password']);
$sql = "UPDATE `localplay_httpq` SET `host`='$host', `port`='$port', `name`='$name', `password`='$pass' WHERE `id`='$uid'"; $sql = "UPDATE `localplay_httpq` SET `host`='$host', `port`='$port', `name`='$name', `password`='$pass' WHERE `id`='$uid'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
return true; return true;
@ -232,7 +232,7 @@ class AmpacheHttpq extends localplay_controller {
$instance = Dba::escape($instance); $instance = Dba::escape($instance);
$sql = "SELECT * FROM `localplay_httpq` WHERE `id`='$instance'"; $sql = "SELECT * FROM `localplay_httpq` WHERE `id`='$instance'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results); $row = Dba::fetch_assoc($db_results);

View file

@ -72,7 +72,7 @@ class AmpacheMpd extends localplay_controller {
public function is_installed() { public function is_installed() {
$sql = "DESCRIBE `localplay_mpd`"; $sql = "DESCRIBE `localplay_mpd`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
return Dba::num_rows($db_results); return Dba::num_rows($db_results);
@ -93,7 +93,7 @@ class AmpacheMpd extends localplay_controller {
"`password` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL , " . "`password` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL , " .
"`access` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'" . "`access` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'" .
") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Add an internal preference for the users current active instance // Add an internal preference for the users current active instance
Preference::insert('mpd_active','MPD Active Instance','0','25','integer','internal'); Preference::insert('mpd_active','MPD Active Instance','0','25','integer','internal');
@ -110,7 +110,7 @@ class AmpacheMpd extends localplay_controller {
public function uninstall() { public function uninstall() {
$sql = "DROP TABLE `localplay_mpd`"; $sql = "DROP TABLE `localplay_mpd`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
Preference::delete('mpd_active'); Preference::delete('mpd_active');
@ -142,7 +142,7 @@ class AmpacheMpd extends localplay_controller {
$sql = "INSERT INTO `localplay_mpd` (`name`,`host`,`port`,`password`,`owner`) " . $sql = "INSERT INTO `localplay_mpd` (`name`,`host`,`port`,`password`,`owner`) " .
"VALUES ('$name','$host','$port','$password','$user_id')"; "VALUES ('$name','$host','$port','$password','$user_id')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
return $db_results; return $db_results;
@ -158,7 +158,7 @@ class AmpacheMpd extends localplay_controller {
// Go ahead and delete this mofo! // Go ahead and delete this mofo!
$sql = "DELETE FROM `localplay_mpd` WHERE `id`='$uid'"; $sql = "DELETE FROM `localplay_mpd` WHERE `id`='$uid'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
return true; return true;
@ -172,7 +172,7 @@ class AmpacheMpd extends localplay_controller {
public function get_instances() { public function get_instances() {
$sql = "SELECT * FROM `localplay_mpd` ORDER BY `name`"; $sql = "SELECT * FROM `localplay_mpd` ORDER BY `name`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$results = array(); $results = array();
@ -195,7 +195,7 @@ class AmpacheMpd extends localplay_controller {
$instance = Dba::escape($instance); $instance = Dba::escape($instance);
$sql = "SELECT * FROM `localplay_mpd` WHERE `id`='$instance'"; $sql = "SELECT * FROM `localplay_mpd` WHERE `id`='$instance'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results); $row = Dba::fetch_assoc($db_results);
@ -216,7 +216,7 @@ class AmpacheMpd extends localplay_controller {
$pass = Dba::escape($data['password']); $pass = Dba::escape($data['password']);
$sql = "UPDATE `localplay_mpd` SET `host`='$host', `port`='$port', `name`='$name', `password`='$pass' WHERE `id`='$uid'"; $sql = "UPDATE `localplay_mpd` SET `host`='$host', `port`='$port', `name`='$name', `password`='$pass' WHERE `id`='$uid'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
return true; return true;

View file

@ -77,7 +77,7 @@ class AmpacheShoutCast extends localplay_controller {
public function is_installed() { public function is_installed() {
$sql = "DESCRIBE `localplay_shoutcast`"; $sql = "DESCRIBE `localplay_shoutcast`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
return Dba::num_rows($db_results); return Dba::num_rows($db_results);
@ -98,7 +98,7 @@ class AmpacheShoutCast extends localplay_controller {
"`local_root` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL , " . "`local_root` VARCHAR( 255 ) COLLATE utf8_unicode_ci NOT NULL , " .
"`access` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'" . "`access` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '0'" .
") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; ") ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
// Add an internal preference for the users current active instance // Add an internal preference for the users current active instance
Preference::insert('shoutcast_active','Shoutcast Active Instance','0','25','integer','internal'); Preference::insert('shoutcast_active','Shoutcast Active Instance','0','25','integer','internal');
@ -115,7 +115,7 @@ class AmpacheShoutCast extends localplay_controller {
public function uninstall() { public function uninstall() {
$sql = "DROP TABLE `localplay_shoutcast`"; $sql = "DROP TABLE `localplay_shoutcast`";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
Preference::delete('shoutcast_active'); Preference::delete('shoutcast_active');
@ -147,7 +147,7 @@ class AmpacheShoutCast extends localplay_controller {
$sql = "INSERT INTO `localplay_shoutcast` (`name`,`pid`,`playlist`,`local_root`,`owner`) " . $sql = "INSERT INTO `localplay_shoutcast` (`name`,`pid`,`playlist`,`local_root`,`owner`) " .
"VALUES ('$name','$pid','$playlist','$local_root','$user_id')"; "VALUES ('$name','$pid','$playlist','$local_root','$user_id')";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
return $db_results; return $db_results;
@ -163,7 +163,7 @@ class AmpacheShoutCast extends localplay_controller {
// Go ahead and delete this mofo! // Go ahead and delete this mofo!
$sql = "DELETE FROM `localplay_shoutcast` WHERE `id`='$uid'"; $sql = "DELETE FROM `localplay_shoutcast` WHERE `id`='$uid'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
return true; return true;
@ -177,7 +177,7 @@ class AmpacheShoutCast extends localplay_controller {
public function get_instances() { public function get_instances() {
$sql = "SELECT * FROM `localplay_shoutcast` ORDER BY `name`"; $sql = "SELECT * FROM `localplay_shoutcast` ORDER BY `name`";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$results = array(); $results = array();
@ -200,7 +200,7 @@ class AmpacheShoutCast extends localplay_controller {
$instance = Dba::escape($instance); $instance = Dba::escape($instance);
$sql = "SELECT * FROM `localplay_shoutcast` WHERE `id`='$instance'"; $sql = "SELECT * FROM `localplay_shoutcast` WHERE `id`='$instance'";
$db_results = Dba::query($sql); $db_results = Dba::read($sql);
$row = Dba::fetch_assoc($db_results); $row = Dba::fetch_assoc($db_results);
@ -221,7 +221,7 @@ class AmpacheShoutCast extends localplay_controller {
$local_root = Dba::escape($data['local_root']); $local_root = Dba::escape($data['local_root']);
$sql = "UPDATE `localplay_shoutcast` SET `pid`='$pid', `playlist`='$playlist', `name`='$name', `local_root`='$local_root' WHERE `id`='$uid'"; $sql = "UPDATE `localplay_shoutcast` SET `pid`='$pid', `playlist`='$playlist', `name`='$name', `local_root`='$local_root' WHERE `id`='$uid'";
$db_results = Dba::query($sql); $db_results = Dba::write($sql);
return true; return true;