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

Miscellaneous cleanup.

This commit is contained in:
Paul 'flowerysong' Arthur 2010-06-13 08:11:09 +00:00
parent 93f4a26ab0
commit 4b5756ba9d
45 changed files with 233 additions and 182 deletions

View file

@ -41,7 +41,7 @@ if (!vauth::session_exists('interface',$_COOKIE[Config::get('session_name')]) AN
if (!Config::get('resize_images')) { unset($_GET['thumb']); }
// FIXME: Legacy stuff - should be removed after a version or so
if (!$_GET['object_type']) {
if (!isset($_GET['object_type'])) {
$_GET['object_type'] = 'album';
}

View file

@ -24,7 +24,7 @@ require_once 'lib/init.php';
show_header();
$action = scrub_in($_REQUEST['action']);
$action = isset($_REQUEST['action']) ? scrub_in($_REQUEST['action']) : null;
/**
* Check for the refresh mojo, if it's there then require the

View file

@ -23,8 +23,7 @@
/**
* get_song_files
* tmakes array of song ids and returns
* array of path to actual files
* Takes an array of song ids and returns an array of the actual filenames
*/
function get_song_files($media_ids) {
@ -57,13 +56,13 @@ function get_song_files($media_ids) {
*/
function send_zip( $name, $song_files ) {
// Check if they want to save it to a file, if so then make sure they've got
// a defined path as well and that it's writeable
// Check if they want to save it to a file, if so then make sure they've
// got a defined path as well and that it's writable.
if (Config::get('file_zip_download') && Config::get('file_zip_path')) {
// Check writeable
if (!is_writable(Config::get('file_zip_path'))) {
$in_memory = '1';
debug_event('Error','File Zip Path:' . Config::get('file_zip_path') . ' is not writeable','1');
debug_event('Error','File Zip Path:' . Config::get('file_zip_path') . ' is not writable','1');
}
else {
$in_memory = '0';

View file

@ -312,13 +312,15 @@ class Access {
/**
* check_access
* This is the global 'has_access' function it can check for any 'type' of object
* everything uses the global 0,5,25,50,75,100 stuff. GLOBALS['user'] is always used
* This is the global 'has_access' function it can check for any 'type'
* of object.
* Everything uses the global 0,5,25,50,75,100 stuff. GLOBALS['user'] is
* always used.
*/
public static function check($type,$level) {
if (Config::get('demo_mode')) { return true; }
if (INSTALL == '1') { return true; }
if (defined('INSTALL')) { return true; }
$level = intval($level);

View file

@ -108,15 +108,14 @@ class Ajax {
// If they passed a span class
if ($class) {
$class_txt = ' class="' . $class . '"';
$class = ' class="' . $class . '"';
}
$string = get_user_icon($icon,$alt);
// Generate a <a> so that it's more compliant with older browsers
// (ie :hover actions) and also to unify linkbuttons (w/o ajax) display
$string = "<a href=\"javascript:void(0);\" id=\"$source\" $class_txt>".$string."</a>\n";
$string = "<a href=\"javascript:void(0);\" id=\"$source\" $class>".$string."</a>\n";
$string .= self::observe($source,'click',$ajax_string);
@ -126,7 +125,7 @@ class Ajax {
/**
* text
* This prints out the specified text as a link and setups the required
* This prints out the specified text as a link and sets up the required
* ajax for the link so it works correctly
*/
public static function text($action,$text,$source,$post='',$class='') {
@ -136,11 +135,11 @@ class Ajax {
// If they passed a span class
if ($class) {
$class_txt = ' class="' . $class . '"';
$class = ' class="' . $class . '"';
}
// If we pass a source put it in the ID
$string = "<a href=\"javascript:void(0);\" id=\"$source\" $class_txt>$text</a>\n";
$string = "<a href=\"javascript:void(0);\" id=\"$source\" $class>$text</a>\n";
$string .= self::observe($source,'click',$ajax_string);
@ -177,7 +176,7 @@ class Ajax {
*/
public static function start_container($name) {
if (AJAX_INCLUDE == '1' AND !self::$include_override) { return true; }
if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; }
echo '<div id="' . scrub_out($name) . '">';
@ -189,7 +188,7 @@ class Ajax {
*/
public static function end_container() {
if (AJAX_INCLUDE == '1' AND !self::$include_override) { return true; }
if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; }
echo "</div>";

View file

@ -30,12 +30,13 @@ class Album extends database_object {
/* Variables from DB */
public $id;
public $name;
public $full_name; // Prefix + Name, genereated by format();
public $disk;
public $year;
public $prefix;
public $mbid; // MusicBrainz ID
public $full_name; // Prefix + Name, generated
// cached information
public $_songs=array();
@ -58,7 +59,7 @@ class Album extends database_object {
$this->$key = $value;
}
// Little bit of formating here
// Little bit of formatting here
$this->full_name = trim(trim($info['prefix']) . ' ' . trim($info['name']));
return true;
@ -140,11 +141,16 @@ class Album extends database_object {
return parent::get_from_cache('album_extra',$this->id);
}
$sql = "SELECT COUNT(DISTINCT(song.artist)) as artist_count,COUNT(song.id) AS song_count,artist.name AS artist_name" .
",artist.prefix AS artist_prefix, artist.id AS artist_id ".
"FROM `song` " .
"INNER JOIN `artist` ON `artist`.`id`=`song`.`artist` " .
"WHERE `song`.`album`='$this->id' GROUP BY `song`.`album`";
$sql = "SELECT " .
"COUNT(DISTINCT(`song`.`artist`)) AS `artist_count`, " .
"COUNT(`song`.`id`) AS `song_count`, " .
"`artist`.`name` AS `artist_name`, " .
"`artist`.`prefix` AS `artist_prefix`, " .
"`artist`.`id` AS `artist_id` " .
"FROM `song` INNER JOIN `artist` " .
"ON `artist`.`id`=`song`.`artist` " .
"WHERE `song`.`album`='$this->id' " .
"GROUP BY `song`.`album`";
$db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results);
@ -170,12 +176,16 @@ class Album extends database_object {
$results = array();
if ($artist) {
$artist_sql = "AND `artist`='" . Dba::escape($artist) . "'";
}
$artist = Dba::escape($artist);
$sql = "SELECT `id` FROM `song` WHERE `album`='$this->id' $artist_sql ORDER BY `track`, `title`";
if ($limit) { $sql .= " LIMIT $limit"; }
$sql = "SELECT `id` FROM `song` WHERE `album`='$this->id' ";
if ($artist) {
$sql .= "AND `artist`='$artist'";
}
$sql .= "ORDER BY `track`, `title`";
if ($limit) {
$sql .= " LIMIT $limit";
}
$db_results = Dba::read($sql);
while ($r = Dba::fetch_assoc($db_results)) {
@ -228,7 +238,7 @@ class Album extends database_object {
$this->f_name_link .="</a>";
$this->f_link = $this->f_name_link;
$this->f_title = $full_name;
$this->f_title = $this->full_name; // FIXME: Legacy?
if ($this->artist_count == '1') {
$artist = trim(trim($this->artist_prefix) . ' ' . trim($this->artist_name));
$this->f_artist_name = $artist;

View file

@ -55,7 +55,12 @@ class Art extends database_object {
* Called on creation of the class
*/
public static function _auto_init() {
self::$enabled = make_bool($_SESSION['art_enabled']);
if (!isset($_SESSION['art_enabled'])) {
$_SESSION['art_enabled'] = (Config::get('bandwidth') > 25);
}
else {
self::$enabled = make_bool($_SESSION['art_enabled']);
}
}
/**
@ -63,7 +68,7 @@ class Art extends database_object {
* Checks whether the user currently wants art
*/
public static function is_enabled() {
if (self::$enabled || (Config::get('bandwidth') > 25)) {
if (self::$enabled) {
return true;
}
@ -718,7 +723,7 @@ class Art extends database_object {
$arurl = $ar->getTargetId();
debug_event('mbz-gatherart', "Found URL AR: " . $arurl , '5');
foreach ($coverartsites as $casite) {
if (strstr($arurl, $casite['domain'])) {
if (strpos($arurl, $casite['domain']) !== false) {
debug_event('mbz-gatherart', "Matched coverart site: " . $casite['name'], '5');
if (preg_match($casite['regexp'], $arurl, $matches) == 1) {
$num_found++;
@ -1085,7 +1090,7 @@ class Art extends database_object {
$url = $coverart[$key];
// We need to check the URL for the /noimage/ stuff
if (strstr($url,"/noimage/")) {
if (strpos($url,"/noimage/") !== false) {
debug_event('LastFM','Detected as noimage, skipped ' . $url,'3');
continue;
}

View file

@ -227,7 +227,7 @@ class Artist extends database_object {
// If this is a fake object, we're done here
if ($this->_fake) { return true; }
$this->f_name_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&amp;artist=" . $this->id . "\" title=\"" . $this->full_name . "\">" . $name . "</a>";
$this->f_name_link = "<a href=\"" . Config::get('web_path') . "/artists.php?action=show&amp;artist=" . $this->id . "\" title=\"" . $this->f_full_name . "\">" . $name . "</a>";
$this->f_link = Config::get('web_path') . '/artists.php?action=show&amp;artist=' . $this->id;
// Get the counts

View file

@ -103,6 +103,7 @@ class Browse extends Query {
${$class_name} = new $class_name($id);
}
$match = '';
// Format any matches we have so we can show them to the masses
if ($filter_value = $this->get_filter('alpha_match')) {
$match = ' (' . $filter_value . ')';

View file

@ -459,7 +459,7 @@ class Catalog extends database_object {
}
// Correctly detect the slash we need to use here
if (strstr($path,"/")) {
if (strpos($path,"/") !== false) {
$slash_type = '/';
}
else {
@ -952,7 +952,10 @@ class Catalog extends database_object {
// Try the preferred filename, if that fails use folder.???
$preferred_filename = Config::get('album_art_preferred_filename');
if (!$preferred_filename || strstr($preferred_filename,"%")) { $preferred_filename = "folder.$extension"; }
if (!$preferred_filename ||
strpos($preferred_filename, '%') !== false) {
$preferred_filename = "folder.$extension";
}
$file = "$dir/$preferred_filename";
if ($file_handle = fopen($file,"w")) {

View file

@ -424,7 +424,10 @@ class Dba {
// Itterate through the columns of the table
while ($table = Dba::fetch_assoc($describe_results)) {
if (strstr($table['Type'],'varchar') OR strstr($table['Type'],'enum') OR strstr($table['Table'],'text')) {
if (
(strpos($table['Type'], 'varchar') !== false) ||
(strpos($table['Type'], 'enum') !== false) ||
(strpos($table['Table'],'text') !== false)) {
$sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset;
$charset_results = Dba::write($sql);
if (!$charset_results) {

View file

@ -145,6 +145,7 @@ class Query {
$this->reset_join();
$this->reset_select();
$this->reset_having();
$this->set_static_content(false);
$this->set_is_simple(false);
$this->set_start(0);
$this->set_offset(Config::get('offset_limit') ? Config::get('offset_limit') : '25');
@ -219,7 +220,9 @@ class Query {
// Simple enough, but if we ever move this crap
// If we ever move this crap what?
return $this->_state['filter'][$key];
return isset($this->_state['filter'][$key])
? $this->_state['filter'][$key]
: false;
} // get_filter

View file

@ -65,6 +65,8 @@ class Rating extends database_object {
if (!is_array($ids) OR !count($ids)) { return false; }
$user_id = intval($GLOBALS['user']->id);
$ratings = array();
$user_ratings = array();
$idlist = '(' . implode(',', $ids) . ')';
$sql = "SELECT `rating`, `object_id` FROM `rating` " .
@ -73,7 +75,7 @@ class Rating extends database_object {
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
$user[$row['object_id']] = $row['rating'];
$user_ratings[$row['object_id']] = $row['rating'];
}
$sql = "SELECT AVG(`rating`) as `rating`, `object_id` FROM " .
@ -82,19 +84,26 @@ class Rating extends database_object {
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
$rating[$row['object_id']] = $row['rating'];
$ratings[$row['object_id']] = $row['rating'];
}
foreach ($ids as $id) {
parent::add_to_cache('rating_' . $type . '_user' . $user_id, $id, intval($user[$id]));
if (!isset($rating[$id])) {
// First store the user-specific rating
if (!isset($user_ratings[$id])) {
$rating = 0;
}
else {
$rating = round($rating[$id]['rating'], 1);
$rating = intval($user_ratings[$id]);
}
parent::add_to_cache('rating_' . $type . '_user' . $user_id, $id, $rating);
// Then store the average
if (!isset($ratings[$id])) {
$rating = 0;
}
else {
$rating = round($ratings[$id]['rating'], 1);
}
parent::add_to_cache('rating_' . $type . '_all', $id, $rating);
}
@ -125,11 +134,14 @@ class Rating extends database_object {
"AND `object_id`='$id' AND `object_type`='$type'";
$db_results = Dba::read($sql);
$results = Dba::fetch_assoc($db_results);
$rating = 0;
parent::add_to_cache($key, $id, $results['rating']);
if ($results = Dba::fetch_assoc($db_results)) {
$rating = $results['rating'];
}
return $results['rating'];
parent::add_to_cache($key, $id, $rating);
return $rating;
} // get_user_rating

View file

@ -875,15 +875,16 @@ class Song extends database_object implements media {
$user_id = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1';
$type = $song->type;
// Required for some versions of winamp that won't work if the stream doesn't end in
// .ogg This will not break any properly working player, don't report this as a bug!
// Required for some versions of winamp that won't work if the
// stream doesn't end in .ogg This will not break any properly
// working player, don't report this as a bug!
if ($song->type == 'flac') { $type = 'ogg'; }
$song->format();
$song_name = rawurlencode($song->f_artist_full . " - " . $song->title . "." . $type);
$url = Stream::get_base_url() . "oid=$song->id&uid=$user_id$session_string$ds_string&name=/$song_name";
$url = Stream::get_base_url() . "oid=$song->id&uid=$user_id&name=/$song_name";
return $url;
@ -921,15 +922,14 @@ class Song extends database_object implements media {
*/
public static function get_recently_played($user_id='') {
if ($user_id) {
$user_limit = " AND `object_count`.`user`='" . Dba::escape($user_id) . "'";
}
$user_id = Dba::escape($user_id);
$sql = "SELECT `object_count`.`object_id`,`object_count`.`user`,`object_count`.`object_type`, " .
"`object_count`.`date` " .
"FROM `object_count` " .
"WHERE `object_type`='song'$user_limit " .
"ORDER BY `object_count`.`date` DESC ";
$sql = "SELECT `object_id`, `user`, `object_type`, `date` " .
"FROM `object_count` WHERE `object_type`='song' ";
if ($user_id) {
$sql .= "AND `user`='$user_id' ";
}
$sql .= "ORDER BY `date` DESC ";
$db_results = Dba::read($sql);
$results = array();
@ -946,17 +946,17 @@ class Song extends database_object implements media {
/**
* native_stream
* This returns true/false if this can be nativly streamed
* This returns true/false if this can be natively streamed
*/
public function native_stream() {
if ($this->_transcode) { return false; }
if ($this->_transcoded) { return false; }
$conf_var = 'transcode_' . $this->type;
$conf_type = 'transcode_' . $this->type . '_target';
if (Config::get($conf_var)) {
$this->_transcode = true;
$this->_transcoded = true;
debug_event('auto_transcode','Transcoding to ' . $this->type,'5');
return false;
}

View file

@ -186,7 +186,7 @@ class Stream {
$db_results = Dba::write($sql);
foreach ($append_array as $append_agent) {
if (strstr(strtoupper($agent),$append_agent)) {
if (strpos(strtoupper($agent), $append_agent) !== false) {
// We're done here jump ship!
return true;
}
@ -828,14 +828,15 @@ class Stream {
/**
* run_playlist_method
* This takes care of the different types of 'playlist methods' the reason this is here
* is because it deals with streaming rather then playlist mojo. If something needs to happen
* this will echo the javascript required to cause a reload of the iframe.
* This takes care of the different types of 'playlist methods'. The
* reason this is here is because it deals with streaming rather than
* playlist mojo. If something needs to happen this will echo the
* javascript required to cause a reload of the iframe.
*/
public static function run_playlist_method() {
// If this wasn't ajax included run away
if (AJAX_INCLUDE != '1') { return false; }
if (!defined('AJAX_INCLUDE')) { return false; }
// If we're doin the flash magic then run away as well
if (Config::get('play_type') == 'xspf_player') { return false; }

View file

@ -99,8 +99,9 @@ class Tag extends database_object {
/**
* set_object
* This assoicates the tag with a specified object, we try to get the data
* from the map cache, otherwise I guess we'll just have to look it up
* This associates the tag with a specified object, we try to get the
* data from the map cache, otherwise I guess we'll just have to look it
* up.
*/
public function set_object($type,$object_id) {
@ -114,7 +115,7 @@ class Tag extends database_object {
// If nothing is found, then go ahead and return false
if (!is_array($data) OR !count($data)) { return false; }
$this->weight = $data[$this->id]['count'];
$this->weight = count($data[$this->id]['users']);
if (in_array($GLOBALS['user']->id,$data[$this->id]['users'])) {
$this->owner = $GLOBALS['user']->id;
@ -164,14 +165,18 @@ class Tag extends database_object {
while ($row = Dba::fetch_assoc($db_results)) {
$tags[$row['object_id']][$row['tag_id']]['users'][] = $row['user'];
$tags[$row['object_id']][$row['tag_id']]['count']++;
$tag_map[$row['object_id']] = array('id'=>$row['id'],'tag_id'=>$row['tag_id'],'user'=>$row['user'],'object_type'=>$type,'object_id'=>$row['object_id']);
}
// Run through our origional ids as we want to cache NULL results
// Run through our original ids as we also want to cache NULL
// results
foreach ($ids as $id) {
parent::add_to_cache('tag_top_' . $type,$id,$tags[$id]);
parent::add_to_cache('tag_map_' . $type,$id,$tag_map[$id]);
if (!isset($tags[$id])) {
$tags[$id] = null;
$tag_map[$id] = null;
}
parent::add_to_cache('tag_top_' . $type, $id, $tags[$id]);
parent::add_to_cache('tag_map_' . $type, $id, $tag_map[$id]);
}
return true;
@ -338,7 +343,6 @@ class Tag extends database_object {
while ($row = Dba::fetch_assoc($db_results)) {
$results[$row['tag_id']]['users'][] = $row['user'];
$results[$row['tag_id']]['count']++;
}
parent::add_to_cache('tag_top_' . $type,$object_id,$results);

View file

@ -1384,7 +1384,10 @@ class Update {
// Itterate through the columns of the table
while ($table = Dba::fetch_assoc($describe_results)) {
if (strstr($table['Type'],'varchar') OR strstr($table['Type'],'enum') OR strstr($table['Table'],'text')) {
if (
(strpos($table['Type'], 'varchar') !== false) ||
(strpos($table['Type'], 'enum') !== false) ||
strpos($table['Table'],'text') !== false) {
$sql = "ALTER TABLE `" . $row['0'] . "` MODIFY `" . $table['Field'] . "` " . $table['Type'] . " CHARACTER SET " . $target_charset;
$charset_results = Dba::write($sql);
if (!$charset_results) {

View file

@ -937,7 +937,7 @@ class vainfo {
$results = array();
// Correctly detect the slash we need to use here
if (strstr($filename,"/")) {
if (strpos($filename, '/') !== false) {
$slash_type = '/';
}
else {

View file

@ -84,7 +84,7 @@ class vauth {
*/
public static function write($key, $value) {
if (NO_SESSION_UPDATE == '1') { return true; }
if (defined('NO_SESSION_UPDATE')) { return true; }
$length = Config::get('session_length');
$value = Dba::escape($value);
@ -168,7 +168,7 @@ class vauth {
// Do a quick check to see if this is an AJAXed logout request
// if so use the iframe to redirect
if (AJAX_INCLUDE == '1') {
if (defined('AJAX_INCLUDE')) {
ob_end_clean();
ob_start();
@ -455,7 +455,9 @@ class vauth {
public static function ungimp_ie() {
// If no https, no ungimpage required
if ($_SERVER['HTTPS'] != 'on') { return true; }
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'on') {
return true;
}
// Try to detect IE
$agent = trim($_SERVER['HTTP_USER_AGENT']);

View file

@ -163,20 +163,20 @@ function check_php_pcre() {
function check_config_values($conf) {
if (!$conf['database_hostname']) {
return false;
}
if (!$conf['database_name']) {
return false;
}
if (!$conf['database_username']) {
return false;
}
if (!$conf['database_password']) {
return false;
}
if (!$conf['session_length']) {
return false;
}
return false;
}
if (!$conf['database_name']) {
return false;
}
if (!$conf['database_username']) {
return false;
}
if (!$conf['database_password']) {
return false;
}
if (!$conf['session_length']) {
return false;
}
if (!$conf['session_name']) {
return false;
}
@ -192,7 +192,7 @@ function check_config_values($conf) {
}
}
return true;
return true;
} // check_config_values
@ -311,35 +311,35 @@ function generate_config($current) {
/* Start building the new config file */
$distfile = Config::get('prefix') . '/config/ampache.cfg.php.dist';
$handle = fopen($distfile,'r');
$dist = fread($handle,filesize($distfile));
fclose($handle);
$handle = fopen($distfile,'r');
$dist = fread($handle,filesize($distfile));
fclose($handle);
$data = explode("\n",$dist);
$data = explode("\n",$dist);
/* Run throught the lines and set our settings */
foreach ($data as $line) {
/* Run throught the lines and set our settings */
foreach ($data as $line) {
/* Attempt to pull out Key */
if (preg_match("/^;?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$line,$matches)
/* Attempt to pull out Key */
if (preg_match("/^;?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$line,$matches)
|| preg_match("/^;?([\w\d]+)\s+=\s+[\']{1}(.*?)[\']{1}$/", $line, $matches)
|| preg_match("/^;?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/",$line,$matches)) {
|| preg_match("/^;?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/",$line,$matches)) {
$key = $matches[1];
$value = $matches[2];
$value = $matches[2];
/* Put in the current value */
/* Put in the current value */
if ($key == 'config_version') {
$line = $key . ' = ' . $value;
}
elseif (isset($current[$key])) {
$line = $key . ' = "' . $current[$key] . '"';
unset($current[$key]);
elseif (isset($current[$key])) {
$line = $key . ' = "' . $current[$key] . '"';
unset($current[$key]);
} // if set
} // if key
$final .= $line . "\n";
$final .= $line . "\n";
} // end foreach line

View file

@ -20,10 +20,10 @@
*/
/*!
@function load_gettext
@discussion sets the local
*/
/**
* load_gettext
* Sets up our local gettext settings.
*/
function load_gettext() {
/* If we have gettext */
if (function_exists('bindtextdomain')) {
@ -57,9 +57,9 @@ function load_gettext() {
*/
function __($string,$subject,$replace) {
$translated = _($string);
$result = str_replace($subject,$replace,$translated);
return $result;
$translated = _($string);
$result = str_replace($subject,$replace,$translated);
return $result;
} // __

View file

@ -33,10 +33,8 @@ if (floatval(phpversion()) < 5) {
exit;
}
error_reporting(E_ERROR); // Only show fatal errors in production
error_reporting(E_ERROR); // Only show fatal errors in production
// This makes this file nolonger need customization
// the config file is in the same dir as this (init.php) file.
$ampache_path = dirname(__FILE__);
$prefix = realpath($ampache_path . "/../");
$configfile = "$prefix/config/ampache.cfg.php";
@ -52,7 +50,7 @@ if (!function_exists('gettext')) {
Config::set('prefix',$prefix);
/*
Check to see if this is Http or https
Check to see if this is http or https
*/
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$http_type = "https://";
@ -62,18 +60,18 @@ else {
}
/*
See if the Config File Exists if it doesn't
then go ahead and move them over to the install
script
Check to make sure the config file exists. If it doesn't then go ahead and send
them over to the install script.
*/
if (!file_exists($configfile)) {
$path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
$path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
$link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/install.php";
header ("Location: $link");
exit();
}
// Use the built in PHP function, supress errors here so we can handle it properly
// Use the built in PHP function, suppress errors here so we can handle it
// properly below
$results = @parse_ini_file($configfile);
if (!count($results)) {
@ -83,7 +81,7 @@ if (!count($results)) {
exit();
}
/** Verify a few commonly removed PHP functions exist and re-direct to /test if not **/
/** Verify a few commonly disabled PHP functions exist and re-direct to /test if not **/
if (!function_exists('hash') OR !function_exists('inet_pton') OR (strtoupper(substr(PHP_OS,0,3)) == 'WIN' AND floatval(phpversion()) < 5.3)) {
$path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
$link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/test.php";
@ -153,9 +151,8 @@ $results = Preference::fix_preferences($results);
Config::set_by_array($results,1);
// Modules (These are conditionaly included depending upon config values)
// Modules (These are conditionally included depending upon config values)
if (Config::get('ratings')) {
require_once $prefix . '/lib/class/rating.class.php';
require_once $prefix . '/lib/rating.lib.php';
}
@ -169,20 +166,20 @@ if (substr($post_size,strlen($post_size)-1,strlen($post_size)) != 'M') {
ini_set('post_max_size','8M');
}
if ($results['memory_limit'] < 24) {
// In case the local setting is 0
ini_set('session.gc_probability','5');
if (! isset($results['memory_limit']) || $results['memory_limit'] < 24) {
$results['memory_limit'] = 24;
}
// Incase the local setting is 0
ini_set('session.gc_probability','5');
set_memory_limit($results['memory_limit']);
/**** END Set PHP Vars ****/
// If we want a session
if (NO_SESSION != '1' AND Config::get('use_auth')) {
/* Verify Their session */
if (!defined('NO_SESSION') && Config::get('use_auth')) {
/* Verify their session */
if (!vauth::session_exists('interface',$_COOKIE[Config::get('session_name')])) { vauth::logout($_COOKIE[Config::get('session_name')]); exit; }
// This actually is starting the session
@ -191,7 +188,7 @@ if (NO_SESSION != '1' AND Config::get('use_auth')) {
/* Create the new user */
$GLOBALS['user'] = User::get_from_username($_SESSION['userdata']['username']);
/* If they user ID doesn't exist deny them */
/* If the user ID doesn't exist deny them */
if (!$GLOBALS['user']->id AND !Config::get('demo_mode')) { vauth::logout(session_id()); exit; }
vauth::session_extend(session_id());
@ -223,9 +220,9 @@ elseif (!Config::get('use_auth')) {
else {
$GLOBALS['user'] = new User($auth['username']);
$GLOBALS['user']->id = '-1';
$GLOBALS['user']->username = $auth['username'];
$GLOBALS['user']->fullname = $auth['fullname'];
$GLOBALS['user']->access = $auth['access'];
$GLOBALS['user']->username = $auth['username'];
$GLOBALS['user']->fullname = $auth['fullname'];
$GLOBALS['user']->access = $auth['access'];
}
if (!$GLOBALS['user']->id AND !Config::get('demo_mode')) { vauth::logout(session_id()); exit; }
$GLOBALS['user']->update_last_seen();
@ -266,7 +263,7 @@ header ("Content-Type: text/html; charset=" . Config::get('site_charset'));
unset($array);
unset($results);
/* Setup the flip class */
/* Set up the flip class */
flip_class(array('odd','even'));
/* Check to see if we need to perform an update */
@ -284,7 +281,7 @@ if (Config::get('debug')) {
error_reporting(E_ALL);
}
// Merge GET then POST into REQUEST effectivly striping COOKIE without depending on
// a PHP setting change to take affect
// Merge GET then POST into REQUEST effectively stripping COOKIE without
// depending on a PHP setting change for the effect
$_REQUEST = array_merge($_GET,$_POST);
?>

View file

@ -22,8 +22,7 @@
/**
* split_sql
* splits up a standard SQL dump file into distinct
* sql queryies
* splits up a standard SQL dump file into distinct sql queries
*/
function split_sql($sql) {
$sql = trim($sql);

View file

@ -304,7 +304,8 @@ if (Config::get('downsample_remote')) {
} // if downsample remote is enabled
// If they are downsampling, or if the song is not a native stream or it's non-local
if ((Config::get('transcode') == 'always' || !$media->native_stream() || $not_local) && Config::get('transcode') != 'never') {
if ((Config::get('transcode') == 'always' || !$media->native_stream() ||
isset($not_local)) && Config::get('transcode') != 'never') {
debug_event('Downsample','Starting Downsample {Transcode:' . Config::get('transcode') . '} {Native Stream:' . $media->native_stream() .'} {Not Local:' . $not_local . '}','5');
$fp = Stream::start_downsample($media,$lastid,$media_name,$start);
$media_name = $media->f_artist_full . " - " . $media->title . "." . $media->type;

View file

@ -37,7 +37,9 @@ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
switch ($_REQUEST['page']) {
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : null;
switch ($page) {
case 'flag':
require_once Config::get('prefix') . '/server/flag.ajax.php';
exit;

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
if (isset($_REQUEST['browse_id'])) {
$browse_id = $_REQUEST['browse_id'];

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
$democratic = Democratic::get_current_playlist();
$democratic->set_parent();

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
switch ($_REQUEST['action']) {
case 'reject':

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
switch ($_REQUEST['action']) {
case 'random_albums':

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
switch ($_REQUEST['action']) {
case 'set_instance':

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
switch ($_REQUEST['action']) {
case 'delete_track':

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
switch ($_REQUEST['action']) {
case 'album':

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
switch ($_REQUEST['action']) {
case 'flip_state':

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
switch ($_REQUEST['action']) {
default:

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
switch ($_REQUEST['action']) {
case 'set_play_type':

View file

@ -21,9 +21,9 @@
*/
/**
* Sub-Ajax page, requires AJAX_INCLUDE as one
* Sub-Ajax page, requires AJAX_INCLUDE
*/
if (AJAX_INCLUDE != '1') { exit; }
if (!defined('AJAX_INCLUDE')) { exit; }
switch ($_REQUEST['action']) {
case 'show_add_tag':

View file

@ -164,7 +164,9 @@ switch ($_REQUEST['method']) {
/* Start the Stream */
debug_event('stream.php' , 'Stream Type: '.$stream_type.' Media IDs: '.$media_ids, '5');
$stream = new Stream($stream_type,$media_ids);
$stream->add_urls($urls);
if (isset($urls)) {
$stream->add_urls($urls);
}
$stream->start();
} // end method switch

View file

@ -22,7 +22,7 @@
*/
?>
<div style="clear:both;"></div>
<?php if ($_SESSION['userdata']['password'] == 'old') {?>
<?php if (isset($_SESSION['userdata']['password'])) {?>
<span class="fatalerror"><?php echo _('Using Old Password Encryption, Please Reset your Password'); ?></span>
<?php } ?>
</div> <!-- end id="content"-->

View file

@ -79,7 +79,7 @@
$objects = array();
//FIXME :: this is kludgy
if (NO_SONGS != '1') {
if (!defined('NO_SONGS')) {
$objects = $GLOBALS['user']->playlist->get_items();
}
@ -108,7 +108,7 @@
<?php } if (!count($objects)) { ?>
<li class="error"><?php echo _('Not Enough Data'); ?></li>
<?php } ?>
<?php if ($truncated) { ?>
<?php if (isset($truncated)) { ?>
<li class="<?php echo flip_class(); ?>">
<?php echo $truncated . ' ' . _('More'); ?>...
</li>

View file

@ -24,15 +24,16 @@ $web_path = Config::get('web_path');
$ajax_url = Config::get('ajax_url');
// Title for this album
$title = scrub_out($album->name) . '&nbsp;(' . $album->year . ')';
if ($album->disk) {
$disk = "<span class=\"discnb disc" .$album->disk. "\">, " . _('Disk') . " " . $album->disk . "</span>";
$title .= "<span class=\"discnb disc" . $album->disk . "\">, " . _('Disk') . " " . $album->disk . "</span>";
}
$title = scrub_out($album->name) . '&nbsp;(' . $album->year . ')' . $disk .'&nbsp;-&nbsp;' . $album->f_artist_link;
$title .= '&nbsp;-&nbsp;' . $album->f_artist_link;
?>
<?php show_box_top($title,'info-box'); ?>
<div class="album_art">
<?php
if ($album_name != _('Unknown (Orphaned)')) {
if ($album->name != _('Unknown (Orphaned)')) {
$name = '[' . $album->f_artist . '] ' . scrub_out($album->full_name);
$aa_url = $web_path . "/image.php?id=" . $album->id . "&amp;type=popup&amp;sid=" . session_id();

View file

@ -19,7 +19,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
if (INSTALL != '1') { exit; }
if (!defined('INSTALL')) { exit; }
$prefix = realpath(dirname(__FILE__). "/../");
$dir = is_rtl($htmllang) ? 'rtl' : 'ltr';
?>

View file

@ -20,7 +20,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
if (INSTALL != '1') { exit; }
if (!defined('INSTALL')) { exit; }
$prefix = realpath(dirname(__FILE__). "/../");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

View file

@ -20,7 +20,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
if (INSTALL != '1') { exit; }
if (!defined('INSTALL')) { exit; }
$prefix = realpath(dirname(__FILE__). "/../");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

View file

@ -21,7 +21,7 @@
*/
$prefix = realpath(dirname(__FILE__). "/../");
?>
<?php if (INSTALL != '1') { exit; } ?>
<?php if (!defined('INSTALL')) { exit; } ?>
<?php $results = 0; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $htmllang; ?>" lang="<?php echo $htmllang; ?>">

View file

@ -25,8 +25,10 @@ $ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path');
<li><h4><?php echo _('Browse'); ?></h4>
<?php
// Build the selected dealie
$text = scrub_in($_REQUEST['action']) . '_ac';
${$text} = ' selected="selected"';
if (isset($_REQUEST['action'])) {
$text = scrub_in($_REQUEST['action']) . '_ac';
${$text} = ' selected="selected"';
}
?>
<ul class="sb3" id="sb_browse_bb">
<li id="sb_browse_bb_SongTitle"><a href="<?php echo $web_path; ?>/browse.php?action=song"><?php echo _('Song Titles'); ?></a></li>