[PHP] Removing duplicate in an array… really fast

Let’s imagine you have a huge array, with say couple ten thousands of elements and you want to remove any duplicates entries in this array. As PHP programmer you’ll be thinking of array_unique. For a “small” sized array and one dimensional array this one does the trick.

I have some nice snippets which cover multi dimensional and/or huge sized array.

First: you have a huge, one dimensional array.

This one works only on one dimensional array. The key of the last element will be preserved and the keys are not sorted

Second: for a huge, multi dimensional array

sources:

  1. http://dk.php.net/manual/en/function.array-unique.php#97285
  2. http://www.puremango.co.uk/2010/06/fast-php-array_unique-for-removing-duplicates/

[TYPO3] Redirect to last page

Problem of the week:

you have a password protected pages on your TYPO3 site. If you spread the URL of the pages and other user will be shown the login page, if they call the URL. Problem will be, after logging in, the user is not redirected to the last page, which they call.

The felogin extension of TYPO3 supports 6 type of redirect after login:

  1. defined by usergroup record
  2. defined by user record
  3. TypoScript or Flexform of the felogin extension
  4. GET/POST-Parameter
  5. Referer
  6. Domain entries

The solution is the “referer” redirection. The question is how. This is where we use the fabulous TypoScript.

This TypoScript creates a redirect per meta tag (see wrap), but to which URL. The magic happens in the typolink function. xxx is your login page. The GET parameter “referer” will have the value of the last page, which the user visited.

The magic does not end here. You have to set to “referer” redirect in the flexform of the felogin extension.

felogin

so that’s all.. hope this could be help.

Cheers

 

 

Wrapping image based on width… pure TypoScript

following issue: images should be wrapped with various class parameter (or div, or whatever) based on its width. And it should be solved only per TypoScript…

hmmm… quite a difficult one, don’t you think? well, you know what… I solved it… :D

Continue reading Wrapping image based on width… pure TypoScript

Rewrite robots.txt

Your CMS (read: TYPO3) can handle multiple subdomain in one installation. Problem: you can only put one robots.txt in the htdocs. The following rewrite rule will solve the problemby rewriting robots.txt to robots_(subdomain).txt

it will do following rewrite:

  • www.domain.tld/robots.txt will load robots_www.txt
  • sub1.domain.tld/robots.txt will load robots_sub1.txt, if it’s not exist, then robots_def.txt will be loaded

New plugin

you know… in Germany, they have one thing that bugs me a lot… privacy on web… ok it will annoy me also, if my data are spread out there without me knowing (may be it has been happening the time I wrote this). but the privacy law has problem if the guest data are sent to some foreign server (read Google). So instead Google Analytics, Piwik is used, since you can host your own analytics software and you can anonymize it, so it’s ok. So Piwik is used here….

Second.. Akismet. Who don’t know akismet… spam comment detecting service, which automatically remove those viagra ads (read “spam”) from the comments… but akismet is also a foreign server and your guests data are sent to some foreign server… so need to find something else to replace it… Here comes Antispambee. It’s supposed not to sent any data out from your server, but promising some spam accuracy… so I give it a chance… let’s see how good this thing is… BUT it is NOT a challange for you guys to spam my blog :)

you’ve been warned… watch out for the bees and so long…

munich

Gruß Gott, si ivan ke bayern, tepatnya ke munich. refreshing, weekend travel. naek kreta kyk jaman student dulu :)
jln dr rumah jam 7 pagi, msh gelap n thermometer “cuma” minus 1 :) skrg dah ada matahari n kereta br berangkat dari Nuernberg. dr frankfurt ke wuerzburg, trs ke nuernberg, n skrg finish di muenchen :) msh ada 1,5jam lagi.
so, bsk dr muenchen ke zugspitze. snow? maybe. lets see. ivan’s out