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);
?>
PHP Script to create subdomains
function create_subdomain($subDomain,$cPanelUser,$cPanelPass,$rootDomain)
{
$buildRequest = "/frontend/x3/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain . "&dir=public_html/subdomains/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 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);
}
}
///////////////////////// for insert into table ////////////////////////////////////////
if(isset($_POST["txtSubmitAffiliate"]))
{
$strSubdomain = $_POST["txtSubdomainname"];
$sqlAffiliateQuery = "INSERT INTO affiliate SET
username='".$_POST["txtUsername"]."',
password='".$_POST["txtPassword"]."',
name='".$_POST["txtName"]."',
email='".$_POST["txtEmail"]."',
sub_domain_name='".$_POST["txtSubdomainname"]."',
street_address='".$_POST["txtStreetAddress"]."',
city='".$_POST["txtCity"]."',
state='".$_POST["txtState"]."',
country='".$_POST["txtCountry"]."',
zipcode='".$_POST["txtZipcode"]."',
status='1',
created_at=NOW(),
updated_at=NOW()";
db_res($sqlAffiliateQuery);
$intLastId = mysql_insert_id();
@mkdir($dir['root']."subdomains/affiliate/".$strSubdomain, 0777);
full_copy($dir['root']."resources/affiliate/",$dir['root']."subdomains/affiliate/".$strSubdomain."/");
@unlink($dir['root']."subdomains/affiliate/".$strSubdomain."/inc/config.inc.php");
$strContentfile = file_get_contents($dir['root']."resources/affiliate/inc/config.sample.inc.php", true);
$strContentfile = str_replace('#aff_id#',$intLastId,$strContentfile);
$strContentfile = str_replace('#sub_url#',$strSubdomain,$strContentfile);
$strContentfile = str_replace('#root_dir#',$strSubdomain,$strContentfile);
$myFile = $dir['root']."subdomains/affiliate/".$strSubdomain."/inc/config.sample.inc.php";
$fh = fopen($myFile, 'w');
fwrite($fh, $strContentfile);
fclose($fh);
$oldFile = $dir['root']."subdomains/affiliate/".$strSubdomain."/inc/config.sample.inc.php";
$newFile = $dir['root']."subdomains/affiliate/".$strSubdomain."/inc/config.inc.php";
@rename($oldFile,$newFile);
$subdomain = create_subdomain($strSubdomain,'newyugco','9730951424','newyug.com');
@mkdir($dir['root']."subdomains/affiliate/".$strSubdomain, 0755);
header("Location:".$site["url"]."affiliate_success.php?msg=success");
}
{
$buildRequest = "/frontend/x3/subdomain/doadddomain.html?rootdomain=" . $rootDomain . "&domain=" . $subDomain . "&dir=public_html/subdomains/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 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);
}
}
///////////////////////// for insert into table ////////////////////////////////////////
if(isset($_POST["txtSubmitAffiliate"]))
{
$strSubdomain = $_POST["txtSubdomainname"];
$sqlAffiliateQuery = "INSERT INTO affiliate SET
username='".$_POST["txtUsername"]."',
password='".$_POST["txtPassword"]."',
name='".$_POST["txtName"]."',
email='".$_POST["txtEmail"]."',
sub_domain_name='".$_POST["txtSubdomainname"]."',
street_address='".$_POST["txtStreetAddress"]."',
city='".$_POST["txtCity"]."',
state='".$_POST["txtState"]."',
country='".$_POST["txtCountry"]."',
zipcode='".$_POST["txtZipcode"]."',
status='1',
created_at=NOW(),
updated_at=NOW()";
db_res($sqlAffiliateQuery);
$intLastId = mysql_insert_id();
@mkdir($dir['root']."subdomains/affiliate/".$strSubdomain, 0777);
full_copy($dir['root']."resources/affiliate/",$dir['root']."subdomains/affiliate/".$strSubdomain."/");
@unlink($dir['root']."subdomains/affiliate/".$strSubdomain."/inc/config.inc.php");
$strContentfile = file_get_contents($dir['root']."resources/affiliate/inc/config.sample.inc.php", true);
$strContentfile = str_replace('#aff_id#',$intLastId,$strContentfile);
$strContentfile = str_replace('#sub_url#',$strSubdomain,$strContentfile);
$strContentfile = str_replace('#root_dir#',$strSubdomain,$strContentfile);
$myFile = $dir['root']."subdomains/affiliate/".$strSubdomain."/inc/config.sample.inc.php";
$fh = fopen($myFile, 'w');
fwrite($fh, $strContentfile);
fclose($fh);
$oldFile = $dir['root']."subdomains/affiliate/".$strSubdomain."/inc/config.sample.inc.php";
$newFile = $dir['root']."subdomains/affiliate/".$strSubdomain."/inc/config.inc.php";
@rename($oldFile,$newFile);
$subdomain = create_subdomain($strSubdomain,'newyugco','9730951424','newyug.com');
@mkdir($dir['root']."subdomains/affiliate/".$strSubdomain, 0755);
header("Location:".$site["url"]."affiliate_success.php?msg=success");
}
Select Query Fetch multiple result function
<?php
mysql_connect("localhost","root","");
mysql_select_db("fetch");
function fnFetchMultipleResults($resResource, $strFetchType = 'ARR')
{
$resResource = mysql_query($resResource);
$intRows = mysql_num_rows($resResource);
if($intRows > 0)
{
if($strFetchType == 'OBJ')
{
while($arrRecord = mysql_fetch_object($resResource))
{
$arrResults[] = $arrRecord;
}
}
else if($strFetchType == 'ARR')
{
while($arrRecord = mysql_fetch_assoc($resResource))
{
$arrResults[] = $arrRecord;
}
}
}
else
{
$arrResults = array();
}
return $arrResults;
}
function fnFetchSingleResult($resResource, $strFetchType = 'ARR')
{
$resResource = mysql_query($resResource);
$intRows = mysql_num_rows($resResource);
if($intRows > 0)
{
if($strFetchType == 'OBJ')
{
$arrRecord = mysql_fetch_object($resResource);
}
else if($strFetchType == 'ARR')
{
$arrRecord = mysql_fetch_assoc($resResource);
}
}
else
{
return array();
}
return $arrRecord;
}
$sqlQuery = "SELECT * FROM `fetch`";
$arrRes = fnFetchMultipleResults($sqlQuery, $strFetchType = 'ARR');
print_r($arrRes);
?>
Javascript disable right click
<script type="text/javascript">
function md(e)
{
try { if (event.button==2||event.button==3) return false; }
catch (e) { if (e.which == 3) return false; }
}
document.oncontextmenu = function() { return false; }
document.ondragstart = function() { return false; }
document.onmousedown = md;
</script>
safsdfsfsdfsdfsdafsdfsadf
Javascript to bookmark your page
<script language="javascript">
function addBookmark()
{
bookmarkurl = "http://www.tildemark.com";
bookmarktitle="Tildemark blogs";
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
else if ( window.sidebar ) {
window.sidebar.addPanel(bookmarktitle, bookmarkurl,"");
}
}
</script>
<a href="javascript:addBookmark();">Bookmark this page!</a>
Javascript onclick Display n number of textbox
<SCRIPT language="javascript">
function addRow(tableID)
{
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
var cnt = document.getElementById('cntdiv').innerHTML;
document.getElementById('cntdiv').innerHTML=parseInt(cnt) + 1;
for(var i=0; i<colCount; i++)
{
var newcell = row.insertCell(i);
//alert("error_"+cnt);
newcell.innerHTML = '<div id="error_'+cnt+'"></div>'+table.rows[0].cells[i].innerHTML;
switch(newcell.childNodes[0].type)
{
case "text":
newcell.childNodes[0].value = "";
break;
case "radio":
newcell.childNodes[0].checked = false;
break;
case "textarea":
newcell.childNodes[0].selectedIndex = 0;
break;
}
}
cnt++;
}
</SCRIPT>
<div id='cntdiv' style="display:none;"></div>
<form action="/index.php?option=com_business" method="post" id="josForm" name="adminForm" class="form-validate"
enctype="multipart/form-data">
<table id="dataTable" border="0">
<div id="error_0" align="center"></div>
<tr>
<td><label>Category Name</label>
<span class="strk">*</span>
<div class="clr"></div>
<input type="text" title="Menu Category" name="name[]" id="name[]" class="textbox validate(required)" style="width: 245px;" value="">
<div class="clr"></div>
<br>
</td>
</tr>
</table>
<div class="rs">
<INPUT type="button" value="Add Category" onClick="addRow('dataTable')" />
</div>
</form>
Display image at the center of content
<?php
function displayImage($intGetWidth,$intGetHeight,$intNewWidth,$intNewHeight)
{
$intWidth = $intNewWidth;
$intHeight = $intNewHeight;
if( $intGetWidth > $intNewWidth)
{
$intWidth = $intNewWidth;
$intHeight = (($intGetHeight * $intNewWidth)/$intGetWidth);
}
if($intHeight > $intNewHeight)
{
$intHeight = $intNewHeight;
$intWidth = (($intWidth * $intNewHeight)/$intHeight);
}
return array($intWidth,$intHeight);
}
$intNewWidth = 100;
$intNewHeight = 100;
$strSource = "image/Google22.jpg";
$arrDimensions = getimagesize($strSource);
$intOrigionalWidth = $arrDimensions[0];
$intOrigionalHeight = $arrDimensions[1];
$intNewDim = displayImage($intOrigionalWidth,$intOrigionalHeight,$intNewWidth,$intNewHeight);
$intWhiteWidth = (($intNewWidth - $intNewDim[0])/2);
$intWhiteHeight = (($intNewHeight - $intNewDim[1])/2);
?>
<div style="height:100px;width:100px;border:1px solid #FF0000;">
<img src="http://localhost/display_image/image/Google22.jpg" width="<?php echo $intNewDim[0];?>" height="<?php echo $intNewDim[1];?>" style="margin-top:<?php echo $intWhiteHeight;?>;margin-left:<?php echo $intWhiteWidth;?>"/>
</div>
Saturday, June 23, 2012
PHP Script header cannot send problem solutions
if(!isset($_SESSION["email"]))
{
if(!headers_sent())
{
$strRedirectUrl = $site['url'].'admin/index.php';
header("Location:".$strRedirectUrl);
}
else
{
$strRedirectUrl = $site['url'].'admin/index.php';
?>
{
if(!headers_sent())
{
$strRedirectUrl = $site['url'].'admin/index.php';
header("Location:".$strRedirectUrl);
}
else
{
$strRedirectUrl = $site['url'].'admin/index.php';
?>
location.href = '';
}
}
}
PHP Script header cannot send problem solutions
if(!isset($_SESSION["email"]))
{
if(!headers_sent())
{
$strRedirectUrl = $site['url'].'admin/index.php';
header("Location:".$strRedirectUrl);
}
else
{
$strRedirectUrl = $site['url'].'admin/index.php';
?>
{
if(!headers_sent())
{
$strRedirectUrl = $site['url'].'admin/index.php';
header("Location:".$strRedirectUrl);
}
else
{
$strRedirectUrl = $site['url'].'admin/index.php';
?>
location.href = '';
<?php
}
}
}
}
PHP Read curl data
<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://api.google.com/v1/jobsearch?&DeveloperKey=WDH38FQ65G6P0DTBZ09C&Keywords=php&PageNumber=1");
curl_setopt ($curl,CURLOPT_RETURNTRANSFER,1);
$data = curl_exec ($curl);
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://api.google.com/v1/jobsearch?&DeveloperKey=WDH38FQ65G6P0DTBZ09C&Keywords=php&PageNumber=1");
curl_setopt ($curl,CURLOPT_RETURNTRANSFER,1);
$data = curl_exec ($curl);
$arrData = simplexml_load_string($data);
/*echo "
/*echo "
"; print_r($arrData);*/ echo "
Total Result : ".$arrData->TotalCount."
";
echo "
echo "
Total Pages : ".$arrData->TotalPages."
";
echo "
echo "
Limit Start : ".$arrData->FirstItemIndex."
";
echo "
echo "
Limit End : ".$arrData->LastItemIndex."
";
echo "
";
echo "
echo "
";
echo "
"; echo "";echo "";
echo "Description";
echo "Date";
echo "";
foreach($arrData->Results->JobSearchResult as $key=>$obj)
{/*$arrvalues[] = array(
'location'=>$obj->Location,
'company_name'=>$obj->Company,
'description'=>$obj->DescriptionTeaser,
'date_added'=>$obj->PostedDate
);*/
$arrvalues[] = array(
'title'=>(string)$obj->JobTitle,
'location'=>(string)$obj->Location,
'company_name'=>(string)$obj->Company,
'description'=>(string)$obj->DescriptionTeaser,
'date_added'=>(string)$obj->PostedDate
);
echo "
";echo "".$obj->Location."";
echo "".$obj->DescriptionTeaser."";
echo "".$obj->PostedDate."";
echo "";
}
/*echo "";
print_r($arrvalues);*/
echo "
echo "Description";
echo "Date";
echo "";
foreach($arrData->Results->JobSearchResult as $key=>$obj)
{/*$arrvalues[] = array(
'location'=>$obj->Location,
'company_name'=>$obj->Company,
'description'=>$obj->DescriptionTeaser,
'date_added'=>$obj->PostedDate
);*/
$arrvalues[] = array(
'title'=>(string)$obj->JobTitle,
'location'=>(string)$obj->Location,
'company_name'=>(string)$obj->Company,
'description'=>(string)$obj->DescriptionTeaser,
'date_added'=>(string)$obj->PostedDate
);
echo "
";echo "".$obj->Location."";
echo "".$obj->DescriptionTeaser."";
echo "".$obj->PostedDate."";
echo "";
}
/*echo "";
print_r($arrvalues);*/
echo "
Location |
---|
";
curl_close ($curl);
?>
curl_close ($curl);
?>
PHP Resize image on both side
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}");}
{
$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 );
$intNewHeight = $intOrigionalHeight = imagesy( $img );
if($intOrigionalWidth > $intGetWidth)
{
$intNewWidth = $intGetWidth;
$intNewHeight = (($intOrigionalHeight * $intGetWidth)/$intOrigionalWidth);
}
if($intNewHeight > $intGetHeight)
{
$intNewHeight = $intGetHeight;
$intNewWidth = (($intOrigionalWidth * $intGetHeight)/$intOrigionalHeight);
}
{
$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);
$strWhiteBackground = imagecolorallocate($tmp_img, 255, 255, 255);
imagefill($tmp_img, 0, 0, $strWhiteBackground);
$floatWhiteWidth = (($intGetWidth - $intNewWidth)/2);
$floatWhiteHeight = (($intGetHeight - $intNewHeight)/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";
}
}
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";
}
}
fnCreatThumbnail(TEMPLATEPATH.'/images/banners/','abc.jpg',TEMPLATEPATH.'/images/banners/large/',300,300);
Javascript get screen height and width
function fnGetScreenSize()
{
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3)
{
screenW = screen.width;
screenH = screen.height;
}
else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled())
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenW = jScreenSize.width;
screenH = jScreenSize.height;
}
return screenW;
}
intWidth = fnGetScreenSize();
{
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3)
{
screenW = screen.width;
screenH = screen.height;
}
else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled())
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenW = jScreenSize.width;
screenH = jScreenSize.height;
}
return screenW;
}
intWidth = fnGetScreenSize();
Apply Class through javascript
jQuery('body').addClass('width1024');
jQuery('.main-container').css('min-height',screen.height);
Javascript Checkall Code
function fnCheckAll()
{
var nam="";
var mainchk = document.frmManage.mycheckbox;
var chklen = document.frmManage.elements.length;
if(mainchk.checked==true)
{
for(var n=0; n {
nam="check"+ n;
var currobj = document.getElementById(nam);
if(currobj.type == "checkbox" )
currobj.checked=true;
}
}
else if(mainchk.checked==false)
{
for(var n=0; n= 0)
{
allInputs = document.getElementsByTagName("input");
var flag=1;
for (i = 0; i< allInputs.length; i++)
{
if (allInputs[i].checked==true)
{
flag=0;
}
}
if (flag != 0 )
{
alert("Please select at least one.");
return false;
}
else
{
if(confirm('Are You Sure Want To Delete Selected Employee?'))
{
document.frmManage.submit();
}
}
}
}
{
var nam="";
var mainchk = document.frmManage.mycheckbox;
var chklen = document.frmManage.elements.length;
if(mainchk.checked==true)
{
for(var n=0; n
nam="check"+ n;
var currobj = document.getElementById(nam);
if(currobj.type == "checkbox" )
currobj.checked=true;
}
}
else if(mainchk.checked==false)
{
for(var n=0; n= 0)
{
allInputs = document.getElementsByTagName("input");
var flag=1;
for (i = 0; i< allInputs.length; i++)
{
if (allInputs[i].checked==true)
{
flag=0;
}
}
if (flag != 0 )
{
alert("Please select at least one.");
return false;
}
else
{
if(confirm('Are You Sure Want To Delete Selected Employee?'))
{
document.frmManage.submit();
}
}
}
}
for($intI=0;$intI
Bulk Action :
Please Select
Iframe code to display google map
http://maps.google.co.in/maps?source=s_q&hl=en&geocode=&q=Mayank+M+Patel,+1,+PatelFaliyu,+Unn,+Udhana-Navsari+Main+Rd,&aq=0&sll=21.125498,81.914063&sspn=42.891601,56.513672&vpsrc=6&ie=UTF8&hq=Mayank+M+Patel,+1,+Patel+Faliya,+Unn,+Udhana-Navsari+Main+Rd,&hnear=Udhana+Zone,+Surat,+Gujarat&ll=21.109609,72.862124&spn=0.073774,0.049263&t=m&output=embed
View Larger Map
View Larger Map
Iframe call
function callIframe(strUrl,height,width)
{
document.getElementById('companyiframe').src = strUrl;
document.getElementById('companyiframe').style.height = height;
document.getElementById('companyiframe').style.width = width;
document.getElementById('companyiframe').style.border = 'none';
}
{
document.getElementById('companyiframe').src = strUrl;
document.getElementById('companyiframe').style.height = height;
document.getElementById('companyiframe').style.width = width;
document.getElementById('companyiframe').style.border = 'none';
}
var url = "http://192.168.0.1/";
callIframe(url,"400px","710px");
callIframe(url,"400px","710px");
Magento Blog Links
http://www.fontis.com.au/blog/magento/
http://ommune.com/adding-new-currency-symbol-of-indian-rupee-inr-in-magento/
http://magentosnippet.blogspot.in/
http://magento-talks.blogspot.in/2011_09_01_archive.html
http://xhtmlandcsshelp.blogspot.in/2011/02/absolute-path-of-base-directory-in.html
http://magentocookbook.wordpress.com/category/magento-coding/
http://www.designer-daily.com/magento-tips-17085
http://www.learnmagento.org/page/4/
http://magebase.com/
http://www.magthemes.com/magento-blog/
http://amilan.wordpress.com/2008/05/
http://www.catgento.com/
http://spenserbaldwin.com/2010/03
http://magentoexpert.blogspot.in/2010/02/restrict-access-to-magento-during.html
http://keertikiran.blogspot.in/search/label/Magento
http://ommune.com/adding-new-currency-symbol-of-indian-rupee-inr-in-magento/
http://magentosnippet.blogspot.in/
http://magento-talks.blogspot.in/2011_09_01_archive.html
http://xhtmlandcsshelp.blogspot.in/2011/02/absolute-path-of-base-directory-in.html
http://magentocookbook.wordpress.com/category/magento-coding/
http://www.designer-daily.com/magento-tips-17085
http://www.learnmagento.org/page/4/
http://magebase.com/
http://www.magthemes.com/magento-blog/
http://amilan.wordpress.com/2008/05/
http://www.catgento.com/
http://spenserbaldwin.com/2010/03
http://magentoexpert.blogspot.in/2010/02/restrict-access-to-magento-during.html
http://keertikiran.blogspot.in/search/label/Magento
Subscribe to:
Posts (Atom)