sub isadmin { # This can takes zero or one parameter. # if param is "blocked" or no param, then # it will exit the script via dienice # If param is "check" it will continue running and return # the admin field for that record. my($param)=@_; $dbh=dbconnect(); # print "
Remoteuser: $remoteuser"; ## Grab user info from the table $sth = $dbh->prepare("SELECT * FROM registered WHERE username = ?") or dienice ("Couldn't prepare select statement: $!" . $dbh->errstr); $sth->execute ($remoteuser) or dienice ("Couldn't execute prepared statement $!" . $dbh->errstr); while ($h = $sth->fetchrow_hashref){ %item = %{$h}; $user = $item{username}; # Get their username $name = $item{name}; # Get their name $email = $item{email}; # Get their email $isadmin = $item{admin}; # Get the admin column } if (length($name)<=0) { dienice("There is no username that matches $remoteuser in the database. Use a different username."); } if ($isadmin ne "Y" and $isadmin ne "S") { if ($param ne "check"){ dienice("$name, you do not have priveleges to perform this operation. Your current privilege code is: $isadmin (param is: $param)"); } } return $isadmin; }