ss_blog_claim=88d0a386a6277415f42c9ee5561ded98

Archive for June, 2007

Generating Random Passwords in PHP

So here is my first coding article for this site and I thought I’d start with something simple: generating random passwords using PHP.

Generation of random passwords is very practical in many situations, for example generating forum activation codes, but it doesn’t stop there. There are virtually thousands of uses for a script like this.

The script becomes more versatile and scalable if it is written in the form of a function, so that is exactly what I will do. This function will hopefully work anywhere.

The basic idea behind this random password is that it will give a different password every time it is called. This can only be done by using the time as what the password is generated off to make each code truly unique. So we will start of by defining a PHP function which will generate this password for us. There will be one input from the user: the length of the password. When the function is called, it will return a random password of alphanumeric characters ranging from 0-32 depending on the length given.

Here is the complete function:

<?php
function randomPassword($length){
 
  $pass = md5(time());
  $pass = substr($pass, 0, $length);
  return $pass;
}
?>

Download this code: genrandpw.phps

The above function is pretty straightforward. The first line defines a function called randomPassword which takes a parameter ‘length’. The next line uses the built-in PHP function MD5(). MD5 function returns the hash of the input given. Here we give MD5 the time as an input. The time() function returns the timestamp. Remember that the timestamp will always be different because the date is always changing (here date includes time and seconds). So basically when we give the MD5 function the latest timestamp, it generates the hash for that specific instant, which is also always different because of the ever changing time.

Next we substr the password returned. Substr is used for returning some specific length of a given string. For example, the substr used here will return the initial string of the password of the length that the user will give.

The last line of code returns the password randomly generated.

The code can be used in such a way as shown in the examples below:

<?php
echo randomPassword(15);
 
// Or you could use the below and call the string via the $password variable.
 
$password = randomPassword(15);
echo $password;
?>

Download this code: genrandpw-examples.phps

The above code will return something like 1n48a6fb3m9f6c8

I hope you enjoyed the first code article on this blog, which should be the sign of more articles to come.

Tips, questions or just plain baffled by my code? Leave a comment.

If you liked this post, buy me a coffee!

Alexa Ranking - What It Is and Why You Should Care

My fellow readers, to be honest, I haven’t paid much attention to my Alexa rank, but some recent posts around the interweb have prompted me to start thinking about it.

For those who don’t know, your website’s Alexa rank affects the amount of money that advertisers will pay to be shown on your site. The lower the numerical Alexa rank, the more money advertisers are prepared to pay. It’s not all that they will be looking for, but it’s an important factor regardless.

In short: a good Alexa ranking matters. So how do you go about ensuring a good ranking? Well, recently I’ve watched the Alexa ranking of this site get better and better over time so the waiting game is a crucial part of the rank improvement process.

So how do you go about improving your Alexa rank? Here’s a few simple tips to get you started:

Install the Alexa Toolbar
If you install the Alexa toolbar on your own web browser, then every time you view your own site, you register as a hit (and so does everyone else who vists your site with the toolbar installed). If you are an Internet Explorer user you can download it here. If Firefox is your browser of choice don’t feel excluded because you can install the SearchStatus Extension instead.

Encourage others to follow suit
Conformity isn’t such a bad thing in this case; so encourage your friends, fellow webmasters as well as site visitors/blog readers to install the toolbar or the Firefox extension. Give them motivation by placing a link to it on your site. (Hint, hint)

Install Alexa widgets
It seems every site offers a widget for your site these days and Alexa is no exception. Read all about their widgets here. They look something like this:

Use Alexa redirects
Use Alexa Redirects on your website URL. For example: redirect.alexa.com/redirect?www.forgedeuphoria.com. Replace forgedeuphoria.com with the URL for your website. Leave this redirected URL in blog comments as well as forum signatures. This redirect will only count each unique IP address once a day.

Write or Blog about Alexa
Webmasters and bloggers love to hear about ways to increase their Alexa rank. They’ll link to you and send you targeted traffic (i.e. visitors with the toolbar already installed). This gradually has effects on your Alexa ranking.

Give people good links
The blogosphere is generally a nice place, so it’s only simple logic that the more times you give people good quality links with good anchor text, the more times you will get the same high quality links in return and hopefully when clicked, will increase your Alexa ranking.

Try Alexa Autosurfs
Do they work? Everyone says maybe for brand new sites with a very poor Alexa rank. Note that there might be problems when you try to use auto surfs alongside contextual ads like Adsense. They aren’t also long term solutions to improving your Alexa Rank so I suggest using this option with caution.

So there are just a few options/tips to increase your Alexa ranking and start moving up in the interweb hierarchy.

Got any other Alexa tips? I’d love to hear them.

If you liked this post, buy me a coffee!

IDrive-E Online Backup Service

I-DriveE is a new online backup service that comes with 2gb space, 256 bit encryption for a grand total of $0 (yes, that’s right: free!) It is feature-rich (full list) and has the option of always appearing as an encrypted, mapped drive on your computer for quick and easy backups. This also means that you can schedule backups whenever you like. You can protect your MP3s, photos, videos, emails and financial documents easily with IDrive-E. The great thing is there is no download/upload limit! If you’re looking for more, for a fee of $4.95 per month you can use one of the newest introduced features: the ability to create and manage multiple accounts, which is ideal for a small business. A paid account also offers unlimited storage and if you purchase a full year in bulk for $49.50, you receive 2 months free usage. So why not check out IDrive-E and sleep easily knowing your data is safe and secure.

This is a sponsored post

If you liked this post, buy me a coffee!

Up For A Swim, Anyone?

Google Maps is a great tool for mapping out your journey or getting directions to an unknown land which lies beyond your wardrobe door. But Lion, Witch and the Wardrobe references and anomalies aside, Google Maps is suggesting if you want to Go to New York from London, you must swim 3,462 miles across the Atlantic Ocean; or that’s the suggested route anyway. So check it out at Google Maps and scroll down to Step 31. Laughs guaranteed.

If you liked this post, buy me a coffee!

PayPerPost Love

PayPerPost are a company that connect advertisers who want to place ads on blogs and connect them with bloggers who want to earn a little bit of money on the side to pay for something or to spoil themselves or someone else. Now usually, people see the word ‘ads’ and think: ‘Wow, I’m not putting a huge banner on my page that screams Blatant Advertising!’. The difference with PayPerPost is YOU choose what you want to advertise on your blog and do it through the means of a blog post. This also means you can offer your honest opinion on products and pick things that suit your, your blog or your writing style. So far I’ve made just under $80 (and hoping to increase that to $90 with this post!). There’s people on PPP who have made over $12,000 dollars! So what not give PayPerPost a try and earn a little moolah on the side?

If you liked this post, buy me a coffee!

Snail Mail Spam

The Domain Name Registry of America thinks it’s doing me a courteous service by posting me a letter by snail mail (internationally, may I add) to tell me that this domain name will expire within the next few months. October 21, 2007 to be exact. I’m being offered a 1 year renewal for AU $41.00, which according to the letter, is a huge saving on their prices, which makes me wonder why they even bother sending out these letters if I can get a renewal from Dotster (my registrar) for $14.95? Something tells me they don’t make very much money with such outrageous prices.

So as I said, a one year registration costs AU $41.00, 2 years for AU $68.00 and 5 years for only AU $130.00 ($75 saving - AU $205.00 for a domain for 5 years? I think not!) and considering I purchased this domain for $1 something tells me their letter is wasted on me. I even got the bunch of fine print on the back of the letter which got a glance before I scrunched up the letter and placed it in the bin. But before I did this I decided to scan the letter just for effect - The Original Letter. Apologies for the poor quality scan.

Conclusively, I believe this is the last time I place my real address to be displayed on the WHOIS database. Goodbye Domain Registration snail mail spam! I consider this letter a preparation for if I ever receive a letter in the post to enlarge my penis. And while we’re on the subject of spam why not read up on the history of Spam?

If you liked this post, buy me a coffee!

Wordpress 2.2 Upgrade Headaches

So I upgraded to Wordpress 2.2 last night and all supposedly went smooth, until I viewed my blog. The sidebar went crazy so I tried downgrading to 2.1.3 to maybe fix the sidebar — my backups were fine, the MySQL backup didn’t want to import into phpMyAdmin so I am using the Qwilm theme until I can work out something more permanent.

If you liked this post, buy me a coffee!

Hurrah, The Pages Are Back

After monkeying around in PHP and MySQL for long enough; I’ve finally fixed the pages and they now show the full content! I apologise for any inconveniences this may have caused but the pages seem to be in 100% working order which is awesome. Excuse me now while I do a small jig to commemorate this occasion.

If you liked this post, buy me a coffee!




June 2007
M T W T F S S
« May   Jul »
 123
45678910
11121314151617
18192021222324
252627282930  

RSS  


Posts (RSS) Posts     Comments (RSS) Comments
 Add to Technorati Favorites


advertisements  






top commentators