Nov 30

Militant

Nov 16

The Pirate Bay Logo

The Pirate Bay Logo


So, apparently, Swedish corporation Sandryds Handel AB noticed that The Pirate Bay logo isn’t registered or copyrighted to anyone in particular, so what was the next logical step? Well to register/copyright it for themselves of course! Obviously, this is soliciting a reaction from the collective forces of the internetz, including (but not limited to) the torrent community.

According to Sandryds Handel spokesman Bengt Wessborg, the company is intending to “sell USB drives using this brand”, which is actually kind-of a cool idea (especially if they donated a certain percentage to tpb). Here’s the issue, The Pirate Bay logo isn’t registered or copyrighted because it was never meant to be at all restricted, in alignment with the opinion that information should be free, so using the image for USB drives or t-shirts is one thing, but registering and copyrighting the image to your company? That’s completely different.

ex-Pirate Bay spokesman Peter Sunde told TorrentFreak: “It will be turned over quite easily, it’s a preliminary registration that is being ‘tested’” indicating that this isn’t something to be terribly worried about, adding later that “It’s a person at the registration office that has made an error – willingly or not, we’re not sure”. So no worries, pirates, your beloved logo will be safe for now.

Torrentfreak article
SR

Nov 12

mod_rewrite is an awesome module for apache that allows you to rewrite urls. Describes itself right? Like all other apache modules, simply loading the module won’t do jack. You have to configure your apache server, telling it how you want to use mod_rewrite and where you want to use it.

Install mod_rewrite
If you already have apache installed, chances are that you already have the mod_rewrite module. If not, install it.
Debain only

a2enmod rewrite

Load the module in your apache config
Like all other daemons, apache relies on configuration files to tell it how to behave. Common configuration changes for apache would be to load/unload modules, change error or access log locations, etc. If your version apache loads modules in the configuration file, uncomment or add the following line to your config.

LoadModule /path/to/mod_rewrite.so

If your version of apache loads modules from the mods-enabled folder, create a symbolic link to the mod_rewrite config file in mods-enabled. This is what it would look like for me.

egeste:/etc/apache2# ln -s ../mods-available/rewrite.load

Enable .htaccess override in your web application root directory
Enabling .htaccess to override some settings in the root dir of your application allows you to change the way apache will behave in that directory without the need to restart the apache daemon. I like to add this setting to my vhost config. This is what mine looks like (some info redacted).

egeste:/etc/apache2# cat sites-available/egeste.net.conf
<VirtualHost *:80>
 ServerAdmin webmaster@localhost
 DocumentRoot /path/to/site/root
 ServerName www.egeste.net
 ServerAlias egeste.net
</VirtualHost>
<Directory /path/to/site/root>
 Options FollowSymLinks
 AllowOverride All
 Order deny,allow
 Allow from all
</Directory>

At this point go ahead and give your apache server a restart.

egeste:/etc/apache2# /etc/init.d/apache2 restart

Cool, if all went well, you should have mod_rewrite installed, loaded and configured to allow .htaccess overrides in your site root. The only steps that remain are to define a ruleset in .htaccess and write your web application to handle the requests. I won’t go into detail on mod-rewrite rules and regex, but here’s my wordpress .htaccess file.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Happy coding =)
-Egeste

Nov 09

Every once in a while you run into a problem that makes you scratch your head… and eventually maybe smash it against your desk a few times. This was definitely one of those.

get_pages() is a method that returns an array of $post objects (which is very well documented here). There are multiple arguments you can pass to get_pages() for the purpose of filtering the results you get back (these args are well documented here). For example, if you only want to retrieve sub-pages of the current page, you could say:

$pages = get_pages("child_of=".$post->ID);

One of the args you can specify is the meta_key arg, which will only return pages that contain the meta_key you specify. (See: Custom Fields) This is where I ran into some trouble.

It turns out that get_pages has an argument called hierarchical, which according to the codex does the following:

hierarchical
(boolean) Display sub-Pages in an indented manner below their parent or list the Pages inline. The default is true (display sub-Pages indented below the parent list item). Valid values:

  • 1 (true) – default
  • 0 (false)

What’s not intuitive about this argument is that it will filter subpages, (that is, not top-level pages) when using the meta_key arg. Here’s an example:

Data Set

  • Homepage
  • About
    • Foo
    • Bar (This item has a meta_key named banner_title)

Code

count(get_pages("meta_key=banner_title"));

Output: 0

The output indicates that 0 results were returned, despite the fact that we have a page with a meta_key named banner_title. So lets try something different.

Code

count(get_pages("meta_key=banner_title&hierarchical=0"));

Output: 1

Ah, now we’re getting the results we want.

TL;DR – you have to use the hierarchical=0 arg to list all pages that contain your meta_key, otherwise you will only get top-level pages.

-Egeste

Tagged with:
preload preload preload
This website uses a Hackadelic PlugIn, Hackadelic Sliding Notes 1.6.3+.