Authenticate external app to Joomla user database

Hi folks, ifound this in a forum. This is for everyone who's trying to authenticate a user against the joomla db and does not know to compare the password. This is no code but only a way you can do it:

Example:

Username:
passexample

User entered Plain text password:
password12

Lookup username in Joomla database and return password stored in database for the username:
bec20914e6738d0150f4af07c0161297:MhMtmNgZRWQgfznO

Explode into parts:
Password:
bec20914e6738d0150f4af07c0161297

Salt:
MhMtmNgZRWQgfznO

Append salt to password:
password12MhMtmNgZRWQgfznO

Plain text password with salt appended to it and md5 encrypted result:
bec20914e6738d0150f4af07c0161297

Compare result to password part from Joomla password. If same good, user is authenticated against Joomla database, if not bad password, try again.

source: http://forum.joomla.org/viewtopic.php?p=1368032

Regular expression

In computing, a regular expression, also referred to as regex or regexp, provides a concise and flexible means for matching strings of text, such as particular characters, words, or patterns of characters. A regular expression is written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.

The following examples illustrate a few specifications that could be expressed in a regular expression:

  • The sequence of characters "car" appearing consecutively in any context, such as in "car", "cartoon", or "bicarbonate"
  • The sequence of characters "car" occurring in that order with other characters between them, such as in "Icelander" or "chandler"
  • The word "car" when it appears as an isolated word
  • The word "car" when preceded by the word "blue" or "red"
  • The word "car" when not preceded by the word "motor"
  • A dollar sign immediately followed by one or more digits, and then optionally a period and exactly two more digits (for example, "$100" or "$245.99").

Regular expressions can be much more complex than these examples.

The rest of the article can be found on wikipedia with some nice examples.

Perl Regular Expressions

Hi, for all those who do not understand or are interested in Perl Regular Expressions, here is a small explanation of the symbols (source: http://www.troubleshooters.com/codecorn/littperl/perlreg.htm).

Another interesting article can be found here:
http://www.grymoire.com/Unix/Regular.html

Using Simple "Wildcards" and "Repetitions"

Calling these "wildcards" may actually conflict with the theoretical grammar and syntax of Perl, but in fact is the most intuitive way to think of it, and will not lead to any coding mistakes.

. – Match any character
\w – Match "word" character (alphanumeric plus "_")
\W – Match non-word character
\s – Match whitespace character
\S – Match non-whitespace character
\d – Match digit character
\D – Match non-digit character
\t – Match tab
\n – Match newline
\r – Match return
\f – Match formfeed
\a – Match alarm (bell, beep, etc)
\e – Match escape
\021 – Match octal char (in this case 21 octal)
\xf0 – Match hex char ( in this case f0 hexidecimal)

You can follow any character, wildcard, or series of characters and/or wildcard with a repetiton. Here's where you start getting some power:

* – Match 0 or more times
+ – Match 1 or more times
? – Match 1 or 0 times
{n} – Match exactly n times
{n,} – Match at least n times
{n,m} – Match at least n but not more than m times

 

Symbol Explanations:

=~

This operator appears between the string var you are comparing, and the regular expression you're looking for (note that in selection or substitution a regular expression operates on the string var rather than comparing). Here's a simple example:

$string =~ m/Bill Clinton/; #return true if var $string contains the name of the president
$string =~ s/Bill Clinton/Al Gore/; #replace the president with the vice president

!~

Just like =~, except negated. With matching, returns true if it DOESN'T match. I can't imagine what it would do in translates, etc.

/

This is the usual delimiter for the text part of a regular expression. If the sought-after text contains slashes, it's sometimes easier to use pipe symbols (|) for delimiters, but this is rare. Here are simple examples of the slash operator:

$string =~ m/Bill Clinton/; #return true if var $string contains the name of the president
$string =~ s/Bill Clinton/Al Gore/; #replace the president with the vice president

m

The match operator. Coming before the opening delimiter, this is the "match" operator. It means read the string expression on the left of the =~, and see if any part of it matches the expression within the delimiters following the m. Note that if the delimiters are slashes (which is the normal state of affairs), the m is optional and often not included. Whether it's there or not, it's still a match operation. Here are some examples:

$string =~ m/Bill Clinton/; #return true if var $string contains the name of the president
$string =~ /Bill Clinton/; #same result as previous statement

^

This is the "beginning of line" symbol. When used immediately after the starting delimiter, it signifies "at the beginning of the line". For instance:

$string =~ m/^Bill Clinton/; #true only when "Bill Clinton" is the first text in the string

$

This is the "end of line" symbol. When used immediately before the ending delimiter, it signifies "at the end of the line". For instance:

$string =~ m/Bill Clinton$/; #true only when "Bill Clinton" is the last text in the string

i

This is the "case insensitivity" operator when used immediately after the closing delimiter. For instance:

$string =~ m/Bill Clinton/i; #true when $string contains "Bill Clinton" or BilL ClInToN"