soderlind.no

I code for fun

18.4.2008
by PerS
8 Comments

WP-DenyHost

This is a plugin that will block a spammer if he already has been tagged as a spammer. I use it together with the Akismet plugin. Akismet tags the spammer, and wp-denyhost prevents him from adding more comment spam.

Core functionality :

define('PS_DENYHOST_THRESHOLD', 5);
function ps_denyhost() {
    global $wpdb;

    $suspect = $this->get_IP();
    $count = (int) $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_approved = 'spam' AND comment_author_IP = '$suspect'");

    if ($count > PS_DENYHOST_THRESHOLD) {
        exit;
    }
}
add_action('init', 'ps_denyhost');

Download / install: http://wordpress.org/extend/plugins/wp-denyhost/

View-sourcehttp://soderlind.no/code/view/ps_wp_denyhost.php

Changelog (updated 28.12.2009):

v1.1.3: Fixed a minor bug
v1.1.2: Added response 403 Forbidden
v1.1.1: Added languages/wp-denyhost.pot
v1.1.0: Major rewrite. Added option page
v1.0.1: Replaced LIKE (‘%$suspect%’) with = ‘$suspect’ i.e. look for exact match
v1.0: Initial release

7.1.2007
by PerS
0 comments

Sandbox Skin Editor

Note: This is work in progress, when the editor is done, it will be announced here.

I’m coding a skin editor for the sandbox theme. The code will be gpl, so you can adjust it to other themes, but I will only support the sandbox theme.

Here’s a demo of the prototype: http://soderlind.no/demo/skineditor.php

v1.0 will:

  • support both WordPress 2.x and MU
  • have a preview
  • allow you to save a style to a temporary file prior to publishing it (for testing)
  • in MU, save the style to wp-content/blogs.dir/$wpdb->blogid/css
  • filter the saved css to prevent xss

btw, if you don’t know the Sandbox theme, have a look here: http://www.plaintxt.org/themes/sandbox/. It is one of the easiest/best themes to use as a building block for creating your own themes using css.

3.1.2006
by Guest
185 Comments

ImageManager 2.0

R.I.P. ImageManager

As of today (13.11.08), ImageManager is e.o.l. If you need image editing functionality in WordPress, head over to Scissors

Current Version: 2.5.3 (supporting WordPress 2.5, WPMU 1.3.3 and WordPress 2.3.3)


click to view the ImageManager demoThe ImageManager plugin integrates the stand alone PHP ImageManager + Editor with WordPress. The ImageManager provides an interface for browsing and uploading image files on/to your server. The Editor allows for some basic image manipulations such as, cropping, rotation, flip, and scaling.

View the flash demo.

Feature list

  • Simple image editor (crop, rotate, flip, and scale).
  • Upload and delete images.
  • Can be localized using the included ImageManager.pot file.
    Language files: Chinese, English (default), German, Japanese, Norwegian and Spanish.
  • Supports the Role Manager plugin. Capabilities: Upload Files, Make Direcory, Edit Image and Delete Image.
  • Add style using inline style or by setting a class name.
  • Insert the selected image as; the original image, thumbnail with popup (create mini galleries), thumbnail with a link to the original image, thumbnail, or a text link to the original image.
  • Lightbox support. Added rel=”lightbox” to the Thumbnail with link to image and to Link to image. This should make it possible to use the WP lightbox JS or other lightbox plugins together with ImageManager.
  • You can disable the native WordPress Upload Files.

Continue Reading

8.11.2004
by Guest
76 Comments

aggrss, an rss aggregator


[updated] Uses the lastRSS library tolastrss_button.gif
aggregate RSS feeds.
lastRSS (and this plugin) gives you:

  • All RSS versions supported (0.9, 1.0 and 2.0)
  • Regullar expression parsing (very quick)
  • Returns an associative array with RSS fields
  • RSS tags not present in RSS are also not present in result now
  • Transparent cache
  • Character encoding conversion (all encodings supported by iconv library)

lastRSS is free open-source software (GNU/GPL), this plugin has a BSD license

Instructions:

  1. Create the cache directory – wp-content/aggrss-cache – and make it world writeable (chmod 777)
  2. create subdir wp-content/plugins/lastRSS
  3. Extract lastRSS.zip and save lastRSS.php in wp-content/plugins/lastRSS
    local copy: lastRSS.0.9.1.zip (2.9 KiB, 2,636 downloads)
  4. Save aggrss.php.txt (4.4 KiB, 2,483 downloads) as aggrss.php in your wp-content/plugins directory
  5. Activate the plugin from the Plugins page (re-activate (deactivate + activate) if you are upgrading aggrss)

Use:

$rs = aggrss($rssurl,$striptags=false,$num=0);
/*
$rssurl, url to the rss

optional parameters:
$striptags, if true all html tags will be remove from decriptions.
$num, defines the number of records you want to display, $num=0 equals all available
*/

aggrss returns the rss content as an associative array with RSS fields, see sample below.


if ($rs = aggrss('http://soderlind.no/feed/rss2/')) {
    // dump the structure
    //echo "<pre>";
    //print_r($rs);
    //echo "</pre>";
    echo "<h2><a xhref='" . $rs[link] . "'>" . $rs[title] . "</a></h2>";
    echo $rs[description] . "<br />";

    foreach ($rs['items'] as $item) {
        echo "<p><a xhref='" .$item['link']. "'>" . $item['title'] . "</a><br />" .html_entity_decode($item['description']). "</p>";
    }

    if ($rs['items_count'] < = 0) {
        echo "Sorry, no items found in the RSS file :-( "; }
    } else {
        echo "<!-- It's not possible to reach RSS file -->";
    }
}

Demo:
http://soderlind.no/dilbert/

3.8.2004
by Guest
4 Comments

GeoIP

This plugin might exist allready, but I couldn’t find it using google, so here it is

The plugin gives you four functions you can use in your blog:
get_geoip_country_code and get_geoip_country_name returns the the visitors country code / name

the_geoip_country_code and the_geoip_country_name echos the the visitors country code / name

INSTALLATION:

1) Extract the plugin into your WordPress plugins directory.

2) Download the free GeoIP country database from MaxMind , and extract it into your plugins/GeoIP directory

3) Optional, If you need country flags, you’ll find them here: http://www.maxmind.com/download/geoip/database/flag.zip

4) Activate it on the Plugins tab of the WordPress admin console.

SAMPLE USE:

<img src="/flag/<?php echo
strtolower(get_geoip_country_code())?>.gif" alt="<?php
the_geoip_country_name()?>" />

NOTE, If you have full access to your server and it’s running Apache, you should take a look at the mod_geoip

Rodney's 404 Handler Plugin plugged in.