Protect WordPress
กุมภาพันธ์ 15, 2011
Force User Login
This is a very small plugin that forces users to login before viewing any content. This is done by checking if the user is logged in, and if not, redirecting them to the login page. Users attempting to view blog content via RSS are also authenticated via HTTP Auth.
http://wordpress.org/extend/plugins/force-user-login/
Perl Scan Folder and Access Image on Web
สิงหาคม 26, 2010
#!/usr/bin/perl
use LWP::Simple;
use LWP;
# scan all files in folder
sub scanFolder {
my $dirtoget = ".\\yourPath\\";
opendir(IMD, $dirtoget) || die ("Cannot open directory");
my @thefiles = readdir(IMD);
foreach $f (@thefiles) {
unless (($f eq ".") || ($f eq "..") )
{
my $filename = $dirtoget.$f;
// do what you want ^^
}
}
closedir(IMD);
}
sub saveImagesFromWWW {
my ($filename, $target) = @_;
my $browser = LWP::UserAgent->new;
# Get image from hotlink protection
my $response = $browser->get(
$filename, # image path
'Referer' => # The URL where I see the strip:
"http://yourWantedPage.......html",
);
$fileOutput = ".\\outputPath\\".$target.".jpg";
open(OUT, ">".$fileOutput) || die $!;
binmode(OUT);
print OUT $response->content;
close(OUT);
}
Perl Plays Sound
สิงหาคม 26, 2010
#!/usr/bin/perl
use Win32::Sound;
Win32::Sound::Volume(’100%’);
Win32::Sound::Play(“delightMind.wav“);
Win32::Sound::Stop();
PHP with Session
มิถุนายน 17, 2010
1. If you use session (PHP), use UTF-8 encoding without BOM Some text editors in windows don't support UTF-8 without BOM such as Editplus (T_T) 2. session_register(), session_unregister() are deprecated for secureity issue In order to use session variables, access via $_SESSION["yourname"]; directly. For initializing, declare $_SESSION["yourname"]; is enough. For destruction, you can use unset($_SESSION["yourname"]);
Thai language on html
มิถุนายน 17, 2010
1. Set defualt language of html page to Thai. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang='th-TH' xml:lang='th-TH' xmlns='http://www.w3.org/1999/xhtml'> 2. Set charset = utf-8 <meta content='text/html; charset=utf-8' http-equiv='Content-Type' /> 3. Set database encoding = utf8_unicode MySQL connection collation: utr8_unicode_ci