Monday, December 20, 2010
Authorize.Net Direct Post Method (DPM)
you can find more detail of Authorize.Net Direct Post Method (DPM) on http://www.articlesrain.com/tutorial/index.php/2010/12/authorize-net-direct-post-method-dpm/
Wednesday, April 28, 2010
How to add days, weeks, months to any date ?
$date = date("Y-m-d");// current date
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");
echo date("Y-m-d", $date);//Now your can see added date
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");
echo date("Y-m-d", $date);//Now your can see added date
Friday, February 12, 2010
how can login in ilias with own page
//you can also use in another way
/////////////////////This concept is used on gradtrain.com////////////////
/////////////////////This concept is used on gradtrain.com////////////////
File upload like gmail
Step1: Create A file name index.php
File Uploading Like Gmail. You can upload multiple files without submitting the whole page. You can upload file like ajax. This is using iframe for file upload
Step2:create a file upload.php
File Uploading Like Gmail. You can upload multiple files without submitting the whole page. You can upload file like ajax. This is using iframe for file upload
Step2:create a file upload.php
Tuesday, January 12, 2010
Check Date Between Two Dates in PHP
function dateBetween( $checkDate )
{
$firstDate1 = strtotime( "15-Jan-2008" );
$firstDate2 = strtotime( "15-Mar-2008" );
$secondDate1 = strtotime( "16-Mar-2008" );
$secondDate2 = strtotime( "15-Jun-2008" );
$checkDate = strtotime( $checkDate );
if( $checkDate > $firstDate1 && $checkDate < $firstDate2 )
{
return "2000";
}
elseif( $checkDate > $secondDate1 && $checkDate < $secondDate2 )
{
return "4000";
}
return "0";
}
echo dateBetween( "25-Sep-2008" );
?>
Thursday, December 10, 2009
How to calculate the date difference between 2 dates using php
$date1 = "2006-03-25";
$date2 = "2009-11-10";
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
printf("%d years, %d months, %d days\n", $years, $months, $days);
$date2 = "2009-11-10";
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
printf("%d years, %d months, %d days\n", $years, $months, $days);
Monday, September 21, 2009
File Handling in php Through Class
class File{
private $fileName;
private $fileMode;
private $filePointer;
private $fileSize;
public function File($fileName='',$fileMode='',$fileSize=''){
//echo "
Construcor Call
";
if(!empty($fileName))
$this->fileName=$fileName;
if(!empty($fileMode))
$this->fileMode=$fileMode;
if(empty($fileSize))
$this->fileSize=filesize($this->fileName);
else
$this->fileSize=$fileSize;
}
function FileDetail(){
echo "
fileName[$this->fileName] fileMode[$this->fileMode][$this->filePointer] fileSize[$this->fileSize]
";
}
function FileExists($fileName){
if(!file_exists($fileName)){
echo "Error: This file does not exist!";
exit();
}
}
public function OpenFile(){
if(!$this->filePointer=fopen($this->fileName,$this->fileMode)){
echo "Cannot open file ($this->fileName)";
exit;
}
}
public function CloseFile(){
fclose($this->filePointer);
}
public function CheckFileMode($fileMode){
}
public function SetNameSize($fileName='',$fileSize=''){
if(!empty($fileName))
$this->fileName=$fileName;
if(empty($fileSize))
$this->fileSize=filesize($this->fileName);
else if(gettype($fileSize)=='integer')
$this->fileSize=$fileSize;
else {
echo "Erro:Invalid File Size only use Integer value!";
exit();
}
}
function SetStringSize($string){
$this->fileSize=strlen($string);
}
public function SetMode($fileMode){
$this->fileMode=$fileMode;
}
public function ReadFile($fileName='',$fileSize=''){
$this->FileExists($fileName);
$this->SetNameSize($fileName,$fileSize);
$this->SetMode('r');
$this->OpenFile();
if($this->fileSize>0)
return fread($this->filePointer,$this->fileSize);
else
return fread($this->filePointer);
}
public function WriteFile($fileName,$content,$fileSize='',$fileMode='w'){
$this->FileExists($fileName);
$this->SetNameSize($fileName,$fileSize);
if(empty($fileSize))
$this->SetStringSize($content);
$this->SetMode($fileMode);
$this->OpenFile();
if($this->fileSize>0)
return fwrite($this->filePointer,$content,$this->fileSize);
else
return fwrite($this->filePointer,$content);
}
public function SearchFile($fileName,$content){
return strpos($this->ReadFile($fileName),$content);
}
function AppendFile($fileName,$content){
$this->FileExists($fileName);
$this->SetNameSize($fileName);
$this->SetMode('a');
$this->OpenFile();
if($this->fileSize>0)
return fwrite($this->filePointer,$content,$this->fileSize);
else
return fwrite($this->filePointer,$content);
}
function ReplaceFile($fileName,$search,$replace){
return $this->WriteFile($fileName,str_replace($search, $replace,$this->ReadFile($fileName)));
}
}
?>
//Class Test
$file=new File();
echo $file->ReadFile('test.txt);
//$file->WriteFile('test.txt','this is new text in this file the quick brown fox jumpso over the lazy dog');
//echo $file->SearchFile('test.txt','love')
//$file->AppendFile('test.txt','rajput');
//$file->ReplaceFile('test.txt','rajput','change');
?>
private $fileName;
private $fileMode;
private $filePointer;
private $fileSize;
public function File($fileName='',$fileMode='',$fileSize=''){
//echo "
Construcor Call
";
if(!empty($fileName))
$this->fileName=$fileName;
if(!empty($fileMode))
$this->fileMode=$fileMode;
if(empty($fileSize))
$this->fileSize=filesize($this->fileName);
else
$this->fileSize=$fileSize;
}
function FileDetail(){
echo "
fileName[$this->fileName] fileMode[$this->fileMode][$this->filePointer] fileSize[$this->fileSize]
";
}
function FileExists($fileName){
if(!file_exists($fileName)){
echo "Error: This file does not exist!";
exit();
}
}
public function OpenFile(){
if(!$this->filePointer=fopen($this->fileName,$this->fileMode)){
echo "Cannot open file ($this->fileName)";
exit;
}
}
public function CloseFile(){
fclose($this->filePointer);
}
public function CheckFileMode($fileMode){
}
public function SetNameSize($fileName='',$fileSize=''){
if(!empty($fileName))
$this->fileName=$fileName;
if(empty($fileSize))
$this->fileSize=filesize($this->fileName);
else if(gettype($fileSize)=='integer')
$this->fileSize=$fileSize;
else {
echo "Erro:Invalid File Size only use Integer value!";
exit();
}
}
function SetStringSize($string){
$this->fileSize=strlen($string);
}
public function SetMode($fileMode){
$this->fileMode=$fileMode;
}
public function ReadFile($fileName='',$fileSize=''){
$this->FileExists($fileName);
$this->SetNameSize($fileName,$fileSize);
$this->SetMode('r');
$this->OpenFile();
if($this->fileSize>0)
return fread($this->filePointer,$this->fileSize);
else
return fread($this->filePointer);
}
public function WriteFile($fileName,$content,$fileSize='',$fileMode='w'){
$this->FileExists($fileName);
$this->SetNameSize($fileName,$fileSize);
if(empty($fileSize))
$this->SetStringSize($content);
$this->SetMode($fileMode);
$this->OpenFile();
if($this->fileSize>0)
return fwrite($this->filePointer,$content,$this->fileSize);
else
return fwrite($this->filePointer,$content);
}
public function SearchFile($fileName,$content){
return strpos($this->ReadFile($fileName),$content);
}
function AppendFile($fileName,$content){
$this->FileExists($fileName);
$this->SetNameSize($fileName);
$this->SetMode('a');
$this->OpenFile();
if($this->fileSize>0)
return fwrite($this->filePointer,$content,$this->fileSize);
else
return fwrite($this->filePointer,$content);
}
function ReplaceFile($fileName,$search,$replace){
return $this->WriteFile($fileName,str_replace($search, $replace,$this->ReadFile($fileName)));
}
}
?>
//Class Test
$file=new File();
echo $file->ReadFile('test.txt);
//$file->WriteFile('test.txt','this is new text in this file the quick brown fox jumpso over the lazy dog');
//echo $file->SearchFile('test.txt','love')
//$file->AppendFile('test.txt','rajput');
//$file->ReplaceFile('test.txt','rajput','change');
?>
Subscribe to:
Posts (Atom)