Archive for the ‘News’ Category

VS.PHP - IDE, Debugger, WYSIWYG HTML Editor

Wow.  I am blown away.  I think the pricing is just a tad too high though.  I would recommend selling the Standalone Edition for $100 and the for Visual Studio Edition for $75.  Anythign prices over $100 is a hard sell.  Lucky for me I have a copy of Visual Studio Standard I got from a Podcast promotion from Microsoft last year.

VS.PHP Web Site

I am hoping that the debugger in this product works well.  This is the one thing that PHP lacks.  So far I’ve confirmed that it is not a Dreamweaver replacement.  It does not have a split view for editing HTML and it does not treat PHP pages the same as HTML pages.  I would like to edit my PHP in a design view.  Most likely the developers of this application do not consider the spaghetti coding style as a way their program should be used.

Compiled Weekly Podcast coming back!

The compiled weekly podcast is coming back!

Expect a new episode this Wednesday on Subversion.

Universal Extractor - Extract files from unknown compressed formats

Just used this to extract a file that WinZip, 7-zip and IZArc couldn’t extract. Pretty nifty tool and free!

http://www.legroom.net/software/uniextract

Free Text Editors Reviewed

It has been a while since I looked at using a different text editor. I have been a die hard SciTE user for the past 4 years. Today though I thought I would look at some other editors and see if they would meet my needs.

SciTE Home Page: http://www.scintilla.org/SciTE.html

First, I went to Wikipedia to review the list of text editors available: http://en.wikipedia.org/wiki/Comparison_of_text_editors

I also found a wiki that compares most of the popular editors with a shareware editor called Edit Plus.
http://editplus.info/wiki/Alternative_Editors
I visited the web sites to most of the free text editors. Through the process of elimination, limited my testing to two editors, Notepad++ and PSPad.

Notepad++
I was pretty blown away by the number of features that are packaged in Notepad++. IT also uses the Scintilla text control, which is found in SciTE. The only big feature that was missing in this editor was the api function arguments tool tips, sometimes referred to as call tips. This is one of the main reasons I use SciTE to this day. If someone could add this logic to the FunctionList plugin then I may be willing to switch to Notepad++.
http://notepad-plus.sourceforge.net/uk/site.htm
PSPad
PSPad had some features listed that really got my attention. Once I downloaded and installed, I was really disappointed. I was under the impression that TopStyle Light was integrated into PSPad. All PSPad does is launch TopStyle Lite. On top of that, PSPad does not include code folding and quite frankly, has so many menu options I was overwhelmed.
http://www.pspad.com/

TopStyle Lite
If there is one thing I did find from this search was TopStyle Lite. This CSS editor works reasonably well. I think Dreamweaver 8’s CSS editor has a cleaner interface but if you don’t have the cash to buy Dreamweaver and you want a CSS specific editor, then I would recommend this for sure.
http://www.newsgator.com/NGOLProduct.aspx?ProdId=TopStyle&ProdView=lite

I am going to stick with SciTE for now.

What text editor do you recommend?

basename() function for JavaScript

I wrote this basename() function for JavaScript today. It parses a file portion for either windows ‘c:\path\to\file.ext’, *nix ‘/path/to/file.ext’ or href ‘http://server/path/to/file.ext’.

function GetBaseName(file)
{
var Parts = file.split('\\');
if( Parts.length < 2 )
Parts = file.split('/');
return Parts[ Parts.length -1 ];
}

PHP file verification - md5_file vs sha1_file vs crc32 and no native crc32_file

The following was originally posted on php.net/crc32/ under the ‘User Contributed Notes’ but was recently removed. Since this information came up in topic again with a colleague, I am making this research available on my blog.

If you are trying to decide on a function for file verification, I came to the conclusion that md5_file() is the best all around solution.

file_crc() function that Bulk at bulksplace dot com posted on php.net/crc32/ is the most efficient solution on Windows for small and medium size files. It is most likely because file_get_contents() uses memory mapping techniques. Unfortunately on Linux (Fedora), the results were slightly better for md5_file().

sha1_file() on large files is slower than md5_file(). The time it takes for the __crc32_file() function found on php.net/crc32/ is linear to the size of the file. I would avoid using __crc32_file(). The file_crc() function will fail when using the file_get_contents() if the file is larger than the PHP.ini memory_limit setting. Windows does not seem to use the memory_limit for file_get_contents(), but I did run into an error ‘FATAL: emalloc(): Unable to allocate x bytes’ when testing iso files.

I ran the following tests on both WindowsXP and Fedora 4 machines.

< ?php
// File verification tests by Angelo Mandato (angelo [at] mandato {period} com)

// __crc32_file() is very slow, you can uncomment to test for yourself.
//require_once('crc32_file.php');
// Copy and paste the contents of the crc32_file() code found on
// the php.net crc32 PHP manual page in a new file and save
// as crc32_file.php in the same directory as this script.

// Get microseconds
function GetMicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}

// file_crc() - function to test
function file_crc($file)
{
$file_string = file_get_contents($file);
$crc = crc32($file_string);
return sprintf("%u", $crc);
}

$Methods = array('sha1_file()', 'md5_file()', 'file_crc()');
if( function_exists('__crc32_file') )
$Methods[] = '__crc32_file()';
$directory = '/path/to/directory/'; // Don't forget trailing backslash.
$files = scandir($directory);

for( $method_index = 0; $method_index < count($Methods); $method_index++ )
{
$start_time = GetMicrotime();
while( list($index,$file) = each($files) )
{
if( $file != '.' && $file != '..' && is_file($directory.$file) )
{
switch( $method_index )
{
case 0: { // sha1_file()
$value = sha1_file($directory.$file);
}; break;
case 1: { // md5_file()
$value = md5_file($directory.$file);
}; break;
case 2: { // file_crc()
$value = file_crc($directory.$file);
}; break;
case 3: { // __crc32_file()
$value = __crc32_file($directory.$file);
}; break;
}
}
else // It is not part of our test results, lets remove it from the array
{
unset($files[$index]);
}
}
$end_time = GetMicrotime();
echo sprintf("%s took %.03f seconds to calculate %d files.\n", $Methods[$method_index], $end_time-$start_time, count($files) );
reset($files); // Reset pointer in array
}
echo "file verification tests completed.\n";
?>

In conclusion, the md5_file() function was the all around fastest file verification function in PHP. I suspect if a well written crc32_file() function was incorporated into PHP then it would be the best way verify files.

Fix for unresolved DNS queries that are reported by DNS servers to display ads

If you have an ISP that displays a ’site not found’ page when ever you enter an incorrectly typed domain name in your address bar and it drives you nuts, then this post is for you.

My new ISP, WOW Internet (Wide Open West Cable), has their DNS servers configured to return a specific IP address when the queried domain name does not exist. It loads a splash page that contains the text of the address you just typed. This method of harvesting web surfers reached a head 2 years ago when VeriSign launched their Site Finder service. Read more here: http://cyber.law.harvard.edu/tlds/sitefinder/ Other Other DNS services such as OpenDNS do the same thing. In OpenDNS.com case, the advertising displayed in the search results are how they make their money. For WOW Internet though, they are already getting my hard earned money and I see no reason for them to make additional money from me by directing me to their search pages. Not only that, but other TCP services now function incorrectly. If someone gives me a domain name that they are unsure about, my computer is going to return an IP address whether it is valid or not and the only way I know for certain is if I know that IP address is part of the WOW Internet Site Finder service or I type in the domain name in the address bar and view the WOW Internet Site Finder page. This also relegates client side Anti-SPAM software that use a common technique of looking up the DNS entry of the received messages ‘From’ address to verify the E-mail actually came from a registered domain name.

Solution
Configure your own local DNS server. There is a windows port of Bind, or if you are knowledgable of Linux, I recommend setting up your own local Linux DNS server. For those who run Windows and don’t want to learn how to setup Bind on Windows, there is another solution called TreeWalk. TreeWalk is already configured to not resolve a default address if the initially queried domain does not exist.

I installed TreeWalk on my main Windows machine in my home. Then I setup my routers DNS settings statically with the first DNS server ip the ip of my local windows machine on my network. Then the other 2 additional ip addresses for dns servers I set to my ISP’s DNS servers. The first DNS server is used by default unless it is inaccessible.

Quick fix for problem uploading images in phpAdsNew

I was installing a copy of phpAdsNew on a server and ran into a problem where the uploaded images were not saving to the specified local folder on the server.  Searching for the answer was a nightmare, as the forums for the phpAdsNew is terrible.

Many of the threads I loaded included moderators yelling at the original posters that the issue was already addressed and told them to search harder.  Granted I know how fustrating it is when you hear the same question again and again, I also believe there is no such thing as a bad question, now matter how many times it is asked by different people.  My breaking point is when I hear the same question from the same individual multiple times.   Anyway, I never found the actual solution to the problem but I gathered helpful hints which lead me to find a solution.

One of the posts suggested removing the @  in front of all the functions and turning error reporting on for the web site.  I did this and still received no error output.  I was completely stumped.

Synopsis
Once I found that others were able to solve the problem by either reverting back to an older version of PHP or by installing on a different server with an older version of PHP, I decided to look specifically at how the uploads are being handled.  I found the banner-edit.php script was using the $HTTP_POST_FILES PHP global variable.  This global variable was changed in PHP version 4.0.3 to $_FILES.

Solution
To solve the problem, I added the following two lines of code near the top of the file.  It does not have to be placed at the top of the script, but it needs to be inserted before the use of the $HTTP_POST_FILES array is used in the code.

[PHP]
if( isset($_FILES) && !isset($HTTP_POST_FILES) )
$HTTP_POST_FILES = $_FILES;
[/PHP]

I am not exactly sure why they are using $HTTP_POST_FILES variable.  I would presume if anyone was using that old of a version of PHP then they have other security issues to deal with and shouldn’t even allow file uploads. Hopefully the phpAdsNew folks will switch to the $_FILES array and soon before others get frustrated and end up using some other similar product.

Remove the close tab button from Firefox 2.0

If you are a Firefox user like myself, you most likely installed the latest Firefox 2.0 and love it. The only problem I have had is the new close button found in the right side of each tab. I’ve accidently closed about a dozen tabs simply cause my tab clicks were over the X button. Talk about fustrating. I did a little searching and found the setting to remove the close tab button.

First, in the address bar, type:

about:config

Do a search for the following:

browser.tabs.closeButtons

Possible values:

0 - Display close button on current tab only
1 - Display close button on each tab (default)
2 - No close button in any tab

I used the 0 setting which removes the close button from all of the tabs except the one you are viewing currently. That’s just perfect for me!

Happy surfing!

CW8 - October 12, 2006 - web design, shoutcast, media production and hosting

Recorded on October 4th, Angelo speaks with good friend Matt, who owns Choice Lynk Media, a Multi-media production company. We talk about his web site, podcasting, shoutcast server and other interesting tech stuff. Also cover some basic features that we will be talking about over the next few weeks on how to setup your own web hosting server.