Friday, October 28, 2011

PHP - Print any variable easily

You often need to print some PHP variable right into the HTML code, but the variable is out of your current scope. Familiar problem, isn't it?

Here is a bright solution: PHP function that prints any global variable:


function print_var($var = 'domain', $url = '')
{
  global $$var, $$$var;
  if ($url != '')
    echo("<a href=\"$url\">${$var}</a>");
  else
    echo(${$var});
}

Moreover, you can pass some URL as a second parameter, and your variable becomes a clicable link :)

Some examples:


<?php print_var('page')?>
<?php print_var('domain', '/') ?>
<?php print_var('software', '/download/') ?>
<?php print_var('author', 'http://www.site.com') ?>

Sunday, October 16, 2011

Wordpress + Custom Scripts = Error 404

Wordpress is the most popular CMS in the world. Many sites are powered by Wordpress, plugins almost for every need are available. But...

If you decide to add some custom web scripts or other CMS to the domain where Wordpress is already installed, you'll get a problem with Error Handling. Wordpress shows Error 404 (File not found) for any URL that is not a part of Wordpress system!

Moreover, Wordpress changes standard error pages to its own ones. So if an error occurs outside Wordpress environment, the error message appears in Wordpress style anyway!

This can be fixed using .htaccess settings. At first you should exclude work folders form RewriteMode redirections. Add the following line into .htaccess file in the root of your site:

RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(folder1|folder2)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress /index.php [L]

Then you should disable custom error page, at least in folders of your scripts. Add the following line to .htaccess files in your script folders. You can add this line to the root file as well, but sometimes it doesn't work:

ErrorDocument 404 default

This is enough if Wordpress is installed into a folder. But if Wordpress is installed into the root of the site, the solution may not work depending on CMS version and installed theme. Most probably you will need to fix some files manually to disable 404 error handling. The core is located in class-wp.php file:

function handle_404() {
...
$wp_query->set_404();
status_header( 404 );
...
}

BTW, Wordpress in the root of the site is not a best practice...


Friday, September 23, 2011

Keyboard Leds 2.0

Keyboard LEDs version 2.0 has been released.

Program allows you to see the current state of keyboard locks (Caps, Num, Scroll). Information is shown in the system tray or on a floating window over your screen. Also there is an option to indicate the locks state changing with sound.

Keyboard Leds software by KARPOLAN

You can download and use Keyboard Leds program absolutely free!

Download EXE file
Download ZIP Archive

Monday, July 04, 2011

Function IsValidEmail for Delphi

It's hard to believe, but there is no standard function in Delphi to verify the email address. Also there is no native RegExp support. So I have to create own routine for email verification. It is not fully RFC compatible (there is no support for user@[10.20.30.40] and John Dow <a@b.c>) but is good enough for 99% of end-user programs.

Click on code, press Ctrl+A to select all, Ctrl+C to copy the text.

P.S. Does anybody use Delphi in 2011? :)

Thursday, June 23, 2011

Keyboard Leds 1.5

Keyboard LEDs version 1.5 has been released.

Program allows you to see the current state of keyboard locks (Caps, Num, Scroll). Information is shown in the system tray or on a floating window over your screen. Also there is an option to indicate the locks state changing with sound.

Keyboard LEDs software by KARPOLAN

You can download and use Keyboard LEDs program absolutely free!

Download EXE file
Download ZIP Archive

Monday, June 20, 2011

List of USA and Canada States

Same to the countries list I'm publishing the list of USA and Canadian states:

Hope this helps somebody :)

Hint: Click on list, press Ctrl+A to select all, Ctrl+C to copy the list.

Country List

Every time I create the user panel in some program or website I'm searching for a list of countries for dropdown (combo box) options control. So I decide to palace such list in a public place:

This is ISO 3166 Country Name list. Maybe other people will be happy to use this list in own projects :)

Hint: Click on list, press Ctrl+A to select all, Ctrl+C to copy the list.

Tuesday, May 17, 2011

Keyboard Leds 1.3

Keyboard LEDs version 1.3 has been released.

Program allows you to see the current state of keyboard locks (Caps, Num, Scroll). Information is shown in the system tray or on a floating window over your screen. Also there is an option to indicate the locks state changing with sound.

Keyboard LEDs software by KARPOLAN

You can download and use Keyboard LEDs program absolutely free!

Download EXE file
Download ZIP Archive

Software works on Windows, there is no MacOS edition. Yet :)

Saturday, March 26, 2011

My CV

I've updated my Resume (Curriculum Vitae). I don't know what to do with this "paper", so just put it in a public place: KARPOLAN's CV.

Sunday, January 16, 2011

Software to monitor internet usage

What is the best software to monitor internet usage?

I know WorkTime by NesterSoft but I'm not sure that is the easiest one.

Any other suggestions?