Archive for the 'PHP' Category

IpPreviewTheme v1.0 – a Wordpress Plugin

Short: Use this wordpress plugin to preview your own theme when comming from your IP:

This is a wordpress plugin to allow viewing the selected theme when comming from your own Ip, logged in and have over 8 in user_level. Usefull when developing a new theme or debugging something. I got this idea from the preview-theme. I just did not want to specify the ?preview_theme=[Theme name] in the URL all the time. Therefor I changed it a lot and saved the theme name and IP from a Option page.

Sign out, and you will se how the page is for a normal user.
Sign in and debug it when you’re comming from your IP.
I recommend turing off the plugin when not debugging/developing a new theme.

Bear with me, this is the first Wordpress plugin I have created for 2.5 (I think I have created a wordpress plugin earlier). I will probably release this one in wordpress normal plugin directory after testing it for a while (I hope).
Continue reading ‘IpPreviewTheme v1.0 – a Wordpress Plugin’

dilbert.php

Here is a small and fast way to show dilbert stripe on your webpage:

It downloads the new rss feed pubished by dilbert.com to a cache-file ‘/tmp/dilbert.xml’ using the rss_php class. Go here to download it, then unzip it into the same directory where you put this dilbert.php script.

After first fetch of the rss feed, it reads the cache for the next 2 hours without refetching the rss. Made this within an hour or two. Enjoy!

Continue reading ‘dilbert.php’

WP 2.5.1: Secure Cookies in Wordpress with SECRET_KEY parameter in config settings

Ready to solveJosé Carlos Nieto Jarquín reported a vulnerability WP 2.5:
He published an advisory on SecurityFocus on 15 Apr 2008 regarding insecurity regarding the default SECRET_KEY configuration value. You could gain access to any account if you know the default SECRET_KEY value on a system where SECRET_KEY is left with default value.

Read about the vulnerability in Wordpress 2.5 on Securityfocus

To generate a random new SECRET_KEY for your configuration file, you can go
here.

The default wp-config.php sais:

Change SECRET_KEY to a unique phrase.  You won't have to remember
it later, so make it long and complicated.  You can visit
https://www.grc.com/passwords.htm to get a phrase generated for you,
or just make something up.
define('SECRET_KEY', 'put your unique phrase here');

Here is a example of what you could put in your SECRET_KEY

define('SECRET_KEY', 'b<r4 c/.I.?d+3<cW$DITK79.Aiq~W]Xk.!D^ic]O]ppxSgy+o\'gT\\r+*t0Kqlq:');

Handle both single and double quote characters in input field

There is normaly no problem for the server to recive both double and single quotes from a input field. The problem is when you want to show both single and double quote characters: ‘ and ” in a input text field. You can’t escape characters in html to make the browser show everytning between the outer quote-characters. The trix around this problem is to use javascript to change the value of the input field. That works because javascript understands the whole string when you have escaped it.

Continue reading ‘Handle both single and double quote characters in input field’

[phpPatterns] is not usefull?

I was reading in a php-magazine about [phpPatterns] webpage. It seems to have been stuck since 2005. The owner self writes that “The #1 problem with the old site was the person running it”. I could not agree more. Over year without envolving the page. How serious could the php-magazine writing about this be? Btw, I don’t know why I even blog about this.. Just had to press something? it makes your mind go “hmmm”

I’ve merged Simple Syntax Highlighter and iG:Syntax Hiliter

I’ve merged Simple Syntax Highlighter and iG:Syntax Hiliter by modifying the iG:Syntax Hiliter. That gave me the possibility to post code written in a file, just as Simple Syntax did, but with the nice boxed version like iG:Syntax have.
Continue reading ‘I’ve merged Simple Syntax Highlighter and iG:Syntax Hiliter’

Xinha for WordPress: High resolution for ImageManager

I felt the ImageManager had to small window by default. Therefor I fixed a small patch to fix it. Shown below is only a part of the manager.php that I needed to edit.. You can download the file: xinha_core/plugins/ImageManager/manager.php

[syntax,manager-patch.php,php]

And I needed a new managerHQ.css file in xinha_core/plugins/ImageManager/assets

Xinha v316 (9/14/2005)
Xinha4WP: v1.1 (11/02/2005)

WordPress winampsong plugin

I’ve just created a WordPress plugin to the MSN-SongText program.
Here is a the output (also on the footer of this page):
##WINAMP##

Writing the song anywhere in the themes..

echo winampsong();

or use one of the two strings:

 <!--winampsong-->
##WINAMP##

Download the plugin here put it in your wordpress plugin directory.

I guess this plugin does not work with WP2.5

Moving wordpress database, converting between UTF8 and ISO-8859-1

Yes, I was downgrading because of moving a database from a newer MySQL to a older one. I’ve got problems with some characters in the database. Some UTF8-converting stuff. Well, I don’t think this is the best way, but it worked. Continue reading ‘Moving wordpress database, converting between UTF8 and ISO-8859-1′

Get winamp songname on webpage

Here is a idea of how to do it. Continue reading ‘Get winamp songname on webpage’