Jul 06 2010

VBulletin 4: “This seems like a terrible place to put this, but I don’t know where else it should go.”

Category: VBulletinFractalizeR @ 12:26 pm

class_taggablecontent.php of VBulletin 4.0.4 forum engine contains the following code:

//This seems like a terrible place to put this, but I don't know where else it should go.
if ($vbulletin->options['tagmaxlen'] <= 0 OR $vbulletin->options['tagmaxlen'] >= 100)
{
       $vbulletin->options['tagmaxlen'] = 100;
}

Continue reading “VBulletin 4: “This seems like a terrible place to put this, but I don’t know where else it should go.””


Jun 20 2010

VBulletin Forum 4.x Bugs: My Cold Anger

Category: Articles,VBulletinFractalizeR @ 8:58 pm

I’ve met VBulletin forum engine several years ago. It was some 3.6.x version. I loved it from the first sight. It’s neat plugin architecture, which allows a user to install plugins without changing any VBulletin file made me happy. A huge plugin repository at www.vbulletin.org made me even more happy because I now could do with my forum EVERYTHING I want. VBulletin 3.x code was so nice and easy to read, that I could site and write everything I wanted, that is absent on vbulletin.org repository. And I wrote some plugins indeed.

My happiness lasted until VBulletin 4.0 was announced. I was surprised by price increase for VBulletin license, but I accepted that and upgraded to Suite license to make use of CMS. I waited for VBulletin 4.0 Gold like hell. On 21 of December 2009 my wish came true. VBulletin 4.0 Gold released.

Continue reading “VBulletin Forum 4.x Bugs: My Cold Anger”


May 20 2010

CentOS: Migrating root (and any other) filesystem from ext3 to ext4

Category: Articles,Linux administrationFractalizeR @ 4:52 pm

With the release of CentOS 5.5 ext4 is considered stable in this distribution so I decided to migrate to it. Luckily I started from migrating fresh server with CentOS 5.5 using some instruction I found on the internet. I think I shouldn’t say, that I screwed the whole thing up ;) After about 6 hours cursing, kicking, and crying I solved the task and figured the correct sequence of actions. The small problem with migrating root partition is that you can’t unmount it BTW.

Continue reading “CentOS: Migrating root (and any other) filesystem from ext3 to ext4″


May 03 2010

WordPress: undocumented “no_texturize_shortcodes” filter

Category: Articles,WordPressFractalizeR @ 7:05 pm

Modifying my WP-SynHighlight addon for WordPress I came across a problem, that WordPress rewrites symbols inside my codesyntax shortcode with their nicer Unicode equivalents. I patched code against some. Then against some more. And then some more… And at last I felt tired of patching my code. Suddenly, I came across no_texturize_shortcodes filter, documentation for which at the time of written was published nowhere.

Continue reading “WordPress: undocumented “no_texturize_shortcodes” filter”


May 03 2010

FractalizeR: VBulletin 4 extensive optimization guide

Category: Articles,VBulletinFractalizeR @ 6:25 pm

Preface

Actually, I never bothered to optimize my server for VBulletin, because the server we purchased for forum is really powerful. But once upon a time logwatch told me, that smartd told her, that he found several relocated sectors on one of server HDDs. And then instantly I realized, that many time ago when I assembled that server, I configured HDDs to be in RAID-0 (striped mode)… Oh…. When you will make some stupid thing on your server, please keep in mind, that there are some people that can do things even more stupid…. Nothing critical happened, because I, actually, have all database backups. Database snapshots are made on server using this script of mine every hour or so (BTW, database backup on my server of 1.12Gb database (reported at admincp) takes around a minute to complete together with compression).

So, we had to visit datacenter and remove/replace HDDs. To allow our forum users to continue using forum until we fix that, we moved our forum to a new server. After forum move, I upgraded it to v4 to benefit from friendly URLs. And there it started. Server load almost immediately reached 4.0 (server had two dualcore CPUs, so this is almost 100% of standard load) and those were even not peak hours. Of course, that was not because of V4 (I turned off both that huge CMS issuing ~200 queries on home page and blogs). This was because that new server where the forum was moved to was less powerful. Of course, 4.0 is not a heavy load for server (once one of my servers reached around 100.0 and still I was able to login by SSH :) ).

But nevertheless, that was the moment, where optimization hysteria first visited my head.

Continue reading “FractalizeR: VBulletin 4 extensive optimization guide”


Jan 09 2010

[Linux] “network unreachable resolving XXXX” messages in system log

Category: Articles,Linux administrationFractalizeR @ 3:10 pm

Some time ago I noticed many messages in log file about named attempt to resolve strange addresses.

Continue reading “[Linux] “network unreachable resolving XXXX” messages in system log”

Tags: ,


Jan 06 2010

Free opensource Symfony-friendly IDE: NetBeans 6.8

Category: Articles,PHPFractalizeR @ 8:03 pm

My search for a good PHP IDE never stops ;) My choice was Zend Studio until recently. But Zend Studio is not free and it’s free analogue – PDT – lacks some features like refactoring (PDT is also mainly developed by Zend, so, I think, Zend will always keep it low to prevent competition with Zend Studio). Also, it is monstrous (More than 300Mb installer) and it definitely lacks good Symfony support.

Recently I came across NetBeans, which is now free and developed by Sun. Sun seem to abandon all own IDE projects in favour of NetBeans, so this is a somehow strong foundation.

Oh… 25Mb installer only for PHP version ;) And… it is easy to use. Very. I would like to guide you through the creation of new symfony project in NetBeans.

Continue reading “Free opensource Symfony-friendly IDE: NetBeans 6.8″

Tags: , ,


Jan 06 2010

[JavaScript] EditArea: Realtime Syntax Highlighting JavaScript Library

Category: Articles,JavaScriptFractalizeR @ 3:19 pm

Recently, improving my WordPress plugin WP-SynHighlight, I chose EditArea as a source code editor with realtime syntax highlighting. The syntax of language description files for highlighting of EditArea is pretty much the same as Geshi has. So, I wrote a small converter and executed it over all Geshi files for 1.0.x version.

I have posted a patch for EditArea with all generated files.

So, now you can have EditArea with almost all power of supporting more than 130 languages ;)

Tags: , ,


Jan 06 2010

[JavaScript] PHP PCRE_DOT_ALL option emulation in JavaScript

Category: Articles,JavaScriptFractalizeR @ 2:06 pm

Writting my WP-SynHighlight WordPress plugin, I came to a need of parsing multilined shortcode like this:

[ codesyntax option1="optionvalue1"...] <many lines here….> [ / codesyntax]

So, I extracted regular expression to parse shortcode from WordPress source code (if you are interested in it, see /wp-includes/shortcodes.php file). This regex was executed with /s option (PCRE_DOT_ALL) which makes dot (“.”) to match newlines also. There is no such option in JavaScript for some reason and I had to replace dot by such character class:

[\S\s]

Actually, any opposite metacharacters should work. [\W\w] for example.

Quite easy, isn’t it? :)

Tags: , ,


Jan 04 2010

[Linux, PHP] PHP script to backup all databases

Category: Articles,Linux administration,PHPFractalizeR @ 1:20 am

Hello.

I’d like to share my script, which I use on some production servers for quick database backup using mysql tools. People say, that I should use bash for that, but I prefer PHP :)

Script uses mysqldump for dumping databases and gzip for compressing backups. rm is run to ensure backups are not stored for too long.

Continue reading “[Linux, PHP] PHP script to backup all databases”

Tags: , , ,


Dec 27 2009

WARNING: mismatch_cnt is not 0 on /dev/md0

Category: Articles,Linux administrationFractalizeR @ 12:37 pm

I’ve gotten cron log from one of my servers today which says:

/etc/cron.weekly/99-raid-check:
 WARNING: mismatch_cnt is not 0 on /dev/md0

That worried me a little and I decided to investigate.

Continue reading “WARNING: mismatch_cnt is not 0 on /dev/md0″

Tags: , , , ,


Dec 20 2009

Script for securing server with IPTables

Category: Articles,Linux administrationFractalizeR @ 7:31 pm

Hello.

Here is a script, which I use on my production servers to secure them a bit. I hope it will be useful to you. Script logs all dropped packets so that you can easily find out tye clutch should there be any. Additional FTP server setup will be necessary. For ProFTPD add the following line to /etc/proftpd.conf:

PassivePorts 65400 65534

Continue reading “Script for securing server with IPTables”

Tags: , , ,


Jul 01 2009

[Linux, FreeBSD] Small Anti-DDOS Shell Script for FreeBSD

Category: Articles,Linux administrationFractalizeR @ 3:21 pm

Struggling with DDoS on my friend’s site, I wrote small Anti-DDoS script, that in original just lists all IPs, that have more than X active connections open to your server. It was originally written for FreeBSD.

#!/bin/sh
# Set here a minimum number of connections for action to be executed (150 by default).
FR_MIN_CONN=150
TMP_PREFIX='/tmp/frrr'
TMP_FILE=`mktemp $TMP_PREFIX.XXXXXXXX`
netstat -ntu -f inet| awk '{if(NR>2 && NF=6) print $5}' | cut -d. -f1-4 | grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$' | sort | uniq -c | sort -nr > $TMP_FILE
while read line; do
 CURR_LINE_CONN=$(echo $line | cut -d" " -f1)
 CURR_LINE_IP=$(echo $line | cut -d" " -f2)
 if [ $CURR_LINE_CONN -lt $FR_MIN_CONN ]; then
 break
 fi
 
 # You can insert your own logic here (e.g. ban with your favourite firewall). Now it just prints the IP to console.
 echo $CURR_LINE_IP
done < $TMP_FILE
rm -f $TMP_PREFIX.*

I think this will work on general Linux also. You just need to change “cut -d.” to “cut -d:” in the listing and, probably, “/bin/sh” to “/bin/bash”.

Tags: , ,


Jul 01 2009

[Linux, FreeBSD] Using netstat and ipfw to manually detect and blacklist DOSers on FreeBSD

Category: Articles,Linux administrationFractalizeR @ 1:22 pm

This is just an addition to my this article with some corrections needed if you use FreeBSD.

netstat command should look like

netstat -ntu -f inet| awk '{print $5}' | cut -d. -f1-4 | sort | uniq -c | sort -nr|more

And firewall IP blocking command should be

ipfw add deny all from xxx.xxx.xxx.xxx to any in

Tags: , , ,


Jun 25 2009

[Linux] Automated RPMForge Repository Installation

Category: Articles,Linux administrationFractalizeR @ 12:28 pm

Actually, I am using CentOS on production servers. CentOS native repository is very small and contains very necessary packages. If you need something more, you should consider using RPMForge repository as I do ;) But to add this repository to CentOS you need to do several annoying actions. And this is annoyng when you do so on each new server you are asked to setup. So, I wrote small script to automate the job which I like to share with you now.

Continue reading “[Linux] Automated RPMForge Repository Installation”

Tags: , , , ,


Jun 01 2009

[Solution] Apache: No space left on device: Couldn’t create accept lock

Category: Articles,Linux administrationFractalizeR @ 3:31 pm

My friend asked me to check the server with this problem. I did and of course first I checked free space on disk using ‘df -h’, but free space was ok. Googling around I found the reason. Unclean shutdown of Apache left many semaphores opened. So, I cleaned them with

for i in `ipcs -s | awk '/nobody/ {print $2}'`; do (ipcrm -s $i); done

You should replace “nobody” in the command with the name of the user Apache is running on your system under. Also I increased semaphore limit in /etc/sysctl.conf by adding to the end of this file

kernel.msgmni = 1024
kernel.sem = 250 256000 32 1024

No system restart is needed to apply changes. Just issue 'sysctl -p‘ command. The solution was found here.

You may also want to switch to another SSLMutex implementation.

Tags:


Sep 19 2008

[Misc] A guide to effective forum administration v.0.9

Category: Articles,Miscellaneous,VBulletinFractalizeR @ 5:14 pm

Introduction
Being a forum administrator/moderator on several forums I would like to share my opinions on how a good forum should be organized and administrated.

Continue reading “[Misc] A guide to effective forum administration v.0.9″

Tags:


Aug 27 2008

[PHP] PHP Quine

Category: Articles,PHPFractalizeR @ 4:28 pm

Browing internet, I found the term of “quine” which is the program, that prints it’s exact source code. I was curious, if I am able to write such software. This is what I was able to compose:

<?php
$u='$';
$q="'";
$qq='"';
$s='<?php';
$e='?>';
$w='eval($p);';
$p='echo"$s\r\n{$u}u=$q$u$q;\r\n{$u}q=$qq$q$qq;\r\n{$u}qq=$q$qq$q;\r\n{$u}s=$q$s$q;\r\n{$u}e=$q$e$q;\r\n{$u}w=$q$w$q;\r\n{$u}p=$q$p$q;\r\n$w";';
eval($p);

It is a small and quite simple quine, however, I spent about several hours understanding how quines work and how to write them in PHP :)

Tags: ,


Aug 25 2008

[PHP, MySQL] Batch changing charset and collation on databases

Category: Articles,MySQL,PHPFractalizeR @ 11:51 pm

Recently I needed to quickly change charset on all tables and change each field’s chanset in each table in a specific database to latin1 and collation to latin1_swedish_ci. I googled a little and found this solution by shimon doodkin. I used it and it did work, but also it attempted to change charset at MySQL information_schema system database which is something I didn’t want to. It also proceessed all databases at MySQL server. Luckily, there was only two :) It was a test server, that’s why I was uncareful.

Ok. I wrote a bit more elegant solution I would like to share with you today. It is pretty self-explanatory and is based on ALTER TABLE CONVERT TO charset MySQL statement.

Continue reading “[PHP, MySQL] Batch changing charset and collation on databases”

Tags: , , , , ,


Aug 24 2008

[Linux] Installing latest Apache, PHP and MySQL from sources

Category: Articles,Linux administrationFractalizeR @ 12:48 am

As you probably know, latest software versions are rarely available to be installed as rpms. So, you need to compile them yourself. In this article I will briefly describe a process of installing, configuring and  upgrading latest Apache and PHP.

Please remember, that installing from sources can sometimes break working system. So, please use this guide carefully.

Continue reading “[Linux] Installing latest Apache, PHP and MySQL from sources”

Tags: , , , , ,


Next Page »