########################## package pm::user; ########################## #/ # Encapsulates all user related functions # these routines do NOT require a DBH # the DB is connected to automagically! #/ ########################## use strict; use CGI::Carp qw(fatalsToBrowser); use URI::Escape; use Exporter; use vars qw($VERSION @ISA @EXPORT); ########################## ########################## $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = qw( _tests blockedUser check_user_stats get_uid_byNickname get_user_age get_user_blocked_users get_user_city get_user_country get_user_dp get_user_friend_requests get_user_friends get_user_fuck_alert_count get_user_message get_user_messages get_user_pic get_user_pics get_user_stat get_user_stats get_user_stats_asIcons get_user_subscription_type get_user_theme_data get_user_unread_messages get_users_emails get_users_nicknames isUser isUserAdmin isUserBday isUserModerator isUserSubscriber isFriend set_user_stats user_paid_expired nickname_in_use email_in_use ); ########################## ########################## my $loggedin = pm::bc_chef::cookie_get("loggedin"); my $db = pm::bc_sql::sql_connect("ns.db"); ########################## # this is just one sub. as you can see there are TONS of subs... ########################## sub get_user_blocked_users($) { #* # gets a list of blocked users for the specified user # can return an empty array #* my ($uid) = @_; # a uid my @blocks = (); my $results = pm::bc_sql::sql_execute($db, "select BID from blocks where UID = " . $db->quote($uid)); # could be a single hash ref, or a ref to an array if (ref $results eq "HASH") { if (pm::bc_sql::user_exists($db, $results->{BID}) and not pm::security::banned($db, $results->{BID})) { push @blocks, $results->{BID}; } } elsif (ref $results eq "ARRAY") { foreach my $ref (@$results) { if (pm::bc_sql::user_exists($db, $ref->{BID}) and not pm::security::banned($db, $ref->{BID})) { push @blocks, $ref->{BID}; } } } else { return undef; } return @blocks; # an array of blocked uid's #usage: my @blocked_users = get_user_blocked_users($uid); } #... 1;