Skip to content

Instantly share code, notes, and snippets.

@dmuth dmuth/gist:1587034
Created Jan 10, 2012

What would you like to do?
How to secure a Drupal site
* From my blog post at:
$path = getenv("SCRIPT_URL");
// If a user is not logged in, they can only access certain unrestricted pages.
if ($user->uid == 0) {
if (
// strstr() is called for efficiency. Keep in mind that ANY path that matches
// these strings will be allowed to anonymous users. So if you have something
// like "/userlist", an anonymous user can view that. I warned ya!
!strstr($path, "user")
&& !strstr($path, "how-to-join")
&& !strstr($path, "contact")
) {
form_set_error("", "You must be logged in first.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.