PHP – Generate Luhn checksum (for valid account numbers)
Here's a function to calculate the Luhn checksum of a 15 digits account number (the checksum'll be the 16th digit) :
-
public function luhnChecksum($accountNumber) {
-
-
// Buffer
-
$sum = 0;
-
-
// Process each digit
-
for ($i = 0; $i < 15; $i++) {
-
$digit = $accountNumber{$i};
-
-
// each 2 digits
-
if ($i % 2 == 0) {
-
$double = $digit * 2;
-
-
// if over 10, sum of the 2 digits
-
if ($double > 10) {
-
$double = (string)$double;
-
$sum += ((int)$double{0} + (int)$double{1});
-
} else {
-
$sum += $digit;
-
}
-
} else {
-
$sum += $digit;
-
}
-
}
-
-
// Euclidian division
-
$rest = $sum % 10;
-
-
// luhn key
-
$key = 10 - $rest;
-
-
return $key;
-
}
Article for teaching purposes.
I can not in any way be held liable for its use
TYPO3 – Change files/images upload limit
Today I'll explain how to change the limit for files, images and other medias upload.
To do the trick, you have multiple changes to make.
HowTo Detect SSL in PHP
Here's a little function I had to use today to detect SSL for payments.
It detects if SSL is on, if not, it redirect the user to the SSL url.
Enjoy
Joomla – Detect homepage in extensions
Here's a little tip to detect, in your Joomla extensions, if the Frontend user is on the Homepage.
-
// Your code for Homepage
-
}
Tell me if it bugs for you, but for me on 1.5.21 it's ok
SabreDAV 1.3.0 available
The new version of SabreDAV comes out with a big change: it is the performance gain for the operations of most trees.
As a reminder, you can easily add SabreDAV WebDAV PHP applications. It is intended to cover the full standard to enable integration using this API easily.
Of course, this version also brings many other changes such as:
- Add a layer of tree cover in the Subject
- Added a new method
- Modifications to some classes
- Patches
- Etc.
