Display Featured Links Randomly Using PHP

Posted on June 29, 2009. Filed under: Main, Tech Tips, Web Development, Work Links | Tags: , , , , , , |

I had a request to add a "Link of the Day" feature to one of the pages on the Law-related Education pages of the OBA Web site using what we currently have in place.  I’m sure there are widgets out there already that will do this for me, and it may even be built into whatever CMS we deploy next, but I wanted to learn a bit so I decided to implement it on our current site.  I don’t know much about PHP, but I learned to code in VB.NET and C++, so I can learn enough as I go to make things work.

With the help of The Google, I was able to piece together a little bit of code that reads from a CSV file into an array, then randomly displays a link from within that array on each page load, so that a new link is loaded on each visit.

The original code has appeared in several forms across the Internet already, so if it’s yours, please let me know so I can credit you.  I’ve made some slight adjustments to fit my needs.

  1: <?php
  2: function makeClickableLinks($text) {
  4:   $text = eregi_replace('(((f|ht){1}(tp|tps)://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
  5:     '\\1', $text);
  6:   $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
  7:     '\\1\\2', $text);
  8:   $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})',
  9:     '\\1', $text);
 11: return $text;
 13: } // end function
 16: function displayLink(){
 18: $fp = fopen("your-file.csv", "r");
 19: while (!feof ($fp)) {
 20: $contents[] = explode(",", fgets($fp, 512));
 21: }
 22: fclose ($fp);
 24: do {
 25: 	$x = rand(0, count($contents)-1);
 26: 		} while ($contents[$x] == '0');
 28: // displays link title above clickable URL
 29: echo $contents[$x][0] . "<br />\n" . makeClickableLinks($contents[$x][1]) . "<br />\n";
 31: // displays link title as clickable link
 32: echo '<a href="' . $contents[$x][1] . '" rel="nofollow">' . $contents[$x][0] . '</a>';
 34: } // end function
 36: ?>
 37: <body>
 38: <?php displayLink(); ?>
 39: </body>

Click to view a working sample of this page here.

WordPress Tags: Display,Links,Link,Education,code,Google,Internet,text,Click,Development,adjustments,makeClickableLinks,eregi_replace,displayLink,clickable

Read Full Post | Make a Comment ( 1 so far )

Bonjour, mDNS Responder!

Posted on June 17, 2009. Filed under: Apple, Main, Software, Tech support | Tags: , , , , |

I’m tired of iTunes.  Listening to streaming radio is frustrating, as it stops to buffer often and brings the window to the front every time, which interrupts what I’m working on.  I can just listen to the station straight from the browser, thankyouverymuch.  It’s a hog when it’s running, Apple assumes I have an iWhatever and tries to force apps down my throat every time I start up.  The only good thing with it was that I can download movies to watch on demand.  Oh, and it’s a pretty decent podcaster, but that can be handled with other, nicer software.

So I removed iTunes, but that pesky Bonjour remained to laugh at me, as if to say “you can’t leave Apple behind, we’re the silent Google!”.  Fun.  Thanks to the wonderful Interweb, here’s how I got rid of it once and for all:

How To Uninstall or Remove Bonjour mDNSResponder.exe

Hope this helps!

WordPress Tags: Bonjour,Responder,Apple,Google,Interweb,Uninstall,Remove,goodbye,iTunes,mDNSResponder

Read Full Post | Make a Comment ( None so far )

Don’t Forget to Clean Your Code!

Posted on June 17, 2009. Filed under: Main, Microsoft, Tech Tips, Web Development | Tags: , , , , , |

I recently was asked to update a Web page with a rather long list of names, which were provided in a Word document.  I use a combination of Dreamweaver and Expression Web, because they both have good tools for stripping out problematic HTML from Word, but today they weren’t much help.

This particular document had a table (of sorts) built into it, which listed names and cities, but after a good ol’

copy and paste, I found that things didn’t quite line up.  Upon closer review, I found that the “table” was actually made up of tabs and spaces.  While this worked in Word, it made a horrible mess for the Web.  Just doing a copy and paste job created spaces (technically non-breaking spaces — “nbsp”) that seemed like empty space, but actually take up quite a lot.  In fact, these spaces made the page 322kb!  Most of the larger pages on the site were around 20-25kb, so I took another look at things.

In this case, I decided not to go with a table for the little bit of text that could fit in, instead going with the city name in parentheses after the person’s name.  After removing all the nbsp’s from the code, I was able to shrink the page to 32kb – a 90% reduction in page size!  That means the page will load in just over 1 second, instead of over 12 from before.

So, to recap:

  1. Copy and paste doesn’t work as expected with the web, so be prepared to clean up your code a bit.
  2. Check for spaces that don’t belong, particularly the “ ” – they take up more space than just hitting the spacebar does.
  3. Use a tool like Firebug for Firefox, or the built-in tools in several other browsers (IE8, Safari 4, Chrome) to test your page for load times and see how you can improve them.

Windows Live Tags: Code,Word,Dreamweaver,Expression,tools,HTML,spaces,text,reduction,size,Copy,tool,Firebug,Firefox,Safari,Chrome,nbsp

WordPress Tags: Code,Word,Dreamweaver,Expression,tools,HTML,spaces,text,reduction,size,Copy,tool,Firebug,Firefox,Safari,Chrome,nbsp

Read Full Post | Make a Comment ( None so far )

If you need to track your mileage for work, here’s an easy tool for you

Posted on February 20, 2009. Filed under: Main, Software, Tech Tips | Tags: , , , , |


Many small business owners and consultants spend time on the road in their personal vehicles traveling to clients and work sites.  We know those miles need to be tracked for tax purposes (money back from the IRS is a good thing), but it’s often a pain to do.  That’s where the TripBook comes into play.


Read Full Post | Make a Comment ( None so far )

Tweet, Tweet

Posted on February 10, 2009. Filed under: Main |

New, exciting things happening here in OKC.  You can follow Estes Tech on twitter for updates to the blog and news items.

Follow us at for the latest happenings!

Read Full Post | Make a Comment ( None so far )

"Could not Open Install.Log File!" Problem Solved!!

Posted on February 3, 2009. Filed under: Main, Software, Tech support, Tech Tips | Tags: , , , , , |

I recently installed some backup software for testing and decided to remove the ones I wasn’t interested in anymore.  My hard drive has had some corruption issues, which means I’m losing programs, but don’t know it until I try to start them and something fails.  This, I think, is what happened with today’s problem.


Read Full Post | Make a Comment ( 1 so far )

Are your programs up to date?

Posted on January 27, 2009. Filed under: Main, Software, Tech support, Tech Tips | Tags: , , , , |

I often find myself installing software for a specific purpose (testing, maintenance, etc.) and not using it regularly, which means it’s probably outdated when I need to use it again.  Sometimes it’s a game that is still being developed (like Frets on Fire, a free, great Guitar Hero style game for your PC) that gets updates pretty often.  When I go to use it after a while, I have to take the time to update it to the latest release before I can use it, which is kind of a pain.

Fortunately, there are a couple of programs out there that minimize the hassle of updating software.  While they don’t automatically update the programs that are installed on your machine, they make it easier for you to do it when you have some free time.  Let’s take a look at a couple of them.


Read Full Post | Make a Comment ( None so far )

Cross-posting from one blog to another

Posted on September 27, 2008. Filed under: Main |

I’m testing out a new plug-in for Windows Live Writer which lets me write one blog entry and post it to both of my blogs.  This should show up on both WordPress and Windows Live Spaces.

Read Full Post | Make a Comment ( None so far )

Making Excel Charts Even Easier

Posted on August 31, 2008. Filed under: Main, Microsoft, Software, Tech Tips |

If you’re like me, you crunch numbers.  It may be sales, inventory, finances, or any number of things.  You probably use Microsoft Excel; maybe you even need a chart now and then but avoid it because it’s just a bit too crazy. 

If this describes you (even a little), check out the Chart Advisor from Office Labs.  These folks have been putting out some good Add-Ins that run within various Office programs.  This one evaluates your data, creates a chart, and automatically puts it in your spreadsheet.  I’ve tried it and am immensely impressed with it.

Here’s the official description:

Chart Advisor is a prototype that provides an alternate approach for creating charts in Excel 2007. This add-in uses an advanced rules engine to scan your data and, based on predefined rules, displays charts according to score. Top scoring charts are available for you to preview, tweak, and insert into your Excel worksheet.


Read Full Post | Make a Comment ( None so far )

So what version is it?

Posted on July 18, 2008. Filed under: Internet, Main, Software, Tech support |

I recently upgraded to Firefox 3, and have been happy with it.  Today I found out that there has been an update issued, which puts it at version 3.0.1.  For some reason, firefoxversionafter the update, I was presented with this page (right) that says I’m “now running Firefox”, even though the About dialog box clearly shows 3.0.1. 

I’ve also noticed that the Add-ons site shows several add-ons that won’t work because I don’t have a high enough version installed.

Anyone else having problems with the “latest” version of Firefox?

Read Full Post | Make a Comment ( None so far )

« Previous Entries
  • July 2018
    S M T W T F S
    « Jun    
  • Meta

  • Categories

  • delicious tags

  • Blog Stats

    • 10,802 visits

Liked it here?
Why not try sites on the blogroll...