diff --git a/frontend_routes.pm b/frontend_routes.pm index 656cb40..beef4c0 100644 --- a/frontend_routes.pm +++ b/frontend_routes.pm @@ -89,24 +89,33 @@ sub handlePath { my $channelID = $row[0]; my $channelName = $row[1]; my $serverName = $row[2]; + $channelName =~ s/%23/#/; $table.="$channelName$serverName"; } my $privateChannels = ""; if($logged) { - $query = $aConnection->prepare(qq(select id from users where name=?;)); + $query = $aConnection->prepare(qq(select id, privileges from users where name=?;)); $query->execute($frontend_session::sessions{$aRequest->{"cookies"}{"session"}}{"username"}); my @row = $query->fetchrow_array(); my $id = $row[0]; - $query = $aConnection->prepare(qq(select channel_id from accessors where user_id=?;)); - $query->execute($id); + my $privileges = $row[1]; + if($privileges>0) { + $query = $aConnection->prepare(qq(select id from channels where public=0;)); + $query->execute(); + } + else { + $query = $aConnection->prepare(qq(select channel_id from accessors where user_id=?;)); + $query->execute($id); + } while(@row = $query->fetchrow_array()) { my $channelID = $row[0]; my $channelQuery = $aConnection->prepare(qq(select channels.name, servers.name from channels inner join servers on channels.server_id=servers.id where channels.id=$channelID;)); $channelQuery->execute(); @row = $channelQuery->fetchrow_array(); my $channelName = $row[0]; + $channelName =~ s/%23/#/; my $serverName = $row[1]; $privateChannels.="$channelName$serverName"; }