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: , , , , ,


Aug 21 2008

[Linux] Installing YUM (Yellow dog Updater, Modified)

Category: Articles,Linux administrationFractalizeR @ 4:46 pm

YUM is an rpm package manager with very easy syntax. It is preferred especially for beginners to install packages using yum as this is very easy. Your Linux distro should already have yum by default, but if this is not so, let’s install it. BTW, you can find yum manual here.

You can check if your system has yum by entering

  • yum –help

Continue reading “[Linux] Installing YUM (Yellow dog Updater, Modified)”

Tags: ,


Aug 18 2008

[PHP] Writting Custom Class Autoloader Using SPL

Category: Articles,PHPFractalizeR @ 1:11 am

My approach to writting mid-to-huge applications is to put each class to separate file and autoload class files on demand to eliminate the use of include/require statements completely. Autoloading in some cases can even speed up your project (for example, my scripts rarely throw exceptions. Exception classes are loaded by demand and only in case exception happend, so I remove

<?php
require_once('DatabaseException.php');
require_once('UserBOException.php);

overhead from my project. However, writting a good universal autoloader class is not trivial, however, simple. In this article I would like to suggest my own lightweigh multifunctional autoloader class.

Continue reading “[PHP] Writting Custom Class Autoloader Using SPL”

Tags: , , ,


Aug 18 2008

[PHP] PDO: Wrapping and making sweet

Category: Articles,PHPFractalizeR @ 12:18 am

Now PDO is most promising database access mechanism in PHP5. However, using PDO natively is not always convinient. In this article I will suggest my own lightweight wrapper for PDO calls, which simplyfies things for me. I am PHP5 fan, so we will use all object oriented technologies this language can give us in constructing our PDO wrapper.

Continue reading “[PHP] PDO: Wrapping and making sweet”

Tags: , , , , , , , ,


Aug 14 2008

[VBulletin Addon] “Edit User” Button in postbit

Category: Software releases,VBulletin Add-onsFractalizeR @ 5:38 pm

Preable:

I turned VBulletin forum into support system for our customers. In some forums users post requests to activate their access to some subforums. Administrator looks through all the requests, verifies data, provided by each user and sets secondary usergroups for certain user according to request. Each time having checked user data, administrator needs to go to user profile and click Options there to go to user edit window.

What this hack does?

This hack adds a button Edit User to each post. Having clicked this button opens /admincp/user.php?do=edit&u=$post[userid] page in new window. So, my staff needs only one click to access user account data.
Hack is fully customizable. The following parameters are adjustable:

* Window height and width
* Button icon
* User groups for which this button is shown
* Button location (choose from 9 possible)

Continue reading “[VBulletin Addon] “Edit User” Button in postbit”

Tags: ,


Aug 11 2008

[Linux] Limiting download speed and number of connections per IP with mod_choke (Apache 1.x)

Category: Articles,Linux administrationFractalizeR @ 1:47 am

If you have many greedy users downloading files from your server using many streams per user, you can fight them easily with mod_choke Apache 1.x module. It is very easy. The article assumes your server is running under CPanel/WHM

Continue reading “[Linux] Limiting download speed and number of connections per IP with mod_choke (Apache 1.x)”


Aug 11 2008

[Linux] Decreasing server CPU load with PHP APC cache extension

Category: Articles,Linux administrationFractalizeR @ 1:44 am

As you know, each time php script is executed, PHP interpreter need to compile it first to bytecode and only after that – execute. That compilation takes much time.

APC PHP extension (which will be included and enabled in PHP6 by default. It becomes a standard) can speedup php script execution process by caching once compiled PHP bytecode in memory. So, installing this extension increases your server performance (we assume you are doing this at CPanel/WHM controlled server). To install extension just do the following:
Continue reading “[Linux] Decreasing server CPU load with PHP APC cache extension”

Tags: , ,


Aug 11 2008

[Linux] Installing ClamAV antivirus and integrating with Exim and pure-ftpd

Category: Articles,Linux administrationFractalizeR @ 1:41 am

Every good server must have a good antivirus installed. Let’s install ClamAV to our machine. Paths to distributions are provided to the latest versions at the time of writting. If new version releases all you need to do is to change numbers in shell command.

Continue reading “[Linux] Installing ClamAV antivirus and integrating with Exim and pure-ftpd”

Tags: , ,


Aug 08 2008

[VBulletin Addon] VBulletin Antivirus

Category: Software releases,VBulletin Add-onsFractalizeR @ 5:45 pm

Powerful VBulletin addon, that scans every attachment any user uploads to your forum for viruses and allows to execute various actions if any virus is found. Hack requires PHP 5.x. and (depending on driver) PHP AV extensions or some antivirus software installed on PC

Continue reading “[VBulletin Addon] VBulletin Antivirus”

Tags: , , ,


Aug 08 2008

[VBulletin] Create checkbox group at your hack’s options (usergroup selection for example)

Category: Articles,VBulletinFractalizeR @ 5:43 pm

Hello.

In this article I will show how to create a checkbox group in your hack’s options. It’s easy. Just do the following:

Continue reading “[VBulletin] Create checkbox group at your hack’s options (usergroup selection for example)”

Tags: ,


Aug 07 2008

[VBulletin addon] Show items, awaiting moderation in notifications area

Category: Software releases,VBulletin Add-onsFractalizeR @ 8:18 pm

What does it do?
This hack shows all items, that require moderation in a notifications area. Items are grouped by type:

Continue reading “[VBulletin addon] Show items, awaiting moderation in notifications area”

Tags: , , , , , ,


Aug 07 2008

[VBulletin] Using VBulletin 3.7.x notifications engine

Category: Articles,VBulletinFractalizeR @ 7:51 pm

Everyone saw a nice drop-down list with all notifications you have at the top-right corner of every page. Let’s look, how to add our own notifications to this list. It is very easy!

Continue reading “[VBulletin] Using VBulletin 3.7.x notifications engine”

Tags: ,