";
foreach ($list as $l) {
$style_name = "style_" . strtolower($l);
$class = "link";
if ($l==$selected) $class .=" active";
echo "" .
$l . "\n";
}
echo "";
} // show_alphabet_list
/**
* show_alphabet_form
* this shows the spiffy little form that acts as a "quick search" when browsing
* @package General
* @catagory Display
*/
function show_alphabet_form($match, $text, $action) {
require (conf('prefix') . '/templates/show_alphabet_form.inc.php');
} // show_alphabet_form
/**
* show_local_control
* shows the controls
* for localplay
*/
function show_local_control () {
require_once(conf('prefix') . "/templates/show_localplay.inc");
} // show_local_control
/**
* truncate_with_ellipsis
* Correct Spelling function that truncates text to a specific lenght
* and appends three dots, or an ellipsis to the end
* @package Web Interface
* @catagory General
* @author Nedko Arnaudov
*/
function truncate_with_ellipsis($text, $max='') {
$max = $max ? $max : '27';
/* If we want it to be shorter than three, just throw it back */
if ($max > 3) {
/* Make sure the functions exist before doing the iconv mojo */
if (function_exists('iconv') && function_exists('iconv_substr') && function_exists('iconv_strlen')) {
if (iconv_strlen($text, Config::get('site_charset')) > $max) {
$text = iconv_substr($text, 0, $max-3, Config::get('site_charset'));
$text .= iconv("ISO-8859-1", Config::get('site_charset'), "...");
}
}
/* Do normal substr if we don't have iconv */
else {
if (strlen($text) > $max) {
$text = substr($text,0,$max-3)."...";
}
} // else no iconv
} // else greater than 3
return $text;
} // truncate_with_ellipsis
/**
* show_header
* This shows the header.inc.php, it may do something
* more in the future
*/
function show_header() {
require_once Config::get('prefix') . '/templates/header.inc.php';
} // show_header
/**
* show_footer
* shows the footer of the page
*/
function show_footer() {
require_once Config::get('prefix') . '/templates/footer.inc.php';
} // show_footer
/**
* show_user_registration
* this function is called for a new user
* registration
* @author Terry
* @todo Fix so that it recieves an array of values for the user reg rather than seperate
*/
function show_user_registration ($values=array()) {
require (conf('prefix') . "/templates/show_user_registration.inc.php");
} // show_user_registration
/**
* show_play_selected
* this shows the playselected/add to playlist
* box, which includes a little javascript
*/
function show_play_selected() {
require (conf('prefix') . "/templates/show_play_selected.inc.php");
} // show_play_selected
/*
* Artist Ratings - Implemented by SoundOfEmotion
*
* set_artist_rating()
*
* check to see if the ratings exist
* if they do: update them
* if they don't: insert them
*
*/
function set_artist_rating ($artist_id, $rate_user, $rating) {
$artist_id = sql_escape($artist_id);
$sql = "SELECT * FROM ratings WHERE user='$rate_user' AND object_type='artist' AND object_id='$artist_id'";
$db_result = mysql_query( $sql, dbh() );
$r = mysql_fetch_row( $db_result );
if($r[0]) {
$sql2 = "UPDATE ratings SET user_rating='$rating' WHERE object_id='$artist_id' AND user='$rate_user' AND object_type='artist'";
$db_result2 = mysql_query( $sql2, dbh() );
$r = mysql_fetch_row( $db_result2 );
return mysql_insert_id( dbh() );
}
else if(!$r[0]) {
$sql2 = "INSERT INTO ratings (id,user,object_type,object_id,user_rating) ".
"VALUES ('','$rate_user','artist','$artist_id','$rating')";
$db_result2 = mysql_query( $sql2, dbh() );
return mysql_insert_id(dbh() );
}
else{
return "NA";
}
} // set_artist_rating()
/*
* Album Ratings - Implemented by SoundOfEmotion
*
* set_album_rating()
*
* check to see if the ratings exist
* if they do: update them
* if they don't: insert them
*
*/
function set_album_rating($album_id, $rate_user, $rating) {
$album_id = sql_escape($album_id);
$sql = "SELECT * FROM ratings WHERE user='$rate_user' AND object_type='album' AND object_id='$album_id'";
$db_result = mysql_query( $sql, dbh() );
$r = mysql_fetch_row( $db_result );
if($r[0]) {
$sql2 = "UPDATE ratings SET user_rating='$rating' WHERE object_id='$album_id' AND user='$rate_user' AND object_type='album'";
$db_result2 = mysql_query( $sql2, dbh() );
return mysql_insert_id( dbh() );
}
else if(!$r[0]) {
$sql2 = "INSERT INTO ratings (id,user,object_type,object_id,user_rating) ".
"VALUES ('','$rate_user','album','$album_id','$rating')";
$db_result2 = mysql_query( $sql2, dbh() );
return mysql_insert_id( dbh() );
}
else{
return "NA";
}
} // set_album_rating()
/*
* Song Ratings - Implemented by SoundOfEmotion
*
* set_song_rating()
*
* check to see if the ratings exist
* if they do: update them
* if they don't: insert them
*
*/
function set_song_rating($song_id, $rate_user, $rating) {
$song_id = sql_escape($song_id);
$sql = "SELECT * FROM ratings WHERE user='$rate_user' AND object_type='song' AND object_id='$song_id'";
$db_result = mysql_query( $sql, dbh() );
$r = mysql_fetch_row( $db_result );
if($r[0]){
$sql2 = "UPDATE ratings SET user_rating='$rating' WHERE object_id='$song_id' AND user='$rate_user' AND object_type='song'";
$db_result2 = mysql_query( $sql2, dbh() );
return mysql_insert_id( dbh() );
}
else if(!$r[0]){
$sql2 = "INSERT INTO ratings (id,user,object_type,object_id,user_rating) ".
"VALUES ('','$rate_user','song','$song_id','$rating')";
$db_result2 = mysql_query( $sql2, dbh() );
return mysql_insert_id( dbh() );
}
else{
return "NA";
}
} // set_song_rating()
/**
* show_clear
* this is a hack because of the float mojo it clears the floats
* @package Web Interface
* @catagory Hack-o-Rama
* @author Karl Vollmer
*/
function show_clear() {
echo "\n
\n";
} // show_clear
/**
* show_page_footer
* adds page footer including html and body end tags
* @param $menu menu item to highlight
* @param $admin_menu admin menu item to highlight
* @param $display_menu display menu or not (1 on 0 off)
* @package Web Interface
* @catagory Display
*/
function show_page_footer($menu="Home", $admin_menu='', $display_menu=0) {
if ($display_menu){
if($menu == 'Admin'){
show_admin_menu($admin_menu);
} // end if admin
show_menu_items($menu);
} // end if
show_template('footer');
} // show_page_footer
/**
* Show All Popular
* This functions shows all of the possible global popular tables, this is basicly a top X where X is
* set on a per user basis
* @package Web Interface
* @catagory Display
* @author Karl Vollmer
*/
function show_all_popular() {
$artists = get_global_popular('artist');
$albums = get_global_popular('album');
$songs = get_global_popular('song');
$genres = get_global_popular('genre');
require_once Config::get('prefix') . '/templates/show_all_popular.inc.php';
} // show_all_popular
/**
* img_resize
* this automaticly resizes the image for thumbnail viewing
* only works on gif/jpg/png this function also checks to make
* sure php-gd is enabled
*/
function img_resize($image,$size,$type,$album_id) {
/* Make sure they even want us to resize it */
if (!Config::get('resize_images')) {
return $image['raw'];
}
// Already resized
if ($image['db_resized']) {
debug_event('using_resized','using resized image for Album:' . $album_id,'2');
return $image['raw'];
}
$image = $image['raw'];
if (!function_exists('gd_info')) { return false; }
/* First check for php-gd */
$info = gd_info();
if ( ($type == 'jpg' OR $type == 'jpeg') AND !$info['JPG Support']) {
return false;
}
elseif ($type == 'png' AND !$info['PNG Support']) {
return false;
}
elseif ($type == 'gif' AND !$info['GIF Create Support']) {
return false;
}
$src = imagecreatefromstring($image);
if (!$src) {
debug_event('IMG_RESIZE','Failed to create from string','3');
return false;
}
$width = imagesx($src);
$height = imagesy($src);
$new_w = $size['width'];
$new_h = $size['height'];
$img = imagecreatetruecolor($new_w,$new_h);
if (!imagecopyresampled($img,$src,0,0,0,0,$new_w,$new_h,$width,$height)) {
debug_event('IMG_RESIZE','Failed to copy resample image','3');
return false;
}
ob_start();
// determine image type and send it to the client
switch ($type) {
case 'jpg':
case 'jpeg':
imagejpeg($img,null,100);
break;
case 'gif':
imagegif($img,null,100);
break;
case 'png':
imagepng($img,null,100);
break;
}
// Grab this image data and save it into the thumbnail
$data = ob_get_contents();
ob_end_clean();
// If our image create failed don't save it, just return
if (!$data) {
debug_event('IMG_RESIZE','Failed to resize Art from Album:' . $album_id,'3');
return $image;
}
// Save what we've got
Album::save_resized_art($data,'image/' . $type,$album_id);
return $data;
} // img_resize
/**
* show_genres
* this shows the 'many' genre form, it takes an array of genre objects and the view object
*/
function show_genres($genres,$view) {
require Config::get('prefix') . '/templates/show_genres.inc.php';
} // show_genres
/**
* show_genre
* this shows a single genre item which is basicly just a link to the albums/artists/songs of said genre
*/
function show_genre($genre_id) {
$genre = new Genre($genre_id);
require Config::get('prefix') . '/templates/show_genre.inc.php';
} // show_genre
/**
* get_location
* This function gets the information about said persons currently location
* this is used for A) Sidebar highlighting & submenu showing and B) Titlebar information
* it returns an array of information about what they are currently doing
* Possible array elements
* ['title'] Text name for the page
* ['page'] actual page name
* ['section'] name of the section we are in, admin, browse etc (submenu control)
* @package General
*/
function get_location() {
$location = array();
if (strlen($_SERVER['PHP_SELF'])) {
$source = $_SERVER['PHP_SELF'];
}
else {
$source = $_SERVER['REQUEST_URI'];
}
/* Sanatize the $_SERVER['PHP_SELF'] variable */
$source = ltrim($source, Config::get('raw_web_path'));
$location['page'] = preg_replace("/^\/(.+\.php)\/?.*/","$1",$source);
switch ($location['page']) {
case 'index.php':
$location['title'] = _('Home');
break;
case 'upload.php':
$location['title'] = _('Upload');
break;
case 'localplay.php':
$location['title'] = _('Local Play');
break;
case 'randomplay.php':
$location['title'] = _('Random Play');
break;
case 'playlist.php':
$location['title'] = _('Playlist');
break;
case 'search.php':
$location['title'] = _('Search');
break;
case 'preferences.php':
$location['title'] = _('Preferences');
break;
case 'admin/index.php':
$location['title'] = _('Admin-Catalog');
$location['section'] = 'admin';
break;
case 'admin/catalog.php':
$location['title'] = _('Admin-Catalog');
$location['section'] = 'admin';
break;
case 'admin/users.php':
$location['title'] = _('Admin-User Management');
$location['section'] = 'admin';
break;
case 'admin/mail.php':
$location['title'] = _('Admin-Mail Users');
$location['section'] = 'admin';
break;
case 'admin/access.php':
$location['title'] = _('Admin-Manage Access Lists');
$location['section'] = 'admin';
break;
case 'admin/preferences.php':
$location['title'] = _('Admin-Site Preferences');
$location['section'] = 'admin';
break;
case 'admin/modules.php':
$location['title'] = _('Admin-Manage Modules');
$location['section'] = 'admin';
break;
case 'browse.php':
$location['title'] = _('Browse Music');
$location['section'] = 'browse';
break;
case 'albums.php':
$location['title'] = _('Albums');
$location['section'] = 'browse';
break;
case 'artists.php':
$location['title'] = _('Artists');
$location['section'] = 'browse';
break;
case 'genre.php':
$location['title'] = _('Genre');
$location['section'] = 'browse';
break;
case 'stats.php':
$location['title'] = _('Statistics');
break;
default:
$location['title'] = '';
break;
} // switch on raw page location
return $location;
} // get_location
/**
* show_preference_box
* This shows the preference box for the preferences pages
* it takes a chunck of the crazy preference array and then displays it out
* it does not contain the