Cleaning up after an emailing

November 5th, 2009 § 0

As a web master, I often send out mass mailings. After the mailing is done, the bounced emails are returned to my Outlook. I go through them manually. The real bouncers are put in a “Bounced” folder and,  Out of office messages in the “Trash”. The rest of the emails are addresses I need to update in my database or people that wish to unsubscribe. Since sorting through 2000 bouncers can take up a lot of time, I did some research on how to automate this.

PHP offers a set of functions to connect to a mail server (IMAP/POP3).  The plan was to let my web server connect to the mail server and sort out the bouncers for me. Below is a little script to give you some ideas of what I came up with.

__autoload function

October 21st, 2009 § 0

Some info,snippets on PHP5 autoload function:

function __autoload($className) {
include_once __autoloadFilename($className);
}
function __autoloadFilename($className) {
return str_replace('_','/',$className).".php";
}
$class = new myclass();

When a Class is not found, php will pass the classname to the __autoload function.
You can name your class like Folder1_Folder1a_Myclass and this function will look for it in Folder1/Folder1a/Myclass.php

You can put multiple classes in one folder and still make this work by creating a link to the correct file.
On Unix, Linux machines use the command “ln -s targetfile.php nonexistingclassfile.php”

Prototype: submit multiple select with ajax call

August 11th, 2009 § 0

Beware when posting data from a multiple select through ajax. You can’t send an array with a Prototype ajax call.

expl.

function postmydata(){
new Ajax.Request(’data.php’,
{
method:’post’,
parameters: {selectdata: $F(’myselect’)},
onSuccess: function(transport){
var response = transport.responseText || alert(”couldn’t add data”);
$(’mydiv’).update(response);
},
onFailure: function(){ $(’mydiv’).update(’error’); }
});
}

This won’t work. Your php page will not get an array.

Solution

replace the parameter part with:
parameters: {selectdata: $F(’myselect’).join(”,”)}, // this will send a comma seperated string
In your php code use:
$myselect = = explode(’,',$_POST['selectdata']);

Related Blogs

Google analytics api – no PHP

April 23rd, 2009 § 0

Google finally released an api for Analytics this month. The example code includes code for java and javascript but no PHP. Fortunatly The electric toolbox hosts some example data of how it can be used with Curl.

usersniffing: visitors from a dogs point of view

March 27th, 2009 § 0

Companys put a lot of time and effort in creating compelling websites. Tons of resources are spend to ensure sites add to sales. But is all this money well spend? Thats what analytics software should clarify. Tools like Google Analytics, AWstats,… give a wide overview of visitors, time on site, conversions and other usefull information. But what if this is not enough? What if you want to target your visitors in a more personal way. What follows are some of the options that I found and that could help you change your content on a page per page level.

GeoIP:
This tool allows you to check the visitors ip adres and make an estimated guess as to where he/she is from. Maxmind offers a free and a licensed version for GeoIP Country and GeoIP City.
I tried out the free version and it gave me:

  • country code
  • city
  • Postal code
  • latitude – longitude

Device

Handsetdetection.com has a big list of hardware it can detect. Even Kindle 2 is included.

PHP

With php you have a few tools to analyse your visitors. Just like GeoIP, you cannot be 100% sure. Some of the data that gets send to the server can be manipulated. Here are some of the things that I use.

$_SERVER referer. What is the page that the visitor was on before he came to the current.
get_browser A php function that uses an ini file to detect browserinfo.

CSS, HTML and Javascript

performance checklist AS3

March 25th, 2009 § 0

  • cach bitmaps when possible
  • use correct object types: int and unit instead of Number if possible
  • set mouseEnabled and mouseChildren to fals for items that don’t use mouseevents
  • keep only the objects that you use and when you use them. Assign null when nolonger needed
  • Bitwise math

unchecked checkbox not in $_POST

January 20th, 2009 § 1

Iamcam posted a good hack on his blog. It makes your unchecked checkboxes show up in the $_POST on the server.
It’s very simple and doesn’t need javascript.

<input type="hidden" name="box1" value="0" />
<input type="checkbox" name="box1" value="1" />

If the checkbox is not checked then the value of the hidden input is submited, else the value of the checkbox.

scraping your pc for mp3 files

January 19th, 2009 § 0

The following is a simple dos trick to create a playlist of all your mp3’s.

  1. go to the start menu
  2. click run
  3. enter cmd  => this opens a black dos window
  4. type dir /b/s *.mp3 > c:\mp3list.m3u

When this command finishes, a file will be created under c: with a list of all your mp3 files.
The m3u file is a plain text file with links to all your music. Some audio applications us this format for playlists.

Travian.nl

January 14th, 2009 § 0

Some tools to help play Travian

http://asite.110mb.com/cropfinder.php
Graandorpen zoeken

http://www.travianmap.nl/
http://travian.drvdijk.nl/
http://traviantool2.ww7.be/ mensen die niet actief zijn
http://www.traviantoolbox.com/combat_simulator
http://travian.ws/analyser.pl Speler analiseren
http://traviantoolbox.com/index.php

travian FAQ:http://help.travian.nl/index.php?type=start&mod=100
wiki travian(Eng):http://dhost.info/travian2005/Wiki/index.php/Main_Page
travian wiki v3 (Eng): http://travianwiki.uni.cc/index.php?title=Main_Page
Travian guide: http://tg.dutchtraviantools.nl/
DutchTravianTools: http://dutchtraviantools.nl/
help: http://help.travian.nl/
gebouwen stamboom: http://img107.imageshack.us/img107/7140/gebouwenenunitsv37zo.jpg

troepen vergelijker: http://n00bz.biz/travianstuff/troops.html

travian troepen tabel: http://forum.travian.nl/showthread.php?t=14297

scraping the web

January 7th, 2009 § 3

I’ve been working on a tool to scrape urls. The idea is to have a tool that checks my sites for invalid code, urls and images.

Below some tools and ideas that I might consider using

  • Wget can be used to spider a website (list url’s, not download) with the following command: wget -r –spider -o logfile.txt http://www.myurl.com
  • ruby: open-uri & hapricot.
  • php is not a good idea since scripts can only run for a certain time. (php on commandline is ok)
  • put the results in a mysql database so I can link it with other data

check for:

  • Valid html
  • 404
  • sitespeed
  • image compression (jpegsnoop for photoshop compression, Smush it)
  • readability
  • pagerank
  • internal links (links on my domain to pages on my domain)
  • external links (links on my domain to external domains)
  • received links (who links to me and what alt text is used, page rank)
  • keywords

Try to :

curl into Google analytics and import the results in mysql

[update]should read[/update]

Where Am I?

You are currently browsing the a note to self category at westworld: a webmasters best friend.