Another day, another problem….
We have an automated printing system for invoices that downloads an automatically generated PDF invoice from our production server to one of our office Linux servers and then prints it out before deleting it.
Today the toner cartrige ran out on the printer and so invoices were starting to get backed up in the print queue. It could easily have been a few days before we could get the printer up and running so I thought about the alternatives
- Get them and print them manually on our other colour laser printer – really can´t be bothered
- Let them back up till it´s fixed – not the best of ideas
- Get them automatically printing on the other printer
So I decided to try and get them going on the other printer (it could be useful in case this happens again). Only problem is that this printer is a USB device shared on a Windoze 2000 server. I guessed that trying to get the linux server printing to the windows share would be a knightmare so I went with the option of getting windows to do the printing.
The Linux server is set up with a Samba share so all I needed to do is print the PDFs. I´d heard somewhere that you can do command line printing with Acrobat Reader so I did some reseach to find out how. After three hours of browsing the internet I found out a few things…
- Newer version of the Reader will print from the command line but the Reader window won´t close after printing the document and so doesn´t lend well to batch or automated printing.
- Older versions (think 4.0 or below) will do it but I had problems with some of the images being in black and white instead of colour.
- You have to pay for a solution that actually works…
So I went back to the drawing board. Next option, try to hook up the Linux server to the Windows printer. After a bit of searching, turns out it´s bloody easy! Since I have Samba installed, I also have the smbclient installed and you can use this to print a .ps (converted with Ghostscript from a pdf) with a one line command!
Put this in a script (or in my case a php file so I can do other things at the same time) and you´re good to go my friends.
Windows is easy, Linux is complecated… Bullshit!
One of our clients that does interior design asked me to do a mailing list for them. Not a problem. We have done a lot of leg-work to make sure that we can code an email that gets past most spam filters out there (since this is both targeted and subscribed to, its not spam anyway – just automated).
Only problem was to get some way to track if people were actually reading the things, or even receiving them at all! Since read receipts are an iffy one since they are optional, we decided to do something server side to check it. As it is database driven the code can be altered for each email that gets sent out and therefore the simplest way is to include an image (such as the company logo) with the path altered to include the ID of the email address from the database.
Since there isn´t an image there on the server, Apache and htaccess will handle the 404 error and direct it to a PHP file. This will then take the ID from the requested URL and then update the database to say that email has been read. It will then stream the requested image out to the email client. Ah, Apache and .htaccess, if I could I would run away with you both and live on a mountain side in peace.
Not a bad idea though, time to see if it´ll actually work…
Although the main reason i started this was so that I could start up a Linux terminal, sit there typing away and still have everyone think I was still working, but there was also that it could be useful for other web developers trying to do similar stuff and looking for info.
The main part of my job has always been back-end programming and other coding, along with the occasional bit of design work. Over the past couple of months though, I´ve starting to put more effort into Search Engine Optimisation (SEO) for some of our companies major projects. One of these is eppointments that I have mentioned here before. Optimisation on this site and doing the essential SEO job of creating incoming links has caused the number of hits coming from the three major search engines to go up by about 400%. Not bad!
One of our other major projects, Find Locally, is more difficult though as it consists of over a thousand domains! This means that it would be impossible to generate enough links to all the individual sites to get enough PR to get them up the rankings. This is where internal linking comes in. Eventually the individual sites will contain enough content for the search engines to take a larger interest in them. By funelling this interest to the home page with the proper key words, then optimising the home page accordingly, it should help to drive the sites up the rankings.
Oh well, time to go and re-code the 1,387 sites then i suppose….
Recently got asked to redo the EBS: European Business Solutions site as it was a bit outdated code wise and we thought it could be a bit friendlier to search engines.
The original code was done in an old HTML editor and so contains a lot of font, span, div tags and all the other html that just bloats up a page and can now be replaced by my wonderful friend CSS.
In order to make it as search engine friendly as possible i wanted to shift as much of the code into a single CSS file used accross the site. This means that the ratio of relevant text to code tags on a page is quite high which can help increase your search engine rankings.
Its definately worth doing on older sites. For starters, it can save loads of bandwidth!
So we have a simple login system for our automated reminder system which asks for various details such as name, address, mobile number and lastly, email address. The email address is quite important as this is a purely online system and so most communication is done through email (such as notifications, billing reminders, special offers, etc).
Upon registration an email is sent out confirming the new users email address and password. Lately I´ve been getting messages rebounded from some of the various free email providers such as Hotmail. Chances are this is because the user hasn´t checked their account in the last month, as opposed to a false address (since they are along the lines of some_random_string_of_crap74@hotmail.com).
I originally didn´t want to use email verification methods as it makes it a more complicated registration process and as it´s a paid for service, I expected users to be responsible with the information they gave. On second thoughts I´ve decided to implement a verification process where the user is logged in when they click on a link in an email they receive to an address they specify. This must be done within a certain time which is stored in the database. This means that anyone not verifying will have their account disabled.
The downside to this is that legitimate users would suffer a delay before they can use their account, so I decided to give them a 24 hour grace period, then log them out and disable their account if they haven´t verified by this time. Hopefully it´ll give a more robust system.
One of my latest projects, a trainer & training providers database contains an area for displaying various training venues. This is to help training providers to find a location to run their training courses in accross the country.
We also have another site for advertising training venues which will be used for venues to register and place their adverts. This will then be added to the database on both sites. It also logs them in on the Venue Hound site. The only problem is that I wanted to log them in on Find Trainers as well.
What with a large numbers of users having third party cookies disabled, using that as an authentication methos is ruled out. I could have used the database and login scripts on both sites so they use the same informtaion to login, but that kind of defeats the whole point of trying to have a unified login.
I decided to come up with another plan. Both sites are written in PHP and so any particular page I serve up can have the links modified to different URLs. Using this and a cookie set for the Venue Hound domain, I can modify the links displayed for Find Trainers to have extra information in the URL. When the user arrives at findtrainers.co.uk the PHP in the page will take the extra information in the URL, check it with the database and assuming the information is correct, log them in!
Hey presto and Bob´s your uncle. Its not foolproof and you have to be a bit tighter with security, but it works fairly well.
So I was sitting at work either writing a complex database driven program or watching Stargate SG1, I´m not sure. My boss came in and asked me if the database got backed up anywhere. I said "Yup, it´s backed up onto the development server every day".
"Where is the development server?"
"It´s that one there", I said, pointing at the Linux box balanced on the top of an old monitor on the edge of my desk.
"Ha huh. Can we do an off-site backup somewhere?"
So I did. Since our databases are stored on several different servers I wrote a program to export each of the databases as a text file of SQL commands. These files are then compressed into a gzip file and downloaded to the local server. It also archives these by date so that I can keep an archive of our databases, gradually reducing the number of old files it keeps.
The next stage is to gzip all the files in the document root of our development web server, which also includes the gzipped sql files. Since this is our development server it also contains copies of all the files for all the various the websites. This final gzipped file now contains everything I need to restore any of our servers from catastrophe.
The final part then FTPs to my remote home server and uploads the gzip file to a protected directory. Bingo bango, job done!
Its all done in PHP using commands to standard Linux tools like wget, ftp, gzip and the mysql command line utility. With a little tinkering it should work on most linux setups. If anyone thinks that this might be useful to you then drop a comment below and I might stick it up here for download.