How to Start sshd On Plesk

I had a client machine reboot today and ssh wasn’t configured to come up on boot. This was a CentOS Plesk machine at my least favorite hosting provider, Media Temple. Secure shell isn’t mentioned in the services section in Plesk, and Media Temple doesn’t have a remote console feature. So in order to avoid submitting a ticket and waiting for Media Temple’s slow support, I managed to restart sshd using Plesk’s web interface to cron (Scheduled Tasks) to start it. Here’s what I did:

  • Got the current server time (it might not be in your timezone) by going to Server > Time
  • Went to Server > Scheduled Tasks and created a new scheduled task 2 minutes ahead of the current server time. The task should run /etc/init.d/sshd start.
  • Wait.

Hopefully within 2 minutes sshd is started. Don’t forget to remove the scheduled task, and ensure that sshd is configured to start on boot (chkconfig –levels 345 sshd start or whatever your distro uses.) Honestly I think Media Temple should have a backend console similar to how other VPS providers such as Slice and Linode do it. You’re paying enough.

Link Log Matcher WordPress Plugin

Power Indexer

Power Indexer is a plugin that gets inbound links indexed by search engines within hours rather than weeks. Even if you have a lot of inbound links to your site, if the search engines don’t know about them, they’re worthless. Power Indexer is simple but effective at making your link building efforts count for more!

Benefits:

  • Increase your rankings by getting pages that contain inbound links indexed faster.
  • Enable the plugin and it starts working immediately.
  • Uses your visitor’s IP address, not your server!
  • Maximum pings per link is configurable.
  • Works with caching plugins!

Power Indexer can save you time and money by getting those precious inbound links counting now instead of weeks from now!

FAQ

How does it work?

Power Indexer uses a small JavaScript snippet that ensures pages linking to your site are indexed faster, helping your link building be more effective and increasing your rankings! You control how many times an incoming link gets pinged and can see stats on incoming links from the Power Indexer options page.

There is a secondary option that uses a hardcoded iframe. This is for cases where you’re finding users coming to your site with JavaScript disabled. It is incompatible with caching plugins, however.

Power Indexer also rate-limits the pings to occur no more than once every 30 minutes. It does this in a cache-friendly way by using AJAX to find out if a link should be pinged or not.

What versions of WordPress does it work on?

I’ve successfully tested it on WordPress 2.5 to 3.0.

Does this plugin help me build links?

No, but it increases your link building ability! If you get a link to your site
but the page its on is not indexed, it won’t help you rank. Power Indexer helps make the links you DO build count!

I’m using a caching plugin – will it work?

Yes, if you use the JavaScript (default) option.

What’s the iframe option for?

It’s there if you’d prefer not running JavaScript on your site or if you know a lot of your users don’t have JavaScript enabled. Note that the iframe option is NOT compatible with caching plugins.

How do I limit the number of pings that are sent?

Settings > Power Indexer. You can change the maximum number of times an incoming link is pinged. The default is 10.

How does the rate limiting work?

By default Power Indexer limits pings to no less than 30 minutes between. If you want to change this, edit the power_indexer.php file and change the default_rate_limit line to the MINIMUM number of seconds between pings. 600 is 10 minutes, 1800 is a half hour, 3600 is an hour, and 86400 is one day.

Does it ping *every* incoming link?

No, only links that are not from search engine result pages (SERPs.) Bots will not trigger the pings either since they do no execute JavaScript or index iFrames.

Will my site get banned in Google for using this?

Honestly I have no idea. I don’t see why it would get your site banned, but
please be aware you’re using it at your own risk.

How do I report bugs and request new features?

Please email me directly with bug reports. As for new features, you can email me those too, although this plugin is meant to be simple to use and un-bloated.

Affiliate Link Cloaker Plugin

Introduction

This plugin will cloak an affiliate link in a similar fashion to a product called GC Affiliate Cloaker. It essentially spits out some JavaScript that opens the cloaked link in an iframe. Cloaking in this case is not for SEO purposes – it is to shorten URLs so they look prettier and also to prevent other affiliates from stealing your commissions. You can use a redirect plugin to accomplish the same thing, but this is easier as you make the “redirect” just like writing a post.

Installation

Installation is the same as most plugins, and if you’ve used widgets before you’ll know what to do. Please contact me if you’re having difficulty or you think something is broken. Here’s a step-by-step:

  1. Download the Affiliate Cloaker Plugin and extract link_cloaker.php
  2. Copy the file into your wp-content/plugins/ folder
  3. Go to the Plugins menu in WordPress and activate the Affiliate Cloaker plugin

Using the Affiliate Cloaker plugin

When you’re writing a post you’ll see additional options below the posting window. Click the “Cloaked?” checkbox and fill in the URL field with the destination URL (your affiliate link.) If you want to stop cloaking, just uncheck the box.

Apache restarts with vlad

Often when deploying a new web application you need to restart the apache process. If you’re deploying the application with vlad the deployer as a non-root user (which you should be doing) and you need to restart apache, this can be a little tricky. Luckily there’s a Linux command called sudo which allows you to run commands from a non-root user’s account as though you were root. We’ll limit the commands to just controlling the apache process. It’s a bad idea to give open access with sudo since the user can simply run “sudo su -” and become root.

In order to edit the configuration file that sudo uses (/etc/sudoers btw) we use the visudo command, which edits the file in a safe way by checking for simultaneous users editing the file, parse errors, etc. The idea being to minimize the number of mistakes that can be made. You’ll need to be root (or have sudo permission!) to edit the file:

  # visudo

This brings up an editor screen, whatever you have configured as your default editor. The example below is for Ubuntu, so if you’re using a different distro or web server you’ll need to change the location of the init scripts accordingly (i.e. Ubuntu uses /etc/init.d/apache2 but your distro may use /etc/init.d/httpd or /etc/init.d/lighttpd if you’re running Lighttpd.) I’ll also assume you’re calling the deployment user deploy.

Here are the lines you want to add:

Cmnd_Alias     APACHE = /etc/init.d/apache2 start, /etc/init.d/apache2 stop, /etc/init.d/apache2 restart, /etc/init.d/apache2 reload
# Allow the deploy user to control apache
deploy ALL=NOPASSWD: APACHE

Now save the file, and log in as your deploy user. You should be able to restart apache with the above commands by running:

deploy@steve:~$ sudo /etc/init.d/apache2 restart

Now in your vlad tasks, use the sudo version above to kick the webserver over when you do a deploy:

         # desc "Starts Apache"
         remote_task :start => :settings do
             run 'sudo /etc/init.d/apache2 start'
         end

         # desc "Restarts Apache"
         remote_task :restart => :settings do
             run 'sudo /etc/init.d/apache2 restart'
         end

         # desc "Stop Apache"
         remote_task :stop => :settings do
             run 'sudo /etc/init.d/apache2 stop'
         end

Updating WordPress XML Sitemaps Offline

I personally love Arne Brachhold’s Google XML Sitemap plugin for WordPress. I personally use it on any WordPress install I do. On larger blogs, or blogs where you’re using automated content generators (i.e. posting content in an automated way through XML-RPC) the default build mode will slow down your blog because it rebuilds the entire XML sitemap from scratch every time you create or update a post or page.

There is a second build mode this plugin supports, which is to build via a GET request. For sites that have a lot of posts or do automated posting, this is a great option. It’s possible to schedule the XML sitemap updates to happen at specific times of the day with a simple script that uses an HTTP GET request to refresh them. This will speed up posting, especially for sites that use automatically generated content. Here’s a simple php script that you can schedule via cron to update your sitemaps and send you an email when it is done. Just update the $admin_email variable to where you want the email to go and the $sitemap_link variable to whatever the XML Sitemaps plugin tells you when you change the build mode. Notethat you may need to change the link to include the wp-admin especially if you’re on WordPress mu – the link the plugin gives doesn’t work (i.e. http://myblog.com/?sm_command… to http://myblog.com/wp-admin/?sm_command…)

Here’s the script:

<?php

$admin_email='info@myblog.com';
$sitemap_link = 'http://myblog.com/?sm_command=build&sm_key=90210';

function getURIContents( $uri ) {
    return file_get_contents( $uri );
}

function generateSitemap( $link ) {
    $ret = '';
    $result = getURIContents( $link );
    if( !preg_match( '/.*DONE.*/', $result ) ) {
        $ret = $result;
    }
    return $ret;
}

$result = generateSitemap( $sitemap_link );
if( $result != '' ) {
        mail( $admin_email, 'Sitemap Generator failed:$result" );
} else {
        mail( $admin_email, 'Sitemap Generator Complete',
                "Completed sitemap generation." );
}
?>

If you get errors related to file_get_contents not being able to load a remote URI, just replace the above function with this, which uses libcurl and you should be ok:

function getURIContents( $uri ) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $uri);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_USERAGENT, 'IE 6 - Mozilla/4.0' );
    ret = curl_exec( $ch );
    if( curl_errno( $ch ) ) {
        $ret = '';
    } else {
        curl_close( $ch );
    }
    return $ret;
}

Clickbank Ad Feed WordPress Plugin

Introduction

Clickbank does not have an RSS feed, but they do have an XML version of their products called the Clickbank Marketplace. I wrote a simple backend for importing this XML file and producing RSS feeds, and then wrote a WordPress plugin that will show these feeds on your blog as a widget. Affiliate ID, number of items, campaign tracking tag and keywords are all available. You’re also able to put multiple ad feeds on your blog in different places, provided your WordPress theme has more than one sidebar.

Installation

Installation is the same as most plugins, and if you’ve used widgets before you’ll know what to do. Please contact me if you’re having difficulty or you think something is broken. Here’s a step-by-step:

  1. Download the Clickbank Ad Feed plugin and extract clickbank_adfeed.php
  2. Copy the file into your wp-content/plugins/ folder
  3. Go to the Plugins menu in WordPress and activate the Clickbank Ad Feed plugin
  4. Go to Design > Widgets
  5. Add the Clickbank Ad Feed widget by clicking “Add”
  6. Click “Edit” and fill out the fields, or leave them as the defaults (you will want to fill in your affiliate ID!)
  7. Click “Change” then “Save Changes” and view your site

Additional Information

  • Keywords are specified one per line and can include spaces. The software will use these keywords to search the title and description fields of the Clickbank product database. If not enough ads are found, it will fill the remaining slots with the most popular ads based on Clickbank’s popularity score.
  • Ordering is done by Clickbank’s popularity score. There are plans to add the ability to sort based on commission amount, whether a product is recurring, or gravity.
  • Affiliate ID is set in the widget itself. You can have multiple instances of the widget, so you can use different IDs on different sidebars. Note that my ID is rotated through roughly 20% of the time.
  • Campaign tracking tags are part of the Clickbank hoplink and can be specified in the widget options. I highly recommend using different values on different sidebars so you can track which ones are more profitable.
  • Data updates are done once a day. Clickbank updates their marketplace XML file once a day, so there’s no point in doing it more frequently.
  • Clickbank RSS feed access is coming shortly – this will allow you to use any RSS feed reader to include a Clickbank Ad Feed on your site.

Content Generation with N-grams

Although this is an outdated method, I thought I would post some content generation code I wrote a while ago. Google possesses the n-gram data (more on those later) and algorithms to detect content generated in this fashion. It’s a cool method for text generation but I haven’t found too much in the way of available source code for it. Sure, there is code to take some text and generate n-grams (there’s a perl module for it!), but no sample code to run the n-grams in “reverse” to generate statistically-equivalent text.

The steps for generating statistically-equivalent text to some document are as follows:

  1. Generate a database of n-grams from source document(s) that are similar in nature to what you want to generate. If you want to generate content about male pattern baldness, use articles and content about male pattern baldness. You must record how often each n-gram appears in your source text.
  2. For each n-gram, create a new record that has the first n-1 characters as they key, and the last character and how often it occurred as the value. For example, the 4-gram “then” occurred 15 times in your source text, so your new database entry would have the key “the” with the value ( “n”, 15 ).
  3. Group the same keys together, from step 2. This new database is what you will use to generate the content. For example, step 1 gave you the following 4-grams: ( “then” => 10, “ther” => 20, “thes” => 30 ). Grouping the results from step 2 would give you ( “the” => ( ( “n”, 10 ), ( “r”, 20 ), ( “s”, 30 ) ) ).
  4. Now to generate text, simply start with a random key from your database at step 3, and use the occurrence values as weights to a random number generator to decide which character ( n, r, or s) above should be chosen. Then use the next n-1 characters as a key into your dictionary at step 3 and lather, rinse, repeat until you have enough text.

Here is the source code to generate content. To generate 1,000 characters of text, put all your source content into a file (we’ll call it source.txt), and do the following:

$ gendict.pl 8 source.txt > s_dict.txt
$ gentext.pl s_dict.txt 1000

Obviously you can play around with the ‘n’ parameter (I chose 8 as a starting point.) If you go too small, you’ll end up generating garbage words, and if you go too big, you’ll generate large portions of your source text, but it will make more sense.

I used character-level n-grams in this code, but word-level n-grams would work well, for a large source body. This is similar to the Dissociated Press algorithm except we do a pre-processing step and build an n-gram database first. This n-gram database can be used for other things, such as duplicate content detection, generated content detection and source author recognition to detect cheaters and people using essay writing services.

Modifying the code to stick the generated text into a MySQL database, and then generate an RSS feed from that would allow you use a technique like Affiliate Marketing through RSS Feeds easily. The key to this method is giving it enough source content, and playing around with the size of the n-grams.

Here is some sample text I generated using this document as source with n=8:

baldness, use articles and content detection, generated in this code, but
word-level n-gram appears in your source text, so your new database of
n-grams in thi. It's a cool method, I thought I would work well, for a
large source to generaly-equivalent text.
WORDPRESS