Regular Expression Cheatsheet
posted by adityachandra @ 10:13 PM, ,
<?php
class DATABASE_CONFIG {
var $development = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'port' => '',
'login' => 'your_local_username',
'password' => 'your_local_password',
'database' => 'your_local_database',
'schema' => '',
'prefix' => '',
'encoding' => ''
);
var $production = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'your_remote_server',
'port' => '',
'login' => 'your_remote_username',
'password' => 'your_remote_password',
'database' => 'your_remote_database',
'schema' => '',
'prefix' => '',
'encoding' => ''
);
var $default = array();
function __construct(){
$this->default = ($_SERVER['SERVER_ADDR'] == '127.0.0.1') ? $this->development : $this->production;
}
function DATABASE_CONFIG(){
$this-> __construct();
}
}
?>
Configure::write('debug',2);
if($_SERVER['SERVER_ADDR'] == '127.0.0.1'){
Configure::write('debug', 2);
}else{
Configure::write('debug', 0);
}
Labels: advanced database switching cakephp, cakephp, change database cakephp, database switching cakephp, debug cakephp
posted by adityachandra @ 11:18 PM, ,
In some pages(like creditcard payment page or any other authentication page) we have to avoid the drop down which was appeared below the input text elements. This is active by default in a web browser.
To avoid the autocomplete of input text elements add autocomplete="off" attribute to your input element.
For example..
<input id="creditcardnumber" name="creditcardnumber" autocomplete="off" type="text">
Labels: autocomplete off, cache php off, disable caching php, php
posted by adityachandra @ 1:56 PM, ,
1) If you want to exclude a single directory.
tar -cvf /home/Virtualhosts/foostor.zip /home/Virtualhosts/foo --exclude "/home/Virtualhosts/foo/yourdirectory"
2) If you want to exclude multiple directories .
tar -cvf /home/Virtualhosts/foostor.zip /home/Virtualhosts/foo --exclude "/home/Virtualhosts/foo/yourdirectory1" --exclude "/home/Virtualhosts/foo/yourdirectory2" --exclude "/home/Virtualhosts/foo/yourdirectory3"
Labels: exclude zip linux, linux, tar linux, zip linux
posted by adityachandra @ 1:19 PM, ,
Hello Readers( if any ;) ) . Encryption and Decryption is one of the most useful and widely used technique when we want to pass values through URL (or) for encrypting the sensitive data. I googled over the Internet for these functions and finally i got them. Here are the two simple functions to encrypt and decrypt the the data with a key (or) password.
First, let us see the ENCRYPT function
/** Input Parameters are
** $string- The string you want to encrypt
** $key- string(it's like a password)
**/
function encrypt($string, $key) {
$result ='';
for($i=0; $i
//enode the result using base64 function for more security
return base64_encode($result);
}
?>
Now head on to DECRYPT function.
/** Input Parameters are
** $string- The string you want to encrypt
** $key- string(it's like a password)
**/
function decrypt($string, $key) {
$result ='';
//decode the result using base64 decode function
$string = base64_decode($string);
for($i=0; $i
?>
USAGE:
//Here we are encrypting "foobar" using the key "wordpress"
$encoded = encrypt("foobar","wordpress");
//Here we are decrypting "foobar" using the key "wordpress"
$decoded= decrypt($encoded,"wordpress");
Labels: decrypt php, encrypt php, encryption decryption php, php
posted by adityachandra @ 12:55 PM, ,
Here is java script function to calculate the date difference in number of days.
function dateDiff(date1,date2) {
//Date Format YYYY-MM-DD
var startingdate = date1.split("-");
var startingdate=new Date(startingdate[0], startingdate[1], startingdate[2]) ;//Month is 0-11 in JavaScript
var endingdate = date2.split("-");
var endingdate=new Date(endingdate[0], endingdate[1], endingdate[2]) ;//Month is 0-11 in JavaScript
var one_day=1000*60*60*24;
alert("Difference is "+Math.ceil((endingdate.getTime()-startingdate.getTime())/(one_day))+" days ");
}
Points to Remember
Labels: date diff javascript, date difference javascript, javascript
posted by adityachandra @ 11:04 PM, ,