Category Archives: Tech

php-header

Automate FTP File Transfers with PHP

This is a follow up to my post Useful FTP Bash Script. In that script I posted a bash script that would connect to a remote FTP server, retrieve remote files, delete remote files and disconnect. I was able to simplify that script using PHP.

Keep in mind that this script will delete the remote file, so if that is not your intent, you will need to change it by removing lines 54 – 60.

<?php

// This script will:
// 1. connect to an ftp server in the specified directory ($destdir)
// 2. Download all files in the $destdir directory to the $localdir directory
// 3. If download was successful, delete the file from $destdir

$now = date("Y-m-d H:i:s");
$nowdate = date("Y-m-d");
$thelogfilename = "/path/to/logging/FTPLOGFILE-" . $nowdate . ".txt";

if ( !file_exists($thelogfilename)){
		touch ($thelogfilename);
	}

$thelogfile = fopen($thelogfilename,'a');

fwrite($thelogfile,"*********** " . BASENAME(__FILE__) . " START AT: " . $now . " ***********\n");

// Initialise the connection parameters  
$ftp_server = "ftp.domain.net";  
$ftp_username = "myusername";  
$ftp_password = "mypass";  


// Directory to retrieve ALL files from
$destdir = "/";

// Directory to store all files to
$localdir = "/path/to/save/documents/";

// ====== SHOULDN'T NEED TO ALTER BELOW UNLESS PROCEDURE NEEDS TO BE CHANGED ====== //
// Create an FTP connection  
$conn = ftp_connect($ftp_server);  

// Login to FTP account using username and password  
if (@ftp_login($conn, $ftp_username, $ftp_password)) {
fwrite($thelogfile,"Connected as $ftp_username@$ftp_server\n");

// Get the contents of the current directory  
// Change the second parameter if wanting a subdirectories contents  
$files = ftp_nlist($conn, $destdir);  

// Loop through $files  
foreach ($files as $file)
{

	//Download section
	if (ftp_get($conn, $localdir . BASENAME($file), $file, FTP_BINARY))
	{

		fwrite($thelogfile,$file . " downloaded correctly\n");
		
		// We can delete the server file since the ftp_get was successful
		if (ftp_delete($conn, $file)) {
		fwrite($thelogfile,$file . " deleted successful\n");

		} else {
		fwrite($thelogfile,"could not delete " . $file . "\n");
		}

	} else {
		fwrite($thelogfile,$file . "NOT downloaded correctly\n");
	}

}

} else {
	fwrite($thelogfile,"Couldn't connect as $ftp_username\n");
}

$endnow = date("Y-m-d H:i:s");
fwrite($thelogfile,"*********** " . BASENAME(__FILE__) . " END AT: " . $endnow . " *************\n\n");
fclose($thelogfile);

// close the connection
ftp_close($conn); 

?>

New Site Goes Live – Screens.com Features Licensed Art Printed on Room Dividers and Wall Art

My company and I have been working on screens.com for a few months and we just recently launched it. We worked out licensing agreements with carefully selected licensors and are proud to represent them in our collection of Printed Room Dividers and Wall Art. Continue reading

WP-Property WordPress Plugin

I have been playing around with the WP-Property plugin on my maine beach rentals website. The website was created to list my mother-in-laws beach house to help book summer rentals.

The plugin is very robust and customizable. My favorite features I’ve uncovered so far are:

- Variety of sidebar widgets
– Google maps integration and address validation
– Property search. I only have one listing, but can see the power of the search feature.

The plugin is replacing a Real Estate theme that had built in property management. But the wp-property plugin is much more intuitive and flexible.

Audio Hijack Pro on Ustream with Skype Cohost

I have started to use Audio Hijack Pro as a way to mix all the different sounds together for the weekly TPT Live broadcast. I had been using a hardware mixer but it was proving difficult to get the sounds I wanted in the broadcast while omitting the sounds I didn’t.

I found a great video tutorial called How To Podcast on a Mac With Skype by biznickman and it really got me going down the right path. The only thing missing was allowing the sounds I wanted in the broadcast to go through Skype so that my cohost Paul could hear it. Using the tutorial in that video, the Music, pre-recorded broadcasts and the soundboard were set to go straight to the channel we would push up to ustream but the Skype callers would not be able to hear them.

So here is what I have come up with to rectify that:

Audio Hijack Pro

Soundflower (16ch)
– Input: Soundflower (16ch)
– Output: Silence Output
– Effects: None

iTunes
– Effects: Aux Device Output to Soundflower (2ch)

Logitech USB Headset
– Input: Logitech USB Headset
– Output: Soundflower (2ch)
– Effects: Bass (3.96) and Treble (0.24)
– Effects: Reverb (Wet/Dry: 0, Room Size: 0, Damping: 0.825)

Safari
– Effects: Aux Device Output to Soundflower (2ch)

Skype
– Input (Advanced): MegaMix Mode :: Play outputs through “Both Channels”; Play Inputs through “Mute”
– Effects: Aux Device Output to Soundflower (16ch)

Soundboard
– Effects: Aux Device Output to Soundflower (2ch)

Soundflower (2ch)
– Input: Soundflower (2ch)
– Output: Soundflower (16ch)

Skype

Audio Output: Logitech USB Headset
Audio Input: Soundflower (2ch)
Ringing: Logitech USB Headset

Virtual Audio Connector + Ustream + Skype

I am trying to broadcast live on Ustream using the Ustream Producer with callins from Skype. I also would like to play music/audio/mp3’s and feed the audio to Ustream producer and to Skype. The solution below seems to work, but I was hoping there was a way to do it without so many VAC Audio Repeaters.

Here is what I have come up with:

Note: The lines are Virtual Audio Connector lines.

Windows Media Player: Output to “Line 1″
Skype Mic: “Line 2″
Skype Spkrs: “Line 3″

Repeaters: 6 total, yikes!
A) Line 1 –> Line 3
B) Headset Mic –> Line 2
C) Line 1 –> Headset Earphone
D) Line 3 –> Headset Earphone
E) Line 3 –> Line 4
F) Line 2 –> Line 4

Ustream Producer: Input from Line 4

I’m Officially a WordPress Plugin Developer

UPDATE: I have stopped development on this plugin due to the fact that the Twitter Poker Tour league disbanded some time ago. I am posting the module here to be downloaded and used.

Standard Disclaimer:
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Download the WP-PokerLeague Plugin

Continue reading

Generate 301 Redirects in Excel

If you are not using Google Webmaster Tools then stop reading now, sign up and come back, we’ll wait. OK now, say we are analyzing the Diagnostics > Web Crawl section in Google Webmaster Tools and notice that there are some Not Found errors. One way to fix these errors is to redirect them in .htaccess using a 301 Redirect.

Here is a handy spreadsheet (301-generator.xls) that I use to create my redirects using the data I download from Webmaster Tools. If you don’t like opening spreadsheets from an unknown blogger, then scroll down to the bottom of this post for the formula! 

How to use it

  1. Download the Not Found errors by clicking Download this table in Webmaster Tools
  2. Copy the non-domain part of the bad URL in first column (URL) of the spreadsheet downloaded from Google Webmaster Tools. Paste it into the next open field in column A on the 301-Generator spreadsheet. The non-domain part is everything after the http://www.yourdomain.com part of the URL field.
  3. Paste or Type in the new destination (in FQDN or Fully Qualified Domain Name format) into column B on the same row as the bad URL in step 2 above.
  4. The 301 redirect syntax will populate column C in the same row. You can paste that into your .htaccess file.
  5. All requests for the bad URL will now be redirected to the new destination.

Important

  • Always make a backup of your .htaccess file before making modifications. 
  • Always test the results of your changes, you may inadvertently redirect traffic from your homepage or otherwise make your site inaccessible.
  • If you are using WordPress you should use the Redirection plugin instead of .htaccess 

Excel Formula

If you just want the formula, and not the spreadsheet, read on:

  • In column A1 type Bad URL
  • In column B1 type NEW URL
  • In column C1 type 301 Syntax for htaccess
  • In column C2 enter the formula
    • =”redirect 301 ” & A2 & ” ” & B2
  • Copy that formula to all cells in column C as needed.

Cure for the Cluttered Desktop

I used to have a chronically messy desktop. Fed up with all the clutter I asked myself what the point of the Desktop was. For me it was to hold files and application shortcuts. Well, if I can’t keep it clean, can’t I just hide it and have it still serve it’s purpose? 

What I did was (I’m running Windows XP):

  1. Right clicked the desktop
  2. Clicked Arrange Icons
  3. Deselected Show Desktop Items.

Voila! Clean desktop. But have I lost any functionality?

Access to Desktop Files?

I put a shortcut to the Desktop folder in my quick launch bar so I can click it to see my desktop as a folder. So I still have direct access to desktop files.

Access to Desktop Application Icons

I installed Launchy to quick launch any apps so I don’t miss having desktop app icons. I hit ALT-Space and start typing the app I want.

Hope this helps keep your desktop clean!

WordPress Plugins for a Better Life

Well, at least they make *my* life better, and hopefully those of my readers! I use a lot of WordPress plug ins for SEO, Event Management, Web Analytics, Communications, etc so I wanted to just list them out for all to see.

Here are all the plug ins in use over at Complete Poker Rules:

  • AdSense Manager
    • For managing Adsense Ads throughout the site
  • Akismet
    • Nearly eliminates the spam comments I receive. Some false positives but that may just be the nature of running a Poker Blog.
  • Amazon Reloaded for WordPress
    • Allows you to search Amazon from the post edit screen and insert the product image or text link complete with Amazon Associate ID.
       
  • cforms
    • Contact forms with an excellent admin interface and highly flexible styling. 
  • FeedBurner FeedSmith
    • Used in conjunction with FeedBurner to manage your RSS subscriptions.
  • Google XML Sitemaps
    • Creates and keeps up to date you sitemap.xml file for assisting search engines with the structure and pages of your site.
  • Headspace2
    • Make your WordPress site SEO friendly with this very powerful tool.
  • Highlight Author Comments
    • Call attention to the comments that you leave as admin so they stick out from the rest.
       
  • More Link Modifier
    • Changes the behavior of the ‘More’ link in WordPress posts. You can customize the copy that is displayed as well as disabling the “Jump To” behavior of the More anchor link when clicked.
       
  • Redirection
    • Manage the redirection of deleted posts, etc without needing to edit your .htaccess file. Also great for 301 redirecting domain.com to www.domain.com or vice-versa.
  • Robots Meta
    • Manage the index nature of your site. Some SEO expert say that duplicating content within your own site dilutes the link juice you would otherwise get from a single instance of a post. Also good for noindexing your WordPress Login page among others.
  • RSS Footer
    • Append a footer to the end of each post in your RSS feed. This is especially key if you have sites that scrape your content, it will include a link back to your site and you can at least benefit from the juice!
  • Search Excerpt
    • Enhance the on site search experience for your readers with keyword highlighting and relevancy sorting. 
  • Sociable
    • Allow your readers to share your content on social networks.
       
  • Theme Tester
    • Allows you to test out a new theme without disrupting service to your visitors. 
  • Ultimate Google Analytics
    • Plugin to allow you to include your Google Analytics tracking code on all your pages. Also allows you to set which user level should the tracking code be displayed for. For instance, you can disable to tracking code for admin users to avoid inflating your tracking numbers.
  • WordPress Database Backup
    • Schedule the backup of your WordPress database tables to file or email.
  • WordPress Related Posts
    • Include links to related posts based on tagging. great for deep linking content.
       
  • WP-Polls
    • Include a poll in your post. Highly customizable: user contributed answers, multiple selection answers, etc. 
  • WP-PostRatings
    • Adds a ratings system to each post. 
  • WP-Table
    • Insert a table in your posts or pages for a better handle on structuring your content without CSS.
       
  • WPListcal
    • Create events and display them in any post, page or template. Flexible scheduling system to show x days out, only current and future events, etc.