Archive for July, 2008
iWebDir.net launched, BETA state!
I am glad to announce you that www.iwebdir.net is now online!
Do you have a website? Submit it now on my web directory!
This directory isn’t using a predefined script like PHPLD. It’s a custom script, made exclusively by me.
It uses AJAX for the registration page, account and rating system. I will continue to add many cool features, but right now I don’t have the time to do this, ’cause this saturday I’ll be gone in Switzerland, Austria, Hungary and possibly Germany. So no posting in the next 2 weeks.
Anyway, you just submit your website and I’ll be glad to approve it right away!
Automatically resize images in PHP - Script tutorial
Have you ever needed a simple script to automatically resize your uploaded images in PHP?
For example, suppose that you have a database containing some websites and that you want to store a thumbnail for every website. You take a screenshot of the website, but you have at a higher dimension. Suppose you want to resize it to 110×70px but your don’t want to manually resize it in your image editor. Well, let’s make a simple function in PHP so we can save our precious time.
Let’s start by first uploading and moving your image as it is:
move_uploaded_file ($_FILES['thumbnail']['tmp_name'], $_FILES['thumbnail']['name']);
You moved your file. Now we use a function like imagepng(), together with our custom resize_image() function. Remember that if your uploaded file is in PNG format, you must use imagepng() otherwise it won’t work. This applies for other extensions too (like GIF, JPG, etc.).
imagepng (resize_image ($_FILES['thumbnail']['name'], ‘png’, 110, 70), “/thumbnails/thumbnail-resized.png”);
If you do not plan to use the original, unresized image, you can delete it:
@unlink ($thumbnail['name']);
I placed the “@” symbol to suppress the errors (if any).
And now we create our resize_image() function. We have four arguments: the filename ($_FILES['thumbnail']['name']), the extension (png|gif|jpg), width and height:
function resize_image ($filename, $extension, $width, $height) {
Based on the file’s extension, we create our image:
if ($extension == “jpg” || $extension == “JPG”) {
$image = imagecreatefromjpeg ($filename);
} elseif ($extension == “png” || $extension == “PNG”) {
$image = imagecreatefrompng ($filename);
} elseif ($extension == “gif” || $extension == “GIF”) {
$image = imagecreatefromgif ($filename);
}
We find out the actual width and height of the image and we also put our new values in some variables:
$actual_width = imagesx ($image);
$actual_height = imagesy ($image);
$new_width = $width;
$new_height = $height;
Now we create our new resized image (a blank one) and after that we copy the old one, resizing it at the same time.
$new_image = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, floor($new_width), floor($new_height), $actual_width, $actual_height);
We finally return the new image created and finalize the function.
return $new_image;
}
That’s it! Now you have a fully working image-resizing PHP script!
Apache slow on Windows Vista? Not anymore!
Have you ever encountered a 2-3 second delay when loading your local pages on Windows Vista and thought “Windows Vista sucks” and after that reinstalled good old XP?
Well, the problem lays in the HOSTS file. There is a line there which slows Apache. (sincerely, I don’t know why).
So, to solve the problem:
1. Open Windows Explorer and choose the partition where you have Windows Vista installed;
2. Navigate to Windows -> system32 -> drivers -> etc
3. Open the HOSTS file with Notepad.
4. Find the line “::1 localhost” and put a “#” symbol before it
5. Save the file with Ctrl + S and restart your Apache server.
After completing these steps, you should not experience loading problems anymore.
YouTube must give full logs to Viacom
U.S. District Judge Louis L. Stanton authorized full access to the YouTube logs for Viacom, so that they can see whether their copyrighted videos are more heavily watched than amateur-uploaded ones.
The logs won’t be publicly released, they will go straight to Viacom. This would be a direct threat to users’ privacy, said Google’s lawyers. Every log would contain: the name of each video a user is playing, user’s ID and his/her IP address.
However, Google’s secret source code will not be disclosed for the plaintiffs.
Read full article here
Google AdSense Referrals will be discontinued
Google has decided that AdSense Referrals should be retired during the last week of August.
They also give an alternative to their service, the so far known as DoubleClick Performics Affiliate Network, now Google Affiliate Network, but this is only for advertisers targeting users in the United States. This program enables users to get paid by advertiser-defined actions, instead of the classical click or impression.
Google recommends that all the publisher who currently use AdSense Referrals should replace their referral code from their website with another AdSense for Content code, because starting from the last week of August, the ads will no longer display, a blank space appearing instead.
If you are interested in the Google Affiliate Network, follow this link: Google Affiliate Network
Source: AdSense Blog



