Matthew Steven Kelly

My Alma Mater

May2

This is just a little demonstration of embedding Google maps into a website or blog. I just created a website for an upcoming event and wanted to give visitors directions from a local hotel to the event. To make it easier for everyone, I just embedded a Google map with directions on the “Directions” page.

More information from Google here

As a demonstration, if the event was at the University of Dayton, and my guests were staying at the Dayton Marriott…

Print this map

View Larger Map

However, so much more is possible with the Google Maps API. Matt Cutt’s (a favorite blogger of mine) made a great post about things you can do: http://www.mattcutts.com/blog/fun-with-zip-codes/

posted under Random | No Comments »

Antivirus Software

April14

As I have recently worked on two computers with multiple viruses (one literally reported 177 viruses found, the other only a mere 14), I wanted to make a note about Anti-Virus software. These two different relatives of mine both had computers that were  un-usable, and asked for help to make it so their computers did not run so slow when they tried to use them. Were they ever suprised by the amount of viruses I found!

My antivirus software program of choice is AVG Free Anti-Virus. Mostly because while it is FREE, it is still very good. I used Symantec Anti-Virus (Version 10) for long period of time but had real problems with its sluggishness and responsiveness on my computer. It was OK (not great) when my laptop was XP, but then when I switched to Vista, it was a resource hog that noticeably slowed my computer down.

I think of AVG Free like I do Google Chrome. Fast, efficient, and loads quickly. I find those things important.

At any rate, if you do not have an anti-virus program on your computer right now, at least download AVG FREE and do a computer scan. You might be surprised by what you find.

What to do if you find out you have a virus:

  1. This may be a given, especially if you already know you have a virus, but make sure you have UP TO DATE ANTI-VIRUS software running on your PC. A lot of users think they have up to date anti-virus software, but really they only have the 6 month trial version of Symantec or McAfee, which while it runs after the 6 month period, offers you zero protection.
  2. Make sure to change all passwords you use on the web (of course only after the virus is removed). A common virus users have is a Trojan Horse which can log what passwords you enter and where you entered them and send that information back to a hacker.
  3. Make sure Windows has all of the latest updates. Go to http://update.microsoft.com/ (in Internet Explorer only unfortunately) until it tells you that you have no more updates to download and install. You should also set up Windows to update nightly on its own. That can be done with the Microsoft Security Center. While you are there, make sure the Windows Firewall is turned on (if you are not using a commercial firewall product).Make sure other programs you use, such as your web browser, email client (if not using web mail), etc are also up to date. Many viruses exploit flaws in web browsers and email clients as those are typically much easier to break than Windows itself.
  4. Stop doing things that help cause viruses, such as going to shady internet sites, opening email attachments from unknown sources, or downloading files. If you are using a program like Limewire or Bearshare… STOP. Not only are you probably downloading illegal files with those programs; programs like Limewire load tons of adware on your PC, not to mention the likely hood that files you download could have viruses in them. Oh, and the possibility of six figure fines, but I digress.
  5. Other than that… don’t panic. You can get a virus by just being connected to the internet. The most important thing to do is keep your computer up to date and protected. Happy internet-ing!



posted under Random | No Comments »

Generating an image from text

March23

if(!isset($_POST['text_value']))
{
$_POST['text_value'] = "This is an image displaying text from the input box";
}
?>

Text to display:

How did I do that?

Generating an image from text can be easy with PHP and GD. This requires GD 1.8 or higher.

Check out www.php.net for an exact description of the php functions used in this code. They are all pretty much built in GD functions.

Now the part that make this code great is that there is no temporary files saved on the server, it is all done in memory.

Save this code as generate_image.php

<?php
function trimLength($data,$len)
{
if(strlen($data)>$len)
{
$data = substr($data,0,$len);
}
return $data;
}

function filterText($data)
{
return preg_replace("/[^A-Za-z0-9.,\s\s+]/","",$data);
}

$text = filterText($_GET['text']); // remove all illegal characters
$text = trimLength($text, 60); // trim to sixty characters
if($text == "") { $text = "Text"; }

$font = 4;
$width = ImageFontWidth($font) * strlen($text);
$height = ImageFontHeight($font);

header("Content-type: image/gif;");
$im = @imagecreatetruecolor($width, $height)
or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 0, 0, 0);
$COULEUR_BLANC=imagecolorallocate($im,255,255,255) ;
imagefilledrectangle($im,0,0,$width,$height,$COULEUR_BLANC) ;
imagestring($im, $font, 0, 0, $text, $text_color);
imagegif($im);
imagedestroy($im);
?>

And then on the page you want the image created add this code

<img src="generate_image.php?text=The security code is 9999" alt="" />
posted under Random | No Comments »

Checking Dell warranty information

February16

Dell.com has a great feature allowing you to check the warranty information on a dell product by using its service code.

If you have a system with a lot of dell computers, you can do is store all of the service tag codes and put them on a web page with an easy click-able link to see the warranty information. With some more work you can integrate it into a content managements system where a user could enter new service tags, disable tags that are no longer valid, and the tag links were automatically generated, etc.

Lets go with a simple example, of setting up a single static link. First setup a php file as follows named dell-warranty.php:

<?php
 
$code = $_GET['code'];
 
echo "<html>";
echo "<body ";
 
// validate code
if ( $code != "" )
{
        echo "onload=\"document.getElementById('submitForm').submit()\"";
}
echo ">";
echo "<form id=\"submitForm\" name=\"frmServiceTagSelect\" method=\"post\" ";
echo "action=\"http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen\">";
echo "<input type=\"hidden\" name=\"logout\" value=\"\">";
echo "Service Tag: ";
echo "<input name=\"ServiceTag\" type=\"text\" id=\"ServiceTag\" maxlength=\"7\" size=\"30\" value=\"".$code."\"/>";
echo "<input type=\"submit\">";
echo "</form>";
echo "</body>";
echo "</html>";
?>

Then create a web page that has a link to the dell-warranty.php page and passes the service tag as an argument to the page. ie: <a href="dell-warranty.php?code=9999999">9999999</a>. When some one clicks a link on your web page it will automatically forward them to the dell website.

Below is a recreation of the form, enter your dell service code and click the check warranty button.

Sample Dell warranty form

Service Tag:

What is a Service Tag?  |  Find My Service Tag

posted under Random | 3 Comments »

Threading in C#

February10

A quick snippet of C# code to process data in a thread, and update a status label on the GUI to show how far along in the process it is.

To use this code you just need a generic Windows Form C# application with a label control named “lblStatus” and a button control named “btnProcessData”. Additionall add a click event to the button:

In Form1.Designer.cs:

this.btnProcessData.Click += new System.EventHandler(this.btnProcessData_Click);

Form1.cs

using System;
using System.Threading;
using System.Windows.Forms;
using System.IO;
namespace ProcessData
{
  public partial class Form1 : Form
  {
    private System.Threading.Thread _thread;
    public Form1()
    {
        InitializeComponent();
    }
    public delegate void UpdateLabelTextCallback(Label box, string msg);
    /// <summary>
    /// Allows threads to update text on a label
    /// </summary>
    /// <param name="lbl"></param>
    /// <param name="msg"></param>
    private void UpdateLabelText(Label lbl, string msg)
    {
        lbl.Text = msg;
    }
    /// <summary>
    /// Function that processes data
    /// </summary>
    private void btnProcessData_Click(object sender, EventArgs e)
    {
        lblStatus.Invoke(new UpdateLabelTextCallback(this.UpdateLabelText), new object[] { lblStatus, string.Format("Starting to process…") });
        ThreadStart TS;
        try
        {
            TS = new ThreadStart(ProcessData);
            _thread = new Thread(TS);
            _thread.Start();
        }
        catch (Exception E)
        {
            MessageBox.Show(string.Format("{0} {1} {2}", E.Message.ToString(), E.Source.ToString(), E.StackTrace.ToString()));
            _thread.Abort();
        }
    }
    /// <summary>
    /// Function that processes data
    /// </summary>
    private void ProcessData()
    {
        int iMax = 10;
        for (int i=1; i<=iMax; i++)
        {
            Thread.Sleep(500);
            lblStatus.Invoke(new UpdateLabelTextCallback(this.UpdateLabelText), new object[] { lblStatus, string.Format("Processing {0} or {1}", i, iMax) });
        }
        lblStatus.Invoke(new UpdateLabelTextCallback(this.UpdateLabelText), new object[] { lblStatus, string.Format("Finished processing…") });
    }
  }
}
posted under Random | No Comments »

Programmatically click a C# button

February10

Many times I am writing a c# application where a certain function needs to be performed on a timer event as well as from a user clicking a button. So in the effort of keeping the programmatic functionality the same as the user clicked event, we can programmatically click the button:

btnProcessData_Click(this, new EventArgs());

One could argue that it would be just as easy to to call a function from both locations such as ProcessData() instead of clicking the button programmatically, but the advantage is if a programmer in the future (or even you down the road) adds logic to the _Click event, it won’t be implemented in the triggered event (an event you or the new programmer may not remember or know occurs).

posted under Random | No Comments »

Task Schedule Web Script From Windows

February9

If your website hosting is of the Linux variety, you know you can schedule scripts to automatically run using cron jobs. But what if your servers are all of the Windows variety? Not a problem, Windows provides the Windows Task Scheduler.

Lets say you have a php script that sends out emails to a newsletter list, but because you do not want to flood your email servers, you would like to have the server send out (20) emails every 30 minutes to keep your daily total under 1000 emails/day. You could generate a script that every time it was executed grabbed the next 20 emails from a database list and send them a predefined email.

Or if you have a database that has a large amount of volume, so to conserve space you only want to keep data that is less than 30 days old. You could create a script that executes a query to delete any content older than 30 days. With the task scheduler, you could have this script run every night.

Or if you have a production database and need to email a report out every hour, you could create a script to do so and task schedule it.

Or any other task you wish to have repeated on a scheduled basis and can easily script the task. This is a great tool for developers who are only familiar with scripting languages like PHP, ASP, etc and can complete advanced tasks in them that would otherwise be done by coding a C++ or C# server application.

Lets go with scheduling the email script example above for a walk through on setting up the Windows Task Scheduler.

On the Windows server (note this does not have to be the web server – it can be any Windows machine that will be running 24/7 to be able to execute the script when scheduled) go to “Start | Control Panel | Scheduled Tasks”.

  1. Click the Add Scheduled Task button
  2. Click Next
  3. Select Internet explorer from the list and click Next
  4. Select Perform this task Daily (we’ll change it later) and click Next
  5. Click Next on the task start time
  6. Enter your username and password of the computer
  7. Check the open advanced properties checkbox and click Finish

In advanced properties

  1. Add “www.mywebsite.com/mail.php” after “C:\PROGRA~1\INTERN~1\iexplore.exe” in the “Run” Section. The field will look like this: “C:\PROGRA~1\INTERN~1\iexplore.exe www.mywebsite.com/mail.php
  2. Click on the schedule tab and click advanced
  3. Check “Repeat Task” and say every 30 minutes for 24 hours.
  4. Click OK
  5. Click OK
  6. Enter the Windows user name and password again

Internet explorer will pop up and execute the script every 30 minutes now.

Need the script to have a few layers of security? Here are a few things you can add:

  • Utilize SSL encryption and setup the task scheduler to access the page via https:// instead of http:// this ensures any data transmitted between the web server and computer running the task scheduler is encrypted.
  • Have the web page look for a specific cookie on the computer making the request to execute the script. Then add a method to the script to allow for the one time creation of the cookie, such as mail.php?generatecookie=1. Now on any computer you need to run the task scheduler, first generate the cookie on the computer, then run the scheduler.
  • Have the script check the IP address of where the request is coming from and only allow it to execute if it is the IP address of the server running task scheduler. With PHP you can detect the IP address of where the web request is coming from using “$_SERVER['REMOTE_ADDR']” (note: only works if you have a static IP address and keep in mind IP addresses can be spoofed).
posted under Random | 1 Comment »

Processing Credit Cards Online

February8

If you are a company that will be (or currently is) accepting credit cards online I hope you are aware of the security requirements that your company is required by law to implement. All Internet merchants – not just large companies – are required to be compliant with the Payment Card Industry (PCI) cardholder data security requirements. A company that is not compliant can have large fines imposed against them or worse – lose the ability to process any credit cards.

For the small business owner, it does take some work to ensure PCI compliance and it should be noted that unless specifically stated, shared hosting accounts are NOT PCI compliant. Typically shared hosting sites offer a way to be compliant, such as GoDaddy, whose shared hosting sites are not PCI compliant unless you add on their E-Commerce and Shopping Cart Software. As of this post, their service agreements state that their hosting is NOT PCI compliant: The Services are not intended to provide a PCI (Payment Card Industry) compliant environment and therefore should not be considered as one.. Even their dedicated hosting servers are the same way: The Dedicated Services are not intended to provide a PCI (Payment Card Industry) compliant environment and therefore should not be considered as one.

The basic qualifications of PCI compliance are detailed here, and as follows:

Build and Maintain a Secure Network
Requirement 1: Install and maintain a firewall configuration to protect cardholder data
Requirement 2: Do not use vendor-supplied defaults for system passwords and other security parameters

Protect Cardholder Data
Requirement 3: Protect stored cardholder data
Requirement 4: Encrypt transmission of cardholder data across open, public networks

Maintain a Vulnerability Management Program
Requirement 5: Use and regularly update anti-virus software
Requirement 6: Develop and maintain secure systems and applications

Implement Strong Access Control Measures
Requirement 7: Restrict access to cardholder data by business need-to-know
Requirement 8: Assign a unique ID to each person with computer access
Requirement 9: Restrict physical access to cardholder data

Regularly Monitor and Test Networks
Requirement 10: Track and monitor all access to network resources and cardholder data
Requirement 11: Regularly test security systems and processes

Maintain an Information Security Policy
Requirement 12: Maintain a policy that addresses information security

There is a self assessment questionnaire available at the PCI website. All internet merchants will most likely qualify as option D. Take a read through the requirements. The form gives you step by step instructions on what needs to be done to ensure compliance.

It may also help to have a third party verify your PCI compliance status. This not only gives your visitors peace of mind, it can give you peace of mind as well, ensuring your site is always compliant. For as little as $79 a year C-O-M-O-D-O offers PCI compliance testing. Two other well known services available are Control Scan and McAfee (previously Scan Alert).

Depending on your volume of business, these scans can be required by the major credit card companies.

posted under Random | No Comments »

Search Engines Webmaster Support

February8

According to research by Hitwise, as of December 2008, the top four search engines are (in order) Google (72.07%), Yahoo (17.79%), MSN (4.10%) and then Ask (3.15%). Each of these search engines provides a method for you to track how your site is doing in their results.

  1. The first step is to make sure you have a robots.txt file and that it allows search engines to index your site.
  2. The next step is to setup a sitemap, based on the sitemap protocol. This gives the major search engines a list of what pages you would like indexed and how you would like them to be indexed.

With those two steps complete the major search engines will be able to better find and index your content. To track how your site’s indexing is going for each engine, the steps are pretty much the same. Create a login, verify you own the site through either creating a file on your site or updating a meta tag, submitting a sitemap, and then tracking results:

  • Google: Google.com by far the most popular search engine, provides Google Webmaster Tools. I like Google’s tools the best, as it not only provides statistics, but lets you view how individual pages, if there are any indexing errors, and allows you to diagnose your site. I think it provides the most information and I use it in combination with Google Analytics to track my traffic results.
  • Yahoo: Yahoo.com provides Yahoo Site Explorer for its users to track their sites indexing. This tool provides a method to submit a sitemap and see your site indexing statistics but not much else. I still have an account registered to track how I am doing statistically.
  • MSN: MSN.com provides Webmaster Tools to access indexing information. They provide a cross between Google and Yahoo tools as far as depth of information goes. While they have more information than just the statistics offered by Yahoo, it is not to par with Google’s offering.
  • Ask: Ask.com does not provide a webmaster login but states that simply creating the appropriate robots.txt and sitemap files are all you need to do to help your listings. More information about Ask.com sitemap submission here.

Using these tools, why it will not increase your search ranking, will help you see how you are doing and diagnose areas of improvement. They are great tools to see how different SEO techniques are improving how your site is indexed.

posted under Random | No Comments »

Google Page Rank Checker

February7

The method I was using is no longer working. Google returns a “Forbidden” message now.

It was previously using the return from this link: http://www.google.com/search?client=navclient-auto&ch=6488814576&features=Rank&q=info:www.matthewstevenkelly.com

What is your websites Google Page Rank? A sites page rank shows how important Google says it is for search results. The higher the page rank, the higher and more likely the page will display in a search. Additionally, every page has its own individual page rank. With a good internal site linking structure when one page obtains a higher page rank it will pass it on to all other pages in your site. You should check your home page as well as many different pages throughout your site to see what your overall page ranking is.

Wikipedia actually has a great overly technical description of the page rank algorithm: http://en.wikipedia.org/wiki/PageRank

Website URL:
posted under Random | No Comments »
« Older EntriesNewer Entries »