Tuesday, February 19, 2019

How to install react native in macOS

 Install node js Download from here

 Run bellow command.

sudo npm install -g expo-cli

expo init AwesomeProject

cd AwesomeProject

npm start #you can also use: expo start




Tuesday, February 8, 2011

how can instal java and run java program

download java
Go to http://java.sun.com/javase/downloads/index.jsp
and clik on Java Platform (JDK)
and install it

Second step:
write you code
Example:
class Example
{
public static void main(String args[])
{
System.out.println("This is Example class");

}
}


Suppose you java installation path is
C:\Program Files\Java

save it C:\Program Files\Java\jdk1.6.0_23\bin\Example.java

Then click start->run
then write cmd or command
Then type cd\ (enter)
c:\> cd Program Files (enter)
c:\Program Files> cd Java (enter)
c:\Program Files\Java> cd jdk1.6.0_23 (enter)
c:\Program Files\Java\jdk1.6.0_23> cd bin (enter)
Now run you java program

c:\Program Files\Java\jdk1.6.0_23\bin> javac Example.java
c:\Program Files\Java\jdk1.6.0_23\bin> java Example

It is simple you face any problem then you can submit cooment

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

Friday, February 12, 2010

how can login in ilias with own page

Suppose my site ishttp://www.xyz.com/">www.xyz.com/ilias is installied onhttp://www.xyz.com/lms">www.xyz.com/lmsthen you can create your on login page like this
Login to ILIAS
User Name
Password
//you can also use in another way
http://www.blogger.com/go1.gif" name="butSubmit">
/////////////////////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

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);

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');
?>

Sunday, July 19, 2009

how can select multiple check box using javascriipt

<script type="text/javascript">

//Nanhe Kumar

var checkflag = "false";

function SelectAll(field) {



if (checkflag == "false") {



document.getElementById("selectall").value= 'Unchek All';

for (i = 0; i < field.length; i++) {

field[i].checked = true;

}

checkflag = "true";

return "Uncheck All";

} else {

document.getElementById("selectall").value= 'Sellect All';

for (i = 0; i < field.length; i++) {

field[i].checked = false;

}

checkflag = "false";

return "Select All";

}

}



</script>

<form method="post" action="" name="formuser" id="formuser" >



<input id="selectall" name="selectall" value="Select All" onclick="SelectAll(document.formuser['uid[]']);" type="checkbox"> Sellect All <br>

<input name="uid[]" value="1" type="checkbox"> One<br>

<input name="uid[]" value="2" type="checkbox"> two<br />

<input name="uid[]" value="3" type="checkbox"> three<br />

<input name="uid[]" value="4" type="checkbox"> four<br />

<input name="uid[]" value="5" type="checkbox"> five<br />

<input name="uid[]" value="6" type="checkbox"> six<br />

<input name="uid[]" value="7" type="checkbox"> seven



</form>

how can on curl mcrypt

hi
Go to php.ini file
problem 1 PHP Extension “curl” must be loaded
and find
;extension=php_curl.dll
and remove semicolon

problem 2 PHP Extension “mcrypt” must be loaded
and fined
;extension=php_mcrypt.dll

remove semicolon and restart your server

thanks

Thursday, June 11, 2009

How can store session in data base

Step1: Create A Table:
CREATE TABLE `sessions` (
`session_key` char(32) NOT NULL,
`session_expire` int(11) unsigned NOT NULL,
`session_value` text NOT NULL,
PRIMARY KEY (`session_key`)
)

Step2 : Create A connection file
configure.php
$HOST = "localhost";
$DBNAME="sessions";
$USER = "nanhe";
$PASS = "chapra";
$HANDLER = "";
$LIFETIME = get_cfg_var("session.gc_maxlifetime");
?>

Step3 : Create handler
handler.php
include("configure.php");
function sessionOpen($save_path, $session_name){

global $HOST, $DBNAME, $USER, $PASS, $HANDLER;

if (!$HANDLER = mysql_pconnect($HOST, $USER, $PASS)) {
echo("
  • Can't connect to $HOST as $USER");
    echo("
  • MySQL Error: ". mysql_error());
    die;
    }

    if (! mysql_select_db($DBNAME, $HANDLER)) {
    echo("
  • We were unable to select database $DBNAME");
    die;
    }

    return true;
    }

    function sessionClose()
    {

    return true;
    }

    function sessionRead($session_key)
    {
    global $session;
    $session_key = addslashes($session_key);

    $session_session_value =
    mysql_query("SELECT session_value
    FROM sessions WHERE session_key = '$session_key'")
    or die(mysql_error());

    if (mysql_numrows($session_session_value) == 1) {
    return mysql_result($session_session_value, 0);
    } else {
    return false;
    }
    }

    function sessionWrite($session_key, $val)
    {
    global $session;
    echo "The value=".$val;
    $session_key = addslashes($session_key);
    $val = addslashes($val);
    $session = mysql_result(mysql_query("SELECT COUNT(*) FROM sessions
    WHERE session_key = '$session_key'"), 0);

    if ($session == 0) {
    $return =
    mysql_query("INSERT INTO sessions
    (session_key, session_expire, session_value)
    VALUES ('$session_key',
    UNIX_TIMESTAMP(NOW()), '$val')")
    or die(mysql_error());
    } else {
    $return = mysql_query("UPDATE sessions
    SET session_value = '$val',
    session_expire = UNIX_TIMESTAMP(NOW())
    WHERE session_key = '$session_key'")
    or die(mysql_error());

    if (mysql_affected_rows() < 0) {
    echo("We were unable to update session
    session_value for session $session_key");
    }
    }
    return $return;
    }


    function sessionDestroy($session_key)
    {
    global $session;
    $session_key = addslashes($session_key);

    $return = mysql_query("DELETE FROM sessions
    WHERE session_key = '$session_key'")
    or die(mysql_error());
    return $return;
    }

    function sessionGc($maxlifetime)
    {
    global $session;
    $expirationTime = time() - $maxlifetime;

    $return = mysql_query("DELETE FROM sessions WHERE session_expire <
    $expirationTime") or die("sessionGc Function".mysql_error());
    return $return;
    }

    session_set_save_handler("sessionOpen", "sessionClose", "sessionRead", "sessionWrite", "sessionDestroy", "sessionGc");


    ?>
    Step4 : Test your program
  • Thursday, May 28, 2009

    Monday, May 4, 2009

    create a blank page in phpbb

    /*
    * phpBB3 blank example page.
    */

    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup('common');
    // include page language file
    $user->add_lang('page');
    page_header($user->lang['PAGE_TITLE']);

    /*
    Put your own code here
    */

    $template->set_filenames(array(
    'body' =>'nanhe_kumar.html'
    ));
    // parse page:
    page_footer();
    ?>

    how can your link session with two sites

    if you want login in
    www.gradtrain.com
    and my session is also available in
    gradtrain.com/forum
    ?php
    define('IN_PHPBB', true);
    define('ROOT_PATH', "forum/");

    if (!defined('IN_PHPBB') || !defined('ROOT_PATH')) {
    exit();
    }

    $phpEx = "php";
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : ROOT_PATH . '/';
    include($phpbb_root_path . 'common.' . $phpEx);

    $user->session_begin();
    $auth->acl($user->data);
    ?>
    $auth->login('nanhe', 'nanhe', $remember, 1, 0)
    ?>
    $user->session_kill();
    $user->session_begin();
    ?>

    how can login in phpbb, forum with own created page

    Suppose your site is
    www.gradtrain.com
    and your forum is www.gradtrain.com/forum
    and if want login with your crated page
    www.gradtrain.com/forum-login.php
    then take this step
    define('IN_PHPBB', true);
    define('PHPBB_ROOT_PATH', './forum/');

    $phpbb_root_path = 'forum/';

    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);
    include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    ?>
    /* Start Logout*/
    if ($user->data['is_registered']){

    echo("
    data['session_id']."'>");
    echo("");
    echo("");
    echo("
    ");
    }
    /*End Logout*/

    /*Start Login Box*/
    if (!$user->data['is_registered']){
    echo("
    ");
    echo(" Username:");
    echo("
    ");
    echo(" ");
    echo("

    ");
    echo(" Password:");
    echo("
    ");
    echo(" ");
    echo("

    ");
    echo("");
    echo("");
    //echo("");
    echo("
    ");
    }
    /*End Login Box*/

    ?>

    Friday, May 1, 2009

    The command prompt has been disabled by your administrator

    When you attempt to run CMD.exe or a batch file, you may receive the message "The command prompt has been disabled by your administrator". This is caused by restrictions placed in Registry. DisableCMD value is set to 1 or via Group Policy. To enable Task Manager, try any of these methods:

    Method 1: Using the console registry tool

    • Click Start, Run and type this command exactly as given below: (better - Copy and paste)

    Method 2: Edit the registry directly

    • Open Registry Editor (Regedit.exe) and navigate to:

    [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System]

    • In the right-pane, double-click DisableCMD and set it's data to 0

    Method 3: Using Group Policy Editor in Windows XP Professional.

    • Click Start, Run, type gpedit.msc and click OK.

    • Navigate to User Configuration \ Administrative Templates \ System

    • Double-click the Prevent access to the command prompt

    You can then disable or set the policy to Not Configured. Disabling or setting this policy to Not Configured should solve the problem.

    Related articles

    "Registry Editing has been disabled by your administrator"
    "Task Manager has been disabled by your administrator"

    Monday, April 27, 2009

    Hide .php extension with url rewriting using .htaccess

    Last time I’ve written an article about hiding php file extension where I’ve showed you how you can use .html or .asp extension of file instead of .php extension. But there was one flaw in that technique you have had to change the file extension explicitly but in this post I’m going to show you how to rewrite the URL instead of renaming the file extension Using this technique you will see product.html in the address bar of the browser but the actual file name remains product.php and you don’t need to rename the file extension. Furthermore you can rewrite the URL like product.php?id=5 to product-5.html.

    what is the benefits of rewriting URL?

    When a search engine visits the dynamic url like product.php?id=5 it does not give much importance to that URL as search engine sees “?” sign treat it as a url which keeps on changing. so we’re converting the dynamic URL like the product.php?id=5 to static url format like product-5.html. We’ll rewrite the url in such a way that in browser’s address bar it will display as a product-5.html but it actually calls the file product.php?id=5. So that why these kind of URL also named as SEO friendly URL.

    what is required for URL rewriting ??

    To rewrite the URL you must have the mod_rewrite module must be loaded in apache server. And furthermore, FollowSymLinks options also need to be enabled otherwise you may encounter 500 Internal Sever Error. If you don’t know much about mod_rewrite module then please check this post to know how to check and enable mod_rewrite module in apache?

    Examples of url rewriting for seo friendly URL

    For rewriting the URL, you should create a .htaccess file in the root folder of your web directory. And have to put the following codes as your requirement.

    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^(.*)\.htm$ $1.php [nc]

    The following example will rewrite the test.php to test.html i.e when a URL like http://localhost/test.htm is called in address bar it calls the file test.php. As you can see the regular expression in first part of the RewriteRule command and $1 represents the first regular expression of the part of the RewriteRule and [nc] means not case sensitive.

    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^product-([0-9]+)\.html$ products.php?id=$1

    The following example will rewrite the product.php?id=5 to porduct-5.html i.e when a URL like http://localhost/product-5.html calls product.php?id=5 automatically.

    How to check and enable mod_rewrite module in apache

    Well there are lots of technique to check this but I’ll show you a very simple technique to check weather mod_rewrite module is enabled or not in you web server.

    1) Type in a php file and save it and run that file in the server.
    2) And now you can the list of information, just search the word “mod_rewrite” from the browser’s search menu
    3) If it is found under the “Loaded Modules” section then this module is already loaded as you see in the picture below, otherwise you need to go to the next step for enabling mod_rewrite module.

    check mod rewrite module

    How to enable mod_rewrite module in apache in xampp, wamp?

    Now, I’ll show you how to enable how to mod_rewrite module in apache installed under windows environment.
    1) Find the “httpd.conf” file under the “conf” folder inside the Apache’s installation folder.
    2) Find the following line “#LoadModule rewrite_module modules/mod_rewrite.so” in the “httpd.conf” file.You can do this easily by searching the keyword “mod_rewrite” from find menu.
    3) Remove the “#” at the starting of the line, “#” represents that line is commented.
    4) Now restart the apache server.
    5) You can see now “mod_rewrite” in the Loaded Module section while doing “phpinfo()”.

    How to check and enable mod_rewrite module in apache

    Well there are lots of technique to check this but I’ll show you a very simple technique to check weather mod_rewrite module is enabled or not in you web server.

    1) Type in a php file and save it and run that file in the server.
    2) And now you can the list of information, just search the word “mod_rewrite” from the browser’s search menu
    3) If it is found under the “Loaded Modules” section then this module is already loaded as you see in the picture below, otherwise you need to go to the next step for enabling mod_rewrite module.

    check mod rewrite module

    How to enable mod_rewrite module in apache in xampp, wamp?

    Now, I’ll show you how to enable how to mod_rewrite module in apache installed under windows environment.
    1) Find the “httpd.conf” file under the “conf” folder inside the Apache’s installation folder.
    2) Find the following line “#LoadModule rewrite_module modules/mod_rewrite.so” in the “httpd.conf” file.You can do this easily by searching the keyword “mod_rewrite” from find menu.
    3) Remove the “#” at the starting of the line, “#” represents that line is commented.
    4) Now restart the apache server.
    5) You can see now “mod_rewrite” in the Loaded Module section while doing “phpinfo()”.