Examples on PHP, MySQL, JavaScript, MooTools and CSS

Newest stuff in here

Useful PHP classes and other great tools

February 16th, 2008 in Tools of the trade | 2 comments

From time to time there is a task that needs to be accomplished and it’s a quite difficult one. When that happens and the deadline is tight it’s a very good solution to search the web for what you need. Below, I’ll put some good stuff I found on the web. …view full post

Gzip output, minify CSS and JavaScript

February 13th, 2008 in PHP, Tools of the trade | 11 comments

Smaller pages mean smaller downloads and faster page loading. As a programmer, my primary goal is to develop PHP code that parses fast and consumes the minimum amount of resources. Bandwidth and filesize were not a problem that I realized until lately. So, what can you do to reduce filesize and as a consequence to that to use less bandwidth? …view full post

PHP read directory

October 30th, 2007 in PHP | 11 comments

The other day I found myself having a problem with not empty directories. I had to delete a directory that had another directory in it that contained a file. Giving the fact that I’m a lazy programmer, I had to find an easy enough solution to use then and every time I needed it without doing much work every time.

So I came up with a class that reads the whole directory, it stores in 2 different arrays all the files and subdirectories (the full path to them, starting with the given directory) and than it deletes them if one wants to do that. If you need such code use the one below. It worked fine for me so it should read the directories for you too. Here goes: …view full post

PHP login

September 7th, 2007 in PHP, Security | 14 comments

After searching the web for a php login script (and you can find tons of it), I declared myself a little bit unsatisfied. I was looking for something simple yet powerful and I found all sorts of login scripts (a lot of them not safe at all). By the way, as a warning, BEWARE OF THE LOGIN SCRIPTS THAT HAVE SOMETHING LIKE: $_SESSION['has_access'] = true; INTO THEIR CODE followed by the explanation:”and you simply check the pages using if($_SESSION['has_access'])“.They are not safe at all, but that’s another discussion.

So, what was i looking for? Well, as I said before, the login script should be small, reusable, simple to understand and implement, it should check the user on every page (and I mean CHECK like … strip search). Since the www offer was not good enough, I started implementing my own code.

In order to make it reusable, I thought about creating an object to do this task for me. So, what this php login script does it’s actually quite simple: for every secured page it is installed on, it checks using the data stored in session if the user credentials are ok and if they are it returns his/her details from the database. …view full post

Verify your link exchange partner

August 25th, 2007 in Tools of the trade | no comments

This SEO thing is a pain in the @$$ sometimes. You work and try to find good partners with good page rank to help your domain rank higher and in exchange for a link on his website, you put one of his on yours.

Well, some webmasters are honest. But some are not. And that’s when the process starts to get messy. You put his link and than you start the watch: did he put your link on his page? Is the link clean (no rel=’nofollow’, javascript, frames or other things)? So, you start typing his web address in your browser, select the view source option and perform a search. This is time consuming and not very productive. In this time you could do something more useful.

For that particular reason I started the development of a tool I called backlink verifier. For now, what it does is simply crawl your partner’s page that you specify and search for your domain in all the links available on that particular page and when it finds it it checks whether your link has a nofollow attribute on it or not. Simple, no pain, no source code for you to search into. It will also display the number of links available on page, how many are outbound links and how many nofollow links are on the page.

If this tool will provide itself useful, I will develop it further so please feel free to comment on this article any problems, wishes or things you think it should do.

As a future development “to do” list, I have in mind the following:

  • display outbound links available on partner’s webpage
  • user accounts so that you simply log in and start testing all addresses you added to your accound
  • crawling at least 2 levels deep on your partner’s webpage (for now it only crawls the address you insert)
  • cronjob that will e-mail you if one of your links gets changed / is removed
  • listing of the title text used on your link

Again, you can find the backlink verifier tool here.

Coolest web archive ever – wayback machine

August 24th, 2007 in Tools of the trade | no comments

This is so cool. By accident I found the web.archive.org website. It has web pages dating since 1996 from what I’ve found out reading the info available. It looks like it’s based on an open source web crawler called Heritrix. The list of contributors is huge and thanks to them we can now see how the internet was looking like 10 years ago. If you are an internet addict you’ll love this.

Pages available for a certain domain are chronologically ordered (years, months) and you can browse the whole website not just an index page.

I really REALLY recommend you to visit this website. It made me remember of my teenager period with Starcraft (lots of it) and unfortunately no internet.

For fun, this is how various big fishes used to look like not so many years ago.

Google webpage at Nov 11, 1998

Google webpage 1998

Yahoo webpage at Oct 20, 1996

Yahoo homepage 1996

Blizzard webpage at Oct 19, 1996

Blizzard homepage 1996

PHP header 500 – manage your mySQL errors

August 21st, 2007 in MySQL, PHP | 1 comment

From time to time problems appear. mySQL server crashes, some error in a sql query might think it’s time to show her ugly face and in top of all that, the all mighty Google comes to index your page. And when he does, he indexes a page that presents an error or a blank page. How can we stop him from indexing that page? With a header 500 error.

The header 500 error or “Internal Server Error” means that the server has a nasty indigestion and the search engine should come back later to see the page in all it’s splendor. And that’s exactly what it will do. So, how do we trigger that error?

Most scripts use the mysql_query(“some sql”)or die(mysql_error()) sintax. Well, that’s ok because in case of an error, the script stops and the error appears so the debug process can begin. The only problem is that if some error appears, it will be indexed by search engines. …view full post

Watermark all images in a folder

August 20th, 2007 in PHP | 13 comments

I was checking out the searches from this blog and one in particular caught my eye. It was something like “watermark images from folder“. I remember that not a long time ago I had the same problem.

One of the clients I work for, in the development stage, asked me not to watermark the images of his products because… I really don’t remember the reason. What I do remember is that at some later point, he changed his mind (the website was online with a few hundred products added) and now he wanted to watermark images to prevent theft (some of his competition borrowed them).

So, I came up with 2 solutions. The first one was to watermark the images and save them on his server (a bulk watermark, while reading the whole directory) and another one was to watermark on demand. …view full post

Watermark image

July 23rd, 2007 in PHP | 9 comments

watermark Do you need to watermark your images? If so, do it the smart way. Put your mark on them by resizing the watermark. If you upload images having different sizes, you’ll love this. Read on.

Over the time I had clients that wanted to put a watermark on their images for copyright purposes. But there was a little problem. The watermark was too small on bigger images and too big on smaller ones. What to do… what to do?! Resize the watermark of course! …view full post

Image titles generated with PHP and GD

July 21st, 2007 in PHP | 1 comment

image titles generated with php Some time ago, a client came and asked specifically that the headers (h1 stuff) should use his particular font specified in his identity manual. At that time I did now knew about the flash possibility to overwrite text (search for sIFR.js and you’ll see what I mean), so I chose to dynamically generate these titles using PHP and GD. The reason for this solution (instead of changing them using some image editing software) was that there was some dynamic data (a list of newsletters) that needed the same title styling. …view full post