How to check if user is logged without bootstrapping – using .htaccess file

Wednesday, 28. September 2011, 16:31
Veröffentlicht in der Kategorie Life

This is a cached copy from http://ayesh.me/content/how-check-if-user-logged-without-bootstrapping-using-htaccess-file

In this post, I’m going to say you how to check if the remote user is logged in to your Drupal network. There’s no need to bootstrap Drupal at all. The point is, we are checking the client’s cookie storage to see if Drupal’s logged in cookies are set.

This small trick will help forbidding access to files for anonymous users from your host. For an example, say you are giving away a GPL theme to all registered users, you can easily wrap access to the “giving away node” but not to file itself. Others can get your direct download URL and distribute it as they want. Don’t say me that it’s GPL, remember – it’s our bandwidth ;)

There’s an exception though. You can put this .htaccess trick anywhere you want but Drupal’d cookie must be there. If your site is hosted on example.com, you can make use of this trick from static.example.com , files.example.com , example.com/files , etc. But not from example.net.

Let’s start.
Create a .htaccess file in the root of the directory, and add the following code to it.

RewriteEngine on

RewriteCond %{HTTP_COOKIE} !DRUPAL_UID=1

RewriteRule .* http://example.com [R]

This will check if the client who access the file has DRUPAL_UID cookie set. If Please note that advanced users can manually set a cookie named DRUPAL_UID and add some number (>= 1) to download the file without actually logging in. So this is not a better way to deny access for files you sale. But the reason why you don’t have to worry to much is nobody except you know that .htaccess file is checking the cookie.

This stupid piece of shi**y code will prevent some download managers (that don’t have browser integration)

If this doesn’t work, make sure that $cookie_domain thing in settings.php setup like .example.com – note the “dot” before example.com .

My GTD setup: Part 2

Saturday, 6. November 2010, 18:10
Veröffentlicht in der Kategorie Cognition, Computers, Life

After I introduced GTD yesterday a little bit and I tried to show my personal requirements for an organizational system, I want to jump today right into the implementation of several parts:

Read the rest of this entry »

My GTD setup: Part 1

Friday, 5. November 2010, 2:30
Veröffentlicht in der Kategorie Cognition, Computers, Life

I have recently started to implement GTD. There are millions and millions of setups out there and I certainly am not interested in boring you too much. I rather want to give you an idea of what I find important in an GTD implementation and where I see problems. I would be really interested in hearing about our setups and how ou solved certain things.

What is GTD?

First of all, I want to give you a short intro to GTD. This is intended for people who have never heard of it. So if you know about lists, inbox and general reference filing systems, you should skip this.

Read the rest of this entry »

November Commitment

Wednesday, 3. November 2010, 9:05
Veröffentlicht in der Kategorie Life, News from LA

Hi everyone.

Since March nothing new on the blog. Reasons for that are manifold, but the biggest one is that I am working at USC and that this kept me pretty busy. However, the fact that I was not able to update the blog kept bugging me. I therefore thought about a way to force me to update the blog more regular and about how to sustain the productivity a bit better.

Here is my idea:

Read the rest of this entry »

Ada Lovelace Day – Meine Heldin(nen) in Wissenschaft und Forschung

Thursday, 25. March 2010, 4:55
Veröffentlicht in der Kategorie Computers, Politics

Ich habe mir seit langem Gedanken zu diesem Thema gemacht. Als “Forschungsassistent” lebe ich in der Wissenschaftswelt und man erwartet eigentlich nicht, dass es viele Frauen in dem Bereich gibt. Aber zumindest fuer mich stimmt das nicht. In meinem Lab sind Frauen in der Ueberzahl, in dem speziellen Subfachgebiet eher die Regel als die Ausnahmen. Zusaetzlich dazu ist meine Verlobte auch ein Gradstudent… Ich kann also nicht einfach jemanden waehlen, sondern muss zumindestens ueber einige Leute was sagen, da ich ansonsten unfair waere. Read the rest of this entry »

Mac OS X 10.6 Snow Leopard Passwort ändern ohne Boot DVD

Saturday, 13. March 2010, 23:42
Veröffentlicht in der Kategorie Computers, Life

Heute was aus der praktischen Computerecke.

Ich habe mein altes MacBook mit insgesamt 4 Betriebssystemen ausgestattet, die ich alle mehr oder weniger nutze. Da bleibt es nicht aus, dass ich nach mehreren Wochen mal wieder eines meiner Loginpasswörter vergessen habe. Noch dazu hat mein DVD-Laufwerk den Geist aufgegeben, so dass ich nicht mehr einfach die Boot DVD benutzen kann um unter Snow Leopard mein Passwort zurück zu setzen.

Auf der aktuellen Platte habe ich ein Dual-Boot mit Windows XP und Snow Leopard sowie eines der Tools zum Lesen und beschreiben vom Mac-Dateiensystem (HFS+). Also sollte es doch möglich sein das aktuelle Userpasswort zu verändern. Leider ist das dann doch nicht so einfach, dass Mac Passwörter nicht wie Linux verschlüsselt in der /etc/passwd oder /etc/shadow speichert, sondern die in einer eigenen Datenbank hat, die man ohne Mac Tools nicht bearbeiten kann.

Es gibt für Mac OS X Versionen vor 10.6 noch die Möglichkeit den Computer im “Single User Mode” zu starten und dann das Passwort zurück zu setzen. Dazu drückt man während des Bootens einfach ⌘-S .

Da das aber nicht geht, habe ich einfach meinem OS X gesagt, dass es brandneu ist und einen neuen User anlegen soll. Dazu löscht man in /var/db/ die Datei .AppleSetupDone. Wenn man dann neu startet, kommt der Begrüssungsbildschirm und man kann einen neuen User anlegen, den man dann benutzt um das Passwort des alten Users zu ersetzen.

Einziger Haken: Man verliert seine Keychain. Aber das sollte das geringste Problem sein :)

Protected: Unser Apartment in LA

Tuesday, 9. March 2010, 15:32
Veröffentlicht in der Kategorie News from LA
Enter your password to view comments.

This post is password protected. To view it please enter your password below:


Protected: Bilder aus LA

Monday, 8. March 2010, 2:41
Veröffentlicht in der Kategorie News from LA
Enter your password to view comments.

This post is password protected. To view it please enter your password below:


Textfeldeingaben von Versuchspersonen in E-Prime

Thursday, 8. January 2009, 8:43
Veröffentlicht in der Kategorie Cognition

Ich habe in letzter Zeit mehrfach die Frage gestellt bekommen wie man eine Versuchpersoneneingabe in ein Textfeld bei E-Prime und E-Prime 2 macht. Ich habe sowas eigentlich nie verwendet, aber wie es der Zufall will, benoetigen wir sowas in unserem naechsten Experiment. Man beschaeftigt sich halt mit sowas nie, ausser man braucht es selber. Wenn man es braucht dann ist es aber meist umso noetiger.

Und damit ihr da draussen nicht in Not geratet, beschreibe ich hier bebildert wie das ganze geht. Es ist nicht schwer, aber die Funktion ist (wie so haeufig) etwas versteckt.
Read the rest of this entry »

Debatte 3: I stay the course!

Wednesday, 15. October 2008, 21:35
Veröffentlicht in der Kategorie Politics

Meine Vorhersage zur letzten Debatte sind ja so nicht eingetreten. Abgesehen von 2-3 Spitzen, war es ganz ruhig. Auch hat das Town Hall Format nicht soviel mehr Interaktion gebracht wie ich mir gewünscht hatte.

Ich bleibe aber dabei, dass wir mehr Attacken auch in einer persönlichen Debatte sehen werden. da heute die letzte ist, nehme ich an, dass wir also heute einige Attacken von McCain bzgl. “Palin’ around with Terrorists” hören werden und Obamas Pastoren nochmal aufgekocht werden.

Ich bin mir immer noch nicht sicher wie Obama reagieren wird. Oder vielleicht macht er ja die erste Attack. Es gibt jedoch inzwischen viele Hinweise, dass die persönlichen Attacken nicht fruchten, was vielleicht auch mit den seltsamen Verhalten einiger Randrepublikaner zu tun hat.

Wahrscheinlich ist Obamagut beraten genau nix zu tun. Dann werden die Spitzen natürlich auf beiden Seiten auch nicht so stark werden, wie ich mir das vielleicht wünsche.

Tags: , ,

Was kann die Kognitionswissenschaft?

Tuesday, 7. October 2008, 22:55
Veröffentlicht in der Kategorie Cognition

Viele Leute fragen mich, was die Kognitionswissenschaften denn heutzutage bereits alles können. Die Anwendungsfälle sind natprlich vielfältig, aber ich erzähle immer gerne die Sachen die maximal möglich sind, nicht unbedingt die praktischsten. Klar, Handschriftenentzifferung bei Briefen ist toll, Visual Heat Point Berechnungen der feuchte Traum gewisser Marketingleute und Fussballroboterweltmeister sein ist auch nicht schlecht.

Aber tatsächlich das faszinierendste habe ich erst vor ein paar Tagen gefunden. Wissenschaftler benutzen in Computern simulierte Neuronen um ein Gehirn nachzubilden. Noch nicht das eines Menschens, sondern das einer Maus, aber auch das ist schon sehr beeindruckend. Hier ein paar Daten:

  • 8 000 000 Neuronen insgesamit im Netzwerk
  • 6 300 von real 8 000 Synapsen pro Neuron simuliert
  • Plattform: 4096 Prozessor BlueGene/L supercomputer
  • Jede CPU mit 256 MB Speicher ausgerüstet
  • 1 Terabyte RAM
  • Zeitverzögerung 1:10

Ein ganz schöner Aufwand für ein halbes Mausgehirn. Ein Jahr später ist man bereits bei einem Rattengehirn angelangt, aber die Kosten in Sinne von Ressourcen steigen exponentiell. Man brauch nämlich bereits 32,768 Prozessoren.

Wir sprechen hier also von einer sehr biologienahen Nachbildung eines Gehirn, dass also in der richtigen Umgebung das gleiche wie eine Maus/Ratte lernen könnte. Faszinierend, wenn man sich einmal anschaut, was solche Tiere alles können.

Können Tiere träumen?

Tuesday, 7. October 2008, 22:26
Veröffentlicht in der Kategorie Cognition, Life

Das weiss ich nicht, aber mein Degu schnarcht auf jeden Fall ;)
Deguschnarchen (ogg)
Deguschnarchen (mp3)

Tags:

Zweite Debatte: Ein neuer Stil

Tuesday, 7. October 2008, 21:24
Veröffentlicht in der Kategorie Politics

Die letzte Debatte war ja sehr zivil was den Umgangston angeht. McCain hat aber bereit angekündigt dieses mal aggressiver zu sein. Das entspricht auch eher dem Stil, den die Kampagnen in den letzten Tagen angenommen haben. Obama wird vorgeworfen mit Anarchoterroristen aus den 70er Jahren rumzuhängen, McCain wird ein Skandal aus den frühen 90ern wieder aufgetischt.

Das ganze geschah mit Ankündigung, gestartet von McCain, der offensichtlich seine Vorteile alle ausgespiel hatte und den ehemaligen Chef-Strategen von Bush, Karl Rove, engagierte. Der Tenor ist klar. Obama kennen wir zu wenig. Wer weiss, was er früher gemacht hat. Ich bin mir sicher, dass bei dieser Debatte auch die Drogenvergangenheit, die Obama in seinen Büchern veröffentlich hat, heute zur Sprache kommen werden.

Ich bin gespannt was Obama machen wird. Sicherlich wird er mit Charakterattacken antworten müssen, aber er sollte auf jede Attacke eine Antwort haben: “I have pledged, just as you have, to lead a clean, honourable campaign. I will keep my promises.” Das würde meiner Meinung nach McCain den Wind aus den Segeln nehmen. Das Obama natürlich im nächsten Satz dann eine versteckte Attacke fahren würde ist auch sehr wahrscheinlich.

Man darf gespannt sein. Mein Tipp: C-SPAN Debate Hub, alles live, inklusive Spin-Room. Dazu später mehr :)

Tuesday, 7. October 2008, 12:56
Veröffentlicht in der Kategorie Cognition

I have no data yet. It is a capital mistake to theorize
before one has data. Insensibly one begins to twist facts to suit
theories, instead of theories to suit facts.

Sherlock Holmes

Falsche Zeile

Sunday, 28. September 2008, 17:14
Veröffentlicht in der Kategorie Cognition, Life

(….) independent of the content of experience; moreover, unlike the rationalists, Kant thinks that a priori knowledge, in its pure form, that is without the admixture of any empirical content, is independent of the content of experience; moreover, unlike the rationalists, Kant thinks that a priori knowledge, in its pure form, that is without the admixture of any empirical content, is independent of the content of experience; moreover, unlike the rationalists, Kant thinks that a priori knowledge, in its pure form, that is without the admixture of any empirical content, is independent of the content of experience; moreover, unlike the rationalists, Kant thinks that a priori knowledge, in its pure form, that is without the admixture of any empirical content, is independent of the content of experience; moreover, unlike the rationalists, Kant thinks that a priori knowledge, in its pure form, that is without the admixture of any empirical content, is independent of the content of experience; moreover, unlike the rationalists, Kant thinks that a priori knowledge, in its pure form, that is without the admixture of any empirical content, is independent of the content of experience; moreover, unlike the rationalists, Kant thinks that a priori knowledge, in its pure form, that is without the admixture of any empirical content, is independent of the content of experience; moreover, unlike the rationalists, Kant thinks that a priori knowledge, in its pure form, that is without the admixture of any empirical content, is independent of the content of experience; moreover, unlike the rationalists, Kant thinks that a priori knowledge, in its pure form, that is without the admixture of any empirical content, is independent of the content of experience; (…)

Tags: ,
Stoppt die Vorratsdatenspeicherung! Jetzt klicken & handeln!Willst du auch bei der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien: