By brian, 2 days ago

Freelance Programming Feedback

This post contains comments from people whom I've done custom work for in the WordPress, vBulletin, and vBSEO worlds. I've asked those that I've worked with before to leave a few words here about my quality of work.

If I've done work for you, please leave a few words so others who are considering working with me know that I'm legit and can deliver as promised.

Thanks

By brian, 2 months and 15 days ago

Wordpress Permalinks on IIS with ISAPI_Rewrite

I've run WordPress here on my CentOS box for nearly 4 years and am quite familiar with the software. Recently, I had a client on a Windows system request a blog be added to their web store. Their webstore is written in ASP and runs on windows. They wanted to stay on the same domain for SEO purposes, (thus site.com/blog/ instead of blog.site.com or a new .com). Without the subdomain or new IP, there's no way to change DNS for a subdirectory to a different server. This meant I had to get it working on IIS.

Native installations for apache tend not to port well (or perhaps, easily) over to windows/IIS. Thankfully, ISAPI3 from HeliconTech.com supports .htaccess files and makes the job a little easier. Wordpress works fine on windows/IIS until you want nice permalinks.

After MUCH searching, testing, and error log analysis, I've got a working solution for Windows Server 2003 with ISAPI_Rewrite 3.1.x, running php 5.2.x and mysql 5.0.x community.

  1. index.php should be set up in IIS as a default document (same place you find default.asp, index.htm, etc)
  2. edit wp-settings.php
    Find:
    1. <?php

    at the very top of the file.

    Replace with:

    1. <?php
    2. //*****************************
    3. //    IIS FIX
    4. //
    5. $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
    6. //*****************************
  3. create the following htaccess file with the Helicon Manager:
    1. RewriteEngine On
    2.  
    3. #RewriteBase /
    4.  
    5. RewriteCond %{REQUEST_FILENAME} -f [OR]
    6. RewriteCond %{REQUEST_FILENAME} -d
    7. RewriteRule . - [L]
    8. RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    9. RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    10. RewriteRule . /blog/index.php [L]

    • Note: You may need to alter the RewriteBase or the last rule to your specific location. In my particular case, I was installed on domain.com/blog/

From here, you can edit your permalink structure as you normally would. If the default options has index.php/ as part of the rule, you can remove that.

By Brian, 8 months and 23 days ago

Rand() isn't Random

If you use Microsoft SQL 2000, you've probably at one point had to pull random results. The built in rand() function simply doesn't work. It gives you a random value the first time, and every time after it is the same it seems.

I found a new way to do this today after 20 pages of searching, so hopefully this will help someone else.

ORDER BY newid()

yup, it's that simple.

  1. SELECT
  2.   TOP 2
  3.     field1
  4.    ,field2
  5. FROM
  6.   TABLE
  7. WHERE
  8.   field1 = 1
  9. ORDER BY
  10.   newid()

To be noted, this will put a full table scan in place before it selects the top 2, so keep performance in mind.

By Brian, 9 months and 12 days ago

Intro to CURL with PHP

CURL is a command-line style function to send data via a URL. WikiPedia has a more detailed article on what it is and does.

Preface - your php installation on your server must be CURL-enabled. You can download the CURL package for free. This article assumes your server is ready to go.

While CURL is not an alternative to AJAX, it can be used in similar situations where you need to send data out somewhere without the user having to go there. In it's most basic operation, you have some data to send out to a script.

We need a a simple function to handle our data, a page to process said data, and a source page where the function is called from.

The call page is simple. Something as simple as:

  1. <?php
  2. print sendCURL($var1, $var2, $var3)
  3. ?>

where $var1 -3 are predefined, or even hard-coded strings will suffice for basic testing. This php block sets us up to print the output of our function:

  1. function sendCURL($var1, $var2, $var3, $referrer="") {
  2.   $mycurl = curl_init("http://domain.com/curl_processor_page.php");
  3.   
  4.   $fields = array(
  5.     "var1" => $var1,
  6.     "var2" => $var2,
  7.     "var3" => $var3
  8.   );
  9.  
  10.   $curlagent = array(
  11.     "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
  12.   );
  13.  
  14.   curl_setopt($mycurl, CURLOPT_POST, 1);
  15.   curl_setopt($mycurl, CURLOPT_HEADER, 0);
  16.   curl_setopt($mycurl, CURLOPT_NOBODY, 0);
  17.   curl_setopt($mycurl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
  18.   curl_setopt($mycurl, CURLOPT_REFERER, $referer);
  19.   curl_setopt($mycurl, CURLOPT_RETURNTRANSFER, 1);
  20.   curl_setopt($mycurl, CURLOPT_SSL_VERIFYPEER, FALSE);
  21.   curl_setopt($mycurl, CURLOPT_HTTPHEADER, $curlagent);
  22.   curl_setopt($mycurl, CURLOPT_POSTFIELDS, $fields);
  23.  
  24.   $response = curl_exec($mycurl);
  25.   curl_close ($mycurl);
  26.   
  27.   return $response;
  28. }

This function is your basic CURL request. Setting the variables into an array to pass, and setting headers and Options within CURL on how to process it. The only real change you will need to make to this function are your variables in the array and your URL that you wish to send it to.

The curl_processor_page.php is no different than any other php page that can handle incoming $_REQUEST parameters. Those var's need to be set up in the function that the page is looking for, perhaps a username, password, and a realname.

What that script does is entirely up to you. I won't post an example, because I don't want anyone to think that you can only do one method with this function set.

You could have the response be ANYTHING that gets returned from the processor page. A remote login, a simple welcome screen, or even creating accounts (how do you think those auto MySpace friend adder bots work?!)

A useful tool when playing with CURL is the LiveHTTP Headers plugin for FireFox. This plugin let's you see what's getting sent via HTTP AS it happens. It's a real-time watchdog and is very useful for debugging CURL requests to see where it's bombing.

Happy CURLing :)

By Brian, 1 year ago

Yahoo Releases YSlow

YSlow is an add-on for the popular FireBug add-on for the popular browser, FireFox. Confused? :D

It has neat tools to help you to improve your site's load times, and rates you accordingly. I scored an F on my blog. haha

Check it out: YSlow

By Brian, 1 year ago

BrainBench Certifications

I got an email tonight to take some free online tests. I took a couple, and scored pretty high in many areas, as I expected to, but also got stumped on a couple of the performance related issues (as I rarely deal with them). It's fun to see how you compare to others who have taken the same test.

You can view my complete transcript here:

Brain Bench Transcript

HTML Programmer Cert

DB Cert

apache config

By Brian, 1 year and 1 month ago

Getting a Global Array to work in a Function

I recently spent a lot of time debugging this code i was working on for what I thought would be a simple onchange event.

The Issue:
I have sizes and colors, but not all sizes are available in all colors, so onchange of the color select box, i need to load the correct size options select box.

Between a lot of back-end manipulation, I was able to create my front-end JS arrays of colors with the sizes that are available. I ran into the issue that my passed in variable to the function was becoming the array, instead of calling the array.

For example, If I passed in «BLK» for Black, I was getting:

  1. array[0] =>B
  2. array[1] =>L
  3. array[2] =>K
  4. array[N] => undefined

where the Nth options looped through undefined until my for loop for the options of my color box's length had been reached.

The Solution:
After scratching my head for hours and trying 232132 things, It turns out all I needed to do was to use the eval() function to evaluate my variable first, instead of treating it like a literal string.

Here's the completed working source:

  1.  
  2. function popsizes(colorcode) {
  3.  
  4.    var BLK= ["2XL","3XL","4XL","5XL","LG","MD","SM","XL","XS"];
  5.    var WH= ["LG","MD"];
  6.    // etc, many more color arrays
  7.  
  8.    elem = document.getElementById("selcolor");
  9.    sizelist = eval(colorcode);
  10.  
  11.    for (i=0; i<elem .options.length; i++) {
  12.   document.getElementById("selsize").options[i] = new Option(sizelist[i]);
  13.    }
  14. }
  15.  

That script is powered by the onchange event from the form:

  1. <tr>
  2.   <td>
  3.     <select "id="selcolor" name="color" onchange="popsizes(this.options[this.selectedIndex].value);">
  4.       <option value="WH">White</option>
  5.       <option value="BLK">Black</option>
  6.       <option value=""> Many more colors, etc .... </option>
  7.     </select>
  8.   </td>
  9.   <td>
  10.     <select "id="selsize" name="size">
  11.       <option value="">Select Color First</option>
  12.     </select>
  13.   </td>
  14. </tr>

By Brian, 1 year and 7 months ago

Scripting Around Poor Table Design

We've all seen it. Some 3rd party database you've inherited from someone else was simply never designed with scalability and portability in mind. There's no hope to change it, as it will break the original design and thus the original application that it is supporting.

Keep reading →

By Brian, 1 year and 7 months ago

Quick SQL Date Functions and Queries

It's easy to grab the date from a field in a database so long as you saved a timestamp field along with your data row. However, there are often times in developing stored procedures and advanced queries where one needs to look up events in the future, or past based on some other reference point from either the data at hand, or an arbitrary date, such as in a calendar.

Keep reading →

By Brian, 1 year and 7 months ago

RFC-32 Date Formatting with Classic ASP

Tonight I was working on an RSS package for a client of mine. Having dealt with RSS feeds in the past, I figured it wouldn't be a big deal. However, my experience with them has always been on the 'receiving' end of it, imploding out the <item></item>'s and making sense of the xml.

For the most part, setting up the RSS2.0 feed was pretty straight forward. The one thing that took a little time to manipulate was the RFC-32 date/time formatting that RSS Feeds require in order to validate. And we all know how important validation is :)

Keep reading →

← Previous 01 02 Next →