Javascript all key validation
function validateNumberKey(event) {
var key = window.event ? event.keyCode : event.which;
if (event.keyCode == 8 || event.keyCode == 46
|| event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 9) {
return true;
}
else if ( key < 48 || key > 57 ) {
return false;
}
else return true;
}
function validateAlphaNumericKey(event) {
var key = window.event ? event.keyCode : event.which;
if (event.keyCode == 8 || event.keyCode == 46
|| event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 9) {
return true;
}
else if ( key >= 48 && key <= 57 )
{
return true;
}
else if ( key >= 65 && key <= 90 )
{
return true;
}
else if ( key >= 97 && key <= 122 )
{
return true;
}
else return false;
}
function validateAlphabeticKey(event) {
var key = window.event ? event.keyCode : event.which;
if (event.keyCode == 8 || event.keyCode == 46
|| event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 9) {
return true;
}
else if ( key >= 65 && key <= 90 )
{
return true;
}
else if ( key >= 97 && key <= 122 )
{
return true;
}
else return false;
}
Number :
AlphaNumeric :
Alphabetic :
Research and Development work on PHP, MYSQ,JQuery,Angular Js,React Native,Laravel,Wordpress,Magento,Joomla
Wednesday, June 27, 2012
Sunday, June 24, 2012
Create table through javascript
Javascript all key validation
function validateNumberKey(event) {
var key = window.event ? event.keyCode : event.which;
if (event.keyCode == 8 || event.keyCode == 46
|| event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 9) {
return true;
}
else if ( key < 48 || key > 57 ) {
return false;
}
else return true;
}
function validateAlphaNumericKey(event) {
var key = window.event ? event.keyCode : event.which;
if (event.keyCode == 8 || event.keyCode == 46
|| event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 9) {
return true;
}
else if ( key >= 48 && key <= 57 )
{
return true;
}
else if ( key >= 65 && key <= 90 )
{
return true;
}
else if ( key >= 97 && key <= 122 )
{
return true;
}
else return false;
}
function validateAlphabeticKey(event) {
var key = window.event ? event.keyCode : event.which;
if (event.keyCode == 8 || event.keyCode == 46
|| event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 9) {
return true;
}
else if ( key >= 65 && key <= 90 )
{
return true;
}
else if ( key >= 97 && key <= 122 )
{
return true;
}
else return false;
}
Number : <input type="text" name="number" onkeypress="return validateNumberKey(event)"/>
AlphaNumeric : <input type="alphanumaric" name="an" onkeypress="return validateAlphaNumericKey(event)"/>
Alphabetic : <input type="text" name="fname" onkeypress="return validateAlphabeticKey(event)" />
function validateNumberKey(event) {
var key = window.event ? event.keyCode : event.which;
if (event.keyCode == 8 || event.keyCode == 46
|| event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 9) {
return true;
}
else if ( key < 48 || key > 57 ) {
return false;
}
else return true;
}
function validateAlphaNumericKey(event) {
var key = window.event ? event.keyCode : event.which;
if (event.keyCode == 8 || event.keyCode == 46
|| event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 9) {
return true;
}
else if ( key >= 48 && key <= 57 )
{
return true;
}
else if ( key >= 65 && key <= 90 )
{
return true;
}
else if ( key >= 97 && key <= 122 )
{
return true;
}
else return false;
}
function validateAlphabeticKey(event) {
var key = window.event ? event.keyCode : event.which;
if (event.keyCode == 8 || event.keyCode == 46
|| event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 9) {
return true;
}
else if ( key >= 65 && key <= 90 )
{
return true;
}
else if ( key >= 97 && key <= 122 )
{
return true;
}
else return false;
}
Number : <input type="text" name="number" onkeypress="return validateNumberKey(event)"/>
AlphaNumeric : <input type="alphanumaric" name="an" onkeypress="return validateAlphaNumericKey(event)"/>
Alphabetic : <input type="text" name="fname" onkeypress="return validateAlphabeticKey(event)" />
PHP Script to read doc file
<?php
function parseWord($userDoc)
{
$fileHandle = fopen($userDoc, "r");
$line = @fread($fileHandle, filesize($userDoc));
$lines = explode(chr(0x0D),$line);
$outtext = "";
foreach($lines as $thisline)
{
$pos = strpos($thisline, chr(0x00));
if (($pos !== FALSE)||(strlen($thisline)==0))
{
} else {
$outtext .= $thisline." ";
}
}
$outtext = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext);
return $outtext;
}
$userDoc = "aa.doc";
$text = parseWord($userDoc);
echo $text;
?>
function parseWord($userDoc)
{
$fileHandle = fopen($userDoc, "r");
$line = @fread($fileHandle, filesize($userDoc));
$lines = explode(chr(0x0D),$line);
$outtext = "";
foreach($lines as $thisline)
{
$pos = strpos($thisline, chr(0x00));
if (($pos !== FALSE)||(strlen($thisline)==0))
{
} else {
$outtext .= $thisline." ";
}
}
$outtext = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$outtext);
return $outtext;
}
$userDoc = "aa.doc";
$text = parseWord($userDoc);
echo $text;
?>
PHP Script to remove directory from project
function delete_directory($dirname) {
if (is_dir($dirname))
$dir_handle = opendir($dirname);
if (!$dir_handle)
return false;
while($file = readdir($dir_handle)) {
if ($file != "." && $file != "..") {
if (!is_dir($dirname."/".$file))
unlink($dirname."/".$file);
else
delete_directory($dirname.'/'.$file);
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
delete_directory("first directory");
if (is_dir($dirname))
$dir_handle = opendir($dirname);
if (!$dir_handle)
return false;
while($file = readdir($dir_handle)) {
if ($file != "." && $file != "..") {
if (!is_dir($dirname."/".$file))
unlink($dirname."/".$file);
else
delete_directory($dirname.'/'.$file);
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
delete_directory("first directory");
apply browserwise css
.top_search {
margin-top:-11px;
* margin-top:-2px; ////////for IE 7
margin-left:95px;
/*width:170px;*/
width:107px;
padding-left:10px;
background:transparent;
border:0px;
}
///// this is for google chrome css /////////////
@media screen and (-webkit-min-device-pixel-ratio:0) {
.top_search
{
margin-top:-13px;
}
}
input[type='submit'].top_submit {
margin:-12px 0 0 ;
margin-left:-5px \9; /////////////this is for IE 8///////////
margin-top:-2px \9;
padding:0px;
border:none;
outline:none;
background:transparent url(../images/search_submit.png) no-repeat scroll center top;
width:18px;
height:18px;position:absolute;
}
margin-top:-11px;
* margin-top:-2px; ////////for IE 7
margin-left:95px;
/*width:170px;*/
width:107px;
padding-left:10px;
background:transparent;
border:0px;
}
///// this is for google chrome css /////////////
@media screen and (-webkit-min-device-pixel-ratio:0) {
.top_search
{
margin-top:-13px;
}
}
input[type='submit'].top_submit {
margin:-12px 0 0 ;
margin-left:-5px \9; /////////////this is for IE 8///////////
margin-top:-2px \9;
padding:0px;
border:none;
outline:none;
background:transparent url(../images/search_submit.png) no-repeat scroll center top;
width:18px;
height:18px;position:absolute;
}
PHP Script to calculate date after 10 days
// date to calcaulate after 30 days//
//echo date('Y-m-d',strtotime($date."+30 days"));die;
//echo date('Y-m-d',strtotime($date."+30 days"));die;
Show hide div through jquery
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#hide").click(function(){
$("p").hide();
});
$("#show").click(function(){
$("p").show();
});
});
</script>
</head>
<body>
<p>If you click on the "Hide" button, I will disappear.</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
</body>
</html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#hide").click(function(){
$("p").hide();
});
$("#show").click(function(){
$("p").show();
});
});
</script>
</head>
<body>
<p>If you click on the "Hide" button, I will disappear.</p>
<button id="hide">Hide</button>
<button id="show">Show</button>
</body>
</html>
Resize image and create thumbnail
<?php
function fnCreatThumbnail($strSourcePath,$strFilename,$strDestinationPath,$intGetWidth)
{
$info = pathinfo($strSourcePath);
if ( strtolower($info['extension']) == 'jpg') {$img = imagecreatefromjpeg( "{$strSourcePath}");}
elseif ( strtolower($info['extension']) == 'gif'){$img = imagecreatefromgif( "{$strSourcePath}");}
elseif ( strtolower($info['extension']) == 'png'){$img = imagecreatefrompng( "{$strSourcePath}");}
$width = imagesx( $img );
$height = imagesy( $img );
$new_width = $intGetWidth;
$new_height = floor( $height * ( $intGetWidth / $width ) );
$tmp_img = imagecreatetruecolor($new_width, $new_height);
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
if(strtolower($info['extension']) == 'jpg'){imagejpeg($tmp_img,"{$strDestinationPath}{$strFilename}");}
elseif(strtolower($info['extension']) == 'gif'){imagegif( $tmp_img, "{$strDestinationPath}{$strFilename}");}
elseif(strtolower($info['extension']) == 'png'){imagepng( $tmp_img, "{$strDestinationPath}{$strFilename}");}
}
if($_REQUEST["btnSubmit"])
{
$type = $_FILES['file']['type'];
if(($type=="image/gif")||($type=="image/jpeg"))
{
move_uploaded_file($_FILES['file']['tmp_name'],'upload/'.$_FILES['file']['name']);
$origional_image_path = "upload/".$_FILES['file']['name'];
$strFilename = $_FILES['file']['name'];
$strDestinationPath = "thumbnail/".$strFilename;
fnCreatThumbnail($origional_image_path,$strFilename,$strDestinationPath,100);
}
else
{
echo "Invalid value";
}
}
?>
<html>
<body>
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>
function fnCreatThumbnail($strSourcePath,$strFilename,$strDestinationPath,$intGetWidth)
{
$info = pathinfo($strSourcePath);
if ( strtolower($info['extension']) == 'jpg') {$img = imagecreatefromjpeg( "{$strSourcePath}");}
elseif ( strtolower($info['extension']) == 'gif'){$img = imagecreatefromgif( "{$strSourcePath}");}
elseif ( strtolower($info['extension']) == 'png'){$img = imagecreatefrompng( "{$strSourcePath}");}
$width = imagesx( $img );
$height = imagesy( $img );
$new_width = $intGetWidth;
$new_height = floor( $height * ( $intGetWidth / $width ) );
$tmp_img = imagecreatetruecolor($new_width, $new_height);
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
if(strtolower($info['extension']) == 'jpg'){imagejpeg($tmp_img,"{$strDestinationPath}{$strFilename}");}
elseif(strtolower($info['extension']) == 'gif'){imagegif( $tmp_img, "{$strDestinationPath}{$strFilename}");}
elseif(strtolower($info['extension']) == 'png'){imagepng( $tmp_img, "{$strDestinationPath}{$strFilename}");}
}
if($_REQUEST["btnSubmit"])
{
$type = $_FILES['file']['type'];
if(($type=="image/gif")||($type=="image/jpeg"))
{
move_uploaded_file($_FILES['file']['tmp_name'],'upload/'.$_FILES['file']['name']);
$origional_image_path = "upload/".$_FILES['file']['name'];
$strFilename = $_FILES['file']['name'];
$strDestinationPath = "thumbnail/".$strFilename;
fnCreatThumbnail($origional_image_path,$strFilename,$strDestinationPath,100);
}
else
{
echo "Invalid value";
}
}
?>
<html>
<body>
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>
Upload image by Resize both side and display center of content
<?php
function fnCreatBigThumbnail($strSourcePath,$strFilename,$strDestinationPath,$intGetWidth,$intGetHeight)
{
$strSourcePath = $strSourcePath.$strFilename;
$info = pathinfo($strSourcePath);
if (strtolower($info['extension']) == 'jpg') {$img = imagecreatefromjpeg( "{$strSourcePath}");}
elseif(strtolower($info['extension']) == 'gif'){$img = imagecreatefromgif( "{$strSourcePath}");}
elseif(strtolower($info['extension']) == 'png'){$img = imagecreatefrompng( "{$strSourcePath}");}
$intNewWidth = $intOrigionalWidth = imagesx( $img );
$intNewHeight = $intOrigionalHeight = imagesy( $img );
if($intOrigionalWidth > $intGetWidth)
{
$intNewWidth = $intGetWidth;
$intNewHeight = (($intOrigionalHeight * $intGetWidth)/$intOrigionalWidth);
}
if($intNewHeight > $intGetHeight)
{
$intNewHeight = $intGetHeight;
$intNewWidth = (($intOrigionalWidth * $intGetHeight)/$intOrigionalHeight);
}
$tmp_img = imagecreatetruecolor($intGetWidth,$intGetHeight);
$strWhiteBackground = imagecolorallocate($tmp_img, 255, 255, 255);
imagefill($tmp_img, 0, 0, $strWhiteBackground);
$floatWhiteWidth = (($intGetWidth - $intNewWidth)/2);
$floatWhiteHeight = (($intGetHeight - $intNewHeight)/2);
imagecopyresized( $tmp_img, $img, $floatWhiteWidth, $floatWhiteHeight, 0, 0, $intNewWidth, $intNewHeight, $intOrigionalWidth, $intOrigionalHeight );
if(strtolower($info['extension']) == 'jpg'){imagejpeg($tmp_img,"{$strDestinationPath}{$strFilename}");}
elseif(strtolower($info['extension']) == 'gif'){imagegif( $tmp_img, "{$strDestinationPath}{$strFilename}");}
elseif(strtolower($info['extension']) == 'png'){imagepng( $tmp_img, "{$strDestinationPath}{$strFilename}");}
}
if(isset($_REQUEST["submit"]))
{
$type = strtolower($_FILES['file']['type']);
if(($type=="image/gif")||($type=="image/jpeg") ||($type=="image/png") ||($type=="image/jpeg"))
{
move_uploaded_file($_FILES['file']['tmp_name'],'upload/'.$_FILES['file']['name']);
$strSourcePath = "upload/";
$strFilename = $_FILES['file']['name'];
$strDestinationPath = "resize/";
fnCreatBigThumbnail($strSourcePath,$strFilename,$strDestinationPath,935,440);
}
else
{
echo "Invalid value";
}
}
?>
<form name="frm" action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" name="submit" value="Save" />
</form>
function fnCreatBigThumbnail($strSourcePath,$strFilename,$strDestinationPath,$intGetWidth,$intGetHeight)
{
$strSourcePath = $strSourcePath.$strFilename;
$info = pathinfo($strSourcePath);
if (strtolower($info['extension']) == 'jpg') {$img = imagecreatefromjpeg( "{$strSourcePath}");}
elseif(strtolower($info['extension']) == 'gif'){$img = imagecreatefromgif( "{$strSourcePath}");}
elseif(strtolower($info['extension']) == 'png'){$img = imagecreatefrompng( "{$strSourcePath}");}
$intNewWidth = $intOrigionalWidth = imagesx( $img );
$intNewHeight = $intOrigionalHeight = imagesy( $img );
if($intOrigionalWidth > $intGetWidth)
{
$intNewWidth = $intGetWidth;
$intNewHeight = (($intOrigionalHeight * $intGetWidth)/$intOrigionalWidth);
}
if($intNewHeight > $intGetHeight)
{
$intNewHeight = $intGetHeight;
$intNewWidth = (($intOrigionalWidth * $intGetHeight)/$intOrigionalHeight);
}
$tmp_img = imagecreatetruecolor($intGetWidth,$intGetHeight);
$strWhiteBackground = imagecolorallocate($tmp_img, 255, 255, 255);
imagefill($tmp_img, 0, 0, $strWhiteBackground);
$floatWhiteWidth = (($intGetWidth - $intNewWidth)/2);
$floatWhiteHeight = (($intGetHeight - $intNewHeight)/2);
imagecopyresized( $tmp_img, $img, $floatWhiteWidth, $floatWhiteHeight, 0, 0, $intNewWidth, $intNewHeight, $intOrigionalWidth, $intOrigionalHeight );
if(strtolower($info['extension']) == 'jpg'){imagejpeg($tmp_img,"{$strDestinationPath}{$strFilename}");}
elseif(strtolower($info['extension']) == 'gif'){imagegif( $tmp_img, "{$strDestinationPath}{$strFilename}");}
elseif(strtolower($info['extension']) == 'png'){imagepng( $tmp_img, "{$strDestinationPath}{$strFilename}");}
}
if(isset($_REQUEST["submit"]))
{
$type = strtolower($_FILES['file']['type']);
if(($type=="image/gif")||($type=="image/jpeg") ||($type=="image/png") ||($type=="image/jpeg"))
{
move_uploaded_file($_FILES['file']['tmp_name'],'upload/'.$_FILES['file']['name']);
$strSourcePath = "upload/";
$strFilename = $_FILES['file']['name'];
$strDestinationPath = "resize/";
fnCreatBigThumbnail($strSourcePath,$strFilename,$strDestinationPath,935,440);
}
else
{
echo "Invalid value";
}
}
?>
<form name="frm" action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" name="submit" value="Save" />
</form>
display map in iframe like sis
<iframe width="285" height="200" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
src="http://maps.google.co.in/maps?source=s_q&hl=en&geocode=&q=Sankhala+Info+Solutions,+F-33,+Amenity+Center,+Udhana+Bus+Depo,+Udhana-Navsari+Main+Rd,&aq=0&sll=21.125498,81.914063&sspn=42.891601,56.513672&vpsrc=6&ie=UTF8&hq=Sankhala+Info+Solutions,+F-33,+Amenity+Center,+Udhana+Bus+Depo,+Udhana-Navsari+Main+Rd,&hnear=Udhana+Zone,+Surat,+Gujarat&ll=21.109609,72.862124&spn=0.073774,0.049263&t=m&output=embed"></iframe>
<br />
<small>
<a href="http://maps.google.co.in/maps?source=embed&hl=en&geocode=&q=Sankhala+Info+Solutions,+F-33,+Amenity+Center,+Udhana+Bus+Depo,+Udhana-Navsari+Main+Rd,&aq=0&sll=21.125498,81.914063&sspn=42.891601,56.513672&vpsrc=6&ie=UTF8&hq=Sankhala+Info+Solutions,+F-33,+Amenity+Center,+Udhana+Bus+Depo,+Udhana-Navsari+Main+Rd,&hnear=Udhana+Zone,+Surat,+Gujarat&ll=21.109609,72.862124&spn=0.073774,0.049263&t=m" style="color:#0000FF;text-align:left">View Larger Map</a>
</small>
src="http://maps.google.co.in/maps?source=s_q&hl=en&geocode=&q=Sankhala+Info+Solutions,+F-33,+Amenity+Center,+Udhana+Bus+Depo,+Udhana-Navsari+Main+Rd,&aq=0&sll=21.125498,81.914063&sspn=42.891601,56.513672&vpsrc=6&ie=UTF8&hq=Sankhala+Info+Solutions,+F-33,+Amenity+Center,+Udhana+Bus+Depo,+Udhana-Navsari+Main+Rd,&hnear=Udhana+Zone,+Surat,+Gujarat&ll=21.109609,72.862124&spn=0.073774,0.049263&t=m&output=embed"></iframe>
<br />
<small>
<a href="http://maps.google.co.in/maps?source=embed&hl=en&geocode=&q=Sankhala+Info+Solutions,+F-33,+Amenity+Center,+Udhana+Bus+Depo,+Udhana-Navsari+Main+Rd,&aq=0&sll=21.125498,81.914063&sspn=42.891601,56.513672&vpsrc=6&ie=UTF8&hq=Sankhala+Info+Solutions,+F-33,+Amenity+Center,+Udhana+Bus+Depo,+Udhana-Navsari+Main+Rd,&hnear=Udhana+Zone,+Surat,+Gujarat&ll=21.109609,72.862124&spn=0.073774,0.049263&t=m" style="color:#0000FF;text-align:left">View Larger Map</a>
</small>
PHP in_array example
<?php
$people = array("1", "2", "3", "4", "5");
//$people = array(1,2,3,4,5);
?>
<select name="ad" multiple="multiple" style="height:100px;width:100px;">
<option value="0">Select Value</option>
<?php
for($intI=0;$intI<5;$intI++)
{
if(in_array($intI,$people))
{
$selected = "selected='selected'";
}
?>
<option value="<?php echo $intI;?>" <?php echo $selected;?>><?php echo $intI;?></option>
<?php
}
?>
</select>
$people = array("1", "2", "3", "4", "5");
//$people = array(1,2,3,4,5);
?>
<select name="ad" multiple="multiple" style="height:100px;width:100px;">
<option value="0">Select Value</option>
<?php
for($intI=0;$intI<5;$intI++)
{
if(in_array($intI,$people))
{
$selected = "selected='selected'";
}
?>
<option value="<?php echo $intI;?>" <?php echo $selected;?>><?php echo $intI;?></option>
<?php
}
?>
</select>
PHP Show current temprature of city through zipcode
<?php echo "NOTE : Please on curl library from php.ini file";?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Yahoo! Weather API RSS</title>
<?php
function retrieveYahooWeather($zipCode="394230") {
$yahooUrl = "http://weather.yahooapis.com/forecastrss";
$yahooZip = "?p=$zipCode";
$yahooFullUrl = $yahooUrl . $yahooZip;
$curlObject = curl_init();
curl_setopt($curlObject,CURLOPT_URL,$yahooFullUrl);
curl_setopt($curlObject,CURLOPT_HEADER,false);
curl_setopt($curlObject,CURLOPT_RETURNTRANSFER,true);
$returnYahooWeather = curl_exec($curlObject);
curl_close($curlObject);
return $returnYahooWeather;
}
$localZipCode = "07306"; // Lake Arrowhead, CA
$weatherXmlString = retrieveYahooWeather($localZipCode);
$weatherXmlObject = new SimpleXMLElement($weatherXmlString);
$currentCondition = $weatherXmlObject->xpath("//yweather:condition");
$currentTemperature = $currentCondition[0]["temp"];
$currentDescription = $currentCondition[0]["text"];
?>
</head>
<body>
<ul>
<li>Current Temperature: <?=$currentTemperature;?>°F</li>
<li>Current Description: <?=$currentDescription;?></li>
</ul>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Yahoo! Weather API RSS</title>
<?php
function retrieveYahooWeather($zipCode="394230") {
$yahooUrl = "http://weather.yahooapis.com/forecastrss";
$yahooZip = "?p=$zipCode";
$yahooFullUrl = $yahooUrl . $yahooZip;
$curlObject = curl_init();
curl_setopt($curlObject,CURLOPT_URL,$yahooFullUrl);
curl_setopt($curlObject,CURLOPT_HEADER,false);
curl_setopt($curlObject,CURLOPT_RETURNTRANSFER,true);
$returnYahooWeather = curl_exec($curlObject);
curl_close($curlObject);
return $returnYahooWeather;
}
$localZipCode = "07306"; // Lake Arrowhead, CA
$weatherXmlString = retrieveYahooWeather($localZipCode);
$weatherXmlObject = new SimpleXMLElement($weatherXmlString);
$currentCondition = $weatherXmlObject->xpath("//yweather:condition");
$currentTemperature = $currentCondition[0]["temp"];
$currentDescription = $currentCondition[0]["text"];
?>
</head>
<body>
<ul>
<li>Current Temperature: <?=$currentTemperature;?>°F</li>
<li>Current Description: <?=$currentDescription;?></li>
</ul>
</body>
</html>
PHP Script to copy directory
<?php
function full_copy($source,$target)
{
if(is_dir($source))
{
@mkdir($target);
$d = dir($source);
while(FALSE !== ($entry = $d->read()))
{
if($entry == '.' || $entry == '..')
{
continue;
}
$Entry = $source . '/' . $entry;
if(is_dir($Entry))
{
full_copy( $Entry, $target . '/' . $entry );
continue;
}
copy($Entry,$target.'/'.$entry);
}
$d->close();
}
else
{
copy($source,$target);
}
}
$strSubdomain = "SIS";
/// absolute path///////
$strSource = $dir['root']."resources/affiliate/";
$strDest = $dir['root']."subdomain/affiliate/$strSubdomain";
full_copy($strSource,$strDest);
?>
function full_copy($source,$target)
{
if(is_dir($source))
{
@mkdir($target);
$d = dir($source);
while(FALSE !== ($entry = $d->read()))
{
if($entry == '.' || $entry == '..')
{
continue;
}
$Entry = $source . '/' . $entry;
if(is_dir($Entry))
{
full_copy( $Entry, $target . '/' . $entry );
continue;
}
copy($Entry,$target.'/'.$entry);
}
$d->close();
}
else
{
copy($source,$target);
}
}
$strSubdomain = "SIS";
/// absolute path///////
$strSource = $dir['root']."resources/affiliate/";
$strDest = $dir['root']."subdomain/affiliate/$strSubdomain";
full_copy($strSource,$strDest);
?>
Create subdomains in php
<?php
function create_subdomain($subDomain,$cPanelUser,$cPanelPass,$rootDomain) {
// to be change ///// x3 on different server///
$buildRequest = "/frontend/x3/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain . "&dir=public_html/beta/subdomain/affiliate/" . $subDomain;
$openSocket = fsockopen('localhost',2082);
if(!$openSocket) {
return "Socket error";
exit();
}
$authString = $cPanelUser . ":" . $cPanelPass;
$authPass = base64_encode($authString);
$buildHeaders = "GET " . $buildRequest ."\r\n";
$buildHeaders .= "HTTP/1.0\r\n";
$buildHeaders .= "Host:localhost\r\n";
$buildHeaders .= "Authorization: Basic " . $authPass . "\r\n";
$buildHeaders .= "\r\n";
fputs($openSocket, $buildHeaders);
while(!feof($openSocket)) {
fgets($openSocket,128);
}
fclose($openSocket);
$newDomain = "http://" . $subDomain . "." . $rootDomain . "/";
return "Created subdomain $newDomain";
}
function delete_subdomain($subDomain,$cPanelUser,$cPanelPass,$rootDomain)
{
///////// to be change different server name x3/////////////
$buildRequest = "/frontend/x3/subdomain/dodeldomain.html?domain=" . $subDomain . "_" . $rootDomain;
$openSocket = fsockopen('localhost',2082);
if(!$openSocket) {
return "Socket error";
exit();
}
$authString = $cPanelUser . ":" . $cPanelPass;
$authPass = base64_encode($authString);
$buildHeaders = "GET " . $buildRequest ."\r\n";
$buildHeaders .= "HTTP/1.0\r\n";
$buildHeaders .= "Host:localhost\r\n";
$buildHeaders .= "Authorization: Basic " . $authPass . "\r\n";
$buildHeaders .= "\r\n";
fputs($openSocket, $buildHeaders);
while(!feof($openSocket)) {
fgets($openSocket,128);
}
fclose($openSocket);
$passToShell = "rm -rf /home/" . $cPanelUser . "/public_html/beta/subdomain/affiliate/" . $subDomain;
system($passToShell);
}
$subdomain = create_subdomain('sisconsultancy','newyugco','9730951424','newyug.com');
echo $subdomain;
?>
function create_subdomain($subDomain,$cPanelUser,$cPanelPass,$rootDomain) {
// to be change ///// x3 on different server///
$buildRequest = "/frontend/x3/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain . "&dir=public_html/beta/subdomain/affiliate/" . $subDomain;
$openSocket = fsockopen('localhost',2082);
if(!$openSocket) {
return "Socket error";
exit();
}
$authString = $cPanelUser . ":" . $cPanelPass;
$authPass = base64_encode($authString);
$buildHeaders = "GET " . $buildRequest ."\r\n";
$buildHeaders .= "HTTP/1.0\r\n";
$buildHeaders .= "Host:localhost\r\n";
$buildHeaders .= "Authorization: Basic " . $authPass . "\r\n";
$buildHeaders .= "\r\n";
fputs($openSocket, $buildHeaders);
while(!feof($openSocket)) {
fgets($openSocket,128);
}
fclose($openSocket);
$newDomain = "http://" . $subDomain . "." . $rootDomain . "/";
return "Created subdomain $newDomain";
}
function delete_subdomain($subDomain,$cPanelUser,$cPanelPass,$rootDomain)
{
///////// to be change different server name x3/////////////
$buildRequest = "/frontend/x3/subdomain/dodeldomain.html?domain=" . $subDomain . "_" . $rootDomain;
$openSocket = fsockopen('localhost',2082);
if(!$openSocket) {
return "Socket error";
exit();
}
$authString = $cPanelUser . ":" . $cPanelPass;
$authPass = base64_encode($authString);
$buildHeaders = "GET " . $buildRequest ."\r\n";
$buildHeaders .= "HTTP/1.0\r\n";
$buildHeaders .= "Host:localhost\r\n";
$buildHeaders .= "Authorization: Basic " . $authPass . "\r\n";
$buildHeaders .= "\r\n";
fputs($openSocket, $buildHeaders);
while(!feof($openSocket)) {
fgets($openSocket,128);
}
fclose($openSocket);
$passToShell = "rm -rf /home/" . $cPanelUser . "/public_html/beta/subdomain/affiliate/" . $subDomain;
system($passToShell);
}
$subdomain = create_subdomain('sisconsultancy','newyugco','9730951424','newyug.com');
echo $subdomain;
?>
Read user data from facebook through api
$fbUrl = "https://graph.facebook.com/?id=$identity&access_token=".$aData["Session"]["access_token"];
$curl = curl_init($fbUrl);
curl_setopt ($curl,CURLOPT_RETURNTRANSFER,1);
$data = curl_exec ($curl);
$arrdata = json_decode($data);
?>
refer the following/////////
https://developers.facebook.com/docs/reference/api/
$curl = curl_init($fbUrl);
curl_setopt ($curl,CURLOPT_RETURNTRANSFER,1);
$data = curl_exec ($curl);
$arrdata = json_decode($data);
?>
refer the following/////////
https://developers.facebook.com/docs/reference/api/
PHP Script to read curl data from other site
<?php
$curl = curl_init();
/*curl_setopt ($curl, CURLOPT_URL, "http://api.careerbuilder.com/v1/jobsearch?&DeveloperKey=WDH38FQ65G6P0DTBZ09C&Keywords=php&PageNumber=1");*/
curl_setopt ($curl, CURLOPT_URL, "http://api.careerbuilder.com/v1/jobsearch?&DeveloperKey=111&Keywords=php&PageNumber=1");
curl_setopt ($curl,CURLOPT_RETURNTRANSFER,1);
$data = curl_exec ($curl);
$arrData = simplexml_load_string($data);
echo "<pre>";
print_r($arrData);
curl_close ($curl);
?>
$curl = curl_init();
/*curl_setopt ($curl, CURLOPT_URL, "http://api.careerbuilder.com/v1/jobsearch?&DeveloperKey=WDH38FQ65G6P0DTBZ09C&Keywords=php&PageNumber=1");*/
curl_setopt ($curl, CURLOPT_URL, "http://api.careerbuilder.com/v1/jobsearch?&DeveloperKey=111&Keywords=php&PageNumber=1");
curl_setopt ($curl,CURLOPT_RETURNTRANSFER,1);
$data = curl_exec ($curl);
$arrData = simplexml_load_string($data);
echo "<pre>";
print_r($arrData);
curl_close ($curl);
?>
Subscribe to:
Posts (Atom)