Sunday, 6 December 2009

Creating a MySQL Datasource in Coldfusion(CF) Server

Before we can create a ColdFusion datasource we need to create a empty MySQL database to point the datasource at.

Create Empty Database

To create an empty MySQL database for your ShadoCMS site use your favorite client to connect to your database server and create the database as you normally would but with the following encoding settings:

Character Set utf8
Collation utf8_unicode_ci

Create Datasource

You now need to create a new datasource in the ColdFusion Administrator and point it to the new empty database you have just created.

Login to the ColdFusion Administrator on the server at http://localhost/cfide/administrator/.

Click on the “Datasources” link in the left navigation.

Enter the name of the new site in the “Add New Datasource” box, select the "MySQL (4/5)" driver, and click "Add".

On the next screen, fill in the following connection details:

CF Data Source Name (The name of your ShadoCMS site you want to create) eg “emptysite”
Database (The name of your database) eg “emptysite”
Server (The name of your database server) eg “localhost”
Port 3306
Username [your database username]
Password [your database password]
Advanced Settings:
Connection String
Enter text: “useUnicode=true&characterEncoding=UTF-8”

Click “Submit”. You should be informed that the datasource was updated successfully.

Creating a Shado Site

Now that you have a empty database and a ColdFusion datasource setup you now need to create a ShadoCMS site.

This is the way to connect mysql to Coldfusion server's datasource.

Monday, 30 November 2009

Update Twitter Status with PHP

/* Function to update the twitter status, Update Twitter Status Using PHP */
function tweetMyMessage($tweetUsername = '', $tweetPassword = '', $tweetMessage = '') {
if (function_exists('curl_init')) {
$twitterUsername = trim($tweetUsername);
$twitterPassword = trim($tweetPassword);

if(strlen($tweetMessage) > 140) {
$tweetMessage = substr($tweetMessage, 0, 140);
}

$twitterStatus = htmlentities(trim(strip_tags($tweetMessage)));

if (!empty($twitterUsername) && !empty($twitterPassword) && !empty($twitterStatus)) {
$strTweetUrl = 'http://www.twitter.com/statuses/update.xml';

$objCurlHandle = curl_init();
curl_setopt($objCurlHandle, CURLOPT_URL, "$strTweetUrl");
curl_setopt($objCurlHandle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($objCurlHandle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($objCurlHandle, CURLOPT_POST, 1);
curl_setopt($objCurlHandle, CURLOPT_POSTFIELDS, "status=$twitterStatus");
curl_setopt($objCurlHandle, CURLOPT_USERPWD, "$twitterUsername:$twitterPassword");

$result = curl_exec($objCurlHandle);
$arrResult = curl_getinfo($objCurlHandle);

if ($arrResult['http_code'] == 200) {
echo 'Your Tweet has been posted for update.';
}
else {
echo 'Sorry, could not post your Tweet message to Twitter.';
}

curl_close($objCurlHandle);
}
else {
echo('Missing required parameters to submit your Twitter message.');
}
}
else {
echo('Curl Extension is not installed.');
}
}

$username = 'twitterUsername';
$password = '**********';
$message = 'update my twitter status.';
/* invoking the tweetMyMessage function to Post Twitter from PHP. */
tweetMyMessage($username, $password, $message);

Search Engine-Friendly URL Generator & how to use/write .htaccess file for SEF URL

1. First of all, goto the /../apache/conf/httpd.conf file, try to find the with keyword ("rewrite_module"), you will get the line as
#LoadModule rewrite_module modules/mod_rewrite.so

uncomment(revode the # char at the beginning of line) the above line as
LoadModule rewrite_module modules/mod_rewrite.so

2. Then goto the root directory of your project, for example, samplesite at location htdocs/samplesite/. Then create the .htaccess (don't forgot to add dot(.) on filename) file on that location as htdocs/samplesite/.htaccess

3. Then write the following lines of code on that .htaccess file as;

/* ------------ .htaccess file ---------*/
---------------------------------------------------------------------------------
Options +FollowSymlinks
RewriteEngine on
RewriteBase /samplesite /* this /samplesite is base url of your project. */

/* then write the rule of your choice, sample rules as below */
RewriteRule searcharticle/(.*)/(.*)/(.*)\.html searcharticle.php?cat=$1&atitle=$2&aid=$3

RewriteRule viewarticle/(.*)/(.*) viewarticle.php?title=$1&aid=$2
---------------------------------------------------------------------------------

Then, save the .htaccess file with above data.

Here,
RewriteRule searcharticle/(.*)/(.*)/(.*)\.html searcharticle.php?cat=$1&atitle=$2&aid=$3
means ( we need to set article search URL in below format as )
http://localhost/samplesite/searcharticle/cat/articleTitle/24.html
=>(implies to )
http://localhost/samplesite/searcharticle.php?cat=catTitle&atitle=ArticleTitle&aid=24
(in normal PHP way without using of .htaccess code)

Similarly,
RewriteRule viewarticle/(.*)/(.*) viewarticle.php?title=$1&aid=$2
means ( we need to set article view URL in below format as )
http://localhost/samplesite/viewarticle/articleTitle/24
=>(implies to )
http://localhost/samplesite/viewarticle.php?atitle=ArticleTitle&aid=24
(in normal PHP way without using of .htaccess code)

This is the way to generate Search Engine-Friendly URL.
Also, here to Generator to make RULES for Search Engine-Friendly URL.

Friday, 27 November 2009

How to Use PHPMailer to send mail, PHPMailer() Class, class.phpmailer.php

1. First, download the PHPMailer library class.
2. Include the class.phpmailer.php to the file from where you want to send mail.
3. Make a local library function class of your choice.

for example, the following "func.global.php" as
/* ------------------file name: - func.global.php ---------- */
function sendMailWithAttachment($config, $email_data)
{
$email = $email_data;
$mail = new PHPMailer();
$mail->CharSet = "utf-8";

if($config['email_type'] == 'smtp')
{
$mail->IsSMTP();
$mail->SMTPAuth = TRUE;
$mail->Username = $config['email_username'];
$mail->Password = $config['email_password'];
$mail->Host = $config['email_hostname'];
}
else if ( $config['email_type'] == 'sendmail')
{
$mail->IsSendmail();
}
else { $mail->IsMail(); }

$mail->FromName = $email['from_name'];
$mail->From = $email['from_email'];

if ( count($email['bcc']) > 0)
{
$counter = 0;
foreach ($email['bcc'] as $value)
{
if($counter == 0) { $mail->AddAddress($value); }
else { $mail->AddBCC($value); }

$counter++;
}
} else
{
$mail->AddAddress ( $email['to_email'];
}

if ( !empty($email['attachment']))
{
$mail->AddAttachment ($email['attachemnt']);
}

$mail->IsHTML (FALSE);
$mail->Send();

$sentMessage = array();
$sentMessage['isSent'] = TRUE:
$sentMessage['sentMessage'] = "Message has been sent";
if ( ! $mail->Send())
{
$sentMessage['isSent'] = FALSE;
$sentMessage['sentMessage'] = "Message could not be sent

";
$sentMessage['sentMessage'] .= "Mailer Error : ", $mail->ErrorInfo;
}

return $sentMessage;
}
/* end of sendMailWithAttachment function. */


4. Use the above "func.global.php" file's function called sendMailWithAttachment() as;

/* ------------------file name: - sendEmail.php ---------- */

require_once ( "class.phpmailer.php");
require_once ( "func.global.php");

/* To send the email as normal php mailto() function ways but throw the your own SMTP mail server. */
$config = array('email_type'=>'smtp', 'email_username'=>'smtpuser', 'email_password'=>'smtppswd', 'email_host'=>'hostserver');

/* To send the email as normal php mailto() function ways. */
$config = array('email_type'=>'sendmail');
$email_data = array('from_name'=>'Jastin', 'from_email'=>'jastin.td@gmail.com',
'to_email'=>'kuliek@hotmail.com',
'bcc'=>array('gostels@live.com','hellopotak@yahoo.com'),
'attachement'=>'C:\docs\my_pics.jpeg'
);

sendMailWithAttachment ($config, $email_data);

If you like to read more about the PHP Mailer, click here

Sunday, 22 November 2009

How to Install Magento on XAMPP in XP

(UPDATED-03.25.09) - I have started using WAMP. Magento has a nice install guide on their wiki. The guide covers both XAMPP and WAMP but I've been having problems getting v1.2 or newer of Magento to work with XAMPP. Thus the switch to WAMP. So far I am liking WAMP better.

XAMPP is an easy to install LAMP environment used for testing. Magento is an open source ecommerce package. You should already have XAMPP installed and a copy of Magento. Start Apache and MySql if not already running.

Enable curl in XAMPP
1) Locate the following files:
C:\Program Files\xampp\apache\bin\php.ini
C:\Program Files\xampp\php\php.ini
C:\Program Files\xampp\php\php4\php.ini
2) Uncomment the following line on the php.ini files by removing the semicolon.
;extension=php_curl.dll
3) Restart your apache server

Create Magento database
1) Open a browser and navigate to http://127.0.0.1/phpmyadmin/
2) Create a new data base named magento

Install Magento
1) Extract the Magento-1.0.19870.4. zip file
2) Copy the extracted files to the httpdoc folder of XAMPP (rename any exsisting index files for your XMAPP install)
3) Navigate your browser to http://127.0.0.1/index.php
4) Follow the Magento install wizard

Sunday, 15 November 2009

KTM: HSEB publishes class XI results 2009

BHAKTAPUR: The Higher Secondary Education Board (HSEB), Sanothimi, Bhaktapur, has announced the results of class XI examinations 2066 Saturday evening. The board has announced the results under both regular and partial categories. Under regular category, a total of 2,50,654 students had appeared for the examinations , out of which 1,01,433 students made it through with the pass percentage standing at 40.45 per cent.
To View the Result, please Click Here

Friday, 13 November 2009

To reload the Parent Window from Clild Window by Javascript


< a href="#" onClick="javascript:parent.location.reload()" > Click to Reload Parent window < /a >

Thursday, 12 November 2009

HTML to PDF, generate PDF with HTML data,

To generate the HTML contents in PDF datatype or .pdf file format. Use the following steps:

1. Download the dompdf from
    http://code.google.com/p/dompdf/
or http://sourceforge.net/projects/dompdf/

2. Upzip(if necessary) and keep the dompdf/ folder at your's project root directory.

then, make a function to generate pdf file for download or write a file to the disk as;

/* function to generate the .pdf file for download. */

function get_generate_pdf ($htmlContent, $filename)
{
require_once ("../dompdf/dompdf_config.inc.php");

$dompdf = new DOMPDF();
$dompdf -> load_html($htmlContent);
$dompdf -> render();

$dompdf -> stream($filename);
}

/* function to write the .pdf file with HTML Contents. */
function get_write_pdf_file ($htmlContent, $filename)
{
require_once ("../dompdf/dompdf_config.inc.php");

$dompdf = new DOMPDF();
$dompdf -> load_html($htmlContent);
$dompdf -> render();

$pdfContent = $dompdf -> output();
file_put_contents($filename, $pdfContent);
}

/* function to write the file Contents. */
function get_write_file ($content, $filename, $mode="w")
{
$fp = @fopen ($file, $mode);

if ( ! is_resource($fp)) { return false; }

fwrite ($fp, $content);
fclose ($fp);
}

$htmlContent = "< html >< head >< title >SamplePDF file< /title >< /head >
< body >< strong >You can include any kinda html content in this body format.< /strong >< /body >< /html >";

$filename = "sample_pdf_file.pdf";

/* Calling above function for html content in pdf attachment file format. */
get_generate_pdf ($htmlContent, $filename)

/* Calling above function for html content in pdf attachment file format. */
get_generate_pdf ($htmlContent, $filename);

Friday, 6 November 2009

PDF and PHP, Generate PDFs with PHP

There is a lot of PHP code available to generate PDF but most of it requires downloading and installing php extensions. In a shared hosting environment you don't always have access to php configuration, which is why ezPDF is nice. ezPDF is open source PDF generation PHP. See below for an example of 'on the fly' pdf generation, using ezPDF.

include_once ('class.ezpdf.php');
//ezpdf: from http://www.ros.co.nz/pdf/?
//docs: http://www.ros.co.nz/pdf/readme.pdf
//note: xy origin is at the bottom left

//data
$colw = array( 80 , 40, 220, 80, 40 );//column widths
$rows = array(
array('company','size','desc','cost','instock'),
array("WD", "80GB","WD800AAJS SATA2 7200rpm 8mb" ,"$36.90","Y"),
array("WD","160GB","WD1600AAJS SATA300 8mb 7200rpm" ,"$39.87","Y"),
array("WD", "80GB","800jd SATA2 7200rpm 8mb" ,"$41.90","Y"),
array("WD","250GB","WD2500AAKS SATA300 16mb 7200rpm" ,"$49.88","Y"),
array("WD","320GB","WD3200AAKS SATA300 16mb 7200rpm" ,"$49.90","Y"),
array("WD","160GB","1600YS SATA raid 16mb 7200rpm" ,"$59.90","Y"),
array("WD","500GB","500gb WD5000AAKS SATA2 16mb 7200rpm","$64.90","Y"),
array("WD","250GB","2500ys SATA raid 7200rpm 16mb" ,"$69.90","Y"),
);

//x is 0-600, y is 0-780 (origin is at bottom left corner)
$pdf =& new Cezpdf('LETTER');

$image = imagecreatefrompng("background.png");
$pdf->addImage($image,0,0,611);

$pdf->selectFont("fonts/Helvetica.afm");
$pdf->setColor(0/255,0/255,0/255);
$pdf->addText(80,620,10,"List of Hard Drives");

$pdf->setLineStyle(0.5);
$pdf->line(80,615,540,615);
$pdf->setStrokeColor(0,0,0);

$pdf->setColor(0/255,0/255,0/255);
$pdf->addText(30,16,8,"Created ".date("m/d/Y"));

$total=0;
$curr_x=80;
$curr_y=600;
foreach($rows as $r)
{
$xoffset = $curr_x;
foreach($r as $i=>$data)
{
$pdf->setColor(0/255,0/255,0/255);
$pdf->addText( $xoffset, $curr_y , 10, $data );
$xoffset+=$colw[$i];
}
$curr_y-=20;
}

$pdf->ezStream();
?>


Demo:
Download Demo PDF (dynamically generated with php)
Download all-in-one example.zip 349KB (includes ezPDF)

Notes:
* The above code generates a 1 page pdf, but a multi-page PDF is possible using the $pdf->ezNewPage() function. Any $pdf->addText() or $pdf->addImage() calls after that point are added to the new page.
* The size of a LETTER page in ezPDF is 612x792 (w by h in pixels)
* The (x,y) origin (0,0) is at the bottom left of a PDF page

Further Reading
* ezPDF and
* ezPDF API Docs[pdf]
* pdf-php at sourceforge

Thursday, 5 November 2009

Nepali Date, Get Nepali Date, Today's Nepali Date

You can Get Nepali Date to your site from us;
Nepali Date Sample
(no need to update daily, it will be auto update)

For that Please Contact at :
Email: info@grabhost.net
visit: www.date.grabhost.net

Thank You !!!

Friday, 30 October 2009

Regular Expression (Validation) Examples in PHP

The Regular Expressions quickly covers the basics of regular-expression syntax, then delves into the mechanics of expression-processing, common pitfalls, performance issues, and implementation-specific differences. Written in an engaging style and sprinkled with solutions to complex real-world problems, MRE offers a wealth information that you use. I will start with some simple usage examples of the regular expressions and continue with a huge list of cases for various situations where we would normally need a regex to operate. We will use simple functions which return TRUE or FALSE. $regex will serve as our regular expression to match against and $text will be our text (pretty obvious):
function do_reg($text, $regex)
{
 if (preg_match($regex, $text)) {
  return TRUE;
 }
 else {
  return FALSE;
 }
}
The next function will get the part of a given string ($text) matched by the regex ($regex) using a group srorage ($regs). By changing the $regs[0] to $regs[1] we can use a capturing group (in this case griup 1) to match against. The capturing group can also have a name ($regs['groupname']):
function do_reg($text, $regex, $regs)
{
 if (preg_match($regex, $text, $regs)) {
  $result = $regs[0];
 }
 else {
  $result = "";
 }
 return $result;
}  

The following function will return an array of all regex matches in a given string ($text):
function do_reg($text, $regex)
{
 preg_match_all($regex, $text, $result, PREG_PATTERN_ORDER);
 return $result = $result[0];
}

Next we can iterate (loop) over all matches in a string ($text) and output the results:
function do_reg($text, $regex, $regs)
{
 preg_match_all($regex, $text, $result, PREG_PATTERN_ORDER);
  for ($i = 0; $i < count($result[0]); $i++) {
  $result[0][$i];
 }
}  

Extending the above one we can iterate over all matches ($text) and capture groups in a string ($text):
function do_reg($text, $regex)
{
 preg_match_all($regex, $text, $result, PREG_SET_ORDER);
 for ($matchi = 0; $matchi < count($result); $matchi++) {
  for ($backrefi = 0; $backrefi < count($result[$matchi]); $backrefi++) {
   $result[$matchi][$backrefi];
  }
 }
} 

EXAMPLES:
For Date

$date_regex = "/^(0[1-9]|[12][0-9]|3[01])[\-\/\.](0[1-9]|1[012])[\-\/\.](19|20)[\d][\d]$/";
$date_regex = "/^(0[1-9]|[12][0-9]|3[01])[\-\/.](0[1-9]|1[012])[\-\/.](19|20)[\d][\d]$/";


//Date d/m/yy and dd/mm/yyyy
//1/1/00 through 31/12/99 and 01/01/1900 through 31/12/2099
//Matches invalid dates such as February 31st
'\b(0?[1-9]|[12][0-9]|3[01])[- /.](0?[1-9]|1[012])[- /.](19|20)?[0-9]{2}\b'

//Date dd/mm/yyyy
//01/01/1900 through 31/12/2099
//Matches invalid dates such as February 31st
'(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9]{2}'

//Date m/d/y and mm/dd/yyyy
//1/1/99 through 12/31/99 and 01/01/1900 through 12/31/2099
//Matches invalid dates such as February 31st
//Accepts dashes, spaces, forward slashes and dots as date separators
'\b(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2}\b'

//Date mm/dd/yyyy
//01/01/1900 through 12/31/2099
//Matches invalid dates such as February 31st
'(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)[0-9]{2}'

//Date yy-m-d or yyyy-mm-dd
//00-1-1 through 99-12-31 and 1900-01-01 through 2099-12-31
//Matches invalid dates such as February 31st
'\b(19|20)?[0-9]{2}[- /.](0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])\b'

//Date yyyy-mm-dd
//1900-01-01 through 2099-12-31
//Matches invalid dates such as February 31st
'(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])' 
/-------------------------------------------------------------------------------/ For Address /-------------------------------------------------------------------------------/
//Address: State code (US)
'/\\b(?:A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])\\b/'

//Address: ZIP code (US)
'\b[0-9]{5}(?:-[0-9]{4})?\b' 
/-------------------------------------------------------------------------------/ For Email /-------------------------------------------------------------------------------/
//Email address
//Use this version to seek out email addresses in random documents and texts.
//Does not match email addresses using an IP address instead of a domain name.
//Does not match email addresses on new-fangled top-level domains with more than 4 letters such as .museum.
//Including these increases the risk of false positives when applying the regex to random documents.
'\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b'

//Email address (anchored)
//Use this anchored version to check if a valid email address was entered.
//Does not match email addresses using an IP address instead of a domain name.
//Does not match email addresses on new-fangled top-level domains with more than 4 letters such as .museum.
//Requires the "case insensitive" option to be ON.
'^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$'

//Email address (anchored; no consecutive dots)
//Use this anchored version to check if a valid email address was entered.
//Improves on the original email address regex by excluding addresses with consecutive dots such as john@aol...com
//Does not match email addresses using an IP address instead of a domain name.
//Does not match email addresses on new-fangled top-level domains with more than 4 letters such as .museum.
//Including these increases the risk of false positives when applying the regex to random documents.
'^[A-Z0-9._%-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$'

//Email address (no consecutive dots)
//Use this version to seek out email addresses in random documents and texts.
//Improves on the original email address regex by excluding addresses with consecutive dots such as john@aol...com
//Does not match email addresses using an IP address instead of a domain name.
//Does not match email addresses on new-fangled top-level domains with more than 4 letters such as .museum.
//Including these increases the risk of false positives when applying the regex to random documents.
'\b[A-Z0-9._%-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b'

//Email address (specific TLDs)
//Does not match email addresses using an IP address instead of a domain name.
//Matches all country code top level domains, and specific common top level domains.
'^[A-Z0-9._%-]+@[A-Z0-9.-]+\.(?:[A-Z]{2}|com|org|net|biz|info|name|aero|biz|info|jobs|museum|name)$'

//Email address: Replace with HTML link
'\b(?:mailto:)?([A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4})\b' 
/-------------------------------------------------------------------------------/ For Credit Cards /-------------------------------------------------------------------------------/
//Credit card: All major cards
'^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$'

//Credit card: American Express
'^3[47][0-9]{13}$'

//Credit card: Diners Club
'^3(?:0[0-5]|[68][0-9])[0-9]{11}$'

//Credit card: Discover
'^6011[0-9]{12}$'

//Credit card: MasterCard
'^5[1-5][0-9]{14}$'

//Credit card: Visa
'^4[0-9]{12}(?:[0-9]{3})?$'

//Credit card: remove non-digits
'/[^0-9]+/'

//Delimiters: Replace commas with tabs
//Replaces commas with tabs, except for commas inside double-quoted strings
'((?:"[^",]*+")|[^,]++)*+,'

/-------------------------------------------------------------------------------/ For HTML /-------------------------------------------------------------------------------/
//HTML comment
''

//HTML file
//Matches a complete HTML file. Place round brackets around the .*? parts you want to extract from the file.
//Performance will be terrible on HTML files that miss some of the tags
//(and thus won't be matched by this regular expression). Use the atomic version instead when your search
//includes such files (the atomic version will also fail invalid files, but much faster).
'.*?.*?.*?.*?]*>.*?.*?'

//HTML file (atomic)
//Matches a complete HTML file. Place round brackets around the .*? parts you want to extract from the file.
//Atomic grouping maintains the regular expression's performance on invalid HTML files.
'(?>.*?)(?>.*?)(?>.*?)(?>.*?]*>)(?>.*?).*?'

//HTML tag
//Matches the opening and closing pair of whichever HTML tag comes next.
//The name of the tag is stored into the first capturing group.
//The text between the tags is stored into the second capturing group.
'<([A-Z][A-Z0-9]*)[^>]*>(.*?)'

//HTML tag
//Matches the opening and closing pair of a specific HTML tag.
//Anything between the tags is stored into the first capturing group.
//Does NOT properly match tags nested inside themselves.
'<%TAG%[^>]*>(.*?)'

//HTML tag
//Matches any opening or closing HTML tag, without its contents.
']*>' 

Thursday, 16 July 2009

Brute Force Protection

While trying to browse the site, if you get this
--------------------------------------------------------------------------------------------
The requested URL /suspended.page/ was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
------------------------------------------------------------------------------------------
It could be due to due to Brute force attempt was detected.

Brute Force Protection
This account is currently locked out because a brute force attempt was detected.
Please wait 10 minutes and try again. Attempting to login again will only increase this delay.
If you frequently experience this problem, we recommend having your username changed to something less generic.

Solution / Fix

Account Locks Out Due to Brute Force Protection in cPanel WebHost Manager (WHM)


Occasionally, when user or website administrator attempts to login to cPanel’s WebHost Manager (WHM), or remote or local log in via Telnet or SSH to Linux console to the web server, the login is denied and not allowed. The following error message may appear.

This account is currently locked out because a brute force attempt was detected. Please wait 10 minutes and try again. Attempting to login again will only increase this delay. If you frequently experience this problem, we recommend having your username changed to something less generic.


The brute force protection on cPanel-powerd web host is provided by cPHulk, which prevents malicious forces from trying to access the server’s services by guessing the login password for that service. When an account on the system has experienced too many failed login attempts, the particular account will automatically been “protected” by forbidding further login attempts, including all-important root account. cPHulk Brute Force Protection will also block out an IP address which has been detected to send too many unauthorized logon attempts.

As a result, server’s owner are potentially been locked out of the server if the cPHulkd is enabled, even the wild-guessing brute force hacking is done by hackers in another corner of the world.

When WHM locks out an user account, especially “root”, the best way is to wait for 10 minutes to see if the account will be unlocked. If the locks persists, webmaster and administrator who still can remote login via SSH to the server as root can manually remove the lockouts via following steps:

  1. Type mysql at console to access MySQL client.
  2. At MySQL client prompt, enter the following commands (preceding with mysql>)one after one, pressing Enter each time:

    mysql> use cphulkd;

    Expected result: Database changed.

    mysql> BACKUP TABLE `brutes` TO ‘/path/to/backup/directory’;
    mysql> BACKUP TABLE `logins` TO ‘/path/to/backup/directory’;

    Above command will backup the brutes table, the main table used by cPHulk to record locked accounts and denied IP addresses.

    mysql> DELETE FROM `brutes`;
    mysql> DELETE FROM `logins`;

    Above commands will remove all blocked IP addresses and locked accounts from the system, enabling full access again. If you’re familiar with SQL statements, it’s possible to use WHERE clause to specify logins or IP address that you want to remove only.

    mysql> quit;

    Exit MySQL client.

If you can’t login to the server due to brute force protection, you probably have to contact web hosting service provider support to physically access the server to remove the Brute Force Protection. To avoid future blockage or lock out, it’s recommended to add own IP address as Trusted Hosts List whitelist in cPHulk Brute Force Protection. To do so, go to WHM -> Security -> Security Center -> cPHulk Brute Force Protection. Inside “Configure cPHulk”, click Trusted Hosts List link.

Sunday, 28 June 2009

School Leaving Certificate (SLC) examination result 2065/2066 (2009 AD) has been just published by today...

School Leaving Certificate (SLC) examination result 2065/2066 (2009 AD) has been just published by today...

For details information, please do LogOn to http://www.nepalipathshala.com,

Best of luck for better result to you !!!

Thanks !!!

Tuesday, 9 June 2009

JQuery Fancy Box AutoClose, Auto Close Fancy Box, Auto Closing of Fancy Box iframe

Sample Code for Auto Close of Fancy Box ( JQuery Fancy Box AutoClose )

1. The parent page(file) from where the Fancy Box is called as;

-----parent.html---------
===================================
< type="text/javascript">
$().ready(function(){
'hideOnContentClick': true,'callbackOnShow': autoClose });
$("a.uploadVideo").fancybox({'frameWidth': 400, 'frameHeight':160});
});

< /script>

< type="text/javascript" src="http://localhost/test/jscripts/jquery.js">< /script>
< type="text/javascript" src="http://localhost/test/jscripts/jquery.fancybox/jquery.fancybox-1.2.1.pack.js">< /script>

<>
function triggerClose(){
var el = $("#fancyCloseId");
el.bind("click", $.fn.fancybox.close);
el.trigger('click');
}

function autoClose(){
setTimeout("triggerClose()",1000);
}
< /script>


<>
< class="iframe uploadVideo" href="iframepage.html?ie=UTF-8&aid=video">Video< /a>

< id="fancyCloseId">< /div < /body >


2. The Child ( or Light box) page included the following code.

===========================================
iframepage.html page
-----------------------

< type="text/javascript" src="http://localhost/test/jscripts/jquery.js">< /script>
< type="text/javascript" src="http://localhost/test/jscripts/jquery.fancybox/jquery.fancybox-1.2.1.pack.js">< /script>

<>
...........message here........
< /body>

$(function(){
if(typeof(parent.autoClose)=="function"){
parent.autoClose();
}
else {alert("Function not found")};
});
< / script >

Use the following code for JQuery Fancy Box Auto Close(Auto Close Fancy Box).

Thursday, 4 June 2009

Email Validation in PHP using Regular Experession


if((!ereg("[a-zA-Z0-9]+[\w{0}|\.|\-|_]+@[a-zA-Z0-9]+\.[a-zA-z]{2,4}$", $ email))
{
$email_error = 'set error message';
}

Wednesday, 27 May 2009

के गर्ने होला..?

पखालिएको मेरो मन...
पग्लिएको तिम्रो माया...
अनि यो एउटा बिचित्रको मतलबी संसारमा...
हेरन के गर्ने होला..?

Tuesday, 19 May 2009

Our Love

"Our love" was like one tale,
A Lost dream was like one fresh morning,
Hey "My Love", you forgot me exactly as
like mountain become the water river.

Wednesday, 18 March 2009

is Folder Option Vanished in your PC?

1.  Go to your Start menu, click on Run and open up your Registry Editor by typing "regedit" without the quotes and pressing OK.

2.  Once there go to: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folde r\Hidden\SHOWALL

3.  Delete the value CheckedValue. (Its type should be REG_SZ and data should be 2.)

4.  Create a new DWORD value called CheckedValue (same as above, except that the type is REG_DWORD) by right clicking on the right pane->New->DWORD Value. Modify the value data to 1 (0x00000001).

After this, it will let you change the "Hidden Files and Folders" option.

How to disable the Right Click on Web Page ?

To disable the Right Click on Web Pages, include the following JavaScript code on the such pages.....

< script language="javascript" >
window.onload = function() {
runmikescroll();
document.onmousedown = function() {return false;}
document.onselectstart = function() {return false;}
}

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {
if(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false");
< /script >

नेपली राष्टिय गान

सयौँ थुङ्गा फूलका हामी, एउटै माला नेपाली
सार्वभौम भई फैलिएका, मेची महाकाली

प्रकृतिका कोटीकोटी, सम्पदाको आँचल
वीरहरुका रगतले, स्वतन्त्र र अटल

ज्ञानभूमि, शान्तिभूमि, तराई, पहाड, हिमाल
अखण्ड यो प्यारो मातृभूमि नेपाल

बहुल जाति, भाषा, धर्म, संस्कृति छन् विशाल
अग्रगामी राष्ट्र हाम्रो, जय-जय नेपाल ।

रचनाकारः व्याकुल माइला (प्रदीपकुमार राई),
सङ्गीतकारः अम्बर गुरुङ
सङ्गीत संयोजनः शरद गुरुङ
गायक/गायिकाः ज्ञानु राणा, शिशिर योगी, सुनिता सुब्बा, यम बराल, विमला राई, अन्जु पन्त, अजय थापा, जयनन्द लामा, बेनुका राई, झुमा लिम्बू, रुपा झा, चन्दा देवान, राजेशपायल राई, अनीलमान महर्जन, गॅगा न्यौपाने, नारायण ओली, राजेन्द्रमान श्रेष्ठ, राम गुरुङ, रीना भुसाल, सृजना श्रेष्ठ ।

Nepal Nation Anthem (in english)

We are hundreds of flowers, the one garland - Nepali
Sovereign, spread out from Mechi to Mahakali.

Amassing nature's millions of resources
By the blood of heroes, independent and immovable.

Land of knowledge, land of peace, Terai, hills, mountains
Indivisible this beloved, our motherland Nepal.

The diverse races, languages, faiths, and cultures are so extensive
Our progressive nation, long live Nepal.

Friday, 6 February 2009

Do you know how to retieve the form value from bean in MVC Framework in Coldfusion ?

While working with MVC framework, if you want to retrieve the value from UI form elements to bean file of model.
Sometimes, we have this kinda problem, we are not able to retrieve value from bean. To resolve the value which are provided to UI, at that time, the Name of function on Bean file should be exactly same as the elements NAME value in UI.

Lets take a small example here,
you make a userBean.cfc at with the following content;

< cfcomponent output="false" name="userBean" displayName="Users Bean" >
< cfset variables.instance.username = "" / >
< cfset variables.instance.password = "" / >

< cffunction name="setUsername" returnType="void" access="public" output="false" >
< cfargument name="username" type="string" required="true" >
< cfset variables.instance.username = arguments.username >
< /cffunction >

< cffunction name="getUsername" returnType="string" access="public" output="false" >
< cfreturn variables.instance.username >
< /cffunction >

< cffunction name="setPassword" returnType="void" access="public" output="false" >
< cfargument name="password" type="string" required="true" >
< cfset variables.instance.password = arguments.password >
< /cffunction >

< cffunction name="getPassword" returnType="string" access="public" output="false" >
< cfreturn variables.instance.password >
< /cffunction >
< /cfcomponent >

you have a UI file as login.cfm at with the following content;
 
< cfform action="#viewstate.getValue('myself')#adminLoggedIn" method="post" >
< span >Sign In< /span >
< label for="username" >Email:< /label >
< cfinput type="text" name="username" value=""/ >< br / >
< label for="password" >Password:< /label >
< cfinput type="password" name="password" value=""/ >< br / >
< input type="submit" value="Submit" / >
< /cfform >

Now, if you go through above Bean file (userBean.cfc) & UI file (login.cfm),
the name= "username" and name="password" of login.cfm file have same name as the function name of userBean.cfc file as
setUsername();
getUsername();
setPassword();
getPassword();

Which do really work out.

if name value of login form and function name after have get/set prefix should be exactly same, otherwise it will not work out.

Tuesday, 6 January 2009

New Year Greeting


Hi everyone,
Wish yOu a very Happy New Year 2009

May this New Year bring you more success
&
pleasure at every steps...