This code can be used to avoid needing a log in block on your site.
If a user is logged in, the link will allow them to log out. If they are not logged in, it will allow them to do so.
You can see the link in action on the footer of my other drupal site penguin.ox4.org (although you can't log in - you'll just have to trust me that it works!).
The code is a little bit of PHP - so you'll need the PHP filter module enabled.
To use the code, create a block. Make sue that you've got the Input format option set to PHP code and your on plain text editing. Copy this code into the Block body:
<?php
global $user;
if ($user->uid) {
echo "<a href=\"/logout\">Logout</a>";
}
else {
echo "<a href=\"/?q=user\">Log in</a>";
}
echo "</p>";
?>
The place the block wherever you want it on the page. Since I'm using the code in my footer, I've kept the link to ox4.org by starting my code block like this:
<?php
echo "<p>Hosted by <a href=\"http://ox4.org\">ox4.org</a> | ";
global $user;
...