From 9c8be228a73a602ac3e91e30bf980dd1cc695a81 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sun, 26 Nov 2006 20:28:46 +0000 Subject: playlist switcher, plugin interface and the shell of a lastfm plugin (need patch file) --- modules/admin.php | 239 -------------------------------------- modules/lib.php | 110 ------------------ modules/plugins/Lastfm.plugin.php | 77 ++++++++++++ 3 files changed, 77 insertions(+), 349 deletions(-) delete mode 100644 modules/admin.php create mode 100644 modules/plugins/Lastfm.plugin.php (limited to 'modules') diff --git a/modules/admin.php b/modules/admin.php deleted file mode 100644 index 0be633e5..00000000 --- a/modules/admin.php +++ /dev/null @@ -1,239 +0,0 @@ -ip); - - print("\t$host->name". - "$ip". - "id\">Delete\n"); - } - } - else { - print("\tYou don't have any hosts in your access list.\n"); - } -} // show_access_list() - - -/* - * show_manage_users - * - */ - -function show_manage_users () { - - show_box_top(_('Manage Users')); - echo "

Use the following tools to manage the users that access your site.

\n"; - echo "
\n"; - show_box_bottom(); - - show_users(); -} // show_manage_users() - - -/* - * show_change_password - * - */ - -function show_change_password ($username) { - - $user = get_user($username); - - print("
"); - - print("

Changing User Password

\n"); - - print(""); - - print("\n"); - print(""); - print(""); - print("\n"); - - print("\n"); - print(""); - print(""); - print("\n"); - - print("
Enter password:
Enter password again:
\n"); - print(""); - print("
"); -} // show_change_password - -/* - * show_update_user_info - * - */ - -function show_update_user_info ($username) { - - $user = get_user($username); - - $user->offset_limit = abs($user->offset_limit); - - print("
"); - - print("

Changing User Information for $user->fullname

\n"); - - print(""); - - print("\n"); - print(""); - print(""); - print("\n"); - - print("\n"); - print(""); - print(""); - print("\n"); - - print("\n"); - print(""); - print(""); - print("\n"); - - print("
Fullname:fullname\">
Email:email\">
View Limit:offset_limit\">
\n"); - print(""); - print("
"); -} // show_update_user_info() - -/* - * show_delete_stats - * - */ - -function show_delete_stats($username) { - print("
"); - print("
"); - - if ( $username == 'all') { - print("

Delete Your Personal Statistics

\n"); - } - else { - print("

Delete Your Personal Statistics

\n"); - } - - print(""); - print("
"); -} // show_delete_stats() - - - -/* - * get_user - * - */ -function get_user_byid ($id) { - - - $sql = "SELECT * FROM user WHERE id='$id'"; - $db_result = mysql_query($sql, dbh()); - return (mysql_fetch_object($db_result)); -} // get_user_byid() - -function get_user ($username) { - - - $sql = "SELECT * FROM user WHERE username='$username'"; - $db_result = mysql_query($sql, dbh()); - - return (mysql_fetch_object($db_result)); -} // get_user() - -/* - * delete_user - * - */ - -function delete_user ($username) { - - // delete from the user table - $sql = "DELETE FROM user WHERE username='$username'"; - $db_result = mysql_query($sql, dbh()); - - // also delete playlists for user - $sql = "DELETE FROM playlist WHERE username='$username'"; - $db_result = mysql_query($sql, dbh()); - - delete_user_stats('all'); - -} // delete_user() - -/* - * update_user - * - */ - -function update_user ($username, $fullname, $email, $access) -{ - $dbh = libglue_param(libglue_param('dbh_name')); - if(!$username || !$fullname || !$email || !$access) return 0; - $sql = "UPDATE user ". - "SET fullname='$fullname',". - "email='$email',". - "access='$access'". - "WHERE username='$username'"; - $db_result = mysql_query($sql, $dbh); - if($db_result) return 1; - else return 0; -} // update_user() - -/* - * update_user_info - * - * this for use by 'user' to update limited amounts of info - * - */ - -function update_user_info ($username, $fullname, $email,$offset) { - - $dbh = libglue_param(libglue_param('dbh_name')); - - $sql = "UPDATE user SET fullname='$fullname', email='$email', offset_limit='$offset' WHERE username='$username'"; - $db_result = mysql_query($sql, $dbh); - - // Update current session (so the views are updated) - $_SESSION['offset_limit'] = $offset; - - return ($db_result)?1:0; - -} // update_user_info() - - -/* - * set_user_password - * - */ - -function set_user_password ($username, $password1, $password2) { - - $dbh = libglue_param(libglue_param('dbh_name')); - if($password1 !== $password2) return 0; - - $sql = "UPDATE user SET password=PASSWORD('$password1') WHERE username='$username' LIMIT 1"; - $db_result = mysql_query($sql, $dbh); - return ($db_result)?1:0; -} // set_user_password() - -?> diff --git a/modules/lib.php b/modules/lib.php index b90a6c4f..e51b8e4a 100644 --- a/modules/lib.php +++ b/modules/lib.php @@ -9,55 +9,6 @@ */ -/* - * show_album_pulldown() - * OLD FUNCTION!! use show_album_select($name,$selected) - */ - -function show_album_pulldown ($album) { - - global $settings; - $dbh = dbh(); - - $sql = "SELECT id,name FROM album ORDER BY name"; - $db_result = mysql_query($sql, $dbh); - - echo "\n\n"; -} // show_album_pulldown() - - -/* - * delete_user_stats() - * - * just delete stats for specific users or all of them - * - */ - -function delete_user_stats ($user) { - - $dbh = dbh(); - - if ( $user == 'all' ) { - $sql = "DELETE FROM object_count"; - } - else { - $sql = "DELETE FROM object_count WHERE userid = '$user'"; - } - $db_result = mysql_query($sql, $dbh); -} // delete_user_stats() - /*********************************************************/ /* Functions for getting songs given artist, album or id */ @@ -90,54 +41,6 @@ function get_songs_from_album ($album) { } -function get_song_ids_from_album ($album) { - - $dbh = dbh(); - - $song_ids = array(); - - $query = "SELECT id FROM song" . - " WHERE album = '$album'" . - " ORDER BY track, title"; - - $db_result = mysql_query($query, $dbh); - - while ( $r = mysql_fetch_object($db_result) ) { - $song_ids[] = $r->id; - } - - return $song_ids; - -} - - -/* - * get_song_ids_from_artist_and_album(); - * - * Get all of the songs that are from this album and artist - * - */ -function get_song_ids_from_artist_and_album ($artist, $album) { - - global $settings; - $dbh = dbh(); - - $sql = "SELECT id FROM song" . - " WHERE artist = '$artist'" . - " AND album = '$album'" . - " ORDER BY track, title"; - $db_result = mysql_query($sql, $dbh); - - $song_ids = array(); - - while ( $r = mysql_fetch_object($db_result) ) { - $song_ids[] = $r->id; - } - - return $song_ids; -} - - // Used by playlist functions when you have an array of something of type // and you want to extract the songs from it whether type is artists or albums function get_songs_from_type ($type, $results, $artist_id = 0) { @@ -232,19 +135,6 @@ function get_artist_info ($artist_id) { } -function get_artist_from_album ($album_id) { - - global $settings; - $dbh = dbh(); - - $query = "SELECT DISTINCT artist.id, artist.name FROM artist,song" . - " WHERE song.album = '$album_id' AND song.artist = artist.id"; - $db_result = mysql_query($query, $dbh); - $r = mysql_fetch_object($db_result); - return $r; -} - - function get_album_name ($album, $dbh = 0) { $album = new Album($album); diff --git a/modules/plugins/Lastfm.plugin.php b/modules/plugins/Lastfm.plugin.php new file mode 100644 index 00000000..cb833bea --- /dev/null +++ b/modules/plugins/Lastfm.plugin.php @@ -0,0 +1,77 @@ + -- cgit