Monday, December 21, 2009

Nusoap PHP Request (USING WSDL Document/literal)

// example 2
// include soap file
require_once('nusoap.php');
// set name space
$ns="urn:service";
// set end point
$endpoint = "https://localhost/MethodName";
// create client
$client = new soapclientw($endpoint);

if ( $client->getError() ) {
print "Soap Constructor Error:".
$client->getError()."";
}

$request = 'Yorr XML DATA';
$action = "MethodName";
$msg = $client->serializeEnvelope($request, '', array(), 'document', 'literal');
$result = $client->send($msg, $action, 60, 60);

if ($client->fault) { //soap_fault
print "Soap Fault: (". $client->fault->faultcode .") ".
$client->fault->faultstring. "";
}
elseif ( $client->getError() ) {
print "Soap Error: ". $client->getError() ."";
}
else {
print "Result: ";
print_r($result);
print "";
}

print 'Details:'.
'Request' .
htmlspecialchars( $client->request, ENT_QUOTES) .''.
'Response' .
htmlspecialchars( $client->response, ENT_QUOTES) .''.
'Debug' .
htmlspecialchars( $client->debug_str, ENT_QUOTES) .'';

Nusoap PHP Request (USING WSDL URL)

// example one using WSDL URL
// include nusoap file
require_once('nusoap.php');
// set the wsdl path
$wsdl="http://localhost/server.php?wsdl";
// crate client
$client=new soapclientw($wsdl, 'wsdl');
// set the parameter
$param=array('amount'=>'15.00');
// cal method and echo the resutl
echo $client->call('CalculateOntarioTax', $param);
// echo request and response
echo 'Request ' . htmlspecialchars($client->requestHeaders, ENT_QUOTES) . '';
echo 'Response ' . htmlspecialchars($client->responseHeaders, ENT_QUOTES) . ' ';

Tuesday, December 1, 2009

URL Rewriting Using .htacess file

URL Rewriting Using .htacess file

Our Aim is to

http://www.example.com/test/blog/var1/testFile.html

into dynamic URL

http://www.example.com/test/testFile.php?var1=var1&var2=testFile

using .htacess file

Create .htacess file in test directory

Now you directory structure is

www.example.com/test/

.htacess

testFile.php

In .htacess file write the code

Options +FollowSymlinks

RewriteEngine On

RewriteRule ^blog/([^/]+)/([^/]+)\.html$ /test/testFile.php?var1=$1&var1=$2 [QSA]

Now in testFile.php your code will be there

If you type URL in Browser

http://www.example.com/test/blog /var1/testFile.html

it will execute on server as

http://www.example.com/test/testFile.php?var1=var1&var2=testFile

if you want todo external redirecting the just change the .htacess code

Options +FollowSymlinks

RewriteEngine On

RewriteRule ^blog/([^/]+)/([^/]+)\.html$ /test/testFile.php?var1=$1&var1=$2 [R=301,L]

Saturday, November 7, 2009

Enable SSH Terminal for FTP user within Plesk

1) Login to Plesk
2) Click on Domains
3) Click on your domain
4) You will see the SSH Terminal for your domain is disabled
5) Click on Setup
6) Select /bin/bash for Shell access to server with FTP user's credentials
7) Now you can use the SSH Terminal within Plesk by clicking on the icon or preferably use a SSH Application such as Putty (PC) or Terminal (MAC).

Wednesday, September 9, 2009

Dynamic Height of iframe Javascript

Set the Height of iframe Dynamically..

1] If iframe Source from same domain

Here is the Code Used for to set the Height of iFrame Using Javascript.
this code is working if source of iframe is from same domain.
same domain means the script execution page and iframe page source from same hosting server.

function resizeFrame(f) {
f.style.height = f.contentWindow.document.body.scrollHeight+'px';
}

and on iframe onload="resizeFrame(this)"

1] If iframe Source from different domain

// FrameManager.js -- Must be added in Hosting window
var FrameManager =
{
currentFrameId : '',
currentFrameHeight : 0,
lastFrameId : '',
lastFrameHeight : 0,
resizeTimerId : null,

init : function()
{
if (FrameManager.resizeTimerId == null)
{
FrameManager.resizeTimerId = window.setInterval(FrameManager.resizeFrames, 500);
}
},

resizeFrames : function()
{
FrameManager.retrieveFrameIdAndHeight();

if ((FrameManager.currentFrameId != FrameManager.lastFrameId) ||
(FrameManager.currentFrameHeight != FrameManager.lastFrameHeight))
{
var iframe = document.getElementById(FrameManager.currentFrameId.toString());

if (iframe == null) return;

iframe.style.height = FrameManager.currentFrameHeight.toString() + "px";

FrameManager.lastFrameId = FrameManager.currentFrameId;
FrameManager.lastFrameHeight = FrameManager.currentFrameHeight;
window.location.hash = '#';
}
},

retrieveFrameIdAndHeight : function()
{
if (window.location.hash.length == 0) return;

var hashValue = window.location.hash.substring(1);

if ((hashValue == null) || (hashValue.length == 0)) return;

var pairs = hashValue.split('&');

if ((pairs != null) && (pairs.length > 0))
{
for(var i = 0; i < style="color: rgb(0, 0, 255);">var pair = pairs[i].split('=');

if ((pair != null) && (pair.length > 0))
{
if (pair[0] == 'frameId')
{
if ((pair[1] != null) && (pair[1].length > 0))
{
FrameManager.currentFrameId = pair[1];
}
}
else if (pair[0] == 'height')
{
var height = parseInt(pair[1]);

if (!isNaN(height))
{
FrameManager.currentFrameHeight = height;
FrameManager.currentFrameHeight += 15;
}
}
}
}
}
},

registerFrame : function(frame)
{
var currentLocation = location.href;
var hashIndex = currentLocation.indexOf('#');

if (hashIndex > -1)
{
currentLocation = currentLocation.substring(0, hashIndex);
}

frame.contentWindow.location = frame.src + '?frameId=' + frame.id + '#' + currentLocation;
}
};

window.setTimeout(FrameManager.init, 300);


// Host.html-Where the Target iframe resides
iframe id="ifrSample1" scrolling="no" frameborder="0" src="Frame.html" style="margin:0px;width:330px;height:100px" onload="FrameManager.registerFrame(this)"


// Frame.js -- Must be added in iframe window
function publishHeight()
{
if (window.location.hash.length == 0) return;

var frameId = getFrameId();

if (frameId == '') return;

var actualHeight = getBodyHeight();
var currentHeight = getViewPortHeight();

if (Math.abs(actualHeight - currentHeight) > 15)
{
var hostUrl = window.location.hash.substring(1);

hostUrl += "#";
hostUrl += 'frameId=' + frameId;
hostUrl += '&';
hostUrl += 'height=' + actualHeight.toString();

window.top.location = hostUrl;
}
}

function getFrameId()
{
var qs = parseQueryString(window.location.href);
var frameId = qs["frameId"];

var hashIndex = frameId.indexOf('#');

if (hashIndex > -1)
{
frameId = frameId.substring(0, hashIndex);
}

return frameId;
}

function getBodyHeight()
{
var height;
var scrollHeight;
var offsetHeight;

if (document.height)
{
height = document.height;
}
else if (document.body)
{
if (document.body.scrollHeight)
{
height = scrollHeight = document.body.scrollHeight;
}
if (document.body.offsetHeight)
{
height = offsetHeight = document.body.offsetHeight;
}

if (scrollHeight && offsetHeight)
{
height = Math.max(scrollHeight, offsetHeight);
}
}

return height;
}

function getViewPortHeight()
{
var height = 0;

if (window.innerHeight)
{
height = window.innerHeight - 18;
}
else if ((document.documentElement) && (document.documentElement.clientHeight))
{
height = document.documentElement.clientHeight;
}
else if ((document.body) && (document.body.clientHeight))
{
height = document.body.clientHeight;
}

return height;
}

function parseQueryString(url)
{
url = new String(url);
var queryStringValues = new Object();
var querystring = url.substring(url.indexOf('frameId') , url.length);
var querystringSplit = querystring.split('&');

for (i = 0; i < style="color: rgb(0, 0, 255);">var pair = querystringSplit[i].split('=');
var name = pair[0];
var value = pair[1];

queryStringValues[name] = value;
}

return queryStringValues;
}

// Frame.html-Will reside in another domain
script type="text/javascript" src="Frame.js" script
window.onload = function(event)
{
window.setInterval(publishHeight, 300);
}

Please note That i got above code from google search...........and i remove the two bugs from that....and it is working fine............

if have any problem let me know.............vish.ideal@gmail.com
Thanks,
Vishnu

Tuesday, September 1, 2009

URL Rewriting Using .htacess file

URL Rewriting Using .htacess file
Our Aim is to
http://www.example.com/test/blog/var1/testFile.html
into dynamic URL
http://www.example.com/test/testFile.php?var1=var1&var2=testFile
using .htacess file


Create .htacess file in test directory

Now you directory structure is
www.example.com/test/
.htacess
testFile.php

In .htacess file write the code
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^blog/([^/]+)/([^/]+)\.html$ /test/testFile.php?var1=$1&var1=$2 [QSA]

Now in testFile.php your code will be there
If you type URL in Browser
http://www.example.com/test/blog /var1/testFile.html

it will execute on server as
http://www.example.com/test/testFile.php?var1=var1&var2=testFile

if you want todo external redirecting the just change the .htacess code
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^blog/([^/]+)/([^/]+)\.html$ /test/testFile.php?var1=$1&var1=$2 [R=301,L]


Friday, April 10, 2009

IE, Lightbox JS and security popup over SSL connection

A security popup occurring only in IE, "This page contains both secure and nonsecure items. Do you want to display the nonsecure items?".

Solution: Change the following line in lightbox.css:

#prevLink, #nextLink{ width: 49%; height: 100%;
background-image: url(data:image/gif;base64,AAAA);
/* Trick IE into showing hover */ display: block; }

to the following:

#prevLink, #nextLink{ width: 49%; height: 100%;
background-image: url(../images/blank.gif);
/* Trick IE into showing hover */ display: block; }

Add blank.gif in images directory of lightbox library