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: php, quine
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: change charset, charset, charset conversion, CONVERT TO CHARACTER SET, mysql, php
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: apache, CentOS, httpd, linux, mysql, php
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
Continue reading “[Linux] Installing YUM (Yellow dog Updater, Modified)”
Tags: install yum, yum
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: autoloading, FL_FLAutoloader, php, php autoload
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: FL_DB_Connection, FL_DB_Exception, FL_DB_RecordsetObj, FR_DB, pdo, pdo wrapper, pgo_mysql, php, wrapper
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: fr_edituser, vbulletin
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)”
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: apc, php, php optimization
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: clam, clamav, linux
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: antivirus, clam, fr_vbav, VBulletin Add-ons
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: notifications, vbulletin