Written by Tyler Ingram on Oct 17th, 2008
I was looking over my index page and wanted to modify WordPress' pre-built the_excerpt() function which limits the amount of words displayed for a particular post on my front page without cutting words in half. The draw back from using the built-in the_excerpt() function is that you can not modify how it works, there is not option to give the function arguments such as how many words to display.
So how would I go about creating a function to display the amount of words I want in the way I want it? Well I had to take a look at how I display the content of the front page. This isn't typical of most blogs but I run custom MySQL query and then loop through each post. Sure this sounds like the WordPress' Loop but doing it this way allows me to customize the information in the way I want it.
So … Continue Reading »
Written by Tyler Ingram on Jun 3rd, 2008
One of the tasks I have been looking into at work is the ability to use PHP to authenticate users against a Windows Active Directory (AD). After searching around on the internet I did manage to find a great little tutorial that helped explain the steps in searching the AD for a particular user and then if they existed to authenticate them with the submitted credentials.
While writing this post I have noticed that the blog that tutorial was written on is currently undergoing some transformations and I won't be able to link to it yet. It was a fairly good tutorial and it allowed me to easily access our company's AD with using the proper authentication to look up user accounts and authenticate them properly.
The next task that was to create some sort of structured access system based on the groups the user belonged too. The code below assumes you … Continue Reading »
Written by Tyler Ingram on Apr 25th, 2008
For some strange reason one of my php scripts at work stopped functioning and was throwing a fatal error complaining that the json_encode() function was undefined. I thought this was a bit strange since I could of sworn the previous week it was working fine. I am using the json_encode() function to allow javascript to properly parse data that it requests via AJAX. It allows the parsing of database information in a more efficient manner than other methods I have seen.
It seems that the version of PHP previous to 5.2 do not have the json_encode() function available and this can be a bit of a pain when working with ajax scripts that request information from a MySQL database. I hopefully have found a quick solution by recreating the proper output for those who are running PHP versions 5.1 and older.
$qry = mysql_query("SELECT * FROM blah");
$results = mysql_fetch_array($qry);
$json = "{";
foreach ($results … Continue Reading »